alchemy 0.1.11 → 0.1.12
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/apply.d.ts +2 -2
- package/lib/apply.d.ts.map +1 -1
- package/lib/apply.js +2 -2
- 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 +84 -0
- package/lib/cloudflare/api.d.ts.map +1 -0
- package/lib/cloudflare/api.js +178 -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 +244 -0
- package/lib/cloudflare/bindings.d.ts.map +1 -0
- package/lib/cloudflare/bindings.js +7 -0
- package/lib/cloudflare/bindings.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 +6 -0
- package/lib/cloudflare/index.d.ts.map +1 -0
- package/lib/cloudflare/index.js +6 -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 +10 -0
- package/lib/cloudflare/static-site-router.d.ts.map +1 -0
- package/lib/cloudflare/static-site-router.js +88 -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 +152 -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.d.ts +87 -0
- package/lib/cloudflare/worker.d.ts.map +1 -0
- package/lib/cloudflare/worker.js +364 -0
- package/lib/cloudflare/worker.js.map +1 -0
- package/lib/esbuild.d.ts +82 -0
- package/lib/esbuild.d.ts.map +1 -1
- package/lib/esbuild.js +24 -17
- package/lib/esbuild.js.map +1 -1
- package/lib/fs.d.ts +1 -1
- package/lib/global.d.ts.map +1 -1
- package/lib/global.js +3 -1
- package/lib/global.js.map +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -1
- 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 +17 -13
- package/lib/output.d.ts.map +1 -1
- package/lib/output.js +2 -2
- package/lib/output.js.map +1 -1
- package/lib/resource.d.ts +3 -2
- package/lib/resource.d.ts.map +1 -1
- package/lib/resource.js +2 -2
- package/lib/resource.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 +26 -8
- package/src/apply.ts +5 -5
- package/src/aws/index.ts +1 -0
- package/src/aws/ses.ts +346 -0
- package/src/cloudflare/api.ts +276 -0
- package/src/cloudflare/asset-manifest.ts +16 -0
- package/src/cloudflare/auth.ts +187 -0
- package/src/cloudflare/bindings.ts +286 -0
- package/src/cloudflare/generate-asset-manifest.ts +93 -0
- package/src/cloudflare/index.ts +5 -0
- package/src/cloudflare/kv-namespace.ts +195 -0
- package/src/cloudflare/state.ts +138 -0
- package/src/cloudflare/static-site-router.ts +108 -0
- package/src/cloudflare/static-site.ts +379 -0
- package/src/cloudflare/types.ts +71 -0
- package/src/cloudflare/upload-asset-manifest.ts +83 -0
- package/src/cloudflare/worker.ts +568 -0
- package/src/esbuild.ts +31 -22
- package/src/global.ts +1 -0
- package/src/index.ts +0 -1
- package/src/main.ts +1 -1
- package/src/output.ts +32 -32
- package/src/resource.ts +11 -5
- package/src/utils/content-type.ts +42 -0
- package/lib/$.d.ts +0 -7
- package/lib/$.d.ts.map +0 -1
- package/lib/$.js +0 -31
- package/lib/$.js.map +0 -1
- 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/$.ts +0 -36
- 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
package/src/output.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export type Eval<U> = U extends Output<infer V> ? Eval<V> : U;
|
|
2
|
-
|
|
3
1
|
export function isOutput<T>(value: any): value is Output<T> {
|
|
4
2
|
return (
|
|
5
3
|
value && typeof value === "object" && typeof value.apply === "function"
|
|
@@ -13,33 +11,11 @@ export type Outputs<P extends readonly any[]> = P extends [
|
|
|
13
11
|
? [Output<First>, ...Outputs<Rest>]
|
|
14
12
|
: [];
|
|
15
13
|
|
|
16
|
-
export
|
|
17
|
-
apply<U>(fn: (value: T) => U): Output<
|
|
18
|
-
}
|
|
19
|
-
? {
|
|
20
|
-
[k in keyof typeof String.prototype]: Output<
|
|
21
|
-
(typeof String.prototype)[k]
|
|
22
|
-
>;
|
|
23
|
-
}
|
|
24
|
-
: T extends number
|
|
25
|
-
? {
|
|
26
|
-
[K in keyof typeof Number.prototype]: Output<
|
|
27
|
-
(typeof Number.prototype)[K]
|
|
28
|
-
>;
|
|
29
|
-
}
|
|
30
|
-
: T extends boolean
|
|
31
|
-
? {
|
|
32
|
-
[K in keyof typeof Boolean.prototype]: Output<
|
|
33
|
-
(typeof Boolean.prototype)[K]
|
|
34
|
-
>;
|
|
35
|
-
}
|
|
36
|
-
: T extends any[]
|
|
37
|
-
? Outputs<T>
|
|
38
|
-
: {
|
|
39
|
-
[k in keyof T]: Output<T[k]>;
|
|
40
|
-
});
|
|
14
|
+
export interface Output<T> {
|
|
15
|
+
apply<U>(fn: (value: T) => U): Output<U>;
|
|
16
|
+
}
|
|
41
17
|
|
|
42
|
-
export
|
|
18
|
+
export class OutputChain<T, U> {
|
|
43
19
|
constructor(
|
|
44
20
|
public readonly parent: Output<T>,
|
|
45
21
|
public readonly fn: (value: T) => U,
|
|
@@ -49,7 +25,31 @@ export const Output = class<T, U> {
|
|
|
49
25
|
// @ts-expect-error - we know we are an "Output"
|
|
50
26
|
return new Output(this, fn);
|
|
51
27
|
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type Resolve<O> = O extends Output<infer U>
|
|
31
|
+
? U
|
|
32
|
+
: O extends null
|
|
33
|
+
? O
|
|
34
|
+
: O extends any[]
|
|
35
|
+
? ResolveN<O>
|
|
36
|
+
: O extends object
|
|
37
|
+
? {
|
|
38
|
+
[k in keyof O]: Resolve<O[k]>;
|
|
39
|
+
}
|
|
40
|
+
: O;
|
|
41
|
+
|
|
42
|
+
type ResolveN<O extends any[]> = O extends [infer First, ...infer Rest]
|
|
43
|
+
? [Resolve<First>, ...ResolveN<Rest>]
|
|
44
|
+
: [];
|
|
45
|
+
|
|
46
|
+
// export data from a resource
|
|
47
|
+
export type Export<Out> = Out extends null
|
|
48
|
+
? Output<Out>
|
|
49
|
+
: Out extends any[]
|
|
50
|
+
? Outputs<Out>
|
|
51
|
+
: Out extends object
|
|
52
|
+
? {
|
|
53
|
+
[k in keyof Out]: Output<Out[k]>;
|
|
54
|
+
}
|
|
55
|
+
: Output<Out>;
|
package/src/resource.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { type ApplyOptions, apply } from "./apply";
|
|
|
3
3
|
import type { DestroyOptions } from "./destroy";
|
|
4
4
|
import { defaultStateStore, deletions, providers } from "./global";
|
|
5
5
|
import type { Inputs, Input as input } from "./input";
|
|
6
|
-
import { Output } from "./output";
|
|
6
|
+
import { type Export, type Output, OutputChain, type Resolve } from "./output";
|
|
7
7
|
import { Scope as IScope, getScope, pushScope } from "./scope";
|
|
8
8
|
import type { State, StateStore } from "./state";
|
|
9
9
|
|
|
@@ -46,7 +46,12 @@ export type Resource<In extends any[] = any[], Out = any> = {
|
|
|
46
46
|
[Apply]: <O>(value: Out) => O;
|
|
47
47
|
[Provide]: (value: Out) => void;
|
|
48
48
|
[Options]: ProviderOptions;
|
|
49
|
-
} & Output<Out
|
|
49
|
+
} & Output<Out> &
|
|
50
|
+
Export<
|
|
51
|
+
// the resource handler may export another Output - we need to resolve it first
|
|
52
|
+
// then, export that resolved value
|
|
53
|
+
Resolve<Out>
|
|
54
|
+
>;
|
|
50
55
|
|
|
51
56
|
export interface BaseContext {
|
|
52
57
|
quiet: boolean;
|
|
@@ -65,6 +70,7 @@ export interface BaseContext {
|
|
|
65
70
|
|
|
66
71
|
export interface CreateContext extends BaseContext {
|
|
67
72
|
event: "create";
|
|
73
|
+
output?: undefined;
|
|
68
74
|
}
|
|
69
75
|
|
|
70
76
|
export interface UpdateContext<Outputs> extends BaseContext {
|
|
@@ -218,7 +224,7 @@ export function Resource<
|
|
|
218
224
|
}
|
|
219
225
|
|
|
220
226
|
public [Apply]<U>(fn: (value: Out) => U): Output<U> {
|
|
221
|
-
return new
|
|
227
|
+
return new OutputChain<Out, U>(this as any, fn);
|
|
222
228
|
}
|
|
223
229
|
|
|
224
230
|
private box?: {
|
|
@@ -381,9 +387,9 @@ export function Resource<
|
|
|
381
387
|
deps: [...deps],
|
|
382
388
|
});
|
|
383
389
|
if (evaluated !== undefined) {
|
|
384
|
-
resource[Provide](evaluated);
|
|
390
|
+
resource[Provide](evaluated as Out);
|
|
385
391
|
}
|
|
386
|
-
return evaluated
|
|
392
|
+
return evaluated as Awaited<Out>;
|
|
387
393
|
}
|
|
388
394
|
|
|
389
395
|
static async delete(
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
|
|
3
|
+
// Common MIME types
|
|
4
|
+
const mimeTypes: Record<string, string> = {
|
|
5
|
+
".html": "text/html",
|
|
6
|
+
".htm": "text/html",
|
|
7
|
+
".css": "text/css",
|
|
8
|
+
".js": "application/javascript",
|
|
9
|
+
".json": "application/json",
|
|
10
|
+
".xml": "application/xml",
|
|
11
|
+
".txt": "text/plain",
|
|
12
|
+
".md": "text/markdown",
|
|
13
|
+
".png": "image/png",
|
|
14
|
+
".jpg": "image/jpeg",
|
|
15
|
+
".jpeg": "image/jpeg",
|
|
16
|
+
".gif": "image/gif",
|
|
17
|
+
".webp": "image/webp",
|
|
18
|
+
".svg": "image/svg+xml",
|
|
19
|
+
".ico": "image/x-icon",
|
|
20
|
+
".pdf": "application/pdf",
|
|
21
|
+
".zip": "application/zip",
|
|
22
|
+
".woff": "font/woff",
|
|
23
|
+
".woff2": "font/woff2",
|
|
24
|
+
".ttf": "font/ttf",
|
|
25
|
+
".otf": "font/otf",
|
|
26
|
+
".eot": "application/vnd.ms-fontobject",
|
|
27
|
+
".mp4": "video/mp4",
|
|
28
|
+
".webm": "video/webm",
|
|
29
|
+
".mp3": "audio/mpeg",
|
|
30
|
+
".wav": "audio/wav",
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Gets the content type for a file based on its extension
|
|
35
|
+
*
|
|
36
|
+
* @param filePath Path to the file
|
|
37
|
+
* @returns The content type for the file
|
|
38
|
+
*/
|
|
39
|
+
export function getContentType(filePath: string): string {
|
|
40
|
+
const extension = path.extname(filePath).toLowerCase();
|
|
41
|
+
return mimeTypes[extension] || "application/octet-stream";
|
|
42
|
+
}
|
package/lib/$.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Input } from "./input";
|
|
2
|
-
import { type Output } from "./output";
|
|
3
|
-
type Primitive = string | number | boolean;
|
|
4
|
-
type _Input = Primitive | Output<Primitive>;
|
|
5
|
-
export declare function $(template: TemplateStringsArray, ...args: _Input[]): Input<string>;
|
|
6
|
-
export {};
|
|
7
|
-
//# sourceMappingURL=$.d.ts.map
|
package/lib/$.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"$.d.ts","sourceRoot":"","sources":["../src/$.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,MAAM,EAAY,MAAM,UAAU,CAAC;AAEjD,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAC3C,KAAK,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AAE5C,wBAAgB,CAAC,CACf,QAAQ,EAAE,oBAAoB,EAC9B,GAAG,IAAI,EAAE,MAAM,EAAE,GAChB,KAAK,CAAC,MAAM,CAAC,CA0Bf"}
|
package/lib/$.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { isOutput } from "./output";
|
|
2
|
-
export function $(template, ...args) {
|
|
3
|
-
const inputs = args.reduce((acc, arg) => {
|
|
4
|
-
if (isOutput(arg)) {
|
|
5
|
-
if (arg === null) {
|
|
6
|
-
return acc;
|
|
7
|
-
}
|
|
8
|
-
else {
|
|
9
|
-
return arg.apply((arg) => [...acc, arg]);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
else if (isOutput(acc)) {
|
|
13
|
-
return acc.apply((acc) => [...acc, arg]);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
return [...acc, arg];
|
|
17
|
-
}
|
|
18
|
-
}, null);
|
|
19
|
-
function interpolate(inputs) {
|
|
20
|
-
return template.reduce((acc, str, i) => {
|
|
21
|
-
return acc + str + (inputs[i] ?? "");
|
|
22
|
-
}, "");
|
|
23
|
-
}
|
|
24
|
-
if (isOutput(inputs)) {
|
|
25
|
-
return inputs.apply(interpolate);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
return interpolate(inputs);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=$.js.map
|
package/lib/$.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"$.js","sourceRoot":"","sources":["../src/$.ts"],"names":[],"mappings":"AACA,OAAO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-1,40 +0,0 @@
|
|
|
1
|
-
import { generateObject as _generateObject, generateText as _generateText } from "ai";
|
|
2
|
-
/**
|
|
3
|
-
* Rate-limited wrapper around generateText
|
|
4
|
-
*/
|
|
5
|
-
export declare const generateText: typeof _generateText;
|
|
6
|
-
/**
|
|
7
|
-
* Rate-limited wrapper around generateObject
|
|
8
|
-
*/
|
|
9
|
-
export declare const generateObject: typeof _generateObject;
|
|
10
|
-
/**
|
|
11
|
-
* Configuration for rate limiting and retries
|
|
12
|
-
*/
|
|
13
|
-
export interface RateLimitConfig {
|
|
14
|
-
/**
|
|
15
|
-
* Maximum number of concurrent requests
|
|
16
|
-
* @default 3
|
|
17
|
-
*/
|
|
18
|
-
maxConcurrent?: number;
|
|
19
|
-
/**
|
|
20
|
-
* Base delay for exponential backoff (in milliseconds)
|
|
21
|
-
* @default 1000
|
|
22
|
-
*/
|
|
23
|
-
baseDelay?: number;
|
|
24
|
-
/**
|
|
25
|
-
* Maximum number of retries
|
|
26
|
-
* @default 3
|
|
27
|
-
*/
|
|
28
|
-
maxRetries?: number;
|
|
29
|
-
/**
|
|
30
|
-
* Maximum delay for exponential backoff (in milliseconds)
|
|
31
|
-
* @default 30000
|
|
32
|
-
*/
|
|
33
|
-
maxDelay?: number;
|
|
34
|
-
/**
|
|
35
|
-
* Jitter factor for randomizing delays (between 0 and 1)
|
|
36
|
-
* @default 0.1
|
|
37
|
-
*/
|
|
38
|
-
jitter?: number;
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=ai.d.ts.map
|
package/lib/agent/ai.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../src/agent/ai.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,cAAc,IAAI,eAAe,EACjC,YAAY,IAAI,aAAa,EAC9B,MAAM,IAAI,CAAC;AAWZ;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,OAAO,aAEjC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,OAAO,eAM3B,CAAC;AAkCV;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
package/lib/agent/ai.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { generateObject as _generateObject, generateText as _generateText, } from "ai";
|
|
2
|
-
import { isOpenAIModel } from "./openai";
|
|
3
|
-
/**
|
|
4
|
-
* Rate-limited wrapper around generateText
|
|
5
|
-
*/
|
|
6
|
-
export const generateText = async (options) => {
|
|
7
|
-
return withRateLimit(() => _generateText(options), options);
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Rate-limited wrapper around generateObject
|
|
11
|
-
*/
|
|
12
|
-
export const generateObject = (async (options) => {
|
|
13
|
-
return withRateLimit(() => _generateObject(options), options);
|
|
14
|
-
});
|
|
15
|
-
/**
|
|
16
|
-
* A simple async semaphore implementation for rate limiting
|
|
17
|
-
*/
|
|
18
|
-
class AsyncSemaphore {
|
|
19
|
-
permits;
|
|
20
|
-
queue = [];
|
|
21
|
-
constructor(permits) {
|
|
22
|
-
this.permits = permits;
|
|
23
|
-
}
|
|
24
|
-
async acquire() {
|
|
25
|
-
if (this.permits > 0) {
|
|
26
|
-
this.permits--;
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
return new Promise((resolve) => {
|
|
30
|
-
this.queue.push(resolve);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
release() {
|
|
34
|
-
if (this.queue.length > 0) {
|
|
35
|
-
const next = this.queue.shift();
|
|
36
|
-
next?.();
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
this.permits++;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
// Global semaphore instances per client configuration
|
|
44
|
-
const defaultConfig = {
|
|
45
|
-
maxConcurrent: 3,
|
|
46
|
-
baseDelay: 1000,
|
|
47
|
-
maxRetries: 10,
|
|
48
|
-
maxDelay: 30000,
|
|
49
|
-
jitter: 0.1,
|
|
50
|
-
};
|
|
51
|
-
// WeakMap to store semaphores per client
|
|
52
|
-
const clientSemaphores = new Map();
|
|
53
|
-
/**
|
|
54
|
-
* Gets or creates a semaphore for a specific client
|
|
55
|
-
*/
|
|
56
|
-
function getSemaphore(client) {
|
|
57
|
-
let semaphore = clientSemaphores.get(client);
|
|
58
|
-
if (!semaphore) {
|
|
59
|
-
semaphore = new AsyncSemaphore(defaultConfig.maxConcurrent);
|
|
60
|
-
clientSemaphores.set(client, semaphore);
|
|
61
|
-
}
|
|
62
|
-
return semaphore;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Calculates the delay for exponential backoff with jitter
|
|
66
|
-
*/
|
|
67
|
-
function calculateBackoffDelay(attempt, { baseDelay, maxDelay, jitter }) {
|
|
68
|
-
const exponentialDelay = Math.min(baseDelay * Math.pow(2, attempt), maxDelay);
|
|
69
|
-
const jitterAmount = exponentialDelay * jitter;
|
|
70
|
-
return exponentialDelay + (Math.random() * 2 - 1) * jitterAmount;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Checks if an error is a rate limit related error
|
|
74
|
-
*/
|
|
75
|
-
function isRateLimitError(error) {
|
|
76
|
-
if (error.url === "https://api.anthropic.com/v1/messages") {
|
|
77
|
-
return error.status === 429;
|
|
78
|
-
}
|
|
79
|
-
const openAIError = error;
|
|
80
|
-
// Check for specific OpenAI rate limit error codes
|
|
81
|
-
if (openAIError.code) {
|
|
82
|
-
return [
|
|
83
|
-
"rate_limit_exceeded",
|
|
84
|
-
"insufficient_quota",
|
|
85
|
-
"tokens_quota_exceeded",
|
|
86
|
-
"requests_quota_exceeded",
|
|
87
|
-
].includes(openAIError.code);
|
|
88
|
-
}
|
|
89
|
-
// Check for HTTP 429 status
|
|
90
|
-
if (openAIError.status === 429)
|
|
91
|
-
return true;
|
|
92
|
-
// Check error types
|
|
93
|
-
if (openAIError.type) {
|
|
94
|
-
return ["tokens", "requests", "rate_limit", "capacity"].includes(openAIError.type.toLowerCase());
|
|
95
|
-
}
|
|
96
|
-
// Fallback to message content check
|
|
97
|
-
return (openAIError.message.toLowerCase().includes("rate") ||
|
|
98
|
-
openAIError.message.toLowerCase().includes("quota") ||
|
|
99
|
-
openAIError.message.toLowerCase().includes("capacity") ||
|
|
100
|
-
openAIError.message.toLowerCase().includes("throttle"));
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Wraps an async function with rate limiting and exponential backoff
|
|
104
|
-
*/
|
|
105
|
-
async function withRateLimit(fn, options, config = {}) {
|
|
106
|
-
const finalConfig = { ...defaultConfig, ...config };
|
|
107
|
-
const client = options.model;
|
|
108
|
-
const semaphore = getSemaphore(isOpenAIModel(client.modelId) ? "openai" : "anthropic");
|
|
109
|
-
for (let attempt = 0; attempt <= finalConfig.maxRetries; attempt++) {
|
|
110
|
-
try {
|
|
111
|
-
await semaphore.acquire();
|
|
112
|
-
const result = await fn();
|
|
113
|
-
return result;
|
|
114
|
-
}
|
|
115
|
-
catch (error) {
|
|
116
|
-
if (attempt === finalConfig.maxRetries) {
|
|
117
|
-
throw error;
|
|
118
|
-
}
|
|
119
|
-
if (!isRateLimitError(error)) {
|
|
120
|
-
throw error;
|
|
121
|
-
}
|
|
122
|
-
const delay = calculateBackoffDelay(attempt, finalConfig);
|
|
123
|
-
console.log(`Rate limit error, retrying... (attempt ${attempt + 1}/${finalConfig.maxRetries + 1}, waiting ${Math.round(delay)}ms)`);
|
|
124
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
125
|
-
}
|
|
126
|
-
finally {
|
|
127
|
-
semaphore.release();
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
throw new Error("Unexpected: Should not reach this point");
|
|
131
|
-
}
|
|
132
|
-
//# sourceMappingURL=ai.js.map
|
package/lib/agent/ai.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ai.js","sourceRoot":"","sources":["../../src/agent/ai.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,cAAc,IAAI,eAAe,EACjC,YAAY,IAAI,aAAa,GAC9B,MAAM,IAAI,CAAC;AAEZ,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AASzC;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAyB,KAAK,EAAE,OAAO,EAAE,EAAE;IAClE,OAAO,aAAa,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;AAC9D,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAA2B,CAAC,KAAK,EAC1D,OAEC,EACsC,EAAE;IACzC,OAAO,aAAa,CAAC,GAAG,EAAE,CAAC,eAAe,CAAS,OAAc,CAAC,EAAE,OAAO,CAAC,CAAC;AAC/E,CAAC,CAAQ,CAAC;AAEV;;GAEG;AACH,MAAM,cAAc;IACV,OAAO,CAAS;IAChB,KAAK,GAAsB,EAAE,CAAC;IAEtC,YAAY,OAAe;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,OAAO;QACX,IAAI,IAAI,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC;YACrB,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,OAAO;QACT,CAAC;QAED,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YACnC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO;Q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,YAAY,CAC5B,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CACvD,CAAC;IACF,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,WAAW,CAAC,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC;QACnE,IAAI,CAAC;YACH,MAAM,SAAS,CAAC,OAAO,EAAE,CAAC;YAC1B,MAAM,MAAM,GAAG,MAAM,EAAE,EAAE,CAAC;YAC1B,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,OAAO,KAAK,WAAW,CAAC,UAAU,EAAE,CAAC;gBACvC,MAAM,KAAK,CAAC;YACd,CAAC;YAED,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC7B,MAAM,KAAK,CAAC;YACd,CAAC;YAED,MAAM,KAAK,GAAG,qBAAqB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YAC1D,OAAO,CAAC,GAAG,CACT,0CAA0C,OAAO,GAAG,CAAC,IAAI,WAAW,CAAC,UAAU,GAAG,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CACvH,CAAC;YACF,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;QAC7D,CAAC;gBAAS,CAAC;YACT,SAAS,CAAC,OAAO,EAAE,CAAC;QACtB,CAAC;IACH,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;AAC7D,CAAC"}
|
package/lib/agent/anthropic.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
/**
|
|
3
|
-
* @see https://docs.anthropic.com/en/docs/about-claude/models#model-comparison-table
|
|
4
|
-
*/
|
|
5
|
-
export declare const AnthropicModels: readonly ["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"];
|
|
6
|
-
export declare const AnthropicModel: 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"]>;
|
|
7
|
-
export type AnthropicModelId = (typeof AnthropicModels)[number] | (string & {});
|
|
8
|
-
export declare function isAnthropicModel(model: string): model is AnthropicModelId;
|
|
9
|
-
//# sourceMappingURL=anthropic.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../src/agent/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,eAAe,kSAiBlB,CAAC;AAEX,eAAO,MAAM,cAAc,oSAA0B,CAAC;AAEtD,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAEhF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,gBAAgB,CAEzE"}
|
package/lib/agent/anthropic.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
/**
|
|
3
|
-
* @see https://docs.anthropic.com/en/docs/about-claude/models#model-comparison-table
|
|
4
|
-
*/
|
|
5
|
-
export const AnthropicModels = [
|
|
6
|
-
// Claude 3.5 Sonnet models
|
|
7
|
-
"claude-3-5-sonnet-latest",
|
|
8
|
-
"claude-3-5-sonnet-20241022",
|
|
9
|
-
"claude-3-5-sonnet-20240620",
|
|
10
|
-
// Claude 3.5 Haiku models
|
|
11
|
-
"claude-3-5-haiku-latest",
|
|
12
|
-
"claude-3-5-haiku-20241022",
|
|
13
|
-
// Claude 3 models
|
|
14
|
-
"claude-3-opus",
|
|
15
|
-
"claude-3-opus-20240229",
|
|
16
|
-
"claude-3-sonnet",
|
|
17
|
-
"claude-3-sonnet-20240229",
|
|
18
|
-
"claude-3-haiku",
|
|
19
|
-
"claude-3-haiku-20240307",
|
|
20
|
-
];
|
|
21
|
-
export const AnthropicModel = z.enum(AnthropicModels);
|
|
22
|
-
export function isAnthropicModel(model) {
|
|
23
|
-
return model.startsWith("claude-");
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=anthropic.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../src/agent/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,2BAA2B;IAC3B,0BAA0B;IAC1B,4BAA4B;IAC5B,4BAA4B;IAE5B,0BAA0B;IAC1B,yBAAyB;IACzB,2BAA2B;IAE3B,kBAAkB;IAClB,eAAe;IACf,wBAAwB;IACxB,iBAAiB;IACjB,0BAA0B;IAC1B,gBAAgB;IAChB,yBAAyB;CACjB,CAAC;AAEX,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AAItD,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,OAAO,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../src/agent/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,WAAW,EAAE,GAAG,SAAS,GACtC,WAAW,EAAE,CAyBf"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export function dependenciesAsMessages(dependencies) {
|
|
2
|
-
if (!dependencies?.length)
|
|
3
|
-
return [];
|
|
4
|
-
const fileTree = generateFileTree(dependencies);
|
|
5
|
-
return [
|
|
6
|
-
{
|
|
7
|
-
role: "user",
|
|
8
|
-
content: [
|
|
9
|
-
`Here are some relevant upstream files that you may need to reference.`,
|
|
10
|
-
`Existing file structure:`,
|
|
11
|
-
fileTree,
|
|
12
|
-
`File contents:`,
|
|
13
|
-
dependencies
|
|
14
|
-
.flatMap((dep) => dep.content ? [`// ${dep.path}\n${dep.content}`] : [])
|
|
15
|
-
.join("\n\n"),
|
|
16
|
-
].join("\n"),
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
role: "assistant",
|
|
20
|
-
content: "Thanks, I'll refer to those where relevant.",
|
|
21
|
-
},
|
|
22
|
-
];
|
|
23
|
-
}
|
|
24
|
-
function generateFileTree(dependencies) {
|
|
25
|
-
const tree = {};
|
|
26
|
-
// Sort dependencies by path for consistent ordering
|
|
27
|
-
dependencies.sort((a, b) => a.path.localeCompare(b.path));
|
|
28
|
-
for (const dep of dependencies) {
|
|
29
|
-
const parts = dep.path.split("/");
|
|
30
|
-
let currentPath = "";
|
|
31
|
-
for (let i = 0; i < parts.length; i++) {
|
|
32
|
-
const part = parts[i];
|
|
33
|
-
const newPath = currentPath ? `${currentPath}/${part}` : part;
|
|
34
|
-
tree[newPath] = true;
|
|
35
|
-
currentPath = newPath;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
const paths = Object.keys(tree);
|
|
39
|
-
let result = "";
|
|
40
|
-
for (const path of paths) {
|
|
41
|
-
const depth = path.split("/").length - 1;
|
|
42
|
-
const prefix = " ".repeat(depth);
|
|
43
|
-
const name = path.split("/").pop();
|
|
44
|
-
result += `${prefix}${depth > 0 ? "└─ " : ""}${name}\n`;
|
|
45
|
-
}
|
|
46
|
-
return result;
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=dependencies.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/agent/dependencies.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,sBAAsB,CACpC,YAAuC;IAEvC,IAAI,CAAC,YAAY,EAAE,MAAM;QAAE,OAAO,EAAE,CAAC;IAErC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAEhD,OAAO;QACL;YACE,IAAI,EAAE,MAAe;YACrB,OAAO,EAAE;gBACP,uEAAuE;gBACvE,0BAA0B;gBAC1B,QAAQ;gBACR,gBAAgB;gBAChB,YAAY;qBACT,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CACf,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CACtD;qBACA,IAAI,CAAC,MAAM,CAAC;aAChB,CAAC,IAAI,CAAC,IAAI,CAAC;SACb;QACD;YACE,IAAI,EAAE,WAAoB;YAC1B,OAAO,EAAE,6CAA6C;SACvD;KACF,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,YAA2B;IACnD,MAAM,IAAI,GAA+B,EAAE,CAAC;IAE5C,oDAAoD;IACpD,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAE1D,KAAK,MAA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
|
5
|
-
content: z.ZodOptional<z.ZodString>;
|
|
6
|
-
}, "strip", z.ZodTypeAny, {
|
|
7
|
-
path: string;
|
|
8
|
-
content?: string | undefined;
|
|
9
|
-
}, {
|
|
10
|
-
path: string;
|
|
11
|
-
content?: string | undefined;
|
|
12
|
-
}>;
|
|
13
|
-
//# sourceMappingURL=file-context.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-context.d.ts","sourceRoot":"","sources":["../../src/agent/file-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD,eAAO,MAAM,WAAW;;;;;;;;;EAGtB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-context.js","sourceRoot":"","sources":["../../src/agent/file-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC/B,CAAC,CAAC"}
|
package/lib/agent/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from "./ai";
|
|
2
|
-
export * from "./anthropic";
|
|
3
|
-
export * from "./dependencies";
|
|
4
|
-
export * from "./file-context";
|
|
5
|
-
export * from "./model";
|
|
6
|
-
export * from "./module";
|
|
7
|
-
export * from "./openai";
|
|
8
|
-
export * from "./program";
|
|
9
|
-
export * from "./scrape";
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
package/lib/agent/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC;AACrB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
|
package/lib/agent/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from "./ai";
|
|
2
|
-
export * from "./anthropic";
|
|
3
|
-
export * from "./dependencies";
|
|
4
|
-
export * from "./file-context";
|
|
5
|
-
export * from "./model";
|
|
6
|
-
export * from "./module";
|
|
7
|
-
export * from "./openai";
|
|
8
|
-
export * from "./program";
|
|
9
|
-
export * from "./scrape";
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
package/lib/agent/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC;AACrB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
|
package/lib/agent/model.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { LanguageModelV1 } from "ai";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { type AnthropicModelId } from "./anthropic";
|
|
4
|
-
import { type OpenAIChatModelId } from "./openai";
|
|
5
|
-
export type ModelId = OpenAIChatModelId | AnthropicModelId;
|
|
6
|
-
export declare const ModelId: 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"]>]>;
|
|
7
|
-
export declare function resolveModel(modelId: ModelId): Promise<LanguageModelV1>;
|
|
8
|
-
//# sourceMappingURL=model.d.ts.map
|
package/lib/agent/model.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/agent/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAC1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEL,KAAK,gBAAgB,EAEtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,iBAAiB,EAA8B,MAAM,UAAU,CAAC;AAE9E,MAAM,MAAM,OAAO,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;AAE3D,eAAO,MAAM,OAAO,yzBAAyC,CAAC;AAI9D,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,CAuB7E"}
|
package/lib/agent/model.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { AnthropicModel, isAnthropicModel, } from "./anthropic";
|
|
3
|
-
import { OpenAIModel, isOpenAIModel } from "./openai";
|
|
4
|
-
export const ModelId = z.union([OpenAIModel, AnthropicModel]);
|
|
5
|
-
const modelCache = new Map();
|
|
6
|
-
export async function resolveModel(modelId) {
|
|
7
|
-
const cached = modelCache.get(modelId);
|
|
8
|
-
if (cached) {
|
|
9
|
-
return await cached;
|
|
10
|
-
}
|
|
11
|
-
const client = (async () => {
|
|
12
|
-
let client;
|
|
13
|
-
if (isOpenAIModel(modelId)) {
|
|
14
|
-
const { openai } = await import("@ai-sdk/openai");
|
|
15
|
-
client = openai(modelId);
|
|
16
|
-
}
|
|
17
|
-
else if (isAnthropicModel(modelId)) {
|
|
18
|
-
const { anthropic } = await import("@ai-sdk/anthropic");
|
|
19
|
-
client = anthropic(modelId);
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
throw new Error(`Unsupported model ID: ${modelId}`);
|
|
23
|
-
}
|
|
24
|
-
return client;
|
|
25
|
-
})();
|
|
26
|
-
modelCache.set(modelId, client);
|
|
27
|
-
return client;
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=model.js.map
|
package/lib/agent/model.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/agent/model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,cAAc,EAEd,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAA0B,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAI9E,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC;AAE9D,MAAM,UAAU,GAAG,IAAI,GAAG,EAAqC,CAAC;AAEhE,MAAM,CAAC,KAAK,UAAU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