nolo-cli 0.206.0 → 0.207.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 (116) hide show
  1. package/{_executeModel-Y4Y6NSF2.js → _executeModel-J7C6BIAS.js} +20 -20
  2. package/{agentDeleteCommand-QDQJ3HRU.js → agentDeleteCommand-KMRFMAZZ.js} +38 -38
  3. package/{agentEmailCommands-CMMDVTMB.js → agentEmailCommands-6QO4IX72.js} +37 -37
  4. package/{agentListCommands-YVUCTMRI.js → agentListCommands-CPI4EWX4.js} +30 -50
  5. package/{agentMachineCommands-AHMFIF7U.js → agentMachineCommands-HSSTZYNV.js} +18 -18
  6. package/{agentProviderCommands-SKW4L6NN.js → agentProviderCommands-EMKA6NAN.js} +2 -2
  7. package/{agentPullCommand-LGASFNH7.js → agentPullCommand-2JMJP5BS.js} +1 -1
  8. package/{agentRecordCommands-G6RARTFX.js → agentRecordCommands-ZL5I4ODT.js} +34 -34
  9. package/{agentRunCommand-G7IJ23OW.js → agentRunCommand-ROWADWSO.js} +35 -35
  10. package/{agentRunControl-ABDUPJLX.js → agentRunControl-45EM36PW.js} +4 -4
  11. package/{agentRuntimeLocal-7Q72MXKN.js → agentRuntimeLocal-MYHHTO4B.js} +13 -13
  12. package/{agentSlice-ZRGNTU3K.js → agentSlice-OGOKIDXG.js} +1 -1
  13. package/{appDeleteCommands-ZUKOQOIM.js → appDeleteCommands-DKINMBOK.js} +20 -20
  14. package/{appDeployCommands-G5YC3DKA.js → appDeployCommands-C3JX4GRQ.js} +20 -20
  15. package/{appDeployStatusCommands-EMOTU2NU.js → appDeployStatusCommands-LVRMBYUP.js} +20 -20
  16. package/{appGetCommands-N3D2EBDM.js → appGetCommands-CSD32O6F.js} +20 -20
  17. package/{appListCommands-DGSGMKJL.js → appListCommands-YFEJLREL.js} +20 -20
  18. package/authCommand-22FYBEGY.js +69 -0
  19. package/{authCommands-MZUXPRYJ.js → authCommands-WK6E42L2.js} +2 -2
  20. package/{chromeOpsCommands-ECVS6CAO.js → chromeOpsCommands-HEN5AX2J.js} +1 -1
  21. package/{chunk-UETRBTZ2.js → chunk-2GALTKXN.js} +38 -20
  22. package/{authCommand-NZC3H2EN.js → chunk-2NZUZIHB.js} +18 -43
  23. package/{chunk-JBWLZ3CB.js → chunk-2REKDWYL.js} +2 -2
  24. package/{chunk-767YOSGT.js → chunk-36ZR37HK.js} +8 -8
  25. package/{chunk-PPCUXO3E.js → chunk-3RQVYR4B.js} +103 -0
  26. package/{chunk-DTLSKEXN.js → chunk-3YYHTRF7.js} +2 -2
  27. package/{chunk-Y6ROFCZO.js → chunk-4O22PGNQ.js} +1 -0
  28. package/{chunk-64K7WX26.js → chunk-4WVJLODK.js} +1 -1
  29. package/{chunk-RMLFNM3J.js → chunk-5FMSOP2W.js} +2 -2
  30. package/{chunk-2Q3LOAFE.js → chunk-6HVBI6TI.js} +2 -2
  31. package/{chunk-U7HTU2S7.js → chunk-7AUQ3WCW.js} +1 -1
  32. package/{chunk-2U2DMUGG.js → chunk-7VTNQXNS.js} +29 -29
  33. package/{chunk-ZIEPLFWS.js → chunk-7WSZHITX.js} +2 -2
  34. package/{chunk-MFUGGMIS.js → chunk-AFHKLTOB.js} +2 -2
  35. package/{chunk-EDSRC2JN.js → chunk-AJ7K2REY.js} +2 -2
  36. package/{chunk-P64WRQYV.js → chunk-AZMYUSVF.js} +1 -1
  37. package/{chunk-JX2QFYIA.js → chunk-BRA5E6CI.js} +2 -2
  38. package/{chunk-VT3MVIIU.js → chunk-DLTR5MMT.js} +7 -7
  39. package/{chunk-QEHXPNCZ.js → chunk-DTVCIIUZ.js} +5 -5
  40. package/{chunk-5BHQICF2.js → chunk-E32ZPIX6.js} +7 -6
  41. package/{chunk-JTLREMIA.js → chunk-EI77BHWD.js} +5 -5
  42. package/{chunk-WPOKOKZA.js → chunk-EPRYABUO.js} +1 -1
  43. package/{chunk-T6CHEJ27.js → chunk-FSGQN6RC.js} +6 -6
  44. package/{chunk-RXX262QX.js → chunk-GMEAELJ6.js} +120 -6
  45. package/{chunk-YF4ZRVP3.js → chunk-HXHPAEAN.js} +1 -1
  46. package/{chunk-7DQSP7JU.js → chunk-J5JTMQIA.js} +1 -1
  47. package/{chunk-5OV4MVQK.js → chunk-JBOUVTZX.js} +3 -3
  48. package/{chunk-YHT3ZONH.js → chunk-JUNMZOX6.js} +2 -2
  49. package/{chunk-7T5TLIY4.js → chunk-LKDF3ATR.js} +1 -1
  50. package/{chunk-LEJSZV6V.js → chunk-P2ZLUIW2.js} +243 -15
  51. package/{chunk-MNUOMXJH.js → chunk-PQTOTGMI.js} +4 -2
  52. package/{chunk-354R5A62.js → chunk-Q54YKNWP.js} +4 -80
  53. package/{chunk-7COVU5SP.js → chunk-Q55XFXQ6.js} +2 -2
  54. package/{chunk-RQDGDKFL.js → chunk-QVUYL2TW.js} +3 -3
  55. package/{chunk-XNOILBHV.js → chunk-QWHAFJIJ.js} +1 -1
  56. package/{chunk-HAB2UDLT.js → chunk-R56VAYY4.js} +1 -1
  57. package/{chunk-YT65GYRP.js → chunk-RIGJPEBW.js} +1 -1
  58. package/{chunk-ACMRWLRR.js → chunk-RTAVELOC.js} +12 -12
  59. package/{chunk-5MXA4LWL.js → chunk-U6QSCADP.js} +1 -1
  60. package/{chunk-KJCSY4TW.js → chunk-UDHMQGMR.js} +10 -10
  61. package/{chunk-7NMNKOW5.js → chunk-UVXVWXYH.js} +2 -2
  62. package/{chunk-JASKVAYJ.js → chunk-UYY2CECP.js} +2 -2
  63. package/{chunk-6AMR3AE6.js → chunk-UZT65S6D.js} +12 -1
  64. package/{chunk-LTI5T3A6.js → chunk-VY3D2DSK.js} +1 -1
  65. package/{chunk-HSZ2YEPR.js → chunk-WADDWY7O.js} +1 -1
  66. package/{chunk-YZGNKHUM.js → chunk-WBSCOXFS.js} +1 -1
  67. package/{chunk-7C45ONOU.js → chunk-XBZDTBTK.js} +3 -3
  68. package/{chunk-TYKUYQDP.js → chunk-XDLQYUBV.js} +13 -10
  69. package/{chunk-UGCQKKXW.js → chunk-XE4Q46FF.js} +1 -1
  70. package/{chunk-PJILX6KS.js → chunk-XKH3DAKH.js} +1 -1
  71. package/{chunk-2BMURXSB.js → chunk-XPHZK3PJ.js} +4 -1
  72. package/{chunk-MNWKNN6V.js → chunk-XXYDK7L5.js} +1 -1
  73. package/{chunk-SH52SBSW.js → chunk-XYKRRB5Z.js} +13 -5
  74. package/{chunk-F6MQO3YY.js → chunk-ZG6RWZGY.js} +3 -3
  75. package/{chunk-AWVFQMOV.js → chunk-ZYKJBRZ3.js} +5 -1
  76. package/{commandRegistry-HTURFH3S.js → commandRegistry-3WR5YAN4.js} +70 -70
  77. package/{contentThunks-DYUKG2UT.js → contentThunks-4AJV2XJY.js} +4 -4
  78. package/{cooldownCommands-WGVSKMU4.js → cooldownCommands-YL7H74YB.js} +3 -3
  79. package/{createAgentAutomationAction-Y4BMH7SM.js → createAgentAutomationAction-YMY5N7IX.js} +4 -4
  80. package/{createDialogAction-RY47EJA7.js → createDialogAction-RIMBMOTA.js} +5 -5
  81. package/{createPageAction-RLV5IWBB.js → createPageAction-MDNA4BXK.js} +4 -4
  82. package/{db-2QOTXYGH.js → db-HUCI5R4G.js} +2 -2
  83. package/{dialogCommands-UR3JECOS.js → dialogCommands-LH6ILXLQ.js} +23 -23
  84. package/{dialogSlice-X23NSXGM.js → dialogSlice-JWULZZKI.js} +3 -3
  85. package/{dialogUsageCommand-QTG6ILEJ.js → dialogUsageCommand-ZCPPHPJ5.js} +1 -1
  86. package/{docCreateCommands-AM3RDP6K.js → docCreateCommands-ZJV2YVBO.js} +18 -18
  87. package/{docDeleteCommands-KCRF23RY.js → docDeleteCommands-5YMS6VX6.js} +19 -19
  88. package/{docReadCommands-M4SZAVQR.js → docReadCommands-UCHOA64J.js} +18 -18
  89. package/{docStore-OCOEV524.js → docStore-IGB6VYJW.js} +1 -1
  90. package/{docUpdateCommands-XU6NSHXX.js → docUpdateCommands-R7DXVPBN.js} +18 -18
  91. package/{getPricing-3PQY3TGI.js → getPricing-RPAQXFXY.js} +1 -1
  92. package/{handleSendMessageAction-JYLG2PGY.js → handleSendMessageAction-2TN3FOIF.js} +12 -12
  93. package/index.js +9 -9
  94. package/{localDialogRead-FUXGZ57B.js → localDialogRead-5VCMQQZF.js} +1 -1
  95. package/{localRuntimeAdapter-GQCC7EJL.js → localRuntimeAdapter-QLD7V33U.js} +30 -30
  96. package/{localRuntimeAuthority-NEGF3LRQ.js → localRuntimeAuthority-OYH4AE4G.js} +2 -2
  97. package/{localRuntimeDb-SDYFAEKA.js → localRuntimeDb-VBIMCWUC.js} +1 -1
  98. package/{machineCommands-SYG2QENB.js → machineCommands-3TQNL2KD.js} +32 -32
  99. package/{machineWsRunDispatch-HJWCU2XA.js → machineWsRunDispatch-6Z6KSDUJ.js} +32 -32
  100. package/package.json +1 -1
  101. package/{processSpawn-SOAV3FEV.js → processSpawn-ZU5QFM43.js} +1 -1
  102. package/{providerPresetApply-EQESXT6X.js → providerPresetApply-YKCAQCBR.js} +3 -3
  103. package/{providerRegistry-PZ56P43E.js → providerRegistry-QBBABMUW.js} +3 -3
  104. package/{readlineWorkspace-457FDLML.js → readlineWorkspace-NHPGVRF6.js} +560 -141
  105. package/{removeDialogAgentAction-BDLO7UC2.js → removeDialogAgentAction-GZ56EZZI.js} +1 -1
  106. package/{runAgentClientLoop-O6XYZPOG.js → runAgentClientLoop-P3ZALQBG.js} +18 -18
  107. package/{runtimeDoctorCommands-3VFVTGPI.js → runtimeDoctorCommands-3R3ZOZVS.js} +5 -5
  108. package/{secretCommands-RLIO3QK5.js → secretCommands-ZCZ4KVET.js} +1 -1
  109. package/{setPrimaryDialogAgentAction-PGBTR247.js → setPrimaryDialogAgentAction-JPTPBQH4.js} +1 -1
  110. package/{spaceCommands-SVGAP4C2.js → spaceCommands-VZ4FGE6E.js} +17 -17
  111. package/{streamAgentChatTurn-VWPG52FR.js → streamAgentChatTurn-TXTRBFOW.js} +22 -22
  112. package/{tools-WFCFBL74.js → tools-72N432Y2.js} +13 -13
  113. package/{tuiSummaryLlmCaller-CEIZAKUV.js → tuiSummaryLlmCaller-WJBM4E2H.js} +6 -6
  114. package/{updateCommands-N7K7TEU4.js → updateCommands-Q6CYAEYJ.js} +4 -4
  115. package/{updateDialogTitleAction-ZBQOKKO4.js → updateDialogTitleAction-EWTTA5A4.js} +4 -4
  116. package/{windowsSelfUpdate-SVJKL6VH.js → windowsSelfUpdate-XSQVF2GK.js} +2 -2
@@ -1,8 +1,9 @@
1
1
  import {
2
+ Level,
2
3
  createLegacyServerDb,
3
4
  createLevelAuthorityStore,
4
5
  isLevelLockError
5
- } from "./chunk-AWVFQMOV.js";
6
+ } from "./chunk-ZYKJBRZ3.js";
6
7
  import {
7
8
  createCliAuthorityBrokerClient,
8
9
  createCliAuthorityBrokerSocketInvoker,
@@ -21,13 +22,188 @@ import {
21
22
  } from "./chunk-HNMXYYJR.js";
22
23
 
23
24
  // packages/cli/localRuntimeAuthority.ts
24
- import fs2 from "node:fs";
25
- import path2 from "node:path";
25
+ import fs4 from "node:fs";
26
+ import path4 from "node:path";
26
27
 
27
28
  // packages/database-engine/cliAuthorityBrokerServer.ts
29
+ import fs3 from "node:fs";
30
+ import path3 from "node:path";
31
+ import { createServer } from "node:net";
32
+
33
+ // packages/database-engine/levelDbCorruptionRecovery.ts
28
34
  import fs from "node:fs";
29
35
  import path from "node:path";
30
- import { createServer } from "node:net";
36
+ var CORRUPTION_CODE = "LEVEL_CORRUPTION";
37
+ var CORRUPTION_MESSAGE = /Corruption:|missing files/i;
38
+ var levelClassWithRepair = Level;
39
+ function isLevelCorruptionError(error) {
40
+ const seen = /* @__PURE__ */ new Set();
41
+ let current = error;
42
+ while (current && !seen.has(current)) {
43
+ seen.add(current);
44
+ if (current.code === CORRUPTION_CODE) return true;
45
+ if (CORRUPTION_MESSAGE.test(toErrorMessage(current))) return true;
46
+ current = current.cause;
47
+ }
48
+ return false;
49
+ }
50
+ function formatUtcStamp(now) {
51
+ return new Date(now).toISOString().replace(/[-:]/g, "").replace(/\.\d{3}Z$/, "").replace("T", "-");
52
+ }
53
+ function resolveBackupPath(dbPath, now) {
54
+ const base = `${dbPath}.corrupt-${formatUtcStamp(now)}`;
55
+ let candidate = base;
56
+ for (let index = 2; fs.existsSync(candidate); index += 1) {
57
+ candidate = `${base}-${index}`;
58
+ }
59
+ return candidate;
60
+ }
61
+ async function repairLevelDatabase(dbPath) {
62
+ await levelClassWithRepair.repair(dbPath);
63
+ }
64
+ async function recoverCorruptedLevelDb(options) {
65
+ const { dbPath } = options;
66
+ const log = options.log ?? ((message) => console.warn(message));
67
+ const repair = options.repair ?? repairLevelDatabase;
68
+ const backupPath = resolveBackupPath(dbPath, (options.now ?? Date.now)());
69
+ fs.renameSync(dbPath, backupPath);
70
+ try {
71
+ fs.cpSync(backupPath, dbPath, { recursive: true, preserveTimestamps: true });
72
+ await repair(dbPath);
73
+ } catch (error) {
74
+ try {
75
+ fs.rmSync(dbPath, { recursive: true, force: true });
76
+ fs.renameSync(backupPath, dbPath);
77
+ } catch (rollbackError) {
78
+ throw Object.assign(
79
+ new Error(
80
+ `Failed to repair the local database at ${dbPath} and could not restore the original. The untouched copy is at ${backupPath}; stop every Nolo process before retrying. Do not delete ${path.join(dbPath, "LOCK")} and do not reinstall Nolo: ${toErrorMessage(error)}`,
81
+ { cause: new AggregateError([error, rollbackError], "LevelDB repair and rollback both failed") }
82
+ ),
83
+ { code: CORRUPTION_CODE, backupPath }
84
+ );
85
+ }
86
+ throw Object.assign(
87
+ new Error(
88
+ `Failed to repair the local database at ${dbPath}; the original database was restored unchanged. Stop every Nolo process and run the CLI again. Do not delete ${path.join(dbPath, "LOCK")} and do not reinstall Nolo: ${toErrorMessage(error)}`,
89
+ { cause: error }
90
+ ),
91
+ { code: CORRUPTION_CODE, backupPath }
92
+ );
93
+ }
94
+ log(
95
+ `[nolo] local database corruption detected; preserved original at ${backupPath} and repaired a copy.`
96
+ );
97
+ return { backupPath };
98
+ }
99
+
100
+ // packages/database-engine/levelDbOwnershipLock.ts
101
+ import fs2 from "node:fs";
102
+ import path2 from "node:path";
103
+ var LOCKED_CODE = "LEVEL_LOCKED";
104
+ var UNWRITTEN_LOCK_GRACE_MS = 5e3;
105
+ function createLockError(lockPath, ownerPid) {
106
+ const detail = ownerPid === void 0 ? `the lock file ${lockPath} exists but its owner process is unknown` : `it is held by process ${ownerPid}`;
107
+ return Object.assign(
108
+ new Error(
109
+ `CLI authority database is already open by another process: ${detail} (${lockPath}). Wait for that process to exit, or stop it before starting Nolo again.`
110
+ ),
111
+ { code: LOCKED_CODE, lockPath, ownerPid }
112
+ );
113
+ }
114
+ function isProcessAlive(pid) {
115
+ try {
116
+ process.kill(pid, 0);
117
+ return true;
118
+ } catch (error) {
119
+ return error.code === "EPERM";
120
+ }
121
+ }
122
+ function readLockHolder(lockPath) {
123
+ let raw;
124
+ try {
125
+ raw = fs2.readFileSync(lockPath, "utf8");
126
+ } catch (error) {
127
+ if (error.code === "ENOENT") return void 0;
128
+ throw error;
129
+ }
130
+ let pid;
131
+ try {
132
+ const parsed = JSON.parse(raw);
133
+ if (typeof parsed.pid === "number" && Number.isInteger(parsed.pid) && parsed.pid > 0) {
134
+ pid = parsed.pid;
135
+ }
136
+ } catch {
137
+ }
138
+ let mtimeMs = Date.now();
139
+ try {
140
+ mtimeMs = fs2.statSync(lockPath).mtimeMs;
141
+ } catch {
142
+ }
143
+ return { pid, mtimeMs };
144
+ }
145
+ function acquireLevelDbOwnershipLock(dbPath) {
146
+ const lockPath = `${dbPath}.owner`;
147
+ fs2.mkdirSync(path2.dirname(lockPath), { recursive: true });
148
+ const content = `${JSON.stringify({ pid: process.pid, startedAt: (/* @__PURE__ */ new Date()).toISOString() })}
149
+ `;
150
+ for (let attempt = 0; attempt < 3; attempt += 1) {
151
+ let fd;
152
+ try {
153
+ fd = fs2.openSync(lockPath, "wx", 420);
154
+ } catch (error) {
155
+ if (error.code !== "EEXIST") throw error;
156
+ const holder = readLockHolder(lockPath);
157
+ if (!holder) continue;
158
+ if (holder.pid !== void 0 && isProcessAlive(holder.pid)) {
159
+ throw createLockError(lockPath, holder.pid);
160
+ }
161
+ if (holder.pid === void 0 && Date.now() - holder.mtimeMs < UNWRITTEN_LOCK_GRACE_MS) {
162
+ throw createLockError(lockPath);
163
+ }
164
+ const quarantine = `${lockPath}.stale-${process.pid}-${Date.now()}`;
165
+ try {
166
+ fs2.renameSync(lockPath, quarantine);
167
+ fs2.rmSync(quarantine, { force: true });
168
+ } catch (renameError) {
169
+ if (renameError.code !== "ENOENT") throw renameError;
170
+ }
171
+ continue;
172
+ }
173
+ try {
174
+ fs2.writeSync(fd, content);
175
+ } catch (error) {
176
+ try {
177
+ fs2.closeSync(fd);
178
+ } catch {
179
+ }
180
+ try {
181
+ fs2.rmSync(lockPath, { force: true });
182
+ } catch {
183
+ }
184
+ throw error;
185
+ }
186
+ let released = false;
187
+ return {
188
+ lockPath,
189
+ release() {
190
+ if (released) return;
191
+ released = true;
192
+ try {
193
+ fs2.closeSync(fd);
194
+ } catch {
195
+ }
196
+ try {
197
+ fs2.rmSync(lockPath, { force: true });
198
+ } catch {
199
+ }
200
+ }
201
+ };
202
+ }
203
+ throw createLockError(lockPath);
204
+ }
205
+
206
+ // packages/database-engine/cliAuthorityBrokerServer.ts
31
207
  var brokerRegistry = /* @__PURE__ */ new Map();
32
208
  var databaseOwners = /* @__PURE__ */ new Map();
33
209
  var DEFAULT_ITERATOR_LIMIT = 200;
@@ -57,18 +233,18 @@ function buildListeningEndpoint(server, target) {
57
233
  return `tcp://${target.host}:${info.port}`;
58
234
  }
59
235
  function ensureParentDir(filePath) {
60
- fs.mkdirSync(path.dirname(filePath), { recursive: true });
236
+ fs3.mkdirSync(path3.dirname(filePath), { recursive: true });
61
237
  }
62
238
  function writeJsonFile(filePath, data) {
63
239
  if (!filePath) return;
64
240
  ensureParentDir(filePath);
65
- fs.writeFileSync(filePath, `${JSON.stringify(data, null, 2)}
241
+ fs3.writeFileSync(filePath, `${JSON.stringify(data, null, 2)}
66
242
  `, "utf8");
67
243
  }
68
244
  function removeFileIfPresent(filePath) {
69
245
  if (!filePath) return;
70
246
  try {
71
- fs.rmSync(filePath, { force: true });
247
+ fs3.rmSync(filePath, { force: true });
72
248
  } catch {
73
249
  }
74
250
  }
@@ -140,10 +316,55 @@ async function dispatchCliAuthorityBrokerRequest(store, request) {
140
316
  return createErrorResponse(error);
141
317
  }
142
318
  }
319
+ async function openAuthorityStoreWithCorruptionRecovery(options, track) {
320
+ let attemptStore;
321
+ try {
322
+ attemptStore = await options.createStore();
323
+ track(attemptStore);
324
+ await attemptStore.open();
325
+ return attemptStore;
326
+ } catch (error) {
327
+ if (!options.dbPath || !isLevelCorruptionError(error)) throw error;
328
+ if (attemptStore) {
329
+ try {
330
+ await attemptStore.close();
331
+ } catch (closeError) {
332
+ throw Object.assign(
333
+ new Error(
334
+ `LevelDB corruption detected at ${options.dbPath}, but the failed database handle could not be closed; on-disk files were left untouched. Stop every Nolo process and retry: ${toErrorMessage(closeError)}`,
335
+ { cause: closeError }
336
+ ),
337
+ { code: "LEVEL_CORRUPTION" }
338
+ );
339
+ }
340
+ track(void 0);
341
+ attemptStore = void 0;
342
+ }
343
+ const { backupPath } = await recoverCorruptedLevelDb({
344
+ dbPath: options.dbPath,
345
+ now: options.now
346
+ });
347
+ try {
348
+ attemptStore = await options.createStore();
349
+ track(attemptStore);
350
+ await attemptStore.open();
351
+ return attemptStore;
352
+ } catch (retryError) {
353
+ throw Object.assign(
354
+ new Error(
355
+ `Local database corruption at ${options.dbPath} was preserved at ${backupPath}, but reopening the repaired copy failed: ${toErrorMessage(retryError)}. Do not reinstall Nolo and do not delete ${path3.join(options.dbPath, "LOCK")}; the preserved original database is at ${backupPath}.`,
356
+ { cause: retryError }
357
+ ),
358
+ { code: "LEVEL_CORRUPTION", backupPath }
359
+ );
360
+ }
361
+ }
362
+ }
143
363
  async function createBrokerHandle(options) {
144
364
  const target = resolveBrokerListenTarget(options.endpoint);
145
365
  const socketMode = (options.transportMode ?? "socket") === "socket";
146
366
  let store;
367
+ let ownershipLock;
147
368
  const sockets = /* @__PURE__ */ new Set();
148
369
  const server = createServer((socket) => {
149
370
  sockets.add(socket);
@@ -174,8 +395,12 @@ async function createBrokerHandle(options) {
174
395
  });
175
396
  server.unref();
176
397
  }
177
- store = await options.createStore();
178
- await store.open();
398
+ if (options.dbPath) {
399
+ ownershipLock = acquireLevelDbOwnershipLock(options.dbPath);
400
+ }
401
+ store = await openAuthorityStoreWithCorruptionRecovery(options, (created) => {
402
+ store = created;
403
+ });
179
404
  storeReady = true;
180
405
  const readyStore = store;
181
406
  const now = options.now ?? Date.now;
@@ -212,6 +437,8 @@ async function createBrokerHandle(options) {
212
437
  await readyStore.close();
213
438
  brokerRegistry.delete(options.endpoint);
214
439
  releaseDatabaseOwnership(options);
440
+ ownershipLock?.release();
441
+ ownershipLock = void 0;
215
442
  removeFileIfPresent(options.metadataPath);
216
443
  removeFileIfPresent(options.healthPath);
217
444
  })().catch((error) => {
@@ -234,6 +461,7 @@ async function createBrokerHandle(options) {
234
461
  throw Object.assign(new AggregateError([error, closeError], "Broker startup failed and the native authority store could not close"), { retainAuthorityOwnership: true });
235
462
  }
236
463
  }
464
+ ownershipLock?.release();
237
465
  throw error;
238
466
  }
239
467
  }
@@ -259,14 +487,14 @@ function bindSocketRequestHandler(args) {
259
487
  });
260
488
  }
261
489
  function canonicalDatabasePath(dbPath) {
262
- const absolute = path.resolve(dbPath);
490
+ const absolute = path3.resolve(dbPath);
263
491
  try {
264
- return fs.realpathSync(absolute);
492
+ return fs3.realpathSync(absolute);
265
493
  } catch (error) {
266
494
  if (error.code !== "ENOENT") throw error;
267
- const parent = path.dirname(absolute);
495
+ const parent = path3.dirname(absolute);
268
496
  if (parent === absolute) throw error;
269
- return path.join(canonicalDatabasePath(parent), path.basename(absolute));
497
+ return path3.join(canonicalDatabasePath(parent), path3.basename(absolute));
270
498
  }
271
499
  }
272
500
  function releaseDatabaseOwnership(options) {
@@ -302,7 +530,7 @@ function getOrCreateCliAuthorityBrokerServer(options) {
302
530
 
303
531
  // packages/cli/localRuntimeAuthority.ts
304
532
  function ensureDbParentDir(dbPath) {
305
- fs2.mkdirSync(path2.dirname(dbPath), { recursive: true });
533
+ fs4.mkdirSync(path4.dirname(dbPath), { recursive: true });
306
534
  }
307
535
  function findCliAuthorityCorruption(error) {
308
536
  const seen = /* @__PURE__ */ new Set();
@@ -336,7 +564,7 @@ async function sleep(ms) {
336
564
  await new Promise((resolve) => setTimeout(resolve, ms));
337
565
  }
338
566
  function resolveCliLocalRuntimeDbPath(options = {}) {
339
- return path2.join(
567
+ return path4.join(
340
568
  resolveNoloHome({
341
569
  env: options.env,
342
570
  homeDir: options.homeDir
@@ -4,10 +4,10 @@ import {
4
4
  } from "./chunk-PJNFNEJE.js";
5
5
  import {
6
6
  findPowerShellExecutable
7
- } from "./chunk-2BMURXSB.js";
7
+ } from "./chunk-XPHZK3PJ.js";
8
8
  import {
9
9
  resolvePlatformAuthToken
10
- } from "./chunk-WPOKOKZA.js";
10
+ } from "./chunk-EPRYABUO.js";
11
11
  import {
12
12
  isRecord
13
13
  } from "./chunk-KUG52IAP.js";
@@ -2338,6 +2338,8 @@ async function spawnLocalBackgroundRun(input, deps = {}) {
2338
2338
  cwd: input.cwd,
2339
2339
  env: childEnv,
2340
2340
  detached: true,
2341
+ // Detached on Windows means no console; hide the one its children would create.
2342
+ windowsHide: true,
2341
2343
  stdio: deps.shellApprovalHost ? ["ignore", logFd, logFd, "ipc"] : ["ignore", logFd, logFd]
2342
2344
  });
2343
2345
  } catch (error) {
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  listUserRecordsFromServers,
3
3
  readLiveDbRecordAfterTombstoneMerge
4
- } from "./chunk-PJILX6KS.js";
4
+ } from "./chunk-XKH3DAKH.js";
5
5
  import {
6
6
  agentRecordHasConfiguredCredential
7
- } from "./chunk-7C45ONOU.js";
7
+ } from "./chunk-XBZDTBTK.js";
8
8
  import {
9
9
  deriveCredentialGroup
10
- } from "./chunk-RQDGDKFL.js";
10
+ } from "./chunk-QVUYL2TW.js";
11
11
  import {
12
12
  isTombstoneRecord
13
13
  } from "./chunk-D2MDMY2M.js";
@@ -307,81 +307,6 @@ async function decorateAgentsWithPublicStatusAcrossServers(args) {
307
307
  return args.agents;
308
308
  }
309
309
 
310
- // packages/ai/agent/quotaSnapshot.ts
311
- function findTightestQuotaWindow(quota, now = Date.now()) {
312
- if (!quota || !Array.isArray(quota.windows) || quota.windows.length === 0) {
313
- return void 0;
314
- }
315
- let best;
316
- let bestScore = -Infinity;
317
- for (const w of quota.windows) {
318
- let score = 0;
319
- if (typeof w.utilization === "number" && w.utilization >= 0) {
320
- score = 500 + Math.min(w.utilization, 1) * 500;
321
- } else if (typeof w.remaining === "number" && typeof w.limit === "number" && w.limit > 0) {
322
- const util = Math.max(0, 1 - w.remaining / w.limit);
323
- score = 500 + util * 500;
324
- } else if (typeof w.resetAt === "number" && w.resetAt > now) {
325
- score = 200;
326
- } else if (typeof w.remaining === "number") {
327
- score = 100;
328
- }
329
- if (score > bestScore) {
330
- bestScore = score;
331
- best = w;
332
- }
333
- }
334
- return best ?? quota.windows[0];
335
- }
336
- function formatQuotaSummary(quota, now = Date.now(), options) {
337
- const compact = options?.compact === true;
338
- const planText = formatPlanLabel(quota?.plan);
339
- const planName = typeof quota?.plan?.name === "string" ? quota.plan.name.trim() : "";
340
- const tightest = findTightestQuotaWindow(quota, now);
341
- if (!tightest) return compact ? planName || void 0 : planText;
342
- const parts = [];
343
- if (typeof tightest.utilization === "number") {
344
- const pct = Math.round(tightest.utilization * 100);
345
- parts.push(`${pct}%\u5DF2\u7528`);
346
- } else if (typeof tightest.remaining === "number") {
347
- if (typeof tightest.limit === "number") {
348
- parts.push(`${tightest.remaining}/${tightest.limit}${tightest.unit ? ` ${tightest.unit}` : ""}`);
349
- } else {
350
- parts.push(`\u4F59${tightest.remaining}${tightest.unit ? ` ${tightest.unit}` : ""}`);
351
- }
352
- }
353
- if (compact) {
354
- const head = parts.length > 0 ? parts[0] : void 0;
355
- return [planName || void 0, head].filter(Boolean).join(" \xB7 ") || void 0;
356
- }
357
- if (tightest.scope && tightest.scope !== "user" && tightest.scope !== "project" && tightest.scope !== tightest.unit) {
358
- parts.push(tightest.scope);
359
- }
360
- if (typeof tightest.resetAt === "number" && tightest.resetAt > now) {
361
- const diffSec = Math.round((tightest.resetAt - now) / 1e3);
362
- if (diffSec < 60) {
363
- parts.push(`${diffSec}s\u540E\u91CD\u7F6E`);
364
- } else if (diffSec < 3600) {
365
- parts.push(`${Math.round(diffSec / 60)}m\u540E\u91CD\u7F6E`);
366
- } else if (diffSec < 86400) {
367
- const hours = (diffSec / 3600).toFixed(1).replace(/\.0$/, "");
368
- parts.push(`${hours}h\u540E\u91CD\u7F6E`);
369
- } else {
370
- const days = (diffSec / 86400).toFixed(1).replace(/\.0$/, "");
371
- parts.push(`${days}d\u540E\u91CD\u7F6E`);
372
- }
373
- }
374
- const onlyScope = parts.length === 0 || parts.length === 1 && parts[0] === tightest.scope;
375
- if (onlyScope) return planText;
376
- return [planText, ...parts].filter(Boolean).join(" \xB7 ");
377
- }
378
- function formatPlanLabel(plan) {
379
- const name = typeof plan?.name === "string" ? plan.name.trim() : "";
380
- if (!name) return void 0;
381
- const credits = typeof plan?.monthlyCreditsUsd === "number" && Number.isFinite(plan.monthlyCreditsUsd) && plan.monthlyCreditsUsd > 0 ? `\u6708\u5EA6\u989D\u5EA6 $${plan.monthlyCreditsUsd}` : void 0;
382
- return [`${name} \u5957\u9910`, credits].filter(Boolean).join(" \xB7 ");
383
- }
384
-
385
310
  export {
386
311
  normalizeListedAgent,
387
312
  parseAgentListArgs,
@@ -390,6 +315,5 @@ export {
390
315
  listRemoteAgents,
391
316
  listRemoteAgentsAcrossServers,
392
317
  listFavoriteAgentIdsAcrossServers,
393
- decorateAgentsWithPublicStatusAcrossServers,
394
- formatQuotaSummary
318
+ decorateAgentsWithPublicStatusAcrossServers
395
319
  };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  toolRegistry
3
- } from "./chunk-ACMRWLRR.js";
3
+ } from "./chunk-RTAVELOC.js";
4
4
  import {
5
5
  runtime_default
6
- } from "./chunk-KJCSY4TW.js";
6
+ } from "./chunk-UDHMQGMR.js";
7
7
  import {
8
8
  canonicalizeToolNames
9
9
  } from "./chunk-AKE53VMW.js";
@@ -3,12 +3,12 @@ import {
3
3
  } from "./chunk-UEILX4EV.js";
4
4
  import {
5
5
  compareAgentSelection
6
- } from "./chunk-2Q3LOAFE.js";
6
+ } from "./chunk-6HVBI6TI.js";
7
7
  import {
8
8
  DEFAULT_PROVIDER_RETRY_MS,
9
9
  isAgentUnavailableNow,
10
10
  resolveAgentAvailability
11
- } from "./chunk-RXX262QX.js";
11
+ } from "./chunk-GMEAELJ6.js";
12
12
  import {
13
13
  isOAuthApiKeyRef
14
14
  } from "./chunk-UKZX3NHN.js";
@@ -21,7 +21,7 @@ import {
21
21
  isAntigravityOAuthAgent,
22
22
  isSubscriptionEndpoint,
23
23
  isSubscriptionOAuthCredential
24
- } from "./chunk-YF4ZRVP3.js";
24
+ } from "./chunk-HXHPAEAN.js";
25
25
  import {
26
26
  getModelAbility
27
27
  } from "./chunk-T43B7LB2.js";
@@ -5,7 +5,7 @@ import {
5
5
  ANTIGRAVITY_CLOUD_CODE_BASE_URL,
6
6
  isAntigravityCloudCodeBaseUrl,
7
7
  isAntigravityOAuthAgent
8
- } from "./chunk-YF4ZRVP3.js";
8
+ } from "./chunk-HXHPAEAN.js";
9
9
  import {
10
10
  isOpenAiResponsesModel,
11
11
  resolvePlatformChatCompletionsEndpoint,
@@ -2,7 +2,7 @@ import {
2
2
  mergeAvailabilityDeadline,
3
3
  resolveCredentialCandidateKeys,
4
4
  resolveCredentialKeyWithFallback
5
- } from "./chunk-RXX262QX.js";
5
+ } from "./chunk-GMEAELJ6.js";
6
6
 
7
7
  // packages/agent-runtime/credentialAvailability.ts
8
8
  import { homedir } from "node:os";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  readDbRecord,
3
3
  writeAgentRecord
4
- } from "./chunk-7C45ONOU.js";
4
+ } from "./chunk-XBZDTBTK.js";
5
5
  import {
6
6
  buildSkillSummaryMarker
7
7
  } from "./chunk-VF4K2QE6.js";
@@ -6,7 +6,7 @@ import {
6
6
  resolveDiscoveryScope,
7
7
  resolvePaginationArgs,
8
8
  toDiscoverySafeAgentSummary
9
- } from "./chunk-RQDGDKFL.js";
9
+ } from "./chunk-QVUYL2TW.js";
10
10
  import {
11
11
  getUserDataItemTimestamp,
12
12
  mergeAndDedupUserData
@@ -38,7 +38,7 @@ import {
38
38
  toolRunUpdated,
39
39
  uiCardFallback,
40
40
  waitForAbortableDelay
41
- } from "./chunk-ZIEPLFWS.js";
41
+ } from "./chunk-7WSZHITX.js";
42
42
  import {
43
43
  isGatewayHttpStatus
44
44
  } from "./chunk-NF64D32W.js";
@@ -55,7 +55,7 @@ import {
55
55
  } from "./chunk-I5PBXF7O.js";
56
56
  import {
57
57
  createDocState
58
- } from "./chunk-JX2QFYIA.js";
58
+ } from "./chunk-BRA5E6CI.js";
59
59
  import {
60
60
  ToolApiError,
61
61
  buildToolRequestHeaders,
@@ -79,7 +79,7 @@ import {
79
79
  } from "./chunk-63W5N6P3.js";
80
80
  import {
81
81
  createDialogAction
82
- } from "./chunk-EDSRC2JN.js";
82
+ } from "./chunk-AJ7K2REY.js";
83
83
  import {
84
84
  DEFAULT_COLLAPSED_CATEGORIES,
85
85
  addContentToSpace,
@@ -96,7 +96,7 @@ import {
96
96
  updateContentCategory,
97
97
  updateContentTitle,
98
98
  writeStoredCollapsedCategories
99
- } from "./chunk-HSZ2YEPR.js";
99
+ } from "./chunk-WADDWY7O.js";
100
100
  import {
101
101
  getCurrentSpaceId,
102
102
  getCurrentSpaceIdRaw,
@@ -119,14 +119,14 @@ import {
119
119
  selectMsgById,
120
120
  uiAskChoiceFunc,
121
121
  uiAskChoiceFunctionSchema
122
- } from "./chunk-KJCSY4TW.js";
122
+ } from "./chunk-UDHMQGMR.js";
123
123
  import {
124
124
  createAgent,
125
125
  deleteServerSyncedCredential,
126
126
  runLlm,
127
127
  streamAgentChatTurn,
128
128
  updateAgent
129
- } from "./chunk-F6MQO3YY.js";
129
+ } from "./chunk-ZG6RWZGY.js";
130
130
  import {
131
131
  buildMediaToolConfirmation,
132
132
  normalizeMediaConfirmExecutionRevision
@@ -222,11 +222,11 @@ import {
222
222
  resolveNoloDialogInput,
223
223
  resolveReadOnlyToolConstraints,
224
224
  verifyNoloDialogSubjectRefQuery
225
- } from "./chunk-2Q3LOAFE.js";
225
+ } from "./chunk-6HVBI6TI.js";
226
226
  import {
227
227
  mergeAvailabilityDeadline,
228
228
  resolveCredentialKeyWithFallback
229
- } from "./chunk-RXX262QX.js";
229
+ } from "./chunk-GMEAELJ6.js";
230
230
  import {
231
231
  clipCompactText
232
232
  } from "./chunk-5MMAK75Q.js";
@@ -1264,7 +1264,7 @@ var buildPlatformFormDataFromArgs = async (args) => {
1264
1264
  const trimmedModel = toTrimmedString(model);
1265
1265
  const trimmedProvider = toTrimmedString(provider);
1266
1266
  const modelConfig = await findModelConfig(trimmedModel, trimmedProvider);
1267
- const { getModelPricing } = await import("./getPricing-3PQY3TGI.js");
1267
+ const { getModelPricing } = await import("./getPricing-RPAQXFXY.js");
1268
1268
  const normalizedTools = tools ?? [];
1269
1269
  const resolvedRuntimeToolPolicy = runtimeToolPolicy ?? (normalizedTools.includes("execShell") ? HOSTED_EXEC_RUNTIME_TOOL_POLICY : void 0);
1270
1270
  const formData = {
@@ -3898,7 +3898,7 @@ async function deleteDialogsFunc(args, thunkApi) {
3898
3898
  const deletedDialogIds = [];
3899
3899
  const deletedDialogKeys = [];
3900
3900
  const failures = [];
3901
- const { deleteDialog: deleteDialog2 } = await import("./dialogSlice-X23NSXGM.js");
3901
+ const { deleteDialog: deleteDialog2 } = await import("./dialogSlice-JWULZZKI.js");
3902
3902
  for (const target of targets) {
3903
3903
  try {
3904
3904
  await thunkApi.dispatch(deleteDialog2(target.dbKey)).unwrap();
@@ -18699,7 +18699,7 @@ async function updateDocFunc(args, thunkApi) {
18699
18699
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
18700
18700
  };
18701
18701
  await dispatch(write({ data: updatedPageData, customKey: id })).unwrap();
18702
- const { getDocState, applyExternalDocUpdate } = await import("./docStore-OCOEV524.js");
18702
+ const { getDocState, applyExternalDocUpdate } = await import("./docStore-IGB6VYJW.js");
18703
18703
  if (getDocState().pageKey === id) {
18704
18704
  applyExternalDocUpdate({
18705
18705
  slateData: finalSlateData,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  generatePkcePair,
3
3
  startCallbackServer
4
- } from "./chunk-LTI5T3A6.js";
4
+ } from "./chunk-VY3D2DSK.js";
5
5
  import {
6
6
  toErrorMessage
7
7
  } from "./chunk-HNMXYYJR.js";