nolo-cli 0.8.0-alpha.21 → 0.8.0-alpha.24

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 (114) hide show
  1. package/{_executeModel-42U3VOVZ.js → _executeModel-2ZAPHFOX.js} +46 -43
  2. package/{action-TLI3V62L.js → action-QM2ONPYZ.js} +9 -9
  3. package/{addContentAction-57RSIIMR.js → addContentAction-UXY3GM53.js} +8 -8
  4. package/{addDialogAgentAction-G3VWEA6E.js → addDialogAgentAction-MUBYOG65.js} +10 -10
  5. package/{agentDeleteCommand-5DD2IM3J.js → agentDeleteCommand-5TFSII4Z.js} +28 -27
  6. package/{agentEmailCommands-6FACJBU4.js → agentEmailCommands-XMXWGUMZ.js} +62 -58
  7. package/{agentListCommands-I6KZYCIG.js → agentListCommands-OWEFQEY4.js} +119 -33
  8. package/{agentMachineCommands-VKLIGMZA.js → agentMachineCommands-DGHYBBFC.js} +27 -26
  9. package/{agentPullCommand-O2MTUAFR.js → agentPullCommand-N6UWRTVL.js} +3 -3
  10. package/{agentRecordCommands-7TZICYDT.js → agentRecordCommands-I433EE5F.js} +53 -49
  11. package/{agentRunCommand-L4OM23KV.js → agentRunCommand-UQSX3IGW.js} +57 -52
  12. package/{agentRunControl-K4VKNEHF.js → agentRunControl-S3G62M6C.js} +3 -3
  13. package/{agentRuntimeLocal-ZYEIPTY4.js → agentRuntimeLocal-73SVOC5U.js} +14 -12
  14. package/{agentSlice-BX7GXSNO.js → agentSlice-JQCS4LR3.js} +9 -9
  15. package/{authCommand-EB5JSOX5.js → authCommand-B6P2XYLN.js} +11 -11
  16. package/{authCommands-XPEHTKSM.js → authCommands-4YKA4GTU.js} +7 -7
  17. package/{chunk-AS4PVWA4.js → chunk-2CVZSC5L.js} +1 -1
  18. package/{chunk-JRKKFRAV.js → chunk-3HPUUWOR.js} +58 -8
  19. package/{chunk-5KLGBAAR.js → chunk-3KGTFX3T.js} +2 -13
  20. package/{chunk-IWX4UW2E.js → chunk-524BDL33.js} +89 -8
  21. package/chunk-6QFNUK2G.js +144 -0
  22. package/{chunk-4QEWT7KD.js → chunk-AISLHYDB.js} +367 -85
  23. package/{chunk-2FTTDCD4.js → chunk-AMJ7LA5D.js} +1 -1
  24. package/{chunk-I6XMPTMR.js → chunk-BFDWXLFF.js} +2 -2
  25. package/{chunk-RL776AGR.js → chunk-BKGNXJAM.js} +1 -1
  26. package/{chunk-RCSJFQPB.js → chunk-BQECZ3Q4.js} +361 -90
  27. package/{chunk-VVX233PH.js → chunk-BT37DVDA.js} +9 -9
  28. package/{chunk-ENOG22KJ.js → chunk-BT57QC5K.js} +18 -20
  29. package/chunk-BYXBJQAS.js +0 -0
  30. package/{chunk-O2ZNTTET.js → chunk-C4DZRHFJ.js} +24 -15
  31. package/{chunk-4XENYTF5.js → chunk-DS3VC4EA.js} +3 -3
  32. package/{chunk-N54XAP77.js → chunk-FVVST32H.js} +1 -1
  33. package/{chunk-P3PKED2I.js → chunk-FZ2G3I4B.js} +11 -13
  34. package/{chunk-AGFH73SK.js → chunk-G7KM6BBZ.js} +1 -1
  35. package/{chunk-2ECQG4YX.js → chunk-GROGNZOA.js} +264 -161
  36. package/chunk-IOQIOZNI.js +42 -0
  37. package/{chunk-AL2KDGR2.js → chunk-IPA2WQGY.js} +201 -98
  38. package/{chunk-7DAJ4AI4.js → chunk-IYMGQ3TN.js} +9 -2
  39. package/{chunk-CKOJQDKR.js → chunk-JEMATI63.js} +1 -1
  40. package/{chunk-7U44LYTR.js → chunk-JTINRTBT.js} +1 -1
  41. package/{chunk-4O3CARJ4.js → chunk-KTHLAJEY.js} +1 -1
  42. package/{chunk-URUUZLPA.js → chunk-L3KWEH3V.js} +8 -8
  43. package/{chunk-XBUBEFNX.js → chunk-L76QNLGU.js} +1 -1
  44. package/{chunk-UB6SN4NJ.js → chunk-LE6JAIXE.js} +6 -6
  45. package/{chunk-2JCXITPK.js → chunk-LRKEOCWY.js} +15 -15
  46. package/{chunk-5EFXE3O7.js → chunk-LTH6AVG7.js} +3 -3
  47. package/{chunk-YPRZSPF3.js → chunk-OCDEWRE2.js} +1 -1
  48. package/{chunk-6KHNO3SK.js → chunk-P2SPC3FT.js} +27 -23
  49. package/{chunk-4IJYA27C.js → chunk-PXZAAB4L.js} +4 -4
  50. package/{chunk-VUW5FBDB.js → chunk-Q7S2ORXX.js} +9 -9
  51. package/{chunk-C3RUNRHT.js → chunk-QWM7YWVT.js} +1 -1
  52. package/{chunk-25LCXTML.js → chunk-RQPZX6KP.js} +2 -2
  53. package/chunk-S3UTETIC.js +4885 -0
  54. package/{chunk-SDJDLO5W.js → chunk-SBVUZC2E.js} +5 -5
  55. package/{chunk-VX3SXJ3N.js → chunk-UBSKX3LP.js} +6 -6
  56. package/{chunk-4ZDM73SD.js → chunk-V2J635L5.js} +1 -1
  57. package/{chunk-DSZUWUYB.js → chunk-VBKJTOAW.js} +1 -1
  58. package/{chunk-FVYY6MCS.js → chunk-VUEXKW6U.js} +17 -17
  59. package/{chunk-7KCUSYT2.js → chunk-WKQGZJVI.js} +7 -7
  60. package/{chunk-GU3PEVGZ.js → chunk-WM7P5OWZ.js} +2639 -1579
  61. package/{chunk-7GNGZRLZ.js → chunk-WTBWWBSF.js} +150 -78
  62. package/{chunk-FSO5B7GH.js → chunk-WVS3GX3B.js} +2 -2
  63. package/chunk-Z3NEXVYE.js +33 -0
  64. package/{createAgentAutomationAction-RJF3N2QY.js → createAgentAutomationAction-GXZNLJZK.js} +26 -24
  65. package/{createDialogAction-DRSPS6CE.js → createDialogAction-KLW42ZGF.js} +26 -24
  66. package/{createPageAction-6B2WMNO3.js → createPageAction-IBJHE6MH.js} +26 -24
  67. package/{dbSlice-Q3TM2FJV.js → dbSlice-R5EJKZBW.js} +7 -7
  68. package/{deleteFile-OW53A6BX.js → deleteFile-WPWVZE4B.js} +5 -5
  69. package/{dialogCommands-4IX4XIZE.js → dialogCommands-7O5PUZRU.js} +23 -22
  70. package/{dialogSlice-3M7KX2TX.js → dialogSlice-GGV7PF53.js} +25 -23
  71. package/{docCreateCommands-SIL3NPGT.js → docCreateCommands-7ZO2NQQF.js} +22 -21
  72. package/{docDeleteCommands-7IOMLUS4.js → docDeleteCommands-YKIXZYBR.js} +23 -22
  73. package/{docReadCommands-FNFXUA5L.js → docReadCommands-5UDONBUL.js} +22 -21
  74. package/{docStore-SV7E34D4.js → docStore-VDWTATFH.js} +25 -23
  75. package/{docUpdateCommands-X2HNDVUC.js → docUpdateCommands-EPZIIQMY.js} +22 -21
  76. package/fetchMessages-KTNM7QAR.js +1 -1
  77. package/{getPricing-3E6UNPKL.js → getPricing-6TOZXPAU.js} +7 -3
  78. package/{handleSendMessageAction-JYETO5RZ.js → handleSendMessageAction-MMATC5V5.js} +30 -28
  79. package/index.js +74 -74
  80. package/{localDialogRead-2VRI24F4.js → localDialogRead-YSKFFRTT.js} +1 -1
  81. package/{machineCommands-RIO3RP5Q.js → machineCommands-PTHPKSIZ.js} +59 -55
  82. package/{machineWsRunDispatch-W7UYLGB5.js → machineWsRunDispatch-M5L2NVWJ.js} +51 -47
  83. package/{memoryCommands-O4MIPIWQ.js → memoryCommands-HG4WKTU7.js} +2 -2
  84. package/{models-4OPOOLFS.js → models-H524GH3U.js} +3 -2
  85. package/package.json +1 -1
  86. package/{read-GW7ZEI23.js → read-5ZMY7FKP.js} +5 -5
  87. package/{readDocTool-HUFU6OCT.js → readDocTool-2NXDK32S.js} +1 -1
  88. package/{readlineWorkspace-27JR7WPW.js → readlineWorkspace-4NXMEOHP.js} +835 -622
  89. package/{removeDialogAgentAction-CXKR4NJI.js → removeDialogAgentAction-KOLQ2R5W.js} +13 -12
  90. package/{runAgentClientLoop-HZFAPJHS.js → runAgentClientLoop-FGUYNGSA.js} +45 -42
  91. package/{runtimeDoctorCommands-LRHLPDRC.js → runtimeDoctorCommands-UWR5UDSM.js} +5 -5
  92. package/{setDialogExtraReferencesAction-6RKUSXHX.js → setDialogExtraReferencesAction-OMTEO7X6.js} +10 -10
  93. package/{setPrimaryDialogAgentAction-T3UTBEFG.js → setPrimaryDialogAgentAction-DOCIS6V4.js} +13 -12
  94. package/{settingSlice-IVKXJXMG.js → settingSlice-UWZJYDOA.js} +8 -8
  95. package/{spaceCommands-E7VOF4LO.js → spaceCommands-S3EB6TOS.js} +29 -28
  96. package/{spaceSlice-TSVROA5U.js → spaceSlice-RG2GSV7K.js} +24 -22
  97. package/{streamAgentChatTurn-3C5RQZJF.js → streamAgentChatTurn-X576C23M.js} +209 -86
  98. package/{tableCommands-O7O2LBEG.js → tableCommands-M3DJUETS.js} +10 -10
  99. package/{toolApiClient-QI3YBNWB.js → toolApiClient-C7P7YSE4.js} +2 -2
  100. package/{tools-EQDEKR6N.js → tools-HURZ2N4O.js} +33 -30
  101. package/{tuiSummaryLlmCaller-RV3THLZF.js → tuiSummaryLlmCaller-DG2LBTBX.js} +8 -6
  102. package/{updateCommands-VOSPKXFF.js → updateCommands-TC5SX42Y.js} +3 -3
  103. package/{updateDialogTitleAction-3XV7VWSZ.js → updateDialogTitleAction-62LVIAUZ.js} +28 -26
  104. package/chunk-BBYVOSU2.js +0 -792
  105. package/chunk-DCOA4QSN.js +0 -105
  106. package/{chunk-DZ3XJVET.js → chunk-3QAF2LTL.js} +3 -3
  107. package/{chunk-EHLHSX7R.js → chunk-5MMZUWSG.js} +3 -3
  108. package/{chunk-ISNCLGUZ.js → chunk-AVMJVOQY.js} +3 -3
  109. package/{chunk-UTLZINAP.js → chunk-DVRHHFEA.js} +10 -10
  110. package/{chunk-4CQLVGRV.js → chunk-ID4G2MAR.js} +3 -3
  111. package/{chunk-5MIDPSSK.js → chunk-JK7VW2FN.js} +3 -3
  112. package/{chunk-TILFE6LV.js → chunk-YOCHZD7D.js} +3 -3
  113. package/{db-HCJ5PRB5.js → db-6QED3ZVO.js} +3 -3
  114. package/{understanding-3CUQQ6SV.js → understanding-ZOESBLF3.js} +3 -3
@@ -3,12 +3,16 @@ import {
3
3
  refreshAntigravityOAuthToken,
4
4
  refreshOpenAiCodexToken,
5
5
  refreshXaiOAuthToken
6
- } from "./chunk-EHLHSX7R.js";
6
+ } from "./chunk-5MMZUWSG.js";
7
+ import {
8
+ CliProviderQuotaError,
9
+ executeCli
10
+ } from "./chunk-CMKUBIGW.js";
7
11
  import {
8
12
  buildLocalAgentLookupKeys,
9
13
  normalizeAgentHandle,
10
14
  shouldReadAgentKeyRemotely
11
- } from "./chunk-N54XAP77.js";
15
+ } from "./chunk-FVVST32H.js";
12
16
  import {
13
17
  LOCAL_CODEX_AGENT_ID,
14
18
  LOCAL_CODEX_AGENT_KEY,
@@ -17,23 +21,19 @@ import {
17
21
  } from "./chunk-VHBWHNVT.js";
18
22
  import {
19
23
  inferCaptureIntent
20
- } from "./chunk-4O3CARJ4.js";
21
- import {
22
- CliProviderQuotaError,
23
- executeCli
24
- } from "./chunk-CMKUBIGW.js";
24
+ } from "./chunk-KTHLAJEY.js";
25
25
  import {
26
26
  buildCliPrompt
27
27
  } from "./chunk-ATNTHIZI.js";
28
28
  import {
29
29
  prepareTools
30
- } from "./chunk-FSO5B7GH.js";
30
+ } from "./chunk-WVS3GX3B.js";
31
31
  import {
32
32
  getAntigravityUserAgent,
33
33
  isAntigravityOAuthAgent,
34
34
  readAntigravityProjectId,
35
35
  resolveAntigravityCloudCodeBaseUrl
36
- } from "./chunk-C3RUNRHT.js";
36
+ } from "./chunk-QWM7YWVT.js";
37
37
  import {
38
38
  FORCED_TOOLS,
39
39
  addDefaultLightWebToolsForConfiguredAgents,
@@ -43,27 +43,19 @@ import {
43
43
  readXPostFunctionSchema,
44
44
  readXhsProfileFunc,
45
45
  readXhsProfileFunctionSchema
46
- } from "./chunk-AL2KDGR2.js";
46
+ } from "./chunk-IPA2WQGY.js";
47
47
  import {
48
48
  normalizeDialogTitle
49
49
  } from "./chunk-OWOHNGCN.js";
50
50
  import {
51
51
  BUILTIN_TITLE_LLM_CONFIG
52
- } from "./chunk-4ZDM73SD.js";
52
+ } from "./chunk-V2J635L5.js";
53
53
  import {
54
54
  fetchServerSyncedCredential
55
- } from "./chunk-VUW5FBDB.js";
56
- import {
57
- isCompiledBinary,
58
- parseUserIdFromAuthToken
59
- } from "./chunk-ISNCLGUZ.js";
60
- import {
61
- DEFAULT_NOLO_SERVER_URL
62
- } from "./chunk-OLZBQWZU.js";
55
+ } from "./chunk-Q7S2ORXX.js";
63
56
  import {
64
57
  buildAgentRuntimeDialogWritePlan,
65
58
  buildLocalWorkspaceOpenAiTools,
66
- buildLocalWorkspacePolicyToolNames,
67
59
  buildLocalWorkspaceToolset,
68
60
  createHybridRecordStore,
69
61
  createLocalWorkspaceToolExecutors,
@@ -73,7 +65,7 @@ import {
73
65
  parseSseDataLineJson,
74
66
  readOpenAiCompatibleSseCompletion,
75
67
  resolveOpenAiCompatibleProviderConfig
76
- } from "./chunk-O2ZNTTET.js";
68
+ } from "./chunk-C4DZRHFJ.js";
77
69
  import {
78
70
  buildPlatformChatCompletionRequest,
79
71
  canUsePlatformChatProvider,
@@ -82,23 +74,22 @@ import {
82
74
  readSseDataValues,
83
75
  resolvePlatformChatProviderConfig,
84
76
  shouldUsePlatformChatProvider
85
- } from "./chunk-5KLGBAAR.js";
77
+ } from "./chunk-3KGTFX3T.js";
86
78
  import {
87
79
  resolveAgentRuntimeConfigFromRecord
88
- } from "./chunk-TILFE6LV.js";
80
+ } from "./chunk-YOCHZD7D.js";
89
81
  import {
90
82
  parseToolArgumentsJson,
91
83
  summarizeToolArguments
92
- } from "./chunk-4QEWT7KD.js";
84
+ } from "./chunk-AISLHYDB.js";
93
85
  import {
94
86
  buildLoadSkillExecutor,
95
87
  buildNoloWorkspaceCliToolExecutors,
96
88
  buildNoloWorkspaceOpenAiTools,
97
89
  canonicalizeToolNames,
98
- filterNoloWorkspaceToolNames,
99
90
  parseNoloWorkspaceToolArguments,
100
91
  resolveRuntimeToolSurfaceForAgent
101
- } from "./chunk-P3PKED2I.js";
92
+ } from "./chunk-FZ2G3I4B.js";
102
93
  import {
103
94
  clipCompactText
104
95
  } from "./chunk-5MMAK75Q.js";
@@ -114,12 +105,6 @@ import {
114
105
  readOAuthCredential,
115
106
  resolveFreshAccessToken
116
107
  } from "./chunk-JZPBVBIY.js";
117
- import {
118
- toErrorMessage
119
- } from "./chunk-HNMXYYJR.js";
120
- import {
121
- getDefaultCliLocalRuntimeDb
122
- } from "./chunk-H33743XH.js";
123
108
  import {
124
109
  asRecordOrEmpty
125
110
  } from "./chunk-KX6YBIHG.js";
@@ -132,6 +117,26 @@ import {
132
117
  import {
133
118
  asOptionalFiniteNumber
134
119
  } from "./chunk-WWC7I6TA.js";
120
+ import {
121
+ checkStaleRun,
122
+ finalizeRunRecord,
123
+ findRunRecord,
124
+ listRunRecords,
125
+ spawnLocalBackgroundRun
126
+ } from "./chunk-AMJ7LA5D.js";
127
+ import {
128
+ isCompiledBinary,
129
+ parseUserIdFromAuthToken
130
+ } from "./chunk-AVMJVOQY.js";
131
+ import {
132
+ DEFAULT_NOLO_SERVER_URL
133
+ } from "./chunk-OLZBQWZU.js";
134
+ import {
135
+ toErrorMessage
136
+ } from "./chunk-HNMXYYJR.js";
137
+ import {
138
+ getDefaultCliLocalRuntimeDb
139
+ } from "./chunk-H33743XH.js";
135
140
  import {
136
141
  BUILTIN_NOLO_AGENT_KEY,
137
142
  PUBLIC_DEEPSEEK_V4_FLASH_AGENT_KEY,
@@ -139,25 +144,25 @@ import {
139
144
  PUBLIC_GLM_52_AGENT_KEY,
140
145
  PUBLIC_KIMI_K26_IMAGE_AGENT_KEY,
141
146
  PUBLIC_KIMI_K27_CODING_AGENT_KEY
142
- } from "./chunk-DSZUWUYB.js";
147
+ } from "./chunk-VBKJTOAW.js";
143
148
  import {
144
- isLoopbackHostname
145
- } from "./chunk-4SN6J65J.js";
149
+ asTrimmedString
150
+ } from "./chunk-3EUW3WEO.js";
151
+ import {
152
+ isRecord
153
+ } from "./chunk-KUG52IAP.js";
146
154
  import {
147
155
  NOLO_CLUSTER_SERVERS
148
156
  } from "./chunk-LCBAMY2M.js";
149
157
  import {
150
- asTrimmedString
151
- } from "./chunk-3EUW3WEO.js";
158
+ isLoopbackHostname
159
+ } from "./chunk-4SN6J65J.js";
152
160
  import {
153
161
  normalizeServerOrigin
154
162
  } from "./chunk-CF7PE763.js";
155
163
  import {
156
164
  asOptionalTrimmedString
157
165
  } from "./chunk-G3SUCT4W.js";
158
- import {
159
- isRecord
160
- } from "./chunk-KUG52IAP.js";
161
166
 
162
167
  // packages/cli/client/localRuntimeAdapter.ts
163
168
  import { dirname, extname, join } from "node:path";
@@ -714,14 +719,14 @@ var BUILTIN_PLATFORM_AGENT_CONFIGS = {
714
719
  [PUBLIC_KIMI_K26_IMAGE_AGENT_KEY]: {
715
720
  key: PUBLIC_KIMI_K26_IMAGE_AGENT_KEY,
716
721
  name: "Kimi K2.6",
717
- provider: "ollama-cloud",
722
+ provider: "nolo",
718
723
  model: "kimi-k2.6",
719
724
  apiSource: "platform",
720
725
  useServerProxy: true,
721
726
  rawRecord: {
722
727
  dbKey: PUBLIC_KIMI_K26_IMAGE_AGENT_KEY,
723
728
  isPublic: true,
724
- provider: "ollama-cloud",
729
+ provider: "nolo",
725
730
  model: "kimi-k2.6",
726
731
  apiSource: "platform",
727
732
  useServerProxy: true
@@ -730,14 +735,14 @@ var BUILTIN_PLATFORM_AGENT_CONFIGS = {
730
735
  [PUBLIC_KIMI_K27_CODING_AGENT_KEY]: {
731
736
  key: PUBLIC_KIMI_K27_CODING_AGENT_KEY,
732
737
  name: "Kimi K2.7 Coding",
733
- provider: "ollama-cloud",
738
+ provider: "nolo",
734
739
  model: "kimi-k2.7-code",
735
740
  apiSource: "platform",
736
741
  useServerProxy: true,
737
742
  rawRecord: {
738
743
  dbKey: PUBLIC_KIMI_K27_CODING_AGENT_KEY,
739
744
  isPublic: true,
740
- provider: "ollama-cloud",
745
+ provider: "nolo",
741
746
  model: "kimi-k2.7-code",
742
747
  apiSource: "platform",
743
748
  useServerProxy: true
@@ -1042,12 +1047,6 @@ var LOCAL_SERVER_WEB_TOOL_NAMES = ["fetchWebpage", "exa_search"];
1042
1047
  var LOCAL_SERVER_WEB_TOOL_NAME_SET = new Set(
1043
1048
  LOCAL_SERVER_WEB_TOOL_NAMES
1044
1049
  );
1045
- var REGISTRY_INJECTED_TOOL_NAMES = /* @__PURE__ */ new Set([
1046
- "callAgent",
1047
- "ui_ask_choice",
1048
- "read_x_post",
1049
- "read_xhs_profile"
1050
- ]);
1051
1050
 
1052
1051
  // packages/cli/client/cliServerPlatformToolExecutors.ts
1053
1052
  function buildServerPlatformToolExecutors(args) {
@@ -1143,7 +1142,183 @@ function buildServerPlatformToolExecutors(args) {
1143
1142
  return { ...tableExecutors, ...webExecutors };
1144
1143
  }
1145
1144
 
1145
+ // packages/cli/client/cliAgentRunToolExecutors.ts
1146
+ import { existsSync, readFileSync } from "node:fs";
1147
+ var noopOutput = { write: () => {
1148
+ } };
1149
+ var parseCallArgs = (call) => {
1150
+ try {
1151
+ return JSON.parse(call?.arguments || "{}");
1152
+ } catch {
1153
+ return {};
1154
+ }
1155
+ };
1156
+ var resolveFs = (deps) => deps.fs ?? { existsSync, readFileSync };
1157
+ var tailFile = (logPath, tailLines, fs) => {
1158
+ if (!fs.existsSync(logPath)) return void 0;
1159
+ try {
1160
+ const content = fs.readFileSync(logPath, "utf8");
1161
+ const lines = String(content).split(/\r?\n/);
1162
+ if (lines.length > 0 && lines[lines.length - 1] === "") lines.pop();
1163
+ return lines.slice(Math.max(0, lines.length - tailLines)).join("\n");
1164
+ } catch {
1165
+ return void 0;
1166
+ }
1167
+ };
1168
+ function createCliStartAgentRunExecutor(deps = {}) {
1169
+ return async (call) => {
1170
+ const args = parseCallArgs(call);
1171
+ const agentKey = typeof args.agentKey === "string" ? args.agentKey.trim() : "";
1172
+ const task = typeof args.task === "string" ? args.task.trim() : "";
1173
+ if (!agentKey) throw new Error("startAgentRun: \u7F3A\u5C11 agentKey \u53C2\u6570\u3002");
1174
+ if (!task) throw new Error("startAgentRun: \u7F3A\u5C11\u6709\u6548\u7684 task \u6587\u672C\u63CF\u8FF0\u3002");
1175
+ const message = typeof args.input === "undefined" ? task : `${task}
1176
+
1177
+ --- \u9644\u52A0\u8F93\u5165 ---
1178
+ ${JSON.stringify(args.input)}`;
1179
+ const rawArgs = ["--agent", agentKey, "--msg-file", "PLACEHOLDER", "--bg"];
1180
+ const { runId, pid } = await spawnLocalBackgroundRun(
1181
+ {
1182
+ rawArgs,
1183
+ commandPath: ["agent", "run"],
1184
+ cliEntrypointPath: deps.cliEntrypoint,
1185
+ agentKey,
1186
+ cwd: deps.cwd ?? process.cwd(),
1187
+ message,
1188
+ output: noopOutput
1189
+ },
1190
+ deps
1191
+ );
1192
+ return {
1193
+ content: JSON.stringify({ runId, status: "running" }),
1194
+ metadata: {
1195
+ displayData: `\u23F3 \u540E\u53F0 run \u5DF2\u542F\u52A8\uFF0CrunId: ${runId}\uFF08pid ${pid ?? "-"}\uFF09\u3002\u7528 controlAgentRun(action:"status", runId:"${runId}") \u67E5\u8FDB\u5EA6\u3002`
1196
+ }
1197
+ };
1198
+ };
1199
+ }
1200
+ function createCliControlAgentRunExecutor(deps = {}) {
1201
+ return async (call) => {
1202
+ const args = parseCallArgs(call);
1203
+ const action = typeof args.action === "string" ? args.action : "";
1204
+ const tailLines = typeof args.tailLines === "number" ? args.tailLines : 0;
1205
+ if (action === "list") {
1206
+ const runs = listRunRecords(deps).map((record2) => ({
1207
+ runId: record2.runId,
1208
+ status: record2.status,
1209
+ agentKey: record2.agentKey,
1210
+ pid: record2.pid ?? null,
1211
+ startedAt: record2.startedAt
1212
+ }));
1213
+ return {
1214
+ content: JSON.stringify({ runs, count: runs.length }),
1215
+ metadata: {
1216
+ displayData: runs.length > 0 ? `\u{1F4CB} \u627E\u5230 ${runs.length} \u4E2A run\uFF1A
1217
+ ${runs.map((r) => `${r.runId} [${r.status}] ${r.agentKey}`).join("\n")}` : "\u{1F4CB} \u6CA1\u6709\u627E\u5230 run\u3002"
1218
+ }
1219
+ };
1220
+ }
1221
+ if (action !== "status" && action !== "stop") {
1222
+ throw new Error(`controlAgentRun: \u672A\u77E5 action "${action}"\u3002`);
1223
+ }
1224
+ if (!args.runId) throw new Error(`controlAgentRun(action:"${action}"): \u7F3A\u5C11 runId\u3002`);
1225
+ const record = findRunRecord(String(args.runId), deps);
1226
+ if (!record) {
1227
+ return {
1228
+ content: JSON.stringify({ runId: args.runId, found: false }),
1229
+ metadata: { displayData: `\u2753 run ${args.runId} \u672A\u627E\u5230\u3002\u53EF\u80FD\u5DF2\u5B8C\u6210\u5E76\u88AB\u6E05\u7406\uFF0C\u6216 ID \u9519\u8BEF\u3002` }
1230
+ };
1231
+ }
1232
+ if (action === "status") {
1233
+ const reconciled = checkStaleRun(record.runId, deps) ?? record;
1234
+ const logTail = tailLines > 0 ? tailFile(record.logPath, tailLines, resolveFs(deps)) : void 0;
1235
+ return {
1236
+ content: JSON.stringify({
1237
+ runId: reconciled.runId,
1238
+ found: true,
1239
+ status: reconciled.status,
1240
+ pid: reconciled.pid ?? null,
1241
+ agentKey: reconciled.agentKey,
1242
+ startedAt: reconciled.startedAt,
1243
+ endedAt: reconciled.endedAt ?? null,
1244
+ exitCode: reconciled.exitCode ?? null,
1245
+ ...logTail !== void 0 ? { logTail } : {}
1246
+ }),
1247
+ metadata: {
1248
+ displayData: `\u{1F4CC} run ${reconciled.runId} status=${reconciled.status}` + (logTail ? `
1249
+ --- \u65E5\u5FD7\uFF08\u672B ${tailLines} \u884C\uFF09---
1250
+ ${logTail}` : "")
1251
+ }
1252
+ };
1253
+ }
1254
+ if (typeof record.pid === "number") {
1255
+ try {
1256
+ (deps.kill ?? ((pid, signal) => process.kill(pid, signal)))(
1257
+ record.pid,
1258
+ "SIGTERM"
1259
+ );
1260
+ } catch {
1261
+ }
1262
+ }
1263
+ finalizeRunRecord(record.runId, { status: "killed" }, deps);
1264
+ return {
1265
+ content: JSON.stringify({ runId: record.runId, found: true, status: "killed" }),
1266
+ metadata: { displayData: `\u{1F6D1} run ${record.runId} \u5DF2\u505C\u6B62\uFF08killed\uFF09\u3002` }
1267
+ };
1268
+ };
1269
+ }
1270
+
1146
1271
  // packages/cli/client/cliLocalToolExecutors.ts
1272
+ var MAX_PASTED_TEXT_LINES_PER_READ = 200;
1273
+ function createReadPastedTextExecutor(store) {
1274
+ return async (call) => {
1275
+ let parsed = {};
1276
+ try {
1277
+ const value = JSON.parse(call.arguments || "{}");
1278
+ if (value && typeof value === "object") parsed = value;
1279
+ } catch {
1280
+ return {
1281
+ content: "readPastedText requires a JSON object with pasteId.",
1282
+ metadata: { error: true, code: "invalid_arguments" }
1283
+ };
1284
+ }
1285
+ const pasteId = Number(parsed.pasteId);
1286
+ if (!Number.isInteger(pasteId) || pasteId < 1) {
1287
+ return {
1288
+ content: "readPastedText requires a positive integer pasteId.",
1289
+ metadata: { error: true, code: "invalid_paste_id" }
1290
+ };
1291
+ }
1292
+ const text = store.items.get(pasteId);
1293
+ if (text === void 0) {
1294
+ return {
1295
+ content: `pasted text #${pasteId} is no longer available in this TUI turn.`,
1296
+ metadata: { error: true, code: "paste_not_found", pasteId }
1297
+ };
1298
+ }
1299
+ const lines = text.split("\n");
1300
+ const requestedStart = Number(parsed.startLine);
1301
+ const requestedEnd = Number(parsed.endLine);
1302
+ const startLine = Number.isInteger(requestedStart) && requestedStart > 0 ? Math.min(requestedStart, lines.length) : 1;
1303
+ const endLine = Math.min(
1304
+ lines.length,
1305
+ Number.isInteger(requestedEnd) && requestedEnd >= startLine ? requestedEnd : startLine + MAX_PASTED_TEXT_LINES_PER_READ - 1,
1306
+ startLine + MAX_PASTED_TEXT_LINES_PER_READ - 1
1307
+ );
1308
+ return {
1309
+ content: lines.slice(startLine - 1, endLine).join("\n"),
1310
+ metadata: {
1311
+ pasteId,
1312
+ startLine,
1313
+ endLine,
1314
+ totalLines: lines.length,
1315
+ totalChars: text.length,
1316
+ truncated: endLine < lines.length,
1317
+ source: "tui-paste-store"
1318
+ }
1319
+ };
1320
+ };
1321
+ }
1147
1322
  function buildCliWorkspaceToolExecutors(args) {
1148
1323
  return buildNoloWorkspaceCliToolExecutors({
1149
1324
  cliEntrypoint: args.cliEntrypoint ?? process.argv[1] ?? "",
@@ -1297,6 +1472,17 @@ function buildLocalToolExecutors(args) {
1297
1472
  metadata: { uiAskChoice: true }
1298
1473
  };
1299
1474
  },
1475
+ // agent-orchestration 能力包:startAgentRun / controlAgentRun 本地 --bg 执行器
1476
+ // (复用 ~/.nolo/runs/ 注册表,MED-1 修复)。
1477
+ startAgentRun: createCliStartAgentRunExecutor({
1478
+ env: args.env,
1479
+ cliEntrypoint: args.cliEntrypoint,
1480
+ cwd: args.workspaceRoot
1481
+ }),
1482
+ controlAgentRun: createCliControlAgentRunExecutor({
1483
+ env: args.env
1484
+ }),
1485
+ ...args.pastedTextStore ? { readPastedText: createReadPastedTextExecutor(args.pastedTextStore) } : {},
1300
1486
  ...args.localToolExecutors ?? {}
1301
1487
  };
1302
1488
  }
@@ -6920,6 +7106,7 @@ function toolResultText(result) {
6920
7106
  function toolResultIsError(result) {
6921
7107
  const meta = result.metadata;
6922
7108
  if (!meta) return false;
7109
+ if (meta.error === true) return true;
6923
7110
  if (typeof meta.error === "string" && meta.error.length > 0) return true;
6924
7111
  if (typeof meta.exitCode === "number" && meta.exitCode !== 0) return true;
6925
7112
  if (typeof meta.reason === "string" && meta.reason === "error") return true;
@@ -7226,6 +7413,28 @@ function synthesizeCursorExecToolCall(ctx, toolCallId, toolName, args) {
7226
7413
  ctx.blocks.push(block);
7227
7414
  return block;
7228
7415
  }
7416
+ function toErrorMessage2(e) {
7417
+ if (e instanceof Error) return e.message;
7418
+ if (typeof e === "string") return e;
7419
+ try {
7420
+ return JSON.stringify(e);
7421
+ } catch {
7422
+ return String(e);
7423
+ }
7424
+ }
7425
+ function fillToolCallBlockError(toolCallBlock, error, extras) {
7426
+ const message = toErrorMessage2(error);
7427
+ const result = {
7428
+ content: message,
7429
+ metadata: {
7430
+ error: true,
7431
+ message,
7432
+ ...extras ?? {}
7433
+ }
7434
+ };
7435
+ toolCallBlock.result = result;
7436
+ return result;
7437
+ }
7229
7438
  function decodeMcpArgValue(value) {
7230
7439
  try {
7231
7440
  const parsed = fromBinary(ValueSchema, value);
@@ -7307,6 +7516,7 @@ async function handleExecServerMessage(execMsg, h2Request, ctx) {
7307
7516
  ...toolResult.metadata ? { metadata: toolResult.metadata } : {}
7308
7517
  });
7309
7518
  } catch (e) {
7519
+ fillToolCallBlockError(toolCallBlock, e);
7310
7520
  result = create(ReadResultSchema, {
7311
7521
  result: {
7312
7522
  case: "error",
@@ -7322,6 +7532,7 @@ async function handleExecServerMessage(execMsg, h2Request, ctx) {
7322
7532
  });
7323
7533
  }
7324
7534
  } else {
7535
+ fillToolCallBlockError(toolCallBlock, "Tool execution not configured", { reason: "rejected" });
7325
7536
  result = create(ReadResultSchema, {
7326
7537
  result: {
7327
7538
  case: "rejected",
@@ -7375,6 +7586,7 @@ async function handleExecServerMessage(execMsg, h2Request, ctx) {
7375
7586
  ...toolResult.metadata ? { metadata: toolResult.metadata } : {}
7376
7587
  });
7377
7588
  } catch (e) {
7589
+ fillToolCallBlockError(toolCallBlock, e);
7378
7590
  result = create(ShellResultSchema, {
7379
7591
  result: {
7380
7592
  case: "failure",
@@ -7399,6 +7611,7 @@ async function handleExecServerMessage(execMsg, h2Request, ctx) {
7399
7611
  });
7400
7612
  }
7401
7613
  } else {
7614
+ fillToolCallBlockError(toolCallBlock, "Tool execution not configured", { reason: "rejected" });
7402
7615
  result = create(ShellResultSchema, {
7403
7616
  result: {
7404
7617
  case: "rejected",
@@ -7474,6 +7687,7 @@ async function handleExecServerMessage(execMsg, h2Request, ctx) {
7474
7687
  ...toolResult.metadata ? { metadata: toolResult.metadata } : {}
7475
7688
  });
7476
7689
  } catch (e) {
7690
+ fillToolCallBlockError(toolCallBlock, e);
7477
7691
  result = create(GrepResultSchema, {
7478
7692
  result: {
7479
7693
  case: "error",
@@ -7489,6 +7703,7 @@ async function handleExecServerMessage(execMsg, h2Request, ctx) {
7489
7703
  });
7490
7704
  }
7491
7705
  } else {
7706
+ fillToolCallBlockError(toolCallBlock, "Tool execution not configured", { reason: "rejected" });
7492
7707
  result = create(GrepResultSchema, {
7493
7708
  result: {
7494
7709
  case: "error",
@@ -7535,6 +7750,7 @@ async function handleExecServerMessage(execMsg, h2Request, ctx) {
7535
7750
  ...toolResult.metadata ? { metadata: toolResult.metadata } : {}
7536
7751
  });
7537
7752
  } catch (e) {
7753
+ fillToolCallBlockError(toolCallBlock, e);
7538
7754
  result = create(WriteResultSchema, {
7539
7755
  result: {
7540
7756
  case: "error",
@@ -7550,6 +7766,7 @@ async function handleExecServerMessage(execMsg, h2Request, ctx) {
7550
7766
  });
7551
7767
  }
7552
7768
  } else {
7769
+ fillToolCallBlockError(toolCallBlock, "Tool execution not configured", { reason: "rejected" });
7553
7770
  result = create(WriteResultSchema, {
7554
7771
  result: {
7555
7772
  case: "rejected",
@@ -7592,6 +7809,7 @@ async function handleExecServerMessage(execMsg, h2Request, ctx) {
7592
7809
  ...toolResult.metadata ? { metadata: toolResult.metadata } : {}
7593
7810
  });
7594
7811
  } catch (e) {
7812
+ fillToolCallBlockError(toolCallBlock, e);
7595
7813
  result = create(DeleteResultSchema, {
7596
7814
  result: {
7597
7815
  case: "error",
@@ -7607,6 +7825,7 @@ async function handleExecServerMessage(execMsg, h2Request, ctx) {
7607
7825
  });
7608
7826
  }
7609
7827
  } else {
7828
+ fillToolCallBlockError(toolCallBlock, "Tool execution not configured", { reason: "rejected" });
7610
7829
  result = create(DeleteResultSchema, {
7611
7830
  result: {
7612
7831
  case: "rejected",
@@ -7649,6 +7868,7 @@ async function handleExecServerMessage(execMsg, h2Request, ctx) {
7649
7868
  ...toolResult.metadata ? { metadata: toolResult.metadata } : {}
7650
7869
  });
7651
7870
  } catch (e) {
7871
+ fillToolCallBlockError(toolCallBlock, e);
7652
7872
  result = create(LsResultSchema, {
7653
7873
  result: {
7654
7874
  case: "error",
@@ -7664,6 +7884,7 @@ async function handleExecServerMessage(execMsg, h2Request, ctx) {
7664
7884
  });
7665
7885
  }
7666
7886
  } else {
7887
+ fillToolCallBlockError(toolCallBlock, "Tool execution not configured", { reason: "rejected" });
7667
7888
  result = create(LsResultSchema, {
7668
7889
  result: {
7669
7890
  case: "rejected",
@@ -7710,6 +7931,7 @@ async function handleExecServerMessage(execMsg, h2Request, ctx) {
7710
7931
  ...toolResult.metadata ? { metadata: toolResult.metadata } : {}
7711
7932
  });
7712
7933
  } catch (e) {
7934
+ fillToolCallBlockError(toolCallBlock, e);
7713
7935
  result = create(McpResultSchema, {
7714
7936
  result: {
7715
7937
  case: "error",
@@ -7725,6 +7947,10 @@ async function handleExecServerMessage(execMsg, h2Request, ctx) {
7725
7947
  });
7726
7948
  }
7727
7949
  } else {
7950
+ fillToolCallBlockError(toolCallBlock, `Tool not found: ${toolName}`, {
7951
+ reason: "toolNotFound",
7952
+ toolName
7953
+ });
7728
7954
  result = buildMcpToolNotFoundResult(toolName);
7729
7955
  }
7730
7956
  sendExecClientMessage(h2Request, execMsg, "mcpResult", result);
@@ -7736,15 +7962,6 @@ async function handleExecServerMessage(execMsg, h2Request, ctx) {
7736
7962
  }
7737
7963
  }
7738
7964
  }
7739
- function toErrorMessage2(e) {
7740
- if (e instanceof Error) return e.message;
7741
- if (typeof e === "string") return e;
7742
- try {
7743
- return JSON.stringify(e);
7744
- } catch {
7745
- return String(e);
7746
- }
7747
- }
7748
7965
  function clipArgumentsPreview(toolName, rawArgs) {
7749
7966
  return summarizeToolArguments(toolName, rawArgs);
7750
7967
  }
@@ -8039,9 +8256,41 @@ function buildOpenAiTools(args) {
8039
8256
  const toolNameSet = new Set(args.toolNames ?? []);
8040
8257
  const callAgentTools = toolNameSet.has("callAgent") ? prepareTools(["callAgent"]) : [];
8041
8258
  const uiAskChoiceTools = toolNameSet.has("ui_ask_choice") ? prepareTools(["ui_ask_choice"]) : [];
8259
+ const readPastedTextTools = toolNameSet.has("readPastedText") ? [
8260
+ {
8261
+ type: "function",
8262
+ function: {
8263
+ name: "readPastedText",
8264
+ description: "Read a chunk of a large TUI paste by pasteId. Use startLine and endLine to page through the full content.",
8265
+ parameters: {
8266
+ type: "object",
8267
+ properties: {
8268
+ pasteId: {
8269
+ type: "integer",
8270
+ minimum: 1,
8271
+ description: "The paste id from the user message reference."
8272
+ },
8273
+ startLine: {
8274
+ type: "integer",
8275
+ minimum: 1,
8276
+ description: "First 1-based line to return; defaults to 1."
8277
+ },
8278
+ endLine: {
8279
+ type: "integer",
8280
+ minimum: 1,
8281
+ description: "Last 1-based line to return; each call is bounded to a 200-line chunk."
8282
+ }
8283
+ },
8284
+ required: ["pasteId"],
8285
+ additionalProperties: false
8286
+ }
8287
+ }
8288
+ }
8289
+ ] : [];
8042
8290
  return [
8043
8291
  ...callAgentTools,
8044
8292
  ...uiAskChoiceTools,
8293
+ ...readPastedTextTools,
8045
8294
  ...buildLocalWorkspaceOpenAiTools({
8046
8295
  toolNames: toolset.toolNames,
8047
8296
  exposeShellTools: toolset.exposeShellTools,
@@ -8057,7 +8306,13 @@ function buildOpenAiTools(args) {
8057
8306
  searchFilesParameterVariant: resolveSearchFilesParameterVariant(args.env)
8058
8307
  }),
8059
8308
  ...buildServerPlatformOpenAiTools({ toolNames: args.toolNames }),
8060
- ...buildNoloWorkspaceOpenAiTools({ toolNames: args.toolNames })
8309
+ ...buildNoloWorkspaceOpenAiTools({ toolNames: args.toolNames }),
8310
+ // startAgentRun/controlAgentRun:CLI 本地 --bg 执行器已就绪(MED-1 修复,
8311
+ // cliAgentRunToolExecutors),只要 agent 声明(agent-orchestration 包展开)
8312
+ // 就注入 schema。
8313
+ ...prepareTools(
8314
+ ["startAgentRun", "controlAgentRun"].filter((name) => toolNameSet.has(name))
8315
+ )
8061
8316
  ];
8062
8317
  }
8063
8318
  var CLI_DEFAULT_TOOLS = ["exa_search", "fetchWebpage"];
@@ -8072,9 +8327,9 @@ function resolveCliEffectiveEnabledPacks(args) {
8072
8327
  }
8073
8328
  const base = args.enabledPacks ?? [];
8074
8329
  if (base.length === 0) {
8075
- return ["code"];
8330
+ return ["code", "agent-orchestration"];
8076
8331
  }
8077
- return base;
8332
+ return base.includes("agent-orchestration") ? base : [...base, "agent-orchestration"];
8078
8333
  }
8079
8334
  function resolveCliRequestedToolNames(agentConfig, env) {
8080
8335
  const declaredOnly = shouldUseDeclaredOnlyLocalWorkspaceTools(env);
@@ -8101,8 +8356,13 @@ function resolveCliRequestedToolNames(agentConfig, env) {
8101
8356
  agentConfig?.disabledTools
8102
8357
  );
8103
8358
  }
8104
- function resolveProviderOpenAiToolBundle(agentConfig, env, buildTools = buildOpenAiTools) {
8105
- const requestedToolNames = resolveCliRequestedToolNames(agentConfig, env);
8359
+ function resolveProviderOpenAiToolBundle(agentConfig, env, buildTools = buildOpenAiTools, additionalToolNames = []) {
8360
+ const requestedToolNames = [
8361
+ .../* @__PURE__ */ new Set([
8362
+ ...resolveCliRequestedToolNames(agentConfig, env),
8363
+ ...additionalToolNames
8364
+ ])
8365
+ ];
8106
8366
  const tools = buildTools({
8107
8367
  agentKey: agentConfig.key,
8108
8368
  toolNames: requestedToolNames,
@@ -8121,25 +8381,17 @@ function buildLocalWorkspaceToolsetForEnv(args) {
8121
8381
  return toolset;
8122
8382
  }
8123
8383
  function buildLocalPolicyToolNames(args) {
8384
+ const buildTools = args.buildTools ?? buildOpenAiTools;
8124
8385
  return [
8125
- ...buildLocalWorkspacePolicyToolNames({
8126
- declaredToolNames: args.toolNames,
8127
- exposeShellTools: true,
8128
- useDeclaredToolNamesOnly: shouldUseDeclaredOnlyLocalWorkspaceTools(
8129
- args.env
8386
+ ...new Set(
8387
+ summarizeOpenAiToolNames(
8388
+ buildTools({
8389
+ agentKey: args.agentKey,
8390
+ toolNames: args.toolNames,
8391
+ env: args.env
8392
+ })
8130
8393
  )
8131
- }),
8132
- ...(() => {
8133
- const extra = [];
8134
- const names = args.toolNames ?? [];
8135
- for (const name of names) {
8136
- if (REGISTRY_INJECTED_TOOL_NAMES.has(name)) extra.push(name);
8137
- if (LOCAL_SERVER_TABLE_TOOL_NAME_SET.has(name)) extra.push(name);
8138
- if (LOCAL_SERVER_WEB_TOOL_NAME_SET.has(name)) extra.push(name);
8139
- }
8140
- return extra;
8141
- })(),
8142
- ...filterNoloWorkspaceToolNames(args.toolNames)
8394
+ )
8143
8395
  ];
8144
8396
  }
8145
8397
  function buildServerPlatformOpenAiTools(args) {
@@ -8464,6 +8716,7 @@ function createCliLocalRuntimeAdapter(deps) {
8464
8716
  const localToolBudgets = parseLocalToolBudgets(deps.env);
8465
8717
  const localToolUsage = /* @__PURE__ */ new Map();
8466
8718
  const buildProviderOpenAiTools = deps.buildProviderOpenAiTools ?? buildOpenAiTools;
8719
+ const additionalToolNames = deps.pastedTextStore ? ["readPastedText"] : [];
8467
8720
  let activeAgentToolNames = [];
8468
8721
  const workspaceRoot = deps.cwd ?? process.cwd();
8469
8722
  let runtimeToolExecutionLimits = {};
@@ -8477,6 +8730,7 @@ function createCliLocalRuntimeAdapter(deps) {
8477
8730
  cliEntrypoint: CLI_ENTRYPOINT,
8478
8731
  ...deps.confirmDestructiveAction ? { confirmDestructiveAction: deps.confirmDestructiveAction } : {},
8479
8732
  ...deps.requestUserChoice ? { requestUserChoice: deps.requestUserChoice } : {},
8733
+ ...deps.pastedTextStore ? { pastedTextStore: deps.pastedTextStore } : {},
8480
8734
  ...runtimeToolExecutionLimits
8481
8735
  });
8482
8736
  return {
@@ -8493,7 +8747,7 @@ function createCliLocalRuntimeAdapter(deps) {
8493
8747
  agentRef,
8494
8748
  cwd: normalizeRuntimeCacheCwd(workspaceRoot)
8495
8749
  });
8496
- const cached = preparedAgentRuntimeCache.get(cacheKey);
8750
+ const cached = deps.pastedTextStore ? void 0 : preparedAgentRuntimeCache.get(cacheKey);
8497
8751
  if (cached) {
8498
8752
  activeAgentToolNames = cached.activeAgentToolNames;
8499
8753
  runtimeToolExecutionLimits = cached.runtimeToolExecutionLimits;
@@ -8512,7 +8766,8 @@ function createCliLocalRuntimeAdapter(deps) {
8512
8766
  );
8513
8767
  const requestedToolNames = agentConfig ? resolveCliRequestedToolNames(agentConfig, deps.env) : [];
8514
8768
  activeAgentToolNames = buildLocalPolicyToolNames({
8515
- toolNames: requestedToolNames,
8769
+ agentKey: agentConfig?.key,
8770
+ toolNames: [...requestedToolNames, ...additionalToolNames],
8516
8771
  env: deps.env
8517
8772
  });
8518
8773
  runtimeToolExecutionLimits = resolveLocalWorkspaceExecutorOptionsFromPolicy(
@@ -8528,9 +8783,10 @@ function createCliLocalRuntimeAdapter(deps) {
8528
8783
  cliEntrypoint: CLI_ENTRYPOINT,
8529
8784
  ...deps.confirmDestructiveAction ? { confirmDestructiveAction: deps.confirmDestructiveAction } : {},
8530
8785
  ...deps.requestUserChoice ? { requestUserChoice: deps.requestUserChoice } : {},
8786
+ ...deps.pastedTextStore ? { pastedTextStore: deps.pastedTextStore } : {},
8531
8787
  ...runtimeToolExecutionLimits
8532
8788
  });
8533
- if (agentConfig) {
8789
+ if (agentConfig && !deps.pastedTextStore) {
8534
8790
  preparedAgentRuntimeCache.set(cacheKey, {
8535
8791
  agentConfig,
8536
8792
  activeAgentToolNames,
@@ -8623,7 +8879,8 @@ function createCliLocalRuntimeAdapter(deps) {
8623
8879
  const { requestedToolNames: requestedToolNames2, tools: tools2 } = resolveProviderOpenAiToolBundle(
8624
8880
  agentConfig,
8625
8881
  deps.env,
8626
- buildProviderOpenAiTools
8882
+ buildProviderOpenAiTools,
8883
+ additionalToolNames
8627
8884
  );
8628
8885
  logLocalRuntimeDiagnostic("provider.selected", {
8629
8886
  agentKey: agentConfig.key,
@@ -8703,7 +8960,8 @@ function createCliLocalRuntimeAdapter(deps) {
8703
8960
  const { requestedToolNames: requestedToolNames2, tools: tools2 } = resolveProviderOpenAiToolBundle(
8704
8961
  agentConfig,
8705
8962
  deps.env,
8706
- buildProviderOpenAiTools
8963
+ buildProviderOpenAiTools,
8964
+ additionalToolNames
8707
8965
  );
8708
8966
  logLocalRuntimeDiagnostic("provider.selected", {
8709
8967
  agentKey: agentConfig.key,
@@ -8768,7 +9026,8 @@ function createCliLocalRuntimeAdapter(deps) {
8768
9026
  const { requestedToolNames: requestedToolNames2, tools: tools2 } = resolveProviderOpenAiToolBundle(
8769
9027
  agentConfig,
8770
9028
  deps.env,
8771
- buildProviderOpenAiTools
9029
+ buildProviderOpenAiTools,
9030
+ additionalToolNames
8772
9031
  );
8773
9032
  logLocalRuntimeDiagnostic("provider.selected", {
8774
9033
  agentKey: agentConfig.key,
@@ -8850,7 +9109,8 @@ function createCliLocalRuntimeAdapter(deps) {
8850
9109
  const { requestedToolNames: requestedToolNames2, tools: tools2 } = resolveProviderOpenAiToolBundle(
8851
9110
  agentConfig,
8852
9111
  deps.env,
8853
- buildProviderOpenAiTools
9112
+ buildProviderOpenAiTools,
9113
+ additionalToolNames
8854
9114
  );
8855
9115
  return {
8856
9116
  model: providerConfig2.model,
@@ -8889,8 +9149,18 @@ function createCliLocalRuntimeAdapter(deps) {
8889
9149
  if (!res.ok) {
8890
9150
  const raw2 = await res.text().catch(() => "");
8891
9151
  const data2 = parsePlatformChatCompletionData(raw2);
9152
+ const rawPreview = raw2.length > 200 ? `${raw2.slice(0, 200)}\u2026(${raw2.length}b)` : raw2;
9153
+ const gatewayHeaders = [
9154
+ "server",
9155
+ "cf-ray",
9156
+ "cf-cache-status",
9157
+ "content-length"
9158
+ ].map((h) => {
9159
+ const v = res.headers.get(h);
9160
+ return v ? `${h}=${v}` : null;
9161
+ }).filter(Boolean).join(" ");
8892
9162
  throw new Error(
8893
- `platform provider failed: HTTP ${res.status} ${JSON.stringify(data2)}`
9163
+ `platform provider failed: HTTP ${res.status} ${JSON.stringify(data2)}` + (rawPreview ? ` raw="${rawPreview}"` : "") + (gatewayHeaders ? ` headers=[${gatewayHeaders}]` : "")
8894
9164
  );
8895
9165
  }
8896
9166
  const contentType = res.headers.get("content-type") ?? "";
@@ -8959,7 +9229,8 @@ function createCliLocalRuntimeAdapter(deps) {
8959
9229
  const { requestedToolNames, tools } = resolveProviderOpenAiToolBundle(
8960
9230
  agentConfig,
8961
9231
  deps.env,
8962
- buildProviderOpenAiTools
9232
+ buildProviderOpenAiTools,
9233
+ additionalToolNames
8963
9234
  );
8964
9235
  return {
8965
9236
  model: providerConfig.model,