@sema-agent/core 7.5.1 → 7.6.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/CHANGELOG.md +61 -0
- package/dist/agents/cascade.d.ts +2 -2
- package/dist/agents/cascade.js +12 -10
- package/dist/agents/repair-loop.d.ts +5 -3
- package/dist/agents/repair-loop.js +13 -15
- package/dist/agents/subagent.d.ts +24 -42
- package/dist/agents/subagent.js +119 -105
- package/dist/agents/suspend-guard.d.ts +31 -19
- package/dist/agents/suspend-guard.js +14 -8
- package/dist/agents/teacher.js +9 -9
- package/dist/agents/team.d.ts +4 -3
- package/dist/agents/team.js +10 -8
- package/dist/agents/verify.d.ts +3 -3
- package/dist/agents/verify.js +17 -17
- package/dist/core/a2a.js +2 -1
- package/dist/core/ask-origin.d.ts +60 -7
- package/dist/core/ask-origin.js +26 -1
- package/dist/core/checkpoint-store.d.ts +78 -76
- package/dist/core/checkpoint-store.js +17 -1
- package/dist/core/gate-outcome.d.ts +189 -0
- package/dist/core/gate-outcome.js +70 -0
- package/dist/core/hooks.d.ts +18 -92
- package/dist/core/hooks.js +88 -85
- package/dist/core/mcp-failure.d.ts +104 -0
- package/dist/core/mcp-failure.js +128 -0
- package/dist/core/mcp.d.ts +21 -77
- package/dist/core/mcp.js +76 -150
- package/dist/core/pause-registry.d.ts +131 -0
- package/dist/core/pause-registry.js +27 -0
- package/dist/core/protocol-table.d.ts +5 -0
- package/dist/core/protocol-table.js +1 -0
- package/dist/core/runner/abort-race.d.ts +41 -0
- package/dist/core/runner/abort-race.js +38 -0
- package/dist/core/runner/assemble-result.d.ts +32 -41
- package/dist/core/runner/assemble-result.js +55 -74
- package/dist/core/runner/checkpoint-scope.d.ts +15 -3
- package/dist/core/runner/checkpoint-scope.js +3 -0
- package/dist/core/runner/compaction-call-options.d.ts +1 -1
- package/dist/core/runner/content-ask-bindings.d.ts +27 -0
- package/dist/core/runner/content-ask-bindings.js +1 -0
- package/dist/core/runner/contracts.d.ts +144 -50
- package/dist/core/runner/denial-limit-arms.d.ts +24 -1
- package/dist/core/runner/denial-limit-arms.js +24 -3
- package/dist/core/runner/gate-exit.d.ts +74 -0
- package/dist/core/runner/gate-exit.js +55 -0
- package/dist/core/runner/inherited-ask-grants.d.ts +46 -0
- package/dist/core/runner/inherited-ask-grants.js +29 -0
- package/dist/core/runner/park-commit.d.ts +102 -0
- package/dist/core/runner/park-commit.js +31 -0
- package/dist/core/runner/{prepare-permission-rules.d.ts → permission-rule-lanes.d.ts} +109 -3
- package/dist/core/runner/{prepare-permission-rules.js → permission-rule-lanes.js} +47 -1
- package/dist/core/runner/prepare-ask-lane.d.ts +107 -0
- package/dist/core/runner/prepare-ask-lane.js +131 -0
- package/dist/core/runner/prepare-boundary-parks.d.ts +102 -0
- package/dist/core/runner/prepare-boundary-parks.js +169 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +1 -1
- package/dist/core/runner/prepare-context-lane.d.ts +119 -0
- package/dist/core/runner/prepare-context-lane.js +230 -0
- package/dist/core/runner/prepare-gate-stations.d.ts +174 -0
- package/dist/core/runner/prepare-gate-stations.js +265 -0
- package/dist/core/runner/prepare-hands-readface.d.ts +4 -4
- package/dist/core/runner/prepare-inherited-gate.d.ts +4 -4
- package/dist/core/runner/prepare-inherited-gate.js +1 -1
- package/dist/core/runner/prepare-memory-engine-session.d.ts +84 -0
- package/dist/core/runner/prepare-memory-engine-session.js +233 -0
- package/dist/core/runner/prepare-memory.d.ts +44 -26
- package/dist/core/runner/prepare-park-ask.d.ts +162 -0
- package/dist/core/runner/prepare-park-ask.js +377 -0
- package/dist/core/runner/prepare-policy-chain.d.ts +208 -0
- package/dist/core/runner/prepare-policy-chain.js +584 -0
- package/dist/core/runner/prepare-project-context.d.ts +1 -13
- package/dist/core/runner/prepare-project-context.js +1 -3
- package/dist/core/runner/prepare-prompt-assembly.d.ts +95 -0
- package/dist/core/runner/prepare-prompt-assembly.js +162 -0
- package/dist/core/runner/prepare-prompt-inputs.d.ts +1 -20
- package/dist/core/runner/prepare-protocol-tools.d.ts +3 -3
- package/dist/core/runner/prepare-protocol-tools.js +0 -3
- package/dist/core/runner/prepare-question-face.d.ts +3 -21
- package/dist/core/runner/prepare-question-face.js +2 -1
- package/dist/core/runner/prepare-safety-scan.d.ts +0 -5
- package/dist/core/runner/prepare-safety-scan.js +1 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +170 -0
- package/dist/core/runner/prepare-suspend-saga.js +308 -0
- package/dist/core/runner/prepare-task.d.ts +9 -136
- package/dist/core/runner/prepare-task.js +47 -2745
- package/dist/core/runner/prepare-turn-wiring.d.ts +154 -0
- package/dist/core/runner/prepare-turn-wiring.js +201 -0
- package/dist/core/runner/prepare-wiring-manifest.d.ts +17 -17
- package/dist/core/runner/prepare-wiring-manifest.js +16 -10
- package/dist/core/runner/prepare-workspace-restore.d.ts +2 -29
- package/dist/core/runner/prepare-workspace-restore.js +3 -16
- package/dist/core/runner/prompt-hash-salt.d.ts +1 -0
- package/dist/core/runner/prompt-hash-salt.js +2 -0
- package/dist/core/runner/remote-env-retry.d.ts +29 -0
- package/dist/core/runner/remote-env-retry.js +16 -0
- package/dist/core/runner/runtask.d.ts +16 -31
- package/dist/core/runner/runtask.js +110 -121
- package/dist/core/runner/terminal-projection.d.ts +22 -0
- package/dist/core/runner/terminal-projection.js +28 -0
- package/dist/core/session.d.ts +12 -0
- package/dist/core/session.js +3 -0
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +4 -1
- package/dist/core/store-contracts/checkpoint-store-contract.js +8 -2
- package/dist/core/terminal-cause.d.ts +137 -0
- package/dist/core/terminal-cause.js +9 -0
- package/dist/core/tool-policy.d.ts +43 -139
- package/dist/core/tool-policy.js +79 -112
- package/dist/core/types.d.ts +67 -164
- package/dist/core/wiring-manifest.d.ts +6 -3
- package/dist/core/workflow-journal-store.js +3 -4
- package/dist/engine/harness/agent-harness.d.ts +1 -1
- package/dist/index.d.ts +10 -7
- package/dist/index.js +8 -5
- package/dist/orchestration/builtin-workflows.d.ts +2 -2
- package/dist/orchestration/builtin-workflows.js +1 -1
- package/dist/orchestration/goal.js +8 -7
- package/dist/orchestration/run-spec.js +5 -3
- package/dist/orchestration/run-workflow-tool.d.ts +1 -1
- package/dist/orchestration/run-workflow-tool.js +4 -4
- package/dist/orchestration/workflow-governance.d.ts +4 -4
- package/dist/orchestration/workflow-governance.js +4 -2
- package/dist/orchestration/workflow-primitives.d.ts +1 -1
- package/dist/orchestration/workflow-primitives.js +1 -1
- package/dist/orchestration/workflow.d.ts +11 -0
- package/dist/orchestration/workflow.js +64 -39
- package/dist/prompts/supervisor.d.ts +1 -1
- package/dist/prompts/supervisor.js +3 -3
- package/dist/scenarios/scenario-registry.js +1 -1
- package/package.json +3 -1
- package/test/export-surface.snapshot.json +74 -22
- /package/dist/core/runner/{prepare-announce-once.d.ts → announce-once-ledger.d.ts} +0 -0
- /package/dist/core/runner/{prepare-announce-once.js → announce-once-ledger.js} +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { isRetryableRemoteErrorCode, RETRYABLE_REMOTE_ERROR_CODES } from "../remote-env.js";
|
|
2
|
+
import { withRetry } from "../with-retry.js";
|
|
3
|
+
export function remoteEnvFailureNote(op, error, attempts) {
|
|
4
|
+
return { op, code: error.code, retryable: isRetryableRemoteErrorCode(error.code), attempts, message: error.message };
|
|
5
|
+
}
|
|
6
|
+
const REMOTE_RESTORE_MAX_ATTEMPTS = 2;
|
|
7
|
+
const REMOTE_RESTORE_BACKOFF_MS = 200;
|
|
8
|
+
export async function restoreWorkspaceWithRetry(env, snapshotId, options, onAttempt) {
|
|
9
|
+
let attempts = 0;
|
|
10
|
+
const outcome = await withRetry(async (attempt) => {
|
|
11
|
+
attempts = attempt;
|
|
12
|
+
onAttempt?.(attempt);
|
|
13
|
+
return env.resumeVM(snapshotId, options);
|
|
14
|
+
}, { retryableCodes: RETRYABLE_REMOTE_ERROR_CODES, maxAttempts: REMOTE_RESTORE_MAX_ATTEMPTS, backoffMs: () => REMOTE_RESTORE_BACKOFF_MS }, { ...(options.abortSignal !== undefined ? { signal: options.abortSignal } : {}) });
|
|
15
|
+
return { outcome, attempts };
|
|
16
|
+
}
|
|
@@ -5,7 +5,8 @@ import { type TaskOutcome } from "../task-outcome.js";
|
|
|
5
5
|
import { type SideQuerySpec, type SideQueryResult } from "../side-query.js";
|
|
6
6
|
import type { SessionStore } from "../session.js";
|
|
7
7
|
import { type RecoveredOrphan } from "../session-reconcile.js";
|
|
8
|
-
import {
|
|
8
|
+
import type { GateOutcome } from "../gate-outcome.js";
|
|
9
|
+
import { type McpDelivered } from "../mcp-failure.js";
|
|
9
10
|
import type { AgentDefinition, ModelRef, RunnerDeps, TaskEvent, TaskResult, TaskSpec, TaskStream } from "../types.js";
|
|
10
11
|
/**
|
|
11
12
|
* Config re-supplied to {@link Runner.resume} (design/45). A suspended task's tools / model / policy /
|
|
@@ -80,45 +81,29 @@ interface ResumeRun {
|
|
|
80
81
|
* the live loop's frames and the resumed batch's frames (`resolvePendingCall` + the deferred-sibling
|
|
81
82
|
* close): the resumed frames used to carry only `isError`, so a client rendering tool output from frames
|
|
82
83
|
* showed an empty body for every durable-approved call. Same projection = same source as the transcript.
|
|
83
|
-
* Also the one place
|
|
84
|
+
* Also the one place the gate outcome reaches a frame — see the parameter. */
|
|
84
85
|
declare function toolEndBodyFrom(result: unknown, isError: boolean,
|
|
85
|
-
/**
|
|
86
|
-
* live loop reads it off the gate's per-call sideband, the resumed leg off the decide
|
|
87
|
-
* a parameter and never derived from `result`: a tool's own `details`
|
|
88
|
-
* also replace) is writable by layers that adjudicate nothing, so reading
|
|
89
|
-
* let a failing tool claim a person approved it. Omitted ⇒ the
|
|
90
|
-
*
|
|
91
|
-
|
|
92
|
-
settledBy?: ApprovalSettledBy,
|
|
93
|
-
/** design/252 G-7 — WHOSE settlement, from the same caller and the same channel as `settledBy`, and
|
|
94
|
-
* for the same reason it is a parameter: an attribution read out of a tool's own result would let a
|
|
95
|
-
* tool name the person who approved it. Omitted ⇒ this call's settlement named nobody. */
|
|
96
|
-
approver?: string,
|
|
97
|
-
/** The ask resolver's deny-arm classification — same caller, same engine-owned channel and the same
|
|
98
|
-
* never-derived-from-`result` posture as the two above. Omitted ⇒ not an ask-resolution deny. */
|
|
99
|
-
resolution?: import("../tool-policy.js").AskDenyResolution,
|
|
86
|
+
/** The gate's record of the pass that admitted or refused this call, supplied by the CALLER of this
|
|
87
|
+
* projection — the live loop reads it off the gate's per-call sideband, the resumed leg off the decide's
|
|
88
|
+
* minted record. Deliberately a parameter and never derived from `result`: a tool's own `details`
|
|
89
|
+
* (which post-tool hooks may also replace) is writable by layers that adjudicate nothing, so reading
|
|
90
|
+
* provenance out of it would let a failing tool claim a person approved it. Omitted ⇒ the call never
|
|
91
|
+
* went through the gate (see the `tool_end.gate` doc, the one home). */
|
|
92
|
+
gate?: GateOutcome,
|
|
100
93
|
/** WHICH call this run's committed durable park is holding ({@link gatedCallIdOf}), for the frames the
|
|
101
|
-
* abort short-circuits. Same never-derived-from-`result` posture as the
|
|
94
|
+
* abort short-circuits. Same never-derived-from-`result` posture as the outcome above, and for the
|
|
102
95
|
* sharpest version of that reason: this one is an assertion about a DIFFERENT call, so a tool able to
|
|
103
96
|
* author it could point an approval UI at a call nobody is waiting on. Omitted ⇒ no park is holding a
|
|
104
97
|
* call (nothing parked, or the park that did holds none), and the frame then carries no id at all. */
|
|
105
|
-
gatedCallIdOfRun?: string
|
|
106
|
-
/** #557 — the classifier denial-limit fallback's own auto-deny marker, from the same engine-owned
|
|
107
|
-
* settlement sideband as `resolution` (same never-derived-from-`result` posture). Omitted ⇒ absent.
|
|
108
|
-
* The pair `settledBy:"timeout"` + `resolution:"window_expired"` WITHOUT this bit is the approval
|
|
109
|
-
* factory's own `approvalTimeoutMs` window; a durable park's expiry is neither — the decide lane's
|
|
110
|
-
* emitter passes no `resolution` at all (see the `tool_end.autoDenied` doc on the event type). */
|
|
111
|
-
autoDenied?: true): {
|
|
98
|
+
gatedCallIdOfRun?: string): {
|
|
112
99
|
output?: unknown;
|
|
113
100
|
truncated?: boolean;
|
|
114
101
|
totalChars?: number;
|
|
115
102
|
structured?: unknown;
|
|
116
103
|
errorCode?: string;
|
|
104
|
+
delivered?: McpDelivered;
|
|
117
105
|
gatedCallId?: string;
|
|
118
|
-
|
|
119
|
-
approver?: string;
|
|
120
|
-
resolution?: import("../tool-policy.js").AskDenyResolution;
|
|
121
|
-
autoDenied?: true;
|
|
106
|
+
gate?: GateOutcome;
|
|
122
107
|
};
|
|
123
108
|
/**
|
|
124
109
|
* scan-1/A1 — the BODY of the synthetic `tool_end` that closes a reconcile-recovered orphan. ONE
|
|
@@ -440,12 +425,12 @@ export declare class Runner {
|
|
|
440
425
|
* factory-minted remote/worktree lane captured an already-destroyed env (plain host/static lanes were
|
|
441
426
|
* false-green).
|
|
442
427
|
*
|
|
443
|
-
* design/49 v1.5 / design/76 §2.5: a
|
|
428
|
+
* design/49 v1.5 / design/76 §2.5: a committed durable pause (`pausedRef.current`, any gate kind)
|
|
444
429
|
* `suspendVM`-paused the env and persisted its `workspaceHandle` into the checkpoint — destroying it would
|
|
445
430
|
* discard the paused VM and make resume fail to restore. Skip teardown; `resume()` rebuilds + `resumeVM`s it. A
|
|
446
431
|
* cancelled pause is reaped via `TaskStream.destroy()` (design/51); an abandoned one is the service container
|
|
447
432
|
* reaper's backstop. The gate here MIRRORS the tail's reap-stash (same durable fact
|
|
448
|
-
* `
|
|
433
|
+
* `pausedRef.current === undefined`), so exactly one path owns the env's fate.
|
|
449
434
|
*/
|
|
450
435
|
private teardownOwnedEnv;
|
|
451
436
|
}
|