nolo-cli 0.228.0-alpha.1 → 0.228.0-alpha.2

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 (81) hide show
  1. package/{_executeModel-WZKT6XEU.js → _executeModel-VYCHHZVT.js} +18 -16
  2. package/{agentDeleteCommand-PZWRHNXY.js → agentDeleteCommand-QWQKT54A.js} +24 -22
  3. package/{agentEmailCommands-QTKMEICX.js → agentEmailCommands-EISMBIRE.js} +24 -22
  4. package/{agentListCommands-GUGMORTK.js → agentListCommands-4WLG32IW.js} +23 -415
  5. package/{agentMachineCommands-7QGICJLM.js → agentMachineCommands-DC6NKWTU.js} +12 -11
  6. package/{agentRecordCommands-SLLADS5C.js → agentRecordCommands-IZYUVHME.js} +24 -22
  7. package/{agentRunCommand-OFQLOF5Y.js → agentRunCommand-QM7ETUTX.js} +25 -23
  8. package/{agentRuntimeLocal-TU4LA353.js → agentRuntimeLocal-HOXKWCYO.js} +9 -8
  9. package/{agentSlice-L4SBGWTB.js → agentSlice-UG76KEBH.js} +1 -1
  10. package/{appDeleteCommands-JWP3XPUA.js → appDeleteCommands-WWCC6WA5.js} +13 -12
  11. package/{appDeployCommands-6E4TQCWI.js → appDeployCommands-AU4IUN33.js} +13 -12
  12. package/{appDeployStatusCommands-ALU4SADG.js → appDeployStatusCommands-STUW7WXL.js} +13 -12
  13. package/{appGetCommands-JEY4L6L4.js → appGetCommands-BGTLIQ4K.js} +13 -12
  14. package/{appListCommands-PCAVHU7M.js → appListCommands-CUCPRUXW.js} +13 -12
  15. package/{authCommand-CGRIIOOV.js → authCommand-OZ2KTP4Z.js} +2 -2
  16. package/{chunk-JUSHVFNF.js → chunk-3QIYD3VM.js} +414 -342
  17. package/{chunk-H6L2NFHY.js → chunk-3VZLEKV2.js} +2 -2
  18. package/{chunk-3P54D2E4.js → chunk-42OKN2LI.js} +1 -1
  19. package/{chunk-EXJK7TQO.js → chunk-45CAVC35.js} +43 -288
  20. package/{chunk-SMJEXX2S.js → chunk-4QYJPWHH.js} +2 -2
  21. package/{chunk-Q3IVPFVO.js → chunk-5YMA6DDZ.js} +1 -1
  22. package/{chunk-R3NEQZ53.js → chunk-7BCG67EI.js} +8 -8
  23. package/{chunk-CYWNWA77.js → chunk-7FEP5USX.js} +6 -3
  24. package/{chunk-GACR7H6T.js → chunk-CNMY2XM6.js} +2 -2
  25. package/{chunk-STJ6LSQE.js → chunk-DLXMMTGM.js} +82 -21
  26. package/{chunk-MDZWUD3R.js → chunk-EGHP7KOY.js} +3 -3
  27. package/{chunk-AGYPUBFW.js → chunk-FPBJM2BW.js} +4 -1
  28. package/{chunk-IXG6YXQM.js → chunk-GAYNXB6T.js} +51 -40
  29. package/{chunk-XJPLSAPJ.js → chunk-HF7BLF3F.js} +2 -2
  30. package/{chunk-GYS5FUYR.js → chunk-HXB4VDGK.js} +1 -1
  31. package/{chunk-BNMPUQW6.js → chunk-JQZRSXS5.js} +23 -23
  32. package/{chunk-VSYTM22R.js → chunk-LYD6C7OU.js} +2 -2
  33. package/{chunk-QBZCGP34.js → chunk-M3OZRQNH.js} +1 -1
  34. package/{chunk-DDC6P6EH.js → chunk-MJI3UAXN.js} +34 -10
  35. package/{chunk-RYOLWYBK.js → chunk-MNEZUL5S.js} +16 -1
  36. package/{chunk-GOCSSER3.js → chunk-MZG5CETE.js} +2 -2
  37. package/{chunk-QCB42576.js → chunk-OJ45MEEI.js} +1 -1
  38. package/{chunk-UE2EVEYS.js → chunk-OTKSESZR.js} +2 -2
  39. package/{chunk-NHY322ZU.js → chunk-RRDRQOEC.js} +508 -2
  40. package/{chunk-2MCB7CD7.js → chunk-TCZ2VJZQ.js} +3 -3
  41. package/{chunk-D6YNCNM6.js → chunk-TQEKUOTI.js} +2 -2
  42. package/{chunk-2NPD3FTX.js → chunk-U2HBB7RS.js} +14 -14
  43. package/{chunk-AUAJTAFM.js → chunk-VQ5N5GSV.js} +1 -1
  44. package/{chunk-K67C2JUC.js → chunk-WCFFRBL5.js} +3 -3
  45. package/{chunk-GPOV42YM.js → chunk-WFDNADFX.js} +1 -1
  46. package/chunk-WFGNWWJI.js +326 -0
  47. package/{chunk-OYU2MA5S.js → chunk-X3E6EHJW.js} +9 -8
  48. package/{chunk-GUXZK7SE.js → chunk-XAG3FWBE.js} +11 -0
  49. package/{chunk-OG6MQOQG.js → chunk-XFXFPUO7.js} +2 -2
  50. package/{chunk-UWAIJOF2.js → chunk-XTJKU3Z4.js} +4 -4
  51. package/{chunk-IAAIUH64.js → chunk-YVFH2MFB.js} +3 -3
  52. package/{chunk-TGNIKIHR.js → chunk-ZEVQHCLM.js} +1 -1
  53. package/{cliLocalAgentRecordReader-M3F76NIP.js → cliLocalAgentRecordReader-H3HYQRRR.js} +11 -10
  54. package/{commandRegistry-ZLWHQVAI.js → commandRegistry-FVYPE2IN.js} +47 -47
  55. package/{contentThunks-4ZX2TO7C.js → contentThunks-GNFPG32S.js} +3 -3
  56. package/{createAgentAutomationAction-L4CYUZJG.js → createAgentAutomationAction-PB4QIFQ4.js} +3 -3
  57. package/{createDialogAction-QTU2R2Q3.js → createDialogAction-EVTOPY7A.js} +4 -4
  58. package/{createPageAction-F3GJTHW2.js → createPageAction-2UYF2IDZ.js} +4 -4
  59. package/{dialogCommands-NRLCOPJR.js → dialogCommands-6SZD4TYP.js} +13 -12
  60. package/{dialogSlice-P2S4LXQD.js → dialogSlice-5EQ2A6LY.js} +2 -2
  61. package/{docCreateCommands-YJRDA3RX.js → docCreateCommands-25E6PGN3.js} +12 -11
  62. package/{docDeleteCommands-A5QIHZNF.js → docDeleteCommands-F7ZVGEHW.js} +13 -12
  63. package/{docReadCommands-CF2LTMYH.js → docReadCommands-JY2E5XEN.js} +12 -11
  64. package/{docStore-6O7NYL6A.js → docStore-OKKIKLT3.js} +1 -1
  65. package/{docUpdateCommands-QRKV4ZXE.js → docUpdateCommands-OZ4CUSIQ.js} +12 -11
  66. package/{handleSendMessageAction-7IHLR37A.js → handleSendMessageAction-LNT7SZND.js} +12 -11
  67. package/{hostCredentialCreate-VNCQUAFT.js → hostCredentialCreate-XUU2CSHI.js} +24 -22
  68. package/index.js +3 -3
  69. package/{localRuntimeAdapter-FOWVNMIK.js → localRuntimeAdapter-IBSTMSX7.js} +23 -21
  70. package/{machineCommands-ZGC3J4JB.js → machineCommands-HSQHDHOT.js} +41 -24
  71. package/{machineWsRunDispatch-KK5U4M3G.js → machineWsRunDispatch-L6H7J66T.js} +24 -22
  72. package/package.json +1 -1
  73. package/{projectArchive-7ZDYBXAX.js → projectArchive-FQO654Z3.js} +4 -4
  74. package/{readlineWorkspace-YHT4SX2C.js → readlineWorkspace-7U272DSA.js} +36 -33
  75. package/{runAgentClientLoop-H4ED5V3K.js → runAgentClientLoop-AF4JQIJ7.js} +16 -14
  76. package/{skillDiscovery-I37M5KJC.js → skillDiscovery-BHHPCUHZ.js} +3 -3
  77. package/{spaceCommands-MEH3HJBC.js → spaceCommands-5VNWMDBE.js} +12 -11
  78. package/{streamAgentChatTurn-ZXPOXU33.js → streamAgentChatTurn-YSPEFY4K.js} +24 -21
  79. package/{tools-2MRWA2PP.js → tools-M35PTIFB.js} +11 -9
  80. package/{updateDialogTitleAction-RZ3KZSGQ.js → updateDialogTitleAction-IMIRJRQQ.js} +3 -3
  81. package/chunk-2WZXXAQD.js +0 -57
@@ -1,6 +1,3 @@
1
- import {
2
- resolveObservedSpeed
3
- } from "./chunk-AMWMV56B.js";
4
1
  import {
5
2
  decorateAgentsWithPublicStatusAcrossServers,
6
3
  listFavoriteAgentIdsAcrossServers,
@@ -10,7 +7,7 @@ import {
10
7
  listRemotePublicAgents,
11
8
  normalizeListedAgent,
12
9
  parseAgentListArgs
13
- } from "./chunk-CYWNWA77.js";
10
+ } from "./chunk-7FEP5USX.js";
14
11
  import {
15
12
  refreshSubscriptionQuotas
16
13
  } from "./chunk-TUSTONB3.js";
@@ -25,22 +22,24 @@ import {
25
22
  } from "./chunk-WWTSEBDF.js";
26
23
  import {
27
24
  buildAgentDiscoveryResult,
25
+ injectSpeedContextIntoListAgentsResult,
28
26
  matchesAgentQuery,
29
27
  resolvePaginationArgs,
30
28
  summarizeCredentialGroups,
31
29
  toDiscoverySafeAgentSummary
32
- } from "./chunk-NHY322ZU.js";
30
+ } from "./chunk-RRDRQOEC.js";
31
+ import "./chunk-AMWMV56B.js";
33
32
  import {
34
33
  buildSpaceLookup,
35
34
  getSpaceContentKeys
36
35
  } from "./chunk-ID4G2MAR.js";
37
36
  import {
38
37
  readLiveDbRecordAfterTombstoneMerge
39
- } from "./chunk-QBZCGP34.js";
38
+ } from "./chunk-M3OZRQNH.js";
40
39
  import {
41
40
  queryUserRecords,
42
41
  readDbRecord
43
- } from "./chunk-D6YNCNM6.js";
42
+ } from "./chunk-TQEKUOTI.js";
44
43
  import "./chunk-5ZUOVCKT.js";
45
44
  import "./chunk-UEILX4EV.js";
46
45
  import "./chunk-GBWGPTA7.js";
@@ -50,26 +49,26 @@ import {
50
49
  import "./chunk-2X7WFDT6.js";
51
50
  import "./chunk-OOJNQK6V.js";
52
51
  import "./chunk-BV3FLP2L.js";
53
- import "./chunk-QCB42576.js";
52
+ import "./chunk-OJ45MEEI.js";
54
53
  import "./chunk-BR3GT6MR.js";
55
- import "./chunk-JUSHVFNF.js";
54
+ import "./chunk-3QIYD3VM.js";
56
55
  import "./chunk-ZNFJWEN4.js";
57
- import "./chunk-2NPD3FTX.js";
56
+ import "./chunk-U2HBB7RS.js";
58
57
  import "./chunk-PWTNI4N7.js";
59
58
  import "./chunk-AL3TYDIF.js";
60
59
  import "./chunk-HSSBDZLD.js";
61
60
  import "./chunk-HNUWUO75.js";
62
61
  import "./chunk-CHOZJMJS.js";
63
- import "./chunk-GUXZK7SE.js";
62
+ import "./chunk-XAG3FWBE.js";
64
63
  import "./chunk-LKA64WH4.js";
65
- import "./chunk-2WZXXAQD.js";
64
+ import "./chunk-BYXBJQAS.js";
66
65
  import "./chunk-DUUDXSLX.js";
67
66
  import "./chunk-QYB23WUH.js";
68
67
  import "./chunk-56GBUMO5.js";
69
- import "./chunk-AGYPUBFW.js";
68
+ import "./chunk-FPBJM2BW.js";
70
69
  import "./chunk-EEOOBRA7.js";
71
70
  import "./chunk-X4O7FJF5.js";
72
- import "./chunk-RYOLWYBK.js";
71
+ import "./chunk-MNEZUL5S.js";
73
72
  import {
74
73
  DEFAULT_PROVIDER_RETRY_MS,
75
74
  formatQuotaSummary,
@@ -82,6 +81,7 @@ import {
82
81
  import "./chunk-VS276URX.js";
83
82
  import "./chunk-TLE77UJ5.js";
84
83
  import "./chunk-OBIC6EG7.js";
84
+ import "./chunk-WFGNWWJI.js";
85
85
  import "./chunk-FJSNBZXR.js";
86
86
  import "./chunk-2MBTWINN.js";
87
87
  import "./chunk-QRGDJA4B.js";
@@ -107,16 +107,13 @@ import "./chunk-W6RFEDN4.js";
107
107
  import "./chunk-EVGU5P4U.js";
108
108
  import "./chunk-ILHQ2AXT.js";
109
109
  import "./chunk-M2EJHDJP.js";
110
- import {
111
- createKey,
112
- createTokenKey
113
- } from "./chunk-SYTHYBMI.js";
110
+ import "./chunk-SYTHYBMI.js";
114
111
  import "./chunk-OJKUU3LP.js";
115
112
  import "./chunk-YZMNK53S.js";
116
113
  import "./chunk-I42VC5KR.js";
117
114
  import "./chunk-U6VC4MU4.js";
118
- import "./chunk-3P54D2E4.js";
119
- import "./chunk-BNMPUQW6.js";
115
+ import "./chunk-42OKN2LI.js";
116
+ import "./chunk-JQZRSXS5.js";
120
117
  import "./chunk-KHCLMKZZ.js";
121
118
  import {
122
119
  parseUserIdFromAuthToken,
@@ -150,400 +147,6 @@ import "./chunk-OBSEKCVK.js";
150
147
  import "./chunk-QSJ3HFEF.js";
151
148
  import "./chunk-U67V476Y.js";
152
149
 
153
- // packages/ai/agent/speedSampleCache.ts
154
- var SPEED_SAMPLE_DISK_CACHE_TTL_MS = 10 * 6e4;
155
- var SPEED_SAMPLE_SCAN_BUDGET_MS = 2500;
156
- var SPEED_SAMPLE_CACHE_VERSION = 4;
157
- var isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
158
- var sanitizeSample = (value) => {
159
- if (!value || typeof value !== "object") return null;
160
- const sample = value;
161
- const clean = {};
162
- if (isFiniteNumber(sample.firstOutputMs)) clean.firstOutputMs = sample.firstOutputMs;
163
- if (isFiniteNumber(sample.callDurationMs)) clean.callDurationMs = sample.callDurationMs;
164
- if (isFiniteNumber(sample.output_tokens)) clean.output_tokens = sample.output_tokens;
165
- if (isFiniteNumber(sample.t)) clean.t = sample.t;
166
- return clean.firstOutputMs === void 0 && clean.callDurationMs === void 0 ? null : clean;
167
- };
168
- var SPEED_SAMPLE_STALE_SNAPSHOT_MAX_MS = 7 * 24 * 60 * 6e4;
169
- async function parseCacheFile(cachePath, userId) {
170
- try {
171
- const fs = await import("node:fs/promises");
172
- const raw = await fs.readFile(cachePath, "utf8");
173
- const parsed = JSON.parse(raw);
174
- if (!parsed || typeof parsed !== "object") return null;
175
- const version = parsed.version;
176
- if (version !== SPEED_SAMPLE_CACHE_VERSION) {
177
- return null;
178
- }
179
- if (parsed.userId !== userId) return null;
180
- if (!isFiniteNumber(parsed.at)) return null;
181
- const source = parsed.samples;
182
- if (!source || typeof source !== "object") return null;
183
- const samples = /* @__PURE__ */ new Map();
184
- for (const [model, list] of Object.entries(source)) {
185
- if (!model || !Array.isArray(list)) continue;
186
- const cleaned = [];
187
- for (const entry of list) {
188
- const sample = sanitizeSample(entry);
189
- if (sample) cleaned.push(sample);
190
- }
191
- samples.set(model, cleaned);
192
- }
193
- const complete = parsed.complete === true;
194
- const cursor = typeof parsed.cursor === "string" && parsed.cursor.length > 0 ? parsed.cursor : void 0;
195
- return { samples, at: parsed.at, complete, cursor: complete ? void 0 : cursor };
196
- } catch {
197
- return null;
198
- }
199
- }
200
- async function readSpeedSamplesSnapshot(cachePath, options) {
201
- const maxAgeMs = isFiniteNumber(options.maxAgeMs) ? options.maxAgeMs : SPEED_SAMPLE_STALE_SNAPSHOT_MAX_MS;
202
- const parsed = await parseCacheFile(cachePath, options.userId);
203
- if (!parsed || !parsed.complete) return null;
204
- const age = options.now - parsed.at;
205
- if (age < 0 || age >= maxAgeMs) return null;
206
- return { samples: parsed.samples, ageMs: age };
207
- }
208
- async function readSpeedSamplesProgress(cachePath, userId) {
209
- const parsed = await parseCacheFile(cachePath, userId);
210
- if (!parsed) return null;
211
- return {
212
- samples: parsed.samples,
213
- at: parsed.at,
214
- complete: parsed.complete,
215
- ...parsed.cursor === void 0 ? {} : { cursor: parsed.cursor }
216
- };
217
- }
218
- function resolveSpeedSamplesProgressPath(cachePath) {
219
- return `${cachePath}.progress`;
220
- }
221
- async function writeSpeedSamplesCache(cachePath, payload) {
222
- try {
223
- const fs = await import("node:fs/promises");
224
- const path = await import("node:path");
225
- await fs.mkdir(path.dirname(cachePath), { recursive: true });
226
- const tmpPath = `${cachePath}.tmp-${process.pid}-${Math.random().toString(36).slice(2, 8)}`;
227
- await fs.writeFile(tmpPath, JSON.stringify(payload), "utf8");
228
- await fs.rename(tmpPath, cachePath);
229
- } catch {
230
- }
231
- }
232
-
233
- // packages/ai/agent/candidateSpeedContext.ts
234
- var OBSERVED_SPEED_WINDOW = 50;
235
- var MIN_OBSERVED_FIRST_OUTPUT_SAMPLES = 5;
236
- var SPEED_SAMPLES_CACHE_TTL_MS = 5 * 6e4;
237
- var SPEED_SAMPLES_CACHE_MAX_ENTRIES = 500;
238
- function normalizeSpeedModelName(raw) {
239
- const name = raw.trim().toLowerCase();
240
- const slash = name.lastIndexOf("/");
241
- return slash === -1 ? name : name.slice(slash + 1);
242
- }
243
- var isFiniteNumber2 = (value) => typeof value === "number" && Number.isFinite(value);
244
- var REASONING_EFFORT_SUFFIXES = ["minimal", "low", "medium", "high", "xhigh"];
245
- var REASONING_EFFORT_SUFFIX_RE = new RegExp(`-(?:${REASONING_EFFORT_SUFFIXES.join("|")})$`);
246
- function stripReasoningEffortSuffix(model) {
247
- const base = model.replace(REASONING_EFFORT_SUFFIX_RE, "");
248
- return base && base !== model ? base : null;
249
- }
250
- function resolveOneBare(model, samplesByModel) {
251
- const observed = resolveObservedSpeed(samplesByModel.get(model) ?? [], {
252
- limit: OBSERVED_SPEED_WINDOW
253
- });
254
- if (observed.firstOutputSampleCount >= MIN_OBSERVED_FIRST_OUTPUT_SAMPLES && observed.medianFirstOutputMs !== void 0) {
255
- return {
256
- source: "observed",
257
- firstOutputMs: observed.medianFirstOutputMs,
258
- ...observed.medianOutputTokensPerSecond !== void 0 ? { outputTps: observed.medianOutputTokensPerSecond } : {},
259
- firstOutputSamples: observed.firstOutputSampleCount,
260
- tpsSamples: observed.throughputSampleCount
261
- };
262
- }
263
- return null;
264
- }
265
- function resolveOne(model, samplesByModel) {
266
- const direct = resolveOneBare(model, samplesByModel);
267
- if (direct) return { model, ...direct };
268
- const base = stripReasoningEffortSuffix(model);
269
- if (!base) return null;
270
- const stripped = resolveOneBare(base, samplesByModel);
271
- return stripped ? { model, ...stripped } : null;
272
- }
273
- function resolveCandidateSpeedFacts(models, samplesByModel) {
274
- const unique = [
275
- ...new Set(
276
- models.filter((model) => typeof model === "string").map(normalizeSpeedModelName).filter(Boolean)
277
- )
278
- ];
279
- return unique.map((model) => resolveOne(model, samplesByModel)).filter((fact) => fact !== null);
280
- }
281
- var formatSeconds = (ms) => `${(ms / 1e3).toFixed(1)}s`;
282
- var formatTps = (tps) => String(Math.round(tps));
283
- var SPEED_CONTEXT_HEADER = "speed (observed=\u672C\u7528\u6237\u5B9E\u6D4B\u8C03\u7528\u4E2D\u4F4D\u6570, firstOutput \u542B\u63A8\u7406\u8F93\u51FA; tps=generation\uFF08\u4E0D\u542B\u7AEF\u5230\u7AEF\u53E3\u5F84\uFF09, tps=n/a \u8868\u793A\u65E0\u53EF\u4FE1\u541E\u5410\u6837\u672C\u3002\u672A\u5217\u51FA\u7684 model \u8868\u793A\u6CA1\u6709\u5B9E\u6D4B\u6837\u672C\uFF0C\u4E0D\u4EE3\u8868\u6162):";
284
- function formatSnapshotAge(ageMs) {
285
- const minutes = Math.floor(ageMs / 6e4);
286
- if (minutes < 1) return "<1min";
287
- if (minutes < 60) return `${minutes}min`;
288
- const hours = Math.floor(minutes / 60);
289
- if (hours < 24) return `${hours}h`;
290
- return `${Math.floor(hours / 24)}d`;
291
- }
292
- function formatCandidateSpeedFacts(facts, options = {}) {
293
- if (facts.length === 0) return null;
294
- const lines = facts.map((fact) => {
295
- const tps = fact.outputTps !== void 0 ? formatTps(fact.outputTps) : "n/a";
296
- return ` ${fact.model}: firstOutput=${formatSeconds(fact.firstOutputMs ?? 0)} tps=${tps} [observed n=${fact.firstOutputSamples ?? 0} tpsN=${fact.tpsSamples ?? 0}]`;
297
- });
298
- const age = options.snapshotAgeMs;
299
- const note = typeof age === "number" && age > 0 ? ` (snapshot=${formatSnapshotAge(age)}\u524D\u91C7\u96C6\u7684\u5B8C\u6574\u7A97\u53E3, \u975E\u672C\u6B21\u5B9E\u65F6\u626B\u63CF)` : "";
300
- return `${SPEED_CONTEXT_HEADER}${note}
301
- ${lines.join("\n")}`;
302
- }
303
- function buildCandidateSpeedContext(models, samplesByModel, options = {}) {
304
- return formatCandidateSpeedFacts(resolveCandidateSpeedFacts(models, samplesByModel), options);
305
- }
306
- var SPEED_SAMPLE_PAGE_SIZE = 2e3;
307
- var DISPATCH_ENTRY_PATH = "agent-run";
308
- var eventTime = (value) => {
309
- if (isFiniteNumber2(value.timestamp)) return value.timestamp;
310
- if (isFiniteNumber2(value.createdAt)) return value.createdAt;
311
- return 0;
312
- };
313
- function collectSample(collected, value) {
314
- if (typeof value.model !== "string") return;
315
- if (!isFiniteNumber2(value.firstOutputMs) && !isFiniteNumber2(value.callDurationMs)) return;
316
- const model = normalizeSpeedModelName(value.model);
317
- if (!model) return;
318
- const list = collected.get(model) ?? [];
319
- list.push({
320
- t: eventTime(value),
321
- firstOutputMs: value.firstOutputMs,
322
- callDurationMs: value.callDurationMs,
323
- output_tokens: value.output_tokens
324
- });
325
- collected.set(model, list);
326
- }
327
- function finalizeSamples(collected, keepTime = false) {
328
- const result = /* @__PURE__ */ new Map();
329
- for (const [model, list] of collected) {
330
- list.sort((a, b) => b.t - a.t);
331
- const window = list.slice(0, OBSERVED_SPEED_WINDOW);
332
- result.set(
333
- model,
334
- keepTime ? window : window.map(({ t: _t, ...sample }) => sample)
335
- );
336
- }
337
- return result;
338
- }
339
- async function collectRecentSpeedSamples(db, userId, options = {}) {
340
- const pageSize = isFiniteNumber2(options.pageSize) && options.pageSize > 0 ? Math.floor(options.pageSize) : SPEED_SAMPLE_PAGE_SIZE;
341
- const budgetMs = isFiniteNumber2(options.budgetMs) ? options.budgetMs : Number.POSITIVE_INFINITY;
342
- const { start, end } = createTokenKey.rangeOfUser(userId);
343
- const failedPrefix = createKey("token", userId, "failed-call", "");
344
- const dispatchRunCache = /* @__PURE__ */ new Map();
345
- const isDispatchSampleRecord = async (record2, resolver, cache) => {
346
- if (record2.entry_path !== DISPATCH_ENTRY_PATH && record2.entry_path !== "cli-local") return false;
347
- const runId = typeof record2.dialogId === "string" ? record2.dialogId.trim() : "";
348
- if (!runId) return false;
349
- const cacheKey = `${record2.entry_path}:${runId}`;
350
- const cached = cache.get(cacheKey);
351
- if (cached !== void 0) return cached;
352
- let dispatch = false;
353
- if (resolver) {
354
- try {
355
- dispatch = await resolver(runId, record2.entry_path) === true;
356
- } catch {
357
- dispatch = false;
358
- }
359
- }
360
- cache.set(cacheKey, dispatch);
361
- return dispatch;
362
- };
363
- const collected = /* @__PURE__ */ new Map();
364
- const startedAt = Date.now();
365
- let lastKey = options.startAfter;
366
- let budgetExhausted = false;
367
- let scanned = 0;
368
- while (true) {
369
- if (Date.now() - startedAt >= budgetMs) {
370
- budgetExhausted = true;
371
- break;
372
- }
373
- const pageOptions = {
374
- ...lastKey === void 0 ? { gte: start } : { gt: lastKey },
375
- lte: end,
376
- limit: pageSize
377
- };
378
- let accepted = 0;
379
- let newestKey = lastKey;
380
- for await (const [key, raw] of db.iterator(pageOptions)) {
381
- if (typeof key !== "string") continue;
382
- if (lastKey !== void 0 && key <= lastKey) continue;
383
- accepted += 1;
384
- scanned += 1;
385
- newestKey = key;
386
- if (key.startsWith(failedPrefix)) continue;
387
- if (!raw || typeof raw !== "object") continue;
388
- const record2 = raw;
389
- const resolver = options.isDispatchRun ?? db.isDispatchRun;
390
- if (!await isDispatchSampleRecord(
391
- record2,
392
- resolver ? (runId, entryPath) => resolver.call(db, runId, entryPath) : void 0,
393
- dispatchRunCache
394
- ))
395
- continue;
396
- collectSample(collected, record2);
397
- }
398
- if (accepted === 0 || accepted < pageSize) break;
399
- lastKey = newestKey;
400
- }
401
- return {
402
- samples: finalizeSamples(collected, options.keepTime === true),
403
- budgetExhausted,
404
- scanned,
405
- ...budgetExhausted && lastKey !== void 0 ? { nextCursor: lastKey } : {}
406
- };
407
- }
408
- function mergeNewestSamples(into, from) {
409
- for (const [model, list] of from) {
410
- const merged = [...into.get(model) ?? [], ...list];
411
- merged.sort(
412
- (a, b) => (b.t ?? 0) - (a.t ?? 0)
413
- );
414
- into.set(model, merged.slice(0, OBSERVED_SPEED_WINDOW));
415
- }
416
- }
417
- async function loadSpeedSamplesWithDiskCache(db, userId, now, cache) {
418
- try {
419
- const ttlMs = isFiniteNumber2(cache.ttlMs) ? cache.ttlMs : SPEED_SAMPLE_DISK_CACHE_TTL_MS;
420
- const snapshot = await readSpeedSamplesSnapshot(cache.cachePath, { userId, now });
421
- if (snapshot && snapshot.ageMs < ttlMs) return { samples: snapshot.samples };
422
- const progressPath = resolveSpeedSamplesProgressPath(cache.cachePath);
423
- const progress = await readSpeedSamplesProgress(progressPath, userId);
424
- const resumable = progress && !progress.complete && progress.cursor ? progress : void 0;
425
- const collected = new Map(resumable?.samples ?? []);
426
- let step;
427
- try {
428
- step = await collectRecentSpeedSamples(db, userId, {
429
- pageSize: cache.pageSize,
430
- budgetMs: isFiniteNumber2(cache.budgetMs) ? cache.budgetMs : SPEED_SAMPLE_SCAN_BUDGET_MS,
431
- keepTime: true,
432
- ...resumable?.cursor ? { startAfter: resumable.cursor } : {}
433
- });
434
- } catch {
435
- return snapshot ? { samples: snapshot.samples, snapshotAgeMs: snapshot.ageMs } : { samples: /* @__PURE__ */ new Map() };
436
- }
437
- if (!resumable && step.scanned === 0 && !step.budgetExhausted) {
438
- return snapshot ? { samples: snapshot.samples, snapshotAgeMs: snapshot.ageMs } : { samples: /* @__PURE__ */ new Map() };
439
- }
440
- mergeNewestSamples(collected, step.samples);
441
- if (!step.budgetExhausted) {
442
- await writeSpeedSamplesCache(cache.cachePath, {
443
- version: SPEED_SAMPLE_CACHE_VERSION,
444
- userId,
445
- at: now,
446
- complete: true,
447
- samples: Object.fromEntries(collected)
448
- });
449
- await writeSpeedSamplesCache(progressPath, {
450
- version: SPEED_SAMPLE_CACHE_VERSION,
451
- userId,
452
- at: now,
453
- complete: true,
454
- samples: {}
455
- });
456
- return { samples: collected };
457
- }
458
- await writeSpeedSamplesCache(progressPath, {
459
- version: SPEED_SAMPLE_CACHE_VERSION,
460
- userId,
461
- // Progress keeps the cycle's collection start so a later stale label stays honest.
462
- at: resumable?.at ?? now,
463
- complete: false,
464
- samples: Object.fromEntries(collected),
465
- ...step.nextCursor ? { cursor: step.nextCursor } : {}
466
- });
467
- return snapshot ? { samples: snapshot.samples, snapshotAgeMs: snapshot.ageMs } : { samples: /* @__PURE__ */ new Map() };
468
- } catch {
469
- return { samples: /* @__PURE__ */ new Map() };
470
- }
471
- }
472
- var samplesCache = /* @__PURE__ */ new Map();
473
- function writeSamplesCache(userId, now, samples) {
474
- for (const [key, entry] of samplesCache) {
475
- if (now - entry.at >= SPEED_SAMPLES_CACHE_TTL_MS) samplesCache.delete(key);
476
- }
477
- samplesCache.delete(userId);
478
- samplesCache.set(userId, { at: now, samples });
479
- while (samplesCache.size > SPEED_SAMPLES_CACHE_MAX_ENTRIES) {
480
- const oldest = samplesCache.keys().next().value;
481
- if (oldest === void 0) break;
482
- samplesCache.delete(oldest);
483
- }
484
- }
485
- var SPEED_SAMPLE_REFRESH_BUDGET_MS = 6e4;
486
- var snapshotRefreshes = /* @__PURE__ */ new Map();
487
- function startSpeedSnapshotRefresh(db, userId, now = Date.now()) {
488
- const inFlight = snapshotRefreshes.get(userId);
489
- if (inFlight) return inFlight;
490
- const job = (async () => {
491
- try {
492
- const { samples, budgetExhausted } = await collectRecentSpeedSamples(db, userId, {
493
- budgetMs: SPEED_SAMPLE_REFRESH_BUDGET_MS
494
- });
495
- if (!budgetExhausted) writeSamplesCache(userId, now, samples);
496
- } catch {
497
- }
498
- })().finally(() => {
499
- snapshotRefreshes.delete(userId);
500
- });
501
- snapshotRefreshes.set(userId, job);
502
- return job;
503
- }
504
- async function loadCachedSpeedSamples(db, userId, now) {
505
- const hit = samplesCache.get(userId);
506
- if (hit) {
507
- const age = now - hit.at;
508
- if (age >= 0 && age < SPEED_SAMPLE_STALE_SNAPSHOT_MAX_MS) {
509
- if (age >= SPEED_SAMPLES_CACHE_TTL_MS) void startSpeedSnapshotRefresh(db, userId);
510
- return age >= SPEED_SAMPLES_CACHE_TTL_MS ? { samples: hit.samples, snapshotAgeMs: age } : { samples: hit.samples };
511
- }
512
- }
513
- void startSpeedSnapshotRefresh(db, userId);
514
- return { samples: /* @__PURE__ */ new Map() };
515
- }
516
- async function injectSpeedContextIntoListAgentsResult(result, options = {}) {
517
- try {
518
- let parsed;
519
- try {
520
- parsed = JSON.parse(result);
521
- } catch {
522
- return result;
523
- }
524
- if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.agents)) return result;
525
- const models = parsed.agents.map((agent) => agent?.model).filter((model) => typeof model === "string");
526
- if (models.length === 0) return result;
527
- const now = options.now ?? Date.now();
528
- let samples = /* @__PURE__ */ new Map();
529
- let snapshotAgeMs;
530
- const userId = typeof options.userId === "string" ? options.userId.trim() : "";
531
- if (options.db && userId) {
532
- try {
533
- const loaded = options.diskCache ? await loadSpeedSamplesWithDiskCache(options.db, userId, now, options.diskCache) : await loadCachedSpeedSamples(options.db, userId, now);
534
- samples = loaded.samples;
535
- snapshotAgeMs = loaded.snapshotAgeMs;
536
- } catch {
537
- samples = /* @__PURE__ */ new Map();
538
- }
539
- }
540
- const speedContext = buildCandidateSpeedContext(models, samples, { snapshotAgeMs });
541
- return speedContext ? JSON.stringify({ ...parsed, speedContext }) : result;
542
- } catch {
543
- return result;
544
- }
545
- }
546
-
547
150
  // packages/ai/agent/dispatchSpeedProvenance.ts
548
151
  var record = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
549
152
  function isServerDispatchSpeedSource(value, dialogId, userId) {
@@ -597,7 +200,7 @@ async function runAgentListCommand(args, deps = {}) {
597
200
  } catch {
598
201
  }
599
202
  const output = deps.output ?? process.stdout;
600
- const { wantJson, wantSafe, publicOnly, scope: requestedScope, idsOnly, showUnavailable, verbose, compact, limit, offset, query } = parseAgentListArgs(args);
203
+ const { wantJson, wantSafe, publicOnly, scope: requestedScope, idsOnly, showUnavailable, verbose, compact, limit, offset, query, fragmentOffset, fragmentAgentKey, fragmentDigest } = parseAgentListArgs(args);
601
204
  if (requestedScope && !["preferred", "public", "all"].includes(requestedScope)) {
602
205
  throw new Error(`Invalid scope '${requestedScope}'`);
603
206
  }
@@ -888,6 +491,7 @@ async function runAgentListCommand(args, deps = {}) {
888
491
  ...typeof discovery.limit === "number" ? { limit: discovery.limit } : {},
889
492
  ...discovery.truncated ? { truncated: true } : {},
890
493
  unavailableCount: discovery.unavailableCount,
494
+ availableCount: discovery.availableCount,
891
495
  // agents 在最前:host 截断长输出时保头保尾,派发所需的 agentKey
892
496
  // 必须落在头部;凭证分组是说明性大块,放最后。
893
497
  // 限流 agent 已合入 agents(带 availabilityStatus / nextAvailableAt
@@ -897,6 +501,10 @@ async function runAgentListCommand(args, deps = {}) {
897
501
  }, null, 2);
898
502
  const cliNoloHome = env.NOLO_HOME?.trim() || (env.HOME?.trim() ? `${env.HOME.trim()}/.nolo` : "");
899
503
  const speedAwareListResult = await injectSpeedContextIntoListAgentsResult(listResult, {
504
+ compactPage: compact === true && verbose !== true,
505
+ fragmentOffset,
506
+ fragmentAgentKey,
507
+ fragmentDigest,
900
508
  db: createCliDispatchSampleDb(deps.db ?? await getReadableCliDb(output), userId, env),
901
509
  userId,
902
510
  ...cliNoloHome ? { diskCache: { cachePath: `${cliNoloHome}/cache/speed-samples-${userId}.json` } } : {}
@@ -10,36 +10,37 @@ import {
10
10
  readAgentRecord,
11
11
  resolveAgentRecordFromHybridStore,
12
12
  writeAgentRecord
13
- } from "./chunk-D6YNCNM6.js";
13
+ } from "./chunk-TQEKUOTI.js";
14
14
  import "./chunk-5ZUOVCKT.js";
15
15
  import "./chunk-3L2WKC3W.js";
16
16
  import "./chunk-BV3FLP2L.js";
17
- import "./chunk-QCB42576.js";
17
+ import "./chunk-OJ45MEEI.js";
18
18
  import {
19
19
  resolveCliAgentKeyInput
20
20
  } from "./chunk-BR3GT6MR.js";
21
- import "./chunk-JUSHVFNF.js";
21
+ import "./chunk-3QIYD3VM.js";
22
22
  import "./chunk-ZNFJWEN4.js";
23
- import "./chunk-2NPD3FTX.js";
23
+ import "./chunk-U2HBB7RS.js";
24
24
  import "./chunk-PWTNI4N7.js";
25
25
  import "./chunk-AL3TYDIF.js";
26
26
  import "./chunk-HSSBDZLD.js";
27
27
  import "./chunk-HNUWUO75.js";
28
28
  import "./chunk-CHOZJMJS.js";
29
- import "./chunk-GUXZK7SE.js";
29
+ import "./chunk-XAG3FWBE.js";
30
30
  import "./chunk-LKA64WH4.js";
31
- import "./chunk-2WZXXAQD.js";
31
+ import "./chunk-BYXBJQAS.js";
32
32
  import "./chunk-DUUDXSLX.js";
33
33
  import "./chunk-QYB23WUH.js";
34
34
  import "./chunk-56GBUMO5.js";
35
- import "./chunk-AGYPUBFW.js";
35
+ import "./chunk-FPBJM2BW.js";
36
36
  import "./chunk-EEOOBRA7.js";
37
37
  import "./chunk-X4O7FJF5.js";
38
- import "./chunk-RYOLWYBK.js";
38
+ import "./chunk-MNEZUL5S.js";
39
39
  import "./chunk-QJTZ76CP.js";
40
40
  import "./chunk-VS276URX.js";
41
41
  import "./chunk-TLE77UJ5.js";
42
42
  import "./chunk-OBIC6EG7.js";
43
+ import "./chunk-WFGNWWJI.js";
43
44
  import "./chunk-FJSNBZXR.js";
44
45
  import "./chunk-2MBTWINN.js";
45
46
  import "./chunk-QRGDJA4B.js";
@@ -72,8 +73,8 @@ import "./chunk-OJKUU3LP.js";
72
73
  import "./chunk-YZMNK53S.js";
73
74
  import "./chunk-I42VC5KR.js";
74
75
  import "./chunk-U6VC4MU4.js";
75
- import "./chunk-3P54D2E4.js";
76
- import "./chunk-BNMPUQW6.js";
76
+ import "./chunk-42OKN2LI.js";
77
+ import "./chunk-JQZRSXS5.js";
77
78
  import "./chunk-KHCLMKZZ.js";
78
79
  import {
79
80
  parseUserIdFromAuthToken,
@@ -111,7 +112,7 @@ async function defaultExecuteCli(provider, prompt, options) {
111
112
  return executeCli(provider, prompt, options);
112
113
  }
113
114
  async function forwardConnectorRunMessage(machine, message, pushMessage, executeCli, env, fetchImpl) {
114
- const { handleConnectorRunMessage } = await import("./machineWsRunDispatch-KK5U4M3G.js");
115
+ const { handleConnectorRunMessage } = await import("./machineWsRunDispatch-L6H7J66T.js");
115
116
  return handleConnectorRunMessage(message, pushMessage, executeCli, env, fetchImpl);
116
117
  }
117
118
  async function detectLaunchableMachineInfo() {