@brainbase-labs/cli 0.2.1 → 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 +26 -11
- 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) {
|