benignswarm 0.12.101 → 0.12.102
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/antigravity.js +49 -6
- package/dist/args.js +1 -1
- package/dist/commands/codex-start.js +9 -6
- package/dist/commands/machine-admin.js +110 -30
- package/dist/commands/machine.js +24 -13
- package/dist/help.js +7 -5
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/antigravity.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
|
-
import { appendFileSync, existsSync, mkdirSync, readFileSync, statSync } from "node:fs";
|
|
2
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
|
-
import { basename, dirname, join } from "node:path";
|
|
4
|
+
import { basename, delimiter, dirname, join } from "node:path";
|
|
5
5
|
import { configRoot } from "./config.js";
|
|
6
|
+
import { repoDirectory } from "./directories.js";
|
|
6
7
|
import { CliError } from "./errors.js";
|
|
7
8
|
export function antigravityTotalTokens(usage) {
|
|
8
9
|
if (!usage)
|
|
@@ -14,7 +15,41 @@ export function antigravityTotalTokens(usage) {
|
|
|
14
15
|
export const antigravityLog = (ref) => join(configRoot(), "logs", `antigravity.${ref.replace("/", ".")}.jsonl`);
|
|
15
16
|
export const antigravityConversationDb = (id, home = homedir()) => join(home, ".gemini", "antigravity-cli", "conversations", `${id}.db`);
|
|
16
17
|
const shq = (s) => (/^[\w./=:@-]+$/.test(s) ? s : `'${s.replace(/'/g, `'\\''`)}'`);
|
|
17
|
-
|
|
18
|
+
function b9sPackageRoot(bin) {
|
|
19
|
+
let dir = dirname(realpathSync(bin));
|
|
20
|
+
for (;;) {
|
|
21
|
+
const manifest = join(dir, "package.json");
|
|
22
|
+
if (existsSync(manifest)) {
|
|
23
|
+
try {
|
|
24
|
+
if (JSON.parse(readFileSync(manifest, "utf8")).name === "benignswarm")
|
|
25
|
+
return dir;
|
|
26
|
+
}
|
|
27
|
+
catch { /* continue up to the package root */ }
|
|
28
|
+
}
|
|
29
|
+
const parent = dirname(dir);
|
|
30
|
+
if (parent === dir)
|
|
31
|
+
break;
|
|
32
|
+
dir = parent;
|
|
33
|
+
}
|
|
34
|
+
throw new CliError("install_package_missing", `cannot find the benignswarm package containing recorded b9s install ${bin}`);
|
|
35
|
+
}
|
|
36
|
+
export function antigravitySandboxPermissions(apiHost, b9sHome, b9sBin, nodeBin = process.execPath, skillRoot) {
|
|
37
|
+
const packageRoot = b9sPackageRoot(b9sBin);
|
|
38
|
+
const allow = [
|
|
39
|
+
`read_url(${apiHost})`, "read_url(github.com)", "command(b9s)",
|
|
40
|
+
`read_file(${b9sBin})`, `read_file(${realpathSync(b9sBin)})`, `read_file(${nodeBin})`, `read_file(${packageRoot})`,
|
|
41
|
+
`write_file(${b9sHome})`,
|
|
42
|
+
];
|
|
43
|
+
if (skillRoot) {
|
|
44
|
+
allow.push(`read_file(${join(skillRoot, "identity.json")})`);
|
|
45
|
+
for (const file of ["SKILL.md", "references/api.md", "references/watchers.md", "references/process.md", "references/continuity.md"]) {
|
|
46
|
+
allow.push(`read_file(${join(skillRoot, file)})`);
|
|
47
|
+
}
|
|
48
|
+
allow.push(`read_file(${join(dirname(skillRoot), ".agents", "rules", "bschat.md")})`);
|
|
49
|
+
}
|
|
50
|
+
return [...new Set(allow)];
|
|
51
|
+
}
|
|
52
|
+
export function antigravitySettings(sandbox, cwd, b9sHome, apiHost, extraWritable = [], b9sBin, nodeBin = process.execPath) {
|
|
18
53
|
if (sandbox === "read-only")
|
|
19
54
|
throw new CliError("unsupported", "Antigravity has no read-only permission mode; use workspace-write or danger-full-access");
|
|
20
55
|
if (sandbox === "danger-full-access")
|
|
@@ -23,10 +58,12 @@ export function antigravitySettings(sandbox, cwd, b9sHome, apiHost, extraWritabl
|
|
|
23
58
|
throw new CliError("usage", `unknown sandbox ${sandbox}`);
|
|
24
59
|
if (!/^[a-z0-9.-]+(?::\d+)?$/i.test(apiHost))
|
|
25
60
|
throw new CliError("usage", "the BenignSwarm API host is invalid for Antigravity sandbox permissions");
|
|
61
|
+
if (!b9sBin)
|
|
62
|
+
throw new CliError("not_installed", "the recorded b9s install path is required for Antigravity workspace-write");
|
|
26
63
|
const dirs = [...new Set([dirname(cwd), b9sHome, ...extraWritable])];
|
|
27
64
|
return [
|
|
28
65
|
"--sandbox", "--settings",
|
|
29
|
-
JSON.stringify({ enableTerminalSandbox: true, toolPermission: "proceed-in-sandbox", permissions: { allow:
|
|
66
|
+
JSON.stringify({ enableTerminalSandbox: true, toolPermission: "proceed-in-sandbox", permissions: { allow: antigravitySandboxPermissions(apiHost, b9sHome, b9sBin, nodeBin, repoDirectory(cwd)) } }),
|
|
30
67
|
...dirs.flatMap((dir) => ["--add-dir", dir]),
|
|
31
68
|
];
|
|
32
69
|
}
|
|
@@ -66,8 +103,14 @@ export function recordAntigravityTurn(path, record) {
|
|
|
66
103
|
appendFileSync(path, `${JSON.stringify(record)}\n`, { mode: 0o600 });
|
|
67
104
|
}
|
|
68
105
|
/** Explicit markers let commands launched by this turn inherit only this harness's sandbox workaround. */
|
|
69
|
-
export function
|
|
70
|
-
return
|
|
106
|
+
export function antigravityPath(b9sBin, path = process.env.PATH ?? "") {
|
|
107
|
+
return [...new Set([dirname(b9sBin), dirname(process.execPath), ...path.split(delimiter).filter(Boolean)])].join(delimiter);
|
|
108
|
+
}
|
|
109
|
+
export function antigravityTurnEnv(sandbox, b9sBin) {
|
|
110
|
+
if (sandbox !== "workspace-write")
|
|
111
|
+
return { BSCHAT_HARNESS: "antigravity", BSCHAT_ANTIGRAVITY_SANDBOX: sandbox };
|
|
112
|
+
const path = b9sBin ? antigravityPath(b9sBin) : [...new Set([dirname(process.execPath), ...(process.env.PATH ?? "").split(delimiter).filter(Boolean)])].join(delimiter);
|
|
113
|
+
return { BSCHAT_HARNESS: "antigravity", BSCHAT_ANTIGRAVITY_SANDBOX: sandbox, PATH: path };
|
|
71
114
|
}
|
|
72
115
|
export function runAntigravityTurn(bin, args, logPath, cwd, agent, expectedConversation, run = spawnSync, envOverride = {}) {
|
|
73
116
|
const started = new Date().toISOString();
|
package/dist/args.js
CHANGED
|
@@ -22,7 +22,7 @@ export const STRING_FLAGS = [
|
|
|
22
22
|
"require-evidence", "default-approver", "merged-by", "integrator-role", "require-rebased", "require-merge-commit",
|
|
23
23
|
"require-pushed", "quiet", "summary", "meaning", "expert-role", "reviews", "works", "trials", "email",
|
|
24
24
|
"repeat", "summary-minutes", "churn", "unmet", "require-cited-changes", "checks-every", "propose", "waits-on",
|
|
25
|
-
"sandbox", "thread", "turn-timeout", "turns-per-hour", "unproductive-per-hour", "turn-coalesce-seconds", "session",
|
|
25
|
+
"sandbox", "thread", "turn-timeout", "turns-per-hour", "unproductive-per-hour", "turn-coalesce-seconds", "session", "operation",
|
|
26
26
|
"plain", "if-yes", "if-no", "ssh", "variant", "count", "needs", "min-ram", "exclude", "carry", "from",
|
|
27
27
|
"to-ssh", "wait", "writable", "writable-root", "dsh", "agy", "for", "until", "reason", "at", "requires",
|
|
28
28
|
"priority", "informs", "amend", "waive-informs", "text", "kind", "claim", "decision", "sha", "value", "expect",
|
|
@@ -171,8 +171,11 @@ export async function harnessStart(p, out, harness) {
|
|
|
171
171
|
await configureGitCredentialForWorktree(process.cwd(), creds);
|
|
172
172
|
if (creds.vendor && creds.vendor !== harness)
|
|
173
173
|
throw new CliError("vendor_mismatch", `${ref} is saved as ${creds.vendor}, not ${harness}`);
|
|
174
|
-
if (harness === "antigravity")
|
|
175
|
-
|
|
174
|
+
if (harness === "antigravity") {
|
|
175
|
+
if (inContainer)
|
|
176
|
+
provisionContainerInstallRecord();
|
|
177
|
+
settings = antigravitySettings(sandbox, process.cwd(), configRoot(), new URL(creds.url).host, [...writable, ...ownWorktreeGitDir(process.cwd())], requireInstall().bin);
|
|
178
|
+
}
|
|
176
179
|
const priorState = readState(ref);
|
|
177
180
|
if (priorState.turn_guard?.fault) {
|
|
178
181
|
const fault = priorState.turn_guard.fault;
|
|
@@ -222,7 +225,7 @@ export async function harnessStart(p, out, harness) {
|
|
|
222
225
|
lines.push(`Adopted Antigravity conversation ${session}. Do not resume it elsewhere while the watcher runs it: two clients on one conversation conflict.`);
|
|
223
226
|
}
|
|
224
227
|
if (harness === "antigravity" && sandbox === "workspace-write")
|
|
225
|
-
await runAntigravitySandboxSelfCheck(ref, bin, settings, process.cwd(), session, model, effort, turnTimeout * 60, firstTurnLog, turnsPerHour, antigravityTurnEnv(sandbox), unproductivePerHour);
|
|
228
|
+
await runAntigravitySandboxSelfCheck(ref, bin, settings, process.cwd(), session, model, effort, turnTimeout * 60, firstTurnLog, turnsPerHour, antigravityTurnEnv(sandbox, install.bin), unproductivePerHour);
|
|
226
229
|
}
|
|
227
230
|
}
|
|
228
231
|
else {
|
|
@@ -257,12 +260,12 @@ export async function harnessStart(p, out, harness) {
|
|
|
257
260
|
lines.push(`Started DeepSeek Harness session ${session}; its first turn (reading its role and inbox) is running, event log: ${firstTurnLog}`);
|
|
258
261
|
}
|
|
259
262
|
else if (harness === "antigravity") {
|
|
260
|
-
const started = runAntigravityTurn(bin, antigravityTurnArgs(prompt, model, effort, turnTimeout * 60, settings), firstTurnLog, process.cwd(), ref, undefined, undefined, antigravityTurnEnv(sandbox));
|
|
263
|
+
const started = runAntigravityTurn(bin, antigravityTurnArgs(prompt, model, effort, turnTimeout * 60, settings), firstTurnLog, process.cwd(), ref, undefined, undefined, antigravityTurnEnv(sandbox, install.bin));
|
|
261
264
|
session = started.conversation;
|
|
262
265
|
await completePendingTurnGuard(ref, probeFor(harness, session, ref), (message) => diagnostic.push(message), started.output, antigravityTokenTotal(started.record.result?.usage));
|
|
263
266
|
lines.push(`Started Antigravity conversation ${session}; its first turn (reading its role and inbox) completed, JSON turn log: ${firstTurnLog}`);
|
|
264
267
|
if (sandbox === "workspace-write")
|
|
265
|
-
await runAntigravitySandboxSelfCheck(ref, bin, settings, process.cwd(), session, model, effort, turnTimeout * 60, firstTurnLog, turnsPerHour, antigravityTurnEnv(sandbox), unproductivePerHour);
|
|
268
|
+
await runAntigravitySandboxSelfCheck(ref, bin, settings, process.cwd(), session, model, effort, turnTimeout * 60, firstTurnLog, turnsPerHour, antigravityTurnEnv(sandbox, install.bin), unproductivePerHour);
|
|
266
269
|
}
|
|
267
270
|
else {
|
|
268
271
|
// Claude Code takes the session id from us, so nothing has to be read back from its output.
|
|
@@ -313,7 +316,7 @@ export async function harnessStart(p, out, harness) {
|
|
|
313
316
|
mkdirSync(tmp, { recursive: true });
|
|
314
317
|
const followDelay = Number(str(p.flags, "follow-delay") ?? "300");
|
|
315
318
|
const prune = bool(p.flags, "prune");
|
|
316
|
-
watcherEnv = { TMPDIR: tmp, ...(machineSessionId ? { BSCHAT_MACHINE_SESSION_ID: machineSessionId } : {}), ...(harness === "claude-code" ? claudeSandboxEnv(sandbox) : {}), ...(harness === "antigravity" ? {
|
|
319
|
+
watcherEnv = { TMPDIR: tmp, ...(machineSessionId ? { BSCHAT_MACHINE_SESSION_ID: machineSessionId } : {}), ...(harness === "claude-code" ? claudeSandboxEnv(sandbox) : {}), ...(harness === "antigravity" ? { ...antigravityTurnEnv(sandbox, install.bin), BSCHAT_MODEL: model, ...(effort ? { BSCHAT_EFFORT: effort } : {}) } : {}) };
|
|
317
320
|
const turnSpec = { harness, session, timeout: turnTimeout, turnsPerHour, unproductivePerHour, coalesceSeconds: turnCoalesceSeconds, provider, model, ...(machineSessionId ? { machineSessionId } : {}) };
|
|
318
321
|
if (inContainer) {
|
|
319
322
|
const sess = sessionOfExec(exec);
|
|
@@ -827,7 +827,7 @@ function machineMoveReadinessError(machine, harness, provider, sandbox, liveSamp
|
|
|
827
827
|
return null;
|
|
828
828
|
}
|
|
829
829
|
/**
|
|
830
|
-
* agent move <project>/<agent> --to <machine> --sandbox <mode> [--dir path|auto] [--harness codex|claude-code] [--provider anthropic|deepseek] [--model m] [--effort e]
|
|
830
|
+
* agent move <project>/<agent> (--to <machine> --sandbox <mode> | --operation <id>) [--dir path|auto] [--harness codex|claude-code] [--provider anthropic|deepseek] [--model m] [--effort e]
|
|
831
831
|
* [--carry note|thread] [--from local|<ssh host>] [--to-ssh <host>] [--thread id] [--wait min]
|
|
832
832
|
* [--force --confirm-force <project>/<agent>]
|
|
833
833
|
*
|
|
@@ -839,19 +839,99 @@ function machineMoveReadinessError(machine, harness, provider, sandbox, liveSamp
|
|
|
839
839
|
export async function agentMove(rest, p, out) {
|
|
840
840
|
const ref = rest[0] ?? "";
|
|
841
841
|
const [project, agent] = ref.split("/");
|
|
842
|
-
const
|
|
843
|
-
const
|
|
844
|
-
const
|
|
845
|
-
const
|
|
846
|
-
const
|
|
842
|
+
const operationId = str(p.flags, "operation");
|
|
843
|
+
const requestedTo = str(p.flags, "to");
|
|
844
|
+
const requestedSandbox = str(p.flags, "sandbox");
|
|
845
|
+
const requestedHarness = str(p.flags, "harness");
|
|
846
|
+
const requestedProvider = str(p.flags, "provider");
|
|
847
|
+
const requestedCarry = str(p.flags, "carry");
|
|
848
|
+
const requestedDir = str(p.flags, "dir");
|
|
849
|
+
const requestedModel = str(p.flags, "model");
|
|
850
|
+
const requestedEffort = str(p.flags, "effort");
|
|
851
|
+
const requestedThread = str(p.flags, "thread");
|
|
847
852
|
const from = str(p.flags, "from");
|
|
848
853
|
const forceConfirmation = str(p.flags, "confirm-force");
|
|
849
|
-
if (!project || !agent || !
|
|
850
|
-
throw new CliError("usage", "agent move <project>/<agent> --to <machine> --sandbox <mode> [--dir <path>|auto] [--harness codex|claude-code] [--provider anthropic|deepseek] [--carry note|thread] [--from local|<ssh host>] [--model m] [--effort e] [--wait min] [--force --confirm-force <project>/<agent>]");
|
|
854
|
+
if (!project || !agent || (!operationId && (!requestedTo || !requestedSandbox)))
|
|
855
|
+
throw new CliError("usage", "agent move <project>/<agent> (--to <machine> --sandbox <mode> | --operation <id>) [--dir <path>|auto] [--harness codex|claude-code] [--provider anthropic|deepseek] [--carry note|thread] [--from local|<ssh host>] [--model m] [--effort e] [--wait min] [--force --confirm-force <project>/<agent>]");
|
|
851
856
|
if (forceConfirmation && !bool(p.flags, "force"))
|
|
852
857
|
throw new CliError("usage", "--confirm-force is valid only with --force");
|
|
853
858
|
if (forceConfirmation && forceConfirmation !== ref)
|
|
854
859
|
throw new CliError("confirmation_required", `--confirm-force must exactly match ${ref}`);
|
|
860
|
+
if (!from)
|
|
861
|
+
throw new CliError("usage", "--from local|<ssh host> is required so the trusted CLI can check the source before authorizing completion");
|
|
862
|
+
const c = adminClient(p);
|
|
863
|
+
const say = (l) => { if (!out.json)
|
|
864
|
+
process.stderr.write(`${l}\n`); };
|
|
865
|
+
const moveRoute = `/projects/${project}/agents/${agent}/moves`;
|
|
866
|
+
let move;
|
|
867
|
+
let to;
|
|
868
|
+
let sandbox;
|
|
869
|
+
let harness;
|
|
870
|
+
let provider;
|
|
871
|
+
let carry;
|
|
872
|
+
let dir;
|
|
873
|
+
let model = requestedModel;
|
|
874
|
+
let effort = requestedEffort;
|
|
875
|
+
let thread = requestedThread ?? null;
|
|
876
|
+
if (operationId) {
|
|
877
|
+
const loaded = await c.call("GET", `${moveRoute}/${encodeURIComponent(operationId)}`);
|
|
878
|
+
move = loaded.move;
|
|
879
|
+
if (move.status !== "requested")
|
|
880
|
+
throw new CliError("move_not_awaiting_execution", `move operation ${operationId} is ${move.status}; only a requested operation can be continued`);
|
|
881
|
+
const target = move.target;
|
|
882
|
+
const expected = [
|
|
883
|
+
["--to", requestedTo, move.to], ["--sandbox", requestedSandbox, target.sandbox], ["--harness", requestedHarness, target.harness],
|
|
884
|
+
["--provider", requestedProvider, target.provider], ["--carry", requestedCarry, move.carry], ["--dir", requestedDir, target.dir],
|
|
885
|
+
["--model", requestedModel, target.model], ["--effort", requestedEffort, target.effort], ["--thread", requestedThread, target.thread],
|
|
886
|
+
];
|
|
887
|
+
for (const [flag, supplied, stored] of expected) {
|
|
888
|
+
if (supplied !== undefined && supplied !== (stored == null ? undefined : String(stored))) {
|
|
889
|
+
throw new CliError("move_option_mismatch", `${flag}=${supplied} does not match move operation ${operationId}${stored == null ? " (not set on the operation)" : ` (${stored})`}`);
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
if (str(p.flags, "turn-timeout") !== undefined && Number(str(p.flags, "turn-timeout")) !== target.turn_timeout) {
|
|
893
|
+
throw new CliError("move_option_mismatch", `--turn-timeout=${str(p.flags, "turn-timeout")} does not match move operation ${operationId} (${target.turn_timeout})`);
|
|
894
|
+
}
|
|
895
|
+
to = String(move.to);
|
|
896
|
+
sandbox = String(target.sandbox);
|
|
897
|
+
harness = String(target.harness ?? "codex");
|
|
898
|
+
provider = String(target.provider ?? "anthropic");
|
|
899
|
+
carry = String(move.carry ?? "note");
|
|
900
|
+
dir = String(target.dir ?? "auto");
|
|
901
|
+
model ??= typeof target.model === "string" ? target.model : undefined;
|
|
902
|
+
effort ??= typeof target.effort === "string" ? target.effort : undefined;
|
|
903
|
+
thread ??= typeof target.thread === "string" ? target.thread : null;
|
|
904
|
+
}
|
|
905
|
+
else {
|
|
906
|
+
to = requestedTo;
|
|
907
|
+
sandbox = requestedSandbox;
|
|
908
|
+
harness = requestedHarness ?? "codex";
|
|
909
|
+
provider = requestedProvider ?? "anthropic";
|
|
910
|
+
carry = requestedCarry ?? "note";
|
|
911
|
+
dir = requestedDir ?? "auto";
|
|
912
|
+
if (harness !== "codex" && harness !== "claude-code")
|
|
913
|
+
throw new CliError("usage", "agent move currently supports codex and claude-code sessions; DSH and Antigravity session behavior is unchanged");
|
|
914
|
+
if (provider !== "anthropic" && provider !== "deepseek")
|
|
915
|
+
throw new CliError("usage", "--provider must be anthropic or deepseek");
|
|
916
|
+
if (provider === "deepseek" && harness !== "claude-code")
|
|
917
|
+
throw new CliError("usage", "--provider deepseek requires --harness claude-code");
|
|
918
|
+
if (carry !== "note" && carry !== "thread")
|
|
919
|
+
throw new CliError("usage", "--carry note (a resume note it writes now) or thread (its Codex thread, copied)");
|
|
920
|
+
if (carry !== "thread" && thread)
|
|
921
|
+
throw new CliError("usage", "--thread is valid only with --carry thread");
|
|
922
|
+
if (carry === "thread" && harness !== "codex")
|
|
923
|
+
throw new CliError("usage", "--carry thread copies a Codex thread; a Claude Code agent moves with --carry note (its resume note), and its new machine starts a fresh session");
|
|
924
|
+
if (carry === "thread" && !from)
|
|
925
|
+
throw new CliError("usage", "--carry thread needs --from local|<ssh host>: the machine whose ~/.codex holds its thread");
|
|
926
|
+
const requested = await c.call("POST", moveRoute, {
|
|
927
|
+
to, carry, harness, provider, dir, sandbox,
|
|
928
|
+
...(model ? { model } : {}),
|
|
929
|
+
...(effort ? { effort } : {}),
|
|
930
|
+
...(thread ? { thread } : {}),
|
|
931
|
+
...(str(p.flags, "turn-timeout") ? { turn_timeout: Number(str(p.flags, "turn-timeout")) } : {}),
|
|
932
|
+
});
|
|
933
|
+
move = requested.move;
|
|
934
|
+
}
|
|
855
935
|
if (harness !== "codex" && harness !== "claude-code")
|
|
856
936
|
throw new CliError("usage", "agent move currently supports codex and claude-code sessions; DSH and Antigravity session behavior is unchanged");
|
|
857
937
|
if (provider !== "anthropic" && provider !== "deepseek")
|
|
@@ -860,33 +940,16 @@ export async function agentMove(rest, p, out) {
|
|
|
860
940
|
throw new CliError("usage", "--provider deepseek requires --harness claude-code");
|
|
861
941
|
if (carry !== "note" && carry !== "thread")
|
|
862
942
|
throw new CliError("usage", "--carry note (a resume note it writes now) or thread (its Codex thread, copied)");
|
|
863
|
-
if (carry !== "thread" &&
|
|
943
|
+
if (carry !== "thread" && thread)
|
|
864
944
|
throw new CliError("usage", "--thread is valid only with --carry thread");
|
|
865
|
-
if (carry === "thread" &&
|
|
945
|
+
if (carry === "thread" && harness !== "codex")
|
|
866
946
|
throw new CliError("usage", "--carry thread copies a Codex thread; a Claude Code agent moves with --carry note (its resume note), and its new machine starts a fresh session");
|
|
867
947
|
if (carry === "thread" && !from)
|
|
868
948
|
throw new CliError("usage", "--carry thread needs --from local|<ssh host>: the machine whose ~/.codex holds its thread");
|
|
869
|
-
if (!from)
|
|
870
|
-
throw new CliError("usage", "--from local|<ssh host> is required so the trusted CLI can check the source before authorizing completion");
|
|
871
|
-
const c = adminClient(p);
|
|
872
|
-
const say = (l) => { if (!out.json)
|
|
873
|
-
process.stderr.write(`${l}\n`); };
|
|
874
|
-
const moveRoute = `/projects/${project}/agents/${agent}/moves`;
|
|
875
|
-
const requested = await c.call("POST", moveRoute, {
|
|
876
|
-
to, carry, harness, provider, dir: str(p.flags, "dir") ?? "auto", sandbox,
|
|
877
|
-
...(str(p.flags, "model") ? { model: str(p.flags, "model") } : {}),
|
|
878
|
-
...(str(p.flags, "effort") ? { effort: str(p.flags, "effort") } : {}),
|
|
879
|
-
...(str(p.flags, "thread") ? { thread: str(p.flags, "thread") } : {}),
|
|
880
|
-
...(str(p.flags, "turn-timeout") ? { turn_timeout: Number(str(p.flags, "turn-timeout")) } : {}),
|
|
881
|
-
});
|
|
882
|
-
const move = requested.move;
|
|
883
949
|
const progressRoute = `${moveRoute}/${move.id}`;
|
|
884
950
|
if (!out.json)
|
|
885
951
|
say(` move ${move.id}: ${move.from ?? "source"} → ${to}; other agent keys will be revoked only after completion`);
|
|
886
|
-
await c.call("PATCH", progressRoute, { status: "checking", detail: "trusted CLI is checking local readiness and preparing the handoff" });
|
|
887
|
-
let thread = str(p.flags, "thread") ?? null;
|
|
888
|
-
let model = str(p.flags, "model");
|
|
889
|
-
let effort = str(p.flags, "effort");
|
|
952
|
+
await c.call("PATCH", progressRoute, { status: "checking", expected_status: "requested", detail: "trusted CLI is checking local readiness and preparing the handoff" });
|
|
890
953
|
let problems = [];
|
|
891
954
|
const destinationHost = str(p.flags, "to-ssh") ?? to;
|
|
892
955
|
try {
|
|
@@ -1012,7 +1075,8 @@ export async function agentMove(rest, p, out) {
|
|
|
1012
1075
|
? "source-only work was not explicitly confirmed"
|
|
1013
1076
|
: "local source check or context handoff failed";
|
|
1014
1077
|
try {
|
|
1015
|
-
|
|
1078
|
+
const refusalReason = error instanceof CliError ? `${error.code}: ${recordedDetail}` : recordedDetail;
|
|
1079
|
+
await c.call("PATCH", progressRoute, { status: "blocked", detail: recordedDetail, refusal_reason: refusalReason.slice(0, 1000) });
|
|
1016
1080
|
}
|
|
1017
1081
|
catch (recordError) {
|
|
1018
1082
|
throw new CliError("move_progress_failed", `${detail}\nCould not record the blocked move operation: ${recordError instanceof Error ? recordError.message : String(recordError)}`);
|
|
@@ -1028,7 +1092,23 @@ export async function agentMove(rest, p, out) {
|
|
|
1028
1092
|
...(carry === "thread" && thread ? { thread } : {}),
|
|
1029
1093
|
...(model ? { model } : {}), ...(effort ? { effort } : {}),
|
|
1030
1094
|
});
|
|
1031
|
-
|
|
1095
|
+
let r;
|
|
1096
|
+
try {
|
|
1097
|
+
r = await c.call("POST", `${progressRoute}/complete`, { carried_context_kind: carry });
|
|
1098
|
+
}
|
|
1099
|
+
catch (error) {
|
|
1100
|
+
const refusalReason = error instanceof CliError ? `${error.code}: server move completion failed` : "server move completion failed";
|
|
1101
|
+
try {
|
|
1102
|
+
const current = await c.call("GET", progressRoute);
|
|
1103
|
+
if (!current.move.completion_summary) {
|
|
1104
|
+
await c.call("PATCH", progressRoute, {
|
|
1105
|
+
status: "failed", detail: "server move completion failed", refusal_reason: refusalReason.slice(0, 1000),
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
catch { /* preserve the completion error; the server may already have recorded its failure summary */ }
|
|
1110
|
+
throw error;
|
|
1111
|
+
}
|
|
1032
1112
|
return out.print([
|
|
1033
1113
|
`Move ${move.id} completed: ${ref} now runs on ${to} (${r.session.harness}/${r.session.provider}, ${r.session.sandbox}, ${r.session.dir || "automatic checkout"}${thread ? `, thread ${thread}` : ", a fresh session"}); its daemon starts it within 30 s.`,
|
|
1034
1114
|
r.moved_from.length ? `Its session on ${r.moved_from.join(", ")} was removed.` : null,
|
package/dist/commands/machine.js
CHANGED
|
@@ -12,14 +12,14 @@ import { applySparse } from "../git.js";
|
|
|
12
12
|
import { drainingUntil, writeMaintenance } from "../maintenance.js";
|
|
13
13
|
import { TURN_HARNESSES, claudeFacts, claudeSandbox, dshFacts, dshProcesses, probeFor, sessionProcesses } from "../harnesses.js";
|
|
14
14
|
import { readState, writeState } from "../state.js";
|
|
15
|
-
import { installService, lingerEnabled, MACHINE_LABEL, machineDaemonPath, removeService, requireInstall, restartWatcher, serviceActive, WATCH_LABEL_PREFIX, watcherServices } from "../install.js";
|
|
15
|
+
import { installService, lingerEnabled, MACHINE_LABEL, machineDaemonPath, readInstall, removeService, requireInstall, restartWatcher, serviceActive, WATCH_LABEL_PREFIX, watcherServices } from "../install.js";
|
|
16
16
|
import { CLI_VERSION } from "../version.js";
|
|
17
17
|
import { probeCapabilities } from "../capabilities.js";
|
|
18
18
|
import { diskSpaceNotice } from "../notices.js";
|
|
19
19
|
import { verifyClaudeProvider } from "../providers.js";
|
|
20
20
|
import { busyTurnPause, DEFAULT_TURNS_PER_HOUR, DEFAULT_UNPRODUCTIVE_PER_HOUR, resumeTurnGuard } from "../turn-guard.js";
|
|
21
21
|
import { defaultWorkspaceWritableRoots } from "../start-options.js";
|
|
22
|
-
import { antigravityTurnArgs, parseAntigravityJson } from "../antigravity.js";
|
|
22
|
+
import { antigravityPath, antigravitySandboxPermissions, antigravityTurnArgs, parseAntigravityJson } from "../antigravity.js";
|
|
23
23
|
import { bootTimeMs } from "../boot-time.js";
|
|
24
24
|
import { DEFAULT_CACHE_FLOOR_PCT, manageBuildCaches } from "../build-caches.js";
|
|
25
25
|
import { agentContainerName, agentContainerRunArgs, isolatedBuildCommand, isolatedDevcontainerBuildCommand, isolatedImagePullCommands, isolatedSubprocessEnv, probeImdsIsolation, probeNestedSandbox, readGitIdentity, resolveSessionSecretDelivery, validateDevcontainerSpec, } from "../container.js";
|
|
@@ -1234,18 +1234,24 @@ const AGY_SANDBOX_PROBE_MODEL = "gemini-4-hydrogen-low";
|
|
|
1234
1234
|
const AGY_SANDBOX_PROBE_RESPONSE = "B9S_SANDBOX_OK";
|
|
1235
1235
|
let agySandboxCache = null;
|
|
1236
1236
|
/** Runs one cached no-op turn through Antigravity's real workspace-write terminal sandbox. */
|
|
1237
|
-
export function antigravitySandbox(force = false, path = process.env.PATH ?? "") {
|
|
1238
|
-
if (!force && agySandboxCache && agySandboxCache.path === path && Date.now() - agySandboxCache.at < AGY_SANDBOX_PROBE_MS)
|
|
1237
|
+
export function antigravitySandbox(force = false, path = process.env.PATH ?? "", b9sBin = readInstall()?.bin ?? null) {
|
|
1238
|
+
if (!force && agySandboxCache && agySandboxCache.path === path && agySandboxCache.b9sBin === b9sBin && Date.now() - agySandboxCache.at < AGY_SANDBOX_PROBE_MS)
|
|
1239
1239
|
return agySandboxCache.result;
|
|
1240
|
-
|
|
1240
|
+
if (!b9sBin) {
|
|
1241
|
+
const result = { ok: false, error: `recorded b9s install is unavailable; expected ${join(configRoot(), "install.json")}` };
|
|
1242
|
+
agySandboxCache = { at: Date.now(), result, path, b9sBin };
|
|
1243
|
+
return result;
|
|
1244
|
+
}
|
|
1241
1245
|
let result;
|
|
1246
|
+
let work = null;
|
|
1242
1247
|
try {
|
|
1248
|
+
work = mkdtempSync(join(tmpdir(), "b9s-agy-sandbox-probe-"));
|
|
1243
1249
|
const marker = join(work, ".b9s-sandbox-probe");
|
|
1244
1250
|
const quotedMarker = `'${marker.replace(/'/g, `'\\''`)}'`;
|
|
1245
|
-
const prompt = `Use your terminal tool once to run exactly: printf '${AGY_SANDBOX_PROBE_RESPONSE}' > ${quotedMarker}. Then reply with exactly ${AGY_SANDBOX_PROBE_RESPONSE}. Do not call any other tool.`;
|
|
1246
|
-
const settings = ["--sandbox", "--settings", JSON.stringify({ enableTerminalSandbox: true, toolPermission: "proceed-in-sandbox", permissions: { allow:
|
|
1251
|
+
const prompt = `Use your terminal tool once to run exactly: b9s --version && printf '${AGY_SANDBOX_PROBE_RESPONSE}' > ${quotedMarker}. Then reply with exactly ${AGY_SANDBOX_PROBE_RESPONSE}. Do not call any other tool.`;
|
|
1252
|
+
const settings = ["--sandbox", "--settings", JSON.stringify({ enableTerminalSandbox: true, toolPermission: "proceed-in-sandbox", permissions: { allow: antigravitySandboxPermissions("api.benignswarm.org", configRoot(), b9sBin) } })];
|
|
1247
1253
|
const r = spawnSync("agy", antigravityTurnArgs(prompt, AGY_SANDBOX_PROBE_MODEL, undefined, 45, settings), {
|
|
1248
|
-
encoding: "utf8", timeout: 60_000, maxBuffer: 1024 * 1024, cwd: work, env: { ...process.env, PATH: path },
|
|
1254
|
+
encoding: "utf8", timeout: 60_000, maxBuffer: 1024 * 1024, cwd: work, env: { ...process.env, PATH: antigravityPath(b9sBin, path) },
|
|
1249
1255
|
});
|
|
1250
1256
|
const parsed = parseAntigravityJson(r.stdout ?? "");
|
|
1251
1257
|
let wroteMarker = false;
|
|
@@ -1255,12 +1261,17 @@ export function antigravitySandbox(force = false, path = process.env.PATH ?? "")
|
|
|
1255
1261
|
catch { /* a missing marker means the sandbox command did not run */ }
|
|
1256
1262
|
result = r.status === 0 && parsed?.status === "SUCCESS" && parsed.response?.trim() === AGY_SANDBOX_PROBE_RESPONSE && wroteMarker
|
|
1257
1263
|
? { ok: true, error: null }
|
|
1258
|
-
: { ok: false, error:
|
|
1264
|
+
: { ok: false, error: `sandbox could not run b9s --version and its no-op check (agy exit ${r.status ?? "unknown"}); verify recorded install ${b9sBin} and Node runtime ${process.execPath} are readable and executable inside the sandbox` };
|
|
1265
|
+
}
|
|
1266
|
+
catch (error) {
|
|
1267
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
1268
|
+
result = { ok: false, error: `sandbox could not prepare b9s --version probe for recorded install ${b9sBin} with Node runtime ${process.execPath}: ${detail}` };
|
|
1259
1269
|
}
|
|
1260
1270
|
finally {
|
|
1261
|
-
|
|
1271
|
+
if (work)
|
|
1272
|
+
rmSync(work, { recursive: true, force: true });
|
|
1262
1273
|
}
|
|
1263
|
-
agySandboxCache = { at: Date.now(), result, path };
|
|
1274
|
+
agySandboxCache = { at: Date.now(), result, path, b9sBin };
|
|
1264
1275
|
return result;
|
|
1265
1276
|
}
|
|
1266
1277
|
function antigravityLoginFacts(path) {
|
|
@@ -1277,11 +1288,11 @@ function antigravityLoginFacts(path) {
|
|
|
1277
1288
|
};
|
|
1278
1289
|
}
|
|
1279
1290
|
/** Machine facts used by placement; the daemon probes login cheaply and caches the sandbox turn. */
|
|
1280
|
-
export function antigravityFacts(path = process.env.PATH ?? "") {
|
|
1291
|
+
export function antigravityFacts(path = process.env.PATH ?? "", b9sBin = readInstall()?.bin ?? null) {
|
|
1281
1292
|
const facts = antigravityLoginFacts(path);
|
|
1282
1293
|
return {
|
|
1283
1294
|
...facts,
|
|
1284
|
-
sandbox: facts.logged_in ? antigravitySandbox(false, path) : null,
|
|
1295
|
+
sandbox: facts.logged_in ? antigravitySandbox(false, path, b9sBin) : null,
|
|
1285
1296
|
};
|
|
1286
1297
|
}
|
|
1287
1298
|
/** Memory a new process could use: Linux's MemAvailable (free alone undercounts the page cache), else free. */
|
package/dist/help.js
CHANGED
|
@@ -23,6 +23,7 @@ Session/admin clients can use GET /assistant/conversations, GET /assistant/conve
|
|
|
23
23
|
Free and paid accounts without a live Stripe subscription use the UTC calendar month; subscribed paid accounts reset at current_period_end.
|
|
24
24
|
|
|
25
25
|
Mac capacity/signing API (profiles, leases, signer-only references, TestFlight approvals, and the isolated signer job contract) is documented in docs/MACOS-MACHINES-API.md. There is no CLI command to issue signer-host credentials or trigger release; operator controls are WU #286, real host/provider integration is WU #288.
|
|
26
|
+
Standing rules are resolved by account, project, role, and exact-agent scope. GET /agents/me/standing-rules and GET /projects/:p/standing-rules return complete authorized sets and fingerprints; their separate ack endpoints accept only a current fingerprint after complete delivery. Operators and authorized assigners manage rules through the API; limits, compatibility confirmation, audit, and authorization are in packages/skill/references/api.md. Console management and chat promotion are planned in implementation unit 3 of docs/STANDING-RULES.md.
|
|
26
27
|
|
|
27
28
|
GitHub connection and repository status are available in the console and through b9s-admin github status and b9s-admin project github <project> status|unlink. A repository link enables agent credentials without requiring a ruleset. An agent can inspect its effective repository permission with GET /projects/:p/git-credentials; a project admin can inspect a named agent with GET /projects/:p/git-credentials?agent=<name-or-id>. Each issuance records its permission reason without storing the token. Verify an exact target ruleset in Account -> GitHub connection before enabling hosted merge; the CLI cannot perform this owner OAuth step. Disconnect an installation with b9s-admin github disconnect <installation-id>. Hosted merge execution and status use b9s wu merge <n> and b9s wu merge status <n>; they call POST/GET /projects/:p/work-units/:n/merge and never inspect local Git state. API role checks use merge.merged_by and operator override; operator_hold is checked, merges serialize in MergeTargetDO, and retries reconcile idempotently. Manual wu done remains disabled for enabled linked targets. Enable with b9s-admin project hosted-merge <project> enable --confirm-bypass-signal only after ruleset verification and the live GitHub bypass-change check; disable with b9s-admin project hosted-merge <project> disable. The console control is WU #196. App setup steps are in packages/skill-admin/references/setup.md.
|
|
28
29
|
|
|
@@ -37,9 +38,9 @@ Agent commands
|
|
|
37
38
|
b9s login --as <name> --key <bs_agent_...> [--url <api>] [--label <machine-label>]
|
|
38
39
|
b9s logout --as <name>
|
|
39
40
|
b9s identities list saved identities on this machine
|
|
40
|
-
b9s me who am I, role, permissions, channels; --json includes your machine sessions
|
|
41
|
+
b9s me who am I, role, permissions, channels, standing rules and acknowledgment; --json includes your machine sessions
|
|
41
42
|
b9s git-credential get|store|erase Git credential helper for the project's linked GitHub repository
|
|
42
|
-
b9s resume compact recovery brief: units, reviews, asks, slices, decisions, outcomes, process and notices
|
|
43
|
+
b9s resume compact recovery brief: units, reviews, asks, slices, decisions, outcomes, process, standing rules and notices
|
|
43
44
|
b9s notice add --project <p> "<text>" [--until <time>] [--command-pattern <regex>]
|
|
44
45
|
assigner only: add a project notice; matching commands warn but continue
|
|
45
46
|
b9s who [--account] agent status (--account: all projects); shows pressure for active machine sessions
|
|
@@ -56,7 +57,7 @@ Agent commands
|
|
|
56
57
|
b9s inbox handle <project>/<channel>/<seq> mark an addressed question handled outside its thread
|
|
57
58
|
b9s follow <channel> | unfollow <channel> | following followed channels' new messages are injected by the hook;
|
|
58
59
|
other channels appear as a one-line unread digest
|
|
59
|
-
b9s process the project's process: tag vocabulary, reviewers, wake-path warnings, scope templates,
|
|
60
|
+
b9s process the project's process: tag vocabulary, reviewers, wake-path warnings, scope templates, agreements and active standing rules
|
|
60
61
|
b9s wu open "<title>" --scope "..." [--scope-file <path> | --scope-from <n>] [--tags a,b] [--lands-with <n>] [--after <n>[,<m>]] [--requires cap,cap] [--force] [--evidence id[,id...]] [--target <branch>] [--here] open a work unit in its own
|
|
61
62
|
worktree; tags come from the vocabulary; --target is the branch it lands in (default: the
|
|
62
63
|
process target), e.g. a lane branch; wu target <n> <branch|default> changes it before review
|
|
@@ -386,10 +387,11 @@ Machines (provisioned over your own ssh; a daemon on each runs the agent session
|
|
|
386
387
|
b9s-admin machine session thread <machine> <project>/<agent> <thread-id|none> set or clear the thread a pool session adopts
|
|
387
388
|
b9s-admin machine session stop|start|resume|limit|coalesce|remove <machine> <project>/<agent> set its busy, unproductive, or coalescing limit
|
|
388
389
|
(change its count/settings, pause scaling, pin, or bench the agent)
|
|
389
|
-
b9s-admin agent move <project>/<agent> --to <machine> --sandbox <mode> --from local|<ssh host> [--dir <path>|auto]
|
|
390
|
+
b9s-admin agent move <project>/<agent> (--to <machine> --sandbox <mode> | --operation <id>) --from local|<ssh host> [--dir <path>|auto]
|
|
390
391
|
[--harness codex|claude-code] [--provider anthropic|deepseek] [--carry note|thread]
|
|
391
392
|
[--model m] [--effort e] [--wait min] [--force --confirm-force <project>/<agent>]
|
|
392
|
-
|
|
393
|
+
creates a move or continues the requested operation from the console; stored options are loaded and explicit options must match
|
|
394
|
+
checks source worktrees, transfers thread/note plus local agent state over SSH,
|
|
393
395
|
refuses newer destination state and avoids duplicate Codex hooks under managed policy,
|
|
394
396
|
then commits the session only after handoff succeeds; work left on the source requires both flags
|
|
395
397
|
b9s-admin machine label <name> <label...> [--remove a,b] what cannot be measured (lab-lan, builds); pools' --needs match it
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CLI_VERSION = "0.12.
|
|
1
|
+
export const CLI_VERSION = "0.12.102";
|