nolo-cli 0.54.0 → 0.61.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/README.md +3 -3
  2. package/{_executeModel-OPTKYHJA.js → _executeModel-CKT6RGTL.js} +48 -45
  3. package/{action-ORXWW2ZG.js → action-76JX3JX3.js} +7 -6
  4. package/{addContentAction-53BZ34AE.js → addContentAction-V3NAZRTJ.js} +6 -5
  5. package/{addDialogAgentAction-JRYUS54Y.js → addDialogAgentAction-RZOAF46K.js} +5 -4
  6. package/{agentDeleteCommand-FJIWU2BS.js → agentDeleteCommand-VN7NPXQ4.js} +30 -27
  7. package/{agentEmailCommands-CE32L43B.js → agentEmailCommands-F2TNAV4A.js} +59 -56
  8. package/{agentGrantCommands-2LEZDADN.js → agentGrantCommands-R3VQEZJR.js} +1 -1
  9. package/{agentListCommands-VJNKULIK.js → agentListCommands-OSM2ANI3.js} +61 -31
  10. package/{agentMachineCommands-HCJ3WQXL.js → agentMachineCommands-MTPWYVRV.js} +31 -28
  11. package/{agentPullCommand-M552CYSI.js → agentPullCommand-N7L2CT7L.js} +2 -2
  12. package/{agentRecordCommands-QFWERED4.js → agentRecordCommands-VWAWTVVC.js} +57 -54
  13. package/{agentRunCommand-G3GQMUNN.js → agentRunCommand-PLZOBNVK.js} +61 -58
  14. package/{agentRunControl-INKFDXDA.js → agentRunControl-WECMOO6O.js} +11 -6
  15. package/{agentRuntimeLocal-K327ELSL.js → agentRuntimeLocal-XCJLRWQE.js} +26 -23
  16. package/{agentSlice-ODKF4J6M.js → agentSlice-F6DOP4IW.js} +8 -7
  17. package/{appDeleteCommands-XUXMFDI4.js → appDeleteCommands-3BCFTRFJ.js} +30 -27
  18. package/{appDeployCommands-37F4GPCU.js → appDeployCommands-B4GMHCYA.js} +30 -27
  19. package/{appDeployStatusCommands-WSPU7TUK.js → appDeployStatusCommands-4MN36WIG.js} +30 -27
  20. package/{appGetCommands-YLOBA3EM.js → appGetCommands-4GJIEUAX.js} +30 -27
  21. package/{appListCommands-UD62R5ME.js → appListCommands-CHU53GSX.js} +30 -27
  22. package/{authCommand-OK6HLHGS.js → authCommand-WOTWLJNF.js} +35 -29
  23. package/{authCommands-2DUIUEMT.js → authCommands-ILTBI6JV.js} +7 -5
  24. package/{chatQueueReduxAdapter-TV2TUOQS.js → chatQueueReduxAdapter-HNSQXNIR.js} +20 -18
  25. package/{chunk-HPW5MNDQ.js → chunk-22BTGNSP.js} +113 -57
  26. package/{chunk-TR4DXUYX.js → chunk-2HPRMEEZ.js} +1180 -736
  27. package/{chunk-UNZDCI3O.js → chunk-2KDR4CWE.js} +35 -4
  28. package/{chunk-3ZTR7ZO4.js → chunk-2PGGC63K.js} +1 -1
  29. package/{chunk-JXIP6ZWH.js → chunk-37QVS7BU.js} +18 -5
  30. package/{chunk-EA5OYZVD.js → chunk-37XDGCY7.js} +1 -1
  31. package/chunk-3BLB7QKO.js +433 -0
  32. package/{chunk-CS6TCJ7E.js → chunk-3JQ2NRYU.js} +30 -7
  33. package/{chunk-RHMDMTDK.js → chunk-3JWKQDA4.js} +2 -2
  34. package/{chunk-3LKZRP7E.js → chunk-3QGUVVX5.js} +2 -2
  35. package/{chunk-SSXTSPSG.js → chunk-45YO6H7P.js} +71 -30
  36. package/{chunk-EJE33XNR.js → chunk-4C4ST2YE.js} +1521 -565
  37. package/{chunk-YLCUU3WM.js → chunk-4NJEIGBQ.js} +5 -5
  38. package/{chunk-K4NISKOR.js → chunk-5ZYA4JJ3.js} +47 -17
  39. package/{chunk-3Y2K5O2R.js → chunk-7A3RRUCQ.js} +125 -40
  40. package/{chunk-5FCIPEKT.js → chunk-7O7KH4X5.js} +1051 -926
  41. package/{chunk-6HDYSFLO.js → chunk-7UF7CQ6B.js} +3 -3
  42. package/{chunk-SUEIAK5N.js → chunk-AQMVUA7N.js} +1 -0
  43. package/{chunk-WQHGJHAL.js → chunk-AVE2YR4F.js} +732 -726
  44. package/{chunk-6COJEAYH.js → chunk-B7DXRX7F.js} +44 -37
  45. package/chunk-BFU6C242.js +66 -0
  46. package/{chunk-IA3A5373.js → chunk-C3FZR5EC.js} +1 -1
  47. package/{chunk-IWUMSAQF.js → chunk-CJCJF5XB.js} +26 -3
  48. package/{chunk-UGBHDMHI.js → chunk-CP7VIDZ7.js} +1 -1
  49. package/{chunk-JON2PHYT.js → chunk-CTCW7U7N.js} +1 -1
  50. package/{chunk-YBFJQC2M.js → chunk-D5XKNNUV.js} +65 -42
  51. package/{chunk-7NYDJAQ7.js → chunk-DNNSCSA2.js} +5 -5
  52. package/{chunk-NI2BS6UD.js → chunk-DWUCB2A3.js} +1 -1
  53. package/{chunk-AA564GBL.js → chunk-DZZL7UBV.js} +1 -1
  54. package/{chunk-75MSWWUE.js → chunk-E6RGHPDR.js} +5 -3
  55. package/chunk-EDKF7RX4.js +30 -0
  56. package/{chunk-FJHMLRDQ.js → chunk-ES6CVKVD.js} +21 -27
  57. package/{chunk-SYYUU7EV.js → chunk-FHAGENAS.js} +2 -3
  58. package/{chunk-NJUQBYFJ.js → chunk-FKFMIBTT.js} +3 -1
  59. package/{chunk-INZZJSQF.js → chunk-FZGV4FGK.js} +24 -12
  60. package/{chunk-YQBXOHE6.js → chunk-GAL47RNP.js} +1 -1
  61. package/{chunk-UOWXD4VN.js → chunk-HBPV76EK.js} +335 -243
  62. package/{chunk-MLEZPE3U.js → chunk-HLU5Q2GV.js} +4 -4
  63. package/{chunk-TC6P4NDR.js → chunk-HQP7HJDL.js} +6 -6
  64. package/{chunk-7FAS3NEF.js → chunk-IYCUMIYS.js} +19 -15
  65. package/{chunk-AUVFJGPC.js → chunk-JX5PJCWS.js} +7 -5
  66. package/{chunk-LYGNQHUW.js → chunk-JYYZCK2Z.js} +2 -4
  67. package/{chunk-XOJRZUPF.js → chunk-KWSQR2KK.js} +14 -29
  68. package/{chunk-2WBFJHQA.js → chunk-L7B47JXR.js} +34 -39
  69. package/{chunk-EICIFHVS.js → chunk-LAFC3B2I.js} +1 -1
  70. package/{chunk-N4JKMCY3.js → chunk-LJKICKVC.js} +2 -2
  71. package/chunk-M3JEW6N6.js +193 -0
  72. package/{chunk-LRGKOI5Y.js → chunk-MBOEV4L2.js} +7 -3
  73. package/{chunk-SVDMVX4G.js → chunk-MMZ6ZTVO.js} +112 -73
  74. package/{chunk-JDSUTNYY.js → chunk-MP64VFGD.js} +2 -2
  75. package/{chunk-NFLA6GSU.js → chunk-MXUDQZXQ.js} +44 -5
  76. package/chunk-N4G4PKQ6.js +23 -0
  77. package/{chunk-KXKQO4Q6.js → chunk-NTW5GWDM.js} +58 -1
  78. package/chunk-ONXOABJR.js +215 -0
  79. package/{chunk-TY3ADTX5.js → chunk-OZX2IPKM.js} +7 -2
  80. package/{chunk-Q4XZVZPN.js → chunk-P7OOB7QP.js} +1 -1
  81. package/{chunk-XIJZOCSP.js → chunk-PEZJEQAO.js} +1 -1
  82. package/{chunk-SWJGJMTW.js → chunk-PQDIDWGX.js} +1 -1
  83. package/chunk-PSCNXBYA.js +11 -0
  84. package/{chunk-BY2FF2C4.js → chunk-QEFJJS2I.js} +55 -73
  85. package/{chunk-BG7J6Y5X.js → chunk-QEW2MFDQ.js} +1 -1
  86. package/{chunk-KLIBF3BY.js → chunk-RDBARW6T.js} +8 -3
  87. package/{chunk-ZVOHVJI3.js → chunk-RJ2SAFB5.js} +82 -35
  88. package/{chunk-MYMBBB6Q.js → chunk-RVWRKFUB.js} +5 -3
  89. package/{chunk-43CXXVJD.js → chunk-RXX4GDIH.js} +1 -1
  90. package/chunk-SEJ5OS6F.js +49 -0
  91. package/{chunk-SAJSBPI2.js → chunk-SOJM57FX.js} +5 -2
  92. package/{chunk-EKLRRZIN.js → chunk-SPAQ4PVV.js} +0 -5
  93. package/{chunk-L7NG2M6H.js → chunk-TRV2MIDW.js} +89 -74
  94. package/{chunk-5UAYZEXO.js → chunk-UZPQSVM6.js} +1 -1
  95. package/{chunk-SVC3GGUA.js → chunk-VMWYBIXG.js} +7 -5
  96. package/{chunk-ZHXJ6M7T.js → chunk-W7XHHYWM.js} +4 -0
  97. package/{chunk-UR66XPVF.js → chunk-XAVSS3KE.js} +21 -3
  98. package/{chunk-A65UV3M5.js → chunk-XOKOSO35.js} +10 -19
  99. package/{chunk-VZMUOPYG.js → chunk-XTJTN3RW.js} +46 -3
  100. package/{chunk-T5HJEUQN.js → chunk-YCDWJX45.js} +1 -1
  101. package/{chunk-BBTN4NQD.js → chunk-Z4QSJILV.js} +85 -13
  102. package/{chunk-O5FLGN2L.js → chunk-ZRSJ3JEH.js} +6 -2
  103. package/{cliExecutor-BBUVQU4L.js → cliExecutor-HG3S345O.js} +1 -1
  104. package/{codingSkills-BCQXRZOI.js → codingSkills-VDXQYWX4.js} +2 -2
  105. package/{contentThunks-KNI6VXLT.js → contentThunks-7YG2ZYQC.js} +21 -19
  106. package/{cooldownCommands-GI5NNWGL.js → cooldownCommands-BSCH2W7P.js} +2 -2
  107. package/{createAgentAutomationAction-OK4L33KF.js → createAgentAutomationAction-PJQSCAIO.js} +23 -21
  108. package/{createDialogAction-JDSMY4AY.js → createDialogAction-SFEJX6SP.js} +23 -21
  109. package/{createPageAction-T7RA3HCG.js → createPageAction-B7WRHOQO.js} +24 -22
  110. package/{dbSlice-TVX6SN2T.js → dbSlice-IBVOBVMS.js} +5 -4
  111. package/{deleteFile-JYKRT7C3.js → deleteFile-FWP2PSBG.js} +3 -2
  112. package/{dialogCommands-UQZYWOOV.js → dialogCommands-VL2X22QC.js} +30 -27
  113. package/{dialogSlice-TYW2G7IL.js → dialogSlice-ANMACABO.js} +20 -18
  114. package/{docCreateCommands-OA6HZBWO.js → docCreateCommands-ITLGZ5YI.js} +29 -26
  115. package/{docDeleteCommands-KBB3YQI2.js → docDeleteCommands-LH3YNL4C.js} +30 -27
  116. package/{docReadCommands-ZLMFVC67.js → docReadCommands-YAJ77F36.js} +29 -26
  117. package/{docStore-2URPBVCS.js → docStore-D4HGHPWI.js} +6 -5
  118. package/{docUpdateCommands-HMH5KUON.js → docUpdateCommands-DQBOMH2G.js} +29 -26
  119. package/{getPricing-RFOPUWHY.js → getPricing-NM3NUTAS.js} +4 -4
  120. package/handleSendMessageAction-DF2OABGW.js +675 -0
  121. package/index.js +79 -88
  122. package/{lib-2ZTNRXR4.js → lib-FRRS27KN.js} +63 -28
  123. package/{localRuntimeAuthority-KQDAE64E.js → localRuntimeAuthority-R5UBODT3.js} +6 -4
  124. package/{localRuntimeDb-PF7CFKDL.js → localRuntimeDb-P37ZTX55.js} +1 -1
  125. package/{machineCommands-RK6L7ZWL.js → machineCommands-JXDYQ5LB.js} +296 -79
  126. package/{machineWsRunDispatch-3X64DW2Z.js → machineWsRunDispatch-3QHI7JX5.js} +55 -52
  127. package/{memberThunks-THZYZFSN.js → memberThunks-VZI6G7YZ.js} +10 -8
  128. package/{models-JVKUEER5.js → models-FAMINFZ7.js} +2 -2
  129. package/package.json +3 -2
  130. package/{read-K4JU4MQC.js → read-2BYWW7AA.js} +3 -2
  131. package/{readDocTool-LQGR6FUN.js → readDocTool-LC3A7QTB.js} +1 -1
  132. package/{readlineWorkspace-XUFJV3RS.js → readlineWorkspace-KVZTEAHB.js} +4365 -2795
  133. package/{removeDialogAgentAction-ECHCFB7N.js → removeDialogAgentAction-SFYZXHNK.js} +8 -7
  134. package/{runAgentClientLoop-24GQ2AW6.js → runAgentClientLoop-KGTEL7ZP.js} +49 -45
  135. package/{runtimeDoctorCommands-JKTTN723.js → runtimeDoctorCommands-CROTMULY.js} +7 -5
  136. package/{setDialogExtraReferencesAction-KCVJNGMB.js → setDialogExtraReferencesAction-Q32RGFTA.js} +6 -5
  137. package/{setPrimaryDialogAgentAction-VDOBOMKC.js → setPrimaryDialogAgentAction-BFYJHUJS.js} +8 -7
  138. package/{settingSlice-VR2IJSXC.js → settingSlice-IRUU4VFB.js} +6 -5
  139. package/{skillDiscovery-2QTZINON.js → skillDiscovery-NTRLM6KP.js} +1 -1
  140. package/{spaceCommands-S5YJJXL7.js → spaceCommands-KNAYWMCZ.js} +33 -215
  141. package/{streamAgentChatTurn-QHKP3ABO.js → streamAgentChatTurn-FLYPTXKZ.js} +105 -73
  142. package/{switchDialogAgentAction-5L4UP7VI.js → switchDialogAgentAction-L2KOKCGG.js} +5 -4
  143. package/{tableCommands-R6WFRDYF.js → tableCommands-SUNTHAYX.js} +1 -1
  144. package/{toolApiClient-53U4UDFF.js → toolApiClient-VGYUB4P5.js} +2 -1
  145. package/{tools-SSXSTC3O.js → tools-CVLUXK6P.js} +37 -34
  146. package/{tuiSummaryLlmCaller-URFJHFC5.js → tuiSummaryLlmCaller-F3DPFFZM.js} +15 -13
  147. package/{updateCommands-IYKLF3JX.js → updateCommands-AJYSD73Y.js} +2 -2
  148. package/{updateDialogTitleAction-YFYAEW3T.js → updateDialogTitleAction-HWJIZEIV.js} +23 -21
  149. package/agentSuperviseCommands-5AR3DKNN.js +0 -640
  150. package/chunk-6IGD47IC.js +0 -19
  151. package/chunk-FD36SCCD.js +0 -105
  152. package/chunk-GRFK2XP4.js +0 -230
  153. package/chunk-HJTAGT3W.js +0 -370
  154. package/handleSendMessageAction-GO53TY7U.js +0 -409
@@ -11,10 +11,10 @@ import {
11
11
  getAntigravityUserAgent,
12
12
  normalizeAntigravityTokenPayload,
13
13
  refreshAntigravityToken
14
- } from "./chunk-BG7J6Y5X.js";
14
+ } from "./chunk-QEW2MFDQ.js";
15
15
  import {
16
16
  writeOAuthCredential
17
- } from "./chunk-FD36SCCD.js";
17
+ } from "./chunk-ONXOABJR.js";
18
18
  import {
19
19
  toErrorMessage
20
20
  } from "./chunk-HNMXYYJR.js";
@@ -483,6 +483,39 @@ async function refreshOpenAiCodexToken(credential, deps = {}) {
483
483
  });
484
484
  }
485
485
 
486
+ // packages/cli/oauth/deviceCodeDisplay.ts
487
+ var BOLD = "\x1B[1m";
488
+ var RESET = "\x1B[0m";
489
+ function renderDeviceCodeDisplay(args) {
490
+ const { provider, verificationUrl, completeUrl, userCode, notes = [] } = args;
491
+ const bold = args.isTTY ?? Boolean(process.stdout.isTTY);
492
+ const rows = [
493
+ { rendered: ` URL: ${verificationUrl} `, plain: ` URL: ${verificationUrl} ` }
494
+ ];
495
+ if (completeUrl) {
496
+ rows.push({
497
+ rendered: ` Link: ${completeUrl} `,
498
+ plain: ` Link: ${completeUrl} `
499
+ });
500
+ }
501
+ rows.push({
502
+ rendered: ` Code: ${bold ? `${BOLD}${userCode}${RESET}` : userCode} `,
503
+ plain: ` Code: ${userCode} `
504
+ });
505
+ const innerWidth = Math.max(...rows.map((row) => row.plain.length));
506
+ const top = `\u250C${"\u2500".repeat(innerWidth)}\u2510`;
507
+ const bottom = `\u2514${"\u2500".repeat(innerWidth)}\u2518`;
508
+ return [
509
+ `Authorize nolo-cli for ${provider} (device code / headless):`,
510
+ top,
511
+ ...rows.map(
512
+ (row) => `\u2502${row.rendered}${" ".repeat(innerWidth - row.plain.length)}\u2502`
513
+ ),
514
+ bottom,
515
+ ...notes
516
+ ];
517
+ }
518
+
486
519
  // packages/cli/oauth/pkce.ts
487
520
  import { createHash, randomBytes } from "node:crypto";
488
521
  var PKCE_VERIFIER_LENGTH = 64;
@@ -612,9 +645,14 @@ async function pollDeviceCodeToken(args) {
612
645
  async function runOpenAiCodexDeviceCode(deps = {}) {
613
646
  const now = deps.now ?? Date.now;
614
647
  const start = await startDeviceCodeFlow(deps);
615
- deps.output?.log?.("Authorize nolo-cli for ChatGPT / OpenAI Codex:");
616
- deps.output?.log?.(OPENAI_CODEX_DEVICE_VERIFICATION_URL);
617
- deps.output?.log?.(`Enter code: ${start.userCode}`);
648
+ for (const line of renderDeviceCodeDisplay({
649
+ provider: "ChatGPT / OpenAI Codex",
650
+ verificationUrl: OPENAI_CODEX_DEVICE_VERIFICATION_URL,
651
+ userCode: start.userCode,
652
+ notes: ["Code expires in ~15 minutes. Never share the code or tokens."]
653
+ })) {
654
+ deps.output?.log?.(line);
655
+ }
618
656
  if (deps.openBrowser) {
619
657
  const opened = await deps.openBrowser(OPENAI_CODEX_DEVICE_VERIFICATION_URL);
620
658
  if (!opened) deps.output?.log?.("Could not open a browser automatically. Open the URL above.");
@@ -1116,6 +1154,7 @@ export {
1116
1154
  startCallbackServer,
1117
1155
  runAntigravityOAuthLogin,
1118
1156
  refreshAntigravityOAuthToken,
1157
+ renderDeviceCodeDisplay,
1119
1158
  generatePkcePair,
1120
1159
  runOpenAiCodexDeviceCode,
1121
1160
  runOpenAiCodexBrowserPkce,
@@ -0,0 +1,23 @@
1
+ // packages/core/abortableDelay.ts
2
+ function waitForAbortableDelay(ms, signal) {
3
+ const delayMs = Number.isFinite(ms) && ms >= 0 ? Math.round(ms) : 0;
4
+ if (signal?.aborted) {
5
+ return Promise.reject(new DOMException("Aborted", "AbortError"));
6
+ }
7
+ return new Promise((resolve, reject) => {
8
+ const onAbort = () => {
9
+ clearTimeout(timeoutId);
10
+ signal?.removeEventListener("abort", onAbort);
11
+ reject(new DOMException("Aborted", "AbortError"));
12
+ };
13
+ const timeoutId = setTimeout(() => {
14
+ signal?.removeEventListener("abort", onAbort);
15
+ resolve();
16
+ }, delayMs);
17
+ signal?.addEventListener("abort", onAbort, { once: true });
18
+ });
19
+ }
20
+
21
+ export {
22
+ waitForAbortableDelay
23
+ };
@@ -1,20 +1,76 @@
1
+ import {
2
+ estimateTokenCount
3
+ } from "./chunk-PSCNXBYA.js";
4
+
1
5
  // packages/ai/tools/agent/agentRunDisplayHelpers.ts
2
6
  function buildDelegatedTaskContent(task, input) {
3
7
  if (input === void 0 || input === null) {
4
8
  return task;
5
9
  }
6
10
  if (typeof input === "string") {
11
+ const trimmedInput = input.trim();
12
+ if (!trimmedInput || trimmedInput === task.trim()) {
13
+ return task;
14
+ }
7
15
  return `${task}
8
16
 
9
17
  --- INPUT (text) ---
10
18
  ${input}`;
11
19
  }
12
- const jsonStr = JSON.stringify(input, null, 2);
20
+ let jsonStr;
21
+ try {
22
+ const serialized = JSON.stringify(input, null, 2);
23
+ if (serialized === void 0) {
24
+ return task;
25
+ }
26
+ jsonStr = serialized;
27
+ } catch {
28
+ jsonStr = "[Unserializable Input]";
29
+ }
13
30
  return `${task}
14
31
 
15
32
  --- INPUT (json) ---
16
33
  ${jsonStr}`;
17
34
  }
35
+ function calculateDelegatedPayloadMetrics(task, input, delegatedContent) {
36
+ const taskText = typeof task === "string" ? task : "";
37
+ const taskChars = taskText.length;
38
+ let inputChars = 0;
39
+ let serializedInputForTokens = void 0;
40
+ if (input !== void 0 && input !== null) {
41
+ if (typeof input === "string") {
42
+ inputChars = input.length;
43
+ serializedInputForTokens = input;
44
+ } else {
45
+ try {
46
+ const serialized = JSON.stringify(input, null, 2);
47
+ if (serialized !== void 0) {
48
+ inputChars = serialized.length;
49
+ serializedInputForTokens = serialized;
50
+ } else {
51
+ inputChars = 0;
52
+ }
53
+ } catch {
54
+ const fallback = "[Unserializable Input]";
55
+ inputChars = fallback.length;
56
+ serializedInputForTokens = fallback;
57
+ }
58
+ }
59
+ }
60
+ const finalContent = delegatedContent ?? buildDelegatedTaskContent(task, input);
61
+ const totalChars = finalContent.length;
62
+ const estimatedTaskTokens = estimateTokenCount(taskText);
63
+ const estimatedTotalTokens = estimateTokenCount(finalContent);
64
+ const estimatedInputTokens = serializedInputForTokens && inputChars > 0 ? estimateTokenCount(serializedInputForTokens) : 0;
65
+ return {
66
+ taskChars,
67
+ inputChars,
68
+ totalChars,
69
+ estimatedTaskTokens,
70
+ estimatedInputTokens,
71
+ estimatedTotalTokens
72
+ };
73
+ }
18
74
  function getAgentRunStatusIcon(status) {
19
75
  switch (status) {
20
76
  case "running":
@@ -221,6 +277,7 @@ function isAgentRunTerminalStatus(status) {
221
277
 
222
278
  export {
223
279
  buildDelegatedTaskContent,
280
+ calculateDelegatedPayloadMetrics,
224
281
  getAgentRunStatusIcon,
225
282
  shortRunId,
226
283
  clipText,
@@ -0,0 +1,215 @@
1
+ // packages/agent-runtime/oauthTokenStore.ts
2
+ import {
3
+ chmodSync as chmodSync2,
4
+ existsSync as existsSync2,
5
+ mkdirSync as mkdirSync2,
6
+ readFileSync as readFileSync2,
7
+ unlinkSync as unlinkSync2,
8
+ writeFileSync as writeFileSync2
9
+ } from "node:fs";
10
+ import { homedir as homedir2 } from "node:os";
11
+ import { join as join3 } from "node:path";
12
+
13
+ // packages/agent-runtime/credentialLocationMigration.ts
14
+ import {
15
+ chmodSync,
16
+ existsSync,
17
+ lstatSync,
18
+ mkdirSync,
19
+ readFileSync,
20
+ linkSync,
21
+ unlinkSync,
22
+ writeFileSync
23
+ } from "node:fs";
24
+ import { dirname, join } from "node:path";
25
+ function getLegacyCredentialPath(relativePath, legacyHomeDir) {
26
+ return join(legacyHomeDir, ".nolo", "credentials", relativePath);
27
+ }
28
+ function credentialMigrationMarkerPath(canonicalPath) {
29
+ return `${canonicalPath}.legacy-migration-complete`;
30
+ }
31
+ function isRegularFile(path) {
32
+ try {
33
+ return lstatSync(path).isFile();
34
+ } catch {
35
+ return false;
36
+ }
37
+ }
38
+ function ensurePrivateDir(dir) {
39
+ mkdirSync(dir, { recursive: true, mode: 448 });
40
+ try {
41
+ chmodSync(dir, 448);
42
+ } catch {
43
+ }
44
+ }
45
+ function markCredentialMigrationComplete(canonicalPath) {
46
+ const marker = credentialMigrationMarkerPath(canonicalPath);
47
+ ensurePrivateDir(dirname(marker));
48
+ if (existsSync(marker)) return;
49
+ writeFileSync(marker, "\n", { encoding: "utf8", mode: 384 });
50
+ try {
51
+ chmodSync(marker, 384);
52
+ } catch {
53
+ }
54
+ }
55
+ function migrateLegacyCredentialFile(args) {
56
+ if (args.mode !== "production" && args.mode !== "test") return false;
57
+ if (existsSync(credentialMigrationMarkerPath(args.canonicalPath))) return false;
58
+ if (existsSync(args.canonicalPath)) {
59
+ markCredentialMigrationComplete(args.canonicalPath);
60
+ return false;
61
+ }
62
+ if (!isRegularFile(args.legacyPath)) return false;
63
+ let raw;
64
+ try {
65
+ raw = readFileSync(args.legacyPath, "utf8");
66
+ if (!args.isValid(raw)) return false;
67
+ } catch {
68
+ return false;
69
+ }
70
+ ensurePrivateDir(dirname(args.canonicalPath));
71
+ const tempPath = `${args.canonicalPath}.migrate-${process.pid}-${Math.random().toString(36).slice(2)}`;
72
+ try {
73
+ writeFileSync(tempPath, raw, { encoding: "utf8", mode: 384 });
74
+ try {
75
+ chmodSync(tempPath, 384);
76
+ } catch {
77
+ }
78
+ try {
79
+ linkSync(tempPath, args.canonicalPath);
80
+ } catch {
81
+ unlinkSync(tempPath);
82
+ return false;
83
+ }
84
+ unlinkSync(tempPath);
85
+ markCredentialMigrationComplete(args.canonicalPath);
86
+ try {
87
+ chmodSync(args.canonicalPath, 384);
88
+ } catch {
89
+ }
90
+ return true;
91
+ } catch {
92
+ try {
93
+ unlinkSync(tempPath);
94
+ } catch {
95
+ }
96
+ return false;
97
+ }
98
+ }
99
+
100
+ // packages/agent-runtime/noloStateDir.ts
101
+ import { homedir } from "node:os";
102
+ import { join as join2 } from "node:path";
103
+ function resolveNoloStateDir(name, homeDir) {
104
+ if (homeDir) return join2(homeDir, ".nolo", name);
105
+ const noloHome = process.env.NOLO_HOME?.trim();
106
+ return noloHome ? join2(noloHome, name) : join2(homedir(), ".nolo", name);
107
+ }
108
+
109
+ // packages/agent-runtime/oauthTokenStore.ts
110
+ var DEFAULT_REFRESH_SKEW_MS = 5 * 60 * 1e3;
111
+ function getCredentialsDir(homeDir) {
112
+ return resolveNoloStateDir("credentials", homeDir);
113
+ }
114
+ function getCredentialPath(provider, homeDir) {
115
+ return join3(getCredentialsDir(homeDir), `${provider}.json`);
116
+ }
117
+ function ensurePrivateDir2(dir) {
118
+ mkdirSync2(dir, { recursive: true, mode: 448 });
119
+ try {
120
+ chmodSync2(dir, 448);
121
+ } catch {
122
+ }
123
+ }
124
+ function writePrivateFile(path, body) {
125
+ writeFileSync2(path, body, { encoding: "utf8", mode: 384 });
126
+ try {
127
+ chmodSync2(path, 384);
128
+ } catch {
129
+ }
130
+ }
131
+ function isValidOAuthCredential(raw, provider) {
132
+ try {
133
+ const parsed = JSON.parse(raw);
134
+ return parsed?.provider === provider && typeof parsed.accessToken === "string" && Boolean(parsed.accessToken);
135
+ } catch {
136
+ return false;
137
+ }
138
+ }
139
+ function migrateOAuthCredentialIfNeeded(provider, homeDir, migration) {
140
+ if (homeDir !== void 0 || !migration?.enableLegacyMigration) return;
141
+ const legacyHomeDir = migration.legacyHomeDir ?? homedir2();
142
+ const canonicalPath = getCredentialPath(provider);
143
+ migrateLegacyCredentialFile({
144
+ canonicalPath,
145
+ legacyPath: getLegacyCredentialPath(`${provider}.json`, legacyHomeDir),
146
+ mode: migration.mode ?? (migration.legacyHomeDir ? "test" : "production"),
147
+ isValid: (raw) => isValidOAuthCredential(raw, provider)
148
+ });
149
+ }
150
+ function readOAuthCredential(provider, homeDir, migration) {
151
+ migrateOAuthCredentialIfNeeded(provider, homeDir, migration);
152
+ const path = getCredentialPath(provider, homeDir);
153
+ if (!existsSync2(path)) return null;
154
+ const raw = readFileSync2(path, "utf8");
155
+ try {
156
+ const parsed = JSON.parse(raw);
157
+ if (!parsed?.provider || !parsed?.accessToken) return null;
158
+ return parsed;
159
+ } catch {
160
+ return null;
161
+ }
162
+ }
163
+ function writeOAuthCredential(provider, credential, homeDir) {
164
+ const path = getCredentialPath(provider, homeDir);
165
+ ensurePrivateDir2(getCredentialsDir(homeDir));
166
+ writePrivateFile(path, `${JSON.stringify(credential, null, 2)}
167
+ `);
168
+ }
169
+ function removeOAuthCredential(provider, homeDir) {
170
+ const path = getCredentialPath(provider, homeDir);
171
+ if (!existsSync2(path)) return;
172
+ unlinkSync2(path);
173
+ }
174
+ function createOAuthTokenStore(homeDir, migration) {
175
+ return {
176
+ read(provider) {
177
+ return readOAuthCredential(provider, homeDir, migration);
178
+ },
179
+ write(provider, credential) {
180
+ writeOAuthCredential(provider, credential, homeDir);
181
+ },
182
+ remove(provider) {
183
+ removeOAuthCredential(provider, homeDir);
184
+ }
185
+ };
186
+ }
187
+ function isTokenExpired(credential, skewMs = DEFAULT_REFRESH_SKEW_MS, now = Date.now()) {
188
+ if (!credential.expiresAt) return false;
189
+ return credential.expiresAt - now <= skewMs;
190
+ }
191
+ async function resolveFreshAccessToken(args) {
192
+ const store = args.store ?? createOAuthTokenStore(args.homeDir, args.migration);
193
+ const now = args.now ?? Date.now;
194
+ const credential = store.read(args.provider);
195
+ if (!credential) return null;
196
+ if (!args.force && !isTokenExpired(credential, args.skewMs ?? DEFAULT_REFRESH_SKEW_MS, now())) {
197
+ return credential.accessToken;
198
+ }
199
+ if (!credential.refreshToken || !args.refresh) return null;
200
+ const refreshed = await args.refresh(credential);
201
+ store.write(args.provider, refreshed);
202
+ return refreshed.accessToken;
203
+ }
204
+
205
+ export {
206
+ resolveNoloStateDir,
207
+ getLegacyCredentialPath,
208
+ migrateLegacyCredentialFile,
209
+ getCredentialsDir,
210
+ readOAuthCredential,
211
+ writeOAuthCredential,
212
+ createOAuthTokenStore,
213
+ isTokenExpired,
214
+ resolveFreshAccessToken
215
+ };
@@ -10,6 +10,9 @@ import {
10
10
  import {
11
11
  extractCustomId
12
12
  } from "./chunk-BJIRLHJR.js";
13
+ import {
14
+ selectIdentityToken
15
+ } from "./chunk-SEJ5OS6F.js";
13
16
  import {
14
17
  isRecord
15
18
  } from "./chunk-KUG52IAP.js";
@@ -31,7 +34,10 @@ var resolveDesktopSafeServer = (value) => {
31
34
  return isLocalServerUrl(value) ? MAIN_SERVER : value || MAIN_SERVER;
32
35
  };
33
36
  var selectCurrentServerFromState = (state) => resolveDesktopSafeServer(state?.settings?.currentServer);
34
- var selectCurrentTokenFromState = (state) => typeof state?.auth?.currentToken === "string" ? state.auth.currentToken : null;
37
+ var selectCurrentTokenFromState = (state) => {
38
+ const token = selectIdentityToken(state);
39
+ return typeof token === "string" ? token : null;
40
+ };
35
41
  var selectCurrentDialogKeyFromState = (_state) => getActiveDialogKey();
36
42
  var resolveToolBaseUrl = (currentServer) => {
37
43
  const _window = globalThis.window;
@@ -48,7 +54,6 @@ var DESKTOP_LOCAL_TOOL_PATHS = /* @__PURE__ */ new Set([
48
54
  "/api/apply-edit",
49
55
  "/api/apply-line-edits",
50
56
  "/api/code-search",
51
- "/api/search-repo",
52
57
  "/api/desktop/files/roots",
53
58
  "/api/desktop/files/roots/request",
54
59
  "/api/desktop/files/list",
@@ -2,7 +2,7 @@ import {
2
2
  deleteDbRecord,
3
3
  queryUserRecords,
4
4
  readDbRecord
5
- } from "./chunk-SYYUU7EV.js";
5
+ } from "./chunk-FHAGENAS.js";
6
6
  import {
7
7
  mergeAndDedupUserData
8
8
  } from "./chunk-KQHGZWSV.js";
@@ -7,7 +7,7 @@ import {
7
7
  listUserRecordsFromServers,
8
8
  readDbRecordFromServers,
9
9
  readLiveDbRecordAfterTombstoneMerge
10
- } from "./chunk-Q4XZVZPN.js";
10
+ } from "./chunk-P7OOB7QP.js";
11
11
  import {
12
12
  fetchWithTransientRetry
13
13
  } from "./chunk-5XTOKQLW.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  generatePkcePair,
3
3
  startCallbackServer
4
- } from "./chunk-NFLA6GSU.js";
4
+ } from "./chunk-MXUDQZXQ.js";
5
5
  import {
6
6
  toErrorMessage
7
7
  } from "./chunk-HNMXYYJR.js";
@@ -0,0 +1,11 @@
1
+ // packages/ai/context/tokenUtils.ts
2
+ var estimateTokenCount = (text) => {
3
+ if (!text) return 0;
4
+ const chineseChars = (text.match(/[\u4e00-\u9fa5\u3400-\u4dbf]/g) || []).length;
5
+ const otherChars = text.length - chineseChars;
6
+ return Math.ceil(chineseChars * 1.5 + otherChars * 0.25);
7
+ };
8
+
9
+ export {
10
+ estimateTokenCount
11
+ };