bamboo-agents 0.1.5-dev.22 → 0.1.5-dev.23

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 CHANGED
@@ -1 +1 @@
1
- 0.1.5-dev.22
1
+ 0.1.5-dev.23
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.22";
3040
+ VERSION = "0.1.5-dev.23";
3041
3041
  }
3042
3042
  });
3043
3043
 
@@ -11540,6 +11540,31 @@ var init_agent_health = __esm({
11540
11540
  }
11541
11541
  });
11542
11542
 
11543
+ // ../../src/lib/api-contracts/cli/onboarding-next-prompt.ts
11544
+ var OnboardingNextPromptResponseSchema;
11545
+ var init_onboarding_next_prompt = __esm({
11546
+ "../../src/lib/api-contracts/cli/onboarding-next-prompt.ts"() {
11547
+ init_zod();
11548
+ OnboardingNextPromptResponseSchema = external_exports.object({
11549
+ /** Checklist item key from `compute_onboarding_status.next_best_step.key`.
11550
+ * Empty string when there's no next step at all. */
11551
+ key: external_exports.string(),
11552
+ /** Human-readable item label (e.g., "Add Important Context"). */
11553
+ label: external_exports.string(),
11554
+ /** The question to ask the user. `null` when no prompt is available
11555
+ * for this item (CLI treats null as "skip"). */
11556
+ prompt: external_exports.string().nullable(),
11557
+ /** Optional one-liner explaining why answering this matters. Surfaces
11558
+ * above the prompt as `💡 <impact>` in the CLI. */
11559
+ impact: external_exports.string().nullable(),
11560
+ /** Workspace-repo-relative path where the answer should be written.
11561
+ * Non-null ONLY when `key === 'knowledge'` — the only item v1 saves
11562
+ * inline from the CLI. Other keys get `null` (CLI skips). */
11563
+ save_path: external_exports.string().nullable()
11564
+ });
11565
+ }
11566
+ });
11567
+
11543
11568
  // src/lib/api.ts
11544
11569
  import { platform as platform2 } from "node:os";
11545
11570
  function defaultApiBase(version) {
@@ -11639,6 +11664,43 @@ async function getAgentHealth(bambooSession, agentId) {
11639
11664
  const json = await res.json();
11640
11665
  return AgentHealthResponseSchema.parse(json);
11641
11666
  }
11667
+ async function getOnboardingNextPrompt(bambooSession) {
11668
+ const res = await cliApiFetch(
11669
+ `${apiBase()}/api/v1/cli/onboarding/next-prompt`,
11670
+ {
11671
+ headers: { Authorization: `Bearer ${bambooSession}` }
11672
+ }
11673
+ );
11674
+ if (!res.ok) throw await parseError(res);
11675
+ const json = await res.json();
11676
+ return OnboardingNextPromptResponseSchema.parse(json);
11677
+ }
11678
+ async function saveKnowledgeAnswer(bambooSession, path2, prompt, answer) {
11679
+ const content = formatAsMarkdown(prompt, answer);
11680
+ const res = await cliApiFetch(`${apiBase()}/api/v1/workspace/save`, {
11681
+ method: "POST",
11682
+ headers: {
11683
+ Authorization: `Bearer ${bambooSession}`,
11684
+ "Content-Type": "application/json"
11685
+ },
11686
+ body: JSON.stringify({
11687
+ edits: [{ path: path2, content, base_sha: null }],
11688
+ intent: "Save Boo's first-chat answer"
11689
+ })
11690
+ });
11691
+ if (!res.ok) throw await parseError(res);
11692
+ await res.json().catch(() => void 0);
11693
+ }
11694
+ function formatAsMarkdown(prompt, answer) {
11695
+ const stamp = (/* @__PURE__ */ new Date()).toISOString();
11696
+ return `# ${prompt}
11697
+
11698
+ ${answer}
11699
+
11700
+ ---
11701
+ Saved by Boo via CLI magic-moment, ${stamp}.
11702
+ `;
11703
+ }
11642
11704
  var PROD_DEFAULT_BASE, DEV_DEFAULT_BASE, REQUEST_TIMEOUT_MS, ApiError, OAuthRelinkStartResponseSchema, ProvisionWorkspaceResponseSchema, FirstAutoInstalledAgentResponseSchema;
11643
11705
  var init_api = __esm({
11644
11706
  "src/lib/api.ts"() {
@@ -11648,6 +11710,7 @@ var init_api = __esm({
11648
11710
  init_auth_status();
11649
11711
  init_billing_status();
11650
11712
  init_agent_health();
11713
+ init_onboarding_next_prompt();
11651
11714
  init_version();
11652
11715
  PROD_DEFAULT_BASE = "https://withbamboo.com";
11653
11716
  DEV_DEFAULT_BASE = "https://dev.withbamboo.com";
@@ -12557,6 +12620,135 @@ var init_clone_or_adopt_phase = __esm({
12557
12620
  }
12558
12621
  });
12559
12622
 
12623
+ // src/lib/prompt.ts
12624
+ import { createInterface } from "node:readline";
12625
+ async function promptStdin(question, opts = {}) {
12626
+ const maxRetries = opts.maxRetries ?? 2;
12627
+ const isInteractive2 = process.stdin.isTTY === true;
12628
+ const rl = createInterface({
12629
+ input: process.stdin,
12630
+ output: process.stdout,
12631
+ terminal: isInteractive2
12632
+ });
12633
+ const onSigInt = () => {
12634
+ rl.close();
12635
+ };
12636
+ rl.on("SIGINT", onSigInt);
12637
+ try {
12638
+ let attempts = 0;
12639
+ while (attempts <= maxRetries) {
12640
+ const answer = await readOnce(rl, question);
12641
+ if (answer === null) return null;
12642
+ const trimmed = answer.trim();
12643
+ if (trimmed.length > 0) return trimmed;
12644
+ attempts += 1;
12645
+ if (attempts > maxRetries || !isInteractive2) return null;
12646
+ console.log(" (Press Enter without typing to skip \u2014 or answer Boo's question.)");
12647
+ }
12648
+ return null;
12649
+ } finally {
12650
+ rl.off("SIGINT", onSigInt);
12651
+ rl.close();
12652
+ }
12653
+ }
12654
+ function readOnce(rl, question) {
12655
+ return new Promise((resolve) => {
12656
+ let resolved = false;
12657
+ const settle = (value) => {
12658
+ if (resolved) return;
12659
+ resolved = true;
12660
+ resolve(value);
12661
+ };
12662
+ rl.once("close", () => settle(null));
12663
+ rl.question(question, (answer) => settle(answer));
12664
+ });
12665
+ }
12666
+ var init_prompt = __esm({
12667
+ "src/lib/prompt.ts"() {
12668
+ "use strict";
12669
+ }
12670
+ });
12671
+
12672
+ // src/lib/phases-impl/magic-moment-phase.ts
12673
+ var magicMomentSpec;
12674
+ var init_magic_moment_phase = __esm({
12675
+ "src/lib/phases-impl/magic-moment-phase.ts"() {
12676
+ "use strict";
12677
+ init_api();
12678
+ init_prompt();
12679
+ magicMomentSpec = {
12680
+ name: "magic-moment",
12681
+ async probe(ctx) {
12682
+ if (!ctx.credentials) {
12683
+ return {
12684
+ status: "needs_action",
12685
+ summary: "(no creds)",
12686
+ reason: "Run `bamboo-agents login` first."
12687
+ };
12688
+ }
12689
+ try {
12690
+ const next = await getOnboardingNextPrompt(ctx.credentials.bamboo_session);
12691
+ if (next.key !== "knowledge" || !next.prompt || !next.save_path) {
12692
+ return { status: "done", summary: "no question to ask" };
12693
+ }
12694
+ ctx.magicMoment = next;
12695
+ return {
12696
+ status: "needs_work",
12697
+ summary: "answer Boo's first question"
12698
+ };
12699
+ } catch {
12700
+ return {
12701
+ status: "done",
12702
+ summary: "no question to ask (endpoint unavailable)"
12703
+ };
12704
+ }
12705
+ },
12706
+ async execute(ctx) {
12707
+ const next = ctx.magicMoment;
12708
+ if (!next || !next.prompt || !next.save_path || !ctx.credentials) {
12709
+ return { kind: "done" };
12710
+ }
12711
+ console.log("");
12712
+ if (next.impact) {
12713
+ console.log(` \u{1F4A1} ${next.impact}`);
12714
+ console.log("");
12715
+ }
12716
+ const answer = await promptStdin(` Boo asks: ${next.prompt}
12717
+ > `);
12718
+ if (!answer) {
12719
+ return { kind: "done" };
12720
+ }
12721
+ try {
12722
+ await saveKnowledgeAnswer(
12723
+ ctx.credentials.bamboo_session,
12724
+ next.save_path,
12725
+ next.prompt,
12726
+ answer
12727
+ );
12728
+ console.log("");
12729
+ console.log(" \u2713 Saved to your workspace. Boo will use this in your first chat.");
12730
+ return {
12731
+ kind: "advanced",
12732
+ summary: "answered Boo's first question"
12733
+ };
12734
+ } catch (err) {
12735
+ const msg = err instanceof Error ? err.message : String(err);
12736
+ console.warn(
12737
+ "[magic-moment] save failed:",
12738
+ JSON.stringify({ path: next.save_path, error: msg })
12739
+ );
12740
+ console.log("");
12741
+ console.log(" (Couldn't save your answer right now \u2014 Boo will ask again in your first chat.)");
12742
+ return {
12743
+ kind: "advanced",
12744
+ summary: "answered Boo's first question (save retried in-app)"
12745
+ };
12746
+ }
12747
+ }
12748
+ };
12749
+ }
12750
+ });
12751
+
12560
12752
  // src/lib/claude-desktop.ts
12561
12753
  import { execFile as execFile7 } from "node:child_process";
12562
12754
  import { platform as platform3 } from "node:os";
@@ -12789,12 +12981,14 @@ var init_orchestrator = __esm({
12789
12981
  init_login_phase();
12790
12982
  init_provision_phase();
12791
12983
  init_clone_or_adopt_phase();
12984
+ init_magic_moment_phase();
12792
12985
  init_open_phase();
12793
12986
  init_health_line();
12794
12987
  PHASES = [
12795
12988
  loginSpec,
12796
12989
  provisionSpec,
12797
12990
  cloneOrAdoptSpec,
12991
+ magicMomentSpec,
12798
12992
  openSpec
12799
12993
  ];
12800
12994
  }