bamboo-agents 0.1.5-dev.25 → 0.1.5-dev.27

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.25
1
+ 0.1.5-dev.27
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.25";
3040
+ VERSION = "0.1.5-dev.27";
3041
3041
  }
3042
3042
  });
3043
3043
 
@@ -11542,10 +11542,13 @@ var init_agent_health = __esm({
11542
11542
  });
11543
11543
 
11544
11544
  // ../../src/lib/api-contracts/cli/onboarding-next-prompt.ts
11545
- var OnboardingNextPromptResponseSchema;
11545
+ var OnboardingNextPromptRequestSchema, OnboardingNextPromptResponseSchema;
11546
11546
  var init_onboarding_next_prompt = __esm({
11547
11547
  "../../src/lib/api-contracts/cli/onboarding-next-prompt.ts"() {
11548
11548
  init_zod();
11549
+ OnboardingNextPromptRequestSchema = external_exports.object({
11550
+ agent_id: external_exports.string().uuid()
11551
+ });
11549
11552
  OnboardingNextPromptResponseSchema = external_exports.object({
11550
11553
  /** Checklist item key from `compute_onboarding_status.next_best_step.key`.
11551
11554
  * Empty string when there's no next step at all. */
@@ -11717,17 +11720,6 @@ async function provisionWorkspace(bambooSession) {
11717
11720
  const json = await res.json();
11718
11721
  return ProvisionWorkspaceResponseSchema.parse(json);
11719
11722
  }
11720
- async function getFirstAutoInstalledAgent(bambooSession) {
11721
- const res = await cliApiFetch(
11722
- `${apiBase()}/api/v1/agents/first-auto-installed`,
11723
- {
11724
- headers: { Authorization: `Bearer ${bambooSession}` }
11725
- }
11726
- );
11727
- if (!res.ok) throw await parseError(res);
11728
- const json = await res.json();
11729
- return FirstAutoInstalledAgentResponseSchema.parse(json).agent_id;
11730
- }
11731
11723
  async function getAgentHealth(bambooSession, agentId) {
11732
11724
  const res = await cliApiFetch(
11733
11725
  `${apiBase()}/api/v1/agents/${encodeURIComponent(agentId)}/health`,
@@ -11739,13 +11731,12 @@ async function getAgentHealth(bambooSession, agentId) {
11739
11731
  const json = await res.json();
11740
11732
  return AgentHealthResponseSchema.parse(json);
11741
11733
  }
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
- );
11734
+ async function getOnboardingNextPrompt(bambooSession, agentId) {
11735
+ const url = new URL(`${apiBase()}/api/v1/cli/onboarding/next-prompt`);
11736
+ url.searchParams.set("agent_id", agentId);
11737
+ const res = await cliApiFetch(url.toString(), {
11738
+ headers: { Authorization: `Bearer ${bambooSession}` }
11739
+ });
11749
11740
  if (!res.ok) throw await parseError(res);
11750
11741
  const json = await res.json();
11751
11742
  return OnboardingNextPromptResponseSchema.parse(json);
@@ -12794,8 +12785,8 @@ var init_prompt = __esm({
12794
12785
  });
12795
12786
 
12796
12787
  // 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";
12788
+ import { readFile as readFile3, stat } from "node:fs/promises";
12789
+ import { join as pathJoin, resolve as pathResolve3 } from "node:path";
12799
12790
  async function runCaseA(ctx) {
12800
12791
  console.log(" Let's set up YOUR first agent. How would you like to start?");
12801
12792
  console.log("");
@@ -12886,7 +12877,34 @@ async function runUploadFlow(ctx) {
12886
12877
  ` Path to the CLAUDE.md/AGENTS.md file (default: ${defaultsHint}): `
12887
12878
  );
12888
12879
  const filePath = filePathInput ?? UPLOAD_DEFAULT_PATHS[0];
12889
- const absPath = pathResolve3(ctx.cwd, filePath);
12880
+ const requestedPath = pathResolve3(ctx.cwd, filePath);
12881
+ let absPath = requestedPath;
12882
+ try {
12883
+ const s = await stat(requestedPath);
12884
+ if (s.isDirectory()) {
12885
+ let resolved = null;
12886
+ for (const name2 of UPLOAD_DEFAULT_PATHS) {
12887
+ const candidate = pathJoin(requestedPath, name2);
12888
+ try {
12889
+ const cs = await stat(candidate);
12890
+ if (cs.isFile()) {
12891
+ resolved = candidate;
12892
+ break;
12893
+ }
12894
+ } catch {
12895
+ }
12896
+ }
12897
+ if (!resolved) {
12898
+ console.log("");
12899
+ console.log(
12900
+ ` ${requestedPath} is a directory and doesn't contain a ${UPLOAD_DEFAULT_PATHS.join(" or ")}.`
12901
+ );
12902
+ return null;
12903
+ }
12904
+ absPath = resolved;
12905
+ }
12906
+ } catch {
12907
+ }
12890
12908
  let content;
12891
12909
  try {
12892
12910
  content = await readFile3(absPath, "utf8");
@@ -13069,6 +13087,19 @@ var init_pick_first_user_agent_phase = __esm({
13069
13087
  const preInstalled = listing.agents.filter((a) => a.is_auto_installed);
13070
13088
  const cap = listing.tier_cap;
13071
13089
  const atCap = cap.limit > -1 && cap.current >= cap.limit;
13090
+ await Promise.all(
13091
+ userCreated.map(async (a) => {
13092
+ try {
13093
+ const h = await getAgentHealth(
13094
+ ctx.credentials.bamboo_session,
13095
+ a.id
13096
+ );
13097
+ a.health_score = h?.score ?? null;
13098
+ } catch {
13099
+ a.health_score = null;
13100
+ }
13101
+ })
13102
+ );
13072
13103
  console.log("");
13073
13104
  if (preInstalled.length > 0) {
13074
13105
  console.log(
@@ -13120,8 +13151,18 @@ var init_magic_moment_phase = __esm({
13120
13151
  reason: "Run `bamboo-agents login` first."
13121
13152
  };
13122
13153
  }
13154
+ if (!ctx.agentId) {
13155
+ return {
13156
+ status: "needs_action",
13157
+ summary: "(no agent picked)",
13158
+ reason: "Internal: magic-moment ran before pick-first-user-agent populated ctx.agentId."
13159
+ };
13160
+ }
13123
13161
  try {
13124
- const next = await getOnboardingNextPrompt(ctx.credentials.bamboo_session);
13162
+ const next = await getOnboardingNextPrompt(
13163
+ ctx.credentials.bamboo_session,
13164
+ ctx.agentId
13165
+ );
13125
13166
  if (next.key !== "knowledge" || !next.prompt || !next.save_path) {
13126
13167
  return { status: "done", summary: "no question to ask" };
13127
13168
  }
@@ -13293,13 +13334,10 @@ var init_open_phase = __esm({
13293
13334
  async function printHealthLine(ctx) {
13294
13335
  try {
13295
13336
  if (!ctx.credentials?.bamboo_session) return;
13296
- const agentId = await getFirstAutoInstalledAgent(
13297
- ctx.credentials.bamboo_session
13298
- );
13299
- if (!agentId) return;
13337
+ if (!ctx.agentId) return;
13300
13338
  const health = await getAgentHealth(
13301
13339
  ctx.credentials.bamboo_session,
13302
- agentId
13340
+ ctx.agentId
13303
13341
  );
13304
13342
  if (!health) return;
13305
13343
  const score = Math.round(health.score);