alchemy 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +324 -0
- package/lib/$.d.ts +8 -3
- package/lib/$.d.ts.map +1 -1
- package/lib/$.js +38 -27
- package/lib/$.js.map +1 -1
- package/lib/alchemize.d.ts.map +1 -1
- package/lib/alchemize.js +7 -0
- package/lib/alchemize.js.map +1 -1
- package/lib/apply.d.ts +2 -2
- package/lib/apply.d.ts.map +1 -1
- package/lib/apply.js +3 -3
- package/lib/apply.js.map +1 -1
- package/lib/aws/index.d.ts +1 -0
- package/lib/aws/index.d.ts.map +1 -1
- package/lib/aws/index.js +1 -0
- package/lib/aws/index.js.map +1 -1
- package/lib/aws/ses.d.ts +75 -0
- package/lib/aws/ses.d.ts.map +1 -0
- package/lib/aws/ses.js +197 -0
- package/lib/aws/ses.js.map +1 -0
- package/lib/cloudflare/api.d.ts +88 -0
- package/lib/cloudflare/api.d.ts.map +1 -0
- package/lib/cloudflare/api.js +184 -0
- package/lib/cloudflare/api.js.map +1 -0
- package/lib/cloudflare/asset-manifest.d.ts +15 -0
- package/lib/cloudflare/asset-manifest.d.ts.map +1 -0
- package/lib/cloudflare/asset-manifest.js +2 -0
- package/lib/cloudflare/asset-manifest.js.map +1 -0
- package/lib/cloudflare/auth.d.ts +52 -0
- package/lib/cloudflare/auth.d.ts.map +1 -0
- package/lib/cloudflare/auth.js +114 -0
- package/lib/cloudflare/auth.js.map +1 -0
- package/lib/cloudflare/bindings.d.ts +254 -0
- package/lib/cloudflare/bindings.d.ts.map +1 -0
- package/lib/cloudflare/bindings.js +2 -0
- package/lib/cloudflare/bindings.js.map +1 -0
- package/lib/cloudflare/durable-object-namespace.d.ts +23 -0
- package/lib/cloudflare/durable-object-namespace.d.ts.map +1 -0
- package/lib/cloudflare/durable-object-namespace.js +26 -0
- package/lib/cloudflare/durable-object-namespace.js.map +1 -0
- package/lib/cloudflare/generate-asset-manifest.d.ts +3 -0
- package/lib/cloudflare/generate-asset-manifest.d.ts.map +1 -0
- package/lib/cloudflare/generate-asset-manifest.js +69 -0
- package/lib/cloudflare/generate-asset-manifest.js.map +1 -0
- package/lib/cloudflare/index.d.ts +7 -0
- package/lib/cloudflare/index.d.ts.map +1 -0
- package/lib/cloudflare/index.js +7 -0
- package/lib/cloudflare/index.js.map +1 -0
- package/lib/cloudflare/kv-namespace.d.ts +61 -0
- package/lib/cloudflare/kv-namespace.d.ts.map +1 -0
- package/lib/cloudflare/kv-namespace.js +93 -0
- package/lib/cloudflare/kv-namespace.js.map +1 -0
- package/lib/cloudflare/state.d.ts +83 -0
- package/lib/cloudflare/state.d.ts.map +1 -0
- package/lib/cloudflare/state.js +109 -0
- package/lib/cloudflare/state.js.map +1 -0
- package/lib/cloudflare/static-site-router.d.ts +19 -0
- package/lib/cloudflare/static-site-router.d.ts.map +1 -0
- package/lib/cloudflare/static-site-router.js +110 -0
- package/lib/cloudflare/static-site-router.js.map +1 -0
- package/lib/cloudflare/static-site.d.ts +166 -0
- package/lib/cloudflare/static-site.d.ts.map +1 -0
- package/lib/cloudflare/static-site.js +168 -0
- package/lib/cloudflare/static-site.js.map +1 -0
- package/lib/cloudflare/types.d.ts +52 -0
- package/lib/cloudflare/types.d.ts.map +1 -0
- package/lib/cloudflare/types.js +21 -0
- package/lib/cloudflare/types.js.map +1 -0
- package/lib/cloudflare/upload-asset-manifest.d.ts +12 -0
- package/lib/cloudflare/upload-asset-manifest.d.ts.map +1 -0
- package/lib/cloudflare/upload-asset-manifest.js +55 -0
- package/lib/cloudflare/upload-asset-manifest.js.map +1 -0
- package/lib/cloudflare/worker-metadata.d.ts +130 -0
- package/lib/cloudflare/worker-metadata.d.ts.map +1 -0
- package/lib/cloudflare/worker-metadata.js +2 -0
- package/lib/cloudflare/worker-metadata.js.map +1 -0
- package/lib/cloudflare/worker-migration.d.ts +110 -0
- package/lib/cloudflare/worker-migration.d.ts.map +1 -0
- package/lib/cloudflare/worker-migration.js +11 -0
- package/lib/cloudflare/worker-migration.js.map +1 -0
- package/lib/cloudflare/worker.d.ts +105 -0
- package/lib/cloudflare/worker.d.ts.map +1 -0
- package/lib/cloudflare/worker.js +358 -0
- package/lib/cloudflare/worker.js.map +1 -0
- package/lib/destroy.d.ts +1 -1
- package/lib/destroy.d.ts.map +1 -1
- package/lib/destroy.js +2 -1
- package/lib/destroy.js.map +1 -1
- package/lib/esbuild.d.ts +83 -1
- package/lib/esbuild.d.ts.map +1 -1
- package/lib/esbuild.js +27 -18
- package/lib/esbuild.js.map +1 -1
- package/lib/fs.d.ts +1 -1
- package/lib/global.d.ts +0 -2
- package/lib/global.d.ts.map +1 -1
- package/lib/global.js +3 -3
- package/lib/global.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/main.js +1 -1
- package/lib/main.js.map +1 -1
- package/lib/output.d.ts +18 -13
- package/lib/output.d.ts.map +1 -1
- package/lib/output.js +12 -5
- package/lib/output.js.map +1 -1
- package/lib/print.d.ts +7 -0
- package/lib/print.d.ts.map +1 -0
- package/lib/print.js +10 -0
- package/lib/print.js.map +1 -0
- package/lib/resource.d.ts +9 -4
- package/lib/resource.d.ts.map +1 -1
- package/lib/resource.js +127 -93
- package/lib/resource.js.map +1 -1
- package/lib/scope.d.ts +3 -0
- package/lib/scope.d.ts.map +1 -1
- package/lib/scope.js +4 -12
- package/lib/scope.js.map +1 -1
- package/lib/utils/content-type.d.ts +8 -0
- package/lib/utils/content-type.d.ts.map +1 -0
- package/lib/utils/content-type.js +41 -0
- package/lib/utils/content-type.js.map +1 -0
- package/package.json +27 -8
- package/src/$.ts +63 -30
- package/src/alchemize.ts +12 -0
- package/src/apply.ts +6 -6
- package/src/aws/index.ts +1 -0
- package/src/aws/ses.ts +346 -0
- package/src/cloudflare/api.ts +282 -0
- package/src/cloudflare/asset-manifest.ts +16 -0
- package/src/cloudflare/auth.ts +187 -0
- package/src/cloudflare/bindings.ts +297 -0
- package/src/cloudflare/durable-object-namespace.ts +43 -0
- package/src/cloudflare/generate-asset-manifest.ts +93 -0
- package/src/cloudflare/index.ts +6 -0
- package/src/cloudflare/kv-namespace.ts +195 -0
- package/src/cloudflare/state.ts +138 -0
- package/src/cloudflare/static-site-router.ts +150 -0
- package/src/cloudflare/static-site.ts +395 -0
- package/src/cloudflare/types.ts +71 -0
- package/src/cloudflare/upload-asset-manifest.ts +83 -0
- package/src/cloudflare/worker-metadata.ts +154 -0
- package/src/cloudflare/worker-migration.ts +145 -0
- package/src/cloudflare/worker.ts +666 -0
- package/src/destroy.ts +2 -2
- package/src/esbuild.ts +34 -22
- package/src/global.ts +1 -3
- package/src/index.ts +1 -1
- package/src/main.ts +1 -1
- package/src/output.ts +53 -37
- package/src/print.ts +18 -0
- package/src/resource.ts +163 -116
- package/src/scope.ts +7 -12
- package/src/utils/content-type.ts +42 -0
- package/lib/agent/ai.d.ts +0 -40
- package/lib/agent/ai.d.ts.map +0 -1
- package/lib/agent/ai.js +0 -132
- package/lib/agent/ai.js.map +0 -1
- package/lib/agent/anthropic.d.ts +0 -9
- package/lib/agent/anthropic.d.ts.map +0 -1
- package/lib/agent/anthropic.js +0 -25
- package/lib/agent/anthropic.js.map +0 -1
- package/lib/agent/dependencies.d.ts +0 -4
- package/lib/agent/dependencies.d.ts.map +0 -1
- package/lib/agent/dependencies.js +0 -48
- package/lib/agent/dependencies.js.map +0 -1
- package/lib/agent/file-context.d.ts +0 -13
- package/lib/agent/file-context.d.ts.map +0 -1
- package/lib/agent/file-context.js +0 -6
- package/lib/agent/file-context.js.map +0 -1
- package/lib/agent/index.d.ts +0 -10
- package/lib/agent/index.d.ts.map +0 -1
- package/lib/agent/index.js +0 -10
- package/lib/agent/index.js.map +0 -1
- package/lib/agent/model.d.ts +0 -8
- package/lib/agent/model.d.ts.map +0 -1
- package/lib/agent/model.js +0 -29
- package/lib/agent/model.js.map +0 -1
- package/lib/agent/module.d.ts +0 -81
- package/lib/agent/module.d.ts.map +0 -1
- package/lib/agent/module.js +0 -309
- package/lib/agent/module.js.map +0 -1
- package/lib/agent/openai.d.ts +0 -6
- package/lib/agent/openai.d.ts.map +0 -1
- package/lib/agent/openai.js +0 -41
- package/lib/agent/openai.js.map +0 -1
- package/lib/agent/program.d.ts +0 -12
- package/lib/agent/program.d.ts.map +0 -1
- package/lib/agent/program.js +0 -21
- package/lib/agent/program.js.map +0 -1
- package/lib/agent/prompts.d.ts +0 -4
- package/lib/agent/prompts.d.ts.map +0 -1
- package/lib/agent/prompts.js +0 -11
- package/lib/agent/prompts.js.map +0 -1
- package/lib/agent/scrape.d.ts +0 -71
- package/lib/agent/scrape.d.ts.map +0 -1
- package/lib/agent/scrape.js +0 -45
- package/lib/agent/scrape.js.map +0 -1
- package/lib/aws/auto/docs.d.ts +0 -11
- package/lib/aws/auto/docs.d.ts.map +0 -1
- package/lib/aws/auto/docs.js +0 -56
- package/lib/aws/auto/docs.js.map +0 -1
- package/lib/aws/auto/index.d.ts +0 -5
- package/lib/aws/auto/index.d.ts.map +0 -1
- package/lib/aws/auto/index.js +0 -5
- package/lib/aws/auto/index.js.map +0 -1
- package/lib/aws/auto/resource.d.ts +0 -24
- package/lib/aws/auto/resource.d.ts.map +0 -1
- package/lib/aws/auto/resource.js +0 -194
- package/lib/aws/auto/resource.js.map +0 -1
- package/lib/aws/auto/service.d.ts +0 -10
- package/lib/aws/auto/service.d.ts.map +0 -1
- package/lib/aws/auto/service.js +0 -34
- package/lib/aws/auto/service.js.map +0 -1
- package/lib/aws/auto/spec.d.ts +0 -83
- package/lib/aws/auto/spec.d.ts.map +0 -1
- package/lib/aws/auto/spec.js +0 -58
- package/lib/aws/auto/spec.js.map +0 -1
- package/lib/markdown/design.d.ts +0 -17
- package/lib/markdown/design.d.ts.map +0 -1
- package/lib/markdown/design.js +0 -92
- package/lib/markdown/design.js.map +0 -1
- package/lib/markdown/extract.d.ts +0 -7
- package/lib/markdown/extract.d.ts.map +0 -1
- package/lib/markdown/extract.js +0 -10
- package/lib/markdown/extract.js.map +0 -1
- package/lib/markdown/index.d.ts +0 -4
- package/lib/markdown/index.d.ts.map +0 -1
- package/lib/markdown/index.js +0 -4
- package/lib/markdown/index.js.map +0 -1
- package/lib/markdown/requirements.d.ts +0 -79
- package/lib/markdown/requirements.d.ts.map +0 -1
- package/lib/markdown/requirements.js +0 -105
- package/lib/markdown/requirements.js.map +0 -1
- package/lib/typescript/check-omission.d.ts +0 -2
- package/lib/typescript/check-omission.d.ts.map +0 -1
- package/lib/typescript/check-omission.js +0 -43
- package/lib/typescript/check-omission.js.map +0 -1
- package/lib/typescript/debug-type-errors.d.ts +0 -3
- package/lib/typescript/debug-type-errors.d.ts.map +0 -1
- package/lib/typescript/debug-type-errors.js +0 -35
- package/lib/typescript/debug-type-errors.js.map +0 -1
- package/lib/typescript/extract.d.ts +0 -7
- package/lib/typescript/extract.d.ts.map +0 -1
- package/lib/typescript/extract.js +0 -10
- package/lib/typescript/extract.js.map +0 -1
- package/lib/typescript/index.d.ts +0 -7
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/index.js +0 -7
- package/lib/typescript/index.js.map +0 -1
- package/lib/typescript/install-dependencies.d.ts +0 -29
- package/lib/typescript/install-dependencies.d.ts.map +0 -1
- package/lib/typescript/install-dependencies.js +0 -52
- package/lib/typescript/install-dependencies.js.map +0 -1
- package/lib/typescript/package.d.ts +0 -157
- package/lib/typescript/package.d.ts.map +0 -1
- package/lib/typescript/package.js +0 -115
- package/lib/typescript/package.js.map +0 -1
- package/lib/typescript/repair-omissions.d.ts +0 -3
- package/lib/typescript/repair-omissions.d.ts.map +0 -1
- package/lib/typescript/repair-omissions.js +0 -23
- package/lib/typescript/repair-omissions.js.map +0 -1
- package/lib/typescript/repair.d.ts +0 -3
- package/lib/typescript/repair.d.ts.map +0 -1
- package/lib/typescript/repair.js +0 -34
- package/lib/typescript/repair.js.map +0 -1
- package/lib/typescript/tsconfig.d.ts +0 -469
- package/lib/typescript/tsconfig.d.ts.map +0 -1
- package/lib/typescript/tsconfig.js +0 -143
- package/lib/typescript/tsconfig.js.map +0 -1
- package/lib/typescript/typescript.d.ts +0 -107
- package/lib/typescript/typescript.d.ts.map +0 -1
- package/lib/typescript/typescript.js +0 -180
- package/lib/typescript/typescript.js.map +0 -1
- package/lib/typescript/validate.d.ts +0 -10
- package/lib/typescript/validate.d.ts.map +0 -1
- package/lib/typescript/validate.js +0 -49
- package/lib/typescript/validate.js.map +0 -1
- package/src/agent/ai.ts +0 -215
- package/src/agent/anthropic.ts +0 -31
- package/src/agent/dependencies.ts +0 -62
- package/src/agent/file-context.ts +0 -8
- package/src/agent/index.ts +0 -9
- package/src/agent/model.ts +0 -39
- package/src/agent/module.ts +0 -418
- package/src/agent/openai.ts +0 -50
- package/src/agent/program.md +0 -38
- package/src/agent/program.ts +0 -37
- package/src/agent/prompts.ts +0 -20
- package/src/agent/scrape.ts +0 -47
- package/src/aws/auto/cfn.json +0 -225310
- package/src/aws/auto/docs.ts +0 -73
- package/src/aws/auto/index.ts +0 -4
- package/src/aws/auto/resource.ts +0 -269
- package/src/aws/auto/service.ts +0 -51
- package/src/aws/auto/spec.ts +0 -160
- package/src/markdown/design.ts +0 -125
- package/src/markdown/extract.ts +0 -9
- package/src/markdown/index.ts +0 -3
- package/src/markdown/requirements.ts +0 -135
- package/src/typescript/check-omission.ts +0 -47
- package/src/typescript/debug-type-errors.ts +0 -42
- package/src/typescript/extract.ts +0 -9
- package/src/typescript/index.ts +0 -6
- package/src/typescript/install-dependencies.ts +0 -61
- package/src/typescript/package.ts +0 -143
- package/src/typescript/repair-omissions.ts +0 -31
- package/src/typescript/repair.ts +0 -45
- package/src/typescript/tsconfig.ts +0 -170
- package/src/typescript/typescript.ts +0 -217
- package/src/typescript/validate.ts +0 -73
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export type TypeScriptFileInput = z.infer<typeof TypeScriptFileInput>;
|
|
3
|
-
declare const TypeScriptFileInput: z.ZodObject<{
|
|
4
|
-
/**
|
|
5
|
-
* The ID of the model to use for generating TypeScript code
|
|
6
|
-
* @default "gpt-4o"
|
|
7
|
-
*/
|
|
8
|
-
modelId: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["o3-mini", "o1", "o1-2024-12-17", "o1-mini", "o1-mini-2024-09-12", "o1-preview", "o1-preview-2024-09-12", "gpt-4o", "gpt-4o-2024-05-13", "gpt-4o-2024-08-06", "gpt-4o-2024-11-20", "gpt-4o-audio-preview", "gpt-4o-audio-preview-2024-10-01", "gpt-4o-audio-preview-2024-12-17", "gpt-4o-mini", "gpt-4o-mini-2024-07-18", "gpt-4-turbo", "gpt-4-turbo-2024-04-09", "gpt-4-turbo-preview", "gpt-4-0125-preview", "gpt-4-1106-preview", "gpt-4", "gpt-4-0613", "gpt-3.5-turbo-0125", "gpt-3.5-turbo", "gpt-3.5-turbo-1106"]>, z.ZodEnum<["claude-3-5-sonnet-latest", "claude-3-5-sonnet-20241022", "claude-3-5-sonnet-20240620", "claude-3-5-haiku-latest", "claude-3-5-haiku-20241022", "claude-3-opus", "claude-3-opus-20240229", "claude-3-sonnet", "claude-3-sonnet-20240229", "claude-3-haiku", "claude-3-haiku-20240307"]>]>>;
|
|
9
|
-
/**
|
|
10
|
-
* The name of the file to write the code to
|
|
11
|
-
*/
|
|
12
|
-
path: z.ZodString;
|
|
13
|
-
/**
|
|
14
|
-
* The requirements for the TypeScript file
|
|
15
|
-
*/
|
|
16
|
-
requirements: z.ZodString;
|
|
17
|
-
/**
|
|
18
|
-
* List of other code files that it depends on
|
|
19
|
-
*/
|
|
20
|
-
dependencies: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
21
|
-
path: z.ZodString;
|
|
22
|
-
content: z.ZodOptional<z.ZodString>;
|
|
23
|
-
}, "strip", z.ZodTypeAny, {
|
|
24
|
-
path: string;
|
|
25
|
-
content?: string | undefined;
|
|
26
|
-
}, {
|
|
27
|
-
path: string;
|
|
28
|
-
content?: string | undefined;
|
|
29
|
-
}>, "many">>;
|
|
30
|
-
/**
|
|
31
|
-
* Temperature setting for model generation (higher = more creative, lower = more focused)
|
|
32
|
-
* @default 0.7
|
|
33
|
-
*/
|
|
34
|
-
temperature: z.ZodOptional<z.ZodNumber>;
|
|
35
|
-
/**
|
|
36
|
-
* Whether to perform TypeScript type checking on the generated code
|
|
37
|
-
* @default false
|
|
38
|
-
*/
|
|
39
|
-
typeCheck: z.ZodOptional<z.ZodBoolean>;
|
|
40
|
-
/**
|
|
41
|
-
* Path to the tsconfig.json file to use for validation
|
|
42
|
-
* If not provided, will look for tsconfig.json in the project root
|
|
43
|
-
* Only used if typeCheck is true
|
|
44
|
-
*/
|
|
45
|
-
tsconfigPath: z.ZodOptional<z.ZodString>;
|
|
46
|
-
/**
|
|
47
|
-
* Project root directory. Used to resolve tsconfig.json and module imports
|
|
48
|
-
* If not provided, will use the directory of the target file
|
|
49
|
-
* Only used if typeCheck is true
|
|
50
|
-
*/
|
|
51
|
-
projectRoot: z.ZodOptional<z.ZodString>;
|
|
52
|
-
}, "strip", z.ZodTypeAny, {
|
|
53
|
-
path: string;
|
|
54
|
-
requirements: string;
|
|
55
|
-
temperature?: number | undefined;
|
|
56
|
-
modelId?: "o3-mini" | "o1" | "o1-2024-12-17" | "o1-mini" | "o1-mini-2024-09-12" | "o1-preview" | "o1-preview-2024-09-12" | "gpt-4o" | "gpt-4o-2024-05-13" | "gpt-4o-2024-08-06" | "gpt-4o-2024-11-20" | "gpt-4o-audio-preview" | "gpt-4o-audio-preview-2024-10-01" | "gpt-4o-audio-preview-2024-12-17" | "gpt-4o-mini" | "gpt-4o-mini-2024-07-18" | "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-turbo-preview" | "gpt-4-0125-preview" | "gpt-4-1106-preview" | "gpt-4" | "gpt-4-0613" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo" | "gpt-3.5-turbo-1106" | "claude-3-5-sonnet-latest" | "claude-3-5-sonnet-20241022" | "claude-3-5-sonnet-20240620" | "claude-3-5-haiku-latest" | "claude-3-5-haiku-20241022" | "claude-3-opus" | "claude-3-opus-20240229" | "claude-3-sonnet" | "claude-3-sonnet-20240229" | "claude-3-haiku" | "claude-3-haiku-20240307" | undefined;
|
|
57
|
-
dependencies?: {
|
|
58
|
-
path: string;
|
|
59
|
-
content?: string | undefined;
|
|
60
|
-
}[] | undefined;
|
|
61
|
-
typeCheck?: boolean | undefined;
|
|
62
|
-
tsconfigPath?: string | undefined;
|
|
63
|
-
projectRoot?: string | undefined;
|
|
64
|
-
}, {
|
|
65
|
-
path: string;
|
|
66
|
-
requirements: string;
|
|
67
|
-
temperature?: number | undefined;
|
|
68
|
-
modelId?: "o3-mini" | "o1" | "o1-2024-12-17" | "o1-mini" | "o1-mini-2024-09-12" | "o1-preview" | "o1-preview-2024-09-12" | "gpt-4o" | "gpt-4o-2024-05-13" | "gpt-4o-2024-08-06" | "gpt-4o-2024-11-20" | "gpt-4o-audio-preview" | "gpt-4o-audio-preview-2024-10-01" | "gpt-4o-audio-preview-2024-12-17" | "gpt-4o-mini" | "gpt-4o-mini-2024-07-18" | "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-turbo-preview" | "gpt-4-0125-preview" | "gpt-4-1106-preview" | "gpt-4" | "gpt-4-0613" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo" | "gpt-3.5-turbo-1106" | "claude-3-5-sonnet-latest" | "claude-3-5-sonnet-20241022" | "claude-3-5-sonnet-20240620" | "claude-3-5-haiku-latest" | "claude-3-5-haiku-20241022" | "claude-3-opus" | "claude-3-opus-20240229" | "claude-3-sonnet" | "claude-3-sonnet-20240229" | "claude-3-haiku" | "claude-3-haiku-20240307" | undefined;
|
|
69
|
-
dependencies?: {
|
|
70
|
-
path: string;
|
|
71
|
-
content?: string | undefined;
|
|
72
|
-
}[] | undefined;
|
|
73
|
-
typeCheck?: boolean | undefined;
|
|
74
|
-
tsconfigPath?: string | undefined;
|
|
75
|
-
projectRoot?: string | undefined;
|
|
76
|
-
}>;
|
|
77
|
-
export type TypeScriptFileOutput = z.infer<typeof TypeScriptFileOutput>;
|
|
78
|
-
export declare const TypeScriptFileOutput: z.ZodObject<{
|
|
79
|
-
path: z.ZodString;
|
|
80
|
-
content: z.ZodOptional<z.ZodString>;
|
|
81
|
-
}, "strip", z.ZodTypeAny, {
|
|
82
|
-
path: string;
|
|
83
|
-
content?: string | undefined;
|
|
84
|
-
}, {
|
|
85
|
-
path: string;
|
|
86
|
-
content?: string | undefined;
|
|
87
|
-
}>;
|
|
88
|
-
declare const TypeScriptFile_base: import("../resource").Provider<"code::TypeScriptFile", [props: {
|
|
89
|
-
path: string;
|
|
90
|
-
requirements: string;
|
|
91
|
-
temperature?: number | undefined;
|
|
92
|
-
modelId?: "o3-mini" | "o1" | "o1-2024-12-17" | "o1-mini" | "o1-mini-2024-09-12" | "o1-preview" | "o1-preview-2024-09-12" | "gpt-4o" | "gpt-4o-2024-05-13" | "gpt-4o-2024-08-06" | "gpt-4o-2024-11-20" | "gpt-4o-audio-preview" | "gpt-4o-audio-preview-2024-10-01" | "gpt-4o-audio-preview-2024-12-17" | "gpt-4o-mini" | "gpt-4o-mini-2024-07-18" | "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-turbo-preview" | "gpt-4-0125-preview" | "gpt-4-1106-preview" | "gpt-4" | "gpt-4-0613" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo" | "gpt-3.5-turbo-1106" | "claude-3-5-sonnet-latest" | "claude-3-5-sonnet-20241022" | "claude-3-5-sonnet-20240620" | "claude-3-5-haiku-latest" | "claude-3-5-haiku-20241022" | "claude-3-opus" | "claude-3-opus-20240229" | "claude-3-sonnet" | "claude-3-sonnet-20240229" | "claude-3-haiku" | "claude-3-haiku-20240307" | undefined;
|
|
93
|
-
dependencies?: {
|
|
94
|
-
path: string;
|
|
95
|
-
content?: string | undefined;
|
|
96
|
-
}[] | undefined;
|
|
97
|
-
typeCheck?: boolean | undefined;
|
|
98
|
-
tsconfigPath?: string | undefined;
|
|
99
|
-
projectRoot?: string | undefined;
|
|
100
|
-
}], {
|
|
101
|
-
path: string;
|
|
102
|
-
content?: string | undefined;
|
|
103
|
-
}>;
|
|
104
|
-
export declare class TypeScriptFile extends TypeScriptFile_base {
|
|
105
|
-
}
|
|
106
|
-
export {};
|
|
107
|
-
//# sourceMappingURL=typescript.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../../src/typescript/typescript.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAaxB,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEtE,QAAA,MAAM,mBAAmB;IACvB;;;OAGG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;;;;;;;;;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;;OAIG;;IAGH;;;;OAIG;;;;;;;;;;;;;;;;;;;;;;;;;;EAEH,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACxE,eAAO,MAAM,oBAAoB;;;;;;;;;EAAc,CAAC;;;;;;;;;;;;;;;;;AAEhD,qBAAa,cAAe,SAAQ,mBAkJnC;CAAG"}
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { mkdir, writeFile } from "fs/promises";
|
|
2
|
-
import { dirname } from "path";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
import { ModelId, generateText, resolveModel } from "../agent";
|
|
5
|
-
import { dependenciesAsMessages } from "../agent/dependencies";
|
|
6
|
-
import { FileContext } from "../agent/file-context";
|
|
7
|
-
import { rm } from "../fs";
|
|
8
|
-
import { Resource } from "../resource";
|
|
9
|
-
import { checkForCodeOmission } from "./check-omission";
|
|
10
|
-
import { debugTypeErrors } from "./debug-type-errors";
|
|
11
|
-
import { extractTypeScriptCode } from "./extract";
|
|
12
|
-
import { repairTypeScriptCode } from "./repair";
|
|
13
|
-
import { repairCodeOmissions } from "./repair-omissions";
|
|
14
|
-
import { validateTypeScript } from "./validate";
|
|
15
|
-
const TypeScriptFileInput = z.object({
|
|
16
|
-
/**
|
|
17
|
-
* The ID of the model to use for generating TypeScript code
|
|
18
|
-
* @default "gpt-4o"
|
|
19
|
-
*/
|
|
20
|
-
modelId: ModelId.optional(),
|
|
21
|
-
/**
|
|
22
|
-
* The name of the file to write the code to
|
|
23
|
-
*/
|
|
24
|
-
path: z.string(),
|
|
25
|
-
/**
|
|
26
|
-
* The requirements for the TypeScript file
|
|
27
|
-
*/
|
|
28
|
-
requirements: z.string(),
|
|
29
|
-
/**
|
|
30
|
-
* List of other code files that it depends on
|
|
31
|
-
*/
|
|
32
|
-
dependencies: z.array(FileContext).optional(),
|
|
33
|
-
/**
|
|
34
|
-
* Temperature setting for model generation (higher = more creative, lower = more focused)
|
|
35
|
-
* @default 0.7
|
|
36
|
-
*/
|
|
37
|
-
temperature: z.number().optional(),
|
|
38
|
-
/**
|
|
39
|
-
* Whether to perform TypeScript type checking on the generated code
|
|
40
|
-
* @default false
|
|
41
|
-
*/
|
|
42
|
-
typeCheck: z.boolean().optional(),
|
|
43
|
-
/**
|
|
44
|
-
* Path to the tsconfig.json file to use for validation
|
|
45
|
-
* If not provided, will look for tsconfig.json in the project root
|
|
46
|
-
* Only used if typeCheck is true
|
|
47
|
-
*/
|
|
48
|
-
tsconfigPath: z.string().optional(),
|
|
49
|
-
/**
|
|
50
|
-
* Project root directory. Used to resolve tsconfig.json and module imports
|
|
51
|
-
* If not provided, will use the directory of the target file
|
|
52
|
-
* Only used if typeCheck is true
|
|
53
|
-
*/
|
|
54
|
-
projectRoot: z.string().optional(),
|
|
55
|
-
});
|
|
56
|
-
export const TypeScriptFileOutput = FileContext;
|
|
57
|
-
export class TypeScriptFile extends Resource("code::TypeScriptFile", async (ctx, props) => {
|
|
58
|
-
if (ctx.event === "delete") {
|
|
59
|
-
await rm(props.path);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
console.log("Implementing", props.path);
|
|
63
|
-
// Get the appropriate model based on the ID
|
|
64
|
-
const model = await resolveModel(props.modelId ?? "gpt-4o");
|
|
65
|
-
const messages = [
|
|
66
|
-
{
|
|
67
|
-
role: "system",
|
|
68
|
-
content: "You are an expert TypeScript developer that generates clean, well-documented code following best practices. " +
|
|
69
|
-
"Your response must follow this exact format:\n" +
|
|
70
|
-
"1. A single sentence describing what the code will do\n" +
|
|
71
|
-
"2. A single TypeScript code block surrounded by ```ts and ``` tags containing the COMPLETE implementation\n" +
|
|
72
|
-
"IMPORTANT: You must ALWAYS provide the ENTIRE file contents, including ALL imports, types, and implementations.\n" +
|
|
73
|
-
"NEVER output partial code or omit any functionality from the original file when making changes.\n" +
|
|
74
|
-
"Do not include any other explanations or multiple code blocks.",
|
|
75
|
-
},
|
|
76
|
-
...dependenciesAsMessages(props.dependencies),
|
|
77
|
-
{
|
|
78
|
-
role: "user",
|
|
79
|
-
content: `Please generate TypeScript code based on the following specifications:
|
|
80
|
-
|
|
81
|
-
Requirements:
|
|
82
|
-
${props.requirements}
|
|
83
|
-
|
|
84
|
-
The code should:
|
|
85
|
-
1. Be well-documented with JSDoc comments
|
|
86
|
-
2. Follow TypeScript best practices
|
|
87
|
-
3. Include proper type definitions
|
|
88
|
-
4. Be ready to use with the provided context files
|
|
89
|
-
5. Include ALL necessary imports and dependencies
|
|
90
|
-
6. Contain the COMPLETE implementation with no omissions`,
|
|
91
|
-
},
|
|
92
|
-
];
|
|
93
|
-
const maxAttempts = 3;
|
|
94
|
-
let code;
|
|
95
|
-
let typeErrors;
|
|
96
|
-
// Try generating and validating code up to maxAttempts times
|
|
97
|
-
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
98
|
-
try {
|
|
99
|
-
// After 2 failed attempts, consult o3-mini for analysis
|
|
100
|
-
if (attempt === maxAttempts) {
|
|
101
|
-
if (!ctx.quiet) {
|
|
102
|
-
console.log("[TypeScript] Consulting expert for code analysis...");
|
|
103
|
-
}
|
|
104
|
-
const diagnosis = await debugTypeErrors(messages, typeErrors);
|
|
105
|
-
messages.push({
|
|
106
|
-
role: "user",
|
|
107
|
-
content: diagnosis,
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
// Generate the TypeScript code
|
|
111
|
-
if (!ctx.quiet) {
|
|
112
|
-
console.log(`[TypeScript] Generating code attempt ${attempt}...`);
|
|
113
|
-
}
|
|
114
|
-
const { text } = await generateText({
|
|
115
|
-
model,
|
|
116
|
-
temperature: Math.max(0.1, (props.temperature ?? 0.7) * (1 - attempt * 0.2)),
|
|
117
|
-
messages,
|
|
118
|
-
});
|
|
119
|
-
code = extractTypeScriptCode(text);
|
|
120
|
-
if (!code) {
|
|
121
|
-
console.log("Format mismatch");
|
|
122
|
-
messages.push({
|
|
123
|
-
role: "assistant",
|
|
124
|
-
content: text,
|
|
125
|
-
}, {
|
|
126
|
-
role: "user",
|
|
127
|
-
content: "Your response did not match the required format. Please provide your response with exactly one sentence summary" +
|
|
128
|
-
" followed by a single TypeScript code block surrounded by ```ts and ``` tags containing the COMPLETE implementation. No other text or explanations.",
|
|
129
|
-
});
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
// First check for omissions
|
|
133
|
-
if (!ctx.quiet) {
|
|
134
|
-
console.log("[TypeScript] Checking for code omissions...");
|
|
135
|
-
}
|
|
136
|
-
const hasOmissions = await checkForCodeOmission(code);
|
|
137
|
-
if (hasOmissions) {
|
|
138
|
-
code = await repairCodeOmissions(model, messages);
|
|
139
|
-
}
|
|
140
|
-
// Ensure the directory exists
|
|
141
|
-
await mkdir(dirname(props.path), { recursive: true });
|
|
142
|
-
// Write the TypeScript file
|
|
143
|
-
await writeFile(props.path, code);
|
|
144
|
-
if (props.typeCheck) {
|
|
145
|
-
typeErrors = await validateTypeScript(props.path, {
|
|
146
|
-
tsconfigPath: props.tsconfigPath,
|
|
147
|
-
projectRoot: props.projectRoot,
|
|
148
|
-
});
|
|
149
|
-
if (typeErrors) {
|
|
150
|
-
if (attempt === maxAttempts) {
|
|
151
|
-
throw new Error(`Failed to generate type-safe code after maximum attempts. Errors:\n${typeErrors}`);
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
code = await repairTypeScriptCode(model, typeErrors, messages);
|
|
155
|
-
continue;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
// If we get here, the code is valid
|
|
160
|
-
return {
|
|
161
|
-
path: props.path,
|
|
162
|
-
content: code,
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
catch (error) {
|
|
166
|
-
// On the last attempt, rethrow the error
|
|
167
|
-
if (attempt === maxAttempts) {
|
|
168
|
-
throw error;
|
|
169
|
-
}
|
|
170
|
-
// Otherwise continue to the next attempt
|
|
171
|
-
if (!ctx.quiet) {
|
|
172
|
-
console.log(`Attempt ${attempt} failed:`, error);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
// This should never be reached due to the throws above
|
|
177
|
-
throw new Error("Unexpected code generation failure");
|
|
178
|
-
}) {
|
|
179
|
-
}
|
|
180
|
-
//# sourceMappingURL=typescript.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.js","sourceRoot":"","sources":["../../src/typescript/typescript.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,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C,IAAI,EAAE,IAAI,CAAC,CAAC;YAElC,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;gBACpB,UAAU,GAAG,MAAM,kBAAkB,CAAC,KAAK,CAAC,IAAI,EAAE;oBAChD,YAAY,EAAE,KAAK,CAAC,YAAY;oBAChC,WAAW,EAAE,KAAK,CAAC,WAAW;iBAC/B,CAAC,CAAC;gBACH,IAAI,UAAU,EAAE,CAAC;oBACf,IAAI,OAAO,KAAK,WAAW,EAAE,CAAC;wBAC5B,MAAM,IAAI,KAAK,CACb,sEAAsE,UAAU,EAAE,CACnF,CAAC;oBACJ,CAAC;yBAAM,CAAC;wBACN,IAAI,GAAG,MAAM,oBAAoB,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;wBAC/D,SAAS;oBACX,CAAC;gBACH,CAAC;YACH,CAAC;YAED,oCAAoC;YACpC,OAAO;gBACL,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,yCAAyC;YACzC,IAAI,OAAO,KAAK,WAAW,EAAE,CAAC;gBAC5B,MAAM,KAAK,CAAC;YACd,CAAC;YACD,yCAAyC;YACzC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,GAAG,CAAC,WAAW,OAAO,UAAU,EAAE,KAAK,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;IACH,CAAC;IAED,uDAAuD;IACvD,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;AACxD,CAAC,CACF;CAAG"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export interface TypeCheckOptions {
|
|
2
|
-
tsconfigPath?: string;
|
|
3
|
-
projectRoot?: string;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Validates TypeScript code and returns formatted error messages if there are any type errors
|
|
7
|
-
* @returns Formatted error message if there are errors, undefined if valid
|
|
8
|
-
*/
|
|
9
|
-
export declare function validateTypeScript(filePath: string, options: TypeCheckOptions): Promise<string | undefined>;
|
|
10
|
-
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/typescript/validate.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,gBAAgB;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAyD7B"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { dirname, resolve } from "path";
|
|
2
|
-
import * as ts from "typescript";
|
|
3
|
-
/**
|
|
4
|
-
* Validates TypeScript code and returns formatted error messages if there are any type errors
|
|
5
|
-
* @returns Formatted error message if there are errors, undefined if valid
|
|
6
|
-
*/
|
|
7
|
-
export async function validateTypeScript(filePath, options) {
|
|
8
|
-
const projectRoot = options.projectRoot ?? dirname(filePath);
|
|
9
|
-
const tsconfigPath = options.tsconfigPath ?? resolve(projectRoot, "tsconfig.json");
|
|
10
|
-
// Load tsconfig.json if it exists
|
|
11
|
-
let compilerOptions = {
|
|
12
|
-
target: ts.ScriptTarget.ESNext,
|
|
13
|
-
module: ts.ModuleKind.ESNext,
|
|
14
|
-
strict: true,
|
|
15
|
-
esModuleInterop: true,
|
|
16
|
-
skipLibCheck: true,
|
|
17
|
-
noEmit: true,
|
|
18
|
-
};
|
|
19
|
-
if (ts.sys.fileExists(tsconfigPath)) {
|
|
20
|
-
const { config, error } = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
|
|
21
|
-
if (error) {
|
|
22
|
-
throw new Error(`Error reading tsconfig.json: ${error.messageText}`);
|
|
23
|
-
}
|
|
24
|
-
const { options: parsedOptions, errors } = ts.parseJsonConfigFileContent(config, ts.sys, projectRoot);
|
|
25
|
-
if (errors.length) {
|
|
26
|
-
throw new Error(`Error parsing tsconfig.json: ${errors.map((e) => e.messageText).join("\n")}`);
|
|
27
|
-
}
|
|
28
|
-
compilerOptions = parsedOptions;
|
|
29
|
-
}
|
|
30
|
-
// Create program
|
|
31
|
-
const program = ts.createProgram({
|
|
32
|
-
rootNames: [filePath],
|
|
33
|
-
options: compilerOptions,
|
|
34
|
-
});
|
|
35
|
-
// Get diagnostics
|
|
36
|
-
const diagnostics = [
|
|
37
|
-
...program.getSemanticDiagnostics(),
|
|
38
|
-
...program.getSyntacticDiagnostics(),
|
|
39
|
-
];
|
|
40
|
-
if (diagnostics.length > 0) {
|
|
41
|
-
return ts.formatDiagnosticsWithColorAndContext(diagnostics, {
|
|
42
|
-
getCanonicalFileName: (path) => path,
|
|
43
|
-
getCurrentDirectory: () => projectRoot,
|
|
44
|
-
getNewLine: () => ts.sys.newLine,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
return undefined;
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=validate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/typescript/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAOjC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,QAAgB,EAChB,OAAyB;IAEzB,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7D,MAAM,YAAY,GAChB,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;IAEhE,kCAAkC;IAClC,IAAI,eAAe,GAAuB;QACxC,MAAM,EAAE,EAAE,CAA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E,CAAC,oCAAoC,CAAC,WAAW,EAAE;YAC1D,oBAAoB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI;YACpC,mBAAmB,EAAE,GAAG,EAAE,CAAC,WAAW;YACtC,UAAU,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO;SACjC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/src/agent/ai.ts
DELETED
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type GenerateObjectResult,
|
|
3
|
-
type LanguageModelV1,
|
|
4
|
-
generateObject as _generateObject,
|
|
5
|
-
generateText as _generateText,
|
|
6
|
-
} from "ai";
|
|
7
|
-
import type { z } from "zod";
|
|
8
|
-
import { isOpenAIModel } from "./openai";
|
|
9
|
-
|
|
10
|
-
// OpenAI error types
|
|
11
|
-
interface OpenAIError extends Error {
|
|
12
|
-
status?: number;
|
|
13
|
-
code?: string;
|
|
14
|
-
type?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Rate-limited wrapper around generateText
|
|
19
|
-
*/
|
|
20
|
-
export const generateText: typeof _generateText = async (options) => {
|
|
21
|
-
return withRateLimit(() => _generateText(options), options);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Rate-limited wrapper around generateObject
|
|
26
|
-
*/
|
|
27
|
-
export const generateObject: typeof _generateObject = (async <OBJECT>(
|
|
28
|
-
options: Parameters<typeof _generateObject>[0] & {
|
|
29
|
-
schema: z.Schema<OBJECT>;
|
|
30
|
-
},
|
|
31
|
-
): Promise<GenerateObjectResult<OBJECT>> => {
|
|
32
|
-
return withRateLimit(() => _generateObject<OBJECT>(options as any), options);
|
|
33
|
-
}) as any;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* A simple async semaphore implementation for rate limiting
|
|
37
|
-
*/
|
|
38
|
-
class AsyncSemaphore {
|
|
39
|
-
private permits: number;
|
|
40
|
-
private queue: Array<() => void> = [];
|
|
41
|
-
|
|
42
|
-
constructor(permits: number) {
|
|
43
|
-
this.permits = permits;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async acquire(): Promise<void> {
|
|
47
|
-
if (this.permits > 0) {
|
|
48
|
-
this.permits--;
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return new Promise<void>((resolve) => {
|
|
53
|
-
this.queue.push(resolve);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
release(): void {
|
|
58
|
-
if (this.queue.length > 0) {
|
|
59
|
-
const next = this.queue.shift();
|
|
60
|
-
next?.();
|
|
61
|
-
} else {
|
|
62
|
-
this.permits++;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Configuration for rate limiting and retries
|
|
69
|
-
*/
|
|
70
|
-
export interface RateLimitConfig {
|
|
71
|
-
/**
|
|
72
|
-
* Maximum number of concurrent requests
|
|
73
|
-
* @default 3
|
|
74
|
-
*/
|
|
75
|
-
maxConcurrent?: number;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Base delay for exponential backoff (in milliseconds)
|
|
79
|
-
* @default 1000
|
|
80
|
-
*/
|
|
81
|
-
baseDelay?: number;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Maximum number of retries
|
|
85
|
-
* @default 3
|
|
86
|
-
*/
|
|
87
|
-
maxRetries?: number;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Maximum delay for exponential backoff (in milliseconds)
|
|
91
|
-
* @default 30000
|
|
92
|
-
*/
|
|
93
|
-
maxDelay?: number;
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Jitter factor for randomizing delays (between 0 and 1)
|
|
97
|
-
* @default 0.1
|
|
98
|
-
*/
|
|
99
|
-
jitter?: number;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Global semaphore instances per client configuration
|
|
103
|
-
const defaultConfig: Required<RateLimitConfig> = {
|
|
104
|
-
maxConcurrent: 3,
|
|
105
|
-
baseDelay: 1000,
|
|
106
|
-
maxRetries: 10,
|
|
107
|
-
maxDelay: 30000,
|
|
108
|
-
jitter: 0.1,
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
// WeakMap to store semaphores per client
|
|
112
|
-
const clientSemaphores = new Map<"openai" | "anthropic", AsyncSemaphore>();
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Gets or creates a semaphore for a specific client
|
|
116
|
-
*/
|
|
117
|
-
function getSemaphore(client: "openai" | "anthropic"): AsyncSemaphore {
|
|
118
|
-
let semaphore = clientSemaphores.get(client);
|
|
119
|
-
if (!semaphore) {
|
|
120
|
-
semaphore = new AsyncSemaphore(defaultConfig.maxConcurrent);
|
|
121
|
-
clientSemaphores.set(client, semaphore);
|
|
122
|
-
}
|
|
123
|
-
return semaphore;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Calculates the delay for exponential backoff with jitter
|
|
128
|
-
*/
|
|
129
|
-
function calculateBackoffDelay(
|
|
130
|
-
attempt: number,
|
|
131
|
-
{ baseDelay, maxDelay, jitter }: Required<RateLimitConfig>,
|
|
132
|
-
): number {
|
|
133
|
-
const exponentialDelay = Math.min(baseDelay * Math.pow(2, attempt), maxDelay);
|
|
134
|
-
const jitterAmount = exponentialDelay * jitter;
|
|
135
|
-
return exponentialDelay + (Math.random() * 2 - 1) * jitterAmount;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Checks if an error is a rate limit related error
|
|
140
|
-
*/
|
|
141
|
-
function isRateLimitError(error: any): boolean {
|
|
142
|
-
if (error.url === "https://api.anthropic.com/v1/messages") {
|
|
143
|
-
return error.status === 429;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const openAIError = error as OpenAIError;
|
|
147
|
-
|
|
148
|
-
// Check for specific OpenAI rate limit error codes
|
|
149
|
-
if (openAIError.code) {
|
|
150
|
-
return [
|
|
151
|
-
"rate_limit_exceeded",
|
|
152
|
-
"insufficient_quota",
|
|
153
|
-
"tokens_quota_exceeded",
|
|
154
|
-
"requests_quota_exceeded",
|
|
155
|
-
].includes(openAIError.code);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// Check for HTTP 429 status
|
|
159
|
-
if (openAIError.status === 429) return true;
|
|
160
|
-
|
|
161
|
-
// Check error types
|
|
162
|
-
if (openAIError.type) {
|
|
163
|
-
return ["tokens", "requests", "rate_limit", "capacity"].includes(
|
|
164
|
-
openAIError.type.toLowerCase(),
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// Fallback to message content check
|
|
169
|
-
return (
|
|
170
|
-
openAIError.message.toLowerCase().includes("rate") ||
|
|
171
|
-
openAIError.message.toLowerCase().includes("quota") ||
|
|
172
|
-
openAIError.message.toLowerCase().includes("capacity") ||
|
|
173
|
-
openAIError.message.toLowerCase().includes("throttle")
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Wraps an async function with rate limiting and exponential backoff
|
|
179
|
-
*/
|
|
180
|
-
async function withRateLimit<T>(
|
|
181
|
-
fn: () => Promise<T>,
|
|
182
|
-
options: { model: LanguageModelV1 },
|
|
183
|
-
config: RateLimitConfig = {},
|
|
184
|
-
): Promise<T> {
|
|
185
|
-
const finalConfig = { ...defaultConfig, ...config };
|
|
186
|
-
const client = options.model;
|
|
187
|
-
const semaphore = getSemaphore(
|
|
188
|
-
isOpenAIModel(client.modelId) ? "openai" : "anthropic",
|
|
189
|
-
);
|
|
190
|
-
for (let attempt = 0; attempt <= finalConfig.maxRetries; attempt++) {
|
|
191
|
-
try {
|
|
192
|
-
await semaphore.acquire();
|
|
193
|
-
const result = await fn();
|
|
194
|
-
return result;
|
|
195
|
-
} catch (error) {
|
|
196
|
-
if (attempt === finalConfig.maxRetries) {
|
|
197
|
-
throw error;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (!isRateLimitError(error)) {
|
|
201
|
-
throw error;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const delay = calculateBackoffDelay(attempt, finalConfig);
|
|
205
|
-
console.log(
|
|
206
|
-
`Rate limit error, retrying... (attempt ${attempt + 1}/${finalConfig.maxRetries + 1}, waiting ${Math.round(delay)}ms)`,
|
|
207
|
-
);
|
|
208
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
209
|
-
} finally {
|
|
210
|
-
semaphore.release();
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
throw new Error("Unexpected: Should not reach this point");
|
|
215
|
-
}
|
package/src/agent/anthropic.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @see https://docs.anthropic.com/en/docs/about-claude/models#model-comparison-table
|
|
5
|
-
*/
|
|
6
|
-
export const AnthropicModels = [
|
|
7
|
-
// Claude 3.5 Sonnet models
|
|
8
|
-
"claude-3-5-sonnet-latest",
|
|
9
|
-
"claude-3-5-sonnet-20241022",
|
|
10
|
-
"claude-3-5-sonnet-20240620",
|
|
11
|
-
|
|
12
|
-
// Claude 3.5 Haiku models
|
|
13
|
-
"claude-3-5-haiku-latest",
|
|
14
|
-
"claude-3-5-haiku-20241022",
|
|
15
|
-
|
|
16
|
-
// Claude 3 models
|
|
17
|
-
"claude-3-opus",
|
|
18
|
-
"claude-3-opus-20240229",
|
|
19
|
-
"claude-3-sonnet",
|
|
20
|
-
"claude-3-sonnet-20240229",
|
|
21
|
-
"claude-3-haiku",
|
|
22
|
-
"claude-3-haiku-20240307",
|
|
23
|
-
] as const;
|
|
24
|
-
|
|
25
|
-
export const AnthropicModel = z.enum(AnthropicModels);
|
|
26
|
-
|
|
27
|
-
export type AnthropicModelId = (typeof AnthropicModels)[number] | (string & {});
|
|
28
|
-
|
|
29
|
-
export function isAnthropicModel(model: string): model is AnthropicModelId {
|
|
30
|
-
return model.startsWith("claude-");
|
|
31
|
-
}
|