llmz 0.9.13 → 0.9.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/context.d.ts CHANGED
@@ -408,6 +408,11 @@ export declare class Iteration implements Serializable<Iteration.JSON> {
408
408
  ended_ts?: number;
409
409
  status: IterationStatus;
410
410
  private _mutations;
411
+ /**
412
+ * The messages as built, after any onIterationStart changes, while `messages` becomes what was sent. Sent messages
413
+ * have no truncation tags, so the next iteration builds on these to keep older messages truncatable
414
+ */
415
+ builtMessages?: LLMzPrompts.Message[];
411
416
  get mutations(): ObjectMutation[];
412
417
  trackMutation(mutation: ObjectMutation): void;
413
418
  private _parameters;
@@ -2156,6 +2156,11 @@ var Iteration = class {
2156
2156
  ended_ts;
2157
2157
  status;
2158
2158
  _mutations;
2159
+ /**
2160
+ * The messages as built, after any onIterationStart changes, while `messages` becomes what was sent. Sent messages
2161
+ * have no truncation tags, so the next iteration builds on these to keep older messages truncatable
2162
+ */
2163
+ builtMessages;
2159
2164
  get mutations() {
2160
2165
  return [...this._mutations.values()];
2161
2166
  }
@@ -2436,7 +2441,7 @@ var Context = class {
2436
2441
  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 })]);
2437
2442
  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 })]);
2438
2443
  if (!lastIteration) return withParts([systemMessage, await this.version.getInitialUserMessage(promptProps)]);
2439
- const history = lastIteration.messages.slice();
2444
+ const history = (lastIteration.builtMessages ?? lastIteration.messages).slice();
2440
2445
  if (previousLastMessage) history[history.length - 1] = previousLastMessage;
2441
2446
  const lastIterationMessages = [systemMessage, ...history.filter((x) => x.role !== "system")];
2442
2447
  if ((lastIteration === null || lastIteration === void 0 ? void 0 : lastIteration.status.type) === "thinking_requested") {
@@ -2156,6 +2156,11 @@ var Iteration = class {
2156
2156
  ended_ts;
2157
2157
  status;
2158
2158
  _mutations;
2159
+ /**
2160
+ * The messages as built, after any onIterationStart changes, while `messages` becomes what was sent. Sent messages
2161
+ * have no truncation tags, so the next iteration builds on these to keep older messages truncatable
2162
+ */
2163
+ builtMessages;
2159
2164
  get mutations() {
2160
2165
  return [...this._mutations.values()];
2161
2166
  }
@@ -2436,7 +2441,7 @@ var Context = class {
2436
2441
  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 })]);
2437
2442
  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 })]);
2438
2443
  if (!lastIteration) return withParts([systemMessage, await this.version.getInitialUserMessage(promptProps)]);
2439
- const history = lastIteration.messages.slice();
2444
+ const history = (lastIteration.builtMessages ?? lastIteration.messages).slice();
2440
2445
  if (previousLastMessage) history[history.length - 1] = previousLastMessage;
2441
2446
  const lastIterationMessages = [systemMessage, ...history.filter((x) => x.role !== "system")];
2442
2447
  if ((lastIteration === null || lastIteration === void 0 ? void 0 : lastIteration.status.type) === "thinking_requested") {
@@ -2,7 +2,7 @@ const require_compiler = require("./compiler-BJJUmNS9.cjs");
2
2
  const require_dual_modes = require("./dual-modes-D3cSQ8j4.cjs");
3
3
  const require_common = require("./common-CaWHSEW4.cjs");
4
4
  const require__baseIteratee = require("./_baseIteratee-CF4qP2a8.cjs");
5
- const require_custom_client = require("./custom-client-C3EnKARC.cjs");
5
+ const require_custom_client = require("./custom-client-qYqKvH6E.cjs");
6
6
  const require_utils = require("./utils-DGQ4sRke.cjs");
7
7
  const require_jsx = require("./jsx-BJ6GWXI2.cjs");
8
8
  const require_stack_traces = require("./stack-traces-ntw_qhoy.cjs");
@@ -220,6 +220,7 @@ const generateCode = async ({ iteration, ctx, cognitive, controller, metadata, o
220
220
  const cap = ctx.maxTokens ? ` (context window capped at ${modelLimit} tokens by options.maxTokens — consider raising or removing it)` : ` (model context window: ${modelLimit} tokens)`;
221
221
  throw new require_errors.CognitiveError(`The prompt does not fit in the context window${cap}: ${require_utils.getErrorMessage(thrown)}`);
222
222
  }
223
+ iteration.builtMessages = iteration.messages;
223
224
  iteration.messages = messages;
224
225
  traces.push({
225
226
  type: "llm_call_started",
@@ -1,7 +1,7 @@
1
1
  import { c as toNumber } from "./dual-modes-BdZuONje.js";
2
2
  import { a as ResponseParser, i as toParsedAssistantResponse } from "./common-P6vdw8Vv.js";
3
3
  import { n as baseIsEqual } from "./_baseIteratee-P_firB7b.js";
4
- import { d as Snapshot, f as parseExit, l as PartialExecutionResult, n as Context, s as ErrorExecutionResult, t as _CustomModelClient, u as SuccessExecutionResult } from "./custom-client-CZVu-wF4.js";
4
+ import { d as Snapshot, f as parseExit, l as PartialExecutionResult, n as Context, s as ErrorExecutionResult, t as _CustomModelClient, u as SuccessExecutionResult } from "./custom-client-BJeaPZ9B.js";
5
5
  import { d as stripInvalidIdentifiers, i as getErrorMessage, o as getTokenizer, r as fromJSONSchemaCompat, s as init } from "./utils-UBeAFeEI.js";
6
6
  import { t as createJsxComponent } from "./jsx-CIgdGGVs.js";
7
7
  import { t as cleanStackTrace } from "./stack-traces-BIE_5Xwf.js";
@@ -219,6 +219,7 @@ const generateCode = async ({ iteration, ctx, cognitive, controller, metadata, o
219
219
  const cap = ctx.maxTokens ? ` (context window capped at ${modelLimit} tokens by options.maxTokens — consider raising or removing it)` : ` (model context window: ${modelLimit} tokens)`;
220
220
  throw new CognitiveError(`The prompt does not fit in the context window${cap}: ${getErrorMessage(thrown)}`);
221
221
  }
222
+ iteration.builtMessages = iteration.messages;
222
223
  iteration.messages = messages;
223
224
  traces.push({
224
225
  type: "llm_call_started",
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_dual_modes = require("./dual-modes-D3cSQ8j4.cjs");
3
3
  const require_common = require("./common-CaWHSEW4.cjs");
4
- const require_custom_client = require("./custom-client-C3EnKARC.cjs");
4
+ const require_custom_client = require("./custom-client-qYqKvH6E.cjs");
5
5
  const require_utils = require("./utils-DGQ4sRke.cjs");
6
6
  const require_tool = require("./tool-ikMsh-TB.cjs");
7
7
  const require_errors = require("./errors-C962uJdS.cjs");
@@ -12,7 +12,7 @@ const require_truncator = require("./truncator-DmCu9M4m.cjs");
12
12
  const require_quickjs_variant = require("./quickjs-variant-CsIwTVFC.cjs");
13
13
  let _bpinternal_zui = require("@bpinternal/zui");
14
14
  //#region package.json
15
- var version = "0.9.13";
15
+ var version = "0.9.15";
16
16
  //#endregion
17
17
  //#region src/hoist.ts
18
18
  /**
@@ -1693,7 +1693,7 @@ const utils = {
1693
1693
  * })
1694
1694
  */
1695
1695
  const execute = async (props) => {
1696
- const { executeContext } = await Promise.resolve().then(() => require("./execute-DBMmurHH.cjs"));
1696
+ const { executeContext } = await Promise.resolve().then(() => require("./execute-CQVnI3SR.cjs"));
1697
1697
  return executeContext(props);
1698
1698
  };
1699
1699
  /**
@@ -1702,7 +1702,7 @@ const execute = async (props) => {
1702
1702
  * It's recommended to call this function at the beginning of your application without awaiting it (void init())
1703
1703
  */
1704
1704
  const init = async () => {
1705
- await Promise.resolve().then(() => require("./execute-DBMmurHH.cjs"));
1705
+ await Promise.resolve().then(() => require("./execute-CQVnI3SR.cjs"));
1706
1706
  await Promise.resolve().then(() => require("./component-CPKXe6Ca.cjs")).then((n) => n.component_exports);
1707
1707
  await Promise.resolve().then(() => require("./tool-ikMsh-TB.cjs")).then((n) => n.tool_exports);
1708
1708
  await Promise.resolve().then(() => require("./exit-DTDB1SJ3.cjs")).then((n) => n.exit_exports);
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { d as validateComponent, f as validateProps, l as Example, p as ComponentRegistry, u as generateInstructions } from "./dual-modes-BdZuONje.js";
2
2
  import { c as MARKER, l as NAME_REGEX, o as StreamingMessageParser, s as tryParseJson } from "./common-P6vdw8Vv.js";
3
- import { a as ThinkExit, c as ExecutionResult, d as Snapshot, f as parseExit, i as ListenExit, l as PartialExecutionResult, o as getValue, r as DefaultExit, s as ErrorExecutionResult, t as _CustomModelClient, u as SuccessExecutionResult } from "./custom-client-CZVu-wF4.js";
3
+ import { a as ThinkExit, c as ExecutionResult, d as Snapshot, f as parseExit, i as ListenExit, l as PartialExecutionResult, o as getValue, r as DefaultExit, s as ErrorExecutionResult, t as _CustomModelClient, u as SuccessExecutionResult } from "./custom-client-BJeaPZ9B.js";
4
4
  import { a as getMultilineComment, c as isJsonSchema, l as isValidIdentifier, m as toValidObjectName, n as escapeString, p as toValidFunctionName, t as configureTokenizer, u as isZuiSchema, v as upperFirst } from "./utils-UBeAFeEI.js";
5
5
  import { t as Tool } from "./tool-BoXBgZeM.js";
6
6
  import { c as SnapshotSignal, l as ThinkSignal, o as LoopExceededError, r as CodeFormattingError } from "./errors-Cg1G0Awu.js";
@@ -11,7 +11,7 @@ import { i as wrapContent, n as truncateWrappedContent, t as stripTruncationTags
11
11
  import { t as configureQuickJS } from "./quickjs-variant-BYhMBpwU.js";
12
12
  import { transforms, z } from "@bpinternal/zui";
13
13
  //#region package.json
14
- var version = "0.9.13";
14
+ var version = "0.9.15";
15
15
  //#endregion
16
16
  //#region src/hoist.ts
17
17
  /**
@@ -1692,7 +1692,7 @@ const utils = {
1692
1692
  * })
1693
1693
  */
1694
1694
  const execute = async (props) => {
1695
- const { executeContext } = await import("./execute-hoM7wiQS.js");
1695
+ const { executeContext } = await import("./execute-FRDs8Tbc.js");
1696
1696
  return executeContext(props);
1697
1697
  };
1698
1698
  /**
@@ -1701,7 +1701,7 @@ const execute = async (props) => {
1701
1701
  * It's recommended to call this function at the beginning of your application without awaiting it (void init())
1702
1702
  */
1703
1703
  const init = async () => {
1704
- await import("./execute-hoM7wiQS.js");
1704
+ await import("./execute-FRDs8Tbc.js");
1705
1705
  await import("./component-DGG7d_Mz.js").then((n) => n.r);
1706
1706
  await import("./tool-BoXBgZeM.js").then((n) => n.n);
1707
1707
  await import("./exit-AwQk1cyW.js").then((n) => n.n);
@@ -52,7 +52,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
52
52
  }) : target, mod));
53
53
  //#endregion
54
54
  //#region package.json
55
- var version = "0.9.13", quoteExample, quotePartialExample, exampleBoundaryInstructions, quoteResponseExample;
55
+ var version = "0.9.15", quoteExample, quotePartialExample, exampleBoundaryInstructions, quoteResponseExample;
56
56
  var init_example_format = __esmMin((() => {
57
57
  quoteExample = (output) => `"""\n${output}\n"""`;
58
58
  quotePartialExample = (output) => quoteExample(`(...)\n${output}\n(...)`);
@@ -13706,6 +13706,11 @@ var init_context = __esmMin((() => {
13706
13706
  ended_ts;
13707
13707
  status;
13708
13708
  _mutations;
13709
+ /**
13710
+ * The messages as built, after any onIterationStart changes, while `messages` becomes what was sent. Sent messages
13711
+ * have no truncation tags, so the next iteration builds on these to keep older messages truncatable
13712
+ */
13713
+ builtMessages;
13709
13714
  get mutations() {
13710
13715
  return [...this._mutations.values()];
13711
13716
  }
@@ -13983,7 +13988,7 @@ var init_context = __esmMin((() => {
13983
13988
  if (this.snapshot?.status.type === "resolved") return withParts([systemMessage, this.version.getSnapshotResolvedMessage({ snapshot: this.snapshot })]);
13984
13989
  if (this.snapshot?.status.type === "rejected") return withParts([systemMessage, this.version.getSnapshotRejectedMessage({ snapshot: this.snapshot })]);
13985
13990
  if (!lastIteration) return withParts([systemMessage, await this.version.getInitialUserMessage(promptProps)]);
13986
- const history = lastIteration.messages.slice();
13991
+ const history = (lastIteration.builtMessages ?? lastIteration.messages).slice();
13987
13992
  if (previousLastMessage) history[history.length - 1] = previousLastMessage;
13988
13993
  const lastIterationMessages = [systemMessage, ...history.filter((x) => x.role !== "system")];
13989
13994
  if (lastIteration?.status.type === "thinking_requested") return withParts([
@@ -18197,6 +18202,7 @@ var init_generate = __esmMin((() => {
18197
18202
  const cap = ctx.maxTokens ? ` (context window capped at ${modelLimit} tokens by options.maxTokens — consider raising or removing it)` : ` (model context window: ${modelLimit} tokens)`;
18198
18203
  throw new CognitiveError(`The prompt does not fit in the context window${cap}: ${getErrorMessage(thrown)}`);
18199
18204
  }
18205
+ iteration.builtMessages = iteration.messages;
18200
18206
  iteration.messages = messages;
18201
18207
  traces.push({
18202
18208
  type: "llm_call_started",
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "llmz",
3
3
  "type": "module",
4
4
  "description": "LLMz - An LLM-native Typescript VM built on top of Zui",
5
- "version": "0.9.13",
5
+ "version": "0.9.15",
6
6
  "files": [
7
7
  "dist",
8
8
  "DOCS.md"
@@ -68,7 +68,7 @@
68
68
  "tsx": "^4.19.2"
69
69
  },
70
70
  "peerDependencies": {
71
- "@botpress/client": "2.11.0",
71
+ "@botpress/client": "2.12.0",
72
72
  "@botpress/cognitive": "1.3.0",
73
73
  "@bpinternal/thicktoken": "^3.1.0",
74
74
  "@bpinternal/zui": "^2.4.1"