llmz 0.2.1 → 0.2.3

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.
Files changed (62) hide show
  1. package/CLAUDE.md +0 -1
  2. package/dist/{chunk-WWZ2W4WR.cjs → chunk-3UZKLXAD.cjs} +410 -514
  3. package/dist/{chunk-HM5H556L.js → chunk-72ZWBNZV.js} +1 -1
  4. package/dist/{chunk-D6PU5YAS.cjs → chunk-DDSJTR6Q.cjs} +8 -7
  5. package/dist/{chunk-665O7CAN.js → chunk-GDJTKI7J.js} +5 -1
  6. package/dist/{chunk-YX27XM67.js → chunk-GLXADNTR.js} +13 -1
  7. package/dist/{chunk-FPLSJF4S.cjs → chunk-GOWPACSK.cjs} +15 -3
  8. package/dist/{chunk-XVVYNOTX.js → chunk-HB2G32AK.js} +3 -2
  9. package/dist/{chunk-YQT5G77W.cjs → chunk-HEAQAEFZ.cjs} +2 -2
  10. package/dist/{chunk-DD4AZSP5.cjs → chunk-HMMM32RG.cjs} +19 -15
  11. package/dist/{chunk-MY26EAOP.cjs → chunk-KG5E3UZZ.cjs} +20 -20
  12. package/dist/{chunk-YGKQEVQQ.cjs → chunk-OVRDJMZJ.cjs} +29 -37
  13. package/dist/{chunk-E5NHK3FS.js → chunk-OXEKAOVI.js} +6 -14
  14. package/dist/{chunk-ETYFOCWC.cjs → chunk-PZE6PIPG.cjs} +12 -11
  15. package/dist/chunk-RGUG3UMF.cjs +26 -0
  16. package/dist/{chunk-GC5IQDGV.js → chunk-TDALRNGL.js} +4 -3
  17. package/dist/chunk-UGHFNCPD.js +26 -0
  18. package/dist/{chunk-ZWUWCRHG.js → chunk-XMFQVARN.js} +5 -5
  19. package/dist/{chunk-DH35WO5G.js → chunk-YRS7KRKP.js} +401 -505
  20. package/dist/compiler/ast.d.ts +26 -0
  21. package/dist/compiler/compiler.d.ts +13 -11
  22. package/dist/compiler/plugins/line-tracking.d.ts +6 -4
  23. package/dist/compiler/plugins/replace-comment.d.ts +8 -4
  24. package/dist/compiler/plugins/return-async.d.ts +18 -4
  25. package/dist/compiler/plugins/track-tool-calls.d.ts +21 -4
  26. package/dist/compiler/plugins/variable-extraction.d.ts +9 -4
  27. package/dist/component.default.d.ts +13 -91
  28. package/dist/{dual-modes-RMF7V7ZQ.js → dual-modes-BYABHBDI.js} +3 -3
  29. package/dist/dual-modes-HO6RRIZ5.cjs +10 -0
  30. package/dist/emscripten-module.wasm +0 -0
  31. package/dist/{execute-LNUBLVMZ.js → execute-DSGJ2UNL.js} +9 -8
  32. package/dist/{execute-2AGZ5QUN.cjs → execute-MRZZ4AYY.cjs} +41 -40
  33. package/dist/exit-MX56VN2C.cjs +8 -0
  34. package/dist/{exit-VJATJTQI.js → exit-UQ3EUX5D.js} +2 -2
  35. package/dist/exit.d.ts +1 -1
  36. package/dist/index.cjs +210 -253
  37. package/dist/index.d.ts +2 -0
  38. package/dist/index.js +184 -227
  39. package/dist/index.workerd.js +17328 -0
  40. package/dist/prompts/chat-mode/system.md.d.ts +1 -1
  41. package/dist/prompts/worker-mode/system.md.d.ts +1 -1
  42. package/dist/prompts/worker-mode/user.md.d.ts +1 -1
  43. package/dist/quickjs-variant.d.ts +22 -0
  44. package/dist/quickjs-variant.workerd.d.ts +22 -0
  45. package/dist/{tool-HTAYKIA2.js → tool-KD7FL45V.js} +3 -3
  46. package/dist/{tool-V55GD2FS.cjs → tool-VE2YHIY2.cjs} +4 -4
  47. package/dist/{truncator-OZOBNYON.js → truncator-73RCL52Y.js} +2 -2
  48. package/dist/truncator-FZNLYSDL.cjs +12 -0
  49. package/dist/{typings-SCKZCAPN.js → typings-E2RROCLT.js} +2 -2
  50. package/dist/{typings-S6I6IPTG.cjs → typings-LQOBZXSO.cjs} +3 -3
  51. package/dist/typings-formatter.d.ts +19 -0
  52. package/dist/{utils-ZEZ66X6Q.js → utils-IATCUNKF.js} +5 -1
  53. package/dist/utils-ITB4NEL7.cjs +43 -0
  54. package/dist/utils.d.ts +18 -0
  55. package/dist/vm-6D3IIIU7.cjs +12 -0
  56. package/dist/{vm-44H4UKI2.js → vm-QO5FSGPN.js} +2 -1
  57. package/package.json +8 -14
  58. package/dist/dual-modes-ZZY6QPYT.cjs +0 -10
  59. package/dist/exit-LUJY7JIG.cjs +0 -8
  60. package/dist/truncator-7PGEGCHV.cjs +0 -12
  61. package/dist/utils-GLZVMRWO.cjs +0 -39
  62. package/dist/vm-A3OTQVIR.cjs +0 -11
@@ -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 * as BabelCore from '@babel/core';
1
+ import { type Ctx } from '../ast.js';
2
2
  export declare const LineTrackingFnIdentifier = "__track__";
3
- export declare const lineTrackingBabelPlugin: ({ types: t }: {
4
- types: typeof BabelCore.types;
5
- }) => BabelCore.PluginObj;
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 * as BabelCore from '@babel/core';
1
+ import { type Ctx } from '../ast.js';
2
2
  export declare const CommentFnIdentifier = "__comment__";
3
- export declare const replaceCommentBabelPlugin: ({ types: t, }: {
4
- types: typeof BabelCore.types;
5
- }) => BabelCore.PluginObj;
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 * as BabelCore from '@babel/core';
2
- export declare const instrumentLastLinePlugin: ({ types: t, }: {
3
- types: typeof BabelCore.types;
4
- }) => BabelCore.PluginObj;
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 * as BabelCore from '@babel/core';
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
- export declare const toolCallTrackingPlugin: (calls?: Map<number, ToolCallEntry>) => ({}: {
15
- types: typeof BabelCore.types;
16
- }) => BabelCore.PluginObj;
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 * as BabelCore from '@babel/core';
1
+ import { type Ctx } from '../ast.js';
2
2
  export declare const VariableTrackingFnIdentifier = "__var__";
3
- export declare const variableTrackingPlugin: (variables?: Set<string>) => ({ types: t }: {
4
- types: typeof BabelCore.types;
5
- }) => BabelCore.PluginObj;
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,9 +1,9 @@
1
1
  import {
2
2
  DualModePrompt
3
- } from "./chunk-E5NHK3FS.js";
3
+ } from "./chunk-OXEKAOVI.js";
4
4
  import "./chunk-YEAWWJSJ.js";
5
- import "./chunk-HM5H556L.js";
6
- import "./chunk-YX27XM67.js";
5
+ import "./chunk-72ZWBNZV.js";
6
+ import "./chunk-GLXADNTR.js";
7
7
  import "./chunk-34GJUS6U.js";
8
8
  export {
9
9
  DualModePrompt
@@ -0,0 +1,10 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkOVRDJMZJcjs = require('./chunk-OVRDJMZJ.cjs');
4
+ require('./chunk-KIN7Y247.cjs');
5
+ require('./chunk-HEAQAEFZ.cjs');
6
+ require('./chunk-GOWPACSK.cjs');
7
+ require('./chunk-HC2QZTVT.cjs');
8
+
9
+
10
+ exports.DualModePrompt = _chunkOVRDJMZJcjs.DualModePrompt;
Binary file
@@ -2,7 +2,7 @@ import {
2
2
  hasTopLevelReturn,
3
3
  runAsyncFunction,
4
4
  warmupVM
5
- } from "./chunk-DH35WO5G.js";
5
+ } from "./chunk-YRS7KRKP.js";
6
6
  import {
7
7
  Context,
8
8
  ErrorExecutionResult,
@@ -11,13 +11,14 @@ import {
11
11
  SuccessExecutionResult,
12
12
  _CustomModelClient,
13
13
  parseExit
14
- } from "./chunk-ZWUWCRHG.js";
14
+ } from "./chunk-XMFQVARN.js";
15
15
  import {
16
16
  StreamingMessageParser,
17
17
  toParsedAssistantResponse
18
- } from "./chunk-E5NHK3FS.js";
19
- import "./chunk-GC5IQDGV.js";
20
- import "./chunk-665O7CAN.js";
18
+ } from "./chunk-OXEKAOVI.js";
19
+ import "./chunk-UGHFNCPD.js";
20
+ import "./chunk-TDALRNGL.js";
21
+ import "./chunk-GDJTKI7J.js";
21
22
  import {
22
23
  AssignmentError,
23
24
  CodeExecutionError,
@@ -31,19 +32,19 @@ import {
31
32
  import {
32
33
  cleanStackTrace
33
34
  } from "./chunk-YEAWWJSJ.js";
34
- import "./chunk-XVVYNOTX.js";
35
+ import "./chunk-HB2G32AK.js";
35
36
  import "./chunk-KWQTYXAT.js";
36
37
  import {
37
38
  createJsxComponent
38
39
  } from "./chunk-XTEHT2TK.js";
39
40
  import {
40
41
  truncateWrappedContent
41
- } from "./chunk-HM5H556L.js";
42
+ } from "./chunk-72ZWBNZV.js";
42
43
  import {
43
44
  getErrorMessage,
44
45
  init,
45
46
  stripInvalidIdentifiers
46
- } from "./chunk-YX27XM67.js";
47
+ } from "./chunk-GLXADNTR.js";
47
48
  import {
48
49
  clamp_default,
49
50
  isEqual_default