nolo-cli 0.10.0 → 0.12.0-alpha.1

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 (125) hide show
  1. package/{_executeModel-YAXYAUOK.js → _executeModel-MWAY74HA.js} +47 -44
  2. package/{action-TLI3V62L.js → action-RAXNQQKC.js} +9 -10
  3. package/{addContentAction-PLWJSCOZ.js → addContentAction-ZHI7TVV3.js} +8 -10
  4. package/{addDialogAgentAction-BJ6SB76X.js → addDialogAgentAction-JWXPKXNC.js} +7 -8
  5. package/{agentDeleteCommand-2VYX73U5.js → agentDeleteCommand-LXR5A5FV.js} +36 -26
  6. package/{agentEmailCommands-3GDZIX64.js → agentEmailCommands-DXRAP7BB.js} +63 -58
  7. package/{agentListCommands-UWVBT3LH.js → agentListCommands-ZFMS5ZLY.js} +132 -35
  8. package/{agentMachineCommands-WOKMUG2Y.js → agentMachineCommands-ZJLYVV52.js} +40 -29
  9. package/{agentPullCommand-O2MTUAFR.js → agentPullCommand-KRBRIFIY.js} +6 -6
  10. package/{agentRecordCommands-MVNZRH3U.js → agentRecordCommands-DFS626TB.js} +55 -50
  11. package/{agentRunCommand-K7THIJLA.js → agentRunCommand-GWBIE2TS.js} +60 -56
  12. package/{agentRunControl-K4VKNEHF.js → agentRunControl-IX4F5W2C.js} +3 -3
  13. package/{agentRuntimeLocal-WJIGU24U.js → agentRuntimeLocal-YNZSHMZC.js} +29 -14
  14. package/{agentSlice-LL5TKZEO.js → agentSlice-T2PXOEPQ.js} +9 -10
  15. package/{authCommand-TC2SW2CQ.js → authCommand-DMW336GT.js} +13 -13
  16. package/{authCommands-XPEHTKSM.js → authCommands-GH5T6RYV.js} +6 -6
  17. package/{chunk-5JGGZCZL.js → chunk-3HHTVM6G.js} +64 -5
  18. package/chunk-3QKO4EHV.js +112 -0
  19. package/{chunk-AUQ747NZ.js → chunk-43UD5ZP7.js} +76 -15
  20. package/{chunk-6SLCD4RB.js → chunk-4BTHUYMY.js} +596 -67
  21. package/{chunk-T7R3NGUU.js → chunk-4EH7AR52.js} +13 -13
  22. package/{chunk-C3RUNRHT.js → chunk-4GBNEA5B.js} +1 -1
  23. package/{chunk-4IJYA27C.js → chunk-4LG74DRG.js} +1 -1
  24. package/{chunk-2FTTDCD4.js → chunk-4ON5AV72.js} +2 -1
  25. package/{chunk-IWX4UW2E.js → chunk-524BDL33.js} +89 -8
  26. package/{chunk-EXXFGKF7.js → chunk-5ITRDSHY.js} +1400 -119
  27. package/{chunk-ISNCLGUZ.js → chunk-5NBHQD4D.js} +4 -3
  28. package/{chunk-7KNKFIRO.js → chunk-6LMFFG3K.js} +3 -3
  29. package/{chunk-PAKN26FP.js → chunk-6OVCRC72.js} +1 -1
  30. package/{chunk-CKOJQDKR.js → chunk-7JJCGV7N.js} +146 -3
  31. package/{chunk-KBKYAONQ.js → chunk-7MYHLZ3F.js} +2 -2
  32. package/{chunk-PIVFPOW6.js → chunk-AM53Q2SD.js} +175 -2541
  33. package/chunk-BYXBJQAS.js +0 -0
  34. package/{chunk-CL3IOKGK.js → chunk-DE5BA4O6.js} +20 -2
  35. package/{chunk-6KUOUWMP.js → chunk-DRMGJFGQ.js} +300 -89
  36. package/{chunk-QAALPJS7.js → chunk-EBH7G34M.js} +20 -7
  37. package/{chunk-HJGEVL7C.js → chunk-G3B356GF.js} +15 -17
  38. package/{chunk-OZMMKDBI.js → chunk-GDBCUWQ3.js} +26 -20
  39. package/{chunk-I5URP43I.js → chunk-GPZM7QH6.js} +9 -9
  40. package/chunk-IKXL2HZ3.js +70 -0
  41. package/{chunk-AS4PVWA4.js → chunk-IVAOVLM7.js} +1 -1
  42. package/{chunk-TNPIMII7.js → chunk-JUN3HFMN.js} +221 -81
  43. package/{chunk-HFASY3WO.js → chunk-JZDIW766.js} +1 -1
  44. package/{chunk-6JJWFVZ6.js → chunk-LHSJMY5V.js} +17 -17
  45. package/chunk-LTRXGFMS.js +83 -0
  46. package/{chunk-YIHFXH5Q.js → chunk-MEVCDATU.js} +3 -3
  47. package/{chunk-TILFE6LV.js → chunk-NCGFB7NN.js} +5 -3
  48. package/{chunk-BE2OOJ5P.js → chunk-NITP2JDG.js} +42 -11
  49. package/{chunk-YPRZSPF3.js → chunk-OCDEWRE2.js} +1 -1
  50. package/{chunk-VVX233PH.js → chunk-OHEKYYJF.js} +9 -9
  51. package/chunk-OOIN7HSO.js +146 -0
  52. package/{chunk-WPE4F4Z6.js → chunk-OPKKB25T.js} +1 -1
  53. package/{chunk-OR2XR25C.js → chunk-QCA3EPYK.js} +8 -8
  54. package/{chunk-SL35K7AH.js → chunk-QLUFR47U.js} +13 -83
  55. package/{chunk-CDTLMEB3.js → chunk-RNQ5BLR2.js} +1 -1
  56. package/{chunk-AVMKZHBC.js → chunk-RSEUHW6T.js} +3 -2
  57. package/{chunk-TYSCFY6S.js → chunk-RZ735TLX.js} +762 -167
  58. package/chunk-S3UTETIC.js +4885 -0
  59. package/chunk-S73OEOHH.js +2286 -0
  60. package/{chunk-JRKKFRAV.js → chunk-TSKWE74T.js} +58 -8
  61. package/{chunk-A67QFHAA.js → chunk-UG3WOFU6.js} +1 -1
  62. package/{chunk-4ZDM73SD.js → chunk-V2J635L5.js} +1 -1
  63. package/chunk-VC6OZXO5.js +298 -0
  64. package/{chunk-7U44LYTR.js → chunk-WPHL6ALY.js} +1 -1
  65. package/{chunk-4SIMLBEU.js → chunk-WTYKCU4W.js} +9 -9
  66. package/{chunk-NPVBXJY2.js → chunk-WWU275LU.js} +9 -9
  67. package/{chunk-ZQ2UM4KG.js → chunk-WZSRQNQG.js} +1 -292
  68. package/{chunk-DSZUWUYB.js → chunk-XHQWJUW4.js} +2 -2
  69. package/{chunk-GAKEBQD6.js → chunk-YDCZVUFP.js} +4 -0
  70. package/{chunk-2O4IZNTG.js → chunk-YTQLJYLB.js} +2 -2
  71. package/{chunk-3Y3HW5PX.js → chunk-ZPFRLGIZ.js} +1512 -935
  72. package/{chunk-5KLGBAAR.js → chunk-ZR4VHQ5D.js} +14 -13
  73. package/cliEnvHelpers-VYC2OPTB.js +30 -0
  74. package/{cliExecutor-DNE7TCC4.js → cliExecutor-K3F7DMRO.js} +2 -2
  75. package/{createAgentAutomationAction-CCE7CWGQ.js → createAgentAutomationAction-G32GKDGV.js} +22 -23
  76. package/{createDialogAction-QTRR4AT7.js → createDialogAction-TISANRZK.js} +25 -25
  77. package/{createPageAction-Y4KQOAJE.js → createPageAction-O7KOYNV4.js} +27 -27
  78. package/{dbSlice-WWNV2SGX.js → dbSlice-WDP2ZZHK.js} +7 -8
  79. package/{deleteFile-OW53A6BX.js → deleteFile-M7UNIUOO.js} +5 -5
  80. package/{dialogCommands-SMKIAC3Y.js → dialogCommands-6JPB3YQY.js} +33 -23
  81. package/{dialogSlice-PT7YBWNE.js → dialogSlice-PRHHYSP5.js} +21 -22
  82. package/{docCreateCommands-RFNA4HNM.js → docCreateCommands-75E6TZNN.js} +36 -25
  83. package/{docDeleteCommands-4YZ325M6.js → docDeleteCommands-EJHLN7LW.js} +37 -27
  84. package/{docReadCommands-RT6VAFFG.js → docReadCommands-RJYBC4FS.js} +36 -25
  85. package/{docStore-QUQZAFZF.js → docStore-H5VWKT5D.js} +22 -23
  86. package/{docUpdateCommands-EKKKNYPW.js → docUpdateCommands-MG4CNISV.js} +36 -25
  87. package/fetchMessages-KTNM7QAR.js +1 -1
  88. package/{getPricing-3E6UNPKL.js → getPricing-6TOZXPAU.js} +7 -3
  89. package/{handleSendMessageAction-5NSYAS53.js → handleSendMessageAction-QTUGICSZ.js} +22 -23
  90. package/index.js +77 -76
  91. package/{machineCommands-DOOSIUKG.js → machineCommands-MAV7M3TK.js} +67 -60
  92. package/{machineWsRunDispatch-PIOIQRBW.js → machineWsRunDispatch-ZOEGTKHC.js} +54 -49
  93. package/{memoryCommands-O4MIPIWQ.js → memoryCommands-AFMES3LN.js} +5 -5
  94. package/{models-4OPOOLFS.js → models-LSCRJJ6P.js} +2 -2
  95. package/package.json +1 -1
  96. package/{read-GW7ZEI23.js → read-2MIMRBZ2.js} +5 -5
  97. package/{readDocTool-HUFU6OCT.js → readDocTool-QHVGQHUJ.js} +1 -1
  98. package/{readlineWorkspace-QEAOH5EP.js → readlineWorkspace-SWQKC7ZS.js} +1126 -678
  99. package/{removeDialogAgentAction-OHMCNSSD.js → removeDialogAgentAction-GTX5AN54.js} +11 -11
  100. package/{runAgentClientLoop-AIGLXC3R.js → runAgentClientLoop-P25HACXX.js} +42 -40
  101. package/{runtimeDoctorCommands-LRHLPDRC.js → runtimeDoctorCommands-QNF3J3UV.js} +6 -6
  102. package/{setDialogExtraReferencesAction-YJUM5BWQ.js → setDialogExtraReferencesAction-WFQ63KYO.js} +7 -8
  103. package/{setPrimaryDialogAgentAction-EBAREZDM.js → setPrimaryDialogAgentAction-P57FXTSU.js} +11 -11
  104. package/{settingSlice-UW4IUI5L.js → settingSlice-CK5YZGNI.js} +8 -9
  105. package/skillDiscovery-ZYHSX7VD.js +16 -0
  106. package/{spaceCommands-BKHSPR73.js → spaceCommands-6O5EFEM5.js} +41 -33
  107. package/{spaceSlice-TYNWE3OC.js → spaceSlice-4EXTYXS4.js} +25 -24
  108. package/{streamAgentChatTurn-HRMFFA7E.js → streamAgentChatTurn-Q3FJAHG2.js} +205 -107
  109. package/{tableCommands-O7O2LBEG.js → tableCommands-E4SQWDOX.js} +10 -10
  110. package/{tools-3JNDS3WH.js → tools-AHNQE4GP.js} +33 -31
  111. package/{tuiSummaryLlmCaller-RV3THLZF.js → tuiSummaryLlmCaller-TXLF4MEI.js} +8 -6
  112. package/{updateCommands-VOSPKXFF.js → updateCommands-XZDOOYFH.js} +13 -5
  113. package/{updateDialogTitleAction-OCETSKCP.js → updateDialogTitleAction-XZDVLKVX.js} +25 -25
  114. package/chunk-5MMAK75Q.js +0 -15
  115. package/chunk-AZPCASRE.js +0 -36
  116. package/chunk-BBYVOSU2.js +0 -792
  117. package/chunk-DCOA4QSN.js +0 -105
  118. package/chunk-UAD2WT54.js +0 -64
  119. package/{chunk-DZ3XJVET.js → chunk-3QAF2LTL.js} +3 -3
  120. package/{chunk-X7W4TNB4.js → chunk-CMKUBIGW.js} +3 -3
  121. package/{chunk-4CQLVGRV.js → chunk-ID4G2MAR.js} +3 -3
  122. package/{chunk-5CS33IBL.js → chunk-PDL2AV3E.js} +3 -3
  123. package/{chunk-EHLHSX7R.js → chunk-TOILAPLH.js} +3 -3
  124. package/{chunk-UTLZINAP.js → chunk-TSUJOM6N.js} +10 -10
  125. package/{offlineMarxistsAgentCommand-BCPJITJL.js → offlineMarxistsAgentCommand-5OOWZLJI.js} +3 -3
@@ -1,75 +1,82 @@
1
- import {
2
- MEMORY_USE_GUIDANCE,
3
- wrapHistoricalSummaryWithReplayGuard
4
- } from "./chunk-KKY4B2Q2.js";
5
1
  import {
6
2
  ANTIGRAVITY_CLOUD_CODE_BASE_URL,
7
3
  isAntigravityOAuthAgent
8
- } from "./chunk-C3RUNRHT.js";
4
+ } from "./chunk-4GBNEA5B.js";
9
5
  import {
10
6
  clipMultilineText,
11
- fetchAndSerializeTable
12
- } from "./chunk-TYSCFY6S.js";
7
+ fetchAndSerializeTable,
8
+ waitForAbortableDelay
9
+ } from "./chunk-RZ735TLX.js";
13
10
  import {
11
+ CORE_DRAIN_REASON,
12
+ isGatewayHttpStatus,
14
13
  normalizeNonNegativeMs,
15
14
  parseRetryAfterHeaderMs
16
- } from "./chunk-GAKEBQD6.js";
15
+ } from "./chunk-YDCZVUFP.js";
17
16
  import {
18
17
  slateToSimplifiedMarkdown
19
- } from "./chunk-AS4PVWA4.js";
18
+ } from "./chunk-IVAOVLM7.js";
20
19
  import {
21
20
  extractCategorizedMentions
22
21
  } from "./chunk-VP4WJWKW.js";
23
22
  import {
24
23
  resolvePageSkillMetadata
25
- } from "./chunk-ZQ2UM4KG.js";
24
+ } from "./chunk-VC6OZXO5.js";
26
25
  import {
27
- estimateTokenCount,
28
26
  fetchAndCacheMessages,
29
27
  shouldUseServerProxy
30
- } from "./chunk-PIVFPOW6.js";
28
+ } from "./chunk-AM53Q2SD.js";
31
29
  import {
32
30
  fetchServerSyncedCredential
33
- } from "./chunk-I5URP43I.js";
34
- import {
35
- createSpaceKey
36
- } from "./chunk-UAD2WT54.js";
31
+ } from "./chunk-GPZM7QH6.js";
37
32
  import {
38
33
  buildCurrentTimeBlock,
39
34
  buildIdentityBlock,
40
35
  buildRuntimeGuidanceBlocks
41
- } from "./chunk-PAKN26FP.js";
36
+ } from "./chunk-6OVCRC72.js";
42
37
  import {
43
- OPENAI_RESPONSES_ENDPOINT,
44
38
  buildProviderAuthHeaders,
45
39
  convertMessagesToResponsesInput,
46
40
  isOpenAiResponsesModel,
47
- resolvePlatformChatCompletionsEndpoint
48
- } from "./chunk-JRKKFRAV.js";
41
+ preserveAgentStateFields,
42
+ resolvePlatformChatCompletionsEndpoint,
43
+ resolvePlatformResponsesEndpoint
44
+ } from "./chunk-TSKWE74T.js";
49
45
  import {
50
46
  canonicalizeToolNames
51
- } from "./chunk-AUQ747NZ.js";
47
+ } from "./chunk-43UD5ZP7.js";
48
+ import {
49
+ estimateTokenCount
50
+ } from "./chunk-S73OEOHH.js";
52
51
  import {
52
+ clampReasoningEffort,
53
53
  getModelConfig,
54
54
  isModelSupportReasoningEffort
55
- } from "./chunk-BBYVOSU2.js";
55
+ } from "./chunk-S3UTETIC.js";
56
56
  import {
57
57
  createFileCredentialBroker
58
- } from "./chunk-5CS33IBL.js";
58
+ } from "./chunk-PDL2AV3E.js";
59
59
  import {
60
- isDeepInfraKimiModel,
61
- isFireworksKimiModel,
62
- resolveFireworksKimiModel
63
- } from "./chunk-IWX4UW2E.js";
60
+ MEMORY_USE_GUIDANCE,
61
+ wrapHistoricalSummaryWithReplayGuard
62
+ } from "./chunk-KKY4B2Q2.js";
64
63
  import {
65
64
  extractCustomId
66
65
  } from "./chunk-DFFIZ25G.js";
67
66
  import {
68
67
  toErrorMessage
69
68
  } from "./chunk-HNMXYYJR.js";
69
+ import {
70
+ isDeepInfraKimiModel,
71
+ isFireworksKimiModel,
72
+ resolveFireworksKimiModel
73
+ } from "./chunk-524BDL33.js";
74
+ import {
75
+ createSpaceKey
76
+ } from "./chunk-3HHTVM6G.js";
70
77
  import {
71
78
  read
72
- } from "./chunk-BE2OOJ5P.js";
79
+ } from "./chunk-NITP2JDG.js";
73
80
  import {
74
81
  asNonEmptyStringArray
75
82
  } from "./chunk-I42VC5KR.js";
@@ -78,19 +85,19 @@ import {
78
85
  } from "./chunk-QSJ3HFEF.js";
79
86
  import {
80
87
  getRuntimeServerContext
81
- } from "./chunk-UTLZINAP.js";
88
+ } from "./chunk-TSUJOM6N.js";
82
89
  import {
83
90
  isAbortError
84
91
  } from "./chunk-OOSFSFMA.js";
85
92
  import {
86
- isLoopbackUrl
87
- } from "./chunk-4SN6J65J.js";
93
+ asTrimmedString
94
+ } from "./chunk-3EUW3WEO.js";
88
95
  import {
89
96
  API_ENDPOINTS
90
97
  } from "./chunk-LCBAMY2M.js";
91
98
  import {
92
- asTrimmedString
93
- } from "./chunk-3EUW3WEO.js";
99
+ isLoopbackUrl
100
+ } from "./chunk-4SN6J65J.js";
94
101
  import {
95
102
  asOptionalTrimmedString
96
103
  } from "./chunk-G3SUCT4W.js";
@@ -406,6 +413,45 @@ var resolveToolsFromKeys = async (keys, dispatch, preloaded) => {
406
413
  };
407
414
  };
408
415
 
416
+ // packages/agent-runtime/responsesConversationState.ts
417
+ function supportsResponsesConversationState(agent) {
418
+ return normalizeIdentityPart(agent.provider) === "openai";
419
+ }
420
+ var normalizeIdentityPart = (value) => typeof value === "string" ? value.trim().toLowerCase() : "";
421
+ function normalizeResponsesConversationState(value) {
422
+ if (!value || typeof value !== "object") return null;
423
+ const raw = value;
424
+ const provider = normalizeIdentityPart(raw.provider);
425
+ const model = normalizeIdentityPart(raw.model);
426
+ const responseId = typeof raw.responseId === "string" ? raw.responseId.trim() : "";
427
+ if (!provider || !model || !responseId) return null;
428
+ return { provider, model, responseId };
429
+ }
430
+ function selectResponsesConversationState(value, agent) {
431
+ if (!supportsResponsesConversationState(agent)) return null;
432
+ const state = normalizeResponsesConversationState(value);
433
+ if (!state) return null;
434
+ if (state.provider !== normalizeIdentityPart(agent.provider)) return null;
435
+ if (state.model !== normalizeIdentityPart(agent.model)) return null;
436
+ return state;
437
+ }
438
+ function updateResponsesConversationState(agent, responseId) {
439
+ if (!supportsResponsesConversationState(agent)) return null;
440
+ const provider = normalizeIdentityPart(agent.provider);
441
+ const model = normalizeIdentityPart(agent.model);
442
+ const normalizedResponseId = typeof responseId === "string" ? responseId.trim() : "";
443
+ if (!provider || !model || !normalizedResponseId) return null;
444
+ return { provider, model, responseId: normalizedResponseId };
445
+ }
446
+ function isResponsesConversationStateRejection(status, responseBody) {
447
+ if (![400, 404, 409].includes(status)) return false;
448
+ const text = typeof responseBody === "string" ? responseBody.trim().toLowerCase() : "";
449
+ if (!text) return false;
450
+ const mentionsResponseState = /previous[\s_-]*response/.test(text) || /response[\s_-]*(?:id|state)/.test(text);
451
+ const rejectsState = /not[\s_-]*found/.test(text) || /does not exist/.test(text) || /invalid/.test(text) || /expired/.test(text) || /unknown/.test(text);
452
+ return mentionsResponseState && rejectsState;
453
+ }
454
+
409
455
  // packages/agent-runtime/agentCallPlan.ts
410
456
  var CODEX_RESPONSES_URL = "https://chatgpt.com/backend-api/codex/responses";
411
457
  var CURSOR_AGENT_URL = "https://api2.cursor.sh/agent.v1.AgentService/Run";
@@ -521,7 +567,7 @@ function resolveAgentCallPlan(agentConfig, _env) {
521
567
  endpointKey: agentConfig.endpointKey
522
568
  });
523
569
  const upstreamWire = useResponses ? "responses" : "chat.completions";
524
- const endpoint = useResponses ? OPENAI_RESPONSES_ENDPOINT : resolvePlatformChatCompletionsEndpoint(provider) ?? "";
570
+ const endpoint = useResponses ? resolvePlatformResponsesEndpoint(provider) ?? "" : resolvePlatformChatCompletionsEndpoint(provider) ?? "";
525
571
  return {
526
572
  authMethod: { kind: "platform-key" },
527
573
  transport,
@@ -660,7 +706,7 @@ function createHash(_algo) {
660
706
  };
661
707
  }
662
708
  var hasLayerContent = (layer) => Boolean(layer.content);
663
- var estimateContextTokens = (content) => Math.ceil(content.length / 4);
709
+ var estimateContextTokens = (content) => estimateTokenCount(content);
664
710
  var compileContextLayers = (layers) => {
665
711
  const compiledLayers = [];
666
712
  for (const layer of layers) {
@@ -707,6 +753,24 @@ var CONTEXT_USAGE_INSTRUCTIONS = `\u53C2\u8003\u8D44\u6599\u4F7F\u7528\u8BF4\u66
707
753
  - \u5982\u679C\u8D44\u6599\u4E2D\u6CA1\u6709\u5305\u542B\u7B54\u6848\uFF0C\u5E94\u8BF4\u660E\u8FD9\u4E00\u70B9\uFF0C\u7136\u540E\u518D\u4F7F\u7528\u4F60\u7684\u901A\u7528\u77E5\u8BC6\u8FDB\u884C\u56DE\u7B54\u3002
708
754
  - \u5982\u679C\u4F60\u5728\u8D44\u6599\u4E2D\u53D1\u73B0\u76F8\u4E92\u77DB\u76FE\u7684\u4FE1\u606F\uFF0C\u4E5F\u8981\u5728\u56DE\u7B54\u4E2D\u6307\u51FA\u8FD9\u4E00\u70B9\u3002
709
755
  - \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`;
756
+ var AGENT_ORCHESTRATION_RUN_INSTRUCTIONS = `--- \u591A Agent \u7F16\u6392\uFF08\u540E\u53F0 Run\uFF09 ---
757
+ \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
758
+ 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
759
+ - \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
760
+ - \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
761
+ - \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
762
+ 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
763
+ 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
764
+ 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
765
+ 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
766
+ 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
767
+ \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`;
768
+ var AGENT_COLLABORATION_INSTRUCTIONS = `--- \u591A Agent \u534F\u4F5C\uFF08\u8BA1\u5212 \u2192 \u6D3E\u53D1 \u2192 \u5BA1\u67E5\uFF09 ---
769
+ \u7528\u5B50\u4EE3\u7406\u5B8C\u6210\u4E2D\u5927\u578B\u4EFB\u52A1\u65F6\uFF0C\u6309\u4E09\u6BB5\u7EAA\u5F8B\u6267\u884C\uFF1A
770
+ 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
771
+ 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
772
+ 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
773
+ \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`;
710
774
  var MENU_USAGE_INSTRUCTIONS = `--- \u4EA4\u4E92\u8BF4\u660E ---
711
775
  \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
712
776
 
@@ -797,12 +861,28 @@ var isBrowser = typeof window !== "undefined";
797
861
  var TOOL_GUIDED_SECTIONS = [
798
862
  {
799
863
  id: "agentOrchestration",
800
- triggerTools: ["callAgent", "runStreamingAgent"],
864
+ triggerTools: [
865
+ "callAgent",
866
+ "runStreamingAgent",
867
+ "startAgentRun",
868
+ "controlAgentRun"
869
+ ],
801
870
  build: (tools) => [
802
871
  AGENT_ORCHESTRATION_INSTRUCTIONS,
803
- tools.includes("runStreamingAgent") ? PAGE_BUILDER_HANDOFF_INSTRUCTIONS : ""
872
+ tools.includes("runStreamingAgent") ? PAGE_BUILDER_HANDOFF_INSTRUCTIONS : "",
873
+ tools.includes("startAgentRun") || tools.includes("controlAgentRun") ? AGENT_ORCHESTRATION_RUN_INSTRUCTIONS : ""
804
874
  ].filter(Boolean).join("\n\n")
805
875
  },
876
+ {
877
+ id: "agentCollaboration",
878
+ triggerTools: [
879
+ "callAgent",
880
+ "runStreamingAgent",
881
+ "startAgentRun",
882
+ "controlAgentRun"
883
+ ],
884
+ build: () => AGENT_COLLABORATION_INSTRUCTIONS
885
+ },
806
886
  { id: "menuUsage", triggerTools: ["ui_ask_choice"], build: () => MENU_USAGE_INSTRUCTIONS },
807
887
  {
808
888
  id: "webAccess",
@@ -979,6 +1059,7 @@ ${wrapHistoricalSummaryWithReplayGuard(contexts.dialogSummary)}` : "";
979
1059
  { id: "startup-protocol", owner: "platform", cacheScope: "static", content: startupProtocol },
980
1060
  { id: "core-persona", owner: "agent", cacheScope: "session", content: corePersonaSection },
981
1061
  { id: "agent-orchestration", owner: "platform", cacheScope: "session", content: toolSections.agentOrchestration },
1062
+ { id: "agent-collaboration", owner: "platform", cacheScope: "session", content: toolSections.agentCollaboration },
982
1063
  { id: "web-access", owner: "platform", cacheScope: "session", content: toolSections.webAccess },
983
1064
  { id: "menu-usage", owner: "platform", cacheScope: "session", content: toolSections.menuUsage },
984
1065
  { id: "clarification-mode", owner: "platform", cacheScope: "session", content: clarifyingSection },
@@ -1019,6 +1100,8 @@ ${wrapHistoricalSummaryWithReplayGuard(contexts.dialogSummary)}` : "";
1019
1100
  };
1020
1101
 
1021
1102
  // packages/integrations/openai/providerBodyCompatibility.ts
1103
+ var MOONSHOT_KIMI_K3_MODEL = "kimi-k3";
1104
+ var isMoonshotKimiK3 = (provider, model) => asTrimmedLowercaseString(provider) === "moonshot" && asTrimmedLowercaseString(model) === MOONSHOT_KIMI_K3_MODEL;
1022
1105
  var normalizeChatCompletionsBodyForProvider = ({
1023
1106
  body,
1024
1107
  provider,
@@ -1030,6 +1113,16 @@ var normalizeChatCompletionsBodyForProvider = ({
1030
1113
  delete nextBody.reasoning;
1031
1114
  delete nextBody.reasoning_effort;
1032
1115
  }
1116
+ if (isMoonshotKimiK3(provider, model)) {
1117
+ delete nextBody.temperature;
1118
+ delete nextBody.top_p;
1119
+ delete nextBody.frequency_penalty;
1120
+ delete nextBody.presence_penalty;
1121
+ if (typeof nextBody.max_tokens === "number") {
1122
+ nextBody.max_completion_tokens = nextBody.max_tokens;
1123
+ delete nextBody.max_tokens;
1124
+ }
1125
+ }
1033
1126
  return nextBody;
1034
1127
  };
1035
1128
 
@@ -1094,15 +1187,7 @@ var sanitizeChatCompletionsMessage = (message) => {
1094
1187
  };
1095
1188
  const name = asOptionalTrimmedString(message.name);
1096
1189
  if (name) sanitized.name = name;
1097
- const toolCallId = asOptionalTrimmedString(message.tool_call_id);
1098
- if (toolCallId) sanitized.tool_call_id = toolCallId;
1099
- if (Array.isArray(message.tool_calls)) {
1100
- sanitized.tool_calls = message.tool_calls;
1101
- }
1102
- if (message.role === "assistant" && typeof message.reasoning_content === "string" && message.reasoning_content) {
1103
- sanitized.reasoning_content = message.reasoning_content;
1104
- }
1105
- return sanitized;
1190
+ return preserveAgentStateFields(message, sanitized);
1106
1191
  };
1107
1192
  var buildRequestBody = (options) => {
1108
1193
  const {
@@ -1129,7 +1214,10 @@ var buildRequestBody = (options) => {
1129
1214
  });
1130
1215
  Object.assign(bodyData, usageRequestOptions);
1131
1216
  if (reasoning_effort && isModelSupportReasoningEffort(model)) {
1132
- bodyData.reasoning_effort = reasoning_effort;
1217
+ const clamped = clampReasoningEffort(reasoning_effort, providerName);
1218
+ if (clamped) {
1219
+ bodyData.reasoning_effort = clamped;
1220
+ }
1133
1221
  }
1134
1222
  if (typeof temperature === "number") bodyData.temperature = temperature;
1135
1223
  if (typeof top_p === "number") bodyData.top_p = top_p;
@@ -1205,9 +1293,32 @@ var generateOpenAIRequestBody = (agentConfig, providerName, messages, contexts,
1205
1293
  };
1206
1294
 
1207
1295
  // packages/integrations/openai/generateResponseRequestBody.ts
1208
- function generateResponseRequestBody(agentConfig, msgs, contexts, prependSystemPrompt = true) {
1296
+ var DEFAULT_RESPONSES_COMPACTION_THRESHOLD = 2e5;
1297
+ function resolveResponsesCompactionThreshold(agentConfig) {
1298
+ const configured = Number(
1299
+ agentConfig.responsesCompactionThreshold ?? agentConfig.responses_compaction_threshold
1300
+ );
1301
+ return Number.isFinite(configured) && configured > 0 ? Math.floor(configured) : DEFAULT_RESPONSES_COMPACTION_THRESHOLD;
1302
+ }
1303
+ function selectResponsesContinuationMessages(msgs) {
1304
+ let lastAssistantIndex = -1;
1305
+ for (let index = msgs.length - 1; index >= 0; index -= 1) {
1306
+ if (msgs[index]?.role === "assistant") {
1307
+ lastAssistantIndex = index;
1308
+ break;
1309
+ }
1310
+ }
1311
+ const candidates = lastAssistantIndex >= 0 ? msgs.slice(lastAssistantIndex + 1) : msgs;
1312
+ return candidates.filter((message) => message.role !== "system");
1313
+ }
1314
+ function generateResponseRequestBody(agentConfig, msgs, contexts, prependSystemPrompt = true, responsesState) {
1209
1315
  const language = typeof navigator !== "undefined" && navigator.language ? navigator.language : "zh-CN";
1210
- const input = convertMessagesToResponsesInput(msgs);
1316
+ const state = responsesState !== void 0 ? responsesState : selectResponsesConversationState(agentConfig.responsesState, agentConfig);
1317
+ const supportsServerState = supportsResponsesConversationState(agentConfig);
1318
+ const stateful = supportsServerState && state && agentConfig.store !== false ? state : null;
1319
+ const input = convertMessagesToResponsesInput(
1320
+ stateful ? selectResponsesContinuationMessages(msgs) : msgs
1321
+ );
1211
1322
  const body = {
1212
1323
  model: agentConfig.model,
1213
1324
  input,
@@ -1243,6 +1354,25 @@ function generateResponseRequestBody(agentConfig, msgs, contexts, prependSystemP
1243
1354
  if (agentConfig.metadata !== void 0) {
1244
1355
  body.metadata = agentConfig.metadata;
1245
1356
  }
1357
+ if (stateful) {
1358
+ body.previous_response_id = stateful.responseId;
1359
+ if (agentConfig.context_management === void 0) {
1360
+ body.context_management = [
1361
+ {
1362
+ type: "compaction",
1363
+ compact_threshold: resolveResponsesCompactionThreshold(agentConfig)
1364
+ }
1365
+ ];
1366
+ }
1367
+ } else if (supportsServerState && responsesState === void 0 && agentConfig.previous_response_id !== void 0) {
1368
+ body.previous_response_id = agentConfig.previous_response_id;
1369
+ }
1370
+ if (supportsServerState && agentConfig.store !== void 0) {
1371
+ body.store = agentConfig.store;
1372
+ }
1373
+ if (supportsServerState && agentConfig.context_management !== void 0) {
1374
+ body.context_management = agentConfig.context_management;
1375
+ }
1246
1376
  return body;
1247
1377
  }
1248
1378
 
@@ -1317,7 +1447,8 @@ var generateRequestBody = ({
1317
1447
  messages,
1318
1448
  contexts,
1319
1449
  stableMessages,
1320
- prependSystemPrompt = true
1450
+ prependSystemPrompt = true,
1451
+ responsesState
1321
1452
  }) => {
1322
1453
  const provider = (agentConfig.provider || "").toLowerCase();
1323
1454
  const imageSettings = getImageOutputSettings(agentConfig, provider);
@@ -1333,7 +1464,8 @@ var generateRequestBody = ({
1333
1464
  agentConfigForRequest,
1334
1465
  [...stableMessages ?? [], ...messages],
1335
1466
  contexts,
1336
- prependSystemPrompt
1467
+ prependSystemPrompt,
1468
+ responsesState
1337
1469
  );
1338
1470
  }
1339
1471
  const baseBody = generateOpenAIRequestBody(
@@ -1348,11 +1480,21 @@ var generateRequestBody = ({
1348
1480
  };
1349
1481
 
1350
1482
  // packages/ai/chat/serverProxyRetry.ts
1351
- var RETRYABLE_SERVER_PROXY_STATUSES = /* @__PURE__ */ new Set([502, 503, 504]);
1352
1483
  var DEFAULT_SERVER_PROXY_RETRY_AFTER_MS = 1500;
1353
1484
  var MAX_SERVER_PROXY_RETRIES = 2;
1354
1485
  var MAX_STATUS_RETRIES = 1;
1355
- var resolveServerProxyRetryAfterMs = (response) => parseRetryAfterHeaderMs(response.headers.get("Retry-After")) ?? DEFAULT_SERVER_PROXY_RETRY_AFTER_MS;
1486
+ var MAX_SERVER_DRAIN_STATUS_RETRIES = 30;
1487
+ var readRetryableResponseBody = async (response) => {
1488
+ try {
1489
+ return await response.clone().json();
1490
+ } catch {
1491
+ return null;
1492
+ }
1493
+ };
1494
+ var resolveServerProxyRetryAfterMs = (response, body) => parseRetryAfterHeaderMs(response.headers.get("Retry-After")) ?? normalizeNonNegativeMs(
1495
+ body?.retryAfterMs,
1496
+ DEFAULT_SERVER_PROXY_RETRY_AFTER_MS
1497
+ );
1356
1498
  var isRetryableServerProxyFetchError = (error) => {
1357
1499
  if (!error || isAbortError(error)) return false;
1358
1500
  const message = typeof error?.message === "string" ? error.message : String(error);
@@ -1361,49 +1503,45 @@ var isRetryableServerProxyFetchError = (error) => {
1361
1503
  );
1362
1504
  };
1363
1505
  var waitForServerProxyRetry = async (retryAfterMs, signal) => {
1364
- if (retryAfterMs <= 0) return;
1365
- if (signal?.aborted) {
1366
- const abortError = new Error("Aborted");
1367
- abortError.name = "AbortError";
1368
- throw abortError;
1369
- }
1370
- await new Promise((resolve, reject) => {
1371
- const onAbort = () => {
1372
- clearTimeout(timeoutId);
1373
- signal?.removeEventListener("abort", onAbort);
1374
- const abortError = new Error("Aborted");
1375
- abortError.name = "AbortError";
1376
- reject(abortError);
1377
- };
1378
- const timeoutId = setTimeout(() => {
1379
- signal?.removeEventListener("abort", onAbort);
1380
- resolve();
1381
- }, normalizeNonNegativeMs(retryAfterMs, DEFAULT_SERVER_PROXY_RETRY_AFTER_MS));
1382
- signal?.addEventListener("abort", onAbort, { once: true });
1383
- });
1506
+ const delayMs = normalizeNonNegativeMs(
1507
+ retryAfterMs,
1508
+ DEFAULT_SERVER_PROXY_RETRY_AFTER_MS
1509
+ );
1510
+ if (delayMs <= 0) return;
1511
+ await waitForAbortableDelay(delayMs, signal);
1384
1512
  };
1385
1513
  var performServerProxyFetchWithRetry = async ({
1386
1514
  execute,
1387
1515
  signal,
1388
1516
  logPrefix = "[fetchWithServerProxy]"
1389
1517
  }) => {
1390
- for (let attempt = 0; attempt <= MAX_SERVER_PROXY_RETRIES; attempt += 1) {
1518
+ let networkRetries = 0;
1519
+ let statusRetries = 0;
1520
+ while (true) {
1391
1521
  try {
1392
1522
  const response = await execute();
1393
- if (attempt < MAX_STATUS_RETRIES && RETRYABLE_SERVER_PROXY_STATUSES.has(response.status)) {
1394
- const retryAfterMs = resolveServerProxyRetryAfterMs(response);
1523
+ const responseBody = response.status === 503 ? await readRetryableResponseBody(response) : null;
1524
+ const isCoreDraining = response.status === 503 && responseBody?.reason === CORE_DRAIN_REASON;
1525
+ const maxStatusRetries = isCoreDraining ? MAX_SERVER_DRAIN_STATUS_RETRIES : MAX_STATUS_RETRIES;
1526
+ if (statusRetries < maxStatusRetries && isGatewayHttpStatus(response.status)) {
1527
+ statusRetries += 1;
1528
+ const retryAfterMs = resolveServerProxyRetryAfterMs(
1529
+ response,
1530
+ responseBody
1531
+ );
1395
1532
  console.warn(
1396
- `${logPrefix} \u68C0\u6D4B\u5230${response.status}\u72B6\u6001\uFF0C${retryAfterMs}ms\u540E\u91CD\u8BD5\u4E00\u6B21...`
1533
+ `${logPrefix} \u68C0\u6D4B\u5230${response.status}\u72B6\u6001\uFF0C${retryAfterMs}ms\u540E\u91CD\u8BD5...`
1397
1534
  );
1398
1535
  await waitForServerProxyRetry(retryAfterMs, signal);
1399
1536
  continue;
1400
1537
  }
1401
1538
  return response;
1402
1539
  } catch (error) {
1403
- if (attempt < MAX_SERVER_PROXY_RETRIES && isRetryableServerProxyFetchError(error)) {
1404
- const retryDelay = (attempt + 1) * 1e3;
1540
+ if (networkRetries < MAX_SERVER_PROXY_RETRIES && isRetryableServerProxyFetchError(error)) {
1541
+ networkRetries += 1;
1542
+ const retryDelay = networkRetries * 1e3;
1405
1543
  console.warn(
1406
- `${logPrefix} \u68C0\u6D4B\u5230\u7F51\u7EDC\u77AC\u65AD\uFF0C${retryDelay}ms\u540E\u91CD\u8BD5(\u7B2C${attempt + 1}\u6B21)...`,
1544
+ `${logPrefix} \u68C0\u6D4B\u5230\u7F51\u7EDC\u77AC\u65AD\uFF0C${retryDelay}ms\u540E\u91CD\u8BD5(\u7B2C${networkRetries}\u6B21)...`,
1407
1545
  error
1408
1546
  );
1409
1547
  await waitForServerProxyRetry(retryDelay, signal);
@@ -1412,7 +1550,6 @@ var performServerProxyFetchWithRetry = async ({
1412
1550
  throw error;
1413
1551
  }
1414
1552
  }
1415
- throw new Error("server proxy retry exhausted unexpectedly");
1416
1553
  };
1417
1554
 
1418
1555
  // packages/ai/chat/resolveDirectRequestApiKey.ts
@@ -1893,6 +2030,9 @@ export {
1893
2030
  mergeReferences,
1894
2031
  resolveReferenceAssets,
1895
2032
  resolveToolsFromKeys,
2033
+ selectResponsesConversationState,
2034
+ updateResponsesConversationState,
2035
+ isResponsesConversationStateRejection,
1896
2036
  resolveClientWire,
1897
2037
  resolveAgentCallPlan,
1898
2038
  generateRequestBody,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  fetchReferenceContents,
3
3
  resolveReferenceAssets
4
- } from "./chunk-TNPIMII7.js";
4
+ } from "./chunk-JUN3HFMN.js";
5
5
 
6
6
  // packages/ai/agent/fetchAgentContexts.ts
7
7
  async function fetchAgentContexts(references, dispatch) {
@@ -1,47 +1,47 @@
1
1
  import {
2
2
  createCliLocalRuntimeAdapter,
3
3
  summarizeEndpoint
4
- } from "./chunk-EXXFGKF7.js";
4
+ } from "./chunk-5ITRDSHY.js";
5
5
  import {
6
6
  clipMultilineText
7
- } from "./chunk-TYSCFY6S.js";
8
- import {
9
- readPipeText,
10
- spawnProcess
11
- } from "./chunk-IDZTNRP2.js";
12
- import {
13
- parseUserIdFromAuthToken
14
- } from "./chunk-ISNCLGUZ.js";
15
- import {
16
- DEFAULT_NOLO_SERVER_URL
17
- } from "./chunk-OLZBQWZU.js";
7
+ } from "./chunk-RZ735TLX.js";
18
8
  import {
19
9
  runLocalAgentTurn
20
- } from "./chunk-6SLCD4RB.js";
10
+ } from "./chunk-4BTHUYMY.js";
21
11
  import {
22
12
  resolveLocalRuntimeEnvFromPolicy
23
- } from "./chunk-5CS33IBL.js";
13
+ } from "./chunk-PDL2AV3E.js";
24
14
  import {
25
15
  toErrorMessage
26
16
  } from "./chunk-HNMXYYJR.js";
17
+ import {
18
+ readPipeText,
19
+ spawnProcess
20
+ } from "./chunk-IDZTNRP2.js";
27
21
  import {
28
22
  asRecordOrEmpty
29
23
  } from "./chunk-KX6YBIHG.js";
30
24
  import {
31
25
  asTrimmedNonEmptyStringArray
32
26
  } from "./chunk-I42VC5KR.js";
27
+ import {
28
+ isRecord
29
+ } from "./chunk-KUG52IAP.js";
33
30
  import {
34
31
  asTrimmedString
35
32
  } from "./chunk-3EUW3WEO.js";
36
33
  import {
37
34
  asOptionalPositiveFiniteNumber
38
35
  } from "./chunk-U6VC4MU4.js";
36
+ import {
37
+ parseUserIdFromAuthToken
38
+ } from "./chunk-5NBHQD4D.js";
39
+ import {
40
+ DEFAULT_NOLO_SERVER_URL
41
+ } from "./chunk-OLZBQWZU.js";
39
42
  import {
40
43
  asOptionalTrimmedString
41
44
  } from "./chunk-G3SUCT4W.js";
42
- import {
43
- isRecord
44
- } from "./chunk-KUG52IAP.js";
45
45
 
46
46
  // packages/ai/agent/machineRunPermissions.ts
47
47
  var DEFAULT_POLICY = {
@@ -0,0 +1,83 @@
1
+ // packages/agent-runtime/modelLayerOverride.ts
2
+ var MODEL_LAYER_KEYS = [
3
+ "provider",
4
+ "model",
5
+ "apiSource",
6
+ "cliProvider",
7
+ "useServerProxy",
8
+ "apiKey",
9
+ "apiKeyRef",
10
+ "apiKeyHeader",
11
+ "customProviderUrl",
12
+ "credentialRef",
13
+ "credentialSynced",
14
+ "temperature",
15
+ "top_p",
16
+ "frequency_penalty",
17
+ "presence_penalty",
18
+ "max_tokens",
19
+ "reasoning_effort",
20
+ "enableThinking",
21
+ "thinkingBudget"
22
+ ];
23
+ function mergeReferences(base, extra) {
24
+ const safeBase = Array.isArray(base) ? base : [];
25
+ const safeExtra = Array.isArray(extra) ? extra : [];
26
+ const seen = /* @__PURE__ */ new Set();
27
+ const merged = [];
28
+ for (const item of [...safeBase, ...safeExtra]) {
29
+ const key = item?.dbKey;
30
+ if (key && seen.has(key)) continue;
31
+ if (key) seen.add(key);
32
+ if (item) merged.push(item);
33
+ }
34
+ return merged;
35
+ }
36
+ var asNonEmptyString = (value) => typeof value === "string" && value.trim().length > 0;
37
+ function buildModelLayerOverride(agent) {
38
+ if (!agent || !asNonEmptyString(agent.provider) || !asNonEmptyString(agent.model)) {
39
+ return null;
40
+ }
41
+ const override = {
42
+ provider: agent.provider,
43
+ model: agent.model
44
+ };
45
+ for (const key of MODEL_LAYER_KEYS) {
46
+ if (key === "provider" || key === "model") continue;
47
+ const value = agent[key];
48
+ if (value !== void 0) {
49
+ override[key] = value;
50
+ }
51
+ }
52
+ if (Array.isArray(agent.references) && agent.references.length > 0) {
53
+ override.references = agent.references;
54
+ }
55
+ return override;
56
+ }
57
+ function applyModelLayerOverride(base, override) {
58
+ const next = { ...base };
59
+ for (const key of MODEL_LAYER_KEYS) {
60
+ delete next[key];
61
+ }
62
+ for (const key of MODEL_LAYER_KEYS) {
63
+ const value = override[key];
64
+ if (value !== void 0) {
65
+ next[key] = value;
66
+ }
67
+ }
68
+ const merged = mergeReferences(
69
+ base.references,
70
+ override.references
71
+ );
72
+ if (merged.length > 0) {
73
+ next.references = merged;
74
+ } else {
75
+ delete next.references;
76
+ }
77
+ return next;
78
+ }
79
+
80
+ export {
81
+ buildModelLayerOverride,
82
+ applyModelLayerOverride
83
+ };