nolo-cli 0.157.0 → 0.158.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/{_executeModel-ZIQHOREX.js → _executeModel-AGVQAILR.js} +19 -19
  2. package/{agentDeleteCommand-LQSOJEXY.js → agentDeleteCommand-56DO7V2R.js} +22 -22
  3. package/{agentEmailCommands-HTPKXONW.js → agentEmailCommands-BPUATKQ6.js} +24 -24
  4. package/{agentListCommands-GOCGOQUB.js → agentListCommands-KS5VUGOW.js} +40 -17
  5. package/{agentMachineCommands-T7DAZG77.js → agentMachineCommands-HSJS7IQK.js} +11 -11
  6. package/{agentRecordCommands-HSW3RJ4H.js → agentRecordCommands-IDGVLDMB.js} +23 -23
  7. package/{agentRunCommand-TIRJ57DK.js → agentRunCommand-LGMDPPPA.js} +24 -24
  8. package/{agentRuntimeLocal-J6I63NZC.js → agentRuntimeLocal-QL4SHNJJ.js} +10 -10
  9. package/{agentSlice-JNM3HF3V.js → agentSlice-WPXWY6BV.js} +1 -1
  10. package/{appDeleteCommands-KKLAK2UR.js → appDeleteCommands-FLCTFYZB.js} +12 -12
  11. package/{appDeployCommands-PXWK4FAX.js → appDeployCommands-UU4Z7DT3.js} +12 -12
  12. package/{appDeployStatusCommands-3NGWDZTX.js → appDeployStatusCommands-GKLZTHTX.js} +12 -12
  13. package/{appGetCommands-APWYPEO3.js → appGetCommands-DPQ2MVJC.js} +12 -12
  14. package/{appListCommands-OP7IRALO.js → appListCommands-J6QMEBNL.js} +12 -12
  15. package/{authCommand-3Z52KJID.js → authCommand-OVBMDPIF.js} +1 -1
  16. package/{chunk-5EDQTOUR.js → chunk-2HG7O7QF.js} +2 -2
  17. package/{chunk-6Y3ETA2Y.js → chunk-323QA7RW.js} +2 -2
  18. package/{chunk-FHG46N5C.js → chunk-3GCLICFW.js} +1 -1
  19. package/{chunk-4226O6F7.js → chunk-4VDSF5NQ.js} +2 -2
  20. package/{chunk-KESKU5BG.js → chunk-4XHZ4QXL.js} +4 -4
  21. package/{chunk-U34KT53V.js → chunk-6BNW7WC4.js} +1 -1
  22. package/{chunk-4JCAW7TO.js → chunk-7JO3ZACS.js} +1 -1
  23. package/{chunk-QXZH5UDF.js → chunk-7NKZA46B.js} +2 -2
  24. package/{chunk-UVYSBQ2M.js → chunk-AO2T6MWY.js} +10 -10
  25. package/{chunk-QA2C5NKI.js → chunk-ASSNAASW.js} +1 -1
  26. package/{chunk-L2JMH4I5.js → chunk-BWIR5QBI.js} +4 -1
  27. package/{chunk-4L4K6YR7.js → chunk-DI7ZFGDQ.js} +1 -1
  28. package/{chunk-ZZDVBZOP.js → chunk-DOBOKBKS.js} +5 -3
  29. package/{chunk-YN5DT4JS.js → chunk-HCZOSYTL.js} +8 -8
  30. package/{chunk-F3SOW2EU.js → chunk-HEC32F3G.js} +1 -1
  31. package/{chunk-XZIW3Q5B.js → chunk-HSY7F4PP.js} +10 -10
  32. package/chunk-JLR5NWP2.js +548 -0
  33. package/{chunk-MMSQTZCJ.js → chunk-KMKVQNFH.js} +3 -3
  34. package/{chunk-NLFTBC6S.js → chunk-KQT46A27.js} +84 -32
  35. package/{chunk-MR3ITQEV.js → chunk-M3IBEHBT.js} +9 -9
  36. package/{chunk-R7GCGOGZ.js → chunk-OE4FM66I.js} +3 -3
  37. package/{chunk-IKOKYBYJ.js → chunk-OHRQXEON.js} +1 -1
  38. package/{chunk-6MXDOUMH.js → chunk-R4BMKAR5.js} +70 -8
  39. package/{chunk-ZKVS36H3.js → chunk-RCZMREV2.js} +131 -24
  40. package/{chunk-TT644UJD.js → chunk-SAZSXMTR.js} +1 -1
  41. package/{chunk-2AB2HA4M.js → chunk-TDX2L4W2.js} +8 -2
  42. package/{chunk-B3ZIFOFI.js → chunk-TSTLLGAC.js} +2 -2
  43. package/{chunk-5E5VB7PS.js → chunk-TTVMMYVH.js} +7 -7
  44. package/{chunk-OLUKIUX6.js → chunk-XYW6JSRD.js} +2 -2
  45. package/{chunk-WYJTNSVL.js → chunk-Y45LLH6C.js} +34 -3
  46. package/{chunk-K6Y5T4GE.js → chunk-Y7F4Q7YP.js} +2 -2
  47. package/{chunk-GGUTTH6C.js → chunk-YFEVODB4.js} +5 -5
  48. package/{chunk-ULQAD7ZY.js → chunk-YKTAUOS7.js} +1 -1
  49. package/{commandRegistry-DR2RPWK6.js → commandRegistry-HHTMBO55.js} +49 -49
  50. package/{contentThunks-CSJDJDEJ.js → contentThunks-ZSKJTGS7.js} +5 -5
  51. package/{cooldownCommands-JFKTYS2D.js → cooldownCommands-NS63RGBO.js} +2 -2
  52. package/{createAgentAutomationAction-ISEUEQSY.js → createAgentAutomationAction-KYHXEVZF.js} +5 -5
  53. package/{createDialogAction-HUCFOZY3.js → createDialogAction-JKB3V4YP.js} +6 -6
  54. package/{createPageAction-DT5CYXCL.js → createPageAction-CRVW6Z65.js} +5 -5
  55. package/{dialogCommands-3W6AIUXT.js → dialogCommands-2NVLHDZP.js} +10 -10
  56. package/{dialogSlice-WJEEPG4W.js → dialogSlice-SOEMTPH4.js} +4 -4
  57. package/{docCreateCommands-KQHQNLRX.js → docCreateCommands-BL4YBQOD.js} +10 -10
  58. package/{docDeleteCommands-O3DWFX2W.js → docDeleteCommands-NTRYV5OH.js} +10 -10
  59. package/{docReadCommands-2U2BUONC.js → docReadCommands-MJGISD7D.js} +10 -10
  60. package/{docStore-7JPYT25V.js → docStore-YXIN3UVQ.js} +1 -1
  61. package/{docUpdateCommands-MF3C52XI.js → docUpdateCommands-C2AIMWBR.js} +10 -10
  62. package/{handleSendMessageAction-BV5FMID4.js → handleSendMessageAction-JXA7PBY2.js} +11 -11
  63. package/index.js +4 -4
  64. package/{localRuntimeAdapter-6FBEJJ4D.js → localRuntimeAdapter-QAXXJCDM.js} +24 -22
  65. package/{machineCommands-WCAFDI5N.js → machineCommands-TKOOPU7X.js} +23 -23
  66. package/{machineWsRunDispatch-ZF6BBQ3X.js → machineWsRunDispatch-AQ3KTB7U.js} +23 -23
  67. package/package.json +1 -1
  68. package/{readlineWorkspace-I5MHMEUE.js → readlineWorkspace-7G2FBC53.js} +25 -25
  69. package/{runAgentClientLoop-TSNSRQEP.js → runAgentClientLoop-NKCVEOOU.js} +17 -17
  70. package/{spaceCommands-NDPGHDMD.js → spaceCommands-44R7DU34.js} +10 -10
  71. package/{streamAgentChatTurn-RJLDV4WZ.js → streamAgentChatTurn-V7GZPMO4.js} +21 -21
  72. package/{tools-X6QNIYFJ.js → tools-SNXGTJMT.js} +11 -11
  73. package/{tuiSummaryLlmCaller-FESHBDTT.js → tuiSummaryLlmCaller-FQOEF4IE.js} +3 -3
  74. package/{updateDialogTitleAction-6LURCTMG.js → updateDialogTitleAction-QKWRDIK3.js} +5 -5
  75. package/chunk-3MZAGMYY.js +0 -239
@@ -9,7 +9,7 @@ import {
9
9
  resolveRawAgentInput,
10
10
  resolveServerUrl,
11
11
  writeUsage
12
- } from "./chunk-FHG46N5C.js";
12
+ } from "./chunk-3GCLICFW.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-ZKVS36H3.js";
34
+ } from "./chunk-RCZMREV2.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,
@@ -79,14 +79,14 @@ import {
79
79
  } from "./chunk-BMQ2MJUK.js";
80
80
  import {
81
81
  resolveCliLocalRuntimeKeyCapability
82
- } from "./chunk-MR3ITQEV.js";
82
+ } from "./chunk-M3IBEHBT.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-K6Y5T4GE.js";
89
+ } from "./chunk-Y7F4Q7YP.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-B3ZIFOFI.js";
98
+ } from "./chunk-TSTLLGAC.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-XZIW3Q5B.js";
106
+ } from "./chunk-HSY7F4PP.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-TTVMMYVH.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-QL4SHNJJ.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
  }
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  assembleAgentDiscoveryResult,
3
3
  resolveDiscoveryScope
4
- } from "./chunk-WYJTNSVL.js";
4
+ } from "./chunk-Y45LLH6C.js";
5
5
  import {
6
6
  fetchWithTransientRetry
7
7
  } from "./chunk-KFHREHUQ.js";
@@ -20,7 +20,7 @@ import {
20
20
  toolRunUpdated,
21
21
  uiCardFallback,
22
22
  waitForAbortableDelay
23
- } from "./chunk-K6Y5T4GE.js";
23
+ } from "./chunk-Y7F4Q7YP.js";
24
24
  import {
25
25
  isGatewayHttpStatus
26
26
  } from "./chunk-NF64D32W.js";
@@ -64,7 +64,7 @@ import {
64
64
  } from "./chunk-VF4K2QE6.js";
65
65
  import {
66
66
  createDocState
67
- } from "./chunk-6Y3ETA2Y.js";
67
+ } from "./chunk-323QA7RW.js";
68
68
  import {
69
69
  addMemberSpace,
70
70
  fetchAuthoritativeRemoteSpace,
@@ -79,7 +79,7 @@ import {
79
79
  } from "./chunk-BAWAKW7X.js";
80
80
  import {
81
81
  createDialogAction
82
- } from "./chunk-B3ZIFOFI.js";
82
+ } from "./chunk-TSTLLGAC.js";
83
83
  import {
84
84
  setDialogExtraReferencesAction
85
85
  } from "./chunk-IF7V3CBU.js";
@@ -102,7 +102,7 @@ import {
102
102
  updateContentCategory,
103
103
  updateContentTitle,
104
104
  writeStoredCollapsedCategories
105
- } from "./chunk-IKOKYBYJ.js";
105
+ } from "./chunk-OHRQXEON.js";
106
106
  import {
107
107
  buildDatabaseFileContentUrl,
108
108
  deleteDialog,
@@ -115,7 +115,7 @@ import {
115
115
  selectMsgById,
116
116
  uiAskChoiceFunc,
117
117
  uiAskChoiceFunctionSchema
118
- } from "./chunk-XZIW3Q5B.js";
118
+ } from "./chunk-HSY7F4PP.js";
119
119
  import {
120
120
  buildMediaToolConfirmation,
121
121
  normalizeMediaConfirmExecutionRevision
@@ -126,7 +126,7 @@ import {
126
126
  runLlm,
127
127
  streamAgentChatTurn,
128
128
  updateAgent
129
- } from "./chunk-R7GCGOGZ.js";
129
+ } from "./chunk-OE4FM66I.js";
130
130
  import {
131
131
  getCurrentSpaceId,
132
132
  getCurrentSpaceIdRaw,
@@ -3882,7 +3882,7 @@ async function deleteDialogsFunc(args, thunkApi) {
3882
3882
  const deletedDialogIds = [];
3883
3883
  const deletedDialogKeys = [];
3884
3884
  const failures = [];
3885
- const { deleteDialog: deleteDialog2 } = await import("./dialogSlice-WJEEPG4W.js");
3885
+ const { deleteDialog: deleteDialog2 } = await import("./dialogSlice-SOEMTPH4.js");
3886
3886
  for (const target of targets) {
3887
3887
  try {
3888
3888
  await thunkApi.dispatch(deleteDialog2(target.dbKey)).unwrap();
@@ -18563,7 +18563,7 @@ async function updateDocFunc(args, thunkApi) {
18563
18563
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
18564
18564
  };
18565
18565
  await dispatch(write({ data: updatedPageData, customKey: id })).unwrap();
18566
- const { getDocState, applyExternalDocUpdate } = await import("./docStore-7JPYT25V.js");
18566
+ const { getDocState, applyExternalDocUpdate } = await import("./docStore-YXIN3UVQ.js");
18567
18567
  if (getDocState().pageKey === id) {
18568
18568
  applyExternalDocUpdate({
18569
18569
  slateData: finalSlateData,
@@ -308,7 +308,7 @@ var slice = createSliceWithThunks({
308
308
  const overrides = {};
309
309
  if (args.systemPromptOverride !== void 0) overrides.prompt = args.systemPromptOverride;
310
310
  if (args.toolsOverride !== void 0) overrides.tools = args.toolsOverride;
311
- const { _executeModel } = await import("./_executeModel-ZIQHOREX.js");
311
+ const { _executeModel } = await import("./_executeModel-AGVQAILR.js");
312
312
  return _executeModel(
313
313
  {
314
314
  isStreaming: args.isStreaming ?? false,
@@ -329,7 +329,7 @@ var slice = createSliceWithThunks({
329
329
  * - 循环直到无工具调用或触发其他运行时停止条件
330
330
  */
331
331
  runAgent: create.asyncThunk(async (args, thunkApi) => {
332
- const { runAgentClientLoop } = await import("./runAgentClientLoop-TSNSRQEP.js");
332
+ const { runAgentClientLoop } = await import("./runAgentClientLoop-NKCVEOOU.js");
333
333
  const { content: loopContent, toolCallCount } = await runAgentClientLoop(
334
334
  {
335
335
  agentKey: args.agentKey,
@@ -345,7 +345,7 @@ var slice = createSliceWithThunks({
345
345
  * 聊天轮次流式 Agent 调用
346
346
  */
347
347
  streamAgentChatTurn: create.asyncThunk(async (args, thunkApi) => {
348
- const { streamAgentChatTurnHandler } = await import("./streamAgentChatTurn-RJLDV4WZ.js");
348
+ const { streamAgentChatTurnHandler } = await import("./streamAgentChatTurn-V7GZPMO4.js");
349
349
  return streamAgentChatTurnHandler(args, thunkApi);
350
350
  }),
351
351
  /**
@@ -2,7 +2,7 @@ import {
2
2
  deleteDialog,
3
3
  runtime_default,
4
4
  toast
5
- } from "./chunk-XZIW3Q5B.js";
5
+ } from "./chunk-HSY7F4PP.js";
6
6
  import {
7
7
  getCurrentSpaceId,
8
8
  getCurrentSpaceIdRaw,
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  mergeAvailabilityDeadline,
3
+ resolveCredentialCandidateKeys,
3
4
  resolveCredentialKeyWithFallback
4
- } from "./chunk-3MZAGMYY.js";
5
+ } from "./chunk-JLR5NWP2.js";
5
6
 
6
7
  // packages/agent-runtime/credentialAvailability.ts
7
8
  import { homedir } from "node:os";
@@ -66,10 +67,56 @@ async function readCredentialAvailability(env = process.env, now = Date.now()) {
66
67
  Object.entries(entries).map(([key, entry]) => [key, entry.nextAvailableAt])
67
68
  );
68
69
  }
69
- async function readCredentialEntry(credentialKey, env = process.env, now = Date.now()) {
70
+ async function readEffectiveCredentialEntry(credentialKey, env = process.env, now = Date.now()) {
70
71
  if (!credentialKey) return void 0;
72
+ const candidates = resolveCredentialCandidateKeys(credentialKey);
73
+ if (candidates.length === 0) return void 0;
71
74
  const entries = await readCredentialEntries(env, now);
72
- return entries[credentialKey];
75
+ let effectiveEntry;
76
+ const activeCandidates = [];
77
+ for (const key of candidates) {
78
+ const entry = entries[key];
79
+ if (!entry || entry.nextAvailableAt <= now) continue;
80
+ activeCandidates.push({ key, markedAt: entry.markedAt });
81
+ if (!effectiveEntry) {
82
+ effectiveEntry = { ...entry, matchedKey: key };
83
+ } else {
84
+ const mergedDeadline = mergeAvailabilityDeadline(
85
+ effectiveEntry.nextAvailableAt,
86
+ entry.nextAvailableAt
87
+ );
88
+ const mergedProbe = effectiveEntry.lastProbeAt !== void 0 || entry.lastProbeAt !== void 0 ? Math.max(effectiveEntry.lastProbeAt ?? 0, entry.lastProbeAt ?? 0) : void 0;
89
+ const mergedMarkedAt = effectiveEntry.markedAt !== void 0 || entry.markedAt !== void 0 ? Math.max(effectiveEntry.markedAt ?? 0, entry.markedAt ?? 0) : void 0;
90
+ effectiveEntry = {
91
+ nextAvailableAt: mergedDeadline ?? entry.nextAvailableAt,
92
+ ...mergedMarkedAt !== void 0 ? { markedAt: mergedMarkedAt } : {},
93
+ ...mergedProbe !== void 0 ? { lastProbeAt: mergedProbe } : {},
94
+ matchedKey: effectiveEntry.matchedKey
95
+ };
96
+ }
97
+ }
98
+ if (effectiveEntry) {
99
+ effectiveEntry.candidates = activeCandidates;
100
+ }
101
+ return effectiveEntry;
102
+ }
103
+ function resolveEffectiveCredentialCooldown(credentialKey, credentialAvailability, now = 0) {
104
+ if (!credentialKey) return void 0;
105
+ const candidates = resolveCredentialCandidateKeys(credentialKey);
106
+ let effective;
107
+ for (const key of candidates) {
108
+ const at = credentialAvailability[key];
109
+ if (typeof at === "number" && Number.isFinite(at) && (now === 0 || at > now)) {
110
+ effective = mergeAvailabilityDeadline(effective, at);
111
+ }
112
+ }
113
+ return effective;
114
+ }
115
+ async function readCredentialEntry(credentialKey, env = process.env, now = Date.now()) {
116
+ const effective = await readEffectiveCredentialEntry(credentialKey, env, now);
117
+ if (!effective) return void 0;
118
+ const { matchedKey, candidates, ...entry } = effective;
119
+ return entry;
73
120
  }
74
121
  async function writeCredentialAvailability(live, env = process.env) {
75
122
  const path = resolveCredentialAvailabilityPath(env);
@@ -106,16 +153,30 @@ async function clearCredentialAvailabilityIfMarkedAt(credentialKey, expectedMark
106
153
  async function clearCredentialAvailability(credentialKey, env = process.env, now = Date.now()) {
107
154
  if (!credentialKey) return;
108
155
  const live = await readCredentialEntries(env, now);
109
- if (!(credentialKey in live)) return;
110
- delete live[credentialKey];
156
+ const candidates = resolveCredentialCandidateKeys(credentialKey);
157
+ let changed = false;
158
+ for (const key of candidates) {
159
+ if (key in live) {
160
+ delete live[key];
161
+ changed = true;
162
+ }
163
+ }
164
+ if (!changed) return;
111
165
  await writeCredentialAvailability(live, env);
112
166
  }
113
167
  async function recordCredentialProbe(credentialKey, env = process.env, now = Date.now()) {
114
168
  if (!credentialKey) return;
115
169
  const live = await readCredentialEntries(env, now);
116
- const existing = live[credentialKey];
170
+ let targetKey = credentialKey;
171
+ if (!(targetKey in live)) {
172
+ const candidates = resolveCredentialCandidateKeys(credentialKey);
173
+ const found = candidates.find((k) => k in live);
174
+ if (!found) return;
175
+ targetKey = found;
176
+ }
177
+ const existing = live[targetKey];
117
178
  if (!existing) return;
118
- live[credentialKey] = { ...existing, lastProbeAt: now };
179
+ live[targetKey] = { ...existing, lastProbeAt: now };
119
180
  await writeCredentialAvailability(live, env);
120
181
  }
121
182
  function applyCredentialAvailability(agents, credentialAvailability) {
@@ -123,7 +184,7 @@ function applyCredentialAvailability(agents, credentialAvailability) {
123
184
  return agents.map((agent) => {
124
185
  const key = resolveCredentialKeyWithFallback(agent);
125
186
  if (!key) return agent;
126
- const at = credentialAvailability[key];
187
+ const at = resolveEffectiveCredentialCooldown(key, credentialAvailability);
127
188
  if (typeof at !== "number") return agent;
128
189
  const merged = mergeAvailabilityDeadline(
129
190
  agent.nextAvailableAt,
@@ -138,6 +199,7 @@ function applyCredentialAvailability(agents, credentialAvailability) {
138
199
 
139
200
  export {
140
201
  readCredentialAvailability,
202
+ readEffectiveCredentialEntry,
141
203
  readCredentialEntry,
142
204
  markCredentialUnavailable,
143
205
  clearCredentialAvailabilityIfMarkedAt,