@commonlyai/cli 0.1.211 → 0.1.212
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/package.json +1 -1
- package/src/commands/agent.js +20 -10
- package/src/lib/adapters/codex.js +7 -0
- package/src/lib/supervised-turn.js +2 -1
package/package.json
CHANGED
package/src/commands/agent.js
CHANGED
|
@@ -1386,6 +1386,15 @@ const extractPrompt = (event) => {
|
|
|
1386
1386
|
// cancel grace, and the wall-clock backstop past the adapter's own timeout.
|
|
1387
1387
|
export { supervisedRunPolicy };
|
|
1388
1388
|
|
|
1389
|
+
// Codex turns are supervised by default (D211): a turn that stops making
|
|
1390
|
+
// progress is named and killed instead of holding the seat. COMMONLY_SUPERVISE_RUNS=0
|
|
1391
|
+
// opts out. Every other adapter stays off unless COMMONLY_SUPERVISE_RUNS=1.
|
|
1392
|
+
export const superviseRunsByDefault = (adapterName, env = process.env) => {
|
|
1393
|
+
if (env.COMMONLY_SUPERVISE_RUNS === '0') return false;
|
|
1394
|
+
if (adapterName === 'codex') return true;
|
|
1395
|
+
return env.COMMONLY_SUPERVISE_RUNS === '1';
|
|
1396
|
+
};
|
|
1397
|
+
|
|
1389
1398
|
/**
|
|
1390
1399
|
* Start the run loop. Polls /events, spawns the adapter per event, posts the
|
|
1391
1400
|
* result into the pod, acks.
|
|
@@ -1461,14 +1470,15 @@ export const performRun = ({
|
|
|
1461
1470
|
resolveOwnProviderKey = null,
|
|
1462
1471
|
runtimeReportClient = null,
|
|
1463
1472
|
refusalHandoff = null,
|
|
1464
|
-
//
|
|
1465
|
-
//
|
|
1466
|
-
//
|
|
1467
|
-
// line per turn goes to
|
|
1468
|
-
// delivery settles. Off, the spawn
|
|
1469
|
-
// always been, and nothing is written.
|
|
1470
|
-
superviseRuns
|
|
1473
|
+
// Each spawn runs under the seats supervisor (stall window, wall-clock
|
|
1474
|
+
// backstop, a named failure on every settle) when superviseRuns is true.
|
|
1475
|
+
// Unset, the default comes from superviseRunsByDefault. The CLI still talks
|
|
1476
|
+
// to its provider directly, and one metadata line per turn goes to
|
|
1477
|
+
// ~/.commonly/state/turns/<agent>.jsonl once delivery settles. Off, the spawn
|
|
1478
|
+
// path is the plain adapter call it has always been, and nothing is written.
|
|
1479
|
+
superviseRuns,
|
|
1471
1480
|
}) => {
|
|
1481
|
+
const supervising = superviseRuns ?? superviseRunsByDefault(adapter?.name);
|
|
1472
1482
|
reportRuntime = reportRuntime && WALKED_HARNESSES.includes(adapter?.name);
|
|
1473
1483
|
if (environment?.provider !== undefined && !adapter?.supportsProvider) {
|
|
1474
1484
|
throw new Error('environment.provider requires a provider-capable adapter');
|
|
@@ -1480,9 +1490,9 @@ export const performRun = ({
|
|
|
1480
1490
|
// The supervised run keeps its trace in memory, metadata only; no record of
|
|
1481
1491
|
// a run is written to disk (lib/supervised-turn.js).
|
|
1482
1492
|
const turnRunner = createTurnRunner({
|
|
1483
|
-
seat: agentName, turnTimeoutMs: effectiveTurnTimeoutMs, supervise:
|
|
1493
|
+
seat: agentName, turnTimeoutMs: effectiveTurnTimeoutMs, supervise: supervising, log,
|
|
1484
1494
|
});
|
|
1485
|
-
if (
|
|
1495
|
+
if (supervising) log(turnRunner.describe(adapter?.name));
|
|
1486
1496
|
const runtimeReporter = createRuntimeReporter({
|
|
1487
1497
|
client: runtimeReportClient || { post: async () => {} },
|
|
1488
1498
|
harness: adapter.name, detect: () => adapter.detect(),
|
|
@@ -1895,7 +1905,7 @@ export const performRun = ({
|
|
|
1895
1905
|
|
|
1896
1906
|
// The spawn → post-decision half of a turn, split out so the claim release
|
|
1897
1907
|
// above is a plain finally instead of threading through every return path.
|
|
1898
|
-
// With
|
|
1908
|
+
// With supervising, the turn's log line is written once delivery has
|
|
1899
1909
|
// settled; anything thrown after a spawn that resolved means the reply never
|
|
1900
1910
|
// reached the pod. Off, `turn` writes nothing.
|
|
1901
1911
|
const runTurn = async (args) => {
|
|
@@ -897,6 +897,13 @@ export default {
|
|
|
897
897
|
await writePublicCodexInstructions(childEnv.CODEX_HOME, ctx);
|
|
898
898
|
}
|
|
899
899
|
|
|
900
|
+
// The awaits above can outlast a supervisor stall window. Once it has
|
|
901
|
+
// aborted, the attempt has already settled and a retry may be running,
|
|
902
|
+
// so no process is created for this one. Checked synchronously before
|
|
903
|
+
// runCodex, so the spawn itself cannot race the abort.
|
|
904
|
+
if (ctx.signal?.aborted) {
|
|
905
|
+
throw ctx.signal.reason || new Error('codex spawn cancelled before the process started');
|
|
906
|
+
}
|
|
900
907
|
const { threadId } = await runCodex({
|
|
901
908
|
args,
|
|
902
909
|
cwd: ctx.cwd,
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* path also writes one metadata line per turn (the turn log), once the
|
|
4
4
|
* turn's outcome has reached the pod or failed to.
|
|
5
5
|
*
|
|
6
|
-
* COMMONLY_SUPERVISE_RUNS=1
|
|
6
|
+
* codex by default, or COMMONLY_SUPERVISE_RUNS=1 (superviseRunsByDefault in
|
|
7
|
+
* commands/agent.js; COMMONLY_SUPERVISE_RUNS=0 opts codex out)
|
|
7
8
|
* the turn runs under `superviseRun` from @commonlyai/seats: a stall
|
|
8
9
|
* window, a wall-clock backstop, and a guarantee the turn settles with a
|
|
9
10
|
* named failure. No provider relay: the CLI talks to its provider directly,
|