nolo-cli 0.97.0-alpha.2 → 0.97.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 (182) hide show
  1. package/README.md +1 -1
  2. package/{_executeModel-G2MRKK2K.js → _executeModel-DYHTQJZC.js} +68 -63
  3. package/{action-YVYQEAAV.js → action-GI44T4DR.js} +10 -10
  4. package/{addContentAction-O7R66HEX.js → addContentAction-B2DRF7P6.js} +9 -9
  5. package/{addDialogAgentAction-74OA7KYP.js → addDialogAgentAction-T3I7IXPK.js} +15 -17
  6. package/{agentDeleteCommand-4427YKQF.js → agentDeleteCommand-LLNNP3AM.js} +47 -43
  7. package/{agentEmailCommands-RNBKKO7Q.js → agentEmailCommands-MQOP76DK.js} +90 -82
  8. package/agentListCommands-J3MWAZWO.js +741 -0
  9. package/{agentMachineCommands-FOFX5S2Q.js → agentMachineCommands-EQIRKAZO.js} +42 -38
  10. package/{agentProviderCommands-GNPTL5XR.js → agentProviderCommands-EMZCM6VA.js} +1 -1
  11. package/{agentPullCommand-O5MPVJ5E.js → agentPullCommand-HF4A42D4.js} +1 -1
  12. package/agentRecordCommands-7MQRBMWZ.js +136 -0
  13. package/{agentRunCommand-2W3Q3A7M.js → agentRunCommand-H6BYSTJ7.js} +90 -80
  14. package/{agentRunControl-WCTKX5VL.js → agentRunControl-2TTTUTSW.js} +2 -2
  15. package/{agentRuntimeLocal-IW3IM5P6.js → agentRuntimeLocal-AY6YNUAL.js} +44 -36
  16. package/{agentSlice-SK47GTN7.js → agentSlice-FOZUXW7X.js} +11 -11
  17. package/{appDeleteCommands-ZXLXNRHF.js → appDeleteCommands-QTTL3QF3.js} +42 -38
  18. package/{appDeployCommands-PWB4YERK.js → appDeployCommands-43LJECGV.js} +42 -38
  19. package/{appDeployStatusCommands-2EZKZP7Y.js → appDeployStatusCommands-L5BKOLYW.js} +42 -38
  20. package/{appGetCommands-JNUKOWHO.js → appGetCommands-HOFZKOPC.js} +42 -38
  21. package/{appListCommands-6X3H67SS.js → appListCommands-I7C3SJCE.js} +42 -38
  22. package/{authCommand-F4EFRRX6.js → authCommand-2YPMMIJN.js} +117 -23
  23. package/{authCommands-RGOGCPP6.js → authCommands-FFDS4FVX.js} +7 -5
  24. package/{builtinSkillRegistry-FUAVTRVZ.js → builtinSkillRegistry-CALVIJTX.js} +6 -5
  25. package/{chatQueueReduxAdapter-ZJ555AT2.js → chatQueueReduxAdapter-NMEZRYC2.js} +30 -29
  26. package/{chromeCommands-FZYAU75D.js → chromeCommands-K27J4OVZ.js} +124 -28
  27. package/{chromeOpsCommands-62P2Q2YB.js → chromeOpsCommands-IXRLN57H.js} +4 -3
  28. package/{chunk-6OZ36FXI.js → chunk-27ONFIEY.js} +22 -4
  29. package/{chunk-JEDZAO7L.js → chunk-2SYTUTLI.js} +257 -37
  30. package/{chunk-YQTQQX2H.js → chunk-2UV22D2F.js} +1 -1
  31. package/{chunk-7D6Z6AA4.js → chunk-3BFMH6GE.js} +6 -7
  32. package/{chunk-OIVSQH2O.js → chunk-3BXNTXYI.js} +299 -5
  33. package/{chunk-QIAVMDHY.js → chunk-3LX6YE3P.js} +4 -4
  34. package/{chunk-EYAQT56M.js → chunk-4DPP773Q.js} +2 -2
  35. package/chunk-4LCOCOR5.js +50 -0
  36. package/{chunk-2GRGFCF6.js → chunk-4VJAC32I.js} +2 -1
  37. package/{chunk-MC4XLIJ7.js → chunk-523DITKR.js} +1 -1
  38. package/{chunk-E4MARS3Q.js → chunk-5GVBDNTO.js} +1 -1
  39. package/chunk-5J3PYNUP.js +255 -0
  40. package/chunk-5MMAK75Q.js +15 -0
  41. package/{chunk-JPGCXHNM.js → chunk-5OA5HMTL.js} +1 -1
  42. package/{chunk-42V6BK2E.js → chunk-62IL3KQV.js} +4 -34
  43. package/{chunk-6YTOJY35.js → chunk-6D2JFXLY.js} +35 -0
  44. package/{chunk-3BMYXEUW.js → chunk-6O4IK4V2.js} +1 -1
  45. package/{chunk-IIVGDG4I.js → chunk-6PHKBY2Q.js} +10 -4
  46. package/{chunk-ASQYTZTR.js → chunk-6ZWMH6TJ.js} +69 -36
  47. package/{chunk-ABQYVJBJ.js → chunk-7CHC4W22.js} +1 -1
  48. package/{chunk-GQBOR3G6.js → chunk-7KVZ5LDQ.js} +2 -2
  49. package/{chunk-SDTTBMBU.js → chunk-7WCQEMPB.js} +888 -1079
  50. package/{chunk-BLJWCTRL.js → chunk-AOPCEXTB.js} +1 -1
  51. package/{chunk-WGR3J4Q6.js → chunk-APMUYAPK.js} +17 -4
  52. package/{chunk-Q554LLSI.js → chunk-AUDNYVRC.js} +1 -1
  53. package/{chunk-RG6JBBX5.js → chunk-AWF3WO5R.js} +166 -13
  54. package/{chunk-GPCZ7UXG.js → chunk-AZRHIN5B.js} +1 -1
  55. package/chunk-BMQ2MJUK.js +153 -0
  56. package/{chunk-B4ZH7KVO.js → chunk-C3VLSD4K.js} +236 -36
  57. package/{chunk-4EZHSKTB.js → chunk-C53ZG23R.js} +2 -2
  58. package/chunk-CHOZJMJS.js +78 -0
  59. package/{chunk-HJUYAD4A.js → chunk-CPUFH46E.js} +8 -8
  60. package/{chunk-LS2ZANRJ.js → chunk-CTUQJVQM.js} +1 -1
  61. package/{chunk-BP4XNZRM.js → chunk-CU3QB4HW.js} +3 -3
  62. package/{chunk-ACTMNVHM.js → chunk-CYSYR67N.js} +1 -1
  63. package/{chunk-KQ4ONNQD.js → chunk-DAWDCRIG.js} +82 -8
  64. package/{chunk-VLTIYV3X.js → chunk-DCLMZ5TX.js} +4 -4
  65. package/{chunk-UKZDAFYT.js → chunk-DSSTTEKI.js} +6 -10
  66. package/{chunk-L7I247DF.js → chunk-EKS2APRJ.js} +21 -5
  67. package/{chunk-HVURBGF3.js → chunk-ESRMFY7G.js} +2 -2
  68. package/{chunk-TRV2MIDW.js → chunk-EXAJ6DCR.js} +1 -0
  69. package/chunk-GMZLP5DV.js +82 -0
  70. package/{chunk-FDTR4QJ6.js → chunk-H6A6X4EK.js} +32 -1
  71. package/{chunk-DVINR3PL.js → chunk-HDLLCBRF.js} +1 -1
  72. package/{chunk-OIMN34NA.js → chunk-HKTIX4ZE.js} +23 -76
  73. package/{chunk-ONXOABJR.js → chunk-HNGRBWYF.js} +3 -0
  74. package/{chunk-H62HCIUP.js → chunk-HYZIYH2H.js} +11 -10
  75. package/{chunk-3VNWWVKB.js → chunk-I3QNET24.js} +30 -17
  76. package/{chunk-WV42OMV7.js → chunk-IAESIMK7.js} +4 -4
  77. package/chunk-JBOO3DKI.js +7808 -0
  78. package/{chunk-O35EJJVP.js → chunk-JJ7P5CIY.js} +56 -34
  79. package/{chunk-OZPMVBJI.js → chunk-JZ5II5UV.js} +15 -20
  80. package/{chunk-JRQFUXY7.js → chunk-KCDUTE5V.js} +96 -19
  81. package/{chunk-QLNJRTKI.js → chunk-KHVJXNRY.js} +100 -100
  82. package/{chunk-ADTY7BWR.js → chunk-L76GP4ER.js} +24 -5
  83. package/{chunk-7S4YWN7P.js → chunk-MX574M24.js} +1 -1
  84. package/{chunk-FZGV4FGK.js → chunk-NUHHBEJC.js} +378 -187
  85. package/{chunk-53HEEOTT.js → chunk-O26PCYLS.js} +80 -13
  86. package/{chunk-3DII57IT.js → chunk-O2OWEFII.js} +1 -1
  87. package/{chunk-TDRTS7QW.js → chunk-O6JPWEEK.js} +77 -17
  88. package/chunk-OCZKATRC.js +129 -0
  89. package/{chunk-6D6VBVEW.js → chunk-OTEMQQZI.js} +80 -14
  90. package/chunk-P6GMCCAT.js +870 -0
  91. package/{chunk-3SK4LEIH.js → chunk-PLRLUZWS.js} +853 -209
  92. package/{chunk-DHDMC6FO.js → chunk-QKUMVP3O.js} +11 -6
  93. package/{chunk-X4QAVDFE.js → chunk-RMAWULCS.js} +498 -480
  94. package/{chunk-V4MJDUSR.js → chunk-RSEEDUMS.js} +2 -2
  95. package/{chunk-UZGQNTVW.js → chunk-S5XGT6GB.js} +5 -3
  96. package/{chunk-76WEAXJB.js → chunk-SACTCJAC.js} +18 -15
  97. package/{chunk-AFUORTY4.js → chunk-SONWNI3L.js} +21 -21
  98. package/{chunk-BYMV6QZG.js → chunk-TNIX77YM.js} +4 -0
  99. package/{chunk-2YMRWISD.js → chunk-TU5NE4U3.js} +9 -84
  100. package/chunk-TY3TIUJK.js +89 -0
  101. package/chunk-UEGYKNHO.js +13349 -0
  102. package/chunk-UNYJU5L6.js +780 -0
  103. package/{chunk-J4MOO56S.js → chunk-UQNS32WZ.js} +10 -2
  104. package/chunk-VIWDGTDA.js +8 -0
  105. package/chunk-VJVNU77E.js +83 -0
  106. package/{chunk-EHKBVWKL.js → chunk-VYN7O3OY.js} +1 -1
  107. package/{chunk-NEDZDG3M.js → chunk-WILHZY7K.js} +45 -45
  108. package/{chunk-UKWGR5SS.js → chunk-WIWM4FE3.js} +187 -398
  109. package/{chunk-R7N5TMTV.js → chunk-X7YLNILS.js} +13 -13
  110. package/{chunk-O6OSWFZQ.js → chunk-XUWRURDF.js} +6 -0
  111. package/{chunk-Q67DOFOO.js → chunk-Y3PMXGLH.js} +2 -0
  112. package/{chunk-SNPMM7H3.js → chunk-Y6AZRODX.js} +13 -13
  113. package/{chunk-RSJECD7I.js → chunk-YJKDTJ2X.js} +7 -7
  114. package/{chunk-SH43IESU.js → chunk-YUNJN43V.js} +44 -9
  115. package/{chunk-TOP2VXOR.js → chunk-Z4CSIXYP.js} +2 -2
  116. package/{chunk-2F7RJC6L.js → chunk-ZOVKKMF6.js} +1 -1
  117. package/chunk-ZRAU6T47.js +56 -0
  118. package/{chunk-Z77CRGTW.js → chunk-ZYWQNCBN.js} +1 -1
  119. package/commandRegistry-HUFXCF7Z.js +833 -0
  120. package/{contentThunks-YLWTUILV.js → contentThunks-TD5YOAQM.js} +32 -30
  121. package/{cooldownCommands-REAWYVTY.js → cooldownCommands-ZLEPIB4A.js} +2 -2
  122. package/{createAgentAutomationAction-HFLPOBWQ.js → createAgentAutomationAction-XUG62ANM.js} +32 -30
  123. package/{createDialogAction-4H52MURR.js → createDialogAction-L3CMZKNL.js} +36 -33
  124. package/{createPageAction-5YDRMJOS.js → createPageAction-WJ3MX6JS.js} +38 -36
  125. package/{chunk-NUVMWYJM.js → cursorProvider-YGGNMVWX.js} +2494 -9892
  126. package/{dbSlice-XVWBAGYN.js → dbSlice-DQ32LYTJ.js} +8 -8
  127. package/{deleteFile-YG6QMJLU.js → deleteFile-NX6QHCWZ.js} +3 -3
  128. package/{dialogCommands-KFK2FF5B.js → dialogCommands-VM3I4HBW.js} +45 -41
  129. package/{dialogSlice-TMSHUGEM.js → dialogSlice-DSHG3YUE.js} +36 -29
  130. package/{dist-VODFSGNG.js → dist-NJC2W7I4.js} +61 -54
  131. package/{docCreateCommands-V777WOZ7.js → docCreateCommands-TYUJPCOP.js} +44 -40
  132. package/{docDeleteCommands-5KHT7Z5Q.js → docDeleteCommands-5XEG2LXO.js} +44 -40
  133. package/{docReadCommands-BLROGWP3.js → docReadCommands-M6RO6QHV.js} +43 -39
  134. package/{docStore-OBC5QOW7.js → docStore-RYOGMPEF.js} +11 -10
  135. package/{docUpdateCommands-QXOZHQ5H.js → docUpdateCommands-DKOFTZRX.js} +44 -40
  136. package/{fetchMessages-EIU7UFFK.js → fetchMessages-67MEFPZR.js} +2 -2
  137. package/{getPricing-LUSEABA6.js → getPricing-NMMFT3YI.js} +3 -3
  138. package/{handleSendMessageAction-4LGNXH6T.js → handleSendMessageAction-XH742B27.js} +91 -83
  139. package/index.js +87 -884
  140. package/{localDialogRead-BTFJ4V2I.js → localDialogRead-EBRS242U.js} +2 -2
  141. package/{localRuntimeAuthority-6IR6BBXE.js → localRuntimeAuthority-5W6IJRAD.js} +6 -6
  142. package/{localRuntimeDb-SYQGUF4U.js → localRuntimeDb-3LRMNLCM.js} +1 -1
  143. package/{machineCommands-SNLCRHQK.js → machineCommands-EY3SKJCP.js} +85 -77
  144. package/{machineWsRunDispatch-ZGZVDQSO.js → machineWsRunDispatch-OJ77YNRD.js} +82 -74
  145. package/{memberThunks-QGFLFVCI.js → memberThunks-5ZXPR63F.js} +9 -9
  146. package/{models-T3SG6MJ5.js → models-ZPU5EDF4.js} +2 -2
  147. package/oauthTokenStore-ITEB663N.js +23 -0
  148. package/package.json +1 -1
  149. package/pdf-U6KSUEZZ.js +26435 -0
  150. package/processSpawn-SOAV3FEV.js +11 -0
  151. package/profileConfig-ZGOFORWV.js +43 -0
  152. package/{providerPresetApply-FG6NZ57W.js → providerPresetApply-76AVU3HD.js} +7 -7
  153. package/{providerRegistry-757OWH3O.js → providerRegistry-Z62NC45X.js} +11 -7
  154. package/{read-COE3ZYR6.js → read-EPTJRAEF.js} +5 -5
  155. package/{readDocTool-5USN4A6V.js → readDocTool-W4NDXNEX.js} +5 -3
  156. package/{readlineWorkspace-OUL7ZN7D.js → readlineWorkspace-PMTHAVMB.js} +2447 -2022
  157. package/{removeDialogAgentAction-IX3MN2ZO.js → removeDialogAgentAction-BVAWQKXE.js} +17 -19
  158. package/{runAgentClientLoop-GD3APV7V.js → runAgentClientLoop-7WXN6I7L.js} +62 -58
  159. package/{runtimeDoctorCommands-X6WDBEQX.js → runtimeDoctorCommands-3USD722U.js} +3 -3
  160. package/runtimeModeArgs-2Y7BALTO.js +31 -0
  161. package/{setDialogExtraReferencesAction-X4HCPNZL.js → setDialogExtraReferencesAction-LYY45IAD.js} +12 -11
  162. package/{setPrimaryDialogAgentAction-4GMIQLOD.js → setPrimaryDialogAgentAction-73IL7DLU.js} +18 -20
  163. package/{settingSlice-ZQZVUPKK.js → settingSlice-Q6EKL7EQ.js} +9 -9
  164. package/{skillDiscovery-CYUCJMAG.js → skillDiscovery-ZBU76COE.js} +3 -3
  165. package/{spaceCommands-TIDVUPDV.js → spaceCommands-QFP4ZXKG.js} +44 -40
  166. package/{streamAgentChatTurn-M73KWCCU.js → streamAgentChatTurn-B4PXPJJS.js} +184 -91
  167. package/{switchDialogAgentAction-N52LRPA3.js → switchDialogAgentAction-UUXDSQ6X.js} +15 -17
  168. package/{tableCommands-O6NWHFKV.js → tableCommands-G7RV3RU3.js} +4 -4
  169. package/{toolApiClient-QVJ6HDNN.js → toolApiClient-INIQCPGY.js} +3 -3
  170. package/{tools-DXXDQ2CP.js → tools-QFS2L7BU.js} +55 -51
  171. package/{tuiSummaryLlmCaller-VJY3YD2Q.js → tuiSummaryLlmCaller-74NRRLVW.js} +18 -16
  172. package/{updateCommands-2M74UL7P.js → updateCommands-4EHDLF5J.js} +3 -3
  173. package/{updateDialogTitleAction-XI73NQMU.js → updateDialogTitleAction-HTDYCNNZ.js} +81 -43
  174. package/agentListCommands-O4AEMQVV.js +0 -406
  175. package/agentRecordCommands-6QK7AMXQ.js +0 -128
  176. package/chunk-M76ECQRD.js +0 -13658
  177. package/chunk-Q5FJJ6XI.js +0 -103
  178. package/chunk-S7Z2HMCN.js +0 -25
  179. package/chunk-WRFW73PB.js +0 -18881
  180. package/{chunk-VMFTFOWF.js → chunk-3AH7LNUB.js} +7 -7
  181. package/{chunk-X7HHHIOZ.js → chunk-Y6ROFCZO.js} +0 -0
  182. package/{db-WK5MDZVN.js → db-VQSAOWAO.js} +1 -1
@@ -2,7 +2,7 @@ import {
2
2
  deleteDbRecord,
3
3
  queryUserRecords,
4
4
  readDbRecord
5
- } from "./chunk-76WEAXJB.js";
5
+ } from "./chunk-SACTCJAC.js";
6
6
  import {
7
7
  mergeAndDedupUserData
8
8
  } from "./chunk-KQHGZWSV.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isAgentRunTerminalStatus
3
- } from "./chunk-3VNWWVKB.js";
3
+ } from "./chunk-I3QNET24.js";
4
4
  import {
5
5
  isCompiledBinary,
6
6
  resolveCliEntrypointPath
@@ -1056,7 +1056,14 @@ function defaultGetProcessStartTime(pid) {
1056
1056
  const output = nodeExecFileSync("ps", ["-o", "lstart=", "-p", String(pid)], {
1057
1057
  encoding: "utf8",
1058
1058
  stdio: ["ignore", "pipe", "ignore"],
1059
- timeout: 1e3
1059
+ timeout: 1e3,
1060
+ // `ps -o lstart` 的日期串随系统 locale 变化:
1061
+ // LANG=en_US.UTF-8 → "Thu Oct 8 08:54:18 2026"(new Date 可解析)
1062
+ // LANG=zh_CN.UTF-8 → "四 10月 8 08:54:18 2026"(new Date → NaN → null)
1063
+ // 这会让 isPidReused 的结论依赖调用者环境:同一条 run 记录在英文
1064
+ // locale 下被判 pid reused → orphaned,中文 locale 下不判。强制 C
1065
+ // locale 让输出恒为可解析的英文格式,结果与 locale 无关。
1066
+ env: { ...process.env, LC_ALL: "C", LANG: "C" }
1060
1067
  }).trim();
1061
1068
  if (!output) return null;
1062
1069
  const d = new Date(output);
@@ -1473,14 +1480,20 @@ async function terminateRunProcess(record, initialSignal, deps) {
1473
1480
  signalGroup(initialSignal);
1474
1481
  if (initialSignal === "SIGTERM") {
1475
1482
  const deadline = nowMs() + TERMINATE_GRACE_MS;
1476
- while (!isPidGone(pid, deps) && nowMs() < deadline) {
1483
+ const maxIterations = Math.ceil(TERMINATE_GRACE_MS / TERMINATE_POLL_MS) + 1;
1484
+ let iterations = 0;
1485
+ while (!isPidGone(pid, deps) && nowMs() < deadline && iterations < maxIterations) {
1486
+ iterations += 1;
1477
1487
  await sleep(TERMINATE_POLL_MS);
1478
1488
  }
1479
1489
  }
1480
1490
  if (!isPidGone(pid, deps)) {
1481
1491
  signalGroup("SIGKILL");
1482
1492
  const killDeadline = nowMs() + TERMINATE_KILL_GRACE_MS;
1483
- while (!isPidGone(pid, deps) && nowMs() < killDeadline) {
1493
+ const maxIterations = Math.ceil(TERMINATE_KILL_GRACE_MS / TERMINATE_POLL_MS) + 1;
1494
+ let iterations = 0;
1495
+ while (!isPidGone(pid, deps) && nowMs() < killDeadline && iterations < maxIterations) {
1496
+ iterations += 1;
1484
1497
  await sleep(TERMINATE_POLL_MS);
1485
1498
  }
1486
1499
  }
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-KHCLMKZZ.js";
5
5
  import {
6
6
  asTrimmedNonEmptyStringArray
7
- } from "./chunk-VMFTFOWF.js";
7
+ } from "./chunk-3AH7LNUB.js";
8
8
  import {
9
9
  asOptionalTrimmedString
10
10
  } from "./chunk-G3SUCT4W.js";
@@ -1,23 +1,30 @@
1
+ import {
2
+ isSubscriptionEndpoint,
3
+ isSubscriptionOAuthCredential
4
+ } from "./chunk-DAWDCRIG.js";
1
5
  import {
2
6
  isOAuthApiKeyRef
3
7
  } from "./chunk-YYLHWIW6.js";
4
8
  import {
5
9
  compareAgentSelection
6
- } from "./chunk-IIVGDG4I.js";
10
+ } from "./chunk-6PHKBY2Q.js";
11
+ import {
12
+ isAgentUnavailableNow
13
+ } from "./chunk-H6A6X4EK.js";
7
14
  import {
8
15
  isAntigravityOAuthAgent
9
- } from "./chunk-UZGQNTVW.js";
16
+ } from "./chunk-S5XGT6GB.js";
10
17
  import {
11
18
  getModelAbility
12
- } from "./chunk-ACTMNVHM.js";
19
+ } from "./chunk-CYSYR67N.js";
20
+ import {
21
+ fnv1a32Hex
22
+ } from "./chunk-WIWM4FE3.js";
13
23
  import {
14
24
  isOwnedAgentKey,
15
25
  ownedAgentKey,
16
26
  publicAgentKey
17
27
  } from "./chunk-M2EJHDJP.js";
18
- import {
19
- fnv1a32Hex
20
- } from "./chunk-UKWGR5SS.js";
21
28
 
22
29
  // packages/ai/agent/agentBilling.ts
23
30
  function resolveBillingSource(candidate) {
@@ -36,6 +43,9 @@ function resolveBillingSource(candidate) {
36
43
  }
37
44
  if (candidate?.isOAuth === true || candidate?.billingSource === "user_subscription" || candidate?.apiSource === "oauth" || isOAuthApiKeyRef(candidate?.apiKeyRef)) return "user_subscription";
38
45
  if (candidate?.apiSource === "custom" || candidate?.billingSource === "user_api") {
46
+ if (isSubscriptionEndpoint(candidate?.customProviderUrl) || isSubscriptionOAuthCredential(candidate?.apiKeyRef)) {
47
+ return "user_subscription";
48
+ }
39
49
  return "user_api";
40
50
  }
41
51
  return "platform_credits";
@@ -227,6 +237,16 @@ function deriveCredentialGroup(ref) {
227
237
  credentialKind: "api-key"
228
238
  };
229
239
  }
240
+ function deriveCustomProviderCredentialGroup(userId, customProviderUrl) {
241
+ if (typeof customProviderUrl !== "string" || !customProviderUrl.trim()) {
242
+ return void 0;
243
+ }
244
+ const basis = `${userId ?? ""}|${customProviderUrl.trim().toLowerCase()}`;
245
+ return {
246
+ credentialGroup: `custom-${fnv1a32Hex(basis)}`,
247
+ credentialKind: "api-key"
248
+ };
249
+ }
230
250
  function summarizeCredentialGroups(agents, now = Date.now()) {
231
251
  const groups = /* @__PURE__ */ new Map();
232
252
  for (const agent of agents) {
@@ -327,6 +347,15 @@ function resolveFavoriteStatus(record, options) {
327
347
  }
328
348
  return { isFavorite: false, favoritedAt: null };
329
349
  }
350
+ function isOwnedAgentRecord(record, userId) {
351
+ if (!userId) return false;
352
+ if (typeof record?.userId === "string" && record.userId === userId || typeof record?.ownerId === "string" && record.ownerId === userId) {
353
+ return true;
354
+ }
355
+ return [record?.dbKey, record?.privateKey].some(
356
+ (key) => isOwnedAgentKey(key, userId)
357
+ );
358
+ }
330
359
  function toSafeAgentSummary(record, options) {
331
360
  const rawId = parseAgentRecordId(
332
361
  typeof record?.privateKey === "string" ? record.privateKey : record?.dbKey,
@@ -356,12 +385,13 @@ function toSafeAgentSummary(record, options) {
356
385
  const isPublic = record?.isPublic === true || record?.isPublicFlag === true || record?.publicRecordExists === true;
357
386
  const updatedAt = safeTimestamp(record?.updatedAt ?? record?.createdAt ?? record?.created);
358
387
  const nextAvailableAt = typeof record?.nextAvailableAt === "number" && Number.isFinite(record.nextAvailableAt) ? record.nextAvailableAt : void 0;
388
+ const rawQuota = record?.quota;
389
+ const quota = rawQuota && typeof rawQuota === "object" && Array.isArray(rawQuota.windows) && typeof rawQuota.observedAt === "number" && Number.isFinite(rawQuota.observedAt) ? rawQuota : void 0;
359
390
  const currentUserId = options?.userId;
360
- const isOwnedByRecord = Boolean(currentUserId) && (typeof record?.userId === "string" && record.userId === currentUserId || typeof record?.ownerId === "string" && record.ownerId === currentUserId);
361
391
  const ownedKey = currentUserId ? [record?.dbKey, record?.privateKey].find(
362
392
  (key) => isOwnedAgentKey(key, currentUserId)
363
393
  ) : void 0;
364
- const isOwned = isOwnedByRecord || Boolean(ownedKey);
394
+ const isOwned = isOwnedAgentRecord(record, currentUserId);
365
395
  const isOAuth = isOAuthApiKeyRef(record?.apiKeyRef);
366
396
  const billingSource = resolveBillingSource({
367
397
  ...record,
@@ -418,6 +448,7 @@ function toSafeAgentSummary(record, options) {
418
448
  isOwned,
419
449
  isOAuth,
420
450
  ...nextAvailableAt !== void 0 ? { nextAvailableAt } : {},
451
+ ...quota !== void 0 ? { quota } : {},
421
452
  ...credentialGroup !== void 0 ? { credentialGroup } : {},
422
453
  ...credentialKind !== void 0 ? { credentialKind } : {},
423
454
  // 「未知 ≠ 独立」:无 credentialGroup 时显式 credentialed:false,调用方
@@ -448,6 +479,8 @@ var COMPACT_AGENT_SUMMARY_FIELDS = [
448
479
  // 决策信息(CLI --show-unavailable 场景);默认列表已把这类 agent 过滤掉,
449
480
  // 所以通常根本不占字节。
450
481
  "nextAvailableAt",
482
+ // 额度快照:只有上游真上报过窗口的 agent 才带(通常是小对象)。
483
+ "quota",
451
484
  "credentialGroup",
452
485
  "credentialKind",
453
486
  "credentialed"
@@ -481,6 +514,7 @@ var UNAVAILABLE_AGENT_SUMMARY_FIELDS = [
481
514
  "isOAuth",
482
515
  "isOwned",
483
516
  "nextAvailableAt",
517
+ "quota",
484
518
  "favoritedAt",
485
519
  "updatedAt"
486
520
  ];
@@ -500,12 +534,131 @@ function toUnavailableAgentSummary(summary) {
500
534
  return item;
501
535
  }
502
536
 
537
+ // packages/ai/agent/agentDiscovery.ts
538
+ function isPreferredAgent(agent) {
539
+ return agent.isFavorite === true || agent.isOwned === true || agent.isOAuth === true || agent.billingSource === "user_subscription" || agent.billingSource === "user_api" || agent.billingSource === "local";
540
+ }
541
+ function isPublicDiscoveryAgent(agent) {
542
+ return agent.isPublic === true && !isPreferredAgent(agent);
543
+ }
544
+ function resolveDiscoveryScope(args) {
545
+ const rawScope = typeof args?.scope === "string" ? args.scope.trim().toLowerCase() : void 0;
546
+ const hasScope = rawScope !== void 0 && rawScope !== "";
547
+ const hasPublicOnly = typeof args?.publicOnly === "boolean";
548
+ const publicOnly = args?.publicOnly === true;
549
+ if (hasScope) {
550
+ if (rawScope !== "preferred" && rawScope !== "public" && rawScope !== "all") {
551
+ throw new Error(`Invalid scope '${args?.scope}': must be 'preferred', 'public', or 'all'.`);
552
+ }
553
+ const scope = rawScope;
554
+ if (hasPublicOnly) {
555
+ if (publicOnly && scope !== "public") {
556
+ throw new Error(
557
+ `Conflicting arguments: scope='${args?.scope}' conflicts with publicOnly=true.`
558
+ );
559
+ }
560
+ if (!publicOnly && scope === "public") {
561
+ throw new Error(
562
+ `Conflicting arguments: scope='${args?.scope}' conflicts with publicOnly=false.`
563
+ );
564
+ }
565
+ }
566
+ return scope;
567
+ }
568
+ if (hasPublicOnly && publicOnly) {
569
+ return "public";
570
+ }
571
+ return "preferred";
572
+ }
573
+ function agentIdentityKeys(agent) {
574
+ return [agent.agentKey, agent.publicKey, agent.id].filter(
575
+ (key) => typeof key === "string" && key.length > 0
576
+ );
577
+ }
578
+ function deduplicateAgentSummaries(agents) {
579
+ const byIdentity = /* @__PURE__ */ new Map();
580
+ for (const agent of agents) {
581
+ const keys = agentIdentityKeys(agent);
582
+ const existing = keys.map((key) => byIdentity.get(key)).find(Boolean);
583
+ if (!existing) {
584
+ for (const key of keys) byIdentity.set(key, agent);
585
+ continue;
586
+ }
587
+ const winner = isPreferredAgent(agent) && !isPreferredAgent(existing) ? agent : existing;
588
+ for (const key of /* @__PURE__ */ new Set([...agentIdentityKeys(existing), ...keys])) byIdentity.set(key, winner);
589
+ }
590
+ return [...new Set(byIdentity.values())];
591
+ }
592
+ function filterAgentsByScope(agents, scope) {
593
+ const unique = deduplicateAgentSummaries(agents);
594
+ if (scope === "preferred") return unique.filter((agent) => isPreferredAgent(agent));
595
+ if (scope === "public") return unique.filter((agent) => isPublicDiscoveryAgent(agent));
596
+ return unique.filter((agent) => isPreferredAgent(agent) || agent.isPublic === true);
597
+ }
598
+ function matchesAgentQuery(agent, query) {
599
+ if (!query || typeof query !== "string") return true;
600
+ const q = query.trim().toLowerCase();
601
+ if (!q) return true;
602
+ const candidates = [
603
+ agent.name,
604
+ agent.model,
605
+ agent.provider,
606
+ agent.handle,
607
+ agent.agentKey,
608
+ agent.publicKey,
609
+ agent.id
610
+ ];
611
+ return candidates.some((text) => typeof text === "string" && text.toLowerCase().includes(q));
612
+ }
613
+ function buildAgentDiscoveryResult(options) {
614
+ const scope = resolveDiscoveryScope({
615
+ scope: options.scope,
616
+ publicOnly: options.publicOnly
617
+ });
618
+ const now = options.now ?? Date.now();
619
+ let scopedAgents = filterAgentsByScope(options.agents, scope);
620
+ if (options.query && typeof options.query === "string" && options.query.trim()) {
621
+ scopedAgents = scopedAgents.filter((a) => matchesAgentQuery(a, options.query));
622
+ }
623
+ const unavailableList = scopedAgents.filter((a) => isAgentUnavailableNow(a, now));
624
+ const unavailableCount = unavailableList.length;
625
+ const unavailableAgents = sortSafeAgentSummaries(unavailableList).map(toUnavailableAgentSummary);
626
+ const credentialGroups = summarizeCredentialGroups(scopedAgents, now);
627
+ if (options.showUnavailable !== true) {
628
+ scopedAgents = scopedAgents.filter((a) => !isAgentUnavailableNow(a, now));
629
+ }
630
+ const sortedAgents = sortSafeAgentSummaries(scopedAgents);
631
+ const projectedAgents = options.verbose === true ? sortedAgents.map(omitNullishAgentSummaryFields) : sortedAgents.map(toCompactAgentSummary);
632
+ return {
633
+ total: projectedAgents.length,
634
+ unavailableCount,
635
+ unavailableAgents,
636
+ credentialGroups,
637
+ agents: projectedAgents
638
+ };
639
+ }
640
+ function toDiscoverySafeAgentSummary(record, options) {
641
+ const mergedOptions = record?.publicRecordExists === true ? { ...options, publicRecordExists: true } : options;
642
+ return toSafeAgentSummary(record, mergedOptions);
643
+ }
644
+ function assembleAgentDiscoveryResult(options) {
645
+ const { records, summaryOptions, ...discoveryOptions } = options;
646
+ const agents = records.map(
647
+ (record) => toDiscoverySafeAgentSummary(
648
+ record,
649
+ typeof summaryOptions === "function" ? summaryOptions(record) : summaryOptions
650
+ )
651
+ );
652
+ return buildAgentDiscoveryResult({ ...discoveryOptions, agents });
653
+ }
654
+
503
655
  export {
504
656
  deriveCredentialGroup,
657
+ deriveCustomProviderCredentialGroup,
505
658
  summarizeCredentialGroups,
506
- toSafeAgentSummary,
507
- sortSafeAgentSummaries,
508
- omitNullishAgentSummaryFields,
509
- toCompactAgentSummary,
510
- toUnavailableAgentSummary
659
+ resolveDiscoveryScope,
660
+ matchesAgentQuery,
661
+ buildAgentDiscoveryResult,
662
+ toDiscoverySafeAgentSummary,
663
+ assembleAgentDiscoveryResult
511
664
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  generatePkcePair,
3
3
  startCallbackServer
4
- } from "./chunk-53HEEOTT.js";
4
+ } from "./chunk-O26PCYLS.js";
5
5
  import {
6
6
  toErrorMessage
7
7
  } from "./chunk-HNMXYYJR.js";
@@ -0,0 +1,153 @@
1
+ import {
2
+ isRecord
3
+ } from "./chunk-KUG52IAP.js";
4
+
5
+ // packages/core/chat/validationUrl.ts
6
+ function safeUrl(raw) {
7
+ if (typeof raw !== "string") return void 0;
8
+ const trimmed = raw.trim();
9
+ if (!/^https?:\/\//i.test(trimmed)) return void 0;
10
+ try {
11
+ const parsed = new URL(trimmed);
12
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
13
+ return void 0;
14
+ }
15
+ return parsed.href;
16
+ } catch {
17
+ return void 0;
18
+ }
19
+ }
20
+ function scanValidationDetails(details) {
21
+ if (!Array.isArray(details)) return {};
22
+ let url;
23
+ let text;
24
+ let learnMoreUrl;
25
+ for (const detail of details) {
26
+ if (url && learnMoreUrl) break;
27
+ if (!isRecord(detail)) continue;
28
+ const metadata = isRecord(detail.metadata) ? detail.metadata : void 0;
29
+ if (metadata) {
30
+ url = url ?? safeUrl(metadata.validation_url);
31
+ text = text ?? (typeof metadata.validation_url_link_text === "string" ? metadata.validation_url_link_text : void 0);
32
+ learnMoreUrl = learnMoreUrl ?? safeUrl(metadata.validation_learn_more_url);
33
+ }
34
+ const links = Array.isArray(detail.links) ? detail.links : [];
35
+ for (const link of links) {
36
+ if (!isRecord(link)) continue;
37
+ const linkUrl = safeUrl(link.url);
38
+ if (!linkUrl) continue;
39
+ const desc = typeof link.description === "string" ? link.description : "";
40
+ if (!url && /verify|continue/i.test(desc)) {
41
+ url = linkUrl;
42
+ text = text ?? desc;
43
+ } else if (!learnMoreUrl && /learn more/i.test(desc)) {
44
+ learnMoreUrl = linkUrl;
45
+ }
46
+ }
47
+ }
48
+ return { url, text, learnMoreUrl };
49
+ }
50
+ function unescapeJsonString(text) {
51
+ return text.replace(
52
+ /\\(["\\/nrtbf]|u[0-9a-fA-F]{4})/g,
53
+ (_match, esc) => {
54
+ switch (esc[0]) {
55
+ case "n":
56
+ return "\n";
57
+ case "r":
58
+ return "\r";
59
+ case "t":
60
+ return " ";
61
+ case "b":
62
+ return "\b";
63
+ case "f":
64
+ return "\f";
65
+ case "u":
66
+ return String.fromCharCode(parseInt(esc.slice(1), 16));
67
+ default:
68
+ return esc;
69
+ }
70
+ }
71
+ );
72
+ }
73
+ function sliceBalancedJsonObject(text) {
74
+ const start = text.indexOf("{");
75
+ if (start < 0) return void 0;
76
+ let depth = 0;
77
+ let inString = false;
78
+ let escaped = false;
79
+ for (let i = start; i < text.length; i += 1) {
80
+ const ch = text[i];
81
+ if (inString) {
82
+ if (escaped) escaped = false;
83
+ else if (ch === "\\") escaped = true;
84
+ else if (ch === '"') inString = false;
85
+ continue;
86
+ }
87
+ if (ch === '"') inString = true;
88
+ else if (ch === "{") depth += 1;
89
+ else if (ch === "}") {
90
+ depth -= 1;
91
+ if (depth === 0) return text.slice(start, i + 1);
92
+ }
93
+ }
94
+ return void 0;
95
+ }
96
+ function parseBalancedJson(text) {
97
+ const slice = sliceBalancedJsonObject(text);
98
+ if (!slice) return void 0;
99
+ try {
100
+ return JSON.parse(slice);
101
+ } catch {
102
+ return void 0;
103
+ }
104
+ }
105
+ function findValidationInParsed(parsed, depth = 0) {
106
+ if (depth > 3 || !isRecord(parsed)) return {};
107
+ const err = isRecord(parsed.error) ? parsed.error : parsed;
108
+ const fromDetails = scanValidationDetails(isRecord(err) ? err.details : void 0);
109
+ if (fromDetails.url) return fromDetails;
110
+ const nested = isRecord(err) ? err.message : void 0;
111
+ if (typeof nested === "string" && nested.trim().startsWith("{")) {
112
+ try {
113
+ const reparsed = findValidationInParsed(JSON.parse(nested), depth + 1);
114
+ if (reparsed.url) return reparsed;
115
+ } catch {
116
+ }
117
+ }
118
+ return {};
119
+ }
120
+ function stripTerminalControlChars(raw) {
121
+ return raw.replace(/[\u0000-\u001f\u007f]/g, "");
122
+ }
123
+ function regexValidationFallback(text) {
124
+ const urlMatch = text.match(
125
+ /validation_url[^h]{0,10}(https?:\/\/[^\s"\\]+)/i
126
+ );
127
+ if (!urlMatch) return {};
128
+ const textMatch = text.match(
129
+ /validation_url_link_text[^A-Za-z]{0,10}([^"\\\n]{1,60})/i
130
+ );
131
+ return {
132
+ // safeUrl first (normalizes C0 into %XX); fall back to stripping controls
133
+ // so a truncated-but-real link is still emitted rather than dropped.
134
+ url: safeUrl(urlMatch[1]) ?? stripTerminalControlChars(urlMatch[1]),
135
+ text: textMatch?.[1] ? stripTerminalControlChars(textMatch[1].trim()) || void 0 : void 0
136
+ };
137
+ }
138
+ function extractGoogleValidationLink(errorText) {
139
+ for (const candidate of [
140
+ parseBalancedJson(errorText),
141
+ parseBalancedJson(unescapeJsonString(errorText))
142
+ ]) {
143
+ if (candidate === void 0) continue;
144
+ const found = findValidationInParsed(candidate);
145
+ if (found.url) return found;
146
+ }
147
+ return regexValidationFallback(errorText);
148
+ }
149
+
150
+ export {
151
+ scanValidationDetails,
152
+ extractGoogleValidationLink
153
+ };