bamboo-agents 0.1.5-dev.58.9abca08 → 0.1.5-dev.59.bf3c8c5
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/VERSION +1 -1
- package/dist/index.js +146 -23
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1.5-dev.
|
|
1
|
+
0.1.5-dev.59.bf3c8c5
|
package/dist/index.js
CHANGED
|
@@ -3037,7 +3037,7 @@ var VERSION;
|
|
|
3037
3037
|
var init_version = __esm({
|
|
3038
3038
|
"src/version.ts"() {
|
|
3039
3039
|
"use strict";
|
|
3040
|
-
VERSION = "0.1.5-dev.
|
|
3040
|
+
VERSION = "0.1.5-dev.59.bf3c8c5";
|
|
3041
3041
|
}
|
|
3042
3042
|
});
|
|
3043
3043
|
|
|
@@ -7377,6 +7377,8 @@ var init_onboarding_status = __esm({
|
|
|
7377
7377
|
// ../../src/lib/api-contracts/cli/agents.ts
|
|
7378
7378
|
var agents_exports = {};
|
|
7379
7379
|
__export(agents_exports, {
|
|
7380
|
+
CliActivationBlockerSchema: () => CliActivationBlockerSchema,
|
|
7381
|
+
CliActivationReadinessSchema: () => CliActivationReadinessSchema,
|
|
7380
7382
|
CliAgentDetailSchema: () => CliAgentDetailSchema,
|
|
7381
7383
|
CliAgentGetResponseSchema: () => CliAgentGetResponseSchema,
|
|
7382
7384
|
CliAgentLifecycleStateSchema: () => CliAgentLifecycleStateSchema,
|
|
@@ -7404,7 +7406,7 @@ __export(agents_exports, {
|
|
|
7404
7406
|
UploadClaudeMdRequestSchema: () => UploadClaudeMdRequestSchema,
|
|
7405
7407
|
UploadClaudeMdResponseSchema: () => UploadClaudeMdResponseSchema
|
|
7406
7408
|
});
|
|
7407
|
-
var SlugSchema, NameSchema, BrandIdSchema, CliAgentRowSchema, CliTierCapSchema, CliAgentsListResponseSchema, CliCreateAgentRequestSchema, CliAgentMutationResponseBase, CliCreateAgentResponseSchema, UPLOAD_MAX_BYTES, CliUploadAgentRequestSchema, CliUploadAgentResponseSchema, CliUpdateAgentRequestSchema, CliUpdateAgentResponseSchema, CliDeleteAgentResponseSchema, CliCloneAgentRequestSchema, CliCloneAgentResponseSchema, CliEnableTemplateRequestSchema, CliEnableTemplateResponseSchema, CliBrandRowSchema, CliBrandsListResponseSchema, CliAgentLifecycleStateSchema, CliAgentDetailSchema, CliAgentGetResponseSchema, CliAgentPauseResponseSchema, CliAgentPublishResponseSchema, CreateFromCliRequestSchema, CreateFromCliResponseSchema, UploadClaudeMdRequestSchema, UploadClaudeMdResponseSchema;
|
|
7409
|
+
var SlugSchema, NameSchema, BrandIdSchema, CliAgentRowSchema, CliTierCapSchema, CliAgentsListResponseSchema, CliCreateAgentRequestSchema, CliAgentMutationResponseBase, CliCreateAgentResponseSchema, UPLOAD_MAX_BYTES, CliUploadAgentRequestSchema, CliUploadAgentResponseSchema, CliUpdateAgentRequestSchema, CliUpdateAgentResponseSchema, CliDeleteAgentResponseSchema, CliCloneAgentRequestSchema, CliCloneAgentResponseSchema, CliEnableTemplateRequestSchema, CliEnableTemplateResponseSchema, CliBrandRowSchema, CliBrandsListResponseSchema, CliAgentLifecycleStateSchema, CliActivationBlockerSchema, CliActivationReadinessSchema, CliAgentDetailSchema, CliAgentGetResponseSchema, CliAgentPauseResponseSchema, CliAgentPublishResponseSchema, CreateFromCliRequestSchema, CreateFromCliResponseSchema, UploadClaudeMdRequestSchema, UploadClaudeMdResponseSchema;
|
|
7408
7410
|
var init_agents = __esm({
|
|
7409
7411
|
"../../src/lib/api-contracts/cli/agents.ts"() {
|
|
7410
7412
|
init_zod();
|
|
@@ -7527,6 +7529,18 @@ var init_agents = __esm({
|
|
|
7527
7529
|
"paused",
|
|
7528
7530
|
"inactive"
|
|
7529
7531
|
]);
|
|
7532
|
+
CliActivationBlockerSchema = external_exports.object({
|
|
7533
|
+
kind: external_exports.string(),
|
|
7534
|
+
scope: external_exports.string(),
|
|
7535
|
+
label: external_exports.string(),
|
|
7536
|
+
cta: external_exports.string(),
|
|
7537
|
+
action_url: external_exports.string(),
|
|
7538
|
+
meta: external_exports.record(external_exports.unknown())
|
|
7539
|
+
});
|
|
7540
|
+
CliActivationReadinessSchema = external_exports.object({
|
|
7541
|
+
ready: external_exports.boolean(),
|
|
7542
|
+
blockers: external_exports.array(CliActivationBlockerSchema)
|
|
7543
|
+
});
|
|
7530
7544
|
CliAgentDetailSchema = external_exports.object({
|
|
7531
7545
|
id: external_exports.string().uuid(),
|
|
7532
7546
|
name: external_exports.string(),
|
|
@@ -7543,7 +7557,12 @@ var init_agents = __esm({
|
|
|
7543
7557
|
description: external_exports.string().nullable(),
|
|
7544
7558
|
created_at: external_exports.string().nullable(),
|
|
7545
7559
|
/** Brand m:m links (agent_brands → brands). */
|
|
7546
|
-
brands: external_exports.array(CliBrandRowSchema)
|
|
7560
|
+
brands: external_exports.array(CliBrandRowSchema),
|
|
7561
|
+
/**
|
|
7562
|
+
* BAM-2651: activation-readiness result. Always present on new servers;
|
|
7563
|
+
* optional here for forward-compat with old servers that don't emit it.
|
|
7564
|
+
*/
|
|
7565
|
+
activation_readiness: CliActivationReadinessSchema.optional()
|
|
7547
7566
|
});
|
|
7548
7567
|
CliAgentGetResponseSchema = external_exports.object({
|
|
7549
7568
|
agent: CliAgentDetailSchema
|
|
@@ -7617,6 +7636,12 @@ async function writeCredentials(creds) {
|
|
|
7617
7636
|
});
|
|
7618
7637
|
await chmod(bambooDir(), 448);
|
|
7619
7638
|
}
|
|
7639
|
+
async function resolveSession() {
|
|
7640
|
+
const envToken = process.env.BAMBOO_API_TOKEN?.trim();
|
|
7641
|
+
if (envToken) return envToken;
|
|
7642
|
+
const creds = await readCredentials();
|
|
7643
|
+
return creds?.bamboo_session ?? null;
|
|
7644
|
+
}
|
|
7620
7645
|
var CredentialsSchema;
|
|
7621
7646
|
var init_credentials = __esm({
|
|
7622
7647
|
"src/lib/credentials.ts"() {
|
|
@@ -7625,7 +7650,16 @@ var init_credentials = __esm({
|
|
|
7625
7650
|
init_paths();
|
|
7626
7651
|
CredentialsSchema = external_exports.object({
|
|
7627
7652
|
bamboo_session: external_exports.string().min(1),
|
|
7628
|
-
|
|
7653
|
+
/**
|
|
7654
|
+
* GitHub token for git push (interactive login flow). Empty string when
|
|
7655
|
+
* the credentials were written by the BAM-2666 headless `bamboo login --token`
|
|
7656
|
+
* path — that flow runs in environments (managed agents, CI) where the
|
|
7657
|
+
* GitHub token isn't needed (writes route through the server's
|
|
7658
|
+
* `executeKnowledgeWrite` core via `bamboo save`, not a client-side push).
|
|
7659
|
+
* Downstream consumers must handle empty string gracefully or fall back
|
|
7660
|
+
* to re-running interactive login.
|
|
7661
|
+
*/
|
|
7662
|
+
github_token: external_exports.string(),
|
|
7629
7663
|
github_token_expires_at: external_exports.string().nullable(),
|
|
7630
7664
|
/** Display-only — git push uses `x-access-token` as username, not the user's login. */
|
|
7631
7665
|
github_username: external_exports.string().nullable(),
|
|
@@ -12983,8 +13017,11 @@ var login_exports = {};
|
|
|
12983
13017
|
__export(login_exports, {
|
|
12984
13018
|
TOKEN_POLL: () => TOKEN_POLL,
|
|
12985
13019
|
handleMissingGithubToken: () => handleMissingGithubToken,
|
|
13020
|
+
isAgentScopedKey: () => isAgentScopedKey,
|
|
12986
13021
|
runLogin: () => runLogin,
|
|
13022
|
+
runLoginWithToken: () => runLoginWithToken,
|
|
12987
13023
|
startCallbackServer: () => startCallbackServer,
|
|
13024
|
+
validateAndWriteHeadlessCreds: () => validateAndWriteHeadlessCreds,
|
|
12988
13025
|
verificationCode: () => verificationCode
|
|
12989
13026
|
});
|
|
12990
13027
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
@@ -13036,10 +13073,10 @@ async function handleMissingGithubToken(bambooSession) {
|
|
|
13036
13073
|
return null;
|
|
13037
13074
|
}
|
|
13038
13075
|
async function startCallbackServer(expectedState) {
|
|
13039
|
-
let
|
|
13076
|
+
let resolveSession2;
|
|
13040
13077
|
let rejectSession;
|
|
13041
13078
|
const session = new Promise((resolve2, reject) => {
|
|
13042
|
-
|
|
13079
|
+
resolveSession2 = resolve2;
|
|
13043
13080
|
rejectSession = reject;
|
|
13044
13081
|
});
|
|
13045
13082
|
const server = createServer((req, res) => {
|
|
@@ -13083,7 +13120,7 @@ async function startCallbackServer(expectedState) {
|
|
|
13083
13120
|
return;
|
|
13084
13121
|
}
|
|
13085
13122
|
respondCors(200, { ok: true });
|
|
13086
|
-
|
|
13123
|
+
resolveSession2(body.session);
|
|
13087
13124
|
setTimeout(() => server.close(), 100);
|
|
13088
13125
|
});
|
|
13089
13126
|
});
|
|
@@ -13111,6 +13148,78 @@ async function startCallbackServer(expectedState) {
|
|
|
13111
13148
|
session: session.finally(() => clearTimeout(timer))
|
|
13112
13149
|
};
|
|
13113
13150
|
}
|
|
13151
|
+
function isAgentScopedKey(token) {
|
|
13152
|
+
return token.startsWith("bam_live_");
|
|
13153
|
+
}
|
|
13154
|
+
async function validateAndWriteHeadlessCreds(bambooSession) {
|
|
13155
|
+
if (!isAgentScopedKey(bambooSession)) {
|
|
13156
|
+
try {
|
|
13157
|
+
await getCliAuthStatus(bambooSession);
|
|
13158
|
+
} catch (err) {
|
|
13159
|
+
if (err instanceof ApiError) {
|
|
13160
|
+
if (err.status === 401) {
|
|
13161
|
+
return {
|
|
13162
|
+
kind: "invalid_token",
|
|
13163
|
+
message: "The token was rejected by Bamboo's auth check."
|
|
13164
|
+
};
|
|
13165
|
+
}
|
|
13166
|
+
if (err.status >= 400 && err.status < 500) {
|
|
13167
|
+
return {
|
|
13168
|
+
kind: "invalid_token",
|
|
13169
|
+
message: `Bamboo's auth check returned ${err.status}: ${err.message}`
|
|
13170
|
+
};
|
|
13171
|
+
}
|
|
13172
|
+
return {
|
|
13173
|
+
kind: "network_error",
|
|
13174
|
+
message: `Bamboo's auth check returned ${err.status}: ${err.message}`
|
|
13175
|
+
};
|
|
13176
|
+
}
|
|
13177
|
+
return {
|
|
13178
|
+
kind: "network_error",
|
|
13179
|
+
message: err?.message ?? String(err)
|
|
13180
|
+
};
|
|
13181
|
+
}
|
|
13182
|
+
}
|
|
13183
|
+
await writeCredentials({
|
|
13184
|
+
bamboo_session: bambooSession,
|
|
13185
|
+
github_token: "",
|
|
13186
|
+
github_token_expires_at: null,
|
|
13187
|
+
github_username: null,
|
|
13188
|
+
written_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
13189
|
+
});
|
|
13190
|
+
return { kind: "success", githubUsername: null };
|
|
13191
|
+
}
|
|
13192
|
+
async function runLoginWithToken(bambooSession) {
|
|
13193
|
+
const result = await validateAndWriteHeadlessCreds(bambooSession);
|
|
13194
|
+
switch (result.kind) {
|
|
13195
|
+
case "success": {
|
|
13196
|
+
console.log("");
|
|
13197
|
+
console.log(
|
|
13198
|
+
` \u2713 Logged in${result.githubUsername ? ` as @${result.githubUsername}` : ""} (headless).`
|
|
13199
|
+
);
|
|
13200
|
+
console.log("");
|
|
13201
|
+
return;
|
|
13202
|
+
}
|
|
13203
|
+
case "invalid_token": {
|
|
13204
|
+
console.error("");
|
|
13205
|
+
console.error(` Invalid token: ${result.message}`);
|
|
13206
|
+
console.error(
|
|
13207
|
+
" Mint a fresh token from your Bamboo workspace and retry."
|
|
13208
|
+
);
|
|
13209
|
+
console.error("");
|
|
13210
|
+
process.exit(1);
|
|
13211
|
+
}
|
|
13212
|
+
case "network_error": {
|
|
13213
|
+
console.error("");
|
|
13214
|
+
console.error(` Network error: ${result.message}`);
|
|
13215
|
+
console.error(
|
|
13216
|
+
` Verify $BAMBOO_BASE_URL (${apiBase()}) is reachable and retry.`
|
|
13217
|
+
);
|
|
13218
|
+
console.error("");
|
|
13219
|
+
process.exit(2);
|
|
13220
|
+
}
|
|
13221
|
+
}
|
|
13222
|
+
}
|
|
13114
13223
|
async function runLogin() {
|
|
13115
13224
|
const state = randomBytes2(32).toString("hex");
|
|
13116
13225
|
const code = verificationCode(state);
|
|
@@ -13472,13 +13581,19 @@ async function runInit(options = {}) {
|
|
|
13472
13581
|
process.exit(1);
|
|
13473
13582
|
}
|
|
13474
13583
|
gitSpinner.succeed(`git ${version.join(".")} ready (${gitEmail})`);
|
|
13475
|
-
|
|
13476
|
-
|
|
13477
|
-
|
|
13478
|
-
|
|
13479
|
-
|
|
13480
|
-
|
|
13481
|
-
|
|
13584
|
+
if (creds.github_token) {
|
|
13585
|
+
const credSpinner = ora("Installing GitHub credential into git\u2026").start();
|
|
13586
|
+
try {
|
|
13587
|
+
await installGithubCredential(creds.github_token);
|
|
13588
|
+
credSpinner.succeed("GitHub credential installed");
|
|
13589
|
+
} catch (err) {
|
|
13590
|
+
credSpinner.fail(`Couldn't install git credential: ${err.message}`);
|
|
13591
|
+
process.exit(1);
|
|
13592
|
+
}
|
|
13593
|
+
} else {
|
|
13594
|
+
console.log(
|
|
13595
|
+
" Skipping git credential install \u2014 credentials are headless (no GitHub token)."
|
|
13596
|
+
);
|
|
13482
13597
|
}
|
|
13483
13598
|
const orgSlug = slugify(membership.org.name);
|
|
13484
13599
|
const canonicalPath = defaultClonePath(orgSlug);
|
|
@@ -15135,20 +15250,20 @@ async function currentBranch(repoPath) {
|
|
|
15135
15250
|
return out.trim() || "main";
|
|
15136
15251
|
}
|
|
15137
15252
|
async function requireSession(opts) {
|
|
15138
|
-
const
|
|
15139
|
-
if (!
|
|
15253
|
+
const session = await resolveSession();
|
|
15254
|
+
if (!session) {
|
|
15140
15255
|
emitError(
|
|
15141
15256
|
{
|
|
15142
15257
|
code: "not_signed_in",
|
|
15143
15258
|
message: "not signed in.",
|
|
15144
|
-
hint: "Run `bamboo-agents login` first."
|
|
15259
|
+
hint: "Run `bamboo-agents login` first (or set BAMBOO_API_TOKEN for headless use)."
|
|
15145
15260
|
},
|
|
15146
15261
|
opts,
|
|
15147
15262
|
1
|
|
15148
15263
|
);
|
|
15149
15264
|
throw new Error("unreachable");
|
|
15150
15265
|
}
|
|
15151
|
-
return
|
|
15266
|
+
return session;
|
|
15152
15267
|
}
|
|
15153
15268
|
async function runSave(intent, options = {}) {
|
|
15154
15269
|
const opts = options;
|
|
@@ -17079,20 +17194,20 @@ __export(knowledge_exports, {
|
|
|
17079
17194
|
});
|
|
17080
17195
|
import { readFile as readFile7 } from "node:fs/promises";
|
|
17081
17196
|
async function requireSession3(opts) {
|
|
17082
|
-
const
|
|
17083
|
-
if (!
|
|
17197
|
+
const session = await resolveSession();
|
|
17198
|
+
if (!session) {
|
|
17084
17199
|
emitError(
|
|
17085
17200
|
{
|
|
17086
17201
|
code: "not_signed_in",
|
|
17087
17202
|
message: "not signed in.",
|
|
17088
|
-
hint: "Run `bamboo-agents login` first."
|
|
17203
|
+
hint: "Run `bamboo-agents login` first (or set BAMBOO_API_TOKEN for headless use)."
|
|
17089
17204
|
},
|
|
17090
17205
|
opts,
|
|
17091
17206
|
1
|
|
17092
17207
|
);
|
|
17093
17208
|
throw new Error("unreachable");
|
|
17094
17209
|
}
|
|
17095
|
-
return
|
|
17210
|
+
return session;
|
|
17096
17211
|
}
|
|
17097
17212
|
function padRight2(s, n) {
|
|
17098
17213
|
return s.length >= n ? s : s + " ".repeat(n - s.length);
|
|
@@ -18174,7 +18289,15 @@ program2.action(async () => {
|
|
|
18174
18289
|
const { runOrchestrator: runOrchestrator2 } = await Promise.resolve().then(() => (init_orchestrator(), orchestrator_exports));
|
|
18175
18290
|
await runOrchestrator2();
|
|
18176
18291
|
});
|
|
18177
|
-
program2.command("login").description("Sign in to Bamboo via your browser").
|
|
18292
|
+
program2.command("login").description("Sign in to Bamboo via your browser (or use --token for headless setup)").option(
|
|
18293
|
+
"--token <session>",
|
|
18294
|
+
"Headless login with a pre-minted Bamboo session token (skips the browser flow). Used by managed agents + CI environments."
|
|
18295
|
+
).action(async (opts) => {
|
|
18296
|
+
if (opts.token) {
|
|
18297
|
+
const { runLoginWithToken: runLoginWithToken2 } = await Promise.resolve().then(() => (init_login(), login_exports));
|
|
18298
|
+
await runLoginWithToken2(opts.token);
|
|
18299
|
+
return;
|
|
18300
|
+
}
|
|
18178
18301
|
const { runLogin: runLogin2 } = await Promise.resolve().then(() => (init_login(), login_exports));
|
|
18179
18302
|
await runLogin2();
|
|
18180
18303
|
});
|