bamboo-agents 0.1.5-dev.61.c67ae11 → 0.1.5-dev.63.0d55db2

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.63.0d55db2
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.63.0d55db2";
3041
3041
  }
3042
3042
  });
3043
3043
 
@@ -12450,6 +12450,97 @@ 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
+
12505
+ // ../../src/lib/api-contracts/cli/inbox-apply-revision.ts
12506
+ var InboxApplyRevisionRequestSchema, InboxApplyRevisionResponseSchema;
12507
+ var init_inbox_apply_revision = __esm({
12508
+ "../../src/lib/api-contracts/cli/inbox-apply-revision.ts"() {
12509
+ init_zod();
12510
+ init_save();
12511
+ InboxApplyRevisionRequestSchema = external_exports.object({
12512
+ /** PR number in the org's workspace repo. */
12513
+ pr_number: external_exports.number().int().positive(),
12514
+ /** Repo-relative path of the single file being revised. */
12515
+ file: external_exports.string().min(1).max(512),
12516
+ /** The complete new file content — the full file, not a diff. */
12517
+ new_content: external_exports.string().min(1).max(1e6),
12518
+ /** Short commit message, e.g. "revision: tighten tone in intro". */
12519
+ commit_message: external_exports.string().min(1).max(200),
12520
+ /**
12521
+ * Blob SHA from the `inbox revise` response — GitHub's optimistic
12522
+ * concurrency check. A stale SHA → 409 `pr_branch_moved`.
12523
+ */
12524
+ file_sha: external_exports.string().min(1).max(64),
12525
+ /**
12526
+ * The head branch from the `inbox revise` response. Validated against
12527
+ * the PR's actual head ref server-side (409 `branch_mismatch` on drift);
12528
+ * the commit always targets the PR's own head ref.
12529
+ */
12530
+ branch: external_exports.string().min(1).max(255).optional()
12531
+ }).refine((r) => isSafeRepoPath(r.file), {
12532
+ message: "unsafe file path: no '..' traversal, absolute paths, backslashes, or control chars",
12533
+ path: ["file"]
12534
+ });
12535
+ InboxApplyRevisionResponseSchema = external_exports.object({
12536
+ committed: external_exports.literal(true),
12537
+ /** The PR head branch the revision landed on. */
12538
+ branch: external_exports.string(),
12539
+ pr_number: external_exports.number()
12540
+ });
12541
+ }
12542
+ });
12543
+
12453
12544
  // ../../src/lib/api-contracts/cli/context-health.ts
12454
12545
  var ScopeKindSchema, ScopeSchema, CriterionMetricsSchema, StatusSchema, CriterionContributionSchema, CriterionResultSchema, BucketScoresSchema, ResolvedScopeSchema, GapsSchema, HealthyResponseSchema, UnavailableResponseSchema, ContextHealthResponseSchema;
12455
12546
  var init_context_health = __esm({
@@ -12651,6 +12742,32 @@ async function saveKnowledge(bambooSession, body) {
12651
12742
  const json = await res.json();
12652
12743
  return KnowledgeSaveResponseSchema.parse(json);
12653
12744
  }
12745
+ async function requestInboxRevision(bambooSession, body) {
12746
+ const res = await cliApiFetch(`${apiBase()}/api/v1/cli/inbox/revise`, {
12747
+ method: "POST",
12748
+ headers: {
12749
+ Authorization: `Bearer ${bambooSession}`,
12750
+ "Content-Type": "application/json"
12751
+ },
12752
+ body: JSON.stringify(body)
12753
+ });
12754
+ if (!res.ok) throw await parseError(res);
12755
+ const json = await res.json();
12756
+ return InboxReviseResponseSchema.parse(json);
12757
+ }
12758
+ async function requestInboxApplyRevision(bambooSession, body) {
12759
+ const res = await cliApiFetch(`${apiBase()}/api/v1/cli/inbox/apply-revision`, {
12760
+ method: "POST",
12761
+ headers: {
12762
+ Authorization: `Bearer ${bambooSession}`,
12763
+ "Content-Type": "application/json"
12764
+ },
12765
+ body: JSON.stringify(body)
12766
+ });
12767
+ if (!res.ok) throw await parseError(res);
12768
+ const json = await res.json();
12769
+ return InboxApplyRevisionResponseSchema.parse(json);
12770
+ }
12654
12771
  async function saveWorkspace(bambooSession, body) {
12655
12772
  const res = await cliApiFetch(`${apiBase()}/api/v1/cli/save`, {
12656
12773
  method: "POST",
@@ -13022,6 +13139,8 @@ var init_api = __esm({
13022
13139
  init_knowledge_slots();
13023
13140
  init_knowledge_save();
13024
13141
  init_skill_apply();
13142
+ init_inbox_revise();
13143
+ init_inbox_apply_revision();
13025
13144
  init_save();
13026
13145
  init_history();
13027
13146
  init_changes();
@@ -17519,13 +17638,311 @@ var init_knowledge = __esm({
17519
17638
  }
17520
17639
  });
17521
17640
 
17641
+ // src/commands/inbox.ts
17642
+ var inbox_exports = {};
17643
+ __export(inbox_exports, {
17644
+ runInboxApplyRevision: () => runInboxApplyRevision,
17645
+ runInboxRevise: () => runInboxRevise
17646
+ });
17647
+ import { mkdir as mkdir5, readFile as readFile8, writeFile as writeFile4 } from "node:fs/promises";
17648
+ import { tmpdir } from "node:os";
17649
+ import { basename, join as join6 } from "node:path";
17650
+ async function requireSession4(opts) {
17651
+ const session = await resolveSession();
17652
+ if (!session) {
17653
+ emitError(
17654
+ {
17655
+ code: "not_signed_in",
17656
+ message: "not signed in.",
17657
+ hint: "Run `bamboo-agents login` first (or set BAMBOO_API_TOKEN for headless use)."
17658
+ },
17659
+ opts,
17660
+ 1
17661
+ );
17662
+ throw new Error("unreachable");
17663
+ }
17664
+ return session;
17665
+ }
17666
+ async function readSelectionFile(path2) {
17667
+ let raw;
17668
+ try {
17669
+ raw = await readFile8(path2, "utf8");
17670
+ } catch (err) {
17671
+ throw new Error(`couldn't read selection file ${path2}: ${err.message}`);
17672
+ }
17673
+ let json;
17674
+ try {
17675
+ json = JSON.parse(raw);
17676
+ } catch {
17677
+ throw new Error(`selection file ${path2} is not valid JSON`);
17678
+ }
17679
+ const parsed = SelectionFileSchema.safeParse(json);
17680
+ if (!parsed.success) {
17681
+ throw new Error(
17682
+ `selection file ${path2} must be a JSON array of {kind: "add"|"del"|"context", old_line: number|null, new_line: number|null, content: string}`
17683
+ );
17684
+ }
17685
+ return parsed.data;
17686
+ }
17687
+ async function materializeReviseContent(result, file) {
17688
+ const { file_content, file_content_base, ...rest } = result;
17689
+ if (result.dispatched || !file_content || !result.file_sha || !result.branch) {
17690
+ return rest;
17691
+ }
17692
+ const dir = join6(tmpdir(), `bamboo-revise-${result.pr_number}`);
17693
+ const headFile = join6(dir, `head-${basename(file)}`);
17694
+ try {
17695
+ await mkdir5(dir, { recursive: true });
17696
+ await writeFile4(headFile, file_content, "utf8");
17697
+ let baseFile;
17698
+ if (file_content_base !== void 0) {
17699
+ baseFile = join6(dir, `base-${basename(file)}`);
17700
+ await writeFile4(baseFile, file_content_base, "utf8");
17701
+ }
17702
+ return {
17703
+ ...rest,
17704
+ head_file: headFile,
17705
+ base_file: baseFile,
17706
+ next_step: `Edit ${headFile} to apply the requested change, then run: bamboo-agents inbox apply-revision --pr ${result.pr_number} --file "${file}" --content-file ${headFile} --sha ${result.file_sha} --branch "${result.branch}" --message "revision: <short summary>" --json`
17707
+ };
17708
+ } catch {
17709
+ return result;
17710
+ }
17711
+ }
17712
+ function printReviseResult(result, opts) {
17713
+ if (result.dispatched) {
17714
+ human(
17715
+ ` \u2713 Revision requested \u2014 the agent has been dispatched. Watch the Inbox for the update.`,
17716
+ opts
17717
+ );
17718
+ if (result.session_id) human(` session: ${result.session_id}`, opts);
17719
+ return;
17720
+ }
17721
+ human(` \u2022 Not dispatched \u2014 this PR's source is not a managed agent.`, opts);
17722
+ if (result.message) human(` ${result.message}`, opts);
17723
+ if (result.head_file) {
17724
+ human(` PR-head content written to ${result.head_file}`, opts);
17725
+ human(
17726
+ ` Edit that file, then commit it back with \`bamboo-agents inbox apply-revision\` (see next_step).`,
17727
+ opts
17728
+ );
17729
+ } else {
17730
+ human(
17731
+ ` The file content could not be read from the PR branch \u2014 make the edit via the Inbox or GitHub.`,
17732
+ opts
17733
+ );
17734
+ }
17735
+ }
17736
+ async function runInboxRevise(options) {
17737
+ const opts = options;
17738
+ const session = await requireSession4(opts);
17739
+ const prNumber = Number.parseInt(options.pr ?? "", 10);
17740
+ if (!Number.isInteger(prNumber) || prNumber <= 0) {
17741
+ emitError(
17742
+ {
17743
+ code: "invalid_pr",
17744
+ message: `--pr must be a positive PR number (got ${JSON.stringify(options.pr ?? null)}).`
17745
+ },
17746
+ opts,
17747
+ 1
17748
+ );
17749
+ return;
17750
+ }
17751
+ const feedback = options.feedback?.trim();
17752
+ if (!feedback) {
17753
+ emitError(
17754
+ {
17755
+ code: "missing_feedback",
17756
+ message: "inbox revise requires --feedback.",
17757
+ hint: 'One sentence describing the change, e.g. --feedback "Keep the removed pricing line."'
17758
+ },
17759
+ opts,
17760
+ 1
17761
+ );
17762
+ return;
17763
+ }
17764
+ const file = options.file?.trim();
17765
+ if (!file) {
17766
+ emitError(
17767
+ {
17768
+ code: "missing_file",
17769
+ message: "inbox revise requires --file (the repo-relative path the feedback targets)."
17770
+ },
17771
+ opts,
17772
+ 1
17773
+ );
17774
+ return;
17775
+ }
17776
+ let selectedLines;
17777
+ if (options.selectionFile) {
17778
+ try {
17779
+ selectedLines = await readSelectionFile(options.selectionFile);
17780
+ } catch (err) {
17781
+ emitError(
17782
+ { code: "invalid_selection_file", message: err.message },
17783
+ opts,
17784
+ 1
17785
+ );
17786
+ return;
17787
+ }
17788
+ }
17789
+ const agentFlag = options.agent?.trim();
17790
+ const agentId = agentFlag && agentFlag.toLowerCase() !== "null" ? agentFlag : null;
17791
+ let result;
17792
+ try {
17793
+ result = await requestInboxRevision(session, {
17794
+ pr_number: prNumber,
17795
+ agent_id: agentId,
17796
+ feedback,
17797
+ file,
17798
+ selected_lines: selectedLines
17799
+ });
17800
+ } catch (err) {
17801
+ const code = err instanceof ApiError && err.errorCode ? err.errorCode : "revise_failed";
17802
+ emitError(
17803
+ { code, message: `revision request failed: ${err.message}` },
17804
+ opts,
17805
+ 1
17806
+ );
17807
+ return;
17808
+ }
17809
+ const output = await materializeReviseContent(result, file);
17810
+ emitSuccess(output, opts, (r) => printReviseResult(r, opts));
17811
+ }
17812
+ async function runInboxApplyRevision(options) {
17813
+ const opts = options;
17814
+ const session = await requireSession4(opts);
17815
+ const prNumber = Number.parseInt(options.pr ?? "", 10);
17816
+ if (!Number.isInteger(prNumber) || prNumber <= 0) {
17817
+ emitError(
17818
+ {
17819
+ code: "invalid_pr",
17820
+ message: `--pr must be a positive PR number (got ${JSON.stringify(options.pr ?? null)}).`
17821
+ },
17822
+ opts,
17823
+ 1
17824
+ );
17825
+ return;
17826
+ }
17827
+ const file = options.file?.trim();
17828
+ if (!file) {
17829
+ emitError(
17830
+ {
17831
+ code: "missing_file",
17832
+ message: "inbox apply-revision requires --file (the repo-relative path being revised)."
17833
+ },
17834
+ opts,
17835
+ 1
17836
+ );
17837
+ return;
17838
+ }
17839
+ const sha = options.sha?.trim();
17840
+ if (!sha) {
17841
+ emitError(
17842
+ {
17843
+ code: "missing_sha",
17844
+ message: "inbox apply-revision requires --sha (the file_sha from `inbox revise`).",
17845
+ hint: "GitHub uses it to reject the write if the PR branch moved since the file was read."
17846
+ },
17847
+ opts,
17848
+ 1
17849
+ );
17850
+ return;
17851
+ }
17852
+ const message = options.message?.trim();
17853
+ if (!message) {
17854
+ emitError(
17855
+ {
17856
+ code: "missing_message",
17857
+ message: "inbox apply-revision requires --message (a short commit message).",
17858
+ hint: 'e.g. --message "revision: tighten tone in intro paragraph"'
17859
+ },
17860
+ opts,
17861
+ 1
17862
+ );
17863
+ return;
17864
+ }
17865
+ if (!options.contentFile) {
17866
+ emitError(
17867
+ {
17868
+ code: "missing_content_file",
17869
+ message: "inbox apply-revision requires --content-file (the revised file content on disk).",
17870
+ hint: "Edit the head_file from `inbox revise`, then pass its path here \u2014 the FULL file, not a diff."
17871
+ },
17872
+ opts,
17873
+ 1
17874
+ );
17875
+ return;
17876
+ }
17877
+ let newContent;
17878
+ try {
17879
+ newContent = await readFile8(options.contentFile, "utf8");
17880
+ } catch (err) {
17881
+ emitError(
17882
+ {
17883
+ code: "invalid_content_file",
17884
+ message: `couldn't read content file ${options.contentFile}: ${err.message}`
17885
+ },
17886
+ opts,
17887
+ 1
17888
+ );
17889
+ return;
17890
+ }
17891
+ if (!newContent.trim()) {
17892
+ emitError(
17893
+ {
17894
+ code: "empty_content_file",
17895
+ message: `content file ${options.contentFile} is empty \u2014 apply-revision commits the full revised file.`,
17896
+ hint: "To remove the change entirely, decline the PR instead."
17897
+ },
17898
+ opts,
17899
+ 1
17900
+ );
17901
+ return;
17902
+ }
17903
+ let result;
17904
+ try {
17905
+ result = await requestInboxApplyRevision(session, {
17906
+ pr_number: prNumber,
17907
+ file,
17908
+ new_content: newContent,
17909
+ commit_message: message,
17910
+ file_sha: sha,
17911
+ branch: options.branch?.trim() || void 0
17912
+ });
17913
+ } catch (err) {
17914
+ const code = err instanceof ApiError && err.errorCode ? err.errorCode : "apply_revision_failed";
17915
+ emitError(
17916
+ { code, message: `apply-revision failed: ${err.message}` },
17917
+ opts,
17918
+ 1
17919
+ );
17920
+ return;
17921
+ }
17922
+ emitSuccess(result, opts, (r) => {
17923
+ human(` \u2713 Revision committed to ${r.branch} \u2014 the Inbox diff is updated.`, opts);
17924
+ });
17925
+ }
17926
+ var SelectionFileSchema;
17927
+ var init_inbox = __esm({
17928
+ "src/commands/inbox.ts"() {
17929
+ "use strict";
17930
+ init_zod();
17931
+ init_inbox_revise();
17932
+ init_credentials();
17933
+ init_api();
17934
+ init_output();
17935
+ SelectionFileSchema = external_exports.array(InboxReviseSelectedLineSchema).min(1).max(1e3);
17936
+ }
17937
+ });
17938
+
17522
17939
  // src/commands/history.ts
17523
17940
  var history_exports2 = {};
17524
17941
  __export(history_exports2, {
17525
17942
  runChanges: () => runChanges,
17526
17943
  runHistory: () => runHistory
17527
17944
  });
17528
- async function requireSession4(opts) {
17945
+ async function requireSession5(opts) {
17529
17946
  const creds = await readCredentials();
17530
17947
  if (!creds) {
17531
17948
  emitError(
@@ -17566,7 +17983,7 @@ function printHistory(data, opts) {
17566
17983
  }
17567
17984
  async function runHistory(options) {
17568
17985
  const opts = options;
17569
- const session = await requireSession4(opts);
17986
+ const session = await requireSession5(opts);
17570
17987
  let data;
17571
17988
  try {
17572
17989
  data = await getHistory(session, {
@@ -17596,7 +18013,7 @@ function printChanges(data, opts) {
17596
18013
  }
17597
18014
  async function runChanges(options) {
17598
18015
  const opts = options;
17599
- const session = await requireSession4(opts);
18016
+ const session = await requireSession5(opts);
17600
18017
  let data;
17601
18018
  try {
17602
18019
  data = await getChanges(session, {
@@ -17629,7 +18046,7 @@ var context_exports = {};
17629
18046
  __export(context_exports, {
17630
18047
  runContextHealth: () => runContextHealth
17631
18048
  });
17632
- async function requireSession5(opts) {
18049
+ async function requireSession6(opts) {
17633
18050
  const creds = await readCredentials();
17634
18051
  if (!creds) {
17635
18052
  emitError(
@@ -17684,7 +18101,7 @@ function printHealthResponse(data, opts) {
17684
18101
  }
17685
18102
  async function runContextHealth(options) {
17686
18103
  const opts = options;
17687
- const session = await requireSession5(opts);
18104
+ const session = await requireSession6(opts);
17688
18105
  let data;
17689
18106
  try {
17690
18107
  data = await getContextHealth(session, {
@@ -17718,7 +18135,7 @@ var onboarding_exports = {};
17718
18135
  __export(onboarding_exports, {
17719
18136
  runOnboardingStatus: () => runOnboardingStatus
17720
18137
  });
17721
- async function requireSession6(opts) {
18138
+ async function requireSession7(opts) {
17722
18139
  const creds = await readCredentials();
17723
18140
  if (!creds) {
17724
18141
  emitError(
@@ -17747,7 +18164,7 @@ function printStatus(data, opts) {
17747
18164
  }
17748
18165
  async function runOnboardingStatus(options) {
17749
18166
  const opts = options;
17750
- const session = await requireSession6(opts);
18167
+ const session = await requireSession7(opts);
17751
18168
  let data;
17752
18169
  try {
17753
18170
  data = await getOnboardingStatus(session, { brandId: options.brand });
@@ -17779,7 +18196,7 @@ __export(brand_exports, {
17779
18196
  runBrandEditor: () => runBrandEditor,
17780
18197
  runBrandUpdate: () => runBrandUpdate
17781
18198
  });
17782
- async function requireSession7() {
18199
+ async function requireSession8() {
17783
18200
  const creds = await readCredentials();
17784
18201
  if (!creds) {
17785
18202
  console.error("bamboo-agents: not signed in. Run `bamboo-agents login` first.");
@@ -17792,7 +18209,7 @@ async function runBrandUpdate(brandId, options) {
17792
18209
  console.error("bamboo-agents: `brand update` requires a brand id.");
17793
18210
  process.exit(2);
17794
18211
  }
17795
- const session = await requireSession7();
18212
+ const session = await requireSession8();
17796
18213
  let result;
17797
18214
  try {
17798
18215
  result = await patchBrand(session, brandId, options.website);
@@ -17813,7 +18230,7 @@ async function runBrandEditor(action, brandId, userId, options) {
17813
18230
  console.error(`bamboo-agents: \`brand editor ${action}\` requires <brand-id> <user-id>.`);
17814
18231
  process.exit(2);
17815
18232
  }
17816
- const session = await requireSession7();
18233
+ const session = await requireSession8();
17817
18234
  let result;
17818
18235
  try {
17819
18236
  result = await postBrandEditor(session, brandId, { action, user_id: userId });
@@ -17852,7 +18269,7 @@ __export(agents_exports2, {
17852
18269
  runAgentsProvision: () => runAgentsProvision,
17853
18270
  runAgentsUpdate: () => runAgentsUpdate
17854
18271
  });
17855
- async function requireSession8(opts) {
18272
+ async function requireSession9(opts) {
17856
18273
  const creds = await readCredentials();
17857
18274
  if (!creds) {
17858
18275
  emitError(
@@ -17939,7 +18356,7 @@ function printList(data, opts) {
17939
18356
  }
17940
18357
  async function runAgentsList(options) {
17941
18358
  const opts = options;
17942
- const session = await requireSession8(opts);
18359
+ const session = await requireSession9(opts);
17943
18360
  let data;
17944
18361
  try {
17945
18362
  data = await listCliAgents(session);
@@ -17966,7 +18383,7 @@ function printDetail(agent, opts) {
17966
18383
  }
17967
18384
  async function runAgentsGet(agentRef, options) {
17968
18385
  const opts = options;
17969
- const session = await requireSession8(opts);
18386
+ const session = await requireSession9(opts);
17970
18387
  const row = await resolveAgentRef(session, agentRef, opts);
17971
18388
  let agent;
17972
18389
  try {
@@ -18008,7 +18425,7 @@ async function resolveBrandId(session, explicit, opts) {
18008
18425
  }
18009
18426
  async function runAgentsProvision(name, options) {
18010
18427
  const opts = options;
18011
- const session = await requireSession8(opts);
18428
+ const session = await requireSession9(opts);
18012
18429
  const brandId = await resolveBrandId(session, options.brand, opts);
18013
18430
  let result;
18014
18431
  try {
@@ -18034,7 +18451,7 @@ async function runAgentsProvision(name, options) {
18034
18451
  }
18035
18452
  async function runAgentsPause(agentRef, options) {
18036
18453
  const opts = options;
18037
- const session = await requireSession8(opts);
18454
+ const session = await requireSession9(opts);
18038
18455
  const row = await resolveAgentRef(session, agentRef, opts);
18039
18456
  try {
18040
18457
  const res = await pauseCliAgent(session, row.id);
@@ -18049,7 +18466,7 @@ async function runAgentsPause(agentRef, options) {
18049
18466
  }
18050
18467
  async function runAgentsUpdate(agentRef, options) {
18051
18468
  const opts = options;
18052
- const session = await requireSession8(opts);
18469
+ const session = await requireSession9(opts);
18053
18470
  const body = {};
18054
18471
  if (options.name !== void 0) body.name = options.name;
18055
18472
  if (options.description !== void 0) body.description = options.description;
@@ -18080,7 +18497,7 @@ async function runAgentsUpdate(agentRef, options) {
18080
18497
  }
18081
18498
  async function runAgentsDelete(agentRef, options) {
18082
18499
  const opts = options;
18083
- const session = await requireSession8(opts);
18500
+ const session = await requireSession9(opts);
18084
18501
  const row = await resolveAgentRef(session, agentRef, opts);
18085
18502
  try {
18086
18503
  const res = await deleteCliAgent(session, row.id);
@@ -18102,7 +18519,7 @@ async function runAgentsDelete(agentRef, options) {
18102
18519
  }
18103
18520
  async function runAgentsClone(sourceRef, targetRef, options) {
18104
18521
  const opts = options;
18105
- const session = await requireSession8(opts);
18522
+ const session = await requireSession9(opts);
18106
18523
  const source = await resolveAgentRef(session, sourceRef, opts);
18107
18524
  const target = await resolveAgentRef(session, targetRef, opts);
18108
18525
  try {
@@ -18131,7 +18548,7 @@ async function runAgentsClone(sourceRef, targetRef, options) {
18131
18548
  }
18132
18549
  async function runAgentsEnableTemplate(agentRef, options) {
18133
18550
  const opts = options;
18134
- const session = await requireSession8(opts);
18551
+ const session = await requireSession9(opts);
18135
18552
  if (!options.template) {
18136
18553
  emitError({ code: "template_required", message: "Provide --template <id>." }, opts, 2);
18137
18554
  return;
@@ -18165,7 +18582,7 @@ async function runAgentsEnableTemplate(agentRef, options) {
18165
18582
  }
18166
18583
  async function runAgentsActivate(agentRef, options) {
18167
18584
  const opts = options;
18168
- const session = await requireSession8(opts);
18585
+ const session = await requireSession9(opts);
18169
18586
  const row = await resolveAgentRef(session, agentRef, opts);
18170
18587
  let state = row.state;
18171
18588
  let status = row.status;
@@ -18537,6 +18954,18 @@ knowledge.command("save").description("Save a knowledge file (routed write \u201
18537
18954
  const { runKnowledgeSave: runKnowledgeSave2 } = await Promise.resolve().then(() => (init_knowledge(), knowledge_exports));
18538
18955
  await runKnowledgeSave2(options);
18539
18956
  });
18957
+ var inbox = program2.command("inbox").description("Actions on pending workspace PRs (the Inbox)");
18958
+ 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(
18959
+ "--selection-file <path>",
18960
+ "JSON file with the selected diff lines (array of {kind, old_line, new_line, content})"
18961
+ ).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) => {
18962
+ const { runInboxRevise: runInboxRevise2 } = await Promise.resolve().then(() => (init_inbox(), inbox_exports));
18963
+ await runInboxRevise2(options);
18964
+ });
18965
+ inbox.command("apply-revision").description("Commit revised file content to a pending inbox PR's head branch (the dispatched:false follow-up to `inbox revise`)").requiredOption("--pr <number>", "PR number in the workspace repo").requiredOption("--file <path>", "Repo-relative path of the file being revised").requiredOption("--content-file <path>", "Local file holding the COMPLETE revised content (edit the head_file from `inbox revise`)").requiredOption("--sha <sha>", "The file_sha from `inbox revise` (GitHub's stale-write check)").requiredOption("--message <text>", "Short commit message, e.g. 'revision: tighten tone in intro'").option("--branch <name>", "PR head branch from `inbox revise` (validated server-side)").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) => {
18966
+ const { runInboxApplyRevision: runInboxApplyRevision2 } = await Promise.resolve().then(() => (init_inbox(), inbox_exports));
18967
+ await runInboxApplyRevision2(options);
18968
+ });
18540
18969
  program2.command("history").description("Recent workspace actions (reverse-chronological)").option("--limit <n>", "Max entries (default 20, max 100)").option(
18541
18970
  "--source <runtime>",
18542
18971
  "Filter by runtime origin (boo | sandbox-boo | managed-agent)"