nolo-cli 0.54.0-alpha.2 → 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 (172) hide show
  1. package/README.md +3 -3
  2. package/{_executeModel-ANY4SIAS.js → _executeModel-CKT6RGTL.js} +58 -49
  3. package/{action-Q4W5JPI5.js → action-76JX3JX3.js} +9 -8
  4. package/{addContentAction-O25HFR37.js → addContentAction-V3NAZRTJ.js} +9 -7
  5. package/{addDialogAgentAction-GH7AUPPB.js → addDialogAgentAction-RZOAF46K.js} +11 -9
  6. package/{agentDeleteCommand-JWIKNWWI.js → agentDeleteCommand-VN7NPXQ4.js} +37 -32
  7. package/{agentEmailCommands-PL22BEU5.js → agentEmailCommands-F2TNAV4A.js} +73 -65
  8. package/{agentGrantCommands-2LEZDADN.js → agentGrantCommands-R3VQEZJR.js} +1 -1
  9. package/{agentListCommands-6NR7AQEK.js → agentListCommands-OSM2ANI3.js} +78 -39
  10. package/{agentMachineCommands-TASPU6OA.js → agentMachineCommands-MTPWYVRV.js} +38 -33
  11. package/{agentPullCommand-M552CYSI.js → agentPullCommand-N7L2CT7L.js} +2 -2
  12. package/agentRecordCommands-VWAWTVVC.js +122 -0
  13. package/agentRunCommand-PLZOBNVK.js +149 -0
  14. package/{agentRunControl-4GHHSXFZ.js → agentRunControl-WECMOO6O.js} +13 -6
  15. package/{agentRuntimeLocal-PCJJ56J2.js → agentRuntimeLocal-XCJLRWQE.js} +35 -28
  16. package/{agentSlice-KYLDUSNN.js → agentSlice-F6DOP4IW.js} +10 -9
  17. package/{appDeleteCommands-WLHMJAVT.js → appDeleteCommands-3BCFTRFJ.js} +37 -32
  18. package/{appDeployCommands-CKON7N2E.js → appDeployCommands-B4GMHCYA.js} +37 -32
  19. package/{appDeployStatusCommands-PXRLDASH.js → appDeployStatusCommands-4MN36WIG.js} +37 -32
  20. package/{appGetCommands-RAB5RM4M.js → appGetCommands-4GJIEUAX.js} +37 -32
  21. package/{appListCommands-GU57FB62.js → appListCommands-CHU53GSX.js} +37 -32
  22. package/{authCommand-QOPOEYEK.js → authCommand-WOTWLJNF.js} +38 -32
  23. package/{authCommands-SBQVTD6V.js → authCommands-ILTBI6JV.js} +8 -6
  24. package/{chatQueueReduxAdapter-5O2WLITN.js → chatQueueReduxAdapter-HNSQXNIR.js} +29 -24
  25. package/{chunk-WL3UOGYO.js → chunk-22BTGNSP.js} +151 -155
  26. package/{chunk-7CH6U3FL.js → chunk-2GRGFCF6.js} +2 -4
  27. package/{chunk-V4KZGLOI.js → chunk-2HPRMEEZ.js} +3059 -1079
  28. package/{chunk-UNZDCI3O.js → chunk-2KDR4CWE.js} +35 -4
  29. package/{chunk-VRZIH5JO.js → chunk-2PGGC63K.js} +1 -1
  30. package/{chunk-T27IEBNQ.js → chunk-2QDDKFG5.js} +74 -1
  31. package/{chunk-7K5VMB4Q.js → chunk-37QVS7BU.js} +21 -8
  32. package/{chunk-UITMHBVK.js → chunk-37XDGCY7.js} +1 -1
  33. package/chunk-3BLB7QKO.js +433 -0
  34. package/{chunk-NQ4N4IGO.js → chunk-3JQ2NRYU.js} +33 -10
  35. package/{chunk-UW4INMD2.js → chunk-3JWKQDA4.js} +2 -2
  36. package/{chunk-IKTHA3JH.js → chunk-3QGUVVX5.js} +2 -2
  37. package/{chunk-WHVQA7PJ.js → chunk-45YO6H7P.js} +97 -35
  38. package/chunk-4C4ST2YE.js +20015 -0
  39. package/{chunk-32I5RVMY.js → chunk-4NJEIGBQ.js} +5 -5
  40. package/{chunk-KUUTWU4I.js → chunk-5ZYA4JJ3.js} +90 -22
  41. package/chunk-6YTOJY35.js +352 -0
  42. package/{chunk-INXBNYCG.js → chunk-7A3RRUCQ.js} +155 -12
  43. package/{chunk-GV35EHNA.js → chunk-7O7KH4X5.js} +1262 -971
  44. package/{chunk-Y7LNKP32.js → chunk-7UF7CQ6B.js} +4 -6
  45. package/{chunk-2BWU4ORW.js → chunk-AQMVUA7N.js} +2 -1
  46. package/{chunk-LA4IDAK7.js → chunk-AVE2YR4F.js} +1056 -3591
  47. package/{chunk-TI5BCZCH.js → chunk-B7DXRX7F.js} +59 -121
  48. package/chunk-BFU6C242.js +66 -0
  49. package/{chunk-FA4SY4F5.js → chunk-BYEJ7K2Z.js} +1 -1
  50. package/chunk-BYXBJQAS.js +0 -0
  51. package/{chunk-IA3A5373.js → chunk-C3FZR5EC.js} +1 -1
  52. package/{chunk-IWUMSAQF.js → chunk-CJCJF5XB.js} +26 -3
  53. package/{chunk-PAHILFNT.js → chunk-CP7VIDZ7.js} +4 -4
  54. package/{chunk-OYNDYVSE.js → chunk-CTCW7U7N.js} +1 -1
  55. package/{chunk-BJLYCOZK.js → chunk-D5XKNNUV.js} +135 -795
  56. package/{chunk-AV6KQCM5.js → chunk-DNNSCSA2.js} +19 -14
  57. package/{chunk-3AOLVADY.js → chunk-DVINR3PL.js} +1 -1
  58. package/{chunk-NI2BS6UD.js → chunk-DWUCB2A3.js} +1 -1
  59. package/{chunk-AA564GBL.js → chunk-DZZL7UBV.js} +1 -1
  60. package/{chunk-6FGXGFAH.js → chunk-E6RGHPDR.js} +6 -4
  61. package/chunk-EDKF7RX4.js +30 -0
  62. package/{chunk-6SZ52ORL.js → chunk-ES6CVKVD.js} +24 -30
  63. package/{chunk-DQLYEGP7.js → chunk-FHAGENAS.js} +3 -4
  64. package/{chunk-56W233KG.js → chunk-FKFMIBTT.js} +5 -1
  65. package/{chunk-INZZJSQF.js → chunk-FZGV4FGK.js} +24 -12
  66. package/{chunk-D3JQPONH.js → chunk-GAL47RNP.js} +1 -1
  67. package/{chunk-6FQ2552G.js → chunk-HBPV76EK.js} +1085 -1150
  68. package/{chunk-LN3OQJGG.js → chunk-HLU5Q2GV.js} +4 -4
  69. package/{chunk-U2A47SVI.js → chunk-HQP7HJDL.js} +7 -7
  70. package/{chunk-H2G6JXTR.js → chunk-HQUORJTM.js} +1 -1
  71. package/{chunk-3Z3DXZBD.js → chunk-IYCUMIYS.js} +24 -20
  72. package/{chunk-7APQB6R6.js → chunk-JX5PJCWS.js} +8 -6
  73. package/{chunk-LYGNQHUW.js → chunk-JYYZCK2Z.js} +2 -4
  74. package/{chunk-PYKV6FSC.js → chunk-KWSQR2KK.js} +16 -31
  75. package/{chunk-VULELK4T.js → chunk-L7B47JXR.js} +37 -64
  76. package/{chunk-4NN3EK7H.js → chunk-LAFC3B2I.js} +1 -1
  77. package/{chunk-VRJUIUIY.js → chunk-LJKICKVC.js} +2 -2
  78. package/chunk-M3JEW6N6.js +193 -0
  79. package/chunk-MBOEV4L2.js +301 -0
  80. package/{chunk-QDHZCAH3.js → chunk-MMZ6ZTVO.js} +229 -74
  81. package/{chunk-JDSUTNYY.js → chunk-MP64VFGD.js} +2 -2
  82. package/{chunk-U5Z7LFZF.js → chunk-MXUDQZXQ.js} +47 -8
  83. package/chunk-N4G4PKQ6.js +23 -0
  84. package/{chunk-SVEUG45B.js → chunk-NHRQCXIQ.js} +0 -24
  85. package/{chunk-KXKQO4Q6.js → chunk-NTW5GWDM.js} +58 -1
  86. package/chunk-ONXOABJR.js +215 -0
  87. package/{chunk-BANYWEYY.js → chunk-OZX2IPKM.js} +8 -3
  88. package/{chunk-Q24S4NDF.js → chunk-P7OOB7QP.js} +1 -1
  89. package/{chunk-GLGD2JGY.js → chunk-PEZJEQAO.js} +7 -7
  90. package/{chunk-GBADO3SM.js → chunk-PQDIDWGX.js} +1 -1
  91. package/chunk-PSCNXBYA.js +11 -0
  92. package/chunk-QEFJJS2I.js +508 -0
  93. package/{chunk-757BGY6Y.js → chunk-QEW2MFDQ.js} +1 -1
  94. package/{chunk-SP3DPVBH.js → chunk-RDBARW6T.js} +8 -3
  95. package/{chunk-TNPCQNGQ.js → chunk-RJ2SAFB5.js} +83 -41
  96. package/{chunk-FGEYVPPR.js → chunk-RVWRKFUB.js} +8 -65
  97. package/{chunk-43CXXVJD.js → chunk-RXX4GDIH.js} +1 -1
  98. package/chunk-SEJ5OS6F.js +49 -0
  99. package/{chunk-MFI4FGHX.js → chunk-SOJM57FX.js} +5 -2
  100. package/{chunk-EKLRRZIN.js → chunk-SPAQ4PVV.js} +0 -5
  101. package/{chunk-L7NG2M6H.js → chunk-TRV2MIDW.js} +89 -74
  102. package/chunk-UAD2WT54.js +64 -0
  103. package/{chunk-RTLJUGQH.js → chunk-UZPQSVM6.js} +2 -2
  104. package/{chunk-3QJTD6DO.js → chunk-VMWYBIXG.js} +9 -7
  105. package/{chunk-ZHXJ6M7T.js → chunk-W7XHHYWM.js} +4 -0
  106. package/{chunk-5WADL4O7.js → chunk-XAVSS3KE.js} +21 -3
  107. package/{chunk-CVT7L2WZ.js → chunk-XOKOSO35.js} +13 -22
  108. package/{chunk-6BYAXNH5.js → chunk-XTJTN3RW.js} +57 -4
  109. package/{chunk-T5HJEUQN.js → chunk-YCDWJX45.js} +1 -1
  110. package/{chunk-MRWGHF56.js → chunk-YDH3FDFQ.js} +12 -356
  111. package/{chunk-H4RYESI6.js → chunk-Z4QSJILV.js} +85 -13
  112. package/chunk-ZJ7UHBJS.js +89 -0
  113. package/{chunk-O5FLGN2L.js → chunk-ZRSJ3JEH.js} +6 -2
  114. package/{cliExecutor-BBUVQU4L.js → cliExecutor-HG3S345O.js} +1 -1
  115. package/{codingSkills-BCQXRZOI.js → codingSkills-VDXQYWX4.js} +2 -2
  116. package/contentThunks-7YG2ZYQC.js +73 -0
  117. package/{cooldownCommands-GI5NNWGL.js → cooldownCommands-BSCH2W7P.js} +2 -2
  118. package/{createAgentAutomationAction-UJLNFFFC.js → createAgentAutomationAction-PJQSCAIO.js} +32 -26
  119. package/createDialogAction-SFEJX6SP.js +64 -0
  120. package/{createPageAction-N3IYABHV.js → createPageAction-B7WRHOQO.js} +35 -28
  121. package/{dbSlice-D5CNGWPD.js → dbSlice-IBVOBVMS.js} +7 -6
  122. package/{deleteFile-44TUM34Y.js → deleteFile-FWP2PSBG.js} +4 -3
  123. package/{dialogCommands-35M6RBAC.js → dialogCommands-VL2X22QC.js} +38 -33
  124. package/{dialogSlice-KO7ADD7H.js → dialogSlice-ANMACABO.js} +29 -24
  125. package/{docCreateCommands-VXHZWQ3P.js → docCreateCommands-ITLGZ5YI.js} +40 -35
  126. package/{docDeleteCommands-4WFAJR6A.js → docDeleteCommands-LH3YNL4C.js} +37 -32
  127. package/{docReadCommands-OYREEFAR.js → docReadCommands-YAJ77F36.js} +36 -31
  128. package/{docStore-5BU76DFK.js → docStore-D4HGHPWI.js} +9 -33
  129. package/{docUpdateCommands-A7QERSME.js → docUpdateCommands-DQBOMH2G.js} +40 -35
  130. package/{fetchMessages-KZQVBXKY.js → fetchMessages-DRABNDPZ.js} +3 -3
  131. package/{getPricing-HAU62AFM.js → getPricing-NM3NUTAS.js} +5 -5
  132. package/handleSendMessageAction-DF2OABGW.js +675 -0
  133. package/index.js +79 -88
  134. package/{lib-2ZTNRXR4.js → lib-FRRS27KN.js} +63 -28
  135. package/{localDialogRead-NQ33HBSI.js → localDialogRead-PUQKFI73.js} +1 -1
  136. package/{localRuntimeAuthority-KQDAE64E.js → localRuntimeAuthority-R5UBODT3.js} +6 -4
  137. package/{localRuntimeDb-PF7CFKDL.js → localRuntimeDb-P37ZTX55.js} +1 -1
  138. package/{machineCommands-J43U3TX5.js → machineCommands-JXDYQ5LB.js} +309 -87
  139. package/{machineWsRunDispatch-Z2Z6STXZ.js → machineWsRunDispatch-3QHI7JX5.js} +67 -59
  140. package/memberThunks-VZI6G7YZ.js +640 -0
  141. package/{models-4QF4BJVY.js → models-FAMINFZ7.js} +2 -2
  142. package/package.json +3 -2
  143. package/{read-RGNPI5H2.js → read-2BYWW7AA.js} +4 -3
  144. package/{readDocTool-6ESWKTXD.js → readDocTool-LC3A7QTB.js} +1 -1
  145. package/{readlineWorkspace-YRPV6JPN.js → readlineWorkspace-KVZTEAHB.js} +4609 -2698
  146. package/{removeDialogAgentAction-JYT73FU2.js → removeDialogAgentAction-SFYZXHNK.js} +14 -12
  147. package/{runAgentClientLoop-5YM5WMAY.js → runAgentClientLoop-KGTEL7ZP.js} +60 -50
  148. package/{runtimeDoctorCommands-JKTTN723.js → runtimeDoctorCommands-CROTMULY.js} +7 -5
  149. package/{setDialogExtraReferencesAction-D564LMYQ.js → setDialogExtraReferencesAction-Q32RGFTA.js} +10 -8
  150. package/{setPrimaryDialogAgentAction-ACY3BLYA.js → setPrimaryDialogAgentAction-BFYJHUJS.js} +14 -12
  151. package/{settingSlice-MKI3MNZJ.js → settingSlice-IRUU4VFB.js} +8 -7
  152. package/{skillDiscovery-GPUDHDTZ.js → skillDiscovery-NTRLM6KP.js} +3 -3
  153. package/{spaceCommands-MY26V52L.js → spaceCommands-KNAYWMCZ.js} +40 -220
  154. package/{streamAgentChatTurn-XV5X5TNQ.js → streamAgentChatTurn-FLYPTXKZ.js} +140 -95
  155. package/{switchDialogAgentAction-CJ5H6SAR.js → switchDialogAgentAction-L2KOKCGG.js} +11 -9
  156. package/{tableCommands-R6WFRDYF.js → tableCommands-SUNTHAYX.js} +1 -1
  157. package/{toolApiClient-B2MFXMEG.js → toolApiClient-VGYUB4P5.js} +4 -2
  158. package/{tools-MIMELA2Y.js → tools-CVLUXK6P.js} +46 -38
  159. package/{tuiSummaryLlmCaller-XJ5BKNNS.js → tuiSummaryLlmCaller-F3DPFFZM.js} +20 -16
  160. package/{updateCommands-IYKLF3JX.js → updateCommands-AJYSD73Y.js} +2 -2
  161. package/{updateDialogTitleAction-EIZUSWHR.js → updateDialogTitleAction-HWJIZEIV.js} +33 -27
  162. package/agentRecordCommands-Z64TA63M.js +0 -114
  163. package/agentRunCommand-4QJQLPRW.js +0 -134
  164. package/agentSuperviseCommands-VB6BUS5H.js +0 -640
  165. package/chunk-6BGAQ3KR.js +0 -7081
  166. package/chunk-FD36SCCD.js +0 -105
  167. package/chunk-J3UALFHL.js +0 -370
  168. package/chunk-RU5D3B22.js +0 -230
  169. package/chunk-YBV6QJKM.js +0 -441
  170. package/createDialogAction-TJCX6GUE.js +0 -58
  171. package/handleSendMessageAction-OSGQJQ45.js +0 -406
  172. package/spaceSlice-JUIXC365.js +0 -127
@@ -2393,29 +2393,6 @@ var require_rambda = __commonJS({
2393
2393
  }
2394
2394
  });
2395
2395
 
2396
- // packages/create/types.ts
2397
- var DataType = /* @__PURE__ */ ((DataType2) => {
2398
- DataType2["AGENT"] = "agent";
2399
- DataType2["DOC"] = "page";
2400
- DataType2["DIALOG"] = "dialog";
2401
- DataType2["NOTIFICATION"] = "notification";
2402
- DataType2["MSG"] = "msg";
2403
- DataType2["TOKEN"] = "token";
2404
- DataType2["SPACE"] = "space";
2405
- DataType2["TRANSACTION"] = "transaction";
2406
- DataType2["SETTING"] = "setting";
2407
- DataType2["TASK"] = "task";
2408
- DataType2["AGENT_AUTOMATION"] = "agent-automation";
2409
- DataType2["TABLE"] = "table";
2410
- DataType2["TABLE_ROW"] = "table_row";
2411
- DataType2["FILE"] = "file";
2412
- DataType2["IMAGE"] = "image";
2413
- DataType2["APP"] = "app";
2414
- DataType2["EMAIL"] = "email";
2415
- DataType2["Category"] = "category";
2416
- return DataType2;
2417
- })(DataType || {});
2418
-
2419
2396
  // packages/core/toTrimmedString.ts
2420
2397
  function toTrimmedString(value) {
2421
2398
  return typeof value === "string" ? value.trim() : value == null ? "" : String(value).trim();
@@ -3192,7 +3169,6 @@ var sanitizeShareData = (data) => {
3192
3169
  };
3193
3170
 
3194
3171
  export {
3195
- DataType,
3196
3172
  ulid,
3197
3173
  toTrimmedString,
3198
3174
  toNonEmptyString,
@@ -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
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getActiveDialogKey
3
- } from "./chunk-MRWGHF56.js";
3
+ } from "./chunk-6YTOJY35.js";
4
4
  import {
5
5
  compactWhitespace
6
6
  } from "./chunk-DWLEOOGR.js";
@@ -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-DQLYEGP7.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-Q24S4NDF.js";
10
+ } from "./chunk-P7OOB7QP.js";
11
11
  import {
12
12
  fetchWithTransientRetry
13
13
  } from "./chunk-5XTOKQLW.js";
@@ -18,7 +18,7 @@ import {
18
18
  import {
19
19
  buildDialogAttachmentPlan,
20
20
  extractFileContentIds
21
- } from "./chunk-H2G6JXTR.js";
21
+ } from "./chunk-HQUORJTM.js";
22
22
  import {
23
23
  isLevelLockError
24
24
  } from "./chunk-URMS4XY2.js";
@@ -53,12 +53,12 @@ import {
53
53
  import {
54
54
  isLevelNotFoundError
55
55
  } from "./chunk-OW765XBU.js";
56
- import {
57
- isRecord
58
- } from "./chunk-KUG52IAP.js";
59
56
  import {
60
57
  asTrimmedString
61
58
  } from "./chunk-3EUW3WEO.js";
59
+ import {
60
+ isRecord
61
+ } from "./chunk-KUG52IAP.js";
62
62
  import {
63
63
  DEFAULT_LOCAL_API_ORIGIN
64
64
  } from "./chunk-4SN6J65J.js";
@@ -708,7 +708,7 @@ function isExplicitDialogIdMismatch(meta, dialogId) {
708
708
  return meta && typeof meta === "object" && "id" in meta && meta.id != null && String(meta.id) !== dialogId;
709
709
  }
710
710
  async function readDialogFromLocalDb(dialogKey, dialogId, limit, readLocalDialog) {
711
- const reader = readLocalDialog ?? (await import("./localDialogRead-NQ33HBSI.js")).readDialogFromLocalDb;
711
+ const reader = readLocalDialog ?? (await import("./localDialogRead-PUQKFI73.js")).readDialogFromLocalDb;
712
712
  const result = await reader({ dialogKey, dialogId, limit });
713
713
  return {
714
714
  ...result,
@@ -725,7 +725,7 @@ async function readLocalDialogAtDbPathDefault(args) {
725
725
  const [{ Level }, { safeJsonEncoding }, { fetchMessages }] = await Promise.all([
726
726
  import("./levelLazyShim-GZBKODGI.js"),
727
727
  import("./serverStoreFactory-YMXDF4NI.js"),
728
- import("./fetchMessages-KZQVBXKY.js")
728
+ import("./fetchMessages-DRABNDPZ.js")
729
729
  ]);
730
730
  const db = new Level(args.dbPath, {
731
731
  valueEncoding: safeJsonEncoding,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  generatePkcePair,
3
3
  startCallbackServer
4
- } from "./chunk-U5Z7LFZF.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
+ };