llmz 0.8.0 → 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.
Files changed (54) hide show
  1. package/README.md +45 -11
  2. package/dist/chat.d.ts +6 -6
  3. package/dist/{common-pgJjFu2Y.js → common-BlRFtdf2.js} +233 -22
  4. package/dist/{common-DdArNQhl.cjs → common-BnvrDnIT.cjs} +238 -21
  5. package/dist/{component-BXS8vAwO.cjs → component-C6Agl2ns.cjs} +1 -1
  6. package/dist/{component-Dq7ZLdvy.js → component-DGG7d_Mz.js} +1 -1
  7. package/dist/component.default.d.ts +10 -0
  8. package/dist/context.d.ts +4 -8
  9. package/dist/{custom-client-2V9lmzUf.js → custom-client-ChuZ63zp.js} +15 -12
  10. package/dist/{custom-client-HkM1Sdzv.cjs → custom-client-DAsGRnYc.cjs} +18 -15
  11. package/dist/{dual-modes-Cy0_W4O2.js → dual-modes-DDkoCp3R.js} +1246 -1170
  12. package/dist/{dual-modes-Cb7ThvoV.cjs → dual-modes-DPXiuvNe.cjs} +1239 -1169
  13. package/dist/example-format.d.ts +8 -0
  14. package/dist/{execute-Aw4cbIx-.js → execute-BWcdv9so.js} +64 -85
  15. package/dist/{execute-COIHOIKR.cjs → execute-DM2-7y86.cjs} +64 -85
  16. package/dist/index.cjs +254 -11
  17. package/dist/index.js +253 -10
  18. package/dist/index.workerd.js +8646 -8108
  19. package/dist/inspect.d.ts +2 -0
  20. package/dist/isPlainObject-CSxXVKCk.cjs +56 -0
  21. package/dist/isPlainObject-D39AzPO2.js +51 -0
  22. package/dist/{jsx-B0iYyvfr.js → jsx-CIgdGGVs.js} +2 -50
  23. package/dist/{jsx-D5Y2cPo-.cjs → jsx-owqxrquU.cjs} +2 -56
  24. package/dist/message-stream/instructions.d.ts +8 -0
  25. package/dist/message-stream/parser.d.ts +6 -0
  26. package/dist/message-stream/response-parser.d.ts +24 -0
  27. package/dist/message-stream/response-parser.test.d.ts +1 -0
  28. package/dist/message-stream/types.d.ts +3 -2
  29. package/dist/prompts/adherence.test.d.ts +1 -0
  30. package/dist/prompts/catalogue-examples.test.d.ts +1 -0
  31. package/dist/prompts/chat-mode/protocol.d.ts +2 -0
  32. package/dist/prompts/chat-mode/system.d.ts +1 -1
  33. package/dist/prompts/chat-mode/user.d.ts +1 -1
  34. package/dist/prompts/code-examples.d.ts +2 -0
  35. package/dist/prompts/code-examples.test.d.ts +1 -0
  36. package/dist/prompts/common.d.ts +2 -1
  37. package/dist/prompts/concrete-patterns.test.d.ts +1 -0
  38. package/dist/prompts/long-search.test.d.ts +1 -0
  39. package/dist/prompts/prompt.d.ts +5 -2
  40. package/dist/prompts/protocol-basics.d.ts +5 -0
  41. package/dist/prompts/protocol-simple.test.d.ts +1 -0
  42. package/dist/prompts/protocol.d.ts +13 -0
  43. package/dist/prompts/sections.test.d.ts +1 -0
  44. package/dist/prompts/worker-mode/protocol.d.ts +2 -0
  45. package/dist/prompts/worker-mode/system.d.ts +1 -1
  46. package/dist/prompts/worker-mode/user.d.ts +1 -1
  47. package/dist/runtime/citations.test.d.ts +1 -0
  48. package/dist/runtime/fixtures/long-search.d.ts +19 -0
  49. package/dist/runtime/fixtures/protocol-languages.d.ts +74 -0
  50. package/dist/runtime/fixtures/qwen-protocol-failures.d.ts +29 -0
  51. package/dist/runtime/generate.d.ts +2 -9
  52. package/dist/runtime/protocol-adherence.test.d.ts +1 -0
  53. package/dist/runtime/types.d.ts +4 -7
  54. package/package.json +1 -1
@@ -63,6 +63,7 @@ var StreamingMessageParser = class {
63
63
  _currentReady = false;
64
64
  _counter = 0;
65
65
  _finished = false;
66
+ _ended = false;
66
67
  _directiveBuffer = "";
67
68
  _nameBuffer = "";
68
69
  _propsBuffer = "";
@@ -74,6 +75,8 @@ var StreamingMessageParser = class {
74
75
  _pendingWhitespace = "";
75
76
  _preambleHeader;
76
77
  _closingFenceTicks;
78
+ _lineStart = true;
79
+ _exampleDelimiter = "";
77
80
  constructor(options = {}) {
78
81
  this._maxPropsLength = options.maxPropsLength ?? 1e5;
79
82
  }
@@ -88,7 +91,7 @@ var StreamingMessageParser = class {
88
91
  push(chunk) {
89
92
  if (this._finished) throw new Error("Parser has already finished. Call reset() before parsing a new stream.");
90
93
  const events = [];
91
- for (const char of chunk) this._processChar(char, events);
94
+ for (const char of chunk) this._processOutputChar(char, events);
92
95
  this._flushBodyDelta(events);
93
96
  return events;
94
97
  }
@@ -102,6 +105,9 @@ var StreamingMessageParser = class {
102
105
  if (this._finished) return [];
103
106
  this._finished = true;
104
107
  const events = [];
108
+ if (/^"""\s*$/.test(this._exampleDelimiter)) this._discardExampleDelimiter(events);
109
+ else if (reason === "end") this._flushExampleDelimiter(events);
110
+ else this._exampleDelimiter = "";
105
111
  if (this._closingFenceTicks !== void 0 && this._closingFenceTicks !== 3) this._skipUnexpectedText(events);
106
112
  this._closingFenceTicks = void 0;
107
113
  const status = reason === "interrupted" ? "interrupted" : void 0;
@@ -138,6 +144,7 @@ var StreamingMessageParser = class {
138
144
  this._currentReady = false;
139
145
  this._counter = 0;
140
146
  this._finished = false;
147
+ this._ended = false;
141
148
  this._directiveBuffer = "";
142
149
  this._nameBuffer = "";
143
150
  this._propsBuffer = "";
@@ -149,6 +156,50 @@ var StreamingMessageParser = class {
149
156
  this._pendingWhitespace = "";
150
157
  this._preambleHeader = void 0;
151
158
  this._closingFenceTicks = void 0;
159
+ this._lineStart = true;
160
+ this._exampleDelimiter = "";
161
+ }
162
+ _processOutputChar(char, events) {
163
+ const lineStart = this._lineStart;
164
+ this._lineStart = char === "\n" || lineStart && (char === " " || char === " " || char === "\r");
165
+ if (this._exampleDelimiter) {
166
+ if (this._exampleDelimiter.includes("\n")) {
167
+ if (isWhitespace(char)) {
168
+ this._exampleDelimiter += char;
169
+ return;
170
+ }
171
+ if (char === "■") this._discardExampleDelimiter(events);
172
+ else this._flushExampleDelimiter(events);
173
+ } else {
174
+ const candidate = this._exampleDelimiter + char;
175
+ if (/^(?:"{1,2}|"""[ \t]*\r?)$/.test(candidate)) {
176
+ this._exampleDelimiter = candidate;
177
+ return;
178
+ }
179
+ if (/^"""[ \t]*\r?\n$/.test(candidate)) {
180
+ this._exampleDelimiter = candidate;
181
+ if (this._state !== "body") this._discardExampleDelimiter(events);
182
+ return;
183
+ }
184
+ this._flushExampleDelimiter(events);
185
+ }
186
+ }
187
+ if (lineStart && char === "\"" && (this._state === "idle" || this._state === "skip" || this._state === "body-wait" || this._state === "body")) {
188
+ this._exampleDelimiter = char;
189
+ return;
190
+ }
191
+ this._processChar(char, events);
192
+ }
193
+ _flushExampleDelimiter(events) {
194
+ for (const char of this._exampleDelimiter) this._processChar(char, events);
195
+ this._exampleDelimiter = "";
196
+ }
197
+ _discardExampleDelimiter(events) {
198
+ this._exampleDelimiter = "";
199
+ this._diagnostic(events, {
200
+ code: "example-delimiter",
201
+ message: "Discarded a triple-quote example delimiter"
202
+ });
152
203
  }
153
204
  _processChar(char, events) {
154
205
  if (this._closingFenceTicks !== void 0) {
@@ -160,9 +211,18 @@ var StreamingMessageParser = class {
160
211
  this._closingFenceTicks = void 0;
161
212
  this._skipUnexpectedText(events);
162
213
  }
214
+ if (this._ended) {
215
+ if (this._state === "skip" || isWhitespace(char)) return;
216
+ if (char === "`") {
217
+ this._closingFenceTicks = 1;
218
+ return;
219
+ }
220
+ this._skipUnexpectedText(events);
221
+ return;
222
+ }
163
223
  switch (this._state) {
164
224
  case "idle":
165
- if (char === "■") this._beginItem();
225
+ if (char === "■") this._beginItem(events);
166
226
  else if (!isWhitespace(char)) {
167
227
  const last = this._items.at(-1);
168
228
  if (char === "`" && (last === null || last === void 0 ? void 0 : last.kind) === "next" && last.status === "complete") {
@@ -178,7 +238,7 @@ var StreamingMessageParser = class {
178
238
  else if (char === "■") {
179
239
  this._endDirective(events, void 0);
180
240
  this._completeCurrent(events);
181
- this._beginItem();
241
+ this._beginItem(events);
182
242
  } else if (char === "\n") this._endDirective(events, "\n");
183
243
  else if (isWhitespace(char)) this._endDirective(events, " ");
184
244
  else if (char === "{") this._endDirective(events, "{");
@@ -188,7 +248,7 @@ var StreamingMessageParser = class {
188
248
  if (char === "■") {
189
249
  this._endName(events);
190
250
  this._completeCurrent(events);
191
- this._beginItem();
251
+ this._beginItem(events);
192
252
  } else if (char === "{") {
193
253
  this._endName(events);
194
254
  this._afterHeaderChar(char, events);
@@ -209,7 +269,7 @@ var StreamingMessageParser = class {
209
269
  case "body-wait":
210
270
  if (char === "■") {
211
271
  this._completeCurrent(events);
212
- this._beginItem();
272
+ this._beginItem(events);
213
273
  } else if (!isWhitespace(char)) {
214
274
  this._startBody(events);
215
275
  this._appendBody(char);
@@ -220,7 +280,7 @@ var StreamingMessageParser = class {
220
280
  this._pendingWhitespace = "";
221
281
  this._flushBodyDelta(events);
222
282
  this._completeCurrent(events);
223
- this._beginItem();
283
+ this._beginItem(events);
224
284
  } else this._appendBody(char);
225
285
  return;
226
286
  case "skip":
@@ -233,7 +293,7 @@ var StreamingMessageParser = class {
233
293
  }
234
294
  return;
235
295
  }
236
- if (char === "■") this._beginItem();
296
+ if (char === "■") this._beginItem(events);
237
297
  return;
238
298
  }
239
299
  }
@@ -250,7 +310,7 @@ var StreamingMessageParser = class {
250
310
  const item = this._current;
251
311
  if (char === "■") {
252
312
  this._completeCurrent(events);
253
- this._beginItem();
313
+ this._beginItem(events);
254
314
  return;
255
315
  }
256
316
  if (char === "{" && (item.kind === "send" || item.kind === "next")) {
@@ -292,7 +352,7 @@ var StreamingMessageParser = class {
292
352
  else if (char === "■" && this._propsBroken) {
293
353
  this._failProps(events, "props were interrupted by a new block");
294
354
  this._completeCurrent(events);
295
- this._beginItem();
355
+ this._beginItem(events);
296
356
  }
297
357
  return;
298
358
  }
@@ -300,14 +360,18 @@ var StreamingMessageParser = class {
300
360
  else if (char === "■") {
301
361
  this._failProps(events, "props were interrupted by a new block");
302
362
  this._completeCurrent(events);
303
- this._beginItem();
363
+ this._beginItem(events);
304
364
  } else if (char === "{" || char === "[") this._propsDepth++;
305
365
  else if (char === "}" || char === "]") {
306
366
  this._propsDepth--;
307
367
  if (this._propsDepth <= 0) this._endProps(events);
308
368
  }
309
369
  }
310
- _beginItem() {
370
+ _beginItem(events) {
371
+ if (this._ended) {
372
+ this._skipUnexpectedText(events);
373
+ return;
374
+ }
311
375
  const item = {
312
376
  id: `item-${this._counter++}`,
313
377
  kind: "unknown",
@@ -506,6 +570,7 @@ var StreamingMessageParser = class {
506
570
  if (!item) return;
507
571
  this._ready(events);
508
572
  if (item.status !== "invalid") item.status = forcedStatus ?? "complete";
573
+ if (item.kind === "next" && item.status === "complete") this._ended = true;
509
574
  events.push({
510
575
  type: "item-complete",
511
576
  item
@@ -516,7 +581,7 @@ var StreamingMessageParser = class {
516
581
  _skipUnexpectedText(events) {
517
582
  this._diagnostic(events, {
518
583
  code: "unexpected-text",
519
- message: "Encountered text outside of a ■ block"
584
+ message: this._ended ? "Discarded content after terminal ■next" : "Encountered text outside of a ■ block"
520
585
  });
521
586
  this._state = "skip";
522
587
  }
@@ -533,17 +598,163 @@ var StreamingMessageParser = class {
533
598
  }
534
599
  };
535
600
  //#endregion
601
+ //#region src/message-stream/response-parser.ts
602
+ /** One wire format: a complete ■start … ■end envelope containing valid blocks. */
603
+ var ResponseParser = class {
604
+ _parser = new StreamingMessageParser();
605
+ _mode = "detect";
606
+ _discardPrefixLine = false;
607
+ _prefixDiagnostics = [];
608
+ _prefix = "";
609
+ _boundary = "";
610
+ _closed = false;
611
+ _finished = false;
612
+ _failure;
613
+ _trailer = "";
614
+ get framed() {
615
+ return this._mode === "framed";
616
+ }
617
+ get valid() {
618
+ return this._finished && this._closed && !this._failure;
619
+ }
620
+ get items() {
621
+ return this.valid ? this._parser.items : [];
622
+ }
623
+ get diagnostics() {
624
+ return [
625
+ ...this._prefixDiagnostics,
626
+ ...this._parser.diagnostics,
627
+ ...this._trailingDiagnostics,
628
+ ...this._failure ? [this._failure] : []
629
+ ];
630
+ }
631
+ push(chunk) {
632
+ if (this._finished) throw new Error("Response parser has already finished");
633
+ const events = [];
634
+ let forward = "";
635
+ const flush = () => {
636
+ if (forward) events.push(...this._parser.push(forward));
637
+ forward = "";
638
+ };
639
+ for (const char of chunk) {
640
+ if (this._mode === "detect") {
641
+ if (this._discardPrefixLine) {
642
+ if (char === "\n") this._discardPrefixLine = false;
643
+ continue;
644
+ }
645
+ if (!this._prefix && /\s/.test(char)) continue;
646
+ this._prefix += char;
647
+ const trimmed = this._prefix.trimEnd();
648
+ if (char === "\n" && trimmed === "\"\"\"") {
649
+ events.push(...this._parser.push(this._prefix));
650
+ this._prefix = "";
651
+ } else if (char === "\n" && trimmed === "■start") {
652
+ this._mode = "framed";
653
+ this._prefix = "";
654
+ } else if (!"■start".startsWith(this._prefix) && !/^■start[ \t\r]*$/.test(this._prefix) && !/^"{1,3}[ \t\r]*$/.test(this._prefix)) {
655
+ if (!this._prefixDiagnostics.length) {
656
+ const diagnostic = {
657
+ code: "unexpected-text",
658
+ message: "Discarded text before ■start"
659
+ };
660
+ this._prefixDiagnostics.push(diagnostic);
661
+ events.push({
662
+ type: "diagnostic",
663
+ diagnostic
664
+ });
665
+ }
666
+ this._prefix = "";
667
+ this._discardPrefixLine = char !== "\n";
668
+ }
669
+ continue;
670
+ }
671
+ if (this._closed) {
672
+ this._trailer += char;
673
+ continue;
674
+ }
675
+ if (this._boundary || char === "■") {
676
+ this._boundary += char;
677
+ if (this._boundary === "■end") {
678
+ flush();
679
+ events.push(...this._parser.finish());
680
+ this._boundary = "";
681
+ this._closed = true;
682
+ } else if (!"■end".startsWith(this._boundary)) {
683
+ forward += this._boundary;
684
+ this._boundary = "";
685
+ }
686
+ } else forward += char;
687
+ }
688
+ flush();
689
+ return events;
690
+ }
691
+ finish(stopReason) {
692
+ if (this._finished) return [];
693
+ this._finished = true;
694
+ const events = [];
695
+ if (this._mode === "detect") {
696
+ if (this._prefix.trim() === "■start") this._mode = "framed";
697
+ else this._fail("Missing ■start: every response must begin with the response envelope");
698
+ this._prefix = "";
699
+ }
700
+ if (this.framed) {
701
+ if (!this._boundary && stopReason === "stop") this._closed = true;
702
+ else if (this._boundary) events.push(...this._parser.push(this._boundary));
703
+ events.push(...this._parser.finish());
704
+ const trailer = this._trailer.trim();
705
+ if (!this._closed) this._fail("Missing ■end: the response envelope is incomplete");
706
+ else if (this._parser.diagnostics.some((d) => d.code !== "example-delimiter")) this._fail("The response envelope contains malformed protocol blocks");
707
+ if (!this._failure) this._validateBlocks();
708
+ if (trailer === "\"\"\"") {
709
+ const parser = new StreamingMessageParser();
710
+ events.push(...parser.push(trailer), ...parser.finish());
711
+ this._trailingDiagnostics = parser.diagnostics;
712
+ } else if (trailer) {
713
+ const diagnostic = {
714
+ code: "unexpected-text",
715
+ message: "Discarded content after ■end"
716
+ };
717
+ this._trailingDiagnostics.push(diagnostic);
718
+ events.push({
719
+ type: "diagnostic",
720
+ diagnostic
721
+ });
722
+ }
723
+ if (this._failure) events.push({
724
+ type: "diagnostic",
725
+ diagnostic: this._failure
726
+ });
727
+ } else if (this._failure) events.push({
728
+ type: "diagnostic",
729
+ diagnostic: this._failure
730
+ });
731
+ return events;
732
+ }
733
+ _trailingDiagnostics = [];
734
+ _validateBlocks() {
735
+ const items = this._parser.items;
736
+ const runs = items.filter((item) => item.kind === "run");
737
+ const next = items.findIndex((item) => item.kind === "next");
738
+ const run = items.findIndex((item) => item.kind === "run");
739
+ if (runs.length > 1 || run >= 0 && items.slice(run + 1).some((item) => item.kind === "send")) this._fail("Use at most one ■run, after all messages; never send a message after code");
740
+ else if (run >= 0 && require_compiler.hasTopLevelReturn(items[run].body ?? "")) {
741
+ if (run !== items.length - 1) this._fail("After code returning a result, write ■end and wait for the result");
742
+ } else if (next < 0 && run < 0) this._fail("Finish with ■next, or return a result from ■run for the next iteration");
743
+ }
744
+ _fail(message) {
745
+ this._failure = {
746
+ code: "invalid-envelope",
747
+ message
748
+ };
749
+ }
750
+ };
751
+ //#endregion
536
752
  //#region src/prompts/common.ts
537
753
  var common_exports = /* @__PURE__ */ require_compiler.__exportAll({
538
754
  parseAssistantResponse: () => parseAssistantResponse,
539
755
  replacePlaceholders: () => replacePlaceholders,
540
756
  toParsedAssistantResponse: () => toParsedAssistantResponse
541
757
  });
542
- /** Strips wrapping code fences the model may have added around the whole response. */
543
- const stripWrappingFences = (text) => text.trim().split("\n").filter((line, index, arr) => {
544
- if ((index === 0 || index === arr.length - 1) && line.trim().startsWith("```")) return false;
545
- return true;
546
- }).join("\n");
547
758
  /** Builds a {@link ParsedAssistantResponse} from parsed protocol items. */
548
759
  const toParsedAssistantResponse = (items, raw, diagnostics = []) => {
549
760
  var _run$body;
@@ -573,10 +784,10 @@ const toParsedAssistantResponse = (items, raw, diagnostics = []) => {
573
784
  } : void 0
574
785
  };
575
786
  };
576
- const parseAssistantResponse = (response) => {
577
- const parser = new StreamingMessageParser();
578
- parser.push(stripWrappingFences(response));
579
- parser.finish();
787
+ const parseAssistantResponse = (response, stopReason) => {
788
+ const parser = new ResponseParser();
789
+ parser.push(response);
790
+ parser.finish(stopReason);
580
791
  return toParsedAssistantResponse(parser.items, response, parser.diagnostics);
581
792
  };
582
793
  const replacePlaceholders = (prompt, values) => {
@@ -605,6 +816,12 @@ Object.defineProperty(exports, "NAME_REGEX", {
605
816
  return NAME_REGEX;
606
817
  }
607
818
  });
819
+ Object.defineProperty(exports, "ResponseParser", {
820
+ enumerable: true,
821
+ get: function() {
822
+ return ResponseParser;
823
+ }
824
+ });
608
825
  Object.defineProperty(exports, "StreamingMessageParser", {
609
826
  enumerable: true,
610
827
  get: function() {
@@ -1,5 +1,5 @@
1
1
  const require_compiler = require("./compiler-C-OI9sim.cjs");
2
- const require_jsx = require("./jsx-D5Y2cPo-.cjs");
2
+ const require_jsx = require("./jsx-owqxrquU.cjs");
3
3
  //#region src/component.ts
4
4
  var component_exports = /* @__PURE__ */ require_compiler.__exportAll({
5
5
  Component: () => Component,
@@ -1,5 +1,5 @@
1
1
  import { n as __exportAll } from "./rolldown-runtime-EAsCxrDo.js";
2
- import { n as isAnyJsxComponent, r as isJsxComponent, t as createJsxComponent } from "./jsx-B0iYyvfr.js";
2
+ import { n as isAnyJsxComponent, r as isJsxComponent, t as createJsxComponent } from "./jsx-CIgdGGVs.js";
3
3
  //#region src/component.ts
4
4
  var component_exports = /* @__PURE__ */ __exportAll({
5
5
  Component: () => Component,
@@ -29,6 +29,11 @@ export declare const DefaultComponents: {
29
29
  generation: {
30
30
  usage: string;
31
31
  examples: ({
32
+ props: {
33
+ action: string;
34
+ label: string;
35
+ };
36
+ }[] | {
32
37
  props: {
33
38
  action: string;
34
39
  label: string;
@@ -194,6 +199,11 @@ export declare const DefaultComponents: {
194
199
  generation: {
195
200
  usage: string;
196
201
  examples: ({
202
+ props: {
203
+ action: string;
204
+ label: string;
205
+ };
206
+ }[] | {
197
207
  props: {
198
208
  action: string;
199
209
  label: string;
package/dist/context.d.ts CHANGED
@@ -579,14 +579,10 @@ export declare class Context implements Serializable<Context.JSON> {
579
579
  */
580
580
  maxTimeToFirstToken?: number;
581
581
  /**
582
- * Allow Cognitive to restart a failed stream on another model. With fallback
583
- * enabled, there is no buffered delivery and no final delivery queue: delta
584
- * text and completed Chat.handler sends stream immediately during generation.
585
- * A reset-only delta (restart: true) on Chat.onMessageDelta invalidates ALL
586
- * current-iteration messages, including completed sends — consumers must
587
- * retract/replace them, which is unsafe for irreversible external transports.
588
- * Only TOOL/CODE execution waits for a successful stream. Streaming-only;
589
- * defaults to false, which leaves progressive sending unchanged.
582
+ * Allow Cognitive to restart a failed stream on another model. Previews remain
583
+ * live and are retracted with a restart delta before replacement output.
584
+ * Completed sends and code always wait for a valid response and successful
585
+ * transport. Streaming-only; defaults to false.
590
586
  */
591
587
  midStreamFallback?: boolean;
592
588
  /**
@@ -1,13 +1,13 @@
1
- import { d as baseCreate, i as inspect, l as flatRest, r as extractType, t as DualModePrompt, u as copyArray } from "./dual-modes-Cy0_W4O2.js";
1
+ import { c as baseCreate, i as inspect, o as flatRest, r as extractType, s as copyArray, t as DualModePrompt } from "./dual-modes-DDkoCp3R.js";
2
2
  import { a as Symbol, n as isArray, o as root, r as isObjectLike } from "./_overArg-CRYbj1NH.js";
3
3
  import { D as isBuffer, E as baseUnary, M as baseAssignValue, R as isObject, T as nodeUtil, _ as baseGet, c as _getTag_default, f as getSymbols, h as Stack, k as isPrototype, s as Uint8Array, u as getAllKeys, v as toKey, x as keys, y as castPath, z as arrayMap } from "./_baseIteratee-P_firB7b.js";
4
4
  import { _ as getSymbolsIn, b as keysIn, g as getAllKeysIn, i as getErrorMessage, o as getTokenizer, x as assignValue, y as baseSlice } from "./utils-UBeAFeEI.js";
5
5
  import { t as getPrototype } from "./_getPrototype-CG7Dxrrz.js";
6
- import { a as isPlainObject } from "./jsx-B0iYyvfr.js";
7
- import { n as assertValidComponent } from "./component-Dq7ZLdvy.js";
6
+ import { t as isPlainObject } from "./isPlainObject-D39AzPO2.js";
8
7
  import { t as Tool } from "./tool-Bv8N4IPj.js";
9
8
  import { l as ThinkSignal, o as LoopExceededError } from "./errors-Cg1G0Awu.js";
10
9
  import { t as Exit } from "./exit-CDdxDBRT.js";
10
+ import { n as assertValidComponent } from "./component-DGG7d_Mz.js";
11
11
  import { i as wrapContent, t as stripTruncationTags } from "./truncator-DZqEqnpD.js";
12
12
  import { z } from "@bpinternal/zui";
13
13
  import { ulid } from "ulid";
@@ -2304,14 +2304,10 @@ var Context = class {
2304
2304
  */
2305
2305
  maxTimeToFirstToken;
2306
2306
  /**
2307
- * Allow Cognitive to restart a failed stream on another model. With fallback
2308
- * enabled, there is no buffered delivery and no final delivery queue: delta
2309
- * text and completed Chat.handler sends stream immediately during generation.
2310
- * A reset-only delta (restart: true) on Chat.onMessageDelta invalidates ALL
2311
- * current-iteration messages, including completed sends — consumers must
2312
- * retract/replace them, which is unsafe for irreversible external transports.
2313
- * Only TOOL/CODE execution waits for a successful stream. Streaming-only;
2314
- * 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.
2315
2311
  */
2316
2312
  midStreamFallback;
2317
2313
  /**
@@ -2479,7 +2475,14 @@ var Context = class {
2479
2475
  await this.version.getInvalidCodeMessage({
2480
2476
  isChatEnabled: parameters.components.length > 0,
2481
2477
  code: lastIteration.next ? `■next=${lastIteration.next.name} ${JSON.stringify(lastIteration.next.props)}` : lastIteration.code ?? "// No code generated",
2482
- message: `Invalid ■next block (${lastIteration.status.exit_error.exit}): ${lastIteration.status.exit_error.message}`
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: getErrorMessage(trace.error) }
2485
+ }))
2483
2486
  })
2484
2487
  ]);
2485
2488
  }
@@ -1,13 +1,13 @@
1
- const require_dual_modes = require("./dual-modes-Cb7ThvoV.cjs");
1
+ const require_dual_modes = require("./dual-modes-DPXiuvNe.cjs");
2
2
  const require__overArg = require("./_overArg-C5Hy7oCi.cjs");
3
3
  const require__baseIteratee = require("./_baseIteratee-CF4qP2a8.cjs");
4
4
  const require_utils = require("./utils-3ESwP3yg.cjs");
5
5
  const require__getPrototype = require("./_getPrototype-DQDlNVVM.cjs");
6
- const require_jsx = require("./jsx-D5Y2cPo-.cjs");
7
- const require_component = require("./component-BXS8vAwO.cjs");
6
+ const require_isPlainObject = require("./isPlainObject-CSxXVKCk.cjs");
8
7
  const require_tool = require("./tool-Dy6AJpJH.cjs");
9
8
  const require_errors = require("./errors-C962uJdS.cjs");
10
9
  const require_exit = require("./exit-DUM96DN1.cjs");
10
+ const require_component = require("./component-C6Agl2ns.cjs");
11
11
  const require_truncator = require("./truncator-CLkouTCO.cjs");
12
12
  let _bpinternal_zui = require("@bpinternal/zui");
13
13
  let ulid = require("ulid");
@@ -539,7 +539,7 @@ function baseUnset(object, path) {
539
539
  * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
540
540
  */
541
541
  function customOmitClone(value) {
542
- return require_jsx.isPlainObject(value) ? void 0 : value;
542
+ return require_isPlainObject.isPlainObject(value) ? void 0 : value;
543
543
  }
544
544
  //#endregion
545
545
  //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/omit.js
@@ -2304,14 +2304,10 @@ var Context = class {
2304
2304
  */
2305
2305
  maxTimeToFirstToken;
2306
2306
  /**
2307
- * Allow Cognitive to restart a failed stream on another model. With fallback
2308
- * enabled, there is no buffered delivery and no final delivery queue: delta
2309
- * text and completed Chat.handler sends stream immediately during generation.
2310
- * A reset-only delta (restart: true) on Chat.onMessageDelta invalidates ALL
2311
- * current-iteration messages, including completed sends — consumers must
2312
- * retract/replace them, which is unsafe for irreversible external transports.
2313
- * Only TOOL/CODE execution waits for a successful stream. Streaming-only;
2314
- * 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.
2315
2311
  */
2316
2312
  midStreamFallback;
2317
2313
  /**
@@ -2353,9 +2349,9 @@ var Context = class {
2353
2349
  const variables = {};
2354
2350
  if ((lastIteration === null || lastIteration === void 0 ? void 0 : lastIteration.status.type) === "thinking_requested") {
2355
2351
  const lastThinkingVariables = lastIteration.status.thinking_requested.variables;
2356
- if (require_jsx.isPlainObject(lastThinkingVariables)) Object.assign(variables, cloneDeep(lastThinkingVariables));
2352
+ if (require_isPlainObject.isPlainObject(lastThinkingVariables)) Object.assign(variables, cloneDeep(lastThinkingVariables));
2357
2353
  }
2358
- if (require_jsx.isPlainObject(lastIteration === null || lastIteration === void 0 ? void 0 : lastIteration.variables)) Object.assign(variables, cloneDeep((lastIteration === null || lastIteration === void 0 ? void 0 : lastIteration.variables) ?? {}));
2354
+ if (require_isPlainObject.isPlainObject(lastIteration === null || lastIteration === void 0 ? void 0 : lastIteration.variables)) Object.assign(variables, cloneDeep((lastIteration === null || lastIteration === void 0 ? void 0 : lastIteration.variables) ?? {}));
2359
2355
  if (((_this$snapshot = this.snapshot) === null || _this$snapshot === void 0 ? void 0 : _this$snapshot.status.type) === "resolved") {
2360
2356
  for (const v of this.snapshot.variables) if (!v.truncated && v.value !== void 0) variables[v.name] = v.value;
2361
2357
  }
@@ -2479,7 +2475,14 @@ var Context = class {
2479
2475
  await this.version.getInvalidCodeMessage({
2480
2476
  isChatEnabled: parameters.components.length > 0,
2481
2477
  code: lastIteration.next ? `■next=${lastIteration.next.name} ${JSON.stringify(lastIteration.next.props)}` : lastIteration.code ?? "// No code generated",
2482
- message: `Invalid ■next block (${lastIteration.status.exit_error.exit}): ${lastIteration.status.exit_error.message}`
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
+ }))
2483
2486
  })
2484
2487
  ]);
2485
2488
  }