nolo-cli 0.206.1 → 0.208.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 (113) hide show
  1. package/{_executeModel-U2XB3H4R.js → _executeModel-F4GZ3K75.js} +20 -20
  2. package/{agentDeleteCommand-NVXNQ2VQ.js → agentDeleteCommand-F2HW7SZI.js} +36 -36
  3. package/{agentEmailCommands-VUJOYASY.js → agentEmailCommands-6PJSMXBQ.js} +35 -35
  4. package/{agentListCommands-KDRCBFUE.js → agentListCommands-S54ZR3L7.js} +27 -47
  5. package/{agentMachineCommands-TGZIF2SL.js → agentMachineCommands-HN7VKXOV.js} +16 -16
  6. package/{agentProviderCommands-SKW4L6NN.js → agentProviderCommands-MN3ABDME.js} +2 -2
  7. package/{agentPullCommand-LGASFNH7.js → agentPullCommand-2JMJP5BS.js} +1 -1
  8. package/{agentRecordCommands-DM5UHNZM.js → agentRecordCommands-SZ6JTRZG.js} +32 -32
  9. package/{agentRunCommand-T6JGFAFZ.js → agentRunCommand-XEV3BK3L.js} +33 -33
  10. package/{agentRunControl-GOH5VSQU.js → agentRunControl-AF7BMR22.js} +3 -3
  11. package/{agentRuntimeLocal-N5S7NSJB.js → agentRuntimeLocal-KCC7QW7Z.js} +12 -12
  12. package/{agentSlice-6XXGHTPP.js → agentSlice-QHBCIRZZ.js} +1 -1
  13. package/{appDeleteCommands-VJNS4HSF.js → appDeleteCommands-7O4SMBTL.js} +18 -18
  14. package/{appDeployCommands-HLZIEHUP.js → appDeployCommands-4Y46KPQJ.js} +18 -18
  15. package/{appDeployStatusCommands-PT64TF2T.js → appDeployStatusCommands-WRAXA7AH.js} +18 -18
  16. package/{appGetCommands-FM2ICAF7.js → appGetCommands-RKC3OW5T.js} +18 -18
  17. package/{appListCommands-QVC3TKQD.js → appListCommands-3QVE4TSI.js} +18 -18
  18. package/authCommand-AUP7FHGM.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-4NWJ3Z3G.js → chunk-25OB36GU.js} +1 -1
  22. package/{chunk-5MXA4LWL.js → chunk-27E2CBBY.js} +1 -1
  23. package/{chunk-3ZUXGHFS.js → chunk-2UZ22L3V.js} +4 -80
  24. package/{chunk-3UCYYSKN.js → chunk-35DNCETZ.js} +29 -29
  25. package/{chunk-7NMNKOW5.js → chunk-3IBHFELR.js} +2 -2
  26. package/{chunk-JASKVAYJ.js → chunk-3QKILTO3.js} +2 -2
  27. package/{chunk-PPCUXO3E.js → chunk-3RQVYR4B.js} +103 -0
  28. package/{chunk-YZGNKHUM.js → chunk-3V2QMRNN.js} +1 -1
  29. package/{chunk-BAPZCPYU.js → chunk-4LEGTOSR.js} +1 -1
  30. package/{chunk-64K7WX26.js → chunk-4WVJLODK.js} +1 -1
  31. package/{chunk-Y3ASVJWL.js → chunk-64D757HH.js} +3 -3
  32. package/{chunk-2Q3LOAFE.js → chunk-6HVBI6TI.js} +2 -2
  33. package/{chunk-U7HTU2S7.js → chunk-7AUQ3WCW.js} +1 -1
  34. package/{chunk-L5FZUSB6.js → chunk-AD26C3WW.js} +3 -3
  35. package/{chunk-4RERKW4Q.js → chunk-AJ65N2PX.js} +5 -5
  36. package/{chunk-5XNUQGLF.js → chunk-ALBTWLUE.js} +7 -7
  37. package/{chunk-P64WRQYV.js → chunk-AZMYUSVF.js} +1 -1
  38. package/{authCommand-NZC3H2EN.js → chunk-B2WYM23T.js} +18 -43
  39. package/{chunk-WC6TH54L.js → chunk-BF3TXGWM.js} +5 -5
  40. package/{chunk-PK5TD4ST.js → chunk-C2XZM3K4.js} +1 -1
  41. package/{chunk-5ZBZHVMF.js → chunk-CAB2CZ5H.js} +36 -19
  42. package/{chunk-ZCKXJTCW.js → chunk-CGQSAFXP.js} +10 -10
  43. package/{chunk-XNOILBHV.js → chunk-CKOO42G5.js} +1 -1
  44. package/{chunk-SEOM7GLZ.js → chunk-COWSUNBH.js} +1 -1
  45. package/{chunk-JBWLZ3CB.js → chunk-DA7CTWT4.js} +2 -2
  46. package/{chunk-YJ6UWOO5.js → chunk-DNQ5NOAR.js} +2 -2
  47. package/{chunk-NUAQ3QHF.js → chunk-FPCPCTSA.js} +2 -2
  48. package/{chunk-5OJDQAJ2.js → chunk-FQQWTOBR.js} +2 -2
  49. package/{chunk-7LJEJV4F.js → chunk-GMEAELJ6.js} +88 -1
  50. package/{chunk-7DQSP7JU.js → chunk-J5JTMQIA.js} +1 -1
  51. package/{chunk-EVG6HQQ7.js → chunk-JBOUVTZX.js} +2 -2
  52. package/{chunk-5BHQICF2.js → chunk-JRTNUU5Z.js} +25 -6
  53. package/{chunk-7T5TLIY4.js → chunk-LKDF3ATR.js} +1 -1
  54. package/{chunk-LKV5K7PW.js → chunk-MKK2YY5Q.js} +2 -2
  55. package/{chunk-73PRLLT6.js → chunk-MONJ5H3H.js} +5 -5
  56. package/{chunk-LEJSZV6V.js → chunk-P2ZLUIW2.js} +243 -15
  57. package/{chunk-YF4ZRVP3.js → chunk-PLYWH7XM.js} +1 -1
  58. package/{chunk-WPOKOKZA.js → chunk-PV6JJAUB.js} +1 -1
  59. package/{chunk-IAYMBPDZ.js → chunk-QOI7USOV.js} +2 -2
  60. package/{chunk-W45PCJHS.js → chunk-R56VAYY4.js} +1 -1
  61. package/{chunk-DDVXTOFJ.js → chunk-RIALQUSF.js} +8 -8
  62. package/{chunk-LTI5T3A6.js → chunk-SN5XE6GQ.js} +1 -1
  63. package/{chunk-D3DGBEYY.js → chunk-SU3QL7YG.js} +2 -2
  64. package/{chunk-MNWKNN6V.js → chunk-SZ4ADZFT.js} +1 -1
  65. package/{chunk-2GKUVGRT.js → chunk-THE5CKB2.js} +13 -5
  66. package/{chunk-ZRDUMMDG.js → chunk-UTBQCL6N.js} +9 -7
  67. package/{chunk-6AMR3AE6.js → chunk-UZT65S6D.js} +12 -1
  68. package/{chunk-K7ZZPUNO.js → chunk-WWSPE2GG.js} +12 -12
  69. package/{chunk-2PW2KOII.js → chunk-XDMGY5IU.js} +2 -2
  70. package/{chunk-UGCQKKXW.js → chunk-XE4Q46FF.js} +1 -1
  71. package/{chunk-QSAUX2Q2.js → chunk-YCEA47VH.js} +2 -2
  72. package/{chunk-LDPZBAQK.js → chunk-YY37MQSS.js} +2 -2
  73. package/{chunk-AWVFQMOV.js → chunk-ZYKJBRZ3.js} +5 -1
  74. package/{commandRegistry-PASVNTAX.js → commandRegistry-XVFA25FB.js} +70 -70
  75. package/{contentThunks-IXBWQP4P.js → contentThunks-V3CDW4YX.js} +4 -4
  76. package/{cooldownCommands-I4ETQ4AO.js → cooldownCommands-YL7H74YB.js} +3 -3
  77. package/{createAgentAutomationAction-7O7PFPDO.js → createAgentAutomationAction-FGWAYVEP.js} +4 -4
  78. package/{createDialogAction-DRHO4XCF.js → createDialogAction-UXAMBNR4.js} +5 -5
  79. package/{createPageAction-TFGJRDZX.js → createPageAction-S6HULJP6.js} +4 -4
  80. package/{db-2QOTXYGH.js → db-HUCI5R4G.js} +2 -2
  81. package/{dialogCommands-RYIONJLY.js → dialogCommands-HW6WWUII.js} +21 -21
  82. package/{dialogSlice-CXIZ5UTI.js → dialogSlice-TBITWBDH.js} +3 -3
  83. package/{dialogUsageCommand-QTG6ILEJ.js → dialogUsageCommand-ZCPPHPJ5.js} +1 -1
  84. package/{docCreateCommands-KC2V2RPX.js → docCreateCommands-ETFMIYE5.js} +16 -16
  85. package/{docDeleteCommands-S2SDQL2S.js → docDeleteCommands-HEDB7AHB.js} +17 -17
  86. package/{docReadCommands-3YGFKAOZ.js → docReadCommands-4T5EQQW6.js} +16 -16
  87. package/{docStore-5AHNSAEI.js → docStore-NFLRMEX3.js} +1 -1
  88. package/{docUpdateCommands-PU6MQTLW.js → docUpdateCommands-TYM5V565.js} +16 -16
  89. package/{getPricing-3PQY3TGI.js → getPricing-OQXBJ6VZ.js} +1 -1
  90. package/{handleSendMessageAction-SO3PD3YA.js → handleSendMessageAction-UCFZXCXP.js} +12 -12
  91. package/index.js +7 -7
  92. package/{localDialogRead-FUXGZ57B.js → localDialogRead-5VCMQQZF.js} +1 -1
  93. package/{localRuntimeAdapter-5B7QODVK.js → localRuntimeAdapter-JBXUIVNU.js} +29 -29
  94. package/{localRuntimeAuthority-NEGF3LRQ.js → localRuntimeAuthority-OYH4AE4G.js} +2 -2
  95. package/{localRuntimeDb-SDYFAEKA.js → localRuntimeDb-VBIMCWUC.js} +1 -1
  96. package/{machineCommands-U3DO4TFR.js → machineCommands-FDQA6NCY.js} +30 -30
  97. package/{machineWsRunDispatch-Y3IMIZO7.js → machineWsRunDispatch-VBTEUSVI.js} +30 -30
  98. package/package.json +1 -1
  99. package/{providerPresetApply-EQESXT6X.js → providerPresetApply-ZYMLQA46.js} +3 -3
  100. package/{providerRegistry-PZ56P43E.js → providerRegistry-E34XWDLJ.js} +3 -3
  101. package/{readlineWorkspace-32IDD2MQ.js → readlineWorkspace-SJY4M4YP.js} +558 -139
  102. package/{removeDialogAgentAction-BDLO7UC2.js → removeDialogAgentAction-UQFCQO6L.js} +1 -1
  103. package/{runAgentClientLoop-ERVJ4LFY.js → runAgentClientLoop-V4KMRRPJ.js} +18 -18
  104. package/{runtimeDoctorCommands-3VFVTGPI.js → runtimeDoctorCommands-PGAA47G5.js} +5 -5
  105. package/{secretCommands-RLIO3QK5.js → secretCommands-ZCZ4KVET.js} +1 -1
  106. package/{setPrimaryDialogAgentAction-PGBTR247.js → setPrimaryDialogAgentAction-23PMBXWD.js} +1 -1
  107. package/{spaceCommands-4UWABUD7.js → spaceCommands-JMU4R5LB.js} +15 -15
  108. package/{streamAgentChatTurn-2M4L7PF4.js → streamAgentChatTurn-SUWOIV4S.js} +22 -22
  109. package/{tools-GINHFGST.js → tools-JW4EEFK7.js} +13 -13
  110. package/{tuiSummaryLlmCaller-CEIZAKUV.js → tuiSummaryLlmCaller-4QCQ2TIN.js} +6 -6
  111. package/{updateCommands-X23W5F73.js → updateCommands-Q6CYAEYJ.js} +3 -3
  112. package/{updateDialogTitleAction-4EIHKTKR.js → updateDialogTitleAction-EDXTLVGM.js} +4 -4
  113. 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
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  trimTrailingSlash
3
- } from "./chunk-WPOKOKZA.js";
3
+ } from "./chunk-PV6JJAUB.js";
4
4
  import {
5
5
  commandCodeModels,
6
6
  kimiCodeModels,
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-YUA6OAH5.js";
8
8
  import {
9
9
  CLI_PROVIDER_VALUES
10
- } from "./chunk-5BHQICF2.js";
10
+ } from "./chunk-JRTNUU5Z.js";
11
11
  import {
12
12
  normalizeServerOrigin
13
13
  } from "./chunk-CF7PE763.js";
@@ -333,7 +333,7 @@ async function saveDocState(arg, { dispatch, getState }) {
333
333
  ).unwrap();
334
334
  if (dbSpaceId) {
335
335
  try {
336
- const { updateContentTitle } = await import("./contentThunks-IXBWQP4P.js");
336
+ const { updateContentTitle } = await import("./contentThunks-V3CDW4YX.js");
337
337
  await dispatch(
338
338
  updateContentTitle({
339
339
  spaceId: dbSpaceId,
@@ -372,7 +372,7 @@ async function saveDocState(arg, { dispatch, getState }) {
372
372
  }
373
373
  }
374
374
  async function createDocState(args, thunkApi) {
375
- const { createPageAction } = await import("./createPageAction-TFGJRDZX.js");
375
+ const { createPageAction } = await import("./createPageAction-S6HULJP6.js");
376
376
  return createPageAction(args, thunkApi);
377
377
  }
378
378
  function subscribe(listener) {
@@ -2,7 +2,7 @@ import {
2
2
  mergeAvailabilityDeadline,
3
3
  resolveCredentialCandidateKeys,
4
4
  resolveCredentialKeyWithFallback
5
- } from "./chunk-7LJEJV4F.js";
5
+ } from "./chunk-GMEAELJ6.js";
6
6
 
7
7
  // packages/agent-runtime/credentialAvailability.ts
8
8
  import { homedir } from "node:os";
@@ -7,7 +7,7 @@ import {
7
7
  listUserRecordsFromServers,
8
8
  readDbRecordFromServers,
9
9
  readLiveDbRecordAfterTombstoneMerge
10
- } from "./chunk-BAPZCPYU.js";
10
+ } from "./chunk-4LEGTOSR.js";
11
11
  import {
12
12
  parsePositiveFiniteNumberOrFallback
13
13
  } from "./chunk-Y5GCAMGP.js";
@@ -24,10 +24,10 @@ import {
24
24
  } from "./chunk-LEC5ALIN.js";
25
25
  import {
26
26
  getDefaultCliLocalRuntimeDb
27
- } from "./chunk-LEJSZV6V.js";
27
+ } from "./chunk-P2ZLUIW2.js";
28
28
  import {
29
29
  isLevelLockError
30
- } from "./chunk-AWVFQMOV.js";
30
+ } from "./chunk-ZYKJBRZ3.js";
31
31
  import {
32
32
  resolveLocalDialogDbCandidates,
33
33
  resolveNoloHome,
@@ -43,13 +43,13 @@ import {
43
43
  boundSummaryText,
44
44
  buildDialogReadEnvelope,
45
45
  projectDialogReadForAgent
46
- } from "./chunk-2Q3LOAFE.js";
46
+ } from "./chunk-6HVBI6TI.js";
47
47
  import {
48
48
  asRecordOrEmpty
49
49
  } from "./chunk-KX6YBIHG.js";
50
50
  import {
51
51
  resolveRunsDir
52
- } from "./chunk-PK5TD4ST.js";
52
+ } from "./chunk-C2XZM3K4.js";
53
53
  import {
54
54
  toErrorMessage
55
55
  } from "./chunk-HNMXYYJR.js";
@@ -69,7 +69,7 @@ import {
69
69
  } from "./chunk-4SN6J65J.js";
70
70
  import {
71
71
  t
72
- } from "./chunk-PPCUXO3E.js";
72
+ } from "./chunk-3RQVYR4B.js";
73
73
  import {
74
74
  asNonEmptyStringArray,
75
75
  asTrimmedNonEmptyStringArray
@@ -780,7 +780,7 @@ function isExplicitDialogIdMismatch(meta, dialogId) {
780
780
  return meta && typeof meta === "object" && "id" in meta && meta.id != null && String(meta.id) !== dialogId;
781
781
  }
782
782
  async function readDialogFromLocalDb(dialogKey, dialogId, limit, readLocalDialog) {
783
- const reader = readLocalDialog ?? (await import("./localDialogRead-FUXGZ57B.js")).readDialogFromLocalDb;
783
+ const reader = readLocalDialog ?? (await import("./localDialogRead-5VCMQQZF.js")).readDialogFromLocalDb;
784
784
  const result = await reader({ dialogKey, dialogId, limit });
785
785
  return {
786
786
  ...result,
@@ -795,7 +795,7 @@ async function readLocalDialogAtDbPathDefault(args) {
795
795
  );
796
796
  }
797
797
  const db = await getDefaultCliLocalRuntimeDb();
798
- const { readDialogFromLocalDb: reader } = await import("./localDialogRead-FUXGZ57B.js");
798
+ const { readDialogFromLocalDb: reader } = await import("./localDialogRead-5VCMQQZF.js");
799
799
  return reader({ ...args, db });
800
800
  }
801
801
  async function readDialogFromLocalDbWithFallback(args) {
@@ -14,7 +14,7 @@ import {
14
14
  getAntigravityUserAgent,
15
15
  normalizeAntigravityTokenPayload,
16
16
  refreshAntigravityToken
17
- } from "./chunk-YF4ZRVP3.js";
17
+ } from "./chunk-PLYWH7XM.js";
18
18
  import {
19
19
  toErrorMessage
20
20
  } from "./chunk-HNMXYYJR.js";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  requireTokenUser
3
- } from "./chunk-4NWJ3Z3G.js";
3
+ } from "./chunk-25OB36GU.js";
4
4
  import {
5
5
  resolveServerUrl
6
6
  } from "./chunk-WACI5I6V.js";
7
7
  import {
8
8
  t
9
- } from "./chunk-PPCUXO3E.js";
9
+ } from "./chunk-3RQVYR4B.js";
10
10
 
11
11
  // packages/cli/cliApiClient.ts
12
12
  var CliApiError = class extends Error {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolveAgentImageInputSupport
3
- } from "./chunk-JBWLZ3CB.js";
3
+ } from "./chunk-DA7CTWT4.js";
4
4
  import {
5
5
  TOOL_HAD_IMAGES,
6
6
  hadToolImages
@@ -3,10 +3,10 @@ import {
3
3
  } from "./chunk-HS7MLR74.js";
4
4
  import {
5
5
  performServerProxyFetchWithRetry
6
- } from "./chunk-YJ6UWOO5.js";
6
+ } from "./chunk-DNQ5NOAR.js";
7
7
  import {
8
8
  fetchServerSyncedCredential
9
- } from "./chunk-Y3ASVJWL.js";
9
+ } from "./chunk-64D757HH.js";
10
10
  import {
11
11
  buildSkillGuidancePromptBlock
12
12
  } from "./chunk-Y6M7KJOA.js";
@@ -14,6 +14,7 @@ import {
14
14
  CREDENTIAL_HYGIENE_RULE,
15
15
  DELETE_SAFETY_RED_LINE,
16
16
  DISPATCH_BACKEND_POLICY,
17
+ DISPATCH_CANDIDATE_POLICY,
17
18
  PARALLEL_DISPATCH_DEFAULT_RULE,
18
19
  PLATFORM_RISK_CONTROL_RULE,
19
20
  buildConsultationModeBlock,
@@ -23,7 +24,7 @@ import {
23
24
  compileContextLayers,
24
25
  detectDispatchIntentFromMessages,
25
26
  resolveToolGuidedSections
26
- } from "./chunk-6AMR3AE6.js";
27
+ } from "./chunk-UZT65S6D.js";
27
28
  import {
28
29
  convertMessagesToResponsesInput,
29
30
  getUsageRequestOptions,
@@ -36,7 +37,7 @@ import {
36
37
  import {
37
38
  resolveAgentCallPlan,
38
39
  resolveClientWire
39
- } from "./chunk-XNOILBHV.js";
40
+ } from "./chunk-CKOO42G5.js";
40
41
  import {
41
42
  createFileCredentialBroker
42
43
  } from "./chunk-UIOEHFF6.js";
@@ -50,7 +51,7 @@ import {
50
51
  } from "./chunk-AKE53VMW.js";
51
52
  import {
52
53
  buildProviderAuthHeaders
53
- } from "./chunk-WPOKOKZA.js";
54
+ } from "./chunk-PV6JJAUB.js";
54
55
  import {
55
56
  clampReasoningEffort,
56
57
  getModelConfig,
@@ -292,6 +293,13 @@ ${wrapHistoricalSummaryWithReplayGuard(contexts.dialogSummary)}` : "";
292
293
  cacheScope: "static",
293
294
  content: DISPATCH_BACKEND_POLICY
294
295
  },
296
+ // 派发选人:可用性重扫与速度口径(与后端块同级,紧随其后)。
297
+ {
298
+ id: "dispatch-candidate-policy",
299
+ owner: "platform",
300
+ cacheScope: "static",
301
+ content: DISPATCH_CANDIDATE_POLICY
302
+ },
295
303
  // 平台风控纪律:无条件静态前缀,紧随并行派发块。
296
304
  {
297
305
  id: "platform-risk-control",
@@ -2,7 +2,7 @@ import {
2
2
  DEVIN_CONNECT_URL,
3
3
  parseSseDataLineJson,
4
4
  parseSseDataLineObject
5
- } from "./chunk-JASKVAYJ.js";
5
+ } from "./chunk-3QKILTO3.js";
6
6
  import {
7
7
  applyChatCompletionDelta,
8
8
  applyResponsesToolEvent,
@@ -11,7 +11,7 @@ import {
11
11
  flushChatCompletionStream,
12
12
  providerHttpFailure,
13
13
  throwIfChatCompletionStreamFailed
14
- } from "./chunk-7NMNKOW5.js";
14
+ } from "./chunk-3IBHFELR.js";
15
15
  import {
16
16
  readSseFrames
17
17
  } from "./chunk-HNUWUO75.js";
@@ -29,7 +29,7 @@ import {
29
29
  import {
30
30
  hasImageInRuntimeMessages,
31
31
  stripImagePartsFromMessages
32
- } from "./chunk-MNWKNN6V.js";
32
+ } from "./chunk-SZ4ADZFT.js";
33
33
  import {
34
34
  clipToolText,
35
35
  resolveHistoricalToolContentCap,
@@ -38,7 +38,7 @@ import {
38
38
  import {
39
39
  resolveAgentImageInputSupport,
40
40
  resolveToolImagePolicy
41
- } from "./chunk-JBWLZ3CB.js";
41
+ } from "./chunk-DA7CTWT4.js";
42
42
  import {
43
43
  applyShapingCounts,
44
44
  attachProjectionFacts,
@@ -61,6 +61,7 @@ import {
61
61
  CREDENTIAL_HYGIENE_RULE,
62
62
  DELETE_SAFETY_RED_LINE,
63
63
  DISPATCH_BACKEND_POLICY,
64
+ DISPATCH_CANDIDATE_POLICY,
64
65
  PARALLEL_DISPATCH_DEFAULT_RULE,
65
66
  PLATFORM_RISK_CONTROL_RULE,
66
67
  TOOL_GUIDED_SECTION_ORDER,
@@ -73,7 +74,7 @@ import {
73
74
  hashStablePrefixContent,
74
75
  resolveResponseGuidelines,
75
76
  resolveToolGuidedSections
76
- } from "./chunk-6AMR3AE6.js";
77
+ } from "./chunk-UZT65S6D.js";
77
78
  import {
78
79
  classifyUnparsableToolArgs,
79
80
  collectStablePromptPrefix,
@@ -130,7 +131,7 @@ import {
130
131
  parseNoloWorkspaceToolArguments,
131
132
  readTextStreamUpToChars,
132
133
  resolveNoloDialogInput
133
- } from "./chunk-2Q3LOAFE.js";
134
+ } from "./chunk-6HVBI6TI.js";
134
135
  import {
135
136
  buildDialogFallbackTitleFromUserInput
136
137
  } from "./chunk-2MBTWINN.js";
@@ -222,7 +223,7 @@ import {
222
223
  import {
223
224
  buildProviderAuthHeaders,
224
225
  buildProviderExecutionPlan
225
- } from "./chunk-WPOKOKZA.js";
226
+ } from "./chunk-PV6JJAUB.js";
226
227
  import {
227
228
  toErrorMessage
228
229
  } from "./chunk-HNMXYYJR.js";
@@ -19949,6 +19950,7 @@ async function runLocalAgentTurn(input) {
19949
19950
  { content: PARALLEL_DISPATCH_DEFAULT_RULE, cacheScope: "session" },
19950
19951
  // 派发落点:并行派发纪律的下一层(派到哪个执行后端),沿用 session 占位约定。
19951
19952
  { content: DISPATCH_BACKEND_POLICY, cacheScope: "session" },
19953
+ { content: DISPATCH_CANDIDATE_POLICY, cacheScope: "session" },
19952
19954
  // 平台风控纪律:无条件系统层块,沿用 session 占位约定。
19953
19955
  { content: PLATFORM_RISK_CONTROL_RULE, cacheScope: "session" },
19954
19956
  { content: buildConsultationModeBlock(), cacheScope: "session" },
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AGENT_SELECTION_PRIORITY_INSTRUCTIONS
3
- } from "./chunk-2Q3LOAFE.js";
3
+ } from "./chunk-6HVBI6TI.js";
4
4
  import {
5
5
  canonicalizeToolNames
6
6
  } from "./chunk-AKE53VMW.js";
@@ -132,6 +132,16 @@ var DISPATCH_BACKEND_POLICY = [
132
132
  "\u300C\u5199\u578B\u6D3E\u53D1\u9ED8\u8BA4\u843D docker \u6C99\u76D2\u300D\u53EA\u5C5E\u4E8E CLI \u672C\u5730\u6D3E\u53D1\u901A\u9053\u8FD9\u4E00\u8303\u56F4\uFF1B\u4E0D\u5E26\u5BBF\u4E3B\u72B6\u6001\u4E0E\u5BBF\u4E3B\u51ED\u636E\u7684\u72EC\u7ACB\u4EE3\u7801\u6539\u52A8 + \u8DD1\u6D4B\u8BD5\uFF0C\u6C99\u76D2\u4ECD\u662F\u9996\u9009\uFF08\u9694\u79BB\u662F\u4FDD\u9669\uFF0C\u4E0D\u662F\u8D1F\u62C5\uFF09\u3002"
133
133
  ].join("\n");
134
134
 
135
+ // packages/agent-runtime/dispatchCandidatePolicy.ts
136
+ var DISPATCH_CANDIDATE_POLICY = [
137
+ "\u3010\u6D3E\u53D1\u9009\u4EBA \xB7 \u53EF\u7528\u6027\u4E0E\u901F\u5EA6\u3011",
138
+ "**\u6BCF\u6B21\u6D3E\u53D1\u524D\u91CD\u65B0\u8BFB\u53EF\u7528\u6027**\uFF1A\u5019\u9009\u53EF\u7528\u6027\u53EA\u5BF9\u5F53\u6B21\u6D3E\u53D1\u751F\u6548\u3002\u7981\u6B62\u590D\u7528\u4EFB\u4F55\u65E9\u4E8E\u672C\u6B21\u6D3E\u53D1\u7684\u300C\u989D\u5EA6\u8017\u5C3D/\u51B7\u5374\u4E2D\u300D\u7ED3\u8BBA\u2014\u2014\u6062\u590D\u662F\u5E38\u6001\uFF0C\u51ED\u65E7\u7ED3\u8BBA\u8DF3\u8FC7\u53EF\u7528\u5019\u9009\u7B49\u4E8E\u81EA\u5DF1\u5236\u9020\u963B\u585E\u3002\u5224\u5B9A\u8981\u57FA\u4E8E\u672C\u6B21 listAgents \u7684\u8FD4\u56DE\u3002",
139
+ "**\u6267\u884C\u578B\u5757\u4F18\u5148\u5FEB\u901A\u9053**\uFF1A\u76EE\u6807/\u6587\u4EF6/\u9A8C\u6536\u5DF2\u660E\u786E\u7684\u6267\u884C\u578B\u4EFB\u52A1\uFF0C\u5728\u901A\u8FC7\u80DC\u4EFB\u6027\u7B5B\u9009\u7684\u514D\u8D39\u79C1\u6709\u901A\u9053\u91CC\u4F18\u5148\u9009 `tier: fast` \u4E14**\u6709 observed \u901F\u5EA6\u6570\u636E**\u7684\u5019\u9009\uFF1B\u901F\u5EA6\u6570\u636E\u672A\u77E5\u7684\u5019\u9009\u53EA\u4F5C\u515C\u5E95\uFF0C\u9009\u5B83\u65F6\u5728\u56DE\u590D\u91CC\u5199\u660E\u300C\u901F\u5EA6\u672A\u77E5\u300D\uFF0C\u4E0D\u8981\u5047\u88C5\u5B83\u5FEB\u6216\u6162\u3002",
140
+ "**\u957F\u4EFB\u52A1\u907F\u5F00\u989D\u5EA6\u4E0D\u53EF\u89C1\u7684\u901A\u9053**\uFF1A\u9884\u8BA1\u8D85\u8FC7 30 \u6B21\u5DE5\u5177\u8C03\u7528\u7684\u4EFB\u52A1\uFF0C\u4E0D\u8981\u6D3E\u7ED9 `availabilityStatus` \u4E3A\u672A\u9A8C\u8BC1 / \u65E0\u989D\u5EA6\u5FEB\u7167\u7684\u901A\u9053\u2014\u2014\u4E2D\u9014 402 \u4F1A\u8BA9\u6574\u5757\u5DE5\u4F5C\u4F5C\u5E9F\uFF0C\u4EE3\u4EF7\u8FDC\u9AD8\u4E8E\u7701\u4E0B\u7684\u9009\u62E9\u6210\u672C\u3002",
141
+ "**\u901F\u5EA6\u53EA\u8BA4\u672C\u7528\u6237\u5B9E\u6D4B**\uFF1A\u901F\u5EA6\u4F9D\u636E\u53EA\u6709 observed\uFF08\u672C\u7528\u6237\u8FD1\u671F\u771F\u5B9E\u8C03\u7528\u4E2D\u4F4D\u6570\uFF09\u3002\u4E0D\u8981\u5F15\u7528\u5916\u90E8\u57FA\u51C6\u3001\u5382\u5546\u5BA3\u79F0\u6216\u8BB0\u5FC6\u91CC\u7684\u6570\u5B57\u6765\u81EA\u8BC1\u300C\u54EA\u4E2A\u5FEB\u300D\uFF1B\u6CA1\u6709\u6837\u672C\u5C31\u662F\u6CA1\u6709\u6570\u636E\uFF0C\u4E0D\u7B49\u4E8E\u6162\u3002",
142
+ "\u8FD9\u4E9B\u89C4\u5219\u4E0D\u653E\u5BBD\u4EFB\u4F55\u65E2\u6709\u786C\u95E8\uFF1A\u5E73\u53F0\u79EF\u5206\u6263\u8D39\u6388\u6743\u3001429 \u9650\u6D41\u77E5\u60C5\u6743\u3001\u4F5C\u8005\u56DE\u907F\u3001review \u72EC\u7ACB\u6027\u3001\u5220\u9664\u4E0E\u63A8\u9001\u7684\u786E\u8BA4\uFF0C\u4E00\u6761\u90FD\u4E0D\u56E0\u300C\u66F4\u5FEB\u300D\u800C\u7ED5\u5F00\u3002"
143
+ ].join("\n");
144
+
135
145
  // packages/agent-runtime/platformRiskControl.ts
136
146
  var PLATFORM_RISK_CONTROL_RULE = [
137
147
  "\u3010\u5E73\u53F0\u98CE\u63A7\u7EAA\u5F8B \xB7 \u7B2C\u4E09\u65B9\u7AD9\u70B9\u81EA\u52A8\u5316\u3011",
@@ -832,6 +842,7 @@ export {
832
842
  CREDENTIAL_HYGIENE_RULE,
833
843
  PARALLEL_DISPATCH_DEFAULT_RULE,
834
844
  DISPATCH_BACKEND_POLICY,
845
+ DISPATCH_CANDIDATE_POLICY,
835
846
  PLATFORM_RISK_CONTROL_RULE,
836
847
  isGptProModel,
837
848
  shouldBlockForGptPro,