llmz 0.2.0 → 0.2.2
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/dist/{chunk-WWZ2W4WR.cjs → chunk-2EZSVF5X.cjs} +382 -492
- package/dist/{chunk-33AB6SVX.js → chunk-2MSLOTFO.js} +2 -2
- package/dist/{chunk-IRCB4FRM.js → chunk-3OSQ4XL4.js} +1 -1
- package/dist/{chunk-E5NHK3FS.js → chunk-5ISVDYBA.js} +3 -3
- package/dist/{chunk-IKLFMVSW.cjs → chunk-5XPEVOOW.cjs} +8 -8
- package/dist/{chunk-YGKQEVQQ.cjs → chunk-C2KND2PS.cjs} +3 -3
- package/dist/{chunk-DH35WO5G.js → chunk-EJIDFDQP.js} +373 -483
- package/dist/chunk-GDWRFHM5.js +792 -0
- package/dist/chunk-MHVORH33.cjs +792 -0
- package/dist/{chunk-WODK7Y4J.cjs → chunk-S46T73HR.cjs} +2 -2
- package/dist/compiler/ast.d.ts +26 -0
- package/dist/compiler/compiler.d.ts +13 -11
- package/dist/compiler/plugins/line-tracking.d.ts +6 -4
- package/dist/compiler/plugins/replace-comment.d.ts +8 -4
- package/dist/compiler/plugins/return-async.d.ts +18 -4
- package/dist/compiler/plugins/track-tool-calls.d.ts +21 -4
- package/dist/compiler/plugins/variable-extraction.d.ts +9 -4
- package/dist/component.default.d.ts +13 -91
- package/dist/{dual-modes-ZZY6QPYT.cjs → dual-modes-IZQJTXR7.cjs} +2 -2
- package/dist/{dual-modes-RMF7V7ZQ.js → dual-modes-J4RWHJ2O.js} +1 -1
- package/dist/{execute-BXPFSEVX.cjs → execute-4IL4QPAR.cjs} +23 -23
- package/dist/{execute-HIRXXR6X.js → execute-6AYBMTRM.js} +5 -5
- package/dist/formatting.d.ts +1 -2
- package/dist/index.cjs +185 -234
- package/dist/index.js +172 -221
- package/dist/prompts/chat-mode/system.md.d.ts +1 -1
- package/dist/prompts/worker-mode/system.md.d.ts +1 -1
- package/dist/prompts/worker-mode/user.md.d.ts +1 -1
- package/dist/{tool-GJ6ZXWS2.cjs → tool-56I7OSKU.cjs} +3 -3
- package/dist/{tool-DNHVW3KC.js → tool-I3MAWDN2.js} +2 -2
- package/dist/{typings-ZTFPPA5W.cjs → typings-LVI4VGE2.cjs} +2 -2
- package/dist/{typings-3YV3RDMP.js → typings-SR3EE6LR.js} +1 -1
- package/dist/typings-formatter.d.ts +34 -0
- package/dist/typings-formatter.test.d.ts +1 -0
- package/dist/{vm-44H4UKI2.js → vm-ZLWGAYYJ.js} +1 -1
- package/dist/{vm-A3OTQVIR.cjs → vm-ZVONLAZV.cjs} +2 -2
- package/package.json +5 -14
- package/dist/chunk-7LMIOS6H.cjs +0 -287
- package/dist/chunk-TOGYDN6U.js +0 -287
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class;
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkMHVORH33cjs = require('./chunk-MHVORH33.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -548,7 +548,7 @@ var Tool = (_class = class _Tool {
|
|
|
548
548
|
input = convertObjectToZuiLiterals(this._staticInputValues);
|
|
549
549
|
}
|
|
550
550
|
const fnType = _zui.z.function(input, _zui.z.promise(output)).title(this.name).describe(_nullishCoalesce(this.description, () => ( "")));
|
|
551
|
-
return
|
|
551
|
+
return _chunkMHVORH33cjs.getTypings.call(void 0, fnType, {
|
|
552
552
|
declaration: true
|
|
553
553
|
});
|
|
554
554
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type Comment, type Node, type Options, type Program } from 'acorn';
|
|
2
|
+
import type MagicString from 'magic-string';
|
|
3
|
+
/** An acorn node with free access to its type-specific properties */
|
|
4
|
+
export type AnyNode = Node & Record<string, any>;
|
|
5
|
+
export type Ctx = {
|
|
6
|
+
code: string;
|
|
7
|
+
ms: MagicString;
|
|
8
|
+
ast: Program;
|
|
9
|
+
comments: Comment[];
|
|
10
|
+
};
|
|
11
|
+
export declare function parseScript(code: string, opts?: Partial<Options> & {
|
|
12
|
+
comments?: Comment[];
|
|
13
|
+
}): Program;
|
|
14
|
+
/**
|
|
15
|
+
* Depth-first pre-order walk. `ancestors` is ordered outermost → innermost and
|
|
16
|
+
* excludes `node` itself; `parent` is `ancestors[ancestors.length - 1]`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function walk(root: Node, enter: (node: AnyNode, parent: AnyNode | null, ancestors: AnyNode[]) => void): void;
|
|
19
|
+
export declare const isStatementContainer: (node: AnyNode | null) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The statement that contains `node`: the outermost ancestor (or the node
|
|
22
|
+
* itself) whose parent is a statement container.
|
|
23
|
+
*/
|
|
24
|
+
export declare function enclosingStatement(node: AnyNode, ancestors: AnyNode[]): AnyNode | null;
|
|
25
|
+
/** The innermost node whose range contains [start, end] */
|
|
26
|
+
export declare function innermostContaining(ast: Program, start: number, end: number): AnyNode | null;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { type TransformOptions } from '@babel/core';
|
|
2
1
|
import { ToolCallEntry } from './plugins/track-tool-calls.js';
|
|
3
|
-
export declare const DEFAULT_TRANSFORM_OPTIONS: TransformOptions;
|
|
4
2
|
export declare const Identifiers: {
|
|
5
3
|
ConsoleObjIdentifier: string;
|
|
6
4
|
LineTrackingFnIdentifier: string;
|
|
@@ -17,18 +15,22 @@ export type CompiledCode = ReturnType<typeof compile>;
|
|
|
17
15
|
* Falls back to a word-boundary match if the code cannot be parsed.
|
|
18
16
|
*/
|
|
19
17
|
export declare function hasTopLevelReturn(code: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Compiles the agent's generated JavaScript for VM execution:
|
|
20
|
+
*
|
|
21
|
+
* 1. wraps it in an async `__fn__` so top-level `await`/`return` parse
|
|
22
|
+
* 2. instruments it in a single parse + text-edit pass:
|
|
23
|
+
* line tracking, last-line return, tool-call tracking, comment tracing
|
|
24
|
+
* and variable tracking
|
|
25
|
+
* 3. unwraps it — the VM drivers re-wrap the bare statements themselves
|
|
26
|
+
*
|
|
27
|
+
* All edits preserve line numbers 1:1 with the wrapped source, so positions
|
|
28
|
+
* reported at runtime map straight back to the user code.
|
|
29
|
+
*/
|
|
20
30
|
export declare function compile(code: string): {
|
|
21
31
|
code: string;
|
|
22
32
|
codeWithMarkers: string;
|
|
23
|
-
map:
|
|
24
|
-
version: number;
|
|
25
|
-
sources: string[];
|
|
26
|
-
names: string[];
|
|
27
|
-
sourceRoot?: string | undefined;
|
|
28
|
-
sourcesContent?: string[] | undefined;
|
|
29
|
-
mappings: string;
|
|
30
|
-
file: string;
|
|
31
|
-
} | null | undefined;
|
|
33
|
+
map: import("magic-string").SourceMap;
|
|
32
34
|
variables: Set<string>;
|
|
33
35
|
toolCalls: Map<number, ToolCallEntry>;
|
|
34
36
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Ctx } from '../ast.js';
|
|
2
2
|
export declare const LineTrackingFnIdentifier = "__track__";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Inserts a `__track__(<line>)` call before the statement containing each
|
|
5
|
+
* tracked node — at most one per source line.
|
|
6
|
+
*/
|
|
7
|
+
export declare function applyLineTracking(ctx: Ctx): void;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Ctx } from '../ast.js';
|
|
2
2
|
export declare const CommentFnIdentifier = "__comment__";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Replaces comments at statement position with `__comment__("<text>", <line>)`
|
|
5
|
+
* calls so the agent's inline "thinking" comments show up as traces at runtime.
|
|
6
|
+
* Comments inside expressions and the user-code markers are blanked; comments
|
|
7
|
+
* inside instrumented tool-call ranges are left verbatim.
|
|
8
|
+
*/
|
|
9
|
+
export declare function applyCommentReplacement(ctx: Ctx, skipRanges: Array<[number, number]>): void;
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { type Program } from 'acorn';
|
|
2
|
+
export type LastLineEdit = {
|
|
3
|
+
prefixPos: number;
|
|
4
|
+
prefix: string;
|
|
5
|
+
suffixPos: number;
|
|
6
|
+
suffix: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Plans the instrumentation of the last statement of the `__fn__` wrapper so
|
|
10
|
+
* the generated code always returns an awaited value (the isolated VM cannot
|
|
11
|
+
* return a pending Promise):
|
|
12
|
+
* - `return expr` → `return await (expr)`
|
|
13
|
+
* - a trailing `call()` / `await call()` statement → `return await (…)`
|
|
14
|
+
*
|
|
15
|
+
* The prefix must be applied before, and the suffix after, all other edits so
|
|
16
|
+
* they wrap around the tool-call instrumentation.
|
|
17
|
+
*/
|
|
18
|
+
export declare function planLastLineInstrumentation(ast: Program): LastLineEdit | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Ctx } from '../ast.js';
|
|
2
2
|
export declare const ToolCallTrackerFnIdentifier = "__toolc__";
|
|
3
3
|
export declare const ToolTrackerRetIdentifier = "__ret__";
|
|
4
4
|
export type Assignment = {
|
|
@@ -11,6 +11,23 @@ export type ToolCallEntry = {
|
|
|
11
11
|
tool: string;
|
|
12
12
|
assignment: Assignment;
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Wraps every outermost call expression in an IIFE that reports
|
|
16
|
+
* `__toolc__(<id>, "start" | "end", …)` events around the call:
|
|
17
|
+
*
|
|
18
|
+
* const x = (() => {
|
|
19
|
+
* try {
|
|
20
|
+
* __toolc__(0, "start");
|
|
21
|
+
* const __ret__ = tool();
|
|
22
|
+
* __toolc__(0, "end", __ret__);
|
|
23
|
+
* return __ret__;
|
|
24
|
+
* } catch (err) { __toolc__(1, "end", err); throw new Error(err.message); }
|
|
25
|
+
* })()
|
|
26
|
+
*
|
|
27
|
+
* Calls assigned to a variable are registered in `calls` (keyed by the id used
|
|
28
|
+
* in the catch clause — the id the runtime sees when a tool throws a
|
|
29
|
+
* SnapshotSignal). Awaited calls get an async IIFE that awaits the call.
|
|
30
|
+
*
|
|
31
|
+
* Returns the wrapped source ranges so later passes can avoid editing inside.
|
|
32
|
+
*/
|
|
33
|
+
export declare function applyToolCallTracking(ctx: Ctx, calls: Map<number, ToolCallEntry>): Array<[number, number]>;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Ctx } from '../ast.js';
|
|
2
2
|
export declare const VariableTrackingFnIdentifier = "__var__";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Tracks user variables so the VM can read their values between iterations:
|
|
5
|
+
* - after each variable declaration: `__var__("a", () => eval("a"));`
|
|
6
|
+
* - at the top of function bodies, for their parameters
|
|
7
|
+
*
|
|
8
|
+
* The `eval` indirection captures the variable lazily in its own scope.
|
|
9
|
+
*/
|
|
10
|
+
export declare function applyVariableTracking(ctx: Ctx, variables: Set<string>): void;
|
|
@@ -17,17 +17,7 @@ export declare const DefaultComponents: {
|
|
|
17
17
|
label: z.ZodString;
|
|
18
18
|
value: z.ZodOptional<z.ZodString>;
|
|
19
19
|
url: z.ZodOptional<z.ZodString>;
|
|
20
|
-
}, "strip"
|
|
21
|
-
action: "say" | "url" | "postback";
|
|
22
|
-
label: string;
|
|
23
|
-
value?: string | undefined;
|
|
24
|
-
url?: string | undefined;
|
|
25
|
-
}, {
|
|
26
|
-
label: string;
|
|
27
|
-
value?: string | undefined;
|
|
28
|
-
url?: string | undefined;
|
|
29
|
-
action?: "say" | "url" | "postback" | undefined;
|
|
30
|
-
}>;
|
|
20
|
+
}, "strip">;
|
|
31
21
|
};
|
|
32
22
|
}>;
|
|
33
23
|
Image: Component<{
|
|
@@ -44,13 +34,7 @@ export declare const DefaultComponents: {
|
|
|
44
34
|
props: z.ZodObject<{
|
|
45
35
|
url: z.ZodString;
|
|
46
36
|
alt: z.ZodOptional<z.ZodString>;
|
|
47
|
-
}, "strip"
|
|
48
|
-
url: string;
|
|
49
|
-
alt?: string | undefined;
|
|
50
|
-
}, {
|
|
51
|
-
url: string;
|
|
52
|
-
alt?: string | undefined;
|
|
53
|
-
}>;
|
|
37
|
+
}, "strip">;
|
|
54
38
|
};
|
|
55
39
|
}>;
|
|
56
40
|
File: Component<{
|
|
@@ -67,13 +51,7 @@ export declare const DefaultComponents: {
|
|
|
67
51
|
props: z.ZodObject<{
|
|
68
52
|
url: z.ZodString;
|
|
69
53
|
name: z.ZodOptional<z.ZodString>;
|
|
70
|
-
}, "strip"
|
|
71
|
-
url: string;
|
|
72
|
-
name?: string | undefined;
|
|
73
|
-
}, {
|
|
74
|
-
url: string;
|
|
75
|
-
name?: string | undefined;
|
|
76
|
-
}>;
|
|
54
|
+
}, "strip">;
|
|
77
55
|
};
|
|
78
56
|
}>;
|
|
79
57
|
Video: Component<{
|
|
@@ -90,13 +68,7 @@ export declare const DefaultComponents: {
|
|
|
90
68
|
props: z.ZodObject<{
|
|
91
69
|
url: z.ZodString;
|
|
92
70
|
title: z.ZodOptional<z.ZodString>;
|
|
93
|
-
}, "strip"
|
|
94
|
-
url: string;
|
|
95
|
-
title?: string | undefined;
|
|
96
|
-
}, {
|
|
97
|
-
url: string;
|
|
98
|
-
title?: string | undefined;
|
|
99
|
-
}>;
|
|
71
|
+
}, "strip">;
|
|
100
72
|
};
|
|
101
73
|
}>;
|
|
102
74
|
Audio: Component<{
|
|
@@ -113,13 +85,7 @@ export declare const DefaultComponents: {
|
|
|
113
85
|
props: z.ZodObject<{
|
|
114
86
|
url: z.ZodString;
|
|
115
87
|
title: z.ZodOptional<z.ZodString>;
|
|
116
|
-
}, "strip"
|
|
117
|
-
url: string;
|
|
118
|
-
title?: string | undefined;
|
|
119
|
-
}, {
|
|
120
|
-
url: string;
|
|
121
|
-
title?: string | undefined;
|
|
122
|
-
}>;
|
|
88
|
+
}, "strip">;
|
|
123
89
|
};
|
|
124
90
|
}>;
|
|
125
91
|
Card: Component<{
|
|
@@ -136,13 +102,7 @@ export declare const DefaultComponents: {
|
|
|
136
102
|
props: z.ZodObject<{
|
|
137
103
|
title: z.ZodString;
|
|
138
104
|
subtitle: z.ZodOptional<z.ZodString>;
|
|
139
|
-
}, "strip"
|
|
140
|
-
title: string;
|
|
141
|
-
subtitle?: string | undefined;
|
|
142
|
-
}, {
|
|
143
|
-
title: string;
|
|
144
|
-
subtitle?: string | undefined;
|
|
145
|
-
}>;
|
|
105
|
+
}, "strip">;
|
|
146
106
|
children: ({
|
|
147
107
|
description: string;
|
|
148
108
|
component: {
|
|
@@ -159,13 +119,7 @@ export declare const DefaultComponents: {
|
|
|
159
119
|
props: z.ZodObject<{
|
|
160
120
|
url: z.ZodString;
|
|
161
121
|
alt: z.ZodOptional<z.ZodString>;
|
|
162
|
-
}, "strip"
|
|
163
|
-
url: string;
|
|
164
|
-
alt?: string | undefined;
|
|
165
|
-
}, {
|
|
166
|
-
url: string;
|
|
167
|
-
alt?: string | undefined;
|
|
168
|
-
}>;
|
|
122
|
+
}, "strip">;
|
|
169
123
|
};
|
|
170
124
|
};
|
|
171
125
|
} | {
|
|
@@ -186,17 +140,7 @@ export declare const DefaultComponents: {
|
|
|
186
140
|
label: z.ZodString;
|
|
187
141
|
value: z.ZodOptional<z.ZodString>;
|
|
188
142
|
url: z.ZodOptional<z.ZodString>;
|
|
189
|
-
}, "strip"
|
|
190
|
-
action: "say" | "url" | "postback";
|
|
191
|
-
label: string;
|
|
192
|
-
value?: string | undefined;
|
|
193
|
-
url?: string | undefined;
|
|
194
|
-
}, {
|
|
195
|
-
label: string;
|
|
196
|
-
value?: string | undefined;
|
|
197
|
-
url?: string | undefined;
|
|
198
|
-
action?: "say" | "url" | "postback" | undefined;
|
|
199
|
-
}>;
|
|
143
|
+
}, "strip">;
|
|
200
144
|
};
|
|
201
145
|
};
|
|
202
146
|
})[];
|
|
@@ -213,7 +157,7 @@ export declare const DefaultComponents: {
|
|
|
213
157
|
code: string;
|
|
214
158
|
}[];
|
|
215
159
|
container: {
|
|
216
|
-
props: z.ZodObject<{}, "strip"
|
|
160
|
+
props: z.ZodObject<{}, "strip">;
|
|
217
161
|
children: {
|
|
218
162
|
description: string;
|
|
219
163
|
component: {
|
|
@@ -230,13 +174,7 @@ export declare const DefaultComponents: {
|
|
|
230
174
|
props: z.ZodObject<{
|
|
231
175
|
title: z.ZodString;
|
|
232
176
|
subtitle: z.ZodOptional<z.ZodString>;
|
|
233
|
-
}, "strip"
|
|
234
|
-
title: string;
|
|
235
|
-
subtitle?: string | undefined;
|
|
236
|
-
}, {
|
|
237
|
-
title: string;
|
|
238
|
-
subtitle?: string | undefined;
|
|
239
|
-
}>;
|
|
177
|
+
}, "strip">;
|
|
240
178
|
children: ({
|
|
241
179
|
description: string;
|
|
242
180
|
component: {
|
|
@@ -253,13 +191,7 @@ export declare const DefaultComponents: {
|
|
|
253
191
|
props: z.ZodObject<{
|
|
254
192
|
url: z.ZodString;
|
|
255
193
|
alt: z.ZodOptional<z.ZodString>;
|
|
256
|
-
}, "strip"
|
|
257
|
-
url: string;
|
|
258
|
-
alt?: string | undefined;
|
|
259
|
-
}, {
|
|
260
|
-
url: string;
|
|
261
|
-
alt?: string | undefined;
|
|
262
|
-
}>;
|
|
194
|
+
}, "strip">;
|
|
263
195
|
};
|
|
264
196
|
};
|
|
265
197
|
} | {
|
|
@@ -280,17 +212,7 @@ export declare const DefaultComponents: {
|
|
|
280
212
|
label: z.ZodString;
|
|
281
213
|
value: z.ZodOptional<z.ZodString>;
|
|
282
214
|
url: z.ZodOptional<z.ZodString>;
|
|
283
|
-
}, "strip"
|
|
284
|
-
action: "say" | "url" | "postback";
|
|
285
|
-
label: string;
|
|
286
|
-
value?: string | undefined;
|
|
287
|
-
url?: string | undefined;
|
|
288
|
-
}, {
|
|
289
|
-
label: string;
|
|
290
|
-
value?: string | undefined;
|
|
291
|
-
url?: string | undefined;
|
|
292
|
-
action?: "say" | "url" | "postback" | undefined;
|
|
293
|
-
}>;
|
|
215
|
+
}, "strip">;
|
|
294
216
|
};
|
|
295
217
|
};
|
|
296
218
|
})[];
|
|
@@ -310,7 +232,7 @@ export declare const DefaultComponents: {
|
|
|
310
232
|
code: string;
|
|
311
233
|
}[];
|
|
312
234
|
default: {
|
|
313
|
-
props: z.ZodObject<{}, "strip"
|
|
235
|
+
props: z.ZodObject<{}, "strip">;
|
|
314
236
|
children: never[];
|
|
315
237
|
};
|
|
316
238
|
}>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkC2KND2PScjs = require('./chunk-C2KND2PS.cjs');
|
|
4
4
|
require('./chunk-KIN7Y247.cjs');
|
|
5
5
|
require('./chunk-YQT5G77W.cjs');
|
|
6
6
|
require('./chunk-FPLSJF4S.cjs');
|
|
7
7
|
require('./chunk-HC2QZTVT.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
exports.DualModePrompt =
|
|
10
|
+
exports.DualModePrompt = _chunkC2KND2PScjs.DualModePrompt;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunk2EZSVF5Xcjs = require('./chunk-2EZSVF5X.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
@@ -11,13 +11,13 @@ var _chunkWWZ2W4WRcjs = require('./chunk-WWZ2W4WR.cjs');
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunk5XPEVOOWcjs = require('./chunk-5XPEVOOW.cjs');
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var
|
|
19
|
-
require('./chunk-
|
|
20
|
-
require('./chunk-
|
|
18
|
+
var _chunkC2KND2PScjs = require('./chunk-C2KND2PS.cjs');
|
|
19
|
+
require('./chunk-S46T73HR.cjs');
|
|
20
|
+
require('./chunk-MHVORH33.cjs');
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
@@ -224,7 +224,7 @@ var generateCode = async ({
|
|
|
224
224
|
}
|
|
225
225
|
};
|
|
226
226
|
if (typeof cognitive.generateContentStream === "function") {
|
|
227
|
-
const parser = new (0,
|
|
227
|
+
const parser = new (0, _chunkC2KND2PScjs.StreamingMessageParser)();
|
|
228
228
|
const fence = new LeadingFenceFilter();
|
|
229
229
|
const streamController = createJoinedAbortController([controller.signal]);
|
|
230
230
|
const requestedAt = Date.now();
|
|
@@ -276,7 +276,7 @@ var generateCode = async ({
|
|
|
276
276
|
await dispatchSends(parser.push(remaining));
|
|
277
277
|
}
|
|
278
278
|
await dispatchSends(parser.finish());
|
|
279
|
-
assistantResponse =
|
|
279
|
+
assistantResponse = _chunkC2KND2PScjs.toParsedAssistantResponse.call(void 0, parser.items, raw);
|
|
280
280
|
} else {
|
|
281
281
|
output = await cognitive.generateContent(input).catch((thrown) => {
|
|
282
282
|
throw new (0, _chunkPK72FAKDcjs.CognitiveError)(`LLM generation failed: ${_chunkFPLSJF4Scjs.getErrorMessage.call(void 0, thrown)}`);
|
|
@@ -395,7 +395,7 @@ var interpretVMResult = async ({
|
|
|
395
395
|
return;
|
|
396
396
|
}
|
|
397
397
|
const returnValue = result.return_value;
|
|
398
|
-
const codeRequestsInspection =
|
|
398
|
+
const codeRequestsInspection = _chunk2EZSVF5Xcjs.hasTopLevelReturn.call(void 0, _nullishCoalesce(iteration.code, () => ( "")));
|
|
399
399
|
if (iteration.next && !codeRequestsInspection) {
|
|
400
400
|
await applyNextExit({ iteration, controller, onExit });
|
|
401
401
|
return;
|
|
@@ -420,7 +420,7 @@ var applyNextExit = async ({
|
|
|
420
420
|
if (!next) {
|
|
421
421
|
throw new Error("applyNextExit called without a \u25A0next block on the iteration");
|
|
422
422
|
}
|
|
423
|
-
const attempt = (props) =>
|
|
423
|
+
const attempt = (props) => _chunk5XPEVOOWcjs.parseExit.call(void 0, Object.keys(props).length ? { action: next.name, value: props } : { action: next.name }, iteration.exits);
|
|
424
424
|
let parsedExit = attempt(next.props);
|
|
425
425
|
const keys = Object.keys(next.props);
|
|
426
426
|
if (!parsedExit.success && keys.length === 1 && ["props", "value", "data"].includes(keys[0])) {
|
|
@@ -727,8 +727,8 @@ var executeContextInternal = async (props) => {
|
|
|
727
727
|
const controller = createJoinedAbortController([props.signal]);
|
|
728
728
|
const { onIterationStart, onIterationEnd, onTrace, onExit, onBeforeExecution, onAfterTool, onBeforeTool } = props;
|
|
729
729
|
const client = _nullishCoalesce(props.client, () => ( new (0, _client.Client)()));
|
|
730
|
-
const cognitive = _cognitive.Cognitive.isCognitiveClient(client) ||
|
|
731
|
-
const ctx = new (0,
|
|
730
|
+
const cognitive = _cognitive.Cognitive.isCognitiveClient(client) || _chunk5XPEVOOWcjs._CustomModelClient.isCustomClient(client) ? client : _cognitive.CognitiveBeta.isBetaClient(client) ? _cognitive.cognitiveFromBeta.call(void 0, client) : new (0, _cognitive.Cognitive)({ client, __experimental_beta: true });
|
|
731
|
+
const ctx = new (0, _chunk5XPEVOOWcjs.Context)({
|
|
732
732
|
chat: props.chat,
|
|
733
733
|
instructions: props.instructions,
|
|
734
734
|
objects: props.objects,
|
|
@@ -746,7 +746,7 @@ var executeContextInternal = async (props) => {
|
|
|
746
746
|
try {
|
|
747
747
|
while (true) {
|
|
748
748
|
if (ctx.iterations.length >= ctx.loop) {
|
|
749
|
-
return new (0,
|
|
749
|
+
return new (0, _chunk5XPEVOOWcjs.ErrorExecutionResult)(ctx, new (0, _chunkPK72FAKDcjs.LoopExceededError)());
|
|
750
750
|
}
|
|
751
751
|
const iteration = await ctx.nextIteration();
|
|
752
752
|
const unsubscribeTrace = iteration.traces.onPush((traces) => {
|
|
@@ -777,7 +777,7 @@ var executeContextInternal = async (props) => {
|
|
|
777
777
|
}
|
|
778
778
|
}
|
|
779
779
|
});
|
|
780
|
-
return new (0,
|
|
780
|
+
return new (0, _chunk5XPEVOOWcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted")));
|
|
781
781
|
}
|
|
782
782
|
const iterationResult = await executeIterationWithErrorHandling({
|
|
783
783
|
iteration,
|
|
@@ -807,7 +807,7 @@ var executeContextInternal = async (props) => {
|
|
|
807
807
|
}
|
|
808
808
|
}
|
|
809
809
|
} catch (error) {
|
|
810
|
-
return new (0,
|
|
810
|
+
return new (0, _chunk5XPEVOOWcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(error, () => ( "Unknown error")));
|
|
811
811
|
}
|
|
812
812
|
};
|
|
813
813
|
var executeIterationStartHook = async ({
|
|
@@ -894,7 +894,7 @@ var executeIterationWithErrorHandling = async ({
|
|
|
894
894
|
if (!controller.signal.aborted) {
|
|
895
895
|
return {
|
|
896
896
|
type: "return",
|
|
897
|
-
result: new (0,
|
|
897
|
+
result: new (0, _chunk5XPEVOOWcjs.ErrorExecutionResult)(ctx, err)
|
|
898
898
|
};
|
|
899
899
|
}
|
|
900
900
|
await finalizeIteration({
|
|
@@ -910,7 +910,7 @@ var executeIterationWithErrorHandling = async ({
|
|
|
910
910
|
});
|
|
911
911
|
return {
|
|
912
912
|
type: "return",
|
|
913
|
-
result: new (0,
|
|
913
|
+
result: new (0, _chunk5XPEVOOWcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted")))
|
|
914
914
|
};
|
|
915
915
|
}
|
|
916
916
|
};
|
|
@@ -922,7 +922,7 @@ var transformIterationResult = ({
|
|
|
922
922
|
const exitName = iteration.status.exit_success.exit_name;
|
|
923
923
|
return {
|
|
924
924
|
type: "return",
|
|
925
|
-
result: new (0,
|
|
925
|
+
result: new (0, _chunk5XPEVOOWcjs.SuccessExecutionResult)(ctx, {
|
|
926
926
|
exit: iteration.exits.find((x) => x.name === exitName),
|
|
927
927
|
result: iteration.status.exit_success.return_value
|
|
928
928
|
})
|
|
@@ -931,17 +931,17 @@ var transformIterationResult = ({
|
|
|
931
931
|
if (iteration.status.type === "callback_requested") {
|
|
932
932
|
return {
|
|
933
933
|
type: "return",
|
|
934
|
-
result: new (0,
|
|
934
|
+
result: new (0, _chunk5XPEVOOWcjs.PartialExecutionResult)(
|
|
935
935
|
ctx,
|
|
936
936
|
iteration.status.callback_requested.signal,
|
|
937
|
-
|
|
937
|
+
_chunk5XPEVOOWcjs.Snapshot.fromSignal(iteration.status.callback_requested.signal)
|
|
938
938
|
)
|
|
939
939
|
};
|
|
940
940
|
}
|
|
941
941
|
if (iteration.status.type === "aborted") {
|
|
942
942
|
return {
|
|
943
943
|
type: "return",
|
|
944
|
-
result: new (0,
|
|
944
|
+
result: new (0, _chunk5XPEVOOWcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(iteration.error, () => ( "The operation was aborted")))
|
|
945
945
|
};
|
|
946
946
|
}
|
|
947
947
|
if (iteration.status.type === "thinking_requested" || iteration.status.type === "exit_error" || iteration.status.type === "execution_error" || iteration.status.type === "invalid_code_error") {
|
|
@@ -949,7 +949,7 @@ var transformIterationResult = ({
|
|
|
949
949
|
}
|
|
950
950
|
return {
|
|
951
951
|
type: "return",
|
|
952
|
-
result: new (0,
|
|
952
|
+
result: new (0, _chunk5XPEVOOWcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(iteration.error, () => ( `Unknown error. Status: ${iteration.status.type}`)))
|
|
953
953
|
};
|
|
954
954
|
};
|
|
955
955
|
var executeIteration = async ({
|
|
@@ -966,7 +966,7 @@ var executeIteration = async ({
|
|
|
966
966
|
var _a, _b;
|
|
967
967
|
const runCode = (code) => {
|
|
968
968
|
const vmContext = buildVMContext({ ctx, iteration, controller, onBeforeTool, onAfterTool });
|
|
969
|
-
return
|
|
969
|
+
return _chunk2EZSVF5Xcjs.runAsyncFunction.call(void 0, vmContext, code, iteration.traces, controller.signal, ctx.timeout).catch((err) => {
|
|
970
970
|
return {
|
|
971
971
|
success: false,
|
|
972
972
|
error: err instanceof Error ? err : new Error(_chunkFPLSJF4Scjs.getErrorMessage.call(void 0, err)),
|
|
@@ -985,7 +985,7 @@ var executeIteration = async ({
|
|
|
985
985
|
controller,
|
|
986
986
|
metadata,
|
|
987
987
|
// Pre-warm the VM while the model is still writing the ■run block
|
|
988
|
-
onRunStart: () =>
|
|
988
|
+
onRunStart: () => _chunk2EZSVF5Xcjs.warmupVM.call(void 0, ),
|
|
989
989
|
onRunComplete: canExecuteEarly ? (code) => {
|
|
990
990
|
if (!code.length || controller.signal.aborted || earlyExecution) {
|
|
991
991
|
return;
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
hasTopLevelReturn,
|
|
3
3
|
runAsyncFunction,
|
|
4
4
|
warmupVM
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-EJIDFDQP.js";
|
|
6
6
|
import {
|
|
7
7
|
Context,
|
|
8
8
|
ErrorExecutionResult,
|
|
@@ -11,13 +11,13 @@ import {
|
|
|
11
11
|
SuccessExecutionResult,
|
|
12
12
|
_CustomModelClient,
|
|
13
13
|
parseExit
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-2MSLOTFO.js";
|
|
15
15
|
import {
|
|
16
16
|
StreamingMessageParser,
|
|
17
17
|
toParsedAssistantResponse
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-5ISVDYBA.js";
|
|
19
|
+
import "./chunk-3OSQ4XL4.js";
|
|
20
|
+
import "./chunk-GDWRFHM5.js";
|
|
21
21
|
import {
|
|
22
22
|
AssignmentError,
|
|
23
23
|
CodeExecutionError,
|
package/dist/formatting.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export type CodeFormatOptions = Parameters<typeof format>[1] & {
|
|
1
|
+
export type CodeFormatOptions = {
|
|
3
2
|
throwOnError?: boolean;
|
|
4
3
|
};
|
|
5
4
|
export declare function formatTypings(typings: string, options?: CodeFormatOptions): Promise<string>;
|