nolo-cli 0.8.0-alpha.5 → 0.8.0-alpha.7

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 (174) hide show
  1. package/_executeModel-XIGO7HW5.js +198 -0
  2. package/action-PAXRPJJF.js +27 -0
  3. package/addContentAction-CZVWF3QZ.js +25 -0
  4. package/addDialogAgentAction-CCIDTPHC.js +67 -0
  5. package/agentDeleteCommand-47B24JYG.js +323 -0
  6. package/agentEmailCommands-D4FC6OZJ.js +621 -0
  7. package/agentListCommands-UFET7CC4.js +219 -0
  8. package/agentMachineCommands-LH7QDQPP.js +421 -0
  9. package/agentPullCommand-O2MTUAFR.js +122 -0
  10. package/agentRecordCommands-CWS2B5IA.js +89 -0
  11. package/agentRunCommand-3FRPISLG.js +102 -0
  12. package/agentRunControl-K4VKNEHF.js +57 -0
  13. package/agentRuntimeLocal-JNQQC2WG.js +99 -0
  14. package/agentSlice-XDFSELFJ.js +41 -0
  15. package/authCommand-WXMD3IPR.js +574 -0
  16. package/authCommands-X74AFDTC.js +26 -0
  17. package/chunk-2EISRLRC.js +238 -0
  18. package/chunk-2FTTDCD4.js +675 -0
  19. package/chunk-2JHWPW5B.js +2127 -0
  20. package/chunk-2LMT6K6N.js +171 -0
  21. package/chunk-2MALU52L.js +51 -0
  22. package/chunk-364VYAX2.js +19 -0
  23. package/chunk-3ASDTTEI.js +1774 -0
  24. package/chunk-3EUW3WEO.js +8 -0
  25. package/chunk-3LY4F7SV.js +9293 -0
  26. package/chunk-4CQLVGRV.js +50 -0
  27. package/chunk-4IJYA27C.js +342 -0
  28. package/chunk-4SN6J65J.js +38 -0
  29. package/chunk-4VNS5WPM.js +42 -0
  30. package/chunk-543C7RDK.js +562 -0
  31. package/chunk-572EKYLF.js +792 -0
  32. package/chunk-5MIDPSSK.js +206 -0
  33. package/chunk-5MMAK75Q.js +15 -0
  34. package/chunk-5XH3NZ4T.js +3631 -0
  35. package/chunk-63W5N6P3.js +150 -0
  36. package/chunk-6HYVJV7B.js +102 -0
  37. package/chunk-6PWWWMI7.js +628 -0
  38. package/chunk-6WD3OOJS.js +20 -0
  39. package/chunk-A3X4Y7MO.js +4294 -0
  40. package/chunk-AR7ZSGDI.js +929 -0
  41. package/chunk-ATNTHIZI.js +13 -0
  42. package/chunk-AUGHVUFE.js +69 -0
  43. package/chunk-AVMKZHBC.js +85 -0
  44. package/chunk-AZPCASRE.js +36 -0
  45. package/chunk-B76D3JJK.js +1447 -0
  46. package/chunk-BR2WP3DF.js +548 -0
  47. package/chunk-BSTNFPHD.js +231 -0
  48. package/chunk-CF2WZF4N.js +134 -0
  49. package/chunk-CF7PE763.js +10 -0
  50. package/chunk-CKOJQDKR.js +198 -0
  51. package/chunk-CM54RSSA.js +206 -0
  52. package/chunk-CWMSB67P.js +34 -0
  53. package/chunk-DA2OEKS6.js +27 -0
  54. package/chunk-DFFIZ25G.js +30 -0
  55. package/chunk-DWLEOOGR.js +8 -0
  56. package/chunk-DZ3XJVET.js +231 -0
  57. package/chunk-E5HMHIKL.js +222 -0
  58. package/chunk-EHLHSX7R.js +1433 -0
  59. package/chunk-ELRRLDWI.js +478 -0
  60. package/chunk-EYEEHCU4.js +3066 -0
  61. package/chunk-G3SUCT4W.js +8 -0
  62. package/chunk-G5H7RNFL.js +807 -0
  63. package/chunk-GAKEBQD6.js +30 -0
  64. package/chunk-GBRG75BQ.js +86 -0
  65. package/chunk-GEKCOPTN.js +190 -0
  66. package/chunk-H2RMRZJE.js +113 -0
  67. package/chunk-H33743XH.js +25 -0
  68. package/chunk-HEIIIZBX.js +104 -0
  69. package/chunk-HNMXYYJR.js +12 -0
  70. package/chunk-IAXBCTTE.js +175 -0
  71. package/chunk-IDZTNRP2.js +85 -0
  72. package/chunk-IECI4YHR.js +421 -0
  73. package/chunk-ISNCLGUZ.js +146 -0
  74. package/chunk-IYQV26RA.js +138 -0
  75. package/chunk-JBTJAPUF.js +35 -0
  76. package/chunk-JZPBVBIY.js +94 -0
  77. package/chunk-KK6SWS5B.js +1078 -0
  78. package/chunk-KQHGZWSV.js +63 -0
  79. package/chunk-KTI2WDDG.js +24674 -0
  80. package/chunk-KUG52IAP.js +8 -0
  81. package/chunk-KX6YBIHG.js +8 -0
  82. package/chunk-LCBAMY2M.js +60 -0
  83. package/chunk-LM25IZBJ.js +902 -0
  84. package/chunk-LM6IYQ3F.js +16 -0
  85. package/chunk-M76ECQRD.js +13658 -0
  86. package/chunk-MRC4Q34M.js +188 -0
  87. package/chunk-NE3E3XJ2.js +936 -0
  88. package/chunk-NXZGF7F7.js +2878 -0
  89. package/chunk-OF5H3QWS.js +300 -0
  90. package/chunk-OLZBQWZU.js +6 -0
  91. package/chunk-OVGXXUVI.js +91 -0
  92. package/chunk-OWOHNGCN.js +50 -0
  93. package/chunk-PN7AFLOK.js +3401 -0
  94. package/chunk-QSJ3HFEF.js +8 -0
  95. package/chunk-QYXLLLGL.js +4519 -0
  96. package/chunk-ROWQEJRP.js +139 -0
  97. package/chunk-S7Z2HMCN.js +25 -0
  98. package/chunk-SL3EPWB4.js +1949 -0
  99. package/chunk-TDIQFT2F.js +301 -0
  100. package/chunk-TILFE6LV.js +381 -0
  101. package/chunk-U4TRT5V4.js +246 -0
  102. package/chunk-U6VC4MU4.js +8 -0
  103. package/chunk-UAD2WT54.js +64 -0
  104. package/chunk-USZDUWOV.js +191 -0
  105. package/chunk-USZMK5UT.js +105 -0
  106. package/chunk-UVPF33PW.js +46995 -0
  107. package/chunk-V2F4OGYM.js +9013 -0
  108. package/chunk-VEJLAVTC.js +2052 -0
  109. package/chunk-VF4K2QE6.js +21 -0
  110. package/chunk-VHBWHNVT.js +59 -0
  111. package/chunk-VIDPVFP3.js +20 -0
  112. package/chunk-VP4WJWKW.js +8882 -0
  113. package/chunk-VQ2AJRGD.js +148 -0
  114. package/chunk-W4NVOSFF.js +37 -0
  115. package/chunk-WWC7I6TA.js +8 -0
  116. package/chunk-X7W4TNB4.js +1550 -0
  117. package/chunk-XDVAYP26.js +537 -0
  118. package/chunk-XKIMRZO2.js +221 -0
  119. package/chunk-Y5GCAMGP.js +9 -0
  120. package/chunk-YD43KPCK.js +360 -0
  121. package/chunk-YIJFUVKA.js +34 -0
  122. package/chunk-Z4NR32XR.js +50 -0
  123. package/chunk-ZNFJWEN4.js +56 -0
  124. package/cliExecutor-DNE7TCC4.js +36 -0
  125. package/clipboardy-BVE3LVEH.js +12001 -0
  126. package/createAgentAutomationAction-3QTGNYJC.js +864 -0
  127. package/createDialogAction-5YX3ARBK.js +52 -0
  128. package/createPageAction-EQNQQRCW.js +169 -0
  129. package/db-HCJ5PRB5.js +271 -0
  130. package/dbSlice-C4UJLRZP.js +59 -0
  131. package/deleteFile-4SKGPHOZ.js +41 -0
  132. package/dialogCommands-AOQS23FV.js +59 -0
  133. package/dialogSlice-GZE3NCMC.js +146 -0
  134. package/docCreateCommands-GVOQVJON.js +215 -0
  135. package/docDeleteCommands-GEB7YAUZ.js +176 -0
  136. package/docReadCommands-XYKI2DF2.js +129 -0
  137. package/docStore-MLM5AME5.js +96 -0
  138. package/docUpdateCommands-4L3RAMHZ.js +313 -0
  139. package/fetchMessages-JOCYIFKL.js +16 -0
  140. package/getPricing-PWPJ6MNV.js +30 -0
  141. package/handleSendMessageAction-WG2GKTGZ.js +183 -0
  142. package/index.js +184 -112986
  143. package/localDialogRead-D3BELSTF.js +26 -0
  144. package/localFirstLog-DHNOY2NA.js +19 -0
  145. package/localRuntimeAuthority-TEGCOWX4.js +471 -0
  146. package/localRuntimeDb-LGDF6FQP.js +12 -0
  147. package/machineCommands-ZNXKLH6Q.js +774 -0
  148. package/machineInfo-M6KB6HZN.js +10 -0
  149. package/machineWsRunDispatch-7WRG6HNV.js +105 -0
  150. package/memoryCommands-O4MIPIWQ.js +476 -0
  151. package/models-XLEOET3E.js +9 -0
  152. package/offlineMarxistsAgentCommand-BCPJITJL.js +242 -0
  153. package/package.json +3 -25
  154. package/read-RIJCIVKX.js +17 -0
  155. package/readDocTool-GZD2N3LO.js +16 -0
  156. package/readlineWorkspace-AQURUDN4.js +5357 -0
  157. package/removeDialogAgentAction-CXLST3N6.js +72 -0
  158. package/runAgentClientLoop-VQUEKGA5.js +288 -0
  159. package/runtimeDoctorCommands-LRHLPDRC.js +289 -0
  160. package/setDialogExtraReferencesAction-LP6VYGU7.js +59 -0
  161. package/setPrimaryDialogAgentAction-D3GGH23T.js +79 -0
  162. package/settingSlice-J4I3Z5H7.js +198 -0
  163. package/skillSummaryMarker-42HKSXYY.js +9 -0
  164. package/slateToRenderMarkdown-Y5IYN73U.js +7 -0
  165. package/slateUtils-2M7MUTWX.js +19 -0
  166. package/spaceCommands-R2RXD5UY.js +450 -0
  167. package/spaceSlice-5UT4JNIN.js +145 -0
  168. package/streamAgentChatTurn-NRWSQKFN.js +4503 -0
  169. package/tableCommands-66XEWHAK.js +1286 -0
  170. package/toolApiClient-QI3YBNWB.js +26 -0
  171. package/tools-TNMUDDRK.js +83 -0
  172. package/understanding-HCSFPE7R.js +318 -0
  173. package/updateCommands-VOSPKXFF.js +31 -0
  174. package/updateDialogTitleAction-IXOKAVX3.js +185 -0
@@ -0,0 +1,300 @@
1
+ import {
2
+ buildCliRuntimeEnv,
3
+ clearProfileAuthToken,
4
+ getCurrentProfile,
5
+ getDefaultProfileConfigPath,
6
+ loadProfileConfig,
7
+ saveDefaultProfile
8
+ } from "./chunk-ROWQEJRP.js";
9
+ import {
10
+ resolveAuthTokenFromEnv
11
+ } from "./chunk-ISNCLGUZ.js";
12
+ import {
13
+ DEFAULT_NOLO_SERVER_URL
14
+ } from "./chunk-OLZBQWZU.js";
15
+ import {
16
+ normalizeServerOrigin
17
+ } from "./chunk-CF7PE763.js";
18
+
19
+ // packages/cli/authCommands.ts
20
+ import { createInterface } from "node:readline/promises";
21
+ import { stdin as input, stdout as output } from "node:process";
22
+ import { spawn } from "node:child_process";
23
+ var LOGIN_HELP_TEXT = `Log in to Nolo and save a local profile.
24
+
25
+ Usage:
26
+ nolo login [--server <url>] [--no-browser] [--token <jwt>] [--manual]
27
+
28
+ Options:
29
+ --server <url> Nolo server URL (default: ${DEFAULT_NOLO_SERVER_URL})
30
+ --no-browser Print the authorization URL instead of opening a browser
31
+ --token <jwt> Save a token directly without browser authorization
32
+ --manual Prompt to paste a token interactively
33
+
34
+ By default, opens the Nolo website and polls until authorization completes.
35
+ In SSH sessions, use --no-browser and open the printed URL on a machine with a browser
36
+ where you are already logged into Nolo.
37
+
38
+ Note: nolo login only authorizes your Nolo platform account. To let your agents
39
+ call third-party models using your own subscriptions, you also need:
40
+ nolo auth antigravity # Google Antigravity (Gemini 3, Claude, GPT-OSS)
41
+ nolo auth claude # Claude Pro/Max
42
+ nolo auth chatgpt # ChatGPT Plus / OpenAI Codex
43
+ nolo auth xai # xAI Grok (SuperGrok)
44
+ nolo auth cloudflare # Cloudflare OAuth (email routing, etc.)
45
+ See "nolo auth <provider> --help" for details.
46
+ `;
47
+ var LOGOUT_HELP_TEXT = `Log out of Nolo by clearing the saved auth token.
48
+
49
+ Usage:
50
+ nolo logout
51
+
52
+ Keeps other profile settings such as server URL and default agent preferences.
53
+ Does not unset AUTH_TOKEN or other auth-related environment variables.
54
+ `;
55
+ var WHOAMI_HELP_TEXT = `Show the current login state.
56
+
57
+ Usage:
58
+ nolo whoami
59
+ `;
60
+ function wantsHelp(args) {
61
+ return args.includes("--help") || args.includes("-h");
62
+ }
63
+ function formatDuration(ms) {
64
+ const totalSec = Math.max(0, Math.ceil(ms / 1e3));
65
+ const minutes = Math.floor(totalSec / 60);
66
+ const seconds = totalSec % 60;
67
+ if (minutes > 0) return `${minutes}m ${seconds}s`;
68
+ return `${seconds}s`;
69
+ }
70
+ function formatTokenPreview(token) {
71
+ const trimmed = token.trim();
72
+ if (!trimmed) return "";
73
+ return `${trimmed.slice(0, 8)}...`;
74
+ }
75
+ function getArg(args, flag) {
76
+ const index = args.indexOf(flag);
77
+ return index >= 0 ? args[index + 1] : void 0;
78
+ }
79
+ var postJson = async (fetchImpl, url, body) => fetchImpl(url, {
80
+ method: "POST",
81
+ headers: { "Content-Type": "application/json" },
82
+ body: JSON.stringify(body)
83
+ });
84
+ var defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
85
+ var defaultOpenBrowser = async (url) => {
86
+ const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
87
+ const args = process.platform === "win32" ? ["/c", "start", "", url.replace(/&/g, "^&")] : [url];
88
+ try {
89
+ const child = spawn(command, args, {
90
+ detached: true,
91
+ stdio: "ignore"
92
+ });
93
+ child.unref();
94
+ return true;
95
+ } catch {
96
+ return false;
97
+ }
98
+ };
99
+ async function saveTokenLogin(args) {
100
+ if (!args.authToken.trim()) {
101
+ args.error.error("No auth token provided.");
102
+ return 1;
103
+ }
104
+ saveDefaultProfile(args.configPath, {
105
+ serverUrl: args.serverUrl,
106
+ authToken: args.authToken.trim()
107
+ });
108
+ args.output.log(`Saved profile default -> ${args.serverUrl}`);
109
+ return 0;
110
+ }
111
+ async function runWebLogin(args) {
112
+ const startResponse = await postJson(
113
+ args.fetchImpl,
114
+ `${args.serverUrl}/api/v1/users/cli-login/start`,
115
+ { clientName: "nolo-cli" }
116
+ );
117
+ const start = await startResponse.json().catch(() => ({}));
118
+ if (!startResponse.ok || !start?.deviceCode || !start?.verificationUriComplete) {
119
+ args.error.error(
120
+ `Failed to start web login (${startResponse.status}). Use --token to paste a token manually.`
121
+ );
122
+ return 1;
123
+ }
124
+ args.output.log("Open this URL to authorize nolo-cli:");
125
+ args.output.log(start.verificationUriComplete);
126
+ args.output.log(`Code: ${start.userCode}`);
127
+ if (!args.noBrowser) {
128
+ const opened = await args.openBrowser(start.verificationUriComplete);
129
+ if (!opened) {
130
+ args.output.log("Could not open a browser automatically. Paste the URL above.");
131
+ }
132
+ }
133
+ const intervalMs = Math.max(1, Number(start.interval) || 2) * 1e3;
134
+ const timeoutMs = Math.max(1, Number(start.expiresIn) || 600) * 1e3;
135
+ const deadline = args.now() + timeoutMs;
136
+ const statusLogIntervalMs = 15e3;
137
+ let lastStatusLogAt = 0;
138
+ args.output.log(
139
+ `[nolo] Waiting for browser authorization (${formatDuration(timeoutMs)} remaining)...`
140
+ );
141
+ while (args.now() <= deadline) {
142
+ const pollResponse = await postJson(
143
+ args.fetchImpl,
144
+ `${args.serverUrl}/api/v1/users/cli-login/poll`,
145
+ { deviceCode: start.deviceCode }
146
+ );
147
+ const poll = await pollResponse.json().catch(() => ({}));
148
+ if (pollResponse.status === 202) {
149
+ const currentTime = args.now();
150
+ if (lastStatusLogAt > 0 && currentTime - lastStatusLogAt >= statusLogIntervalMs) {
151
+ const remainingMs = Math.max(0, deadline - currentTime);
152
+ args.output.log(
153
+ `[nolo] Still waiting... (${formatDuration(remainingMs)} remaining)`
154
+ );
155
+ lastStatusLogAt = currentTime;
156
+ } else if (lastStatusLogAt === 0) {
157
+ lastStatusLogAt = currentTime;
158
+ }
159
+ await args.sleep(intervalMs);
160
+ continue;
161
+ }
162
+ if (pollResponse.ok && poll?.token) {
163
+ const approvedServer = typeof poll.serverUrl === "string" && poll.serverUrl.trim() ? normalizeServerOrigin(poll.serverUrl) : args.serverUrl;
164
+ return saveTokenLogin({
165
+ configPath: args.configPath,
166
+ serverUrl: approvedServer,
167
+ authToken: poll.token,
168
+ output: args.output,
169
+ error: args.error
170
+ });
171
+ }
172
+ args.error.error(
173
+ `Web login failed: ${poll?.error || `HTTP ${pollResponse.status}`}. Use --token to paste a token manually.`
174
+ );
175
+ return 1;
176
+ }
177
+ args.error.error("Web login timed out. Run `nolo login` again or use --token.");
178
+ return 1;
179
+ }
180
+ async function runLoginCommand(args, deps = {}) {
181
+ const outputTarget = deps.output ?? console;
182
+ const errorTarget = deps.error ?? console;
183
+ if (wantsHelp(args)) {
184
+ outputTarget.log(LOGIN_HELP_TEXT);
185
+ return 0;
186
+ }
187
+ const configPath = deps.configPath ?? getDefaultProfileConfigPath();
188
+ const serverArg = getArg(args, "--server");
189
+ const tokenArg = getArg(args, "--token");
190
+ const noBrowser = args.includes("--no-browser");
191
+ const serverUrl = (serverArg || DEFAULT_NOLO_SERVER_URL).replace(/\/+$/, "");
192
+ if (tokenArg) {
193
+ return saveTokenLogin({
194
+ configPath,
195
+ serverUrl,
196
+ authToken: tokenArg,
197
+ output: outputTarget,
198
+ error: errorTarget
199
+ });
200
+ }
201
+ if (args.includes("--manual")) {
202
+ const rl = createInterface({ input, output });
203
+ const question = deps.question ?? ((prompt) => rl.question(prompt));
204
+ try {
205
+ const authToken = await question("paste auth token: ");
206
+ return saveTokenLogin({
207
+ configPath,
208
+ serverUrl,
209
+ authToken,
210
+ output: outputTarget,
211
+ error: errorTarget
212
+ });
213
+ } finally {
214
+ rl.close();
215
+ }
216
+ }
217
+ return runWebLogin({
218
+ configPath,
219
+ serverUrl,
220
+ fetchImpl: deps.fetchImpl ?? fetch,
221
+ openBrowser: deps.openBrowser ?? defaultOpenBrowser,
222
+ sleep: deps.sleep ?? defaultSleep,
223
+ now: deps.now ?? Date.now,
224
+ output: outputTarget,
225
+ error: errorTarget,
226
+ noBrowser
227
+ });
228
+ }
229
+ function runWhoamiCommand(deps = {}) {
230
+ const output2 = deps.output ?? console;
231
+ if (wantsHelp(deps.args ?? [])) {
232
+ output2.log(WHOAMI_HELP_TEXT);
233
+ return 0;
234
+ }
235
+ const env = deps.env ?? process.env;
236
+ const config = loadProfileConfig(deps.configPath);
237
+ const profile = getCurrentProfile(config);
238
+ const profileToken = profile?.authToken?.trim() ?? "";
239
+ const envToken = resolveAuthTokenFromEnv(env);
240
+ if (!profileToken && !envToken) {
241
+ output2.log("Not logged in. Run: nolo login");
242
+ return 1;
243
+ }
244
+ const runtimeEnv = buildCliRuntimeEnv(env, config);
245
+ const explicitServer = env.NOLO_SERVER || env.NOLO_SERVER_URL || env.BASE_URL;
246
+ if (!profileToken && envToken) {
247
+ output2.log("profile: not logged in (no saved token)");
248
+ if (profile?.serverUrl) {
249
+ output2.log(`profile server: ${profile.serverUrl}`);
250
+ }
251
+ output2.log(`effective server: ${runtimeEnv.NOLO_SERVER ?? resolveServerUrlFallback(profile)}`);
252
+ output2.log(`server source: ${explicitServer ? "env" : profile?.serverUrl ? "profile" : "default"}`);
253
+ output2.log(`env token: ${formatTokenPreview(envToken)} (source: environment)`);
254
+ return 0;
255
+ }
256
+ const effectiveServer = runtimeEnv.NOLO_SERVER ?? profile.serverUrl;
257
+ const effectiveToken = runtimeEnv.AUTH_TOKEN ?? profileToken;
258
+ output2.log(`profile: ${config.currentProfile}`);
259
+ output2.log(`profile server: ${profile.serverUrl}`);
260
+ output2.log(`effective server: ${effectiveServer}`);
261
+ output2.log(`server source: ${explicitServer ? "env" : "profile"}`);
262
+ output2.log(`token: ${formatTokenPreview(effectiveToken)} (source: ${envToken && envToken !== profileToken ? "environment" : "profile"})`);
263
+ if (envToken && envToken !== profileToken) {
264
+ output2.log(`profile token: ${formatTokenPreview(profileToken)} (source: profile, overridden by environment)`);
265
+ }
266
+ return 0;
267
+ }
268
+ function resolveServerUrlFallback(profile) {
269
+ return profile?.serverUrl ?? DEFAULT_NOLO_SERVER_URL;
270
+ }
271
+ function runLogoutCommand(deps = {}) {
272
+ const output2 = deps.output ?? console;
273
+ if (wantsHelp(deps.args ?? [])) {
274
+ output2.log(LOGOUT_HELP_TEXT);
275
+ return 0;
276
+ }
277
+ const env = deps.env ?? process.env;
278
+ const configPath = deps.configPath ?? getDefaultProfileConfigPath();
279
+ if (!clearProfileAuthToken(configPath)) {
280
+ output2.log("Not logged in.");
281
+ return 0;
282
+ }
283
+ output2.log("Logged out.");
284
+ if (resolveAuthTokenFromEnv(env)) {
285
+ output2.log(
286
+ "Note: AUTH_TOKEN in the environment is unchanged and may still authenticate commands."
287
+ );
288
+ }
289
+ return 0;
290
+ }
291
+
292
+ export {
293
+ LOGIN_HELP_TEXT,
294
+ LOGOUT_HELP_TEXT,
295
+ WHOAMI_HELP_TEXT,
296
+ defaultOpenBrowser,
297
+ runLoginCommand,
298
+ runWhoamiCommand,
299
+ runLogoutCommand
300
+ };
@@ -0,0 +1,6 @@
1
+ // packages/cli/defaultServer.ts
2
+ var DEFAULT_NOLO_SERVER_URL = "https://nolo.chat";
3
+
4
+ export {
5
+ DEFAULT_NOLO_SERVER_URL
6
+ };
@@ -0,0 +1,91 @@
1
+ import {
2
+ dialogMessageKey
3
+ } from "./chunk-PN7AFLOK.js";
4
+ import {
5
+ asOptionalFiniteNumber
6
+ } from "./chunk-WWC7I6TA.js";
7
+ import {
8
+ asOptionalTrimmedString
9
+ } from "./chunk-G3SUCT4W.js";
10
+
11
+ // packages/chat/dialog/dialogAttachmentCleanup.ts
12
+ var FILE_CONTENT_RE = /(?:https?:\/\/[^/"'\s]+)?\/api\/v1\/db\/file\/content\/([^?#"'\s)]+)/g;
13
+ function extractFileContentIds(value) {
14
+ const ids = /* @__PURE__ */ new Set();
15
+ const visit = (input) => {
16
+ if (typeof input === "string") {
17
+ for (const match of input.matchAll(FILE_CONTENT_RE)) {
18
+ const fileId = decodeURIComponent(match[1] ?? "").trim();
19
+ if (fileId) ids.add(fileId);
20
+ }
21
+ return;
22
+ }
23
+ if (Array.isArray(input)) {
24
+ for (const item of input) visit(item);
25
+ return;
26
+ }
27
+ if (input && typeof input === "object") {
28
+ for (const item of Object.values(input)) visit(item);
29
+ }
30
+ };
31
+ visit(value);
32
+ return [...ids];
33
+ }
34
+ function messageDbKey(dialogId, message) {
35
+ const dbKey = asOptionalTrimmedString(message.dbKey);
36
+ if (dbKey) return dbKey;
37
+ const id = asOptionalTrimmedString(message.id);
38
+ if (id) return dialogMessageKey(dialogId, id);
39
+ return null;
40
+ }
41
+ function asText(value) {
42
+ return asOptionalTrimmedString(value) ?? null;
43
+ }
44
+ function buildDialogAttachmentPlan(args) {
45
+ const messageKeys = new Set(
46
+ args.messages.map((message) => messageDbKey(args.dialogId, message)).filter((key) => Boolean(key))
47
+ );
48
+ const referencedFileIds = [
49
+ ...new Set(args.messages.flatMap((message) => extractFileContentIds(message)))
50
+ ];
51
+ const candidates = referencedFileIds.map((fileId) => {
52
+ const metadata = args.metadataByFileId[fileId];
53
+ const ownerType = asText(metadata?.ownerType);
54
+ const ownerId = asText(metadata?.ownerId);
55
+ const ownerDbKey = asText(metadata?.ownerDbKey);
56
+ const fileDbKey = asText(metadata?.dbKey);
57
+ const source = asText(metadata?.source);
58
+ const ownedByDialog = ownerType === "dialog" && ownerId === args.dialogId;
59
+ const ownedByMessage = Boolean(ownerDbKey && messageKeys.has(ownerDbKey));
60
+ const userOwnedReferenced = args.includeUserOwnedReferenced === true && Boolean(args.ownerId) && ownerType === "user" && ownerId === args.ownerId;
61
+ const canDelete = Boolean(fileDbKey && (ownedByDialog || ownedByMessage || userOwnedReferenced));
62
+ return {
63
+ fileId,
64
+ fileDbKey,
65
+ size: asOptionalFiniteNumber(metadata?.size) ?? null,
66
+ ownerType,
67
+ ownerId,
68
+ ownerDbKey,
69
+ source,
70
+ status: canDelete ? "delete" : "retain",
71
+ reason: canDelete ? ownedByMessage ? "ownerDbKey matches a message in this dialog" : userOwnedReferenced ? "user-owned file is referenced by this dialog and explicit referenced-attachment deletion is enabled" : "ownerType/ownerId matches this dialog" : fileDbKey ? "file ownership is not exclusive to this dialog" : "file metadata not found"
72
+ };
73
+ });
74
+ const deleteCandidates = candidates.filter((candidate) => candidate.status === "delete");
75
+ const retainedCandidates = candidates.filter((candidate) => candidate.status === "retain");
76
+ return {
77
+ dialogId: args.dialogId,
78
+ messageCount: args.messages.length,
79
+ referencedFileIds,
80
+ candidates,
81
+ deleteCandidates,
82
+ retainedCandidates,
83
+ bytesToDelete: deleteCandidates.reduce((sum, candidate) => sum + (candidate.size ?? 0), 0),
84
+ metadataReadFailures: args.metadataReadFailures ?? []
85
+ };
86
+ }
87
+
88
+ export {
89
+ extractFileContentIds,
90
+ buildDialogAttachmentPlan
91
+ };
@@ -0,0 +1,50 @@
1
+ import {
2
+ compactWhitespace
3
+ } from "./chunk-DWLEOOGR.js";
4
+
5
+ // packages/chat/dialog/dialogTitle.ts
6
+ var GENERATED_DIALOG_TITLE_MAX_CHARS = 36;
7
+ var FALLBACK_DIALOG_TITLE_MAX_CHARS = 24;
8
+ var WRAPPING_QUOTES_RE = /^[`"'“”‘’「」『』《》]+|[`"'“”‘’「」『』《》]+$/gu;
9
+ var TRAILING_TITLE_PUNCTUATION_RE = /[。!?!?;;,,、::]+$/u;
10
+ var clip = (text, maxChars) => text.length <= maxChars ? text : `${text.slice(0, maxChars - 1).trimEnd()}\u2026`;
11
+ var toSingleLine = (value) => value.replace(/\r\n?/g, "\n").split("\n").map((line) => line.trim()).find(Boolean) ?? "";
12
+ var stripTitleFormatting = (value) => value.replace(/^(?:[-*#>]+\s*|\d+\.\s+)/, "").replace(WRAPPING_QUOTES_RE, "").replace(TRAILING_TITLE_PUNCTUATION_RE, "").trim();
13
+ var pickLeadingClause = (value) => {
14
+ const firstLine = toSingleLine(value);
15
+ if (!firstLine) return "";
16
+ const separatorIndexes = [firstLine.indexOf("\uFF1A"), firstLine.indexOf(":")].filter((index) => index > 0).sort((left, right) => left - right);
17
+ for (const index of separatorIndexes) {
18
+ const clause = firstLine.slice(0, index).trim();
19
+ if (clause.length >= 4) return clause;
20
+ }
21
+ return firstLine;
22
+ };
23
+ var normalizeDialogTitle = (rawTitle, maxChars = GENERATED_DIALOG_TITLE_MAX_CHARS) => {
24
+ if (typeof rawTitle !== "string") return "";
25
+ const normalized = stripTitleFormatting(
26
+ compactWhitespace(toSingleLine(rawTitle))
27
+ );
28
+ if (!normalized) return "";
29
+ return clip(normalized, maxChars);
30
+ };
31
+ var buildDialogFallbackTitleFromUserInput = (userInput, maxChars = FALLBACK_DIALOG_TITLE_MAX_CHARS) => {
32
+ if (typeof userInput !== "string") return "";
33
+ const candidate = pickLeadingClause(userInput);
34
+ return normalizeDialogTitle(candidate || userInput, maxChars);
35
+ };
36
+ var buildDialogFallbackTitleFromMessages = (messages) => {
37
+ for (const message of messages) {
38
+ if (message?.role !== "user") continue;
39
+ const title = buildDialogFallbackTitleFromUserInput(message?.content);
40
+ if (title) return title;
41
+ }
42
+ return "";
43
+ };
44
+ var resolveDialogTitle = (generatedTitle, fallbackTitle) => normalizeDialogTitle(generatedTitle) || fallbackTitle.trim();
45
+
46
+ export {
47
+ normalizeDialogTitle,
48
+ buildDialogFallbackTitleFromMessages,
49
+ resolveDialogTitle
50
+ };