@sema-agent/core 7.28.1 → 7.30.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 +473 -1
- package/dist/agents/child-model-seat.d.ts +59 -7
- package/dist/agents/child-model-seat.js +33 -7
- package/dist/agents/cross-session-judge.d.ts +27 -5
- package/dist/agents/cross-session-judge.js +23 -12
- package/dist/agents/list-agents-tool.d.ts +31 -6
- package/dist/agents/list-agents-tool.js +66 -14
- package/dist/agents/peer-admission.d.ts +20 -8
- package/dist/agents/peer-admission.js +21 -12
- package/dist/agents/peer-directory.d.ts +29 -0
- package/dist/agents/peer-directory.js +20 -0
- package/dist/agents/peer-held-queue.d.ts +31 -4
- package/dist/agents/peer-held-queue.js +32 -1
- package/dist/agents/peer-session-drain.d.ts +91 -13
- package/dist/agents/peer-session-drain.js +409 -102
- package/dist/agents/read-inbox-tool.d.ts +22 -0
- package/dist/agents/read-inbox-tool.js +39 -0
- package/dist/agents/roster-store.d.ts +2 -4
- package/dist/agents/roster-store.js +1 -1
- package/dist/agents/send-message-tool.d.ts +4 -4
- package/dist/agents/send-message-tool.js +22 -2
- package/dist/agents/subagent.js +62 -44
- package/dist/agents/team-role.d.ts +34 -0
- package/dist/agents/team-role.js +17 -0
- package/dist/agents/verify.js +2 -2
- package/dist/brain/anthropic.js +4 -2
- package/dist/brain/open-responses.js +4 -3
- package/dist/brain/openai.js +2 -1
- package/dist/brain/stream-engine.js +6 -0
- package/dist/brain/stream-shared.d.ts +8 -0
- package/dist/brain/stream-shared.js +8 -0
- package/dist/core/auto-compaction.d.ts +42 -0
- package/dist/core/auto-compaction.js +35 -2
- package/dist/core/child-clamp-seats.d.ts +11 -0
- package/dist/core/child-clamp-seats.js +3 -0
- package/dist/core/context-edit.d.ts +3 -2
- package/dist/core/context-edit.js +6 -5
- package/dist/core/context-guard.d.ts +2 -1
- package/dist/core/context-guard.js +3 -2
- package/dist/core/context-settings.d.ts +103 -0
- package/dist/core/context-settings.js +60 -0
- package/dist/core/engine-notice.d.ts +18 -1
- package/dist/core/frame-settlement.d.ts +97 -0
- package/dist/core/frame-settlement.js +36 -0
- package/dist/core/governance-codes.d.ts +1 -1
- package/dist/core/governance-codes.js +4 -0
- package/dist/core/hooks.d.ts +10 -10
- package/dist/core/mailbox-store.d.ts +41 -7
- package/dist/core/mailbox-store.js +9 -3
- package/dist/core/message-utils.d.ts +13 -0
- package/dist/core/message-utils.js +6 -0
- package/dist/core/parent-spec-seat.d.ts +14 -1
- package/dist/core/parent-spec-seat.js +6 -0
- package/dist/core/permission-rule-model.js +1 -1
- package/dist/core/roles.d.ts +20 -0
- package/dist/core/roles.js +35 -16
- package/dist/core/runner/assemble-result.d.ts +2 -0
- package/dist/core/runner/assemble-result.js +3 -1
- package/dist/core/runner/compaction-call-options.d.ts +26 -2
- package/dist/core/runner/compaction-call-options.js +9 -0
- package/dist/core/runner/compaction-seams.d.ts +4 -3
- package/dist/core/runner/compaction-seams.js +13 -6
- package/dist/core/runner/contracts.d.ts +61 -7
- package/dist/core/runner/decide-continuation.d.ts +2 -1
- package/dist/core/runner/decide-continuation.js +11 -10
- package/dist/core/runner/initial-run-state.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.js +9 -1
- package/dist/core/runner/prepare-config-doors.js +4 -1
- package/dist/core/runner/prepare-context-lane.d.ts +9 -2
- package/dist/core/runner/prepare-context-lane.js +15 -10
- package/dist/core/runner/prepare-delegation-surface.d.ts +3 -2
- package/dist/core/runner/prepare-delegation-surface.js +9 -3
- package/dist/core/runner/prepare-file-history.js +10 -8
- package/dist/core/runner/prepare-gate-stations.d.ts +4 -0
- package/dist/core/runner/prepare-gate-stations.js +3 -1
- package/dist/core/runner/prepare-inherited-gate.js +1 -0
- package/dist/core/runner/prepare-prompt-inputs.d.ts +6 -0
- package/dist/core/runner/prepare-prompt-inputs.js +2 -1
- package/dist/core/runner/prepare-task.js +22 -9
- package/dist/core/runner/prepare-wiring-manifest.d.ts +6 -1
- package/dist/core/runner/prepare-wiring-manifest.js +6 -1
- package/dist/core/runner/response-model-seat.d.ts +16 -0
- package/dist/core/runner/response-model-seat.js +27 -0
- package/dist/core/runner/retired-runner-deps.d.ts +3 -1
- package/dist/core/runner/retired-runner-deps.js +1 -0
- package/dist/core/runner/run-compaction-machinery.d.ts +4 -2
- package/dist/core/runner/run-compaction-machinery.js +5 -3
- package/dist/core/runner/run-harness-handlers.js +9 -2
- package/dist/core/runner/run-identity-wiring.js +19 -1
- package/dist/core/runner/run-leg.js +1 -1
- package/dist/core/runner/run-notification-lane.js +8 -2
- package/dist/core/runner/run-recovery-lanes.js +9 -5
- package/dist/core/runner/run-settle-and-teardown.d.ts +4 -22
- package/dist/core/runner/run-settle-and-teardown.js +6 -10
- package/dist/core/runner/run-stop-and-final-verify.js +1 -0
- package/dist/core/runner/run-terminal-adoption.js +5 -5
- package/dist/core/runner/run-turn-boundary.js +32 -5
- package/dist/core/runner/runtask.d.ts +8 -1
- package/dist/core/runner/runtask.js +33 -2
- package/dist/core/runner-deps.d.ts +44 -13
- package/dist/core/side-query.d.ts +6 -5
- package/dist/core/side-query.js +3 -1
- package/dist/core/swappable-deps.d.ts +20 -4
- package/dist/core/swappable-deps.js +6 -1
- package/dist/core/task-event.d.ts +13 -0
- package/dist/core/task-notification.d.ts +144 -2
- package/dist/core/task-notification.js +154 -5
- package/dist/core/task-result.d.ts +27 -3
- package/dist/core/task-spec.d.ts +7 -0
- package/dist/core/tool-catalog-entries.js +2 -1
- package/dist/core/tool-conformance.js +1 -0
- package/dist/core/tool-policy.d.ts +9 -4
- package/dist/core/tool-spec.d.ts +14 -0
- package/dist/core/wiring-manifest.d.ts +12 -0
- package/dist/core/wiring-manifest.js +5 -1
- package/dist/engine/harness/agent-harness.d.ts +14 -1
- package/dist/engine/harness/agent-harness.js +28 -3
- package/dist/engine/harness/types.d.ts +3 -1
- package/dist/engine/llm/types.d.ts +8 -7
- package/dist/engine/llm/types.js +1 -1
- package/dist/engine/session/import-validate.js +4 -0
- package/dist/index.d.ts +10 -7
- package/dist/index.js +7 -5
- package/dist/orchestration/run-workflow-tool.d.ts +4 -4
- package/dist/orchestration/workflow.d.ts +1 -1
- package/dist/orchestration/workflow.js +8 -5
- package/dist/shell/lex.d.ts +30 -51
- package/dist/shell/lex.js +237 -284
- package/dist/stores/cc/mailbox-store.js +3 -2
- package/dist/stores/file/corrupt-read-sink.d.ts +28 -2
- package/dist/stores/file/file-history-store.d.ts +2 -4
- package/dist/stores/file/file-history-store.js +1 -1
- package/dist/stores/file/fs-atomic.d.ts +16 -11
- package/dist/stores/file/fs-atomic.js +17 -6
- package/dist/stores/file/index.d.ts +5 -6
- package/dist/stores/file/index.js +1 -1
- package/dist/stores/file/mailbox-store.d.ts +4 -9
- package/dist/stores/file/mailbox-store.js +29 -30
- package/dist/stores/file/session-policy-store.d.ts +2 -0
- package/dist/stores/file/session-policy-store.js +1 -1
- package/dist/stores/file/session-store.d.ts +11 -7
- package/dist/stores/file/session-store.js +23 -16
- package/dist/stores/file/shared-ledger.js +3 -14
- package/dist/stores/file/tool-result-store.d.ts +2 -0
- package/dist/stores/file/tool-result-store.js +5 -2
- package/dist/stores/file/workflow-journal-store.js +14 -9
- package/dist/tools/fs/bash-program-position.d.ts +15 -24
- package/dist/tools/fs/bash-program-position.js +11 -29
- package/dist/tools/fs/bash-readonly-classifier.d.ts +125 -117
- package/dist/tools/fs/bash-readonly-classifier.js +400 -272
- package/dist/tools/fs/shell-read-check.js +3 -3
- package/dist/tools/fs/shell-read-establish.js +1 -1
- package/dist/tools/fs/shell-read-plan.d.ts +11 -6
- package/dist/tools/fs/shell-read-plan.js +167 -183
- package/dist/tools/fs/shell-read-word.d.ts +50 -0
- package/dist/tools/fs/shell-read-word.js +59 -0
- package/dist/tools/fs/shell-reentry-text.d.ts +10 -0
- package/dist/tools/fs/shell-reentry-text.js +73 -0
- package/package.json +1 -1
- package/test/export-surface.snapshot.json +58 -8
- package/wire-changes/core@7.29.0.json +185 -0
- package/wire-changes/core@7.30.0.json +1821 -0
|
@@ -47,7 +47,7 @@ import type { SystemInjectionPriority, TaskNotificationPayload } from "../task-n
|
|
|
47
47
|
import type { OnAsk, PermissionResult, ResolvedAsk, ToolCallRequest, ToolPolicy } from "../tool-policy.js";
|
|
48
48
|
import type { RemoteExecutionEnv, SnapshotId, WorkspaceHandle } from "../remote-env.js";
|
|
49
49
|
import type { ToolDisclosureManifest } from "../trace.js";
|
|
50
|
-
import type { AgentDefinition, ApproverPosture, Brain, CompactOutcome, ModelRoles, NestedUsageAccum, RunnerDeps, ShellGateDoctrine, TaskEvent, TaskEventIdentity, TaskResult, TaskSpec, TaskStream, ToolActivity, ToolEffect } from "../types.js";
|
|
50
|
+
import type { AgentDefinition, ApproverPosture, Brain, CompactOutcome, ModelRef, ModelRoles, NestedUsageAccum, RunnerDeps, ShellGateDoctrine, TaskEvent, TaskEventIdentity, TaskResult, TaskSpec, TaskStream, ToolActivity, ToolEffect } from "../types.js";
|
|
51
51
|
import type { WiringManifest } from "../wiring-manifest.js";
|
|
52
52
|
import type { ActiveSkillFrame } from "./active-skill-scope.js";
|
|
53
53
|
import type { BudgetAxis } from "./assemble-result.js";
|
|
@@ -248,6 +248,11 @@ export interface Prepared {
|
|
|
248
248
|
* prepare emits run-scoped disclosures of its own and each must have a terminal that names it.
|
|
249
249
|
*/
|
|
250
250
|
runId: string;
|
|
251
|
+
/** The (owner, scope) key this run's registry-facing tools register rows under — (host task id, mount domain), minted once at prepare; the teardown sweeps read it and never re-derive it. */
|
|
252
|
+
registryAccess: {
|
|
253
|
+
readonly owner: string;
|
|
254
|
+
readonly scope: string;
|
|
255
|
+
};
|
|
251
256
|
/** The session's reminder provenance mark this run mints under (adopted
|
|
252
257
|
* through the prepare adoption ladder: checkpoint seed → trusted fork channel → session entry →
|
|
253
258
|
* fresh mint). Every engine-authored `<system-reminder>` open tag in the run carries it, and the
|
|
@@ -257,6 +262,8 @@ export interface Prepared {
|
|
|
257
262
|
* disclosure outlets at tool-execute time; read once at result assembly into
|
|
258
263
|
* `stats.mechanisms.reminderDisclosures` when any key is non-zero). Always present. */
|
|
259
264
|
reminderDisclosureCounts: import("../reminder-disclosure.js").ReminderDisclosureCounts;
|
|
265
|
+
/** Whether the full shell is on this leg's roster (the inherited-gate phase's bit, asserted against the mount). */
|
|
266
|
+
fullShellReachable: boolean;
|
|
260
267
|
/** The run's RESOLVED approval-posture facts — the auto-mode intent and the declared approver posture,
|
|
261
268
|
* folded once by the chain assembly. The first user turn renders them into the engine's own marked
|
|
262
269
|
* reminder; nothing else reads them, and no gate decision keys on either. */
|
|
@@ -471,6 +478,28 @@ export interface Prepared {
|
|
|
471
478
|
* drains — one mount judgment, the drain and the park read it alike. Absent ⇒ in-process parking.
|
|
472
479
|
*/
|
|
473
480
|
sessionBox?: import("../task-notification.js").SessionBoxBinding;
|
|
481
|
+
/**
|
|
482
|
+
* #1036 — the leg's TWO SETTLEMENT LEDGERS, one cell shared by the three beats that fill and
|
|
483
|
+
* read them: the harness's transcript-append sink writes receipts, the compaction commit beat
|
|
484
|
+
* writes effects, and the session-box drain's settlement half-pass reads both and clears what it
|
|
485
|
+
* consumed. Always present (the cell is minted with the leg); empty on a run with no session box,
|
|
486
|
+
* because nothing registers an interest and the receipt sink only records awaited keys.
|
|
487
|
+
*/
|
|
488
|
+
frameSettlement: import("../frame-settlement.js").FrameSettlement;
|
|
489
|
+
/**
|
|
490
|
+
* #1036 — the session-box drain's BOUNDARY PASS, called by the turn-boundary lane as its tail
|
|
491
|
+
* (in a `finally`, so every early exit of the boundary still settles). Present iff this leg bound
|
|
492
|
+
* the drain. `continues` = this leg will issue another request after this boundary, which is what
|
|
493
|
+
* decides whether the pass's NEW-delivery half runs; the settlement half runs either way.
|
|
494
|
+
*
|
|
495
|
+
* It is a tail call and not a `turn_boundary` hook of the drain's own because the ORDER matters and
|
|
496
|
+
* a hook's position is registration-order luck: settlement must run AFTER this boundary's
|
|
497
|
+
* compaction, or a record whose frame the compaction just summarized away is already acked (deleted
|
|
498
|
+
* from the box) by the time anyone could notice.
|
|
499
|
+
*/
|
|
500
|
+
peerBoundaryRound?: (o: {
|
|
501
|
+
continues: boolean;
|
|
502
|
+
}) => Promise<void>;
|
|
474
503
|
/**
|
|
475
504
|
* The per-invocation TIME BOUND every hook seat of this leg runs under (`Hooks.timeoutMs`, already
|
|
476
505
|
* validated — a garbage value was refused to the default and disclosed ONCE, here, rather than on
|
|
@@ -1699,6 +1728,19 @@ export interface RunInternals {
|
|
|
1699
1728
|
* TRUSTED run-scoped channel (NOT a {@link TaskSpec} field), mirroring `insideFork`.
|
|
1700
1729
|
*/
|
|
1701
1730
|
defaultSystemPrompt?: string;
|
|
1731
|
+
/**
|
|
1732
|
+
* The catalog WORD that chose the model this engine-spawned child was handed on its spec.
|
|
1733
|
+
*
|
|
1734
|
+
* The two halves of one fact travel on two channels on purpose: the spec carries the RESOLVED `Model`
|
|
1735
|
+
* object, so nothing re-resolves between the spawn's judgement and this child's prepare (the model the
|
|
1736
|
+
* spawn frames name is the model that runs); this carries the word that object came from, so the child
|
|
1737
|
+
* is not PINNED by having been handed an object — its own children inherit the word in turn, and the
|
|
1738
|
+
* deployment's per-model window overlay (keyed by word) still reaches it. Absent ⇒ no word exists for
|
|
1739
|
+
* this child's model (a caller-pinned object, a `select` criteria), and such a leg is deliberately never
|
|
1740
|
+
* re-resolved and never overlaid. Trusted channel, never a `TaskSpec` field: it is the engine's own
|
|
1741
|
+
* statement about a model the engine itself resolved, and a caller cannot author it.
|
|
1742
|
+
*/
|
|
1743
|
+
inheritedModelRef?: ModelRef;
|
|
1702
1744
|
/**
|
|
1703
1745
|
* GOAL MODE flag, a TRUSTED internal channel set ONLY by `runGoal` (a core caller),
|
|
1704
1746
|
* NEVER a {@link TaskSpec} field. It drives `featureFlags.goalEnabled` → injects `GOAL_COMPLETION_GUIDANCE`.
|
|
@@ -2105,7 +2147,7 @@ export interface RunInternals {
|
|
|
2105
2147
|
* `leg` is the LEG IDENTITY, and the engine mints NONE of it. It is present only where a
|
|
2106
2148
|
* composition labelled the leg it dispatched: the verify entries hand each leg a per-dispatch
|
|
2107
2149
|
* copy of this object whose sink closes over that leg's identity, so a consumer can tell the
|
|
2108
|
-
* implementation leg from
|
|
2150
|
+
* implementation leg from pass 2's verifier without inferring it from arrival order (the
|
|
2109
2151
|
* ordering is all the sibling sinks have — see the attribution paragraph on `verifyCompleted`).
|
|
2110
2152
|
* ABSENT therefore means "nobody labelled this leg", never "implementation": a plain `runTask`,
|
|
2111
2153
|
* a workflow agent call and a cascade rung all reach this sink with no identity, and reading one
|
|
@@ -2113,13 +2155,13 @@ export interface RunInternals {
|
|
|
2113
2155
|
* OWN `leg` field ({@link WiringManifest.leg}, `root` / `child` / `resume`), which is a fact about
|
|
2114
2156
|
* how the ENGINE reached this run; this one is a fact about the composition that dispatched it, and
|
|
2115
2157
|
* a resumed fix leg carries both at once — `manifest.leg.kind === "resume"` and `leg.kind === "fix"`
|
|
2116
|
-
* are both true of it. `
|
|
2158
|
+
* are both true of it. `pass` is 1-based over the gate's verification rounds: a `verifier` leg
|
|
2117
2159
|
* carries the one it verifies, a `fix` leg the one whose findings it answers, and the entry
|
|
2118
2160
|
* implementation leg carries 0 — before the first. The axis is relative to the gate INVOCATION,
|
|
2119
2161
|
* not to the session's history: a resume entry's work leg is THAT invocation's implementation leg
|
|
2120
|
-
* (`impl`,
|
|
2121
|
-
* fix
|
|
2122
|
-
* it — one axis for both fields, rather than a leg that reads "fix
|
|
2162
|
+
* (`impl`, pass 0) even when the checkpoint it resumes was minted inside a previous invocation's
|
|
2163
|
+
* fix pass, because the invocation's own pass counter (`VerificationResult.rounds`) restarts with
|
|
2164
|
+
* it — one axis for both fields, rather than a leg that reads "fix pass 1" inside a result whose
|
|
2123
2165
|
* rounds begin at 1 again.
|
|
2124
2166
|
*
|
|
2125
2167
|
* Observe-only and failure-isolated through the SAME per-run notifier as {@link onActivity} (one
|
|
@@ -2340,6 +2382,10 @@ export interface RunState {
|
|
|
2340
2382
|
} | undefined;
|
|
2341
2383
|
turnUsageMissing: boolean;
|
|
2342
2384
|
turnStopReason: string | undefined;
|
|
2385
|
+
/** The PROVIDER-REPORTED model name of this turn's LAST assistant message, when it differed from the
|
|
2386
|
+
* requested id — surfaced on `turn_end.responseModel`, reset with the rest of the per-turn
|
|
2387
|
+
* bookkeeping. Same shape as `turnStopReason`: last-message-wins, absent by default. */
|
|
2388
|
+
turnResponseModel: string | undefined;
|
|
2343
2389
|
lastTurnHadToolCalls: boolean;
|
|
2344
2390
|
/** B15 三期使能:postToolBatch 的本回合聚集批(每回合边界消费并重置 — 回合语义,故归 turn)。 */
|
|
2345
2391
|
toolBatch: PostToolBatchCall[];
|
|
@@ -2353,6 +2399,9 @@ export interface RunState {
|
|
|
2353
2399
|
/** B15 三期终件补遗:压缩地板/背压 latch — rs.counters.compactionFloor 跨 drainManualCompact(写)/R9(读写)/收尾(读)三方共享,rs.counters.trimForceBackoff 为 R9 跨调用 latch(同款只改绑定不改时机)。 */
|
|
2354
2400
|
compactionFloor: number;
|
|
2355
2401
|
trimForceBackoff: boolean;
|
|
2402
|
+
/** Landed compactions (boundary + prompt-too-long lanes) and the last one's kind — the `TaskResult.compaction` source (the breaker state is read off the breaker itself). */
|
|
2403
|
+
compactionPasses: number;
|
|
2404
|
+
compactionKind?: import("../task-notification.js").CompactionKind;
|
|
2356
2405
|
repetitionCuts: number;
|
|
2357
2406
|
repetitionSpared: number;
|
|
2358
2407
|
repetitionEvents: Array<{
|
|
@@ -2540,7 +2589,7 @@ export interface TurnBoundaryDeps {
|
|
|
2540
2589
|
}, ctx?: import("../hooks.js").PostToolBatchContext) => PostToolBatchResult | undefined | Promise<PostToolBatchResult | undefined>) | undefined;
|
|
2541
2590
|
batchArgs: Map<string, unknown> | undefined;
|
|
2542
2591
|
compactionBrain: Brain;
|
|
2543
|
-
withinTaskCompaction: boolean;
|
|
2592
|
+
withinTaskCompaction: () => boolean;
|
|
2544
2593
|
compactionBreaker: {
|
|
2545
2594
|
failures: number;
|
|
2546
2595
|
};
|
|
@@ -2608,6 +2657,7 @@ export interface HarnessHandlersDeps {
|
|
|
2608
2657
|
batchArgs: Map<string, unknown> | undefined;
|
|
2609
2658
|
runnerHooks: {
|
|
2610
2659
|
onError: RunnerDeps["onError"];
|
|
2660
|
+
onNotice: RunnerDeps["onNotice"];
|
|
2611
2661
|
};
|
|
2612
2662
|
/** The run's ONE isolation scope for the {@link RunInternals} observation sinks, minted by the
|
|
2613
2663
|
* identity-wiring lane (which calls the first of them) and shared with these handlers, so the
|
|
@@ -2653,6 +2703,10 @@ export interface RunnerSelfSeat {
|
|
|
2653
2703
|
models?: Record<string, Model>;
|
|
2654
2704
|
roles?: ModelRoles;
|
|
2655
2705
|
};
|
|
2706
|
+
/** The context-window overlay a leg on `ref` reads RIGHT NOW (`RunnerDeps.contextSettings`, tier aliases followed
|
|
2707
|
+
* against the catalog in force): prepare hands its leg a call-time reader over it, because this is the one seat a
|
|
2708
|
+
* running leg re-reads (geometry, not route — see `context-settings.ts`). */
|
|
2709
|
+
contextOverlayOf?(ref: import("../model-seat.js").ModelRef | undefined): import("../context-settings.js").ContextWindowOverlay | undefined;
|
|
2656
2710
|
/** The deployment-level gating baseline (deps toolPolicy / hooks) as delegate wrappers — for assemblers that compose with it. */
|
|
2657
2711
|
readonly gateBaseline: {
|
|
2658
2712
|
toolPolicy?: RunnerDeps["toolPolicy"];
|
|
@@ -92,5 +92,6 @@ export declare function assertOutcomeText(value: string | undefined, field: "edi
|
|
|
92
92
|
* `prompt(text)` (it always appends a user message — there is no "continue from tool results" entry), so
|
|
93
93
|
* resume re-enters via a `<system-reminder>`-wrapped user message that tells the model the gated decision
|
|
94
94
|
* was applied. The "user message wart" is accepted (API-valid, and clearer than a silent continuation).
|
|
95
|
+
* `fullShellReachable` is the resumed leg's own roster fact, read by {@link reorientClause}.
|
|
95
96
|
*/
|
|
96
|
-
export declare function resumeContinuation(resume: ResumeRun, mark: string | undefined): string;
|
|
97
|
+
export declare function resumeContinuation(resume: ResumeRun, mark: string | undefined, fullShellReachable: boolean): string;
|
|
@@ -74,24 +74,25 @@ export function assertOutcomeText(value, field) {
|
|
|
74
74
|
throw new CheckpointError("checkpoint.invalid_outcome", `resume \`${field}\` is not a plain string (got ${typeof value}) — a decide's text payload is an operator's plain data, not a live object; refusing pre-CAS, the checkpoint stays pending`);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
function reorientClause(fullShellReachable) {
|
|
78
|
+
const source = fullShellReachable
|
|
79
|
+
? "re-orient from the workspace: run `git status` and review your recent changes / last commits"
|
|
80
|
+
: "re-orient from the conversation: re-read your most recent messages and tool results";
|
|
81
|
+
return `Before continuing, ${source} to confirm what is already done, then continue the remaining work. ` +
|
|
82
|
+
"Do NOT restart the task or re-run work that is already committed.";
|
|
83
|
+
}
|
|
84
|
+
export function resumeContinuation(resume, mark, fullShellReachable) {
|
|
78
85
|
if (resume.outcome.gate === "wake") {
|
|
79
|
-
return formatHookFeedback(
|
|
80
|
-
"run `git status` and review your recent changes / last commits to confirm what is already done, then " +
|
|
81
|
-
"continue the remaining work. Do NOT restart the task or re-run work that is already committed.", mark);
|
|
86
|
+
return formatHookFeedback(`You were WOKEN from a parked pause by an operator. ${reorientClause(fullShellReachable)}`, mark);
|
|
82
87
|
}
|
|
83
88
|
if (resume.outcome.gate === "resource_limit") {
|
|
84
|
-
return formatHookFeedback(
|
|
85
|
-
"review your recent changes / last commits to confirm what is already done, then continue the " +
|
|
86
|
-
"remaining work. Do NOT restart the task or re-run work that is already committed.", mark);
|
|
89
|
+
return formatHookFeedback(`You were resumed after a pause. ${reorientClause(fullShellReachable)}`, mark);
|
|
87
90
|
}
|
|
88
91
|
if (resume.outcome.gate === "dry_run_review") {
|
|
89
92
|
const verdict = resume.outcome.decision === "approve"
|
|
90
93
|
? "Your predicted change was REVIEWED and APPROVED; it has been applied"
|
|
91
94
|
: `Your predicted change was REVIEWED and REJECTED${resume.outcome.reason ? `: ${delimitUntrusted("reviewer note", resume.outcome.reason, REVIEWER_NOTE_MAX_BODY)}` : ""}; it was NOT applied`;
|
|
92
|
-
return formatHookFeedback(`You were resumed after a dry-run review. ${verdict}.
|
|
93
|
-
"(run `git status` and review your recent changes) to confirm the current state, then continue the " +
|
|
94
|
-
"remaining work. Do NOT restart the task or re-run work that is already done.", mark);
|
|
95
|
+
return formatHookFeedback(`You were resumed after a dry-run review. ${verdict}. ${reorientClause(fullShellReachable)}`, mark);
|
|
95
96
|
}
|
|
96
97
|
if (resume.outcome.gate === "plan_review") {
|
|
97
98
|
if (resume.outcome.decision === "approve") {
|
|
@@ -4,8 +4,8 @@ export function createRunState() {
|
|
|
4
4
|
degrade: { degradeToModel: undefined, degraded: undefined, outputErrorStreak: 0, outputInvalid: false, recordDegraded: () => { } },
|
|
5
5
|
limits: { turnsExceeded: false, budgetHit: undefined, budgetAxis: undefined, platformTerminal: undefined, outputRetryCap: 0, effectiveMaxTurns: undefined },
|
|
6
6
|
budget: { remainingMicroUsd: undefined, maxCostMicroUsd: undefined, remainingTokens: undefined, maxTokensWindow: undefined, overBudget: () => undefined, streamCancel: false, callOutputChars: 0, lastStreamBudgetCheck: 0, projectedOverBudget: () => undefined },
|
|
7
|
-
turn: { callStartAt: undefined, firstTokenAt: undefined, turnUsage: undefined, turnUsageMissing: false, turnStopReason: undefined, lastTurnHadToolCalls: false, toolBatch: [] },
|
|
8
|
-
counters: { approachNoticesSent: 0, walltimeSyncBackstopFired: false, compactionFloor: 0, trimForceBackoff: false, repetitionCuts: 0, repetitionSpared: 0, repetitionEvents: [], REPETITION_EVENTS_CAP: 0, preemptIgnoredReported: false, wroteThisRun: false, finalVerifyInjections: 0, groundingSignalPreR9: false, groundingSignalPostR9: false, cadenceTurns: 0 },
|
|
7
|
+
turn: { callStartAt: undefined, firstTokenAt: undefined, turnUsage: undefined, turnUsageMissing: false, turnStopReason: undefined, turnResponseModel: undefined, lastTurnHadToolCalls: false, toolBatch: [] },
|
|
8
|
+
counters: { approachNoticesSent: 0, walltimeSyncBackstopFired: false, compactionFloor: 0, trimForceBackoff: false, compactionPasses: 0, repetitionCuts: 0, repetitionSpared: 0, repetitionEvents: [], REPETITION_EVENTS_CAP: 0, preemptIgnoredReported: false, wroteThisRun: false, finalVerifyInjections: 0, groundingSignalPreR9: false, groundingSignalPostR9: false, cadenceTurns: 0 },
|
|
9
9
|
attach: { attachmentsCfg: undefined, agentListingOn: false, skillsListingOn: false, attachState: undefined, dateState: undefined, instrProbe: undefined, instrState: undefined, sizeGuidelineState: undefined, attachmentsInjected: 0 },
|
|
10
10
|
};
|
|
11
11
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isSyntheticApiErrorMessage } from "../../internal/harness.js";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import { childThinkingSeat, deploymentSubagentThinking, deploymentSubagentTierModel, forkGovernanceDenial } from "../../agents/subagent.js";
|
|
4
|
+
import { inheritedParentModel } from "../../agents/child-model-seat.js";
|
|
4
5
|
import { CROSS_SESSION_CLASSIFIER_RULE } from "../../agents/cross-session-envelope.js";
|
|
5
6
|
import { createRunWorkflowTool } from "../../orchestration/run-workflow-tool.js";
|
|
6
7
|
import { isSelfOrchestrationActive } from "../../orchestration/workflow-script-runner.js";
|
|
@@ -287,7 +288,14 @@ export async function prepareCapsAndWorkflow(input) {
|
|
|
287
288
|
taskOwner: hostTaskId,
|
|
288
289
|
limits: deps.workflowLimits,
|
|
289
290
|
sourceTaskId: hostTaskId,
|
|
290
|
-
parentModel: () =>
|
|
291
|
+
parentModel: () => {
|
|
292
|
+
const stated = deploymentSubagentTierModel(runnerSelf.agentCatalog);
|
|
293
|
+
if (stated !== undefined)
|
|
294
|
+
return stated;
|
|
295
|
+
const ref = harnessRef.current?.getModelRef();
|
|
296
|
+
const model = inheritedParentModel(ref, runnerSelf.agentCatalog.models);
|
|
297
|
+
return model === undefined ? undefined : { model, ...(typeof ref === "string" ? { modelRef: ref } : {}) };
|
|
298
|
+
},
|
|
291
299
|
...(spec.getApiKeyAndHeaders !== undefined ? { parentGetApiKeyAndHeaders: spec.getApiKeyAndHeaders } : {}),
|
|
292
300
|
...(frozenOnAsk !== undefined ? { parentOnAsk: frozenOnAsk } : {}),
|
|
293
301
|
...(spec.durableApproval !== undefined ? { parentDurableApproval: { ...spec.durableApproval } } : {}),
|
|
@@ -13,6 +13,7 @@ import { describeRejectedValue } from "../tool-search-setting.js";
|
|
|
13
13
|
import { applyToolModelGate, assertRestoreGatedToolsValue, modelIdTail } from "../tool-model-gate.js";
|
|
14
14
|
import { resolveUsageWindows } from "../usage-window-store.js";
|
|
15
15
|
import { deriveAskEffective, resolveAskSeamForm, resolveQuestionSeam } from "../wiring-manifest.js";
|
|
16
|
+
import { assertPeerPresenceValue } from "../../agents/peer-directory.js";
|
|
16
17
|
import { TOTAL_TOKENS_REMINDER_MODES } from "./turn-attachments.js";
|
|
17
18
|
const TASK_LIMIT_KEY_DICT = {
|
|
18
19
|
maxTokens: true,
|
|
@@ -144,6 +145,7 @@ export function prepareConfigDoors(input) {
|
|
|
144
145
|
const { deps, sessions, resume, internals } = input;
|
|
145
146
|
let spec = input.spec;
|
|
146
147
|
assertNoRetiredRunnerDeps(deps);
|
|
148
|
+
assertPeerPresenceValue(spec.peerPresence);
|
|
147
149
|
assertRestoreGatedToolsValue(spec.restoreGatedTools);
|
|
148
150
|
const microCompactKnob = resolveMicroCompactKnob(deps.microCompact);
|
|
149
151
|
const assertToolNameListValue = (value, seat) => {
|
|
@@ -368,7 +370,8 @@ export function prepareConfigDoors(input) {
|
|
|
368
370
|
}),
|
|
369
371
|
};
|
|
370
372
|
}
|
|
371
|
-
const
|
|
373
|
+
const resolvedRoleRaw = resolveTaskModel(spec, deps);
|
|
374
|
+
const resolvedRole = internals?.inheritedModelRef !== undefined ? { ...resolvedRoleRaw, modelRef: internals.inheritedModelRef } : resolvedRoleRaw;
|
|
372
375
|
const model = resolvedRole.model;
|
|
373
376
|
if (usageWindows !== undefined && deps.usageWindowStore !== undefined) {
|
|
374
377
|
const costed = usageWindows.find((w) => w.maxCostUsd !== undefined);
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
import { type AgentHarness, type AgentMessage } from "../../internal/harness.js";
|
|
19
19
|
import type { Model } from "../../internal/llm.js";
|
|
20
20
|
import { type ClearedProjectionLedger, type MicroCompactMachine, type OccurrenceFingerprint, type OccurrenceIndex } from "../context-edit.js";
|
|
21
|
+
import type { ContextWindowOverlay } from "../context-settings.js";
|
|
21
22
|
import { type ToolResultStore } from "../tool-result-store.js";
|
|
22
23
|
import { type RunnerDeps } from "../types.js";
|
|
23
24
|
import type { Prepared, PreparedMicroCompact } from "./contracts.js";
|
|
@@ -72,13 +73,19 @@ export interface PrepareContextLaneInput {
|
|
|
72
73
|
trimPressureRef: {
|
|
73
74
|
droppedMessages: boolean;
|
|
74
75
|
};
|
|
76
|
+
/** borrowed-readonly — a CALL-TIME getter for the deployment's per-model window overlay in force for this
|
|
77
|
+
* leg ({@link RunnerDeps.contextSettings} keyed by the leg's catalog word). A getter and not a value: this
|
|
78
|
+
* is the one deployment seat an in-flight leg re-reads, and the request-layer frontiers below are asked
|
|
79
|
+
* per request. Absent (a standalone prepare exercise, no Runner behind it) ⇒ no overlay, ever. */
|
|
80
|
+
contextOverlay?: () => ContextWindowOverlay | undefined;
|
|
75
81
|
}
|
|
76
82
|
export interface PrepareContextLaneResult {
|
|
77
83
|
/** owned — the per-run microCompact machine state (`Prepared.microCompact`): machine, MC-R flag, ledger, the projection
|
|
78
84
|
* and in-turn-compaction seats the handler and the runtask arms fill. */
|
|
79
85
|
microCompact: PreparedMicroCompact;
|
|
80
|
-
/** owned — the model's structural coefficient (`charsPerToken ?? DEFAULT`), the
|
|
81
|
-
*
|
|
86
|
+
/** owned — the PREPARE-time model's structural coefficient (`charsPerToken ?? DEFAULT`), the coordinate the
|
|
87
|
+
* prompt-overhead term downstream is computed in. The per-REQUEST defenses read the CURRENT model's
|
|
88
|
+
* instead (`requestGeometry`), beside the window they compare against — one snapshot, one coordinate. */
|
|
82
89
|
charsPerToken: number;
|
|
83
90
|
}
|
|
84
91
|
/** The M21 phase body — prepareTask's context-lane stretch, verbatim (see the module header). */
|
|
@@ -10,14 +10,19 @@ import { applyGitFrameGuard } from "./git-status-frame.js";
|
|
|
10
10
|
import { applyContextShrinkToReadFileState } from "../../tools/fs/index.js";
|
|
11
11
|
export function prepareContextLane(input) {
|
|
12
12
|
const { model, deps, sessionId, runId, hostTaskId, offloadStore, microCompactKnob, harness, batchHaltRef, gitStatusRef, postureFrameRef, requestLossyRef, trimPressureRef, readFileState } = input;
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
13
|
+
const contextOverlay = input.contextOverlay ?? (() => undefined);
|
|
14
|
+
const requestGeometry = () => {
|
|
15
|
+
const current = harness.getModel();
|
|
16
|
+
const overlay = contextOverlay();
|
|
17
|
+
return { editAt: editBudget(current, overlay), guardAt: guardBudget(current, overlay), charsPerToken: current.charsPerToken ?? DEFAULT_CHARS_PER_TOKEN };
|
|
18
|
+
};
|
|
19
|
+
const microCompact = buildMicroCompactState(deps, model, sessionId, runId, offloadStore, microCompactKnob, contextOverlay());
|
|
16
20
|
const charsPerToken = model.charsPerToken ?? DEFAULT_CHARS_PER_TOKEN;
|
|
17
21
|
harness.on("context", async ({ messages, recheck, signal }) => {
|
|
18
22
|
batchHaltRef.current = undefined;
|
|
19
23
|
const pendingProjectionObservations = [];
|
|
20
24
|
try {
|
|
25
|
+
const { editAt, guardAt, charsPerToken: cpt } = requestGeometry();
|
|
21
26
|
const healed = dropEmptyFailureAssistants(messages);
|
|
22
27
|
const replay = replayClearedProjection(healed, microCompact.ledger);
|
|
23
28
|
const replayed = replay.messages;
|
|
@@ -47,8 +52,8 @@ export function prepareContextLane(input) {
|
|
|
47
52
|
budgetTokens: editAt,
|
|
48
53
|
clearSource: replayed,
|
|
49
54
|
onCleared: (pass) => { ccPass = pass; },
|
|
50
|
-
anchoredTotalTokens: estimateContextTokens(mediaCapped,
|
|
51
|
-
charsPerToken,
|
|
55
|
+
anchoredTotalTokens: estimateContextTokens(mediaCapped, cpt).tokens,
|
|
56
|
+
charsPerToken: cpt,
|
|
52
57
|
...(offloadStore
|
|
53
58
|
? {
|
|
54
59
|
offload: {
|
|
@@ -61,7 +66,7 @@ export function prepareContextLane(input) {
|
|
|
61
66
|
recordFrontierClears({ pass: ccPass, index: replay.index, edited, ledger: microCompact.ledger, tracer: deps.tracer, taskId: hostTaskId, trigger: "frontier", ...(readFileState !== undefined ? { readFileState } : {}) });
|
|
62
67
|
}
|
|
63
68
|
const chain = await runGuardChain({
|
|
64
|
-
edited, replayed, index: replay.index, microCompact, guardAt, charsPerToken, offloadStore,
|
|
69
|
+
edited, replayed, index: replay.index, microCompact, guardAt, charsPerToken: cpt, offloadStore,
|
|
65
70
|
sessionId, taskId: hostTaskId, deps, trimPressureRef, recheck, signal,
|
|
66
71
|
pendingProjectionObservations,
|
|
67
72
|
...(readFileState !== undefined ? { readFileState } : {}),
|
|
@@ -76,7 +81,7 @@ export function prepareContextLane(input) {
|
|
|
76
81
|
trimmed,
|
|
77
82
|
budgetTokens: guardAt,
|
|
78
83
|
ref: gitStatusRef,
|
|
79
|
-
charsPerToken,
|
|
84
|
+
charsPerToken: cpt,
|
|
80
85
|
onDegrade: (message) => {
|
|
81
86
|
try {
|
|
82
87
|
deps.onError?.(new Error(message), { phase: "degraded", sessionId, classification: "env-git-snapshot" });
|
|
@@ -86,7 +91,7 @@ export function prepareContextLane(input) {
|
|
|
86
91
|
},
|
|
87
92
|
});
|
|
88
93
|
if (postureFrameRef.protectedText !== undefined) {
|
|
89
|
-
const kept = protectGitFrame(working, trimmed, guardAt, { protectedText: postureFrameRef.protectedText },
|
|
94
|
+
const kept = protectGitFrame(working, trimmed, guardAt, { protectedText: postureFrameRef.protectedText }, cpt);
|
|
90
95
|
if (kept.action === "kept" || kept.action === "reinserted")
|
|
91
96
|
trimmed = kept.messages;
|
|
92
97
|
}
|
|
@@ -119,8 +124,8 @@ export function prepareContextLane(input) {
|
|
|
119
124
|
});
|
|
120
125
|
return { microCompact, charsPerToken };
|
|
121
126
|
}
|
|
122
|
-
function buildMicroCompactState(deps, model, sessionId, runId, offloadStore, knob) {
|
|
123
|
-
const triggerWindow = resolveTriggerWindow(model);
|
|
127
|
+
function buildMicroCompactState(deps, model, sessionId, runId, offloadStore, knob, overlay) {
|
|
128
|
+
const triggerWindow = resolveTriggerWindow(model, overlay);
|
|
124
129
|
if (triggerWindow.clamped) {
|
|
125
130
|
deliverEngineNotice(deps.onNotice, {
|
|
126
131
|
code: "config.autocompact_window_clamped",
|
|
@@ -14,9 +14,9 @@ export interface PrepareDelegationSurfaceInput {
|
|
|
14
14
|
* `handsReadOnly` is NOT read here (the hands mount decided the surface). Never mutated. */
|
|
15
15
|
spec: Pick<TaskSpec, "tools" | "oneShot" | "retainBackgroundProcesses">;
|
|
16
16
|
/** borrowed-readonly — the deployment seats the mounts read: `workflowRunStore` / `backgroundAgentStore` / `mailboxStore` (the
|
|
17
|
-
* read/kill faces and the tier-3 revival seams), `rosterStore`, `
|
|
17
|
+
* read/kill faces and the tier-3 revival seams), `rosterStore`, `peerLane`, `peerDirectory`, `onNotice`,
|
|
18
18
|
* `onBackgroundChildEvent`, `tracer`. */
|
|
19
|
-
deps: Pick<RunnerDeps, "workflowRunStore" | "backgroundAgentStore" | "mailboxStore" | "rosterStore" | "
|
|
19
|
+
deps: Pick<RunnerDeps, "workflowRunStore" | "backgroundAgentStore" | "mailboxStore" | "rosterStore" | "peerLane" | "peerDirectory" | "onNotice" | "onBackgroundChildEvent" | "tracer">;
|
|
20
20
|
/** borrowed-readonly — the trusted spawn-side channel: `parentNotify` (the delegated-child door), the uplink / sibling /
|
|
21
21
|
* identity seats the SendMessage mount forwards, `onTaskNotification`, `onSubagentSpawn`. Never mutated. */
|
|
22
22
|
internals: Pick<RunInternals, "parentNotify" | "parentPeerRef" | "uplinkSessionId" | "parentRetainLedger" | "explicitAgentName" | "parentTaskId" | "parentSessionId" | "peerSelfRef" | "peerInboundChainRef" | "onTaskNotification" | "onSubagentSpawn"> | undefined;
|
|
@@ -52,6 +52,7 @@ export interface PrepareDelegationSurfaceInput {
|
|
|
52
52
|
/** borrowed-mutable — the lane's late-bound facts; the SendMessage mount hands the SAME object to its peer seats (identity is
|
|
53
53
|
* the contract: the wiring station fills `askEffective` later). Not written here. */
|
|
54
54
|
peerLaneRefs: PeerLaneRefs;
|
|
55
|
+
/** borrowed-readonly — the session-box drain's mount judgment (the `ReadInbox` door: a box drained by this leg). */ sessionBox?: import("../task-notification.js").SessionBoxBinding | undefined;
|
|
55
56
|
/** borrowed-mutable — the run's roster builder (`Prepared.tools` is its read face; the writer table is on that field).
|
|
56
57
|
* Writers here: the eight mounts (TaskOutput, TaskStop, SendMessage, AgentTranscript, ListAgents, Monitor, the worktree
|
|
57
58
|
* pair, the offload reader), every one a `mount`. */
|
|
@@ -2,6 +2,8 @@ import { randomBytes } from "node:crypto";
|
|
|
2
2
|
import { createAgentTranscriptTool, AGENT_TRANSCRIPT_TOOL_NAME } from "../../agents/agent-transcript-tool.js";
|
|
3
3
|
import { createSendMessageTool, SEND_MESSAGE_TOOL_NAME } from "../../agents/send-message-tool.js";
|
|
4
4
|
import { listAgentsMountable, mountListAgents, peerLaneSendMessageSeats } from "../../agents/peer-session-drain.js";
|
|
5
|
+
import { resolvePeerLaneConfig } from "../../agents/peer-admission.js";
|
|
6
|
+
import { createReadInboxTool, READ_INBOX_TOOL_NAME } from "../../agents/read-inbox-tool.js";
|
|
5
7
|
import { createMonitorTool } from "../../tools/monitor.js";
|
|
6
8
|
import { createWorktreeTools } from "../../tools/worktree.js";
|
|
7
9
|
import { createTaskOutputTool, createTaskStopTool, defaultTaskRegistry } from "../task-registry.js";
|
|
@@ -30,7 +32,7 @@ function buildTier3ReviveSpawn(delegationForRevive, enrichSpecToolCtx) {
|
|
|
30
32
|
};
|
|
31
33
|
}
|
|
32
34
|
export function prepareDelegationSurface(input) {
|
|
33
|
-
const { spec, deps, internals, resume, sessionId, hostTaskId, taskScope, taskRootFinal, taskRootCanonical, executionEnv, runnerSelf, backgroundTaskToolsActive, workflowToolsActive, peerLaneActive, peerSendMessageBuiltIn, peerLaneRefs, roster, toolEffects, axisExplicitNegatives, envHandToolNames, toolFaceSnapshot, firstPartyOffload, offloadStore, subagentRetain, enrichSpecToolCtx, handsCwdRef, wsSnapshot, rebaseWsPath, rebaseRestoredPath, workspaceStateSettle } = input;
|
|
35
|
+
const { spec, deps, internals, resume, sessionId, hostTaskId, taskScope, taskRootFinal, taskRootCanonical, executionEnv, runnerSelf, backgroundTaskToolsActive, workflowToolsActive, peerLaneActive, peerSendMessageBuiltIn, peerLaneRefs, sessionBox, roster, toolEffects, axisExplicitNegatives, envHandToolNames, toolFaceSnapshot, firstPartyOffload, offloadStore, subagentRetain, enrichSpecToolCtx, handsCwdRef, wsSnapshot, rebaseWsPath, rebaseRestoredPath, workspaceStateSettle } = input;
|
|
34
36
|
let worktreeSessionRef;
|
|
35
37
|
const delegationSurfaceActive = backgroundTaskToolsActive || workflowToolsActive;
|
|
36
38
|
if (delegationSurfaceActive || internals?.parentNotify !== undefined || peerLaneActive) {
|
|
@@ -63,7 +65,7 @@ export function prepareDelegationSurface(input) {
|
|
|
63
65
|
...(internals?.parentSessionId !== undefined ? { parentSessionId: internals.parentSessionId } : {}),
|
|
64
66
|
enrichCtx: enrichSpecToolCtx,
|
|
65
67
|
...(deps.rosterStore !== undefined ? { roster: deps.rosterStore } : {}),
|
|
66
|
-
...(deps.
|
|
68
|
+
...(deps.peerLane !== undefined ? { lane: deps.peerLane } : {}),
|
|
67
69
|
...(deps.onNotice !== undefined ? { onNotice: deps.onNotice } : {}),
|
|
68
70
|
...(internals?.peerSelfRef !== undefined ? { peerSelf: internals.peerSelfRef } : {}),
|
|
69
71
|
...(internals?.peerInboundChainRef !== undefined ? { peerInbound: internals.peerInboundChainRef } : {}),
|
|
@@ -97,7 +99,11 @@ export function prepareDelegationSurface(input) {
|
|
|
97
99
|
}
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
|
-
|
|
102
|
+
if (sessionBox !== undefined && internals?.onTaskNotification !== undefined && !(toolFaceSnapshot.exclude ?? []).includes(READ_INBOX_TOOL_NAME) && !(spec.tools ?? []).some((t) => t.name === READ_INBOX_TOOL_NAME)) {
|
|
103
|
+
toolEffects.set(READ_INBOX_TOOL_NAME, "read");
|
|
104
|
+
roster.mount(firstPartyOffload(createReadInboxTool({ pull: () => peerLaneRefs.pull })), { source: "builtin", mountedBy: "peerLane" });
|
|
105
|
+
}
|
|
106
|
+
const listAgents = (peerLaneActive || delegationSurfaceActive) && peerSendMessageBuiltIn && listAgentsMountable({ exclude: toolFaceSnapshot.exclude, specTools: spec.tools ?? [] }) ? mountListAgents({ ...(peerLaneActive ? { peerDirectory: deps.peerDirectory } : {}), freshWindowMs: resolvePeerLaneConfig(deps.peerLane, deps.onNotice).listingFreshWindowMs, sessionId, scope: taskScope, hostTaskId, ...(internals?.parentTaskId !== undefined ? { parentTaskId: internals.parentTaskId } : {}), ...(internals?.parentSessionId !== undefined ? { parentSessionId: internals.parentSessionId } : {}), registry: defaultTaskRegistry, ...(deps.rosterStore !== undefined ? { roster: deps.rosterStore } : {}), specTools: spec.tools ?? [], toolEffects }) : undefined;
|
|
101
107
|
if (listAgents !== undefined)
|
|
102
108
|
roster.mount(firstPartyOffload(listAgents), { source: "builtin", mountedBy: "peerLane" });
|
|
103
109
|
if (backgroundTaskToolsActive) {
|
|
@@ -10,7 +10,8 @@ export async function prepareFileHistory(input) {
|
|
|
10
10
|
e.code = "config.invalid_on_track_failure";
|
|
11
11
|
throw e;
|
|
12
12
|
}
|
|
13
|
-
const
|
|
13
|
+
const wiredSeat = resolveWiredFileHistoryStore(deps.fileHistoryStore);
|
|
14
|
+
const fileHistoryStore = wiredSeat === "disabled" ? undefined : wiredSeat;
|
|
14
15
|
const legacyRewindFiles = spec.rewindFiles;
|
|
15
16
|
if (legacyRewindFiles === true) {
|
|
16
17
|
if (spec.resumeAt !== undefined) {
|
|
@@ -43,12 +44,13 @@ export async function prepareFileHistory(input) {
|
|
|
43
44
|
});
|
|
44
45
|
}
|
|
45
46
|
const fileHistoryEnabled = fileHistoryStore !== undefined && handsEnabled;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
const livenessArm = fileHistoryStore === undefined ? "file-history-no-store" : "file-history-no-env";
|
|
48
|
+
if (!fileHistoryEnabled && wiredSeat !== "disabled" && (handsEnabled || fileHistoryStore !== undefined) && deps.onError !== undefined && !toldAlready(deps.onError, livenessArm)) {
|
|
49
|
+
const reason = livenessArm === "file-history-no-store"
|
|
50
|
+
? `this deployment wired no RunnerDeps.fileHistoryStore, so NOTHING is recorded: no first-touch snapshot before an edit, no turn boundary, and a later restoreFiles / rewindFilesTo has nothing to restore from and will refuse (rewind.store_unconfigured). Supply a store, or accept an unrecoverable working tree knowingly (fileHistoryStore: "disabled" says so and silences this line)`
|
|
49
51
|
: `RunnerDeps.fileHistoryStore is wired but this run mounts no filesystem-capable ExecutionEnv, so the store is INERT: there is no working tree to snapshot and nothing will ever be written to it. Wire RunnerDeps.executionEnv, or drop the store from this deployment shape`;
|
|
50
52
|
try {
|
|
51
|
-
deps.onError(new Error(`file history is not live for this run — ${reason}.`), { phase: "config", sessionId });
|
|
53
|
+
deps.onError(new Error(`file history is not live for this run — ${reason}.`), { phase: "config", sessionId, classification: livenessArm });
|
|
52
54
|
}
|
|
53
55
|
catch {
|
|
54
56
|
}
|
|
@@ -180,8 +182,8 @@ function restoredAbsPathsOf(restored, root) {
|
|
|
180
182
|
return out;
|
|
181
183
|
}
|
|
182
184
|
function resolveWiredFileHistoryStore(candidate) {
|
|
183
|
-
if (candidate === undefined)
|
|
184
|
-
return
|
|
185
|
+
if (candidate === undefined || candidate === "disabled")
|
|
186
|
+
return candidate;
|
|
185
187
|
const verbs = ["trackEdit", "annulTrack", "snapshot", "restore", "canRestore", "reap", "adoptScope"];
|
|
186
188
|
const verbOf = (v) => {
|
|
187
189
|
try {
|
|
@@ -195,7 +197,7 @@ function resolveWiredFileHistoryStore(candidate) {
|
|
|
195
197
|
const missing = probeable ? verbs.filter((v) => typeof verbOf(v) !== "function") : [...verbs];
|
|
196
198
|
if (missing.length > 0) {
|
|
197
199
|
const shape = candidate === null ? "null" : probeable ? "a value that is not a FileHistoryStore" : `a ${typeof candidate}`;
|
|
198
|
-
const e = new Error(`RunnerDeps.fileHistoryStore was wired with ${shape} — missing contract verbs: ${missing.join(", ")}. Refusing prepare rather than half-wiring the rewind seat (a present-but-unusable store makes every Edit/Write/NotebookEdit fail its first-touch backup while restore requests report "no store wired").
|
|
200
|
+
const e = new Error(`RunnerDeps.fileHistoryStore was wired with ${shape} — missing contract verbs: ${missing.join(", ")}. Refusing prepare rather than half-wiring the rewind seat (a present-but-unusable store makes every Edit/Write/NotebookEdit fail its first-touch backup while restore requests report "no store wired"). Write "disabled" (or omit the key) to run without file history.`);
|
|
199
201
|
e.code = "config.invalid_file_history_store";
|
|
200
202
|
throw e;
|
|
201
203
|
}
|
|
@@ -36,6 +36,7 @@ import type { CwdRef } from "../../tools/fs/fs-shared.js";
|
|
|
36
36
|
import type { AskLane, IrreversibilityTier, ParkAsk, Prepared, ReversibilityProbes, StopForDenialLimit } from "./contracts.js";
|
|
37
37
|
import type { PermissionRuleLanes } from "./permission-rule-lanes.js";
|
|
38
38
|
import { type ToolRosterDeltaSeat } from "../tool-roster.js";
|
|
39
|
+
import { type FrameSettlement } from "../frame-settlement.js";
|
|
39
40
|
/**
|
|
40
41
|
* The parent-thread human-rejection boundary — judged ONCE here, from the pass's own record (CC parity:
|
|
41
42
|
* the reference CLI's reject path aborts exactly when there is no feedback and the run is not a
|
|
@@ -201,6 +202,9 @@ export interface PrepareGateStationsInput {
|
|
|
201
202
|
};
|
|
202
203
|
/** borrowed-readonly — the own hook-crash reporter (an expired post seat is reported through it). */
|
|
203
204
|
notifyOwnHookCrash: (err: unknown) => void;
|
|
205
|
+
/** borrowed-mutable — the leg's settlement seam. Writer here: the `tool_result` station marks a carrier whose output
|
|
206
|
+
* a host hook rewrote (`noteHostRewrite`), so a frame the rewrite removed settles as the host's decision. */
|
|
207
|
+
frameSettlement: FrameSettlement;
|
|
204
208
|
}
|
|
205
209
|
export interface PrepareGateStationsResult {
|
|
206
210
|
/** owned — whether the `tool_call` station registered (the arming predicate's value; observation seat only). */
|
|
@@ -9,6 +9,7 @@ import { deliverEngineNotice } from "../engine-notice.js";
|
|
|
9
9
|
import { askUnresolvableNotice } from "../ask-unresolvable-notice.js";
|
|
10
10
|
import { PATH_CONFINABLE_WRITE_TOOLS } from "./session-rule-policy.js";
|
|
11
11
|
import { toolCallFaceOf } from "../tool-roster.js";
|
|
12
|
+
import { noteHostRewrite } from "../frame-settlement.js";
|
|
12
13
|
function screenGateResult(result) {
|
|
13
14
|
if (result.suspend !== undefined)
|
|
14
15
|
return { defects: [] };
|
|
@@ -41,7 +42,7 @@ export function maybeHumanRejectionHalt(input) {
|
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
44
|
export function prepareGateStations(input) {
|
|
44
|
-
const { askLane, parkAsk, tools, toolRosterDeltas, toolEffects, deps, toolCallGateArmedRef, effectivePolicy, hooks, egressTools, irreversibleTools, spec, complianceDenies, harness, blockedToolCalls, inheritedAskGrants, inheritedUnavailableAsks, foldAskClasses, ancestorSandboxAdmissions, preToolContexts, gateOutcomes, batchHaltRef, blockedTracked, hookIdentity, reminderMark, planModeRef, hostTaskId, sessionId, ownGatePreToolUse, hookTimeoutMs, handsCwdRef, hookEnvFace, writeProtectionCheck, shellReadCheck, irreversibilityTier, reversibilityProbes, abortController, shellGatedTools, autoModeDecider, autoModeDenialTracking, stopForDenialLimit, permissionRuleLane, permissionRuleOrgLane, questionToolMounted, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, delegation, notifyOwnHookCrash } = input;
|
|
45
|
+
const { askLane, parkAsk, tools, toolRosterDeltas, toolEffects, deps, toolCallGateArmedRef, effectivePolicy, hooks, egressTools, irreversibleTools, spec, complianceDenies, harness, blockedToolCalls, inheritedAskGrants, inheritedUnavailableAsks, foldAskClasses, ancestorSandboxAdmissions, preToolContexts, gateOutcomes, batchHaltRef, blockedTracked, hookIdentity, reminderMark, planModeRef, hostTaskId, sessionId, ownGatePreToolUse, hookTimeoutMs, handsCwdRef, hookEnvFace, writeProtectionCheck, shellReadCheck, irreversibilityTier, reversibilityProbes, abortController, shellGatedTools, autoModeDecider, autoModeDenialTracking, stopForDenialLimit, permissionRuleLane, permissionRuleOrgLane, questionToolMounted, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, delegation, notifyOwnHookCrash, frameSettlement } = input;
|
|
45
46
|
if (askLane !== undefined && parkAsk !== undefined) {
|
|
46
47
|
const { adjudicate, resolveAskBound, notifyPermissionDenied, notifyHookError } = askLane;
|
|
47
48
|
const { resolveContentAsk, suspendAsk } = parkAsk;
|
|
@@ -261,6 +262,7 @@ export function prepareGateStations(input) {
|
|
|
261
262
|
if (patch?.updatedOutput) {
|
|
262
263
|
content = patch.updatedOutput;
|
|
263
264
|
changed = true;
|
|
265
|
+
noteHostRewrite(frameSettlement, e.toolCallId);
|
|
264
266
|
}
|
|
265
267
|
if (patch?.additionalContext) {
|
|
266
268
|
content = [...content, { type: "text", text: formatHookFeedback(patch.additionalContext, reminderMark) }];
|
|
@@ -194,6 +194,7 @@ export function prepareInheritedGate(input) {
|
|
|
194
194
|
delegationEntryCaps: delegationEntryCapsResolved,
|
|
195
195
|
reportUsage,
|
|
196
196
|
model: harnessRef.current?.getModel(),
|
|
197
|
+
modelRef: harnessRef.current?.getModelRef(),
|
|
197
198
|
thinkingLevel: harnessRef.current?.getThinkingLevel(),
|
|
198
199
|
principal: spec.principal,
|
|
199
200
|
...(frozenOnAsk !== undefined ? { onAsk: frozenOnAsk } : {}),
|
|
@@ -30,6 +30,7 @@ import type { RunnerDeps, TaskSpec } from "../types.js";
|
|
|
30
30
|
import type { PrepareResume, PromptFeatureFlags, RunInternals, ToolFaceSnapshot } from "./contracts.js";
|
|
31
31
|
import type { AdvertisedWritableDirs } from "./advertised-writable-dirs.js";
|
|
32
32
|
import { type GitStatusLaneRef } from "./git-status-frame.js";
|
|
33
|
+
import { type ContextWindowOverlay } from "../context-settings.js";
|
|
33
34
|
export interface PreparePromptInputsInput {
|
|
34
35
|
/** borrowed-readonly — the REBOUND spec (`spec′`). Read: `promptProvider`, `hooks` (flag), `systemPrompt`
|
|
35
36
|
* / `appendSystemPrompt` (the user prompt sources), `clientContext` (zone, email), `envFacts` (the
|
|
@@ -98,6 +99,11 @@ export interface PreparePromptInputsInput {
|
|
|
98
99
|
advertisedWritableDirs?: AdvertisedWritableDirs;
|
|
99
100
|
/** borrowed-readonly — the acquired session's id (operator-line context). */
|
|
100
101
|
sessionId: string;
|
|
102
|
+
/** borrowed-readonly — the deployment's window overlay for this leg, as it reads at PREPARE. The prompt's
|
|
103
|
+
* context-management sentence must not claim mid-task summarization a deployment has turned off for this
|
|
104
|
+
* model; the seat is live, so a later swap's effect on the SENTENCE lands at the next prepare while its
|
|
105
|
+
* effect on the BEHAVIOR lands at the next boundary — stated, not sworn away. */
|
|
106
|
+
contextOverlay?: ContextWindowOverlay;
|
|
101
107
|
}
|
|
102
108
|
export interface PreparePromptInputsResult {
|
|
103
109
|
/** owned — the prompt provider in force (`spec` ?? `deps` ?? the default). */
|
|
@@ -3,6 +3,7 @@ import { isIsolated } from "../remote-env.js";
|
|
|
3
3
|
import { probeGitStatusLane } from "./git-status-frame.js";
|
|
4
4
|
import { fenceMcpServerInstructions } from "./turn-attachments.js";
|
|
5
5
|
const ULTRA_REASONING_TIERS = new Set(["xhigh", "max"]);
|
|
6
|
+
import { compactionEnabled } from "../context-settings.js";
|
|
6
7
|
export async function preparePromptInputs(input) {
|
|
7
8
|
const { spec, deps, failClosedReason, lockedPreflight, selfOrchestrationActive, executionEnv, reminderMark, resolvedReadFace, resolvedWriteFace, toolFaceSnapshot, promptProfile, fableMitigations, internals, thinking, ownedEnv, delegation, resolvedRole, mcp, model, externalContentTargetActive, resume, handsEnabled, taskRootFinal, additionalRootsCanonical, additionalReadRootsCanonical, sessionId, advertisedWritableDirs } = input;
|
|
8
9
|
const provider = spec.promptProvider ?? deps.promptProvider ?? defaultPromptProvider;
|
|
@@ -26,7 +27,7 @@ export async function preparePromptInputs(input) {
|
|
|
26
27
|
goalEnabled: internals?.goalMode === true,
|
|
27
28
|
awarenessEnabled: thinking !== undefined && ULTRA_REASONING_TIERS.has(thinking),
|
|
28
29
|
worktreeIsolated: internals?.isolation === "worktree" && ownedEnv !== undefined,
|
|
29
|
-
withinTaskCompactionEnabled: (spec.compaction?.enabled
|
|
30
|
+
withinTaskCompactionEnabled: compactionEnabled(spec.compaction?.enabled, input.contextOverlay) && (spec.compaction?.withinTask ?? true),
|
|
30
31
|
isSubagent: delegation.isNonForkChild,
|
|
31
32
|
};
|
|
32
33
|
const userSystemPrompt = spec.systemPrompt ?? resolvedRole.systemPrompt ?? internals?.defaultSystemPrompt;
|