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,18 +1,19 @@
|
|
|
1
|
-
const
|
|
2
|
-
const require_dual_modes = require("./dual-modes-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
1
|
+
const require_compiler = require("./compiler-C-OI9sim.cjs");
|
|
2
|
+
const require_dual_modes = require("./dual-modes-DPXiuvNe.cjs");
|
|
3
|
+
const require_common = require("./common-BnvrDnIT.cjs");
|
|
4
|
+
const require_custom_client = require("./custom-client-DAsGRnYc.cjs");
|
|
5
|
+
const require_utils = require("./utils-3ESwP3yg.cjs");
|
|
6
|
+
const require_jsx = require("./jsx-owqxrquU.cjs");
|
|
6
7
|
const require_stack_traces = require("./stack-traces-ntw_qhoy.cjs");
|
|
7
8
|
const require_errors = require("./errors-C962uJdS.cjs");
|
|
8
|
-
const require_truncator = require("./truncator-
|
|
9
|
-
const require_vm = require("./vm-
|
|
9
|
+
const require_truncator = require("./truncator-CLkouTCO.cjs");
|
|
10
|
+
const require_vm = require("./vm-D6s1zF6M.cjs");
|
|
10
11
|
let _bpinternal_zui = require("@bpinternal/zui");
|
|
11
12
|
let ulid = require("ulid");
|
|
12
13
|
let _botpress_client = require("@botpress/client");
|
|
13
14
|
let _botpress_cognitive = require("@botpress/cognitive");
|
|
14
15
|
let ms = require("ms");
|
|
15
|
-
ms =
|
|
16
|
+
ms = require_compiler.__toESM(ms, 1);
|
|
16
17
|
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseClamp.js
|
|
17
18
|
/**
|
|
18
19
|
* The base implementation of `_.clamp` which doesn't coerce arguments.
|
|
@@ -128,35 +129,7 @@ const assertSuccessfulGeneration = (metadata) => {
|
|
|
128
129
|
if (metadata.stopReason === "max_tokens" || metadata.stopReason === "content_filter") throw new require_errors.CognitiveError(`LLM generation did not complete: stopReason=${metadata.stopReason}`);
|
|
129
130
|
};
|
|
130
131
|
const getModelOutputLimit = (inputLength) => clamp(RESPONSE_LENGTH_BUFFER.PERCENTAGE * inputLength, RESPONSE_LENGTH_BUFFER.MIN_TOKENS, RESPONSE_LENGTH_BUFFER.MAX_TOKENS);
|
|
131
|
-
|
|
132
|
-
* Models sometimes wrap their whole response in a code fence. The fence has to
|
|
133
|
-
* be removed before it reaches the incremental parser to avoid a spurious
|
|
134
|
-
* unexpected-text diagnostic. Works on arbitrary chunk boundaries
|
|
135
|
-
* by holding content back until the first newline.
|
|
136
|
-
*/
|
|
137
|
-
var LeadingFenceFilter = class {
|
|
138
|
-
_buffer = "";
|
|
139
|
-
_done = false;
|
|
140
|
-
push(text) {
|
|
141
|
-
if (this._done) return text;
|
|
142
|
-
this._buffer += text;
|
|
143
|
-
const newline = this._buffer.indexOf("\n");
|
|
144
|
-
if (newline === -1) return "";
|
|
145
|
-
this._done = true;
|
|
146
|
-
const firstLine = this._buffer.slice(0, newline);
|
|
147
|
-
const rest = this._buffer.slice(newline + 1);
|
|
148
|
-
this._buffer = "";
|
|
149
|
-
return firstLine.trim().startsWith("```") ? rest : `${firstLine}\n${rest}`;
|
|
150
|
-
}
|
|
151
|
-
flush() {
|
|
152
|
-
if (this._done) return "";
|
|
153
|
-
this._done = true;
|
|
154
|
-
const buffered = this._buffer;
|
|
155
|
-
this._buffer = "";
|
|
156
|
-
return buffered.trim().startsWith("```") ? "" : buffered;
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
const generateCode = async ({ iteration, ctx, cognitive, controller, metadata, onSend, onSendDelta, onRunStart, onRunComplete }) => {
|
|
132
|
+
const generateCode = async ({ iteration, ctx, cognitive, controller, metadata, onSend, onSendDelta, onRunStart }) => {
|
|
160
133
|
const startedAt = Date.now();
|
|
161
134
|
const traces = iteration.traces;
|
|
162
135
|
const modelRef = Array.isArray(iteration.model) ? iteration.model[0] : iteration.model;
|
|
@@ -219,6 +192,7 @@ const generateCode = async ({ iteration, ctx, cognitive, controller, metadata, o
|
|
|
219
192
|
const liveContent = /* @__PURE__ */ new Map();
|
|
220
193
|
let codeGenerationTraced = false;
|
|
221
194
|
let runCompleted = false;
|
|
195
|
+
let completions = [];
|
|
222
196
|
const dispatchSends = async (events) => {
|
|
223
197
|
for (const event of events) if (event.type === "item-start") {
|
|
224
198
|
liveItems.set(event.item.id, event.item);
|
|
@@ -232,7 +206,7 @@ const generateCode = async ({ iteration, ctx, cognitive, controller, metadata, o
|
|
|
232
206
|
}
|
|
233
207
|
} else if (event.type === "body-delta" && onSendDelta) {
|
|
234
208
|
const item = liveItems.get(event.itemId);
|
|
235
|
-
if ((item === null || item === void 0 ? void 0 : item.kind) !== "send") continue;
|
|
209
|
+
if ((item === null || item === void 0 ? void 0 : item.kind) !== "send" || runCompleted) continue;
|
|
236
210
|
const content = (liveContent.get(item.id) ?? "") + event.delta;
|
|
237
211
|
liveContent.set(item.id, content);
|
|
238
212
|
const delta = {
|
|
@@ -245,21 +219,19 @@ const generateCode = async ({ iteration, ctx, cognitive, controller, metadata, o
|
|
|
245
219
|
};
|
|
246
220
|
await preview(delta);
|
|
247
221
|
} else if (event.type === "item-complete") {
|
|
248
|
-
if (event.item.kind === "send" && onSend)
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
222
|
+
if (event.item.kind === "send" && onSend && !runCompleted) {
|
|
223
|
+
const send = {
|
|
224
|
+
name: event.item.name,
|
|
225
|
+
props: event.item.props,
|
|
226
|
+
body: event.item.body
|
|
227
|
+
};
|
|
228
|
+
const metadata = messageMetadata(event.item.id);
|
|
229
|
+
completions.push(() => onSend(send, metadata));
|
|
230
|
+
} else if (event.item.kind === "run" && event.item.status === "complete" && !runCompleted) runCompleted = true;
|
|
258
231
|
}
|
|
259
232
|
};
|
|
260
233
|
if (typeof cognitive.generateTextStream === "function") {
|
|
261
|
-
let parser = new
|
|
262
|
-
let fence = new LeadingFenceFilter();
|
|
234
|
+
let parser = new require_common.ResponseParser();
|
|
263
235
|
const streamController = createJoinedAbortController([controller.signal]);
|
|
264
236
|
const requestedAt = Date.now();
|
|
265
237
|
const stream = cognitive.generateTextStream({
|
|
@@ -287,6 +259,7 @@ const generateCode = async ({ iteration, ctx, cognitive, controller, metadata, o
|
|
|
287
259
|
};
|
|
288
260
|
raw = "";
|
|
289
261
|
let streamCompleted = false;
|
|
262
|
+
let accepted = false;
|
|
290
263
|
try {
|
|
291
264
|
while (true) {
|
|
292
265
|
var _chunk$value, _chunk$value2, _chunk$value3, _chunk$value4;
|
|
@@ -311,8 +284,9 @@ const generateCode = async ({ iteration, ctx, cognitive, controller, metadata, o
|
|
|
311
284
|
...chunk.value.restart
|
|
312
285
|
});
|
|
313
286
|
raw = "";
|
|
314
|
-
|
|
315
|
-
|
|
287
|
+
completions = [];
|
|
288
|
+
accepted = false;
|
|
289
|
+
parser = new require_common.ResponseParser();
|
|
316
290
|
liveItems.clear();
|
|
317
291
|
liveContent.clear();
|
|
318
292
|
codeGenerationTraced = false;
|
|
@@ -334,19 +308,52 @@ const generateCode = async ({ iteration, ctx, cognitive, controller, metadata, o
|
|
|
334
308
|
timeToLastToken = Date.now() - requestedAt;
|
|
335
309
|
timeToFirstToken ??= timeToLastToken;
|
|
336
310
|
raw += delta;
|
|
337
|
-
await dispatchSends(parser.push(
|
|
311
|
+
await dispatchSends(parser.push(delta));
|
|
338
312
|
}
|
|
339
313
|
if (!responseMetadata) throw new require_errors.CognitiveError("LLM streaming completed without metadata");
|
|
340
314
|
assertSuccessfulGeneration(responseMetadata);
|
|
341
|
-
|
|
342
|
-
if (
|
|
343
|
-
|
|
344
|
-
|
|
315
|
+
await dispatchSends(parser.finish(responseMetadata.stopReason));
|
|
316
|
+
if (parser.valid) {
|
|
317
|
+
for (const complete of completions) await complete();
|
|
318
|
+
accepted = true;
|
|
319
|
+
}
|
|
320
|
+
assistantResponse = require_common.toParsedAssistantResponse(parser.items, raw, parser.diagnostics);
|
|
321
|
+
} catch (error) {
|
|
322
|
+
parser.finish();
|
|
323
|
+
const usage = (responseMetadata === null || responseMetadata === void 0 ? void 0 : responseMetadata.usage) ?? {
|
|
324
|
+
inputTokens: 0,
|
|
325
|
+
outputTokens: 0,
|
|
326
|
+
inputCost: 0,
|
|
327
|
+
outputCost: 0
|
|
328
|
+
};
|
|
329
|
+
iteration.llm = {
|
|
330
|
+
started_at: startedAt,
|
|
331
|
+
ended_at: Date.now(),
|
|
332
|
+
status: "error",
|
|
333
|
+
cached: (responseMetadata === null || responseMetadata === void 0 ? void 0 : responseMetadata.cached) ?? false,
|
|
334
|
+
tokens: usage.inputTokens + usage.outputTokens,
|
|
335
|
+
spend: (responseMetadata === null || responseMetadata === void 0 ? void 0 : responseMetadata.cost) ?? usage.inputCost + usage.outputCost,
|
|
336
|
+
output: raw,
|
|
337
|
+
diagnostics: parser.diagnostics,
|
|
338
|
+
model: (responseMetadata === null || responseMetadata === void 0 ? void 0 : responseMetadata.model) ?? model.id,
|
|
339
|
+
time_to_first_token: timeToFirstToken,
|
|
340
|
+
time_to_last_token: timeToLastToken,
|
|
341
|
+
usage
|
|
342
|
+
};
|
|
343
|
+
throw error;
|
|
345
344
|
} finally {
|
|
346
345
|
streamController.abort("LLM stream closed");
|
|
347
346
|
if (!streamCompleted) stream.return(void 0).catch((err) => {});
|
|
347
|
+
if (!accepted && liveContent.size) await preview({
|
|
348
|
+
restart: true,
|
|
349
|
+
iterationId: iteration.id,
|
|
350
|
+
attempt: attempt + 1,
|
|
351
|
+
fromModel: model.id,
|
|
352
|
+
toModel: model.id,
|
|
353
|
+
reason: "invalid or incomplete response envelope"
|
|
354
|
+
});
|
|
348
355
|
}
|
|
349
|
-
|
|
356
|
+
controller.signal.throwIfAborted();
|
|
350
357
|
} else {
|
|
351
358
|
const response = await cognitive.generateText(input, { signal: controller.signal }).catch((thrown) => {
|
|
352
359
|
throw new require_errors.CognitiveError(`LLM generation failed: ${require_utils.getErrorMessage(thrown)}`);
|
|
@@ -356,7 +363,7 @@ const generateCode = async ({ iteration, ctx, cognitive, controller, metadata, o
|
|
|
356
363
|
responseMetadata = response.metadata;
|
|
357
364
|
assertSuccessfulGeneration(responseMetadata);
|
|
358
365
|
raw = response.output;
|
|
359
|
-
assistantResponse = ctx.version.parseAssistantResponse(raw);
|
|
366
|
+
assistantResponse = ctx.version.parseAssistantResponse(raw, responseMetadata.stopReason);
|
|
360
367
|
for (const [index, send] of assistantResponse.sends.entries()) await (onSend === null || onSend === void 0 ? void 0 : onSend(send, messageMetadata(`send-${index}`)));
|
|
361
368
|
}
|
|
362
369
|
iteration.code = assistantResponse.code;
|
|
@@ -398,6 +405,7 @@ const generateCode = async ({ iteration, ctx, cognitive, controller, metadata, o
|
|
|
398
405
|
//#endregion
|
|
399
406
|
//#region src/runtime/interpret-result.ts
|
|
400
407
|
const interpretVMResult = async ({ iteration, result, controller, startedAt, onExit }) => {
|
|
408
|
+
Object.assign(iteration.variables, Object.fromEntries(Object.entries(result.variables ?? {}).filter(([, value]) => value !== "[[non-primitive]]")));
|
|
401
409
|
if (result.error && result.error instanceof require_errors.InvalidCodeError) {
|
|
402
410
|
iteration.end({
|
|
403
411
|
type: "invalid_code_error",
|
|
@@ -445,7 +453,8 @@ const interpretVMResult = async ({ iteration, result, controller, startedAt, onE
|
|
|
445
453
|
thinking_requested: {
|
|
446
454
|
variables: result.signal.context,
|
|
447
455
|
reason: result.signal.reason,
|
|
448
|
-
metadata: result.signal.metadata
|
|
456
|
+
metadata: result.signal.metadata,
|
|
457
|
+
interrupted: true
|
|
449
458
|
}
|
|
450
459
|
});
|
|
451
460
|
return;
|
|
@@ -458,7 +467,7 @@ const interpretVMResult = async ({ iteration, result, controller, startedAt, onE
|
|
|
458
467
|
return;
|
|
459
468
|
}
|
|
460
469
|
const returnValue = result.return_value;
|
|
461
|
-
const codeRequestsInspection =
|
|
470
|
+
const codeRequestsInspection = require_compiler.hasTopLevelReturn(iteration.code ?? "");
|
|
462
471
|
if (iteration.next && !codeRequestsInspection) {
|
|
463
472
|
await applyNextExit({
|
|
464
473
|
iteration,
|
|
@@ -506,11 +515,14 @@ const applyNextExit = async ({ iteration, controller, onExit }) => {
|
|
|
506
515
|
value: parsedExit.success ? parsedExit.value : next.props
|
|
507
516
|
};
|
|
508
517
|
if (!parsedExit.success) {
|
|
518
|
+
var _parsedExit$validatio;
|
|
519
|
+
const details = (_parsedExit$validatio = parsedExit.validationErrors) === null || _parsedExit$validatio === void 0 ? void 0 : _parsedExit$validatio.join("; ");
|
|
520
|
+
const error = [parsedExit.error.split("\n")[0], details].filter(Boolean).join(". ");
|
|
509
521
|
iteration.end({
|
|
510
522
|
type: "exit_error",
|
|
511
523
|
exit_error: {
|
|
512
524
|
exit: next.name,
|
|
513
|
-
message:
|
|
525
|
+
message: `${error}. Received props: ${JSON.stringify(next.props)}. Choose an exit from <exits> and supply its required props as ONE JSON object on the SAME LINE as ■next=${next.name}. Do not use a JavaScript return statement or wrap the fields in "value" or "props".`,
|
|
514
526
|
return_value: returnValue
|
|
515
527
|
}
|
|
516
528
|
});
|
|
@@ -750,6 +762,7 @@ const executeContextInternal = async (props) => {
|
|
|
750
762
|
const ctx = new require_custom_client.Context({
|
|
751
763
|
chat: props.chat,
|
|
752
764
|
instructions: props.instructions,
|
|
765
|
+
examples: props.examples,
|
|
753
766
|
objects: props.objects,
|
|
754
767
|
tools: props.tools,
|
|
755
768
|
loop: (_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.loop,
|
|
@@ -950,8 +963,6 @@ const executeIteration = async ({ iteration, ctx, cognitive, controller, onExit,
|
|
|
950
963
|
};
|
|
951
964
|
});
|
|
952
965
|
};
|
|
953
|
-
const canExecuteEarly = typeof onBeforeExecution !== "function" && !ctx.midStreamFallback;
|
|
954
|
-
let earlyExecution;
|
|
955
966
|
await generateCode({
|
|
956
967
|
iteration,
|
|
957
968
|
ctx,
|
|
@@ -959,22 +970,15 @@ const executeIteration = async ({ iteration, ctx, cognitive, controller, onExit,
|
|
|
959
970
|
controller,
|
|
960
971
|
metadata,
|
|
961
972
|
onRunStart: () => require_vm.warmupVM(),
|
|
962
|
-
onRunComplete: canExecuteEarly ? (code) => {
|
|
963
|
-
if (!code.length || controller.signal.aborted || earlyExecution) return;
|
|
964
|
-
iteration.code = code;
|
|
965
|
-
earlyExecution = {
|
|
966
|
-
code,
|
|
967
|
-
started_at: Date.now(),
|
|
968
|
-
promise: runCode(code)
|
|
969
|
-
};
|
|
970
|
-
} : void 0,
|
|
971
973
|
onSend: async (send, messageMetadata) => {
|
|
972
974
|
if (!ctx.chat) return;
|
|
973
975
|
const sendStartedAt = Date.now();
|
|
974
|
-
const
|
|
976
|
+
const registered = iteration.components.find((component) => component.definition.name.toLowerCase() === send.name);
|
|
977
|
+
const children = send.body ? [send.body] : [];
|
|
978
|
+
const component = registered ? registered.render(send.props, children) : require_jsx.createJsxComponent({
|
|
975
979
|
type: send.name,
|
|
976
980
|
props: send.props,
|
|
977
|
-
children
|
|
981
|
+
children
|
|
978
982
|
});
|
|
979
983
|
try {
|
|
980
984
|
await ctx.chat.handler(component, messageMetadata);
|
|
@@ -990,7 +994,6 @@ const executeIteration = async ({ iteration, ctx, cognitive, controller, onExit,
|
|
|
990
994
|
},
|
|
991
995
|
onSendDelta: ((_ctx$chat = ctx.chat) === null || _ctx$chat === void 0 ? void 0 : _ctx$chat.onMessageDelta) ? (delta) => ctx.chat.onMessageDelta(delta) : void 0
|
|
992
996
|
});
|
|
993
|
-
if (earlyExecution) iteration.code = earlyExecution.code;
|
|
994
997
|
if (typeof onBeforeExecution === "function") try {
|
|
995
998
|
const hookRes = await onBeforeExecution(iteration, controller);
|
|
996
999
|
if (typeof (hookRes === null || hookRes === void 0 ? void 0 : hookRes.code) === "string" && hookRes.code.trim().length > 0) iteration.code = hookRes.code.trim();
|
|
@@ -1028,7 +1031,7 @@ const executeIteration = async ({ iteration, ctx, cognitive, controller, onExit,
|
|
|
1028
1031
|
return;
|
|
1029
1032
|
}
|
|
1030
1033
|
if (!iteration.code) {
|
|
1031
|
-
var _iteration$
|
|
1034
|
+
var _iteration$llm;
|
|
1032
1035
|
if (iteration.next) {
|
|
1033
1036
|
await applyNextExit({
|
|
1034
1037
|
iteration,
|
|
@@ -1037,26 +1040,14 @@ const executeIteration = async ({ iteration, ctx, cognitive, controller, onExit,
|
|
|
1037
1040
|
});
|
|
1038
1041
|
return;
|
|
1039
1042
|
}
|
|
1040
|
-
if (ctx.chat && ((_iteration$sends = iteration.sends) === null || _iteration$sends === void 0 ? void 0 : _iteration$sends.length)) {
|
|
1041
|
-
iteration.next = {
|
|
1042
|
-
name: "listen",
|
|
1043
|
-
props: {}
|
|
1044
|
-
};
|
|
1045
|
-
await applyNextExit({
|
|
1046
|
-
iteration,
|
|
1047
|
-
controller,
|
|
1048
|
-
onExit
|
|
1049
|
-
});
|
|
1050
|
-
return;
|
|
1051
|
-
}
|
|
1052
1043
|
iteration.end({
|
|
1053
1044
|
type: "invalid_code_error",
|
|
1054
|
-
invalid_code_error: { message: "The response did not include a ■run block or a ■next exit. Reply
|
|
1045
|
+
invalid_code_error: { message: ((_iteration$llm = iteration.llm) === null || _iteration$llm === void 0 || (_iteration$llm = _iteration$llm.diagnostics) === null || _iteration$llm === void 0 || (_iteration$llm = _iteration$llm.find((diagnostic) => diagnostic.code === "invalid-envelope")) === null || _iteration$llm === void 0 ? void 0 : _iteration$llm.message) ?? "The response did not include a ■run block or a ■next exit. Reply with ■start, the required ■ blocks, and ■end." }
|
|
1055
1046
|
});
|
|
1056
1047
|
return;
|
|
1057
1048
|
}
|
|
1058
|
-
const startedAt =
|
|
1059
|
-
const result =
|
|
1049
|
+
const startedAt = Date.now();
|
|
1050
|
+
const result = await runCode(iteration.code);
|
|
1060
1051
|
await interpretVMResult({
|
|
1061
1052
|
iteration,
|
|
1062
1053
|
result,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_compiler = require("./compiler-C-OI9sim.cjs");
|
|
2
2
|
const require_uniq = require("./uniq-G872RWmE.cjs");
|
|
3
|
-
const require_utils = require("./utils-
|
|
3
|
+
const require_utils = require("./utils-3ESwP3yg.cjs");
|
|
4
4
|
let _bpinternal_zui = require("@bpinternal/zui");
|
|
5
5
|
//#region src/exit.ts
|
|
6
|
-
var exit_exports = /* @__PURE__ */
|
|
6
|
+
var exit_exports = /* @__PURE__ */ require_compiler.__exportAll({ Exit: () => Exit });
|
|
7
7
|
/**
|
|
8
8
|
* Defines how LLMz agent execution can terminate.
|
|
9
9
|
*
|
package/dist/exit-parser.d.ts
CHANGED