c8ctl-plugin-nano 1.67.0 → 1.68.0
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/README.md +10 -1
- package/c8ctl-plugin.js +100 -9
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -748,6 +748,15 @@ the job with a decremented retry count. Profiles are stored in the plugin's
|
|
|
748
748
|
> `agentCapabilities._meta.planSeed` also receives it in `session/new` `_meta.plan`
|
|
749
749
|
> so it can keep working the same plan. `NANO_AGENT_PLAN=off` disables both.
|
|
750
750
|
|
|
751
|
+
> **Agent outcomes.** A harness may report an explicit end-of-task outcome in its
|
|
752
|
+
> `session/prompt` result as `_meta.outcome` — `{ "status": "completed" | "blocked",
|
|
753
|
+
> "summary": "…" }` (rusty-harness's `report_outcome` tool). It is recorded in
|
|
754
|
+
> `io.nanobpm.agentResult.outcome`. If the agent returned no result of its own, a
|
|
755
|
+
> `blocked` outcome becomes the result `{ "status": "blocked", "summary", "question" }`,
|
|
756
|
+
> so the job escalates instead of taking a re-emit nudge turn. A result written to
|
|
757
|
+
> `$AGENT_RESULT_FILE` (or the `::nano:result::` sentinel) always wins, and agents
|
|
758
|
+
> that send no outcome are handled exactly as before.
|
|
759
|
+
|
|
751
760
|
### Task envelope, sandboxes & disk hygiene
|
|
752
761
|
|
|
753
762
|
For **agentic** jobs (an agent that clones a repo, works a task, pushes a
|
|
@@ -814,7 +823,7 @@ logged and echoed on the output envelope as `promptResourceKey` for audit (the e
|
|
|
814
823
|
only `latest`, so the key is the reproducibility handle).
|
|
815
824
|
|
|
816
825
|
On completion the plugin writes an **output envelope** back under
|
|
817
|
-
`io.nanobpm.agentResult` (`{schemaVersion, status, sandbox, image, output, truncated, stderrTruncated, exitCode, signal, error, promptResourceKey?}`). When a repository was
|
|
826
|
+
`io.nanobpm.agentResult` (`{schemaVersion, status, sandbox, image, output, truncated, stderrTruncated, exitCode, signal, error, outcome?, promptResourceKey?}`). When a repository was
|
|
818
827
|
provisioned (below) it also carries `{repository, branch, baseSha, headSha, commits[], pushed, pushError?, pushFailed?, strandedCommits?, branchMismatch?, scanError?, gitError?, pr?}`. `pushFailed` is the explicit "push failed" flag — set for a non-zero `git push` **whose result could not be confirmed as landed at the remote** (a non-fast-forward rejection, or an auth, hook, or network error), not only a server rejection. **`pushFailed` does not by itself prove a remote push was attempted or rejected:** `finalizeGit` also sets it (with `strandedCommits` and a `branchMismatch` `{expected, actual}`) when it *refuses to push at all* because the harness moved HEAD off the provisioned work branch — or left commits abandoned on another local branch — so pushing the work branch would publish stale work and strand those commits (no `git push` runs, so `pushError` is absent in that case). As a guard against false strands, a non-zero push is re-checked with `ls-remote`: if `origin/<branch>` already points at `headSha` — or the remote tip is a **descendant** of `headSha` (another actor pushed a further commit after ours landed) — the push is treated as a transport hiccup that landed after the ref was accepted (`pushed: true`, no `pushFailed`/`pushError`); otherwise `pushFailed` is set and `strandedCommits` lists the SHAs of the new commits left UNPUSHED in the throwaway workspace — together they are the recovery handle for a failed push, so consumers must not treat `pushed: false` alone as the only signal. On such a failure (a rejected push **or** a branch-mismatch refusal) the throwaway workspace is preserved **best-effort** (even under the default `--keep-runs=false`) so those SHAs stay recoverable, but this is a *recovery window, not a durable archive*: the run-directory reaper still ages it out by mtime and worker shutdown removes the namespace — copy the stranded commits out promptly (or run with `--keep-runs`). **`scanError`** flags a **best-effort/PARTIAL** `strandedCommits` list: a commit or remote-reachability scan did **not** complete, so a consumer should recover the whole preserved workspace rather than trust the list exactly. It arises two ways: (a) a **pre-push** commit-enumeration scan failed, so `finalizeGit` refused to push on an incomplete graph — **no push was attempted** (`pushError` is absent) and `strandedCommits` is a partial surfacing; or (b) a push was **ATTEMPTED and rejected** but the remote-reachability FILTER that trims already-published commits from the strand set itself failed — so `scanError` is present **alongside** `pushError`, marking the rejected-push strand list as best-effort (it may falsely include an already-landed commit). Either way `pushFailed` stays authoritative; `scanError` is how a consumer knows the strand list is inexact (recover the whole workspace) versus an exact list (a rejected push with no `scanError`).
|
|
819
828
|
|
|
820
829
|
**Git provisioning (host).** When `--sandbox none` (the default) and the envelope
|
package/c8ctl-plugin.js
CHANGED
|
@@ -2739,6 +2739,45 @@ function sanitizeResultVars(obj) {
|
|
|
2739
2739
|
return out;
|
|
2740
2740
|
}
|
|
2741
2741
|
|
|
2742
|
+
// True when `obj` carries at least one EFFECTIVE result var: a key that survives
|
|
2743
|
+
// sanitizeResultVars (reserved / io.nanobpm.* / proto keys stripped) AND whose
|
|
2744
|
+
// value is not null/undefined. A key present with a null/undefined value (e.g.
|
|
2745
|
+
// `{"status":null}`) is NOT effective — it leaves downstream gateways with no
|
|
2746
|
+
// decision value — so it must neither shadow a usable ACP outcome (pickAgentResult)
|
|
2747
|
+
// nor suppress the dropped-result nudge (resolveAgentResultWithNudge). Both
|
|
2748
|
+
// predicates route through here so they stay consistent.
|
|
2749
|
+
function hasEffectiveResultVars(obj) {
|
|
2750
|
+
for (const v of Object.values(sanitizeResultVars(obj))) {
|
|
2751
|
+
if (v !== null && v !== undefined) return true;
|
|
2752
|
+
}
|
|
2753
|
+
return false;
|
|
2754
|
+
}
|
|
2755
|
+
|
|
2756
|
+
// Choose the agent's structured result from its candidate sources (result file,
|
|
2757
|
+
// stdout sentinel, ACP outcome) in priority order. Prefer the first candidate
|
|
2758
|
+
// that carries at least one EFFECTIVE var (i.e. survives sanitizeResultVars —
|
|
2759
|
+
// the reserved / io.nanobpm.* / proto keys stripped, with a non-null value) so an
|
|
2760
|
+
// empty `{}`, a reserved-keys-only, or a null-valued-only result file/sentinel
|
|
2761
|
+
// does NOT shadow a usable `blocked`
|
|
2762
|
+
// ACP outcome via raw `??` nullish precedence: `??` only falls through on
|
|
2763
|
+
// null/undefined, so a present-but-empty object would otherwise win and force
|
|
2764
|
+
// the dropped-result nudge even though the ACP outcome already escalates. Falls
|
|
2765
|
+
// back to the FIRST present-but-empty candidate when none carries effective vars
|
|
2766
|
+
// so the raw object is still surfaced to the audit envelope and the
|
|
2767
|
+
// dropped-result nudge still fires. Candidates are thunks so a later source is
|
|
2768
|
+
// only computed when an earlier one is absent/empty (preserving the previous
|
|
2769
|
+
// short-circuit evaluation and never double-reading the result file needlessly).
|
|
2770
|
+
function pickAgentResult(...thunks) {
|
|
2771
|
+
let firstPresent;
|
|
2772
|
+
for (const thunk of thunks) {
|
|
2773
|
+
const candidate = thunk();
|
|
2774
|
+
if (candidate == null) continue;
|
|
2775
|
+
if (firstPresent === undefined) firstPresent = candidate;
|
|
2776
|
+
if (hasEffectiveResultVars(candidate)) return candidate;
|
|
2777
|
+
}
|
|
2778
|
+
return firstPresent ?? null;
|
|
2779
|
+
}
|
|
2780
|
+
|
|
2742
2781
|
const SANDBOXES = ['none', 'docker', 'podman'];
|
|
2743
2782
|
// Only container-based sandboxes need an image / disk hygiene / a runtime bin.
|
|
2744
2783
|
const CONTAINER_SANDBOXES = new Set(['docker', 'podman']);
|
|
@@ -2824,11 +2863,17 @@ async function resolveAgentResultWithNudge({ result, resultFile, rerun, logger,
|
|
|
2824
2863
|
const stdout0 = result && typeof result.stdout === 'string' ? result.stdout : '';
|
|
2825
2864
|
// A parsed result only counts as usable if it still carries at least one
|
|
2826
2865
|
// *effective* var after sanitizeResultVars strips the reserved / io.nanobpm.* /
|
|
2827
|
-
// proto keys. An empty `{}
|
|
2866
|
+
// proto keys AND ignoring null/undefined values. An empty `{}`, a reserved-keys-
|
|
2867
|
+
// only, or a null-valued-only (e.g. `{"status":null}`) object leaves downstream
|
|
2828
2868
|
// gateways with no status/decision vars — exactly the dropped-result case the
|
|
2829
2869
|
// nudge exists to recover — so gate on effective vars, not raw object presence.
|
|
2830
|
-
const hasUsableResult = (parsed) =>
|
|
2831
|
-
|
|
2870
|
+
const hasUsableResult = (parsed) => hasEffectiveResultVars(parsed);
|
|
2871
|
+
// A `blocked` ACP outcome is a usable result (it escalates), so it needs no nudge.
|
|
2872
|
+
const already = pickAgentResult(
|
|
2873
|
+
() => readAgentResultFile(resultFile),
|
|
2874
|
+
() => parseResultFromStdout(stdout0),
|
|
2875
|
+
() => resultVarsFromAcpOutcome(result?.acpOutcome),
|
|
2876
|
+
);
|
|
2832
2877
|
// Only nudge a clean run that produced NO usable result but DID produce output
|
|
2833
2878
|
// (silence means a crash/hang the idle path already handles, not a dropped result).
|
|
2834
2879
|
// A null `resultFile` (temp-dir creation failed) is NOT a reason to skip: the
|
|
@@ -2840,7 +2885,7 @@ async function resolveAgentResultWithNudge({ result, resultFile, rerun, logger,
|
|
|
2840
2885
|
// `truncated` flag consistent with it — echo the incoming `result.truncated`
|
|
2841
2886
|
// rather than hardcoding false, so callers that trust the return value don't
|
|
2842
2887
|
// see an already-truncated stdout reported as untruncated.
|
|
2843
|
-
return { stdout: stdout0, nudged: false, truncated: result?.truncated === true };
|
|
2888
|
+
return { stdout: stdout0, nudged: false, truncated: result?.truncated === true, acpOutcome: result?.acpOutcome ?? null };
|
|
2844
2889
|
}
|
|
2845
2890
|
let nudge = null;
|
|
2846
2891
|
let nudgeError = null;
|
|
@@ -2869,7 +2914,13 @@ async function resolveAgentResultWithNudge({ result, resultFile, rerun, logger,
|
|
|
2869
2914
|
? `${logPrefix} no result on the first turn — recovered it via one re-emit nudge`
|
|
2870
2915
|
: `${logPrefix} no result on the first turn — re-emit nudge did not recover one`);
|
|
2871
2916
|
}
|
|
2872
|
-
|
|
2917
|
+
// Propagate the rerun turn's OWN validated ACP outcome back to the caller (#263):
|
|
2918
|
+
// the nudge is a continuation, so a fresh `_meta.outcome` it reports (e.g. a
|
|
2919
|
+
// `blocked` that wrote no file/sentinel) is the latest state and must reach
|
|
2920
|
+
// `workAgent` — otherwise the escalation and the recorded envelope outcome would
|
|
2921
|
+
// silently reflect only the first turn's outcome. Fall back to the first result's
|
|
2922
|
+
// outcome when the nudge reported none.
|
|
2923
|
+
return { stdout, nudged: true, truncated, acpOutcome: nudge?.acpOutcome ?? result?.acpOutcome ?? null };
|
|
2873
2924
|
}
|
|
2874
2925
|
|
|
2875
2926
|
function coerceBool(v, dflt = false) {
|
|
@@ -6799,6 +6850,30 @@ export function acpSessionNewParams({ cwd, init, resumePlan }) {
|
|
|
6799
6850
|
return params;
|
|
6800
6851
|
}
|
|
6801
6852
|
|
|
6853
|
+
// The agent's explicit end-of-task report, when its `session/prompt` result carries
|
|
6854
|
+
// `_meta.outcome` (rusty-harness's `report_outcome` tool): `{ status: 'completed' |
|
|
6855
|
+
// 'blocked', summary }`. Anything else — no `_meta`, another agent, a malformed
|
|
6856
|
+
// value — is `null`, so agents that don't send it are handled exactly as before.
|
|
6857
|
+
const ACP_OUTCOME_STATUSES = new Set(['completed', 'blocked']);
|
|
6858
|
+
const ACP_OUTCOME_SUMMARY_MAX_CHARS = 8_000;
|
|
6859
|
+
export function acpOutcomeFrom(promptResult) {
|
|
6860
|
+
const o = promptResult?._meta?.outcome;
|
|
6861
|
+
if (!isPlainObject(o) || !ACP_OUTCOME_STATUSES.has(o.status)) return null;
|
|
6862
|
+
const summary = typeof o.summary === 'string' ? o.summary.trim().slice(0, ACP_OUTCOME_SUMMARY_MAX_CHARS) : '';
|
|
6863
|
+
if (!summary) return null;
|
|
6864
|
+
return { status: o.status, summary };
|
|
6865
|
+
}
|
|
6866
|
+
|
|
6867
|
+
// Result vars implied by an ACP outcome, used ONLY when the agent wrote no result
|
|
6868
|
+
// file / sentinel of its own. `blocked` maps to the workforce escalation contract
|
|
6869
|
+
// (`status: "blocked"` with a non-blank `question`), so the job escalates instead of
|
|
6870
|
+
// spending a re-emit nudge turn. `completed` implies no vars: job-specific status
|
|
6871
|
+
// values can't be guessed, so the normal result / nudge path still applies.
|
|
6872
|
+
export function resultVarsFromAcpOutcome(outcome) {
|
|
6873
|
+
if (outcome?.status !== 'blocked') return null;
|
|
6874
|
+
return { status: 'blocked', summary: outcome.summary, question: outcome.summary };
|
|
6875
|
+
}
|
|
6876
|
+
|
|
6802
6877
|
function spawnCaptureAcp({ command, args = [], cwd, env, stdinData, timeoutMs, idleTimeoutMs, recoveryWindowMs, relayTap = null, stream = false, streamPrefix = '', onStreamOut, onStreamErr, permission = 'yolo', shell = false, onAcpUpdate = null, abortSignal = null, onSpawn = null, resumePlan = null }) {
|
|
6803
6878
|
return new Promise((resolve) => {
|
|
6804
6879
|
const logger = getLogger();
|
|
@@ -6819,6 +6894,7 @@ function spawnCaptureAcp({ command, args = [], cwd, env, stdinData, timeoutMs, i
|
|
|
6819
6894
|
const pending = new Map();
|
|
6820
6895
|
let childClosed = null; // { code, signal } once the child exits
|
|
6821
6896
|
let promptResolved = false; // the main session/prompt turn sent + resolved
|
|
6897
|
+
let acpOutcome = null; // the turn's `_meta.outcome`, if the agent reported one
|
|
6822
6898
|
let settleTimer = null; // post-turn grace before force-reaping a lingering agent
|
|
6823
6899
|
// One-time warning latch for the reserved escalate/filter policies so the
|
|
6824
6900
|
// deferral is observable (not silent) but never spams a warning per request.
|
|
@@ -6913,7 +6989,7 @@ function spawnCaptureAcp({ command, args = [], cwd, env, stdinData, timeoutMs, i
|
|
|
6913
6989
|
if (teeSink) { tee('', true); teeErr('', true); }
|
|
6914
6990
|
// Reap the child if it is still alive (turn resolved but agent lingering).
|
|
6915
6991
|
try { if (child && childClosed === null) killTree(child); } catch { /* best effort */ }
|
|
6916
|
-
resolve(result);
|
|
6992
|
+
resolve(acpOutcome ? { ...result, acpOutcome } : result);
|
|
6917
6993
|
};
|
|
6918
6994
|
|
|
6919
6995
|
// --- JSON-RPC 2.0 plumbing (newline-delimited framing) -------------------
|
|
@@ -7368,10 +7444,11 @@ function spawnCaptureAcp({ command, args = [], cwd, env, stdinData, timeoutMs, i
|
|
|
7368
7444
|
attachSteerIfAny();
|
|
7369
7445
|
// Deliver the task envelope as the prompt (from stdinData, matching the
|
|
7370
7446
|
// pipe/pty paths which write the same payload to stdin).
|
|
7371
|
-
await request('session/prompt', {
|
|
7447
|
+
const prompted = await request('session/prompt', {
|
|
7372
7448
|
sessionId,
|
|
7373
7449
|
prompt: [{ type: 'text', text: String(stdinData ?? '') }],
|
|
7374
7450
|
});
|
|
7451
|
+
acpOutcome = acpOutcomeFrom(prompted);
|
|
7375
7452
|
// End-of-turn: the main session/prompt request resolved. Mark it so the
|
|
7376
7453
|
// `close` handler can tell a completed turn from an early/handshake exit.
|
|
7377
7454
|
promptResolved = true;
|
|
@@ -7732,6 +7809,9 @@ function buildResultEnvelope(result, { sandbox, image, git, result: agentResult,
|
|
|
7732
7809
|
// shutdown (didn't exit on its own within the post-turn grace) — surfaced so
|
|
7733
7810
|
// consistently-hanging agents are visible rather than hidden behind a success.
|
|
7734
7811
|
if (result.forcedReap) env.forcedReap = true;
|
|
7812
|
+
// The agent's explicit ACP end-of-task report (`_meta.outcome`), host-recorded
|
|
7813
|
+
// alongside whatever result vars it returned.
|
|
7814
|
+
if (result.acpOutcome) env.outcome = result.acpOutcome;
|
|
7735
7815
|
// Audit (issue #63): record which linked-resource key supplied the base prompt.
|
|
7736
7816
|
// The engine only keeps `latest` per resourceId (no pinning), so recording the
|
|
7737
7817
|
// resolved key is the only reproducibility handle for which prompt version ran.
|
|
@@ -10457,7 +10537,7 @@ async function workAgent(req, flags, ctx) {
|
|
|
10457
10537
|
// the result is recoverable only via the stdout `::nano:result::`
|
|
10458
10538
|
// sentinel, which `resolveAgentResultWithNudge` handles directly.
|
|
10459
10539
|
if (result.ok) {
|
|
10460
|
-
const { stdout, nudged, truncated } = await resolveAgentResultWithNudge({
|
|
10540
|
+
const { stdout, nudged, truncated, acpOutcome } = await resolveAgentResultWithNudge({
|
|
10461
10541
|
result,
|
|
10462
10542
|
resultFile,
|
|
10463
10543
|
logger,
|
|
@@ -10482,6 +10562,9 @@ async function workAgent(req, flags, ctx) {
|
|
|
10482
10562
|
if (nudged) {
|
|
10483
10563
|
result.nudgedForResult = true;
|
|
10484
10564
|
if (truncated) result.truncated = true;
|
|
10565
|
+
// Adopt the nudge turn's outcome so the escalation / envelope reflect
|
|
10566
|
+
// the latest continuation, not only the first turn (#263).
|
|
10567
|
+
result.acpOutcome = acpOutcome;
|
|
10485
10568
|
}
|
|
10486
10569
|
}
|
|
10487
10570
|
|
|
@@ -10621,7 +10704,13 @@ async function workAgent(req, flags, ctx) {
|
|
|
10621
10704
|
// envelope; the sanitized (reserved-key-stripped) vars are merged into the
|
|
10622
10705
|
// job completion so the model sees `status`/`summary`/… as first-class
|
|
10623
10706
|
// outputs. Read before deleting the temp dir.
|
|
10624
|
-
|
|
10707
|
+
// Last resort: vars implied by the agent's ACP `_meta.outcome` (a `blocked`
|
|
10708
|
+
// report → an escalation) when it wrote no result of its own.
|
|
10709
|
+
const rawResult = pickAgentResult(
|
|
10710
|
+
() => readAgentResultFile(resultFile),
|
|
10711
|
+
() => parseResultFromStdout(result.stdout),
|
|
10712
|
+
() => resultVarsFromAcpOutcome(result.acpOutcome),
|
|
10713
|
+
);
|
|
10625
10714
|
if (resultDir) { try { rmSync(resultDir, { recursive: true, force: true }); } catch { /* best effort */ } liveRunDirs.delete(resultDir); }
|
|
10626
10715
|
const resultVars = sanitizeResultVars(rawResult);
|
|
10627
10716
|
|
|
@@ -16718,6 +16807,8 @@ export {
|
|
|
16718
16807
|
readAgentResultFile,
|
|
16719
16808
|
parseResultFromStdout,
|
|
16720
16809
|
sanitizeResultVars,
|
|
16810
|
+
hasEffectiveResultVars,
|
|
16811
|
+
pickAgentResult,
|
|
16721
16812
|
buildResultNudgePrompt,
|
|
16722
16813
|
resolveAgentResultWithNudge,
|
|
16723
16814
|
parseEnvPairs,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "c8ctl-plugin-nano",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.68.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "c8ctl plugin to start, inspect, and stop a local Nano BPM (nanobpmn) cluster",
|
|
6
6
|
"main": "c8ctl-plugin.js",
|
|
@@ -75,12 +75,12 @@
|
|
|
75
75
|
},
|
|
76
76
|
"optionalDependencies": {
|
|
77
77
|
"node-pty": "^1.0.0",
|
|
78
|
-
"@nanobpm/c8ctl-plugin-nano-darwin-arm64": "1.
|
|
79
|
-
"@nanobpm/c8ctl-plugin-nano-darwin-x64": "1.
|
|
80
|
-
"@nanobpm/c8ctl-plugin-nano-linux-x64": "1.
|
|
81
|
-
"@nanobpm/c8ctl-plugin-nano-linux-arm64": "1.
|
|
82
|
-
"@nanobpm/c8ctl-plugin-nano-linux-armv7": "1.
|
|
83
|
-
"@nanobpm/c8ctl-plugin-nano-linux-armv6": "1.
|
|
84
|
-
"@nanobpm/c8ctl-plugin-nano-win32-x64": "1.
|
|
78
|
+
"@nanobpm/c8ctl-plugin-nano-darwin-arm64": "1.68.0",
|
|
79
|
+
"@nanobpm/c8ctl-plugin-nano-darwin-x64": "1.68.0",
|
|
80
|
+
"@nanobpm/c8ctl-plugin-nano-linux-x64": "1.68.0",
|
|
81
|
+
"@nanobpm/c8ctl-plugin-nano-linux-arm64": "1.68.0",
|
|
82
|
+
"@nanobpm/c8ctl-plugin-nano-linux-armv7": "1.68.0",
|
|
83
|
+
"@nanobpm/c8ctl-plugin-nano-linux-armv6": "1.68.0",
|
|
84
|
+
"@nanobpm/c8ctl-plugin-nano-win32-x64": "1.68.0"
|
|
85
85
|
}
|
|
86
86
|
}
|