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

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.27
1
+ 0.1.5-dev.29
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.27";
3040
+ VERSION = "0.1.5-dev.29";
3041
3041
  }
3042
3042
  });
3043
3043
 
@@ -11536,7 +11536,14 @@ var init_agent_health = __esm({
11536
11536
  max: external_exports.number(),
11537
11537
  /** Slot key of the highest-impact unfilled dimension. Null when
11538
11538
  * every weighted slot is filled (agent is fully scored). */
11539
- top_gap_slot: external_exports.string().nullable()
11539
+ top_gap_slot: external_exports.string().nullable(),
11540
+ /**
11541
+ * ISO-8601 timestamp of when the underlying skill run produced this
11542
+ * score (BAM-2289 P3). Optional for backwards compat with CLI bundles
11543
+ * shipped before the cache layer existed — newer bundles use it to
11544
+ * render "evaluated 12m ago" in the picker. Older bundles ignore it.
11545
+ */
11546
+ evaluated_at: external_exports.string().optional()
11540
11547
  }).nullable();
11541
11548
  }
11542
11549
  });
@@ -11582,15 +11589,7 @@ var init_agents = __esm({
11582
11589
  name: external_exports.string(),
11583
11590
  /** `false` = user-created (eligible for picker choices).
11584
11591
  * `true` = pre-installed (MAM etc.) — shown informational-only. */
11585
- is_auto_installed: external_exports.boolean(),
11586
- /**
11587
- * 0..100 weighted health score (round at render time). Null when
11588
- * the server omits the value (BAM-2246 omits today because per-agent
11589
- * health is an N round-trip fan-out; CLI fetches lazily via
11590
- * `/api/v1/agents/<id>/health`). Also null for legacy agents
11591
- * without an effective_rubric (pre-BAM-2084 installs).
11592
- */
11593
- health_score: external_exports.number().nullable()
11592
+ is_auto_installed: external_exports.boolean()
11594
11593
  });
11595
11594
  CliTierCapSchema = external_exports.object({
11596
11595
  limit: external_exports.number().int(),
@@ -12785,8 +12784,8 @@ var init_prompt = __esm({
12785
12784
  });
12786
12785
 
12787
12786
  // src/lib/phases-impl/pick-first-user-agent-phase.ts
12788
- import { readFile as readFile3, stat } from "node:fs/promises";
12789
- import { join as pathJoin, resolve as pathResolve3 } from "node:path";
12787
+ import { readdir, readFile as readFile3, stat } from "node:fs/promises";
12788
+ import { dirname, join as pathJoin, resolve as pathResolve3 } from "node:path";
12790
12789
  async function runCaseA(ctx) {
12791
12790
  console.log(" Let's set up YOUR first agent. How would you like to start?");
12792
12791
  console.log("");
@@ -12797,7 +12796,7 @@ async function runCaseA(ctx) {
12797
12796
  if (choice === null) return null;
12798
12797
  return choice === "1" ? runCreateFlow(ctx) : runUploadFlow(ctx);
12799
12798
  }
12800
- async function runCaseB(ctx, agents) {
12799
+ async function runCaseB(ctx, agents, healthByAgentId) {
12801
12800
  console.log(
12802
12801
  ` You have ${agents.length} user-created ${pluralize(
12803
12802
  agents.length,
@@ -12805,7 +12804,9 @@ async function runCaseB(ctx, agents) {
12805
12804
  )} so far:`
12806
12805
  );
12807
12806
  for (const a of agents) {
12808
- console.log(` \u2022 ${a.name} \u2014 ${formatHealth(a.health_score)}`);
12807
+ console.log(
12808
+ ` \u2022 ${a.name} \u2014 ${formatHealth(healthByAgentId.get(a.id) ?? null)}`
12809
+ );
12809
12810
  }
12810
12811
  console.log("");
12811
12812
  console.log(" What's next?");
@@ -12822,13 +12823,15 @@ async function runCaseB(ctx, agents) {
12822
12823
  if (choice === "2") return runUploadFlow(ctx);
12823
12824
  return runImproveExistingFlow(agents);
12824
12825
  }
12825
- async function runCaseC(agents) {
12826
+ async function runCaseC(agents, healthByAgentId) {
12826
12827
  console.log(
12827
12828
  ` You're at your tier's agent cap (${agents.length}/${agents.length}). Pick one to improve:`
12828
12829
  );
12829
12830
  console.log("");
12830
12831
  agents.forEach((a, idx) => {
12831
- console.log(` ${idx + 1}) ${a.name} \u2014 ${formatHealth(a.health_score)}`);
12832
+ console.log(
12833
+ ` ${idx + 1}) ${a.name} \u2014 ${formatHealth(healthByAgentId.get(a.id) ?? null)}`
12834
+ );
12832
12835
  });
12833
12836
  console.log("");
12834
12837
  console.log(` (To add more agents, upgrade your plan at ${BILLING_URL})`);
@@ -12871,49 +12874,9 @@ async function runCreateFlow(ctx) {
12871
12874
  }
12872
12875
  async function runUploadFlow(ctx) {
12873
12876
  if (!ctx.credentials) return null;
12874
- console.log("");
12875
- const defaultsHint = UPLOAD_DEFAULT_PATHS.join(" or ");
12876
- const filePathInput = await promptStdin(
12877
- ` Path to the CLAUDE.md/AGENTS.md file (default: ${defaultsHint}): `
12878
- );
12879
- const filePath = filePathInput ?? UPLOAD_DEFAULT_PATHS[0];
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
- }
12908
- let content;
12909
- try {
12910
- content = await readFile3(absPath, "utf8");
12911
- } catch (err) {
12912
- const message = err instanceof Error ? err.message : String(err);
12913
- console.log("");
12914
- console.log(` Couldn't read ${absPath}: ${message}`);
12915
- return null;
12916
- }
12877
+ const resolved = await resolveUploadFile(ctx);
12878
+ if (!resolved) return null;
12879
+ const { absPath, content } = resolved;
12917
12880
  const bytes = Buffer.byteLength(content, "utf8");
12918
12881
  if (bytes > MAX_UPLOAD_BYTES) {
12919
12882
  console.log("");
@@ -12971,6 +12934,99 @@ async function runUploadFlow(ctx) {
12971
12934
  return null;
12972
12935
  }
12973
12936
  }
12937
+ async function resolveUploadFile(ctx) {
12938
+ const defaultsHint = UPLOAD_DEFAULT_PATHS.join(" or ");
12939
+ let isFirstPrompt = true;
12940
+ for (let attempt = 0; attempt < 5; attempt += 1) {
12941
+ console.log("");
12942
+ const question = isFirstPrompt ? ` Path to the CLAUDE.md/AGENTS.md file (default: ${defaultsHint}): ` : " Try a different path (or hit enter to cancel): ";
12943
+ const filePathInput = await promptStdin(question, { maxRetries: 0 });
12944
+ let filePath;
12945
+ if (filePathInput === null) {
12946
+ if (!isFirstPrompt) {
12947
+ return null;
12948
+ }
12949
+ filePath = UPLOAD_DEFAULT_PATHS[0];
12950
+ } else {
12951
+ filePath = filePathInput;
12952
+ }
12953
+ isFirstPrompt = false;
12954
+ const requestedPath = pathResolve3(ctx.cwd, filePath);
12955
+ let absPath = requestedPath;
12956
+ try {
12957
+ const s = await stat(requestedPath);
12958
+ if (s.isDirectory()) {
12959
+ let resolvedInside = null;
12960
+ for (const name of UPLOAD_DEFAULT_PATHS) {
12961
+ const candidate = pathJoin(requestedPath, name);
12962
+ try {
12963
+ const cs = await stat(candidate);
12964
+ if (cs.isFile()) {
12965
+ resolvedInside = candidate;
12966
+ break;
12967
+ }
12968
+ } catch {
12969
+ }
12970
+ }
12971
+ if (!resolvedInside) {
12972
+ console.log("");
12973
+ console.log(
12974
+ ` ${requestedPath} is a directory and doesn't contain a ${UPLOAD_DEFAULT_PATHS.join(" or ")}.`
12975
+ );
12976
+ await printDirectorySneakPeek(ctx.cwd, pathJoin(requestedPath, UPLOAD_DEFAULT_PATHS[0]));
12977
+ continue;
12978
+ }
12979
+ absPath = resolvedInside;
12980
+ }
12981
+ } catch {
12982
+ }
12983
+ try {
12984
+ const content = await readFile3(absPath, "utf8");
12985
+ return { absPath, content };
12986
+ } catch (err) {
12987
+ await handleReadFailure(ctx, absPath, err);
12988
+ }
12989
+ }
12990
+ console.log("");
12991
+ console.log(
12992
+ " Couldn't find a file to upload after several tries \u2014 cancelling. Re-run `bamboo-agents` when ready."
12993
+ );
12994
+ return null;
12995
+ }
12996
+ async function handleReadFailure(ctx, absPath, err) {
12997
+ const code = err.code ?? (err instanceof Error ? err.message : String(err));
12998
+ const message = err instanceof Error ? err.message : String(err);
12999
+ console.log("");
13000
+ console.log(` Couldn't read ${absPath}: ${message}`);
13001
+ if (code === "ENOENT" || code === "EACCES" || code === "EISDIR" || code === "ENOTDIR") {
13002
+ await printDirectorySneakPeek(ctx.cwd, absPath);
13003
+ }
13004
+ }
13005
+ async function printDirectorySneakPeek(cwd, failedAbsPath) {
13006
+ const parent = dirname(failedAbsPath);
13007
+ const targets = [parent, cwd];
13008
+ const seen = /* @__PURE__ */ new Set();
13009
+ for (const target of targets) {
13010
+ if (seen.has(target)) continue;
13011
+ seen.add(target);
13012
+ let entries;
13013
+ try {
13014
+ const s = await stat(target);
13015
+ if (!s.isDirectory()) continue;
13016
+ entries = await readdir(target);
13017
+ } catch {
13018
+ continue;
13019
+ }
13020
+ if (entries.length === 0) {
13021
+ console.log(` (${target} is empty)`);
13022
+ return;
13023
+ }
13024
+ const sample = entries.slice(0, 5).join(", ");
13025
+ const more = entries.length > 5 ? ` (and ${entries.length - 5} more)` : "";
13026
+ console.log(` ${target} contains: ${sample}${more}`);
13027
+ return;
13028
+ }
13029
+ }
12974
13030
  async function resolveBrand(ctx) {
12975
13031
  if (!ctx.credentials) return null;
12976
13032
  let brands;
@@ -13087,6 +13143,7 @@ var init_pick_first_user_agent_phase = __esm({
13087
13143
  const preInstalled = listing.agents.filter((a) => a.is_auto_installed);
13088
13144
  const cap = listing.tier_cap;
13089
13145
  const atCap = cap.limit > -1 && cap.current >= cap.limit;
13146
+ const healthByAgentId = /* @__PURE__ */ new Map();
13090
13147
  await Promise.all(
13091
13148
  userCreated.map(async (a) => {
13092
13149
  try {
@@ -13094,9 +13151,9 @@ var init_pick_first_user_agent_phase = __esm({
13094
13151
  ctx.credentials.bamboo_session,
13095
13152
  a.id
13096
13153
  );
13097
- a.health_score = h?.score ?? null;
13154
+ healthByAgentId.set(a.id, h?.score ?? null);
13098
13155
  } catch {
13099
- a.health_score = null;
13156
+ healthByAgentId.set(a.id, null);
13100
13157
  }
13101
13158
  })
13102
13159
  );
@@ -13114,9 +13171,9 @@ var init_pick_first_user_agent_phase = __esm({
13114
13171
  if (userCreated.length === 0) {
13115
13172
  pickedAgentId = await runCaseA(ctx);
13116
13173
  } else if (atCap) {
13117
- pickedAgentId = await runCaseC(userCreated);
13174
+ pickedAgentId = await runCaseC(userCreated, healthByAgentId);
13118
13175
  } else {
13119
- pickedAgentId = await runCaseB(ctx, userCreated);
13176
+ pickedAgentId = await runCaseB(ctx, userCreated, healthByAgentId);
13120
13177
  }
13121
13178
  if (!pickedAgentId) {
13122
13179
  return {
@@ -13332,22 +13389,32 @@ var init_open_phase = __esm({
13332
13389
 
13333
13390
  // src/lib/orchestrator-steps/health-line.ts
13334
13391
  async function printHealthLine(ctx) {
13392
+ if (!ctx.credentials?.bamboo_session) return;
13393
+ if (!ctx.agentId) return;
13394
+ console.log("");
13395
+ console.log(" Computing health score\u2026");
13396
+ let health;
13335
13397
  try {
13336
- if (!ctx.credentials?.bamboo_session) return;
13337
- if (!ctx.agentId) return;
13338
- const health = await getAgentHealth(
13398
+ health = await getAgentHealth(
13339
13399
  ctx.credentials.bamboo_session,
13340
13400
  ctx.agentId
13341
13401
  );
13342
- if (!health) return;
13343
- const score = Math.round(health.score);
13344
- const max = health.max;
13345
- const gap = health.top_gap_slot;
13346
- const line = gap ? ` Health: ${score} / ${max} \u2014 top gap: ${gap}` : ` Health: ${score} / ${max}`;
13347
- console.log("");
13348
- console.log(line);
13349
- } catch {
13402
+ } catch (err) {
13403
+ const code = err && typeof err === "object" && "errorCode" in err && err.errorCode ? String(err.errorCode) : err instanceof Error ? err.message : String(err);
13404
+ console.log(
13405
+ ` Couldn't compute health: ${code} \u2014 re-run with --debug for details, or check \`bamboo-agents doctor\`.`
13406
+ );
13407
+ return;
13408
+ }
13409
+ if (!health) {
13410
+ console.log(" (this agent doesn't have a health rubric yet \u2014 skipping)");
13411
+ return;
13350
13412
  }
13413
+ const score = Math.round(health.score);
13414
+ const max = health.max;
13415
+ const gap = health.top_gap_slot;
13416
+ const line = gap ? ` Health: ${score} / ${max} \u2014 top gap: ${gap}` : ` Health: ${score} / ${max}`;
13417
+ console.log(line);
13351
13418
  }
13352
13419
  var init_health_line = __esm({
13353
13420
  "src/lib/orchestrator-steps/health-line.ts"() {