secureagentbase 1.2.13

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.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../dist/index.js';
@@ -0,0 +1,4 @@
1
+ export declare function runDestroy(args: {
2
+ yes?: boolean;
3
+ saKey?: string;
4
+ }): Promise<void>;
@@ -0,0 +1,34 @@
1
+ import { createAuth } from '../lib/auth.js';
2
+ import { deleteVm } from '../lib/gcp.js';
3
+ import { loadConfig, clearConfig } from '../utils/config.js';
4
+ import { heading, info, success, warn } from '../utils/output.js';
5
+ export async function runDestroy(args) {
6
+ heading('Destroy SecureAgentBase');
7
+ const config = loadConfig();
8
+ if (!config.gcpProjectId) {
9
+ warn('No deployment found.');
10
+ return;
11
+ }
12
+ if (!args.yes) {
13
+ const { confirm } = await (await import('inquirer')).default.prompt([
14
+ {
15
+ type: 'confirm',
16
+ name: 'confirm',
17
+ message: `Delete VM in ${config.gcpProjectId}?`,
18
+ default: false,
19
+ },
20
+ ]);
21
+ if (!confirm) {
22
+ info('Aborted');
23
+ return;
24
+ }
25
+ }
26
+ const auth = await createAuth(args.saKey);
27
+ if (config.vmZone && config.vmIp) {
28
+ info(`Deleting VM (${config.vmIp}) in ${config.vmZone}...`);
29
+ await deleteVm(auth, config.gcpProjectId, config.vmZone, 'secureagent-manager');
30
+ success('VM deleted');
31
+ }
32
+ clearConfig();
33
+ success('Configuration cleared');
34
+ }
@@ -0,0 +1,15 @@
1
+ export interface InitArgs {
2
+ saKey?: string;
3
+ projectId?: string;
4
+ autoSa?: boolean;
5
+ firebase?: boolean;
6
+ billingAccount?: string;
7
+ githubPat?: string;
8
+ repoName?: string;
9
+ discordToken?: string;
10
+ discordGuild?: string;
11
+ vmZone?: string;
12
+ yes?: boolean;
13
+ vm?: boolean;
14
+ }
15
+ export declare function runInit(args: InitArgs): Promise<void>;
@@ -0,0 +1,426 @@
1
+ import * as fs from 'node:fs';
2
+ import * as crypto from 'node:crypto';
3
+ import inquirer from 'inquirer';
4
+ import { createAuth } from '../lib/auth.js';
5
+ import { listProjects, createProject, getProject, enableApi, createServiceAccount, grantRole, createVm, fetchVmLogs, cleanupVmByName, } from '../lib/gcp.js';
6
+ import { setupFirebaseProject } from '../lib/firebase.js';
7
+ import { ensureRepo, setGitHubVariable, setupOidc, validatePat } from '../lib/github.js';
8
+ import { fetchBillingAccounts, linkBillingAccount, isBillingEnabled } from '../lib/billing.js';
9
+ import { loadConfig, saveConfig } from '../utils/config.js';
10
+ import { heading, info, success, warn, kv } from '../utils/output.js';
11
+ import { CLIError } from '../utils/errors.js';
12
+ import { getStartupScript } from '../lib/startup-script.js';
13
+ export async function runInit(args) {
14
+ heading('SecureAgentBase Init');
15
+ // Auth
16
+ const auth = await createAuth(args.saKey);
17
+ const saEmail = await auth.getClientEmail();
18
+ info(`Authenticated as ${saEmail || 'unknown (ADC)'}`);
19
+ const config = loadConfig();
20
+ // Step 1: Select or create GCP project
21
+ await stepProject(auth, config, args);
22
+ // Step 2: Create/configure service account
23
+ await stepServiceAccount(auth, config, args);
24
+ // Step 3: Set up Firebase projects
25
+ if (args.firebase !== false) {
26
+ await stepFirebase(auth, config, args);
27
+ }
28
+ else {
29
+ info('Skipping Firebase setup (--no-firebase)');
30
+ }
31
+ // Step 4: Link billing
32
+ await stepBilling(auth, config, args);
33
+ // Step 5: GitHub + OIDC
34
+ if (args.githubPat) {
35
+ await stepGitHub(auth, config, args);
36
+ }
37
+ else {
38
+ info('Skipping GitHub setup (no --github-pat provided)');
39
+ }
40
+ // Step 6: Discord bot
41
+ if (args.discordToken) {
42
+ await stepDiscord(config, args);
43
+ }
44
+ else {
45
+ info('Skipping Discord setup (no --discord-token provided)');
46
+ }
47
+ // Step 7: Create VM
48
+ if (args.vm === false) {
49
+ info('Skipping VM creation (--no-vm)');
50
+ }
51
+ else {
52
+ await stepCreateVm(auth, config, args);
53
+ }
54
+ saveConfig(config);
55
+ success('SecureAgentBase deployment complete!');
56
+ kv('VM IP', config.vmIp || 'unknown');
57
+ kv('GitHub Repo', config.githubRepo || 'unknown');
58
+ }
59
+ async function stepProject(auth, config, args) {
60
+ heading('Step 1: GCP Project');
61
+ if (args.projectId) {
62
+ config.gcpProjectId = args.projectId;
63
+ info(`Using project: ${config.gcpProjectId}`);
64
+ saveConfig(config);
65
+ success(`Project: ${config.gcpProjectId}`);
66
+ return;
67
+ }
68
+ const projects = await listProjects(auth);
69
+ const projectChoices = projects.map((p) => ({
70
+ name: `${p.name || p.projectId} (${p.projectId})`,
71
+ value: p.projectId,
72
+ }));
73
+ const { gcpProjectId } = await inquirer.prompt([
74
+ {
75
+ type: 'list',
76
+ name: 'gcpProjectId',
77
+ message: 'Select a GCP project:',
78
+ choices: [...projectChoices, { name: 'Create a new project', value: '__new__' }],
79
+ },
80
+ ]);
81
+ if (gcpProjectId === '__new__') {
82
+ const { projectId, displayName } = await inquirer.prompt([
83
+ { type: 'input', name: 'projectId', message: 'New project ID:', validate: (v) => v.length > 0 },
84
+ { type: 'input', name: 'displayName', message: 'Display name:', default: 'SecureAgentBase' },
85
+ ]);
86
+ info(`Creating project ${projectId}...`);
87
+ await createProject(auth, projectId, displayName);
88
+ for (let i = 0; i < 10; i++) {
89
+ const p = await getProject(auth, projectId);
90
+ if (p)
91
+ break;
92
+ await new Promise((r) => setTimeout(r, 2000));
93
+ }
94
+ config.gcpProjectId = projectId;
95
+ info(`Project ${projectId} ready`);
96
+ }
97
+ else {
98
+ config.gcpProjectId = gcpProjectId;
99
+ }
100
+ saveConfig(config);
101
+ success(`Project: ${config.gcpProjectId}`);
102
+ }
103
+ async function stepServiceAccount(auth, config, args) {
104
+ heading('Step 2: Service Account');
105
+ if (args.autoSa) {
106
+ // Auto-create SA (no user interaction)
107
+ const projectId = config.gcpProjectId;
108
+ const accountId = 'secureagent-manager';
109
+ info('Creating service account...');
110
+ const { email } = await createServiceAccount(auth, projectId, accountId, 'SecureAgent Manager');
111
+ config.saEmail = email;
112
+ info(`SA created: ${email}`);
113
+ const roles = [
114
+ 'roles/compute.admin',
115
+ 'roles/iam.serviceAccountUser',
116
+ 'roles/iam.serviceAccountTokenCreator',
117
+ 'roles/billing.projectManager',
118
+ 'roles/serviceusage.serviceUsageAdmin',
119
+ 'roles/iam.workloadIdentityPoolAdmin',
120
+ 'roles/iam.securityAdmin',
121
+ 'roles/firebase.admin',
122
+ ];
123
+ for (const role of roles) {
124
+ await grantRole(auth, `projects/${projectId}`, `serviceAccount:${email}`, role);
125
+ info(` Granted ${role}`);
126
+ }
127
+ saveConfig(config);
128
+ success('Service account configured');
129
+ return;
130
+ }
131
+ const { choice } = await inquirer.prompt([
132
+ {
133
+ type: 'list',
134
+ name: 'choice',
135
+ message: 'Service account setup:',
136
+ choices: [
137
+ { name: 'Create service account programmatically', value: 'auto' },
138
+ { name: 'Use existing service account key file', value: 'manual' },
139
+ ],
140
+ },
141
+ ]);
142
+ if (choice === 'manual') {
143
+ const { keyPath } = await inquirer.prompt([
144
+ {
145
+ type: 'input',
146
+ name: 'keyPath',
147
+ message: 'Path to service account JSON key:',
148
+ validate: (v) => fs.existsSync(v) || 'File not found',
149
+ },
150
+ ]);
151
+ config.saKeyPath = keyPath;
152
+ }
153
+ else {
154
+ const projectId = config.gcpProjectId;
155
+ const accountId = 'secureagent-manager';
156
+ info('Creating service account...');
157
+ const { email } = await createServiceAccount(auth, projectId, accountId, 'SecureAgent Manager');
158
+ config.saEmail = email;
159
+ info(`SA created: ${email}`);
160
+ const roles = [
161
+ 'roles/compute.admin',
162
+ 'roles/iam.serviceAccountUser',
163
+ 'roles/iam.serviceAccountTokenCreator',
164
+ 'roles/billing.projectManager',
165
+ 'roles/serviceusage.serviceUsageAdmin',
166
+ 'roles/iam.workloadIdentityPoolAdmin',
167
+ 'roles/iam.securityAdmin',
168
+ 'roles/firebase.admin',
169
+ ];
170
+ for (const role of roles) {
171
+ await grantRole(auth, `projects/${projectId}`, `serviceAccount:${email}`, role);
172
+ info(` Granted ${role}`);
173
+ }
174
+ }
175
+ saveConfig(config);
176
+ success('Service account configured');
177
+ }
178
+ async function stepFirebase(auth, config, _args) {
179
+ heading('Step 3: Firebase Setup');
180
+ const projectId = config.gcpProjectId;
181
+ // Enable Identity Toolkit
182
+ info('Enabling Identity Toolkit API...');
183
+ await enableApi(auth, projectId, 'identitytoolkit.googleapis.com');
184
+ info('Setting up staging Firebase project...');
185
+ const staging = await setupFirebaseProject(auth, projectId, 'staging');
186
+ config.firebaseStaging = staging.config;
187
+ success(`Staging: ${staging.projectId}`);
188
+ info('Setting up production Firebase project...');
189
+ const production = await setupFirebaseProject(auth, projectId, 'production');
190
+ config.firebaseProduction = production.config;
191
+ success(`Production: ${production.projectId}`);
192
+ saveConfig(config);
193
+ }
194
+ async function stepBilling(auth, config, args) {
195
+ heading('Step 4: Billing Account');
196
+ const projectId = config.gcpProjectId;
197
+ if (args.billingAccount) {
198
+ info(`Linking billing account: ${args.billingAccount}`);
199
+ await linkBillingAccount(auth, projectId, args.billingAccount);
200
+ success(`Linked billing account: ${args.billingAccount}`);
201
+ return;
202
+ }
203
+ if (await isBillingEnabled(auth, projectId)) {
204
+ info('Billing already enabled');
205
+ return;
206
+ }
207
+ const accounts = await fetchBillingAccounts(auth, projectId);
208
+ if (accounts.length === 0) {
209
+ warn('No billing accounts found');
210
+ const { billingAccountId } = await inquirer.prompt([
211
+ {
212
+ type: 'input',
213
+ name: 'billingAccountId',
214
+ message: 'Enter billing account ID (e.g. XXXXXX-YYYYZZ-AAAAAA):',
215
+ },
216
+ ]);
217
+ await linkBillingAccount(auth, projectId, billingAccountId);
218
+ success(`Linked billing account: ${billingAccountId}`);
219
+ }
220
+ else {
221
+ const { selectedAccount } = await inquirer.prompt([
222
+ {
223
+ type: 'list',
224
+ name: 'selectedAccount',
225
+ message: 'Select a billing account:',
226
+ choices: accounts.map((a) => ({
227
+ name: `${a.displayName || a.name} (${a.name?.replace('billingAccounts/', '')})`,
228
+ value: a.name?.replace('billingAccounts/', ''),
229
+ })),
230
+ },
231
+ ]);
232
+ await linkBillingAccount(auth, projectId, selectedAccount);
233
+ success(`Linked billing account: ${selectedAccount}`);
234
+ }
235
+ }
236
+ async function stepGitHub(auth, config, args) {
237
+ heading('Step 5: GitHub + OIDC Setup');
238
+ if (args.githubPat) {
239
+ config.githubPat = args.githubPat;
240
+ }
241
+ else if (!config.githubPat) {
242
+ const { pat } = await inquirer.prompt([
243
+ {
244
+ type: 'password',
245
+ name: 'pat',
246
+ message: 'GitHub Personal Access Token (repo, workflow, read:org):',
247
+ validate: (v) => v.length > 0 || 'Required',
248
+ },
249
+ ]);
250
+ config.githubPat = pat;
251
+ }
252
+ const userInfo = await validatePat(config.githubPat);
253
+ info(`GitHub user: ${userInfo.login}`);
254
+ const repoName = args.repoName || (await inquirer.prompt([
255
+ {
256
+ type: 'input',
257
+ name: 'repoName',
258
+ message: 'GitHub repo name to create:',
259
+ default: `SecureAgentBase-${crypto.randomBytes(3).toString('hex')}`,
260
+ },
261
+ ])).repoName;
262
+ const repoFull = `${userInfo.login}/${repoName}`;
263
+ info(`Ensuring repo: ${repoFull}`);
264
+ await ensureRepo(config.githubPat, repoFull);
265
+ config.githubRepo = repoFull;
266
+ info('Setting up OIDC infrastructure...');
267
+ const oidcData = await setupOidc(auth, config.gcpProjectId, repoFull);
268
+ config.oidc = oidcData;
269
+ // Upload GitHub variables (best-effort — variables may already be set from prior run)
270
+ const varConfigs = [
271
+ ['VITE_APP_NAME', 'SecureAgentBase'],
272
+ ['GCP_WIF_PROVIDER', oidcData.wifPoolName],
273
+ ['GCP_SA_STAGING', oidcData.saStagingEmail],
274
+ ['GCP_SA_PRODUCTION', oidcData.saProductionEmail],
275
+ ['GCP_CLIENT_ID_STAGING', ''],
276
+ ['GCP_CLIENT_ID_PRODUCTION', ''],
277
+ ['VITE_APP_MODE', 'true'],
278
+ ];
279
+ for (const [name, value] of varConfigs) {
280
+ if (value) {
281
+ await setGitHubVariable(config.githubPat, repoFull, name, value).catch(() => {
282
+ warn(`Could not set GitHub variable ${name} (may already exist)`);
283
+ });
284
+ }
285
+ }
286
+ // Upload Firebase config variables
287
+ const firebaseFields = ['apiKey', 'authDomain', 'projectId', 'storageBucket', 'messagingSenderId', 'appId', 'measurementId'];
288
+ for (const env of ['STAGING', 'PRODUCTION']) {
289
+ const configData = env === 'STAGING' ? config.firebaseStaging : config.firebaseProduction;
290
+ if (configData) {
291
+ for (const field of firebaseFields) {
292
+ const upperField = field.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase();
293
+ if (configData[field]) {
294
+ await setGitHubVariable(config.githubPat, repoFull, `FIREBASE_${upperField}_${env}`, configData[field]).catch(() => { });
295
+ }
296
+ }
297
+ await setGitHubVariable(config.githubPat, repoFull, `FIREBASE_PROJECT_ID_${env}`, configData.projectId).catch(() => { });
298
+ }
299
+ }
300
+ saveConfig(config);
301
+ success(`GitHub repo ready: ${repoFull}`);
302
+ }
303
+ async function stepDiscord(config, args) {
304
+ heading('Step 6: Discord Bot');
305
+ if (args.discordToken) {
306
+ config.discordBotToken = args.discordToken;
307
+ config.discordGuildId = args.discordGuild || '';
308
+ }
309
+ else if (!config.discordBotToken) {
310
+ const { botToken } = await inquirer.prompt([
311
+ {
312
+ type: 'password',
313
+ name: 'botToken',
314
+ message: 'Discord Bot Token:',
315
+ validate: (v) => v.length > 0 || 'Required',
316
+ },
317
+ ]);
318
+ config.discordBotToken = botToken;
319
+ }
320
+ if (args.discordGuild) {
321
+ config.discordGuildId = args.discordGuild;
322
+ }
323
+ // Decode client ID from token
324
+ const decoded = Buffer.from(config.discordBotToken.split('.')[0], 'base64').toString();
325
+ const clientIdMatch = decoded.match(/"(?:id|client_id)"\s*:\s*"(\d+)"/);
326
+ if (clientIdMatch) {
327
+ info(`Bot Client ID: ${clientIdMatch[1]}`);
328
+ }
329
+ if (!config.discordGuildId) {
330
+ if (args.yes) {
331
+ info('No guild ID provided, skipping guild prompt (-y mode)');
332
+ }
333
+ else {
334
+ const inviteUrl = `https://discord.com/oauth2/authorize?client_id=${Buffer.from(config.discordBotToken.split('.')[0], 'base64').toString().match(/"(\d+)"/)?.[1] || 'UNKNOWN'}&permissions=8&integration_type=0&scope=bot%20applications.commands`;
335
+ warn(`Invite your bot to a server: ${inviteUrl}`);
336
+ const { guildId } = await inquirer.prompt([
337
+ {
338
+ type: 'input',
339
+ name: 'guildId',
340
+ message: 'Discord Guild (Server) ID after inviting the bot:',
341
+ },
342
+ ]);
343
+ config.discordGuildId = guildId;
344
+ }
345
+ }
346
+ saveConfig(config);
347
+ success('Discord bot configured');
348
+ }
349
+ async function stepCreateVm(auth, config, args) {
350
+ heading('Step 7: Create VM');
351
+ const projectId = config.gcpProjectId;
352
+ // Enable required APIs
353
+ info('Enabling Compute Engine API...');
354
+ await enableApi(auth, projectId, 'compute.googleapis.com');
355
+ info('Enabling IAM Credentials API...');
356
+ await enableApi(auth, projectId, 'iamcredentials.googleapis.com');
357
+ // Build metadata (same as web wizard's buildVmMetadata)
358
+ const metadata = {
359
+ github_pat: config.githubPat || '',
360
+ github_repo: config.githubRepo || '',
361
+ discord_bot_token: config.discordBotToken || '',
362
+ discord_guild_id: config.discordGuildId || '',
363
+ firebase_staging: config.firebaseStaging?.projectId || '',
364
+ firebase_production: config.firebaseProduction?.projectId || '',
365
+ gcp_wif_provider: config.oidc?.wifPoolName || '',
366
+ gcp_sa_staging: config.oidc?.saStagingEmail || '',
367
+ gcp_sa_production: config.oidc?.saProductionEmail || '',
368
+ firebase_staging_config: JSON.stringify(config.firebaseStaging || {}),
369
+ firebase_production_config: JSON.stringify(config.firebaseProduction || {}),
370
+ vite_app_name: 'SecureAgentBase',
371
+ 'serial-port-enable': 'TRUE',
372
+ 'enable-oslogin': 'false',
373
+ };
374
+ // Use the real startup script (installs Node, gh, kimaki, clones repo, starts bot)
375
+ // Key must be 'startup-script' (plain text) so GCP auto-executes it on boot
376
+ metadata['startup-script'] = getStartupScript();
377
+ // Clean up any existing VM with this name from prior runs
378
+ info('Checking for existing VM...');
379
+ const vmName = `secureagent-manager`;
380
+ await cleanupVmByName(auth, projectId, vmName);
381
+ const zones = args.vmZone ? [args.vmZone] : [
382
+ 'us-central1-a', 'us-central1-b', 'us-central1-c',
383
+ 'us-west1-a', 'us-west1-b',
384
+ 'us-east1-b', 'us-east1-c', 'us-east1-d',
385
+ 'europe-west1-b', 'europe-west1-c', 'europe-west1-d',
386
+ 'asia-east1-a',
387
+ ];
388
+ let vmResult = null;
389
+ for (const zone of zones) {
390
+ try {
391
+ info(`Attempting VM creation in ${zone}...`);
392
+ vmResult = await createVm(auth, projectId, zone, 'secureagent-manager', metadata);
393
+ config.vmIp = vmResult.ip;
394
+ config.vmZone = vmResult.zone;
395
+ break;
396
+ }
397
+ catch (e) {
398
+ warn(`${zone}: ${e.message}`);
399
+ }
400
+ }
401
+ if (!vmResult) {
402
+ throw new CLIError('Failed to create VM in any zone');
403
+ }
404
+ config.vmIp = vmResult.ip;
405
+ config.vmZone = vmResult.zone;
406
+ saveConfig(config);
407
+ success(`VM created at ${config.vmIp} in ${config.vmZone}`);
408
+ // Poll for initialization (real startup script takes ~3-5 min)
409
+ info('Polling VM initialization...');
410
+ for (let i = 0; i < 30; i++) {
411
+ await new Promise((r) => setTimeout(r, 10000));
412
+ try {
413
+ const logs = await fetchVmLogs(auth, projectId, config.vmZone, 'secureagent-manager');
414
+ if (logs.includes('KIMAKI_BOT_ONLINE')) {
415
+ info('Discord bot is online!');
416
+ break;
417
+ }
418
+ }
419
+ catch {
420
+ // Logs not ready yet
421
+ }
422
+ if (i % 6 === 0)
423
+ info('Waiting for VM initialization...');
424
+ }
425
+ success('VM initialized and bot online');
426
+ }
@@ -0,0 +1 @@
1
+ export declare function runStatus(): Promise<void>;
@@ -0,0 +1,17 @@
1
+ import { loadConfig } from '../utils/config.js';
2
+ import { heading, warn, kv } from '../utils/output.js';
3
+ export async function runStatus() {
4
+ heading('SecureAgentBase Status');
5
+ const config = loadConfig();
6
+ if (!config.gcpProjectId) {
7
+ warn('No deployment found. Run `init` first.');
8
+ return;
9
+ }
10
+ kv('GCP Project', config.gcpProjectId || '-');
11
+ kv('Service Account', config.saEmail || config.saKeyPath || '-');
12
+ kv('Staging Firebase', config.firebaseStaging?.projectId || '-');
13
+ kv('Production Firebase', config.firebaseProduction?.projectId || '-');
14
+ kv('GitHub Repo', config.githubRepo || '-');
15
+ kv('VM IP', config.vmIp || '-');
16
+ kv('VM Zone', config.vmZone || '-');
17
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+ import { runInit } from './commands/init.js';
4
+ import { runStatus } from './commands/status.js';
5
+ import { runDestroy } from './commands/destroy.js';
6
+ import { handleError } from './utils/errors.js';
7
+ const pkg = { version: '0.1.0', name: 'secureagentbase' };
8
+ const program = new Command();
9
+ program
10
+ .name('secureagentbase')
11
+ .description('CLI to deploy and manage SecureAgentBase on GCP')
12
+ .version(pkg.version);
13
+ program
14
+ .command('init')
15
+ .description('Run the setup wizard')
16
+ .option('--sa-key <path>', 'Path to a service account JSON key')
17
+ .option('--project-id <id>', 'GCP project ID (skips project selection)')
18
+ .option('--auto-sa', 'Create service account automatically (skips SA prompt)')
19
+ .option('--no-firebase', 'Skip Firebase setup')
20
+ .option('--billing-account <id>', 'Billing account ID (skips billing prompt)')
21
+ .option('--github-pat <token>', 'GitHub PAT (skips PAT prompt)')
22
+ .option('--repo-name <name>', 'GitHub repo name (requires --github-pat)')
23
+ .option('--discord-token <token>', 'Discord bot token')
24
+ .option('--discord-guild <id>', 'Discord guild ID')
25
+ .option('--vm-zone <zone>', 'VM zone (default: us-central1-a)')
26
+ .option('--no-vm', 'Skip VM creation')
27
+ .option('-y, --yes', 'Skip all confirmations (non-interactive mode)')
28
+ .action(async (opts) => {
29
+ try {
30
+ await runInit({
31
+ saKey: opts.saKey,
32
+ projectId: opts.projectId,
33
+ autoSa: opts.autoSa,
34
+ firebase: opts.firebase !== false,
35
+ billingAccount: opts.billingAccount,
36
+ githubPat: opts.githubPat,
37
+ repoName: opts.repoName,
38
+ discordToken: opts.discordToken,
39
+ discordGuild: opts.discordGuild,
40
+ vmZone: opts.vmZone || 'us-central1-a',
41
+ yes: opts.yes,
42
+ vm: opts.vm,
43
+ });
44
+ }
45
+ catch (err) {
46
+ handleError(err);
47
+ }
48
+ });
49
+ program
50
+ .command('status')
51
+ .description('Show deployment status')
52
+ .action(async () => {
53
+ try {
54
+ await runStatus();
55
+ }
56
+ catch (err) {
57
+ handleError(err);
58
+ }
59
+ });
60
+ program
61
+ .command('destroy')
62
+ .description('Delete VM and clear configuration')
63
+ .option('-y, --yes', 'Skip confirmation')
64
+ .option('--sa-key <path>', 'Path to a service account JSON key')
65
+ .action(async (opts) => {
66
+ try {
67
+ await runDestroy({ yes: opts.yes, saKey: opts.saKey });
68
+ }
69
+ catch (err) {
70
+ handleError(err);
71
+ }
72
+ });
73
+ program.parse(process.argv);
@@ -0,0 +1,6 @@
1
+ export interface AuthClient {
2
+ getToken(): Promise<string>;
3
+ getProjectId(): Promise<string | null>;
4
+ getClientEmail(): Promise<string | null>;
5
+ }
6
+ export declare function createAuth(saKeyPath?: string): Promise<AuthClient>;