@brainbase-labs/cli 0.2.0 → 0.2.2
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 +34 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7226,28 +7226,41 @@ async function attachToExistingAgent(cwd, agentId, args, existing) {
|
|
|
7226
7226
|
const adapter = getRouteAdapter(harness);
|
|
7227
7227
|
if (adapter) {
|
|
7228
7228
|
const apiBase2 = proxyBaseUrl(session ?? null);
|
|
7229
|
-
const
|
|
7230
|
-
ksp.start("Generating an API key…");
|
|
7229
|
+
const presetKey = process.env.BB_TASK_KEY?.trim();
|
|
7231
7230
|
try {
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7231
|
+
let keyId;
|
|
7232
|
+
let keyPrefix;
|
|
7233
|
+
let keyPlain;
|
|
7234
|
+
if (presetKey) {
|
|
7235
|
+
keyPlain = presetKey;
|
|
7236
|
+
keyPrefix = presetKey.slice(0, 12) + "…";
|
|
7237
|
+
keyId = "";
|
|
7238
|
+
p13.log.info("Using pre-provisioned BB_TASK_KEY for tracking.");
|
|
7239
|
+
} else {
|
|
7240
|
+
const ksp = p13.spinner();
|
|
7241
|
+
ksp.start("Generating an API key…");
|
|
7242
|
+
const created = await api.createCliKey(agent.id, {
|
|
7243
|
+
name: `${harness} on this machine`,
|
|
7244
|
+
harness: harness === "claude-code" ? "claude_code" : harness
|
|
7245
|
+
});
|
|
7246
|
+
ksp.stop("Key generated.");
|
|
7247
|
+
keyPlain = created.key;
|
|
7248
|
+
keyPrefix = created.prefix;
|
|
7249
|
+
keyId = created.id;
|
|
7250
|
+
}
|
|
7237
7251
|
const cfg = p13.spinner();
|
|
7238
7252
|
cfg.start(`Configuring ${harness}…`);
|
|
7239
|
-
const snap = await adapter.enable(cwd, { apiBase: apiBase2, apiKey:
|
|
7253
|
+
const snap = await adapter.enable(cwd, { apiBase: apiBase2, apiKey: keyPlain });
|
|
7240
7254
|
cfg.stop(`${harness} pointed at brainbase.`);
|
|
7241
7255
|
tracking = {
|
|
7242
7256
|
harness,
|
|
7243
|
-
key_id:
|
|
7244
|
-
key_prefix:
|
|
7257
|
+
key_id: keyId,
|
|
7258
|
+
key_prefix: keyPrefix,
|
|
7245
7259
|
api_base: apiBase2,
|
|
7246
7260
|
snapshot: snap.data,
|
|
7247
7261
|
enabled_at: new Date().toISOString()
|
|
7248
7262
|
};
|
|
7249
7263
|
} catch (err) {
|
|
7250
|
-
ksp.stop("Failed.");
|
|
7251
7264
|
handleApiError(err);
|
|
7252
7265
|
process.exit(1);
|
|
7253
7266
|
}
|
|
@@ -7282,6 +7295,8 @@ async function tearDownTracking(cwd, link) {
|
|
|
7282
7295
|
p13.log.warn(`Failed to restore ${link.tracking.harness} config: ${err.message}`);
|
|
7283
7296
|
}
|
|
7284
7297
|
}
|
|
7298
|
+
if (!link.tracking.key_id)
|
|
7299
|
+
return;
|
|
7285
7300
|
try {
|
|
7286
7301
|
await api.revokeCliKey(link.tracking.key_id);
|
|
7287
7302
|
} catch (err) {
|
|
@@ -9864,6 +9879,7 @@ async function showTokenListCard(props) {
|
|
|
9864
9879
|
}
|
|
9865
9880
|
|
|
9866
9881
|
// src/cli/token.ts
|
|
9882
|
+
var DEFAULT_SCOPES = ["read", "publish"];
|
|
9867
9883
|
async function runTokenCreate(args) {
|
|
9868
9884
|
banner("token create — make a long-lived CLI key");
|
|
9869
9885
|
let name = args.name;
|
|
@@ -9875,11 +9891,12 @@ async function runTokenCreate(args) {
|
|
|
9875
9891
|
});
|
|
9876
9892
|
name = ensureNotCancelled(ans);
|
|
9877
9893
|
}
|
|
9894
|
+
const scopes = args.scopes && args.scopes.length > 0 ? args.scopes : DEFAULT_SCOPES;
|
|
9878
9895
|
const spinner17 = p21.spinner();
|
|
9879
9896
|
spinner17.start("Creating token…");
|
|
9880
9897
|
const created = await registryApi.createCliToken({
|
|
9881
9898
|
name,
|
|
9882
|
-
scopes
|
|
9899
|
+
scopes
|
|
9883
9900
|
});
|
|
9884
9901
|
spinner17.stop("Token created.");
|
|
9885
9902
|
writeToken(created.token, name);
|
|
@@ -9989,6 +10006,11 @@ function printTokenHelp() {
|
|
|
9989
10006
|
out.push(` ${pc30.cyan("revoke")} ${pc30.dim("<id>")} ${pc30.dim("revoke a token by id")}`);
|
|
9990
10007
|
out.push(` ${pc30.cyan("clear")} ${pc30.dim("forget the local token (does not revoke)")}`);
|
|
9991
10008
|
out.push("");
|
|
10009
|
+
out.push(` ${pc30.bold("create flags")}`);
|
|
10010
|
+
out.push(` ${pc30.cyan("--name, -n")} ${pc30.dim("<label>")} ${pc30.dim("token label (prompted if omitted)")}`);
|
|
10011
|
+
out.push(` ${pc30.cyan("--scopes")} ${pc30.dim("<list>")} ${pc30.dim("comma-separated; allowed: read, publish, admin")}`);
|
|
10012
|
+
out.push(` ${pc30.dim("default: read,publish")}`);
|
|
10013
|
+
out.push("");
|
|
9992
10014
|
console.log(out.join(`
|
|
9993
10015
|
`));
|
|
9994
10016
|
}
|