bamboo-agents 0.1.5-dev.61.c67ae11 → 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.61.c67ae11
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.61.c67ae11";
3040
+ VERSION = "0.1.5-dev.62.c11b819";
3041
3041
  }
3042
3042
  });
3043
3043
 
@@ -12450,6 +12450,58 @@ var init_skill_apply = __esm({
12450
12450
  }
12451
12451
  });
12452
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
+
12453
12505
  // ../../src/lib/api-contracts/cli/context-health.ts
12454
12506
  var ScopeKindSchema, ScopeSchema, CriterionMetricsSchema, StatusSchema, CriterionContributionSchema, CriterionResultSchema, BucketScoresSchema, ResolvedScopeSchema, GapsSchema, HealthyResponseSchema, UnavailableResponseSchema, ContextHealthResponseSchema;
12455
12507
  var init_context_health = __esm({
@@ -12651,6 +12703,19 @@ async function saveKnowledge(bambooSession, body) {
12651
12703
  const json = await res.json();
12652
12704
  return KnowledgeSaveResponseSchema.parse(json);
12653
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
+ }
12654
12719
  async function saveWorkspace(bambooSession, body) {
12655
12720
  const res = await cliApiFetch(`${apiBase()}/api/v1/cli/save`, {
12656
12721
  method: "POST",
@@ -13022,6 +13087,7 @@ var init_api = __esm({
13022
13087
  init_knowledge_slots();
13023
13088
  init_knowledge_save();
13024
13089
  init_skill_apply();
13090
+ init_inbox_revise();
13025
13091
  init_save();
13026
13092
  init_history();
13027
13093
  init_changes();
@@ -17519,13 +17585,160 @@ var init_knowledge = __esm({
17519
17585
  }
17520
17586
  });
17521
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
+
17522
17735
  // src/commands/history.ts
17523
17736
  var history_exports2 = {};
17524
17737
  __export(history_exports2, {
17525
17738
  runChanges: () => runChanges,
17526
17739
  runHistory: () => runHistory
17527
17740
  });
17528
- async function requireSession4(opts) {
17741
+ async function requireSession5(opts) {
17529
17742
  const creds = await readCredentials();
17530
17743
  if (!creds) {
17531
17744
  emitError(
@@ -17566,7 +17779,7 @@ function printHistory(data, opts) {
17566
17779
  }
17567
17780
  async function runHistory(options) {
17568
17781
  const opts = options;
17569
- const session = await requireSession4(opts);
17782
+ const session = await requireSession5(opts);
17570
17783
  let data;
17571
17784
  try {
17572
17785
  data = await getHistory(session, {
@@ -17596,7 +17809,7 @@ function printChanges(data, opts) {
17596
17809
  }
17597
17810
  async function runChanges(options) {
17598
17811
  const opts = options;
17599
- const session = await requireSession4(opts);
17812
+ const session = await requireSession5(opts);
17600
17813
  let data;
17601
17814
  try {
17602
17815
  data = await getChanges(session, {
@@ -17629,7 +17842,7 @@ var context_exports = {};
17629
17842
  __export(context_exports, {
17630
17843
  runContextHealth: () => runContextHealth
17631
17844
  });
17632
- async function requireSession5(opts) {
17845
+ async function requireSession6(opts) {
17633
17846
  const creds = await readCredentials();
17634
17847
  if (!creds) {
17635
17848
  emitError(
@@ -17684,7 +17897,7 @@ function printHealthResponse(data, opts) {
17684
17897
  }
17685
17898
  async function runContextHealth(options) {
17686
17899
  const opts = options;
17687
- const session = await requireSession5(opts);
17900
+ const session = await requireSession6(opts);
17688
17901
  let data;
17689
17902
  try {
17690
17903
  data = await getContextHealth(session, {
@@ -17718,7 +17931,7 @@ var onboarding_exports = {};
17718
17931
  __export(onboarding_exports, {
17719
17932
  runOnboardingStatus: () => runOnboardingStatus
17720
17933
  });
17721
- async function requireSession6(opts) {
17934
+ async function requireSession7(opts) {
17722
17935
  const creds = await readCredentials();
17723
17936
  if (!creds) {
17724
17937
  emitError(
@@ -17747,7 +17960,7 @@ function printStatus(data, opts) {
17747
17960
  }
17748
17961
  async function runOnboardingStatus(options) {
17749
17962
  const opts = options;
17750
- const session = await requireSession6(opts);
17963
+ const session = await requireSession7(opts);
17751
17964
  let data;
17752
17965
  try {
17753
17966
  data = await getOnboardingStatus(session, { brandId: options.brand });
@@ -17779,7 +17992,7 @@ __export(brand_exports, {
17779
17992
  runBrandEditor: () => runBrandEditor,
17780
17993
  runBrandUpdate: () => runBrandUpdate
17781
17994
  });
17782
- async function requireSession7() {
17995
+ async function requireSession8() {
17783
17996
  const creds = await readCredentials();
17784
17997
  if (!creds) {
17785
17998
  console.error("bamboo-agents: not signed in. Run `bamboo-agents login` first.");
@@ -17792,7 +18005,7 @@ async function runBrandUpdate(brandId, options) {
17792
18005
  console.error("bamboo-agents: `brand update` requires a brand id.");
17793
18006
  process.exit(2);
17794
18007
  }
17795
- const session = await requireSession7();
18008
+ const session = await requireSession8();
17796
18009
  let result;
17797
18010
  try {
17798
18011
  result = await patchBrand(session, brandId, options.website);
@@ -17813,7 +18026,7 @@ async function runBrandEditor(action, brandId, userId, options) {
17813
18026
  console.error(`bamboo-agents: \`brand editor ${action}\` requires <brand-id> <user-id>.`);
17814
18027
  process.exit(2);
17815
18028
  }
17816
- const session = await requireSession7();
18029
+ const session = await requireSession8();
17817
18030
  let result;
17818
18031
  try {
17819
18032
  result = await postBrandEditor(session, brandId, { action, user_id: userId });
@@ -17852,7 +18065,7 @@ __export(agents_exports2, {
17852
18065
  runAgentsProvision: () => runAgentsProvision,
17853
18066
  runAgentsUpdate: () => runAgentsUpdate
17854
18067
  });
17855
- async function requireSession8(opts) {
18068
+ async function requireSession9(opts) {
17856
18069
  const creds = await readCredentials();
17857
18070
  if (!creds) {
17858
18071
  emitError(
@@ -17939,7 +18152,7 @@ function printList(data, opts) {
17939
18152
  }
17940
18153
  async function runAgentsList(options) {
17941
18154
  const opts = options;
17942
- const session = await requireSession8(opts);
18155
+ const session = await requireSession9(opts);
17943
18156
  let data;
17944
18157
  try {
17945
18158
  data = await listCliAgents(session);
@@ -17966,7 +18179,7 @@ function printDetail(agent, opts) {
17966
18179
  }
17967
18180
  async function runAgentsGet(agentRef, options) {
17968
18181
  const opts = options;
17969
- const session = await requireSession8(opts);
18182
+ const session = await requireSession9(opts);
17970
18183
  const row = await resolveAgentRef(session, agentRef, opts);
17971
18184
  let agent;
17972
18185
  try {
@@ -18008,7 +18221,7 @@ async function resolveBrandId(session, explicit, opts) {
18008
18221
  }
18009
18222
  async function runAgentsProvision(name, options) {
18010
18223
  const opts = options;
18011
- const session = await requireSession8(opts);
18224
+ const session = await requireSession9(opts);
18012
18225
  const brandId = await resolveBrandId(session, options.brand, opts);
18013
18226
  let result;
18014
18227
  try {
@@ -18034,7 +18247,7 @@ async function runAgentsProvision(name, options) {
18034
18247
  }
18035
18248
  async function runAgentsPause(agentRef, options) {
18036
18249
  const opts = options;
18037
- const session = await requireSession8(opts);
18250
+ const session = await requireSession9(opts);
18038
18251
  const row = await resolveAgentRef(session, agentRef, opts);
18039
18252
  try {
18040
18253
  const res = await pauseCliAgent(session, row.id);
@@ -18049,7 +18262,7 @@ async function runAgentsPause(agentRef, options) {
18049
18262
  }
18050
18263
  async function runAgentsUpdate(agentRef, options) {
18051
18264
  const opts = options;
18052
- const session = await requireSession8(opts);
18265
+ const session = await requireSession9(opts);
18053
18266
  const body = {};
18054
18267
  if (options.name !== void 0) body.name = options.name;
18055
18268
  if (options.description !== void 0) body.description = options.description;
@@ -18080,7 +18293,7 @@ async function runAgentsUpdate(agentRef, options) {
18080
18293
  }
18081
18294
  async function runAgentsDelete(agentRef, options) {
18082
18295
  const opts = options;
18083
- const session = await requireSession8(opts);
18296
+ const session = await requireSession9(opts);
18084
18297
  const row = await resolveAgentRef(session, agentRef, opts);
18085
18298
  try {
18086
18299
  const res = await deleteCliAgent(session, row.id);
@@ -18102,7 +18315,7 @@ async function runAgentsDelete(agentRef, options) {
18102
18315
  }
18103
18316
  async function runAgentsClone(sourceRef, targetRef, options) {
18104
18317
  const opts = options;
18105
- const session = await requireSession8(opts);
18318
+ const session = await requireSession9(opts);
18106
18319
  const source = await resolveAgentRef(session, sourceRef, opts);
18107
18320
  const target = await resolveAgentRef(session, targetRef, opts);
18108
18321
  try {
@@ -18131,7 +18344,7 @@ async function runAgentsClone(sourceRef, targetRef, options) {
18131
18344
  }
18132
18345
  async function runAgentsEnableTemplate(agentRef, options) {
18133
18346
  const opts = options;
18134
- const session = await requireSession8(opts);
18347
+ const session = await requireSession9(opts);
18135
18348
  if (!options.template) {
18136
18349
  emitError({ code: "template_required", message: "Provide --template <id>." }, opts, 2);
18137
18350
  return;
@@ -18165,7 +18378,7 @@ async function runAgentsEnableTemplate(agentRef, options) {
18165
18378
  }
18166
18379
  async function runAgentsActivate(agentRef, options) {
18167
18380
  const opts = options;
18168
- const session = await requireSession8(opts);
18381
+ const session = await requireSession9(opts);
18169
18382
  const row = await resolveAgentRef(session, agentRef, opts);
18170
18383
  let state = row.state;
18171
18384
  let status = row.status;
@@ -18537,6 +18750,14 @@ knowledge.command("save").description("Save a knowledge file (routed write \u201
18537
18750
  const { runKnowledgeSave: runKnowledgeSave2 } = await Promise.resolve().then(() => (init_knowledge(), knowledge_exports));
18538
18751
  await runKnowledgeSave2(options);
18539
18752
  });
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
+ });
18540
18761
  program2.command("history").description("Recent workspace actions (reverse-chronological)").option("--limit <n>", "Max entries (default 20, max 100)").option(
18541
18762
  "--source <runtime>",
18542
18763
  "Filter by runtime origin (boo | sandbox-boo | managed-agent)"