bamboo-agents 0.1.5-dev.58.9abca08 → 0.1.5-dev.60.6d2930c
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 +308 -23
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1.5-dev.
|
|
1
|
+
0.1.5-dev.60.6d2930c
|
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.60.6d2930c";
|
|
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(),
|
|
@@ -12355,6 +12389,65 @@ var init_brand = __esm({
|
|
|
12355
12389
|
}
|
|
12356
12390
|
});
|
|
12357
12391
|
|
|
12392
|
+
// ../../src/lib/api-contracts/cli/skill-apply.ts
|
|
12393
|
+
var SkillEditOpSchema, SkillApplyRequestSchema, SkillApplySuccessResponseSchema;
|
|
12394
|
+
var init_skill_apply = __esm({
|
|
12395
|
+
"../../src/lib/api-contracts/cli/skill-apply.ts"() {
|
|
12396
|
+
init_zod();
|
|
12397
|
+
SkillEditOpSchema = external_exports.object({
|
|
12398
|
+
op: external_exports.enum(["add", "delete", "replace"]),
|
|
12399
|
+
anchor: external_exports.string().min(1).describe(
|
|
12400
|
+
"The section heading the op targets, verbatim including the `#` prefix."
|
|
12401
|
+
),
|
|
12402
|
+
before: external_exports.string().optional().describe(
|
|
12403
|
+
"Exact existing text to find. Required for `replace` and `delete`."
|
|
12404
|
+
),
|
|
12405
|
+
after: external_exports.string().optional().describe("New text. Required for `add` and `replace`.")
|
|
12406
|
+
}).superRefine((val, ctx) => {
|
|
12407
|
+
if ((val.op === "replace" || val.op === "delete") && !val.before) {
|
|
12408
|
+
ctx.addIssue({
|
|
12409
|
+
code: external_exports.ZodIssueCode.custom,
|
|
12410
|
+
message: `op '${val.op}' requires 'before'`,
|
|
12411
|
+
path: ["before"]
|
|
12412
|
+
});
|
|
12413
|
+
}
|
|
12414
|
+
if ((val.op === "replace" || val.op === "add") && !val.after) {
|
|
12415
|
+
ctx.addIssue({
|
|
12416
|
+
code: external_exports.ZodIssueCode.custom,
|
|
12417
|
+
message: `op '${val.op}' requires 'after'`,
|
|
12418
|
+
path: ["after"]
|
|
12419
|
+
});
|
|
12420
|
+
}
|
|
12421
|
+
});
|
|
12422
|
+
SkillApplyRequestSchema = external_exports.object({
|
|
12423
|
+
skill_name: external_exports.string().min(1).describe("Kebab-case skill name, e.g. `draft-content`."),
|
|
12424
|
+
current_skill_body: external_exports.string().min(1).describe(
|
|
12425
|
+
"The SKILL.md body the ops were reasoned against. For a Library skill with no per-org fork yet, pass the bundled body \u2014 the fork writes that same body, so the ops still apply."
|
|
12426
|
+
),
|
|
12427
|
+
ops: external_exports.array(SkillEditOpSchema).describe(
|
|
12428
|
+
"Bounded add/delete/replace ops (1\u20138). Budget + protected-section rules enforced in `applyOps` server-side."
|
|
12429
|
+
),
|
|
12430
|
+
behavior_summary: external_exports.string().min(1).describe(
|
|
12431
|
+
"One plain-English sentence describing the behavior change (what the user approves on the card)."
|
|
12432
|
+
)
|
|
12433
|
+
});
|
|
12434
|
+
SkillApplySuccessResponseSchema = external_exports.object({
|
|
12435
|
+
proposed: external_exports.literal(true),
|
|
12436
|
+
/** Whether a Library skill was forked into the workspace before applying ops. */
|
|
12437
|
+
forked: external_exports.boolean(),
|
|
12438
|
+
skill: external_exports.string(),
|
|
12439
|
+
repo_path: external_exports.string(),
|
|
12440
|
+
pr_number: external_exports.number().int().nullable(),
|
|
12441
|
+
pr_url: external_exports.string().url().nullable(),
|
|
12442
|
+
applied_ops: external_exports.number().int(),
|
|
12443
|
+
dropped_protected: external_exports.number().int(),
|
|
12444
|
+
behavior_summary: external_exports.string(),
|
|
12445
|
+
/** Plain-English next-step hint for the agent's log. */
|
|
12446
|
+
note: external_exports.string()
|
|
12447
|
+
});
|
|
12448
|
+
}
|
|
12449
|
+
});
|
|
12450
|
+
|
|
12358
12451
|
// ../../src/lib/api-contracts/cli/context-health.ts
|
|
12359
12452
|
var ScopeKindSchema, ScopeSchema, CriterionMetricsSchema, StatusSchema, CriterionContributionSchema, CriterionResultSchema, BucketScoresSchema, ResolvedScopeSchema, GapsSchema, HealthyResponseSchema, UnavailableResponseSchema, ContextHealthResponseSchema;
|
|
12360
12453
|
var init_context_health = __esm({
|
|
@@ -12530,6 +12623,19 @@ async function getKnowledgeSlots(bambooSession) {
|
|
|
12530
12623
|
const json = await res.json();
|
|
12531
12624
|
return KnowledgeSlotsResponseSchema.parse(json);
|
|
12532
12625
|
}
|
|
12626
|
+
async function applySkillEdit(bambooSession, body) {
|
|
12627
|
+
const res = await cliApiFetch(`${apiBase()}/api/v1/cli/skill-apply`, {
|
|
12628
|
+
method: "POST",
|
|
12629
|
+
headers: {
|
|
12630
|
+
Authorization: `Bearer ${bambooSession}`,
|
|
12631
|
+
"Content-Type": "application/json"
|
|
12632
|
+
},
|
|
12633
|
+
body: JSON.stringify(body)
|
|
12634
|
+
});
|
|
12635
|
+
if (!res.ok) throw await parseError(res);
|
|
12636
|
+
const json = await res.json();
|
|
12637
|
+
return SkillApplySuccessResponseSchema.parse(json);
|
|
12638
|
+
}
|
|
12533
12639
|
async function saveKnowledge(bambooSession, body) {
|
|
12534
12640
|
const res = await cliApiFetch(`${apiBase()}/api/v1/cli/knowledge/save`, {
|
|
12535
12641
|
method: "POST",
|
|
@@ -12912,6 +13018,7 @@ var init_api = __esm({
|
|
|
12912
13018
|
init_agents();
|
|
12913
13019
|
init_knowledge_slots();
|
|
12914
13020
|
init_knowledge_save();
|
|
13021
|
+
init_skill_apply();
|
|
12915
13022
|
init_save();
|
|
12916
13023
|
init_history();
|
|
12917
13024
|
init_changes();
|
|
@@ -12983,8 +13090,11 @@ var login_exports = {};
|
|
|
12983
13090
|
__export(login_exports, {
|
|
12984
13091
|
TOKEN_POLL: () => TOKEN_POLL,
|
|
12985
13092
|
handleMissingGithubToken: () => handleMissingGithubToken,
|
|
13093
|
+
isAgentScopedKey: () => isAgentScopedKey,
|
|
12986
13094
|
runLogin: () => runLogin,
|
|
13095
|
+
runLoginWithToken: () => runLoginWithToken,
|
|
12987
13096
|
startCallbackServer: () => startCallbackServer,
|
|
13097
|
+
validateAndWriteHeadlessCreds: () => validateAndWriteHeadlessCreds,
|
|
12988
13098
|
verificationCode: () => verificationCode
|
|
12989
13099
|
});
|
|
12990
13100
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
@@ -13036,10 +13146,10 @@ async function handleMissingGithubToken(bambooSession) {
|
|
|
13036
13146
|
return null;
|
|
13037
13147
|
}
|
|
13038
13148
|
async function startCallbackServer(expectedState) {
|
|
13039
|
-
let
|
|
13149
|
+
let resolveSession2;
|
|
13040
13150
|
let rejectSession;
|
|
13041
13151
|
const session = new Promise((resolve2, reject) => {
|
|
13042
|
-
|
|
13152
|
+
resolveSession2 = resolve2;
|
|
13043
13153
|
rejectSession = reject;
|
|
13044
13154
|
});
|
|
13045
13155
|
const server = createServer((req, res) => {
|
|
@@ -13083,7 +13193,7 @@ async function startCallbackServer(expectedState) {
|
|
|
13083
13193
|
return;
|
|
13084
13194
|
}
|
|
13085
13195
|
respondCors(200, { ok: true });
|
|
13086
|
-
|
|
13196
|
+
resolveSession2(body.session);
|
|
13087
13197
|
setTimeout(() => server.close(), 100);
|
|
13088
13198
|
});
|
|
13089
13199
|
});
|
|
@@ -13111,6 +13221,78 @@ async function startCallbackServer(expectedState) {
|
|
|
13111
13221
|
session: session.finally(() => clearTimeout(timer))
|
|
13112
13222
|
};
|
|
13113
13223
|
}
|
|
13224
|
+
function isAgentScopedKey(token) {
|
|
13225
|
+
return token.startsWith("bam_live_");
|
|
13226
|
+
}
|
|
13227
|
+
async function validateAndWriteHeadlessCreds(bambooSession) {
|
|
13228
|
+
if (!isAgentScopedKey(bambooSession)) {
|
|
13229
|
+
try {
|
|
13230
|
+
await getCliAuthStatus(bambooSession);
|
|
13231
|
+
} catch (err) {
|
|
13232
|
+
if (err instanceof ApiError) {
|
|
13233
|
+
if (err.status === 401) {
|
|
13234
|
+
return {
|
|
13235
|
+
kind: "invalid_token",
|
|
13236
|
+
message: "The token was rejected by Bamboo's auth check."
|
|
13237
|
+
};
|
|
13238
|
+
}
|
|
13239
|
+
if (err.status >= 400 && err.status < 500) {
|
|
13240
|
+
return {
|
|
13241
|
+
kind: "invalid_token",
|
|
13242
|
+
message: `Bamboo's auth check returned ${err.status}: ${err.message}`
|
|
13243
|
+
};
|
|
13244
|
+
}
|
|
13245
|
+
return {
|
|
13246
|
+
kind: "network_error",
|
|
13247
|
+
message: `Bamboo's auth check returned ${err.status}: ${err.message}`
|
|
13248
|
+
};
|
|
13249
|
+
}
|
|
13250
|
+
return {
|
|
13251
|
+
kind: "network_error",
|
|
13252
|
+
message: err?.message ?? String(err)
|
|
13253
|
+
};
|
|
13254
|
+
}
|
|
13255
|
+
}
|
|
13256
|
+
await writeCredentials({
|
|
13257
|
+
bamboo_session: bambooSession,
|
|
13258
|
+
github_token: "",
|
|
13259
|
+
github_token_expires_at: null,
|
|
13260
|
+
github_username: null,
|
|
13261
|
+
written_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
13262
|
+
});
|
|
13263
|
+
return { kind: "success", githubUsername: null };
|
|
13264
|
+
}
|
|
13265
|
+
async function runLoginWithToken(bambooSession) {
|
|
13266
|
+
const result = await validateAndWriteHeadlessCreds(bambooSession);
|
|
13267
|
+
switch (result.kind) {
|
|
13268
|
+
case "success": {
|
|
13269
|
+
console.log("");
|
|
13270
|
+
console.log(
|
|
13271
|
+
` \u2713 Logged in${result.githubUsername ? ` as @${result.githubUsername}` : ""} (headless).`
|
|
13272
|
+
);
|
|
13273
|
+
console.log("");
|
|
13274
|
+
return;
|
|
13275
|
+
}
|
|
13276
|
+
case "invalid_token": {
|
|
13277
|
+
console.error("");
|
|
13278
|
+
console.error(` Invalid token: ${result.message}`);
|
|
13279
|
+
console.error(
|
|
13280
|
+
" Mint a fresh token from your Bamboo workspace and retry."
|
|
13281
|
+
);
|
|
13282
|
+
console.error("");
|
|
13283
|
+
process.exit(1);
|
|
13284
|
+
}
|
|
13285
|
+
case "network_error": {
|
|
13286
|
+
console.error("");
|
|
13287
|
+
console.error(` Network error: ${result.message}`);
|
|
13288
|
+
console.error(
|
|
13289
|
+
` Verify $BAMBOO_BASE_URL (${apiBase()}) is reachable and retry.`
|
|
13290
|
+
);
|
|
13291
|
+
console.error("");
|
|
13292
|
+
process.exit(2);
|
|
13293
|
+
}
|
|
13294
|
+
}
|
|
13295
|
+
}
|
|
13114
13296
|
async function runLogin() {
|
|
13115
13297
|
const state = randomBytes2(32).toString("hex");
|
|
13116
13298
|
const code = verificationCode(state);
|
|
@@ -13472,13 +13654,19 @@ async function runInit(options = {}) {
|
|
|
13472
13654
|
process.exit(1);
|
|
13473
13655
|
}
|
|
13474
13656
|
gitSpinner.succeed(`git ${version.join(".")} ready (${gitEmail})`);
|
|
13475
|
-
|
|
13476
|
-
|
|
13477
|
-
|
|
13478
|
-
|
|
13479
|
-
|
|
13480
|
-
|
|
13481
|
-
|
|
13657
|
+
if (creds.github_token) {
|
|
13658
|
+
const credSpinner = ora("Installing GitHub credential into git\u2026").start();
|
|
13659
|
+
try {
|
|
13660
|
+
await installGithubCredential(creds.github_token);
|
|
13661
|
+
credSpinner.succeed("GitHub credential installed");
|
|
13662
|
+
} catch (err) {
|
|
13663
|
+
credSpinner.fail(`Couldn't install git credential: ${err.message}`);
|
|
13664
|
+
process.exit(1);
|
|
13665
|
+
}
|
|
13666
|
+
} else {
|
|
13667
|
+
console.log(
|
|
13668
|
+
" Skipping git credential install \u2014 credentials are headless (no GitHub token)."
|
|
13669
|
+
);
|
|
13482
13670
|
}
|
|
13483
13671
|
const orgSlug = slugify(membership.org.name);
|
|
13484
13672
|
const canonicalPath = defaultClonePath(orgSlug);
|
|
@@ -15135,20 +15323,20 @@ async function currentBranch(repoPath) {
|
|
|
15135
15323
|
return out.trim() || "main";
|
|
15136
15324
|
}
|
|
15137
15325
|
async function requireSession(opts) {
|
|
15138
|
-
const
|
|
15139
|
-
if (!
|
|
15326
|
+
const session = await resolveSession();
|
|
15327
|
+
if (!session) {
|
|
15140
15328
|
emitError(
|
|
15141
15329
|
{
|
|
15142
15330
|
code: "not_signed_in",
|
|
15143
15331
|
message: "not signed in.",
|
|
15144
|
-
hint: "Run `bamboo-agents login` first."
|
|
15332
|
+
hint: "Run `bamboo-agents login` first (or set BAMBOO_API_TOKEN for headless use)."
|
|
15145
15333
|
},
|
|
15146
15334
|
opts,
|
|
15147
15335
|
1
|
|
15148
15336
|
);
|
|
15149
15337
|
throw new Error("unreachable");
|
|
15150
15338
|
}
|
|
15151
|
-
return
|
|
15339
|
+
return session;
|
|
15152
15340
|
}
|
|
15153
15341
|
async function runSave(intent, options = {}) {
|
|
15154
15342
|
const opts = options;
|
|
@@ -16723,6 +16911,7 @@ var init_skills_local = __esm({
|
|
|
16723
16911
|
// src/commands/skills.ts
|
|
16724
16912
|
var skills_exports = {};
|
|
16725
16913
|
__export(skills_exports, {
|
|
16914
|
+
runSkillsApply: () => runSkillsApply,
|
|
16726
16915
|
runSkillsCreate: () => runSkillsCreate,
|
|
16727
16916
|
runSkillsGet: () => runSkillsGet,
|
|
16728
16917
|
runSkillsList: () => runSkillsList,
|
|
@@ -17060,6 +17249,88 @@ async function runSkillsUpdateImpl(agentIdentifier, skillName) {
|
|
|
17060
17249
|
console.log(" git -C $(bamboo-agents status) pull");
|
|
17061
17250
|
console.log("");
|
|
17062
17251
|
}
|
|
17252
|
+
async function readJsonFromStdin() {
|
|
17253
|
+
if (process.stdin.isTTY) {
|
|
17254
|
+
throw new Error(
|
|
17255
|
+
"expected JSON on stdin (no input piped). Example: `bamboo-agents skills apply <skill> < lesson.json`"
|
|
17256
|
+
);
|
|
17257
|
+
}
|
|
17258
|
+
const chunks = [];
|
|
17259
|
+
for await (const chunk of process.stdin) {
|
|
17260
|
+
chunks.push(chunk);
|
|
17261
|
+
}
|
|
17262
|
+
const raw = Buffer.concat(chunks).toString("utf8").trim();
|
|
17263
|
+
if (!raw) {
|
|
17264
|
+
throw new Error("stdin was empty \u2014 pipe a JSON body in.");
|
|
17265
|
+
}
|
|
17266
|
+
try {
|
|
17267
|
+
return JSON.parse(raw);
|
|
17268
|
+
} catch (err) {
|
|
17269
|
+
throw new Error(`stdin is not valid JSON: ${err.message}`);
|
|
17270
|
+
}
|
|
17271
|
+
}
|
|
17272
|
+
async function runSkillsApply(skillName) {
|
|
17273
|
+
const envToken = process.env.BAMBOO_API_TOKEN?.trim();
|
|
17274
|
+
let session = null;
|
|
17275
|
+
if (envToken) {
|
|
17276
|
+
session = envToken;
|
|
17277
|
+
} else {
|
|
17278
|
+
const creds = await readCredentials();
|
|
17279
|
+
session = creds?.bamboo_session ?? null;
|
|
17280
|
+
}
|
|
17281
|
+
if (!session) {
|
|
17282
|
+
console.error(
|
|
17283
|
+
"bamboo-agents: not signed in. Run `bamboo-agents login` first (or set BAMBOO_API_TOKEN for headless / managed-agent use)."
|
|
17284
|
+
);
|
|
17285
|
+
process.exit(1);
|
|
17286
|
+
}
|
|
17287
|
+
let body;
|
|
17288
|
+
try {
|
|
17289
|
+
const raw = await readJsonFromStdin();
|
|
17290
|
+
if (typeof raw !== "object" || raw === null) {
|
|
17291
|
+
throw new Error("stdin JSON must be an object");
|
|
17292
|
+
}
|
|
17293
|
+
body = { ...raw, skill_name: skillName };
|
|
17294
|
+
} catch (err) {
|
|
17295
|
+
console.error(`bamboo-agents: ${err.message}`);
|
|
17296
|
+
process.exit(1);
|
|
17297
|
+
}
|
|
17298
|
+
try {
|
|
17299
|
+
const result = await applySkillEdit(session, body);
|
|
17300
|
+
console.log("");
|
|
17301
|
+
console.log(
|
|
17302
|
+
` \u2713 Queued skill-edit PR \u2014 the "Boo is learning" card is in the inbox.`
|
|
17303
|
+
);
|
|
17304
|
+
console.log("");
|
|
17305
|
+
console.log(` Skill: ${result.skill}`);
|
|
17306
|
+
console.log(` Behavior: ${result.behavior_summary}`);
|
|
17307
|
+
console.log(` Applied ops: ${result.applied_ops}`);
|
|
17308
|
+
if (result.dropped_protected > 0) {
|
|
17309
|
+
console.log(
|
|
17310
|
+
` Dropped protected: ${result.dropped_protected} (anchor hit a <!-- protected --> section)`
|
|
17311
|
+
);
|
|
17312
|
+
}
|
|
17313
|
+
if (result.forked) {
|
|
17314
|
+
console.log(` Forked Library skill into the workspace first.`);
|
|
17315
|
+
}
|
|
17316
|
+
if (result.pr_url) {
|
|
17317
|
+
console.log(` PR: ${result.pr_url}`);
|
|
17318
|
+
}
|
|
17319
|
+
console.log("");
|
|
17320
|
+
console.log(` ${result.note}`);
|
|
17321
|
+
console.log("");
|
|
17322
|
+
} catch (err) {
|
|
17323
|
+
if (err instanceof ApiError) {
|
|
17324
|
+
const exitCode = err.status >= 500 ? 2 : 1;
|
|
17325
|
+
console.error("");
|
|
17326
|
+
console.error(` bamboo-agents: ${err.message}`);
|
|
17327
|
+
console.error("");
|
|
17328
|
+
process.exit(exitCode);
|
|
17329
|
+
}
|
|
17330
|
+
console.error(`bamboo-agents: ${err.message}`);
|
|
17331
|
+
process.exit(2);
|
|
17332
|
+
}
|
|
17333
|
+
}
|
|
17063
17334
|
var init_skills = __esm({
|
|
17064
17335
|
"src/commands/skills.ts"() {
|
|
17065
17336
|
"use strict";
|
|
@@ -17079,20 +17350,20 @@ __export(knowledge_exports, {
|
|
|
17079
17350
|
});
|
|
17080
17351
|
import { readFile as readFile7 } from "node:fs/promises";
|
|
17081
17352
|
async function requireSession3(opts) {
|
|
17082
|
-
const
|
|
17083
|
-
if (!
|
|
17353
|
+
const session = await resolveSession();
|
|
17354
|
+
if (!session) {
|
|
17084
17355
|
emitError(
|
|
17085
17356
|
{
|
|
17086
17357
|
code: "not_signed_in",
|
|
17087
17358
|
message: "not signed in.",
|
|
17088
|
-
hint: "Run `bamboo-agents login` first."
|
|
17359
|
+
hint: "Run `bamboo-agents login` first (or set BAMBOO_API_TOKEN for headless use)."
|
|
17089
17360
|
},
|
|
17090
17361
|
opts,
|
|
17091
17362
|
1
|
|
17092
17363
|
);
|
|
17093
17364
|
throw new Error("unreachable");
|
|
17094
17365
|
}
|
|
17095
|
-
return
|
|
17366
|
+
return session;
|
|
17096
17367
|
}
|
|
17097
17368
|
function padRight2(s, n) {
|
|
17098
17369
|
return s.length >= n ? s : s + " ".repeat(n - s.length);
|
|
@@ -18174,7 +18445,15 @@ program2.action(async () => {
|
|
|
18174
18445
|
const { runOrchestrator: runOrchestrator2 } = await Promise.resolve().then(() => (init_orchestrator(), orchestrator_exports));
|
|
18175
18446
|
await runOrchestrator2();
|
|
18176
18447
|
});
|
|
18177
|
-
program2.command("login").description("Sign in to Bamboo via your browser").
|
|
18448
|
+
program2.command("login").description("Sign in to Bamboo via your browser (or use --token for headless setup)").option(
|
|
18449
|
+
"--token <session>",
|
|
18450
|
+
"Headless login with a pre-minted Bamboo session token (skips the browser flow). Used by managed agents + CI environments."
|
|
18451
|
+
).action(async (opts) => {
|
|
18452
|
+
if (opts.token) {
|
|
18453
|
+
const { runLoginWithToken: runLoginWithToken2 } = await Promise.resolve().then(() => (init_login(), login_exports));
|
|
18454
|
+
await runLoginWithToken2(opts.token);
|
|
18455
|
+
return;
|
|
18456
|
+
}
|
|
18178
18457
|
const { runLogin: runLogin2 } = await Promise.resolve().then(() => (init_login(), login_exports));
|
|
18179
18458
|
await runLogin2();
|
|
18180
18459
|
});
|
|
@@ -18237,6 +18516,12 @@ skills.command("update <agent> <skill-name>").description("Update an installed s
|
|
|
18237
18516
|
const { runSkillsUpdate: runSkillsUpdate2 } = await Promise.resolve().then(() => (init_skills(), skills_exports));
|
|
18238
18517
|
await runSkillsUpdate2(agent, skillName);
|
|
18239
18518
|
});
|
|
18519
|
+
skills.command("apply <skill-name>").description(
|
|
18520
|
+
'Apply a bounded skill edit \u2014 opens a queued, human-gated PR (the "Boo is learning" card). Reads JSON body from stdin.'
|
|
18521
|
+
).option("--no-sync", "Skip the auto-sync git pull on this command").action(async (skillName) => {
|
|
18522
|
+
const { runSkillsApply: runSkillsApply2 } = await Promise.resolve().then(() => (init_skills(), skills_exports));
|
|
18523
|
+
await runSkillsApply2(skillName);
|
|
18524
|
+
});
|
|
18240
18525
|
var knowledge = program2.command("knowledge").description("Knowledge surface for CLI-first skills");
|
|
18241
18526
|
knowledge.command("slots").description("Print the knowledge slot schema (kind \xD7 scope \u2192 path) + dimensions").option("--json", "Emit a JSON envelope for agent consumption").option("--fields <list>", "Project only these dotted field paths from data (comma-separated)").option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(async (options) => {
|
|
18242
18527
|
const { runKnowledgeSlots: runKnowledgeSlots2 } = await Promise.resolve().then(() => (init_knowledge(), knowledge_exports));
|