bamboo-agents 0.1.5-dev.60.6d2930c → 0.1.5-dev.62.c11b819

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.60.6d2930c
1
+ 0.1.5-dev.62.c11b819
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.60.6d2930c";
3040
+ VERSION = "0.1.5-dev.62.c11b819";
3041
3041
  }
3042
3042
  });
3043
3043
 
@@ -7161,7 +7161,9 @@ var init_history = __esm({
7161
7161
  tool_name: external_exports.string().nullable(),
7162
7162
  status: external_exports.string(),
7163
7163
  timestamp: external_exports.string(),
7164
- duration_ms: external_exports.number().nullable()
7164
+ duration_ms: external_exports.number().nullable(),
7165
+ /** BAM-2661: runtime origin so `bamboo history --source <X>` can filter. */
7166
+ source: external_exports.string().nullable()
7165
7167
  });
7166
7168
  HistoryResponseSchema = external_exports.object({
7167
7169
  entries: external_exports.array(HistoryEntrySchema),
@@ -12448,6 +12450,58 @@ var init_skill_apply = __esm({
12448
12450
  }
12449
12451
  });
12450
12452
 
12453
+ // ../../src/lib/api-contracts/cli/inbox-revise.ts
12454
+ var InboxReviseSelectedLineSchema, InboxReviseRequestSchema, InboxReviseResponseSchema;
12455
+ var init_inbox_revise = __esm({
12456
+ "../../src/lib/api-contracts/cli/inbox-revise.ts"() {
12457
+ init_zod();
12458
+ init_save();
12459
+ InboxReviseSelectedLineSchema = external_exports.object({
12460
+ kind: external_exports.enum(["add", "del", "context"]),
12461
+ old_line: external_exports.number().int().positive().nullable(),
12462
+ new_line: external_exports.number().int().positive().nullable(),
12463
+ content: external_exports.string()
12464
+ });
12465
+ InboxReviseRequestSchema = external_exports.object({
12466
+ /** PR number in the org's workspace repo. */
12467
+ pr_number: external_exports.number().int().positive(),
12468
+ /** Source agent id. Null → the core resolves it from the PR body. */
12469
+ agent_id: external_exports.string().min(1).nullable().optional(),
12470
+ /** The user's intent, one sentence — what to change. */
12471
+ feedback: external_exports.string().min(1).max(4e3),
12472
+ /** Repo-relative path of the file the feedback targets. */
12473
+ file: external_exports.string().min(1).max(512),
12474
+ /**
12475
+ * The user's selected diff lines, materialized by the sandbox harness —
12476
+ * never re-transcribed by the model (re-typed line numbers drift).
12477
+ */
12478
+ selected_lines: external_exports.array(InboxReviseSelectedLineSchema).max(1e3).optional()
12479
+ }).refine((r) => isSafeRepoPath(r.file), {
12480
+ message: "unsafe file path: no '..' traversal, absolute paths, backslashes, or control chars",
12481
+ path: ["file"]
12482
+ });
12483
+ InboxReviseResponseSchema = external_exports.object({
12484
+ /** True when the source managed agent was dispatched to revise its PR. */
12485
+ dispatched: external_exports.boolean(),
12486
+ runtime: external_exports.enum(["anthropic_managed", "boo"]),
12487
+ /** Present on `dispatched: true` — the bridge session id. */
12488
+ session_id: external_exports.string().optional(),
12489
+ message: external_exports.string().optional(),
12490
+ // Boo-direct fields (dispatched: false — PR source isn't a managed agent).
12491
+ // The sandbox CLI surfaces these honestly; applying the revision directly
12492
+ // is a follow-up verb (`inbox apply-revision`), not part of this contract.
12493
+ file_content: external_exports.string().optional(),
12494
+ /** File content at the PR's base commit — lets Boo reason about deleted lines. */
12495
+ file_content_base: external_exports.string().optional(),
12496
+ file_sha: external_exports.string().optional(),
12497
+ branch: external_exports.string().optional(),
12498
+ repo_owner: external_exports.string().optional(),
12499
+ repo_name: external_exports.string().optional(),
12500
+ pr_number: external_exports.number().optional()
12501
+ });
12502
+ }
12503
+ });
12504
+
12451
12505
  // ../../src/lib/api-contracts/cli/context-health.ts
12452
12506
  var ScopeKindSchema, ScopeSchema, CriterionMetricsSchema, StatusSchema, CriterionContributionSchema, CriterionResultSchema, BucketScoresSchema, ResolvedScopeSchema, GapsSchema, HealthyResponseSchema, UnavailableResponseSchema, ContextHealthResponseSchema;
12453
12507
  var init_context_health = __esm({
@@ -12649,6 +12703,19 @@ async function saveKnowledge(bambooSession, body) {
12649
12703
  const json = await res.json();
12650
12704
  return KnowledgeSaveResponseSchema.parse(json);
12651
12705
  }
12706
+ async function requestInboxRevision(bambooSession, body) {
12707
+ const res = await cliApiFetch(`${apiBase()}/api/v1/cli/inbox/revise`, {
12708
+ method: "POST",
12709
+ headers: {
12710
+ Authorization: `Bearer ${bambooSession}`,
12711
+ "Content-Type": "application/json"
12712
+ },
12713
+ body: JSON.stringify(body)
12714
+ });
12715
+ if (!res.ok) throw await parseError(res);
12716
+ const json = await res.json();
12717
+ return InboxReviseResponseSchema.parse(json);
12718
+ }
12652
12719
  async function saveWorkspace(bambooSession, body) {
12653
12720
  const res = await cliApiFetch(`${apiBase()}/api/v1/cli/save`, {
12654
12721
  method: "POST",
@@ -12665,6 +12732,7 @@ async function saveWorkspace(bambooSession, body) {
12665
12732
  async function getHistory(bambooSession, opts = {}) {
12666
12733
  const url = new URL(`${apiBase()}/api/v1/cli/history`);
12667
12734
  if (opts.limit) url.searchParams.set("limit", String(opts.limit));
12735
+ if (opts.source) url.searchParams.set("source", opts.source);
12668
12736
  const res = await cliApiFetch(url.toString(), {
12669
12737
  headers: { Authorization: `Bearer ${bambooSession}` }
12670
12738
  });
@@ -13019,6 +13087,7 @@ var init_api = __esm({
13019
13087
  init_knowledge_slots();
13020
13088
  init_knowledge_save();
13021
13089
  init_skill_apply();
13090
+ init_inbox_revise();
13022
13091
  init_save();
13023
13092
  init_history();
13024
13093
  init_changes();
@@ -17516,13 +17585,160 @@ var init_knowledge = __esm({
17516
17585
  }
17517
17586
  });
17518
17587
 
17588
+ // src/commands/inbox.ts
17589
+ var inbox_exports = {};
17590
+ __export(inbox_exports, {
17591
+ runInboxRevise: () => runInboxRevise
17592
+ });
17593
+ import { readFile as readFile8 } from "node:fs/promises";
17594
+ async function requireSession4(opts) {
17595
+ const session = await resolveSession();
17596
+ if (!session) {
17597
+ emitError(
17598
+ {
17599
+ code: "not_signed_in",
17600
+ message: "not signed in.",
17601
+ hint: "Run `bamboo-agents login` first (or set BAMBOO_API_TOKEN for headless use)."
17602
+ },
17603
+ opts,
17604
+ 1
17605
+ );
17606
+ throw new Error("unreachable");
17607
+ }
17608
+ return session;
17609
+ }
17610
+ async function readSelectionFile(path2) {
17611
+ let raw;
17612
+ try {
17613
+ raw = await readFile8(path2, "utf8");
17614
+ } catch (err) {
17615
+ throw new Error(`couldn't read selection file ${path2}: ${err.message}`);
17616
+ }
17617
+ let json;
17618
+ try {
17619
+ json = JSON.parse(raw);
17620
+ } catch {
17621
+ throw new Error(`selection file ${path2} is not valid JSON`);
17622
+ }
17623
+ const parsed = SelectionFileSchema.safeParse(json);
17624
+ if (!parsed.success) {
17625
+ throw new Error(
17626
+ `selection file ${path2} must be a JSON array of {kind: "add"|"del"|"context", old_line: number|null, new_line: number|null, content: string}`
17627
+ );
17628
+ }
17629
+ return parsed.data;
17630
+ }
17631
+ function printReviseResult(result, opts) {
17632
+ if (result.dispatched) {
17633
+ human(
17634
+ ` \u2713 Revision requested \u2014 the agent has been dispatched. Watch the Inbox for the update.`,
17635
+ opts
17636
+ );
17637
+ if (result.session_id) human(` session: ${result.session_id}`, opts);
17638
+ return;
17639
+ }
17640
+ human(` \u2022 Not dispatched \u2014 this PR's source is not a managed agent.`, opts);
17641
+ if (result.message) human(` ${result.message}`, opts);
17642
+ human(
17643
+ ` Applying the change directly isn't available from the CLI yet \u2014 make the edit via the Inbox or GitHub.`,
17644
+ opts
17645
+ );
17646
+ }
17647
+ async function runInboxRevise(options) {
17648
+ const opts = options;
17649
+ const session = await requireSession4(opts);
17650
+ const prNumber = Number.parseInt(options.pr ?? "", 10);
17651
+ if (!Number.isInteger(prNumber) || prNumber <= 0) {
17652
+ emitError(
17653
+ {
17654
+ code: "invalid_pr",
17655
+ message: `--pr must be a positive PR number (got ${JSON.stringify(options.pr ?? null)}).`
17656
+ },
17657
+ opts,
17658
+ 1
17659
+ );
17660
+ return;
17661
+ }
17662
+ const feedback = options.feedback?.trim();
17663
+ if (!feedback) {
17664
+ emitError(
17665
+ {
17666
+ code: "missing_feedback",
17667
+ message: "inbox revise requires --feedback.",
17668
+ hint: 'One sentence describing the change, e.g. --feedback "Keep the removed pricing line."'
17669
+ },
17670
+ opts,
17671
+ 1
17672
+ );
17673
+ return;
17674
+ }
17675
+ const file = options.file?.trim();
17676
+ if (!file) {
17677
+ emitError(
17678
+ {
17679
+ code: "missing_file",
17680
+ message: "inbox revise requires --file (the repo-relative path the feedback targets)."
17681
+ },
17682
+ opts,
17683
+ 1
17684
+ );
17685
+ return;
17686
+ }
17687
+ let selectedLines;
17688
+ if (options.selectionFile) {
17689
+ try {
17690
+ selectedLines = await readSelectionFile(options.selectionFile);
17691
+ } catch (err) {
17692
+ emitError(
17693
+ { code: "invalid_selection_file", message: err.message },
17694
+ opts,
17695
+ 1
17696
+ );
17697
+ return;
17698
+ }
17699
+ }
17700
+ const agentFlag = options.agent?.trim();
17701
+ const agentId = agentFlag && agentFlag.toLowerCase() !== "null" ? agentFlag : null;
17702
+ let result;
17703
+ try {
17704
+ result = await requestInboxRevision(session, {
17705
+ pr_number: prNumber,
17706
+ agent_id: agentId,
17707
+ feedback,
17708
+ file,
17709
+ selected_lines: selectedLines
17710
+ });
17711
+ } catch (err) {
17712
+ const code = err instanceof ApiError && err.errorCode ? err.errorCode : "revise_failed";
17713
+ emitError(
17714
+ { code, message: `revision request failed: ${err.message}` },
17715
+ opts,
17716
+ 1
17717
+ );
17718
+ return;
17719
+ }
17720
+ emitSuccess(result, opts, (r) => printReviseResult(r, opts));
17721
+ }
17722
+ var SelectionFileSchema;
17723
+ var init_inbox = __esm({
17724
+ "src/commands/inbox.ts"() {
17725
+ "use strict";
17726
+ init_zod();
17727
+ init_inbox_revise();
17728
+ init_credentials();
17729
+ init_api();
17730
+ init_output();
17731
+ SelectionFileSchema = external_exports.array(InboxReviseSelectedLineSchema).min(1).max(1e3);
17732
+ }
17733
+ });
17734
+
17519
17735
  // src/commands/history.ts
17520
17736
  var history_exports2 = {};
17521
17737
  __export(history_exports2, {
17522
17738
  runChanges: () => runChanges,
17523
17739
  runHistory: () => runHistory
17524
17740
  });
17525
- async function requireSession4(opts) {
17741
+ async function requireSession5(opts) {
17526
17742
  const creds = await readCredentials();
17527
17743
  if (!creds) {
17528
17744
  emitError(
@@ -17563,10 +17779,13 @@ function printHistory(data, opts) {
17563
17779
  }
17564
17780
  async function runHistory(options) {
17565
17781
  const opts = options;
17566
- const session = await requireSession4(opts);
17782
+ const session = await requireSession5(opts);
17567
17783
  let data;
17568
17784
  try {
17569
- data = await getHistory(session, { limit: parseLimit(options.limit) });
17785
+ data = await getHistory(session, {
17786
+ limit: parseLimit(options.limit),
17787
+ source: options.source
17788
+ });
17570
17789
  } catch (err) {
17571
17790
  emitError(
17572
17791
  { code: "history_failed", message: `couldn't load history: ${err.message}` },
@@ -17590,7 +17809,7 @@ function printChanges(data, opts) {
17590
17809
  }
17591
17810
  async function runChanges(options) {
17592
17811
  const opts = options;
17593
- const session = await requireSession4(opts);
17812
+ const session = await requireSession5(opts);
17594
17813
  let data;
17595
17814
  try {
17596
17815
  data = await getChanges(session, {
@@ -17623,7 +17842,7 @@ var context_exports = {};
17623
17842
  __export(context_exports, {
17624
17843
  runContextHealth: () => runContextHealth
17625
17844
  });
17626
- async function requireSession5(opts) {
17845
+ async function requireSession6(opts) {
17627
17846
  const creds = await readCredentials();
17628
17847
  if (!creds) {
17629
17848
  emitError(
@@ -17678,7 +17897,7 @@ function printHealthResponse(data, opts) {
17678
17897
  }
17679
17898
  async function runContextHealth(options) {
17680
17899
  const opts = options;
17681
- const session = await requireSession5(opts);
17900
+ const session = await requireSession6(opts);
17682
17901
  let data;
17683
17902
  try {
17684
17903
  data = await getContextHealth(session, {
@@ -17712,7 +17931,7 @@ var onboarding_exports = {};
17712
17931
  __export(onboarding_exports, {
17713
17932
  runOnboardingStatus: () => runOnboardingStatus
17714
17933
  });
17715
- async function requireSession6(opts) {
17934
+ async function requireSession7(opts) {
17716
17935
  const creds = await readCredentials();
17717
17936
  if (!creds) {
17718
17937
  emitError(
@@ -17741,7 +17960,7 @@ function printStatus(data, opts) {
17741
17960
  }
17742
17961
  async function runOnboardingStatus(options) {
17743
17962
  const opts = options;
17744
- const session = await requireSession6(opts);
17963
+ const session = await requireSession7(opts);
17745
17964
  let data;
17746
17965
  try {
17747
17966
  data = await getOnboardingStatus(session, { brandId: options.brand });
@@ -17773,7 +17992,7 @@ __export(brand_exports, {
17773
17992
  runBrandEditor: () => runBrandEditor,
17774
17993
  runBrandUpdate: () => runBrandUpdate
17775
17994
  });
17776
- async function requireSession7() {
17995
+ async function requireSession8() {
17777
17996
  const creds = await readCredentials();
17778
17997
  if (!creds) {
17779
17998
  console.error("bamboo-agents: not signed in. Run `bamboo-agents login` first.");
@@ -17786,7 +18005,7 @@ async function runBrandUpdate(brandId, options) {
17786
18005
  console.error("bamboo-agents: `brand update` requires a brand id.");
17787
18006
  process.exit(2);
17788
18007
  }
17789
- const session = await requireSession7();
18008
+ const session = await requireSession8();
17790
18009
  let result;
17791
18010
  try {
17792
18011
  result = await patchBrand(session, brandId, options.website);
@@ -17807,7 +18026,7 @@ async function runBrandEditor(action, brandId, userId, options) {
17807
18026
  console.error(`bamboo-agents: \`brand editor ${action}\` requires <brand-id> <user-id>.`);
17808
18027
  process.exit(2);
17809
18028
  }
17810
- const session = await requireSession7();
18029
+ const session = await requireSession8();
17811
18030
  let result;
17812
18031
  try {
17813
18032
  result = await postBrandEditor(session, brandId, { action, user_id: userId });
@@ -17846,7 +18065,7 @@ __export(agents_exports2, {
17846
18065
  runAgentsProvision: () => runAgentsProvision,
17847
18066
  runAgentsUpdate: () => runAgentsUpdate
17848
18067
  });
17849
- async function requireSession8(opts) {
18068
+ async function requireSession9(opts) {
17850
18069
  const creds = await readCredentials();
17851
18070
  if (!creds) {
17852
18071
  emitError(
@@ -17933,7 +18152,7 @@ function printList(data, opts) {
17933
18152
  }
17934
18153
  async function runAgentsList(options) {
17935
18154
  const opts = options;
17936
- const session = await requireSession8(opts);
18155
+ const session = await requireSession9(opts);
17937
18156
  let data;
17938
18157
  try {
17939
18158
  data = await listCliAgents(session);
@@ -17960,7 +18179,7 @@ function printDetail(agent, opts) {
17960
18179
  }
17961
18180
  async function runAgentsGet(agentRef, options) {
17962
18181
  const opts = options;
17963
- const session = await requireSession8(opts);
18182
+ const session = await requireSession9(opts);
17964
18183
  const row = await resolveAgentRef(session, agentRef, opts);
17965
18184
  let agent;
17966
18185
  try {
@@ -18002,7 +18221,7 @@ async function resolveBrandId(session, explicit, opts) {
18002
18221
  }
18003
18222
  async function runAgentsProvision(name, options) {
18004
18223
  const opts = options;
18005
- const session = await requireSession8(opts);
18224
+ const session = await requireSession9(opts);
18006
18225
  const brandId = await resolveBrandId(session, options.brand, opts);
18007
18226
  let result;
18008
18227
  try {
@@ -18028,7 +18247,7 @@ async function runAgentsProvision(name, options) {
18028
18247
  }
18029
18248
  async function runAgentsPause(agentRef, options) {
18030
18249
  const opts = options;
18031
- const session = await requireSession8(opts);
18250
+ const session = await requireSession9(opts);
18032
18251
  const row = await resolveAgentRef(session, agentRef, opts);
18033
18252
  try {
18034
18253
  const res = await pauseCliAgent(session, row.id);
@@ -18043,7 +18262,7 @@ async function runAgentsPause(agentRef, options) {
18043
18262
  }
18044
18263
  async function runAgentsUpdate(agentRef, options) {
18045
18264
  const opts = options;
18046
- const session = await requireSession8(opts);
18265
+ const session = await requireSession9(opts);
18047
18266
  const body = {};
18048
18267
  if (options.name !== void 0) body.name = options.name;
18049
18268
  if (options.description !== void 0) body.description = options.description;
@@ -18074,7 +18293,7 @@ async function runAgentsUpdate(agentRef, options) {
18074
18293
  }
18075
18294
  async function runAgentsDelete(agentRef, options) {
18076
18295
  const opts = options;
18077
- const session = await requireSession8(opts);
18296
+ const session = await requireSession9(opts);
18078
18297
  const row = await resolveAgentRef(session, agentRef, opts);
18079
18298
  try {
18080
18299
  const res = await deleteCliAgent(session, row.id);
@@ -18096,7 +18315,7 @@ async function runAgentsDelete(agentRef, options) {
18096
18315
  }
18097
18316
  async function runAgentsClone(sourceRef, targetRef, options) {
18098
18317
  const opts = options;
18099
- const session = await requireSession8(opts);
18318
+ const session = await requireSession9(opts);
18100
18319
  const source = await resolveAgentRef(session, sourceRef, opts);
18101
18320
  const target = await resolveAgentRef(session, targetRef, opts);
18102
18321
  try {
@@ -18125,7 +18344,7 @@ async function runAgentsClone(sourceRef, targetRef, options) {
18125
18344
  }
18126
18345
  async function runAgentsEnableTemplate(agentRef, options) {
18127
18346
  const opts = options;
18128
- const session = await requireSession8(opts);
18347
+ const session = await requireSession9(opts);
18129
18348
  if (!options.template) {
18130
18349
  emitError({ code: "template_required", message: "Provide --template <id>." }, opts, 2);
18131
18350
  return;
@@ -18159,7 +18378,7 @@ async function runAgentsEnableTemplate(agentRef, options) {
18159
18378
  }
18160
18379
  async function runAgentsActivate(agentRef, options) {
18161
18380
  const opts = options;
18162
- const session = await requireSession8(opts);
18381
+ const session = await requireSession9(opts);
18163
18382
  const row = await resolveAgentRef(session, agentRef, opts);
18164
18383
  let state = row.state;
18165
18384
  let status = row.status;
@@ -18531,7 +18750,18 @@ knowledge.command("save").description("Save a knowledge file (routed write \u201
18531
18750
  const { runKnowledgeSave: runKnowledgeSave2 } = await Promise.resolve().then(() => (init_knowledge(), knowledge_exports));
18532
18751
  await runKnowledgeSave2(options);
18533
18752
  });
18534
- program2.command("history").description("Recent workspace actions (reverse-chronological)").option("--limit <n>", "Max entries (default 20, max 100)").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) => {
18753
+ var inbox = program2.command("inbox").description("Actions on pending workspace PRs (the Inbox)");
18754
+ inbox.command("revise").description("Request a revision on a pending inbox PR (dispatches the source agent)").requiredOption("--pr <number>", "PR number in the workspace repo").requiredOption("--feedback <text>", "One sentence describing the change to make").requiredOption("--file <path>", "Repo-relative path of the file the feedback targets").option("--agent <id>", "Source agent id (default: resolved from the PR body)").option(
18755
+ "--selection-file <path>",
18756
+ "JSON file with the selected diff lines (array of {kind, old_line, new_line, content})"
18757
+ ).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) => {
18758
+ const { runInboxRevise: runInboxRevise2 } = await Promise.resolve().then(() => (init_inbox(), inbox_exports));
18759
+ await runInboxRevise2(options);
18760
+ });
18761
+ program2.command("history").description("Recent workspace actions (reverse-chronological)").option("--limit <n>", "Max entries (default 20, max 100)").option(
18762
+ "--source <runtime>",
18763
+ "Filter by runtime origin (boo | sandbox-boo | managed-agent)"
18764
+ ).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) => {
18535
18765
  const { runHistory: runHistory2 } = await Promise.resolve().then(() => (init_history2(), history_exports2));
18536
18766
  await runHistory2(options);
18537
18767
  });