nolo-cli 0.83.0 → 0.84.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 (106) hide show
  1. package/{_executeModel-LUNEV235.js → _executeModel-BPUR2QYH.js} +29 -28
  2. package/{action-YVYQEAAV.js → action-P4TNFGAD.js} +3 -3
  3. package/{addContentAction-O7R66HEX.js → addContentAction-MB2HHMDZ.js} +2 -2
  4. package/{addDialogAgentAction-74OA7KYP.js → addDialogAgentAction-S2NRBCWW.js} +2 -2
  5. package/{agentDeleteCommand-2YAHAZFJ.js → agentDeleteCommand-MNAA6MIG.js} +15 -14
  6. package/{agentEmailCommands-G6A7IRPQ.js → agentEmailCommands-SK34WJKU.js} +37 -36
  7. package/{agentListCommands-KMS675GZ.js → agentListCommands-I26MKI4T.js} +31 -19
  8. package/{agentMachineCommands-W2SMNSQ3.js → agentMachineCommands-M6QDR6P3.js} +15 -14
  9. package/{agentProviderCommands-GNPTL5XR.js → agentProviderCommands-X3UNW77C.js} +1 -1
  10. package/{agentRecordCommands-D7BRMFNI.js → agentRecordCommands-HTHLO2MM.js} +36 -35
  11. package/{agentRunCommand-VL6MMEUB.js → agentRunCommand-IAIRCMTH.js} +38 -36
  12. package/{agentRuntimeLocal-VXZSDIGT.js → agentRuntimeLocal-3WTYYIT2.js} +16 -11
  13. package/{agentSlice-5YJHUO47.js → agentSlice-TVP3HINW.js} +2 -2
  14. package/{appDeleteCommands-32MHLR4L.js → appDeleteCommands-SB5TNLKY.js} +16 -15
  15. package/{appDeployCommands-WCQOUSOB.js → appDeployCommands-2IPKZINV.js} +16 -15
  16. package/{appDeployStatusCommands-6QKB7DYN.js → appDeployStatusCommands-K63TFUID.js} +16 -15
  17. package/{appGetCommands-SFAPP5PB.js → appGetCommands-VU2SLNEH.js} +16 -15
  18. package/{appListCommands-EKUBDRUO.js → appListCommands-S3T4DJ36.js} +16 -15
  19. package/{authCommand-F4EFRRX6.js → authCommand-HGP2XTKC.js} +100 -8
  20. package/{builtinSkillRegistry-FUAVTRVZ.js → builtinSkillRegistry-Q2VVY3SC.js} +2 -2
  21. package/{chatQueueReduxAdapter-PQMRR2PK.js → chatQueueReduxAdapter-TWIYKVIZ.js} +9 -9
  22. package/{chunk-Z77CRGTW.js → chunk-3AMA42ZI.js} +1 -1
  23. package/{chunk-5FBTLSFG.js → chunk-3BGIKIPF.js} +317 -153
  24. package/{chunk-ORYWEJO4.js → chunk-3IUWIAHP.js} +3 -3
  25. package/{chunk-Q2XN3EOZ.js → chunk-3VUWPRFW.js} +17 -7
  26. package/{chunk-GEPUP7OO.js → chunk-3YIAR5UI.js} +1 -1
  27. package/{chunk-5H7KJX7J.js → chunk-4MK3I7Y4.js} +1 -1
  28. package/{chunk-6VFARHZW.js → chunk-52Q2IW2X.js} +783 -999
  29. package/{chunk-6Q33GUCC.js → chunk-5MEYHVIB.js} +1 -1
  30. package/{chunk-6YTOJY35.js → chunk-6D2JFXLY.js} +35 -0
  31. package/{chunk-FZGV4FGK.js → chunk-6GFOD3TK.js} +260 -140
  32. package/{chunk-HJUYAD4A.js → chunk-6Z7MY3V7.js} +1 -1
  33. package/{chunk-V4MJDUSR.js → chunk-AHAHBQMU.js} +1 -1
  34. package/{chunk-TOP2VXOR.js → chunk-BFDFRLLQ.js} +2 -2
  35. package/chunk-BMQ2MJUK.js +153 -0
  36. package/{chunk-RG6JBBX5.js → chunk-CWQINZEA.js} +119 -3
  37. package/{chunk-BTI7PJDX.js → chunk-DD6XE56O.js} +12 -65
  38. package/{chunk-ETI2NYVF.js → chunk-FKNWP6SG.js} +1 -1
  39. package/{chunk-SSDAAEC2.js → chunk-FP76KI2Y.js} +280 -40
  40. package/chunk-FV3JEYR3.js +870 -0
  41. package/{chunk-DHDMC6FO.js → chunk-GIVFXPWK.js} +2 -0
  42. package/chunk-GMZLP5DV.js +82 -0
  43. package/{chunk-UZGQNTVW.js → chunk-GNCCNNZD.js} +3 -1
  44. package/{chunk-AFUORTY4.js → chunk-GP5LKBUZ.js} +1 -1
  45. package/{chunk-ZCYXJSTU.js → chunk-H4AHY5BU.js} +4 -81
  46. package/{chunk-OEVAY4J6.js → chunk-HAFJ3NDE.js} +2 -2
  47. package/{chunk-IIVGDG4I.js → chunk-HCT7U36O.js} +3 -0
  48. package/{chunk-4OEFYTWL.js → chunk-HKNXJGEC.js} +1 -1
  49. package/{chunk-VLTIYV3X.js → chunk-HYJFRTLW.js} +1 -1
  50. package/{chunk-NA35QHCF.js → chunk-K36IXSCQ.js} +1 -1
  51. package/{chunk-DRGSDQBL.js → chunk-KAUSRTO6.js} +2 -2
  52. package/{chunk-GPCZ7UXG.js → chunk-LJ5VW2UJ.js} +1 -1
  53. package/{chunk-YFE4A4O7.js → chunk-LMREEBWT.js} +120 -37
  54. package/{chunk-JRQFUXY7.js → chunk-LVIFM7VW.js} +1 -1
  55. package/{chunk-RFCKMYDK.js → chunk-MZYBSTMH.js} +4 -4
  56. package/chunk-OCZKATRC.js +129 -0
  57. package/{chunk-DNCEALKX.js → chunk-P5EVSOPA.js} +2 -2
  58. package/{chunk-BP4XNZRM.js → chunk-PBA4UJBK.js} +1 -1
  59. package/{chunk-G2O6V3HJ.js → chunk-PMAIQX7A.js} +3 -3
  60. package/{chunk-AEOE4Z6Q.js → chunk-QSHEEA5N.js} +2 -2
  61. package/{chunk-KQ4ONNQD.js → chunk-QU7KDSZX.js} +1 -1
  62. package/{chunk-45C5ER5U.js → chunk-RPJUFEGR.js} +4 -4
  63. package/{chunk-X6DN5HBD.js → chunk-U4OKDZFH.js} +3 -3
  64. package/{chunk-4S5QUMJP.js → chunk-UDVH2P4A.js} +4 -4
  65. package/{chunk-UKZDAFYT.js → chunk-UEVXFHQB.js} +2 -2
  66. package/{chunk-H62HCIUP.js → chunk-VRTTFDBM.js} +2 -1
  67. package/{chunk-6IG4XSS6.js → chunk-WP5UXDA5.js} +71 -4
  68. package/{chunk-3DII57IT.js → chunk-XD2MJFUG.js} +1 -1
  69. package/{chunk-QVKRR2SS.js → chunk-XP3VVAPG.js} +878 -175
  70. package/{chunk-L5UXH3B2.js → chunk-Z2PV6O2T.js} +18 -2
  71. package/{chunk-53HEEOTT.js → chunk-Z5625XML.js} +1 -1
  72. package/{contentThunks-GJV22WVZ.js → contentThunks-JYWI7G7I.js} +10 -10
  73. package/{createAgentAutomationAction-6V25TZEO.js → createAgentAutomationAction-Z4SUJ54Y.js} +10 -10
  74. package/{createDialogAction-SX36BGSX.js → createDialogAction-RCHFLVJ2.js} +12 -12
  75. package/{createPageAction-IR4BGJSI.js → createPageAction-YK2253XQ.js} +11 -11
  76. package/{dbSlice-XVWBAGYN.js → dbSlice-A6C6H32X.js} +1 -1
  77. package/{dialogCommands-5J56DFWN.js → dialogCommands-X4UOZQWX.js} +16 -15
  78. package/{dialogSlice-UNX2FAPZ.js → dialogSlice-IVTWLCE2.js} +15 -9
  79. package/{docCreateCommands-KYI2DC2U.js → docCreateCommands-VD6TGHG4.js} +15 -14
  80. package/{docDeleteCommands-67REUSRY.js → docDeleteCommands-OT3R2G4W.js} +16 -15
  81. package/{docReadCommands-HOSVSBDJ.js → docReadCommands-2G7BIXSH.js} +15 -14
  82. package/{docStore-JWVG5NDO.js → docStore-UENKCCDX.js} +2 -2
  83. package/{docUpdateCommands-EMGCSMXY.js → docUpdateCommands-45MVJKZA.js} +15 -14
  84. package/{handleSendMessageAction-B75UOJKF.js → handleSendMessageAction-LM2J4HC3.js} +50 -58
  85. package/index.js +51 -51
  86. package/{machineCommands-GFPTOY6L.js → machineCommands-6N6MQIE6.js} +38 -37
  87. package/{machineWsRunDispatch-46PSZ3DJ.js → machineWsRunDispatch-7MFKVQCR.js} +35 -34
  88. package/{memberThunks-QGFLFVCI.js → memberThunks-P2ECUJ56.js} +2 -2
  89. package/package.json +1 -1
  90. package/pdf-U6KSUEZZ.js +26435 -0
  91. package/{providerPresetApply-FG6NZ57W.js → providerPresetApply-XI3WUPTI.js} +2 -2
  92. package/{providerRegistry-757OWH3O.js → providerRegistry-KEPWWGXD.js} +2 -2
  93. package/{readlineWorkspace-UFSWHFKD.js → readlineWorkspace-JWBON5CX.js} +184 -63
  94. package/{removeDialogAgentAction-IX3MN2ZO.js → removeDialogAgentAction-W66BJ7CF.js} +4 -4
  95. package/{runAgentClientLoop-25LJ4XGV.js → runAgentClientLoop-TA4SSPHE.js} +26 -26
  96. package/{setDialogExtraReferencesAction-X4HCPNZL.js → setDialogExtraReferencesAction-2ALKG3WA.js} +3 -3
  97. package/{setPrimaryDialogAgentAction-4GMIQLOD.js → setPrimaryDialogAgentAction-TQZB55F6.js} +4 -4
  98. package/{settingSlice-ZQZVUPKK.js → settingSlice-P4ZW7K5X.js} +2 -2
  99. package/{spaceCommands-NKJVJCQQ.js → spaceCommands-6NSAXB7D.js} +15 -14
  100. package/{streamAgentChatTurn-A46QFV4O.js → streamAgentChatTurn-X5ENGUIS.js} +94 -34
  101. package/{switchDialogAgentAction-N52LRPA3.js → switchDialogAgentAction-3KI72HHS.js} +2 -2
  102. package/{toolApiClient-QVJ6HDNN.js → toolApiClient-G3M73RTB.js} +2 -2
  103. package/{tools-TTDGRNY6.js → tools-XRQR7ZZR.js} +23 -23
  104. package/{tuiSummaryLlmCaller-WFRWERGK.js → tuiSummaryLlmCaller-UFGFOIIW.js} +5 -4
  105. package/{updateDialogTitleAction-QJPZGF52.js → updateDialogTitleAction-ESUUD3GT.js} +10 -10
  106. package/chunk-Q5FJJ6XI.js +0 -103
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-UAD2WT54.js";
8
8
  import {
9
9
  toTimestampMs
10
- } from "./chunk-H62HCIUP.js";
10
+ } from "./chunk-VRTTFDBM.js";
11
11
  import {
12
12
  fetchFromServer,
13
13
  getAllServers
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  patch,
6
6
  read
7
- } from "./chunk-H62HCIUP.js";
7
+ } from "./chunk-VRTTFDBM.js";
8
8
  import {
9
9
  DEVICE_LOCAL_OWNER_ID,
10
10
  isDeviceLocalSpaceBody
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  selectCurrentServer
3
- } from "./chunk-AFUORTY4.js";
3
+ } from "./chunk-GP5LKBUZ.js";
4
4
  import {
5
5
  patch
6
- } from "./chunk-H62HCIUP.js";
6
+ } from "./chunk-VRTTFDBM.js";
7
7
  import {
8
8
  getIsDesktopApp
9
9
  } from "./chunk-QOKAKDPE.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
+ };
@@ -3,10 +3,13 @@ import {
3
3
  } from "./chunk-YYLHWIW6.js";
4
4
  import {
5
5
  compareAgentSelection
6
- } from "./chunk-IIVGDG4I.js";
6
+ } from "./chunk-HCT7U36O.js";
7
+ import {
8
+ isAgentUnavailableNow
9
+ } from "./chunk-FDTR4QJ6.js";
7
10
  import {
8
11
  isAntigravityOAuthAgent
9
- } from "./chunk-UZGQNTVW.js";
12
+ } from "./chunk-GNCCNNZD.js";
10
13
  import {
11
14
  getModelAbility
12
15
  } from "./chunk-ACTMNVHM.js";
@@ -356,6 +359,8 @@ function toSafeAgentSummary(record, options) {
356
359
  const isPublic = record?.isPublic === true || record?.isPublicFlag === true || record?.publicRecordExists === true;
357
360
  const updatedAt = safeTimestamp(record?.updatedAt ?? record?.createdAt ?? record?.created);
358
361
  const nextAvailableAt = typeof record?.nextAvailableAt === "number" && Number.isFinite(record.nextAvailableAt) ? record.nextAvailableAt : void 0;
362
+ const rawQuota = record?.quota;
363
+ const quota = rawQuota && typeof rawQuota === "object" && Array.isArray(rawQuota.windows) && typeof rawQuota.observedAt === "number" && Number.isFinite(rawQuota.observedAt) ? rawQuota : void 0;
359
364
  const currentUserId = options?.userId;
360
365
  const isOwnedByRecord = Boolean(currentUserId) && (typeof record?.userId === "string" && record.userId === currentUserId || typeof record?.ownerId === "string" && record.ownerId === currentUserId);
361
366
  const ownedKey = currentUserId ? [record?.dbKey, record?.privateKey].find(
@@ -418,6 +423,7 @@ function toSafeAgentSummary(record, options) {
418
423
  isOwned,
419
424
  isOAuth,
420
425
  ...nextAvailableAt !== void 0 ? { nextAvailableAt } : {},
426
+ ...quota !== void 0 ? { quota } : {},
421
427
  ...credentialGroup !== void 0 ? { credentialGroup } : {},
422
428
  ...credentialKind !== void 0 ? { credentialKind } : {},
423
429
  // 「未知 ≠ 独立」:无 credentialGroup 时显式 credentialed:false,调用方
@@ -448,6 +454,8 @@ var COMPACT_AGENT_SUMMARY_FIELDS = [
448
454
  // 决策信息(CLI --show-unavailable 场景);默认列表已把这类 agent 过滤掉,
449
455
  // 所以通常根本不占字节。
450
456
  "nextAvailableAt",
457
+ // 额度快照:只有上游真上报过窗口的 agent 才带(通常是小对象)。
458
+ "quota",
451
459
  "credentialGroup",
452
460
  "credentialKind",
453
461
  "credentialed"
@@ -481,6 +489,7 @@ var UNAVAILABLE_AGENT_SUMMARY_FIELDS = [
481
489
  "isOAuth",
482
490
  "isOwned",
483
491
  "nextAvailableAt",
492
+ "quota",
484
493
  "favoritedAt",
485
494
  "updatedAt"
486
495
  ];
@@ -500,6 +509,110 @@ function toUnavailableAgentSummary(summary) {
500
509
  return item;
501
510
  }
502
511
 
512
+ // packages/ai/agent/agentDiscovery.ts
513
+ function isPreferredAgent(agent) {
514
+ return agent.isFavorite === true || agent.isOwned === true || agent.isOAuth === true || agent.billingSource === "user_subscription" || agent.billingSource === "user_api" || agent.billingSource === "local";
515
+ }
516
+ function isPublicDiscoveryAgent(agent) {
517
+ return agent.isPublic === true && !isPreferredAgent(agent);
518
+ }
519
+ function resolveDiscoveryScope(args) {
520
+ const rawScope = typeof args?.scope === "string" ? args.scope.trim().toLowerCase() : void 0;
521
+ const hasScope = rawScope !== void 0 && rawScope !== "";
522
+ const hasPublicOnly = typeof args?.publicOnly === "boolean";
523
+ const publicOnly = args?.publicOnly === true;
524
+ if (hasScope) {
525
+ if (rawScope !== "preferred" && rawScope !== "public" && rawScope !== "all") {
526
+ throw new Error(`Invalid scope '${args?.scope}': must be 'preferred', 'public', or 'all'.`);
527
+ }
528
+ const scope = rawScope;
529
+ if (hasPublicOnly) {
530
+ if (publicOnly && scope !== "public") {
531
+ throw new Error(
532
+ `Conflicting arguments: scope='${args?.scope}' conflicts with publicOnly=true.`
533
+ );
534
+ }
535
+ if (!publicOnly && scope === "public") {
536
+ throw new Error(
537
+ `Conflicting arguments: scope='${args?.scope}' conflicts with publicOnly=false.`
538
+ );
539
+ }
540
+ }
541
+ return scope;
542
+ }
543
+ if (hasPublicOnly && publicOnly) {
544
+ return "public";
545
+ }
546
+ return "preferred";
547
+ }
548
+ function agentIdentityKeys(agent) {
549
+ return [agent.agentKey, agent.publicKey, agent.id].filter(
550
+ (key) => typeof key === "string" && key.length > 0
551
+ );
552
+ }
553
+ function deduplicateAgentSummaries(agents) {
554
+ const byIdentity = /* @__PURE__ */ new Map();
555
+ for (const agent of agents) {
556
+ const keys = agentIdentityKeys(agent);
557
+ const existing = keys.map((key) => byIdentity.get(key)).find(Boolean);
558
+ if (!existing) {
559
+ for (const key of keys) byIdentity.set(key, agent);
560
+ continue;
561
+ }
562
+ const winner = isPreferredAgent(agent) && !isPreferredAgent(existing) ? agent : existing;
563
+ for (const key of /* @__PURE__ */ new Set([...agentIdentityKeys(existing), ...keys])) byIdentity.set(key, winner);
564
+ }
565
+ return [...new Set(byIdentity.values())];
566
+ }
567
+ function filterAgentsByScope(agents, scope) {
568
+ const unique = deduplicateAgentSummaries(agents);
569
+ if (scope === "preferred") return unique.filter((agent) => isPreferredAgent(agent));
570
+ if (scope === "public") return unique.filter((agent) => isPublicDiscoveryAgent(agent));
571
+ return unique.filter((agent) => isPreferredAgent(agent) || agent.isPublic === true);
572
+ }
573
+ function matchesAgentQuery(agent, query) {
574
+ if (!query || typeof query !== "string") return true;
575
+ const q = query.trim().toLowerCase();
576
+ if (!q) return true;
577
+ const candidates = [
578
+ agent.name,
579
+ agent.model,
580
+ agent.provider,
581
+ agent.handle,
582
+ agent.agentKey,
583
+ agent.publicKey,
584
+ agent.id
585
+ ];
586
+ return candidates.some((text) => typeof text === "string" && text.toLowerCase().includes(q));
587
+ }
588
+ function buildAgentDiscoveryResult(options) {
589
+ const scope = resolveDiscoveryScope({
590
+ scope: options.scope,
591
+ publicOnly: options.publicOnly
592
+ });
593
+ const now = options.now ?? Date.now();
594
+ let scopedAgents = filterAgentsByScope(options.agents, scope);
595
+ if (options.query && typeof options.query === "string" && options.query.trim()) {
596
+ scopedAgents = scopedAgents.filter((a) => matchesAgentQuery(a, options.query));
597
+ }
598
+ const unavailableList = scopedAgents.filter((a) => isAgentUnavailableNow(a, now));
599
+ const unavailableCount = unavailableList.length;
600
+ const unavailableAgents = sortSafeAgentSummaries(unavailableList).map(toUnavailableAgentSummary);
601
+ const credentialGroups = summarizeCredentialGroups(scopedAgents, now);
602
+ if (options.showUnavailable !== true) {
603
+ scopedAgents = scopedAgents.filter((a) => !isAgentUnavailableNow(a, now));
604
+ }
605
+ const sortedAgents = sortSafeAgentSummaries(scopedAgents);
606
+ const projectedAgents = options.verbose === true ? sortedAgents.map(omitNullishAgentSummaryFields) : sortedAgents.map(toCompactAgentSummary);
607
+ return {
608
+ total: projectedAgents.length,
609
+ unavailableCount,
610
+ unavailableAgents,
611
+ credentialGroups,
612
+ agents: projectedAgents
613
+ };
614
+ }
615
+
503
616
  export {
504
617
  deriveCredentialGroup,
505
618
  summarizeCredentialGroups,
@@ -507,5 +620,8 @@ export {
507
620
  sortSafeAgentSummaries,
508
621
  omitNullishAgentSummaryFields,
509
622
  toCompactAgentSummary,
510
- toUnavailableAgentSummary
623
+ toUnavailableAgentSummary,
624
+ resolveDiscoveryScope,
625
+ matchesAgentQuery,
626
+ buildAgentDiscoveryResult
511
627
  };
@@ -5,14 +5,14 @@ import {
5
5
  inlineImageUrlsForCustomProvider,
6
6
  prepareTools,
7
7
  shouldInlineImageUrlsForAgent
8
- } from "./chunk-DRGSDQBL.js";
8
+ } from "./chunk-KAUSRTO6.js";
9
9
  import {
10
10
  INVALID_TOOL_ARGS_REPLACEMENT,
11
11
  buildInvalidToolCallSelfHealResult,
12
12
  parseToolCallArguments,
13
13
  performFetchRequest,
14
14
  sanitizeOutboundMessages
15
- } from "./chunk-Q2XN3EOZ.js";
15
+ } from "./chunk-3VUWPRFW.js";
16
16
  import {
17
17
  createSSEParser,
18
18
  createToolRunId,
@@ -23,10 +23,13 @@ import {
23
23
  toolRunSetPending,
24
24
  toolRunStarted,
25
25
  toolRunSucceeded
26
- } from "./chunk-5FBTLSFG.js";
26
+ } from "./chunk-3BGIKIPF.js";
27
27
  import {
28
28
  getPublicImageAgentMode
29
29
  } from "./chunk-VIDPVFP3.js";
30
+ import {
31
+ parseApiError
32
+ } from "./chunk-OCZKATRC.js";
30
33
  import {
31
34
  getCurrentSpaceId
32
35
  } from "./chunk-ZJ7UHBJS.js";
@@ -35,15 +38,15 @@ import {
35
38
  messageStreamEnd,
36
39
  messageStreaming,
37
40
  updateToolMessage
38
- } from "./chunk-QVKRR2SS.js";
41
+ } from "./chunk-XP3VVAPG.js";
39
42
  import {
40
43
  streamAgentChatTurn
41
- } from "./chunk-4S5QUMJP.js";
44
+ } from "./chunk-UDVH2P4A.js";
42
45
  import {
43
46
  addActiveController,
44
47
  removeActiveController,
45
48
  tokenUsageLiveUpdate
46
- } from "./chunk-6YTOJY35.js";
49
+ } from "./chunk-6D2JFXLY.js";
47
50
  import {
48
51
  accumulateToolCallDelta,
49
52
  createThinkParserState,
@@ -56,7 +59,7 @@ import {
56
59
  import {
57
60
  EMPTY_ASSISTANT_REPAIR_PROMPT,
58
61
  getModelInfo
59
- } from "./chunk-4OEFYTWL.js";
62
+ } from "./chunk-HKNXJGEC.js";
60
63
  import {
61
64
  getApiEndpoint
62
65
  } from "./chunk-OIVSQH2O.js";
@@ -65,10 +68,10 @@ import {
65
68
  } from "./chunk-HNMXYYJR.js";
66
69
  import {
67
70
  selectCurrentServer
68
- } from "./chunk-AFUORTY4.js";
71
+ } from "./chunk-GP5LKBUZ.js";
69
72
  import {
70
73
  write
71
- } from "./chunk-H62HCIUP.js";
74
+ } from "./chunk-VRTTFDBM.js";
72
75
  import {
73
76
  createDialogMessageKeyAndId,
74
77
  dialogMessageKey,
@@ -794,61 +797,6 @@ var handleToolCalls = createAsyncThunk(
794
797
  }
795
798
  );
796
799
 
797
- // packages/ai/chat/parseApiError.ts
798
- async function parseApiError(response) {
799
- const errorBody = await response.text();
800
- const truncateErrorMessage = (message, maxChars = 320) => message.length <= maxChars ? message : `${message.slice(0, maxChars)}\u2026`;
801
- const isContextOverflow = (message) => /maximum context length|context length|context_length_exceeded|requested about .*tokens|too many tokens/i.test(message);
802
- let defaultMessage = `\u72B6\u6001\u7801 ${response.status} ${response.statusText}`;
803
- let errorMessage = defaultMessage;
804
- let errorCode = `E${response.status}`;
805
- try {
806
- const errorJson = JSON.parse(errorBody);
807
- errorMessage = errorJson?.error?.message || errorJson?.message || errorJson?.msg || errorBody || defaultMessage;
808
- errorCode = errorJson?.error?.code || errorJson?.code || errorCode;
809
- } catch (_e) {
810
- if (errorBody) {
811
- errorMessage = errorBody;
812
- }
813
- }
814
- switch (response.status) {
815
- case 400:
816
- if (isContextOverflow(errorMessage) || isContextOverflow(errorBody) || errorCode === "UPSTREAM_400") {
817
- return "\u4E0A\u4E0B\u6587\u8FC7\u957F\uFF1A\u672C\u8F6E\u6D88\u606F\u6216\u5DE5\u5177\u7ED3\u679C\u592A\u5927\u3002\u8BF7\u7F29\u5C0F\u8303\u56F4\uFF0C\u6216\u5148\u8BFB\u53D6\u66F4\u5C0F\u7247\u6BB5\u540E\u518D\u7EE7\u7EED\u3002";
818
- }
819
- if (errorCode === "MISSING_PROVIDER_API_KEY") {
820
- return truncateErrorMessage(errorMessage);
821
- }
822
- if (errorMessage && errorMessage !== defaultMessage) {
823
- return `\u8BF7\u6C42\u53C2\u6570\u9519\u8BEF: ${truncateErrorMessage(errorMessage)}`;
824
- }
825
- return "\u8BF7\u6C42\u53C2\u6570\u9519\u8BEF\uFF0C\u8BF7\u68C0\u67E5\u8F93\u5165";
826
- case 413:
827
- return "\u8BF7\u6C42\u5185\u5BB9\u8FC7\u5927\uFF1A\u8BF7\u51CF\u5C11\u4E00\u6B21\u53D1\u9001\u7684\u6D88\u606F\u3001\u6587\u4EF6\u6216\u5DE5\u5177\u7ED3\u679C\u3002";
828
- case 401:
829
- switch (errorCode) {
830
- case "AUTH_TOKEN_EXPIRED":
831
- return "\u767B\u5F55\u72B6\u6001\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u5148\u767B\u51FA\u540E\u91CD\u65B0\u767B\u5F55";
832
- case "AUTH_ACCOUNT_INVALID":
833
- return "\u8D26\u6237\u65E0\u6548\u6216\u5DF2\u88AB\u505C\u7528\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458";
834
- case "AUTH_NO_TOKEN":
835
- return "\u672A\u68C0\u6D4B\u5230\u767B\u5F55\u72B6\u6001\uFF0C\u8BF7\u5148\u767B\u5F55";
836
- case "AUTH_INVALID_TOKEN":
837
- return "\u767B\u5F55\u51ED\u8BC1\u65E0\u6548\uFF0C\u8BF7\u5148\u767B\u51FA\u540E\u91CD\u65B0\u767B\u5F55";
838
- case "AUTH_TOKEN_NOT_ACTIVE":
839
- return "\u4EE4\u724C\u5C1A\u672A\u751F\u6548\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5";
840
- default:
841
- return errorMessage && errorMessage !== `\u72B6\u6001\u7801 401 Unauthorized` ? `\u8BA4\u8BC1\u9519\u8BEF: ${truncateErrorMessage(errorMessage)}` : "\u8EAB\u4EFD\u9A8C\u8BC1\u5931\u8D25\uFF0C\u8BF7\u5148\u767B\u51FA\u540E\u91CD\u65B0\u767B\u5F55";
842
- }
843
- case 503:
844
- return errorMessage && errorMessage !== `\u72B6\u6001\u7801 503 Service Unavailable` ? truncateErrorMessage(errorMessage) : "\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5";
845
- case 504:
846
- return "\u8BF7\u6C42\u8D85\u65F6\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5";
847
- default:
848
- return `API\u8BF7\u6C42\u5931\u8D25: ${truncateErrorMessage(errorMessage)}`;
849
- }
850
- }
851
-
852
800
  // packages/ai/chat/accumulateToolCallChunks.ts
853
801
  function accumulateToolCallChunks(currentAccumulatedCalls, toolCallChunks) {
854
802
  const accumulator = {
@@ -1839,7 +1787,6 @@ export {
1839
1787
  filterAndCleanMessages,
1840
1788
  persistToolMessages,
1841
1789
  handleToolCalls,
1842
- parseApiError,
1843
1790
  updateTotalUsage,
1844
1791
  readStreamChunk,
1845
1792
  sendOpenAICompletionsRequest
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  readDbRecord,
3
3
  writeAgentRecord
4
- } from "./chunk-AEOE4Z6Q.js";
4
+ } from "./chunk-QSHEEA5N.js";
5
5
  import {
6
6
  buildSkillSummaryMarker
7
7
  } from "./chunk-VF4K2QE6.js";