nolo-cli 0.11.0 → 0.12.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/{_executeModel-ZEDPX6OF.js → _executeModel-4F7VZR5U.js} +52 -50
  2. package/{action-AA4IJ5K2.js → action-OTOWUMPW.js} +8 -9
  3. package/{addContentAction-QYVO4SYP.js → addContentAction-JGBUVR7K.js} +7 -9
  4. package/{addDialogAgentAction-WVVKT5WQ.js → addDialogAgentAction-V6CL2UCF.js} +9 -10
  5. package/{agentDeleteCommand-RDPGYIWF.js → agentDeleteCommand-MMRSG6AB.js} +39 -28
  6. package/{agentEmailCommands-2HJJKS5F.js → agentEmailCommands-YFVKOGM7.js} +65 -62
  7. package/{agentListCommands-HFEVV3ZW.js → agentListCommands-2PZHIQ3I.js} +128 -31
  8. package/{agentMachineCommands-25ZOENJU.js → agentMachineCommands-55UUZNHF.js} +38 -26
  9. package/{agentPullCommand-GOL2S4W2.js → agentPullCommand-KRBRIFIY.js} +7 -7
  10. package/{agentRecordCommands-GTCOAM3L.js → agentRecordCommands-BTP3OAPL.js} +57 -54
  11. package/{agentRunCommand-YBS3JDLD.js → agentRunCommand-AA4QLRQZ.js} +60 -59
  12. package/{agentRunControl-K4VKNEHF.js → agentRunControl-IX4F5W2C.js} +3 -3
  13. package/{agentRuntimeLocal-UQBMQI2M.js → agentRuntimeLocal-QDJCBXM2.js} +31 -15
  14. package/{agentSlice-6EKOBCCS.js → agentSlice-6JAJOU3X.js} +8 -9
  15. package/{authCommand-O2OWACN4.js → authCommand-DMW336GT.js} +15 -15
  16. package/{authCommands-H7365TZP.js → authCommands-GH5T6RYV.js} +6 -6
  17. package/{chunk-E4HNJSHC.js → chunk-2BVGERJ2.js} +81 -19
  18. package/{chunk-LP65VRCI.js → chunk-3MI5LDDU.js} +6 -6
  19. package/{chunk-OPZYGHUC.js → chunk-3WGLLTK4.js} +59 -1
  20. package/{chunk-KJR5KAUQ.js → chunk-3XF6LCCN.js} +20 -7
  21. package/{chunk-PXZAAB4L.js → chunk-4LG74DRG.js} +4 -4
  22. package/{chunk-2FTTDCD4.js → chunk-4ON5AV72.js} +2 -1
  23. package/{chunk-IWX4UW2E.js → chunk-524BDL33.js} +89 -8
  24. package/{chunk-ISNCLGUZ.js → chunk-5NBHQD4D.js} +4 -3
  25. package/{chunk-ZPRK73XY.js → chunk-5S4SWV5G.js} +51 -38
  26. package/{chunk-EVZKZF32.js → chunk-5V524MHX.js} +195 -78
  27. package/{chunk-CKOJQDKR.js → chunk-7JJCGV7N.js} +146 -3
  28. package/{chunk-NEM67FX7.js → chunk-ARSC56DC.js} +1 -1
  29. package/{chunk-AFON4QUU.js → chunk-AS3ZQ3O2.js} +19 -28
  30. package/{chunk-4SOKXIW4.js → chunk-B4KT7RN2.js} +10 -13
  31. package/chunk-BYXBJQAS.js +0 -0
  32. package/{chunk-PXQN7IBQ.js → chunk-C3BFP57W.js} +95 -2
  33. package/{chunk-AEZAORLG.js → chunk-CGDQDXKZ.js} +5 -5
  34. package/{chunk-MQI77IRB.js → chunk-DPFWKRHG.js} +2 -2
  35. package/{chunk-TACHTH5D.js → chunk-EIMX5ER5.js} +18 -18
  36. package/{chunk-5MOUAAMK.js → chunk-FSUZIGIG.js} +197 -2578
  37. package/{chunk-FXXSGWAJ.js → chunk-H5Y2H2N6.js} +1 -1
  38. package/chunk-IKXL2HZ3.js +70 -0
  39. package/{chunk-QNMFBBZK.js → chunk-IVAOVLM7.js} +1 -1
  40. package/chunk-JFANOO7I.js +2274 -0
  41. package/{chunk-YPRZSPF3.js → chunk-JKWWVF2I.js} +1 -1
  42. package/{chunk-3NSIQZZ6.js → chunk-JU7J7EAV.js} +45 -45
  43. package/{chunk-X2S7JTIG.js → chunk-KWBH4RAL.js} +1280 -137
  44. package/{chunk-OUI3ZHYD.js → chunk-LUKQQJFL.js} +39 -2
  45. package/{chunk-BX6U3ETE.js → chunk-MG6BVV3T.js} +320 -102
  46. package/{chunk-L53FGHA4.js → chunk-MQRZ5QUH.js} +1 -1
  47. package/{chunk-2W2VYVI5.js → chunk-MZHSAPZP.js} +675 -177
  48. package/{chunk-YOCHZD7D.js → chunk-NCGFB7NN.js} +5 -3
  49. package/{chunk-DWGAEFJL.js → chunk-O4FOPRCP.js} +1 -1
  50. package/chunk-OGGHETUE.js +4900 -0
  51. package/{chunk-PNEW2Z3T.js → chunk-OHEKYYJF.js} +7 -7
  52. package/chunk-OOIN7HSO.js +146 -0
  53. package/{chunk-SV5MWASH.js → chunk-OPM2DE2J.js} +12 -12
  54. package/{chunk-5OIFWVX7.js → chunk-QJSTNKJY.js} +1 -1
  55. package/{chunk-C4FTUXVF.js → chunk-QLUFR47U.js} +11 -1
  56. package/{chunk-LAX2JSTX.js → chunk-QUHUVG6Y.js} +20 -2
  57. package/{chunk-D6OQHXVG.js → chunk-RQSOAMPJ.js} +22 -6
  58. package/{chunk-ZEYDOXHF.js → chunk-RUGEW4P7.js} +1515 -884
  59. package/{chunk-GBDSZATH.js → chunk-RWO5DGXI.js} +3 -3
  60. package/{chunk-S3GS2PRL.js → chunk-TA7VKOHU.js} +613 -70
  61. package/{chunk-XYZA7S7V.js → chunk-TQYYGE6G.js} +6 -6
  62. package/{chunk-YTBMA7NO.js → chunk-TYPHUVK5.js} +70 -8
  63. package/{chunk-4ZDM73SD.js → chunk-V2J635L5.js} +1 -1
  64. package/{chunk-C2MDQQ4O.js → chunk-VBSWHE5W.js} +1 -1
  65. package/{chunk-O26GI2JP.js → chunk-VKG4HXYV.js} +39 -8
  66. package/{chunk-IPYUUY4E.js → chunk-WPHL6ALY.js} +1 -1
  67. package/{chunk-7D3JY6C2.js → chunk-WVTBAALN.js} +64 -5
  68. package/{chunk-XFOLQLDN.js → chunk-XHQWJUW4.js} +2 -2
  69. package/{chunk-Q3UKJVU4.js → chunk-Y5P3ZRGC.js} +10 -10
  70. package/{chunk-KQQVGRA3.js → chunk-YUMYYXPI.js} +53 -183
  71. package/cliEnvHelpers-VYC2OPTB.js +30 -0
  72. package/{createAgentAutomationAction-LTI5QU35.js → createAgentAutomationAction-4NY4JLOK.js} +26 -26
  73. package/{createDialogAction-OJJ7L3L3.js → createDialogAction-I5WUWFJ6.js} +26 -26
  74. package/{createPageAction-5MXWVRGY.js → createPageAction-HFTIQ7TW.js} +26 -26
  75. package/{dbSlice-RQFQQVHT.js → dbSlice-J4PUZ6Y5.js} +6 -7
  76. package/{deleteFile-7XP5BGC7.js → deleteFile-M7UNIUOO.js} +4 -4
  77. package/{dialogCommands-JTJ3RPPW.js → dialogCommands-SVXRJFZS.js} +34 -23
  78. package/{dialogSlice-OWROKURJ.js → dialogSlice-35LA3ZRG.js} +26 -26
  79. package/{docCreateCommands-WJBEW2V7.js → docCreateCommands-Z7RIAYKQ.js} +34 -23
  80. package/{docDeleteCommands-BVEHJOY5.js → docDeleteCommands-NEYHUVZF.js} +35 -25
  81. package/{docReadCommands-NEWOZIJV.js → docReadCommands-I4US2SDE.js} +34 -23
  82. package/{docStore-3DXRYBMD.js → docStore-3CP2IO6M.js} +25 -25
  83. package/{docUpdateCommands-C7WHT7UU.js → docUpdateCommands-UU5HQBRP.js} +34 -23
  84. package/fetchMessages-KTNM7QAR.js +1 -1
  85. package/{getPricing-3E6UNPKL.js → getPricing-UGDJHI7M.js} +7 -3
  86. package/{handleSendMessageAction-B5PRR7BE.js → handleSendMessageAction-FWTLQGOZ.js} +30 -30
  87. package/index.js +77 -76
  88. package/{localDialogRead-YSKFFRTT.js → localDialogRead-2VRI24F4.js} +1 -1
  89. package/{machineCommands-IIIREAEK.js → machineCommands-STHZKBDJ.js} +64 -61
  90. package/{machineWsRunDispatch-3SIU6ILW.js → machineWsRunDispatch-7YHT4TPT.js} +56 -53
  91. package/{memoryCommands-O4MIPIWQ.js → memoryCommands-AFMES3LN.js} +5 -5
  92. package/{models-4OPOOLFS.js → models-LSCRJJ6P.js} +2 -2
  93. package/package.json +1 -1
  94. package/{read-QJNKRROM.js → read-2MIMRBZ2.js} +4 -4
  95. package/{readDocTool-H6X6KO6X.js → readDocTool-QHVGQHUJ.js} +1 -1
  96. package/{readlineWorkspace-HGP3I3OC.js → readlineWorkspace-OMRWYMB6.js} +1279 -716
  97. package/{removeDialogAgentAction-TCT35SOF.js → removeDialogAgentAction-XUZYQBV4.js} +13 -13
  98. package/{runAgentClientLoop-EFM4PTVI.js → runAgentClientLoop-FP2K33ZO.js} +47 -46
  99. package/{runtimeDoctorCommands-ID43Z7VX.js → runtimeDoctorCommands-QNF3J3UV.js} +6 -6
  100. package/{setDialogExtraReferencesAction-CGYLZMFH.js → setDialogExtraReferencesAction-PTAIFKGM.js} +9 -10
  101. package/{setPrimaryDialogAgentAction-F6BFQDJU.js → setPrimaryDialogAgentAction-HRFTDB44.js} +13 -13
  102. package/{settingSlice-2I5HMG47.js → settingSlice-VGRJUSE5.js} +7 -8
  103. package/{skillDiscovery-UGSQGX2U.js → skillDiscovery-6M2BZUFN.js} +3 -3
  104. package/{spaceCommands-MT7BWCIL.js → spaceCommands-GN73BCOB.js} +38 -29
  105. package/{spaceSlice-BS5TSW3W.js → spaceSlice-WTFNKOVA.js} +30 -26
  106. package/{streamAgentChatTurn-I3VBFNR3.js → streamAgentChatTurn-HBAQQVNK.js} +442 -130
  107. package/{toolApiClient-C7P7YSE4.js → toolApiClient-QI3YBNWB.js} +2 -2
  108. package/{tools-XSD2BOEN.js → tools-TPQYTLQZ.js} +34 -33
  109. package/{tuiSummaryLlmCaller-32NRHTT2.js → tuiSummaryLlmCaller-XDC7WG4K.js} +11 -7
  110. package/{updateCommands-VOSPKXFF.js → updateCommands-XZDOOYFH.js} +13 -5
  111. package/{updateDialogTitleAction-7FYNJOGP.js → updateDialogTitleAction-AWXNPUQJ.js} +30 -29
  112. package/chunk-AZPCASRE.js +0 -36
  113. package/chunk-BBYVOSU2.js +0 -792
  114. package/chunk-DCOA4QSN.js +0 -105
  115. package/chunk-UAD2WT54.js +0 -64
  116. package/{chunk-JK7VW2FN.js → chunk-5MIDPSSK.js} +3 -3
  117. package/{chunk-5CS33IBL.js → chunk-PDL2AV3E.js} +3 -3
  118. package/{chunk-5MMZUWSG.js → chunk-TOILAPLH.js} +5 -5
  119. package/{chunk-OOM6SJNR.js → chunk-TSUJOM6N.js} +6 -6
  120. package/{db-6QED3ZVO.js → db-HCJ5PRB5.js} +3 -3
  121. package/{offlineMarxistsAgentCommand-BCPJITJL.js → offlineMarxistsAgentCommand-5OOWZLJI.js} +3 -3
  122. package/{tableCommands-M3DJUETS.js → tableCommands-E4SQWDOX.js} +6 -6
  123. package/{understanding-ZOESBLF3.js → understanding-3CUQQ6SV.js} +3 -3
@@ -1,20 +1,22 @@
1
1
  import {
2
2
  ANTIGRAVITY_CLOUD_CODE_BASE_URL,
3
3
  isAntigravityOAuthAgent
4
- } from "./chunk-FXXSGWAJ.js";
4
+ } from "./chunk-H5Y2H2N6.js";
5
5
  import {
6
6
  clipMultilineText,
7
- fetchAndSerializeTable
8
- } from "./chunk-2W2VYVI5.js";
7
+ fetchAndSerializeTable,
8
+ waitForAbortableDelay
9
+ } from "./chunk-MZHSAPZP.js";
9
10
  import {
10
- CORE_DRAIN_REASON,
11
+ createDrainExhaustedResponse,
12
+ isCoreDrainingBody,
11
13
  isGatewayHttpStatus,
12
14
  normalizeNonNegativeMs,
13
15
  parseRetryAfterHeaderMs
14
- } from "./chunk-D6OQHXVG.js";
16
+ } from "./chunk-RQSOAMPJ.js";
15
17
  import {
16
18
  slateToSimplifiedMarkdown
17
- } from "./chunk-QNMFBBZK.js";
19
+ } from "./chunk-IVAOVLM7.js";
18
20
  import {
19
21
  extractCategorizedMentions
20
22
  } from "./chunk-VP4WJWKW.js";
@@ -22,77 +24,83 @@ import {
22
24
  resolvePageSkillMetadata
23
25
  } from "./chunk-VC6OZXO5.js";
24
26
  import {
25
- estimateTokenCount,
26
27
  fetchAndCacheMessages,
27
28
  shouldUseServerProxy
28
- } from "./chunk-5MOUAAMK.js";
29
+ } from "./chunk-FSUZIGIG.js";
29
30
  import {
30
31
  fetchServerSyncedCredential
31
- } from "./chunk-Q3UKJVU4.js";
32
- import {
33
- createSpaceKey
34
- } from "./chunk-UAD2WT54.js";
35
- import {
36
- read
37
- } from "./chunk-O26GI2JP.js";
38
- import {
39
- MEMORY_USE_GUIDANCE,
40
- wrapHistoricalSummaryWithReplayGuard
41
- } from "./chunk-KKY4B2Q2.js";
32
+ } from "./chunk-Y5P3ZRGC.js";
42
33
  import {
43
34
  buildCurrentTimeBlock,
44
35
  buildIdentityBlock,
45
- buildRuntimeGuidanceBlocks
46
- } from "./chunk-OUI3ZHYD.js";
36
+ buildRuntimeGuidanceBlocks,
37
+ requiresBareImageUrl,
38
+ toBareImageUrlMessages
39
+ } from "./chunk-LUKQQJFL.js";
47
40
  import {
48
- OPENAI_RESPONSES_ENDPOINT,
49
41
  buildProviderAuthHeaders,
50
42
  convertMessagesToResponsesInput,
51
43
  isOpenAiResponsesModel,
52
- resolvePlatformChatCompletionsEndpoint
53
- } from "./chunk-YTBMA7NO.js";
44
+ preserveAgentStateFields,
45
+ resolvePlatformChatCompletionsEndpoint,
46
+ resolvePlatformResponsesEndpoint
47
+ } from "./chunk-TYPHUVK5.js";
54
48
  import {
55
49
  canonicalizeToolNames
56
- } from "./chunk-4SOKXIW4.js";
50
+ } from "./chunk-B4KT7RN2.js";
57
51
  import {
52
+ estimateTokenCount
53
+ } from "./chunk-JFANOO7I.js";
54
+ import {
55
+ clampReasoningEffort,
58
56
  getModelConfig,
59
57
  isModelSupportReasoningEffort
60
- } from "./chunk-BBYVOSU2.js";
58
+ } from "./chunk-OGGHETUE.js";
61
59
  import {
62
60
  createFileCredentialBroker
63
- } from "./chunk-5CS33IBL.js";
61
+ } from "./chunk-PDL2AV3E.js";
62
+ import {
63
+ MEMORY_USE_GUIDANCE,
64
+ wrapHistoricalSummaryWithReplayGuard
65
+ } from "./chunk-KKY4B2Q2.js";
66
+ import {
67
+ extractCustomId
68
+ } from "./chunk-DFFIZ25G.js";
69
+ import {
70
+ toErrorMessage
71
+ } from "./chunk-HNMXYYJR.js";
64
72
  import {
65
73
  isDeepInfraKimiModel,
66
74
  isFireworksKimiModel,
67
75
  resolveFireworksKimiModel
68
- } from "./chunk-IWX4UW2E.js";
76
+ } from "./chunk-524BDL33.js";
77
+ import {
78
+ createSpaceKey
79
+ } from "./chunk-WVTBAALN.js";
80
+ import {
81
+ read
82
+ } from "./chunk-VKG4HXYV.js";
69
83
  import {
70
84
  asNonEmptyStringArray
71
85
  } from "./chunk-I42VC5KR.js";
72
- import {
73
- extractCustomId
74
- } from "./chunk-DFFIZ25G.js";
75
86
  import {
76
87
  asTrimmedLowercaseString
77
88
  } from "./chunk-QSJ3HFEF.js";
78
- import {
79
- toErrorMessage
80
- } from "./chunk-HNMXYYJR.js";
81
89
  import {
82
90
  getRuntimeServerContext
83
- } from "./chunk-OOM6SJNR.js";
91
+ } from "./chunk-TSUJOM6N.js";
84
92
  import {
85
93
  isAbortError
86
94
  } from "./chunk-OOSFSFMA.js";
87
95
  import {
88
96
  asTrimmedString
89
97
  } from "./chunk-3EUW3WEO.js";
90
- import {
91
- isLoopbackUrl
92
- } from "./chunk-4SN6J65J.js";
93
98
  import {
94
99
  API_ENDPOINTS
95
100
  } from "./chunk-LCBAMY2M.js";
101
+ import {
102
+ isLoopbackUrl
103
+ } from "./chunk-4SN6J65J.js";
96
104
  import {
97
105
  asOptionalTrimmedString
98
106
  } from "./chunk-G3SUCT4W.js";
@@ -408,6 +416,45 @@ var resolveToolsFromKeys = async (keys, dispatch, preloaded) => {
408
416
  };
409
417
  };
410
418
 
419
+ // packages/agent-runtime/responsesConversationState.ts
420
+ function supportsResponsesConversationState(agent) {
421
+ return normalizeIdentityPart(agent.provider) === "openai";
422
+ }
423
+ var normalizeIdentityPart = (value) => typeof value === "string" ? value.trim().toLowerCase() : "";
424
+ function normalizeResponsesConversationState(value) {
425
+ if (!value || typeof value !== "object") return null;
426
+ const raw = value;
427
+ const provider = normalizeIdentityPart(raw.provider);
428
+ const model = normalizeIdentityPart(raw.model);
429
+ const responseId = typeof raw.responseId === "string" ? raw.responseId.trim() : "";
430
+ if (!provider || !model || !responseId) return null;
431
+ return { provider, model, responseId };
432
+ }
433
+ function selectResponsesConversationState(value, agent) {
434
+ if (!supportsResponsesConversationState(agent)) return null;
435
+ const state = normalizeResponsesConversationState(value);
436
+ if (!state) return null;
437
+ if (state.provider !== normalizeIdentityPart(agent.provider)) return null;
438
+ if (state.model !== normalizeIdentityPart(agent.model)) return null;
439
+ return state;
440
+ }
441
+ function updateResponsesConversationState(agent, responseId) {
442
+ if (!supportsResponsesConversationState(agent)) return null;
443
+ const provider = normalizeIdentityPart(agent.provider);
444
+ const model = normalizeIdentityPart(agent.model);
445
+ const normalizedResponseId = typeof responseId === "string" ? responseId.trim() : "";
446
+ if (!provider || !model || !normalizedResponseId) return null;
447
+ return { provider, model, responseId: normalizedResponseId };
448
+ }
449
+ function isResponsesConversationStateRejection(status, responseBody) {
450
+ if (![400, 404, 409].includes(status)) return false;
451
+ const text = typeof responseBody === "string" ? responseBody.trim().toLowerCase() : "";
452
+ if (!text) return false;
453
+ const mentionsResponseState = /previous[\s_-]*response/.test(text) || /response[\s_-]*(?:id|state)/.test(text);
454
+ const rejectsState = /not[\s_-]*found/.test(text) || /does not exist/.test(text) || /invalid/.test(text) || /expired/.test(text) || /unknown/.test(text);
455
+ return mentionsResponseState && rejectsState;
456
+ }
457
+
411
458
  // packages/agent-runtime/agentCallPlan.ts
412
459
  var CODEX_RESPONSES_URL = "https://chatgpt.com/backend-api/codex/responses";
413
460
  var CURSOR_AGENT_URL = "https://api2.cursor.sh/agent.v1.AgentService/Run";
@@ -523,7 +570,7 @@ function resolveAgentCallPlan(agentConfig, _env) {
523
570
  endpointKey: agentConfig.endpointKey
524
571
  });
525
572
  const upstreamWire = useResponses ? "responses" : "chat.completions";
526
- const endpoint = useResponses ? OPENAI_RESPONSES_ENDPOINT : resolvePlatformChatCompletionsEndpoint(provider) ?? "";
573
+ const endpoint = useResponses ? resolvePlatformResponsesEndpoint(provider) ?? "" : resolvePlatformChatCompletionsEndpoint(provider) ?? "";
527
574
  return {
528
575
  authMethod: { kind: "platform-key" },
529
576
  transport,
@@ -662,7 +709,7 @@ function createHash(_algo) {
662
709
  };
663
710
  }
664
711
  var hasLayerContent = (layer) => Boolean(layer.content);
665
- var estimateContextTokens = (content) => Math.ceil(content.length / 4);
712
+ var estimateContextTokens = (content) => estimateTokenCount(content);
666
713
  var compileContextLayers = (layers) => {
667
714
  const compiledLayers = [];
668
715
  for (const layer of layers) {
@@ -711,10 +758,22 @@ var CONTEXT_USAGE_INSTRUCTIONS = `\u53C2\u8003\u8D44\u6599\u4F7F\u7528\u8BF4\u66
711
758
  - \u5F53\u901A\u7528\u6307\u4EE4\u4E0E\u66F4\u5177\u4F53\u7684"\u6309 Agent / \u6309\u6587\u6863"\u7684\u89C4\u5219\u53D1\u751F\u51B2\u7A81\u65F6\uFF0C\u5FC5\u987B\u4F18\u5148\u9075\u5B88\u66F4\u5177\u4F53\u3001\u4F18\u5148\u7EA7\u66F4\u9AD8\u7684\u89C4\u5219\u3002`;
712
759
  var AGENT_ORCHESTRATION_RUN_INSTRUCTIONS = `--- \u591A Agent \u7F16\u6392\uFF08\u540E\u53F0 Run\uFF09 ---
713
760
  \u4F60\u53EF\u7528 startAgentRun \u540E\u53F0\u542F\u52A8\u5B50 Agent\uFF08fork+exec\uFF0C\u8FD4\u56DE runId\uFF09\uFF0C\u7528 controlAgentRun \u89C2\u5BDF/\u505C\u6B62\uFF08wait+signal+proc\uFF09\u3002\u6838\u5FC3\u7EAA\u5F8B\uFF08\u53CD\u9762\u6559\u6750\uFF1A\u5B50\u4EE3\u7406\u5D29\u6E83/\u6302\u8D77\u800C\u7F16\u6392\u5668\u6BEB\u65E0\u5BDF\u89C9\uFF09\uFF1A
714
- 1. \u6D3E\u53D1\u540E\u5FC5\u987B\u8F6E\u8BE2\u3002startAgentRun \u62FF\u5230 runId \u540E\uFF0C\u7528 controlAgentRun(action:"status", runId, tailLines:30) \u8F6E\u8BE2\uFF08\u5EFA\u8BAE 5\u201310s \u4E00\u6B21\uFF09\uFF0C\u4E0D\u8981\u53EA\u9760\u804A\u5929\u590D\u8FF0\u7ED3\u679C\u3002\u4E0D\u8F6E\u8BE2 = \u6CA1\u7F16\u6392\u3002
715
- 2. \u8BFB\u65E5\u5FD7\u786E\u8BA4\u8FDB\u5C55\u3002tailLines>0 \u8BFB\u5B9E\u9645\u8F93\u51FA/\u5DE5\u5177\u8C03\u7528\uFF0C\u4E0D\u53EA\u770B status=running\u2014\u2014\u540E\u53F0\u76D1\u89C6\u5668\u53EF\u80FD\u7A7A\u8F6C\u3002
716
- 3. stop \u524D\u5148\u770B\u65E5\u5FD7\u3002\u7528 status \u5224\u65AD\u662F\u771F\u5361\u6B7B\u8FD8\u662F\u6B63\u5E38\u8DD1\uFF0C\u786E\u8BA4\u9700\u8981\u53EB\u505C\u518D controlAgentRun(action:"stop", runId)\uFF1B\u7528 list/status \u786E\u8BA4 run \u771F\u5B9E\u5B58\u5728\u4E14\u975E\u7EC8\u6001\uFF0C\u522B\u5047\u8BBE"\u6D3E\u53D1\u4E86\u5C31\u5728\u8DD1"\u3002
761
+ 1. \u5148\u53D1\u73B0\u518D\u6D3E\u53D1\u3002\u8C03\u7528 listAgents \u8BFB\u53D6\u5B89\u5168\u6458\u8981\u3002\u9009\u4EBA\u6309\u4F18\u5148\u7EA7\uFF1A\u7279\u5B9A\u5DE5\u5177\u9700\u6C42 \u2192 \u4EFB\u52A1\u6863\u4E0E\u6210\u672C/\u80FD\u529B\u5339\u914D \u2192 \u80DC\u4EFB\u8005\u4E2D\u7684 isFavorite \u2192 modelAbility / inputPrice/outputPrice\u3002
762
+ - \u5148\u4F30\u4EFB\u52A1\u6863\uFF1A\u5FAE/\u7B80\u5355\uFF08\u22642 \u6B65\u3001\u6587\u6848\u3001\u5355\u70B9 polish\uFF09\uFF5C\u4E2D\uFF08\u591A\u6587\u4EF6\u8BFB\u6539\u9A8C\uFF09\uFF5C\u9AD8\uFF08\u67B6\u6784\u3001\u6DF1 review\u3001\u9AD8\u98CE\u9669\u63A8\u7406\uFF09\u3002
763
+ - \u9AD8\u4EF7/\u9876\u6863\u6A21\u578B\uFF08Opus\u3001GPT-5.6 Sol\u3001\u540C\u7EA7 Pro/K \u9876\u6863\u7B49\uFF09\u9ED8\u8BA4\u4E0D\u63A5\u7B80\u5355\u6D3B\uFF1B\u7B80\u5355\u6D3B\u4F18\u5148 Flash/Luna/\u4F4E\u4EF7\u6216\u6536\u85CF\u91CC\u7684\u8F7B\u91CF\u5019\u9009\u3002
764
+ - \u7981\u6B62\u51ED\u540D\u5B57\u7F16\u9020\u7EC6\u80FD\u529B\uFF0C\u4F46\u5141\u8BB8\u7528\u4EF7\u683C\u3001modelAbility \u53CA\u660E\u663E\u9876\u6863\u65CF\u7CFB\u505A\u7C97\u6863\u4F4D\u5339\u914D\uFF0C\u907F\u514D\u5927\u6A21\u578B\u5E72\u6742\u6D3B\u3002\u4E0D\u8981\u67E5\u6307\u6D3E\u8868\uFF0C\u4E0D\u8981\u6C42 recommendedFor\u3002
765
+ 2. coding \u662F\u9ED8\u8BA4\u80FD\u529B\u3002tools \u53EA\u7528\u4E8E\u6D4F\u89C8\u5668\u3001\u56FE\u7247\u3001\u8868\u683C\u3001\u90AE\u4EF6\u3001\u6570\u636E\u5E93\u7B49\u7279\u5B9A\u5DE5\u5177\u4EFB\u52A1\uFF1B\u4E0D\u8981\u56E0\u4E3A coding agent \u7684 tools \u6458\u8981\u4E3A\u7A7A\u5C31\u6DD8\u6C70\u5B83\u3002
766
+ 3. listAgents \u8FD4\u56DE\u7684 id\u3001publicKey\u3001handle \u53EA\u662F\u5019\u9009\u6807\u8BC6\u3002\u9009\u4E2D\u540E\u4F18\u5148\u8C03\u7528 readAgent \u89E3\u6790\u53EF\u8FD0\u884C\u7684 agentKey\uFF0C\u518D\u628A\u8BE5 agentKey \u4F20\u7ED9 startAgentRun\uFF1B\u4E0D\u8981\u51ED\u5C55\u793A\u540D\u79F0\u6216 id \u731C key\uFF0C\u4E5F\u4E0D\u8981\u7D22\u53D6 prompt\u3001\u5BC6\u94A5\u6216\u6570\u636E\u5E93 key \u6765\u9009\u4EBA\u3002\u6CA1\u6709 readAgent \u65F6\u53EA\u80FD\u4F7F\u7528\u5DF2\u6709\u4E0A\u4E0B\u6587\u4E2D\u660E\u786E\u7684 agentKey\u3002
767
+ 4. \u6D3E\u53D1\u540E\u5FC5\u987B\u8F6E\u8BE2\u3002startAgentRun \u62FF\u5230 runId \u540E\uFF0C\u7528 controlAgentRun(action:"status", runId, tailLines:30) \u8F6E\u8BE2\uFF08\u5EFA\u8BAE 5\u201310s \u4E00\u6B21\uFF09\uFF0C\u4E0D\u8981\u53EA\u9760\u804A\u5929\u590D\u8FF0\u7ED3\u679C\u3002\u4E0D\u8F6E\u8BE2 = \u6CA1\u7F16\u6392\u3002
768
+ 5. \u8BFB\u65E5\u5FD7\u786E\u8BA4\u8FDB\u5C55\u3002tailLines>0 \u8BFB\u5B9E\u9645\u8F93\u51FA/\u5DE5\u5177\u8C03\u7528\uFF0C\u4E0D\u53EA\u770B status=running\u2014\u2014\u540E\u53F0\u76D1\u89C6\u5668\u53EF\u80FD\u7A7A\u8F6C\u3002
769
+ 6. stop \u524D\u5148\u770B\u65E5\u5FD7\u3002\u7528 status \u5224\u65AD\u662F\u771F\u5361\u6B7B\u8FD8\u662F\u6B63\u5E38\u8DD1\uFF0C\u786E\u8BA4\u9700\u8981\u53EB\u505C\u518D controlAgentRun(action:"stop", runId)\uFF1B\u7528 list/status \u786E\u8BA4 run \u771F\u5B9E\u5B58\u5728\u4E14\u975E\u7EC8\u6001\uFF0C\u522B\u5047\u8BBE"\u6D3E\u53D1\u4E86\u5C31\u5728\u8DD1"\u3002
717
770
  \u5DE5\u5177\u9009\u62E9\uFF1A\u5B50\u4EFB\u52A1 <100s \u4E14\u8981\u7ACB\u5373\u62FF\u7ED3\u679C \u2192 callAgent\uFF08\u540C\u6B65\uFF09\uFF1B\u957F\u4EFB\u52A1 / \u5E76\u884C / \u9700\u8981\u89C2\u5BDF\u6216\u53EB\u505C \u2192 startAgentRun\uFF08\u672C\u6BB5\uFF09\u3002`;
771
+ var AGENT_COLLABORATION_INSTRUCTIONS = `--- \u591A Agent \u534F\u4F5C\uFF08\u8BA1\u5212 \u2192 \u6D3E\u53D1 \u2192 \u5BA1\u67E5\uFF09 ---
772
+ \u7528\u5B50\u4EE3\u7406\u5B8C\u6210\u4E2D\u5927\u578B\u4EFB\u52A1\u65F6\uFF0C\u6309\u4E09\u6BB5\u7EAA\u5F8B\u6267\u884C\uFF1A
773
+ 1. \u8BA1\u5212\u5148\u884C\uFF1A\u52A8\u624B\u524D\u5148\u60F3\u6E05\u695A\u76EE\u6807\u3001\u8FB9\u754C\u3001\u9A8C\u8BC1\u65B9\u5F0F\u548C\u505C\u6B62\u6761\u4EF6\uFF1B\u9884\u8BA1 3 \u6B65\u4EE5\u4E0A\uFF08\u8BFB\u6539\u9A8C\u3001\u591A\u6587\u4EF6\u3001\u4EFB\u4F55\u6D3E\u53D1\uFF09\u5148\u5B9A\u8BA1\u5212\uFF0C\u518D\u51B3\u5B9A\u81EA\u5DF1\u505A\u5B8C\u8FD8\u662F\u6D3E\u53D1\u3002
774
+ 2. \u6D3E\u53D1\u539F\u5219\uFF1A\u5B50\u4EFB\u52A1\u81EA\u5305\u542B\u3001\u8FB9\u754C\u6E05\u6670\u3001\u80FD\u5E76\u884C\u5219\u5E76\u884C\uFF1B\u7ED9\u6267\u884C\u8005\u5199\u6E05\u4EFB\u52A1\u3001\u9A8C\u6536\u548C\u7981\u533A\uFF0C\u4E0D\u4F20\u65E0\u5173\u5386\u53F2\u3002\u6D3E\u53D1\u540E\u8F6E\u8BE2\u7ED3\u679C\uFF0C\u4E0D\u5047\u8BBE\u6210\u529F\u3002
775
+ 3. \u72EC\u7ACB\u5BA1\u67E5\uFF1A\u91CD\u8981\u4EA7\u51FA\uFF08\u4EE3\u7801\u3001\u8FC1\u79FB\u3001\u6570\u636E\u53D8\u66F4\uFF09\u4EA4\u7ED9\u975E\u4F5C\u8005\uFF08\u6700\u597D\u662F\u4E0D\u540C\u6A21\u578B\u7684\uFF09\u72EC\u7ACB review\uFF1Breview \u53EA\u770B diff/\u8BC1\u636E\uFF0C\u4EA7\u51FA finding \u6216 Clean review\uFF0C\u518D\u51B3\u5B9A\u8FD4\u5DE5\u6216\u6536\u5C3E\u3002
776
+ \u6700\u5C0F\u5B9E\u73B0\uFF1A\u80FD\u5220\u89E3\u51B3\u5C31\u4E0D\u52A0\uFF0C\u80FD\u590D\u7528\u5C31\u4E0D\u65B0\u5EFA\uFF1B\u65B0\u62BD\u8C61\u524D\u5148\u641C\u5DF2\u6709\u5B9E\u73B0\u3002\u4E0D\u8981\u4E3A\u4E86\u663E\u5F97\u5FD9\u788C\u800C\u6D3E\u53D1\u6216\u8FC7\u5EA6\u8BBE\u8BA1\u3002`;
718
777
  var MENU_USAGE_INSTRUCTIONS = `--- \u4EA4\u4E92\u8BF4\u660E ---
719
778
  \u6240\u6709\u7528\u6237\u8F93\u5165\u5747\u4E3A\u7EAF\u6587\u672C\u6D88\u606F\uFF0C\u76F4\u63A5\u7406\u89E3\u5373\u53EF\uFF0C\u4E0D\u8981\u5728\u56DE\u590D\u4E2D\u63D0\u53CA\u6309\u94AE\u3001\u83DC\u5355\u3001\u754C\u9762\u7B49 UI \u5143\u7D20\u3002
720
779
 
@@ -817,6 +876,16 @@ var TOOL_GUIDED_SECTIONS = [
817
876
  tools.includes("startAgentRun") || tools.includes("controlAgentRun") ? AGENT_ORCHESTRATION_RUN_INSTRUCTIONS : ""
818
877
  ].filter(Boolean).join("\n\n")
819
878
  },
879
+ {
880
+ id: "agentCollaboration",
881
+ triggerTools: [
882
+ "callAgent",
883
+ "runStreamingAgent",
884
+ "startAgentRun",
885
+ "controlAgentRun"
886
+ ],
887
+ build: () => AGENT_COLLABORATION_INSTRUCTIONS
888
+ },
820
889
  { id: "menuUsage", triggerTools: ["ui_ask_choice"], build: () => MENU_USAGE_INSTRUCTIONS },
821
890
  {
822
891
  id: "webAccess",
@@ -993,6 +1062,7 @@ ${wrapHistoricalSummaryWithReplayGuard(contexts.dialogSummary)}` : "";
993
1062
  { id: "startup-protocol", owner: "platform", cacheScope: "static", content: startupProtocol },
994
1063
  { id: "core-persona", owner: "agent", cacheScope: "session", content: corePersonaSection },
995
1064
  { id: "agent-orchestration", owner: "platform", cacheScope: "session", content: toolSections.agentOrchestration },
1065
+ { id: "agent-collaboration", owner: "platform", cacheScope: "session", content: toolSections.agentCollaboration },
996
1066
  { id: "web-access", owner: "platform", cacheScope: "session", content: toolSections.webAccess },
997
1067
  { id: "menu-usage", owner: "platform", cacheScope: "session", content: toolSections.menuUsage },
998
1068
  { id: "clarification-mode", owner: "platform", cacheScope: "session", content: clarifyingSection },
@@ -1033,6 +1103,8 @@ ${wrapHistoricalSummaryWithReplayGuard(contexts.dialogSummary)}` : "";
1033
1103
  };
1034
1104
 
1035
1105
  // packages/integrations/openai/providerBodyCompatibility.ts
1106
+ var MOONSHOT_KIMI_K3_MODEL = "kimi-k3";
1107
+ var isMoonshotKimiK3 = (provider, model) => asTrimmedLowercaseString(provider) === "moonshot" && asTrimmedLowercaseString(model) === MOONSHOT_KIMI_K3_MODEL;
1036
1108
  var normalizeChatCompletionsBodyForProvider = ({
1037
1109
  body,
1038
1110
  provider,
@@ -1044,6 +1116,19 @@ var normalizeChatCompletionsBodyForProvider = ({
1044
1116
  delete nextBody.reasoning;
1045
1117
  delete nextBody.reasoning_effort;
1046
1118
  }
1119
+ if (isMoonshotKimiK3(provider, model)) {
1120
+ delete nextBody.temperature;
1121
+ delete nextBody.top_p;
1122
+ delete nextBody.frequency_penalty;
1123
+ delete nextBody.presence_penalty;
1124
+ if (typeof nextBody.max_tokens === "number") {
1125
+ nextBody.max_completion_tokens = nextBody.max_tokens;
1126
+ delete nextBody.max_tokens;
1127
+ }
1128
+ }
1129
+ if (Array.isArray(nextBody.messages) && requiresBareImageUrl({ provider, model })) {
1130
+ nextBody.messages = toBareImageUrlMessages(nextBody.messages);
1131
+ }
1047
1132
  return nextBody;
1048
1133
  };
1049
1134
 
@@ -1108,15 +1193,7 @@ var sanitizeChatCompletionsMessage = (message) => {
1108
1193
  };
1109
1194
  const name = asOptionalTrimmedString(message.name);
1110
1195
  if (name) sanitized.name = name;
1111
- const toolCallId = asOptionalTrimmedString(message.tool_call_id);
1112
- if (toolCallId) sanitized.tool_call_id = toolCallId;
1113
- if (Array.isArray(message.tool_calls)) {
1114
- sanitized.tool_calls = message.tool_calls;
1115
- }
1116
- if (message.role === "assistant" && typeof message.reasoning_content === "string" && message.reasoning_content) {
1117
- sanitized.reasoning_content = message.reasoning_content;
1118
- }
1119
- return sanitized;
1196
+ return preserveAgentStateFields(message, sanitized);
1120
1197
  };
1121
1198
  var buildRequestBody = (options) => {
1122
1199
  const {
@@ -1143,7 +1220,10 @@ var buildRequestBody = (options) => {
1143
1220
  });
1144
1221
  Object.assign(bodyData, usageRequestOptions);
1145
1222
  if (reasoning_effort && isModelSupportReasoningEffort(model)) {
1146
- bodyData.reasoning_effort = reasoning_effort;
1223
+ const clamped = clampReasoningEffort(reasoning_effort, providerName);
1224
+ if (clamped) {
1225
+ bodyData.reasoning_effort = clamped;
1226
+ }
1147
1227
  }
1148
1228
  if (typeof temperature === "number") bodyData.temperature = temperature;
1149
1229
  if (typeof top_p === "number") bodyData.top_p = top_p;
@@ -1219,9 +1299,32 @@ var generateOpenAIRequestBody = (agentConfig, providerName, messages, contexts,
1219
1299
  };
1220
1300
 
1221
1301
  // packages/integrations/openai/generateResponseRequestBody.ts
1222
- function generateResponseRequestBody(agentConfig, msgs, contexts, prependSystemPrompt = true) {
1302
+ var DEFAULT_RESPONSES_COMPACTION_THRESHOLD = 2e5;
1303
+ function resolveResponsesCompactionThreshold(agentConfig) {
1304
+ const configured = Number(
1305
+ agentConfig.responsesCompactionThreshold ?? agentConfig.responses_compaction_threshold
1306
+ );
1307
+ return Number.isFinite(configured) && configured > 0 ? Math.floor(configured) : DEFAULT_RESPONSES_COMPACTION_THRESHOLD;
1308
+ }
1309
+ function selectResponsesContinuationMessages(msgs) {
1310
+ let lastAssistantIndex = -1;
1311
+ for (let index = msgs.length - 1; index >= 0; index -= 1) {
1312
+ if (msgs[index]?.role === "assistant") {
1313
+ lastAssistantIndex = index;
1314
+ break;
1315
+ }
1316
+ }
1317
+ const candidates = lastAssistantIndex >= 0 ? msgs.slice(lastAssistantIndex + 1) : msgs;
1318
+ return candidates.filter((message) => message.role !== "system");
1319
+ }
1320
+ function generateResponseRequestBody(agentConfig, msgs, contexts, prependSystemPrompt = true, responsesState) {
1223
1321
  const language = typeof navigator !== "undefined" && navigator.language ? navigator.language : "zh-CN";
1224
- const input = convertMessagesToResponsesInput(msgs);
1322
+ const state = responsesState !== void 0 ? responsesState : selectResponsesConversationState(agentConfig.responsesState, agentConfig);
1323
+ const supportsServerState = supportsResponsesConversationState(agentConfig);
1324
+ const stateful = supportsServerState && state && agentConfig.store !== false ? state : null;
1325
+ const input = convertMessagesToResponsesInput(
1326
+ stateful ? selectResponsesContinuationMessages(msgs) : msgs
1327
+ );
1225
1328
  const body = {
1226
1329
  model: agentConfig.model,
1227
1330
  input,
@@ -1257,6 +1360,25 @@ function generateResponseRequestBody(agentConfig, msgs, contexts, prependSystemP
1257
1360
  if (agentConfig.metadata !== void 0) {
1258
1361
  body.metadata = agentConfig.metadata;
1259
1362
  }
1363
+ if (stateful) {
1364
+ body.previous_response_id = stateful.responseId;
1365
+ if (agentConfig.context_management === void 0) {
1366
+ body.context_management = [
1367
+ {
1368
+ type: "compaction",
1369
+ compact_threshold: resolveResponsesCompactionThreshold(agentConfig)
1370
+ }
1371
+ ];
1372
+ }
1373
+ } else if (supportsServerState && responsesState === void 0 && agentConfig.previous_response_id !== void 0) {
1374
+ body.previous_response_id = agentConfig.previous_response_id;
1375
+ }
1376
+ if (supportsServerState && agentConfig.store !== void 0) {
1377
+ body.store = agentConfig.store;
1378
+ }
1379
+ if (supportsServerState && agentConfig.context_management !== void 0) {
1380
+ body.context_management = agentConfig.context_management;
1381
+ }
1260
1382
  return body;
1261
1383
  }
1262
1384
 
@@ -1331,7 +1453,8 @@ var generateRequestBody = ({
1331
1453
  messages,
1332
1454
  contexts,
1333
1455
  stableMessages,
1334
- prependSystemPrompt = true
1456
+ prependSystemPrompt = true,
1457
+ responsesState
1335
1458
  }) => {
1336
1459
  const provider = (agentConfig.provider || "").toLowerCase();
1337
1460
  const imageSettings = getImageOutputSettings(agentConfig, provider);
@@ -1347,7 +1470,8 @@ var generateRequestBody = ({
1347
1470
  agentConfigForRequest,
1348
1471
  [...stableMessages ?? [], ...messages],
1349
1472
  contexts,
1350
- prependSystemPrompt
1473
+ prependSystemPrompt,
1474
+ responsesState
1351
1475
  );
1352
1476
  }
1353
1477
  const baseBody = generateOpenAIRequestBody(
@@ -1385,26 +1509,12 @@ var isRetryableServerProxyFetchError = (error) => {
1385
1509
  );
1386
1510
  };
1387
1511
  var waitForServerProxyRetry = async (retryAfterMs, signal) => {
1388
- if (retryAfterMs <= 0) return;
1389
- if (signal?.aborted) {
1390
- const abortError = new Error("Aborted");
1391
- abortError.name = "AbortError";
1392
- throw abortError;
1393
- }
1394
- await new Promise((resolve, reject) => {
1395
- const onAbort = () => {
1396
- clearTimeout(timeoutId);
1397
- signal?.removeEventListener("abort", onAbort);
1398
- const abortError = new Error("Aborted");
1399
- abortError.name = "AbortError";
1400
- reject(abortError);
1401
- };
1402
- const timeoutId = setTimeout(() => {
1403
- signal?.removeEventListener("abort", onAbort);
1404
- resolve();
1405
- }, normalizeNonNegativeMs(retryAfterMs, DEFAULT_SERVER_PROXY_RETRY_AFTER_MS));
1406
- signal?.addEventListener("abort", onAbort, { once: true });
1407
- });
1512
+ const delayMs = normalizeNonNegativeMs(
1513
+ retryAfterMs,
1514
+ DEFAULT_SERVER_PROXY_RETRY_AFTER_MS
1515
+ );
1516
+ if (delayMs <= 0) return;
1517
+ await waitForAbortableDelay(delayMs, signal);
1408
1518
  };
1409
1519
  var performServerProxyFetchWithRetry = async ({
1410
1520
  execute,
@@ -1417,7 +1527,7 @@ var performServerProxyFetchWithRetry = async ({
1417
1527
  try {
1418
1528
  const response = await execute();
1419
1529
  const responseBody = response.status === 503 ? await readRetryableResponseBody(response) : null;
1420
- const isCoreDraining = response.status === 503 && responseBody?.reason === CORE_DRAIN_REASON;
1530
+ const isCoreDraining = response.status === 503 && isCoreDrainingBody(responseBody);
1421
1531
  const maxStatusRetries = isCoreDraining ? MAX_SERVER_DRAIN_STATUS_RETRIES : MAX_STATUS_RETRIES;
1422
1532
  if (statusRetries < maxStatusRetries && isGatewayHttpStatus(response.status)) {
1423
1533
  statusRetries += 1;
@@ -1431,6 +1541,10 @@ var performServerProxyFetchWithRetry = async ({
1431
1541
  await waitForServerProxyRetry(retryAfterMs, signal);
1432
1542
  continue;
1433
1543
  }
1544
+ if (isCoreDraining) {
1545
+ console.warn(`${logPrefix} core_draining \u91CD\u8BD5\u8017\u5C3D\uFF0C\u8FD4\u56DE\u53CB\u597D\u63D0\u793A`);
1546
+ return createDrainExhaustedResponse(response);
1547
+ }
1434
1548
  return response;
1435
1549
  } catch (error) {
1436
1550
  if (networkRetries < MAX_SERVER_PROXY_RETRIES && isRetryableServerProxyFetchError(error)) {
@@ -1926,6 +2040,9 @@ export {
1926
2040
  mergeReferences,
1927
2041
  resolveReferenceAssets,
1928
2042
  resolveToolsFromKeys,
2043
+ selectResponsesConversationState,
2044
+ updateResponsesConversationState,
2045
+ isResponsesConversationStateRejection,
1929
2046
  resolveClientWire,
1930
2047
  resolveAgentCallPlan,
1931
2048
  generateRequestBody,
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-IDZTNRP2.js";
7
7
  import {
8
8
  isCompiledBinary
9
- } from "./chunk-ISNCLGUZ.js";
9
+ } from "./chunk-5NBHQD4D.js";
10
10
  import {
11
11
  DEFAULT_NOLO_SERVER_URL
12
12
  } from "./chunk-OLZBQWZU.js";
@@ -15,7 +15,8 @@ import {
15
15
  } from "./chunk-CF7PE763.js";
16
16
 
17
17
  // packages/cli/updateCommands.ts
18
- import { existsSync, readFileSync } from "node:fs";
18
+ import { existsSync, readFileSync, accessSync, constants } from "node:fs";
19
+ import { homedir } from "node:os";
19
20
  import { dirname, join } from "node:path";
20
21
  import { fileURLToPath } from "node:url";
21
22
  function resolvePackageJsonPath() {
@@ -58,6 +59,39 @@ function renderProgressBar(percent, width = 30) {
58
59
  function buildNpmSelfUpdateCommand(channel = "latest") {
59
60
  return ["npm", "install", "-g", `nolo-cli@${channel}`, "--force", "--progress"];
60
61
  }
62
+ function resolveStandaloneBundlePlatform(platform = process.platform, arch = process.arch) {
63
+ if (platform === "linux" && arch === "x64") {
64
+ return { tarballName: "nolo-linux-x64.tar.gz", extractSubdir: "nolo-linux-x64" };
65
+ }
66
+ if (platform === "darwin" && arch === "arm64") {
67
+ return { tarballName: "nolo-darwin-arm64.tar.gz", extractSubdir: "nolo-darwin-arm64" };
68
+ }
69
+ return null;
70
+ }
71
+ function resolveStandaloneBundleRepoBase(channel) {
72
+ return channel === "alpha" ? "https://us.nolo.chat" : "https://nolo.chat";
73
+ }
74
+ function buildStandaloneManualUpdateHint(channel) {
75
+ const repoBase = resolveStandaloneBundleRepoBase(channel);
76
+ return `curl -fsSL ${repoBase}/install-nolo.sh | sh`;
77
+ }
78
+ function resolveStandaloneInstallDir() {
79
+ const candidates = [
80
+ "/usr/local/bin",
81
+ join(homedir(), ".local/bin"),
82
+ join(homedir(), ".nolo/bin")
83
+ ];
84
+ for (const dir of candidates) {
85
+ if (!existsSync(dir)) continue;
86
+ try {
87
+ accessSync(dir, constants.W_OK);
88
+ return dir;
89
+ } catch {
90
+ continue;
91
+ }
92
+ }
93
+ return join(homedir(), ".nolo/bin");
94
+ }
61
95
  function readPackageInfo() {
62
96
  if (PACKAGE_JSON_PATH) {
63
97
  try {
@@ -111,7 +145,7 @@ function buildCliDoctorText(info) {
111
145
  "If direct `nolo` differs from repo-local `bun ./packages/cli/index.ts`,",
112
146
  "the global install is older than this checkout.",
113
147
  "",
114
- `Manual update: ${buildNpmSelfUpdateCommand(info.updateChannel).join(" ")}`
148
+ `Manual update: ${info.installKind === "standalone-bundle" ? buildStandaloneManualUpdateHint(info.updateChannel) : buildNpmSelfUpdateCommand(info.updateChannel).join(" ")}`
115
149
  ].join("\n");
116
150
  }
117
151
  function isRunSelfUpdateOptions(value) {
@@ -134,8 +168,113 @@ function normalizeSpawnChunk(chunk) {
134
168
  }
135
169
  return new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength);
136
170
  }
171
+ async function runShellScript(script, {
172
+ output,
173
+ spawn,
174
+ env,
175
+ cwd,
176
+ useCustomSink
177
+ }) {
178
+ const proc = spawn({
179
+ cmd: ["sh", "-c", script],
180
+ cwd,
181
+ stdin: "inherit",
182
+ stdout: useCustomSink ? "pipe" : "inherit",
183
+ stderr: useCustomSink ? "pipe" : "inherit",
184
+ env
185
+ });
186
+ if (!useCustomSink) {
187
+ return proc.exited;
188
+ }
189
+ const [exitCode] = await Promise.all([
190
+ proc.exited,
191
+ forwardSpawnOutput(proc.stdout, output),
192
+ forwardSpawnOutput(proc.stderr, output)
193
+ ]);
194
+ return exitCode;
195
+ }
196
+ async function runStandaloneBundleUpdate(options) {
197
+ const output = options.output ?? process.stdout;
198
+ const spawn = options.spawn ?? resolveDefaultSpawn();
199
+ const env = options.env ?? process.env;
200
+ const serverUrl = resolveSelfUpdateServerUrl(env, options.serverUrl);
201
+ const channel = getCliInstallChannel(serverUrl);
202
+ const platform = resolveStandaloneBundlePlatform();
203
+ if (!platform) {
204
+ output.write(
205
+ `\u2717 Standalone-bundle self-update is not supported on this platform
206
+ (platform=${process.platform}, arch=${process.arch}).
207
+ Only linux-x64 and darwin-arm64 bundles are published.
208
+ Falling back is not possible from a compiled binary; reinstall via:
209
+ ${buildStandaloneManualUpdateHint(channel)}
210
+ `
211
+ );
212
+ return 1;
213
+ }
214
+ const { tarballName, extractSubdir } = platform;
215
+ const repoBase = resolveStandaloneBundleRepoBase(channel);
216
+ const tarballUrl = `${repoBase}/public/downloads/${tarballName}`;
217
+ const fallbackUrl = `https://nolo.chat/public/downloads/${tarballName}`;
218
+ const extractDir = join(homedir(), ".nolo", extractSubdir);
219
+ const installDir = resolveStandaloneInstallDir();
220
+ const symlinkPath = join(installDir, "nolo");
221
+ const script = `set -euo pipefail
222
+ TEMP_DIR=$(mktemp -d)
223
+ trap 'rm -rf "$TEMP_DIR"' EXIT
224
+
225
+ echo "Downloading nolo from ${tarballUrl}..."
226
+ if ! curl -fL --progress-bar "${tarballUrl}" -o "$TEMP_DIR/${tarballName}"; then
227
+ ${tarballUrl !== fallbackUrl ? `echo "Primary source unavailable, trying ${fallbackUrl}..."
228
+ if ! curl -fL --progress-bar "${fallbackUrl}" -o "$TEMP_DIR/${tarballName}"; then
229
+ echo "Error: download failed from ${fallbackUrl}" >&2
230
+ exit 1
231
+ fi` : `echo "Error: download failed from ${tarballUrl}" >&2
232
+ exit 1`}
233
+ fi
234
+
235
+ mkdir -p "${extractDir}"
236
+ tar -xzf "$TEMP_DIR/${tarballName}" -C "${extractDir}"
237
+ chmod +x "${extractDir}/nolo"
238
+
239
+ mkdir -p "${installDir}"
240
+ if [ -e "${symlinkPath}" ] || [ -L "${symlinkPath}" ]; then
241
+ rm -f "${symlinkPath}"
242
+ fi
243
+ ln -s "${extractDir}/nolo" "${symlinkPath}"
244
+ trap - EXIT
245
+
246
+ echo "nolo updated to ${installDir}/nolo"
247
+ `;
248
+ output.write(`
249
+ Nolo Agent CLI Installer & Updater
250
+ `);
251
+ output.write(`-----------------------------------------
252
+ `);
253
+ output.write(`\u2713 Target channel: ${channel} (standalone bundle)
254
+ `);
255
+ output.write(`\u25B8 Downloading and installing bundle...
256
+ `);
257
+ const useCustomSink = options.output !== void 0;
258
+ const exitCode = await runShellScript(script, {
259
+ output,
260
+ spawn,
261
+ env,
262
+ useCustomSink
263
+ });
264
+ if (exitCode === 0) {
265
+ output.write(` ${renderProgressBar(100)}
266
+ `);
267
+ output.write(`\u2713 Update completed successfully!
268
+
269
+ `);
270
+ }
271
+ return exitCode;
272
+ }
137
273
  async function runSelfUpdate(outputOrOptions) {
138
274
  const options = outputOrOptions === void 0 ? {} : isRunSelfUpdateOptions(outputOrOptions) ? outputOrOptions : { output: outputOrOptions };
275
+ if (isCompiledBinary()) {
276
+ return runStandaloneBundleUpdate(options);
277
+ }
139
278
  const output = options.output ?? process.stdout;
140
279
  const spawn = options.spawn ?? resolveDefaultSpawn();
141
280
  const env = options.env ?? process.env;
@@ -189,10 +328,14 @@ export {
189
328
  getCliInstallChannel,
190
329
  renderProgressBar,
191
330
  buildNpmSelfUpdateCommand,
331
+ resolveStandaloneBundlePlatform,
332
+ resolveStandaloneBundleRepoBase,
333
+ buildStandaloneManualUpdateHint,
192
334
  readPackageInfo,
193
335
  buildCliVersionText,
194
336
  buildSelfUpdateCommand,
195
337
  resolveSelfUpdateServerUrl,
196
338
  buildCliDoctorText,
339
+ runStandaloneBundleUpdate,
197
340
  runSelfUpdate
198
341
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  fetchReferenceContents,
3
3
  resolveReferenceAssets
4
- } from "./chunk-EVZKZF32.js";
4
+ } from "./chunk-5V524MHX.js";
5
5
 
6
6
  // packages/ai/agent/fetchAgentContexts.ts
7
7
  async function fetchAgentContexts(references, dispatch) {