llmz 0.7.1 → 0.9.0
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 +45 -11
- package/dist/{_baseForOwn-buOZDFbK.cjs → _baseForOwn-BfWDTL8L.cjs} +0 -50
- package/dist/chat.d.ts +6 -6
- package/dist/common-BlRFtdf2.js +807 -0
- package/dist/common-BnvrDnIT.cjs +860 -0
- package/dist/compiler-C-OI9sim.cjs +547 -0
- package/dist/compiler-CW1VjQsn.js +473 -0
- package/dist/{component-BwixNVH8.cjs → component-C6Agl2ns.cjs} +3 -3
- package/dist/component.d.ts +4 -4
- package/dist/component.default.d.ts +70 -87
- package/dist/component.default.test.d.ts +1 -0
- package/dist/context.d.ts +14 -8
- package/dist/{custom-client-CMuy7fXU.js → custom-client-ChuZ63zp.js} +128 -30
- package/dist/{custom-client-Bp1TgTKk.cjs → custom-client-DAsGRnYc.cjs} +131 -33
- package/dist/{dual-modes-mNyMThtf.js → dual-modes-DDkoCp3R.js} +1771 -1489
- package/dist/{dual-modes-CfqTk9M8.cjs → dual-modes-DPXiuvNe.cjs} +1767 -1491
- package/dist/example-format.d.ts +8 -0
- package/dist/example.d.ts +45 -0
- package/dist/example.test.d.ts +1 -0
- package/dist/{execute-DP_17lYZ.js → execute-BWcdv9so.js} +77 -85
- package/dist/{execute-msui51b2.cjs → execute-DM2-7y86.cjs} +83 -92
- package/dist/{exit-BGi0Kk0y.cjs → exit-DUM96DN1.cjs} +3 -3
- package/dist/exit-parser.d.ts +2 -0
- package/dist/index.cjs +137 -217
- package/dist/index.d.ts +2 -0
- package/dist/index.js +115 -196
- package/dist/index.workerd.js +16664 -15533
- package/dist/inspect.d.ts +2 -0
- package/dist/{jsx-BWvT6ukg.cjs → jsx-owqxrquU.cjs} +2 -2
- package/dist/message-stream/instructions.d.ts +8 -0
- package/dist/message-stream/parser.d.ts +9 -0
- package/dist/message-stream/response-parser.d.ts +24 -0
- package/dist/message-stream/response-parser.test.d.ts +1 -0
- package/dist/message-stream/types.d.ts +3 -2
- package/dist/prompts/adherence.test.d.ts +1 -0
- package/dist/prompts/catalogue-examples.test.d.ts +1 -0
- package/dist/prompts/chat-mode/protocol.d.ts +2 -0
- package/dist/prompts/chat-mode/system.d.ts +2 -0
- package/dist/prompts/chat-mode/user.d.ts +2 -0
- package/dist/prompts/code-examples.d.ts +2 -0
- package/dist/prompts/code-examples.test.d.ts +1 -0
- package/dist/prompts/common.d.ts +2 -1
- package/dist/prompts/concrete-patterns.test.d.ts +1 -0
- package/dist/prompts/execution-history.d.ts +6 -0
- package/dist/prompts/execution-state.d.ts +3 -0
- package/dist/prompts/long-search.test.d.ts +1 -0
- package/dist/prompts/prompt.d.ts +31 -2
- package/dist/prompts/protocol-basics.d.ts +5 -0
- package/dist/prompts/protocol-simple.test.d.ts +1 -0
- package/dist/prompts/protocol.d.ts +13 -0
- package/dist/prompts/protocol.test.d.ts +1 -0
- package/dist/prompts/sections.test.d.ts +1 -0
- package/dist/prompts/worker-mode/protocol.d.ts +2 -0
- package/dist/prompts/worker-mode/system.d.ts +2 -0
- package/dist/prompts/worker-mode/user.d.ts +2 -0
- package/dist/runtime/citations.test.d.ts +1 -0
- package/dist/runtime/fixtures/long-search.d.ts +19 -0
- package/dist/runtime/fixtures/protocol-languages.d.ts +74 -0
- package/dist/runtime/fixtures/qwen-protocol-failures.d.ts +29 -0
- package/dist/runtime/generate.d.ts +2 -9
- package/dist/runtime/protocol-adherence.test.d.ts +1 -0
- package/dist/runtime/types.d.ts +13 -7
- package/dist/{tool-ReA9gxMp.cjs → tool-Dy6AJpJH.cjs} +4 -4
- package/dist/{truncator-B6aaJaN1.cjs → truncator-CLkouTCO.cjs} +3 -3
- package/dist/{typings-BwAz_TM9.cjs → typings-3lsqCbkn.cjs} +3 -3
- package/dist/{utils-ZpJm00ed.cjs → utils-3ESwP3yg.cjs} +2 -2
- package/dist/{vm-C5vf1LH3.js → vm-BLsHw1da.js} +3 -462
- package/dist/{vm-BjkJqSQH.cjs → vm-D6s1zF6M.cjs} +28 -489
- package/package.json +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
const require_dual_modes = require("./dual-modes-DPXiuvNe.cjs");
|
|
1
2
|
const require__overArg = require("./_overArg-C5Hy7oCi.cjs");
|
|
2
3
|
const require__baseIteratee = require("./_baseIteratee-CF4qP2a8.cjs");
|
|
3
|
-
const
|
|
4
|
-
const require_utils = require("./utils-ZpJm00ed.cjs");
|
|
4
|
+
const require_utils = require("./utils-3ESwP3yg.cjs");
|
|
5
5
|
const require__getPrototype = require("./_getPrototype-DQDlNVVM.cjs");
|
|
6
6
|
const require_isPlainObject = require("./isPlainObject-CSxXVKCk.cjs");
|
|
7
|
-
const require_tool = require("./tool-
|
|
7
|
+
const require_tool = require("./tool-Dy6AJpJH.cjs");
|
|
8
8
|
const require_errors = require("./errors-C962uJdS.cjs");
|
|
9
|
-
const require_exit = require("./exit-
|
|
10
|
-
const require_component = require("./component-
|
|
11
|
-
const require_truncator = require("./truncator-
|
|
9
|
+
const require_exit = require("./exit-DUM96DN1.cjs");
|
|
10
|
+
const require_component = require("./component-C6Agl2ns.cjs");
|
|
11
|
+
const require_truncator = require("./truncator-CLkouTCO.cjs");
|
|
12
12
|
let _bpinternal_zui = require("@bpinternal/zui");
|
|
13
13
|
let ulid = require("ulid");
|
|
14
14
|
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayEach.js
|
|
@@ -819,7 +819,8 @@ function parseExit(returnValue, exits) {
|
|
|
819
819
|
}
|
|
820
820
|
const schema = returnExit.zSchema;
|
|
821
821
|
const schemaType = schema._def.typeName;
|
|
822
|
-
|
|
822
|
+
const initialParse = schema.safeParse(valueToValidate);
|
|
823
|
+
let parsed = initialParse;
|
|
823
824
|
if (!parsed.success && alternativeValue !== void 0 && alternativeValue !== valueToValidate) {
|
|
824
825
|
const altParsed = schema.safeParse(alternativeValue);
|
|
825
826
|
if (altParsed.success) {
|
|
@@ -833,6 +834,7 @@ function parseExit(returnValue, exits) {
|
|
|
833
834
|
parsed = result.parsed;
|
|
834
835
|
}
|
|
835
836
|
if (!parsed.success) {
|
|
837
|
+
var _initialParse$error;
|
|
836
838
|
const getValueTypeDescription = (val) => {
|
|
837
839
|
if (val === null) return "null";
|
|
838
840
|
if (val === void 0) return "undefined";
|
|
@@ -894,6 +896,7 @@ function parseExit(returnValue, exits) {
|
|
|
894
896
|
"But expected one of:",
|
|
895
897
|
...expectedStatements.map((s) => ` ${s}`)
|
|
896
898
|
].join("\n"),
|
|
899
|
+
validationErrors: (((_initialParse$error = initialParse.error) === null || _initialParse$error === void 0 ? void 0 : _initialParse$error.issues) ?? []).map((issue) => `${issue.path.join(".") || "value"}: ${issue.message}`),
|
|
897
900
|
returnValue
|
|
898
901
|
};
|
|
899
902
|
}
|
|
@@ -1788,6 +1791,49 @@ var HookedArray = class extends Array {
|
|
|
1788
1791
|
}
|
|
1789
1792
|
};
|
|
1790
1793
|
//#endregion
|
|
1794
|
+
//#region src/prompts/execution-history.ts
|
|
1795
|
+
function describeOutcome(status) {
|
|
1796
|
+
switch (status.type) {
|
|
1797
|
+
case "thinking_requested": return status.thinking_requested.interrupted ? "a tool paused execution" : "code completed and returned control";
|
|
1798
|
+
case "execution_error": return "code execution failed";
|
|
1799
|
+
case "invalid_code_error": return "invalid code or protocol";
|
|
1800
|
+
case "exit_error": return "exit validation failed";
|
|
1801
|
+
default: return status.type;
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
/** Summarize observed effects, including failed calls and retracted deliveries. */
|
|
1805
|
+
function summarizeIterations(iterations, canTalk) {
|
|
1806
|
+
const history = [];
|
|
1807
|
+
const attempts = /* @__PURE__ */ new Map();
|
|
1808
|
+
const deliveredMessages = [];
|
|
1809
|
+
for (const [index, iteration] of iterations.entries()) {
|
|
1810
|
+
const calls = [];
|
|
1811
|
+
const lastRestart = iteration.traces.reduce((last, trace, traceIndex) => trace.type === "llm_call_restarted" ? traceIndex : last, -1);
|
|
1812
|
+
for (const [traceIndex, trace] of iteration.traces.entries()) {
|
|
1813
|
+
if (trace.type === "tool_call") {
|
|
1814
|
+
const name = trace.object ? `${trace.object}.${trace.tool_name}` : trace.tool_name;
|
|
1815
|
+
let outcome = "failed or paused";
|
|
1816
|
+
if (trace.success) outcome = trace.output instanceof require_errors.ThinkSignal ? "paused for attention" : "succeeded";
|
|
1817
|
+
attempts.set(name, (attempts.get(name) ?? 0) + 1);
|
|
1818
|
+
calls.push(`${name}: ${outcome}`);
|
|
1819
|
+
}
|
|
1820
|
+
if (canTalk && trace.type === "yield") deliveredMessages.push({
|
|
1821
|
+
iteration: index + 1,
|
|
1822
|
+
content: trace.value,
|
|
1823
|
+
...traceIndex < lastRestart ? { retracted: true } : {}
|
|
1824
|
+
});
|
|
1825
|
+
}
|
|
1826
|
+
const outcome = describeOutcome(iteration.status);
|
|
1827
|
+
const toolSummary = calls.length ? ` Tool attempts: ${calls.join("; ")}.` : "";
|
|
1828
|
+
history.push(`Iteration ${index + 1}: ${outcome}.${toolSummary}`);
|
|
1829
|
+
}
|
|
1830
|
+
return {
|
|
1831
|
+
history,
|
|
1832
|
+
toolAttempts: Object.fromEntries(attempts),
|
|
1833
|
+
deliveredMessages: canTalk ? deliveredMessages : void 0
|
|
1834
|
+
};
|
|
1835
|
+
}
|
|
1836
|
+
//#endregion
|
|
1791
1837
|
//#region src/transcript.ts
|
|
1792
1838
|
const MAX_MESSAGE_LENGTH = 5e3;
|
|
1793
1839
|
function getMessagePreview(message) {
|
|
@@ -1991,7 +2037,7 @@ const ThinkExit = new require_exit.Exit({
|
|
|
1991
2037
|
*/
|
|
1992
2038
|
const ListenExit = new require_exit.Exit({
|
|
1993
2039
|
name: "listen",
|
|
1994
|
-
description: "
|
|
2040
|
+
description: "Stop talking and wait for the user to talk next."
|
|
1995
2041
|
});
|
|
1996
2042
|
/**
|
|
1997
2043
|
* Default exit used when no custom exits are provided.
|
|
@@ -2117,6 +2163,9 @@ var Iteration = class {
|
|
|
2117
2163
|
this._mutations.set(`${mutation.object ?? "global"}:${mutation.property}`, mutation);
|
|
2118
2164
|
}
|
|
2119
2165
|
_parameters;
|
|
2166
|
+
get components() {
|
|
2167
|
+
return this._parameters.components;
|
|
2168
|
+
}
|
|
2120
2169
|
get transcript() {
|
|
2121
2170
|
return this._parameters.transcript;
|
|
2122
2171
|
}
|
|
@@ -2234,6 +2283,7 @@ var Context = class {
|
|
|
2234
2283
|
id;
|
|
2235
2284
|
chat;
|
|
2236
2285
|
instructions;
|
|
2286
|
+
examples;
|
|
2237
2287
|
objects;
|
|
2238
2288
|
tools;
|
|
2239
2289
|
exits;
|
|
@@ -2254,14 +2304,10 @@ var Context = class {
|
|
|
2254
2304
|
*/
|
|
2255
2305
|
maxTimeToFirstToken;
|
|
2256
2306
|
/**
|
|
2257
|
-
* Allow Cognitive to restart a failed stream on another model.
|
|
2258
|
-
*
|
|
2259
|
-
*
|
|
2260
|
-
*
|
|
2261
|
-
* current-iteration messages, including completed sends — consumers must
|
|
2262
|
-
* retract/replace them, which is unsafe for irreversible external transports.
|
|
2263
|
-
* Only TOOL/CODE execution waits for a successful stream. Streaming-only;
|
|
2264
|
-
* defaults to false, which leaves progressive sending unchanged.
|
|
2307
|
+
* Allow Cognitive to restart a failed stream on another model. Previews remain
|
|
2308
|
+
* live and are retracted with a restart delta before replacement output.
|
|
2309
|
+
* Completed sends and code always wait for a valid response and successful
|
|
2310
|
+
* transport. Streaming-only; defaults to false.
|
|
2265
2311
|
*/
|
|
2266
2312
|
midStreamFallback;
|
|
2267
2313
|
/**
|
|
@@ -2271,6 +2317,7 @@ var Context = class {
|
|
|
2271
2317
|
transcriptionModel;
|
|
2272
2318
|
metadata;
|
|
2273
2319
|
snapshot;
|
|
2320
|
+
_lastMessageWithoutExecutionState;
|
|
2274
2321
|
iteration = 0;
|
|
2275
2322
|
iterations;
|
|
2276
2323
|
async nextIteration() {
|
|
@@ -2329,18 +2376,20 @@ var Context = class {
|
|
|
2329
2376
|
const tools = countText(parts.tools);
|
|
2330
2377
|
const transcript = countText(parts.transcript);
|
|
2331
2378
|
const protocol = countText(parts.protocol);
|
|
2379
|
+
const examples = countText(parts.examples);
|
|
2332
2380
|
const systemTokens = messages.filter((x) => x.role === "system").reduce((acc, x) => acc + countMessage(x), 0);
|
|
2333
2381
|
const otherTokens = messages.filter((x) => x.role !== "system").reduce((acc, x) => acc + countMessage(x), 0);
|
|
2334
2382
|
const isFirstIteration = this.iterations.length === 0 && !this.snapshot;
|
|
2335
|
-
const framework = Math.max(0, systemTokens - (instructions + tools + transcript + protocol));
|
|
2383
|
+
const framework = Math.max(0, systemTokens - (instructions + tools + transcript + protocol + examples));
|
|
2336
2384
|
const iterations = isFirstIteration ? 0 : otherTokens;
|
|
2337
2385
|
return {
|
|
2338
|
-
total: framework + instructions + tools + transcript + protocol + iterations + (isFirstIteration ? otherTokens : 0),
|
|
2386
|
+
total: framework + instructions + tools + transcript + protocol + examples + iterations + (isFirstIteration ? otherTokens : 0),
|
|
2339
2387
|
framework: framework + (isFirstIteration ? otherTokens : 0),
|
|
2340
2388
|
instructions,
|
|
2341
2389
|
tools,
|
|
2342
2390
|
transcript,
|
|
2343
2391
|
protocol,
|
|
2392
|
+
examples,
|
|
2344
2393
|
iterations
|
|
2345
2394
|
};
|
|
2346
2395
|
}
|
|
@@ -2348,24 +2397,50 @@ var Context = class {
|
|
|
2348
2397
|
var _this$snapshot2, _this$snapshot3;
|
|
2349
2398
|
const lastIteration = this.iterations.at(-1);
|
|
2350
2399
|
const promptProps = {
|
|
2400
|
+
iteration: {
|
|
2401
|
+
current: this.iterations.length + 1,
|
|
2402
|
+
limit: this.loop,
|
|
2403
|
+
resumed: !!this.snapshot,
|
|
2404
|
+
...summarizeIterations(this.iterations, parameters.components.length > 0)
|
|
2405
|
+
},
|
|
2351
2406
|
globalTools: parameters.tools,
|
|
2352
2407
|
objects: parameters.objects,
|
|
2353
2408
|
instructions: parameters.instructions,
|
|
2409
|
+
examples: parameters.examples,
|
|
2354
2410
|
transcript: parameters.transcript,
|
|
2355
2411
|
exits: parameters.components.length ? [...parameters.exits, ListenExit] : parameters.exits,
|
|
2356
2412
|
components: parameters.components
|
|
2357
2413
|
};
|
|
2358
2414
|
const { message: systemMessage, parts } = await this.version.getSystemMessage(promptProps);
|
|
2359
|
-
const
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2415
|
+
const previousLastMessage = this._lastMessageWithoutExecutionState;
|
|
2416
|
+
const withParts = (messages) => {
|
|
2417
|
+
var _this$version$getExec, _this$version;
|
|
2418
|
+
const last = messages.at(-1);
|
|
2419
|
+
this._lastMessageWithoutExecutionState = last;
|
|
2420
|
+
const state = ((_this$version$getExec = (_this$version = this.version).getExecutionState) === null || _this$version$getExec === void 0 ? void 0 : _this$version$getExec.call(_this$version, promptProps)) ?? "";
|
|
2421
|
+
if (state) messages[messages.length - 1] = Array.isArray(last.content) ? {
|
|
2422
|
+
...last,
|
|
2423
|
+
content: [...last.content, {
|
|
2424
|
+
type: "text",
|
|
2425
|
+
text: state.trim()
|
|
2426
|
+
}]
|
|
2427
|
+
} : {
|
|
2428
|
+
...last,
|
|
2429
|
+
content: (last.content ?? "") + state
|
|
2430
|
+
};
|
|
2431
|
+
return {
|
|
2432
|
+
messages,
|
|
2433
|
+
parts
|
|
2434
|
+
};
|
|
2435
|
+
};
|
|
2363
2436
|
if (((_this$snapshot2 = this.snapshot) === null || _this$snapshot2 === void 0 ? void 0 : _this$snapshot2.status.type) === "resolved") return withParts([systemMessage, this.version.getSnapshotResolvedMessage({ snapshot: this.snapshot })]);
|
|
2364
2437
|
if (((_this$snapshot3 = this.snapshot) === null || _this$snapshot3 === void 0 ? void 0 : _this$snapshot3.status.type) === "rejected") return withParts([systemMessage, this.version.getSnapshotRejectedMessage({ snapshot: this.snapshot })]);
|
|
2365
2438
|
if (!lastIteration) return withParts([systemMessage, await this.version.getInitialUserMessage(promptProps)]);
|
|
2366
|
-
const
|
|
2439
|
+
const history = lastIteration.messages.slice();
|
|
2440
|
+
if (previousLastMessage) history[history.length - 1] = previousLastMessage;
|
|
2441
|
+
const lastIterationMessages = [systemMessage, ...history.filter((x) => x.role !== "system")];
|
|
2367
2442
|
if ((lastIteration === null || lastIteration === void 0 ? void 0 : lastIteration.status.type) === "thinking_requested") {
|
|
2368
|
-
var _lastIteration$llm;
|
|
2443
|
+
var _lastIteration$llm, _lastIteration$llm2;
|
|
2369
2444
|
return withParts([
|
|
2370
2445
|
...lastIterationMessages,
|
|
2371
2446
|
{
|
|
@@ -2377,60 +2452,80 @@ var Context = class {
|
|
|
2377
2452
|
})
|
|
2378
2453
|
},
|
|
2379
2454
|
await this.version.getThinkingMessage({
|
|
2455
|
+
isChatEnabled: parameters.components.length > 0,
|
|
2380
2456
|
reason: lastIteration.status.thinking_requested.reason,
|
|
2381
|
-
variables: lastIteration.status.thinking_requested.variables
|
|
2457
|
+
variables: lastIteration.status.thinking_requested.variables,
|
|
2458
|
+
interrupted: lastIteration.status.thinking_requested.interrupted,
|
|
2459
|
+
discardedMessages: (_lastIteration$llm2 = lastIteration.llm) === null || _lastIteration$llm2 === void 0 || (_lastIteration$llm2 = _lastIteration$llm2.diagnostics) === null || _lastIteration$llm2 === void 0 ? void 0 : _lastIteration$llm2.some((diagnostic) => diagnostic.code === "send-after-run")
|
|
2382
2460
|
})
|
|
2383
2461
|
]);
|
|
2384
2462
|
}
|
|
2385
2463
|
if ((lastIteration === null || lastIteration === void 0 ? void 0 : lastIteration.status.type) === "exit_error") {
|
|
2386
|
-
var _lastIteration$
|
|
2464
|
+
var _lastIteration$llm3;
|
|
2387
2465
|
return withParts([
|
|
2388
2466
|
...lastIterationMessages,
|
|
2389
2467
|
{
|
|
2390
2468
|
role: "assistant",
|
|
2391
|
-
content: require_truncator.wrapContent(((_lastIteration$
|
|
2469
|
+
content: require_truncator.wrapContent(((_lastIteration$llm3 = lastIteration.llm) === null || _lastIteration$llm3 === void 0 ? void 0 : _lastIteration$llm3.output) ?? "", {
|
|
2392
2470
|
preserve: "top",
|
|
2393
2471
|
flex: 4,
|
|
2394
2472
|
minTokens: 25
|
|
2395
2473
|
})
|
|
2396
2474
|
},
|
|
2397
2475
|
await this.version.getInvalidCodeMessage({
|
|
2398
|
-
|
|
2399
|
-
|
|
2476
|
+
isChatEnabled: parameters.components.length > 0,
|
|
2477
|
+
code: lastIteration.next ? `■next=${lastIteration.next.name} ${JSON.stringify(lastIteration.next.props)}` : lastIteration.code ?? "// No code generated",
|
|
2478
|
+
message: `Invalid ■next block (${lastIteration.status.exit_error.exit}): ${lastIteration.status.exit_error.message}`,
|
|
2479
|
+
variables: lastIteration.variables,
|
|
2480
|
+
toolCalls: lastIteration.traces.filter((trace) => trace.type === "tool_call").map((trace) => ({
|
|
2481
|
+
tool: trace.tool_name,
|
|
2482
|
+
input: trace.input,
|
|
2483
|
+
success: trace.success,
|
|
2484
|
+
...trace.success ? { output: trace.output } : { error: require_utils.getErrorMessage(trace.error) }
|
|
2485
|
+
}))
|
|
2400
2486
|
})
|
|
2401
2487
|
]);
|
|
2402
2488
|
}
|
|
2403
2489
|
if ((lastIteration === null || lastIteration === void 0 ? void 0 : lastIteration.status.type) === "invalid_code_error") {
|
|
2404
|
-
var _lastIteration$
|
|
2490
|
+
var _lastIteration$llm4;
|
|
2405
2491
|
return withParts([
|
|
2406
2492
|
...lastIterationMessages,
|
|
2407
2493
|
{
|
|
2408
2494
|
role: "assistant",
|
|
2409
|
-
content: require_truncator.wrapContent(((_lastIteration$
|
|
2495
|
+
content: require_truncator.wrapContent(((_lastIteration$llm4 = lastIteration.llm) === null || _lastIteration$llm4 === void 0 ? void 0 : _lastIteration$llm4.output) ?? "", {
|
|
2410
2496
|
preserve: "top",
|
|
2411
2497
|
flex: 4,
|
|
2412
2498
|
minTokens: 25
|
|
2413
2499
|
})
|
|
2414
2500
|
},
|
|
2415
2501
|
await this.version.getInvalidCodeMessage({
|
|
2502
|
+
isChatEnabled: parameters.components.length > 0,
|
|
2416
2503
|
code: lastIteration.code ?? "// No code generated",
|
|
2417
2504
|
message: lastIteration.status.invalid_code_error.message
|
|
2418
2505
|
})
|
|
2419
2506
|
]);
|
|
2420
2507
|
}
|
|
2421
2508
|
if ((lastIteration === null || lastIteration === void 0 ? void 0 : lastIteration.status.type) === "execution_error") {
|
|
2422
|
-
var _lastIteration$
|
|
2509
|
+
var _lastIteration$llm5;
|
|
2423
2510
|
return withParts([
|
|
2424
2511
|
...lastIterationMessages,
|
|
2425
2512
|
{
|
|
2426
2513
|
role: "assistant",
|
|
2427
|
-
content: require_truncator.wrapContent(((_lastIteration$
|
|
2514
|
+
content: require_truncator.wrapContent(((_lastIteration$llm5 = lastIteration.llm) === null || _lastIteration$llm5 === void 0 ? void 0 : _lastIteration$llm5.output) ?? "", {
|
|
2428
2515
|
preserve: "top",
|
|
2429
2516
|
flex: 4,
|
|
2430
2517
|
minTokens: 25
|
|
2431
2518
|
})
|
|
2432
2519
|
},
|
|
2433
2520
|
await this.version.getCodeExecutionErrorMessage({
|
|
2521
|
+
isChatEnabled: parameters.components.length > 0,
|
|
2522
|
+
variables: lastIteration.variables,
|
|
2523
|
+
toolCalls: lastIteration.traces.filter((trace) => trace.type === "tool_call").map((trace) => ({
|
|
2524
|
+
tool: trace.tool_name,
|
|
2525
|
+
input: trace.input,
|
|
2526
|
+
success: trace.success,
|
|
2527
|
+
...trace.success ? { output: trace.output } : { error: require_utils.getErrorMessage(trace.error) }
|
|
2528
|
+
})),
|
|
2434
2529
|
message: lastIteration.status.execution_error.message,
|
|
2435
2530
|
stacktrace: lastIteration.status.execution_error.stack
|
|
2436
2531
|
})
|
|
@@ -2441,6 +2536,7 @@ var Context = class {
|
|
|
2441
2536
|
async _refreshIterationParameters() {
|
|
2442
2537
|
var _this$chat, _this$chat2;
|
|
2443
2538
|
const instructions = await getValue(this.instructions, this);
|
|
2539
|
+
const examples = await getValue(this.examples, this);
|
|
2444
2540
|
const transcript = new TranscriptArray(await getValue(((_this$chat = this.chat) === null || _this$chat === void 0 ? void 0 : _this$chat.transcript) ?? [], this));
|
|
2445
2541
|
const tools = require_tool.Tool.withUniqueNames(await getValue(this.tools, this) ?? []);
|
|
2446
2542
|
const objects = await getValue(this.objects, this) ?? [];
|
|
@@ -2497,6 +2593,7 @@ var Context = class {
|
|
|
2497
2593
|
objects,
|
|
2498
2594
|
exits,
|
|
2499
2595
|
instructions,
|
|
2596
|
+
examples,
|
|
2500
2597
|
components,
|
|
2501
2598
|
model,
|
|
2502
2599
|
temperature,
|
|
@@ -2506,6 +2603,7 @@ var Context = class {
|
|
|
2506
2603
|
constructor(props) {
|
|
2507
2604
|
this.id = `llmz_${(0, ulid.ulid)()}`;
|
|
2508
2605
|
this.instructions = props.instructions;
|
|
2606
|
+
this.examples = props.examples;
|
|
2509
2607
|
this.objects = props.objects;
|
|
2510
2608
|
this.tools = props.tools;
|
|
2511
2609
|
this.exits = props.exits;
|