@sema-agent/core 7.6.0 → 7.6.2
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 +37 -0
- package/dist/agents/agent-transcript-tool.d.ts +2 -2
- package/dist/agents/cascade.d.ts +2 -3
- package/dist/agents/repair-loop.d.ts +2 -2
- package/dist/agents/retain-ledger.d.ts +2 -3
- package/dist/agents/send-message-tool.d.ts +2 -2
- package/dist/agents/session-util.d.ts +2 -2
- package/dist/agents/subagent.d.ts +3 -4
- package/dist/agents/teacher.d.ts +2 -2
- package/dist/agents/team.d.ts +2 -2
- package/dist/agents/verify.d.ts +5 -6
- package/dist/core/agent-definition.d.ts +172 -0
- package/dist/core/agent-definition.js +1 -0
- package/dist/core/checkpoint-store.d.ts +8 -4
- package/dist/core/delegation-frames.d.ts +298 -0
- package/dist/core/delegation-frames.js +21 -0
- package/dist/core/engine-notice.d.ts +555 -0
- package/dist/core/engine-notice.js +55 -0
- package/dist/core/gate-fold.d.ts +12 -0
- package/dist/core/gate-fold.js +158 -0
- package/dist/core/gate-lanes.d.ts +93 -0
- package/dist/core/gate-lanes.js +626 -0
- package/dist/core/hands-band.d.ts +134 -0
- package/dist/core/hands-band.js +1 -0
- package/dist/core/hooks.d.ts +20 -101
- package/dist/core/hooks.js +53 -854
- package/dist/core/mcp-failure.d.ts +43 -5
- package/dist/core/mcp-failure.js +31 -14
- package/dist/core/mcp-server-spec.d.ts +217 -0
- package/dist/core/mcp-server-spec.js +1 -0
- package/dist/core/model-seat.d.ts +99 -0
- package/dist/core/model-seat.js +1 -0
- package/dist/core/reminder-mint.d.ts +10 -0
- package/dist/core/reminder-mint.js +3 -0
- package/dist/core/runner/contracts.d.ts +382 -6
- package/dist/core/runner/gate-exit.d.ts +177 -9
- package/dist/core/runner/gate-exit.js +70 -1
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +2 -7
- package/dist/core/runner/prepare-delegation-surface.d.ts +2 -7
- package/dist/core/runner/prepare-run-refs.d.ts +12 -0
- package/dist/core/runner/prepare-run-refs.js +5 -0
- package/dist/core/runner/prepare-task.d.ts +2 -2
- package/dist/core/runner/runtask.d.ts +4 -71
- package/dist/core/runner/runtask.js +18 -6
- package/dist/core/runner-deps.d.ts +1416 -0
- package/dist/core/runner-deps.js +1 -0
- package/dist/core/runtime-caps.d.ts +164 -0
- package/dist/core/runtime-caps.js +1 -0
- package/dist/core/task-event.d.ts +910 -0
- package/dist/core/task-event.js +1 -0
- package/dist/core/task-limits.d.ts +110 -0
- package/dist/core/task-limits.js +1 -0
- package/dist/core/task-result.d.ts +809 -0
- package/dist/core/task-result.js +1 -0
- package/dist/core/task-spec.d.ts +1370 -0
- package/dist/core/task-spec.js +1 -0
- package/dist/core/task-stream.d.ts +382 -0
- package/dist/core/task-stream.js +1 -0
- package/dist/core/tool-spec.d.ts +1174 -0
- package/dist/core/tool-spec.js +1 -0
- package/dist/core/types.d.ts +26 -7691
- package/dist/core/types.js +2 -76
- package/dist/core/warm-resume.d.ts +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/orchestration/goal.d.ts +2 -2
- package/dist/orchestration/run-spec.d.ts +2 -2
- package/dist/orchestration/run-workflow-tool.d.ts +3 -3
- package/dist/orchestration/workflow.d.ts +4 -4
- package/dist/scenarios/scenario-registry.d.ts +3 -3
- package/dist/scenarios/teacher-quickstart.d.ts +2 -2
- package/dist/server/http.d.ts +2 -2
- package/dist/stores/file/fs-atomic.d.ts +88 -12
- package/dist/stores/file/fs-atomic.js +184 -55
- package/dist/stores/file/index.d.ts +1 -0
- package/dist/stores/file/index.js +1 -0
- package/package.json +1 -1
- package/test/export-surface.snapshot.json +9 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two envelopes that say what a run MAY do: `WorkflowGovernanceBaseline` (the floor a deployment
|
|
3
|
+
* puts under every workflow step) and `RuntimeCaps` (the per-agent capability projection). Neither
|
|
4
|
+
* names the other; they share a module because "the host's declared ceiling" is one concern, and both
|
|
5
|
+
* are read off `RunnerDeps`. Layer 0 vocabulary; `types.ts` re-exports both, so no consumer's import
|
|
6
|
+
* changes.
|
|
7
|
+
*/
|
|
8
|
+
import type { TaskSpec } from "./task-spec.js";
|
|
9
|
+
/**
|
|
10
|
+
* design/98 §E.2 / §2.5 (S8b) — the deployment-trusted governance that EVERY sub-agent an LLM-authored
|
|
11
|
+
* workflow script spawns INHERITS (tighten-only). The child spec is BUILT from this baseline + a strict
|
|
12
|
+
* WHITELIST of safe work-fields the script may set — `{ ...base, ...pick(scriptSpec, WHITELIST_KEYS) }` then
|
|
13
|
+
* `tightenTaskSpec(base, child)` (default-deny / complete-by-construction, NOT a blacklist
|
|
14
|
+
* strip — a missed control-plane field would otherwise leak). It is captured from `RunnerDeps` (trusted,
|
|
15
|
+
* never LLM-influenced), NEVER from the LLM-influenced initiating task spec.
|
|
16
|
+
*
|
|
17
|
+
* Why an EXPLICIT field (arbitration): `RunnerDeps` has no `tools`/`mcp`/`skills`/`principal`
|
|
18
|
+
* (those are TaskSpec-only), so the capability a workflow child gets cannot be auto-derived from deps —
|
|
19
|
+
* the deployment must DECLARE it here. Unset ⇒ self-orchestration is FAIL-CLOSED (the `run_workflow` tool is
|
|
20
|
+
* not mounted, same hard deploy gate as a missing sandbox): a script-spawned agent must never run without a
|
|
21
|
+
* governed baseline.
|
|
22
|
+
*/
|
|
23
|
+
export interface WorkflowGovernanceBaseline {
|
|
24
|
+
/**
|
|
25
|
+
* The deployment's trusted control-plane the child inherits — toolPolicy / onAsk / onQuestion / hooks /
|
|
26
|
+
* principal / tools / mcp / skills / lspManager / checkpointStore / getApiKeyAndHeaders / promptProvider /
|
|
27
|
+
* handsReadOnly / shellGate / limits / maxCostUsd / maxTokens, etc. Snapshotted into each child spec FIRST,
|
|
28
|
+
* so every governance field comes from here; only whitelisted work-fields overlay it.
|
|
29
|
+
*/
|
|
30
|
+
base: Partial<TaskSpec>;
|
|
31
|
+
/**
|
|
32
|
+
* OPTIONAL baseline OVERLAY for a child the script spawns WITH `isolation: "worktree"` (design/97 CORE-6 ×
|
|
33
|
+
* governance). A worktree-isolated agent works in its OWN detached git worktree, so a deployment whose `base`
|
|
34
|
+
* clamps writes (e.g. `handsReadOnly: true` — the right default for children sharing one working tree) can
|
|
35
|
+
* grant isolated children write access WITHOUT loosening the shared-tree baseline — typically
|
|
36
|
+
* `worktreeBase: { handsReadOnly: false }` (lift only the write clamp; the worktree provides the file
|
|
37
|
+
* containment instead of the spec clamp).
|
|
38
|
+
*
|
|
39
|
+
* **Overlay semantics (shallow merge)**: when — and only when — the spawn requested `isolation: "worktree"`,
|
|
40
|
+
* the effective baseline is `{ ...base, ...worktreeBase }`. Field-level at the TOP level only: a field
|
|
41
|
+
* present here overrides the same-named `base` field WHOLESALE (a nested object such as `limits` or
|
|
42
|
+
* `toolPolicy` is replaced entirely, never deep-merged); an absent field inherits from `base` — so
|
|
43
|
+
* toolPolicy / shellGate / limits / maxCostUsd keep governing isolated children unless deliberately
|
|
44
|
+
* overridden. The same whitelist/allowlist/clamp construction applies on top. **Absent ⇒ `base` governs
|
|
45
|
+
* every child, isolated or not (zero behavior change).**
|
|
46
|
+
*
|
|
47
|
+
* **What the containment actually is (honest scope)**: the worktree is COOPERATIVE file isolation — it is
|
|
48
|
+
* the cwd domain the file tools resolve against, not a jail. Bash can `cd` out of it (same posture as the
|
|
49
|
+
* upstream worktree-isolation feature this mirrors; a worktree was never a shell sandbox). Relaxing writes
|
|
50
|
+
* here is therefore safe only under the deployment's trust in the workflow-script author lane it already
|
|
51
|
+
* accepted. Residuals: an isolation request that cannot be honored FAILS the spawn (fail-closed, see
|
|
52
|
+
* {@link ExecutionEnvFactoryContext.isolation}) with the observable degrade shapes rejected outright, but a
|
|
53
|
+
* factory that mints a worktree DEEP INSIDE the shared tree is within-contract — verifying that the minted
|
|
54
|
+
* dir is a genuine fresh worktree is the factory's MUST-throw contract, not an engine receipt.
|
|
55
|
+
*/
|
|
56
|
+
worktreeBase?: Partial<TaskSpec>;
|
|
57
|
+
/**
|
|
58
|
+
* The allowed model NAMES an LLM-authored script may pick (design/98 §2.5 新洞2). A script gives a
|
|
59
|
+
* `modelName` string (never a `Model` object — that carries `baseUrl`/`headers` = exfil); the engine
|
|
60
|
+
* resolves it against this list to a deploy-configured `Model` (the script never sees the object).
|
|
61
|
+
* **FAIL-CLOSED**: `undefined`/empty ⇒ the script CANNOT pick a model — a spec that names `modelName`
|
|
62
|
+
* THROWS `WorkflowModelNotAllowedError` and the child is never spawned. The refusal is loud, not a
|
|
63
|
+
* silent downgrade: the script asked for a model it may not have, so the agent call FAILS rather than
|
|
64
|
+
* quietly running on the workflow's default role (a script that wants the default must simply OMIT
|
|
65
|
+
* the field). The same throw covers a name that is off the list, and a listed name the `models`
|
|
66
|
+
* catalog does not hold — so the legal set is the INTERSECTION of this list and the catalog keys
|
|
67
|
+
* (note the catalog is the Runner's TIER-EXPANDED one, so on a deployment with `RunnerDeps.tiers`
|
|
68
|
+
* the tier words and CC aliases are catalog keys here too, still gated by this list).
|
|
69
|
+
* NEVER fail-open to the whole `models` catalog for an LLM-authored workflow.
|
|
70
|
+
*/
|
|
71
|
+
workflowModelAllowlist?: string[];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* design/99 §K — the per-principal runtime ENTITLEMENTS the engine enforces server-side, resolved by a
|
|
75
|
+
* deployment via {@link RunnerDeps.runtimeCapsResolver} from center's `GET /api/config/effective?principal=`.
|
|
76
|
+
* Every field is TIGHTEN-ONLY (a cap only ever DENIES or FORCES) — but the family carries THREE
|
|
77
|
+
* polarities, and "absent" does not read the same on each:
|
|
78
|
+
* · DENY-shaped, `false` denies / absent is no restriction: {@link allowWorkflows}, {@link allowFork},
|
|
79
|
+
* {@link autoMode} (the per-principal deny bit of a user-enabled mode), {@link allowMemoryOptOut}
|
|
80
|
+
* (the one member whose resolver-FAULT degrade is allow, on the privacy axis);
|
|
81
|
+
* · GRANT-shaped, `=== true` opts in / absent is OFF: {@link allowObservers};
|
|
82
|
+
* · FORCE-shaped, `true` mandates / absent is the caller's opt-in default: {@link forceDurableGate}
|
|
83
|
+
* (binds only where a checkpoint store is wired; announced `config.durable_gate_unavailable` where none is).
|
|
84
|
+
* These six are the caps the ENGINE enforces; `allowUltracode`/`allowBypassPermissions` are shell-UX /
|
|
85
|
+
* service-settings-layer concerns (see {@link RunnerDeps.runtimeCapsResolver}).
|
|
86
|
+
*/
|
|
87
|
+
export interface RuntimeCaps {
|
|
88
|
+
/** `false` DENIES workflow self-orchestration for this principal server-side — even on a deployment that is
|
|
89
|
+
* capable ({@link RunnerDeps.workflowScriptRunner} + governance). The third stage of the workflows gate.
|
|
90
|
+
* `undefined`/`true` = no per-principal restriction (the deployment capability still governs). */
|
|
91
|
+
allowWorkflows?: boolean;
|
|
92
|
+
/** `false` DENIES fork (`Agent(subagent_type:"fork")` — design/136: the only fork face since the standalone
|
|
93
|
+
* tool was retired; the deny is the honest `fork.disabled` result, and since 1.256 it binds the Agent-fork
|
|
94
|
+
* route too, closing the 1.254 governance circumvention) for this principal server-side — even on a fork-capable
|
|
95
|
+
* (durable-store) deployment. Fork is a compute-amplification primitive (a principal spawns
|
|
96
|
+
* context-inheriting children, each spending on its own quota), so a multi-tenant operator gates it
|
|
97
|
+
* per-principal the SAME way as {@link allowWorkflows}. `undefined`/`true` = no per-principal restriction
|
|
98
|
+
* (the task `enableFork` + durable-store capability still govern). Tighten-only: it can DENY a capable
|
|
99
|
+
* deployment, never GRANT beyond it. */
|
|
100
|
+
allowFork?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Observer agents (CC 2.1.206 parity, docs/CC206-OBSERVER-ANCHORS-2026-07-11.md §6): honor
|
|
103
|
+
* {@link AgentDefinition.observer} auto-spawn declarations. **POLARITY NOTE — unlike
|
|
104
|
+
* `allowWorkflows`/`allowFork` (`undefined` = unrestricted), this one is `=== true` EXPLICIT
|
|
105
|
+
* opt-in, default OFF**: CC's gate pair is a default-UNSET experimental env var
|
|
106
|
+
* (`CLAUDE_CODE_EXPERIMENTAL_OBSERVER_AGENTS`) ANDed with a default-true statsig gate — the
|
|
107
|
+
* composite ships dark. `undefined`/`false` ⇒ declarations resolve to unobserved (no warn: the
|
|
108
|
+
* gate, not a config mistake).
|
|
109
|
+
*/
|
|
110
|
+
allowObservers?: boolean;
|
|
111
|
+
/** `true` FORCES this principal's run onto the durable-approval path: the engine synthesizes a
|
|
112
|
+
* `durableApproval{scope: principal}` so a policy `ask` suspends to the wire (a per-tool CC-faithful gate)
|
|
113
|
+
* even when the caller did not opt in — center's fleet-wide "interactive runs gate" mandate. A
|
|
114
|
+
* caller-supplied `TaskSpec.durableApproval` always wins (it may carry a tighter scope/ttl).
|
|
115
|
+
* The mandate binds only where a {@link RunnerDeps.checkpointStore} is wired — the park facility it
|
|
116
|
+
* forces the run onto. On a store-less deployment it has no facility: the leg announces
|
|
117
|
+
* `config.durable_gate_unavailable` once (before its first ask), every ask resolves on the live chain
|
|
118
|
+
* (a live approver / question face in-stream, or the fail-closed deny with none), no durable record
|
|
119
|
+
* is written, and a live question face is consulted rather than vetoed (a mandate that cannot park
|
|
120
|
+
* must not demote a reachable person into the model answering for them). */
|
|
121
|
+
forceDurableGate?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* The per-principal auto-mode DENY bit (CC 2.1.250 polarity — the mirror of the settings-plane
|
|
124
|
+
* `permissions.disableAutoMode` ratchet: an organization may only take auto mode AWAY; it is the
|
|
125
|
+
* USER who turns it on, at the task's intent seat {@link TaskSpec.autoModeRequested}).
|
|
126
|
+
*
|
|
127
|
+
* **POLARITY: `=== false` DENIES; ABSENT IS NOT A DENIAL.** This is the family's deny-shaped
|
|
128
|
+
* member (like {@link allowWorkflows} / {@link allowFork}), NOT a grant-shaped one like
|
|
129
|
+
* {@link allowObservers}: a deployment with no entitlement source at all resolves `undefined` here
|
|
130
|
+
* and still arms on intent + capability. `true` is accepted and means the same as absent (no
|
|
131
|
+
* per-principal restriction) — it is not a grant, and it cannot arm a task whose intent seat is
|
|
132
|
+
* unset. The arming itself: intent ∧ {@link RunnerDeps.autoMode} present ∧ this bit not `false`
|
|
133
|
+
* (allow → run; block → deny `source:"classifier"`; classifier failure → FAIL-CLOSED back to the
|
|
134
|
+
* original ask chain). The trust gate is unchanged: classifier RULES enter only through the
|
|
135
|
+
* deployment assembly face, never a repo-controlled plane (the CC 2.1.207 three-source invariant).
|
|
136
|
+
* A denial resolves to a no-op (asks flow the original chain; no warn — the gate, not a mistake).
|
|
137
|
+
*/
|
|
138
|
+
autoMode?: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* design/383 §3.1 — may this principal declare a session memory-capture OPT-OUT
|
|
141
|
+
* (`TaskSpec.memory.capture: "off"` / the Runner flip verb)? `false` = the deployment REQUIRES
|
|
142
|
+
* capture for this principal (compliance / knowledge retention) — the declaration is refused
|
|
143
|
+
* terminal (`memory.capture_optout_denied`). `undefined` / `true` = no per-principal restriction.
|
|
144
|
+
*
|
|
145
|
+
* ⚠️ POLARITY REVERSAL — this member is the family's one deliberate exception to the
|
|
146
|
+
* fail-closed resolver degrade (`{allowWorkflows:false, allowFork:false}`): on the PRIVACY axis
|
|
147
|
+
* "deny" means "capture the session of a user who explicitly said no", which is the IRREVERSIBLE
|
|
148
|
+
* side (a wrongly-captured session has been read, may be folded into products, may have synced —
|
|
149
|
+
* deleting later does not unhappen it), while a wrongly-honored opt-out costs one uncaptured
|
|
150
|
+
* session (recoverable). Under the default/`"open"` posture a resolver FAULT therefore reads as
|
|
151
|
+
* ALLOW (+ a named `onError` disclosure), and only an explicit `false` denies; a deployment for
|
|
152
|
+
* which the compliance side is the heavier irreversibility declares `memoryCapturePolicy:
|
|
153
|
+
* "governed"`, which flips the fault arm to refuse-to-run (see {@link RunnerDeps.memoryCapturePolicy}).
|
|
154
|
+
*
|
|
155
|
+
* 🔒 FAULT-TRANSIT CONTRACT (server F2, written here because the resolver's habits run the other
|
|
156
|
+
* way): a resolver failure for THIS member must surface as the member being ABSENT (`undefined`)
|
|
157
|
+
* or as a THROW — both read as "fault". The resolver MUST NOT coin a stand-in explicit value on
|
|
158
|
+
* failure (the `{allowWorkflows:false}` degrade habit): an explicit `false` IS the denied
|
|
159
|
+
* verdict, and encoding an outage as one silently swaps the fault arm for the verdict arm — under
|
|
160
|
+
* `"open"` that is the exact polarity inversion this member exists to prevent. A non-boolean
|
|
161
|
+
* value here is treated as a fault (never truthiness-read) and disclosed.
|
|
162
|
+
*/
|
|
163
|
+
allowMemoryOptOut?: boolean;
|
|
164
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|