bamboo-agents 0.1.5-dev.22 → 0.1.5-dev.24
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 +636 -5
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
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.24";
|
|
3041
3041
|
}
|
|
3042
3042
|
});
|
|
3043
3043
|
|
|
@@ -11483,7 +11483,8 @@ var init_auth_status = __esm({
|
|
|
11483
11483
|
});
|
|
11484
11484
|
MembershipSchema = external_exports.object({
|
|
11485
11485
|
org: OrgRefSchema,
|
|
11486
|
-
|
|
11486
|
+
// BAM-2229: `owner` collapsed into `admin`.
|
|
11487
|
+
role: external_exports.enum(["admin", "member"]),
|
|
11487
11488
|
workspace_ready: external_exports.boolean()
|
|
11488
11489
|
});
|
|
11489
11490
|
InviterSchema = external_exports.object({
|
|
@@ -11540,6 +11541,105 @@ var init_agent_health = __esm({
|
|
|
11540
11541
|
}
|
|
11541
11542
|
});
|
|
11542
11543
|
|
|
11544
|
+
// ../../src/lib/api-contracts/cli/onboarding-next-prompt.ts
|
|
11545
|
+
var OnboardingNextPromptResponseSchema;
|
|
11546
|
+
var init_onboarding_next_prompt = __esm({
|
|
11547
|
+
"../../src/lib/api-contracts/cli/onboarding-next-prompt.ts"() {
|
|
11548
|
+
init_zod();
|
|
11549
|
+
OnboardingNextPromptResponseSchema = external_exports.object({
|
|
11550
|
+
/** Checklist item key from `compute_onboarding_status.next_best_step.key`.
|
|
11551
|
+
* Empty string when there's no next step at all. */
|
|
11552
|
+
key: external_exports.string(),
|
|
11553
|
+
/** Human-readable item label (e.g., "Add Important Context"). */
|
|
11554
|
+
label: external_exports.string(),
|
|
11555
|
+
/** The question to ask the user. `null` when no prompt is available
|
|
11556
|
+
* for this item (CLI treats null as "skip"). */
|
|
11557
|
+
prompt: external_exports.string().nullable(),
|
|
11558
|
+
/** Optional one-liner explaining why answering this matters. Surfaces
|
|
11559
|
+
* above the prompt as `💡 <impact>` in the CLI. */
|
|
11560
|
+
impact: external_exports.string().nullable(),
|
|
11561
|
+
/** Workspace-repo-relative path where the answer should be written.
|
|
11562
|
+
* Non-null ONLY when `key === 'knowledge'` — the only item v1 saves
|
|
11563
|
+
* inline from the CLI. Other keys get `null` (CLI skips). */
|
|
11564
|
+
save_path: external_exports.string().nullable()
|
|
11565
|
+
});
|
|
11566
|
+
}
|
|
11567
|
+
});
|
|
11568
|
+
|
|
11569
|
+
// ../../src/lib/api-contracts/cli/agents.ts
|
|
11570
|
+
var SlugSchema, NameSchema, BrandIdSchema, CliAgentRowSchema, CliTierCapSchema, CliAgentsListResponseSchema, CliCreateAgentRequestSchema, CliAgentMutationResponseBase, CliCreateAgentResponseSchema, UPLOAD_MAX_BYTES, CliUploadAgentRequestSchema, CliUploadAgentResponseSchema, CliBrandRowSchema, CliBrandsListResponseSchema;
|
|
11571
|
+
var init_agents = __esm({
|
|
11572
|
+
"../../src/lib/api-contracts/cli/agents.ts"() {
|
|
11573
|
+
init_zod();
|
|
11574
|
+
SlugSchema = external_exports.string().min(1).max(63).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, "slug must be lowercase kebab-case");
|
|
11575
|
+
NameSchema = external_exports.string().min(1).max(120);
|
|
11576
|
+
BrandIdSchema = external_exports.string().uuid();
|
|
11577
|
+
CliAgentRowSchema = external_exports.object({
|
|
11578
|
+
id: external_exports.string().uuid(),
|
|
11579
|
+
name: external_exports.string(),
|
|
11580
|
+
/** `false` = user-created (eligible for picker choices).
|
|
11581
|
+
* `true` = pre-installed (MAM etc.) — shown informational-only. */
|
|
11582
|
+
is_auto_installed: external_exports.boolean(),
|
|
11583
|
+
/**
|
|
11584
|
+
* 0..100 weighted health score (round at render time). Null when
|
|
11585
|
+
* the server omits the value (BAM-2246 omits today because per-agent
|
|
11586
|
+
* health is an N round-trip fan-out; CLI fetches lazily via
|
|
11587
|
+
* `/api/v1/agents/<id>/health`). Also null for legacy agents
|
|
11588
|
+
* without an effective_rubric (pre-BAM-2084 installs).
|
|
11589
|
+
*/
|
|
11590
|
+
health_score: external_exports.number().nullable()
|
|
11591
|
+
});
|
|
11592
|
+
CliTierCapSchema = external_exports.object({
|
|
11593
|
+
limit: external_exports.number().int(),
|
|
11594
|
+
current: external_exports.number().int().nonnegative(),
|
|
11595
|
+
/** Display name for the user's tier (e.g. "Self-Serve"). */
|
|
11596
|
+
tier_name: external_exports.string().nullable()
|
|
11597
|
+
});
|
|
11598
|
+
CliAgentsListResponseSchema = external_exports.object({
|
|
11599
|
+
agents: external_exports.array(CliAgentRowSchema),
|
|
11600
|
+
tier_cap: CliTierCapSchema
|
|
11601
|
+
});
|
|
11602
|
+
CliCreateAgentRequestSchema = external_exports.object({
|
|
11603
|
+
brand_id: BrandIdSchema,
|
|
11604
|
+
name: NameSchema,
|
|
11605
|
+
slug: SlugSchema.optional()
|
|
11606
|
+
});
|
|
11607
|
+
CliAgentMutationResponseBase = external_exports.object({
|
|
11608
|
+
agent_id: external_exports.string().uuid(),
|
|
11609
|
+
/** e.g. "brands/acme/agents/paid-ads" — workspace-repo-relative. */
|
|
11610
|
+
folder_path: external_exports.string().min(1),
|
|
11611
|
+
/**
|
|
11612
|
+
* Whether the write landed straight on `main` (solo workspaces) or
|
|
11613
|
+
* was routed through a queue PR (multi-user — pending admin review).
|
|
11614
|
+
*/
|
|
11615
|
+
write_status: external_exports.enum(["instant-merged", "queued-pr"]),
|
|
11616
|
+
/**
|
|
11617
|
+
* True iff the agent already existed (slug idempotency hit). When
|
|
11618
|
+
* true, `write_status` may be `"instant-merged"` even though no file
|
|
11619
|
+
* write happened this call — the existing folder is the answer.
|
|
11620
|
+
*/
|
|
11621
|
+
reused: external_exports.boolean()
|
|
11622
|
+
});
|
|
11623
|
+
CliCreateAgentResponseSchema = CliAgentMutationResponseBase;
|
|
11624
|
+
UPLOAD_MAX_BYTES = 256 * 1024;
|
|
11625
|
+
CliUploadAgentRequestSchema = external_exports.object({
|
|
11626
|
+
brand_id: BrandIdSchema,
|
|
11627
|
+
name: NameSchema,
|
|
11628
|
+
slug: SlugSchema.optional(),
|
|
11629
|
+
/** Server caps at 256 KB and validates UTF-8. */
|
|
11630
|
+
claude_md_content: external_exports.string().min(1)
|
|
11631
|
+
});
|
|
11632
|
+
CliUploadAgentResponseSchema = CliAgentMutationResponseBase;
|
|
11633
|
+
CliBrandRowSchema = external_exports.object({
|
|
11634
|
+
id: external_exports.string().uuid(),
|
|
11635
|
+
name: external_exports.string()
|
|
11636
|
+
});
|
|
11637
|
+
CliBrandsListResponseSchema = external_exports.object({
|
|
11638
|
+
brands: external_exports.array(CliBrandRowSchema)
|
|
11639
|
+
});
|
|
11640
|
+
}
|
|
11641
|
+
});
|
|
11642
|
+
|
|
11543
11643
|
// src/lib/api.ts
|
|
11544
11644
|
import { platform as platform2 } from "node:os";
|
|
11545
11645
|
function defaultApiBase(version) {
|
|
@@ -11639,6 +11739,91 @@ async function getAgentHealth(bambooSession, agentId) {
|
|
|
11639
11739
|
const json = await res.json();
|
|
11640
11740
|
return AgentHealthResponseSchema.parse(json);
|
|
11641
11741
|
}
|
|
11742
|
+
async function getOnboardingNextPrompt(bambooSession) {
|
|
11743
|
+
const res = await cliApiFetch(
|
|
11744
|
+
`${apiBase()}/api/v1/cli/onboarding/next-prompt`,
|
|
11745
|
+
{
|
|
11746
|
+
headers: { Authorization: `Bearer ${bambooSession}` }
|
|
11747
|
+
}
|
|
11748
|
+
);
|
|
11749
|
+
if (!res.ok) throw await parseError(res);
|
|
11750
|
+
const json = await res.json();
|
|
11751
|
+
return OnboardingNextPromptResponseSchema.parse(json);
|
|
11752
|
+
}
|
|
11753
|
+
async function saveKnowledgeAnswer(bambooSession, path2, prompt, answer) {
|
|
11754
|
+
const content = formatAsMarkdown(prompt, answer);
|
|
11755
|
+
const res = await cliApiFetch(`${apiBase()}/api/v1/workspace/save`, {
|
|
11756
|
+
method: "POST",
|
|
11757
|
+
headers: {
|
|
11758
|
+
Authorization: `Bearer ${bambooSession}`,
|
|
11759
|
+
"Content-Type": "application/json"
|
|
11760
|
+
},
|
|
11761
|
+
body: JSON.stringify({
|
|
11762
|
+
edits: [{ path: path2, content, base_sha: null }],
|
|
11763
|
+
intent: "Save Boo's first-chat answer"
|
|
11764
|
+
})
|
|
11765
|
+
});
|
|
11766
|
+
if (!res.ok) throw await parseError(res);
|
|
11767
|
+
await res.json().catch(() => void 0);
|
|
11768
|
+
}
|
|
11769
|
+
function formatAsMarkdown(prompt, answer) {
|
|
11770
|
+
const stamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
11771
|
+
return `# ${prompt}
|
|
11772
|
+
|
|
11773
|
+
${answer}
|
|
11774
|
+
|
|
11775
|
+
---
|
|
11776
|
+
Saved by Boo via CLI magic-moment, ${stamp}.
|
|
11777
|
+
`;
|
|
11778
|
+
}
|
|
11779
|
+
async function listCliAgents(bambooSession) {
|
|
11780
|
+
const res = await cliApiFetch(`${apiBase()}/api/v1/cli/agents`, {
|
|
11781
|
+
headers: { Authorization: `Bearer ${bambooSession}` }
|
|
11782
|
+
});
|
|
11783
|
+
if (!res.ok) throw await parseError(res);
|
|
11784
|
+
const json = await res.json();
|
|
11785
|
+
return CliAgentsListResponseSchema.parse(json);
|
|
11786
|
+
}
|
|
11787
|
+
async function listCliBrands(bambooSession) {
|
|
11788
|
+
const res = await cliApiFetch(`${apiBase()}/api/v1/cli/brands`, {
|
|
11789
|
+
headers: { Authorization: `Bearer ${bambooSession}` }
|
|
11790
|
+
});
|
|
11791
|
+
if (!res.ok) throw await parseError(res);
|
|
11792
|
+
const json = await res.json();
|
|
11793
|
+
return CliBrandsListResponseSchema.parse(json);
|
|
11794
|
+
}
|
|
11795
|
+
async function createAgentFromCli(bambooSession, body) {
|
|
11796
|
+
const res = await cliApiFetch(
|
|
11797
|
+
`${apiBase()}/api/v1/cli/agents/create-from-cli`,
|
|
11798
|
+
{
|
|
11799
|
+
method: "POST",
|
|
11800
|
+
headers: {
|
|
11801
|
+
Authorization: `Bearer ${bambooSession}`,
|
|
11802
|
+
"Content-Type": "application/json"
|
|
11803
|
+
},
|
|
11804
|
+
body: JSON.stringify(body)
|
|
11805
|
+
}
|
|
11806
|
+
);
|
|
11807
|
+
if (!res.ok) throw await parseError(res);
|
|
11808
|
+
const json = await res.json();
|
|
11809
|
+
return CliCreateAgentResponseSchema.parse(json);
|
|
11810
|
+
}
|
|
11811
|
+
async function uploadClaudeMdFromCli(bambooSession, body) {
|
|
11812
|
+
const res = await cliApiFetch(
|
|
11813
|
+
`${apiBase()}/api/v1/cli/agents/upload-claude-md`,
|
|
11814
|
+
{
|
|
11815
|
+
method: "POST",
|
|
11816
|
+
headers: {
|
|
11817
|
+
Authorization: `Bearer ${bambooSession}`,
|
|
11818
|
+
"Content-Type": "application/json"
|
|
11819
|
+
},
|
|
11820
|
+
body: JSON.stringify(body)
|
|
11821
|
+
}
|
|
11822
|
+
);
|
|
11823
|
+
if (!res.ok) throw await parseError(res);
|
|
11824
|
+
const json = await res.json();
|
|
11825
|
+
return CliUploadAgentResponseSchema.parse(json);
|
|
11826
|
+
}
|
|
11642
11827
|
var PROD_DEFAULT_BASE, DEV_DEFAULT_BASE, REQUEST_TIMEOUT_MS, ApiError, OAuthRelinkStartResponseSchema, ProvisionWorkspaceResponseSchema, FirstAutoInstalledAgentResponseSchema;
|
|
11643
11828
|
var init_api = __esm({
|
|
11644
11829
|
"src/lib/api.ts"() {
|
|
@@ -11648,6 +11833,8 @@ var init_api = __esm({
|
|
|
11648
11833
|
init_auth_status();
|
|
11649
11834
|
init_billing_status();
|
|
11650
11835
|
init_agent_health();
|
|
11836
|
+
init_onboarding_next_prompt();
|
|
11837
|
+
init_agents();
|
|
11651
11838
|
init_version();
|
|
11652
11839
|
PROD_DEFAULT_BASE = "https://withbamboo.com";
|
|
11653
11840
|
DEV_DEFAULT_BASE = "https://dev.withbamboo.com";
|
|
@@ -12557,6 +12744,445 @@ var init_clone_or_adopt_phase = __esm({
|
|
|
12557
12744
|
}
|
|
12558
12745
|
});
|
|
12559
12746
|
|
|
12747
|
+
// src/lib/prompt.ts
|
|
12748
|
+
import { createInterface } from "node:readline";
|
|
12749
|
+
async function promptStdin(question, opts = {}) {
|
|
12750
|
+
const maxRetries = opts.maxRetries ?? 2;
|
|
12751
|
+
const isInteractive2 = process.stdin.isTTY === true;
|
|
12752
|
+
const rl = createInterface({
|
|
12753
|
+
input: process.stdin,
|
|
12754
|
+
output: process.stdout,
|
|
12755
|
+
terminal: isInteractive2
|
|
12756
|
+
});
|
|
12757
|
+
const onSigInt = () => {
|
|
12758
|
+
rl.close();
|
|
12759
|
+
};
|
|
12760
|
+
rl.on("SIGINT", onSigInt);
|
|
12761
|
+
try {
|
|
12762
|
+
let attempts = 0;
|
|
12763
|
+
while (attempts <= maxRetries) {
|
|
12764
|
+
const answer = await readOnce(rl, question);
|
|
12765
|
+
if (answer === null) return null;
|
|
12766
|
+
const trimmed = answer.trim();
|
|
12767
|
+
if (trimmed.length > 0) return trimmed;
|
|
12768
|
+
attempts += 1;
|
|
12769
|
+
if (attempts > maxRetries || !isInteractive2) return null;
|
|
12770
|
+
console.log(" (Press Enter without typing to skip \u2014 or answer Boo's question.)");
|
|
12771
|
+
}
|
|
12772
|
+
return null;
|
|
12773
|
+
} finally {
|
|
12774
|
+
rl.off("SIGINT", onSigInt);
|
|
12775
|
+
rl.close();
|
|
12776
|
+
}
|
|
12777
|
+
}
|
|
12778
|
+
function readOnce(rl, question) {
|
|
12779
|
+
return new Promise((resolve) => {
|
|
12780
|
+
let resolved = false;
|
|
12781
|
+
const settle = (value) => {
|
|
12782
|
+
if (resolved) return;
|
|
12783
|
+
resolved = true;
|
|
12784
|
+
resolve(value);
|
|
12785
|
+
};
|
|
12786
|
+
rl.once("close", () => settle(null));
|
|
12787
|
+
rl.question(question, (answer) => settle(answer));
|
|
12788
|
+
});
|
|
12789
|
+
}
|
|
12790
|
+
var init_prompt = __esm({
|
|
12791
|
+
"src/lib/prompt.ts"() {
|
|
12792
|
+
"use strict";
|
|
12793
|
+
}
|
|
12794
|
+
});
|
|
12795
|
+
|
|
12796
|
+
// src/lib/phases-impl/pick-first-user-agent-phase.ts
|
|
12797
|
+
import { readFile as readFile3 } from "node:fs/promises";
|
|
12798
|
+
import { resolve as pathResolve3 } from "node:path";
|
|
12799
|
+
async function runCaseA(ctx) {
|
|
12800
|
+
console.log(" Let's set up YOUR first agent. How would you like to start?");
|
|
12801
|
+
console.log("");
|
|
12802
|
+
console.log(" 1) Create a new agent \u2014 I'll ask you a few questions");
|
|
12803
|
+
console.log(" 2) Upload an existing CLAUDE.md or AGENTS.md from your machine");
|
|
12804
|
+
console.log("");
|
|
12805
|
+
const choice = await promptChoice(" Choose [1-2]: ", ["1", "2"]);
|
|
12806
|
+
if (choice === null) return null;
|
|
12807
|
+
return choice === "1" ? runCreateFlow(ctx) : runUploadFlow(ctx);
|
|
12808
|
+
}
|
|
12809
|
+
async function runCaseB(ctx, agents) {
|
|
12810
|
+
console.log(
|
|
12811
|
+
` You have ${agents.length} user-created ${pluralize(
|
|
12812
|
+
agents.length,
|
|
12813
|
+
"agent"
|
|
12814
|
+
)} so far:`
|
|
12815
|
+
);
|
|
12816
|
+
for (const a of agents) {
|
|
12817
|
+
console.log(` \u2022 ${a.name} \u2014 ${formatHealth(a.health_score)}`);
|
|
12818
|
+
}
|
|
12819
|
+
console.log("");
|
|
12820
|
+
console.log(" What's next?");
|
|
12821
|
+
console.log("");
|
|
12822
|
+
console.log(" 1) Create another agent");
|
|
12823
|
+
console.log(" 2) Upload an existing CLAUDE.md/AGENTS.md");
|
|
12824
|
+
console.log(
|
|
12825
|
+
` 3) Improve ${agents.length === 1 ? `"${agents[0].name}"` : "an existing agent"} (run health check + next question)`
|
|
12826
|
+
);
|
|
12827
|
+
console.log("");
|
|
12828
|
+
const choice = await promptChoice(" Choose [1-3]: ", ["1", "2", "3"]);
|
|
12829
|
+
if (choice === null) return null;
|
|
12830
|
+
if (choice === "1") return runCreateFlow(ctx);
|
|
12831
|
+
if (choice === "2") return runUploadFlow(ctx);
|
|
12832
|
+
return runImproveExistingFlow(agents);
|
|
12833
|
+
}
|
|
12834
|
+
async function runCaseC(agents) {
|
|
12835
|
+
console.log(
|
|
12836
|
+
` You're at your tier's agent cap (${agents.length}/${agents.length}). Pick one to improve:`
|
|
12837
|
+
);
|
|
12838
|
+
console.log("");
|
|
12839
|
+
agents.forEach((a, idx) => {
|
|
12840
|
+
console.log(` ${idx + 1}) ${a.name} \u2014 ${formatHealth(a.health_score)}`);
|
|
12841
|
+
});
|
|
12842
|
+
console.log("");
|
|
12843
|
+
console.log(` (To add more agents, upgrade your plan at ${BILLING_URL})`);
|
|
12844
|
+
console.log("");
|
|
12845
|
+
return runImproveExistingFlow(agents);
|
|
12846
|
+
}
|
|
12847
|
+
async function runImproveExistingFlow(agents) {
|
|
12848
|
+
const validChoices = agents.map((_, idx2) => String(idx2 + 1));
|
|
12849
|
+
const choice = await promptChoice(
|
|
12850
|
+
` Choose [1-${agents.length}]: `,
|
|
12851
|
+
validChoices
|
|
12852
|
+
);
|
|
12853
|
+
if (choice === null) return null;
|
|
12854
|
+
const idx = Number.parseInt(choice, 10) - 1;
|
|
12855
|
+
return agents[idx]?.id ?? null;
|
|
12856
|
+
}
|
|
12857
|
+
async function runCreateFlow(ctx) {
|
|
12858
|
+
if (!ctx.credentials) return null;
|
|
12859
|
+
console.log("");
|
|
12860
|
+
const name = await promptStdin(" Agent name (e.g. Paid Ads Agent): ");
|
|
12861
|
+
if (!name) return null;
|
|
12862
|
+
const brand = await resolveBrand(ctx);
|
|
12863
|
+
if (!brand) return null;
|
|
12864
|
+
console.log("");
|
|
12865
|
+
console.log(" Creating your agent\u2026");
|
|
12866
|
+
try {
|
|
12867
|
+
const created = await createAgentFromCli(ctx.credentials.bamboo_session, {
|
|
12868
|
+
brand_id: brand.id,
|
|
12869
|
+
name
|
|
12870
|
+
});
|
|
12871
|
+
console.log("");
|
|
12872
|
+
console.log(` \u2713 Created agent at ${created.folder_path}`);
|
|
12873
|
+
return created.agent_id;
|
|
12874
|
+
} catch (err) {
|
|
12875
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
12876
|
+
console.log("");
|
|
12877
|
+
console.log(` Couldn't create agent: ${message}`);
|
|
12878
|
+
return null;
|
|
12879
|
+
}
|
|
12880
|
+
}
|
|
12881
|
+
async function runUploadFlow(ctx) {
|
|
12882
|
+
if (!ctx.credentials) return null;
|
|
12883
|
+
console.log("");
|
|
12884
|
+
const defaultsHint = UPLOAD_DEFAULT_PATHS.join(" or ");
|
|
12885
|
+
const filePathInput = await promptStdin(
|
|
12886
|
+
` Path to the CLAUDE.md/AGENTS.md file (default: ${defaultsHint}): `
|
|
12887
|
+
);
|
|
12888
|
+
const filePath = filePathInput ?? UPLOAD_DEFAULT_PATHS[0];
|
|
12889
|
+
const absPath = pathResolve3(ctx.cwd, filePath);
|
|
12890
|
+
let content;
|
|
12891
|
+
try {
|
|
12892
|
+
content = await readFile3(absPath, "utf8");
|
|
12893
|
+
} catch (err) {
|
|
12894
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
12895
|
+
console.log("");
|
|
12896
|
+
console.log(` Couldn't read ${absPath}: ${message}`);
|
|
12897
|
+
return null;
|
|
12898
|
+
}
|
|
12899
|
+
const bytes = Buffer.byteLength(content, "utf8");
|
|
12900
|
+
if (bytes > MAX_UPLOAD_BYTES) {
|
|
12901
|
+
console.log("");
|
|
12902
|
+
console.log(
|
|
12903
|
+
` ${absPath} is ${Math.round(bytes / 1024)} KB \u2014 server caps uploads at 256 KB.`
|
|
12904
|
+
);
|
|
12905
|
+
return null;
|
|
12906
|
+
}
|
|
12907
|
+
if (content.trim().length === 0) {
|
|
12908
|
+
console.log("");
|
|
12909
|
+
console.log(` ${absPath} is empty \u2014 nothing to upload.`);
|
|
12910
|
+
return null;
|
|
12911
|
+
}
|
|
12912
|
+
console.log("");
|
|
12913
|
+
console.log(` Preview of ${absPath} (${Math.round(bytes / 1024)} KB):`);
|
|
12914
|
+
console.log("");
|
|
12915
|
+
const previewLines = content.split("\n").slice(0, 6);
|
|
12916
|
+
for (const line of previewLines) {
|
|
12917
|
+
console.log(` ${line}`);
|
|
12918
|
+
}
|
|
12919
|
+
if (content.split("\n").length > 6) {
|
|
12920
|
+
console.log(" \u2026");
|
|
12921
|
+
}
|
|
12922
|
+
console.log("");
|
|
12923
|
+
const confirm = await promptChoice(
|
|
12924
|
+
" Upload this? [y/n]: ",
|
|
12925
|
+
["y", "n", "Y", "N"]
|
|
12926
|
+
);
|
|
12927
|
+
if (confirm === null || confirm.toLowerCase() !== "y") return null;
|
|
12928
|
+
console.log("");
|
|
12929
|
+
const name = await promptStdin(
|
|
12930
|
+
" Name this agent (e.g. My Existing Agent): "
|
|
12931
|
+
);
|
|
12932
|
+
if (!name) return null;
|
|
12933
|
+
const brand = await resolveBrand(ctx);
|
|
12934
|
+
if (!brand) return null;
|
|
12935
|
+
console.log("");
|
|
12936
|
+
console.log(" Uploading\u2026");
|
|
12937
|
+
try {
|
|
12938
|
+
const uploaded = await uploadClaudeMdFromCli(
|
|
12939
|
+
ctx.credentials.bamboo_session,
|
|
12940
|
+
{
|
|
12941
|
+
brand_id: brand.id,
|
|
12942
|
+
name,
|
|
12943
|
+
claude_md_content: content
|
|
12944
|
+
}
|
|
12945
|
+
);
|
|
12946
|
+
console.log("");
|
|
12947
|
+
console.log(` \u2713 Uploaded to ${uploaded.folder_path}`);
|
|
12948
|
+
return uploaded.agent_id;
|
|
12949
|
+
} catch (err) {
|
|
12950
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
12951
|
+
console.log("");
|
|
12952
|
+
console.log(` Couldn't upload agent: ${message}`);
|
|
12953
|
+
return null;
|
|
12954
|
+
}
|
|
12955
|
+
}
|
|
12956
|
+
async function resolveBrand(ctx) {
|
|
12957
|
+
if (!ctx.credentials) return null;
|
|
12958
|
+
let brands;
|
|
12959
|
+
try {
|
|
12960
|
+
const listed = await listCliBrands(ctx.credentials.bamboo_session);
|
|
12961
|
+
brands = listed.brands;
|
|
12962
|
+
} catch (err) {
|
|
12963
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
12964
|
+
console.log("");
|
|
12965
|
+
console.log(` Couldn't load brands: ${message}`);
|
|
12966
|
+
return null;
|
|
12967
|
+
}
|
|
12968
|
+
if (brands.length === 0) {
|
|
12969
|
+
console.log("");
|
|
12970
|
+
console.log(
|
|
12971
|
+
" No brands found in this org. Create one in the app first, then re-run."
|
|
12972
|
+
);
|
|
12973
|
+
return null;
|
|
12974
|
+
}
|
|
12975
|
+
if (brands.length === 1) {
|
|
12976
|
+
console.log("");
|
|
12977
|
+
console.log(` Using brand: ${brands[0].name}`);
|
|
12978
|
+
return brands[0];
|
|
12979
|
+
}
|
|
12980
|
+
console.log("");
|
|
12981
|
+
console.log(" Which brand should this agent belong to?");
|
|
12982
|
+
brands.forEach((b, idx) => {
|
|
12983
|
+
console.log(` ${idx + 1}) ${b.name}`);
|
|
12984
|
+
});
|
|
12985
|
+
console.log("");
|
|
12986
|
+
const validChoices = brands.map(
|
|
12987
|
+
(_, idx) => String(idx + 1)
|
|
12988
|
+
);
|
|
12989
|
+
const choice = await promptChoice(
|
|
12990
|
+
` Choose [1-${brands.length}]: `,
|
|
12991
|
+
validChoices
|
|
12992
|
+
);
|
|
12993
|
+
if (choice === null) return null;
|
|
12994
|
+
return brands[Number.parseInt(choice, 10) - 1] ?? null;
|
|
12995
|
+
}
|
|
12996
|
+
async function promptChoice(question, validChoices) {
|
|
12997
|
+
for (let attempt = 0; attempt < 5; attempt += 1) {
|
|
12998
|
+
const answer = await promptStdin(question);
|
|
12999
|
+
if (answer === null) return null;
|
|
13000
|
+
if (validChoices.includes(answer)) return answer;
|
|
13001
|
+
console.log(` Please choose one of: ${validChoices.join(", ")}`);
|
|
13002
|
+
}
|
|
13003
|
+
return null;
|
|
13004
|
+
}
|
|
13005
|
+
function formatHealth(score) {
|
|
13006
|
+
if (score === null) return "health unknown";
|
|
13007
|
+
const tenScale = Math.round(score / 10);
|
|
13008
|
+
return `health ${tenScale}/10`;
|
|
13009
|
+
}
|
|
13010
|
+
function pluralize(n, word) {
|
|
13011
|
+
return n === 1 ? word : `${word}s`;
|
|
13012
|
+
}
|
|
13013
|
+
var BILLING_URL, UPLOAD_DEFAULT_PATHS, MAX_UPLOAD_BYTES, pickFirstUserAgentSpec;
|
|
13014
|
+
var init_pick_first_user_agent_phase = __esm({
|
|
13015
|
+
"src/lib/phases-impl/pick-first-user-agent-phase.ts"() {
|
|
13016
|
+
"use strict";
|
|
13017
|
+
init_api();
|
|
13018
|
+
init_prompt();
|
|
13019
|
+
BILLING_URL = "https://withbamboo.com/billing";
|
|
13020
|
+
UPLOAD_DEFAULT_PATHS = ["./CLAUDE.md", "./AGENTS.md"];
|
|
13021
|
+
MAX_UPLOAD_BYTES = 256 * 1024;
|
|
13022
|
+
pickFirstUserAgentSpec = {
|
|
13023
|
+
name: "pick-first-user-agent",
|
|
13024
|
+
async probe(ctx) {
|
|
13025
|
+
if (!ctx.credentials) {
|
|
13026
|
+
return {
|
|
13027
|
+
status: "needs_action",
|
|
13028
|
+
summary: "(no creds)",
|
|
13029
|
+
reason: "Internal: pickFirstUserAgentSpec.probe called without creds."
|
|
13030
|
+
};
|
|
13031
|
+
}
|
|
13032
|
+
if (process.stdin.isTTY === false) {
|
|
13033
|
+
return {
|
|
13034
|
+
status: "needs_action",
|
|
13035
|
+
summary: "(no terminal)",
|
|
13036
|
+
reason: "pick-first-user-agent requires a terminal \u2014 re-run interactively. (Set BAMBOO_DEFAULT_PICKER_CHOICE to skip prompts in a future release.)"
|
|
13037
|
+
};
|
|
13038
|
+
}
|
|
13039
|
+
let listing;
|
|
13040
|
+
try {
|
|
13041
|
+
listing = await listCliAgents(ctx.credentials.bamboo_session);
|
|
13042
|
+
} catch (err) {
|
|
13043
|
+
if (err instanceof ApiError && err.status === 401) {
|
|
13044
|
+
return { status: "needs_relogin", summary: "session expired" };
|
|
13045
|
+
}
|
|
13046
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
13047
|
+
return {
|
|
13048
|
+
status: "needs_action",
|
|
13049
|
+
summary: "(couldn't list agents)",
|
|
13050
|
+
reason: `Couldn't load your agents from the server: ${message}
|
|
13051
|
+
Try again in a moment, or run \`bamboo-agents doctor\`.`
|
|
13052
|
+
};
|
|
13053
|
+
}
|
|
13054
|
+
ctx.pickFirstUserAgent = listing;
|
|
13055
|
+
return {
|
|
13056
|
+
status: "needs_work",
|
|
13057
|
+
summary: "pick which agent to set up"
|
|
13058
|
+
};
|
|
13059
|
+
},
|
|
13060
|
+
async execute(ctx) {
|
|
13061
|
+
const listing = ctx.pickFirstUserAgent;
|
|
13062
|
+
if (!listing || !ctx.credentials) {
|
|
13063
|
+
return {
|
|
13064
|
+
kind: "needs_action",
|
|
13065
|
+
reason: "Internal: pickFirstUserAgentSpec.execute called without a stashed listing."
|
|
13066
|
+
};
|
|
13067
|
+
}
|
|
13068
|
+
const userCreated = listing.agents.filter((a) => !a.is_auto_installed);
|
|
13069
|
+
const preInstalled = listing.agents.filter((a) => a.is_auto_installed);
|
|
13070
|
+
const cap = listing.tier_cap;
|
|
13071
|
+
const atCap = cap.limit > -1 && cap.current >= cap.limit;
|
|
13072
|
+
console.log("");
|
|
13073
|
+
if (preInstalled.length > 0) {
|
|
13074
|
+
console.log(
|
|
13075
|
+
" Your workspace already has these pre-installed agents:"
|
|
13076
|
+
);
|
|
13077
|
+
for (const a of preInstalled) {
|
|
13078
|
+
console.log(` \u2022 ${a.name} (sample)`);
|
|
13079
|
+
}
|
|
13080
|
+
console.log("");
|
|
13081
|
+
}
|
|
13082
|
+
let pickedAgentId;
|
|
13083
|
+
if (userCreated.length === 0) {
|
|
13084
|
+
pickedAgentId = await runCaseA(ctx);
|
|
13085
|
+
} else if (atCap) {
|
|
13086
|
+
pickedAgentId = await runCaseC(userCreated);
|
|
13087
|
+
} else {
|
|
13088
|
+
pickedAgentId = await runCaseB(ctx, userCreated);
|
|
13089
|
+
}
|
|
13090
|
+
if (!pickedAgentId) {
|
|
13091
|
+
return {
|
|
13092
|
+
kind: "needs_action",
|
|
13093
|
+
reason: "Couldn't pick a user agent. Re-run `bamboo-agents` when you're ready."
|
|
13094
|
+
};
|
|
13095
|
+
}
|
|
13096
|
+
ctx.agentId = pickedAgentId;
|
|
13097
|
+
return {
|
|
13098
|
+
kind: "advanced",
|
|
13099
|
+
summary: `picked agent ${pickedAgentId}`
|
|
13100
|
+
};
|
|
13101
|
+
}
|
|
13102
|
+
};
|
|
13103
|
+
}
|
|
13104
|
+
});
|
|
13105
|
+
|
|
13106
|
+
// src/lib/phases-impl/magic-moment-phase.ts
|
|
13107
|
+
var magicMomentSpec;
|
|
13108
|
+
var init_magic_moment_phase = __esm({
|
|
13109
|
+
"src/lib/phases-impl/magic-moment-phase.ts"() {
|
|
13110
|
+
"use strict";
|
|
13111
|
+
init_api();
|
|
13112
|
+
init_prompt();
|
|
13113
|
+
magicMomentSpec = {
|
|
13114
|
+
name: "magic-moment",
|
|
13115
|
+
async probe(ctx) {
|
|
13116
|
+
if (!ctx.credentials) {
|
|
13117
|
+
return {
|
|
13118
|
+
status: "needs_action",
|
|
13119
|
+
summary: "(no creds)",
|
|
13120
|
+
reason: "Run `bamboo-agents login` first."
|
|
13121
|
+
};
|
|
13122
|
+
}
|
|
13123
|
+
try {
|
|
13124
|
+
const next = await getOnboardingNextPrompt(ctx.credentials.bamboo_session);
|
|
13125
|
+
if (next.key !== "knowledge" || !next.prompt || !next.save_path) {
|
|
13126
|
+
return { status: "done", summary: "no question to ask" };
|
|
13127
|
+
}
|
|
13128
|
+
ctx.magicMoment = next;
|
|
13129
|
+
return {
|
|
13130
|
+
status: "needs_work",
|
|
13131
|
+
summary: "answer Boo's first question"
|
|
13132
|
+
};
|
|
13133
|
+
} catch {
|
|
13134
|
+
return {
|
|
13135
|
+
status: "done",
|
|
13136
|
+
summary: "no question to ask (endpoint unavailable)"
|
|
13137
|
+
};
|
|
13138
|
+
}
|
|
13139
|
+
},
|
|
13140
|
+
async execute(ctx) {
|
|
13141
|
+
const next = ctx.magicMoment;
|
|
13142
|
+
if (!next || !next.prompt || !next.save_path || !ctx.credentials) {
|
|
13143
|
+
return { kind: "done" };
|
|
13144
|
+
}
|
|
13145
|
+
console.log("");
|
|
13146
|
+
if (next.impact) {
|
|
13147
|
+
console.log(` \u{1F4A1} ${next.impact}`);
|
|
13148
|
+
console.log("");
|
|
13149
|
+
}
|
|
13150
|
+
const answer = await promptStdin(` Boo asks: ${next.prompt}
|
|
13151
|
+
> `);
|
|
13152
|
+
if (!answer) {
|
|
13153
|
+
return { kind: "done" };
|
|
13154
|
+
}
|
|
13155
|
+
try {
|
|
13156
|
+
await saveKnowledgeAnswer(
|
|
13157
|
+
ctx.credentials.bamboo_session,
|
|
13158
|
+
next.save_path,
|
|
13159
|
+
next.prompt,
|
|
13160
|
+
answer
|
|
13161
|
+
);
|
|
13162
|
+
console.log("");
|
|
13163
|
+
console.log(" \u2713 Saved to your workspace. Boo will use this in your first chat.");
|
|
13164
|
+
return {
|
|
13165
|
+
kind: "advanced",
|
|
13166
|
+
summary: "answered Boo's first question"
|
|
13167
|
+
};
|
|
13168
|
+
} catch (err) {
|
|
13169
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
13170
|
+
console.warn(
|
|
13171
|
+
"[magic-moment] save failed:",
|
|
13172
|
+
JSON.stringify({ path: next.save_path, error: msg })
|
|
13173
|
+
);
|
|
13174
|
+
console.log("");
|
|
13175
|
+
console.log(" (Couldn't save your answer right now \u2014 Boo will ask again in your first chat.)");
|
|
13176
|
+
return {
|
|
13177
|
+
kind: "advanced",
|
|
13178
|
+
summary: "answered Boo's first question (save retried in-app)"
|
|
13179
|
+
};
|
|
13180
|
+
}
|
|
13181
|
+
}
|
|
13182
|
+
};
|
|
13183
|
+
}
|
|
13184
|
+
});
|
|
13185
|
+
|
|
12560
13186
|
// src/lib/claude-desktop.ts
|
|
12561
13187
|
import { execFile as execFile7 } from "node:child_process";
|
|
12562
13188
|
import { platform as platform3 } from "node:os";
|
|
@@ -12736,7 +13362,8 @@ async function runOrchestrator() {
|
|
|
12736
13362
|
credentials: null,
|
|
12737
13363
|
membership: null,
|
|
12738
13364
|
config: null,
|
|
12739
|
-
cwd: process.cwd()
|
|
13365
|
+
cwd: process.cwd(),
|
|
13366
|
+
agentId: null
|
|
12740
13367
|
};
|
|
12741
13368
|
for (const phase of PHASES) {
|
|
12742
13369
|
let probe = await phase.probe(ctx);
|
|
@@ -12765,7 +13392,7 @@ async function runOrchestrator() {
|
|
|
12765
13392
|
}
|
|
12766
13393
|
if (probe.status === "done") {
|
|
12767
13394
|
console.log(` \u2713 ${probe.summary}`);
|
|
12768
|
-
if (phase.name ===
|
|
13395
|
+
if (phase.name === pickFirstUserAgentSpec.name) {
|
|
12769
13396
|
await printHealthLine(ctx);
|
|
12770
13397
|
}
|
|
12771
13398
|
continue;
|
|
@@ -12775,7 +13402,7 @@ async function runOrchestrator() {
|
|
|
12775
13402
|
printNeedsAction(result.reason);
|
|
12776
13403
|
process.exit(2);
|
|
12777
13404
|
}
|
|
12778
|
-
if (phase.name ===
|
|
13405
|
+
if (phase.name === pickFirstUserAgentSpec.name) {
|
|
12779
13406
|
await printHealthLine(ctx);
|
|
12780
13407
|
}
|
|
12781
13408
|
}
|
|
@@ -12789,12 +13416,16 @@ var init_orchestrator = __esm({
|
|
|
12789
13416
|
init_login_phase();
|
|
12790
13417
|
init_provision_phase();
|
|
12791
13418
|
init_clone_or_adopt_phase();
|
|
13419
|
+
init_pick_first_user_agent_phase();
|
|
13420
|
+
init_magic_moment_phase();
|
|
12792
13421
|
init_open_phase();
|
|
12793
13422
|
init_health_line();
|
|
12794
13423
|
PHASES = [
|
|
12795
13424
|
loginSpec,
|
|
12796
13425
|
provisionSpec,
|
|
12797
13426
|
cloneOrAdoptSpec,
|
|
13427
|
+
pickFirstUserAgentSpec,
|
|
13428
|
+
magicMomentSpec,
|
|
12798
13429
|
openSpec
|
|
12799
13430
|
];
|
|
12800
13431
|
}
|