nolo-cli 0.32.0 → 0.33.0-alpha.3

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 (170) hide show
  1. package/README.md +6 -12
  2. package/{_executeModel-LTMSIBS4.js → _executeModel-RWPVI3YV.js} +76 -67
  3. package/{action-HI3VRQLP.js → action-SMLG6OTB.js} +17 -15
  4. package/{addContentAction-NCURJ6PK.js → addContentAction-SFO244QN.js} +14 -13
  5. package/{addDialogAgentAction-RCY4ECF4.js → addDialogAgentAction-W44ZCEHB.js} +14 -13
  6. package/{agentDeleteCommand-D3MYZK6E.js → agentDeleteCommand-KU2RXQPP.js} +42 -59
  7. package/{agentEmailCommands-6BXS574I.js → agentEmailCommands-MPCMDENS.js} +89 -80
  8. package/{agentGrantCommands-E7ZZFRHK.js → agentGrantCommands-2LEZDADN.js} +2 -2
  9. package/{agentListCommands-SF3HEUTT.js → agentListCommands-EPD4N6FX.js} +73 -78
  10. package/{agentMachineCommands-YARVXRR6.js → agentMachineCommands-AF7C3YRT.js} +40 -57
  11. package/{agentPullCommand-ARSIDNVC.js → agentPullCommand-YH5GEBK4.js} +5 -5
  12. package/agentRecordCommands-EYE6MZZG.js +112 -0
  13. package/agentRunCommand-LL22SGTN.js +130 -0
  14. package/{agentRuntimeLocal-ATGJY6WC.js → agentRuntimeLocal-JX34G47Z.js} +35 -50
  15. package/{agentSlice-4XWW344Y.js → agentSlice-TNMFQQOV.js} +15 -13
  16. package/{appDeleteCommands-63JO7RXS.js → appDeleteCommands-43K5VXQB.js} +38 -55
  17. package/{appDeployCommands-Y7EWYUGM.js → appDeployCommands-FEEJSVDZ.js} +38 -55
  18. package/{appDeployStatusCommands-ZBEY3DWB.js → appDeployStatusCommands-H76CG45R.js} +38 -55
  19. package/{appGetCommands-QSSOSEYL.js → appGetCommands-MDZYFTYZ.js} +38 -55
  20. package/{appListCommands-PH3XWNDX.js → appListCommands-TUJJXPWG.js} +38 -55
  21. package/{authCommand-BBDHMSO6.js → authCommand-T7UK4CWS.js} +18 -18
  22. package/{authCommands-4UDEKRE6.js → authCommands-EAPFGNHN.js} +8 -8
  23. package/chatQueueReduxAdapter-LVQXC4ZY.js +180 -0
  24. package/chunk-2H3XIBY4.js +239 -0
  25. package/{chunk-TEYN42N3.js → chunk-2IVEXF7P.js} +11 -4
  26. package/{chunk-WTGCTVJG.js → chunk-2QTEYCR7.js} +3 -6
  27. package/{chunk-DOISARTV.js → chunk-2UECQ7RE.js} +1 -1
  28. package/{chunk-SWYMCHM7.js → chunk-37V5LNEQ.js} +69 -1
  29. package/{chunk-E3APEOIM.js → chunk-3GZXL6FM.js} +4 -19
  30. package/{chunk-O3JR45Q2.js → chunk-3VAQHAXT.js} +44 -44
  31. package/{chunk-O5OMJPPF.js → chunk-3WXRAHCG.js} +6 -5
  32. package/{chunk-LAXMH7JY.js → chunk-57QJXIB6.js} +18 -15
  33. package/chunk-5CS33IBL.js +301 -0
  34. package/{chunk-3UGKATZQ.js → chunk-5SBK2MTI.js} +8 -369
  35. package/chunk-6PO2SYCS.js +1800 -0
  36. package/{chunk-TA6EA2A3.js → chunk-6SXC35F4.js} +182 -20
  37. package/{chunk-MXFQHRSS.js → chunk-6XIE5ZGI.js} +1 -1
  38. package/{chunk-3GZT3L6F.js → chunk-73GINUCW.js} +326 -481
  39. package/{chunk-VMWR7VNI.js → chunk-7E72JMBB.js} +7 -7
  40. package/{chunk-4PNU7W7K.js → chunk-AAGCMVFT.js} +106 -124
  41. package/chunk-ADLYMQB6.js +642 -0
  42. package/{chunk-ZWJOGMKH.js → chunk-AETZ7AD6.js} +1 -1
  43. package/{chunk-UDA3ZYLW.js → chunk-AFV4FOT2.js} +70 -24
  44. package/{chunk-BGTUGS3T.js → chunk-AOXVOC6D.js} +4 -30
  45. package/{chunk-2ZRP5RUG.js → chunk-B2BSG6QQ.js} +12 -11
  46. package/{chunk-44HACRCK.js → chunk-BANYWEYY.js} +4 -4
  47. package/{chunk-TOW4E763.js → chunk-BJIRLHJR.js} +2 -0
  48. package/{chunk-ZJ2WITOO.js → chunk-BQXOGBFN.js} +2 -2
  49. package/{chunk-G5GVZAXF.js → chunk-CLP2K7U4.js} +15 -19
  50. package/{chunk-2K4NDPT5.js → chunk-DFUPZE6V.js} +20 -12
  51. package/{chunk-YHGHADBQ.js → chunk-DPMBNHOJ.js} +4 -4
  52. package/chunk-EGRJC4ZN.js +91 -0
  53. package/{chunk-K6QEHQZ3.js → chunk-EKLRRZIN.js} +1 -1
  54. package/{chunk-XFG3BAKN.js → chunk-FMEVI5TG.js} +65 -0
  55. package/{chunk-RH53LMEJ.js → chunk-FSSX3XRY.js} +2 -4
  56. package/{chunk-VP4WJWKW.js → chunk-GM6PU7B6.js} +431 -345
  57. package/{chunk-EEF23OOK.js → chunk-GMXWYXAF.js} +7 -7
  58. package/{chunk-SFWZUTCI.js → chunk-GTYM4HKV.js} +1 -1
  59. package/{chunk-MITD7CON.js → chunk-HDKRSRYU.js} +1461 -301
  60. package/chunk-HS7MLR74.js +38 -0
  61. package/{chunk-3AUWC6EM.js → chunk-HUCT7HID.js} +5 -84
  62. package/{chunk-PTHDLIRB.js → chunk-I6N2UVVY.js} +1 -1
  63. package/chunk-IDAU4UFS.js +437 -0
  64. package/{chunk-Q76I4SXI.js → chunk-IHEC7VBF.js} +1 -1
  65. package/{chunk-OWHNFZNW.js → chunk-IL545V3E.js} +4 -4
  66. package/{chunk-3LY4F7SV.js → chunk-INZZJSQF.js} +348 -331
  67. package/{chunk-CF2WZF4N.js → chunk-J6WH4PYZ.js} +0 -8
  68. package/{chunk-2HXKAPH7.js → chunk-JMPYDFHY.js} +6 -6
  69. package/{chunk-V54H24CQ.js → chunk-JTSGWTYZ.js} +3 -3
  70. package/{chunk-ATK5WJOA.js → chunk-JZ5AMMXU.js} +4 -4
  71. package/chunk-KHCLMKZZ.js +3062 -0
  72. package/{chunk-WHLVPK32.js → chunk-KMSZPTM6.js} +27 -3
  73. package/{chunk-L3GCUVOH.js → chunk-KSRFVP36.js} +1 -1
  74. package/{chunk-DLWCWUNW.js → chunk-LOD75GOS.js} +336 -32
  75. package/{chunk-UOJRKY5J.js → chunk-M2YMQOLC.js} +44 -53
  76. package/chunk-M3JEW6N6.js +193 -0
  77. package/{chunk-XDHHF73Q.js → chunk-M4NC7NF6.js} +95 -95
  78. package/{chunk-3FCNXC2J.js → chunk-MPZJVZDC.js} +3735 -1394
  79. package/{chunk-IXZX5CJK.js → chunk-MQRZ5QUH.js} +1 -1
  80. package/{chunk-3ASDTTEI.js → chunk-MRWGHF56.js} +2 -0
  81. package/{chunk-D34RI6NI.js → chunk-NNWHHCVP.js} +75 -1
  82. package/{chunk-6YABCOFU.js → chunk-NUO3QFWD.js} +1 -1
  83. package/{chunk-GAF5X6B7.js → chunk-O6GEBMIY.js} +269 -309
  84. package/{chunk-CAENRKNJ.js → chunk-OR2HNLVO.js} +126 -88
  85. package/chunk-OW765XBU.js +10 -0
  86. package/chunk-PREQU5QV.js +231 -0
  87. package/{chunk-Q3CSL43H.js → chunk-Q5ITEGIN.js} +1 -1
  88. package/{chunk-7S54ZGF6.js → chunk-RAZOLMJR.js} +256 -12
  89. package/chunk-RCFIB45Q.js +28 -0
  90. package/chunk-RY57GLGW.js +188 -0
  91. package/{chunk-KGEVMUMI.js → chunk-TFPUAELY.js} +11 -11
  92. package/{chunk-ZJH3LKEW.js → chunk-UK5JGQVU.js} +94 -15
  93. package/chunk-URMS4XY2.js +10 -0
  94. package/{chunk-RXVX5LFR.js → chunk-VH2F7ZB6.js} +1 -1
  95. package/chunk-VIDPVFP3.js +20 -0
  96. package/{chunk-W367V5CH.js → chunk-WHD6BG7M.js} +400 -115
  97. package/{chunk-5RDLGLAP.js → chunk-WJSW43QZ.js} +4 -7
  98. package/{chunk-CF7S2RYZ.js → chunk-WLH5BAKX.js} +6 -6
  99. package/{chunk-VVEH6XUE.js → chunk-X2DAEZ3X.js} +1 -1
  100. package/{chunk-2IJAKBK2.js → chunk-X664KVEV.js} +426 -246
  101. package/{chunk-43EPBPZ2.js → chunk-XCCGU6QB.js} +2 -2
  102. package/chunk-Y5GCAMGP.js +9 -0
  103. package/{chunk-V42OE5HT.js → chunk-YDTYDA5W.js} +3 -3
  104. package/chunk-YYLHWIW6.js +48 -0
  105. package/{chunk-AOS5IN2I.js → chunk-ZHYK3N56.js} +1 -1
  106. package/{chunk-ODS2MVMU.js → chunk-ZJMME4DS.js} +19 -303
  107. package/{chunk-PJ2DDQQM.js → chunk-ZURFOV5J.js} +2 -2
  108. package/chunk-ZZ2MH7LE.js +84 -0
  109. package/{cliExecutor-BBUVQU4L.js → cliExecutor-DW3PHGEL.js} +2 -2
  110. package/{clipboardy-BVE3LVEH.js → clipboardy-MMBYVRLF.js} +166 -372
  111. package/{codingSkills-V35TRR4Y.js → codingSkills-DY5MINPG.js} +5 -4
  112. package/{createAgentAutomationAction-WLRNE7C4.js → createAgentAutomationAction-INQT23LX.js} +40 -31
  113. package/createDialogAction-LDCPDI73.js +60 -0
  114. package/{createPageAction-7YROVZ3W.js → createPageAction-5YXOG2M4.js} +56 -47
  115. package/{db-6DPSJ6WT.js → db-3H3JECGY.js} +45 -5
  116. package/{dbSlice-BBL3PEVW.js → dbSlice-3SD5L5H2.js} +13 -12
  117. package/{deleteFile-RJTEPOT4.js → deleteFile-XQXPBFFB.js} +7 -6
  118. package/dialogCommands-CHJO47AX.js +81 -0
  119. package/{dialogSlice-N4HPG6HM.js → dialogSlice-DOWKOILN.js} +36 -29
  120. package/{docCreateCommands-GRA5BHSA.js → docCreateCommands-OVZARUFX.js} +40 -55
  121. package/{docDeleteCommands-ONIJM5MD.js → docDeleteCommands-E2XJ62LD.js} +42 -57
  122. package/{docReadCommands-H55VQ2US.js → docReadCommands-I7OSREPJ.js} +40 -55
  123. package/{docStore-B5AHDNW5.js → docStore-UAWSKZ2Y.js} +39 -30
  124. package/{docUpdateCommands-ZQIQVGC2.js → docUpdateCommands-X4Z26VJM.js} +43 -58
  125. package/{fetchMessages-VPPQDDZ4.js → fetchMessages-7QRCCRYK.js} +3 -3
  126. package/{getPricing-QO5TYNCK.js → getPricing-L2ENXWHV.js} +7 -6
  127. package/{handleSendMessageAction-IN5XX5U7.js → handleSendMessageAction-C3TSDWKH.js} +38 -31
  128. package/index.js +67 -67
  129. package/{lib-FYYBQIXS.js → lib-2ZTNRXR4.js} +432 -183
  130. package/{localDialogRead-3DBXVYXS.js → localDialogRead-SLMPV5SK.js} +2 -2
  131. package/{localRuntimeAuthority-NDUA2D7Y.js → localRuntimeAuthority-E3R24J4T.js} +4 -2
  132. package/{localRuntimeDb-GKYRBWLQ.js → localRuntimeDb-DDZCJFQZ.js} +1 -1
  133. package/{machineCommands-H3UMKE76.js → machineCommands-BUOIYJAD.js} +93 -84
  134. package/{machineWsRunDispatch-HONRUK3R.js → machineWsRunDispatch-7CRWAA6O.js} +83 -74
  135. package/{models-WDUTTYFS.js → models-OX2S5C6Q.js} +2 -2
  136. package/{offlineMarxistsAgentCommand-E6LUG63A.js → offlineMarxistsAgentCommand-GEH6SNNA.js} +1 -1
  137. package/package.json +1 -4
  138. package/{read-64OQDO3I.js → read-6G73BMEY.js} +8 -7
  139. package/{readDocTool-MXM3T6PE.js → readDocTool-DK4EI2GA.js} +1 -2
  140. package/{readlineWorkspace-XVJZDCSC.js → readlineWorkspace-ZDWEASJV.js} +265 -428
  141. package/{removeDialogAgentAction-NEKVAMSH.js → removeDialogAgentAction-E7H557UO.js} +19 -17
  142. package/{runAgentClientLoop-H7U53QB6.js → runAgentClientLoop-U7HYA3O5.js} +72 -64
  143. package/{runtimeDoctorCommands-WI2YZUSJ.js → runtimeDoctorCommands-KIKM6BIO.js} +5 -5
  144. package/{setDialogExtraReferencesAction-WTOHQDIV.js → setDialogExtraReferencesAction-RMMGBR5F.js} +15 -14
  145. package/{setPrimaryDialogAgentAction-LDJOYC4F.js → setPrimaryDialogAgentAction-FWBKKLVA.js} +19 -17
  146. package/{settingSlice-4M37TN7V.js → settingSlice-73PV4KG4.js} +16 -14
  147. package/{skillDiscovery-5U6RYAHN.js → skillDiscovery-KLLKXPUO.js} +4 -4
  148. package/{slateUtils-2M7MUTWX.js → slateUtils-VO2FU36K.js} +1 -1
  149. package/{spaceCommands-7VVKJBDV.js → spaceCommands-GEWZXGHM.js} +43 -240
  150. package/{spaceSlice-T6YK6D34.js → spaceSlice-B6MOVY4N.js} +38 -61
  151. package/{streamAgentChatTurn-RQ63QFQ7.js → streamAgentChatTurn-T527EQTT.js} +1261 -150
  152. package/{switchDialogAgentAction-XVWGKR2Z.js → switchDialogAgentAction-US6QNL3N.js} +14 -13
  153. package/syncMapping-RK2MANUX.js +43 -0
  154. package/{tableCommands-RJZ3V4TF.js → tableCommands-QE47K72R.js} +8 -7
  155. package/{toolApiClient-ARGFDJAG.js → toolApiClient-B2MFXMEG.js} +3 -3
  156. package/tools-XMWCVMPM.js +98 -0
  157. package/{tuiSummaryLlmCaller-SRZ4QQUP.js → tuiSummaryLlmCaller-NCAJSVSD.js} +24 -21
  158. package/{updateDialogTitleAction-BBDSWHNG.js → updateDialogTitleAction-XPJZRJEL.js} +48 -38
  159. package/agentRecordCommands-JFZRQJQ4.js +0 -103
  160. package/agentRunCommand-NOX5FLKO.js +0 -121
  161. package/chunk-AYMOSAHE.js +0 -3158
  162. package/chunk-D2BPX6DQ.js +0 -1707
  163. package/chunk-DCDL3GC4.js +0 -171
  164. package/chunk-F3MP7CP6.js +0 -73
  165. package/chunk-WZSRQNQG.js +0 -2587
  166. package/createDialogAction-Y6YV64QB.js +0 -52
  167. package/dialogCommands-XLO5CAHZ.js +0 -95
  168. package/tools-KYZX3BGO.js +0 -90
  169. package/{chunk-Z5MXSEOJ.js → chunk-RQSOAMPJ.js} +2 -2
  170. package/{chunk-JDSUTNYY.js → chunk-SAQQLJZ5.js} +3 -3
@@ -3,7 +3,11 @@ import {
3
3
  } from "./chunk-T27IEBNQ.js";
4
4
  import {
5
5
  accumulateToolCallDelta,
6
+ createThinkParserState,
7
+ createToolCallAccumulator,
8
+ createToolCallTextParserState,
6
9
  extractThinkContent,
10
+ finalizeAccumulatedToolCalls,
7
11
  flushThinkParser,
8
12
  flushToolCallTextParserIntoCallback,
9
13
  longestTagPrefixLength,
@@ -14,11 +18,12 @@ import {
14
18
  convertMessagesToResponsesInput,
15
19
  extractTextFromResponseOutput,
16
20
  extractToolCallsFromResponseOutput,
21
+ getUsageRequestOptions,
17
22
  hasImageParts,
18
23
  shouldStripReasoningContentForOutbound,
19
24
  toOpenAiCompatibleMessages,
20
25
  toResponsesTools
21
- } from "./chunk-D34RI6NI.js";
26
+ } from "./chunk-NNWHHCVP.js";
22
27
  import {
23
28
  buildProviderExecutionPlan,
24
29
  canUsePlatformChatProvider,
@@ -27,14 +32,48 @@ import {
27
32
  resolvePlatformAuthToken,
28
33
  resolvePlatformServerUrl,
29
34
  resolveProviderTransportDecision
30
- } from "./chunk-UDA3ZYLW.js";
35
+ } from "./chunk-AFV4FOT2.js";
31
36
  import {
32
37
  clipCompactText
33
- } from "./chunk-BGTUGS3T.js";
38
+ } from "./chunk-AOXVOC6D.js";
34
39
  import {
35
40
  isRecord
36
41
  } from "./chunk-KUG52IAP.js";
37
42
 
43
+ // packages/ai/token/sseUsageExtract.ts
44
+ var TOKEN_FIELDS = [
45
+ "prompt_tokens",
46
+ "completion_tokens",
47
+ "input_tokens",
48
+ "output_tokens",
49
+ "total_tokens"
50
+ ];
51
+ function hasUsageTokens(value) {
52
+ if (!value || typeof value !== "object") return false;
53
+ const record = value;
54
+ return TOKEN_FIELDS.some(
55
+ (field) => typeof record[field] === "number" && Number.isFinite(record[field])
56
+ );
57
+ }
58
+ function extractUsageFromSsePayload(parsed) {
59
+ if (!parsed || typeof parsed !== "object") return void 0;
60
+ const payload = parsed;
61
+ const topLevel = payload.usage;
62
+ if (topLevel && typeof topLevel === "object" && hasUsageTokens(topLevel)) {
63
+ return topLevel;
64
+ }
65
+ if (payload.type === "response.completed") {
66
+ const response = payload.response;
67
+ if (response && typeof response === "object") {
68
+ const nested = response.usage;
69
+ if (nested && typeof nested === "object" && hasUsageTokens(nested)) {
70
+ return nested;
71
+ }
72
+ }
73
+ }
74
+ return void 0;
75
+ }
76
+
38
77
  // packages/core/chat/providerFailureMessage.ts
39
78
  var RAW_BODY_CLIP = 400;
40
79
  function describeProviderFailure(args) {
@@ -147,6 +186,54 @@ function parseDsml(text) {
147
186
  return { content: chunk.content + tail.content, toolCalls: [...chunk.toolCalls, ...tail.toolCalls] };
148
187
  }
149
188
 
189
+ // packages/agent-runtime/responsesToolCallAccumulator.ts
190
+ function normalizeResponsesToolArguments(value) {
191
+ if (typeof value === "string") return value;
192
+ if (value && typeof value === "object") {
193
+ try {
194
+ return JSON.stringify(value);
195
+ } catch {
196
+ return void 0;
197
+ }
198
+ }
199
+ return void 0;
200
+ }
201
+ function createResponsesToolAccumulator() {
202
+ return /* @__PURE__ */ new Map();
203
+ }
204
+ function keyOf(event) {
205
+ return typeof event?.item_id === "string" && event.item_id ? event.item_id : typeof event?.item?.id === "string" && event.item.id ? event.item.id : typeof event?.item?.call_id === "string" && event.item.call_id ? event.item.call_id : typeof event?.call_id === "string" && event.call_id ? event.call_id : "";
206
+ }
207
+ function applyResponsesToolEvent(calls, event) {
208
+ const key = keyOf(event);
209
+ if (!key) return;
210
+ const item = event?.item;
211
+ const id = item?.call_id || item?.id || event?.call_id || key;
212
+ const current = calls.get(key) ?? { id, name: "", arguments: "" };
213
+ if (typeof item?.name === "string" && item.name) current.name = item.name;
214
+ const itemArguments = normalizeResponsesToolArguments(item?.arguments);
215
+ if (itemArguments !== void 0) current.arguments = itemArguments;
216
+ const eventArguments = normalizeResponsesToolArguments(event?.arguments);
217
+ if (eventArguments !== void 0) current.arguments = eventArguments;
218
+ if (typeof event?.delta === "string") current.arguments += event.delta;
219
+ calls.set(key, current);
220
+ }
221
+ function addResponsesToolCall(calls, call) {
222
+ const key = call.id;
223
+ calls.set(key, {
224
+ id: call.id,
225
+ name: call.function.name,
226
+ arguments: call.function.arguments
227
+ });
228
+ }
229
+ function finalizeResponsesToolCalls(calls) {
230
+ return [...calls.values()].filter((call) => call.name).map((call) => ({
231
+ id: call.id,
232
+ type: "function",
233
+ function: { name: call.name, arguments: call.arguments }
234
+ }));
235
+ }
236
+
150
237
  // packages/agent-runtime/processChatCompletionDelta.ts
151
238
  function extractChatCompletionStreamError(parsed) {
152
239
  const raw = parsed?.error;
@@ -177,8 +264,9 @@ function applyChatCompletionDelta(parsed, state) {
177
264
  if (streamError && !state.streamError) {
178
265
  state.streamError = streamError;
179
266
  }
180
- if (parsed?.usage && typeof parsed.usage === "object") {
181
- state.usage = parsed.usage;
267
+ const extractedUsage = extractUsageFromSsePayload(parsed);
268
+ if (extractedUsage) {
269
+ state.usage = extractedUsage;
182
270
  }
183
271
  const rawFinishReason = parsed?.choices?.[0]?.finish_reason;
184
272
  if (typeof rawFinishReason === "string" && rawFinishReason.length > 0) {
@@ -260,11 +348,10 @@ async function* readSseFrames(response) {
260
348
  }
261
349
  if (buffer.trim()) yield buffer;
262
350
  }
263
- async function readSseDataValues(response, parse) {
351
+ async function* streamSseDataValues(response, parse) {
264
352
  const reader = response.body?.getReader();
265
- if (!reader) return [];
353
+ if (!reader) return;
266
354
  const decoder = new TextDecoder();
267
- const values = [];
268
355
  let buffer = "";
269
356
  while (true) {
270
357
  const { done, value } = await reader.read();
@@ -274,12 +361,18 @@ async function readSseDataValues(response, parse) {
274
361
  buffer = lines.pop() ?? "";
275
362
  for (const line of lines) {
276
363
  const parsed = parse(line);
277
- if (parsed) values.push(parsed);
364
+ if (parsed) yield parsed;
278
365
  }
279
366
  }
280
367
  if (buffer.trim()) {
281
368
  const parsed = parse(buffer);
282
- if (parsed) values.push(parsed);
369
+ if (parsed) yield parsed;
370
+ }
371
+ }
372
+ async function readSseDataValues(response, parse) {
373
+ const values = [];
374
+ for await (const value of streamSseDataValues(response, parse)) {
375
+ values.push(value);
283
376
  }
284
377
  return values;
285
378
  }
@@ -365,7 +458,7 @@ function buildPlatformChatCompletionRequest(args) {
365
458
  })
366
459
  },
367
460
  stream: args.stream ?? false,
368
- ...args.stream ? { stream_options: { include_usage: true } } : {},
461
+ ...args.stream ? getUsageRequestOptions(args.providerConfig.provider, { api: "chat-completions" }) : {},
369
462
  ...requestOptions,
370
463
  ...args.tools && args.tools.length > 0 ? {
371
464
  tools: usesResponsesApi ? toResponsesTools(args.tools) : args.tools,
@@ -375,6 +468,7 @@ function buildPlatformChatCompletionRequest(args) {
375
468
  url: args.providerConfig.endpoint,
376
469
  provider: args.providerConfig.provider,
377
470
  agentKey: args.providerConfig.agentKey,
471
+ ...args.dialogId?.trim() ? { dialogId: args.dialogId.trim() } : {},
378
472
  ...args.providerConfig.apiSource ? { apiSource: args.providerConfig.apiSource } : {},
379
473
  ...args.providerConfig.apiKey ? { KEY: args.providerConfig.apiKey } : {},
380
474
  ...args.providerConfig.apiKeyHeader ? { apiKeyHeader: args.providerConfig.apiKeyHeader } : {}
@@ -442,7 +536,8 @@ function parsePlatformChatCompletionData(raw) {
442
536
  return objects.find((object) => Array.isArray(object?.choices)) ?? objects[0] ?? {};
443
537
  }
444
538
  function parsePlatformChatCompletionResponse(args) {
445
- if (isResponsesEndpoint(args.providerConfig.endpoint)) {
539
+ const hasCompletionsShape = Array.isArray(args.data?.choices);
540
+ if (!hasCompletionsShape && isResponsesEndpoint(args.providerConfig.endpoint)) {
446
541
  const rawContent2 = extractTextFromResponseOutput(args.data);
447
542
  const dsml = parseDsml(rawContent2);
448
543
  const tool_calls = extractToolCallsFromResponseOutput(args.data);
@@ -464,18 +559,162 @@ function parsePlatformChatCompletionResponse(args) {
464
559
  const choiceMessage = args.data?.choices?.[0]?.message ?? {};
465
560
  const rawContent = String(choiceMessage?.content ?? "");
466
561
  const { content, reasoning } = extractThinkContent(rawContent);
562
+ const rawFinishReason = args.data?.choices?.[0]?.finish_reason;
467
563
  return {
468
564
  content,
469
565
  model: args.providerConfig.model,
470
566
  provider: args.providerConfig.provider,
471
567
  ...Array.isArray(choiceMessage?.tool_calls) ? { tool_calls: choiceMessage.tool_calls } : {},
472
568
  ...reasoning ? { reasoning_content: reasoning } : typeof choiceMessage?.reasoning_content === "string" && choiceMessage.reasoning_content ? { reasoning_content: choiceMessage.reasoning_content } : {},
569
+ ...typeof rawFinishReason === "string" && rawFinishReason.length > 0 ? { finish_reason: rawFinishReason } : {},
473
570
  // 非流式:完整的 200 JSON body 即证明调用走完,见 AgentRuntimeResult。
474
571
  stream_complete: true,
475
572
  usage: args.data?.usage,
476
573
  trace: args.trace
477
574
  };
478
575
  }
576
+ function processPlatformChatSseEvent(event, state) {
577
+ for (const line of event.split("\n")) {
578
+ const trimmed = line.trim();
579
+ if (!trimmed.startsWith("data:")) continue;
580
+ const payload = trimmed.slice(5).trim();
581
+ if (!payload || payload === "[DONE]") continue;
582
+ let parsed;
583
+ try {
584
+ parsed = JSON.parse(payload);
585
+ } catch {
586
+ continue;
587
+ }
588
+ if (parsed?.billing && typeof parsed.billing === "object") {
589
+ state.billing = parsed.billing;
590
+ }
591
+ const extractedUsage = extractUsageFromSsePayload(parsed);
592
+ if (extractedUsage) {
593
+ state.usage = extractedUsage;
594
+ } else if (parsed?.usage && typeof parsed.usage === "object" && !hasUsageTokens(parsed.usage)) {
595
+ state.billing = {
596
+ ...state.billing ?? {},
597
+ ...parsed.usage
598
+ };
599
+ }
600
+ if (Array.isArray(parsed?.choices)) {
601
+ applyChatCompletionDelta(parsed, state);
602
+ continue;
603
+ }
604
+ if (!state.usesResponsesApi) {
605
+ applyChatCompletionDelta(parsed, state);
606
+ continue;
607
+ }
608
+ if (!state.streamError) {
609
+ const responsesError = extractChatCompletionStreamError(parsed);
610
+ if (responsesError) state.streamError = responsesError;
611
+ }
612
+ const eventType = typeof parsed?.type === "string" ? parsed.type : "";
613
+ if (eventType === "response.output_text.delta" && typeof parsed?.delta === "string") {
614
+ const dsml = pushDsmlChunk(parsed.delta, state.dsmlToolCallState);
615
+ for (const [index, call] of dsml.toolCalls.entries()) {
616
+ const id = buildDsmlToolCallId(state.responsesToolCalls.size, index);
617
+ addResponsesToolCall(state.responsesToolCalls, {
618
+ id,
619
+ type: "function",
620
+ function: { name: call.name, arguments: call.arguments }
621
+ });
622
+ }
623
+ if (dsml.content) {
624
+ state.content += dsml.content;
625
+ state.onTextDelta?.(dsml.content);
626
+ }
627
+ continue;
628
+ }
629
+ if (eventType === "response.reasoning_text.delta" && typeof parsed?.delta === "string") {
630
+ state.reasoning += parsed.delta;
631
+ state.onReasoningDelta?.(parsed.delta);
632
+ continue;
633
+ }
634
+ if (eventType === "response.output_item.added" || eventType === "response.output_item.done" || eventType === "response.function_call_arguments.delta" || eventType === "response.function_call_arguments.done") {
635
+ applyResponsesToolEvent(state.responsesToolCalls, parsed);
636
+ continue;
637
+ }
638
+ if (eventType === "response.completed" && parsed?.response) {
639
+ state.completedResponsesPayload = parsed.response;
640
+ }
641
+ }
642
+ }
643
+ async function readPlatformChatSseCompletion(args) {
644
+ const state = {
645
+ content: "",
646
+ reasoning: "",
647
+ usage: void 0,
648
+ billing: void 0,
649
+ usesResponsesApi: args.usesResponsesApi,
650
+ onTextDelta: args.onTextDelta,
651
+ onReasoningDelta: args.onReasoningDelta,
652
+ completedResponsesPayload: void 0,
653
+ responsesToolCalls: createResponsesToolAccumulator(),
654
+ dsmlToolCallState: createDsmlParserState(),
655
+ streamError: void 0,
656
+ accumulatedToolCalls: createToolCallAccumulator(),
657
+ thinkState: createThinkParserState(),
658
+ toolCallTextState: createToolCallTextParserState(),
659
+ finishReason: void 0
660
+ };
661
+ for await (const frame of readSseFrames(args.response)) {
662
+ processPlatformChatSseEvent(frame, state);
663
+ }
664
+ flushChatCompletionStream(state);
665
+ if (state.usesResponsesApi) {
666
+ const dsml = finishDsml(state.dsmlToolCallState);
667
+ for (const [index, call] of dsml.toolCalls.entries()) {
668
+ const id = buildDsmlToolCallId(state.responsesToolCalls.size, index);
669
+ addResponsesToolCall(state.responsesToolCalls, {
670
+ id,
671
+ type: "function",
672
+ function: { name: call.name, arguments: call.arguments }
673
+ });
674
+ }
675
+ if (dsml.content) state.content += dsml.content;
676
+ }
677
+ throwIfChatCompletionStreamFailed(state);
678
+ if (state.usesResponsesApi) {
679
+ const response = state.completedResponsesPayload;
680
+ const completedToolCalls = response ? extractToolCallsFromResponseOutput(response) : [];
681
+ const finalContent = response ? extractTextFromResponseOutput(response) : "";
682
+ const normalizedFinal = finalContent ? parseDsml(finalContent) : { content: "", toolCalls: [] };
683
+ const normalizedDsmlCalls = normalizedFinal.toolCalls.map((call, index) => ({
684
+ id: buildDsmlToolCallId(completedToolCalls.length, index),
685
+ type: "function",
686
+ function: { name: call.name, arguments: call.arguments }
687
+ }));
688
+ const completionsToolCalls = finalizeAccumulatedToolCalls(
689
+ state.accumulatedToolCalls
690
+ );
691
+ const tool_calls2 = completedToolCalls.length > 0 ? completedToolCalls : normalizedDsmlCalls.length > 0 ? normalizedDsmlCalls : completionsToolCalls.length > 0 ? completionsToolCalls : finalizeResponsesToolCalls(state.responsesToolCalls);
692
+ const finalUsage2 = mergeBillingIntoUsage(state.usage, state.billing);
693
+ return {
694
+ content: normalizedFinal.content || state.content,
695
+ ...state.reasoning ? { reasoning_content: state.reasoning } : {},
696
+ ...tool_calls2.length > 0 ? { tool_calls: tool_calls2 } : {},
697
+ ...finalUsage2 ? { usage: finalUsage2, stream_complete: true } : {},
698
+ // finish_reason 供 executePlatformChatCompletion 穿透给 localLoop 的
699
+ // 空轮/截断判定;此前 reader 从不回传,流式路径恒缺。
700
+ ...state.finishReason ? { finish_reason: state.finishReason } : {}
701
+ };
702
+ }
703
+ const tool_calls = finalizeAccumulatedToolCalls(state.accumulatedToolCalls);
704
+ const finalUsage = mergeBillingIntoUsage(state.usage, state.billing);
705
+ return {
706
+ content: state.content,
707
+ ...state.reasoning ? { reasoning_content: state.reasoning } : {},
708
+ ...tool_calls.length > 0 ? { tool_calls } : {},
709
+ ...finalUsage ? { usage: finalUsage, stream_complete: true } : {},
710
+ ...state.finishReason ? { finish_reason: state.finishReason } : {}
711
+ };
712
+ }
713
+ function mergeBillingIntoUsage(usage, billing) {
714
+ if (!billing) return usage;
715
+ if (!usage) return billing;
716
+ return { ...usage, ...billing };
717
+ }
479
718
  function canUsePlatformChatProvider2(env) {
480
719
  return canUsePlatformChatProvider(env);
481
720
  }
@@ -506,11 +745,16 @@ export {
506
745
  flushChatCompletionStream,
507
746
  providerHttpFailure,
508
747
  readSseFrames,
748
+ streamSseDataValues,
509
749
  readSseDataValues,
750
+ createResponsesToolAccumulator,
751
+ applyResponsesToolEvent,
752
+ finalizeResponsesToolCalls,
510
753
  resolvePlatformChatProviderConfig,
511
754
  buildPlatformChatCompletionRequest,
512
755
  parsePlatformChatCompletionData,
513
756
  parsePlatformChatCompletionResponse,
757
+ readPlatformChatSseCompletion,
514
758
  canUsePlatformChatProvider2 as canUsePlatformChatProvider,
515
759
  hasDirectOpenAiCompatibleProvider2 as hasDirectOpenAiCompatibleProvider,
516
760
  shouldUsePlatformChatProvider
@@ -0,0 +1,28 @@
1
+ // packages/chat/dialog/actions/builtinDialogLlm.ts
2
+ var BASE_BUILTIN_DIALOG_LLM_CONFIG = {
3
+ apiSource: "platform",
4
+ useServerProxy: true
5
+ };
6
+ var BUILTIN_TITLE_LLM_CONFIG = {
7
+ ...BASE_BUILTIN_DIALOG_LLM_CONFIG,
8
+ provider: "nolo",
9
+ id: "builtin-dialog-title-llm",
10
+ name: "Builtin Dialog Title LLM",
11
+ model: "deepseek-v4-flash",
12
+ prompt: "You are a title generator for chat history. \u4F60\u53EA\u505A\u4E00\u4EF6\u4E8B\uFF1A\u6839\u636E\u5BF9\u8BDD\u5185\u5BB9\u8F93\u51FA\u6700\u7EC8\u6807\u9898\u3002\u786C\u6027\u89C4\u5219\uFF1A1) \u53EA\u8F93\u51FA\u6807\u9898\u8FD9\u4E00\u884C\uFF1B\u4E25\u7981\u8F93\u51FA\u63A8\u7406\u3001\u5206\u6790\u3001\u6B65\u9AA4\u3001\u89E3\u91CA\u3001\u524D\u8A00\u3001\u540E\u8BB0\u3001\u7FFB\u8BD1\u3001\u81F4\u6B49\u6216\u4EFB\u4F55\u989D\u5916\u8BF4\u660E\u30022) \u4E0D\u8981\u56DE\u7B54\u7528\u6237\u8BF7\u6C42\uFF0C\u4E0D\u8981\u5199\u6458\u8981\uFF0C\u53EA\u7ED9\u6807\u9898\u7ED3\u679C\u30023) \u6807\u9898\u5C3D\u91CF\u77ED\uFF1A\u901A\u5E38 2-5 \u4E2A\u8BCD\uFF0C\u82F1\u6587\u4E0D\u8D85\u8FC7 6 \u4E2A\u8BCD\u30024) \u4F7F\u7528\u5BF9\u8BDD\u4E3B\u8BED\u8A00\uFF1B\u6DF7\u5408\u8BED\u8A00\u65F6\u4F18\u5148\u7528\u6237\u4E3B\u8981\u8BED\u8A00\u30025) \u4F18\u5148\u590D\u7528\u5BF9\u8BDD\u4E2D\u7684\u5177\u4F53\u4E3B\u9898\u8BCD\uFF0C\u907F\u514D issue\u3001help\u3001discussion\u3001analysis\u3001update \u8FD9\u7C7B\u7A7A\u6CDB\u8BCD\u30026) \u5FFD\u7565 tool JSON\u3001\u51FD\u6570\u540D\u3001branch label\u3001agent \u540D\u3001\u7CFB\u7EDF\u6307\u4EE4\u548C\u7F16\u6392\u75D5\u8FF9\uFF08\u5982 GPT\u3001Claude\u3001Gemini\uFF09\uFF1B\u6807\u9898\u8981\u843D\u5728\u7528\u6237\u771F\u6B63\u8BA8\u8BBA\u7684\u5BF9\u8C61\u6216\u51B3\u7B56\u4E0A\u30027) \u66F4\u504F\u597D\u201C\u5BF9\u8C61 + \u52A8\u4F5C/\u5224\u65AD\u201D\u7684\u77ED\u6807\u9898\uFF0C\u4F8B\u5982\u201CAI \u90AE\u4EF6\u52A9\u624B\u53D6\u820D\u201D\u201C\u4E1C\u4EAC\u56DB\u65E5\u6162\u65C5\u884C\u201D\u201C\u91CD\u590D\u6263\u8D39\u9000\u6B3E\u201D\u30028) \u7EAF\u6587\u672C\uFF0C\u4E0D\u8981\u9879\u76EE\u7B26\u53F7\u3001\u7F16\u53F7\u3001markdown\u3001emoji\u3002\u6700\u7EC8\u53EA\u8FD4\u56DE\u6807\u9898\u6587\u672C\u3002 Output only the title text."
13
+ };
14
+ var BUILTIN_SUMMARY_LLM_CONFIG = {
15
+ ...BASE_BUILTIN_DIALOG_LLM_CONFIG,
16
+ provider: "nolo",
17
+ id: "builtin-dialog-summary-llm",
18
+ name: "Builtin Dialog Summary LLM",
19
+ model: "deepseek-v4-flash",
20
+ // @deprecated 用 COMPACTION_SUMMARY_SYSTEM_PROMPT(packages/ai/context/compactionShared.ts)。
21
+ // 生产代码已全部迁移;此旧两段式 prompt 仅被 scripts/probes/dialog 探针脚本使用,待探针迁移后删除。
22
+ prompt: "\u4F60\u662F\u4E00\u4E2A\u4E13\u4E1A\u7684\u5BF9\u8BDD\u8BB0\u5FC6\u52A9\u7406\u3002\u8BF7\u57FA\u4E8E\u3010\u73B0\u6709\u8BB0\u5FC6\u3011\u548C\u3010\u65B0\u589E\u5BF9\u8BDD\u3011\uFF0C\u8F93\u51FA\u4E00\u4EFD\u66F4\u65B0\u540E\u7684\u5BF9\u8BDD\u8BB0\u5FC6\u6863\u6848\u3002\u4E25\u683C\u53EA\u8F93\u51FA\u4E0B\u9762\u4E24\u90E8\u5206\uFF0C\u6807\u9898\u5FC5\u987B\u5B8C\u5168\u4E00\u81F4\uFF1A\n\u5173\u952E\u4E8B\u5B9E\u6863\u6848\n- ...\n\u5BF9\u8BDD\u5267\u60C5\u6458\u8981\n- ...\n\u8981\u6C42\uFF1A1) \u4F7F\u7528\u5BF9\u8BDD\u4E3B\u8BED\u8A00\uFF1B\u6DF7\u5408\u8BED\u8A00\u65F6\u4F18\u5148\u8DDF\u968F\u7528\u6237\u4E3B\u8981\u8BED\u8A00\uFF0C\u4E13\u6709\u540D\u8BCD\u4FDD\u7559\u539F\u6587\u30022) \u5173\u952E\u4E8B\u5B9E\u6863\u6848\u53EA\u4FDD\u7559\u4E4B\u540E\u7EE7\u7EED\u5BF9\u8BDD\u4ECD\u6709\u4EF7\u503C\u7684\u4FE1\u606F\uFF0C\u4F8B\u5982\u7528\u6237\u504F\u597D\u3001\u76EE\u6807\u3001\u7EA6\u675F\u3001\u6280\u672F\u6808\u3001\u786E\u5B9A\u7684\u6587\u4EF6\u540D/\u53D8\u91CF\u540D\u3001\u6838\u5FC3\u51B3\u7B56\u3001\u5F85\u529E\u4E8B\u9879\u30023) \u5BF9\u8BDD\u5267\u60C5\u6458\u8981\u5148\u6781\u7B80\u6982\u62EC\u65E7\u4E0A\u4E0B\u6587\uFF0C\u518D\u66F4\u8BE6\u7EC6\u8BB0\u5F55\u6700\u8FD1\u65B0\u589E\u7684\u8FDB\u5C55\u3001\u5206\u6B67\u3001\u7ED3\u8BBA\u548C\u4E0B\u4E00\u6B65\u30024) \u5FFD\u7565\u5BD2\u6684\u3001\u91CD\u590D\u5C1D\u8BD5\u3001\u5DF2\u653E\u5F03\u65B9\u6848\u548C\u65E0\u4EF7\u503C\u5E9F\u8BDD\u30025) \u4E0D\u8981\u7F16\u9020\u672A\u51FA\u73B0\u7684\u4FE1\u606F\uFF0C\u4E0D\u8981\u8F93\u51FA\u5F00\u573A\u767D\u3001\u7ED3\u675F\u8BED\u3001markdown \u4EE3\u7801\u5757\u6216\u989D\u5916\u7AE0\u8282\u3002"
23
+ };
24
+
25
+ export {
26
+ BUILTIN_TITLE_LLM_CONFIG,
27
+ BUILTIN_SUMMARY_LLM_CONFIG
28
+ };
@@ -0,0 +1,188 @@
1
+ // packages/core/chat/internalTurnEvent.ts
2
+ function normalizeRunCompletionShape(record) {
3
+ const runId = String(record.runId ?? record.id ?? "");
4
+ const agentKey = String(record.agentKey ?? record.agent ?? "");
5
+ const status = String(record.status ?? "done");
6
+ const counters = record.activity?.counters;
7
+ return {
8
+ runId,
9
+ agentKey,
10
+ ...typeof record.agentName === "string" ? { agentName: record.agentName } : {},
11
+ status,
12
+ ...typeof record.exitCode === "number" ? { exitCode: record.exitCode } : {},
13
+ ...typeof record.parentDialogId === "string" ? { parentDialogId: record.parentDialogId } : {},
14
+ ...typeof record.dialogId === "string" ? { dialogId: record.dialogId } : {},
15
+ ...typeof record.ephemeral === "boolean" ? { ephemeral: record.ephemeral } : {},
16
+ ...record.startedAt !== void 0 ? { startedAt: record.startedAt } : {},
17
+ ...record.endedAt !== void 0 ? { endedAt: record.endedAt } : {},
18
+ ...typeof record.note === "string" ? { note: record.note } : {},
19
+ ...typeof record.error === "string" ? { error: record.error } : {},
20
+ ...typeof record.ack === "boolean" ? { ack: record.ack } : {},
21
+ ...counters ? {
22
+ activity: {
23
+ counters: {
24
+ toolCalls: typeof counters.toolCalls === "number" ? counters.toolCalls : 0,
25
+ llmCalls: typeof counters.llmCalls === "number" ? counters.llmCalls : 0,
26
+ fileEdits: typeof counters.fileEdits === "number" ? counters.fileEdits : 0
27
+ }
28
+ }
29
+ } : {}
30
+ };
31
+ }
32
+ function createTurnRequest(input) {
33
+ if (typeof input === "string") {
34
+ return {
35
+ event: { kind: "user", text: input },
36
+ text: input
37
+ };
38
+ }
39
+ if ("event" in input && typeof input.event === "object" && typeof input.text === "string") {
40
+ return input;
41
+ }
42
+ const event = input;
43
+ return {
44
+ event,
45
+ text: event.text
46
+ };
47
+ }
48
+
49
+ // packages/core/chat/chatQueueMachine.ts
50
+ var initialChatQueueState = {
51
+ running: false,
52
+ queue: [],
53
+ drainPaused: false,
54
+ lastDrainError: null
55
+ };
56
+ function reduceChatQueue(state, event) {
57
+ switch (event.type) {
58
+ case "turn-start":
59
+ if (state.running && state.lastDrainError === null) return state;
60
+ return {
61
+ ...state,
62
+ running: true,
63
+ lastDrainError: null
64
+ };
65
+ case "turn-end":
66
+ return {
67
+ ...state,
68
+ running: false,
69
+ queue: event.aborted ? [] : state.queue,
70
+ lastDrainError: !event.ok && !event.aborted ? "previous turn failed" : state.lastDrainError
71
+ };
72
+ case "enqueue": {
73
+ const req = createTurnRequest(event.text);
74
+ if (!req.text.trim() && req.event.kind === "user") {
75
+ return state;
76
+ }
77
+ return {
78
+ ...state,
79
+ queue: [...state.queue, req]
80
+ };
81
+ }
82
+ case "dequeue":
83
+ if (state.queue.length === 0) return state;
84
+ return {
85
+ ...state,
86
+ queue: state.queue.slice(1)
87
+ };
88
+ case "clear":
89
+ if (state.queue.length === 0 && state.lastDrainError === null) return state;
90
+ return {
91
+ ...state,
92
+ queue: [],
93
+ lastDrainError: null
94
+ };
95
+ case "pause-drain":
96
+ if (state.drainPaused) return state;
97
+ return {
98
+ ...state,
99
+ drainPaused: true
100
+ };
101
+ case "resume-drain":
102
+ if (!state.drainPaused) return state;
103
+ return {
104
+ ...state,
105
+ drainPaused: false
106
+ };
107
+ case "drain-error":
108
+ return {
109
+ ...state,
110
+ lastDrainError: event.message || null
111
+ };
112
+ default:
113
+ return state;
114
+ }
115
+ }
116
+ function shouldDrainAfterTurnEnd(state, cleanTurnEnd) {
117
+ return cleanTurnEnd && !state.running && !state.drainPaused && state.queue.length > 0;
118
+ }
119
+ function applyChatQueueEvent(state, event) {
120
+ const prevQueueLen = state.queue.length;
121
+ const prevRunning = state.running;
122
+ const prevPaused = state.drainPaused;
123
+ const next = reduceChatQueue(state, event);
124
+ const outgoing = [];
125
+ if (next.queue.length !== prevQueueLen) {
126
+ outgoing.push({ type: "queue-changed", length: next.queue.length });
127
+ }
128
+ if (next.running !== prevRunning) {
129
+ outgoing.push({ type: "running-changed", running: next.running });
130
+ }
131
+ if (next.drainPaused !== prevPaused) {
132
+ outgoing.push({ type: "drain-paused-changed", paused: next.drainPaused });
133
+ }
134
+ if (event.type === "turn-end" && !event.aborted && event.ok) {
135
+ if (shouldDrainAfterTurnEnd(next, true)) {
136
+ const head = next.queue[0];
137
+ outgoing.push({ type: "drain-ready", text: head.text, request: head });
138
+ }
139
+ }
140
+ return { state: next, outgoing };
141
+ }
142
+
143
+ // packages/core/chat/chatQueueRuntime.ts
144
+ function createChatQueueRuntime(initialState = initialChatQueueState) {
145
+ let state = initialState;
146
+ const listeners = /* @__PURE__ */ new Set();
147
+ const dispatch = (events) => {
148
+ for (const e of events) {
149
+ for (const l of listeners) l(e);
150
+ }
151
+ };
152
+ return {
153
+ getState: () => state,
154
+ send(event) {
155
+ const result = applyChatQueueEvent(state, event);
156
+ state = result.state;
157
+ dispatch(result.outgoing);
158
+ return state;
159
+ },
160
+ subscribe(listener) {
161
+ listeners.add(listener);
162
+ return () => {
163
+ listeners.delete(listener);
164
+ };
165
+ },
166
+ on(type, listener) {
167
+ const wrapped = (e) => {
168
+ if (e.type === type) {
169
+ listener(e);
170
+ }
171
+ };
172
+ listeners.add(wrapped);
173
+ return () => {
174
+ listeners.delete(wrapped);
175
+ };
176
+ },
177
+ dispose() {
178
+ listeners.clear();
179
+ state = initialChatQueueState;
180
+ }
181
+ };
182
+ }
183
+
184
+ export {
185
+ normalizeRunCompletionShape,
186
+ createTurnRequest,
187
+ createChatQueueRuntime
188
+ };
@@ -1,16 +1,7 @@
1
1
  import {
2
2
  selectCurrentServer,
3
3
  selectRemoteServers
4
- } from "./chunk-G5GVZAXF.js";
5
- import {
6
- noloDeleteRequest,
7
- noloWriteRequest,
8
- selectIdentityUser,
9
- selectIdentityUserId
10
- } from "./chunk-2IJAKBK2.js";
11
- import {
12
- normalizeTimeFields
13
- } from "./chunk-5RDLGLAP.js";
4
+ } from "./chunk-CLP2K7U4.js";
14
5
  import {
15
6
  createUserKey,
16
7
  extractAgentInfo,
@@ -19,7 +10,16 @@ import {
19
10
  sanitizeShareData,
20
11
  shareKey,
21
12
  toNonEmptyString
22
- } from "./chunk-WHLVPK32.js";
13
+ } from "./chunk-KMSZPTM6.js";
14
+ import {
15
+ noloDeleteRequest,
16
+ noloWriteRequest,
17
+ selectIdentityUser,
18
+ selectIdentityUserId
19
+ } from "./chunk-X664KVEV.js";
20
+ import {
21
+ normalizeTimeFields
22
+ } from "./chunk-WJSW43QZ.js";
23
23
 
24
24
  // packages/share/action.ts
25
25
  var generateToken = () => {