Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/src/bridge/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class BridgeAdapter {
}
if (schema instanceof z.ZodDefault) {
const inner = this.fieldToJsonSchema(schema.removeDefault());
(inner as any).default = schema._def.defaultValue();
inner.default = schema._def.defaultValue();
return inner;
}
if (schema instanceof z.ZodLiteral) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/commands/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export interface InterpretedViewportError {
export interface CustomCommandSpec {
name: string;
description: string;
schema: z.ZodObject<any>;
schema: z.ZodObject<z.ZodRawShape>;
handler: (params: Record<string, unknown>, context: ExecutionContext) => Promise<CommandResult>;
terminatesSequence?: boolean;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const AgentConfigSchema = z.object({
traceOutputPath: z.string().optional(),
replayOutputPath: z.string().optional(),
strategyInterval: z.number().default(0),
plannerModel: z.any().optional(),
plannerModel: z.unknown().optional(),
enableStrategy: z.boolean().default(false),
enableEvaluation: z.boolean().default(false),
stepTimeout: z.number().default(60000),
Expand Down
17 changes: 12 additions & 5 deletions packages/core/src/model/adapters/vercel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,23 @@ export class VercelModelAdapter implements LanguageModel {
usage,
finishReason: mapFinishReason(result.finishReason),
};
} catch (error: any) {
if (error?.statusCode === 429 || error?.message?.includes('rate limit')) {
const retryAfter = error?.headers?.['retry-after'];
} catch (error: unknown) {
const err = error as Record<string, unknown> | undefined;
const message = err && typeof err === 'object' && 'message' in err ? String(err.message) : String(error);
const statusCode = err && typeof err === 'object' && 'statusCode' in err ? err.statusCode : undefined;
const headers = err && typeof err === 'object' && 'headers' in err
? (err.headers as Record<string, string> | undefined)
: undefined;

if (statusCode === 429 || message.includes('rate limit')) {
const retryAfter = headers?.['retry-after'];
throw new ModelThrottledError(
error.message ?? 'Rate limited',
message || 'Rate limited',
retryAfter ? Number.parseInt(retryAfter) * 1000 : undefined,
);
}
throw new ModelError(
`LLM invocation failed: ${error?.message ?? String(error)}`,
`LLM invocation failed: ${message}`,
{ cause: error },
);
}
Expand Down
14 changes: 7 additions & 7 deletions packages/core/src/model/schema-optimizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export function optimizeSchemaForModel<T extends ZodTypeAny>(
const kept = variants.slice(0, maxVariants - 1);
const catchAll = z.object({}).passthrough().describe('Other action (see documentation)');
const unionMembers = [...kept, catchAll] as unknown as [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]];
return z.union(unionMembers) as any;
return z.union(unionMembers) as unknown as T;
}
}

Expand All @@ -91,7 +91,7 @@ export function optimizeSchemaForModel<T extends ZodTypeAny>(
const kept = variants.slice(0, maxVariants - 1);
const catchAll = z.object({}).passthrough().describe('Other variant');
const unionMembers = [...kept, catchAll] as unknown as [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]];
return z.union(unionMembers) as any;
return z.union(unionMembers) as unknown as T;
}
}

Expand Down Expand Up @@ -441,11 +441,11 @@ export function zodToJsonSchema(schema: ZodTypeAny): Record<string, unknown> {
jsonSchema.type = 'array';
jsonSchema.items = zodToJsonSchema(schema.element);
} else if (schema instanceof z.ZodOptional) {
return zodToJsonSchema(schema.unwrap()) as any;
return zodToJsonSchema(schema.unwrap());
} else if (schema instanceof z.ZodDefault) {
const inner = zodToJsonSchema(schema.removeDefault()) as any;
const inner = zodToJsonSchema(schema.removeDefault());
inner.default = schema._def.defaultValue();
return inner as any;
return inner;
} else if (schema instanceof z.ZodEnum) {
jsonSchema.type = 'string';
jsonSchema.enum = schema.options;
Expand All @@ -459,7 +459,7 @@ export function zodToJsonSchema(schema: ZodTypeAny): Record<string, unknown> {
);
} else if (schema instanceof z.ZodNullable) {
const inner = zodToJsonSchema(schema.unwrap());
return { oneOf: [inner, { type: 'null' }] } as any;
return { oneOf: [inner, { type: 'null' }] };
} else if (schema instanceof z.ZodRecord) {
jsonSchema.type = 'object';
jsonSchema.additionalProperties = zodToJsonSchema(schema.element);
Expand All @@ -471,5 +471,5 @@ export function zodToJsonSchema(schema: ZodTypeAny): Record<string, unknown> {
jsonSchema.description = schema.description;
}

return jsonSchema as any;
return jsonSchema;
}
4 changes: 2 additions & 2 deletions packages/core/src/viewport/viewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export class Viewport {
const pageTitle = await this._currentPage.title();

// Emit initial lifecycle events
this.eventBus.emit('content-ready', undefined as any);
this.eventBus.emit('content-ready', undefined as void);

if (!isNewTabPage(pageUrl)) {
this.eventBus.emit('page-ready', { url: pageUrl });
Expand Down Expand Up @@ -993,7 +993,7 @@ export class Viewport {
this.knownTargets.clear();
this.cachedViewport = null;

this.eventBus.emit('shutdown', undefined as any);
this.eventBus.emit('shutdown', undefined as void);
this.eventBus.removeAllListeners();

logger.info('Browser session closed');
Expand Down