llmz 0.9.0 → 1.0.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/DOCS.md +232 -1794
- package/ERRORS.md +101 -0
- package/README.md +96 -582
- package/dist/chat/chat.d.ts +63 -0
- package/dist/chat/component.d.ts +31 -0
- package/dist/chat/component.default.d.ts +58 -0
- package/dist/chat/response.d.ts +15 -0
- package/dist/compiler/compiler.d.ts +2 -7
- package/dist/compiler/plugins/dynamic-code.d.ts +7 -0
- package/dist/compiler/plugins/replace-comment.d.ts +2 -3
- package/dist/compiler/plugins/return-async.d.ts +5 -4
- package/dist/compiler/plugins/termination.d.ts +8 -0
- package/dist/compiler/plugins/tool-resolution.d.ts +4 -0
- package/dist/compiler/plugins/variable-extraction.d.ts +2 -8
- package/dist/component-CMFoCHyu.cjs +649 -0
- package/dist/component-DncqP4fB.js +614 -0
- package/dist/context.d.ts +71 -378
- package/dist/custom-client-C-WXvLD9.js +1655 -0
- package/dist/custom-client-Cgt9_0r1.cjs +1732 -0
- package/dist/custom-client.d.ts +12 -2
- package/dist/errors/catalog.d.ts +294 -0
- package/dist/errors/hooks.d.ts +2 -0
- package/dist/errors-C6ppQUZX.cjs +893 -0
- package/dist/errors-Crk5P8jo.js +636 -0
- package/dist/errors.d.ts +24 -36
- package/dist/execute-CiYvPs5Q.js +2061 -0
- package/dist/execute-DTTfacsi.cjs +2062 -0
- package/dist/{exit-DUM96DN1.cjs → exit-BOtKWPuT.cjs} +38 -28
- package/dist/{exit-CDdxDBRT.js → exit-DMPwCSba.js} +37 -27
- package/dist/exit.d.ts +19 -16
- package/dist/index.cjs +177 -1237
- package/dist/index.d.ts +25 -28
- package/dist/index.js +137 -1213
- package/dist/index.workerd.js +8974 -11145
- package/dist/inspect.d.ts +18 -4
- package/dist/inspection.d.ts +40 -0
- package/dist/native-0bq5ATZM.cjs +212 -0
- package/dist/native-n_718Z-T.js +177 -0
- package/dist/objects.d.ts +2 -57
- package/dist/prompts/native.d.ts +2 -0
- package/dist/prompts/prompt.d.ts +10 -101
- package/dist/quickjs-variant-21IO97PF.cjs +1080 -0
- package/dist/quickjs-variant-CtuGagsb.js +985 -0
- package/dist/result.d.ts +30 -861
- package/dist/runtime/execute.d.ts +3 -2
- package/dist/runtime/execution-activity.d.ts +11 -0
- package/dist/runtime/execution-diagnostics.d.ts +11 -0
- package/dist/runtime/execution-report.d.ts +51 -0
- package/dist/runtime/fixtures/chat.d.ts +8 -0
- package/dist/runtime/fixtures/long-search.d.ts +1 -1
- package/dist/runtime/fixtures/native-client.d.ts +33 -0
- package/dist/runtime/fixtures/protocol-languages.d.ts +1 -1
- package/dist/runtime/forced-inspection.d.ts +13 -0
- package/dist/runtime/forced-inspection.test.d.ts +1 -0
- package/dist/runtime/generate.d.ts +23 -20
- package/dist/runtime/generate.test.d.ts +1 -0
- package/dist/runtime/hook-provenance.test.d.ts +1 -0
- package/dist/runtime/inspection-hook.test.d.ts +1 -0
- package/dist/runtime/inspection-values.d.ts +14 -0
- package/dist/runtime/inspection-values.test.d.ts +1 -0
- package/dist/runtime/interruption-control-flow.test.d.ts +1 -0
- package/dist/runtime/interruption-settings.test.d.ts +1 -0
- package/dist/runtime/javascript-api.d.ts +62 -0
- package/dist/runtime/javascript-api.test.d.ts +1 -0
- package/dist/runtime/native-review.test.d.ts +1 -0
- package/dist/runtime/native-tools.d.ts +18 -0
- package/dist/runtime/native-tools.test.d.ts +1 -0
- package/dist/runtime/object-memory.test.d.ts +1 -0
- package/dist/runtime/single-tool.test.d.ts +1 -0
- package/dist/runtime/think-signal.test.d.ts +1 -0
- package/dist/runtime/token-budget.d.ts +22 -0
- package/dist/runtime/token-budget.test.d.ts +1 -0
- package/dist/runtime/tool-wrapper.d.ts +6 -5
- package/dist/runtime/traces.test.d.ts +1 -0
- package/dist/runtime/truncation.test.d.ts +1 -0
- package/dist/runtime/types.d.ts +47 -31
- package/dist/runtime/variable-recovery.test.d.ts +1 -0
- package/dist/runtime/vm-context.d.ts +6 -1
- package/dist/runtime/worker-completion.test.d.ts +1 -0
- package/dist/runtime-names.d.ts +4 -0
- package/dist/schema-CXlnbb3n.cjs +68 -0
- package/dist/schema-GE4ISPCR.js +45 -0
- package/dist/schema.d.ts +10 -0
- package/dist/schema.test.d.ts +1 -0
- package/dist/session/compactor.d.ts +51 -0
- package/dist/session/compactor.test.d.ts +1 -0
- package/dist/session/history.d.ts +36 -0
- package/dist/session/history.test.d.ts +1 -0
- package/dist/session/json.d.ts +3 -0
- package/dist/session/json.test.d.ts +1 -0
- package/dist/session/memory-codec.d.ts +9 -0
- package/dist/session/memory-codec.test.d.ts +1 -0
- package/dist/session/memory-render.d.ts +15 -0
- package/dist/session/memory-render.test.d.ts +1 -0
- package/dist/session/memory.d.ts +112 -0
- package/dist/session/memory.test.d.ts +1 -0
- package/dist/session/messages.d.ts +19 -0
- package/dist/session/messages.test.d.ts +1 -0
- package/dist/session/serialization.d.ts +36 -0
- package/dist/session/serialization.test.d.ts +1 -0
- package/dist/session/session-memory.test.d.ts +1 -0
- package/dist/session/session.d.ts +121 -0
- package/dist/session/session.test.d.ts +1 -0
- package/dist/session/speaker.test.d.ts +1 -0
- package/dist/{transcript.d.ts → session/transcript.d.ts} +4 -8
- package/dist/session/transcript.test.d.ts +1 -0
- package/dist/{tool-Bv8N4IPj.js → tool-DstssiAs.js} +144 -92
- package/dist/{tool-Dy6AJpJH.cjs → tool-_wK9hQOb.cjs} +146 -94
- package/dist/tool.d.ts +25 -17
- package/dist/truncate-BEKbdo3t.js +79 -0
- package/dist/truncate-uomAMGPs.cjs +102 -0
- package/dist/truncate.d.ts +24 -0
- package/dist/truncate.test.d.ts +1 -0
- package/dist/types.d.ts +33 -9
- package/dist/{typings-3lsqCbkn.cjs → typings-BA_XxAcY.cjs} +38 -193
- package/dist/{typings-CrBa7Tyy.js → typings-BEVDvtuk.js} +38 -175
- package/dist/typings-formatter.d.ts +1 -1
- package/dist/typings.d.ts +3 -0
- package/dist/{uniq-BYQ7GWwb.js → uniq-DfUeSNaX.js} +2 -2
- package/dist/{uniq-G872RWmE.cjs → uniq-DiXgysNV.cjs} +6 -18
- package/dist/{_baseIteratee-P_firB7b.js → utils-BOFzb8Ok.js} +1134 -16
- package/dist/{_baseIteratee-CF4qP2a8.cjs → utils-CTlsXvdj.cjs} +1281 -84
- package/dist/vm/drivers/node.d.ts +1 -1
- package/dist/vm/drivers/quickjs.d.ts +1 -1
- package/dist/vm/errors.d.ts +4 -4
- package/dist/vm/index.d.ts +3 -4
- package/dist/vm/instrument.d.ts +14 -6
- package/dist/vm/member-proxy.d.ts +4 -0
- package/dist/vm/member-proxy.test.d.ts +1 -0
- package/dist/vm/memory.test.d.ts +1 -0
- package/dist/vm/return-semantics.test.d.ts +1 -0
- package/dist/vm/types.d.ts +20 -3
- package/dist/{vm-BLsHw1da.js → vm-C7SfutHn.js} +1187 -180
- package/dist/{vm-D6s1zF6M.cjs → vm-gmekHc0i.cjs} +1221 -207
- package/package.json +13 -6
- package/dist/_baseForOwn-BfWDTL8L.cjs +0 -53
- package/dist/_baseForOwn-CFhWe_W6.js +0 -48
- package/dist/_getPrototype-CG7Dxrrz.js +0 -6
- package/dist/_getPrototype-DQDlNVVM.cjs +0 -10
- package/dist/_overArg-C5Hy7oCi.cjs +0 -196
- package/dist/_overArg-CRYbj1NH.js +0 -155
- package/dist/chat.d.ts +0 -401
- package/dist/common-BlRFtdf2.js +0 -807
- package/dist/common-BnvrDnIT.cjs +0 -860
- package/dist/compiler/plugins/track-tool-calls.d.ts +0 -33
- package/dist/compiler-C-OI9sim.cjs +0 -547
- package/dist/compiler-CW1VjQsn.js +0 -473
- package/dist/component-C6Agl2ns.cjs +0 -73
- package/dist/component-DGG7d_Mz.js +0 -44
- package/dist/component.d.ts +0 -88
- package/dist/component.default.d.ts +0 -278
- package/dist/custom-client-ChuZ63zp.js +0 -2658
- package/dist/custom-client-DAsGRnYc.cjs +0 -2729
- package/dist/dual-modes-DDkoCp3R.js +0 -3006
- package/dist/dual-modes-DPXiuvNe.cjs +0 -3090
- package/dist/errors-C962uJdS.cjs +0 -220
- package/dist/errors-Cg1G0Awu.js +0 -161
- package/dist/example-format.d.ts +0 -8
- package/dist/example.d.ts +0 -45
- package/dist/execute-BWcdv9so.js +0 -1059
- package/dist/execute-DM2-7y86.cjs +0 -1060
- package/dist/exit-parser.d.ts +0 -39
- package/dist/handlers.d.ts +0 -10
- package/dist/hoist.d.ts +0 -2
- package/dist/isEmpty-BhJRCqIF.js +0 -52
- package/dist/isEmpty-LY533Wmh.cjs +0 -57
- package/dist/isPlainObject-CSxXVKCk.cjs +0 -56
- package/dist/isPlainObject-D39AzPO2.js +0 -51
- package/dist/jsx-CIgdGGVs.js +0 -52
- package/dist/jsx-owqxrquU.cjs +0 -75
- package/dist/jsx.d.ts +0 -11
- package/dist/message-stream/index.d.ts +0 -9
- package/dist/message-stream/instructions.d.ts +0 -30
- package/dist/message-stream/normalizer.d.ts +0 -21
- package/dist/message-stream/parser.d.ts +0 -89
- package/dist/message-stream/registry.d.ts +0 -14
- package/dist/message-stream/replayable.d.ts +0 -27
- package/dist/message-stream/response-parser.d.ts +0 -24
- package/dist/message-stream/sanitize.d.ts +0 -10
- package/dist/message-stream/stream.d.ts +0 -54
- package/dist/message-stream/types.d.ts +0 -97
- package/dist/message-stream/validator.d.ts +0 -23
- package/dist/prompts/chat-mode/protocol.d.ts +0 -2
- package/dist/prompts/chat-mode/system.d.ts +0 -2
- package/dist/prompts/chat-mode/system.md.d.ts +0 -2
- package/dist/prompts/chat-mode/user.d.ts +0 -2
- package/dist/prompts/chat-mode/user.md.d.ts +0 -2
- package/dist/prompts/code-examples.d.ts +0 -2
- package/dist/prompts/common.d.ts +0 -7
- package/dist/prompts/dual-modes.d.ts +0 -2
- package/dist/prompts/execution-history.d.ts +0 -6
- package/dist/prompts/execution-state.d.ts +0 -3
- package/dist/prompts/protocol-basics.d.ts +0 -5
- package/dist/prompts/protocol.d.ts +0 -31
- package/dist/prompts/worker-mode/protocol.d.ts +0 -2
- package/dist/prompts/worker-mode/system.d.ts +0 -2
- package/dist/prompts/worker-mode/system.md.d.ts +0 -2
- package/dist/prompts/worker-mode/user.d.ts +0 -2
- package/dist/prompts/worker-mode/user.md.d.ts +0 -2
- package/dist/quickjs-variant-BYhMBpwU.js +0 -45
- package/dist/quickjs-variant-CsIwTVFC.cjs +0 -56
- package/dist/rolldown-runtime-EAsCxrDo.js +0 -14
- package/dist/runtime/fixtures/qwen-protocol-failures.d.ts +0 -29
- package/dist/runtime/interpret-result.d.ts +0 -22
- package/dist/snapshots.d.ts +0 -249
- package/dist/stack-traces-BIE_5Xwf.js +0 -21
- package/dist/stack-traces-ntw_qhoy.cjs +0 -26
- package/dist/truncator-CLkouTCO.cjs +0 -276
- package/dist/truncator-DZqEqnpD.js +0 -253
- package/dist/truncator.d.ts +0 -118
- package/dist/utils-3ESwP3yg.cjs +0 -1075
- package/dist/utils-UBeAFeEI.js +0 -950
- /package/dist/{citations.d.ts → chat/citations.d.ts} +0 -0
- /package/dist/{citations.test.d.ts → chat/citations.test.d.ts} +0 -0
- /package/dist/{component.default.test.d.ts → chat/component.default.test.d.ts} +0 -0
- /package/dist/{compiler/plugins/track-tool-calls.test.d.ts → chat/component.test.d.ts} +0 -0
- /package/dist/{example.test.d.ts → chat/response.test.d.ts} +0 -0
- /package/dist/{exit-parser.test.d.ts → compiler/plugins/dynamic-code.test.d.ts} +0 -0
- /package/dist/{handlers.test.d.ts → compiler/plugins/tool-resolution.test.d.ts} +0 -0
- /package/dist/{hoist.test.d.ts → errors/catalog.test.d.ts} +0 -0
- /package/dist/{message-stream/instructions.test.d.ts → exit.test.d.ts} +0 -0
- /package/dist/{message-stream/normalizer.test.d.ts → inspection.test.d.ts} +0 -0
- /package/dist/{message-stream/parser.test.d.ts → prompts/native.test.d.ts} +0 -0
- /package/dist/{message-stream/response-parser.test.d.ts → result.test.d.ts} +0 -0
- /package/dist/{message-stream/stream.test.d.ts → runtime/chat-completion.test.d.ts} +0 -0
- /package/dist/{message-stream/validator.test.d.ts → runtime/chat-delivery.test.d.ts} +0 -0
- /package/dist/{prompts/adherence.test.d.ts → runtime/chat-last-speaker.test.d.ts} +0 -0
- /package/dist/{prompts/catalogue-examples.test.d.ts → runtime/compatibility-regressions.test.d.ts} +0 -0
- /package/dist/{prompts/code-examples.test.d.ts → runtime/context-registration.test.d.ts} +0 -0
- /package/dist/{prompts/common.test.d.ts → runtime/empty-completion.test.d.ts} +0 -0
- /package/dist/{prompts/concrete-patterns.test.d.ts → runtime/error-recovery.test.d.ts} +0 -0
- /package/dist/{prompts/long-search.test.d.ts → runtime/errors.test.d.ts} +0 -0
- /package/dist/{prompts/protocol-simple.test.d.ts → runtime/execution-activity.test.d.ts} +0 -0
- /package/dist/{prompts/protocol.test.d.ts → runtime/execution-diagnostics.test.d.ts} +0 -0
- /package/dist/{prompts/sections.test.d.ts → runtime/execution-report.test.d.ts} +0 -0
- /package/dist/runtime/{interpret-result.test.d.ts → execution-safety.test.d.ts} +0 -0
- /package/dist/{transcript.test.d.ts → runtime/exit-control-flow.test.d.ts} +0 -0
- /package/dist/{truncator.test.d.ts → runtime/fixtures/long-search.test.d.ts} +0 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
const require_errors = require("./errors-C6ppQUZX.cjs");
|
|
2
|
+
//#region src/truncate.ts
|
|
3
|
+
const TRUNCATE_SIGNATURE = "llmz.truncate.v1";
|
|
4
|
+
const DEFAULT_TOOL_RESULT_MAX_TOKENS = 2e3;
|
|
5
|
+
/** Sets a display budget without truncating or changing the underlying value. */
|
|
6
|
+
function truncate({ value, maxTokens, preserve = "top" }) {
|
|
7
|
+
if (!Number.isSafeInteger(maxTokens) || maxTokens < 0) throw new require_errors.InvalidConfigurationError("maxTokens must be a finite nonnegative integer");
|
|
8
|
+
if (preserve !== "top" && preserve !== "bottom" && preserve !== "both") throw new require_errors.InvalidConfigurationError("preserve must be \"top\", \"bottom\", or \"both\"");
|
|
9
|
+
return Object.freeze({
|
|
10
|
+
$$truncate: Object.freeze({
|
|
11
|
+
signature: TRUNCATE_SIGNATURE,
|
|
12
|
+
maxTokens,
|
|
13
|
+
preserve
|
|
14
|
+
}),
|
|
15
|
+
value
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function ownValue(value, key) {
|
|
19
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
20
|
+
return descriptor && "value" in descriptor ? descriptor.value : void 0;
|
|
21
|
+
}
|
|
22
|
+
function isTruncated(value) {
|
|
23
|
+
if (!value || typeof value !== "object") return false;
|
|
24
|
+
const policy = ownValue(value, "$$truncate");
|
|
25
|
+
if (!policy || typeof policy !== "object" || !Object.hasOwn(value, "value")) return false;
|
|
26
|
+
const signature = ownValue(policy, "signature");
|
|
27
|
+
const maxTokens = ownValue(policy, "maxTokens");
|
|
28
|
+
const preserve = ownValue(policy, "preserve");
|
|
29
|
+
const valueDescriptor = Object.getOwnPropertyDescriptor(value, "value");
|
|
30
|
+
return signature === TRUNCATE_SIGNATURE && typeof maxTokens === "number" && Number.isSafeInteger(maxTokens) && maxTokens >= 0 && (preserve === "top" || preserve === "bottom" || preserve === "both") && !!valueDescriptor && "value" in valueDescriptor;
|
|
31
|
+
}
|
|
32
|
+
function isContainer(value) {
|
|
33
|
+
if (!value || typeof value !== "object") return false;
|
|
34
|
+
const prototype = Object.getPrototypeOf(value);
|
|
35
|
+
return Array.isArray(value) || prototype === Object.prototype || prototype === null;
|
|
36
|
+
}
|
|
37
|
+
function unwrapTruncated(value) {
|
|
38
|
+
let underlying = value;
|
|
39
|
+
const rootWrappers = /* @__PURE__ */ new WeakSet();
|
|
40
|
+
while (isTruncated(underlying)) {
|
|
41
|
+
if (rootWrappers.has(underlying)) throw new require_errors.InvalidConfigurationError("Circular truncation wrappers cannot be unwrapped");
|
|
42
|
+
rootWrappers.add(underlying);
|
|
43
|
+
underlying = underlying.value;
|
|
44
|
+
}
|
|
45
|
+
const visited = /* @__PURE__ */ new WeakSet();
|
|
46
|
+
function containsWrapper(current) {
|
|
47
|
+
if (isTruncated(current)) return true;
|
|
48
|
+
if (!isContainer(current) || visited.has(current)) return false;
|
|
49
|
+
visited.add(current);
|
|
50
|
+
for (const key of Reflect.ownKeys(current)) if (containsWrapper(ownValue(current, key))) return true;
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
if (!containsWrapper(underlying)) return underlying;
|
|
54
|
+
const copies = /* @__PURE__ */ new WeakMap();
|
|
55
|
+
const wrappers = /* @__PURE__ */ new WeakSet();
|
|
56
|
+
function unwrap(current) {
|
|
57
|
+
if (current && typeof current === "object" && copies.has(current)) return copies.get(current);
|
|
58
|
+
if (isTruncated(current)) {
|
|
59
|
+
if (wrappers.has(current)) throw new require_errors.InvalidConfigurationError("Circular truncation wrappers cannot be unwrapped");
|
|
60
|
+
wrappers.add(current);
|
|
61
|
+
const result = unwrap(current.value);
|
|
62
|
+
wrappers.delete(current);
|
|
63
|
+
copies.set(current, result);
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
if (!isContainer(current)) return current;
|
|
67
|
+
const copy = Array.isArray(current) ? new Array(current.length) : Object.create(Object.getPrototypeOf(current));
|
|
68
|
+
copies.set(current, copy);
|
|
69
|
+
for (const key of Reflect.ownKeys(current)) {
|
|
70
|
+
const descriptor = Object.getOwnPropertyDescriptor(current, key);
|
|
71
|
+
if ("value" in descriptor) descriptor.value = unwrap(descriptor.value);
|
|
72
|
+
Object.defineProperty(copy, key, descriptor);
|
|
73
|
+
}
|
|
74
|
+
return copy;
|
|
75
|
+
}
|
|
76
|
+
return unwrap(underlying);
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
Object.defineProperty(exports, "DEFAULT_TOOL_RESULT_MAX_TOKENS", {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: function() {
|
|
82
|
+
return DEFAULT_TOOL_RESULT_MAX_TOKENS;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
Object.defineProperty(exports, "isTruncated", {
|
|
86
|
+
enumerable: true,
|
|
87
|
+
get: function() {
|
|
88
|
+
return isTruncated;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
Object.defineProperty(exports, "truncate", {
|
|
92
|
+
enumerable: true,
|
|
93
|
+
get: function() {
|
|
94
|
+
return truncate;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
Object.defineProperty(exports, "unwrapTruncated", {
|
|
98
|
+
enumerable: true,
|
|
99
|
+
get: function() {
|
|
100
|
+
return unwrapTruncated;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare const TRUNCATE_SIGNATURE = "llmz.truncate.v1";
|
|
2
|
+
export declare const DEFAULT_TOOL_RESULT_MAX_TOKENS = 2000;
|
|
3
|
+
export type TruncatePreserve = 'top' | 'bottom' | 'both';
|
|
4
|
+
export type TruncationPolicy = {
|
|
5
|
+
maxTokens: number;
|
|
6
|
+
preserve: TruncatePreserve;
|
|
7
|
+
};
|
|
8
|
+
export type Truncated<T> = {
|
|
9
|
+
readonly $$truncate: Readonly<TruncationPolicy & {
|
|
10
|
+
signature: typeof TRUNCATE_SIGNATURE;
|
|
11
|
+
}>;
|
|
12
|
+
readonly value: T;
|
|
13
|
+
};
|
|
14
|
+
/** Sets a display budget without truncating or changing the underlying value. */
|
|
15
|
+
export declare function truncate<T>({ value, maxTokens, preserve, }: {
|
|
16
|
+
value: T;
|
|
17
|
+
maxTokens: number;
|
|
18
|
+
preserve?: TruncatePreserve;
|
|
19
|
+
}): Truncated<T>;
|
|
20
|
+
export declare function isTruncated(value: unknown): value is Truncated<unknown>;
|
|
21
|
+
/** Removes display wrappers from plain data without changing the wrapped values. */
|
|
22
|
+
export declare function unwrapTruncated<T>(value: Truncated<T>): T;
|
|
23
|
+
export declare function unwrapTruncated<T>(value: T): T;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare namespace Traces {
|
|
|
12
12
|
success: true;
|
|
13
13
|
tool_name: string;
|
|
14
14
|
tool_call_id: string;
|
|
15
|
+
native_call_id?: string;
|
|
15
16
|
object?: string;
|
|
16
17
|
input: any;
|
|
17
18
|
output: any;
|
|
@@ -20,6 +21,7 @@ export declare namespace Traces {
|
|
|
20
21
|
success: false;
|
|
21
22
|
tool_name: string;
|
|
22
23
|
tool_call_id: string;
|
|
24
|
+
native_call_id?: string;
|
|
23
25
|
object?: string;
|
|
24
26
|
input: any;
|
|
25
27
|
error: any;
|
|
@@ -33,6 +35,12 @@ export declare namespace Traces {
|
|
|
33
35
|
duration: number;
|
|
34
36
|
}>;
|
|
35
37
|
type ThinkSignal = TraceTemplate<'think_signal', {
|
|
38
|
+
tool_name?: string;
|
|
39
|
+
tool_call_id?: string;
|
|
40
|
+
object?: string;
|
|
41
|
+
reason?: string;
|
|
42
|
+
context?: unknown;
|
|
43
|
+
metadata?: Record<string, unknown>;
|
|
36
44
|
line: number;
|
|
37
45
|
}>;
|
|
38
46
|
type PropertyMutation = TraceTemplate<'property', {
|
|
@@ -62,18 +70,16 @@ export declare namespace Traces {
|
|
|
62
70
|
toModel: string;
|
|
63
71
|
reason: string;
|
|
64
72
|
}>;
|
|
65
|
-
/**
|
|
66
|
-
* Emitted on streaming clients the moment the model starts writing a `■run`
|
|
67
|
-
* block — before the code is fully generated. Useful to show a
|
|
68
|
-
* "writing code..." indicator while waiting for `llm_call_success` (which
|
|
69
|
-
* carries the final code) and the subsequent execution.
|
|
70
|
-
*/
|
|
71
|
-
type CodeGenerationStart = TraceTemplate<'code_generation_started', {}>;
|
|
72
73
|
type AbortTrace = TraceTemplate<'abort_signal', {
|
|
73
74
|
reason: string;
|
|
74
75
|
}>;
|
|
75
|
-
|
|
76
|
+
/** A message send and its delivery outcome, used to avoid replaying completed effects. */
|
|
77
|
+
type MessageDelivery = TraceTemplate<'message_delivery', {
|
|
76
78
|
value: any;
|
|
79
|
+
message_id?: string;
|
|
80
|
+
native_call_id?: string;
|
|
81
|
+
success?: boolean;
|
|
82
|
+
error?: string;
|
|
77
83
|
}>;
|
|
78
84
|
type InvalidCodeExceptionTrace = TraceTemplate<'invalid_code_exception', {
|
|
79
85
|
message: string;
|
|
@@ -84,7 +90,7 @@ export declare namespace Traces {
|
|
|
84
90
|
started_at: number;
|
|
85
91
|
ended_at?: number;
|
|
86
92
|
} & Content;
|
|
87
|
-
type Trace = Comment | Log | ToolCall | ToolSlow | PropertyMutation |
|
|
93
|
+
type Trace = Comment | Log | ToolCall | ToolSlow | PropertyMutation | MessageDelivery | LLMCallStart | LLMCallSuccess | LLMCallRestart | ThinkSignal | CodeExecution | CodeExecutionException | InvalidCodeExceptionTrace | AbortTrace;
|
|
88
94
|
}
|
|
89
95
|
export type Trace = Traces.Trace;
|
|
90
96
|
export type VMExecutionResult = {
|
|
@@ -92,6 +98,15 @@ export type VMExecutionResult = {
|
|
|
92
98
|
variables: {
|
|
93
99
|
[k: string]: any;
|
|
94
100
|
};
|
|
101
|
+
variableWrites?: {
|
|
102
|
+
name: string;
|
|
103
|
+
timestamp: number;
|
|
104
|
+
kind?: 'assignment' | 'mutation';
|
|
105
|
+
}[];
|
|
106
|
+
captureErrors?: {
|
|
107
|
+
name: string;
|
|
108
|
+
reason: string;
|
|
109
|
+
}[];
|
|
95
110
|
signal?: VMSignal;
|
|
96
111
|
error?: Error;
|
|
97
112
|
lines_executed: [number, number][];
|
|
@@ -101,6 +116,15 @@ export type VMExecutionResult = {
|
|
|
101
116
|
variables: {
|
|
102
117
|
[k: string]: any;
|
|
103
118
|
};
|
|
119
|
+
variableWrites?: {
|
|
120
|
+
name: string;
|
|
121
|
+
timestamp: number;
|
|
122
|
+
kind?: 'assignment' | 'mutation';
|
|
123
|
+
}[];
|
|
124
|
+
captureErrors?: {
|
|
125
|
+
name: string;
|
|
126
|
+
reason: string;
|
|
127
|
+
}[];
|
|
104
128
|
signal?: VMSignal;
|
|
105
129
|
error: Error;
|
|
106
130
|
traces: Trace[];
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const require_errors = require("./errors-C962uJdS.cjs");
|
|
1
|
+
const require_utils = require("./utils-CTlsXvdj.cjs");
|
|
2
|
+
const require_errors = require("./errors-C6ppQUZX.cjs");
|
|
4
3
|
let _bpinternal_zui = require("@bpinternal/zui");
|
|
5
4
|
//#region src/typings-formatter.ts
|
|
6
5
|
/**
|
|
7
6
|
* A minimal, dependency-free formatter for the TypeScript typings generated by
|
|
8
|
-
* llmz (typings.ts, objects.ts
|
|
7
|
+
* llmz (typings.ts, objects.ts). It supports only the small grammar
|
|
9
8
|
* those generators emit — type expressions, `declare const` / `declare function`
|
|
10
9
|
* declarations, `type` aliases and `export namespace` blocks — and produces
|
|
11
10
|
* prettier-like output: 80 columns, 2-space indent, no semicolons in broken
|
|
@@ -427,7 +426,7 @@ function breakGroup(p, g, level, tailWidth = 0) {
|
|
|
427
426
|
});
|
|
428
427
|
return;
|
|
429
428
|
}
|
|
430
|
-
const separator = g.open === "(" || g.open === "["
|
|
429
|
+
const separator = g.open === "(" || g.open === "[" || usedComma ? "," : null;
|
|
431
430
|
const trailingSeparator = g.open === "(" || g.open === "[";
|
|
432
431
|
p.atom({
|
|
433
432
|
kind: "open",
|
|
@@ -566,178 +565,42 @@ async function formatTypings(typings, options) {
|
|
|
566
565
|
}
|
|
567
566
|
//#endregion
|
|
568
567
|
//#region src/typings.ts
|
|
569
|
-
var typings_exports = /* @__PURE__ */
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
"object"
|
|
583
|
-
];
|
|
584
|
-
const LARGE_DECLARATION_LINES = 5;
|
|
585
|
-
const isPrimitive = (type) => Primitives.includes(type);
|
|
586
|
-
const isArrayOfPrimitives = (type) => Primitives.map((p) => `${p}[]`).includes(type);
|
|
587
|
-
const stripSpaces = (typings) => typings.replace(/ +/g, " ").trim();
|
|
588
|
-
var KeyValue = class {
|
|
589
|
-
key;
|
|
590
|
-
value;
|
|
591
|
-
constructor(key, value) {
|
|
592
|
-
this.key = key;
|
|
593
|
-
this.value = value;
|
|
594
|
-
}
|
|
595
|
-
};
|
|
596
|
-
var FnParameters = class {
|
|
597
|
-
schema;
|
|
598
|
-
constructor(schema) {
|
|
599
|
-
this.schema = schema;
|
|
600
|
-
}
|
|
601
|
-
};
|
|
602
|
-
var FnReturn = class {
|
|
603
|
-
schema;
|
|
604
|
-
constructor(schema) {
|
|
605
|
-
this.schema = schema;
|
|
606
|
-
}
|
|
607
|
-
};
|
|
608
|
-
var Declaration = class {
|
|
609
|
-
schema;
|
|
610
|
-
identifier;
|
|
611
|
-
constructor(schema, identifier) {
|
|
612
|
-
this.schema = schema;
|
|
613
|
-
this.identifier = identifier;
|
|
568
|
+
var typings_exports = /* @__PURE__ */ require_utils.__exportAll({
|
|
569
|
+
getTypings: () => getTypings,
|
|
570
|
+
schemaToTypeScript: () => schemaToTypeScript
|
|
571
|
+
});
|
|
572
|
+
/** One schema renderer for API inputs, results, and memory properties. */
|
|
573
|
+
function schemaToTypeScript(schema) {
|
|
574
|
+
if (_bpinternal_zui.z.is.zuiDefault(schema)) return schemaToTypeScript(schema._def.innerType);
|
|
575
|
+
const options = { treatDefaultAsOptional: true };
|
|
576
|
+
try {
|
|
577
|
+
return _bpinternal_zui.transforms.toTypescriptType(schema, options);
|
|
578
|
+
} catch {
|
|
579
|
+
const normalized = require_utils.fromJSONSchemaCompat(_bpinternal_zui.transforms.toJSONSchemaLegacy(schema));
|
|
580
|
+
return _bpinternal_zui.transforms.toTypescriptType(normalized, options);
|
|
614
581
|
}
|
|
615
|
-
};
|
|
616
|
-
async function getTypings(schema, options) {
|
|
617
|
-
options ??= {};
|
|
618
|
-
options.declaration ??= false;
|
|
619
|
-
let wrappedSchema = schema;
|
|
620
|
-
if ((options === null || options === void 0 ? void 0 : options.declaration) && _bpinternal_zui.z.is.zuiType(schema)) {
|
|
621
|
-
const title = "title" in schema.ui ? schema.ui.title : null;
|
|
622
|
-
if (!title) throw new Error("Only schemas with \"title\" Zui property can be declared.");
|
|
623
|
-
wrappedSchema = new Declaration(schema, title);
|
|
624
|
-
}
|
|
625
|
-
let dts = await sUnwrapZodRecursive(wrappedSchema, { ...options });
|
|
626
|
-
dts = await formatTypings(dts, { throwOnError: false });
|
|
627
|
-
return dts;
|
|
628
582
|
}
|
|
629
|
-
|
|
630
|
-
|
|
583
|
+
function describeParameter(parameter, index) {
|
|
584
|
+
var _parameter$ui;
|
|
585
|
+
const name = require_utils.toPropertyKey(((_parameter$ui = parameter.ui) === null || _parameter$ui === void 0 ? void 0 : _parameter$ui.title) ?? `arg${index}`);
|
|
586
|
+
const optional = _bpinternal_zui.z.is.zuiOptional(parameter) || _bpinternal_zui.z.is.zuiDefault(parameter);
|
|
587
|
+
let value = parameter;
|
|
588
|
+
while (_bpinternal_zui.z.is.zuiOptional(value) || _bpinternal_zui.z.is.zuiDefault(value)) value = value._def.innerType;
|
|
589
|
+
return `${require_utils.getMultilineComment(parameter.description)}${name}${optional ? "?" : ""}: ${schemaToTypeScript(value.describe(""))}`;
|
|
631
590
|
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
const typings = await sUnwrapZodRecursive(schema.schema.describe(""), {
|
|
641
|
-
...newOptions,
|
|
642
|
-
declaration: true
|
|
643
|
-
});
|
|
644
|
-
const closingTag = typings.split("\n").length >= LARGE_DECLARATION_LINES ? `// end of ${schema.identifier}` : "";
|
|
645
|
-
if (_bpinternal_zui.z.is.zuiFunction(schema.schema)) return stripSpaces(`${description}
|
|
646
|
-
declare function ${schema.identifier}${typings};${closingTag}`);
|
|
647
|
-
return stripSpaces(`${description}
|
|
648
|
-
declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
649
|
-
}
|
|
650
|
-
if (schema instanceof KeyValue) {
|
|
651
|
-
if (_bpinternal_zui.z.is.zuiOptional(schema.value) || _bpinternal_zui.z.is.zuiDefault(schema.value)) {
|
|
652
|
-
let innerType = schema.value._def.innerType;
|
|
653
|
-
if (_bpinternal_zui.z.is.zuiType(innerType) && !innerType.description && schema.value.description) innerType = innerType === null || innerType === void 0 ? void 0 : innerType.describe(schema.value.description);
|
|
654
|
-
const optionalToken = schema.key.endsWith("?") ? "" : "?";
|
|
655
|
-
return sUnwrapZodRecursive(new KeyValue(schema.key + optionalToken, innerType), newOptions);
|
|
656
|
-
}
|
|
657
|
-
const description = require_utils.getMultilineComment(schema.value._def.description || schema.value.description);
|
|
658
|
-
const delimiter = (description === null || description === void 0 ? void 0 : description.trim().length) > 0 ? "\n" : "";
|
|
659
|
-
const withoutDesc = schema.value.describe("");
|
|
660
|
-
return `${delimiter}${description}${delimiter}${schema.key}: ${await sUnwrapZodRecursive(withoutDesc, newOptions)}${delimiter}`;
|
|
661
|
-
}
|
|
662
|
-
if (schema instanceof FnParameters) {
|
|
663
|
-
if (_bpinternal_zui.z.is.zuiTuple(schema.schema)) {
|
|
664
|
-
let args = "";
|
|
665
|
-
for (let i = 0; i < schema.schema.items.length; i++) {
|
|
666
|
-
var _schema$schema$items$;
|
|
667
|
-
const argName = ((_schema$schema$items$ = schema.schema.items[i]) === null || _schema$schema$items$ === void 0 || (_schema$schema$items$ = _schema$schema$items$.ui) === null || _schema$schema$items$ === void 0 ? void 0 : _schema$schema$items$.title) ?? `arg${i}`;
|
|
668
|
-
const item = schema.schema.items[i];
|
|
669
|
-
args += `${await sUnwrapZodRecursive(new KeyValue(require_utils.toPropertyKey(argName), item), newOptions)}, `;
|
|
670
|
-
}
|
|
671
|
-
return args;
|
|
672
|
-
}
|
|
673
|
-
const isLiteral = _bpinternal_zui.z.is.zuiLiteral(schema.schema.naked());
|
|
674
|
-
const typings = (await sUnwrapZodRecursive(schema.schema, newOptions)).trim();
|
|
675
|
-
if (typings.startsWith("{") && typings.endsWith("}") || typings.startsWith("[") && typings.endsWith("]") || typings.startsWith("(") && typings.endsWith(")") || typings.startsWith("Array<") && typings.endsWith(">") || typings.startsWith("Record<") && typings.endsWith(">") || isArrayOfPrimitives(typings) || isLiteral) return `args: ${typings}`;
|
|
676
|
-
else return typings;
|
|
677
|
-
}
|
|
678
|
-
if (schema instanceof FnReturn) {
|
|
679
|
-
if (_bpinternal_zui.z.is.zuiOptional(schema.schema)) return `${await sUnwrapZodRecursive(schema.schema.unwrap(), newOptions)} | undefined`;
|
|
680
|
-
return sUnwrapZodRecursive(schema.schema, newOptions);
|
|
681
|
-
}
|
|
682
|
-
if (schema === null) return "unknown";
|
|
683
|
-
if (_bpinternal_zui.z.is.zuiDefault(schema)) return sUnwrapZodRecursive(schema._def.innerType, options);
|
|
684
|
-
if (_bpinternal_zui.z.is.zuiVoid(schema)) return "void";
|
|
685
|
-
if (_bpinternal_zui.z.is.zuiUnknown(schema)) return "unknown";
|
|
686
|
-
if (_bpinternal_zui.z.is.zuiAny(schema)) return "any";
|
|
687
|
-
if (_bpinternal_zui.z.is.zuiPromise(schema)) return `Promise<${await sUnwrapZodRecursive(schema.unwrap(), newOptions)}>`;
|
|
591
|
+
/** Preserve declaration names and parameter labels; Zui renders every value type. */
|
|
592
|
+
async function getTypings(schema, options = {}) {
|
|
593
|
+
var _schema$ui;
|
|
594
|
+
if (!options.declaration) return formatTypings(schemaToTypeScript(schema), { throwOnError: false });
|
|
595
|
+
const title = (_schema$ui = schema.ui) === null || _schema$ui === void 0 ? void 0 : _schema$ui.title;
|
|
596
|
+
if (typeof title !== "string" || !title) throw new require_errors.InvalidConfigurationError("Only schemas with \"title\" Zui property can be declared.");
|
|
597
|
+
const description = require_utils.getMultilineComment(schema.description);
|
|
598
|
+
let declaration;
|
|
688
599
|
if (_bpinternal_zui.z.is.zuiFunction(schema)) {
|
|
689
|
-
const
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
(${input}): ${output}`;
|
|
694
|
-
return `${description}
|
|
695
|
-
(${input}) => ${output}`;
|
|
696
|
-
}
|
|
697
|
-
if (_bpinternal_zui.z.is.zuiArray(schema)) {
|
|
698
|
-
const item = await sUnwrapZodRecursive(schema._def.type, newOptions);
|
|
699
|
-
if (isPrimitive(item)) return `${item}[]`;
|
|
700
|
-
return `Array<${item}>`;
|
|
701
|
-
}
|
|
702
|
-
if (_bpinternal_zui.z.is.zuiEnum(schema)) return schema._def.values.map(require_utils.escapeString).join(" | ");
|
|
703
|
-
if (_bpinternal_zui.z.is.zuiTuple(schema)) {
|
|
704
|
-
if (schema.items.length === 0) return "[]";
|
|
705
|
-
return `[${(await Promise.all(schema.items.map((i) => sUnwrapZodRecursive(i, newOptions)))).join(", ")}]`;
|
|
706
|
-
}
|
|
707
|
-
if (_bpinternal_zui.z.is.zuiNullable(schema)) return `${await sUnwrapZodRecursive(schema.unwrap(), options)} | null`;
|
|
708
|
-
if (_bpinternal_zui.z.is.zuiOptional(schema)) {
|
|
709
|
-
if ((options === null || options === void 0 ? void 0 : options.declaration) || _bpinternal_zui.z.is.zuiType(options === null || options === void 0 ? void 0 : options.parent) && options.parent.typeName === "ZodRecord") return `${await sUnwrapZodRecursive(schema._def.innerType, newOptions)} | undefined`;
|
|
710
|
-
const optionalToken = options.parent instanceof KeyValue ? "| undefined" : "";
|
|
711
|
-
return `${await sUnwrapZodRecursive(schema._def.innerType, newOptions)}${optionalToken}`;
|
|
712
|
-
}
|
|
713
|
-
if (_bpinternal_zui.z.is.zuiObject(schema)) return `{ ${(await Promise.all(Object.entries(schema.shape).map(async ([key, value]) => {
|
|
714
|
-
if (_bpinternal_zui.z.is.zuiType(value)) return sUnwrapZodRecursive(new KeyValue(require_utils.toPropertyKey(key), value), newOptions);
|
|
715
|
-
return `${key}: unknown`;
|
|
716
|
-
}))).join("; ")} }`;
|
|
717
|
-
if (_bpinternal_zui.z.is.zuiString(schema)) return `${require_utils.getMultilineComment(schema._def.description)} string`.trim();
|
|
718
|
-
if (_bpinternal_zui.z.is.zuiUnion(schema)) return `${require_utils.getMultilineComment(schema._def.description)}
|
|
719
|
-
${(await Promise.all(schema.options.map(async (option) => {
|
|
720
|
-
return sUnwrapZodRecursive(option, newOptions);
|
|
721
|
-
}))).join(" | ")}`;
|
|
722
|
-
if (_bpinternal_zui.z.is.zuiLiteral(schema)) return `${require_utils.getMultilineComment(schema._def.description)}
|
|
723
|
-
${typeof schema.value === "string" ? require_utils.escapeString(schema.value) : String(schema.value)}`.trim();
|
|
724
|
-
if (_bpinternal_zui.z.is.zuiNumber(schema)) return `${require_utils.getMultilineComment(schema._def.description)} number`.trim();
|
|
725
|
-
if (_bpinternal_zui.z.is.zuiBoolean(schema)) return `${require_utils.getMultilineComment(schema._def.description)} boolean`.trim();
|
|
726
|
-
if (_bpinternal_zui.z.is.zuiCatch(schema)) return sUnwrapZodRecursive(schema.removeCatch(), newOptions);
|
|
727
|
-
if (_bpinternal_zui.z.is.zuiLazy(schema)) return sUnwrapZodRecursive(schema._def.getter(), newOptions);
|
|
728
|
-
if (_bpinternal_zui.z.is.zuiRecord(schema)) return `${require_utils.getMultilineComment(schema._def.description)} { [key: (${await sUnwrapZodRecursive(schema._def.keyType, newOptions)})]: (${await sUnwrapZodRecursive(schema._def.valueType, newOptions)}) }`;
|
|
729
|
-
try {
|
|
730
|
-
let typings = schema === null || schema === void 0 ? void 0 : schema.toTypescriptType({ treatDefaultAsOptional: true });
|
|
731
|
-
typings ??= "unknown";
|
|
732
|
-
return stripSpaces(typings);
|
|
733
|
-
} catch (error) {
|
|
734
|
-
console.error("Error in sUnwrapZod", {
|
|
735
|
-
error,
|
|
736
|
-
schema,
|
|
737
|
-
parent: options === null || options === void 0 ? void 0 : options.parent
|
|
738
|
-
});
|
|
739
|
-
return "unknown";
|
|
740
|
-
}
|
|
600
|
+
const input = schema.parameters();
|
|
601
|
+
declaration = `declare function ${title}(${_bpinternal_zui.z.is.zuiTuple(input) ? input.items.map(describeParameter).join(", ") : `args: ${schemaToTypeScript(input)}`}): ${schemaToTypeScript(schema.returnType())};`;
|
|
602
|
+
} else declaration = `declare const ${title}: ${schemaToTypeScript(schema.describe(""))};`;
|
|
603
|
+
return formatTypings(`${description}\n${declaration}`, { throwOnError: false });
|
|
741
604
|
}
|
|
742
605
|
//#endregion
|
|
743
606
|
Object.defineProperty(exports, "formatTypings", {
|
|
@@ -752,28 +615,10 @@ Object.defineProperty(exports, "getTypings", {
|
|
|
752
615
|
return getTypings;
|
|
753
616
|
}
|
|
754
617
|
});
|
|
755
|
-
Object.defineProperty(exports, "
|
|
756
|
-
enumerable: true,
|
|
757
|
-
get: function() {
|
|
758
|
-
return isGroup;
|
|
759
|
-
}
|
|
760
|
-
});
|
|
761
|
-
Object.defineProperty(exports, "isPunct", {
|
|
762
|
-
enumerable: true,
|
|
763
|
-
get: function() {
|
|
764
|
-
return isPunct;
|
|
765
|
-
}
|
|
766
|
-
});
|
|
767
|
-
Object.defineProperty(exports, "parse", {
|
|
768
|
-
enumerable: true,
|
|
769
|
-
get: function() {
|
|
770
|
-
return parse;
|
|
771
|
-
}
|
|
772
|
-
});
|
|
773
|
-
Object.defineProperty(exports, "tokenize", {
|
|
618
|
+
Object.defineProperty(exports, "schemaToTypeScript", {
|
|
774
619
|
enumerable: true,
|
|
775
620
|
get: function() {
|
|
776
|
-
return
|
|
621
|
+
return schemaToTypeScript;
|
|
777
622
|
}
|
|
778
623
|
});
|
|
779
624
|
Object.defineProperty(exports, "typings_exports", {
|