@oxagen/cli 3.0.1-792 → 3.0.1-793

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.
Files changed (2) hide show
  1. package/oxagen.mjs +55 -11
  2. package/package.json +1 -1
package/oxagen.mjs CHANGED
@@ -29915,7 +29915,7 @@ import { readFileSync as readFileSync10 } from "node:fs";
29915
29915
  import { dirname as dirname9, resolve as resolve3 } from "node:path";
29916
29916
  import { fileURLToPath } from "node:url";
29917
29917
  function readVersion() {
29918
- if (true) return "3.0.1-792";
29918
+ if (true) return "3.0.1-793";
29919
29919
  try {
29920
29920
  const here = dirname9(fileURLToPath(import.meta.url));
29921
29921
  const pkg = JSON.parse(
@@ -73315,7 +73315,7 @@ var init_package = __esm({
73315
73315
  "package.json"() {
73316
73316
  package_default = {
73317
73317
  name: "@oxagen/cli",
73318
- version: "3.0.1-792",
73318
+ version: "3.0.1-793",
73319
73319
  description: "Oxagen governance CLI: spend, source tracking, grounding, credentials, and audit (agentic coding lives in the stella CLI)",
73320
73320
  type: "module",
73321
73321
  main: "./dist/index.js",
@@ -86486,6 +86486,7 @@ __export(sandbox_attach_exports, {
86486
86486
  DETACH_KEY: () => DETACH_KEY,
86487
86487
  MAX_RECONNECTS: () => MAX_RECONNECTS,
86488
86488
  MAX_START_WAITS: () => MAX_START_WAITS,
86489
+ TAKE_CONTROL_REASON: () => TAKE_CONTROL_REASON,
86489
86490
  attachToRun: () => attachToRun,
86490
86491
  parseRunTarget: () => parseRunTarget,
86491
86492
  processIo: () => processIo,
@@ -86523,8 +86524,9 @@ function encodeInput(bytes) {
86523
86524
  data: Buffer.from(bytes).toString("base64")
86524
86525
  });
86525
86526
  }
86526
- async function terminalSession(relay, mode, runName, io, writer) {
86527
+ async function terminalSession(relay, mode, runName, io, writer, opts = {}) {
86527
86528
  let token = relay.token;
86529
+ let granted = opts.paused !== true;
86528
86530
  let lastSeq = null;
86529
86531
  let current = null;
86530
86532
  let detaching = false;
@@ -86551,14 +86553,14 @@ async function terminalSession(relay, mode, runName, io, writer) {
86551
86553
  if (control) {
86552
86554
  const at2 = chunk.indexOf(DETACH_KEY);
86553
86555
  const head3 = at2 === -1 ? chunk : chunk.subarray(0, at2);
86554
- if (head3.length > 0) send5(encodeInput(head3));
86556
+ if (head3.length > 0 && granted) send5(encodeInput(head3));
86555
86557
  if (at2 !== -1) detach();
86556
86558
  return;
86557
86559
  }
86558
86560
  if (chunk.includes(DETACH_KEY) || chunk.includes(CTRL_C)) detach();
86559
86561
  };
86560
86562
  const onResize = () => {
86561
- if (!control) return;
86563
+ if (!control || !granted) return;
86562
86564
  const { columns, rows } = io.stdout;
86563
86565
  if (columns && rows) send5({ type: "resize", cols: columns, rows });
86564
86566
  };
@@ -86596,6 +86598,16 @@ async function terminalSession(relay, mode, runName, io, writer) {
86596
86598
  case "token":
86597
86599
  token = message2.token;
86598
86600
  break;
86601
+ case "control": {
86602
+ const next = message2.state === "granted";
86603
+ if (next === granted) break;
86604
+ granted = next;
86605
+ writer.writeErr(
86606
+ granted ? "The run is paused. Your keystrokes reach it now." : "The run resumed, so your keystrokes no longer reach it."
86607
+ );
86608
+ onResize();
86609
+ break;
86610
+ }
86599
86611
  case "closed": {
86600
86612
  const text6 = CLOSED_MESSAGE[message2.reason];
86601
86613
  state.final = {
@@ -86662,7 +86674,12 @@ async function terminalSession(relay, mode, runName, io, writer) {
86662
86674
  }
86663
86675
  }
86664
86676
  const result2 = state.final;
86665
- if (detaching) {
86677
+ if (detaching && opts.paused === true) {
86678
+ writer.writeErr(
86679
+ `
86680
+ You left the terminal. The run stays paused until someone resumes it from its page in the app. Open its terminal again with \`oxagen sandbox attach ${runName}\`.`
86681
+ );
86682
+ } else if (detaching) {
86666
86683
  writer.writeErr(
86667
86684
  `
86668
86685
  You left the terminal. The run keeps going. Open its terminal again with \`oxagen sandbox attach ${runName}\`.`
@@ -86725,12 +86742,35 @@ async function attachToRun(run3, opts, writer = stdoutWriter, io = processIo())
86725
86742
  );
86726
86743
  return 1;
86727
86744
  }
86745
+ const scope = { org, ws: workspace };
86728
86746
  let relay;
86729
- try {
86747
+ let pauses = null;
86748
+ try {
86749
+ if (mode === "control") {
86750
+ const { run: detail } = await apiPostOrThrow("sandbox-runs/get", target, scope);
86751
+ if (!detail.interactive) {
86752
+ if (detail.runId === null) {
86753
+ writer.writeErr(
86754
+ "\u2717 This run has not recorded its first step, so it cannot pause yet. Pass --watch to read the screen."
86755
+ );
86756
+ return 1;
86757
+ }
86758
+ pauses = detail.runId;
86759
+ await apiPostOrThrow(
86760
+ "commands",
86761
+ {
86762
+ target: { kind: "run", id: pauses },
86763
+ command: "pause",
86764
+ reason: TAKE_CONTROL_REASON
86765
+ },
86766
+ scope
86767
+ );
86768
+ }
86769
+ }
86730
86770
  relay = await openRelay(
86731
86771
  target,
86732
86772
  mode,
86733
- { org, ws: workspace },
86773
+ scope,
86734
86774
  io,
86735
86775
  writer,
86736
86776
  opts.waitForStart === true
@@ -86740,15 +86780,17 @@ async function attachToRun(run3, opts, writer = stdoutWriter, io = processIo())
86740
86780
  return 1;
86741
86781
  }
86742
86782
  writer.writeErr(
86743
- mode === "control" ? "Connected. Press Ctrl-] to detach and leave the run going." : "Watching. Press Ctrl-] to stop watching."
86783
+ mode === "watch" ? "Watching. Press Ctrl-] to stop watching." : pauses !== null ? "Pausing the run. Your keystrokes reach it once it reports the pause. Press Ctrl-] to detach." : "Connected. Press Ctrl-] to detach and leave the run going."
86744
86784
  );
86745
- return terminalSession(relay, mode, run3, io, writer);
86785
+ return terminalSession(relay, mode, run3, io, writer, {
86786
+ paused: pauses !== null
86787
+ });
86746
86788
  }
86747
86789
  async function runAttach(run3, opts, writer = stdoutWriter) {
86748
86790
  const code = await attachToRun(run3, opts, writer);
86749
86791
  if (code !== 0) process.exitCode = code;
86750
86792
  }
86751
- var DETACH_KEY, CTRL_C, MAX_RECONNECTS, MAX_START_WAITS, START_WAIT_MS, SOCKET_OPEN, FINAL_CLOSE, CLOSED_MESSAGE;
86793
+ var DETACH_KEY, CTRL_C, TAKE_CONTROL_REASON, MAX_RECONNECTS, MAX_START_WAITS, START_WAIT_MS, SOCKET_OPEN, FINAL_CLOSE, CLOSED_MESSAGE;
86752
86794
  var init_sandbox_attach = __esm({
86753
86795
  "src/commands/sandbox-attach.ts"() {
86754
86796
  init_api();
@@ -86757,6 +86799,7 @@ var init_sandbox_attach = __esm({
86757
86799
  init_sandbox_run();
86758
86800
  DETACH_KEY = 29;
86759
86801
  CTRL_C = 3;
86802
+ TAKE_CONTROL_REASON = "The operator took control of the run's terminal.";
86760
86803
  MAX_RECONNECTS = 5;
86761
86804
  MAX_START_WAITS = 60;
86762
86805
  START_WAIT_MS = 2e3;
@@ -86767,6 +86810,7 @@ var init_sandbox_attach = __esm({
86767
86810
  4401: "The terminal session expired. Run `oxagen sandbox attach` again.",
86768
86811
  4403: "Only the operator who launched this run can stop it or open its terminal.",
86769
86812
  4408: "The relay got no hello in time. Run `oxagen sandbox attach` again.",
86813
+ 4409: "Another session has control of this run's terminal. Pass --watch to read the screen, or try again once that session hands control back.",
86770
86814
  4410: "This terminal session has ended. Run `oxagen sandbox attach` to open a new one.",
86771
86815
  4502: "The relay could not open the run's terminal. Try again in a moment."
86772
86816
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxagen/cli",
3
- "version": "3.0.1-792",
3
+ "version": "3.0.1-793",
4
4
  "description": "Oxagen governance CLI: spend, source tracking, grounding, credentials, and audit (agentic coding lives in the stella CLI)",
5
5
  "type": "module",
6
6
  "bin": {