nolo-cli 0.164.0-alpha.4 → 0.165.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 (85) hide show
  1. package/{_executeModel-M5PGAD3Z.js → _executeModel-CNWZMBTW.js} +21 -21
  2. package/{accountResolver-55EDKEIK.js → accountResolver-JS7QDNNL.js} +1 -1
  3. package/{agentDeleteCommand-E3FXV4KL.js → agentDeleteCommand-XSMZJNQ6.js} +27 -27
  4. package/{agentEmailCommands-7TEXFJMP.js → agentEmailCommands-TCLCOLOI.js} +28 -28
  5. package/{agentListCommands-GOCGOQUB.js → agentListCommands-4I4FZVVV.js} +44 -21
  6. package/{agentMachineCommands-HCMAADXH.js → agentMachineCommands-CAU6REHD.js} +14 -14
  7. package/{agentRecordCommands-S4XDFB4H.js → agentRecordCommands-NDSOSZES.js} +27 -27
  8. package/{agentRunCommand-SENMZRW7.js → agentRunCommand-E7OCABMM.js} +28 -28
  9. package/{agentRuntimeLocal-J6I63NZC.js → agentRuntimeLocal-BCZRYS5T.js} +11 -11
  10. package/{agentSlice-JOVX3KY3.js → agentSlice-2WTAYXEB.js} +1 -1
  11. package/{appDeleteCommands-KKLAK2UR.js → appDeleteCommands-CTBLT5TG.js} +16 -16
  12. package/{appDeployCommands-PXWK4FAX.js → appDeployCommands-IORMXV5D.js} +16 -16
  13. package/{appDeployStatusCommands-3NGWDZTX.js → appDeployStatusCommands-PWMDFYJ6.js} +16 -16
  14. package/{appGetCommands-APWYPEO3.js → appGetCommands-VG3LGNBO.js} +16 -16
  15. package/{appListCommands-OP7IRALO.js → appListCommands-GLIOZCTD.js} +16 -16
  16. package/{authCommand-3Z52KJID.js → authCommand-OVBMDPIF.js} +1 -1
  17. package/{chunk-ZU4J4GRW.js → chunk-3FDRNFCZ.js} +3 -3
  18. package/{chunk-5E5VB7PS.js → chunk-5N23SKBR.js} +10 -9
  19. package/{chunk-U34KT53V.js → chunk-6BNW7WC4.js} +1 -1
  20. package/{chunk-MLEANT7D.js → chunk-6HAE54KH.js} +2 -2
  21. package/{chunk-L2JMH4I5.js → chunk-6LYCXISC.js} +6 -3
  22. package/{chunk-QXZH5UDF.js → chunk-7NKZA46B.js} +2 -2
  23. package/{chunk-EFGBXVOC.js → chunk-ANI67WCB.js} +2 -2
  24. package/{chunk-QA2C5NKI.js → chunk-ASSNAASW.js} +1 -1
  25. package/{chunk-DE3RG4GV.js → chunk-BAAJVNIW.js} +2 -2
  26. package/{chunk-ZMVXHANW.js → chunk-BYGWUVRX.js} +1 -1
  27. package/{chunk-TMVVCQCX.js → chunk-D2RSMFM5.js} +3 -3
  28. package/{chunk-4L4K6YR7.js → chunk-DI7ZFGDQ.js} +1 -1
  29. package/{chunk-YVPQATSC.js → chunk-GPLUFN2E.js} +7 -1
  30. package/{chunk-Y2UYLA5L.js → chunk-H7GI62DA.js} +5 -5
  31. package/{chunk-F3SOW2EU.js → chunk-HEC32F3G.js} +1 -1
  32. package/{chunk-W7FGZRLK.js → chunk-I72LPLCP.js} +1 -1
  33. package/{chunk-VQOQH3DR.js → chunk-IQ37RGA5.js} +5 -5
  34. package/{chunk-LCKCG5TK.js → chunk-JGQTUD55.js} +85 -33
  35. package/chunk-JLR5NWP2.js +548 -0
  36. package/{chunk-ZZDVBZOP.js → chunk-K3NJW7LY.js} +6 -4
  37. package/{chunk-CNWKLQRL.js → chunk-KSTEXKL6.js} +70 -36
  38. package/{chunk-5IKRTRRR.js → chunk-MCGCC5BA.js} +1 -1
  39. package/{chunk-IPQ3W3CZ.js → chunk-NERECMOR.js} +10 -10
  40. package/{chunk-YTWGTCVW.js → chunk-NPTROADE.js} +14 -14
  41. package/{chunk-JGXBS3CI.js → chunk-PV3HYKQX.js} +8 -8
  42. package/{chunk-ZKBZLQTG.js → chunk-QG7BPUGN.js} +3 -3
  43. package/{chunk-3N5VQFR7.js → chunk-QKZV2CVE.js} +2 -2
  44. package/{chunk-6MXDOUMH.js → chunk-R4BMKAR5.js} +70 -8
  45. package/{chunk-RBMYJSZF.js → chunk-RVHXF55T.js} +2 -2
  46. package/{chunk-TT644UJD.js → chunk-SAZSXMTR.js} +1 -1
  47. package/{chunk-3M52COK5.js → chunk-SLAZGVZN.js} +71 -3
  48. package/{chunk-2AB2HA4M.js → chunk-TDX2L4W2.js} +8 -2
  49. package/{chunk-DJ2BOPJY.js → chunk-TQGP2LAX.js} +1 -1
  50. package/{chunk-OC72ZET2.js → chunk-U7LNNRZJ.js} +10 -10
  51. package/{chunk-647HBTHJ.js → chunk-VPHDNJWW.js} +2 -2
  52. package/{chunk-F3FISQL2.js → chunk-WYU4H7EV.js} +140 -29
  53. package/{chunk-N665S3Z2.js → chunk-XI677N45.js} +2 -2
  54. package/{chunk-WYJTNSVL.js → chunk-XKVWXU6D.js} +35 -4
  55. package/{chunk-ULQAD7ZY.js → chunk-YKTAUOS7.js} +1 -1
  56. package/{chunk-BL4HFN6L.js → chunk-YL26TH2V.js} +1 -1
  57. package/{chunk-4JCAW7TO.js → chunk-Z2LMCNOD.js} +2 -2
  58. package/{commandRegistry-YRHEZ67B.js → commandRegistry-BJDH4622.js} +49 -49
  59. package/{contentThunks-7JLGMPNX.js → contentThunks-BV5O7L2Y.js} +5 -5
  60. package/{cooldownCommands-JFKTYS2D.js → cooldownCommands-NS63RGBO.js} +2 -2
  61. package/{createAgentAutomationAction-WSQ3VZ3X.js → createAgentAutomationAction-TBWN2KX2.js} +5 -5
  62. package/{createDialogAction-4SHMWQYD.js → createDialogAction-WPVWZ3VX.js} +6 -6
  63. package/{createPageAction-GHYKDASE.js → createPageAction-ZFEXCZLK.js} +6 -6
  64. package/{dialogCommands-3W6AIUXT.js → dialogCommands-M4H4OOEW.js} +15 -15
  65. package/{dialogSlice-YXRGO7UV.js → dialogSlice-KGVUUVND.js} +4 -4
  66. package/{docCreateCommands-KQHQNLRX.js → docCreateCommands-7A2RHGYU.js} +14 -14
  67. package/{docDeleteCommands-O3DWFX2W.js → docDeleteCommands-SWNITY6F.js} +15 -15
  68. package/{docReadCommands-2U2BUONC.js → docReadCommands-J3PXXPPB.js} +14 -14
  69. package/{docStore-2U6GZMDG.js → docStore-YS6GP4CJ.js} +1 -1
  70. package/{docUpdateCommands-MF3C52XI.js → docUpdateCommands-2PFIC67Z.js} +14 -14
  71. package/{handleSendMessageAction-SK6Q2N7Z.js → handleSendMessageAction-NCHW43LP.js} +24 -11
  72. package/index.js +4 -4
  73. package/{localRuntimeAdapter-GNVO5DGA.js → localRuntimeAdapter-4EQNCW4N.js} +27 -25
  74. package/{machineCommands-LDK57YET.js → machineCommands-AFXYNIRI.js} +26 -26
  75. package/{machineWsRunDispatch-PFYI3ZDF.js → machineWsRunDispatch-2VR24KZ2.js} +26 -26
  76. package/package.json +1 -1
  77. package/{readlineWorkspace-NLHSBWBK.js → readlineWorkspace-5J2JEAGZ.js} +31 -31
  78. package/{runAgentClientLoop-FR7N5TID.js → runAgentClientLoop-ISO62FYI.js} +19 -19
  79. package/{spaceCommands-NDPGHDMD.js → spaceCommands-3GWTIOI2.js} +14 -14
  80. package/{streamAgentChatTurn-YHZNWDWS.js → streamAgentChatTurn-MPMB3V3Q.js} +23 -23
  81. package/{tools-AEPUZOZ2.js → tools-G6OMRLGU.js} +13 -13
  82. package/{tuiSummaryLlmCaller-FESHBDTT.js → tuiSummaryLlmCaller-FQOEF4IE.js} +3 -3
  83. package/{updateDialogTitleAction-QERIYNOM.js → updateDialogTitleAction-WDG2WGZJ.js} +5 -5
  84. package/{workloadLifecycle-6O6PMISX.js → workloadLifecycle-MZ2V5L43.js} +1 -1
  85. package/chunk-3MZAGMYY.js +0 -239
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  addContentToSpace
3
- } from "./chunk-ZMVXHANW.js";
3
+ } from "./chunk-BYGWUVRX.js";
4
4
  import {
5
5
  format,
6
6
  prepareAndPersistMessage,
7
7
  uiAskChoiceFunc,
8
8
  uiAskChoiceFunctionSchema
9
- } from "./chunk-OC72ZET2.js";
9
+ } from "./chunk-U7LNNRZJ.js";
10
10
  import {
11
11
  formatISO
12
12
  } from "./chunk-ZRAU6T47.js";
@@ -34,7 +34,7 @@ var serializeMessageContent = (content, imagePlaceholder = "[\u56FE\u7247]") =>
34
34
  };
35
35
 
36
36
  // packages/core/sha256.ts
37
- import SHA256 from "crypto-js/sha256";
37
+ import SHA256 from "crypto-js/sha256.js";
38
38
  function sha256Hex(text) {
39
39
  return SHA256(text).toString();
40
40
  }
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  toolRegistry
3
- } from "./chunk-YTWGTCVW.js";
3
+ } from "./chunk-NPTROADE.js";
4
4
  import {
5
5
  runtime_default
6
- } from "./chunk-OC72ZET2.js";
6
+ } from "./chunk-U7LNNRZJ.js";
7
7
  import {
8
8
  canonicalizeToolNames
9
9
  } from "./chunk-5EBLANFT.js";
@@ -2,7 +2,7 @@ import {
2
2
  deleteDialog,
3
3
  runtime_default,
4
4
  toast
5
- } from "./chunk-OC72ZET2.js";
5
+ } from "./chunk-U7LNNRZJ.js";
6
6
  import {
7
7
  getCurrentSpaceId,
8
8
  getCurrentSpaceIdRaw,
@@ -6,10 +6,10 @@ import {
6
6
  } from "./chunk-62TBKWTV.js";
7
7
  import {
8
8
  clearCliLocalRuntimePreparedAgentCache
9
- } from "./chunk-F3FISQL2.js";
9
+ } from "./chunk-WYU4H7EV.js";
10
10
  import {
11
11
  readCredentialAvailability
12
- } from "./chunk-6MXDOUMH.js";
12
+ } from "./chunk-R4BMKAR5.js";
13
13
  import {
14
14
  buildCreatedAgentRecord,
15
15
  buildUpdatedAgentRecord,
@@ -19,7 +19,7 @@ import {
19
19
  resolveAgentRecordFromHybridStore,
20
20
  sanitizeAgentRecordForCliOutput,
21
21
  writeAgentRecord
22
- } from "./chunk-5IKRTRRR.js";
22
+ } from "./chunk-MCGCC5BA.js";
23
23
  import {
24
24
  resolveCliAgentKeyInput
25
25
  } from "./chunk-NBTY7YJF.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getModelContextWindow
3
- } from "./chunk-QA2C5NKI.js";
3
+ } from "./chunk-ASSNAASW.js";
4
4
  import {
5
5
  isRecord
6
6
  } from "./chunk-KUG52IAP.js";
@@ -173,6 +173,8 @@ var DEFAULT_TTL_MINUTES = 15;
173
173
  var DEFAULT_MAX_OUTPUT_CHARS = 8e3;
174
174
  var DEFAULT_EXEC_TIMEOUT_MS = 6e4;
175
175
  var DEFAULT_MAX_ACTIVE_SANDBOXES_PER_ACCOUNT = 3;
176
+ var DEFAULT_STOP_CONFIRM_ATTEMPTS = 6;
177
+ var DEFAULT_STOP_CONFIRM_DELAY_MS = 2500;
176
178
  function resolveMaxActiveSandboxesFromEnv(env = process.env) {
177
179
  const raw = (env.NOLO_DOCKER_MAX_ACTIVE_SANDBOXES ?? "").trim();
178
180
  if (!raw) return null;
@@ -299,6 +301,10 @@ function createDockerSandboxExecutionBackend(deps = {}) {
299
301
  const shapeId = deps.shapeId ?? SANDBOX_DEFAULT_SHAPE;
300
302
  const ttlMinutes = deps.ttlMinutes ?? DEFAULT_TTL_MINUTES;
301
303
  const maxOutputChars = deps.maxOutputChars ?? DEFAULT_MAX_OUTPUT_CHARS;
304
+ const stopConfirm = {
305
+ attempts: Math.max(1, deps.stopConfirm?.attempts ?? DEFAULT_STOP_CONFIRM_ATTEMPTS),
306
+ delayMs: Math.max(0, deps.stopConfirm?.delayMs ?? DEFAULT_STOP_CONFIRM_DELAY_MS)
307
+ };
302
308
  const leases = /* @__PURE__ */ new Map();
303
309
  const descriptor = {
304
310
  id: DOCKER_SANDBOX_BACKEND_ID,
@@ -628,7 +634,7 @@ function createDockerSandboxExecutionBackend(deps = {}) {
628
634
  const stop = await runSbx(["--cloud", "stop", entry.sandboxName], {
629
635
  timeoutMs: controlTimeoutMs
630
636
  });
631
- if (stop.exitCode !== 0 || !await confirmDockerSandboxStopped(runSbx, entry.sandboxName, controlTimeoutMs)) {
637
+ if (stop.exitCode !== 0 || !await confirmDockerSandboxStopped(runSbx, entry.sandboxName, controlTimeoutMs, stopConfirm)) {
632
638
  throw new DockerSandboxBackendError("stop-unverified", void 0, true);
633
639
  }
634
640
  entry.released = true;
@@ -3,10 +3,10 @@ import {
3
3
  } from "./chunk-HS7MLR74.js";
4
4
  import {
5
5
  performServerProxyFetchWithRetry
6
- } from "./chunk-647HBTHJ.js";
6
+ } from "./chunk-VPHDNJWW.js";
7
7
  import {
8
8
  fetchServerSyncedCredential
9
- } from "./chunk-ZKBZLQTG.js";
9
+ } from "./chunk-QG7BPUGN.js";
10
10
  import {
11
11
  buildSkillGuidancePromptBlock
12
12
  } from "./chunk-SH3XD4E2.js";
@@ -23,7 +23,7 @@ import {
23
23
  compileContextLayers,
24
24
  detectDispatchIntentFromMessages,
25
25
  resolveToolGuidedSections
26
- } from "./chunk-ZZDVBZOP.js";
26
+ } from "./chunk-K3NJW7LY.js";
27
27
  import {
28
28
  convertMessagesToResponsesInput,
29
29
  getUsageRequestOptions,
@@ -32,11 +32,11 @@ import {
32
32
  resolveReasoningReplayOptions,
33
33
  shouldStripReasoningContentForOutbound,
34
34
  stablePromptCacheKey
35
- } from "./chunk-4L4K6YR7.js";
35
+ } from "./chunk-DI7ZFGDQ.js";
36
36
  import {
37
37
  resolveAgentCallPlan,
38
38
  resolveClientWire
39
- } from "./chunk-TT644UJD.js";
39
+ } from "./chunk-SAZSXMTR.js";
40
40
  import {
41
41
  createFileCredentialBroker
42
42
  } from "./chunk-UHTDNB5Y.js";
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  getModelContextWindow,
6
6
  normalizeTimingMs
7
- } from "./chunk-QA2C5NKI.js";
7
+ } from "./chunk-ASSNAASW.js";
8
8
  import {
9
9
  BUILTIN_NOLO_AGENT_KEY
10
10
  } from "./chunk-LOEO7LRC.js";
@@ -2,7 +2,7 @@ import {
2
2
  deleteDbRecord,
3
3
  queryUserRecords,
4
4
  readDbRecord
5
- } from "./chunk-5IKRTRRR.js";
5
+ } from "./chunk-MCGCC5BA.js";
6
6
  import {
7
7
  mergeAndDedupUserData
8
8
  } from "./chunk-OXME3PEE.js";
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  createCliLocalRuntimeAdapter,
3
3
  summarizeEndpoint
4
- } from "./chunk-F3FISQL2.js";
4
+ } from "./chunk-WYU4H7EV.js";
5
5
  import {
6
6
  t
7
- } from "./chunk-2AB2HA4M.js";
7
+ } from "./chunk-TDX2L4W2.js";
8
8
  import {
9
9
  clipMultilineText
10
- } from "./chunk-RBMYJSZF.js";
10
+ } from "./chunk-RVHXF55T.js";
11
11
  import {
12
12
  runLocalAgentTurn
13
- } from "./chunk-5E5VB7PS.js";
13
+ } from "./chunk-5N23SKBR.js";
14
14
  import {
15
15
  applyToolSurfaceConstraints
16
- } from "./chunk-3M52COK5.js";
16
+ } from "./chunk-SLAZGVZN.js";
17
17
  import {
18
18
  resolveLocalRuntimeEnvFromPolicy
19
19
  } from "./chunk-LIQJTQRN.js";
@@ -9,7 +9,7 @@ import {
9
9
  resolveRawAgentInput,
10
10
  resolveServerUrl,
11
11
  writeUsage
12
- } from "./chunk-N665S3Z2.js";
12
+ } from "./chunk-XI677N45.js";
13
13
  import {
14
14
  getReadableCliDb
15
15
  } from "./chunk-62TBKWTV.js";
@@ -31,19 +31,19 @@ import {
31
31
  resolveFileWriteGateEnabled,
32
32
  resolveLocalUserId,
33
33
  validateInstaboxWorkspaceSelection
34
- } from "./chunk-F3FISQL2.js";
34
+ } from "./chunk-WYU4H7EV.js";
35
35
  import {
36
36
  clearCredentialAvailability,
37
- readCredentialEntry,
37
+ readEffectiveCredentialEntry,
38
38
  recordCredentialProbe
39
- } from "./chunk-6MXDOUMH.js";
39
+ } from "./chunk-R4BMKAR5.js";
40
40
  import {
41
41
  agentRunCardLabels,
42
42
  getCliLocale,
43
43
  t,
44
44
  toolLabel,
45
45
  toolLabelVariants
46
- } from "./chunk-2AB2HA4M.js";
46
+ } from "./chunk-TDX2L4W2.js";
47
47
  import {
48
48
  _appendEntityBatch,
49
49
  _appendEvidenceBatch,
@@ -64,7 +64,7 @@ import {
64
64
  import {
65
65
  readDbRecord,
66
66
  resolveAgentRecordFromHybridStore
67
- } from "./chunk-5IKRTRRR.js";
67
+ } from "./chunk-MCGCC5BA.js";
68
68
  import {
69
69
  isLocalCliAgentKey
70
70
  } from "./chunk-NBTY7YJF.js";
@@ -79,14 +79,14 @@ import {
79
79
  } from "./chunk-BMQ2MJUK.js";
80
80
  import {
81
81
  resolveCliLocalRuntimeKeyCapability
82
- } from "./chunk-YTWGTCVW.js";
82
+ } from "./chunk-NPTROADE.js";
83
83
  import {
84
84
  isTransientFetchError
85
85
  } from "./chunk-KFHREHUQ.js";
86
86
  import {
87
87
  parseUiCard,
88
88
  uiCardFallback
89
- } from "./chunk-RBMYJSZF.js";
89
+ } from "./chunk-RVHXF55T.js";
90
90
  import {
91
91
  isGatewayHttpStatus
92
92
  } from "./chunk-NF64D32W.js";
@@ -95,7 +95,7 @@ import {
95
95
  chooseMemoryOwners,
96
96
  loadMemoryCandidatesFromDb,
97
97
  resolveAgentMemoryPolicy
98
- } from "./chunk-EFGBXVOC.js";
98
+ } from "./chunk-ANI67WCB.js";
99
99
  import {
100
100
  API_REPORTED_COST_MULTIPLIER,
101
101
  estimateMessagesTokens,
@@ -103,7 +103,7 @@ import {
103
103
  resolveAgentContextWindow,
104
104
  resolveOccupancy,
105
105
  resolveOccupancyWindow
106
- } from "./chunk-OC72ZET2.js";
106
+ } from "./chunk-U7LNNRZJ.js";
107
107
  import {
108
108
  buildSkillDiscoveryContextLayer
109
109
  } from "./chunk-AU7AXHUL.js";
@@ -115,10 +115,10 @@ import {
115
115
  LOCAL_AGENT_CONFIG_MISSING_CODE,
116
116
  LOCAL_TURN_ABORTED_CODE,
117
117
  readActionGate
118
- } from "./chunk-5E5VB7PS.js";
118
+ } from "./chunk-5N23SKBR.js";
119
119
  import {
120
120
  resolveAgentRuntimeConfigFromRecord
121
- } from "./chunk-ULQAD7ZY.js";
121
+ } from "./chunk-YKTAUOS7.js";
122
122
  import {
123
123
  createThinkParserState,
124
124
  flushThinkParser,
@@ -133,16 +133,18 @@ import {
133
133
  import {
134
134
  PROBE_INTERVAL_MS,
135
135
  QUOTA_ERROR_PATTERNS,
136
+ classifyFailureSubclass,
137
+ isCapacitySaturatedRateLimit,
136
138
  isQuotaExhaustedError,
137
- isQuotaLimited403Body,
139
+ isQuotaExhaustedText,
138
140
  mergeAvailabilityDeadline,
139
141
  resolveCooldownGate,
140
142
  resolveCredentialKeyWithFallback
141
- } from "./chunk-3MZAGMYY.js";
143
+ } from "./chunk-JLR5NWP2.js";
142
144
  import {
143
145
  isOAuthApiKeyRef,
144
146
  normalizeUsage
145
- } from "./chunk-F3SOW2EU.js";
147
+ } from "./chunk-HEC32F3G.js";
146
148
  import {
147
149
  clipCompactText
148
150
  } from "./chunk-5MMAK75Q.js";
@@ -11371,7 +11373,7 @@ function isBalanceExhaustedError(error) {
11371
11373
 
11372
11374
  // packages/cli/client/agentRun.ts
11373
11375
  async function loadRunLocalAgentTurn() {
11374
- const { runLocalAgentTurn } = await import("./agentRuntimeLocal-J6I63NZC.js");
11376
+ const { runLocalAgentTurn } = await import("./agentRuntimeLocal-BCZRYS5T.js");
11375
11377
  return runLocalAgentTurn;
11376
11378
  }
11377
11379
  var stripDebugNoise = (s) => s.replace(/\s*raw="[\s\S]*"/g, "").replace(/\s*raw=\S+/g, "").replace(/\s*headers=\[[^\]]*\]/g, "").replace(/\s*headers=\S+/g, "").trim();
@@ -11643,7 +11645,7 @@ function looksLikeRateLimitedText(message) {
11643
11645
  var AUTH_TEXT_SIGNAL_RE = /\b401\b|unauthori[sz]ed|invalid[_\s-]?(?:api[_\s-]?key|token|credential)s?|(?:api[_\s-]?key|token|credential)s?[_\s-](?:invalid|expired|rejected|missing|not[_\s-]?found)|authentication[_\s-]?(?:error|failed|required)/i;
11644
11646
  var QUOTA_EXHAUSTED_EXTRA_RE = /insufficient[_\s-]?(?:quota|balance|credits?)|余额不足|额度已?用尽/i;
11645
11647
  function looksLikeQuotaExhaustedText(message) {
11646
- return isQuotaLimited403Body(message) || QUOTA_EXHAUSTED_EXTRA_RE.test(message);
11648
+ return isQuotaExhaustedText(message) || QUOTA_EXHAUSTED_EXTRA_RE.test(message);
11647
11649
  }
11648
11650
  var BARE_UPSTREAM_5XX_RE = /\bHTTP[:\s]+(5\d\d)\b|\bstatus[:\s=]+(5\d\d)\b|\breturned error\s+(5\d\d)\b/i;
11649
11651
  function classifyLocalRunError(message) {
@@ -11890,7 +11892,7 @@ function formatRateLimitResetHint(hint, locale) {
11890
11892
  return parts.join(" ");
11891
11893
  }
11892
11894
  function buildRateLimitFailure(ctx) {
11893
- const headlineKey = ctx.quotaExhausted ? "localRunRateLimitQuota" : "localRunRateLimitThrottled";
11895
+ const headlineKey = isCapacitySaturatedRateLimit(ctx.message, Date.now()) ? "localRunRateLimitCapacity" : ctx.quotaExhausted ? "localRunRateLimitQuota" : "localRunRateLimitThrottled";
11894
11896
  const lines = [
11895
11897
  t(
11896
11898
  headlineKey,
@@ -12228,8 +12230,15 @@ async function runHttpAgentTurn(options, authToken) {
12228
12230
  if (options.abortSignal?.aborted) {
12229
12231
  return { exitCode: 0, streamInterrupted: true };
12230
12232
  }
12233
+ const failureSubclass = classifyFailureSubclass({
12234
+ message: toErrorMessage(error),
12235
+ body: error
12236
+ });
12231
12237
  options.output.write(buildTransportErrorHint(options.serverUrl, error));
12232
- return { exitCode: 1 };
12238
+ return {
12239
+ exitCode: 1,
12240
+ ...failureSubclass && failureSubclass !== "unknown" ? { failureSubclass } : {}
12241
+ };
12233
12242
  }
12234
12243
  if (shouldStream && isGatewayHttpStatus(res.status)) {
12235
12244
  const failureMeta = await readAgentRunFailureMetadata(res);
@@ -12244,8 +12253,15 @@ async function runHttpAgentTurn(options, authToken) {
12244
12253
  res = await postAgentRun(false);
12245
12254
  } catch (error) {
12246
12255
  spinner.stop();
12256
+ const failureSubclass = classifyFailureSubclass({
12257
+ message: toErrorMessage(error),
12258
+ body: error
12259
+ });
12247
12260
  options.output.write(buildTransportErrorHint(options.serverUrl, error));
12248
- return { exitCode: 1 };
12261
+ return {
12262
+ exitCode: 1,
12263
+ ...failureSubclass && failureSubclass !== "unknown" ? { failureSubclass } : {}
12264
+ };
12249
12265
  }
12250
12266
  }
12251
12267
  }
@@ -12293,7 +12309,16 @@ async function runHttpAgentTurn(options, authToken) {
12293
12309
  `
12294
12310
  );
12295
12311
  }
12296
- return dialogIdText ? { exitCode: 1, dialogId: dialogIdText } : { exitCode: 1 };
12312
+ const failureSubclass = classifyFailureSubclass({
12313
+ status: res.status,
12314
+ message: `${errorText || messageText} ${reasonText || ""} ${codeText || ""}`.trim(),
12315
+ body: data
12316
+ });
12317
+ return {
12318
+ exitCode: 1,
12319
+ ...dialogIdText ? { dialogId: dialogIdText } : {},
12320
+ ...failureSubclass && failureSubclass !== "unknown" ? { failureSubclass } : {}
12321
+ };
12297
12322
  }
12298
12323
  const content = formatAssistantResponseForCli(
12299
12324
  String(data?.content ?? data?.message ?? "")
@@ -12604,6 +12629,10 @@ async function executeLocalAgentTurnForCliWithAdapter(options, settings, resolve
12604
12629
  return {
12605
12630
  exitCode: 1,
12606
12631
  localError: error,
12632
+ failureSubclass: classifyFailureSubclass({
12633
+ message: toErrorMessage(error),
12634
+ body: error
12635
+ }),
12607
12636
  ...savedDialogId ? { dialogId: savedDialogId } : {},
12608
12637
  ...abortedTurnCredits !== void 0 ? { turnCredits: abortedTurnCredits } : {},
12609
12638
  ...abortedUsageRecords?.length ? { usageRecords: abortedUsageRecords } : {}
@@ -12622,7 +12651,9 @@ async function checkLocalAvailabilityBeforeHttpDispatch(options) {
12622
12651
  }
12623
12652
  if (!config || typeof config !== "object") return null;
12624
12653
  const baseRecord = config.rawRecord ?? config;
12625
- let credentialKey = resolveCredentialKeyWithFallback(baseRecord);
12654
+ let credentialKey = resolveCredentialKeyWithFallback(
12655
+ baseRecord.agentKey || baseRecord.key ? baseRecord : { ...baseRecord, agentKey: options.agentKey }
12656
+ );
12626
12657
  if (credentialKey && resolveOAuthChannelOwnerSkip(
12627
12658
  config,
12628
12659
  options
@@ -12636,19 +12667,30 @@ async function checkLocalAvailabilityBeforeHttpDispatch(options) {
12636
12667
  }
12637
12668
  const env = options.env;
12638
12669
  const now = Date.now();
12639
- const entry = credentialKey ? await readCredentialEntry(credentialKey, env, now).catch(() => void 0) : void 0;
12670
+ let entry;
12671
+ let matchedKey;
12672
+ if (credentialKey) {
12673
+ const effective = await readEffectiveCredentialEntry(credentialKey, env, now).catch(() => void 0);
12674
+ if (effective) {
12675
+ entry = effective;
12676
+ matchedKey = effective.matchedKey;
12677
+ }
12678
+ }
12640
12679
  const entryAt = entry?.nextAvailableAt;
12641
12680
  const effectiveNextAvailableAt = typeof entryAt === "number" ? mergeAvailabilityDeadline(agentLevelNextAvailableAt, entryAt) : agentLevelNextAvailableAt;
12642
- if (typeof effectiveNextAvailableAt !== "number") return { credentialKey };
12681
+ const activeKey = matchedKey || credentialKey;
12682
+ if (typeof effectiveNextAvailableAt !== "number") {
12683
+ return { credentialKey: credentialKey || activeKey, matchedKey };
12684
+ }
12643
12685
  const gateDecision = resolveCooldownGate(
12644
12686
  { nextAvailableAt: effectiveNextAvailableAt, lastProbeAt: entry?.lastProbeAt },
12645
12687
  now
12646
12688
  );
12647
- if (gateDecision === "probe" && credentialKey) {
12648
- await recordCredentialProbe(credentialKey, env, now).catch(() => void 0);
12649
- return { credentialKey };
12689
+ if (gateDecision === "probe" && activeKey) {
12690
+ await recordCredentialProbe(activeKey, env, now).catch(() => void 0);
12691
+ return { credentialKey: credentialKey || activeKey, matchedKey };
12650
12692
  }
12651
- if (gateDecision !== "blocked") return { credentialKey };
12693
+ if (gateDecision !== "blocked") return { credentialKey: credentialKey || activeKey, matchedKey };
12652
12694
  options.output.write(
12653
12695
  `${t(
12654
12696
  "agentCooldownBlocked",
@@ -12659,7 +12701,7 @@ async function checkLocalAvailabilityBeforeHttpDispatch(options) {
12659
12701
  )}
12660
12702
  `
12661
12703
  );
12662
- return { exitCode: 1 };
12704
+ return { exitCode: 1, failureSubclass: "rate_limit" };
12663
12705
  }
12664
12706
  function foldLocalResultForTui(localResult) {
12665
12707
  const folded = {
@@ -12685,7 +12727,8 @@ function foldLocalResultForTui(localResult) {
12685
12727
  // 上 finalText 永远到不了结算点 → agentRunCommand 的 settleRunTerminal-
12686
12728
  // Authoritatively 拿不到 lastAssistantText → `.result.md` 不写、status 无
12687
12729
  // resultFile,编排者只能去啃带 ANSI 的 .log(同坑位历史:turnCredits)。
12688
- ...localResult.finalText ? { finalText: localResult.finalText } : {}
12730
+ ...localResult.finalText ? { finalText: localResult.finalText } : {},
12731
+ ...localResult.failureSubclass ? { failureSubclass: localResult.failureSubclass } : {}
12689
12732
  };
12690
12733
  const headerMeta = getRunResultHeaderMeta(localResult);
12691
12734
  recordRunResultHeaderMeta(folded, headerMeta);
@@ -12760,9 +12803,14 @@ async function runAgentTurn(options) {
12760
12803
  }
12761
12804
  }
12762
12805
  const localErrorMessage = localResult.localError ? toErrorMessage(localResult.localError) : "local runtime failed";
12806
+ const failureSubclass = localResult.failureSubclass ?? classifyFailureSubclass({
12807
+ message: localErrorMessage,
12808
+ body: localResult.localError
12809
+ });
12763
12810
  options.output.write(describeLocalRunFailure(localErrorMessage, localResult.localError));
12764
12811
  return {
12765
12812
  exitCode: 1,
12813
+ failureSubclass,
12766
12814
  ...localResult.dialogId ? { dialogId: localResult.dialogId } : {},
12767
12815
  // Keep localError so TUI can show balance/quota/dialog-preserved hints
12768
12816
  // instead of only the raw auto-runtime line.
@@ -12782,12 +12830,16 @@ async function runAgentTurn(options) {
12782
12830
  }
12783
12831
  const localAvailability = await checkLocalAvailabilityBeforeHttpDispatch(options);
12784
12832
  if (localAvailability?.exitCode) {
12785
- return { exitCode: localAvailability.exitCode };
12833
+ return {
12834
+ exitCode: localAvailability.exitCode,
12835
+ failureSubclass: localAvailability.failureSubclass ?? "rate_limit"
12836
+ };
12786
12837
  }
12787
12838
  const httpResult = await runHttpAgentTurn(options, authToken);
12788
- if (httpResult.exitCode === 0 && !httpResult.streamInterrupted && localAvailability?.credentialKey) {
12839
+ if (httpResult.exitCode === 0 && !httpResult.streamInterrupted && (localAvailability?.credentialKey || localAvailability?.matchedKey)) {
12840
+ const keyToClear = localAvailability.credentialKey || localAvailability.matchedKey;
12789
12841
  await clearCredentialAvailability(
12790
- localAvailability.credentialKey,
12842
+ keyToClear,
12791
12843
  options.env
12792
12844
  ).catch(() => void 0);
12793
12845
  }