nolo-cli 0.250.0-alpha.1 → 0.251.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/{_executeModel-F4MT6OPO.js → _executeModel-55PHWQWB.js} +27 -27
  2. package/{addContentAction-MLI6GOBV.js → addContentAction-LBVAQUF7.js} +2 -2
  3. package/{addDialogAgentAction-ARGQM22H.js → addDialogAgentAction-6WAUSUSZ.js} +1 -1
  4. package/{agentDeleteCommand-DBCRHB4S.js → agentDeleteCommand-KEO3KDK3.js} +53 -49
  5. package/{agentEmailCommands-T4PAJ4KG.js → agentEmailCommands-RWJQQRNT.js} +54 -50
  6. package/{agentListCommands-5ULWKQ3E.js → agentListCommands-L3TLPLNH.js} +17 -17
  7. package/{agentMachineCommands-65QUOCEY.js → agentMachineCommands-EZWWXWDH.js} +16 -16
  8. package/{agentPullCommand-4EQZYHU4.js → agentPullCommand-6OCNLVGC.js} +1 -1
  9. package/{agentRecordCommands-EKANS3A5.js → agentRecordCommands-7W2CGHJJ.js} +53 -49
  10. package/{agentRunCommand-336PXBRJ.js → agentRunCommand-POL6B6BO.js} +54 -50
  11. package/{agentRunControl-QMWTWV7C.js → agentRunControl-FKSXBUAF.js} +1 -1
  12. package/{agentRuntimeLocal-KKXJOBD3.js → agentRuntimeLocal-WSHWNIMF.js} +14 -14
  13. package/{agentSlice-FWYXP332.js → agentSlice-3G2YLTA4.js} +3 -3
  14. package/{appDeleteCommands-ERJK367V.js → appDeleteCommands-DZZQCVYH.js} +16 -16
  15. package/{appDeployCommands-LUV6QKQJ.js → appDeployCommands-NJJBVNH5.js} +16 -16
  16. package/{appDeployStatusCommands-WW7IYQD4.js → appDeployStatusCommands-GBOAFEYG.js} +16 -16
  17. package/{appGetCommands-G7XYYSFO.js → appGetCommands-GOOKYMKO.js} +16 -16
  18. package/{appListCommands-4RXCIDNI.js → appListCommands-OBCGUG3S.js} +16 -16
  19. package/{authCommand-3C3RN4OU.js → authCommand-77CRN332.js} +9 -9
  20. package/{authCommands-ZMVEDCQD.js → authCommands-BLXNAUF4.js} +2 -2
  21. package/{chromeOpsCommands-NZITLHWO.js → chromeOpsCommands-6RLEBBJJ.js} +1 -1
  22. package/chunk-3A5NNQCN.js +64 -0
  23. package/{chunk-HEIIOJGN.js → chunk-3KWJPTVP.js} +2 -2
  24. package/{chunk-7IQA2VJF.js → chunk-3ZWJVKFB.js} +148 -38
  25. package/{chunk-OLGFIQN2.js → chunk-43VT5PLM.js} +1 -1
  26. package/{chunk-RHBD22LV.js → chunk-5IKKSJYX.js} +4 -2
  27. package/{chunk-U7OMQLRE.js → chunk-6UNJ6JGR.js} +9 -9
  28. package/{chunk-BFKJ2RS3.js → chunk-7RYODZDD.js} +1 -1
  29. package/{chunk-YQO5UKHP.js → chunk-A55E2OCP.js} +16 -16
  30. package/{chunk-XHG7QROB.js → chunk-CUYFRVJF.js} +3 -3
  31. package/{chunk-I3J7HO3U.js → chunk-D35TOEMM.js} +2 -2
  32. package/{chunk-OHUYN3YU.js → chunk-D3E5MYXO.js} +1 -1
  33. package/{chunk-SPU3L3OR.js → chunk-EFM2IPZR.js} +3 -3
  34. package/{chunk-6XRPBZRS.js → chunk-EYLGAEB4.js} +0 -134
  35. package/{chunk-ZKMS73DK.js → chunk-FAFDIQJG.js} +3 -3
  36. package/{chunk-UF6J7NXV.js → chunk-GMWZRXRM.js} +1 -1
  37. package/{chunk-ARFCL53U.js → chunk-HD5EKSLF.js} +3 -3
  38. package/{chunk-4IQN6FWY.js → chunk-HQLCYPL4.js} +1 -1
  39. package/chunk-HZD5HXUO.js +405 -0
  40. package/{chunk-FFFKAOJN.js → chunk-IXAGRTAR.js} +1 -1
  41. package/{chunk-UPOW5HTG.js → chunk-IZWGO2ZS.js} +1 -1
  42. package/{chunk-NEG5LYK5.js → chunk-JCQ3WCQ3.js} +3 -1
  43. package/{chunk-ZTWDSOXD.js → chunk-JUYI2D7J.js} +1 -1
  44. package/{chunk-OKKA4BCM.js → chunk-K5CIMK3R.js} +2 -2
  45. package/{chunk-AXZ5DDLB.js → chunk-KGOBJAWC.js} +51 -49
  46. package/{chunk-JFRJEPFI.js → chunk-KRAPKTAS.js} +1 -1
  47. package/{chunk-RDBDHGU7.js → chunk-KZVRPCOR.js} +2 -2
  48. package/{chunk-TMRJGSK2.js → chunk-L5HV76QT.js} +1 -1
  49. package/{chunk-3IVFGQIM.js → chunk-LOXR4TQN.js} +1 -1
  50. package/{chunk-W6T4FNZP.js → chunk-LUPZLKXL.js} +192 -352
  51. package/{chunk-73PZD7JZ.js → chunk-MTS5DCL2.js} +2 -2
  52. package/{chunk-SMEX763N.js → chunk-N3SEV3CG.js} +34 -26
  53. package/{chunk-WEZ27JA7.js → chunk-NMXGIRSG.js} +1 -1
  54. package/{chunk-I3OW5RAX.js → chunk-NTNX77FI.js} +6 -6
  55. package/{chunk-32WTED6G.js → chunk-OARYOLF3.js} +90 -79
  56. package/{chunk-BAH3BAUZ.js → chunk-OQCAHPDQ.js} +5 -5
  57. package/{chunk-VIYVRPMJ.js → chunk-PHREU2KZ.js} +5 -3
  58. package/{chunk-W4G25PVP.js → chunk-PKMDYRAM.js} +31 -22
  59. package/{chunk-VV5IS3ES.js → chunk-PLS2MJVW.js} +5 -5
  60. package/{chunk-ATRU65OK.js → chunk-Q5KZ6F55.js} +11 -11
  61. package/{chunk-AKWA6PCE.js → chunk-QJ5YDTEF.js} +7 -7
  62. package/{chunk-V4IYI3SB.js → chunk-QLGL43SI.js} +1 -1
  63. package/{chunk-K7VIXYTZ.js → chunk-R3MV2GII.js} +1 -45
  64. package/{chunk-E5RYFR7E.js → chunk-R7D5SRAZ.js} +2 -0
  65. package/{chunk-KK3FCYZM.js → chunk-SQL7YNED.js} +7 -4
  66. package/{chunk-D25ONVOH.js → chunk-SSZHE2RK.js} +1 -1
  67. package/{chunk-ADOOL3PG.js → chunk-T4V6C3J3.js} +1 -1
  68. package/{chunk-X6LYQDN5.js → chunk-TGKAUEV3.js} +4 -4
  69. package/chunk-TRRXYFTR.js +46 -0
  70. package/{chunk-BVEDT6DM.js → chunk-U2OWDHDE.js} +3 -3
  71. package/{chunk-YWNCRUBZ.js → chunk-UCMUXZJV.js} +5 -5
  72. package/{chunk-6QL3SUEK.js → chunk-W2N4OAKM.js} +2 -2
  73. package/{chunk-VHMPJGT4.js → chunk-X337N4D6.js} +3 -3
  74. package/{chunk-6TVYUQRM.js → chunk-XC5RPSXK.js} +1 -1
  75. package/chunk-XRGBJHZX.js +136 -0
  76. package/{chunk-PGDM7AM2.js → chunk-ZKKJZBNO.js} +6 -6
  77. package/{chunk-SHDJLJWV.js → chunk-ZSRR6HCH.js} +1 -1
  78. package/{cliAgentConfigHelpers-37ZNEY5Y.js → cliAgentConfigHelpers-N6LTB7UY.js} +2 -2
  79. package/{cliAuthorityBrokerClient-SFPC3WVK.js → cliAuthorityBrokerClient-TFNXJLXL.js} +1 -1
  80. package/cliAuthorityBrokerProcess-IUCB4XA6.js +22 -0
  81. package/{cliLocalAgentRecordReader-R4CLUHYO.js → cliLocalAgentRecordReader-NFNGYOOW.js} +15 -15
  82. package/{commandRegistry-UIZRI4JV.js → commandRegistry-OM5DU4DS.js} +72 -72
  83. package/{contentThunks-ZQSZA4GH.js → contentThunks-7URM43ET.js} +10 -10
  84. package/{cooldownCommands-TIFCHCUN.js → cooldownCommands-JEEV75B7.js} +1 -1
  85. package/{createAgentAutomationAction-RQE4F6PR.js → createAgentAutomationAction-GGEXIKMC.js} +10 -10
  86. package/{createDialogAction-JDSMQ34U.js → createDialogAction-IXXEMFRQ.js} +11 -11
  87. package/{createPageAction-VLF6XCYO.js → createPageAction-IXIVLIOO.js} +13 -13
  88. package/{db-CMUTP3W5.js → db-J5KE7XRI.js} +3 -2
  89. package/{dbSlice-656PMWR2.js → dbSlice-IE4ADINL.js} +1 -1
  90. package/{dialogCommands-PLM7ZFWH.js → dialogCommands-RPBHOZB6.js} +25 -21
  91. package/{dialogNotifyCommand-PST75COP.js → dialogNotifyCommand-ECKI5MMA.js} +3 -3
  92. package/{dialogSlice-63DD2ER2.js → dialogSlice-5FQB2TNN.js} +8 -8
  93. package/{dialogUsageCommand-6RW2FY6K.js → dialogUsageCommand-TBIA2QAF.js} +2 -2
  94. package/{docCreateCommands-BST5DO7L.js → docCreateCommands-XJ2X57DW.js} +15 -15
  95. package/{docDeleteCommands-YE6G2SO4.js → docDeleteCommands-45WGFFEB.js} +15 -15
  96. package/{docReadCommands-M6T35U3G.js → docReadCommands-LRRVDS46.js} +15 -15
  97. package/{docStore-7QNJWRJ2.js → docStore-SUAVM24F.js} +2 -2
  98. package/{docUpdateCommands-6DFWGPVG.js → docUpdateCommands-QUYX6BVR.js} +15 -15
  99. package/{handleSendMessageAction-FCEFFAV4.js → handleSendMessageAction-FDIWBQUB.js} +65 -23
  100. package/{hostCredentialCreate-YEWCAMZN.js → hostCredentialCreate-CEXQHYT4.js} +53 -49
  101. package/index.js +23 -11
  102. package/{localDialogRead-CIOTQM5T.js → localDialogRead-USDZXKIL.js} +1 -1
  103. package/{localRuntimeAdapter-Z22ZOZRY.js → localRuntimeAdapter-O3JBRK6S.js} +51 -47
  104. package/{localRuntimeAuthority-TYHQCTZN.js → localRuntimeAuthority-QKWTPBQQ.js} +13 -3
  105. package/{localRuntimeDb-BO7IVWAZ.js → localRuntimeDb-3CIC4SKC.js} +1 -1
  106. package/{machineCommands-PT5OJ36V.js → machineCommands-I3YA7TNC.js} +52 -48
  107. package/{machineWsRunDispatch-DQVNBSVE.js → machineWsRunDispatch-E5CIE2OJ.js} +52 -48
  108. package/{markdownToSlate-KIYM7B3P.js → markdownToSlate-PXYAIBVL.js} +1 -1
  109. package/{mcpLocalAuthorizeCommand-GO6AYT63.js → mcpLocalAuthorizeCommand-K5J2VMG6.js} +10 -6
  110. package/{memberThunks-JFYC4Z5L.js → memberThunks-T7EAZE6A.js} +3 -3
  111. package/package.json +2 -1
  112. package/{projectArchive-4XUC5SLF.js → projectArchive-A7E65AZO.js} +13 -13
  113. package/{readlineWorkspace-7U5QM3OM.js → readlineWorkspace-2O65NBFG.js} +89 -86
  114. package/{removeDialogAgentAction-J7XU7OUX.js → removeDialogAgentAction-GRT72HLK.js} +3 -3
  115. package/{runAgentClientLoop-7D7UCAS2.js → runAgentClientLoop-NWCZIXCG.js} +25 -25
  116. package/{runtimeDoctorCommands-RDRJXMXC.js → runtimeDoctorCommands-26HYHFTK.js} +9 -6
  117. package/{secretCommands-2FEMRUFM.js → secretCommands-XR72SHLK.js} +2 -2
  118. package/{setDialogExtraReferencesAction-Q4V2ZZW2.js → setDialogExtraReferencesAction-CBG3X46B.js} +2 -2
  119. package/{setPrimaryDialogAgentAction-742H5S6T.js → setPrimaryDialogAgentAction-EWTDZOAX.js} +3 -3
  120. package/{settingThunks-IHXUF276.js → settingThunks-X4PT66J2.js} +1 -1
  121. package/{spaceCommands-WCLD36WH.js → spaceCommands-EVSNTGRS.js} +14 -14
  122. package/{streamAgentChatTurn-DVTOINT3.js → streamAgentChatTurn-SYP3OEM5.js} +50 -50
  123. package/{switchDialogAgentAction-HLDLHRRA.js → switchDialogAgentAction-YHPZ7K6E.js} +1 -1
  124. package/{tools-BOPINT5S.js → tools-2AO2SK4L.js} +20 -20
  125. package/{tuiRestart-5F2APN66.js → tuiRestart-HBQDF4AE.js} +2 -2
  126. package/{tuiSummaryLlmCaller-TM5BU73J.js → tuiSummaryLlmCaller-Q2PNR63K.js} +4 -4
  127. package/{updateCommands-FBYA5WVG.js → updateCommands-6SI7NWVC.js} +3 -3
  128. package/{updateDialogTitleAction-S76PUCLQ.js → updateDialogTitleAction-MWVMBIPZ.js} +10 -10
  129. package/{usageCommand-L4OFWXEU.js → usageCommand-D44AOTMH.js} +2 -2
  130. package/{usageRebuildCommand-7JR33UHS.js → usageRebuildCommand-IRIMKDI5.js} +3 -3
  131. package/{windowsSelfUpdate-M4V77OUB.js → windowsSelfUpdate-BJIJKKIS.js} +2 -2
  132. package/{chunk-MYYNZG2M.js → chunk-CJ2BP6V7.js} +3 -3
  133. package/{chunk-HZDK56EK.js → chunk-IFJ6OTI6.js} +0 -0
  134. package/{chunk-WMKA2DPK.js → chunk-LMMRWGGJ.js} +3 -3
  135. package/{chunk-EDT65EUE.js → chunk-WZPG63Q4.js} +3 -3
@@ -1,133 +1,3 @@
1
- // packages/cli/client/cliExitSync.ts
2
- import { AsyncLocalStorage } from "node:async_hooks";
3
- var scopes = new AsyncLocalStorage();
4
- var KNOWN_SYNC_FAILURE_CODES = /* @__PURE__ */ new Set([
5
- "owner_mismatch",
6
- "owner_origin_mismatch",
7
- "owner_grant_revoked",
8
- "owner_oauth_unavailable",
9
- "invalid_grant",
10
- "auth_no_token",
11
- "token_expired",
12
- "user_batch_authority_controlled",
13
- "tombstone_conflict"
14
- ]);
15
- var SYNC_FAILURE_CODE_RE = /"(?:code|error|reason)"\s*:\s*"([A-Za-z0-9_.:-]{1,48})"/;
16
- function classifyDialogSyncFailure(error) {
17
- if (error instanceof Error && error.name === "AbortError") return "aborted";
18
- if (error instanceof Error && error.name === "TimeoutError") return "timeout";
19
- const match = error instanceof Error ? /^remote dialog evidence write failed: HTTP (\d{3})\b([\s\S]*)$/.exec(error.message) : null;
20
- if (!match) return "transport_or_sync";
21
- const candidate = SYNC_FAILURE_CODE_RE.exec(match[2] ?? "")?.[1]?.toLowerCase();
22
- const code = candidate && KNOWN_SYNC_FAILURE_CODES.has(candidate) ? candidate : void 0;
23
- return code ? `http_${match[1]}(${code})` : `http_${match[1]}`;
24
- }
25
- function startOwnedDialogSync(fetchImpl, start) {
26
- const scope = scopes.getStore();
27
- if (!scope) return start(fetchImpl);
28
- if (scope.closed) return Promise.reject(new Error("dialog_sync_scope_closed"));
29
- const entry = { watermark: scope.entries.length + 1, httpOkRecords: 0, controller: new AbortController(), state: "pending", done: Promise.resolve() };
30
- scope.entries.push(entry);
31
- const trackedFetch = async (url, init) => {
32
- entry.controller.signal.throwIfAborted();
33
- const signal = init?.signal ? AbortSignal.any([init.signal, entry.controller.signal]) : entry.controller.signal;
34
- const response = await fetchImpl(url, { ...init, signal });
35
- signal.throwIfAborted();
36
- if (response.ok && String(url).includes("/api/v1/db/write/")) entry.httpOkRecords++;
37
- return response;
38
- };
39
- entry.done = Promise.resolve().then(() => start(trackedFetch)).then((result) => {
40
- if (entry.state === "pending") entry.state = "completed";
41
- return result;
42
- }, (error) => {
43
- if (entry.state === "pending") {
44
- entry.state = "failed";
45
- entry.failureClass = classifyDialogSyncFailure(error);
46
- }
47
- throw error;
48
- });
49
- void entry.done.catch(() => {
50
- });
51
- return entry.done;
52
- }
53
- function drain(scope, unsafeRunner = false) {
54
- if (scope.drain) return scope.drain;
55
- scope.closed = true;
56
- scope.drain = (async () => {
57
- const entries = scope.entries.slice();
58
- let timer;
59
- const abortPending = (classification) => {
60
- for (const entry of entries) if (entry.state === "pending") {
61
- entry.state = "timeout";
62
- entry.failureClass = classification;
63
- entry.controller.abort(new Error("dialog_sync_drain_stopped"));
64
- }
65
- };
66
- try {
67
- if (unsafeRunner) abortPending("runner_not_stopped");
68
- else if (entries.length) await Promise.race([
69
- Promise.allSettled(entries.map((entry) => entry.done)),
70
- new Promise((resolve) => {
71
- timer = setTimeout(() => {
72
- abortPending("timeout");
73
- resolve();
74
- }, scope.timeoutMs);
75
- })
76
- ]);
77
- } finally {
78
- if (timer) clearTimeout(timer);
79
- }
80
- const failed = entries.filter((entry) => entry.state !== "completed");
81
- for (const entry of failed) scope.output.write(`[nolo] dialog_sync ${entry.state}: watermark=${entry.watermark} httpOkRecords=${entry.httpOkRecords} class=${entry.failureClass ?? entry.state}; local history retained; remote sync incomplete.
82
- `);
83
- return failed.length === 0;
84
- })();
85
- return scope.drain;
86
- }
87
- function exitCliFromWatchdog(code, exit, stopRunner) {
88
- const scope = scopes.getStore();
89
- if (!scope) {
90
- exit(code);
91
- return Promise.resolve();
92
- }
93
- if (scope.watchdogExit) return scope.watchdogExit;
94
- scope.closed = true;
95
- scope.watchdogExit = (async () => {
96
- let stopped = false;
97
- try {
98
- stopped = await stopRunner();
99
- } catch {
100
- }
101
- if (!stopped) scope.output.write("[nolo] dialog_sync failed: class=runner_not_stopped; cancelling pending sync before hard exit.\n");
102
- const complete = await drain(scope, !stopped);
103
- exit(code === 0 || !complete ? 1 : code);
104
- })();
105
- return scope.watchdogExit;
106
- }
107
- async function runCliCommandWithSyncDrain(command, options) {
108
- const timeoutMs = Number.isFinite(options.timeoutMs) && (options.timeoutMs ?? 0) > 0 ? options.timeoutMs : 15e3;
109
- await scopes.run({ entries: [], closed: false, output: options.output, timeoutMs }, async () => {
110
- const scope = scopes.getStore();
111
- let code = 70;
112
- let commandError;
113
- let commandThrew = false;
114
- try {
115
- code = await command();
116
- } catch (error) {
117
- commandThrew = true;
118
- commandError = error;
119
- }
120
- if (scope.watchdogExit) {
121
- await scope.watchdogExit;
122
- if (commandThrew) throw commandError;
123
- return;
124
- }
125
- const complete = await drain(scope);
126
- if (commandThrew) throw commandError;
127
- await options.exit(code === 0 && !complete ? 1 : code);
128
- });
129
- }
130
-
131
1
  // packages/cli/diagnostics/normalizeError.ts
132
2
  var MAX_CAUSE_DEPTH = 4;
133
3
  var MAX_AGGREGATE_ERRORS = 8;
@@ -904,10 +774,6 @@ function getLogger(component) {
904
774
  }
905
775
 
906
776
  export {
907
- classifyDialogSyncFailure,
908
- startOwnedDialogSync,
909
- exitCliFromWatchdog,
910
- runCliCommandWithSyncDrain,
911
777
  normalizeError,
912
778
  getProcessRingBuffer,
913
779
  resolveDefaultLogPath,
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  patch,
6
6
  readAndWait
7
- } from "./chunk-HZDK56EK.js";
7
+ } from "./chunk-IFJ6OTI6.js";
8
8
  import {
9
9
  require_react
10
10
  } from "./chunk-RD3QLZQV.js";
@@ -335,7 +335,7 @@ async function saveDocState(arg, { dispatch, getState }) {
335
335
  ).unwrap();
336
336
  if (dbSpaceId) {
337
337
  try {
338
- const { updateContentTitle } = await import("./contentThunks-ZQSZA4GH.js");
338
+ const { updateContentTitle } = await import("./contentThunks-7URM43ET.js");
339
339
  await dispatch(
340
340
  updateContentTitle({
341
341
  spaceId: dbSpaceId,
@@ -378,7 +378,7 @@ async function saveDocState(arg, { dispatch, getState }) {
378
378
  }
379
379
  }
380
380
  async function createDocState(args, thunkApi) {
381
- const { createPageAction } = await import("./createPageAction-VLF6XCYO.js");
381
+ const { createPageAction } = await import("./createPageAction-IXIVLIOO.js");
382
382
  return createPageAction(args, thunkApi);
383
383
  }
384
384
  function subscribe(listener) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  generatePkcePair,
3
3
  startCallbackServer
4
- } from "./chunk-6TVYUQRM.js";
4
+ } from "./chunk-XC5RPSXK.js";
5
5
  import {
6
6
  toErrorMessage
7
7
  } from "./chunk-HNMXYYJR.js";
@@ -1,9 +1,9 @@
1
- import {
2
- patch
3
- } from "./chunk-HZDK56EK.js";
4
1
  import {
5
2
  selectCurrentServer
6
3
  } from "./chunk-MTM4LRVG.js";
4
+ import {
5
+ patch
6
+ } from "./chunk-IFJ6OTI6.js";
7
7
  import {
8
8
  getIsDesktopApp
9
9
  } from "./chunk-YHNUDTU4.js";
@@ -10,7 +10,7 @@ import {
10
10
  canUsePlatformChatProvider,
11
11
  parsePlatformChatCompletionResponse,
12
12
  resolvePlatformChatProviderConfig
13
- } from "./chunk-EDT65EUE.js";
13
+ } from "./chunk-WZPG63Q4.js";
14
14
  import {
15
15
  COMPACTION_SUMMARY_SYSTEM_PROMPT,
16
16
  classifySummaryError,
@@ -0,0 +1,405 @@
1
+ import {
2
+ createLegacyServerDb,
3
+ isLevelLockError
4
+ } from "./chunk-TRRXYFTR.js";
5
+ import {
6
+ startCliAuthorityBrokerProcess
7
+ } from "./chunk-LUPZLKXL.js";
8
+ import {
9
+ loadCliAuthorityBrokerTls
10
+ } from "./chunk-3A5NNQCN.js";
11
+ import {
12
+ createCliAuthorityBrokerClient,
13
+ createCliAuthorityBrokerSocketInvoker,
14
+ isCliAuthorityBrokerTimeoutError,
15
+ isCliAuthorityBrokerUnavailableError
16
+ } from "./chunk-SQL7YNED.js";
17
+ import {
18
+ resolveCliAuthorityBrokerEndpoint,
19
+ resolveCliAuthorityBrokerHealthPath,
20
+ resolveCliAuthorityBrokerMetadataPath
21
+ } from "./chunk-CVMMWN6P.js";
22
+ import {
23
+ resolveNoloHome
24
+ } from "./chunk-GLKOYSRU.js";
25
+ import {
26
+ toErrorMessage
27
+ } from "./chunk-HNMXYYJR.js";
28
+
29
+ // packages/cli/localRuntimeAuthority.ts
30
+ import fs from "node:fs";
31
+ import { randomUUID } from "node:crypto";
32
+ import path from "node:path";
33
+ function ensureDbParentDir(dbPath) {
34
+ fs.mkdirSync(path.dirname(dbPath), { recursive: true });
35
+ }
36
+ function findCliAuthorityCorruption(error) {
37
+ const seen = /* @__PURE__ */ new Set();
38
+ let current = error;
39
+ while (current && !seen.has(current)) {
40
+ seen.add(current);
41
+ if (current.code === "LEVEL_CORRUPTION" || /Corruption:|missing files/i.test(toErrorMessage(current))) return current;
42
+ current = current.cause;
43
+ }
44
+ return void 0;
45
+ }
46
+ function throwCliAuthorityStartupError(error) {
47
+ const corruption = findCliAuthorityCorruption(error);
48
+ if (corruption) {
49
+ throw new Error(`Local authority database corruption: ${toErrorMessage(corruption)}`, { cause: error });
50
+ }
51
+ throw error;
52
+ }
53
+ function isCliAuthorityLockError(error) {
54
+ if (findCliAuthorityCorruption(error)) return false;
55
+ const seen = /* @__PURE__ */ new Set();
56
+ let current = error;
57
+ while (current && !seen.has(current)) {
58
+ seen.add(current);
59
+ if (isLevelLockError(current)) return true;
60
+ current = current.cause;
61
+ }
62
+ return /EADDRINUSE|Failed to listen/i.test(toErrorMessage(error));
63
+ }
64
+ async function sleep(ms) {
65
+ await new Promise((resolve) => setTimeout(resolve, ms));
66
+ }
67
+ function resolveCliLocalRuntimeDbPath(options = {}) {
68
+ return path.join(
69
+ resolveNoloHome({
70
+ env: options.env,
71
+ homeDir: options.homeDir
72
+ }),
73
+ "data",
74
+ "leveldb"
75
+ );
76
+ }
77
+ var DEFAULT_ATTACH_BACKOFF_MS = [100, 200, 400, 800];
78
+ var DEFAULT_ATTACH_RETRY_BUDGET_MS = 9e3;
79
+ function findOwnerPid(error) {
80
+ const seen = /* @__PURE__ */ new Set();
81
+ let current = error;
82
+ while (current && typeof current === "object" && !seen.has(current)) {
83
+ seen.add(current);
84
+ const pid = current.ownerPid;
85
+ if (typeof pid === "number" && Number.isInteger(pid) && pid > 0) {
86
+ return pid;
87
+ }
88
+ current = current.cause;
89
+ }
90
+ return void 0;
91
+ }
92
+ function isTransientBrokerOpenError(error) {
93
+ return isCliAuthorityBrokerUnavailableError(error) || isCliAuthorityBrokerTimeoutError(error);
94
+ }
95
+ var defaultCliAuthorityBrokerConnectDeps = {
96
+ createClient: (options) => createCliAuthorityBrokerClient(options),
97
+ startBroker: startCliAuthorityBrokerProcess,
98
+ sleep,
99
+ useFastPath: true
100
+ };
101
+ function verifyBrokerDatabase(args, liveLocation) {
102
+ const expected = fs.existsSync(args.dbPath) ? fs.realpathSync(args.dbPath) : path.join(fs.realpathSync(path.dirname(args.dbPath)), path.basename(args.dbPath));
103
+ if (typeof liveLocation !== "string" || fs.realpathSync(liveLocation) !== expected) {
104
+ throw new Error(`Authority broker at ${args.endpoint} does not match the requested database ${args.dbPath}`);
105
+ }
106
+ }
107
+ function findLegacyBrokerOwner(args) {
108
+ try {
109
+ const metadata = JSON.parse(fs.readFileSync(args.metadataPath, "utf8"));
110
+ const owner = JSON.parse(fs.readFileSync(`${args.dbPath}.owner`, "utf8"));
111
+ if (metadata.transportSecurity !== void 0 || metadata.supervisorPid !== void 0 || metadata.endpoint !== args.endpoint || !Number.isInteger(metadata.pid) || metadata.pid <= 0 || owner.pid !== metadata.pid || fs.realpathSync(metadata.location) !== fs.realpathSync(args.dbPath)) return void 0;
112
+ process.kill(metadata.pid, 0);
113
+ return metadata.pid;
114
+ } catch {
115
+ return void 0;
116
+ }
117
+ }
118
+ async function connectCliAuthorityBroker(args) {
119
+ const deps = {
120
+ ...defaultCliAuthorityBrokerConnectDeps,
121
+ ...args.deps
122
+ };
123
+ async function connectClient() {
124
+ const invoke = createCliAuthorityBrokerSocketInvoker({ endpoint: args.endpoint, tls: args.tls });
125
+ const client2 = deps.createClient({
126
+ endpoint: args.endpoint,
127
+ invoke: async (request) => {
128
+ if (request.type !== "status" || !deps.verifyBroker) return invoke(request);
129
+ const response = await invoke({ type: "status", includeLocation: true });
130
+ if (response.ok && response.result.type === "status") deps.verifyBroker(args, response.result.location);
131
+ return response;
132
+ }
133
+ });
134
+ const backoffSchedule = deps.attachBackoffMs?.length ? deps.attachBackoffMs : DEFAULT_ATTACH_BACKOFF_MS;
135
+ const retryBudgetMs = deps.attachRetryBudgetMs ?? DEFAULT_ATTACH_RETRY_BUDGET_MS;
136
+ let waitedMs = 0;
137
+ let backoffStep = 0;
138
+ let lastAttachError;
139
+ const waitBackoff = async () => {
140
+ if (waitedMs >= retryBudgetMs) return false;
141
+ const delay = backoffSchedule[Math.min(backoffStep, backoffSchedule.length - 1)];
142
+ if (waitedMs > 0 && waitedMs + delay > retryBudgetMs) return false;
143
+ backoffStep += 1;
144
+ const startedAt = Date.now();
145
+ await deps.sleep(delay);
146
+ waitedMs += Math.max(delay, Date.now() - startedAt);
147
+ return true;
148
+ };
149
+ async function attachToExistingBroker(attempts) {
150
+ for (let attempt = 0; attempt < attempts; attempt += 1) {
151
+ if (!await waitBackoff()) return false;
152
+ const probeStartedAt = Date.now();
153
+ try {
154
+ await client2.open();
155
+ return true;
156
+ } catch (error) {
157
+ waitedMs += Date.now() - probeStartedAt;
158
+ if (!isTransientBrokerOpenError(error)) throw error;
159
+ lastAttachError = error;
160
+ }
161
+ }
162
+ return false;
163
+ }
164
+ if (deps.useFastPath) {
165
+ try {
166
+ await client2.open();
167
+ return client2;
168
+ } catch (error) {
169
+ if (!isTransientBrokerOpenError(error)) throw error;
170
+ lastAttachError = error;
171
+ }
172
+ }
173
+ try {
174
+ await deps.startBroker({
175
+ endpoint: args.endpoint,
176
+ metadataPath: args.metadataPath,
177
+ healthPath: args.healthPath,
178
+ dbPath: args.dbPath
179
+ });
180
+ await client2.open();
181
+ return client2;
182
+ } catch (error) {
183
+ if (!isCliAuthorityLockError(error)) throwCliAuthorityStartupError(error);
184
+ if (await attachToExistingBroker(5)) {
185
+ return client2;
186
+ }
187
+ let lastError = error;
188
+ while (await waitBackoff()) {
189
+ try {
190
+ await deps.startBroker({
191
+ endpoint: args.endpoint,
192
+ metadataPath: args.metadataPath,
193
+ healthPath: args.healthPath,
194
+ dbPath: args.dbPath
195
+ });
196
+ await client2.open();
197
+ return client2;
198
+ } catch (retryError) {
199
+ lastError = retryError;
200
+ if (isCliAuthorityLockError(retryError)) {
201
+ if (await attachToExistingBroker(2)) {
202
+ return client2;
203
+ }
204
+ continue;
205
+ }
206
+ if (isTransientBrokerOpenError(retryError)) {
207
+ lastAttachError = retryError;
208
+ continue;
209
+ }
210
+ throwCliAuthorityStartupError(retryError);
211
+ }
212
+ }
213
+ const lastMessage = toErrorMessage(lastError);
214
+ const attachCause = lastAttachError instanceof Error ? lastAttachError.cause : void 0;
215
+ const attachMessage = lastAttachError ? [toErrorMessage(lastAttachError), ...attachCause ? [toErrorMessage(attachCause)] : []].join(" / ") : "";
216
+ const portInUse = lastError !== null && typeof lastError === "object" && "code" in lastError && lastError.code === "EADDRINUSE" || /EADDRINUSE/i.test(lastMessage);
217
+ const ownerPid = findOwnerPid(lastError);
218
+ const legacyOwner = args.tls ? findLegacyBrokerOwner(args) : void 0;
219
+ if (legacyOwner !== void 0) {
220
+ throw new Error(`CLI authority broker upgrade requires exit of the previous Nolo process (PID ${legacyOwner}). Close its Nolo window or let it finish, then retry. The new broker will reopen the same database.`, {
221
+ cause: lastError
222
+ });
223
+ }
224
+ let detail = "";
225
+ if (portInUse) {
226
+ detail = `: EADDRINUSE (${lastMessage}). The broker endpoint is already in use; check the process using it or set NOLO_CLI_AUTHORITY_BROKER_PORT to a free port for all local CLI processes`;
227
+ } else {
228
+ const parts = [
229
+ ownerPid !== void 0 ? `ownerPid=${ownerPid}` : void 0,
230
+ lastMessage || void 0,
231
+ attachMessage && attachMessage !== lastMessage ? `attach=${attachMessage}` : void 0
232
+ ].filter(Boolean);
233
+ if (parts.length > 0) {
234
+ detail = `: ${parts.join("; ")}`;
235
+ }
236
+ }
237
+ throw new Error(`CLI authority broker could not attach or take ownership for ${args.endpoint}${detail}`, {
238
+ cause: lastError
239
+ });
240
+ }
241
+ }
242
+ let client = await connectClient();
243
+ let reconnecting = null;
244
+ async function reconnect() {
245
+ reconnecting ??= connectClient();
246
+ try {
247
+ client = await reconnecting;
248
+ return client;
249
+ } finally {
250
+ reconnecting = null;
251
+ }
252
+ }
253
+ async function runWithSelfHealing(operation) {
254
+ try {
255
+ return await operation(client);
256
+ } catch (error) {
257
+ if (!isCliAuthorityBrokerUnavailableError(error)) throw error;
258
+ const recoveredClient = await reconnect();
259
+ return operation(recoveredClient);
260
+ }
261
+ }
262
+ return {
263
+ get location() {
264
+ return client.location;
265
+ },
266
+ get status() {
267
+ return client.status;
268
+ },
269
+ open: () => runWithSelfHealing((activeClient) => activeClient.open()),
270
+ close: () => runWithSelfHealing((activeClient) => activeClient.close()),
271
+ get: (key) => runWithSelfHealing((activeClient) => activeClient.get(key)),
272
+ conditionalPut: (key, expectedRevision, value) => runWithSelfHealing((activeClient) => {
273
+ if (!activeClient.conditionalPut) {
274
+ throw new Error("CLI authority broker does not support conditionalPut");
275
+ }
276
+ return activeClient.conditionalPut(key, expectedRevision, value);
277
+ }),
278
+ put: (key, value) => runWithSelfHealing((activeClient) => activeClient.put(key, value)),
279
+ del: (key) => runWithSelfHealing((activeClient) => activeClient.del(key)),
280
+ batchWrite: (ops) => runWithSelfHealing((activeClient) => activeClient.batchWrite(ops)),
281
+ createBatch() {
282
+ const ops = [];
283
+ return {
284
+ put(key, value) {
285
+ ops.push({ type: "put", key, value });
286
+ },
287
+ del(key) {
288
+ ops.push({ type: "del", key });
289
+ },
290
+ write: () => runWithSelfHealing((activeClient) => activeClient.batchWrite(ops))
291
+ };
292
+ },
293
+ iterator(options = {}) {
294
+ return async function* iterate() {
295
+ let activeOptions = options;
296
+ let lastYieldedKey;
297
+ let skipResumeKey = false;
298
+ let recovered = false;
299
+ while (true) {
300
+ try {
301
+ for await (const entry of client.iterator(activeOptions)) {
302
+ if (skipResumeKey && entry[0] === lastYieldedKey) {
303
+ skipResumeKey = false;
304
+ continue;
305
+ }
306
+ skipResumeKey = false;
307
+ lastYieldedKey = entry[0];
308
+ yield entry;
309
+ }
310
+ return;
311
+ } catch (error) {
312
+ if (recovered || !isCliAuthorityBrokerUnavailableError(error)) {
313
+ throw error;
314
+ }
315
+ recovered = true;
316
+ await reconnect();
317
+ if (lastYieldedKey === void 0) {
318
+ activeOptions = options;
319
+ continue;
320
+ }
321
+ if (options.reverse) {
322
+ activeOptions = {
323
+ ...options,
324
+ lt: lastYieldedKey
325
+ };
326
+ continue;
327
+ }
328
+ activeOptions = {
329
+ ...options,
330
+ gte: lastYieldedKey
331
+ };
332
+ skipResumeKey = true;
333
+ }
334
+ }
335
+ }();
336
+ }
337
+ };
338
+ }
339
+ async function getDefaultCliLocalRuntimeAuthority(options = {}) {
340
+ const ambientNoloHome = process.env.NOLO_HOME?.trim();
341
+ const ambientBrokerPort = process.env.NOLO_CLI_AUTHORITY_BROKER_PORT?.trim();
342
+ const env = {
343
+ ...ambientNoloHome ? { NOLO_HOME: ambientNoloHome } : {},
344
+ ...ambientBrokerPort ? { NOLO_CLI_AUTHORITY_BROKER_PORT: ambientBrokerPort } : {},
345
+ ...options.env ?? process.env
346
+ };
347
+ const dbPath = resolveCliLocalRuntimeDbPath({
348
+ env,
349
+ homeDir: options.homeDir
350
+ });
351
+ ensureDbParentDir(dbPath);
352
+ const endpoint = resolveCliAuthorityBrokerEndpoint({
353
+ transport: "tcp",
354
+ env,
355
+ homeDir: options.homeDir
356
+ });
357
+ const metadataPath = resolveCliAuthorityBrokerMetadataPath({
358
+ transport: "tcp",
359
+ env,
360
+ homeDir: options.homeDir
361
+ });
362
+ const healthPath = resolveCliAuthorityBrokerHealthPath({
363
+ transport: "tcp",
364
+ env,
365
+ homeDir: options.homeDir
366
+ });
367
+ return connectCliAuthorityBroker({
368
+ endpoint,
369
+ metadataPath,
370
+ healthPath,
371
+ dbPath,
372
+ tls: await loadCliAuthorityBrokerTls(metadataPath),
373
+ deps: { verifyBroker: verifyBrokerDatabase }
374
+ });
375
+ }
376
+ async function getDefaultCliLocalRuntimeDb(options = {}) {
377
+ const authorityStore = await getDefaultCliLocalRuntimeAuthority(options);
378
+ return createLegacyServerDb(authorityStore);
379
+ }
380
+ function createCliLocalMcpConnectionRevisionWriter(authority, authenticatedUserId) {
381
+ if (!authenticatedUserId) throw new Error("Local MCP connection owner is required");
382
+ const prefix = `mcp-private:v1:${encodeURIComponent(authenticatedUserId)}:connection:`;
383
+ const conditionalPut = authority.conditionalPut?.bind(authority);
384
+ if (!conditionalPut) throw new Error("CLI authority broker does not support conditionalPut");
385
+ return {
386
+ async create(value) {
387
+ const id = randomUUID();
388
+ const result = await conditionalPut(prefix + id, null, { ...value, revision: 1 });
389
+ return { id, ...result };
390
+ },
391
+ async update(id, expectedRevision, value) {
392
+ if (!/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(id) || !Number.isSafeInteger(expectedRevision) || expectedRevision < 1 || expectedRevision >= Number.MAX_SAFE_INTEGER) {
393
+ throw new Error("Invalid local MCP connection identity or revision");
394
+ }
395
+ return conditionalPut(prefix + id, expectedRevision, { ...value, revision: expectedRevision + 1 });
396
+ }
397
+ };
398
+ }
399
+
400
+ export {
401
+ connectCliAuthorityBroker,
402
+ getDefaultCliLocalRuntimeAuthority,
403
+ getDefaultCliLocalRuntimeDb,
404
+ createCliLocalMcpConnectionRevisionWriter
405
+ };
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-UAD2WT54.js";
4
4
  import {
5
5
  toTimestampMs
6
- } from "./chunk-HZDK56EK.js";
6
+ } from "./chunk-IFJ6OTI6.js";
7
7
  import {
8
8
  require_react
9
9
  } from "./chunk-RD3QLZQV.js";
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-BR3GT6MR.js";
5
5
  import {
6
6
  resolveRuntimeToolSurfaceForAgent
7
- } from "./chunk-NEG5LYK5.js";
7
+ } from "./chunk-JCQ3WCQ3.js";
8
8
  import {
9
9
  resolveRuntimeAuthToken
10
10
  } from "./chunk-GX6DITLQ.js";
@@ -71,7 +71,9 @@ var HIGH_RISK_MUTATION_TOOL_NAMES = [
71
71
  // 受控云端执行:在用户拥有的云资源上跑任意命令,不可重放、副作用在云端。
72
72
  // 硬边界:它永不进 DEFAULT_PRIVATE_NOLO_WORKSPACE_TOOLS(见该清单注释),
73
73
  // 必须由 agent 显式启用才出现;这里进名单保证只读 run 即使被显式要求也拿不到。
74
- "cloud_exec"
74
+ "cloud_exec",
75
+ // Sandbox 产物持久化提交:会写入 Space / 用户持久存储,只读 run 不允许调用。
76
+ "commitSandboxArtifact"
75
77
  ];
76
78
  function resolveReadOnlyToolConstraints(additionalBlockedTools) {
77
79
  return {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isPidGone
3
- } from "./chunk-YWNCRUBZ.js";
3
+ } from "./chunk-UCMUXZJV.js";
4
4
 
5
5
  // packages/cli/tui/tuiRestart.ts
6
6
  import { realpathSync } from "node:fs";
@@ -3,10 +3,10 @@ import {
3
3
  } from "./chunk-HS7MLR74.js";
4
4
  import {
5
5
  performServerProxyFetchWithRetry
6
- } from "./chunk-XHG7QROB.js";
6
+ } from "./chunk-CUYFRVJF.js";
7
7
  import {
8
8
  fetchServerSyncedCredential
9
- } from "./chunk-AKWA6PCE.js";
9
+ } from "./chunk-QJ5YDTEF.js";
10
10
  import {
11
11
  buildIdentityBlock,
12
12
  buildPlatformStaticContextLayers,