secureagentbase 1.4.8 → 1.5.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.
- package/dist/index.js +17 -4
- package/dist/lib/auth.js +18 -4
- package/dist/lib/startup-script.sh +9 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -23,23 +23,36 @@ program
|
|
|
23
23
|
.option('--auto-sa', 'Create service account automatically (skips SA prompt)')
|
|
24
24
|
.option('--no-firebase', 'Skip Firebase setup')
|
|
25
25
|
.option('--billing-account <id>', 'Billing account ID (skips billing prompt)')
|
|
26
|
-
.option('--github-pat <token>', 'GitHub PAT (skips PAT prompt)')
|
|
26
|
+
.option('--github-pat <token>', 'GitHub PAT (skips PAT prompt) — prefer env SECUREAGENTBASE_GITHUB_PAT')
|
|
27
27
|
.option('--repo-name <name>', 'GitHub repo name (requires --github-pat)')
|
|
28
|
-
.option('--discord-token <token>', 'Discord bot token')
|
|
28
|
+
.option('--discord-token <token>', 'Discord bot token — prefer env SECUREAGENTBASE_DISCORD_TOKEN')
|
|
29
29
|
.option('--discord-guild <id>', 'Discord guild ID')
|
|
30
30
|
.option('--vm-zone <zone>', 'VM zone (default: us-central1-a, falls back across regions)')
|
|
31
31
|
.option('--no-vm', 'Skip VM creation')
|
|
32
32
|
.option('-y, --yes', 'Skip all confirmations (non-interactive mode)')
|
|
33
33
|
.action(async (opts) => {
|
|
34
34
|
try {
|
|
35
|
+
// Secrets may be supplied through the environment instead of argv.
|
|
36
|
+
// argv is exposed to `ps`, shell history, and any CI log that echoes
|
|
37
|
+
// the command; environment variables are not, and GitHub Actions masks
|
|
38
|
+
// values it injects as secrets. Explicit flags still win so existing
|
|
39
|
+
// automation is unaffected.
|
|
40
|
+
const githubPat = opts.githubPat || process.env.SECUREAGENTBASE_GITHUB_PAT;
|
|
41
|
+
const discordToken = opts.discordToken || process.env.SECUREAGENTBASE_DISCORD_TOKEN;
|
|
42
|
+
if (opts.githubPat) {
|
|
43
|
+
process.stderr.write('warning: --github-pat is visible in `ps` and shell history; prefer the SECUREAGENTBASE_GITHUB_PAT environment variable.\n');
|
|
44
|
+
}
|
|
45
|
+
if (opts.discordToken) {
|
|
46
|
+
process.stderr.write('warning: --discord-token is visible in `ps` and shell history; prefer the SECUREAGENTBASE_DISCORD_TOKEN environment variable.\n');
|
|
47
|
+
}
|
|
35
48
|
await runInit({
|
|
36
49
|
projectId: opts.projectId,
|
|
37
50
|
autoSa: opts.autoSa,
|
|
38
51
|
firebase: opts.firebase !== false,
|
|
39
52
|
billingAccount: opts.billingAccount,
|
|
40
|
-
githubPat
|
|
53
|
+
githubPat,
|
|
41
54
|
repoName: opts.repoName,
|
|
42
|
-
discordToken
|
|
55
|
+
discordToken,
|
|
43
56
|
discordGuild: opts.discordGuild,
|
|
44
57
|
vmZone: opts.vmZone,
|
|
45
58
|
yes: opts.yes,
|
package/dist/lib/auth.js
CHANGED
|
@@ -205,10 +205,15 @@ export async function ensureAdc(options = {}) {
|
|
|
205
205
|
throw new MissingAdcError(`${before.detail} Login was skipped.`);
|
|
206
206
|
}
|
|
207
207
|
// `gcloud auth application-default login` is interactive (browser flow), so
|
|
208
|
-
// hand it the real stdio and let the user complete it.
|
|
209
|
-
|
|
208
|
+
// hand it the real stdio and let the user complete it. `shell` must match
|
|
209
|
+
// what findGcloud probed with, or Windows resolves gcloud in one call and not
|
|
210
|
+
// the other (the probe passes, the login then dies with ENOENT).
|
|
211
|
+
const result = spawnSync(gcloud, ['auth', 'application-default', 'login'], {
|
|
212
|
+
stdio: 'inherit',
|
|
213
|
+
shell: needsShell(),
|
|
214
|
+
});
|
|
210
215
|
if (result.error) {
|
|
211
|
-
throw new MissingAdcError(`Could not run gcloud: ${messageOf(result.error)}`);
|
|
216
|
+
throw new MissingAdcError(`Could not run gcloud: ${messageOf(result.error)}`, `Install the Google Cloud SDK and make sure \`gcloud\` runs in this shell (https://cloud.google.com/sdk/docs/install).`);
|
|
212
217
|
}
|
|
213
218
|
if (result.status !== 0) {
|
|
214
219
|
throw new MissingAdcError('`gcloud auth application-default login` exited with a failure (it may have been cancelled).');
|
|
@@ -249,10 +254,19 @@ async function metadataServerAnswers(host) {
|
|
|
249
254
|
clearTimeout(timer);
|
|
250
255
|
}
|
|
251
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* On Windows, `gcloud` is installed as a batch wrapper (`gcloud.cmd`), which
|
|
259
|
+
* spawnSync cannot execute directly — it only resolves real executables. Node
|
|
260
|
+
* resolves the wrapper only when `shell: true`. `git` and `npm` have the same
|
|
261
|
+
* shape on Windows. Everywhere we invoke a CLI, pass this flag.
|
|
262
|
+
*/
|
|
263
|
+
function needsShell() {
|
|
264
|
+
return process.platform === 'win32';
|
|
265
|
+
}
|
|
252
266
|
function findGcloud() {
|
|
253
267
|
const probe = spawnSync('gcloud', ['version', '--format=json'], {
|
|
254
268
|
stdio: 'ignore',
|
|
255
|
-
shell:
|
|
269
|
+
shell: needsShell(),
|
|
256
270
|
});
|
|
257
271
|
return probe.error || probe.status !== 0 ? null : 'gcloud';
|
|
258
272
|
}
|
|
@@ -180,10 +180,13 @@ fi
|
|
|
180
180
|
type gh >/dev/null 2>&1 || (curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg 2>/dev/null && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null && sudo apt-get update -y > /dev/null 2>&1 && sudo apt-get install -y gh > /dev/null 2>&1) || true
|
|
181
181
|
|
|
182
182
|
# Install Kimaki (skip if already installed — re-running npm -g installs crashes with ENOTEMPTY)
|
|
183
|
+
# Pinned, not @latest: a floating tag meant two VMs provisioned days apart could run
|
|
184
|
+
# different code with no record of which version each got. Bump this deliberately.
|
|
185
|
+
KIMAKI_VERSION="1.4.0"
|
|
183
186
|
if command -v kimaki >/dev/null 2>&1; then
|
|
184
187
|
echo "kimaki already installed, skipping global install"
|
|
185
188
|
else
|
|
186
|
-
npm install -g kimaki
|
|
189
|
+
npm install -g "kimaki@${KIMAKI_VERSION}" > /dev/null 2>&1 || true
|
|
187
190
|
fi
|
|
188
191
|
|
|
189
192
|
# Clone the SecureAgentBase template repository into Kimaki's projects dir
|
|
@@ -550,7 +553,7 @@ done
|
|
|
550
553
|
if command -v kimaki &> /dev/null; then
|
|
551
554
|
KIMAKI_CMD="kimaki"
|
|
552
555
|
else
|
|
553
|
-
KIMAKI_CMD="npx -y kimaki@
|
|
556
|
+
KIMAKI_CMD="npx -y kimaki@__KIMAKI_VERSION__"
|
|
554
557
|
fi
|
|
555
558
|
|
|
556
559
|
echo "$(date): Using KIMAKI_CMD: $KIMAKI_CMD" >> /var/log/kimaki-register.log
|
|
@@ -579,6 +582,10 @@ echo "$(date): Registration failed after 30 attempts" >> /var/log/kimaki-registe
|
|
|
579
582
|
exit 1
|
|
580
583
|
REGISTER_SCRIPT
|
|
581
584
|
|
|
585
|
+
# Resolve the pinned kimaki version into the register script (the heredoc above is
|
|
586
|
+
# single-quoted so it does not expand variables; same pattern as __OPENCODE_MODEL__).
|
|
587
|
+
sed -i "s|__KIMAKI_VERSION__|$KIMAKI_VERSION|" /usr/local/bin/kimaki-register.sh
|
|
588
|
+
|
|
582
589
|
chmod +x /usr/local/bin/kimaki-register.sh
|
|
583
590
|
|
|
584
591
|
# Create project registration service
|