@gurulu/cli 0.4.6 → 1.0.0

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 (180) hide show
  1. package/LICENSE +92 -0
  2. package/README.md +35 -106
  3. package/dist/bin.d.ts +3 -0
  4. package/dist/bin.d.ts.map +1 -0
  5. package/dist/bin.js +25410 -0
  6. package/dist/commands/auth.d.ts +23 -20
  7. package/dist/commands/auth.d.ts.map +1 -0
  8. package/dist/commands/doctor.d.ts +20 -6
  9. package/dist/commands/doctor.d.ts.map +1 -0
  10. package/dist/commands/init.d.ts +25 -11
  11. package/dist/commands/init.d.ts.map +1 -0
  12. package/dist/commands/pull.d.ts +13 -0
  13. package/dist/commands/pull.d.ts.map +1 -0
  14. package/dist/commands/push.d.ts +40 -0
  15. package/dist/commands/push.d.ts.map +1 -0
  16. package/dist/commands/validate.d.ts +36 -0
  17. package/dist/commands/validate.d.ts.map +1 -0
  18. package/dist/index.d.ts +4 -1
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +24985 -853
  21. package/dist/lib/api.d.ts +139 -0
  22. package/dist/lib/api.d.ts.map +1 -0
  23. package/dist/lib/codegen.d.ts +4 -0
  24. package/dist/lib/codegen.d.ts.map +1 -0
  25. package/dist/lib/config.d.ts +43 -0
  26. package/dist/lib/config.d.ts.map +1 -0
  27. package/package.json +40 -20
  28. package/bin/gurulu.js +0 -2
  29. package/dist/api-client.d.ts +0 -33
  30. package/dist/api-client.js +0 -175
  31. package/dist/commands/add-server.d.ts +0 -9
  32. package/dist/commands/add-server.js +0 -162
  33. package/dist/commands/alerts.d.ts +0 -27
  34. package/dist/commands/alerts.js +0 -309
  35. package/dist/commands/api-keys.d.ts +0 -20
  36. package/dist/commands/api-keys.js +0 -130
  37. package/dist/commands/attribution.d.ts +0 -22
  38. package/dist/commands/attribution.js +0 -111
  39. package/dist/commands/audiences.d.ts +0 -23
  40. package/dist/commands/audiences.js +0 -243
  41. package/dist/commands/audit.d.ts +0 -20
  42. package/dist/commands/audit.js +0 -130
  43. package/dist/commands/auth.js +0 -249
  44. package/dist/commands/chat.d.ts +0 -18
  45. package/dist/commands/chat.js +0 -117
  46. package/dist/commands/config.d.ts +0 -10
  47. package/dist/commands/config.js +0 -92
  48. package/dist/commands/consent.d.ts +0 -27
  49. package/dist/commands/consent.js +0 -233
  50. package/dist/commands/conversion-paths.d.ts +0 -19
  51. package/dist/commands/conversion-paths.js +0 -55
  52. package/dist/commands/db.d.ts +0 -25
  53. package/dist/commands/db.js +0 -330
  54. package/dist/commands/destinations.d.ts +0 -20
  55. package/dist/commands/destinations.js +0 -191
  56. package/dist/commands/doctor.js +0 -360
  57. package/dist/commands/errors.d.ts +0 -27
  58. package/dist/commands/errors.js +0 -121
  59. package/dist/commands/events.d.ts +0 -33
  60. package/dist/commands/events.js +0 -349
  61. package/dist/commands/experiments.d.ts +0 -22
  62. package/dist/commands/experiments.js +0 -264
  63. package/dist/commands/funnels.d.ts +0 -17
  64. package/dist/commands/funnels.js +0 -203
  65. package/dist/commands/goals.d.ts +0 -18
  66. package/dist/commands/goals.js +0 -214
  67. package/dist/commands/heatmap.d.ts +0 -27
  68. package/dist/commands/heatmap.js +0 -112
  69. package/dist/commands/identity.d.ts +0 -29
  70. package/dist/commands/identity.js +0 -328
  71. package/dist/commands/init.js +0 -215
  72. package/dist/commands/insights.d.ts +0 -10
  73. package/dist/commands/insights.js +0 -65
  74. package/dist/commands/install.d.ts +0 -259
  75. package/dist/commands/install.js +0 -1590
  76. package/dist/commands/login.d.ts +0 -20
  77. package/dist/commands/login.js +0 -170
  78. package/dist/commands/logout.d.ts +0 -10
  79. package/dist/commands/logout.js +0 -41
  80. package/dist/commands/playground.d.ts +0 -11
  81. package/dist/commands/playground.js +0 -47
  82. package/dist/commands/releases.d.ts +0 -17
  83. package/dist/commands/releases.js +0 -54
  84. package/dist/commands/replay.d.ts +0 -18
  85. package/dist/commands/replay.js +0 -64
  86. package/dist/commands/secrets.d.ts +0 -19
  87. package/dist/commands/secrets.js +0 -145
  88. package/dist/commands/sites.d.ts +0 -18
  89. package/dist/commands/sites.js +0 -139
  90. package/dist/commands/skad.d.ts +0 -18
  91. package/dist/commands/skad.js +0 -53
  92. package/dist/commands/sourcemap.d.ts +0 -33
  93. package/dist/commands/sourcemap.js +0 -204
  94. package/dist/commands/status.d.ts +0 -7
  95. package/dist/commands/status.js +0 -136
  96. package/dist/commands/upgrade.d.ts +0 -21
  97. package/dist/commands/upgrade.js +0 -183
  98. package/dist/commands/warehouse.d.ts +0 -20
  99. package/dist/commands/warehouse.js +0 -65
  100. package/dist/commands/warehouses.d.ts +0 -17
  101. package/dist/commands/warehouses.js +0 -182
  102. package/dist/commands/watch.d.ts +0 -45
  103. package/dist/commands/watch.js +0 -258
  104. package/dist/commands/whoami.d.ts +0 -9
  105. package/dist/commands/whoami.js +0 -50
  106. package/dist/config.d.ts +0 -75
  107. package/dist/config.js +0 -329
  108. package/dist/frameworks/detect.d.ts +0 -8
  109. package/dist/frameworks/detect.js +0 -444
  110. package/dist/install-intent-proposal.d.ts +0 -99
  111. package/dist/install-intent-proposal.js +0 -202
  112. package/dist/utils/api.d.ts +0 -20
  113. package/dist/utils/api.js +0 -47
  114. package/dist/utils/config.d.ts +0 -13
  115. package/dist/utils/config.js +0 -30
  116. package/dist/utils/confirm.d.ts +0 -17
  117. package/dist/utils/confirm.js +0 -40
  118. package/dist/utils/dry-run.d.ts +0 -20
  119. package/dist/utils/dry-run.js +0 -67
  120. package/dist/utils/from-file.d.ts +0 -9
  121. package/dist/utils/from-file.js +0 -72
  122. package/dist/utils/redact.d.ts +0 -14
  123. package/dist/utils/redact.js +0 -48
  124. package/dist/utils/ui.d.ts +0 -14
  125. package/dist/utils/ui.js +0 -59
  126. package/scripts/.gitkeep +0 -0
  127. package/scripts/README-gurulu-agentic-install.md +0 -114
  128. package/scripts/README-gurulu-scan.md +0 -98
  129. package/scripts/audit-cli-scopes.mjs +0 -204
  130. package/scripts/backfill-tenant-id.mjs +0 -172
  131. package/scripts/backfill-tenant-links.ts +0 -252
  132. package/scripts/backup-clickhouse.sh +0 -27
  133. package/scripts/backup-postgres.sh +0 -19
  134. package/scripts/bootstrap-runtime-schema.mjs +0 -87
  135. package/scripts/bootstrap-stripe.mjs +0 -158
  136. package/scripts/gurulu-agentic-install.lib.cjs +0 -762
  137. package/scripts/gurulu-agentic-install.mjs +0 -623
  138. package/scripts/gurulu-scan.lib.cjs +0 -1509
  139. package/scripts/gurulu-scan.mjs +0 -91
  140. package/scripts/gurulu-verify-install.lib.cjs +0 -334
  141. package/scripts/gurulu-verify-install.mjs +0 -59
  142. package/scripts/init-ssl.sh +0 -26
  143. package/scripts/migrate-flow-graph-enums.sh +0 -86
  144. package/scripts/monitor-disk.sh +0 -24
  145. package/scripts/patches/astro.patch.cjs +0 -74
  146. package/scripts/patches/auto-instrument/ast-helper.cjs +0 -480
  147. package/scripts/patches/auto-instrument/astro.cjs +0 -273
  148. package/scripts/patches/auto-instrument/express.cjs +0 -383
  149. package/scripts/patches/auto-instrument/fastify.cjs +0 -262
  150. package/scripts/patches/auto-instrument/hono.cjs +0 -392
  151. package/scripts/patches/auto-instrument/index.cjs +0 -80
  152. package/scripts/patches/auto-instrument/nestjs.cjs +0 -286
  153. package/scripts/patches/auto-instrument/nextjs-app-router.cjs +0 -345
  154. package/scripts/patches/auto-instrument/nextjs-pages.cjs +0 -361
  155. package/scripts/patches/auto-instrument/remix.cjs +0 -168
  156. package/scripts/patches/auto-instrument/sdk-helper-map.cjs +0 -241
  157. package/scripts/patches/auto-instrument/singleton-helper.cjs +0 -193
  158. package/scripts/patches/auto-instrument/sveltekit.cjs +0 -161
  159. package/scripts/patches/auto-instrument/vite-react.cjs +0 -37
  160. package/scripts/patches/auto-instrument/vue.cjs +0 -196
  161. package/scripts/patches/express.patch.cjs +0 -99
  162. package/scripts/patches/fastify.patch.cjs +0 -108
  163. package/scripts/patches/index.cjs +0 -300
  164. package/scripts/patches/nestjs.patch.cjs +0 -112
  165. package/scripts/patches/nextjs-app-router.patch.cjs +0 -97
  166. package/scripts/patches/nextjs-pages.patch.cjs +0 -97
  167. package/scripts/patches/remix.patch.cjs +0 -75
  168. package/scripts/patches/sveltekit.patch.cjs +0 -72
  169. package/scripts/patches/vite-react.patch.cjs +0 -73
  170. package/scripts/patches/vue.patch.cjs +0 -82
  171. package/scripts/renew-ssl.sh +0 -14
  172. package/scripts/resolve-migration.sh +0 -23
  173. package/scripts/seed-cli-dev-keys.mjs +0 -130
  174. package/scripts/seed-test-data.mjs +0 -391
  175. package/scripts/spike-browserless.ts +0 -65
  176. package/scripts/tenant-pivot-consistency-check.mjs +0 -205
  177. package/scripts/tenant-pivot-phase-3-cleanup.lib.cjs +0 -258
  178. package/scripts/tenant-pivot-phase-3-cleanup.mjs +0 -98
  179. package/scripts/test-identity-resolution.ts +0 -804
  180. package/scripts/validate-gurulu-schemas.mjs +0 -79
@@ -1,258 +0,0 @@
1
- "use strict";
2
- /**
3
- * Sprint B Group VII B14 — `gurulu watch` live event stream.
4
- *
5
- * Tail every event for the active tenant in near-real time, with optional
6
- * filtering by site / event types. Uses the existing CLI SSE endpoint
7
- * (/api/cli/events/tail) so we don't duplicate poll/heartbeat plumbing.
8
- *
9
- * gurulu watch # all sites, all events
10
- * gurulu watch --site=site_123 # one site
11
- * gurulu watch --types=$purchase,page_view # filter by event names (CSV)
12
- * gurulu watch --tail=50 # show last N before streaming
13
- * gurulu watch --json # one JSON line per event
14
- *
15
- * Auth: bearer token from active profile (`loadActiveProfile` via cliApi).
16
- * Graceful shutdown: SIGINT cancels the fetch via AbortController.
17
- */
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.watchCommand = watchCommand;
20
- exports.formatEventLine = formatEventLine;
21
- const api_client_1 = require("../api-client");
22
- const ui_1 = require("../utils/ui");
23
- async function watchCommand(args) {
24
- const types = parseTypes(args.types);
25
- const tailCount = Math.max(0, Number(args.tail) || 0);
26
- // 1. Optional tail of recent events before streaming.
27
- if (tailCount > 0) {
28
- await printTail(args, types, tailCount);
29
- }
30
- // 2. Open the SSE stream and forward events until SIGINT.
31
- await streamEvents(args, types);
32
- }
33
- function parseTypes(raw) {
34
- if (!raw)
35
- return null;
36
- const list = raw
37
- .split(',')
38
- .map((s) => s.trim())
39
- .filter((s) => s.length > 0);
40
- if (list.length === 0)
41
- return null;
42
- return new Set(list);
43
- }
44
- async function printTail(args, types, tailCount) {
45
- const qs = new URLSearchParams();
46
- if (args.site)
47
- qs.set('site', args.site);
48
- // The tail-history endpoint accepts a single event_name. When the user
49
- // requested multiple, fetch the union and filter client-side.
50
- if (types && types.size === 1) {
51
- qs.set('event_name', Array.from(types)[0]);
52
- }
53
- qs.set('limit', String(Math.min(tailCount * (types ? 5 : 1), 500)));
54
- qs.set('since', '24h');
55
- const path = `/api/cli/events?${qs.toString()}`;
56
- let body;
57
- try {
58
- body = await (0, api_client_1.cliApiJson)(path, {
59
- profile: args.profile,
60
- });
61
- }
62
- catch (err) {
63
- (0, ui_1.error)(`Failed to fetch tail history: ${err.message}`);
64
- return;
65
- }
66
- const all = body.events || [];
67
- const filtered = (types ? all.filter((e) => e.event_name && types.has(e.event_name)) : all)
68
- .slice(-tailCount) // keep the newest N (events arrive newest-first)
69
- .reverse();
70
- if (filtered.length === 0) {
71
- if (!args.json)
72
- (0, ui_1.info)('No prior events in the last 24h.');
73
- }
74
- for (const ev of filtered) {
75
- process.stdout.write(formatEventLine(ev, !!args.json));
76
- }
77
- if (!args.json && filtered.length > 0) {
78
- process.stdout.write((0, ui_1.dim)(' --- live stream ---\n'));
79
- }
80
- }
81
- async function streamEvents(args, types) {
82
- const qs = new URLSearchParams();
83
- if (args.site)
84
- qs.set('site', args.site);
85
- // SSE backend accepts a single eventName. Multi-type filter is applied on
86
- // the client. (Forwarded as a hint when only one is set so the server can
87
- // skip irrelevant rows entirely.)
88
- if (types && types.size === 1)
89
- qs.set('event_name', Array.from(types)[0]);
90
- const path = args.endpoint ||
91
- `/api/cli/events/tail${qs.toString() ? `?${qs.toString()}` : ''}`;
92
- // SIGINT → abort the fetch so the SSE socket is released cleanly.
93
- const controller = new AbortController();
94
- const onSigint = () => {
95
- if (!args.json)
96
- process.stderr.write((0, ui_1.dim)('\n[watch] disconnected\n'));
97
- controller.abort();
98
- // Give the abort path a tick to drain, then exit normally.
99
- setTimeout(() => process.exit(0), 25);
100
- };
101
- process.on('SIGINT', onSigint);
102
- process.on('SIGTERM', onSigint);
103
- if (!args.json) {
104
- (0, ui_1.info)(`Streaming events${args.site ? ` for site=${args.site}` : ''}${types ? ` types=[${Array.from(types).join(',')}]` : ''} — Ctrl+C to stop`);
105
- }
106
- // Reconnect loop — SSE streams cap at 10 minutes server-side. Honour the
107
- // `reconnect` frame and any transient network drop.
108
- let attempt = 0;
109
- while (!controller.signal.aborted) {
110
- try {
111
- const res = await (0, api_client_1.cliApi)(path, {
112
- profile: args.profile,
113
- headers: { accept: 'text/event-stream' },
114
- signal: controller.signal,
115
- });
116
- if (!res.body) {
117
- (0, ui_1.error)('Watch stream returned no body.');
118
- return;
119
- }
120
- attempt = 0; // reset backoff on successful connect
121
- await consumeSseBody(res.body, types, !!args.json);
122
- // Stream ended cleanly (max_lifetime). Re-open immediately.
123
- }
124
- catch (err) {
125
- if (controller.signal.aborted)
126
- return;
127
- attempt += 1;
128
- const wait = Math.min(15_000, 500 * 2 ** attempt);
129
- if (!args.json) {
130
- process.stderr.write((0, ui_1.dim)(`[watch] connection lost (${err.message}); reconnecting in ${wait}ms\n`));
131
- }
132
- await sleep(wait);
133
- }
134
- }
135
- }
136
- async function consumeSseBody(body, types, json) {
137
- // Browser-style ReadableStream
138
- const reader = body.getReader?.();
139
- if (reader) {
140
- const decoder = new TextDecoder();
141
- let buffer = '';
142
- // eslint-disable-next-line no-constant-condition
143
- while (true) {
144
- const { done, value } = await reader.read();
145
- if (done)
146
- return;
147
- buffer += decoder.decode(value, { stream: true });
148
- const flushed = drainSseBuffer(buffer);
149
- buffer = flushed.tail;
150
- for (const frame of flushed.frames)
151
- emitFrame(frame, types, json);
152
- }
153
- }
154
- // Node Readable fallback
155
- let buffer = '';
156
- for await (const chunk of body) {
157
- buffer += Buffer.from(chunk).toString('utf8');
158
- const flushed = drainSseBuffer(buffer);
159
- buffer = flushed.tail;
160
- for (const frame of flushed.frames)
161
- emitFrame(frame, types, json);
162
- }
163
- }
164
- function drainSseBuffer(buffer) {
165
- const frames = [];
166
- let idx = buffer.indexOf('\n\n');
167
- while (idx !== -1) {
168
- const block = buffer.slice(0, idx);
169
- buffer = buffer.slice(idx + 2);
170
- let event = 'message';
171
- let data = '';
172
- for (const line of block.split('\n')) {
173
- if (line.startsWith('event: '))
174
- event = line.slice(7).trim();
175
- else if (line.startsWith('data: '))
176
- data += line.slice(6);
177
- }
178
- if (data)
179
- frames.push({ event, data });
180
- idx = buffer.indexOf('\n\n');
181
- }
182
- return { frames, tail: buffer };
183
- }
184
- function emitFrame(frame, types, json) {
185
- if (frame.event !== 'realtime_event')
186
- return;
187
- let row;
188
- try {
189
- row = JSON.parse(frame.data);
190
- }
191
- catch {
192
- return;
193
- }
194
- if (types && row.event_name && !types.has(row.event_name))
195
- return;
196
- process.stdout.write(formatEventLine(row, json));
197
- }
198
- function formatEventLine(row, json) {
199
- if (json)
200
- return JSON.stringify(row) + '\n';
201
- const ts = formatTimestamp(row.event_ts);
202
- const name = String(row.event_name || '-').padEnd(14);
203
- const namePainted = paintEvent(name, String(row.event_name || ''));
204
- const who = formatActor(row);
205
- const site = row.site_name || row.site_id ? `site=${row.site_name || row.site_id}` : '';
206
- const tail = formatTail(row);
207
- return `${(0, ui_1.dim)(ts)} ${namePainted} ${who}${site ? ' ' + (0, ui_1.dim)(site) : ''}${tail ? ' ' + tail : ''}\n`;
208
- }
209
- function formatTimestamp(ts) {
210
- if (!ts)
211
- return '----------------'.padEnd(19);
212
- // ClickHouse format: '2026-04-27 14:23:01' (UTC) or ISO. Take the first 19.
213
- const cleaned = ts.replace('T', ' ').slice(0, 19);
214
- return cleaned.padEnd(19);
215
- }
216
- function paintEvent(padded, raw) {
217
- if (!raw)
218
- return padded;
219
- if (raw.startsWith('$'))
220
- return (0, ui_1.cyan)(padded); // system events
221
- if (raw.startsWith('error'))
222
- return (0, ui_1.yellow)(padded);
223
- if (raw === 'page_view' || raw === 'pageview')
224
- return (0, ui_1.dim)(padded);
225
- return (0, ui_1.green)(padded);
226
- }
227
- function formatActor(row) {
228
- if (row.user_id)
229
- return `${(0, ui_1.bold)('user')}=${String(row.user_id).slice(0, 8)}`;
230
- if (row.anonymous_id)
231
- return `anon=${String(row.anonymous_id).slice(0, 6)}`;
232
- return (0, ui_1.dim)('anon=?');
233
- }
234
- function formatTail(row) {
235
- const parts = [];
236
- const url = row.url || row.page_url;
237
- if (url)
238
- parts.push(stripHost(String(url)));
239
- if (row.selector)
240
- parts.push(`selector=${row.selector}`);
241
- if (row.revenue_value != null && Number(row.revenue_value) > 0) {
242
- const cur = row.revenue_currency || 'USD';
243
- parts.push(`value=${row.revenue_value} ${cur}`);
244
- }
245
- return parts.join(' ');
246
- }
247
- function stripHost(url) {
248
- try {
249
- const u = new URL(url);
250
- return u.pathname + (u.search || '');
251
- }
252
- catch {
253
- return url;
254
- }
255
- }
256
- function sleep(ms) {
257
- return new Promise((resolve) => setTimeout(resolve, ms));
258
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * Phase 18.5 W2 — `gurulu whoami`. Loads the active profile and hits
3
- * `/api/cli/me` for a concise one-line summary. Supports --json.
4
- */
5
- export interface WhoamiArgs {
6
- profile?: string;
7
- json?: boolean;
8
- }
9
- export declare function whoamiCommand(args: WhoamiArgs): Promise<void>;
@@ -1,50 +0,0 @@
1
- "use strict";
2
- /**
3
- * Phase 18.5 W2 — `gurulu whoami`. Loads the active profile and hits
4
- * `/api/cli/me` for a concise one-line summary. Supports --json.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.whoamiCommand = whoamiCommand;
8
- const config_1 = require("../config");
9
- const api_client_1 = require("../api-client");
10
- const ui_1 = require("../utils/ui");
11
- async function whoamiCommand(args) {
12
- let profile;
13
- try {
14
- profile = await (0, config_1.loadActiveProfile)({ profile: args.profile });
15
- }
16
- catch {
17
- if (args.json) {
18
- process.stdout.write(JSON.stringify({ error: 'not_logged_in' }) + '\n');
19
- }
20
- else {
21
- (0, ui_1.error)('Not logged in. Run `gurulu login` first.');
22
- }
23
- process.exit(1);
24
- }
25
- try {
26
- const me = await (0, api_client_1.cliApiJson)('/api/cli/me', { preloadedProfile: profile });
27
- if (args.json) {
28
- process.stdout.write(JSON.stringify(me, null, 2) + '\n');
29
- return;
30
- }
31
- const sites = (me.sites || []).length;
32
- const keys = (me.apiKeys || []).length;
33
- const installs = me.quota?.installsThisMonth ?? 0;
34
- const rawLimit = me.quota?.installsLimit;
35
- const limit = rawLimit === -1 || rawLimit === null || rawLimit === undefined
36
- ? 'unlimited'
37
- : rawLimit;
38
- process.stdout.write(`${me.user?.email} · ${me.tenant?.name} · ${me.tenant?.plan} plan · ${me.tenant?.id}\n`);
39
- process.stdout.write(`Sites: ${sites} | API keys: ${keys} | Installs this month: ${installs}/${limit}\n`);
40
- }
41
- catch (err) {
42
- if (args.json) {
43
- process.stdout.write(JSON.stringify({ error: err.message }) + '\n');
44
- }
45
- else {
46
- (0, ui_1.error)(`whoami failed: ${err.message}`);
47
- }
48
- process.exit(1);
49
- }
50
- }
package/dist/config.d.ts DELETED
@@ -1,75 +0,0 @@
1
- /**
2
- * Phase 18.5 W2 — Multi-profile CLI config.
3
- *
4
- * Replaces the single-profile `~/.gurulu/config.json` used by earlier phases
5
- * with a profile-aware store, while keeping backward compatibility for
6
- * commands that still call `utils/config.ts` (they now read from the
7
- * currently-active profile).
8
- *
9
- * Resolution order for a live session:
10
- * 1. GURULU_SECRET_KEY (env-var override — bypasses the file entirely)
11
- * 2. --profile <name> (CLI flag)
12
- * 3. GURULU_PROFILE (env)
13
- * 4. default_profile (from file)
14
- * 5. 'personal' (final fallback)
15
- *
16
- * Optional macOS keychain integration: if `keytar` is available at runtime,
17
- * secrets can be stored there under service 'io.gurulu.cli' account
18
- * `<profile>`. If unavailable, secrets fall back to the plaintext file.
19
- * Keytar is a **soft runtime require** — never a hard dependency, because
20
- * it's a native module and we don't want to force its install.
21
- */
22
- export interface ProfileConfig {
23
- email: string;
24
- secret_key: string;
25
- api_base: string;
26
- }
27
- export interface StoredProfile {
28
- email: string;
29
- secret_key?: string;
30
- api_base: string;
31
- keychain?: boolean;
32
- }
33
- export interface ConfigFile {
34
- default_profile: string;
35
- profiles: Record<string, StoredProfile>;
36
- }
37
- export interface ActiveProfile extends ProfileConfig {
38
- name: string;
39
- source: 'env' | 'file' | 'keychain';
40
- }
41
- export interface CliFlags {
42
- profile?: string;
43
- }
44
- export declare function configPath(): string;
45
- export declare function readKeychainSecret(profile: string): Promise<string | null>;
46
- export declare function writeKeychainSecret(profile: string, secret: string): Promise<boolean>;
47
- export declare function deleteKeychainSecret(profile: string): Promise<void>;
48
- export declare function isKeychainAvailable(): boolean;
49
- export declare function listProfiles(): Array<{
50
- name: string;
51
- email: string;
52
- api_base: string;
53
- isDefault: boolean;
54
- keychain: boolean;
55
- }>;
56
- export declare function getStoredProfile(name: string): StoredProfile | null;
57
- export declare function getDefaultProfileName(): string;
58
- export declare function setDefaultProfile(name: string): void;
59
- export declare function saveProfile(name: string, profile: ProfileConfig, opts?: {
60
- useKeychain?: boolean;
61
- }): Promise<{
62
- storedInKeychain: boolean;
63
- }>;
64
- export declare function deleteProfile(name: string): Promise<boolean>;
65
- export declare function deleteAllProfiles(): Promise<string[]>;
66
- /**
67
- * Resolve the active profile given CLI flags. Throws if no usable profile.
68
- * Accepts the `GURULU_SECRET_KEY` env var as an override for CI.
69
- */
70
- export declare function loadActiveProfile(flags?: CliFlags): Promise<ActiveProfile>;
71
- export declare function getActiveProfile(flags?: CliFlags): Promise<ActiveProfile | null>;
72
- export declare class ProfileNotFoundError extends Error {
73
- constructor(name: string);
74
- }
75
- export declare function defaultApiBase(): string;