nolo-cli 0.8.0-alpha.2 → 0.8.0-alpha.21

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 (188) hide show
  1. package/README.md +1 -1
  2. package/_executeModel-42U3VOVZ.js +205 -0
  3. package/action-TLI3V62L.js +28 -0
  4. package/addContentAction-57RSIIMR.js +26 -0
  5. package/addDialogAgentAction-G3VWEA6E.js +68 -0
  6. package/agentDeleteCommand-5DD2IM3J.js +327 -0
  7. package/agentEmailCommands-6FACJBU4.js +628 -0
  8. package/agentListCommands-I6KZYCIG.js +223 -0
  9. package/agentMachineCommands-VKLIGMZA.js +425 -0
  10. package/agentPullCommand-O2MTUAFR.js +122 -0
  11. package/agentRecordCommands-7TZICYDT.js +96 -0
  12. package/agentRunCommand-L4OM23KV.js +114 -0
  13. package/agentRunControl-K4VKNEHF.js +57 -0
  14. package/agentRuntimeLocal-ZYEIPTY4.js +104 -0
  15. package/agentSlice-BX7GXSNO.js +42 -0
  16. package/authCommand-EB5JSOX5.js +581 -0
  17. package/authCommands-XPEHTKSM.js +35 -0
  18. package/chunk-25LCXTML.js +175 -0
  19. package/chunk-2ECQG4YX.js +22296 -0
  20. package/chunk-2FTTDCD4.js +675 -0
  21. package/chunk-2JCXITPK.js +1078 -0
  22. package/chunk-3ASDTTEI.js +1774 -0
  23. package/chunk-3EUW3WEO.js +8 -0
  24. package/chunk-3LY4F7SV.js +9293 -0
  25. package/chunk-4CQLVGRV.js +50 -0
  26. package/chunk-4IJYA27C.js +342 -0
  27. package/chunk-4O3CARJ4.js +231 -0
  28. package/chunk-4QEWT7KD.js +933 -0
  29. package/chunk-4SN6J65J.js +38 -0
  30. package/chunk-4VNS5WPM.js +42 -0
  31. package/chunk-4XENYTF5.js +222 -0
  32. package/chunk-4ZDM73SD.js +34 -0
  33. package/chunk-5CS33IBL.js +301 -0
  34. package/chunk-5EFXE3O7.js +138 -0
  35. package/chunk-5KLGBAAR.js +386 -0
  36. package/chunk-5MIDPSSK.js +206 -0
  37. package/chunk-5MMAK75Q.js +15 -0
  38. package/chunk-63W5N6P3.js +150 -0
  39. package/chunk-6HYVJV7B.js +102 -0
  40. package/chunk-6KHNO3SK.js +1948 -0
  41. package/chunk-6WD3OOJS.js +20 -0
  42. package/chunk-7DAJ4AI4.js +191 -0
  43. package/chunk-7GNGZRLZ.js +1939 -0
  44. package/chunk-7KCUSYT2.js +354 -0
  45. package/chunk-7U44LYTR.js +238 -0
  46. package/chunk-AFON4QUU.js +112 -0
  47. package/chunk-AGFH73SK.js +239 -0
  48. package/chunk-AL2KDGR2.js +27339 -0
  49. package/chunk-AS4PVWA4.js +221 -0
  50. package/chunk-ATNTHIZI.js +13 -0
  51. package/chunk-AVMKZHBC.js +85 -0
  52. package/chunk-AZPCASRE.js +36 -0
  53. package/chunk-BBYVOSU2.js +792 -0
  54. package/chunk-C3RUNRHT.js +51 -0
  55. package/chunk-C4FTUXVF.js +146 -0
  56. package/chunk-CF2WZF4N.js +134 -0
  57. package/chunk-CF7PE763.js +10 -0
  58. package/chunk-CKOJQDKR.js +198 -0
  59. package/chunk-CMKUBIGW.js +1550 -0
  60. package/chunk-CWMSB67P.js +34 -0
  61. package/chunk-DCOA4QSN.js +105 -0
  62. package/chunk-DFFIZ25G.js +30 -0
  63. package/chunk-DSZUWUYB.js +478 -0
  64. package/chunk-DWLEOOGR.js +8 -0
  65. package/chunk-DZ3XJVET.js +231 -0
  66. package/chunk-EHLHSX7R.js +1433 -0
  67. package/chunk-ENOG22KJ.js +939 -0
  68. package/chunk-FSO5B7GH.js +171 -0
  69. package/chunk-FVYY6MCS.js +1447 -0
  70. package/chunk-G3SUCT4W.js +8 -0
  71. package/chunk-GAKEBQD6.js +30 -0
  72. package/chunk-GBRG75BQ.js +86 -0
  73. package/chunk-GU3PEVGZ.js +4723 -0
  74. package/chunk-H33743XH.js +25 -0
  75. package/chunk-HNMXYYJR.js +12 -0
  76. package/chunk-HNW7IJSK.js +71 -0
  77. package/chunk-I42VC5KR.js +15 -0
  78. package/chunk-I6XMPTMR.js +113 -0
  79. package/chunk-IDZTNRP2.js +85 -0
  80. package/chunk-ISNCLGUZ.js +146 -0
  81. package/chunk-IWX4UW2E.js +548 -0
  82. package/chunk-JBTJAPUF.js +35 -0
  83. package/chunk-JEXVIMYZ.js +55 -0
  84. package/chunk-JRKKFRAV.js +537 -0
  85. package/chunk-JZPBVBIY.js +94 -0
  86. package/chunk-KKY4B2Q2.js +21 -0
  87. package/chunk-KQHGZWSV.js +63 -0
  88. package/chunk-KUG52IAP.js +8 -0
  89. package/chunk-KX6YBIHG.js +8 -0
  90. package/chunk-LCBAMY2M.js +60 -0
  91. package/chunk-LM6IYQ3F.js +16 -0
  92. package/chunk-LTRXGFMS.js +83 -0
  93. package/chunk-M76ECQRD.js +13658 -0
  94. package/chunk-MRC4Q34M.js +188 -0
  95. package/chunk-MTU75CZ2.js +91 -0
  96. package/chunk-N54XAP77.js +19 -0
  97. package/chunk-O2ZNTTET.js +3272 -0
  98. package/chunk-O4BU24WZ.js +3212 -0
  99. package/chunk-OLZBQWZU.js +6 -0
  100. package/chunk-OOSFSFMA.js +271 -0
  101. package/chunk-OPZYGHUC.js +89 -0
  102. package/chunk-OWOHNGCN.js +50 -0
  103. package/chunk-P3PKED2I.js +962 -0
  104. package/chunk-QSJ3HFEF.js +8 -0
  105. package/chunk-RCSJFQPB.js +9036 -0
  106. package/chunk-RL776AGR.js +190 -0
  107. package/chunk-ROWQEJRP.js +139 -0
  108. package/chunk-S7Z2HMCN.js +25 -0
  109. package/chunk-SDJDLO5W.js +628 -0
  110. package/chunk-SOTZ6RDN.js +69 -0
  111. package/chunk-TILFE6LV.js +381 -0
  112. package/chunk-U4TRT5V4.js +246 -0
  113. package/chunk-U6VC4MU4.js +8 -0
  114. package/chunk-UAD2WT54.js +64 -0
  115. package/chunk-UB6SN4NJ.js +421 -0
  116. package/chunk-URUUZLPA.js +807 -0
  117. package/chunk-UTLZINAP.js +3066 -0
  118. package/chunk-VC6OZXO5.js +298 -0
  119. package/chunk-VF4K2QE6.js +21 -0
  120. package/chunk-VHBWHNVT.js +59 -0
  121. package/chunk-VIDPVFP3.js +20 -0
  122. package/chunk-VP4WJWKW.js +8882 -0
  123. package/chunk-VUW5FBDB.js +573 -0
  124. package/chunk-VVX233PH.js +482 -0
  125. package/chunk-VX3SXJ3N.js +2052 -0
  126. package/chunk-W4NVOSFF.js +37 -0
  127. package/chunk-WWC7I6TA.js +8 -0
  128. package/chunk-WZSRQNQG.js +2587 -0
  129. package/chunk-XBUBEFNX.js +34 -0
  130. package/chunk-XENYHRUE.js +104 -0
  131. package/chunk-Y5GCAMGP.js +9 -0
  132. package/chunk-YPRZSPF3.js +148 -0
  133. package/chunk-Z4NR32XR.js +50 -0
  134. package/chunk-ZNFJWEN4.js +56 -0
  135. package/cliExecutor-K3F7DMRO.js +36 -0
  136. package/clipboardy-BVE3LVEH.js +12001 -0
  137. package/createAgentAutomationAction-RJF3N2QY.js +866 -0
  138. package/createDialogAction-DRSPS6CE.js +55 -0
  139. package/createPageAction-6B2WMNO3.js +172 -0
  140. package/db-HCJ5PRB5.js +271 -0
  141. package/dbSlice-Q3TM2FJV.js +60 -0
  142. package/deleteFile-OW53A6BX.js +41 -0
  143. package/dialogCommands-4IX4XIZE.js +63 -0
  144. package/dialogSlice-3M7KX2TX.js +148 -0
  145. package/docCreateCommands-SIL3NPGT.js +220 -0
  146. package/docDeleteCommands-7IOMLUS4.js +181 -0
  147. package/docReadCommands-FNFXUA5L.js +134 -0
  148. package/docStore-SV7E34D4.js +98 -0
  149. package/docUpdateCommands-X2HNDVUC.js +318 -0
  150. package/fetchMessages-KTNM7QAR.js +17 -0
  151. package/getPricing-3E6UNPKL.js +30 -0
  152. package/handleSendMessageAction-JYETO5RZ.js +185 -0
  153. package/index.js +188 -112958
  154. package/lib-FYYBQIXS.js +19839 -0
  155. package/localDialogRead-2VRI24F4.js +26 -0
  156. package/localFirstLog-DHNOY2NA.js +19 -0
  157. package/localRuntimeAuthority-TEGCOWX4.js +471 -0
  158. package/localRuntimeDb-LGDF6FQP.js +12 -0
  159. package/machineCommands-RIO3RP5Q.js +781 -0
  160. package/machineInfo-M6KB6HZN.js +10 -0
  161. package/machineWsRunDispatch-W7UYLGB5.js +112 -0
  162. package/memoryCommands-O4MIPIWQ.js +476 -0
  163. package/models-4OPOOLFS.js +9 -0
  164. package/offlineMarxistsAgentCommand-BCPJITJL.js +242 -0
  165. package/package.json +4 -24
  166. package/read-GW7ZEI23.js +17 -0
  167. package/readDocTool-HUFU6OCT.js +16 -0
  168. package/readlineWorkspace-27JR7WPW.js +5682 -0
  169. package/removeDialogAgentAction-CXKR4NJI.js +73 -0
  170. package/runAgentClientLoop-HZFAPJHS.js +293 -0
  171. package/runtimeDoctorCommands-LRHLPDRC.js +289 -0
  172. package/setDialogExtraReferencesAction-6RKUSXHX.js +60 -0
  173. package/setPrimaryDialogAgentAction-T3UTBEFG.js +80 -0
  174. package/settingSlice-IVKXJXMG.js +199 -0
  175. package/skillDiscovery-UGSQGX2U.js +16 -0
  176. package/skillSummaryMarker-42HKSXYY.js +9 -0
  177. package/slateToRenderMarkdown-Y5IYN73U.js +7 -0
  178. package/slateUtils-2M7MUTWX.js +19 -0
  179. package/spaceCommands-E7VOF4LO.js +450 -0
  180. package/spaceSlice-TSVROA5U.js +149 -0
  181. package/streamAgentChatTurn-3C5RQZJF.js +4510 -0
  182. package/tableCommands-O7O2LBEG.js +1286 -0
  183. package/toolApiClient-QI3YBNWB.js +26 -0
  184. package/tools-EQDEKR6N.js +87 -0
  185. package/tuiSummaryLlmCaller-RV3THLZF.js +78 -0
  186. package/understanding-3CUQQ6SV.js +271 -0
  187. package/updateCommands-VOSPKXFF.js +31 -0
  188. package/updateDialogTitleAction-3XV7VWSZ.js +188 -0
@@ -0,0 +1,190 @@
1
+ import {
2
+ deleteDbRecord,
3
+ queryUserRecords,
4
+ readDbRecord
5
+ } from "./chunk-SDJDLO5W.js";
6
+ import {
7
+ mergeAndDedupUserData
8
+ } from "./chunk-KQHGZWSV.js";
9
+ import {
10
+ toErrorMessage
11
+ } from "./chunk-HNMXYYJR.js";
12
+ import {
13
+ isTombstoneRecord
14
+ } from "./chunk-GBRG75BQ.js";
15
+
16
+ // packages/cli/globalRecordOperations.ts
17
+ async function listUserRecordsFromServers(args) {
18
+ const remoteResults = [];
19
+ const failures = [];
20
+ const promises = args.serverUrls.map(async (serverUrl) => {
21
+ try {
22
+ const records = await queryUserRecords({
23
+ authToken: args.authToken,
24
+ fallbackFetchImpl: args.fallbackFetchImpl,
25
+ fetchImpl: args.fetchImpl,
26
+ includeDeleted: true,
27
+ limit: args.limit,
28
+ serverUrl,
29
+ summary: args.summary,
30
+ type: args.type,
31
+ userId: args.userId
32
+ });
33
+ return { ok: true, serverUrl, records };
34
+ } catch (error) {
35
+ return {
36
+ ok: false,
37
+ serverUrl,
38
+ error: toErrorMessage(error)
39
+ };
40
+ }
41
+ });
42
+ const results = await Promise.all(promises);
43
+ for (const res of results) {
44
+ if (res.ok) {
45
+ remoteResults.push({
46
+ data: {
47
+ data: res.records.map((record) => ({
48
+ ...record,
49
+ serverOrigin: typeof record?.serverOrigin === "string" && record.serverOrigin.trim() ? record.serverOrigin : res.serverUrl
50
+ }))
51
+ }
52
+ });
53
+ } else {
54
+ failures.push({
55
+ serverUrl: res.serverUrl,
56
+ error: res.error
57
+ });
58
+ }
59
+ }
60
+ if (remoteResults.length === 0 && failures.length > 0) {
61
+ const label = args.label ?? "record query";
62
+ throw new Error(
63
+ `${label} failed on all candidate servers: ${failures.map((failure) => `${failure.serverUrl}: ${failure.error}`).join("; ")}`
64
+ );
65
+ }
66
+ const merged = mergeAndDedupUserData([], remoteResults, { includeDeleted: true });
67
+ return {
68
+ records: merged.filter((record) => !isTombstoneRecord(record)),
69
+ failures
70
+ };
71
+ }
72
+ async function readDbRecordFromServers(args) {
73
+ const failures = [];
74
+ for (const serverUrl of args.serverUrls) {
75
+ try {
76
+ const record = await readDbRecord({
77
+ authToken: args.authToken,
78
+ dbKey: args.dbKey,
79
+ fallbackFetchImpl: args.fallbackFetchImpl,
80
+ fetchImpl: args.fetchImpl,
81
+ includeDeleted: args.includeDeleted,
82
+ serverUrl
83
+ });
84
+ return { record, serverUrl, failures };
85
+ } catch (error) {
86
+ failures.push({
87
+ serverUrl,
88
+ error: toErrorMessage(error)
89
+ });
90
+ }
91
+ }
92
+ const label = args.label ?? `record ${args.dbKey}`;
93
+ throw new Error(
94
+ `${label} is unreadable on all candidate servers: ${failures.map((failure) => `${failure.serverUrl}: ${failure.error}`).join("; ")}`
95
+ );
96
+ }
97
+ async function readDbRecordVersionsFromServers(args) {
98
+ const records = [];
99
+ const failures = [];
100
+ const promises = args.serverUrls.map(async (serverUrl) => {
101
+ try {
102
+ const record = await readDbRecord({
103
+ authToken: args.authToken,
104
+ dbKey: args.dbKey,
105
+ fallbackFetchImpl: args.fallbackFetchImpl,
106
+ fetchImpl: args.fetchImpl,
107
+ includeDeleted: true,
108
+ serverUrl
109
+ });
110
+ return { ok: true, serverUrl, record };
111
+ } catch (error) {
112
+ return {
113
+ ok: false,
114
+ serverUrl,
115
+ error: toErrorMessage(error)
116
+ };
117
+ }
118
+ });
119
+ const results = await Promise.all(promises);
120
+ for (const res of results) {
121
+ if (res.ok) {
122
+ const record = res.record;
123
+ records.push({
124
+ ...record,
125
+ dbKey: typeof record?.dbKey === "string" && record.dbKey.trim() ? record.dbKey : args.dbKey,
126
+ serverOrigin: typeof record?.serverOrigin === "string" && record.serverOrigin.trim() ? record.serverOrigin : res.serverUrl
127
+ });
128
+ } else {
129
+ failures.push({
130
+ serverUrl: res.serverUrl,
131
+ error: res.error
132
+ });
133
+ }
134
+ }
135
+ return { records, failures };
136
+ }
137
+ async function readLiveDbRecordAfterTombstoneMerge(args) {
138
+ const result = await readDbRecordVersionsFromServers(args);
139
+ const merged = mergeAndDedupUserData(
140
+ [],
141
+ [{ data: { data: result.records } }],
142
+ { includeDeleted: true }
143
+ );
144
+ const record = merged.find((item) => item?.dbKey === args.dbKey);
145
+ if (record && !isTombstoneRecord(record)) {
146
+ return {
147
+ record,
148
+ serverUrl: typeof record.serverOrigin === "string" ? record.serverOrigin : "",
149
+ failures: result.failures
150
+ };
151
+ }
152
+ const label = args.label ?? `record ${args.dbKey}`;
153
+ const failureText = result.failures.length ? ` Failures: ${result.failures.map((failure) => `${failure.serverUrl}: ${failure.error}`).join("; ")}` : "";
154
+ throw new Error(`${label} is deleted or unreadable after global tombstone merge.${failureText}`);
155
+ }
156
+ async function deleteDbRecordOnServers(args) {
157
+ return deleteDbRecordOnTargets({
158
+ ...args,
159
+ targets: args.serverUrls.map((serverUrl) => ({ serverUrl }))
160
+ });
161
+ }
162
+ async function deleteDbRecordOnTargets(args) {
163
+ const promises = args.targets.map(async (target) => {
164
+ try {
165
+ const result = await deleteDbRecord({
166
+ authToken: target.authToken ?? args.authToken,
167
+ dbKey: args.dbKey,
168
+ deleteOptions: args.deleteOptions,
169
+ fallbackFetchImpl: args.fallbackFetchImpl,
170
+ fetchImpl: args.fetchImpl,
171
+ serverUrl: target.serverUrl
172
+ });
173
+ return { serverUrl: target.serverUrl, ok: true, result };
174
+ } catch (error) {
175
+ return {
176
+ serverUrl: target.serverUrl,
177
+ ok: false,
178
+ error: toErrorMessage(error)
179
+ };
180
+ }
181
+ });
182
+ return Promise.all(promises);
183
+ }
184
+
185
+ export {
186
+ listUserRecordsFromServers,
187
+ readDbRecordFromServers,
188
+ readLiveDbRecordAfterTombstoneMerge,
189
+ deleteDbRecordOnServers
190
+ };
@@ -0,0 +1,139 @@
1
+ // packages/cli/client/profileConfig.ts
2
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
+ import { dirname, join } from "node:path";
4
+ import { homedir } from "node:os";
5
+
6
+ // packages/core/noloServerUrl.ts
7
+ function isNoloChatHostname(hostname) {
8
+ if (typeof hostname !== "string") return false;
9
+ const host = hostname.trim().toLowerCase();
10
+ if (!host) return false;
11
+ return host === "nolo.chat" || host.endsWith(".nolo.chat");
12
+ }
13
+ function canonicalizeNoloServerUrl(value) {
14
+ const normalized = value.trim().replace(/\/+$/, "");
15
+ if (!normalized) return normalized;
16
+ try {
17
+ const url = new URL(normalized);
18
+ if (url.protocol === "http:" && isNoloChatHostname(url.hostname)) {
19
+ url.protocol = "https:";
20
+ return url.toString().replace(/\/+$/, "");
21
+ }
22
+ } catch {
23
+ return normalized;
24
+ }
25
+ return normalized;
26
+ }
27
+
28
+ // packages/cli/client/profileConfig.ts
29
+ var normalizeProfileServerUrl = canonicalizeNoloServerUrl;
30
+ function getDefaultProfileConfigPath() {
31
+ return join(homedir(), ".nolo", "config.json");
32
+ }
33
+ function loadProfileConfig(path = getDefaultProfileConfigPath()) {
34
+ if (!existsSync(path)) return null;
35
+ const raw = readFileSync(path, "utf8");
36
+ const parsed = JSON.parse(raw);
37
+ if (!parsed.currentProfile || !parsed.profiles?.[parsed.currentProfile]) return null;
38
+ for (const profile of Object.values(parsed.profiles)) {
39
+ if (!profile?.serverUrl) continue;
40
+ profile.serverUrl = normalizeProfileServerUrl(profile.serverUrl);
41
+ }
42
+ return parsed;
43
+ }
44
+ function clearProfileAuthToken(path = getDefaultProfileConfigPath()) {
45
+ const config = loadProfileConfig(path);
46
+ if (!config) return false;
47
+ const profile = config.profiles[config.currentProfile];
48
+ if (!profile?.authToken?.trim()) return false;
49
+ delete profile.authToken;
50
+ mkdirSync(dirname(path), { recursive: true });
51
+ writeFileSync(path, `${JSON.stringify(config, null, 2)}
52
+ `, "utf8");
53
+ return true;
54
+ }
55
+ function saveDefaultProfile(path, profile) {
56
+ const existing = loadProfileConfig(path);
57
+ const mergedDefault = {
58
+ ...existing?.profiles?.default ?? {},
59
+ serverUrl: normalizeProfileServerUrl(profile.serverUrl),
60
+ authToken: profile.authToken.trim()
61
+ };
62
+ const config = {
63
+ currentProfile: "default",
64
+ profiles: {
65
+ ...existing?.profiles ?? {},
66
+ default: mergedDefault
67
+ }
68
+ };
69
+ mkdirSync(dirname(path), { recursive: true });
70
+ writeFileSync(path, `${JSON.stringify(config, null, 2)}
71
+ `, "utf8");
72
+ return config;
73
+ }
74
+ function buildEnvFromProfile(config) {
75
+ if (!config) return {};
76
+ const profile = config.profiles[config.currentProfile];
77
+ if (!profile) return {};
78
+ return {
79
+ NOLO_PROFILE: config.currentProfile,
80
+ NOLO_SERVER: profile.serverUrl,
81
+ ...profile.authToken?.trim() ? { AUTH_TOKEN: profile.authToken.trim() } : {},
82
+ ...profile.agentKey ? { NOLO_AGENT: profile.agentKey } : {},
83
+ ...profile.agentName ? { NOLO_AGENT_NAME: profile.agentName } : {},
84
+ ...profile.locale ? { NOLO_LANG: profile.locale } : {}
85
+ };
86
+ }
87
+ function buildCliRuntimeEnv(processEnv, config) {
88
+ const profileEnv = buildEnvFromProfile(config);
89
+ const explicitAuthToken = processEnv.AUTH_TOKEN || processEnv.AUTH;
90
+ const explicitServerUrl = processEnv.NOLO_SERVER || processEnv.NOLO_SERVER_URL || processEnv.BASE_URL;
91
+ return {
92
+ ...processEnv,
93
+ ...profileEnv,
94
+ ...explicitAuthToken ? { AUTH_TOKEN: explicitAuthToken } : {},
95
+ ...explicitServerUrl ? {
96
+ NOLO_SERVER: explicitServerUrl,
97
+ BASE_URL: explicitServerUrl
98
+ } : {}
99
+ };
100
+ }
101
+ function getCurrentProfile(config) {
102
+ if (!config) return null;
103
+ return config.profiles[config.currentProfile] ?? null;
104
+ }
105
+ function saveProfileLocale(locale, path = getDefaultProfileConfigPath()) {
106
+ const config = loadProfileConfig(path);
107
+ if (!config) return null;
108
+ const profile = config.profiles[config.currentProfile];
109
+ if (!profile) return null;
110
+ profile.locale = locale;
111
+ mkdirSync(dirname(path), { recursive: true });
112
+ writeFileSync(path, `${JSON.stringify(config, null, 2)}
113
+ `, "utf8");
114
+ return config;
115
+ }
116
+ function saveProfileAgentSelection(selection, path = getDefaultProfileConfigPath()) {
117
+ const config = loadProfileConfig(path);
118
+ if (!config) return null;
119
+ const profile = config.profiles[config.currentProfile];
120
+ if (!profile) return null;
121
+ profile.agentKey = selection.agentKey.trim();
122
+ profile.agentName = selection.agentName.trim();
123
+ mkdirSync(dirname(path), { recursive: true });
124
+ writeFileSync(path, `${JSON.stringify(config, null, 2)}
125
+ `, "utf8");
126
+ return config;
127
+ }
128
+
129
+ export {
130
+ getDefaultProfileConfigPath,
131
+ loadProfileConfig,
132
+ clearProfileAuthToken,
133
+ saveDefaultProfile,
134
+ buildEnvFromProfile,
135
+ buildCliRuntimeEnv,
136
+ getCurrentProfile,
137
+ saveProfileLocale,
138
+ saveProfileAgentSelection
139
+ };
@@ -0,0 +1,25 @@
1
+ // packages/cli/secretScan.ts
2
+ var SECRET_PATTERNS = [
3
+ { label: "password", pattern: /\bpassword\s*[:=]\s*["']?[^"',\s#]{8,}/i },
4
+ { label: "psk", pattern: /\bpsk\s*[:=]\s*["']?[^"',\s#]{8,}/i },
5
+ { label: "api key", pattern: /\b(api[_-]?key|apikey)\s*[:=]\s*["']?[^"',\s#]{12,}/i },
6
+ { label: "token", pattern: /\b(token|secret)\s*[:=]\s*["']?[^"',\s#]{12,}/i },
7
+ { label: "private key", pattern: /-----BEGIN [A-Z ]*PRIVATE KEY-----/ }
8
+ ];
9
+ function findPotentialSecrets(text) {
10
+ return text.split(/\r?\n/).flatMap(
11
+ (line, index) => SECRET_PATTERNS.filter(({ pattern }) => pattern.test(line)).map(({ label }) => ({
12
+ label,
13
+ line: index + 1,
14
+ preview: line.length > 120 ? `${line.slice(0, 117)}...` : line
15
+ }))
16
+ );
17
+ }
18
+ function formatSecretFindings(findings) {
19
+ return findings.map((finding) => ` line ${finding.line} (${finding.label}): ${finding.preview}`).join("\n");
20
+ }
21
+
22
+ export {
23
+ findPotentialSecrets,
24
+ formatSecretFindings
25
+ };