nolo-cli 0.11.0 → 0.12.0-alpha.10

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 (123) hide show
  1. package/{_executeModel-ZEDPX6OF.js → _executeModel-4F7VZR5U.js} +52 -50
  2. package/{action-AA4IJ5K2.js → action-OTOWUMPW.js} +8 -9
  3. package/{addContentAction-QYVO4SYP.js → addContentAction-JGBUVR7K.js} +7 -9
  4. package/{addDialogAgentAction-WVVKT5WQ.js → addDialogAgentAction-V6CL2UCF.js} +9 -10
  5. package/{agentDeleteCommand-RDPGYIWF.js → agentDeleteCommand-MMRSG6AB.js} +39 -28
  6. package/{agentEmailCommands-2HJJKS5F.js → agentEmailCommands-YFVKOGM7.js} +65 -62
  7. package/{agentListCommands-HFEVV3ZW.js → agentListCommands-2PZHIQ3I.js} +128 -31
  8. package/{agentMachineCommands-25ZOENJU.js → agentMachineCommands-55UUZNHF.js} +38 -26
  9. package/{agentPullCommand-GOL2S4W2.js → agentPullCommand-KRBRIFIY.js} +7 -7
  10. package/{agentRecordCommands-GTCOAM3L.js → agentRecordCommands-BTP3OAPL.js} +57 -54
  11. package/{agentRunCommand-YBS3JDLD.js → agentRunCommand-AA4QLRQZ.js} +60 -59
  12. package/{agentRunControl-K4VKNEHF.js → agentRunControl-IX4F5W2C.js} +3 -3
  13. package/{agentRuntimeLocal-UQBMQI2M.js → agentRuntimeLocal-QDJCBXM2.js} +31 -15
  14. package/{agentSlice-6EKOBCCS.js → agentSlice-6JAJOU3X.js} +8 -9
  15. package/{authCommand-O2OWACN4.js → authCommand-DMW336GT.js} +15 -15
  16. package/{authCommands-H7365TZP.js → authCommands-GH5T6RYV.js} +6 -6
  17. package/{chunk-E4HNJSHC.js → chunk-2BVGERJ2.js} +81 -19
  18. package/{chunk-LP65VRCI.js → chunk-3MI5LDDU.js} +6 -6
  19. package/{chunk-OPZYGHUC.js → chunk-3WGLLTK4.js} +59 -1
  20. package/{chunk-KJR5KAUQ.js → chunk-3XF6LCCN.js} +20 -7
  21. package/{chunk-PXZAAB4L.js → chunk-4LG74DRG.js} +4 -4
  22. package/{chunk-2FTTDCD4.js → chunk-4ON5AV72.js} +2 -1
  23. package/{chunk-IWX4UW2E.js → chunk-524BDL33.js} +89 -8
  24. package/{chunk-ISNCLGUZ.js → chunk-5NBHQD4D.js} +4 -3
  25. package/{chunk-ZPRK73XY.js → chunk-5S4SWV5G.js} +51 -38
  26. package/{chunk-EVZKZF32.js → chunk-5V524MHX.js} +195 -78
  27. package/{chunk-CKOJQDKR.js → chunk-7JJCGV7N.js} +146 -3
  28. package/{chunk-NEM67FX7.js → chunk-ARSC56DC.js} +1 -1
  29. package/{chunk-AFON4QUU.js → chunk-AS3ZQ3O2.js} +19 -28
  30. package/{chunk-4SOKXIW4.js → chunk-B4KT7RN2.js} +10 -13
  31. package/chunk-BYXBJQAS.js +0 -0
  32. package/{chunk-PXQN7IBQ.js → chunk-C3BFP57W.js} +95 -2
  33. package/{chunk-AEZAORLG.js → chunk-CGDQDXKZ.js} +5 -5
  34. package/{chunk-MQI77IRB.js → chunk-DPFWKRHG.js} +2 -2
  35. package/{chunk-TACHTH5D.js → chunk-EIMX5ER5.js} +18 -18
  36. package/{chunk-5MOUAAMK.js → chunk-FSUZIGIG.js} +197 -2578
  37. package/{chunk-FXXSGWAJ.js → chunk-H5Y2H2N6.js} +1 -1
  38. package/chunk-IKXL2HZ3.js +70 -0
  39. package/{chunk-QNMFBBZK.js → chunk-IVAOVLM7.js} +1 -1
  40. package/chunk-JFANOO7I.js +2274 -0
  41. package/{chunk-YPRZSPF3.js → chunk-JKWWVF2I.js} +1 -1
  42. package/{chunk-3NSIQZZ6.js → chunk-JU7J7EAV.js} +45 -45
  43. package/{chunk-X2S7JTIG.js → chunk-KWBH4RAL.js} +1280 -137
  44. package/{chunk-OUI3ZHYD.js → chunk-LUKQQJFL.js} +39 -2
  45. package/{chunk-BX6U3ETE.js → chunk-MG6BVV3T.js} +320 -102
  46. package/{chunk-L53FGHA4.js → chunk-MQRZ5QUH.js} +1 -1
  47. package/{chunk-2W2VYVI5.js → chunk-MZHSAPZP.js} +675 -177
  48. package/{chunk-YOCHZD7D.js → chunk-NCGFB7NN.js} +5 -3
  49. package/{chunk-DWGAEFJL.js → chunk-O4FOPRCP.js} +1 -1
  50. package/chunk-OGGHETUE.js +4900 -0
  51. package/{chunk-PNEW2Z3T.js → chunk-OHEKYYJF.js} +7 -7
  52. package/chunk-OOIN7HSO.js +146 -0
  53. package/{chunk-SV5MWASH.js → chunk-OPM2DE2J.js} +12 -12
  54. package/{chunk-5OIFWVX7.js → chunk-QJSTNKJY.js} +1 -1
  55. package/{chunk-C4FTUXVF.js → chunk-QLUFR47U.js} +11 -1
  56. package/{chunk-LAX2JSTX.js → chunk-QUHUVG6Y.js} +20 -2
  57. package/{chunk-D6OQHXVG.js → chunk-RQSOAMPJ.js} +22 -6
  58. package/{chunk-ZEYDOXHF.js → chunk-RUGEW4P7.js} +1515 -884
  59. package/{chunk-GBDSZATH.js → chunk-RWO5DGXI.js} +3 -3
  60. package/{chunk-S3GS2PRL.js → chunk-TA7VKOHU.js} +613 -70
  61. package/{chunk-XYZA7S7V.js → chunk-TQYYGE6G.js} +6 -6
  62. package/{chunk-YTBMA7NO.js → chunk-TYPHUVK5.js} +70 -8
  63. package/{chunk-4ZDM73SD.js → chunk-V2J635L5.js} +1 -1
  64. package/{chunk-C2MDQQ4O.js → chunk-VBSWHE5W.js} +1 -1
  65. package/{chunk-O26GI2JP.js → chunk-VKG4HXYV.js} +39 -8
  66. package/{chunk-IPYUUY4E.js → chunk-WPHL6ALY.js} +1 -1
  67. package/{chunk-7D3JY6C2.js → chunk-WVTBAALN.js} +64 -5
  68. package/{chunk-XFOLQLDN.js → chunk-XHQWJUW4.js} +2 -2
  69. package/{chunk-Q3UKJVU4.js → chunk-Y5P3ZRGC.js} +10 -10
  70. package/{chunk-KQQVGRA3.js → chunk-YUMYYXPI.js} +53 -183
  71. package/cliEnvHelpers-VYC2OPTB.js +30 -0
  72. package/{createAgentAutomationAction-LTI5QU35.js → createAgentAutomationAction-4NY4JLOK.js} +26 -26
  73. package/{createDialogAction-OJJ7L3L3.js → createDialogAction-I5WUWFJ6.js} +26 -26
  74. package/{createPageAction-5MXWVRGY.js → createPageAction-HFTIQ7TW.js} +26 -26
  75. package/{dbSlice-RQFQQVHT.js → dbSlice-J4PUZ6Y5.js} +6 -7
  76. package/{deleteFile-7XP5BGC7.js → deleteFile-M7UNIUOO.js} +4 -4
  77. package/{dialogCommands-JTJ3RPPW.js → dialogCommands-SVXRJFZS.js} +34 -23
  78. package/{dialogSlice-OWROKURJ.js → dialogSlice-35LA3ZRG.js} +26 -26
  79. package/{docCreateCommands-WJBEW2V7.js → docCreateCommands-Z7RIAYKQ.js} +34 -23
  80. package/{docDeleteCommands-BVEHJOY5.js → docDeleteCommands-NEYHUVZF.js} +35 -25
  81. package/{docReadCommands-NEWOZIJV.js → docReadCommands-I4US2SDE.js} +34 -23
  82. package/{docStore-3DXRYBMD.js → docStore-3CP2IO6M.js} +25 -25
  83. package/{docUpdateCommands-C7WHT7UU.js → docUpdateCommands-UU5HQBRP.js} +34 -23
  84. package/fetchMessages-KTNM7QAR.js +1 -1
  85. package/{getPricing-3E6UNPKL.js → getPricing-UGDJHI7M.js} +7 -3
  86. package/{handleSendMessageAction-B5PRR7BE.js → handleSendMessageAction-FWTLQGOZ.js} +30 -30
  87. package/index.js +77 -76
  88. package/{localDialogRead-YSKFFRTT.js → localDialogRead-2VRI24F4.js} +1 -1
  89. package/{machineCommands-IIIREAEK.js → machineCommands-STHZKBDJ.js} +64 -61
  90. package/{machineWsRunDispatch-3SIU6ILW.js → machineWsRunDispatch-7YHT4TPT.js} +56 -53
  91. package/{memoryCommands-O4MIPIWQ.js → memoryCommands-AFMES3LN.js} +5 -5
  92. package/{models-4OPOOLFS.js → models-LSCRJJ6P.js} +2 -2
  93. package/package.json +1 -1
  94. package/{read-QJNKRROM.js → read-2MIMRBZ2.js} +4 -4
  95. package/{readDocTool-H6X6KO6X.js → readDocTool-QHVGQHUJ.js} +1 -1
  96. package/{readlineWorkspace-HGP3I3OC.js → readlineWorkspace-OMRWYMB6.js} +1279 -716
  97. package/{removeDialogAgentAction-TCT35SOF.js → removeDialogAgentAction-XUZYQBV4.js} +13 -13
  98. package/{runAgentClientLoop-EFM4PTVI.js → runAgentClientLoop-FP2K33ZO.js} +47 -46
  99. package/{runtimeDoctorCommands-ID43Z7VX.js → runtimeDoctorCommands-QNF3J3UV.js} +6 -6
  100. package/{setDialogExtraReferencesAction-CGYLZMFH.js → setDialogExtraReferencesAction-PTAIFKGM.js} +9 -10
  101. package/{setPrimaryDialogAgentAction-F6BFQDJU.js → setPrimaryDialogAgentAction-HRFTDB44.js} +13 -13
  102. package/{settingSlice-2I5HMG47.js → settingSlice-VGRJUSE5.js} +7 -8
  103. package/{skillDiscovery-UGSQGX2U.js → skillDiscovery-6M2BZUFN.js} +3 -3
  104. package/{spaceCommands-MT7BWCIL.js → spaceCommands-GN73BCOB.js} +38 -29
  105. package/{spaceSlice-BS5TSW3W.js → spaceSlice-WTFNKOVA.js} +30 -26
  106. package/{streamAgentChatTurn-I3VBFNR3.js → streamAgentChatTurn-HBAQQVNK.js} +442 -130
  107. package/{toolApiClient-C7P7YSE4.js → toolApiClient-QI3YBNWB.js} +2 -2
  108. package/{tools-XSD2BOEN.js → tools-TPQYTLQZ.js} +34 -33
  109. package/{tuiSummaryLlmCaller-32NRHTT2.js → tuiSummaryLlmCaller-XDC7WG4K.js} +11 -7
  110. package/{updateCommands-VOSPKXFF.js → updateCommands-XZDOOYFH.js} +13 -5
  111. package/{updateDialogTitleAction-7FYNJOGP.js → updateDialogTitleAction-AWXNPUQJ.js} +30 -29
  112. package/chunk-AZPCASRE.js +0 -36
  113. package/chunk-BBYVOSU2.js +0 -792
  114. package/chunk-DCOA4QSN.js +0 -105
  115. package/chunk-UAD2WT54.js +0 -64
  116. package/{chunk-JK7VW2FN.js → chunk-5MIDPSSK.js} +3 -3
  117. package/{chunk-5CS33IBL.js → chunk-PDL2AV3E.js} +3 -3
  118. package/{chunk-5MMZUWSG.js → chunk-TOILAPLH.js} +5 -5
  119. package/{chunk-OOM6SJNR.js → chunk-TSUJOM6N.js} +6 -6
  120. package/{db-6QED3ZVO.js → db-HCJ5PRB5.js} +3 -3
  121. package/{offlineMarxistsAgentCommand-BCPJITJL.js → offlineMarxistsAgentCommand-5OOWZLJI.js} +3 -3
  122. package/{tableCommands-M3DJUETS.js → tableCommands-E4SQWDOX.js} +6 -6
  123. package/{understanding-ZOESBLF3.js → understanding-3CUQQ6SV.js} +3 -3
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  buildStaticUserPolicyContext,
6
6
  resolveSpaceContextPreloadPlan
7
- } from "./chunk-5OIFWVX7.js";
7
+ } from "./chunk-QJSTNKJY.js";
8
8
  import {
9
9
  buildCliPrompt
10
10
  } from "./chunk-ATNTHIZI.js";
@@ -20,45 +20,51 @@ import {
20
20
  sanitizeOutboundResponsesInput,
21
21
  sendOpenAICompletionsRequest,
22
22
  updateTotalUsage
23
- } from "./chunk-KQQVGRA3.js";
23
+ } from "./chunk-YUMYYXPI.js";
24
24
  import "./chunk-JEXVIMYZ.js";
25
25
  import {
26
26
  prepareTools
27
- } from "./chunk-PXQN7IBQ.js";
27
+ } from "./chunk-C3BFP57W.js";
28
28
  import {
29
29
  fetchReferenceContents,
30
30
  generateRequestBody,
31
+ isResponsesConversationStateRejection,
31
32
  mergeReferences,
32
33
  performFetchRequest,
33
34
  performServerProxyFetchWithRetry,
34
35
  resolveAgentCallPlan,
35
36
  resolveClientWire,
36
37
  resolveReferenceAssets,
37
- resolveToolsFromKeys
38
- } from "./chunk-EVZKZF32.js";
39
- import "./chunk-FXXSGWAJ.js";
38
+ resolveToolsFromKeys,
39
+ selectResponsesConversationState,
40
+ updateResponsesConversationState
41
+ } from "./chunk-5V524MHX.js";
42
+ import "./chunk-H5Y2H2N6.js";
43
+ import {
44
+ TOOL_PACKS,
45
+ applyDefaultWebToolPacks,
46
+ applyDisabledTools,
47
+ createSSEParser,
48
+ expandEnabledPackPromptPatches,
49
+ expandEnabledPacks,
50
+ getAllToolRuns,
51
+ shouldBlockForGptPro,
52
+ waitForAbortableDelay
53
+ } from "./chunk-MZHSAPZP.js";
54
+ import "./chunk-RQSOAMPJ.js";
55
+ import "./chunk-OOIN7HSO.js";
56
+ import "./chunk-KQHGZWSV.js";
40
57
  import {
41
58
  getFinalPrice,
42
59
  getModelPricing,
43
60
  getPrices,
44
61
  hasExplicitAgentPricing
45
- } from "./chunk-YPRZSPF3.js";
62
+ } from "./chunk-JKWWVF2I.js";
46
63
  import {
47
64
  getPublicImageAgentDefaultProfile,
48
65
  getPublicImageAgentMode
49
66
  } from "./chunk-VIDPVFP3.js";
50
- import {
51
- TOOL_PACKS,
52
- applyDefaultWebToolPacks,
53
- applyDisabledTools,
54
- createSSEParser,
55
- expandEnabledPacks,
56
- getAllToolRuns,
57
- shouldBlockForGptPro
58
- } from "./chunk-2W2VYVI5.js";
59
- import "./chunk-D6OQHXVG.js";
60
- import "./chunk-KQHGZWSV.js";
61
- import "./chunk-QNMFBBZK.js";
67
+ import "./chunk-IVAOVLM7.js";
62
68
  import "./chunk-3LY4F7SV.js";
63
69
  import {
64
70
  extractCategorizedMentions
@@ -67,8 +73,8 @@ import "./chunk-63W5N6P3.js";
67
73
  import "./chunk-VF4K2QE6.js";
68
74
  import {
69
75
  getDocState
70
- } from "./chunk-XYZA7S7V.js";
71
- import "./chunk-E4HNJSHC.js";
76
+ } from "./chunk-TQYYGE6G.js";
77
+ import "./chunk-2BVGERJ2.js";
72
78
  import "./chunk-VC6OZXO5.js";
73
79
  import {
74
80
  PERSONALIZATION_DIALOG_CATEGORY,
@@ -76,14 +82,10 @@ import {
76
82
  addUserMessage,
77
83
  buildPersonalizationDialogPolicyContext,
78
84
  estimateMissingUsage,
79
- estimateTokenCount,
80
85
  extractReferenceKeysFromMessage,
81
86
  finalizeTransientMessageOnError,
82
- getModelContextWindow,
83
- getModelInfo,
84
87
  messageStreamEnd,
85
88
  messageStreaming,
86
- planContextUsage,
87
89
  prepareAndPersistUserMessage,
88
90
  removeTransientMessage,
89
91
  selectAllMsgs,
@@ -95,94 +97,64 @@ import {
95
97
  selectTableRows,
96
98
  selectViewMode,
97
99
  updateTokens
98
- } from "./chunk-5MOUAAMK.js";
99
- import "./chunk-4ZDM73SD.js";
100
+ } from "./chunk-FSUZIGIG.js";
101
+ import "./chunk-V2J635L5.js";
100
102
  import "./chunk-MRC4Q34M.js";
101
103
  import "./chunk-MTU75CZ2.js";
102
104
  import "./chunk-CWMSB67P.js";
103
- import "./chunk-Q3UKJVU4.js";
105
+ import "./chunk-Y5P3ZRGC.js";
104
106
  import {
105
107
  createCliChatTurnStream,
106
108
  getCliChatSession,
107
109
  startCliChatSession
108
- } from "./chunk-GBDSZATH.js";
110
+ } from "./chunk-RWO5DGXI.js";
109
111
  import "./chunk-Z4NR32XR.js";
110
112
  import "./chunk-M76ECQRD.js";
111
- import "./chunk-MQI77IRB.js";
112
- import {
113
- selectAiRecentContentLimit,
114
- selectCurrentServer,
115
- selectGlobalPrompt,
116
- selectKnowledgeCaptureLevel,
117
- selectMaxExecutionTime,
118
- selectSpaceContextLevel,
119
- selectUserTonePreset
120
- } from "./chunk-3NSIQZZ6.js";
121
- import "./chunk-Y5GCAMGP.js";
122
- import "./chunk-SOTZ6RDN.js";
123
- import "./chunk-7D3JY6C2.js";
124
- import "./chunk-UAD2WT54.js";
125
- import {
126
- patch,
127
- read,
128
- selectById,
129
- write
130
- } from "./chunk-O26GI2JP.js";
131
- import "./chunk-AZPCASRE.js";
132
- import "./chunk-DCOA4QSN.js";
133
- import "./chunk-XENYHRUE.js";
134
- import "./chunk-IPYUUY4E.js";
135
- import {
136
- buildLinkedSpacesSection,
137
- buildSpaceContextLayer
138
- } from "./chunk-C4FTUXVF.js";
139
- import "./chunk-KKY4B2Q2.js";
140
113
  import "./chunk-WZSRQNQG.js";
141
114
  import {
142
115
  assertDesktopAgentRuntimeTurnBodyHasNoRawSecrets,
143
116
  buildDesktopAgentRuntimeAgentConfigSnapshot,
144
117
  buildDesktopAgentRuntimeDialogHistorySnapshot
145
- } from "./chunk-YOCHZD7D.js";
118
+ } from "./chunk-NCGFB7NN.js";
146
119
  import {
120
+ projectToolMessageContent,
147
121
  resolveAgentImageInputSupport
148
- } from "./chunk-S3GS2PRL.js";
149
- import "./chunk-OPZYGHUC.js";
150
- import "./chunk-OUI3ZHYD.js";
122
+ } from "./chunk-TA7VKOHU.js";
123
+ import "./chunk-3WGLLTK4.js";
124
+ import "./chunk-LUKQQJFL.js";
151
125
  import {
152
126
  extractImagePartsFromResponseOutput,
153
127
  extractTextFromResponseOutput,
154
128
  toResponsesTools
155
- } from "./chunk-YTBMA7NO.js";
129
+ } from "./chunk-TYPHUVK5.js";
156
130
  import {
157
131
  canonicalizeToolNames,
158
132
  prioritizeToolNames,
159
133
  resolveRuntimeToolSurfaceForAgent
160
- } from "./chunk-4SOKXIW4.js";
134
+ } from "./chunk-B4KT7RN2.js";
135
+ import {
136
+ estimateTokenCount,
137
+ getModelContextWindow,
138
+ getModelInfo,
139
+ planContextUsage
140
+ } from "./chunk-JFANOO7I.js";
161
141
  import "./chunk-5MMAK75Q.js";
162
142
  import {
163
143
  getApiEndpoint,
164
144
  getModelConfig,
165
145
  getProviderByModelName
166
- } from "./chunk-BBYVOSU2.js";
167
- import "./chunk-5CS33IBL.js";
146
+ } from "./chunk-OGGHETUE.js";
147
+ import "./chunk-PDL2AV3E.js";
168
148
  import "./chunk-JZPBVBIY.js";
149
+ import "./chunk-BYXBJQAS.js";
169
150
  import {
170
- asRecordOrEmpty
171
- } from "./chunk-KX6YBIHG.js";
172
- import "./chunk-IWX4UW2E.js";
173
- import {
174
- createDialogMessageKeyAndId,
175
- dialogMessageKey
176
- } from "./chunk-O4BU24WZ.js";
177
- import {
178
- asNonEmptyStringArray
179
- } from "./chunk-I42VC5KR.js";
180
- import {
181
- asOptionalFiniteNumber
182
- } from "./chunk-WWC7I6TA.js";
151
+ buildLinkedSpacesSection,
152
+ buildSpaceContextLayer
153
+ } from "./chunk-QLUFR47U.js";
154
+ import "./chunk-KKY4B2Q2.js";
183
155
  import {
184
156
  resolveToolBaseUrl
185
- } from "./chunk-JK7VW2FN.js";
157
+ } from "./chunk-5MIDPSSK.js";
186
158
  import {
187
159
  extractCustomId
188
160
  } from "./chunk-DFFIZ25G.js";
@@ -196,32 +168,68 @@ import {
196
168
  selectPendingUserInputQueue,
197
169
  tokenUsageLiveUpdate
198
170
  } from "./chunk-3ASDTTEI.js";
199
- import "./chunk-QSJ3HFEF.js";
200
- import "./chunk-DWLEOOGR.js";
201
171
  import {
202
172
  toErrorMessage
203
173
  } from "./chunk-HNMXYYJR.js";
204
- import "./chunk-XFOLQLDN.js";
174
+ import "./chunk-SOTZ6RDN.js";
175
+ import "./chunk-XENYHRUE.js";
176
+ import "./chunk-DWLEOOGR.js";
177
+ import "./chunk-IKXL2HZ3.js";
178
+ import "./chunk-524BDL33.js";
179
+ import "./chunk-DPFWKRHG.js";
180
+ import {
181
+ selectAiRecentContentLimit,
182
+ selectCurrentServer,
183
+ selectGlobalPrompt,
184
+ selectKnowledgeCaptureLevel,
185
+ selectMaxExecutionTime,
186
+ selectSpaceContextLevel,
187
+ selectUserTonePreset
188
+ } from "./chunk-JU7J7EAV.js";
189
+ import "./chunk-Y5GCAMGP.js";
190
+ import {
191
+ asRecordOrEmpty
192
+ } from "./chunk-KX6YBIHG.js";
193
+ import "./chunk-WVTBAALN.js";
194
+ import {
195
+ patch,
196
+ read,
197
+ selectById,
198
+ write
199
+ } from "./chunk-VKG4HXYV.js";
200
+ import "./chunk-WPHL6ALY.js";
201
+ import {
202
+ createDialogMessageKeyAndId,
203
+ dialogMessageKey
204
+ } from "./chunk-O4BU24WZ.js";
205
+ import {
206
+ asNonEmptyStringArray
207
+ } from "./chunk-I42VC5KR.js";
208
+ import {
209
+ asOptionalFiniteNumber
210
+ } from "./chunk-WWC7I6TA.js";
211
+ import "./chunk-QSJ3HFEF.js";
212
+ import "./chunk-XHQWJUW4.js";
205
213
  import {
206
214
  selectIdentityToken,
207
215
  selectIdentityUser,
208
216
  selectIdentityUserId,
209
217
  selectRuntimeCurrentServer
210
- } from "./chunk-OOM6SJNR.js";
218
+ } from "./chunk-TSUJOM6N.js";
211
219
  import {
212
220
  getIsDesktopApp,
213
221
  isAbortError
214
222
  } from "./chunk-OOSFSFMA.js";
215
223
  import "./chunk-GBRG75BQ.js";
224
+ import {
225
+ isRecord
226
+ } from "./chunk-KUG52IAP.js";
216
227
  import {
217
228
  asTrimmedString
218
229
  } from "./chunk-3EUW3WEO.js";
219
230
  import "./chunk-U6VC4MU4.js";
220
- import {
221
- isRecord
222
- } from "./chunk-KUG52IAP.js";
223
- import "./chunk-4SN6J65J.js";
224
231
  import "./chunk-LCBAMY2M.js";
232
+ import "./chunk-4SN6J65J.js";
225
233
  import "./chunk-CF7PE763.js";
226
234
  import {
227
235
  asOptionalTrimmedString
@@ -518,25 +526,10 @@ var isRetryableInitialStreamError = (error) => {
518
526
  );
519
527
  };
520
528
  var waitForInitialStreamRetry = async (retryAfterMs, signal) => {
521
- if (signal?.aborted) {
522
- const abortError = new Error("Aborted");
523
- abortError.name = "AbortError";
524
- throw abortError;
525
- }
526
- await new Promise((resolve, reject) => {
527
- const onAbort = () => {
528
- clearTimeout(timeoutId);
529
- signal?.removeEventListener("abort", onAbort);
530
- const abortError = new Error("Aborted");
531
- abortError.name = "AbortError";
532
- reject(abortError);
533
- };
534
- const timeoutId = setTimeout(() => {
535
- signal?.removeEventListener("abort", onAbort);
536
- resolve();
537
- }, normalizeInitialStreamRetryAfterMs(retryAfterMs));
538
- signal?.addEventListener("abort", onAbort, { once: true });
539
- });
529
+ await waitForAbortableDelay(
530
+ normalizeInitialStreamRetryAfterMs(retryAfterMs),
531
+ signal
532
+ );
540
533
  };
541
534
 
542
535
  // packages/ai/chat/sendOpenAIResponseRequest.ts
@@ -618,7 +611,8 @@ var sendOpenAIResponseRequest = async ({
618
611
  dialogKey,
619
612
  parentMessageId,
620
613
  messageMetadata,
621
- quickChatPerfStartedAt
614
+ quickChatPerfStartedAt,
615
+ fallbackBodyData
622
616
  }) => {
623
617
  const { dispatch, getState, signal: thunkSignal } = thunkApi;
624
618
  const dialogId = extractCustomId(dialogKey);
@@ -652,7 +646,9 @@ var sendOpenAIResponseRequest = async ({
652
646
  hasHandedOff,
653
647
  finishReason,
654
648
  messageId,
655
- usage: state.usage ?? void 0
649
+ usage: state.usage ?? void 0,
650
+ responseId: typeof state.completedResponse?.id === "string" ? state.completedResponse.id : void 0,
651
+ ...state.responsesStateFallback ? { responsesStateFallback: true } : {}
656
652
  });
657
653
  const resetStateForRetry = () => {
658
654
  state.content = "";
@@ -846,6 +842,7 @@ var sendOpenAIResponseRequest = async ({
846
842
  return buildMeta(result.hasPendingInteraction, result.hasHandedOff, null);
847
843
  };
848
844
  let reader;
845
+ let responsesStateFallbackUsed = false;
849
846
  try {
850
847
  if (!parentMessageId) {
851
848
  dispatch(
@@ -878,13 +875,17 @@ var sendOpenAIResponseRequest = async ({
878
875
  }
879
876
  ] : []
880
877
  ];
881
- const sanitizedInput = Array.isArray(bodyData?.input) ? sanitizeOutboundResponsesInput(bodyData.input) : bodyData?.input;
882
- const baseBodyData = sanitizedInput !== bodyData?.input ? { ...bodyData, input: sanitizedInput } : bodyData;
883
- const requestBody = {
884
- ...baseBodyData,
885
- ...tools.length ? { tools, tool_choice: baseBodyData.tool_choice ?? "auto" } : {},
886
- stream: true
878
+ const buildRequestBody = (sourceBodyData) => {
879
+ const sanitizedInput = Array.isArray(sourceBodyData?.input) ? sanitizeOutboundResponsesInput(sourceBodyData.input) : sourceBodyData?.input;
880
+ const baseBodyData = sanitizedInput !== sourceBodyData?.input ? { ...sourceBodyData, input: sanitizedInput } : sourceBodyData;
881
+ return {
882
+ ...baseBodyData,
883
+ ...tools.length ? { tools, tool_choice: baseBodyData.tool_choice ?? "auto" } : {},
884
+ stream: true
885
+ };
887
886
  };
887
+ let requestBody = buildRequestBody(bodyData);
888
+ const fallbackRequestBody = fallbackBodyData ? buildRequestBody(fallbackBodyData) : null;
888
889
  const api = getApiEndpoint(agentConfig);
889
890
  const token = selectIdentityToken(getState());
890
891
  logQuickChatPerfStage(quickChatPerfStartedAt, "openai-response-fetch-starting", {
@@ -928,6 +929,17 @@ var sendOpenAIResponseRequest = async ({
928
929
  );
929
930
  }
930
931
  if (!response.ok) {
932
+ const rejectedStoredState = !!requestBody.previous_response_id && !!fallbackRequestBody && isResponsesConversationStateRejection(
933
+ response.status,
934
+ await response.clone().text().catch(() => "")
935
+ );
936
+ if (!responsesStateFallbackUsed && rejectedStoredState) {
937
+ responsesStateFallbackUsed = true;
938
+ state.responsesStateFallback = true;
939
+ requestBody = fallbackRequestBody;
940
+ resetStateForRetry();
941
+ continue attemptLoop;
942
+ }
931
943
  const errorMessage = await parseApiError(response);
932
944
  state.content = `[\u9519\u8BEF: ${errorMessage}]`;
933
945
  await finalize();
@@ -1025,6 +1037,12 @@ var sendOpenAIResponseRequest = async ({
1025
1037
  flush();
1026
1038
  }
1027
1039
  break;
1040
+ case "response.reasoning_text.delta":
1041
+ if (typeof event.delta === "string" && event.delta) {
1042
+ state.reasoning += event.delta;
1043
+ flush();
1044
+ }
1045
+ break;
1028
1046
  case "response.reasoning.done":
1029
1047
  if (event.text) {
1030
1048
  state.reasoning += event.text;
@@ -1083,6 +1101,9 @@ var sendOpenAIResponseRequest = async ({
1083
1101
  }
1084
1102
  case "response.completed":
1085
1103
  state.completedResponse = event.response ?? null;
1104
+ if (responsesStateFallbackUsed) {
1105
+ state.responsesStateFallback = true;
1106
+ }
1086
1107
  finishReason = event.response?.status === "completed" ? "stop" : event.response?.status ?? null;
1087
1108
  if (event.response?.usage) {
1088
1109
  state.usage = updateTotalUsage(state.usage, event.response.usage);
@@ -1480,6 +1501,29 @@ var buildEditingContextSummary = (state, runtimeOptions) => {
1480
1501
  ...formatAppConstraintPacks(constraintPacks)
1481
1502
  ].join("\n");
1482
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
+ }
1483
1527
  if (targetKind === "image" || targetKind === "file") {
1484
1528
  const editingTarget = runtimeOptions?.editingTarget;
1485
1529
  const metadata = editingTarget?.metadata;
@@ -1666,14 +1710,15 @@ var compressOldToolResults = (messages, maxChars = 800) => {
1666
1710
  }
1667
1711
  return messages.map((msg, idx) => {
1668
1712
  if (msg.role !== "tool") return msg;
1669
- if (idx > lastToolCallAssistantIdx) return msg;
1670
1713
  const content = typeof msg.content === "string" ? msg.content : JSON.stringify(msg.content);
1671
- if (content.length <= maxChars) return msg;
1672
- return {
1673
- ...msg,
1674
- content: content.slice(0, maxChars) + `
1675
- \u2026[\u622A\u65AD\uFF0C\u539F\u59CB\u957F\u5EA6 ${content.length} \u5B57\u7B26]`
1676
- };
1714
+ const projected = projectToolMessageContent({
1715
+ content,
1716
+ isFresh: idx > lastToolCallAssistantIdx,
1717
+ toolName: msg.name,
1718
+ historicalMaxChars: maxChars
1719
+ });
1720
+ if (projected === content) return msg;
1721
+ return { ...msg, content: projected };
1677
1722
  });
1678
1723
  };
1679
1724
  var trimMessagesWithSummary = (messages, contextWindow, summaryTokenCount) => {
@@ -1710,8 +1755,8 @@ var trimMessagesWithSummary = (messages, contextWindow, summaryTokenCount) => {
1710
1755
  }
1711
1756
  let cutIndex = messages.length - keepCount;
1712
1757
  if (cutIndex < 0) cutIndex = 0;
1713
- while (cutIndex < messages.length && messages[cutIndex].role === "tool") {
1714
- cutIndex++;
1758
+ while (cutIndex > 0 && messages[cutIndex]?.role === "tool") {
1759
+ cutIndex--;
1715
1760
  }
1716
1761
  return messages.slice(cutIndex);
1717
1762
  };
@@ -2034,7 +2079,13 @@ var mergeAgentToolsWithRuntime = (agentConfig, referencedTools, mentionedTools,
2034
2079
  ...new Set(asNonEmptyStringArray(agentConfig.recommendedSkillHints))
2035
2080
  ];
2036
2081
  const skillPromptPatches = [
2037
- ...new Set(asNonEmptyStringArray(agentConfig.skillPromptPatches))
2082
+ .../* @__PURE__ */ new Set([
2083
+ ...asNonEmptyStringArray(agentConfig.skillPromptPatches),
2084
+ // 能力包的 promptPatch(方法论文档)与 skill reference 的 patch 走同一条
2085
+ // 注入链(buildSkillGuidanceBlock → buildSkillGuidancePromptBlock),
2086
+ // 让「工具 + 配套纪律」作为一个能力包整体注入 system prompt。
2087
+ ...expandEnabledPackPromptPatches(effectiveEnabledPacks)
2088
+ ])
2038
2089
  ];
2039
2090
  const webPadded = applyDefaultWebToolPacks({
2040
2091
  toolNames: baseTools,
@@ -2619,7 +2670,11 @@ async function consumeAgentRunStream(handlers) {
2619
2670
 
2620
2671
  // packages/ai/llm/isResponseAPIModel.ts
2621
2672
  var isResponseAPIModel = (agentConfig) => {
2622
- if (agentConfig.provider !== "openai") return false;
2673
+ const provider = agentConfig.provider?.trim().toLowerCase();
2674
+ if (provider === "deepseek") {
2675
+ return agentConfig.model?.trim().toLowerCase() === "deepseek-v4-flash";
2676
+ }
2677
+ if (provider !== "openai") return false;
2623
2678
  if (agentConfig.endpointKey === "responses") return true;
2624
2679
  if (!agentConfig.model) return false;
2625
2680
  try {
@@ -2856,6 +2911,122 @@ function hasInlineExecutedToolCalls(result) {
2856
2911
  const output = result?.output;
2857
2912
  return Array.isArray(output) && output.some((b) => b?.type === "toolCall" && b?.result != null);
2858
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
+ }
2859
3030
  var streamAgentChatTurnHandler = async (args, thunkApi) => {
2860
3031
  const {
2861
3032
  agentKey,
@@ -2920,6 +3091,12 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
2920
3091
  runtimeOptions.quickChatModelOverride
2921
3092
  );
2922
3093
  }
3094
+ if (runtimeOptions?.quickChatReasoningEffort && rawAgentConfig.model === "deepseek-v4-flash") {
3095
+ rawAgentConfig = {
3096
+ ...rawAgentConfig,
3097
+ reasoning_effort: runtimeOptions.quickChatReasoningEffort
3098
+ };
3099
+ }
2923
3100
  if (isLiveAudioOnlyAgent(rawAgentConfig)) {
2924
3101
  return rejectWithValue(
2925
3102
  "\u6B64 Agent \u4EC5\u652F\u6301\u5B9E\u65F6\u8BED\u97F3\u6A21\u5F0F\uFF0C\u8BF7\u4F7F\u7528\u8BED\u97F3\u9762\u677F\u8FDB\u884C\u5BF9\u8BDD\u3002"
@@ -2989,6 +3166,11 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
2989
3166
  ...cliMessageMetadata,
2990
3167
  userId: selectIdentityUserId(getState())
2991
3168
  });
3169
+ const remoteToolHandlers = createRemoteToolEventHandlers({
3170
+ dialogId: dialogId2,
3171
+ dispatch,
3172
+ messageMetadata: cliMessageMetadata
3173
+ });
2992
3174
  dispatch(messageStreaming({
2993
3175
  id: messageId,
2994
3176
  dialogId: dialogId2,
@@ -3003,6 +3185,11 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3003
3185
  } else {
3004
3186
  dispatch(removeTransientMessage(messageId));
3005
3187
  }
3188
+ await persistRemoteToolMessagesAndCleanup(
3189
+ dispatch,
3190
+ remoteToolHandlers.activeToolMessages
3191
+ ).catch(() => {
3192
+ });
3006
3193
  setLoopStopReason("error");
3007
3194
  remoteTransientMessageFinalized = true;
3008
3195
  return rejectWithValue(message);
@@ -3045,8 +3232,20 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3045
3232
  const parseSSE = createSSEParser();
3046
3233
  const abortMachineStream = async () => {
3047
3234
  if (w2) w2.__LOOP_STOP_REASON__ = "aborted";
3048
- if (accumulated2.length <= 0) return;
3235
+ if (accumulated2.length <= 0) {
3236
+ await persistRemoteToolMessagesAndCleanup(
3237
+ dispatch,
3238
+ remoteToolHandlers.activeToolMessages
3239
+ ).catch(() => {
3240
+ });
3241
+ return;
3242
+ }
3049
3243
  await persistMessageWithFixedId(dispatch, buildMachineAssistantMessage());
3244
+ await persistRemoteToolMessagesAndCleanup(
3245
+ dispatch,
3246
+ remoteToolHandlers.activeToolMessages
3247
+ ).catch(() => {
3248
+ });
3050
3249
  };
3051
3250
  try {
3052
3251
  const result = await consumeAgentRunStream({
@@ -3061,6 +3260,7 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3061
3260
  if (payload.type === "error") {
3062
3261
  return { reject: payload.message || "\u7535\u8111\u7AEF Agent \u6267\u884C\u5931\u8D25" };
3063
3262
  }
3263
+ remoteToolHandlers.handleToolPayload(payload);
3064
3264
  if (payload.type === "text" && typeof payload.content === "string") {
3065
3265
  accumulated2 += payload.content;
3066
3266
  dispatch(messageStreaming({
@@ -3089,6 +3289,11 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3089
3289
  id: messageId,
3090
3290
  error: "\u7535\u8111\u7AEF Agent \u6D41\u5F0F\u54CD\u5E94\u88AB\u4E2D\u65AD,\u672A\u6536\u5230\u5B8C\u6210\u4FE1\u53F7"
3091
3291
  }));
3292
+ await persistRemoteToolMessagesAndCleanup(
3293
+ dispatch,
3294
+ remoteToolHandlers.activeToolMessages
3295
+ ).catch(() => {
3296
+ });
3092
3297
  remoteTransientMessageFinalized = true;
3093
3298
  setLoopStopReason("error");
3094
3299
  return rejectWithValue(
@@ -3096,6 +3301,10 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3096
3301
  );
3097
3302
  }
3098
3303
  await persistMessageWithFixedId(dispatch, buildMachineAssistantMessage());
3304
+ await persistRemoteToolMessagesAndCleanup(
3305
+ dispatch,
3306
+ remoteToolHandlers.activeToolMessages
3307
+ );
3099
3308
  remoteTransientMessageFinalized = true;
3100
3309
  }
3101
3310
  } finally {
@@ -3103,6 +3312,13 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3103
3312
  await reader2.cancel();
3104
3313
  } catch {
3105
3314
  }
3315
+ if (remoteToolHandlers.activeToolMessages.size > 0) {
3316
+ await persistRemoteToolMessagesAndCleanup(
3317
+ dispatch,
3318
+ remoteToolHandlers.activeToolMessages
3319
+ ).catch(() => {
3320
+ });
3321
+ }
3106
3322
  }
3107
3323
  return {
3108
3324
  usage: totalTurnUsage2 ?? void 0
@@ -3764,6 +3980,11 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3764
3980
  ...remoteMessageMetadata,
3765
3981
  userId: selectIdentityUserId(getState())
3766
3982
  });
3983
+ const remoteToolHandlers = createRemoteToolEventHandlers({
3984
+ dialogId,
3985
+ dispatch,
3986
+ messageMetadata: remoteMessageMetadata
3987
+ });
3767
3988
  loopKey = `loop:${dialogId}`;
3768
3989
  dispatch(addActiveController({ messageId: loopKey, controller: loopController, dialogKey }));
3769
3990
  dispatch(messageStreaming({
@@ -3780,6 +4001,11 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3780
4001
  } else {
3781
4002
  dispatch(removeTransientMessage(messageId));
3782
4003
  }
4004
+ await persistRemoteToolMessagesAndCleanup(
4005
+ dispatch,
4006
+ remoteToolHandlers.activeToolMessages
4007
+ ).catch(() => {
4008
+ });
3783
4009
  setLoopStopReason("error");
3784
4010
  remoteTransientMessageFinalized = true;
3785
4011
  return rejectWithValue(message);
@@ -3798,6 +4024,11 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3798
4024
  entrypoint: "chat-dialog",
3799
4025
  capabilities: ["streaming", "dialog-ui", "tool-cards"]
3800
4026
  },
4027
+ ...runtimeOptions?.quickChatReasoningEffort ? {
4028
+ runtimeOptions: {
4029
+ quickChatReasoningEffort: runtimeOptions.quickChatReasoningEffort
4030
+ }
4031
+ } : {},
3801
4032
  ...currentDialog?.spaceId ? { spaceId: currentDialog.spaceId } : {}
3802
4033
  });
3803
4034
  const remoteRunUrl = `${explicitServerBase.replace(/\/+$/, "")}/api/agent/run`;
@@ -3828,8 +4059,20 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3828
4059
  const decoder = new TextDecoder();
3829
4060
  const parseSSE = createSSEParser();
3830
4061
  const abortRemoteStream = async () => {
3831
- if (accumulated.length <= 0) return;
4062
+ if (accumulated.length <= 0) {
4063
+ await persistRemoteToolMessagesAndCleanup(
4064
+ dispatch,
4065
+ remoteToolHandlers.activeToolMessages
4066
+ ).catch(() => {
4067
+ });
4068
+ return;
4069
+ }
3832
4070
  await persistMessageWithFixedId(dispatch, buildRemoteAssistantMessage());
4071
+ await persistRemoteToolMessagesAndCleanup(
4072
+ dispatch,
4073
+ remoteToolHandlers.activeToolMessages
4074
+ ).catch(() => {
4075
+ });
3833
4076
  };
3834
4077
  try {
3835
4078
  const result = await consumeAgentRunStream({
@@ -3856,6 +4099,7 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3856
4099
  payload.agentKey
3857
4100
  );
3858
4101
  }
4102
+ remoteToolHandlers.handleToolPayload(payload);
3859
4103
  if (payload.type === "text" && typeof payload.content === "string") {
3860
4104
  accumulated += payload.content;
3861
4105
  dispatch(messageStreaming({
@@ -3884,6 +4128,11 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3884
4128
  id: messageId,
3885
4129
  error: "\u8FDC\u7AEF Agent \u6D41\u5F0F\u54CD\u5E94\u88AB\u4E2D\u65AD,\u672A\u6536\u5230\u5B8C\u6210\u4FE1\u53F7"
3886
4130
  }));
4131
+ await persistRemoteToolMessagesAndCleanup(
4132
+ dispatch,
4133
+ remoteToolHandlers.activeToolMessages
4134
+ ).catch(() => {
4135
+ });
3887
4136
  remoteTransientMessageFinalized = true;
3888
4137
  setLoopStopReason("error");
3889
4138
  return rejectWithValue(
@@ -3891,6 +4140,10 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3891
4140
  );
3892
4141
  }
3893
4142
  await persistMessageWithFixedId(dispatch, buildRemoteAssistantMessage());
4143
+ await persistRemoteToolMessagesAndCleanup(
4144
+ dispatch,
4145
+ remoteToolHandlers.activeToolMessages
4146
+ );
3894
4147
  remoteTransientMessageFinalized = true;
3895
4148
  }
3896
4149
  } finally {
@@ -3898,6 +4151,13 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
3898
4151
  await reader.cancel();
3899
4152
  } catch {
3900
4153
  }
4154
+ if (remoteToolHandlers.activeToolMessages.size > 0) {
4155
+ await persistRemoteToolMessagesAndCleanup(
4156
+ dispatch,
4157
+ remoteToolHandlers.activeToolMessages
4158
+ ).catch(() => {
4159
+ });
4160
+ }
3901
4161
  }
3902
4162
  return {
3903
4163
  usage: totalTurnUsage2 ?? void 0
@@ -4019,6 +4279,19 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
4019
4279
  });
4020
4280
  let appendTempUserInput2 = true;
4021
4281
  let currentParentMessageId2 = parentMessageId ?? void 0;
4282
+ const storedResponsesState = currentDialog?.responsesState;
4283
+ let responsesState = selectResponsesConversationState(
4284
+ storedResponsesState,
4285
+ agentConfigForCall
4286
+ );
4287
+ if (storedResponsesState != null && !responsesState) {
4288
+ dispatch(
4289
+ patch({
4290
+ dbKey: dialogKey,
4291
+ changes: { responsesState: null }
4292
+ })
4293
+ );
4294
+ }
4022
4295
  const w2 = typeof globalThis !== "undefined" && globalThis.window ? globalThis.window : null;
4023
4296
  if (w2) w2.__LOOP_STOP_REASON__ = null;
4024
4297
  loopKey = `loop:${dialogId}`;
@@ -4163,8 +4436,17 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
4163
4436
  messages: dynamicMessages,
4164
4437
  stableMessages,
4165
4438
  userInput: userInputText,
4166
- contexts
4439
+ contexts,
4440
+ responsesState
4167
4441
  });
4442
+ const fallbackBodyData = responsesState ? generateRequestBody({
4443
+ agentConfig: effectiveAgentConfig,
4444
+ messages: dynamicMessages,
4445
+ stableMessages,
4446
+ userInput: userInputText,
4447
+ contexts,
4448
+ responsesState: null
4449
+ }) : void 0;
4168
4450
  logQuickChatPerfStage2(quickChatPerfStartedAt, "stream-agent-model-request-starting", {
4169
4451
  responseApi: true,
4170
4452
  dynamicMessageCount: dynamicMessages.length,
@@ -4178,7 +4460,8 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
4178
4460
  dialogKey,
4179
4461
  parentMessageId: currentParentMessageId2,
4180
4462
  messageMetadata: streamingMessageMetadata,
4181
- quickChatPerfStartedAt
4463
+ quickChatPerfStartedAt,
4464
+ fallbackBodyData
4182
4465
  });
4183
4466
  logQuickChatPerfStage2(quickChatPerfStartedAt, "stream-agent-model-request-finished", {
4184
4467
  responseApi: true,
@@ -4188,6 +4471,35 @@ var streamAgentChatTurnHandler = async (args, thunkApi) => {
4188
4471
  });
4189
4472
  appendTempUserInput2 = false;
4190
4473
  currentParentMessageId2 = void 0;
4474
+ if (meta.responseId) {
4475
+ responsesState = updateResponsesConversationState(
4476
+ agentConfigForCall,
4477
+ meta.responseId
4478
+ );
4479
+ if (responsesState) {
4480
+ dispatch(
4481
+ patch({
4482
+ dbKey: dialogKey,
4483
+ changes: { responsesState }
4484
+ })
4485
+ );
4486
+ } else if (meta.responsesStateFallback) {
4487
+ dispatch(
4488
+ patch({
4489
+ dbKey: dialogKey,
4490
+ changes: { responsesState: null }
4491
+ })
4492
+ );
4493
+ }
4494
+ } else if (meta.responsesStateFallback) {
4495
+ responsesState = null;
4496
+ dispatch(
4497
+ patch({
4498
+ dbKey: dialogKey,
4499
+ changes: { responsesState: null }
4500
+ })
4501
+ );
4502
+ }
4191
4503
  totalTurnUsage = updateTotalUsage(totalTurnUsage, meta.usage);
4192
4504
  if (meta.hasHandedOff) {
4193
4505
  if (!requestParentMessageId && meta.messageId) {