nolo-cli 0.16.0-alpha.9 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/{_executeModel-ABTND4KZ.js → _executeModel-WPNX5DH4.js} +46 -41
  2. package/{action-F5JACQBG.js → action-LT7BRFLK.js} +10 -9
  3. package/{addContentAction-AQXEYRBE.js → addContentAction-PL3KKBDH.js} +9 -8
  4. package/{addDialogAgentAction-EJHHJZWW.js → addDialogAgentAction-FCMSKYAF.js} +8 -7
  5. package/{agentDeleteCommand-ARMAV46L.js → agentDeleteCommand-L3357EFL.js} +28 -26
  6. package/{agentEmailCommands-BKPZP4UP.js → agentEmailCommands-N65AVLEI.js} +58 -53
  7. package/{agentListCommands-5J7RRXUO.js → agentListCommands-CH27FTI2.js} +27 -25
  8. package/{agentMachineCommands-VXWJXXPF.js → agentMachineCommands-PPK5HJZB.js} +26 -24
  9. package/{agentPullCommand-6HWUT3SW.js → agentPullCommand-ZZGU5KOY.js} +4 -4
  10. package/{agentRecordCommands-INDJINPN.js → agentRecordCommands-HTVXD4TT.js} +53 -48
  11. package/{agentRunCommand-KBN6HBY4.js → agentRunCommand-MGLVJUA5.js} +59 -51
  12. package/{agentRunControl-6ADXVYMR.js → agentRunControl-P75VPTGS.js} +24 -1
  13. package/{agentRuntimeLocal-AH2RYWGP.js → agentRuntimeLocal-QUTBSY3I.js} +22 -20
  14. package/{agentSlice-R4PELU57.js → agentSlice-DOGRCMWK.js} +9 -8
  15. package/{appDeleteCommands-FRWMPQNS.js → appDeleteCommands-FEEVXUBG.js} +25 -23
  16. package/{appDeployCommands-IRF3T35Z.js → appDeployCommands-C4HCGC4B.js} +25 -23
  17. package/{appDeployStatusCommands-ADFERYPU.js → appDeployStatusCommands-IR5ZUZBQ.js} +25 -23
  18. package/{appGetCommands-FTEOXWMS.js → appGetCommands-6RJGZ66Z.js} +25 -23
  19. package/{appListCommands-WBY7UWYD.js → appListCommands-VMTF5YZF.js} +25 -23
  20. package/{authCommand-QU5BXRBH.js → authCommand-WJZPOLSS.js} +13 -12
  21. package/{authCommands-YXGOXNBZ.js → authCommands-XTBV7OFZ.js} +6 -5
  22. package/{chunk-XPC5C7BK.js → chunk-3ND52WIL.js} +2 -2
  23. package/{chunk-SOTZ6RDN.js → chunk-3Q7WHGCB.js} +1 -1
  24. package/{chunk-WVDAUR2S.js → chunk-45BY7RLP.js} +2 -8
  25. package/{chunk-KKY4B2Q2.js → chunk-4PWB7JRR.js} +4 -1
  26. package/{chunk-6N4KODMN.js → chunk-4T5F7YZQ.js} +1 -1
  27. package/chunk-7BUYEZ6U.js +671 -0
  28. package/{chunk-AS3ZQ3O2.js → chunk-7OBMZCRD.js} +1 -1
  29. package/{chunk-4N7QA72L.js → chunk-AAODAAUQ.js} +1 -1
  30. package/{chunk-QLUFR47U.js → chunk-AL2V7U3E.js} +1 -1
  31. package/{chunk-MTU75CZ2.js → chunk-B5TOXZAK.js} +1 -1
  32. package/{chunk-VK2HVKAO.js → chunk-BT6K76S7.js} +192 -249
  33. package/{chunk-G63IH3ZK.js → chunk-CEFXYF66.js} +1 -1
  34. package/{chunk-RLCXU7A5.js → chunk-D3HVJJIA.js} +1 -1
  35. package/{chunk-B4KT7RN2.js → chunk-DKZFOK24.js} +18 -89
  36. package/chunk-DL6EPNIK.js +50 -0
  37. package/{chunk-OELQ67TN.js → chunk-EGPCU42M.js} +57 -7
  38. package/{chunk-IWLUTMYX.js → chunk-ELT65PZW.js} +2 -2
  39. package/chunk-FKXFCYVO.js +221 -0
  40. package/{chunk-5Y5KEB7V.js → chunk-FPKLD4KB.js} +4 -4
  41. package/{chunk-FMYTM25W.js → chunk-FVIPEIVX.js} +10 -3
  42. package/{chunk-66X4VSRC.js → chunk-HQPG2PIV.js} +41 -1
  43. package/{chunk-ZPPTWRPT.js → chunk-HV2A3B4W.js} +1 -1
  44. package/{chunk-ASZ2C44S.js → chunk-IOOMJJ4Z.js} +1 -1
  45. package/{setDialogExtraReferencesAction-LR6MSIXO.js → chunk-JLA4FXYC.js} +2 -17
  46. package/{chunk-IFPY2BIE.js → chunk-JP7REMYP.js} +18 -0
  47. package/{chunk-R6ALN5F5.js → chunk-L2MLZQXU.js} +3 -3
  48. package/{chunk-HSLJ7QER.js → chunk-L6NVTGI7.js} +1 -1
  49. package/{chunk-BHVBFI6B.js → chunk-MD3V54DA.js} +6 -6
  50. package/{chunk-ZVDRAEZL.js → chunk-MUCU6ATG.js} +1 -1
  51. package/{chunk-KFHN5NGJ.js → chunk-MVQ4TBSD.js} +1 -1
  52. package/{chunk-7HECYFOI.js → chunk-NEKFSXOP.js} +316 -212
  53. package/{chunk-LSHKV3S7.js → chunk-NVB267BZ.js} +397 -324
  54. package/{chunk-SGRDLYRZ.js → chunk-NYUXSXLY.js} +33 -14
  55. package/{chunk-PEDT43JF.js → chunk-PZCBZO4J.js} +2 -2
  56. package/{chunk-LZYEWFPK.js → chunk-QCJITMYO.js} +16 -10
  57. package/{chunk-OOSFSFMA.js → chunk-R5V5G73M.js} +2 -0
  58. package/{chunk-QLWU2KOT.js → chunk-RG2U2MTJ.js} +1 -1
  59. package/{chunk-2XA3QGOH.js → chunk-RRGVDPH3.js} +3 -3
  60. package/{chunk-EABWT43X.js → chunk-RVOUXDFU.js} +5 -5
  61. package/{chunk-JTINRTBT.js → chunk-SKDNBYZK.js} +2 -2
  62. package/{chunk-BG7AP3Q7.js → chunk-SNZV4QCE.js} +34 -18
  63. package/{chunk-KMQPSTMJ.js → chunk-TRT4I4UD.js} +2 -2
  64. package/{chunk-MYMMNKYL.js → chunk-TSIYZBTH.js} +156 -6
  65. package/{chunk-J3VQSU5W.js → chunk-UB4RYYNQ.js} +1 -1
  66. package/{chunk-YJKXGHJ6.js → chunk-UGUW3FHG.js} +4 -4
  67. package/{chunk-XECKIDGJ.js → chunk-UZY4BEBR.js} +938 -91
  68. package/chunk-V5R4NZP2.js +78 -0
  69. package/{chunk-GWESD7AS.js → chunk-VDNQF5VI.js} +6 -6
  70. package/{chunk-ZVC2PCZN.js → chunk-VGMJ6PDJ.js} +5 -5
  71. package/{chunk-W4NVOSFF.js → chunk-WFHXMLHZ.js} +1 -1
  72. package/{chunk-H33743XH.js → chunk-WJRJDX2W.js} +1 -1
  73. package/chunk-X4Q4UZEY.js +26 -0
  74. package/{chunk-RPDGJO4D.js → chunk-XHG22OEX.js} +4 -4
  75. package/{chunk-DVRHHFEA.js → chunk-XMLRJUU5.js} +1 -1
  76. package/{chunk-3S2VOMIF.js → chunk-XRZJGPFI.js} +7 -7
  77. package/{chunk-AFNJWHKL.js → chunk-YLRTBX4Y.js} +26 -14
  78. package/{chunk-4EME3YTO.js → chunk-YXTRNO5W.js} +3 -3
  79. package/{chunk-VAT72PDP.js → chunk-ZJZCMKOR.js} +103 -174
  80. package/{chunk-F6JSVFHX.js → chunk-ZVOZH2HW.js} +1 -1
  81. package/chunk-ZZ2MH7LE.js +84 -0
  82. package/{cliExecutor-K3F7DMRO.js → cliExecutor-DNE7TCC4.js} +2 -2
  83. package/codingSkills-36KN5NQT.js +48 -0
  84. package/{createAgentAutomationAction-3KKRAYGE.js → createAgentAutomationAction-PMOLEPGJ.js} +18 -17
  85. package/{createDialogAction-S7NMQ4TZ.js → createDialogAction-DPRTYNAK.js} +20 -19
  86. package/{createPageAction-2EFBT4LQ.js → createPageAction-JGZK3WAM.js} +24 -23
  87. package/{dbSlice-7KQH6GOU.js → dbSlice-CGSRFJN3.js} +8 -7
  88. package/{deleteFile-WPWVZE4B.js → deleteFile-WDZ3VM7B.js} +3 -3
  89. package/{dialogCommands-J7XFIQRD.js → dialogCommands-XED6DKLV.js} +26 -24
  90. package/{dialogSlice-LNRRBUIC.js → dialogSlice-KO4NRNKC.js} +18 -17
  91. package/{docCreateCommands-MKO5WB34.js → docCreateCommands-P6DYWHH3.js} +24 -22
  92. package/{docDeleteCommands-RCBHRKUE.js → docDeleteCommands-KUWXAMSN.js} +25 -23
  93. package/{docReadCommands-66527P4G.js → docReadCommands-ECW55TKB.js} +24 -22
  94. package/{docStore-67MYPX7P.js → docStore-6KMERNUY.js} +19 -18
  95. package/{docUpdateCommands-UT5HSLOJ.js → docUpdateCommands-5J4BTJQN.js} +24 -22
  96. package/{fetchMessages-KTNM7QAR.js → fetchMessages-BMGVZVSE.js} +4 -3
  97. package/{getPricing-P4XRJRZB.js → getPricing-RYY6OBA4.js} +2 -2
  98. package/{handleSendMessageAction-VZ7226PB.js → handleSendMessageAction-R3ZHTVU4.js} +19 -18
  99. package/index.js +68 -68
  100. package/{localDialogRead-2VRI24F4.js → localDialogRead-HQZPVIE3.js} +1 -1
  101. package/{localRuntimeDb-LGDF6FQP.js → localRuntimeDb-THJZGAOJ.js} +1 -1
  102. package/{machineCommands-ATA7OSBJ.js → machineCommands-JF2YL34J.js} +59 -54
  103. package/{machineWsRunDispatch-ZDCZ645H.js → machineWsRunDispatch-ON4AEOJL.js} +51 -46
  104. package/package.json +1 -1
  105. package/queryRunOverlay-O4LOMMPO.js +161 -0
  106. package/{read-CN3TNXIP.js → read-3FMPZPER.js} +3 -3
  107. package/{readDocTool-WF3675ED.js → readDocTool-VSYHKK3V.js} +1 -1
  108. package/{readlineWorkspace-UUNABTLB.js → readlineWorkspace-SUCINTL7.js} +302 -134
  109. package/{removeDialogAgentAction-YDHBFEGI.js → removeDialogAgentAction-OAGA2G3U.js} +10 -9
  110. package/{runAgentClientLoop-2A577WBM.js → runAgentClientLoop-OBD2AVEL.js} +41 -36
  111. package/runOverlayPresentation-ZO4VCWEU.js +11 -0
  112. package/{runtimeDoctorCommands-THIHX2SY.js → runtimeDoctorCommands-E2OUORHK.js} +6 -6
  113. package/setDialogExtraReferencesAction-JZEXA5SL.js +27 -0
  114. package/{setPrimaryDialogAgentAction-IIVDCY5C.js → setPrimaryDialogAgentAction-4ZUQQKDG.js} +26 -17
  115. package/{settingSlice-O23YDK2O.js → settingSlice-7MNKHZ6R.js} +9 -8
  116. package/{skillDiscovery-6M2BZUFN.js → skillDiscovery-KJWT7JBU.js} +3 -3
  117. package/{spaceCommands-UNZVR2OS.js → spaceCommands-32NTNLHS.js} +27 -25
  118. package/{spaceSlice-MC7FYPMZ.js → spaceSlice-P7VOXLY6.js} +18 -17
  119. package/{streamAgentChatTurn-IEKPNM33.js → streamAgentChatTurn-UHEMNI3X.js} +91 -48
  120. package/{tableCommands-3P7MJ3PF.js → tableCommands-BEQAGE4I.js} +1 -1
  121. package/{tools-E6FHKTCF.js → tools-BMXIXHMB.js} +31 -26
  122. package/{tuiSummaryLlmCaller-QHPDD4WP.js → tuiSummaryLlmCaller-VUNVBRX3.js} +3 -3
  123. package/types-ZSTJ7MPR.js +7 -0
  124. package/{updateDialogTitleAction-SQJEEW2K.js → updateDialogTitleAction-LJBDYZLH.js} +21 -20
  125. package/{chunk-O4BU24WZ.js → chunk-6Y7A3OQQ.js} +3 -3
  126. package/{chunk-CMKUBIGW.js → chunk-X7W4TNB4.js} +3 -3
  127. package/{localRuntimeAuthority-TEGCOWX4.js → localRuntimeAuthority-4IXJCHZ7.js} +3 -3
@@ -3,12 +3,11 @@ import {
3
3
  refreshAntigravityOAuthToken,
4
4
  refreshOpenAiCodexToken,
5
5
  refreshXaiOAuthToken
6
- } from "./chunk-J3VQSU5W.js";
6
+ } from "./chunk-UB4RYYNQ.js";
7
7
  import {
8
8
  buildLocalAgentLookupKeys,
9
- normalizeAgentHandle,
10
9
  shouldReadAgentKeyRemotely
11
- } from "./chunk-WVDAUR2S.js";
10
+ } from "./chunk-45BY7RLP.js";
12
11
  import {
13
12
  LOCAL_CODEX_AGENT_ID,
14
13
  LOCAL_CODEX_AGENT_KEY,
@@ -17,17 +16,17 @@ import {
17
16
  } from "./chunk-VHBWHNVT.js";
18
17
  import {
19
18
  inferCaptureIntent
20
- } from "./chunk-KFHN5NGJ.js";
19
+ } from "./chunk-MVQ4TBSD.js";
21
20
  import {
22
21
  inlineImageUrlsForCustomProvider,
23
22
  prepareTools
24
- } from "./chunk-PEDT43JF.js";
23
+ } from "./chunk-PZCBZO4J.js";
25
24
  import {
26
25
  getAntigravityUserAgent,
27
26
  isAntigravityOAuthAgent,
28
27
  readAntigravityProjectId,
29
28
  resolveAntigravityCloudCodeBaseUrl
30
- } from "./chunk-HSLJ7QER.js";
29
+ } from "./chunk-L6NVTGI7.js";
31
30
  import {
32
31
  FORCED_TOOLS,
33
32
  addDefaultLightWebToolsForConfiguredAgents,
@@ -36,19 +35,13 @@ import {
36
35
  applyDisabledTools,
37
36
  applySystemBuiltinSkillFilter,
38
37
  expandEnabledPacks,
39
- formatListRunsCard,
40
- formatNotFoundRunCard,
41
- formatStartRunCard,
42
- formatStatusRunCard,
43
- formatStopRunCard,
44
38
  readXPostFunc,
45
39
  readXPostFunctionSchema,
46
40
  readXhsProfileFunc,
47
41
  readXhsProfileFunctionSchema,
48
42
  rememberMemoryFunctionSchema,
49
- resolveEffectiveEnabledPacks,
50
- resolveRunLabel
51
- } from "./chunk-7HECYFOI.js";
43
+ resolveEffectiveEnabledPacks
44
+ } from "./chunk-NEKFSXOP.js";
52
45
  import {
53
46
  createDrainExhaustedResponse,
54
47
  isCoreDrainingBody,
@@ -58,15 +51,18 @@ import {
58
51
  import {
59
52
  normalizeDialogTitle
60
53
  } from "./chunk-OWOHNGCN.js";
54
+ import {
55
+ getDefaultCliLocalRuntimeDb
56
+ } from "./chunk-WJRJDX2W.js";
61
57
  import {
62
58
  prepareTokenUsageData
63
- } from "./chunk-LSHKV3S7.js";
59
+ } from "./chunk-NVB267BZ.js";
64
60
  import {
65
61
  BUILTIN_TITLE_LLM_CONFIG
66
62
  } from "./chunk-XOIF2TNF.js";
67
63
  import {
68
64
  fetchServerSyncedCredential
69
- } from "./chunk-BHVBFI6B.js";
65
+ } from "./chunk-MD3V54DA.js";
70
66
  import {
71
67
  buildAgentRuntimeDialogWritePlan,
72
68
  buildLocalWorkspaceOpenAiTools,
@@ -80,7 +76,7 @@ import {
80
76
  parseSseDataLineObject,
81
77
  readOpenAiCompatibleSseCompletion,
82
78
  resolveOpenAiCompatibleProviderConfig
83
- } from "./chunk-AFNJWHKL.js";
79
+ } from "./chunk-YLRTBX4Y.js";
84
80
  import {
85
81
  buildPlatformChatCompletionRequest,
86
82
  canUsePlatformChatProvider,
@@ -89,28 +85,27 @@ import {
89
85
  readSseDataValues,
90
86
  resolvePlatformChatProviderConfig,
91
87
  shouldUsePlatformChatProvider
92
- } from "./chunk-4N7QA72L.js";
88
+ } from "./chunk-AAODAAUQ.js";
93
89
  import {
94
90
  resolveAgentRuntimeConfigFromRecord
95
91
  } from "./chunk-OIQPORYI.js";
96
92
  import {
97
93
  summarizeToolArguments
98
- } from "./chunk-LZYEWFPK.js";
94
+ } from "./chunk-QCJITMYO.js";
99
95
  import {
100
96
  convertMessagesToResponsesInput,
101
97
  toResponsesTools
102
98
  } from "./chunk-KFEVY3ST.js";
103
99
  import {
104
100
  resolvePlatformAuthToken
105
- } from "./chunk-ZVDRAEZL.js";
101
+ } from "./chunk-MUCU6ATG.js";
106
102
  import {
107
103
  buildLoadSkillExecutor,
108
104
  buildNoloWorkspaceCliToolExecutors,
109
105
  buildNoloWorkspaceOpenAiTools,
110
- canonicalizeToolNames,
111
106
  parseNoloWorkspaceToolArguments,
112
107
  resolveRuntimeToolSurfaceForAgent
113
- } from "./chunk-B4KT7RN2.js";
108
+ } from "./chunk-DKZFOK24.js";
114
109
  import {
115
110
  clipCompactText
116
111
  } from "./chunk-5MMAK75Q.js";
@@ -126,6 +121,15 @@ import {
126
121
  readOAuthCredential,
127
122
  resolveFreshAccessToken
128
123
  } from "./chunk-JZPBVBIY.js";
124
+ import {
125
+ isAdaptiveThinkingModelId
126
+ } from "./chunk-HQPG2PIV.js";
127
+ import {
128
+ toErrorMessage
129
+ } from "./chunk-HNMXYYJR.js";
130
+ import {
131
+ canonicalizeToolNames
132
+ } from "./chunk-ZZ2MH7LE.js";
129
133
  import {
130
134
  compactWhitespace
131
135
  } from "./chunk-DWLEOOGR.js";
@@ -133,22 +137,29 @@ import {
133
137
  checkStaleRun,
134
138
  finalizeRunRecord,
135
139
  findRunRecord,
136
- listRunRecords,
140
+ gcRunRecords,
141
+ queryRunRecords,
137
142
  spawnLocalBackgroundRun
138
- } from "./chunk-MYMMNKYL.js";
143
+ } from "./chunk-TSIYZBTH.js";
144
+ import {
145
+ TASK_PREVIEW_MAX,
146
+ formatListRunsCard,
147
+ formatNotFoundRunCard,
148
+ formatStartRunCard,
149
+ formatStatusRunCard,
150
+ formatStopRunCard,
151
+ isAgentNameFallback,
152
+ isAgentRunTerminalStatus,
153
+ resolveRunLabel,
154
+ shortRunId
155
+ } from "./chunk-FKXFCYVO.js";
139
156
  import {
140
157
  CliProviderQuotaError,
141
158
  executeCli
142
- } from "./chunk-CMKUBIGW.js";
159
+ } from "./chunk-X7W4TNB4.js";
143
160
  import {
144
161
  buildCliPrompt
145
162
  } from "./chunk-ATNTHIZI.js";
146
- import {
147
- toErrorMessage
148
- } from "./chunk-HNMXYYJR.js";
149
- import {
150
- getDefaultCliLocalRuntimeDb
151
- } from "./chunk-H33743XH.js";
152
163
  import {
153
164
  isCompiledBinary,
154
165
  parseUserIdFromAuthToken
@@ -160,13 +171,13 @@ import {
160
171
  createTokenKey,
161
172
  createUserKey,
162
173
  dialogMessageRange
163
- } from "./chunk-O4BU24WZ.js";
164
- import {
165
- asTrimmedNonEmptyStringArray
166
- } from "./chunk-I42VC5KR.js";
174
+ } from "./chunk-6Y7A3OQQ.js";
167
175
  import {
168
176
  asOptionalFiniteNumber
169
177
  } from "./chunk-WWC7I6TA.js";
178
+ import {
179
+ asTrimmedNonEmptyStringArray
180
+ } from "./chunk-I42VC5KR.js";
170
181
  import {
171
182
  asTrimmedLowercaseString
172
183
  } from "./chunk-QSJ3HFEF.js";
@@ -176,7 +187,7 @@ import {
176
187
  PUBLIC_DEEPSEEK_V4_PRO_AGENT_KEY,
177
188
  PUBLIC_GLM_52_AGENT_KEY,
178
189
  PUBLIC_KIMI_K26_IMAGE_AGENT_KEY
179
- } from "./chunk-XPC5C7BK.js";
190
+ } from "./chunk-3ND52WIL.js";
180
191
  import {
181
192
  asTrimmedString
182
193
  } from "./chunk-3EUW3WEO.js";
@@ -466,6 +477,10 @@ var STRINGS = {
466
477
  en: "Run stopped",
467
478
  zh: "\u8FD0\u884C\u5DF2\u505C\u6B62"
468
479
  },
480
+ runFinishedLabel: {
481
+ en: "Run finished",
482
+ zh: "\u8FD0\u884C\u5DF2\u7ED3\u675F"
483
+ },
469
484
  runLogTailLabel: {
470
485
  en: "Log tail:",
471
486
  zh: "\u65E5\u5FD7\u5C3E\u90E8\uFF1A"
@@ -500,6 +515,10 @@ var STRINGS = {
500
515
  en: "selected",
501
516
  zh: "\u5DF2\u9009"
502
517
  },
518
+ dialogMultiSelectRequired: {
519
+ en: "Pick at least one option to submit",
520
+ zh: "\u81F3\u5C11\u9009\u62E9\u4E00\u9879\u624D\u80FD\u63D0\u4EA4"
521
+ },
503
522
  dialogConfirmHint: {
504
523
  en: "(\u2191\u2193 move \xB7 Enter choose \xB7 Esc cancel)",
505
524
  zh: "\uFF08\u2191\u2193 \u79FB\u52A8 \xB7 Enter \u9009\u62E9 \xB7 Esc \u53D6\u6D88\uFF09"
@@ -540,7 +559,7 @@ var STRINGS = {
540
559
  en: "abort the operation",
541
560
  zh: "\u4E2D\u6B62\u64CD\u4F5C"
542
561
  },
543
- // --- Ask choice (ui_ask_choice) ------------------------------------------
562
+ // --- Ask choice (ask_user) ------------------------------------------
544
563
  askChoiceTitle: {
545
564
  en: "question",
546
565
  zh: "\u95EE\u9898"
@@ -931,11 +950,191 @@ function agentRunCardLabels() {
931
950
  runStatus: t("runStatusLabel"),
932
951
  runStarted: t("runStartedLabel"),
933
952
  runStopped: t("runStoppedLabel"),
953
+ runFinished: t("runFinishedLabel"),
934
954
  logTail: t("runLogTailLabel"),
935
955
  runs: (count) => t("runsListLabel", String(count))
936
956
  };
937
957
  }
938
958
 
959
+ // packages/ai/tools/agent/quotaCircuitBreaker.ts
960
+ var QUOTA_ERROR_PATTERNS = [
961
+ /429/,
962
+ /quota/i,
963
+ /rate\s*limit/i,
964
+ /too\s*many\s*requests/i,
965
+ /额度/,
966
+ /上限/,
967
+ /用尽/,
968
+ /CliProviderQuotaError/i
969
+ ];
970
+ var AGENT_NOT_FOUND_PATTERNS = [
971
+ /agent[^\n]{0,80}not\s+found/i,
972
+ /agent[^\n]{0,80}not\s+exist/i,
973
+ /agent[^\n]{0,80}不存在/i,
974
+ /agent[^\n]{0,80}未找到/i,
975
+ /AGENT_NOT_FOUND/
976
+ ];
977
+ var AUTH_ERROR_PATTERNS = [
978
+ /401/,
979
+ /403/,
980
+ /unauthori[sz]ed/i,
981
+ /authentication\s+failed/i,
982
+ /invalid\s+(api[-\s]?key|token|credential)/i,
983
+ /api[-\s]?key\s+(invalid|missing|not\s+found)/i,
984
+ /token\s*(invalid|expired|失效|过期)/i,
985
+ /未授权/,
986
+ /认证失败/,
987
+ /凭证/
988
+ ];
989
+ var NETWORK_ERROR_PATTERNS = [
990
+ /ECONNREFUSED|ECONNRESET|ETIMEDOUT|ENOTFOUND|EHOSTUNREACH|EPIPE/i,
991
+ /getaddrinfo|DNS\s+(error|fail)/i,
992
+ /fetch\s+failed/i,
993
+ /network\s+(error|unreachable|down|disconnected)/i,
994
+ /socket\s+(hang|closed|error)/i,
995
+ /连接失败/,
996
+ /网络错误|网络异常|无法连接/
997
+ ];
998
+ function findActiveBreaker(now, table, target) {
999
+ if (!Number.isFinite(now)) return void 0;
1000
+ for (const entry of table) {
1001
+ if (entry.target !== target) continue;
1002
+ if (typeof entry.until === "number" && entry.until > now) return entry;
1003
+ }
1004
+ return void 0;
1005
+ }
1006
+ function isCliProviderQuotaErrorShape(error) {
1007
+ if (!error || typeof error !== "object") return false;
1008
+ const e = error;
1009
+ return e.name === "CliProviderQuotaError" || typeof e.message === "string" && e.message.startsWith("[QUOTA_LIMITED:");
1010
+ }
1011
+ function isQuotaExhaustedError(error) {
1012
+ if (!error) return false;
1013
+ if (isCliProviderQuotaErrorShape(error)) return true;
1014
+ if (error instanceof Error) {
1015
+ return QUOTA_ERROR_PATTERNS.some((pattern) => pattern.test(error.message));
1016
+ }
1017
+ if (typeof error === "string") {
1018
+ return QUOTA_ERROR_PATTERNS.some((pattern) => pattern.test(error));
1019
+ }
1020
+ const maybeStatus = error.status;
1021
+ if (typeof maybeStatus === "number" && maybeStatus === 429) return true;
1022
+ const maybeStatusCode = error.statusCode;
1023
+ if (typeof maybeStatusCode === "number" && maybeStatusCode === 429) return true;
1024
+ return false;
1025
+ }
1026
+ function isAgentNotFoundError(error) {
1027
+ if (!error) return false;
1028
+ const e = error;
1029
+ if (e.code === "AGENT_NOT_FOUND") return true;
1030
+ const message = typeof e.message === "string" ? e.message : typeof error === "string" ? error : "";
1031
+ if (AGENT_NOT_FOUND_PATTERNS.some((pattern) => pattern.test(message))) return true;
1032
+ if ((e.status === 404 || e.statusCode === 404) && /agent|不存在|未找到/i.test(message)) {
1033
+ return true;
1034
+ }
1035
+ return false;
1036
+ }
1037
+ function extractMessage(error) {
1038
+ if (typeof error === "string") return error;
1039
+ if (error instanceof Error) return error.message;
1040
+ if (error && typeof error === "object") {
1041
+ const m = error.message;
1042
+ return typeof m === "string" ? m : "";
1043
+ }
1044
+ return "";
1045
+ }
1046
+ function extractStatus(error) {
1047
+ if (!error || typeof error !== "object") return void 0;
1048
+ const e = error;
1049
+ const s = typeof e.status === "number" ? e.status : void 0;
1050
+ const sc = typeof e.statusCode === "number" ? e.statusCode : void 0;
1051
+ return s ?? sc;
1052
+ }
1053
+ function parseResetsInMs(text) {
1054
+ if (!text) return void 0;
1055
+ const unitMs = (n, unit) => {
1056
+ if (/^d/.test(unit)) return n * 24 * 3600 * 1e3;
1057
+ if (/^h/.test(unit)) return n * 3600 * 1e3;
1058
+ if (/^m/.test(unit)) return n * 60 * 1e3;
1059
+ if (/^s/.test(unit)) return n * 1e3;
1060
+ return NaN;
1061
+ };
1062
+ const re = /(\d+)\s*(d(?:ay|ays)?|h(?:r|rs|our|ours)?|m(?:in|ins|inute|inutes)?|s(?:ec|ecs|econd|econds)?)/gi;
1063
+ let totalMs = 0;
1064
+ let matched = false;
1065
+ let m;
1066
+ while ((m = re.exec(text)) !== null) {
1067
+ const ms = unitMs(Number(m[1]), m[2]);
1068
+ if (!Number.isFinite(ms)) continue;
1069
+ totalMs += ms;
1070
+ matched = true;
1071
+ }
1072
+ return matched ? totalMs : void 0;
1073
+ }
1074
+ function extractProvider(error) {
1075
+ if (!error || typeof error !== "object") return void 0;
1076
+ const p = error.provider;
1077
+ if (typeof p === "string" && p.length > 0) return p;
1078
+ const message = extractMessage(error);
1079
+ const tag = /\[QUOTA_LIMITED:([^\]]+)\]/i.exec(message);
1080
+ if (tag?.[1]) return tag[1];
1081
+ return void 0;
1082
+ }
1083
+ function extractRetryAfterHeader(error) {
1084
+ if (!error || typeof error !== "object") return void 0;
1085
+ const headers = error.headers;
1086
+ if (!headers || typeof headers !== "object") return void 0;
1087
+ const raw = headers["retry-after"];
1088
+ if (typeof raw !== "string" && typeof raw !== "number") return void 0;
1089
+ const secs = Number(raw);
1090
+ return Number.isFinite(secs) && secs > 0 ? secs * 1e3 : void 0;
1091
+ }
1092
+ function classifyRunFailure(error) {
1093
+ const message = extractMessage(error);
1094
+ const status = extractStatus(error);
1095
+ const retryAfterMs = extractRetryAfterHeader(error) ?? parseResetsInMs(message);
1096
+ if (isQuotaExhaustedError(error)) {
1097
+ return {
1098
+ reason: "quota",
1099
+ provider: extractProvider(error),
1100
+ // 纯函数不取时钟:resetsAt 由调用方用 now + retryAfterMs 计算后补齐
1101
+ retryAfterMs,
1102
+ message
1103
+ };
1104
+ }
1105
+ if (isAgentNotFoundError(error)) {
1106
+ return { reason: "agent-not-found", message };
1107
+ }
1108
+ if (isAuthError(error)) {
1109
+ return { reason: "auth", message };
1110
+ }
1111
+ if (isNetworkError(error)) {
1112
+ return { reason: "network", message };
1113
+ }
1114
+ return { reason: "other", message };
1115
+ }
1116
+ function isAuthError(error) {
1117
+ const message = extractMessage(error);
1118
+ const status = extractStatus(error);
1119
+ if (status === 401 || status === 403) return true;
1120
+ return AUTH_ERROR_PATTERNS.some((pattern) => pattern.test(message));
1121
+ }
1122
+ function isNetworkError(error) {
1123
+ const message = extractMessage(error);
1124
+ return NETWORK_ERROR_PATTERNS.some((pattern) => pattern.test(message));
1125
+ }
1126
+ var DEFAULT_QUOTA_BREAKER_MS = 6 * 3600 * 1e3;
1127
+ var DEFAULT_AGENT_NOT_FOUND_BREAKER_MS = 15 * 60 * 1e3;
1128
+ function buildBreakerEntry(now, target, kind, retryAfterMs) {
1129
+ const ttl = kind === "quota" ? typeof retryAfterMs === "number" && retryAfterMs > 0 ? retryAfterMs : DEFAULT_QUOTA_BREAKER_MS : DEFAULT_AGENT_NOT_FOUND_BREAKER_MS;
1130
+ return {
1131
+ target,
1132
+ kind,
1133
+ until: now + ttl,
1134
+ ...kind === "quota" && typeof retryAfterMs === "number" ? { resetsAt: now + retryAfterMs } : {}
1135
+ };
1136
+ }
1137
+
939
1138
  // packages/cli/client/localRuntimeDiagnostics.ts
940
1139
  import { ulid } from "ulid";
941
1140
  var preparedAgentRuntimeCache = /* @__PURE__ */ new Map();
@@ -975,7 +1174,7 @@ function summarizeOpenAiToolNames(tools) {
975
1174
  }
976
1175
 
977
1176
  // packages/cli/client/localRuntimeAdapter.ts
978
- import { dirname, extname, join } from "node:path";
1177
+ import { dirname as dirname2, extname, join as join2 } from "node:path";
979
1178
  import { fileURLToPath } from "node:url";
980
1179
 
981
1180
  // packages/core/summarizeEndpoint.ts
@@ -1126,6 +1325,11 @@ async function fetchWithTransientRetry(fetchImpl, input, init, options = {}) {
1126
1325
  const attemptBudget = coreDraining ? coreDrainingMaxAttempts : maxAttempts;
1127
1326
  if (attempt < attemptBudget) {
1128
1327
  const delayMs = await resolveRetryAfterMs(response, attempt);
1328
+ options.onRetry?.({
1329
+ attempt: attempt + 1,
1330
+ maxAttempts: attemptBudget,
1331
+ delayMs
1332
+ });
1129
1333
  await (options.sleep ?? defaultSleep)(delayMs);
1130
1334
  continue;
1131
1335
  }
@@ -1139,7 +1343,13 @@ async function fetchWithTransientRetry(fetchImpl, input, init, options = {}) {
1139
1343
  if (!isTransientFetchError(error)) throw error;
1140
1344
  lastError = error;
1141
1345
  if (attempt < maxAttempts) {
1142
- await (options.sleep ?? defaultSleep)(transientFetchRetryDelayMs(attempt));
1346
+ const delayMs = transientFetchRetryDelayMs(attempt);
1347
+ options.onRetry?.({
1348
+ attempt: attempt + 1,
1349
+ maxAttempts,
1350
+ delayMs
1351
+ });
1352
+ await (options.sleep ?? defaultSleep)(delayMs);
1143
1353
  }
1144
1354
  }
1145
1355
  }
@@ -1586,23 +1796,6 @@ async function readAgentFromStore(args) {
1586
1796
  if (!record || typeof record !== "object") continue;
1587
1797
  return resolveAgentRuntimeConfigFromRecord(key, record);
1588
1798
  }
1589
- const normalizedRef = normalizeAgentHandle(args.agentRef);
1590
- if (!normalizedRef) {
1591
- return resolveBuiltinPlatformAgentConfig(args.agentRef);
1592
- }
1593
- try {
1594
- const iterator = args.store.iterator({
1595
- gte: "agent-",
1596
- lte: "agent-\uFFFF"
1597
- });
1598
- for await (const [key, record] of iterator) {
1599
- if (!record || typeof record !== "object") continue;
1600
- const handle = normalizeAgentHandle(record.handle);
1601
- if (handle !== normalizedRef) continue;
1602
- return resolveAgentRuntimeConfigFromRecord(key, record);
1603
- }
1604
- } catch {
1605
- }
1606
1799
  return resolveBuiltinPlatformAgentConfig(args.agentRef);
1607
1800
  }
1608
1801
  async function readDialogMessages(args) {
@@ -1761,7 +1954,10 @@ var LOCAL_SERVER_WEB_TOOL_NAMES = ["fetchWebpage", "exa_search"];
1761
1954
  var LOCAL_SERVER_WEB_TOOL_NAME_SET = new Set(
1762
1955
  LOCAL_SERVER_WEB_TOOL_NAMES
1763
1956
  );
1764
- var LOCAL_SERVER_MEMORY_TOOL_NAMES = ["rememberMemory"];
1957
+ var LOCAL_SERVER_MEMORY_TOOL_NAMES = [
1958
+ "queryMemory",
1959
+ "rememberMemory"
1960
+ ];
1765
1961
  var LOCAL_SERVER_MEMORY_TOOL_NAME_SET = new Set(
1766
1962
  LOCAL_SERVER_MEMORY_TOOL_NAMES
1767
1963
  );
@@ -1993,6 +2189,25 @@ function buildServerPlatformToolExecutors(args) {
1993
2189
  }
1994
2190
  ])
1995
2191
  );
2192
+ const queryMemory = async (call) => {
2193
+ const parsed = parseNoloWorkspaceToolArguments(call.arguments);
2194
+ const query = typeof parsed.query === "string" ? parsed.query.trim() : "";
2195
+ if (!query) {
2196
+ return {
2197
+ content: JSON.stringify({ error: "queryMemory \u9700\u8981\u975E\u7A7A query\u3002" }),
2198
+ metadata: { serverPlatformTool: true, memoryRead: false }
2199
+ };
2200
+ }
2201
+ const body = { userInput: query };
2202
+ if (args.agentKey) body.agentKey = args.agentKey;
2203
+ const raw = await postServer("/api/memory/query", body, {
2204
+ retryTransient: true
2205
+ });
2206
+ return {
2207
+ content: raw,
2208
+ metadata: { serverPlatformTool: true, memoryRead: true }
2209
+ };
2210
+ };
1996
2211
  const rememberMemory = async (call) => {
1997
2212
  const parsed = parseNoloWorkspaceToolArguments(call.arguments);
1998
2213
  const content = typeof parsed.content === "string" ? parsed.content.trim() : "";
@@ -2019,11 +2234,368 @@ function buildServerPlatformToolExecutors(args) {
2019
2234
  metadata: { serverPlatformTool: true, memoryWrite: true }
2020
2235
  };
2021
2236
  };
2022
- return { ...tableExecutors, ...webExecutors, rememberMemory };
2237
+ return { ...tableExecutors, ...webExecutors, queryMemory, rememberMemory };
2238
+ }
2239
+
2240
+ // packages/cli/client/cliAgentRunToolExecutors.ts
2241
+ import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
2242
+
2243
+ // packages/cli/client/agentRunSnapshot.ts
2244
+ function readString(value) {
2245
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
2246
+ }
2247
+ function readLogLines(parsed) {
2248
+ if (Array.isArray(parsed.logLines)) return parsed.logLines;
2249
+ const tail = readString(parsed.logTail);
2250
+ return tail ? tail.split("\n") : void 0;
2251
+ }
2252
+ function readTimestamp(value) {
2253
+ if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
2254
+ if (typeof value === "string" && value.trim()) {
2255
+ const parsed = Date.parse(value);
2256
+ if (Number.isFinite(parsed) && parsed > 0) return parsed;
2257
+ }
2258
+ return void 0;
2259
+ }
2260
+ function readToolNames(value) {
2261
+ if (!Array.isArray(value)) return void 0;
2262
+ const names = value.filter((n) => typeof n === "string" && Boolean(n.trim()));
2263
+ return names.length > 0 ? names : void 0;
2264
+ }
2265
+ function buildSnapshot(parsed, event) {
2266
+ const runId = readString(parsed.runId) ?? readString(event.metadata?.runId) ?? "";
2267
+ const label = resolveRunLabel({
2268
+ agentName: parsed.agentName,
2269
+ name: parsed.name,
2270
+ agentKey: parsed.agentKey
2271
+ });
2272
+ const logLines = readLogLines(parsed);
2273
+ const taskPreview = readString(parsed.taskPreview);
2274
+ const lastToolNames = readToolNames(parsed.lastToolNames);
2275
+ const lastAssistantText = readString(parsed.lastAssistantText);
2276
+ const errorMessage = readString(parsed.errorMessage);
2277
+ const startedAt = readTimestamp(parsed.startedAt);
2278
+ const finishedAt = readTimestamp(parsed.finishedAt) ?? readTimestamp(parsed.endedAt);
2279
+ return {
2280
+ runId,
2281
+ status: readString(parsed.status) ?? "running",
2282
+ // The literal `agent` fallback is dropped here rather than at each render
2283
+ // site: an unnamed run should render no name row, not the word "agent".
2284
+ ...isAgentNameFallback(label) ? {} : { agentName: label },
2285
+ ...taskPreview ? { taskPreview } : {},
2286
+ ...typeof parsed.toolCallCount === "number" && Number.isFinite(parsed.toolCallCount) ? { toolCallCount: parsed.toolCallCount } : {},
2287
+ ...lastToolNames ? { lastToolNames } : {},
2288
+ ...lastAssistantText ? { lastAssistantText } : {},
2289
+ ...errorMessage ? { errorMessage } : {},
2290
+ ...startedAt !== void 0 ? { startedAt } : {},
2291
+ ...finishedAt !== void 0 ? { finishedAt } : {},
2292
+ ...logLines ? { logLines } : {},
2293
+ logKey: logLines && logLines.length > 0 ? logLines.join("\n") : ""
2294
+ };
2295
+ }
2296
+ var STOP_STATUSES = /* @__PURE__ */ new Set(["killed", "cancelled", "cancelling"]);
2297
+ function parseAgentRunEvent(event) {
2298
+ if (event.type !== "tool-result") return null;
2299
+ if (event.toolName !== "startAgentRun" && event.toolName !== "controlAgentRun") {
2300
+ return null;
2301
+ }
2302
+ const raw = typeof event.content === "string" ? event.content.trim() : "";
2303
+ if (!raw.startsWith("{")) return null;
2304
+ let parsed;
2305
+ try {
2306
+ parsed = JSON.parse(raw);
2307
+ } catch {
2308
+ return null;
2309
+ }
2310
+ if (Array.isArray(parsed.runs)) return null;
2311
+ const snapshot = buildSnapshot(parsed, event);
2312
+ const status = readString(parsed.status);
2313
+ if (event.toolName === "startAgentRun") {
2314
+ if (!snapshot.runId) return null;
2315
+ return { kind: "start", snapshot };
2316
+ }
2317
+ if (parsed.found === false || status === "not_found") {
2318
+ return { kind: "gone", snapshot: { ...snapshot, status: "not_found" } };
2319
+ }
2320
+ if (status && STOP_STATUSES.has(status)) {
2321
+ return { kind: "stop", snapshot };
2322
+ }
2323
+ if (!status) return null;
2324
+ if (!snapshot.runId) return null;
2325
+ return { kind: "status", snapshot };
2326
+ }
2327
+
2328
+ // packages/ai/tools/agent/batchAggregation.ts
2329
+ var DEFAULT_BATCH_TIMEOUT_MS = 30 * 60 * 1e3;
2330
+ var MAX_ERROR_SUMMARY_CHARS = 120;
2331
+ var MAX_FAILURE_LINES = 10;
2332
+ function isFailureStatus(status) {
2333
+ return isAgentRunTerminalStatus(status) && status !== "done";
2334
+ }
2335
+ function isOrphanedStatus(status) {
2336
+ return status === "orphaned";
2337
+ }
2338
+ function toEpochMs(iso) {
2339
+ if (!iso) return void 0;
2340
+ const ms = Date.parse(iso);
2341
+ return Number.isFinite(ms) ? ms : void 0;
2342
+ }
2343
+ function isOverTimeout(run, nowMs, timeoutMs) {
2344
+ const startedMs = toEpochMs(run.startedAt);
2345
+ if (startedMs === void 0) return false;
2346
+ return nowMs - startedMs >= timeoutMs;
2347
+ }
2348
+ function truncateErrorSummary(text, max = MAX_ERROR_SUMMARY_CHARS) {
2349
+ if (!text) return "";
2350
+ const collapsed = text.replace(/\s+/g, " ").trim();
2351
+ if (collapsed.length <= max) return collapsed;
2352
+ return `${collapsed.slice(0, max - 1)}\u2026`;
2353
+ }
2354
+ function formatFailureLine(run) {
2355
+ const label = shortRunId(run.runId);
2356
+ const agent = run.agentName ? ` (${run.agentName})` : "";
2357
+ const error = truncateErrorSummary(run.errorSummary);
2358
+ return error ? `\u5931\u8D25: ${label}${agent} \u2014 ${error}` : `\u5931\u8D25: ${label}${agent}`;
2359
+ }
2360
+ function formatBatchSummary(batchId, counts, runs, reason) {
2361
+ const failures = runs.filter((r) => isFailureStatus(r.status));
2362
+ const unfinished = runs.filter((r) => !isAgentRunTerminalStatus(r.status));
2363
+ if (reason === "timeout") {
2364
+ const lines2 = [
2365
+ `\u6279\u6B21 ${batchId}: \u8D85\u65F6\u672A\u6536\u655B \u2014 ${counts.running} \u4E2A\u672A\u5B8C\u6210`
2366
+ ];
2367
+ for (const run of unfinished.slice(0, MAX_FAILURE_LINES)) {
2368
+ const agent = run.agentName ? ` (${run.agentName})` : "";
2369
+ lines2.push(`\u672A\u5B8C\u6210: ${shortRunId(run.runId)}${agent}`);
2370
+ }
2371
+ const rest2 = unfinished.length - MAX_FAILURE_LINES;
2372
+ if (rest2 > 0) lines2.push(`\u2026 \u53CA\u53E6\u5916 ${rest2} \u4E2A\u672A\u5B8C\u6210`);
2373
+ return lines2.join("\n");
2374
+ }
2375
+ const tail = counts.running > 0 ? `, ${counts.running} \u4ECD\u5728\u8DD1` : "";
2376
+ const lines = [
2377
+ `\u6279\u6B21 ${batchId}: ${counts.success + counts.failed}/${counts.total} \u5B8C\u6210 \u2014 ${counts.success} \u6210\u529F, ${counts.failed} \u5931\u8D25${tail}`
2378
+ ];
2379
+ for (const run of failures.slice(0, MAX_FAILURE_LINES)) {
2380
+ lines.push(formatFailureLine(run));
2381
+ }
2382
+ const rest = failures.length - MAX_FAILURE_LINES;
2383
+ if (rest > 0) lines.push(`\u2026 \u53CA\u53E6\u5916 ${rest} \u4E2A\u5931\u8D25`);
2384
+ return lines.join("\n");
2385
+ }
2386
+ function aggregateBatch(input) {
2387
+ const { batchId, runs, now } = input;
2388
+ const timeoutMs = input.timeoutMs ?? DEFAULT_BATCH_TIMEOUT_MS;
2389
+ const notified = new Set(input.notifiedReasons ?? []);
2390
+ const nowMs = toEpochMs(now) ?? 0;
2391
+ let success = 0;
2392
+ let failed = 0;
2393
+ let orphaned = 0;
2394
+ let running = 0;
2395
+ const unfinished = [];
2396
+ let timedOut = false;
2397
+ for (const run of runs) {
2398
+ if (isAgentRunTerminalStatus(run.status)) {
2399
+ if (run.status === "done") success += 1;
2400
+ else {
2401
+ failed += 1;
2402
+ if (isOrphanedStatus(run.status)) orphaned += 1;
2403
+ }
2404
+ } else {
2405
+ running += 1;
2406
+ unfinished.push(run.runId);
2407
+ if (isOverTimeout(run, nowMs, timeoutMs)) timedOut = true;
2408
+ }
2409
+ }
2410
+ const converged = running === 0;
2411
+ let newWakeReasons = [];
2412
+ if (failed > 0 && !notified.has("failure")) {
2413
+ newWakeReasons = ["failure"];
2414
+ } else if (converged && !notified.has("converged")) {
2415
+ newWakeReasons = ["converged"];
2416
+ } else if (timedOut && !notified.has("timeout")) {
2417
+ newWakeReasons = ["timeout"];
2418
+ }
2419
+ const counts = {
2420
+ total: runs.length,
2421
+ success,
2422
+ failed,
2423
+ orphaned,
2424
+ running
2425
+ };
2426
+ const summary = newWakeReasons.length > 0 ? formatBatchSummary(batchId, counts, runs, newWakeReasons[0]) : "";
2427
+ return {
2428
+ batchId,
2429
+ converged,
2430
+ timedOut,
2431
+ counts,
2432
+ newWakeReasons,
2433
+ unfinished,
2434
+ summary
2435
+ };
2436
+ }
2437
+
2438
+ // packages/ai/tools/agent/runtimeTodo.ts
2439
+ var TODO_REVIEW_BLOCK = "BLOCK";
2440
+ function deriveTodoStatus(input) {
2441
+ const { todo, runs } = input;
2442
+ if (todo.status === "abandoned") {
2443
+ return { status: "abandoned" };
2444
+ }
2445
+ if (runs.length === 0) {
2446
+ return { status: todo.status };
2447
+ }
2448
+ if (runs.some((r) => !isAgentRunTerminalStatus(r.status))) {
2449
+ return { status: "running", latestRun: latestRun(runs) };
2450
+ }
2451
+ const latest = latestRun(runs);
2452
+ if (latest?.reviewVerdict === TODO_REVIEW_BLOCK) {
2453
+ return {
2454
+ status: "blocked",
2455
+ latestRun: latest,
2456
+ blockedReason: clipSummary(latest.reviewReason, MAX_ERROR_SUMMARY_CHARS)
2457
+ };
2458
+ }
2459
+ if (latest?.status === "done") {
2460
+ return { status: "done", latestRun: latest };
2461
+ }
2462
+ return { status: "pending", latestRun: latest };
2463
+ }
2464
+ function toEpochMs2(iso) {
2465
+ if (!iso) return void 0;
2466
+ const ms = Date.parse(iso);
2467
+ return Number.isFinite(ms) ? ms : void 0;
2468
+ }
2469
+ function latestRun(runs) {
2470
+ let latest;
2471
+ let latestScore = -1;
2472
+ for (const run of runs) {
2473
+ const score = toEpochMs2(run.finishedAt) ?? toEpochMs2(run.startedAt) ?? -1;
2474
+ if (latest === void 0 || score >= latestScore) {
2475
+ latest = run;
2476
+ latestScore = score;
2477
+ }
2478
+ }
2479
+ return latest;
2480
+ }
2481
+ function clipSummary(text, max) {
2482
+ if (!text) return void 0;
2483
+ const folded = text.replace(/\s+/g, " ").trim();
2484
+ if (folded.length === 0) return void 0;
2485
+ return folded.length > max ? `${folded.slice(0, max - 1)}\u2026` : folded;
2486
+ }
2487
+
2488
+ // packages/cli/client/fileSystemStores.ts
2489
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2490
+ import { homedir as nodeHomedir } from "node:os";
2491
+ import { dirname, join } from "node:path";
2492
+ var nodeFs = {
2493
+ mkdirSync,
2494
+ writeFileSync,
2495
+ readFileSync,
2496
+ existsSync
2497
+ };
2498
+ function resolveNoloHome(env, homedir) {
2499
+ const custom = env?.NOLO_HOME;
2500
+ if (custom && custom.trim()) return custom.trim();
2501
+ return join(homedir(), ".nolo");
2502
+ }
2503
+ function ensureDir(dir, fs) {
2504
+ fs.mkdirSync(dir, { recursive: true });
2505
+ }
2506
+ function readJson(path, fs) {
2507
+ if (!fs.existsSync(path)) return void 0;
2508
+ try {
2509
+ const raw = fs.readFileSync(path, "utf8");
2510
+ return JSON.parse(String(raw));
2511
+ } catch {
2512
+ return void 0;
2513
+ }
2514
+ }
2515
+ function writeJson(path, data, fs) {
2516
+ fs.writeFileSync(path, JSON.stringify(data, null, 2));
2517
+ }
2518
+ function createFileSystemCircuitBreakerStore(opts = {}) {
2519
+ const env = opts.env ?? process.env;
2520
+ const homedir = opts.homedir ?? nodeHomedir;
2521
+ const fs = opts.fs ?? nodeFs;
2522
+ const filePath = opts.filePath ?? join(resolveNoloHome(env, homedir), "breakers.json");
2523
+ const loadMap = () => {
2524
+ const data = readJson(filePath, fs);
2525
+ const map = /* @__PURE__ */ new Map();
2526
+ if (data?.entries) {
2527
+ for (const entry of data.entries) {
2528
+ if (entry && typeof entry.target === "string") map.set(entry.target, entry);
2529
+ }
2530
+ }
2531
+ return map;
2532
+ };
2533
+ const persist = (map) => {
2534
+ ensureDir(dirname(filePath), fs);
2535
+ writeJson(filePath, { entries: [...map.values()] }, fs);
2536
+ };
2537
+ return {
2538
+ get(target) {
2539
+ return loadMap().get(target);
2540
+ },
2541
+ set(entry) {
2542
+ const map = loadMap();
2543
+ map.set(entry.target, entry);
2544
+ persist(map);
2545
+ },
2546
+ clear(target) {
2547
+ const map = loadMap();
2548
+ map.delete(target);
2549
+ persist(map);
2550
+ },
2551
+ clearAll() {
2552
+ persist(/* @__PURE__ */ new Map());
2553
+ }
2554
+ };
2555
+ }
2556
+ function createFileSystemTodoStore(opts = {}) {
2557
+ const env = opts.env ?? process.env;
2558
+ const homedir = opts.homedir ?? nodeHomedir;
2559
+ const fs = opts.fs ?? nodeFs;
2560
+ const filePath = opts.filePath ?? join(resolveNoloHome(env, homedir), "todos.json");
2561
+ const loadMap = () => {
2562
+ const data = readJson(filePath, fs);
2563
+ const map = /* @__PURE__ */ new Map();
2564
+ if (data?.todos) {
2565
+ for (const todo of data.todos) {
2566
+ if (todo && typeof todo.id === "string") map.set(todo.id, todo);
2567
+ }
2568
+ }
2569
+ return map;
2570
+ };
2571
+ const persist = (map) => {
2572
+ ensureDir(dirname(filePath), fs);
2573
+ writeJson(filePath, { todos: [...map.values()] }, fs);
2574
+ };
2575
+ return {
2576
+ async getTodo(id) {
2577
+ return loadMap().get(id);
2578
+ },
2579
+ async listTodos(filter) {
2580
+ const all = [...loadMap().values()];
2581
+ if (!filter?.statuses || filter.statuses.length === 0) return all;
2582
+ const wanted = new Set(filter.statuses);
2583
+ return all.filter((t2) => wanted.has(t2.status));
2584
+ },
2585
+ async putTodo(todo) {
2586
+ const map = loadMap();
2587
+ map.set(todo.id, todo);
2588
+ persist(map);
2589
+ },
2590
+ async deleteTodo(id) {
2591
+ const map = loadMap();
2592
+ map.delete(id);
2593
+ persist(map);
2594
+ }
2595
+ };
2023
2596
  }
2024
2597
 
2025
2598
  // packages/cli/client/cliAgentRunToolExecutors.ts
2026
- import { existsSync, readFileSync } from "node:fs";
2027
2599
  var noopOutput = { write: () => {
2028
2600
  } };
2029
2601
  var parseCallArgs = (call) => {
@@ -2033,7 +2605,7 @@ var parseCallArgs = (call) => {
2033
2605
  return {};
2034
2606
  }
2035
2607
  };
2036
- var resolveFs = (deps) => deps.fs ?? { existsSync, readFileSync };
2608
+ var resolveFs = (deps) => deps.fs ?? { existsSync: existsSync2, readFileSync: readFileSync2 };
2037
2609
  var tailFile = (logPath, tailLines, fs) => {
2038
2610
  if (!fs.existsSync(logPath)) return void 0;
2039
2611
  try {
@@ -2045,6 +2617,10 @@ var tailFile = (logPath, tailLines, fs) => {
2045
2617
  return void 0;
2046
2618
  }
2047
2619
  };
2620
+ var resolveBreakerStore = (deps) => deps.breakerStore ?? createFileSystemCircuitBreakerStore({ env: deps.env, homedir: deps.homedir, fs: deps.fs });
2621
+ var resolveTodoStore = (deps) => deps.todoStore ?? createFileSystemTodoStore({ env: deps.env, homedir: deps.homedir, fs: deps.fs });
2622
+ var resolveNowMs = (deps) => typeof deps.nowMs === "function" ? deps.nowMs() : Date.now();
2623
+ var resolveTarget = (deps, agentKey) => typeof deps.resolveProviderTarget === "function" ? deps.resolveProviderTarget(agentKey) : agentKey;
2048
2624
  function createCliStartAgentRunExecutor(deps = {}) {
2049
2625
  return async (call) => {
2050
2626
  const args = parseCallArgs(call);
@@ -2052,19 +2628,54 @@ function createCliStartAgentRunExecutor(deps = {}) {
2052
2628
  const task = typeof args.task === "string" ? args.task.trim() : "";
2053
2629
  if (!agentKey) throw new Error("startAgentRun: \u7F3A\u5C11 agentKey \u53C2\u6570\u3002");
2054
2630
  if (!task) throw new Error("startAgentRun: \u7F3A\u5C11\u6709\u6548\u7684 task \u6587\u672C\u63CF\u8FF0\u3002");
2631
+ const breakerStore = resolveBreakerStore(deps);
2632
+ const target = resolveTarget(deps, agentKey);
2633
+ const nowMs = resolveNowMs(deps);
2634
+ const activeBreaker = findActiveBreaker(
2635
+ nowMs,
2636
+ [breakerStore.get(target)].filter(Boolean),
2637
+ target
2638
+ );
2639
+ if (activeBreaker) {
2640
+ const resetsAt = activeBreaker.resetsAt;
2641
+ return {
2642
+ content: JSON.stringify({
2643
+ rejected: true,
2644
+ reason: "quota",
2645
+ provider: target,
2646
+ ...resetsAt !== void 0 ? { resetsAt } : {},
2647
+ message: `provider ${target} \u5904\u4E8E\u7194\u65AD\u671F\uFF08\u914D\u989D\u8017\u5C3D\uFF09\uFF0C\u5EFA\u8BAE\u6539\u6D3E\u5176\u5B83 provider\u3002`
2648
+ }),
2649
+ metadata: {
2650
+ displayData: `Run rejected \xB7 quota breaker active on ${target}`
2651
+ }
2652
+ };
2653
+ }
2055
2654
  const message = typeof args.input === "undefined" ? task : `${task}
2056
2655
 
2057
2656
  --- \u9644\u52A0\u8F93\u5165 ---
2058
2657
  ${JSON.stringify(args.input)}`;
2059
- const rawArgs = ["--agent", agentKey, "--msg-file", "PLACEHOLDER", "--bg"];
2658
+ const rawArgs = [
2659
+ "--agent",
2660
+ agentKey,
2661
+ "--msg-file",
2662
+ "PLACEHOLDER",
2663
+ "--bg",
2664
+ // 非持久化派发(review 等一次性任务):透传 --ephemeral,run 完成后不留
2665
+ // dialog 记录。与 web 端 runAgentBackground 的 ephemeral: true 对齐。
2666
+ ...args.ephemeral === true ? ["--ephemeral"] : []
2667
+ ];
2060
2668
  const agentName = typeof args.agentName === "string" && args.agentName.trim() ? args.agentName.trim() : typeof args.name === "string" && args.name.trim() ? args.name.trim() : void 0;
2061
- const { runId } = await spawnLocalBackgroundRun(
2669
+ const batchId = typeof args.batchId === "string" && args.batchId.trim() ? args.batchId.trim() : void 0;
2670
+ const { runId, batchId: resolvedBatchId } = await spawnLocalBackgroundRun(
2062
2671
  {
2063
2672
  rawArgs,
2064
2673
  commandPath: ["agent", "run"],
2065
2674
  cliEntrypointPath: deps.cliEntrypoint,
2066
2675
  agentKey,
2067
2676
  ...agentName ? { agentName } : {},
2677
+ ...batchId ? { batchId } : {},
2678
+ ...typeof args.parentDialogId === "string" && args.parentDialogId.trim() ? { parentDialogId: args.parentDialogId.trim() } : {},
2068
2679
  cwd: deps.cwd ?? process.cwd(),
2069
2680
  message,
2070
2681
  output: noopOutput
@@ -2073,14 +2684,49 @@ ${JSON.stringify(args.input)}`;
2073
2684
  );
2074
2685
  const displayName = resolveRunLabel({ agentName, agentKey, runId });
2075
2686
  const labels = agentRunCardLabels();
2687
+ const taskPreview = typeof args.task === "string" ? args.task.replace(/\s+/g, " ").trim().slice(0, TASK_PREVIEW_MAX) : "";
2688
+ const trackTodo = typeof args.trackTodo === "boolean" ? args.trackTodo : Boolean(resolvedBatchId);
2689
+ if (trackTodo) {
2690
+ try {
2691
+ const todoStore = resolveTodoStore(deps);
2692
+ const todoId = `todo-${resolvedBatchId}`;
2693
+ const existing = await todoStore.getTodo(todoId);
2694
+ const nowIso = new Date(nowMs).toISOString();
2695
+ const runIds = existing?.runIds ?? [];
2696
+ if (!runIds.includes(runId)) runIds.push(runId);
2697
+ const todo = {
2698
+ id: todoId,
2699
+ title: taskPreview || task.slice(0, 100),
2700
+ status: existing?.status ?? "pending",
2701
+ ...existing?.specPath ? { specPath: existing.specPath } : {},
2702
+ ...existing?.worktree ? { worktree: existing.worktree } : {},
2703
+ ...existing?.branch ? { branch: existing.branch } : {},
2704
+ ...deps.cwd ? { worktree: deps.cwd } : {},
2705
+ runIds,
2706
+ deps: existing?.deps ?? [],
2707
+ createdAt: existing?.createdAt ?? nowIso,
2708
+ updatedAt: nowIso
2709
+ };
2710
+ await todoStore.putTodo(todo);
2711
+ } catch {
2712
+ }
2713
+ }
2076
2714
  return {
2077
2715
  content: JSON.stringify({
2078
2716
  runId,
2079
2717
  status: "running",
2080
- ...agentName ? { agentName } : {}
2718
+ // batchId is always returned so the caller can later filter by it —
2719
+ // even when the caller didn't supply one, a fresh id was generated.
2720
+ batchId: resolvedBatchId,
2721
+ ...agentName ? { agentName } : {},
2722
+ ...taskPreview ? { taskPreview } : {}
2081
2723
  }),
2082
2724
  metadata: {
2083
- displayData: formatStartRunCard(displayName, "running", labels)
2725
+ displayData: formatStartRunCard(displayName, "running", {
2726
+ task: taskPreview,
2727
+ runId,
2728
+ labels
2729
+ })
2084
2730
  }
2085
2731
  };
2086
2732
  };
@@ -2091,26 +2737,103 @@ function createCliControlAgentRunExecutor(deps = {}) {
2091
2737
  const action = typeof args.action === "string" ? args.action : "";
2092
2738
  const tailLines = typeof args.tailLines === "number" ? args.tailLines : 0;
2093
2739
  if (action === "list") {
2094
- const records = listRunRecords(deps);
2740
+ gcRunRecords(deps);
2741
+ const { runs: records, total, hasMore } = queryRunRecords(
2742
+ {
2743
+ ...typeof args.batchId === "string" && args.batchId.trim() ? { batchId: args.batchId.trim() } : {},
2744
+ ...typeof args.status === "string" && args.status.trim() ? { status: args.status.trim() } : typeof args.statusFilter === "string" && args.statusFilter.trim() ? { status: args.statusFilter.trim() } : {},
2745
+ ...typeof args.limit === "number" ? { limit: args.limit } : {},
2746
+ ...typeof args.offset === "number" ? { offset: args.offset } : {}
2747
+ },
2748
+ deps
2749
+ );
2095
2750
  const runs = records.map((record2) => {
2096
- const reconciled = checkStaleRun(record2.runId, deps) ?? record2;
2097
2751
  return {
2098
- runId: reconciled.runId,
2099
- status: reconciled.status,
2100
- agentKey: reconciled.agentKey,
2101
- ...reconciled.agentName ? { agentName: reconciled.agentName } : {},
2102
- pid: reconciled.pid ?? null,
2103
- startedAt: reconciled.startedAt
2752
+ runId: record2.runId,
2753
+ status: record2.status,
2754
+ agentKey: record2.agentKey,
2755
+ ...record2.agentName ? { agentName: record2.agentName } : {},
2756
+ ...record2.batchId ? { batchId: record2.batchId } : {},
2757
+ pid: record2.pid ?? null,
2758
+ startedAt: record2.startedAt
2104
2759
  };
2105
2760
  });
2106
2761
  const labels2 = agentRunCardLabels();
2762
+ const batchIdArg = typeof args.batchId === "string" && args.batchId.trim() ? args.batchId.trim() : void 0;
2763
+ let batchSummary;
2764
+ if (batchIdArg && records.length > 0) {
2765
+ const batchRuns = records.map((r) => ({
2766
+ runId: r.runId,
2767
+ status: r.status,
2768
+ startedAt: r.startedAt,
2769
+ ...r.agentName ? { agentName: r.agentName } : {}
2770
+ }));
2771
+ batchSummary = aggregateBatch({
2772
+ batchId: batchIdArg,
2773
+ runs: batchRuns,
2774
+ now: new Date(resolveNowMs(deps)).toISOString()
2775
+ });
2776
+ }
2107
2777
  return {
2108
- content: JSON.stringify({ runs, count: runs.length }),
2778
+ content: JSON.stringify({
2779
+ runs,
2780
+ count: runs.length,
2781
+ total,
2782
+ hasMore,
2783
+ ...batchSummary?.summary ? { batchSummary: batchSummary.summary } : {}
2784
+ }),
2109
2785
  metadata: {
2110
2786
  displayData: formatListRunsCard(runs, labels2)
2111
2787
  }
2112
2788
  };
2113
2789
  }
2790
+ if (action === "todo") {
2791
+ const todoStore = resolveTodoStore(deps);
2792
+ const statusesRaw = typeof args.status === "string" ? args.status.trim() : void 0;
2793
+ const filter = statusesRaw && statusesRaw !== "all" ? { statuses: statusesRaw.split(",").map((s) => s.trim()).filter(Boolean) } : void 0;
2794
+ const todos = await todoStore.listTodos(filter);
2795
+ const enriched = await Promise.all(
2796
+ todos.map(async (todo) => {
2797
+ const runSummaries = [];
2798
+ for (const rid of todo.runIds) {
2799
+ const rec = findRunRecord(rid, deps);
2800
+ if (!rec) continue;
2801
+ runSummaries.push({
2802
+ runId: rec.runId,
2803
+ status: rec.status,
2804
+ startedAt: rec.startedAt,
2805
+ ...rec.agentName ? { agentName: rec.agentName } : {}
2806
+ });
2807
+ }
2808
+ const derived = deriveTodoStatus({
2809
+ todo: { id: todo.id, status: todo.status },
2810
+ runs: runSummaries,
2811
+ now: new Date(resolveNowMs(deps)).toISOString()
2812
+ });
2813
+ return {
2814
+ id: todo.id,
2815
+ title: todo.title,
2816
+ status: derived.status,
2817
+ runIds: todo.runIds,
2818
+ ...derived.blockedReason ? { blockedReason: derived.blockedReason } : {},
2819
+ ...derived.latestRun ? { latestRunId: derived.latestRun.runId, latestRunStatus: derived.latestRun.status } : {},
2820
+ updatedAt: todo.updatedAt
2821
+ };
2822
+ })
2823
+ );
2824
+ return {
2825
+ content: JSON.stringify({ todos: enriched, count: enriched.length }),
2826
+ metadata: {
2827
+ displayData: formatListRunsCard(
2828
+ enriched.map((t2) => ({
2829
+ agentName: t2.title,
2830
+ status: t2.status
2831
+ })),
2832
+ agentRunCardLabels()
2833
+ )
2834
+ }
2835
+ };
2836
+ }
2114
2837
  if (action !== "status" && action !== "stop") {
2115
2838
  throw new Error(`controlAgentRun: \u672A\u77E5 action "${action}"\u3002`);
2116
2839
  }
@@ -2129,6 +2852,25 @@ function createCliControlAgentRunExecutor(deps = {}) {
2129
2852
  const name = resolveRunLabel(reconciled);
2130
2853
  const logLines = logTail ? logTail.split("\n") : void 0;
2131
2854
  const labels2 = agentRunCardLabels();
2855
+ if (reconciled.status === "failed" || reconciled.status === "orphaned") {
2856
+ try {
2857
+ const failureSource = logTail ?? reconciled.note ?? "";
2858
+ const failureInfo = classifyRunFailure(
2859
+ failureSource || reconciled.status
2860
+ );
2861
+ if (failureInfo.reason === "quota") {
2862
+ const t2 = resolveTarget(deps, reconciled.agentKey);
2863
+ const entry = buildBreakerEntry(
2864
+ resolveNowMs(deps),
2865
+ t2,
2866
+ "quota",
2867
+ failureInfo.retryAfterMs
2868
+ );
2869
+ resolveBreakerStore(deps).set(entry);
2870
+ }
2871
+ } catch {
2872
+ }
2873
+ }
2132
2874
  return {
2133
2875
  content: JSON.stringify({
2134
2876
  runId: reconciled.runId,
@@ -2153,7 +2895,15 @@ function createCliControlAgentRunExecutor(deps = {}) {
2153
2895
  ...logLines ? { logLines } : {}
2154
2896
  }),
2155
2897
  metadata: {
2156
- displayData: formatStatusRunCard(name, reconciled.status, { logLines, labels: labels2 })
2898
+ displayData: formatStatusRunCard(name, reconciled.status, {
2899
+ runId: reconciled.runId,
2900
+ timing: {
2901
+ startedAt: readTimestamp(reconciled.startedAt),
2902
+ finishedAt: readTimestamp(reconciled.endedAt)
2903
+ },
2904
+ logLines,
2905
+ labels: labels2
2906
+ })
2157
2907
  }
2158
2908
  };
2159
2909
  }
@@ -2291,7 +3041,7 @@ function buildLocalToolExecutors(args) {
2291
3041
  }
2292
3042
  };
2293
3043
  },
2294
- ui_ask_choice: async (call) => {
3044
+ ask_user: async (call) => {
2295
3045
  const parsedArgs = (() => {
2296
3046
  try {
2297
3047
  return JSON.parse(call.arguments || "{}");
@@ -2307,8 +3057,8 @@ function buildLocalToolExecutors(args) {
2307
3057
  if (!hasQuestions && (!question || choices.length === 0)) {
2308
3058
  return {
2309
3059
  content: JSON.stringify({
2310
- error: "ui_ask_choice",
2311
- detail: "ui_ask_choice \u9700\u8981 question+choices \u6216 questions\u3002"
3060
+ error: "ask_user",
3061
+ detail: "ask_user \u9700\u8981 question+choices \u6216 questions\u3002"
2312
3062
  }),
2313
3063
  metadata: { uiAskChoice: true, error: true }
2314
3064
  };
@@ -2324,7 +3074,7 @@ function buildLocalToolExecutors(args) {
2324
3074
  if (result.kind === "multi-submitted") {
2325
3075
  return {
2326
3076
  content: JSON.stringify({
2327
- type: "ui_ask_choice",
3077
+ type: "ask_user",
2328
3078
  question,
2329
3079
  choices,
2330
3080
  blocking,
@@ -2341,7 +3091,7 @@ function buildLocalToolExecutors(args) {
2341
3091
  if (result.kind === "selected") {
2342
3092
  return {
2343
3093
  content: JSON.stringify({
2344
- type: "ui_ask_choice",
3094
+ type: "ask_user",
2345
3095
  question,
2346
3096
  choices,
2347
3097
  blocking,
@@ -2356,7 +3106,7 @@ function buildLocalToolExecutors(args) {
2356
3106
  }
2357
3107
  return {
2358
3108
  content: JSON.stringify({
2359
- type: "ui_ask_choice",
3109
+ type: "ask_user",
2360
3110
  question,
2361
3111
  choices,
2362
3112
  blocking,
@@ -2371,7 +3121,7 @@ function buildLocalToolExecutors(args) {
2371
3121
  }
2372
3122
  return {
2373
3123
  content: JSON.stringify({
2374
- type: "ui_ask_choice",
3124
+ type: "ask_user",
2375
3125
  question,
2376
3126
  choices,
2377
3127
  blocking,
@@ -2835,6 +3585,59 @@ var CLAUDE_CODE_IDENTITY_PATTERNS = [
2835
3585
  CLAUDE_CODE_SYSTEM_INSTRUCTION,
2836
3586
  "You are Claude Code"
2837
3587
  ];
3588
+ var REASONING_EFFORT_TO_BUDGET = {
3589
+ minimal: 2048,
3590
+ low: 4096,
3591
+ medium: 8192,
3592
+ high: 16384,
3593
+ xhigh: 32e3,
3594
+ max: 32e3
3595
+ };
3596
+ function resolveThinkingBudget(effort) {
3597
+ if (!effort) return void 0;
3598
+ const normalized = effort.toLowerCase();
3599
+ if (normalized === "none" || normalized === "off") return void 0;
3600
+ return REASONING_EFFORT_TO_BUDGET[normalized];
3601
+ }
3602
+ var DEFAULT_THINKING_EFFORT = "medium";
3603
+ var DEFAULT_ENABLED_BUDGET = 8192;
3604
+ var DEFAULT_ENABLE_THINKING_BUDGET = 8e3;
3605
+ var ANTHROPIC_EFFORT_ALIASES = { minimal: "low" };
3606
+ function resolveThinkingSpec(input) {
3607
+ const { model, maxTokens } = input;
3608
+ const normalizedEffort = input.reasoningEffort?.toLowerCase();
3609
+ const effortDisabled = normalizedEffort === "none" || normalizedEffort === "off";
3610
+ const effectiveEffort = normalizedEffort !== void 0 && !effortDisabled ? ANTHROPIC_EFFORT_ALIASES[normalizedEffort] ?? normalizedEffort : DEFAULT_THINKING_EFFORT;
3611
+ let thinkingBlock;
3612
+ let outputConfig;
3613
+ let finalMaxTokens = maxTokens;
3614
+ let finalTemperature = input.temperature;
3615
+ if (isAdaptiveThinkingModelId(model)) {
3616
+ if (effortDisabled) {
3617
+ thinkingBlock = { type: "disabled" };
3618
+ } else {
3619
+ thinkingBlock = { type: "adaptive", display: "summarized" };
3620
+ outputConfig = { effort: effectiveEffort };
3621
+ }
3622
+ } else {
3623
+ const injected = input.injectedThinking;
3624
+ const injectedBudget = injected?.type === "enabled" && typeof injected.budget_tokens === "number" ? injected.budget_tokens : void 0;
3625
+ const effortBudget = resolveThinkingBudget(input.reasoningEffort);
3626
+ const fallbackBudget = input.reasoningEffort === void 0 ? injectedBudget ?? (input.enableThinking === true ? typeof input.thinkingBudget === "number" ? input.thinkingBudget : DEFAULT_ENABLE_THINKING_BUDGET : DEFAULT_ENABLED_BUDGET) : void 0;
3627
+ const thinkingBudget = effortBudget ?? fallbackBudget;
3628
+ if (thinkingBudget !== void 0) {
3629
+ thinkingBlock = { type: "enabled", budget_tokens: thinkingBudget };
3630
+ finalMaxTokens = Math.max(maxTokens, thinkingBudget + 1);
3631
+ finalTemperature = 1;
3632
+ }
3633
+ }
3634
+ return {
3635
+ thinkingBlock,
3636
+ outputConfig,
3637
+ maxTokens: finalMaxTokens,
3638
+ temperature: finalTemperature
3639
+ };
3640
+ }
2838
3641
  function stringValue(value) {
2839
3642
  return typeof value === "string" && value.length > 0 ? value : void 0;
2840
3643
  }
@@ -2970,6 +3773,19 @@ function buildAnthropicMessagesBody(args) {
2970
3773
  const model = stringValue(args.openAiBody.model) ?? args.agentConfig.model ?? "claude-sonnet-5";
2971
3774
  const maxTokensRaw = args.openAiBody.max_completion_tokens ?? args.openAiBody.max_tokens ?? args.agentConfig.max_tokens;
2972
3775
  const maxTokens = typeof maxTokensRaw === "number" && Number.isFinite(maxTokensRaw) ? Math.max(1, Math.floor(maxTokensRaw)) : 8192;
3776
+ const reasoningEffort = stringValue(args.openAiBody.reasoning_effort) ?? stringValue(args.agentConfig.reasoning_effort);
3777
+ const spec = resolveThinkingSpec({
3778
+ model,
3779
+ reasoningEffort,
3780
+ maxTokens,
3781
+ temperature: typeof args.openAiBody.temperature === "number" ? args.openAiBody.temperature : args.agentConfig.temperature,
3782
+ injectedThinking: args.openAiBody.thinking,
3783
+ enableThinking: args.agentConfig.enableThinking,
3784
+ thinkingBudget: args.agentConfig.thinkingBudget
3785
+ });
3786
+ const { thinkingBlock, outputConfig } = spec;
3787
+ const finalMaxTokens = spec.maxTokens;
3788
+ const finalTemperature = spec.temperature;
2973
3789
  if (messages.length > 0) {
2974
3790
  const lastMessage = messages[messages.length - 1];
2975
3791
  const content = Array.isArray(lastMessage.content) ? lastMessage.content : [];
@@ -2983,11 +3799,13 @@ function buildAnthropicMessagesBody(args) {
2983
3799
  return {
2984
3800
  model,
2985
3801
  messages,
2986
- max_tokens: maxTokens,
3802
+ max_tokens: finalMaxTokens,
2987
3803
  stream: false,
3804
+ ...thinkingBlock ? { thinking: thinkingBlock } : {},
3805
+ ...outputConfig ? { output_config: outputConfig } : {},
2988
3806
  ...system.length > 0 ? { system } : {},
2989
3807
  ...tools.length > 0 ? { tools } : {},
2990
- ...typeof args.openAiBody.temperature === "number" ? { temperature: args.openAiBody.temperature } : typeof args.agentConfig.temperature === "number" ? { temperature: args.agentConfig.temperature } : {},
3808
+ ...typeof finalTemperature === "number" ? { temperature: finalTemperature } : {},
2991
3809
  ...typeof args.openAiBody.top_p === "number" ? { top_p: args.openAiBody.top_p } : {}
2992
3810
  };
2993
3811
  }
@@ -9861,7 +10679,7 @@ function buildOpenAiTools(args) {
9861
10679
  const toolset = buildLocalWorkspaceToolsetForEnv(args);
9862
10680
  const toolNameSet = new Set(args.toolNames ?? []);
9863
10681
  const callAgentTools = toolNameSet.has("callAgent") ? prepareTools(["callAgent"]) : [];
9864
- const uiAskChoiceTools = toolNameSet.has("ui_ask_choice") ? prepareTools(["ui_ask_choice"]) : [];
10682
+ const uiAskChoiceTools = toolNameSet.has("ask_user") ? prepareTools(["ask_user"]) : [];
9865
10683
  const readPastedTextTools = toolNameSet.has("readPastedText") ? [
9866
10684
  {
9867
10685
  type: "function",
@@ -9921,10 +10739,10 @@ function buildOpenAiTools(args) {
9921
10739
  var CLI_DEFAULT_TOOLS = ["exa_search", "fetchWebpage"];
9922
10740
  function addDefaultCliCoreTools(toolNames, env, options) {
9923
10741
  const declaredOnly = env && shouldUseDeclaredOnlyLocalWorkspaceTools(env);
9924
- const forcedTools = options?.hasUserChoice === true ? FORCED_TOOLS : FORCED_TOOLS.filter((name) => name !== "ui_ask_choice");
10742
+ const forcedTools = options?.hasUserChoice === true ? FORCED_TOOLS : FORCED_TOOLS.filter((name) => name !== "ask_user");
9925
10743
  const injected = declaredOnly ? [...forcedTools] : [...forcedTools, ...CLI_DEFAULT_TOOLS];
9926
10744
  const combined = [...toolNames, ...injected];
9927
- const filtered = options?.hasUserChoice === true ? combined : combined.filter((name) => name !== "ui_ask_choice");
10745
+ const filtered = options?.hasUserChoice === true ? combined : combined.filter((name) => name !== "ask_user");
9928
10746
  return [...new Set(filtered)];
9929
10747
  }
9930
10748
  function resolveCliEffectiveEnabledPacks(args) {
@@ -10217,9 +11035,9 @@ function createCliCallAgentToolExecutor(deps, ctx) {
10217
11035
  // packages/cli/client/localRuntimeAdapter.ts
10218
11036
  var currentMetaFile = fileURLToPath(import.meta.url);
10219
11037
  var isJsBundle = extname(currentMetaFile) === ".js";
10220
- var SOURCE_CLI_DIR = isJsBundle ? dirname(currentMetaFile) : dirname(dirname(currentMetaFile));
10221
- var CLI_DIR = isCompiledBinary() ? dirname(process.execPath) : SOURCE_CLI_DIR;
10222
- var CLI_ENTRYPOINT = isCompiledBinary() ? process.execPath : isJsBundle ? currentMetaFile : join(SOURCE_CLI_DIR, "index.ts");
11038
+ var SOURCE_CLI_DIR = isJsBundle ? dirname2(currentMetaFile) : dirname2(dirname2(currentMetaFile));
11039
+ var CLI_DIR = isCompiledBinary() ? dirname2(process.execPath) : SOURCE_CLI_DIR;
11040
+ var CLI_ENTRYPOINT = isCompiledBinary() ? process.execPath : isJsBundle ? currentMetaFile : join2(SOURCE_CLI_DIR, "index.ts");
10223
11041
  function createCliLocalRuntimeAdapter(deps) {
10224
11042
  const now = deps.now ?? Date.now;
10225
11043
  const createId = deps.createId ?? createFallbackId;
@@ -10857,7 +11675,16 @@ function createCliLocalRuntimeAdapter(deps) {
10857
11675
  },
10858
11676
  {
10859
11677
  sleep: deps.sleep,
10860
- loopbackRequest
11678
+ loopbackRequest,
11679
+ // auto 档位转发 nolo.chat 时,网关层 502(server: Caddy、空 body)
11680
+ // 意味着请求根本没到 Bun 上游,provider 未受理,重试安全。
11681
+ // 与 429/503 同口径:不会重复计费/重复生成。
11682
+ retryableStatuses: /* @__PURE__ */ new Set([429, 502, 503]),
11683
+ onRetry: deps.activityReporter ? ({ attempt, maxAttempts, delayMs }) => {
11684
+ deps.activityReporter(
11685
+ `\u81EA\u52A8\u91CD\u8BD5 ${attempt}/${maxAttempts} \xB7 ${Math.ceil(delayMs / 1e3)}s`
11686
+ );
11687
+ } : void 0
10861
11688
  }
10862
11689
  );
10863
11690
  if (!res.ok) {
@@ -11013,6 +11840,23 @@ function createCliLocalRuntimeAdapter(deps) {
11013
11840
  };
11014
11841
  },
11015
11842
  executeTool: async (call, opts) => {
11843
+ const contextualCall = opts?.runtimeContext ? { ...call, runtimeContext: opts.runtimeContext } : call;
11844
+ let injectedCall = contextualCall;
11845
+ if (contextualCall.name === "startAgentRun" && deps.parentDialogId && typeof contextualCall.arguments === "string") {
11846
+ try {
11847
+ const args = JSON.parse(contextualCall.arguments);
11848
+ if (!args.parentDialogId) {
11849
+ injectedCall = {
11850
+ ...contextualCall,
11851
+ arguments: JSON.stringify({
11852
+ ...args,
11853
+ parentDialogId: deps.parentDialogId
11854
+ })
11855
+ };
11856
+ }
11857
+ } catch {
11858
+ }
11859
+ }
11016
11860
  assertWithinLocalToolBudget({
11017
11861
  toolName: call.name,
11018
11862
  budgets: localToolBudgets,
@@ -11021,7 +11865,7 @@ function createCliLocalRuntimeAdapter(deps) {
11021
11865
  const result = await executeLocalToolWithPolicy({
11022
11866
  env: deps.env,
11023
11867
  agentToolNames: activeAgentToolNames,
11024
- call,
11868
+ call: injectedCall,
11025
11869
  executors: localToolExecutors,
11026
11870
  abortSignal: opts?.abortSignal,
11027
11871
  detachMs: resolveExecShellDetachMs(deps.env),
@@ -11042,6 +11886,7 @@ function createCliLocalRuntimeAdapter(deps) {
11042
11886
  export {
11043
11887
  summarizeEndpoint,
11044
11888
  isBuiltinNoloAgentRef,
11889
+ parseAgentRunEvent,
11045
11890
  parseCliLocale,
11046
11891
  getCliLocale,
11047
11892
  setCliLocale,
@@ -11049,6 +11894,8 @@ export {
11049
11894
  t,
11050
11895
  toolLabel,
11051
11896
  agentRunCardLabels,
11897
+ QUOTA_ERROR_PATTERNS,
11898
+ isQuotaExhaustedError,
11052
11899
  clearCliLocalRuntimePreparedAgentCache,
11053
11900
  createCliCallAgentToolExecutor,
11054
11901
  createCliLocalRuntimeAdapter