nolo-cli 0.12.0-alpha.1 → 0.12.0-alpha.11

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 (82) hide show
  1. package/{_executeModel-MWAY74HA.js → _executeModel-4F7VZR5U.js} +24 -23
  2. package/{action-RAXNQQKC.js → action-OTOWUMPW.js} +3 -3
  3. package/{addContentAction-ZHI7TVV3.js → addContentAction-JGBUVR7K.js} +2 -2
  4. package/{addDialogAgentAction-JWXPKXNC.js → addDialogAgentAction-V6CL2UCF.js} +1 -1
  5. package/{agentDeleteCommand-LXR5A5FV.js → agentDeleteCommand-MMRSG6AB.js} +15 -14
  6. package/{agentEmailCommands-DXRAP7BB.js → agentEmailCommands-VW5FKADD.js} +28 -27
  7. package/{agentListCommands-ZFMS5ZLY.js → agentListCommands-2PZHIQ3I.js} +16 -15
  8. package/{agentMachineCommands-ZJLYVV52.js → agentMachineCommands-T2R7HVRV.js} +17 -16
  9. package/{agentRecordCommands-DFS626TB.js → agentRecordCommands-5DLPK3IV.js} +28 -27
  10. package/{agentRunCommand-GWBIE2TS.js → agentRunCommand-P6EH5DN7.js} +29 -28
  11. package/{agentRuntimeLocal-YNZSHMZC.js → agentRuntimeLocal-QDJCBXM2.js} +12 -11
  12. package/{agentSlice-T2PXOEPQ.js → agentSlice-6JAJOU3X.js} +2 -2
  13. package/{chunk-G3B356GF.js → chunk-2BVGERJ2.js} +67 -3
  14. package/{chunk-WWU275LU.js → chunk-3MI5LDDU.js} +2 -2
  15. package/{chunk-OPZYGHUC.js → chunk-3WGLLTK4.js} +59 -1
  16. package/chunk-5MMAK75Q.js +15 -0
  17. package/{chunk-ZR4VHQ5D.js → chunk-5S4SWV5G.js} +38 -26
  18. package/{chunk-JUN3HFMN.js → chunk-5V524MHX.js} +25 -15
  19. package/{chunk-5ITRDSHY.js → chunk-7HVCFCZK.js} +65 -18
  20. package/{chunk-JZDIW766.js → chunk-ARSC56DC.js} +1 -1
  21. package/{chunk-3QKO4EHV.js → chunk-AS3ZQ3O2.js} +16 -25
  22. package/{chunk-43UD5ZP7.js → chunk-B4KT7RN2.js} +4 -4
  23. package/{chunk-YTQLJYLB.js → chunk-C3BFP57W.js} +95 -2
  24. package/{chunk-QCA3EPYK.js → chunk-CGDQDXKZ.js} +1 -1
  25. package/{chunk-7MYHLZ3F.js → chunk-DPFWKRHG.js} +1 -1
  26. package/{chunk-LHSJMY5V.js → chunk-E2BT7DBP.js} +3 -3
  27. package/{chunk-AM53Q2SD.js → chunk-FSUZIGIG.js} +28 -39
  28. package/{chunk-4GBNEA5B.js → chunk-H5Y2H2N6.js} +1 -1
  29. package/{chunk-S73OEOHH.js → chunk-JFANOO7I.js} +3 -15
  30. package/{chunk-ZPFRLGIZ.js → chunk-JHYLX2QV.js} +70 -37
  31. package/{chunk-OCDEWRE2.js → chunk-JKWWVF2I.js} +1 -1
  32. package/{chunk-WTYKCU4W.js → chunk-JU7J7EAV.js} +37 -37
  33. package/{chunk-EBH7G34M.js → chunk-LIO7AK5S.js} +2 -2
  34. package/{chunk-6OVCRC72.js → chunk-LUKQQJFL.js} +39 -2
  35. package/{chunk-DRMGJFGQ.js → chunk-MG6BVV3T.js} +31 -17
  36. package/{chunk-RSEUHW6T.js → chunk-MQRZ5QUH.js} +1 -1
  37. package/{chunk-RZ735TLX.js → chunk-MZHSAPZP.js} +167 -20
  38. package/{chunk-OPKKB25T.js → chunk-O4FOPRCP.js} +1 -1
  39. package/{chunk-S3UTETIC.js → chunk-OGGHETUE.js} +19 -4
  40. package/{chunk-4EH7AR52.js → chunk-OPM2DE2J.js} +1 -1
  41. package/{chunk-UG3WOFU6.js → chunk-QJSTNKJY.js} +1 -1
  42. package/{chunk-DE5BA4O6.js → chunk-QUHUVG6Y.js} +2 -2
  43. package/{chunk-YDCZVUFP.js → chunk-RQSOAMPJ.js} +16 -0
  44. package/{chunk-6LMFFG3K.js → chunk-RWO5DGXI.js} +2 -2
  45. package/{chunk-4BTHUYMY.js → chunk-TA7VKOHU.js} +23 -9
  46. package/{chunk-MEVCDATU.js → chunk-TQYYGE6G.js} +3 -3
  47. package/{chunk-TSKWE74T.js → chunk-TYPHUVK5.js} +13 -1
  48. package/{chunk-RNQ5BLR2.js → chunk-VBSWHE5W.js} +1 -1
  49. package/{chunk-NITP2JDG.js → chunk-VKG4HXYV.js} +1 -1
  50. package/{chunk-3HHTVM6G.js → chunk-WVTBAALN.js} +1 -1
  51. package/{chunk-GPZM7QH6.js → chunk-Y5P3ZRGC.js} +4 -4
  52. package/{chunk-GDBCUWQ3.js → chunk-YUMYYXPI.js} +31 -167
  53. package/{createAgentAutomationAction-G32GKDGV.js → createAgentAutomationAction-4NY4JLOK.js} +9 -8
  54. package/{createDialogAction-TISANRZK.js → createDialogAction-I5WUWFJ6.js} +10 -9
  55. package/{createPageAction-O7KOYNV4.js → createPageAction-HFTIQ7TW.js} +9 -8
  56. package/{dbSlice-WDP2ZZHK.js → dbSlice-J4PUZ6Y5.js} +1 -1
  57. package/{dialogCommands-6JPB3YQY.js → dialogCommands-SVXRJFZS.js} +16 -15
  58. package/{dialogSlice-PRHHYSP5.js → dialogSlice-35LA3ZRG.js} +9 -8
  59. package/{docCreateCommands-75E6TZNN.js → docCreateCommands-Z7RIAYKQ.js} +15 -14
  60. package/{docDeleteCommands-EJHLN7LW.js → docDeleteCommands-NEYHUVZF.js} +16 -15
  61. package/{docReadCommands-RJYBC4FS.js → docReadCommands-I4US2SDE.js} +15 -14
  62. package/{docStore-H5VWKT5D.js → docStore-3CP2IO6M.js} +10 -9
  63. package/{docUpdateCommands-MG4CNISV.js → docUpdateCommands-UU5HQBRP.js} +15 -14
  64. package/{getPricing-6TOZXPAU.js → getPricing-UGDJHI7M.js} +2 -2
  65. package/{handleSendMessageAction-QTUGICSZ.js → handleSendMessageAction-FWTLQGOZ.js} +9 -8
  66. package/index.js +36 -36
  67. package/{machineCommands-MAV7M3TK.js → machineCommands-J5JWJQ6I.js} +28 -27
  68. package/{machineWsRunDispatch-ZOEGTKHC.js → machineWsRunDispatch-U476S4G2.js} +27 -26
  69. package/package.json +1 -1
  70. package/{readlineWorkspace-SWQKC7ZS.js → readlineWorkspace-AQCPSGS7.js} +260 -87
  71. package/{removeDialogAgentAction-GTX5AN54.js → removeDialogAgentAction-XUZYQBV4.js} +3 -3
  72. package/{runAgentClientLoop-P25HACXX.js → runAgentClientLoop-FP2K33ZO.js} +20 -19
  73. package/{setDialogExtraReferencesAction-WFQ63KYO.js → setDialogExtraReferencesAction-PTAIFKGM.js} +1 -1
  74. package/{setPrimaryDialogAgentAction-P57FXTSU.js → setPrimaryDialogAgentAction-HRFTDB44.js} +3 -3
  75. package/{settingSlice-CK5YZGNI.js → settingSlice-VGRJUSE5.js} +2 -2
  76. package/{skillDiscovery-ZYHSX7VD.js → skillDiscovery-6M2BZUFN.js} +1 -1
  77. package/{spaceCommands-6O5EFEM5.js → spaceCommands-GN73BCOB.js} +15 -14
  78. package/{spaceSlice-4EXTYXS4.js → spaceSlice-WTFNKOVA.js} +11 -8
  79. package/{streamAgentChatTurn-Q3FJAHG2.js → streamAgentChatTurn-HBAQQVNK.js} +244 -26
  80. package/{tools-AHNQE4GP.js → tools-TPQYTLQZ.js} +15 -14
  81. package/{tuiSummaryLlmCaller-TXLF4MEI.js → tuiSummaryLlmCaller-XDC7WG4K.js} +6 -4
  82. package/{updateDialogTitleAction-XZDVLKVX.js → updateDialogTitleAction-AWXNPUQJ.js} +9 -8
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  buildStaticUserPolicyContext,
6
6
  resolveSpaceContextPreloadPlan
7
- } from "./chunk-UG3WOFU6.js";
7
+ } from "./chunk-QJSTNKJY.js";
8
8
  import {
9
9
  buildCliPrompt
10
10
  } from "./chunk-ATNTHIZI.js";
@@ -20,11 +20,11 @@ import {
20
20
  sanitizeOutboundResponsesInput,
21
21
  sendOpenAICompletionsRequest,
22
22
  updateTotalUsage
23
- } from "./chunk-GDBCUWQ3.js";
23
+ } from "./chunk-YUMYYXPI.js";
24
24
  import "./chunk-JEXVIMYZ.js";
25
25
  import {
26
26
  prepareTools
27
- } from "./chunk-YTQLJYLB.js";
27
+ } from "./chunk-C3BFP57W.js";
28
28
  import {
29
29
  fetchReferenceContents,
30
30
  generateRequestBody,
@@ -38,8 +38,8 @@ import {
38
38
  resolveToolsFromKeys,
39
39
  selectResponsesConversationState,
40
40
  updateResponsesConversationState
41
- } from "./chunk-JUN3HFMN.js";
42
- import "./chunk-4GBNEA5B.js";
41
+ } from "./chunk-5V524MHX.js";
42
+ import "./chunk-H5Y2H2N6.js";
43
43
  import {
44
44
  TOOL_PACKS,
45
45
  applyDefaultWebToolPacks,
@@ -50,8 +50,8 @@ import {
50
50
  getAllToolRuns,
51
51
  shouldBlockForGptPro,
52
52
  waitForAbortableDelay
53
- } from "./chunk-RZ735TLX.js";
54
- import "./chunk-YDCZVUFP.js";
53
+ } from "./chunk-MZHSAPZP.js";
54
+ import "./chunk-RQSOAMPJ.js";
55
55
  import "./chunk-OOIN7HSO.js";
56
56
  import "./chunk-KQHGZWSV.js";
57
57
  import {
@@ -59,7 +59,7 @@ import {
59
59
  getModelPricing,
60
60
  getPrices,
61
61
  hasExplicitAgentPricing
62
- } from "./chunk-OCDEWRE2.js";
62
+ } from "./chunk-JKWWVF2I.js";
63
63
  import {
64
64
  getPublicImageAgentDefaultProfile,
65
65
  getPublicImageAgentMode
@@ -73,8 +73,8 @@ import "./chunk-63W5N6P3.js";
73
73
  import "./chunk-VF4K2QE6.js";
74
74
  import {
75
75
  getDocState
76
- } from "./chunk-MEVCDATU.js";
77
- import "./chunk-G3B356GF.js";
76
+ } from "./chunk-TQYYGE6G.js";
77
+ import "./chunk-2BVGERJ2.js";
78
78
  import "./chunk-VC6OZXO5.js";
79
79
  import {
80
80
  PERSONALIZATION_DIALOG_CATEGORY,
@@ -97,17 +97,17 @@ import {
97
97
  selectTableRows,
98
98
  selectViewMode,
99
99
  updateTokens
100
- } from "./chunk-AM53Q2SD.js";
100
+ } from "./chunk-FSUZIGIG.js";
101
101
  import "./chunk-V2J635L5.js";
102
102
  import "./chunk-MRC4Q34M.js";
103
103
  import "./chunk-MTU75CZ2.js";
104
104
  import "./chunk-CWMSB67P.js";
105
- import "./chunk-GPZM7QH6.js";
105
+ import "./chunk-Y5P3ZRGC.js";
106
106
  import {
107
107
  createCliChatTurnStream,
108
108
  getCliChatSession,
109
109
  startCliChatSession
110
- } from "./chunk-6LMFFG3K.js";
110
+ } from "./chunk-RWO5DGXI.js";
111
111
  import "./chunk-Z4NR32XR.js";
112
112
  import "./chunk-M76ECQRD.js";
113
113
  import "./chunk-WZSRQNQG.js";
@@ -119,30 +119,31 @@ import {
119
119
  import {
120
120
  projectToolMessageContent,
121
121
  resolveAgentImageInputSupport
122
- } from "./chunk-4BTHUYMY.js";
123
- import "./chunk-OPZYGHUC.js";
124
- import "./chunk-6OVCRC72.js";
122
+ } from "./chunk-TA7VKOHU.js";
123
+ import "./chunk-3WGLLTK4.js";
124
+ import "./chunk-LUKQQJFL.js";
125
125
  import {
126
126
  extractImagePartsFromResponseOutput,
127
127
  extractTextFromResponseOutput,
128
128
  toResponsesTools
129
- } from "./chunk-TSKWE74T.js";
129
+ } from "./chunk-TYPHUVK5.js";
130
130
  import {
131
131
  canonicalizeToolNames,
132
132
  prioritizeToolNames,
133
133
  resolveRuntimeToolSurfaceForAgent
134
- } from "./chunk-43UD5ZP7.js";
134
+ } from "./chunk-B4KT7RN2.js";
135
135
  import {
136
136
  estimateTokenCount,
137
137
  getModelContextWindow,
138
138
  getModelInfo,
139
139
  planContextUsage
140
- } from "./chunk-S73OEOHH.js";
140
+ } from "./chunk-JFANOO7I.js";
141
+ import "./chunk-5MMAK75Q.js";
141
142
  import {
142
143
  getApiEndpoint,
143
144
  getModelConfig,
144
145
  getProviderByModelName
145
- } from "./chunk-S3UTETIC.js";
146
+ } from "./chunk-OGGHETUE.js";
146
147
  import "./chunk-PDL2AV3E.js";
147
148
  import "./chunk-JZPBVBIY.js";
148
149
  import "./chunk-BYXBJQAS.js";
@@ -175,7 +176,7 @@ import "./chunk-XENYHRUE.js";
175
176
  import "./chunk-DWLEOOGR.js";
176
177
  import "./chunk-IKXL2HZ3.js";
177
178
  import "./chunk-524BDL33.js";
178
- import "./chunk-7MYHLZ3F.js";
179
+ import "./chunk-DPFWKRHG.js";
179
180
  import {
180
181
  selectAiRecentContentLimit,
181
182
  selectCurrentServer,
@@ -184,18 +185,18 @@ import {
184
185
  selectMaxExecutionTime,
185
186
  selectSpaceContextLevel,
186
187
  selectUserTonePreset
187
- } from "./chunk-WTYKCU4W.js";
188
+ } from "./chunk-JU7J7EAV.js";
188
189
  import "./chunk-Y5GCAMGP.js";
189
190
  import {
190
191
  asRecordOrEmpty
191
192
  } from "./chunk-KX6YBIHG.js";
192
- import "./chunk-3HHTVM6G.js";
193
+ import "./chunk-WVTBAALN.js";
193
194
  import {
194
195
  patch,
195
196
  read,
196
197
  selectById,
197
198
  write
198
- } from "./chunk-NITP2JDG.js";
199
+ } from "./chunk-VKG4HXYV.js";
199
200
  import "./chunk-WPHL6ALY.js";
200
201
  import {
201
202
  createDialogMessageKeyAndId,
@@ -1500,6 +1501,29 @@ var buildEditingContextSummary = (state, runtimeOptions) => {
1500
1501
  ...formatAppConstraintPacks(constraintPacks)
1501
1502
  ].join("\n");
1502
1503
  }
1504
+ if (targetKind === "local_preview") {
1505
+ const metadata = runtimeOptions?.editingTarget?.metadata;
1506
+ const selectedNode = metadata && typeof metadata === "object" && metadata.selectedNode && typeof metadata.selectedNode === "object" ? metadata.selectedNode : null;
1507
+ if (!selectedNode) return null;
1508
+ const readString = (key) => typeof selectedNode[key] === "string" ? selectedNode[key] : "";
1509
+ const tagName = readString("tagName") || "\u5143\u7D20";
1510
+ const cssPath = readString("cssPath");
1511
+ const noloLoc = readString("noloLoc");
1512
+ const textSnippet = readString("textSnippet");
1513
+ const outerHTMLSnippet = readString("outerHTMLSnippet");
1514
+ return [
1515
+ "\u5F53\u524D\u7F16\u8F91\u76EE\u6807\uFF1A\u672C\u5730\u5DE5\u4F5C\u533A\u91CC\u6B63\u5728\u9884\u89C8\u7684\u7F51\u9875\uFF08Local Preview\uFF09\u3002",
1516
+ `\u7528\u6237\u5728\u9884\u89C8\u4E2D\u9009\u4E2D\u4E86\u4E00\u4E2A\u5143\u7D20\uFF1A<${tagName}>\uFF0CCSS \u8DEF\u5F84\uFF1A${cssPath}${noloLoc ? `\uFF0C\u6E90\u7801\u4F4D\u7F6E\uFF1A${noloLoc}` : ""}\u3002`,
1517
+ `\u9009\u4E2D\u5143\u7D20\u7684 HTML \u7247\u6BB5\uFF08\u53EF\u80FD\u622A\u65AD\uFF09\uFF1A${outerHTMLSnippet}${textSnippet ? `\uFF1B\u53EF\u89C1\u6587\u672C\uFF1A${textSnippet}` : ""}\u3002`,
1518
+ "",
1519
+ "\u3010\u7ED9 AI \u7684\u64CD\u4F5C\u6307\u5357 / \u975E\u7528\u6237\u539F\u8BDD\u3011",
1520
+ "1. \u672C\u8F6E\u4FEE\u6539\u5FC5\u987B\u4EE5\u8FD9\u4E2A\u5143\u7D20\u4E3A\u4E2D\u5FC3\uFF1B\u5148\u5728\u672C\u5730\u5DE5\u4F5C\u533A\u6E90\u7801\u4E2D\u5B9A\u4F4D\u5230\u751F\u6210\u8FD9\u6BB5 HTML \u7684\u4EE3\u7801\uFF0C\u518D\u52A8\u624B\u3002",
1521
+ noloLoc ? "2. \u5DF2\u7ED9\u51FA\u6E90\u7801\u4F4D\u7F6E\uFF0C\u76F4\u63A5\u8BFB\u8BE5\u6587\u4EF6\u7684\u5BF9\u5E94\u884C\u8303\u56F4\u786E\u8BA4\uFF0C\u4E0D\u8981\u5168\u5C40\u641C\u7D22\u3002" : "2. \u6CA1\u6709\u6E90\u7801\u4F4D\u7F6E\u65F6\uFF0C\u7528 CSS \u8DEF\u5F84\u91CC\u7684\u7C7B\u540D\u3001\u53EF\u89C1\u6587\u672C\u6216 HTML \u7247\u6BB5\u641C\u7D22\u5DE5\u4F5C\u533A\u5B9A\u4F4D\uFF0C\u4E0D\u8981\u51ED\u731C\u6D4B\u6539\u52A8\u3002",
1522
+ "3. \u4FEE\u6539\u6536\u655B\u5728\u8BE5\u5143\u7D20\u53CA\u5176\u76F4\u63A5\u6837\u5F0F\u6765\u6E90\uFF08\u547D\u4E2D\u7684\u7EC4\u4EF6/\u7C7B/design token\uFF09\uFF1B\u4FDD\u6301\u672A\u547D\u4E2D\u7684\u6587\u4EF6\u4E0D\u53D8\u3002",
1523
+ "4. \u5982\u679C\u5B9A\u4F4D\u7ED3\u679C\u843D\u5728 node_modules \u6216\u6765\u81EA\u63A5\u53E3\u6570\u636E\uFF0C\u5148\u544A\u8BC9\u7528\u6237\u5B9E\u9645\u60C5\u51B5\uFF0C\u518D\u63D0\u51FA\u53EF\u884C\u7684\u6539\u6CD5\uFF0C\u4E0D\u8981\u786C\u6539\u3002",
1524
+ "5. \u5982\u679C\u6309 CSS \u8DEF\u5F84\u548C HTML \u7247\u6BB5\u627E\u4E0D\u5230\u5BF9\u5E94\u4F4D\u7F6E\uFF0C\u5148\u5411\u7528\u6237\u8BF4\u660E\u5E76\u8BF7\u5176\u91CD\u65B0\u9009\u62E9\u3002"
1525
+ ].join("\n");
1526
+ }
1503
1527
  if (targetKind === "image" || targetKind === "file") {
1504
1528
  const editingTarget = runtimeOptions?.editingTarget;
1505
1529
  const metadata = editingTarget?.metadata;
@@ -2887,6 +2911,122 @@ function hasInlineExecutedToolCalls(result) {
2887
2911
  const output = result?.output;
2888
2912
  return Array.isArray(output) && output.some((b) => b?.type === "toolCall" && b?.result != null);
2889
2913
  }
2914
+ function createRemoteToolEventHandlers(opts) {
2915
+ const { dialogId, dispatch, messageMetadata } = opts;
2916
+ const activeToolMessages = /* @__PURE__ */ new Map();
2917
+ const handleToolPayload = (payload) => {
2918
+ if (!payload || typeof payload !== "object") return;
2919
+ if (payload.type === "assistant_tool_calls") {
2920
+ const toolCalls = Array.isArray(payload.tool_calls) ? payload.tool_calls : [];
2921
+ for (const tc of toolCalls) {
2922
+ const callId = tc?.id;
2923
+ const toolName = tc?.function?.name;
2924
+ if (!callId || !toolName) continue;
2925
+ const { key: toolDbKey, messageId: toolMsgId } = createDialogMessageKeyAndId(dialogId);
2926
+ const argsStr = typeof tc.function?.arguments === "string" ? tc.function.arguments : "";
2927
+ const toolMsg = {
2928
+ id: toolMsgId,
2929
+ dialogId,
2930
+ dbKey: toolDbKey,
2931
+ role: "tool",
2932
+ content: "",
2933
+ isStreaming: true,
2934
+ toolName,
2935
+ toolCallId: callId,
2936
+ toolPayload: {
2937
+ toolName,
2938
+ status: "running",
2939
+ input: safeParseToolArgs(argsStr),
2940
+ rawToolCall: tc,
2941
+ summary: ""
2942
+ },
2943
+ ...messageMetadata
2944
+ };
2945
+ activeToolMessages.set(callId, toolMsg);
2946
+ dispatch(messageStreaming(toolMsg));
2947
+ }
2948
+ return;
2949
+ }
2950
+ if (payload.type === "tool_result") {
2951
+ const callId = payload.toolCallId;
2952
+ if (!callId) return;
2953
+ const existing = activeToolMessages.get(callId);
2954
+ const toolName = asOptionalTrimmedString(payload.toolName) || asOptionalTrimmedString(existing?.toolName) || "tool";
2955
+ const mergedMeta = isRecord(payload.metadata) ? payload.metadata : void 0;
2956
+ const isToolError = !!mergedMeta?.error;
2957
+ const projectedContent = projectDesktopToolUiContent({
2958
+ toolName,
2959
+ content: payload.content,
2960
+ metadata: mergedMeta ?? void 0
2961
+ });
2962
+ const resultStatus = isToolError ? "failed" : "succeeded";
2963
+ if (existing) {
2964
+ const updatedMsg = {
2965
+ ...existing,
2966
+ isStreaming: false,
2967
+ content: projectedContent,
2968
+ toolName,
2969
+ toolPayload: {
2970
+ ...existing.toolPayload ?? {},
2971
+ toolName,
2972
+ status: resultStatus
2973
+ }
2974
+ };
2975
+ activeToolMessages.set(callId, updatedMsg);
2976
+ dispatch(messageStreaming(updatedMsg));
2977
+ } else {
2978
+ const { key: toolDbKey, messageId: toolMsgId } = createDialogMessageKeyAndId(dialogId);
2979
+ const toolMsg = {
2980
+ id: toolMsgId,
2981
+ dialogId,
2982
+ dbKey: toolDbKey,
2983
+ role: "tool",
2984
+ content: projectedContent,
2985
+ isStreaming: false,
2986
+ toolName,
2987
+ toolCallId: callId,
2988
+ toolPayload: {
2989
+ toolName,
2990
+ status: resultStatus,
2991
+ input: {},
2992
+ summary: ""
2993
+ },
2994
+ ...messageMetadata
2995
+ };
2996
+ activeToolMessages.set(callId, toolMsg);
2997
+ dispatch(messageStreaming(toolMsg));
2998
+ }
2999
+ }
3000
+ };
3001
+ return { handleToolPayload, activeToolMessages };
3002
+ }
3003
+ async function persistRemoteToolMessagesAndCleanup(dispatch, activeToolMessages) {
3004
+ const durableTools = [];
3005
+ for (const toolMsg of activeToolMessages.values()) {
3006
+ const content = toolMsg?.content;
3007
+ const hasContent = typeof content === "string" ? content.trim().length > 0 : Array.isArray(content) && content.length > 0;
3008
+ if (!hasContent) {
3009
+ dispatch(removeTransientMessage(toolMsg.id));
3010
+ continue;
3011
+ }
3012
+ const stopped = { ...toolMsg, isStreaming: false };
3013
+ dispatch(messageStreaming(stopped));
3014
+ durableTools.push(stopped);
3015
+ }
3016
+ await persistToolMessages(dispatch, durableTools, {
3017
+ isStreaming: false,
3018
+ soft: true
3019
+ });
3020
+ activeToolMessages.clear();
3021
+ }
3022
+ function safeParseToolArgs(argsStr) {
3023
+ if (!argsStr) return {};
3024
+ try {
3025
+ return JSON.parse(argsStr);
3026
+ } catch {
3027
+ return { raw: argsStr };
3028
+ }
3029
+ }
2890
3030
  var streamAgentChatTurnHandler = async (args, thunkApi) => {
2891
3031
  const {
2892
3032
  agentKey,
@@ -3026,6 +3166,11 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3026
3166
  ...cliMessageMetadata,
3027
3167
  userId: selectIdentityUserId(getState())
3028
3168
  });
3169
+ const remoteToolHandlers = createRemoteToolEventHandlers({
3170
+ dialogId: dialogId2,
3171
+ dispatch,
3172
+ messageMetadata: cliMessageMetadata
3173
+ });
3029
3174
  dispatch(messageStreaming({
3030
3175
  id: messageId,
3031
3176
  dialogId: dialogId2,
@@ -3040,6 +3185,11 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3040
3185
  } else {
3041
3186
  dispatch(removeTransientMessage(messageId));
3042
3187
  }
3188
+ await persistRemoteToolMessagesAndCleanup(
3189
+ dispatch,
3190
+ remoteToolHandlers.activeToolMessages
3191
+ ).catch(() => {
3192
+ });
3043
3193
  setLoopStopReason("error");
3044
3194
  remoteTransientMessageFinalized = true;
3045
3195
  return rejectWithValue(message);
@@ -3082,8 +3232,20 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3082
3232
  const parseSSE = createSSEParser();
3083
3233
  const abortMachineStream = async () => {
3084
3234
  if (w2) w2.__LOOP_STOP_REASON__ = "aborted";
3085
- if (accumulated2.length <= 0) return;
3235
+ if (accumulated2.length <= 0) {
3236
+ await persistRemoteToolMessagesAndCleanup(
3237
+ dispatch,
3238
+ remoteToolHandlers.activeToolMessages
3239
+ ).catch(() => {
3240
+ });
3241
+ return;
3242
+ }
3086
3243
  await persistMessageWithFixedId(dispatch, buildMachineAssistantMessage());
3244
+ await persistRemoteToolMessagesAndCleanup(
3245
+ dispatch,
3246
+ remoteToolHandlers.activeToolMessages
3247
+ ).catch(() => {
3248
+ });
3087
3249
  };
3088
3250
  try {
3089
3251
  const result = await consumeAgentRunStream({
@@ -3098,6 +3260,7 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3098
3260
  if (payload.type === "error") {
3099
3261
  return { reject: payload.message || "\u7535\u8111\u7AEF Agent \u6267\u884C\u5931\u8D25" };
3100
3262
  }
3263
+ remoteToolHandlers.handleToolPayload(payload);
3101
3264
  if (payload.type === "text" && typeof payload.content === "string") {
3102
3265
  accumulated2 += payload.content;
3103
3266
  dispatch(messageStreaming({
@@ -3126,6 +3289,11 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3126
3289
  id: messageId,
3127
3290
  error: "\u7535\u8111\u7AEF Agent \u6D41\u5F0F\u54CD\u5E94\u88AB\u4E2D\u65AD,\u672A\u6536\u5230\u5B8C\u6210\u4FE1\u53F7"
3128
3291
  }));
3292
+ await persistRemoteToolMessagesAndCleanup(
3293
+ dispatch,
3294
+ remoteToolHandlers.activeToolMessages
3295
+ ).catch(() => {
3296
+ });
3129
3297
  remoteTransientMessageFinalized = true;
3130
3298
  setLoopStopReason("error");
3131
3299
  return rejectWithValue(
@@ -3133,6 +3301,10 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3133
3301
  );
3134
3302
  }
3135
3303
  await persistMessageWithFixedId(dispatch, buildMachineAssistantMessage());
3304
+ await persistRemoteToolMessagesAndCleanup(
3305
+ dispatch,
3306
+ remoteToolHandlers.activeToolMessages
3307
+ );
3136
3308
  remoteTransientMessageFinalized = true;
3137
3309
  }
3138
3310
  } finally {
@@ -3140,6 +3312,13 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3140
3312
  await reader2.cancel();
3141
3313
  } catch {
3142
3314
  }
3315
+ if (remoteToolHandlers.activeToolMessages.size > 0) {
3316
+ await persistRemoteToolMessagesAndCleanup(
3317
+ dispatch,
3318
+ remoteToolHandlers.activeToolMessages
3319
+ ).catch(() => {
3320
+ });
3321
+ }
3143
3322
  }
3144
3323
  return {
3145
3324
  usage: totalTurnUsage2 ?? void 0
@@ -3801,6 +3980,11 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3801
3980
  ...remoteMessageMetadata,
3802
3981
  userId: selectIdentityUserId(getState())
3803
3982
  });
3983
+ const remoteToolHandlers = createRemoteToolEventHandlers({
3984
+ dialogId,
3985
+ dispatch,
3986
+ messageMetadata: remoteMessageMetadata
3987
+ });
3804
3988
  loopKey = `loop:${dialogId}`;
3805
3989
  dispatch(addActiveController({ messageId: loopKey, controller: loopController, dialogKey }));
3806
3990
  dispatch(messageStreaming({
@@ -3817,6 +4001,11 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3817
4001
  } else {
3818
4002
  dispatch(removeTransientMessage(messageId));
3819
4003
  }
4004
+ await persistRemoteToolMessagesAndCleanup(
4005
+ dispatch,
4006
+ remoteToolHandlers.activeToolMessages
4007
+ ).catch(() => {
4008
+ });
3820
4009
  setLoopStopReason("error");
3821
4010
  remoteTransientMessageFinalized = true;
3822
4011
  return rejectWithValue(message);
@@ -3870,8 +4059,20 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3870
4059
  const decoder = new TextDecoder();
3871
4060
  const parseSSE = createSSEParser();
3872
4061
  const abortRemoteStream = async () => {
3873
- if (accumulated.length <= 0) return;
4062
+ if (accumulated.length <= 0) {
4063
+ await persistRemoteToolMessagesAndCleanup(
4064
+ dispatch,
4065
+ remoteToolHandlers.activeToolMessages
4066
+ ).catch(() => {
4067
+ });
4068
+ return;
4069
+ }
3874
4070
  await persistMessageWithFixedId(dispatch, buildRemoteAssistantMessage());
4071
+ await persistRemoteToolMessagesAndCleanup(
4072
+ dispatch,
4073
+ remoteToolHandlers.activeToolMessages
4074
+ ).catch(() => {
4075
+ });
3875
4076
  };
3876
4077
  try {
3877
4078
  const result = await consumeAgentRunStream({
@@ -3898,6 +4099,7 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3898
4099
  payload.agentKey
3899
4100
  );
3900
4101
  }
4102
+ remoteToolHandlers.handleToolPayload(payload);
3901
4103
  if (payload.type === "text" && typeof payload.content === "string") {
3902
4104
  accumulated += payload.content;
3903
4105
  dispatch(messageStreaming({
@@ -3926,6 +4128,11 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3926
4128
  id: messageId,
3927
4129
  error: "\u8FDC\u7AEF Agent \u6D41\u5F0F\u54CD\u5E94\u88AB\u4E2D\u65AD,\u672A\u6536\u5230\u5B8C\u6210\u4FE1\u53F7"
3928
4130
  }));
4131
+ await persistRemoteToolMessagesAndCleanup(
4132
+ dispatch,
4133
+ remoteToolHandlers.activeToolMessages
4134
+ ).catch(() => {
4135
+ });
3929
4136
  remoteTransientMessageFinalized = true;
3930
4137
  setLoopStopReason("error");
3931
4138
  return rejectWithValue(
@@ -3933,6 +4140,10 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3933
4140
  );
3934
4141
  }
3935
4142
  await persistMessageWithFixedId(dispatch, buildRemoteAssistantMessage());
4143
+ await persistRemoteToolMessagesAndCleanup(
4144
+ dispatch,
4145
+ remoteToolHandlers.activeToolMessages
4146
+ );
3936
4147
  remoteTransientMessageFinalized = true;
3937
4148
  }
3938
4149
  } finally {
@@ -3940,6 +4151,13 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3940
4151
  await reader.cancel();
3941
4152
  } catch {
3942
4153
  }
4154
+ if (remoteToolHandlers.activeToolMessages.size > 0) {
4155
+ await persistRemoteToolMessagesAndCleanup(
4156
+ dispatch,
4157
+ remoteToolHandlers.activeToolMessages
4158
+ ).catch(() => {
4159
+ });
4160
+ }
3943
4161
  }
3944
4162
  return {
3945
4163
  usage: totalTurnUsage2 ?? void 0
@@ -11,8 +11,8 @@ import {
11
11
  toolQueryFunc,
12
12
  toolQueryFunctionSchema,
13
13
  toolRegistry
14
- } from "./chunk-RZ735TLX.js";
15
- import "./chunk-YDCZVUFP.js";
14
+ } from "./chunk-MZHSAPZP.js";
15
+ import "./chunk-RQSOAMPJ.js";
16
16
  import "./chunk-OOIN7HSO.js";
17
17
  import "./chunk-KQHGZWSV.js";
18
18
  import "./chunk-IVAOVLM7.js";
@@ -20,22 +20,23 @@ import "./chunk-3LY4F7SV.js";
20
20
  import "./chunk-VP4WJWKW.js";
21
21
  import "./chunk-63W5N6P3.js";
22
22
  import "./chunk-VF4K2QE6.js";
23
- import "./chunk-MEVCDATU.js";
24
- import "./chunk-G3B356GF.js";
23
+ import "./chunk-TQYYGE6G.js";
24
+ import "./chunk-2BVGERJ2.js";
25
25
  import "./chunk-VC6OZXO5.js";
26
- import "./chunk-AM53Q2SD.js";
26
+ import "./chunk-FSUZIGIG.js";
27
27
  import "./chunk-V2J635L5.js";
28
28
  import "./chunk-MRC4Q34M.js";
29
29
  import "./chunk-MTU75CZ2.js";
30
30
  import "./chunk-CWMSB67P.js";
31
- import "./chunk-GPZM7QH6.js";
32
- import "./chunk-6LMFFG3K.js";
31
+ import "./chunk-Y5P3ZRGC.js";
32
+ import "./chunk-RWO5DGXI.js";
33
33
  import "./chunk-Z4NR32XR.js";
34
34
  import "./chunk-M76ECQRD.js";
35
35
  import "./chunk-WZSRQNQG.js";
36
- import "./chunk-43UD5ZP7.js";
37
- import "./chunk-S73OEOHH.js";
38
- import "./chunk-S3UTETIC.js";
36
+ import "./chunk-B4KT7RN2.js";
37
+ import "./chunk-JFANOO7I.js";
38
+ import "./chunk-5MMAK75Q.js";
39
+ import "./chunk-OGGHETUE.js";
39
40
  import "./chunk-PDL2AV3E.js";
40
41
  import "./chunk-JZPBVBIY.js";
41
42
  import "./chunk-BYXBJQAS.js";
@@ -48,12 +49,12 @@ import "./chunk-XENYHRUE.js";
48
49
  import "./chunk-DWLEOOGR.js";
49
50
  import "./chunk-IKXL2HZ3.js";
50
51
  import "./chunk-524BDL33.js";
51
- import "./chunk-7MYHLZ3F.js";
52
- import "./chunk-WTYKCU4W.js";
52
+ import "./chunk-DPFWKRHG.js";
53
+ import "./chunk-JU7J7EAV.js";
53
54
  import "./chunk-Y5GCAMGP.js";
54
55
  import "./chunk-KX6YBIHG.js";
55
- import "./chunk-3HHTVM6G.js";
56
- import "./chunk-NITP2JDG.js";
56
+ import "./chunk-WVTBAALN.js";
57
+ import "./chunk-VKG4HXYV.js";
57
58
  import "./chunk-WPHL6ALY.js";
58
59
  import "./chunk-O4BU24WZ.js";
59
60
  import "./chunk-I42VC5KR.js";
@@ -6,11 +6,13 @@ import {
6
6
  canUsePlatformChatProvider,
7
7
  parsePlatformChatCompletionResponse,
8
8
  resolvePlatformChatProviderConfig
9
- } from "./chunk-ZR4VHQ5D.js";
10
- import "./chunk-OPZYGHUC.js";
11
- import "./chunk-TSKWE74T.js";
12
- import "./chunk-S3UTETIC.js";
9
+ } from "./chunk-5S4SWV5G.js";
10
+ import "./chunk-3WGLLTK4.js";
11
+ import "./chunk-TYPHUVK5.js";
12
+ import "./chunk-5MMAK75Q.js";
13
+ import "./chunk-OGGHETUE.js";
13
14
  import "./chunk-BYXBJQAS.js";
15
+ import "./chunk-DWLEOOGR.js";
14
16
  import "./chunk-524BDL33.js";
15
17
  import "./chunk-I42VC5KR.js";
16
18
  import "./chunk-QSJ3HFEF.js";
@@ -6,7 +6,7 @@ import {
6
6
  isAssistantToolStub,
7
7
  selectAllMsgs,
8
8
  updateContentTitle
9
- } from "./chunk-AM53Q2SD.js";
9
+ } from "./chunk-FSUZIGIG.js";
10
10
  import {
11
11
  BUILTIN_TITLE_LLM_CONFIG
12
12
  } from "./chunk-V2J635L5.js";
@@ -15,16 +15,17 @@ import "./chunk-MTU75CZ2.js";
15
15
  import "./chunk-CWMSB67P.js";
16
16
  import {
17
17
  runLlm
18
- } from "./chunk-GPZM7QH6.js";
19
- import "./chunk-6LMFFG3K.js";
18
+ } from "./chunk-Y5P3ZRGC.js";
19
+ import "./chunk-RWO5DGXI.js";
20
20
  import "./chunk-Z4NR32XR.js";
21
21
  import {
22
22
  require_date_fns
23
23
  } from "./chunk-M76ECQRD.js";
24
24
  import {
25
25
  serializeMessageContent
26
- } from "./chunk-S73OEOHH.js";
27
- import "./chunk-S3UTETIC.js";
26
+ } from "./chunk-JFANOO7I.js";
27
+ import "./chunk-5MMAK75Q.js";
28
+ import "./chunk-OGGHETUE.js";
28
29
  import "./chunk-PDL2AV3E.js";
29
30
  import "./chunk-JZPBVBIY.js";
30
31
  import "./chunk-BYXBJQAS.js";
@@ -37,16 +38,16 @@ import "./chunk-SOTZ6RDN.js";
37
38
  import "./chunk-DWLEOOGR.js";
38
39
  import "./chunk-IKXL2HZ3.js";
39
40
  import "./chunk-524BDL33.js";
40
- import "./chunk-WTYKCU4W.js";
41
+ import "./chunk-JU7J7EAV.js";
41
42
  import "./chunk-Y5GCAMGP.js";
42
43
  import "./chunk-KX6YBIHG.js";
43
44
  import {
44
45
  normalizeSpaceId
45
- } from "./chunk-3HHTVM6G.js";
46
+ } from "./chunk-WVTBAALN.js";
46
47
  import {
47
48
  patch,
48
49
  selectById
49
- } from "./chunk-NITP2JDG.js";
50
+ } from "./chunk-VKG4HXYV.js";
50
51
  import "./chunk-WPHL6ALY.js";
51
52
  import "./chunk-O4BU24WZ.js";
52
53
  import "./chunk-I42VC5KR.js";