@sema-agent/core 7.69.0 → 7.69.1
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 +583 -0
- package/dist/agents/repair-loop.js +6 -14
- package/dist/agents/subagent.js +2 -1
- package/dist/agents/verify.d.ts +1 -1
- package/dist/agents/verify.js +7 -1
- package/dist/brain/reasoning-request.d.ts +7 -0
- package/dist/brain/reasoning-request.js +6 -0
- package/dist/core/agent-config-dir.d.ts +39 -3
- package/dist/core/agent-config-dir.js +67 -11
- package/dist/core/allow-entry.d.ts +5 -5
- package/dist/core/allow-entry.js +12 -6
- package/dist/core/ask-headline.d.ts +2 -2
- package/dist/core/ask-origin.d.ts +31 -31
- package/dist/core/ask-origin.js +20 -13
- package/dist/core/attachment-source.d.ts +1 -1
- package/dist/core/attachment-source.js +1 -0
- package/dist/core/auto-compaction.d.ts +44 -62
- package/dist/core/auto-compaction.js +44 -103
- package/dist/core/cache-break-detector.d.ts +23 -11
- package/dist/core/cache-break-detector.js +11 -5
- package/dist/core/checkpoint-features.d.ts +1 -1
- package/dist/core/checkpoint-features.js +1 -1
- package/dist/core/checkpoint-requirements.d.ts +19 -1
- package/dist/core/checkpoint-requirements.js +6 -0
- package/dist/core/checkpoint-row-verdict.js +3 -0
- package/dist/core/checkpoint-store.d.ts +13 -2
- package/dist/core/child-clamp-seats.d.ts +30 -3
- package/dist/core/child-clamp-seats.js +24 -0
- package/dist/core/compaction-retired-members.d.ts +12 -0
- package/dist/core/compaction-retired-members.js +22 -0
- package/dist/core/config-refusal-codes.d.ts +1 -1
- package/dist/core/config-refusal-codes.js +2 -0
- package/dist/core/context-edit.d.ts +32 -17
- package/dist/core/context-edit.js +28 -0
- package/dist/core/cron.d.ts +68 -0
- package/dist/core/cron.js +259 -0
- package/dist/core/engine-attestation.d.ts +16 -0
- package/dist/core/engine-attestation.js +2 -0
- package/dist/core/engine-capabilities.d.ts +14 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +18 -7
- package/dist/core/engine-version.js +1 -1
- package/dist/core/gate-outcome.d.ts +29 -2
- package/dist/core/gate-outcome.js +6 -0
- package/dist/core/git-read-only.d.ts +10 -0
- package/dist/core/git-read-only.js +1 -0
- package/dist/core/git-worktree-env.js +9 -8
- package/dist/core/governance-codes.d.ts +9 -2
- package/dist/core/governance-codes.js +9 -0
- package/dist/core/locked-config.js +7 -3
- package/dist/core/lsp.d.ts +3 -0
- package/dist/core/lsp.js +3 -2
- package/dist/core/memory-engine/engine.d.ts +48 -12
- package/dist/core/memory-engine/engine.js +108 -46
- package/dist/core/memory-engine/file-backend.d.ts +2 -1
- package/dist/core/memory-engine/index-copies.d.ts +47 -0
- package/dist/core/memory-engine/index-copies.js +88 -0
- package/dist/core/memory-engine/layout.d.ts +20 -3
- package/dist/core/memory-engine/layout.js +39 -3
- package/dist/core/memory-engine/origin-clearance.d.ts +9 -7
- package/dist/core/memory-engine/origin-clearance.js +2 -4
- package/dist/core/memory-engine/types.d.ts +16 -3
- package/dist/core/mode-policy.d.ts +7 -1
- package/dist/core/mode-policy.js +9 -0
- package/dist/core/mods/session-compact.js +3 -3
- package/dist/core/mods/stations.d.ts +2 -0
- package/dist/core/mods/stations.js +2 -1
- package/dist/core/path-guard-rows.d.ts +8 -3
- package/dist/core/path-guard-rows.js +18 -5
- package/dist/core/peer-seat.d.ts +3 -0
- package/dist/core/peer-seat.js +3 -0
- package/dist/core/permission-rule-model.js +3 -2
- package/dist/core/process-identity.d.ts +11 -3
- package/dist/core/process-identity.js +26 -16
- package/dist/core/runner/assemble-result.d.ts +5 -0
- package/dist/core/runner/assemble-result.js +1 -1
- package/dist/core/runner/cleared-results-record.d.ts +33 -0
- package/dist/core/runner/cleared-results-record.js +56 -0
- package/dist/core/runner/compact-session.js +14 -9
- package/dist/core/runner/compaction-knobs.d.ts +1 -1
- package/dist/core/runner/continuation-gate.js +2 -1
- package/dist/core/runner/continues-from.d.ts +1 -1
- package/dist/core/runner/continues-from.js +1 -1
- package/dist/core/runner/contracts.d.ts +83 -31
- package/dist/core/runner/conversation-segment.d.ts +19 -12
- package/dist/core/runner/conversation-segment.js +27 -7
- package/dist/core/runner/derived-route-fallback.d.ts +2 -12
- package/dist/core/runner/derived-route-fallback.js +0 -6
- package/dist/core/runner/gate-exit.d.ts +2 -1
- package/dist/core/runner/gate-exit.js +4 -2
- package/dist/core/runner/git-status-frame.d.ts +2 -2
- package/dist/core/runner/git-status-frame.js +2 -1
- package/dist/core/runner/initial-run-state.js +1 -1
- package/dist/core/runner/leg-caller-places.d.ts +39 -0
- package/dist/core/runner/leg-caller-places.js +23 -0
- package/dist/core/runner/leg-frame.d.ts +8 -2
- package/dist/core/runner/leg-receipt.d.ts +29 -2
- package/dist/core/runner/leg-receipt.js +37 -6
- package/dist/core/runner/media-removed-seat.d.ts +10 -6
- package/dist/core/runner/media-removed-seat.js +6 -3
- package/dist/core/runner/messages-omitted-seat.d.ts +2 -1
- package/dist/core/runner/messages-omitted-seat.js +15 -5
- package/dist/core/runner/person-path-rows.d.ts +25 -7
- package/dist/core/runner/person-path-rows.js +16 -2
- package/dist/core/runner/prefix-ledger.d.ts +120 -0
- package/dist/core/runner/prefix-ledger.js +176 -0
- package/dist/core/runner/prepare-advisor.d.ts +2 -0
- package/dist/core/runner/prepare-advisor.js +2 -1
- package/dist/core/runner/prepare-artifact.d.ts +3 -0
- package/dist/core/runner/prepare-artifact.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +2 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
- package/dist/core/runner/prepare-config-doors.d.ts +9 -8
- package/dist/core/runner/prepare-config-doors.js +15 -12
- package/dist/core/runner/prepare-context-lane.d.ts +25 -6
- package/dist/core/runner/prepare-context-lane.js +82 -27
- package/dist/core/runner/prepare-gate-stations.d.ts +1 -2
- package/dist/core/runner/prepare-gate-stations.js +2 -4
- package/dist/core/runner/prepare-hands-readface.d.ts +18 -5
- package/dist/core/runner/prepare-hands-readface.js +41 -22
- package/dist/core/runner/prepare-inherited-gate.d.ts +5 -0
- package/dist/core/runner/prepare-inherited-gate.js +2 -0
- package/dist/core/runner/prepare-memory.d.ts +10 -2
- package/dist/core/runner/prepare-memory.js +51 -5
- package/dist/core/runner/prepare-policy-chain.d.ts +3 -0
- package/dist/core/runner/prepare-policy-chain.js +13 -2
- package/dist/core/runner/prepare-prompt-assembly.d.ts +12 -4
- package/dist/core/runner/prepare-prompt-assembly.js +10 -4
- package/dist/core/runner/prepare-prompt-inputs.d.ts +3 -7
- package/dist/core/runner/prepare-prompt-inputs.js +6 -7
- package/dist/core/runner/prepare-safety-scan.js +7 -0
- package/dist/core/runner/prepare-suspend-saga.d.ts +4 -0
- package/dist/core/runner/prepare-suspend-saga.js +3 -2
- package/dist/core/runner/prepare-task.js +59 -53
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +5 -11
- package/dist/core/runner/prepare-tool-disclosure-mount.js +7 -8
- package/dist/core/runner/prepare-turn-wiring.d.ts +16 -25
- package/dist/core/runner/prepare-turn-wiring.js +8 -18
- package/dist/core/runner/prepare-wiring-manifest.d.ts +1 -0
- package/dist/core/runner/prepare-wiring-manifest.js +3 -2
- package/dist/core/runner/prompt-suggestions.d.ts +3 -1
- package/dist/core/runner/prompt-suggestions.js +1 -1
- package/dist/core/runner/read-block-judge.d.ts +47 -0
- package/dist/core/runner/read-block-judge.js +33 -0
- package/dist/core/runner/role-resolution-table.d.ts +15 -10
- package/dist/core/runner/role-resolution-table.js +4 -5
- package/dist/core/runner/rule-store-unreadable-notice.d.ts +7 -4
- package/dist/core/runner/rule-store-unreadable-notice.js +4 -3
- package/dist/core/runner/run-compaction-machinery.d.ts +0 -10
- package/dist/core/runner/run-compaction-machinery.js +3 -39
- package/dist/core/runner/run-harness-handlers.js +4 -17
- package/dist/core/runner/run-identity-wiring.js +4 -1
- package/dist/core/runner/run-leg.js +11 -1
- package/dist/core/runner/run-recovery-lanes.d.ts +0 -4
- package/dist/core/runner/run-recovery-lanes.js +34 -18
- package/dist/core/runner/run-settle-and-teardown.d.ts +1 -3
- package/dist/core/runner/run-settle-and-teardown.js +14 -22
- package/dist/core/runner/run-telemetry-and-budget-seats.js +0 -1
- package/dist/core/runner/run-terminal-adoption.d.ts +11 -30
- package/dist/core/runner/run-terminal-adoption.js +5 -88
- package/dist/core/runner/run-tool-mount-facts.js +1 -5
- package/dist/core/runner/run-turn-boundary.js +56 -26
- package/dist/core/runner/runtask.js +7 -7
- package/dist/core/runner/session-hash-salt.d.ts +18 -0
- package/dist/core/runner/session-hash-salt.js +36 -0
- package/dist/core/runner/shell-env-withheld.d.ts +8 -5
- package/dist/core/runner/shell-env-withheld.js +3 -3
- package/dist/core/runner/side-call-account.d.ts +9 -1
- package/dist/core/runner/side-call-account.js +15 -4
- package/dist/core/runner/skill-mention.d.ts +12 -0
- package/dist/core/runner/skill-mention.js +50 -0
- package/dist/core/runner/stream-settle-backstop.js +1 -0
- package/dist/core/runner/synthetic-tools.js +2 -2
- package/dist/core/runner/tool-table-view.d.ts +5 -9
- package/dist/core/runner/tool-table-view.js +23 -21
- package/dist/core/runner/write-protection-station.d.ts +5 -2
- package/dist/core/runner/write-protection-station.js +1 -1
- package/dist/core/runner-deps.d.ts +25 -27
- package/dist/core/scheduler.d.ts +13 -3
- package/dist/core/scheduler.js +0 -12
- package/dist/core/secret-env.d.ts +47 -11
- package/dist/core/secret-env.js +65 -4
- package/dist/core/sensitive-path-policy.js +4 -0
- package/dist/core/session-checkout.js +10 -9
- package/dist/core/shell-read-silence.d.ts +2 -1
- package/dist/core/shell-run-candidates.d.ts +1 -1
- package/dist/core/shell-run-candidates.js +11 -3
- package/dist/core/task-event.d.ts +32 -10
- package/dist/core/task-intake.d.ts +5 -3
- package/dist/core/task-intake.js +6 -2
- package/dist/core/task-result.d.ts +39 -0
- package/dist/core/task-spec-members.d.ts +3 -0
- package/dist/core/task-spec-members.js +2 -2
- package/dist/core/task-spec.d.ts +37 -20
- package/dist/core/tool-policy.d.ts +30 -18
- package/dist/core/tool-policy.js +44 -32
- package/dist/core/tool-roster.d.ts +21 -7
- package/dist/core/tool-roster.js +34 -6
- package/dist/core/tool-spec-members.js +1 -1
- package/dist/core/tool-spec.d.ts +27 -0
- package/dist/core/tools.js +1 -0
- package/dist/core/trace.d.ts +42 -19
- package/dist/core/unc-spelling.d.ts +31 -0
- package/dist/core/unc-spelling.js +51 -0
- package/dist/core/wiring-manifest.d.ts +30 -3
- package/dist/core/wiring-manifest.js +10 -0
- package/dist/core/workflow-run-store-contract.js +22 -0
- package/dist/core/workflow-run-store.d.ts +17 -13
- package/dist/core/workflow-run-store.js +1 -1
- package/dist/core/write-protect.d.ts +4 -0
- package/dist/core/write-protect.js +17 -15
- package/dist/engine/compaction/compaction.d.ts +48 -98
- package/dist/engine/compaction/compaction.js +136 -216
- package/dist/engine/compaction/utils.d.ts +2 -11
- package/dist/engine/compaction/utils.js +4 -13
- package/dist/engine/execution-env/node-execution-env.js +17 -6
- package/dist/engine/harness/agent-harness.d.ts +19 -5
- package/dist/engine/harness/agent-harness.js +18 -7
- package/dist/engine/harness/types.d.ts +5 -7
- package/dist/engine/loop/agent-loop.d.ts +14 -1
- package/dist/engine/loop/agent-loop.js +31 -11
- package/dist/engine/loop/types.d.ts +8 -2
- package/dist/index.d.ts +9 -6
- package/dist/index.js +8 -6
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +1 -1
- package/dist/internal/harness.js +1 -1
- package/dist/orchestration/run-spec.js +7 -2
- package/dist/orchestration/run-workflow-tool.js +5 -3
- package/dist/orchestration/workflow-park-adoption.d.ts +66 -8
- package/dist/orchestration/workflow-park-adoption.js +195 -45
- package/dist/orchestration/workflow-types.d.ts +20 -0
- package/dist/orchestration/workflow-types.js +1 -0
- package/dist/orchestration/workflow.d.ts +3 -2
- package/dist/orchestration/workflow.js +10 -4
- package/dist/prompt-assembly/catalog/core-behavior.js +6 -0
- package/dist/prompt-assembly/catalog/events.d.ts +8 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.js +6 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/mechanism.js +1 -0
- package/dist/prompt-assembly/catalog/mechanism.d.ts +8 -0
- package/dist/prompt-assembly/catalog/mechanism.js +1 -0
- package/dist/prompt-assembly/catalog/schema.d.ts +1 -1
- package/dist/prompt-assembly/catalog/schema.js +1 -0
- package/dist/prompt-assembly/catalog/sections.js +8 -0
- package/dist/prompt-assembly/event-registry.js +1 -0
- package/dist/prompt-assembly/select.js +1 -0
- package/dist/prompt-assembly/turn-snapshot.d.ts +14 -27
- package/dist/prompt-assembly/turn-snapshot.js +6 -18
- package/dist/prompt-assembly/types.d.ts +3 -0
- package/dist/prompts/default.d.ts +9 -0
- package/dist/prompts/default.js +4 -0
- package/dist/shell/lex.d.ts +75 -11
- package/dist/shell/lex.js +340 -76
- package/dist/tools/fs/bash-program-position.js +2 -6
- package/dist/tools/fs/bash-readonly-classifier.d.ts +18 -3
- package/dist/tools/fs/bash-readonly-classifier.js +19 -9
- package/dist/tools/fs/containment-face.d.ts +12 -3
- package/dist/tools/fs/containment-face.js +16 -7
- package/dist/tools/fs/file-read-check.d.ts +26 -1
- package/dist/tools/fs/file-read-check.js +20 -2
- package/dist/tools/fs/fs-bash.js +4 -4
- package/dist/tools/fs/fs-read.d.ts +3 -0
- package/dist/tools/fs/fs-read.js +2 -2
- package/dist/tools/fs/fs-search-tools.d.ts +2 -2
- package/dist/tools/fs/fs-search-tools.js +4 -4
- package/dist/tools/fs/index.js +5 -3
- package/dist/tools/fs/pdf.js +12 -4
- package/dist/tools/fs/read-deny-home.d.ts +13 -2
- package/dist/tools/fs/read-deny-home.js +26 -22
- package/dist/tools/fs/read-deny.js +15 -6
- package/dist/tools/fs/removal-targets.d.ts +33 -17
- package/dist/tools/fs/removal-targets.js +160 -61
- package/dist/tools/fs/repo-map.d.ts +1 -1
- package/dist/tools/fs/repo-map.js +2 -2
- package/dist/tools/fs/safety.d.ts +28 -5
- package/dist/tools/fs/safety.js +72 -8
- package/dist/tools/fs/shell-read-bindings.d.ts +8 -2
- package/dist/tools/fs/shell-read-bindings.js +25 -6
- package/dist/tools/fs/shell-read-check.d.ts +3 -0
- package/dist/tools/fs/shell-read-check.js +22 -4
- package/dist/tools/fs/shell-read-establish.js +73 -43
- package/dist/tools/fs/shell-read-judge.d.ts +32 -14
- package/dist/tools/fs/shell-read-judge.js +13 -5
- package/dist/tools/fs/shell-read-object-path.d.ts +5 -1
- package/dist/tools/fs/shell-read-object-path.js +17 -4
- package/dist/tools/fs/shell-read-plan.d.ts +8 -2
- package/dist/tools/fs/shell-read-plan.js +36 -22
- package/dist/tools/fs/shell-read-sourced.js +12 -4
- package/dist/tools/fs/shell-read-start.d.ts +4 -2
- package/dist/tools/fs/shell-read-start.js +3 -3
- package/dist/tools/fs/shell-read-workdir.d.ts +14 -6
- package/dist/tools/fs/shell-read-workdir.js +35 -17
- package/dist/tools/scheduler-tools.d.ts +7 -17
- package/dist/tools/scheduler-tools.js +9 -85
- package/dist/tools/worktree.js +5 -4
- package/package.json +3 -2
- package/test/export-surface.snapshot.json +47 -1
- package/wire-changes/core-stores-sql@7.68.6.json +39 -0
- package/wire-changes/core-stores-sql@7.69.1.json +39 -0
- package/wire-changes/core@7.68.6.json +125 -0
- package/wire-changes/core@7.69.1.json +2561 -0
- package/wire-changes/mods-kernel@7.68.6.json +39 -0
- package/wire-changes/mods-kernel@7.69.1.json +39 -0
- package/wire-changes/primitives@7.68.6.json +39 -0
- package/wire-changes/primitives@7.69.1.json +39 -0
- package/wire-changes/wiki-gate@7.68.6.json +39 -0
- package/wire-changes/wiki-gate@7.69.1.json +39 -0
- package/dist/core/runner/prompt-hash-salt.d.ts +0 -1
- package/dist/core/runner/prompt-hash-salt.js +0 -2
|
@@ -644,6 +644,16 @@ export interface MemorySessionHandle {
|
|
|
644
644
|
* the gate's whole purpose is keeping those bytes out of the prompt, so a refused clear must not
|
|
645
645
|
* leave the injection path reading them anyway. Absent ⇒ the normal "live file wins" behavior. */
|
|
646
646
|
indexOnDiskUntrusted?: boolean;
|
|
647
|
+
/** What the store withheld and erased as this mount read it BEFORE it read any entry: the ids withheld as challenged
|
|
648
|
+
* (sorted) and the count of erasures the erase door (`MemoryEngine.eraseMemoryEntries`, either lane) has run over the
|
|
649
|
+
* store. A copy of what this handle serves is current only while a later mount reads the same state: whatever is
|
|
650
|
+
* withheld or erased after this read moves the next mount's state. `"unreadable"` ⇔ either could not be read, or the
|
|
651
|
+
* count read lower than one this process read of the store before (the count only goes up) — no copy may stand for it;
|
|
652
|
+
* absent on a handle the engine did not mint, read the same way. */
|
|
653
|
+
storeState?: {
|
|
654
|
+
challenged: readonly string[];
|
|
655
|
+
erasures: number;
|
|
656
|
+
} | "unreadable";
|
|
647
657
|
/**
|
|
648
658
|
* design/336 §3.6 (slice 2) — the session-account OPEN could not be persisted at materialize
|
|
649
659
|
* (control-plane IO): the sticky crash-residue classification for this session never froze, so
|
|
@@ -825,7 +835,9 @@ export interface HarvestReport {
|
|
|
825
835
|
/** False ⇔ the whole harvest was refused (deletion fuse / missing dir / corrupt sidecar incident). */
|
|
826
836
|
ok: boolean;
|
|
827
837
|
/** Set when a fuse tripped (§2.4 删除防线 / B3 fail-closed): the harvest is refused wholesale, NO
|
|
828
|
-
* patches (especially no deletes) are produced, and the report is surfaced as an alert.
|
|
838
|
+
* patches (especially no deletes) are produced, and the report is surfaced as an alert. The
|
|
839
|
+
* deletion fuse (`mass_deletion`) also puts each removed write-face file back from its committed
|
|
840
|
+
* copy (listed in {@link restored}); its `detail` is a plain sentence of counts. */
|
|
829
841
|
incident?: {
|
|
830
842
|
kind: "mass_deletion" | "dir_missing" | "sidecar_corrupt";
|
|
831
843
|
detail: string;
|
|
@@ -865,8 +877,9 @@ export interface HarvestReport {
|
|
|
865
877
|
missing: string[];
|
|
866
878
|
/** Files RESTORED onto disk from the committed copy (backend/shadow), disclosed here (the restore is
|
|
867
879
|
* an engine action, never silent): a read-only layer's edited files, and the write-face
|
|
868
|
-
* removals a
|
|
869
|
-
* under the hard gate)
|
|
880
|
+
* removals a harvest did not commit (the deletion fuse; a session that commits nothing; an
|
|
881
|
+
* instruction-form entry under the hard gate) — a removal goes back only where it left nothing
|
|
882
|
+
* or blank bytes. Restored paths also appear in {@link missing} (the honest record of what
|
|
870
883
|
* vanished) — EXCEPT the design/336 §4 hold arm: an UPDATE-form instruction hold captures the
|
|
871
884
|
* session's edit and restores the committed bytes onto the plane seat it vacated (zero-copy: the
|
|
872
885
|
* file is the storage), so those paths appear here beside {@link containment}.heldInstruction,
|
|
@@ -288,8 +288,14 @@ export declare class PermissionModeController {
|
|
|
288
288
|
/** The ceiling's source moved to another leg (the parent session's next leg); `before` is this leg's receipt under the
|
|
289
289
|
* previous one. A ceiling fold the move produced — or changed — is announced, as the construction-time fold is. */
|
|
290
290
|
ceilingRebound(before: PermissionModeReceipt): void;
|
|
291
|
-
/** Bind the deployment's arming facts (once, after the caps resolved); announces a fold-back if one results
|
|
291
|
+
/** Bind the deployment's arming facts (once, after the caps resolved); announces a fold-back if one results, then lets
|
|
292
|
+
* those waiting for the mode to settle ({@link whenArmed}) go. */
|
|
292
293
|
bindArming(arming: PermissionModeArming): PermissionModeReceipt;
|
|
294
|
+
private readonly awaitingArming;
|
|
295
|
+
/** Run `then` once the arming facts are bound — from then on {@link observed} is the mode the leg runs under; before, a word the
|
|
296
|
+
* arming folds back (`auto` with no classifier, a relaxed mode the deployment denies) reads as itself. Now, when they already are.
|
|
297
|
+
* A throw from `then` is contained (a notice seat is host code). */
|
|
298
|
+
whenArmed(then: () => void): void;
|
|
293
299
|
/** A steer: the requested word changes; the arming fold is re-judged; a leg that became `auto` arms its classifier.
|
|
294
300
|
* When that arming fails the steer rejects with the failure, stops counting (the requested word is again the newest
|
|
295
301
|
* steer's that still counts, else the spec's — a failed arming never undoes another steer, and never leaves the leg
|
package/dist/core/mode-policy.js
CHANGED
|
@@ -234,8 +234,17 @@ export class PermissionModeController {
|
|
|
234
234
|
const answer = this.answerOf(false);
|
|
235
235
|
if (answer.receipt.foldedBy !== before.foldedBy)
|
|
236
236
|
this.announce(answer);
|
|
237
|
+
for (const then of this.awaitingArming.splice(0))
|
|
238
|
+
this.faultSeat.notify(then, "permissionMode.whenArmed");
|
|
237
239
|
return answer.receipt;
|
|
238
240
|
}
|
|
241
|
+
awaitingArming = [];
|
|
242
|
+
whenArmed(then) {
|
|
243
|
+
if (this.arming === undefined)
|
|
244
|
+
this.awaitingArming.push(then);
|
|
245
|
+
else
|
|
246
|
+
this.faultSeat.notify(then, "permissionMode.whenArmed");
|
|
247
|
+
}
|
|
239
248
|
async steer(mode) {
|
|
240
249
|
const entry = { word: mode };
|
|
241
250
|
const before = this.declared;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
import {
|
|
2
|
+
import { compactionCutOf } from "../auto-compaction.js";
|
|
3
3
|
import { describeThrown } from "../tool-policy.js";
|
|
4
4
|
import { foreignLine } from "../protocol-http-auth.js";
|
|
5
5
|
import { ENGINE_ORIGIN } from "./kernel/index.js";
|
|
@@ -112,12 +112,12 @@ export function createCompactStation() {
|
|
|
112
112
|
result = await run(station);
|
|
113
113
|
view = outcomeView(result, outcomeOf(result));
|
|
114
114
|
if (handed !== undefined && result.compacted && result.reused !== true) {
|
|
115
|
-
binding.report(new Error(`session.compact: the summary extension "${foreignLine(handed.by, 80)}" handed was not used — this pass could not take a summary in place of its own (
|
|
115
|
+
binding.report(new Error(`session.compact: the summary extension "${foreignLine(handed.by, 80)}" handed was not used — this pass could not take a summary in place of its own (the summary seat's reuse cap), so the model summarized`));
|
|
116
116
|
}
|
|
117
117
|
return result;
|
|
118
118
|
}
|
|
119
119
|
catch (err) {
|
|
120
|
-
view = outcomeView(undefined,
|
|
120
|
+
view = outcomeView(undefined, compactionCutOf(err) === "failed" ? "failed" : "mooted");
|
|
121
121
|
throw err;
|
|
122
122
|
}
|
|
123
123
|
finally {
|
|
@@ -442,6 +442,8 @@ export declare function admitLegMods(input: {
|
|
|
442
442
|
/** What a leg hands {@link legFacadeSeats}: the seats it already has. */
|
|
443
443
|
export interface LegFacadeInput {
|
|
444
444
|
readonly deps: Pick<RunnerDeps, "brain" | "modelFallback" | "cacheRetention" | "models" | "now">;
|
|
445
|
+
/** Reads a mod's model request against the session's main line before it goes out (its `brain.call` row carries the reading). */
|
|
446
|
+
readonly observeSideRequest: import("../runner/prefix-ledger.js").RequestObserver;
|
|
445
447
|
readonly spec: Pick<TaskSpec, "getApiKeyAndHeaders">;
|
|
446
448
|
readonly sessionId: string;
|
|
447
449
|
readonly model: Model;
|
|
@@ -19,6 +19,7 @@ import { modsReportToOnError, registrationRefusedNotice } from "./host.js";
|
|
|
19
19
|
export { listLegModSeats } from "./host.js";
|
|
20
20
|
import { scopedLegBus, skillScopeRecord, standingBus } from "./spec-seats.js";
|
|
21
21
|
import { modelLaneBrainOf } from "../runner/model-lane-seat.js";
|
|
22
|
+
import { observingBrain } from "../runner/prefix-ledger.js";
|
|
22
23
|
export const ENGINE_CORE_ANSWER = Object.freeze({});
|
|
23
24
|
export function engineCore() {
|
|
24
25
|
return ENGINE_CORE_ANSWER;
|
|
@@ -650,7 +651,7 @@ function replyText(reply) {
|
|
|
650
651
|
return reply.content.flatMap((c) => (c.type === "text" ? [c.text] : [])).join("");
|
|
651
652
|
}
|
|
652
653
|
export function legFacadeSeats(input) {
|
|
653
|
-
const runtime = brainToRuntime(modelLaneBrainOf(input.deps));
|
|
654
|
+
const runtime = brainToRuntime(observingBrain(modelLaneBrainOf(input.deps), input.observeSideRequest));
|
|
654
655
|
const answeredBy = new Map();
|
|
655
656
|
const byUsage = new WeakMap();
|
|
656
657
|
return {
|
|
@@ -112,8 +112,13 @@ export declare function guardHitReachClause(via: GuardHitVia): string | undefine
|
|
|
112
112
|
* THE one judgment of guarded rows over a target's views, for every table and every lane: rows outer, views inner — the
|
|
113
113
|
* first row (in the caller's order) that some view reaches is the answer. `tighten` (deny / ask): any present view reaching
|
|
114
114
|
* the row reaches it; a row that cannot be judged (or a target that cannot be read) is held and answered only when no row
|
|
115
|
-
* reaches.
|
|
116
|
-
*
|
|
117
|
-
*
|
|
115
|
+
* reaches. Only where the views answer NOTHING — no row reached, none held — is each view read once more at the drive a
|
|
116
|
+
* drive's administrative share names ({@link localDriveSpellingOf}). `allow`: a row admits the target only when it admits
|
|
117
|
+
* EVERY view (a link out of an allowed directory is not admitted through its spelling); an unreadable target is admitted by
|
|
118
|
+
* nothing. An exemptible row reads each view through the exemption law (the module header).
|
|
118
119
|
*/
|
|
119
120
|
export declare function judgePathRows<R extends GuardRowReach>(rows: readonly R[], views: TargetViews, direction: "tighten" | "allow"): PathRowsHit<R> | undefined;
|
|
121
|
+
/** The tightening judgment ({@link judgePathRows}) of the views as read alone — no drive reading: what a judgment staged over
|
|
122
|
+
* views read one after another answers before the last is in (a row met here stays the answer whatever a later view adds;
|
|
123
|
+
* one met only where a view may lead does not outrank the hold a later view may become). */
|
|
124
|
+
export declare function judgePathRowsAsRead<R extends GuardRowReach>(rows: readonly R[], views: TargetViews): PathRowsHit<R> | undefined;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isDeviceSpelling, localDriveSpellingOf } from "./unc-spelling.js";
|
|
1
2
|
export function viewSpellings(views) {
|
|
2
3
|
const out = [];
|
|
3
4
|
for (const v of views.views)
|
|
@@ -28,6 +29,12 @@ export function judgePathRows(rows, views, direction) {
|
|
|
28
29
|
return { row };
|
|
29
30
|
return undefined;
|
|
30
31
|
}
|
|
32
|
+
return judgePathRowsAsRead(rows, views) ?? tightenOver(rows, views, (view, judged) => (judged === view ? driveReadingOf(view) : []));
|
|
33
|
+
}
|
|
34
|
+
export function judgePathRowsAsRead(rows, views) {
|
|
35
|
+
return tightenOver(rows, views, (_view, judged) => [judged]);
|
|
36
|
+
}
|
|
37
|
+
function tightenOver(rows, views, readingsOf) {
|
|
31
38
|
let held;
|
|
32
39
|
for (const row of rows) {
|
|
33
40
|
if (views.unreadable !== undefined)
|
|
@@ -36,15 +43,21 @@ export function judgePathRows(rows, views, direction) {
|
|
|
36
43
|
const judged = row.exemptible === true ? exemptReading(view, views) : view;
|
|
37
44
|
if (judged === undefined)
|
|
38
45
|
continue;
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
for (const at of readingsOf(view, judged)) {
|
|
47
|
+
const r = row.reach(at);
|
|
48
|
+
if (r.reach === "reached")
|
|
49
|
+
return { row, view: at.path, viewKind: view.kind };
|
|
50
|
+
if (r.reach === "unreadable")
|
|
51
|
+
held ??= { row, unreadable: r.reason };
|
|
52
|
+
}
|
|
44
53
|
}
|
|
45
54
|
}
|
|
46
55
|
return held;
|
|
47
56
|
}
|
|
57
|
+
function driveReadingOf(view) {
|
|
58
|
+
const drive = isDeviceSpelling(view.path) ? undefined : localDriveSpellingOf(view.path);
|
|
59
|
+
return drive === undefined || drive === view.path ? [] : [{ path: drive, kind: view.kind, ...(view.aliasResolved === true ? { aliasResolved: true } : {}) }];
|
|
60
|
+
}
|
|
48
61
|
function exemptReading(view, views) {
|
|
49
62
|
if (views.identityExempt === true && view.kind !== "canonical")
|
|
50
63
|
return undefined;
|
package/dist/core/peer-seat.d.ts
CHANGED
|
@@ -298,6 +298,9 @@ export declare function declaredCredentials(copy: object, at: keyof typeof CREDE
|
|
|
298
298
|
} | {
|
|
299
299
|
readonly problem: string;
|
|
300
300
|
};
|
|
301
|
+
/** The variables of the resolver's environment a reference points at: an `env` reference's `headers` map (header name → variable) and
|
|
302
|
+
* `env` map (child variable → variable), by their values; a reference of any other kind names none the engine can see. */
|
|
303
|
+
export declare function referencedVariables(ref: CredentialRef): string[];
|
|
301
304
|
/** A declaration that names a credential reference while no seat is wired: nobody would answer it (`config.peer_seat_missing`). */
|
|
302
305
|
export declare function peerSeatMissing(subject: string, credentials: CredentialRef | undefined, seat: PeerSeat | undefined): (Error & {
|
|
303
306
|
code: string;
|
package/dist/core/peer-seat.js
CHANGED
|
@@ -553,6 +553,9 @@ export function declaredCredentials(copy, at) {
|
|
|
553
553
|
const p = read.problem;
|
|
554
554
|
return { problem: `${p.reason}${"kind" in p && p.kind !== undefined ? ` (kind ${callerText(p.kind)})` : ""}${"field" in p ? ` at ${JSON.stringify(p.field)}` : ""}` };
|
|
555
555
|
}
|
|
556
|
+
export function referencedVariables(ref) {
|
|
557
|
+
return ref.kind === "env" ? [...Object.values(ref.headers ?? {}), ...Object.values(ref.env ?? {})] : [];
|
|
558
|
+
}
|
|
556
559
|
export function peerSeatMissing(subject, credentials, seat) {
|
|
557
560
|
if (credentials === undefined || seat !== undefined)
|
|
558
561
|
return undefined;
|
|
@@ -13,7 +13,7 @@ import { boundedForeignReading, cutAt } from "./untrusted-egress.js";
|
|
|
13
13
|
import { catalogRuleFaceOf, catalogToolNames, hostTargetOf, isShellFaceToolName, pathTargetOf, protectivePathTargetOf } from "./tool-registry.js";
|
|
14
14
|
import { HOST_UNREADABLE_SENTENCE, hostPatternAdmits, readHostPattern, spelledHostPattern } from "./host-target.js";
|
|
15
15
|
import { heldBy, heldValues, wireOf } from "./tool-name-readings.js";
|
|
16
|
-
import { carriesDotSegment, isAbsoluteForFamily, isIdentityDir, isPathIdentity, isShellRootedSpellingUnmapped, isUncIdentity, pathFamilyOf, pathIdentityOf } from "../tools/fs/safety.js";
|
|
16
|
+
import { carriesDotSegment, isAbsoluteForFamily, isIdentityDir, isPathIdentity, isShellRootedSpellingUnmapped, isUncIdentity, pathFamilyOf, pathIdentityOf, shellDriveSpellingOf } from "../tools/fs/safety.js";
|
|
17
17
|
import { bindPathRules, judgeRuleRows, rowsWhereTheyLead } from "./path-rule-binding.js";
|
|
18
18
|
import { readShellCommand } from "./shell-run-candidates.js";
|
|
19
19
|
import { lineDescriptorsOfText, readOnlyLineObjection, readOnlyShellVerdict } from "./read-only-shell.js";
|
|
@@ -1351,7 +1351,8 @@ function resolveCdSegmentDirectories(segments, cwd) {
|
|
|
1351
1351
|
if (!priorCd && movesShellCursor(segment))
|
|
1352
1352
|
priorCd = true;
|
|
1353
1353
|
const bases = basesOfCwd(cwd);
|
|
1354
|
-
|
|
1354
|
+
const family = pathFamilyOf(bases);
|
|
1355
|
+
return dir === undefined || isShellRootedSpellingUnmapped(family, dir) || shellDriveSpellingOf(family, dir) !== undefined ? undefined : directoryIdentityOf(dir, bases);
|
|
1355
1356
|
});
|
|
1356
1357
|
}
|
|
1357
1358
|
export function scopeCoversCwd(scope, cwd, sessionId, identity) {
|
|
@@ -31,8 +31,12 @@
|
|
|
31
31
|
* See {@link processCensus}.
|
|
32
32
|
*
|
|
33
33
|
* Both are `null` when this host cannot produce a start time (no `ps`, a cut-down `ps` that rejects the
|
|
34
|
-
* query, a probe too slow for its own reading to be worth anything
|
|
35
|
-
*
|
|
34
|
+
* query, a probe too slow for its own reading to be worth anything, a reading no process could have given —
|
|
35
|
+
* a start before the boot or the epoch, or two starts that name no boot a process could have run in). That is
|
|
36
|
+
* a plain "unknown" — never a zero and never a guess — and every reader treats an unobtainable fingerprint as
|
|
37
|
+
* UNFALSIFIABLE. A number is never negative, and the two never contradict each other: a record that carries
|
|
38
|
+
* such starts anyway (written by an engine before this check, or by hand) is read as carrying none
|
|
39
|
+
* ({@link startsOf}).
|
|
36
40
|
*/
|
|
37
41
|
export interface ProcessFingerprint {
|
|
38
42
|
/** The process id the rest of the record is about. */
|
|
@@ -140,7 +144,11 @@ export declare function processFingerprint(pid?: number): ProcessFingerprint;
|
|
|
140
144
|
* clock correction on exactly the platform where the other does not, so one alone never authorises a
|
|
141
145
|
* "gone". The uptime measure has a second way to condemn, a proof rather than a comparison: a start beyond
|
|
142
146
|
* this host's own uptime names a boot that is over. A record and an observation sharing no measure at all
|
|
143
|
-
* are `uncheckable` (`start_time_unknown`); otherwise the process is `running`.
|
|
147
|
+
* are `uncheckable` (`start_time_unknown`); otherwise the process is `running`. A start no process could have
|
|
148
|
+
* had (negative: a reading that wrapped when it was taken) is no measure, and neither is either start of a
|
|
149
|
+
* pair that names no boot a process could have run in ({@link startsOf}: a boot before the epoch, or a boot
|
|
150
|
+
* that is over for a process whose wall start lies inside this one) — a record stuck with such starts is
|
|
151
|
+
* `uncheckable` like a record that carries none, never "started long before you".
|
|
144
152
|
*/
|
|
145
153
|
export declare function processCensus(options?: ProcessCensusOptions): ProcessCensus;
|
|
146
154
|
/**
|
|
@@ -117,10 +117,12 @@ function probeStartTimesOnce(pid) {
|
|
|
117
117
|
return "imprecise";
|
|
118
118
|
const elapsedMs = (Number(parts[1] ?? "0") * 86_400 + Number(parts[2] ?? "0") * 3_600 + Number(parts[3] ?? "0") * 60 + Number(parts[4] ?? "0")) *
|
|
119
119
|
1000;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
const startedAtMs = Math.round((wallBefore - elapsedMs) / 1000) * 1000;
|
|
121
|
+
const startedSinceBootMs = Math.round((uptimeBefore - elapsedMs) / 1000) * 1000;
|
|
122
|
+
const starts = startsOf(startedAtMs, startedSinceBootMs, wallBefore, uptimeBefore);
|
|
123
|
+
if (starts.wall === null || starts.boot === null)
|
|
124
|
+
return "imprecise";
|
|
125
|
+
return { startedAtMs: starts.wall, startedSinceBootMs: starts.boot };
|
|
124
126
|
}
|
|
125
127
|
export function processFingerprint(pid) {
|
|
126
128
|
const host = thisHost();
|
|
@@ -158,7 +160,17 @@ function signalProbe(pid) {
|
|
|
158
160
|
}
|
|
159
161
|
}
|
|
160
162
|
function isMeasure(value) {
|
|
161
|
-
return typeof value === "number" && Number.isFinite(value);
|
|
163
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
164
|
+
}
|
|
165
|
+
const NO_STARTS = Object.freeze({ wall: null, boot: null });
|
|
166
|
+
function startsOf(startedAtMs, startedSinceBootMs, wallNow, uptimeNow) {
|
|
167
|
+
const wall = isMeasure(startedAtMs) ? startedAtMs : null;
|
|
168
|
+
const boot = isMeasure(startedSinceBootMs) ? startedSinceBootMs : null;
|
|
169
|
+
if (wall === null || boot === null)
|
|
170
|
+
return { wall, boot };
|
|
171
|
+
const bootBeforeEpoch = wall - boot < -START_TIME_TOLERANCE_MS;
|
|
172
|
+
const startedInTwoBoots = uptimeNow !== null && boot - uptimeNow > START_TIME_TOLERANCE_MS && wall - (wallNow - uptimeNow) > START_TIME_TOLERANCE_MS;
|
|
173
|
+
return bootBeforeEpoch || startedInTwoBoots ? NO_STARTS : { wall, boot };
|
|
162
174
|
}
|
|
163
175
|
const GONE = Object.freeze({ state: "gone" });
|
|
164
176
|
const RUNNING = Object.freeze({ state: "running" });
|
|
@@ -198,21 +210,19 @@ export function processCensus(options) {
|
|
|
198
210
|
return GONE;
|
|
199
211
|
if (answer === "refused")
|
|
200
212
|
return uncheckable("probe_refused");
|
|
201
|
-
|
|
213
|
+
const wallNow = Date.now();
|
|
214
|
+
const up = uptimeMs();
|
|
215
|
+
const starts = startsOf(record.startedAtMs, record.startedSinceBootMs, wallNow, up);
|
|
216
|
+
if (starts.wall === null && starts.boot === null)
|
|
202
217
|
return uncheckable("start_time_unknown");
|
|
203
218
|
const now = observe(record.pid);
|
|
204
|
-
const falsified = (was, seen) =>
|
|
205
|
-
const bootIsOver =
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
const up = uptimeMs();
|
|
209
|
-
return up !== null && was - up > START_TIME_TOLERANCE_MS;
|
|
210
|
-
};
|
|
211
|
-
const wallSaysGone = falsified(record.startedAtMs, now.startedAtMs);
|
|
212
|
-
const uptimeSaysGone = falsified(record.startedSinceBootMs, now.startedSinceBootMs) || bootIsOver(record.startedSinceBootMs);
|
|
219
|
+
const falsified = (was, seen) => was !== null && seen !== null && seen - was > START_TIME_TOLERANCE_MS;
|
|
220
|
+
const bootIsOver = starts.boot !== null && up !== null && starts.boot - up > START_TIME_TOLERANCE_MS;
|
|
221
|
+
const wallSaysGone = falsified(starts.wall, now.startedAtMs);
|
|
222
|
+
const uptimeSaysGone = falsified(starts.boot, now.startedSinceBootMs) || bootIsOver;
|
|
213
223
|
if (wallSaysGone && uptimeSaysGone)
|
|
214
224
|
return GONE;
|
|
215
|
-
const compared = (
|
|
225
|
+
const compared = (starts.wall !== null && now.startedAtMs !== null) || (starts.boot !== null && now.startedSinceBootMs !== null);
|
|
216
226
|
return compared ? RUNNING : uncheckable("start_time_unknown");
|
|
217
227
|
},
|
|
218
228
|
};
|
|
@@ -186,6 +186,11 @@ export interface ResultFlags {
|
|
|
186
186
|
effectiveReadFace?: TaskResult["effectiveReadFace"];
|
|
187
187
|
effectiveWriteFace?: TaskResult["effectiveWriteFace"];
|
|
188
188
|
effectiveReadDenyPatterns?: TaskResult["effectiveReadDenyPatterns"];
|
|
189
|
+
/** The byte floor's latch as the leg ends ({@link TaskResult.readDenyFloor}): `true` ⇔ a read-deny table the leg compiled — at
|
|
190
|
+
* prepare or after — held rows its environment's floor does not keep. Pure pass-through, every terminal (the posture law). */
|
|
191
|
+
readDenyFloorUnkept?: boolean;
|
|
192
|
+
effectiveAgentConfigDirs?: TaskResult["effectiveAgentConfigDirs"];
|
|
193
|
+
effectiveAgentHomeDirs?: TaskResult["effectiveAgentHomeDirs"];
|
|
189
194
|
/** The memory-visibility observation, echoed on
|
|
190
195
|
* `TaskResult.effectiveMemoryScopes`. Pure pass-through on every terminal, same law as the
|
|
191
196
|
* read-posture seats above: present iff prepare completed (the memory-less states are their own
|
|
@@ -174,5 +174,5 @@ export function assembleResult(leg, final, stats, flags) {
|
|
|
174
174
|
delete publicStats.costMicroUsd;
|
|
175
175
|
const stampHaltedByUser = haltConsumed(flags.haltConsumption);
|
|
176
176
|
const turnAbortedBy = turnAbortedByOf(flags.haltConsumption);
|
|
177
|
-
return { taskId, ...(flags.runId !== undefined ? { runId: flags.runId } : {}), sessionId, terminal, ...(flags.model !== undefined ? { model: flags.model } : {}), ...(responseModel !== undefined ? { responseModel } : {}), result: result.trim(), ...(flags.answerEntryIds !== undefined ? { resultEntryIds: [...flags.answerEntryIds] } : {}), ...(flags.intake !== undefined ? { intake: flags.intake } : {}), ...(flags.displayed !== undefined ? { resultDisplayedBy: [...flags.displayed.by] } : {}), salvagedOutput, ...(apiFailure !== undefined ? { apiFailure } : {}), ...(retryAfterMs !== undefined ? { retryAfterMs } : {}), ...(flags.rewindNotes !== undefined && flags.rewindNotes.length > 0 ? { rewindNotes: flags.rewindNotes } : {}), ...(flags.editedFiles !== undefined && flags.editedFiles.length > 0 ? { editedFiles: flags.editedFiles } : {}), ...(flags.haltedOnUserRejection === true ? { haltedOnUserRejection: true } : {}), ...(stampHaltedByUser ? { haltedByUser: true } : {}), ...(turnAbortedBy !== undefined ? { turnAbortedBy } : {}), ...(terminal.kind === "completed" && flags.limitCrossed !== undefined ? { limitCrossed: flags.limitCrossed } : {}), ...(flags.remoteEnvFailures !== undefined && flags.remoteEnvFailures.length > 0 ? { remoteEnvFailures: [...flags.remoteEnvFailures] } : {}), ...(flags.refusedAsks !== undefined && flags.refusedAsks.length > 0 ? { refusedAsks: [...flags.refusedAsks] } : {}), ...(terminal.kind !== "paused" && flags.verdictRefused !== undefined ? { verdictRefused: flags.verdictRefused } : {}), ...(flags.strandedHumanAnswers !== undefined && flags.strandedHumanAnswers.length > 0 ? { strandedHumanAnswers: flags.strandedHumanAnswers } : {}), ...(flags.effectiveReadFace !== undefined ? { effectiveReadFace: flags.effectiveReadFace } : {}), ...(flags.effectiveWriteFace !== undefined ? { effectiveWriteFace: flags.effectiveWriteFace } : {}), ...(flags.effectiveReadDenyPatterns !== undefined && flags.effectiveReadDenyPatterns.length > 0 ? { effectiveReadDenyPatterns: flags.effectiveReadDenyPatterns } : {}), ...(flags.effectiveMemoryScopes !== undefined ? { effectiveMemoryScopes: flags.effectiveMemoryScopes } : {}), ...(flags.placementRoot !== undefined ? { placementRoot: flags.placementRoot } : {}), ...(flags.effectiveReasoning !== undefined ? { effectiveReasoning: flags.effectiveReasoning } : {}), ...(flags.fastMode !== undefined ? { fastMode: flags.fastMode } : {}), ...(flags.compaction !== undefined ? { compaction: flags.compaction } : {}), stats: publicStats };
|
|
177
|
+
return { taskId, ...(flags.runId !== undefined ? { runId: flags.runId } : {}), sessionId, terminal, ...(flags.model !== undefined ? { model: flags.model } : {}), ...(responseModel !== undefined ? { responseModel } : {}), result: result.trim(), ...(flags.answerEntryIds !== undefined ? { resultEntryIds: [...flags.answerEntryIds] } : {}), ...(flags.intake !== undefined ? { intake: flags.intake } : {}), ...(flags.displayed !== undefined ? { resultDisplayedBy: [...flags.displayed.by] } : {}), salvagedOutput, ...(apiFailure !== undefined ? { apiFailure } : {}), ...(retryAfterMs !== undefined ? { retryAfterMs } : {}), ...(flags.rewindNotes !== undefined && flags.rewindNotes.length > 0 ? { rewindNotes: flags.rewindNotes } : {}), ...(flags.editedFiles !== undefined && flags.editedFiles.length > 0 ? { editedFiles: flags.editedFiles } : {}), ...(flags.haltedOnUserRejection === true ? { haltedOnUserRejection: true } : {}), ...(stampHaltedByUser ? { haltedByUser: true } : {}), ...(turnAbortedBy !== undefined ? { turnAbortedBy } : {}), ...(terminal.kind === "completed" && flags.limitCrossed !== undefined ? { limitCrossed: flags.limitCrossed } : {}), ...(flags.remoteEnvFailures !== undefined && flags.remoteEnvFailures.length > 0 ? { remoteEnvFailures: [...flags.remoteEnvFailures] } : {}), ...(flags.refusedAsks !== undefined && flags.refusedAsks.length > 0 ? { refusedAsks: [...flags.refusedAsks] } : {}), ...(terminal.kind !== "paused" && flags.verdictRefused !== undefined ? { verdictRefused: flags.verdictRefused } : {}), ...(flags.strandedHumanAnswers !== undefined && flags.strandedHumanAnswers.length > 0 ? { strandedHumanAnswers: flags.strandedHumanAnswers } : {}), ...(flags.effectiveReadFace !== undefined ? { effectiveReadFace: flags.effectiveReadFace } : {}), ...(flags.effectiveWriteFace !== undefined ? { effectiveWriteFace: flags.effectiveWriteFace } : {}), ...(flags.effectiveReadDenyPatterns !== undefined && flags.effectiveReadDenyPatterns.length > 0 ? { effectiveReadDenyPatterns: flags.effectiveReadDenyPatterns } : {}), ...(flags.readDenyFloorUnkept === true ? { readDenyFloor: { kept: false } } : {}), ...(flags.effectiveAgentConfigDirs !== undefined && flags.effectiveAgentConfigDirs.length > 0 ? { effectiveAgentConfigDirs: [...flags.effectiveAgentConfigDirs] } : {}), ...(flags.effectiveAgentHomeDirs !== undefined && flags.effectiveAgentHomeDirs.length > 0 ? { effectiveAgentHomeDirs: [...flags.effectiveAgentHomeDirs] } : {}), ...(flags.effectiveMemoryScopes !== undefined ? { effectiveMemoryScopes: flags.effectiveMemoryScopes } : {}), ...(flags.placementRoot !== undefined ? { placementRoot: flags.placementRoot } : {}), ...(flags.effectiveReasoning !== undefined ? { effectiveReasoning: flags.effectiveReasoning } : {}), ...(flags.fastMode !== undefined ? { fastMode: flags.fastMode } : {}), ...(flags.compaction !== undefined ? { compaction: flags.compaction } : {}), stats: publicStats };
|
|
178
178
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The session's record of the old tool results the engine cleared from its requests (the cleared-projection ledger,
|
|
3
|
+
* `context-edit.ts`): what makes a clear the session's fact rather than one run's.
|
|
4
|
+
*
|
|
5
|
+
* Why it is kept: a clear rewrites the earliest cleared result's position in the request, so the provider re-reads the request
|
|
6
|
+
* from there once. Held only in a run's memory, the next run rebuilt the full results from the transcript — its first request
|
|
7
|
+
* carried them again (the size estimate is anchored on the cleared request, so nothing cleared them again) and the provider
|
|
8
|
+
* re-read the request from that position a second time. Kept with the session, every later request — the next run's, a reloaded
|
|
9
|
+
* engine's, a durable resume's, a fork's — repaints the same markers and extends the request before it.
|
|
10
|
+
*
|
|
11
|
+
* Stored as one engine-owned `custom` entry per change, the whole ledger in each; read as the newest one on the session's
|
|
12
|
+
* branch (a branch rewound to before a clear holds no record of it, and its full results are the history again). A run reads it
|
|
13
|
+
* once, at its first request build, and records the ledger again after any build whose landings or replay changed it (a
|
|
14
|
+
* compaction that summarized a cleared result away prunes its entry). A read or a write that fails is said aloud by the caller
|
|
15
|
+
* (`onFailure`; a write once while writes of the same ledger keep failing): the run keeps its own ledger and writes it again at its next build; a later run that finds no
|
|
16
|
+
* record of it (a read that failed, a run that ended before a write landed) sends those results in full until a clear takes them out again.
|
|
17
|
+
*/
|
|
18
|
+
import type { SessionTreeEntry } from "../../internal/harness-types.js";
|
|
19
|
+
import { type ClearedProjectionLedger } from "../context-edit.js";
|
|
20
|
+
export declare const CLEARED_RESULTS_CUSTOM_TYPE = "engine:cleared-results";
|
|
21
|
+
export interface ClearedResultsSession {
|
|
22
|
+
getBranch(): Promise<ReadonlyArray<SessionTreeEntry>>;
|
|
23
|
+
appendCustomEntry(customType: string, data?: unknown): Promise<string>;
|
|
24
|
+
}
|
|
25
|
+
/** The newest record on `branch`: its ledger, `undefined` when the branch holds none, `"malformed"` when the newest does not read. */
|
|
26
|
+
export declare function storedClearedResults(branch: ReadonlyArray<SessionTreeEntry>): ClearedProjectionLedger | undefined | "malformed";
|
|
27
|
+
/** One run's seat on the record: `seed` fills the run's ledger from the session once; `record` writes it when it differs from the
|
|
28
|
+
* newest record the run read or wrote. */
|
|
29
|
+
export interface ClearedResultsSeat {
|
|
30
|
+
seed(ledger: ClearedProjectionLedger): Promise<void>;
|
|
31
|
+
record(ledger: ClearedProjectionLedger): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
export declare function createClearedResultsSeat(session: ClearedResultsSession, onFailure: (error: unknown, step: "read" | "write") => void): ClearedResultsSeat;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { clearedLedgerFromRecords, clearedLedgerRecords } from "../context-edit.js";
|
|
2
|
+
export const CLEARED_RESULTS_CUSTOM_TYPE = "engine:cleared-results";
|
|
3
|
+
export function storedClearedResults(branch) {
|
|
4
|
+
for (let i = branch.length - 1; i >= 0; i--) {
|
|
5
|
+
const e = branch[i];
|
|
6
|
+
if (e.type !== "custom" || e.customType !== CLEARED_RESULTS_CUSTOM_TYPE)
|
|
7
|
+
continue;
|
|
8
|
+
return clearedLedgerFromRecords(e.data?.entries) ?? "malformed";
|
|
9
|
+
}
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
export function createClearedResultsSeat(session, onFailure) {
|
|
13
|
+
let seeded = false;
|
|
14
|
+
let held = "[]";
|
|
15
|
+
let failed;
|
|
16
|
+
return {
|
|
17
|
+
async seed(ledger) {
|
|
18
|
+
if (seeded)
|
|
19
|
+
return;
|
|
20
|
+
seeded = true;
|
|
21
|
+
let stored;
|
|
22
|
+
try {
|
|
23
|
+
stored = storedClearedResults(await session.getBranch());
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
onFailure(error, "read");
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (stored === "malformed") {
|
|
30
|
+
onFailure(new Error(`the session's newest ${CLEARED_RESULTS_CUSTOM_TYPE} entry does not read as a ledger; this run starts with none`), "read");
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (stored === undefined)
|
|
34
|
+
return;
|
|
35
|
+
for (const [k, v] of stored.entries)
|
|
36
|
+
ledger.entries.set(k, v);
|
|
37
|
+
held = JSON.stringify(clearedLedgerRecords(ledger));
|
|
38
|
+
},
|
|
39
|
+
async record(ledger) {
|
|
40
|
+
const records = clearedLedgerRecords(ledger);
|
|
41
|
+
const spelled = JSON.stringify(records);
|
|
42
|
+
if (spelled === held)
|
|
43
|
+
return;
|
|
44
|
+
try {
|
|
45
|
+
await session.appendCustomEntry(CLEARED_RESULTS_CUSTOM_TYPE, { entries: records });
|
|
46
|
+
held = spelled;
|
|
47
|
+
failed = undefined;
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
if (failed !== spelled)
|
|
51
|
+
onFailure(error, "write");
|
|
52
|
+
failed = spelled;
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -16,8 +16,7 @@ import { readElements, readMember } from "../thrown-value.js";
|
|
|
16
16
|
import { foreignLine } from "../protocol-http-auth.js";
|
|
17
17
|
import { emitInputTruncated, legCompactionSettings } from "./compaction-call-options.js";
|
|
18
18
|
import { compactionHookOptions, summaryProviderOptions } from "./compaction-seams.js";
|
|
19
|
-
import {
|
|
20
|
-
import { resolveCompactionModel } from "./prepare-config-doors.js";
|
|
19
|
+
import { announceIgnoredCompactionMembers } from "./prepare-config-doors.js";
|
|
21
20
|
import { resolveRunModel } from "./seat-model-doors.js";
|
|
22
21
|
import { fastTierNoticeTo } from "../fast-tier-door.js";
|
|
23
22
|
import { compactionActivationSnapshot } from "./prepare-tool-disclosure-mount.js";
|
|
@@ -25,6 +24,8 @@ import { derivedLegBrain, noteUnpricedSpend, sideCallBookOf } from "./side-call-
|
|
|
25
24
|
import { createModelFallbackSeat } from "./model-fallback-seat.js";
|
|
26
25
|
import { inMemoryNoticeTold } from "./announce-once-ledger.js";
|
|
27
26
|
import { modelLaneBrainOf } from "./model-lane-seat.js";
|
|
27
|
+
import { legPrefixObservers, observingBrain } from "./prefix-ledger.js";
|
|
28
|
+
import { storedPromptHashSalt } from "./session-hash-salt.js";
|
|
28
29
|
import { projectRequestCopies } from "../request-copy-projection.js";
|
|
29
30
|
import { acquireExistingSession, claimIdleSession, readOccupantExpectation, readPlainRequest, shownValue } from "./session-verb-doors.js";
|
|
30
31
|
const VERB = "Runner.compactSession";
|
|
@@ -35,7 +36,7 @@ export async function compactIdleSession(seats, request) {
|
|
|
35
36
|
const { deps } = seats;
|
|
36
37
|
const tellFastTier = fastTierNoticeTo(deps.onError, req.sessionId);
|
|
37
38
|
const resolved = resolveRunModel({ model: req.model }, deps, "compactSession.model", tellFastTier);
|
|
38
|
-
|
|
39
|
+
announceIgnoredCompactionMembers(req, "compactSession", deps.onNotice);
|
|
39
40
|
const store = resolveCheckpointStore(req.checkpointStore !== undefined ? { checkpointStore: req.checkpointStore } : {}, deps);
|
|
40
41
|
if (req.signal?.aborted === true)
|
|
41
42
|
return { outcome: "mooted", events: [] };
|
|
@@ -45,7 +46,7 @@ export async function compactIdleSession(seats, request) {
|
|
|
45
46
|
const acquired = await acquireExistingSession(seats.sessions, req.sessionId, VERB, "nothing was compacted", req.expect);
|
|
46
47
|
await refuseParkedSession(store, req.sessionId, req.checkpointStore !== undefined ? "the request's" : "the deployment's");
|
|
47
48
|
legMods = await admitLegMods({ listed: listLegModSeats({ spec: {}, deps }), deps, sessionId: req.sessionId });
|
|
48
|
-
return await compactOnSession(req, deps, new StoredSession(pinnedToLeaf(acquired.session.getStorage())), resolved,
|
|
49
|
+
return await compactOnSession(req, deps, new StoredSession(pinnedToLeaf(acquired.session.getStorage())), resolved, legMods, acquired.session);
|
|
49
50
|
}
|
|
50
51
|
finally {
|
|
51
52
|
legMods?.end();
|
|
@@ -73,7 +74,7 @@ function pinnedToLeaf(storage) {
|
|
|
73
74
|
},
|
|
74
75
|
});
|
|
75
76
|
}
|
|
76
|
-
async function compactOnSession(req, deps, session, resolved,
|
|
77
|
+
async function compactOnSession(req, deps, session, resolved, legMods, ledgerKey) {
|
|
77
78
|
const { sessionId } = req;
|
|
78
79
|
const events = [];
|
|
79
80
|
const ident = () => ({ eventId: uuidv7() });
|
|
@@ -109,10 +110,13 @@ async function compactOnSession(req, deps, session, resolved, named, legMods) {
|
|
|
109
110
|
});
|
|
110
111
|
const trace = deps.tracer;
|
|
111
112
|
try {
|
|
112
|
-
const compactionModel = compactionSummaryIsDerived(req.compactionModel !== undefined, named) ? await compactionSummaryFallback({ derived: named, primary: resolved.model, brain: modelLaneBrainOf(deps), getApiKeyAndHeaders: req.getApiKeyAndHeaders, onNotice: deps.onNotice, sessionId }) : named;
|
|
113
113
|
const branch = await session.getBranch();
|
|
114
|
+
const prefix = legPrefixObservers(ledgerKey, deps.cacheBreakDetection !== false);
|
|
115
|
+
const heldSalt = storedPromptHashSalt(branch);
|
|
116
|
+
if (heldSalt !== undefined)
|
|
117
|
+
prefix.seatSalt(heldSalt);
|
|
114
118
|
const contextMessages = projectRequestCopies(convertToLlm((await session.buildContext()).messages));
|
|
115
|
-
bindSessionFacade(legMods, { deps, req, model: resolved.model, messages: contextMessages, book, turns: async () => promptCountOf(await session.getBranch()) });
|
|
119
|
+
bindSessionFacade(legMods, { deps, req, model: resolved.model, messages: contextMessages, book, observeSideRequest: prefix.observeSide, turns: async () => promptCountOf(await session.getBranch()) });
|
|
116
120
|
const rowSeat = createRowSeat();
|
|
117
121
|
rowSeat.bind({ bus: legMods.bus, identity: undefined, report: legMods.report });
|
|
118
122
|
const compactStation = createCompactStation();
|
|
@@ -125,8 +129,7 @@ async function compactOnSession(req, deps, session, resolved, named, legMods) {
|
|
|
125
129
|
admitRows: rowSeat.admitRows,
|
|
126
130
|
model: resolved.model,
|
|
127
131
|
...(overlay !== undefined ? { contextOverlay: overlay } : {}),
|
|
128
|
-
|
|
129
|
-
brain: derivedLegBrain(() => modelLaneBrainOf(deps), "compaction", book),
|
|
132
|
+
brain: derivedLegBrain(() => observingBrain(modelLaneBrainOf(deps), prefix.observeSide), "compaction", book),
|
|
130
133
|
...(req.getApiKeyAndHeaders !== undefined ? { getApiKeyAndHeaders: req.getApiKeyAndHeaders } : {}),
|
|
131
134
|
...(thinking !== undefined ? { thinking } : {}),
|
|
132
135
|
settings: legCompactionSettings(req.compaction !== undefined ? { compaction: req.compaction } : {}, overlay, "manualCompact"),
|
|
@@ -142,6 +145,7 @@ async function compactOnSession(req, deps, session, resolved, named, legMods) {
|
|
|
142
145
|
}, maybeCompact, req.instructions !== undefined ? { instructions: req.instructions } : undefined);
|
|
143
146
|
const outcome = manualCompactOutcomeOf(comp);
|
|
144
147
|
if (comp.compacted) {
|
|
148
|
+
prefix.ledger.declare("compaction");
|
|
145
149
|
events.push(mintCompactedEvent(comp, "manual", ident()));
|
|
146
150
|
return answer(outcome);
|
|
147
151
|
}
|
|
@@ -174,6 +178,7 @@ function bindSessionFacade(legMods, input) {
|
|
|
174
178
|
};
|
|
175
179
|
const seats = legFacadeSeats({
|
|
176
180
|
deps: input.deps,
|
|
181
|
+
observeSideRequest: input.observeSideRequest,
|
|
177
182
|
spec: input.req.getApiKeyAndHeaders !== undefined ? { getApiKeyAndHeaders: input.req.getApiKeyAndHeaders } : {},
|
|
178
183
|
sessionId: input.req.sessionId,
|
|
179
184
|
model: input.model,
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* §17.4: stop attempting within-task compaction after this many CONSECUTIVE
|
|
13
13
|
* failures in one task — a never-recovering summary gateway must not burn an API call at every turn
|
|
14
14
|
* boundary (CC: MAX_CONSECUTIVE_AUTOCOMPACT_FAILURES = 3). Reset on any success; an open breaker also
|
|
15
|
-
* skips the
|
|
15
|
+
* skips the run-start judgment. Per-task scope.
|
|
16
16
|
*
|
|
17
17
|
* This used to say "a flaky/never-recovering gateway", and the word `flaky` was not true. Because
|
|
18
18
|
* any success zeroes the counter, a gateway that alternates never reaches three CONSECUTIVE failures and
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isHumanRefusal } from "../gate-outcome.js";
|
|
1
2
|
import { attest } from "../engine-attestation.js";
|
|
2
3
|
import { exactBoundInputHashOf } from "../canonical-json.js";
|
|
3
4
|
export function continuationGateOf(input) {
|
|
@@ -36,7 +37,7 @@ export function continuationGateOf(input) {
|
|
|
36
37
|
if (unanswerable)
|
|
37
38
|
return { kind: "ask_unanswerable" };
|
|
38
39
|
const disposition = gate?.disposition;
|
|
39
|
-
return { kind: "denied", layer: disposition?.kind !== "denied" ? "policy" : disposition.deniedBy };
|
|
40
|
+
return { kind: "denied", layer: disposition?.kind !== "denied" ? "policy" : disposition.deniedBy, explicit: isHumanRefusal(gate) };
|
|
40
41
|
},
|
|
41
42
|
};
|
|
42
43
|
}
|
|
@@ -21,7 +21,7 @@ export declare function closableByAppendAt(session: Pick<Session, "getBranch">,
|
|
|
21
21
|
export declare function settleBound(): (ahead: number) => number;
|
|
22
22
|
/**
|
|
23
23
|
* The two records the session's next leg reads that a leg owes at its end — the date anchor (a session's first leg; a leg whose date
|
|
24
|
-
* or prompt head moved: `owedDateAnchor`) and the cross-boundary leg-end record (a bit a child set after the leg's last exit, and what
|
|
24
|
+
* or prompt head moved, or that read the memory store live: `owedDateAnchor`) and the cross-boundary leg-end record (a bit a child set after the leg's last exit, and what
|
|
25
25
|
* the background tasks its task access reaches will deliver — read before the teardown's reaps stop any of them). The returned writer
|
|
26
26
|
* runs once: the settle calls it ahead of the landing it reads, the teardown on a lane that threw before that. Best-effort: a write
|
|
27
27
|
* that fails or does not answer inside its share of `bound` is reported (the cross-boundary lane reports its own store failures
|
|
@@ -29,7 +29,7 @@ export function legEndRecords(prepared, rs, runner, bound) {
|
|
|
29
29
|
written = true;
|
|
30
30
|
const dateSeat = prepared.dateChange;
|
|
31
31
|
const dateState = rs.attach.dateState;
|
|
32
|
-
const writeDateAnchor = owedDateAnchor(prepared.session, prepared.prefixAnchor?.read ?? dateSeat?.anchor, dateSeat !== undefined && dateState !== undefined ? { legDate: dateSeat.legDate, announcedDate: dateState.announcedDate } : undefined, prepared.prefixAnchor?.head());
|
|
32
|
+
const writeDateAnchor = owedDateAnchor(prepared.session, prepared.prefixAnchor?.read ?? dateSeat?.anchor, dateSeat !== undefined && dateState !== undefined ? { legDate: dateSeat.legDate, announcedDate: dateState.announcedDate } : undefined, prepared.prefixAnchor?.head(), prepared.prefixAnchor?.memory);
|
|
33
33
|
if (writeDateAnchor !== undefined)
|
|
34
34
|
await settleTeardownLeg(writeDateAnchor, "date anchor (settle leg)", report("degraded"), bound(prepared.crossBoundary !== undefined ? 3 : 2));
|
|
35
35
|
if (prepared.crossBoundary !== undefined)
|