@sema-agent/core 7.71.1 → 7.73.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 +500 -0
- package/dist/agents/cross-session-ref.d.ts +2 -2
- package/dist/agents/cross-session-ref.js +7 -2
- package/dist/agents/inherited-tool-pool.d.ts +30 -2
- package/dist/agents/inherited-tool-pool.js +53 -7
- package/dist/agents/parked-resume-drive.d.ts +10 -0
- package/dist/agents/parked-resume-drive.js +9 -0
- package/dist/agents/retain-ledger.d.ts +3 -0
- package/dist/agents/send-message-tool.js +7 -2
- package/dist/agents/send-user-message-tool.d.ts +12 -0
- package/dist/agents/send-user-message-tool.js +67 -0
- package/dist/agents/subagent-steps.d.ts +9 -0
- package/dist/agents/subagent-steps.js +38 -0
- package/dist/agents/subagent.d.ts +2 -0
- package/dist/agents/subagent.js +47 -12
- package/dist/agents/verify.js +23 -7
- package/dist/agents/yield-adoption.js +3 -1
- package/dist/brain/anthropic.js +14 -9
- package/dist/brain/open-responses.js +4 -5
- package/dist/brain/openai.js +30 -23
- package/dist/brain/stream-engine.js +159 -151
- package/dist/core/a2a.d.ts +24 -3
- package/dist/core/a2a.js +27 -8
- package/dist/core/actions-digest.d.ts +43 -0
- package/dist/core/actions-digest.js +22 -0
- package/dist/core/agent-state.d.ts +28 -7
- package/dist/core/agent-state.js +19 -6
- package/dist/core/allow-entry.js +3 -3
- package/dist/core/approval-object.d.ts +7 -3
- package/dist/core/approval-object.js +30 -9
- package/dist/core/auto-mode.d.ts +7 -9
- package/dist/core/auto-mode.js +114 -8
- package/dist/core/checkpoint-features.d.ts +16 -5
- package/dist/core/checkpoint-features.js +35 -6
- package/dist/core/checkpoint-rekey.d.ts +1 -1
- package/dist/core/checkpoint-rekey.js +6 -1
- package/dist/core/checkpoint-requirements.d.ts +23 -3
- package/dist/core/checkpoint-requirements.js +5 -1
- package/dist/core/checkpoint-row-verdict.d.ts +1 -1
- package/dist/core/checkpoint-row-verdict.js +10 -4
- package/dist/core/checkpoint-store.d.ts +24 -2
- package/dist/core/checkpoint-store.js +1 -0
- package/dist/core/child-clamp-seats.d.ts +15 -0
- package/dist/core/child-clamp-seats.js +15 -0
- package/dist/core/delegation-frames.d.ts +1 -0
- package/dist/core/delegation-frames.js +1 -1
- package/dist/core/effective-path-target.d.ts +19 -0
- package/dist/core/effective-path-target.js +95 -38
- package/dist/core/engine-capabilities.d.ts +5 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +34 -23
- package/dist/core/engine-version.js +1 -1
- package/dist/core/entries-not-applied.d.ts +19 -7
- package/dist/core/entries-not-applied.js +33 -1
- package/dist/core/file-history-store.d.ts +15 -4
- package/dist/core/file-history-store.js +53 -23
- package/dist/core/gate-fold.js +3 -1
- package/dist/core/governance-codes.d.ts +10 -1
- package/dist/core/governance-codes.js +17 -5
- package/dist/core/hooks.d.ts +3 -0
- package/dist/core/hooks.js +1 -0
- package/dist/core/host-instance.d.ts +23 -0
- package/dist/core/host-instance.js +69 -0
- package/dist/core/instruction-preview.d.ts +63 -0
- package/dist/core/instruction-preview.js +406 -0
- package/dist/core/judged-read.d.ts +57 -0
- package/dist/core/judged-read.js +1 -0
- package/dist/core/leg-budget.d.ts +26 -0
- package/dist/core/leg-budget.js +9 -0
- package/dist/core/leg-identity.d.ts +51 -1
- package/dist/core/leg-identity.js +45 -2
- package/dist/core/manager-launch-check.d.ts +48 -0
- package/dist/core/manager-launch-check.js +64 -0
- package/dist/core/mcp-call-meta.d.ts +2 -2
- package/dist/core/mcp-host-seat.d.ts +5 -0
- package/dist/core/mcp-host-seat.js +7 -1
- package/dist/core/mcp-injection-drop.d.ts +20 -10
- package/dist/core/mcp-injection-drop.js +9 -3
- package/dist/core/mcp-server-spec.d.ts +2 -1
- package/dist/core/mcp.js +3 -1
- package/dist/core/member-outcome.d.ts +3 -2
- package/dist/core/member-outcome.js +1 -1
- package/dist/core/memory-engine/deletion-record.d.ts +46 -0
- package/dist/core/memory-engine/deletion-record.js +96 -0
- package/dist/core/memory-engine/engine.js +24 -16
- package/dist/core/memory-engine/file-backend.js +7 -5
- package/dist/core/memory-engine/index.d.ts +1 -1
- package/dist/core/memory-engine/index.js +1 -1
- package/dist/core/memory-engine/layout.js +6 -4
- package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
- package/dist/core/memory-engine/projection-ledger.js +1 -1
- package/dist/core/memory-engine/scope-contract.d.ts +69 -11
- package/dist/core/memory-engine/scope-contract.js +99 -34
- package/dist/core/memory-engine/sync-client.js +26 -6
- package/dist/core/memory-engine/sync.d.ts +20 -2
- package/dist/core/memory-engine/sync.js +18 -17
- package/dist/core/mode-policy.d.ts +21 -6
- package/dist/core/mode-policy.js +15 -6
- package/dist/core/mounted-mcp.d.ts +7 -2
- package/dist/core/mounted-mcp.js +10 -1
- package/dist/core/own-property-receipt.js +11 -4
- package/dist/core/param-rule-reach.d.ts +8 -3
- package/dist/core/param-rule-reach.js +9 -1
- package/dist/core/parent-spec-seat.d.ts +13 -1
- package/dist/core/parent-spec-seat.js +18 -0
- package/dist/core/peer-registration.d.ts +52 -0
- package/dist/core/peer-registration.js +37 -0
- package/dist/core/peer-seat.d.ts +3 -1
- package/dist/core/peer-seat.js +3 -3
- package/dist/core/peer-task-store.d.ts +365 -0
- package/dist/core/peer-task-store.js +682 -0
- package/dist/core/permission-rule-consent.js +6 -11
- package/dist/core/permission-rule-model.d.ts +27 -0
- package/dist/core/permission-rule-model.js +34 -6
- package/dist/core/permission-rule-provider.d.ts +35 -33
- package/dist/core/permission-rule-provider.js +38 -295
- package/dist/core/permission-rule-store.d.ts +181 -8
- package/dist/core/permission-rule-store.js +420 -17
- package/dist/core/permission-rule-sync.js +15 -1
- package/dist/core/project-seat.d.ts +55 -0
- package/dist/core/project-seat.js +96 -0
- package/dist/core/protocol-http-auth.d.ts +3 -2
- package/dist/core/protocol-http-auth.js +26 -18
- package/dist/core/remote-env.d.ts +4 -4
- package/dist/core/retired-keys.js +1 -0
- package/dist/core/rule-offer-read.d.ts +1 -1
- package/dist/core/rule-offer-read.js +32 -4
- package/dist/core/run-ledger-seat.d.ts +66 -0
- package/dist/core/run-ledger-seat.js +70 -0
- package/dist/core/run-ledger.d.ts +332 -0
- package/dist/core/run-ledger.js +550 -0
- package/dist/core/runner/chain-mismatch.d.ts +32 -0
- package/dist/core/runner/chain-mismatch.js +29 -0
- package/dist/core/runner/changes-history.d.ts +1 -0
- package/dist/core/runner/changes-history.js +2 -2
- package/dist/core/runner/checkpoint-scope.d.ts +13 -3
- package/dist/core/runner/checkpoint-scope.js +12 -4
- package/dist/core/runner/construction-doors.js +6 -0
- package/dist/core/runner/contracts.d.ts +22 -3
- package/dist/core/runner/delegation-owner.d.ts +30 -0
- package/dist/core/runner/delegation-owner.js +20 -4
- package/dist/core/runner/file-history-restore.d.ts +3 -1
- package/dist/core/runner/file-history-restore.js +9 -6
- package/dist/core/runner/finish-reason-seat.js +4 -2
- package/dist/core/runner/leg-frame.js +3 -0
- package/dist/core/runner/loaded-skills.d.ts +2 -0
- package/dist/core/runner/loaded-skills.js +10 -0
- package/dist/core/runner/nested-memory-lane.d.ts +22 -5
- package/dist/core/runner/nested-memory-lane.js +91 -30
- package/dist/core/runner/person-path-rows.d.ts +23 -20
- package/dist/core/runner/person-path-rows.js +82 -18
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +105 -90
- package/dist/core/runner/prepare-config-doors.d.ts +1 -0
- package/dist/core/runner/prepare-config-doors.js +5 -3
- package/dist/core/runner/prepare-context-lane.js +1 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
- package/dist/core/runner/prepare-delegation-surface.js +6 -0
- package/dist/core/runner/prepare-execution-env.d.ts +3 -3
- package/dist/core/runner/prepare-file-history.js +1 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +10 -2
- package/dist/core/runner/prepare-hands-readface.js +36 -22
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -5
- package/dist/core/runner/prepare-inherited-gate.js +14 -6
- package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -2
- package/dist/core/runner/prepare-memory-engine-session.js +2 -2
- package/dist/core/runner/prepare-memory.js +3 -15
- package/dist/core/runner/prepare-project-context.d.ts +1 -1
- package/dist/core/runner/prepare-project-context.js +3 -7
- package/dist/core/runner/prepare-protocol-tools.d.ts +5 -0
- package/dist/core/runner/prepare-protocol-tools.js +2 -2
- package/dist/core/runner/prepare-run-refs.d.ts +1 -1
- package/dist/core/runner/prepare-run-refs.js +3 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
- package/dist/core/runner/prepare-suspend-saga.js +4 -2
- package/dist/core/runner/prepare-task.js +50 -37
- package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
- package/dist/core/runner/prepare-turn-wiring.js +2 -1
- package/dist/core/runner/prepare-wiring-manifest.d.ts +5 -1
- package/dist/core/runner/prepare-wiring-manifest.js +8 -4
- package/dist/core/runner/read-session-changes.js +1 -1
- package/dist/core/runner/resume-apply.js +11 -5
- package/dist/core/runner/resume-checkpoint-screen.d.ts +8 -7
- package/dist/core/runner/resume-checkpoint-screen.js +7 -6
- package/dist/core/runner/resume-review-outcome.d.ts +3 -0
- package/dist/core/runner/resume-review-outcome.js +24 -1
- package/dist/core/runner/rewind-files.js +3 -2
- package/dist/core/runner/run-harness-handlers.js +3 -0
- package/dist/core/runner/run-identity-wiring.js +3 -2
- package/dist/core/runner/run-leg.js +9 -2
- package/dist/core/runner/run-notification-lane.js +20 -1
- package/dist/core/runner/run-settle-and-teardown.js +21 -12
- package/dist/core/runner/run-stop-and-final-verify.js +6 -0
- package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
- package/dist/core/runner/runtask.d.ts +6 -2
- package/dist/core/runner/runtask.js +21 -9
- package/dist/core/runner/shell-env-withheld.d.ts +3 -2
- package/dist/core/runner/shell-env-withheld.js +1 -2
- package/dist/core/runner/stop-tail-notice.d.ts +10 -2
- package/dist/core/runner/stop-tail-notice.js +9 -2
- package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
- package/dist/core/runner/stream-settle-backstop.js +1 -0
- package/dist/core/runner/task-start-doors.js +6 -3
- package/dist/core/runner/terminal-account.d.ts +10 -1
- package/dist/core/runner/terminal-account.js +23 -3
- package/dist/core/runner/tool-face-overlay.d.ts +2 -11
- package/dist/core/runner/tool-face-overlay.js +39 -0
- package/dist/core/runner/trim-stretch.js +7 -2
- package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
- package/dist/core/runner-deps.d.ts +13 -10
- package/dist/core/scheduler.d.ts +47 -7
- package/dist/core/scheduler.js +19 -7
- package/dist/core/secret-env.d.ts +60 -37
- package/dist/core/secret-env.js +45 -48
- package/dist/core/sensitive-path-policy.js +14 -7
- package/dist/core/session-checkout.d.ts +3 -0
- package/dist/core/session-checkout.js +1 -0
- package/dist/core/session-store.d.ts +12 -6
- package/dist/core/session-store.js +26 -6
- package/dist/core/session.d.ts +31 -8
- package/dist/core/shell-read-silence.js +1 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +17 -0
- package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
- package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
- package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
- package/dist/core/store-contracts/session-store-contract.js +87 -3
- package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
- package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
- package/dist/core/task-event.d.ts +11 -3
- package/dist/core/task-notification.d.ts +97 -10
- package/dist/core/task-notification.js +129 -5
- package/dist/core/task-registry-shared.d.ts +12 -1
- package/dist/core/task-registry-shared.js +3 -1
- package/dist/core/task-registry-workflow.d.ts +1 -1
- package/dist/core/task-registry-workflow.js +9 -1
- package/dist/core/task-registry.d.ts +39 -2
- package/dist/core/task-registry.js +76 -12
- package/dist/core/task-result.d.ts +13 -0
- package/dist/core/task-spec-members.d.ts +3 -1
- package/dist/core/task-spec-members.js +11 -3
- package/dist/core/task-spec.d.ts +57 -23
- package/dist/core/tool-catalog-entries.js +4 -0
- package/dist/core/tool-face-reader.js +1 -1
- package/dist/core/tool-face.d.ts +7 -0
- package/dist/core/tool-face.js +1 -0
- package/dist/core/tool-mount-facts.d.ts +5 -3
- package/dist/core/tool-mount-facts.js +4 -3
- package/dist/core/tool-mount-plan.d.ts +7 -3
- package/dist/core/tool-mount-plan.js +11 -5
- package/dist/core/tool-mount-static.d.ts +2 -2
- package/dist/core/tool-mount-static.js +28 -14
- package/dist/core/tool-registry.d.ts +33 -1
- package/dist/core/tool-registry.js +33 -0
- package/dist/core/tool-result-store.d.ts +19 -2
- package/dist/core/tool-result-store.js +51 -2
- package/dist/core/tool-roster.d.ts +16 -0
- package/dist/core/tool-roster.js +6 -0
- package/dist/core/tool-spec.d.ts +13 -4
- package/dist/core/tools.d.ts +6 -0
- package/dist/core/tools.js +1 -1
- package/dist/core/user-attachment.d.ts +5 -1
- package/dist/core/user-attachment.js +14 -7
- package/dist/core/wiring-manifest.d.ts +89 -29
- package/dist/core/wiring-manifest.js +44 -4
- package/dist/core/workflow-journal-store.d.ts +53 -10
- package/dist/core/workflow-journal-store.js +27 -4
- package/dist/core/workflow-run-store-contract.js +16 -0
- package/dist/core/workflow-run-store.d.ts +9 -7
- package/dist/core/workflow-run-store.js +4 -1
- package/dist/engine/execution-env/node-execution-env.js +3 -1
- package/dist/engine/harness/messages.d.ts +1 -1
- package/dist/engine/harness/messages.js +2 -1
- package/dist/engine/harness/types.d.ts +24 -1
- package/dist/engine/harness/types.js +10 -0
- package/dist/engine/llm/types.d.ts +5 -7
- package/dist/engine/loop/types.d.ts +2 -0
- package/dist/engine/lsp/node-lsp-manager.js +2 -1
- package/dist/engine/session/import-validate.js +6 -1
- package/dist/engine/session/session.d.ts +15 -2
- package/dist/engine/session/session.js +35 -5
- package/dist/index.d.ts +27 -12
- package/dist/index.js +20 -8
- package/dist/orchestration/run-workflow-tool.js +40 -32
- package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
- package/dist/orchestration/workflow-park-adoption.js +47 -12
- package/dist/orchestration/workflow-stop.d.ts +128 -0
- package/dist/orchestration/workflow-stop.js +156 -0
- package/dist/orchestration/workflow.d.ts +30 -6
- package/dist/orchestration/workflow.js +117 -54
- package/dist/prompts/manager-recipe.d.ts +18 -0
- package/dist/prompts/manager-recipe.js +24 -0
- package/dist/stores/file/adoption/marker.d.ts +2 -27
- package/dist/stores/file/adoption/marker.js +12 -0
- package/dist/stores/file/index.d.ts +1 -1
- package/dist/stores/file/index.js +1 -1
- package/dist/stores/file/permission-rule-store.d.ts +3 -1
- package/dist/stores/file/permission-rule-store.js +0 -1
- package/dist/stores/file/workflow-journal-store.d.ts +16 -3
- package/dist/stores/file/workflow-journal-store.js +93 -5
- package/dist/stores/file/workflow-run-store.d.ts +1 -1
- package/dist/tools/artifact/artifact-tool.js +11 -6
- package/dist/tools/fs/file-read-check.d.ts +45 -11
- package/dist/tools/fs/file-read-check.js +200 -57
- package/dist/tools/fs/file-write-check.js +9 -3
- package/dist/tools/fs/index.d.ts +8 -7
- package/dist/tools/fs/index.js +4 -4
- package/dist/tools/fs/judged-reads.d.ts +51 -0
- package/dist/tools/fs/judged-reads.js +68 -0
- package/dist/tools/fs/read-deny-home.d.ts +1 -1
- package/dist/tools/fs/read-deny-home.js +5 -5
- package/dist/tools/fs/read-deny.d.ts +33 -8
- package/dist/tools/fs/read-deny.js +114 -25
- package/dist/tools/fs/safety.d.ts +12 -1
- package/dist/tools/fs/safety.js +16 -3
- package/dist/tools/fs/shell-read-check.d.ts +25 -5
- package/dist/tools/fs/shell-read-check.js +100 -15
- package/dist/tools/fs/shell-read-establish.d.ts +9 -0
- package/dist/tools/fs/shell-read-establish.js +34 -14
- package/dist/tools/fs/shell-read-judge.d.ts +13 -1
- package/dist/tools/fs/shell-read-judge.js +26 -7
- package/dist/tools/fs/shell-read-plan.d.ts +5 -0
- package/dist/tools/fs/shell-read-write-targets.js +17 -9
- package/dist/tools/scheduler-store-move.d.ts +74 -0
- package/dist/tools/scheduler-store-move.js +103 -0
- package/dist/tools/scheduler-tools.d.ts +43 -29
- package/dist/tools/scheduler-tools.js +161 -118
- package/package.json +2 -2
- package/test/export-surface.snapshot.json +173 -3
- package/wire-changes/answers/core-stores-sql@7.72.0.json +12 -0
- package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
- package/wire-changes/answers/core@7.72.0.json +84 -0
- package/wire-changes/answers/core@7.73.0.json +216 -0
- package/wire-changes/answers/mods-kernel@7.72.0.json +7 -0
- package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
- package/wire-changes/answers/primitives@7.72.0.json +6 -0
- package/wire-changes/answers/primitives@7.73.0.json +12 -0
- package/wire-changes/answers/wiki-gate@7.72.0.json +7 -0
- package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
- package/wire-changes/core-stores-sql@7.72.0.json +215 -0
- package/wire-changes/core-stores-sql@7.73.0.json +326 -0
- package/wire-changes/core@7.72.0.json +2426 -0
- package/wire-changes/core@7.73.0.json +6480 -0
- package/wire-changes/mods-kernel@7.72.0.json +147 -0
- package/wire-changes/mods-kernel@7.73.0.json +147 -0
- package/wire-changes/primitives@7.72.0.json +143 -0
- package/wire-changes/primitives@7.73.0.json +227 -0
- package/wire-changes/wiki-gate@7.72.0.json +145 -0
- package/wire-changes/wiki-gate@7.73.0.json +145 -0
|
@@ -6,10 +6,11 @@ import { callKeyOrdinal, readWorkflowJournalEntry, launchRecordToKeepOrThrow, re
|
|
|
6
6
|
import { processCensus, processFingerprint } from "../../core/process-identity.js";
|
|
7
7
|
import { AppendLog, readJsonlRecords } from "./fs-atomic.js";
|
|
8
8
|
import { guardCorruptSink } from "./corrupt-read-sink.js";
|
|
9
|
-
import { BootLock, canonicalStoreKey, FileStoreLockError, sanitizePathComponent, writeThenLink } from "./fs-atomic.js";
|
|
9
|
+
import { atomicWriteFile, BootLock, canonicalStoreKey, FileStoreLockError, sanitizePathComponent, writeThenLink } from "./fs-atomic.js";
|
|
10
10
|
import { assertAdoptionBootGate } from "./adoption/marker.js";
|
|
11
11
|
import { optionKeys, receiveOptions } from "../../core/own-property-receipt.js";
|
|
12
12
|
import { assertJournalEntryFits } from "../../core/workflow-journal-store.js";
|
|
13
|
+
const TOMBSTONE_CLAIM_HOLDER = "workflow:stopped";
|
|
13
14
|
function holderProcessOf(v) {
|
|
14
15
|
if (v === null || typeof v !== "object" || Array.isArray(v))
|
|
15
16
|
return undefined;
|
|
@@ -26,12 +27,14 @@ function holderProcessOf(v) {
|
|
|
26
27
|
return { pid: r.pid, startedAtMs, startedSinceBootMs, host: r.host, ...(typeof r.pidNs === "string" ? { pidNs: r.pidNs } : {}) };
|
|
27
28
|
}
|
|
28
29
|
function claimBinds(claim, now) {
|
|
30
|
+
if (claim.stopped !== undefined)
|
|
31
|
+
return true;
|
|
29
32
|
if (claim.rec.expiresAt <= now)
|
|
30
33
|
return false;
|
|
31
34
|
return claim.process === undefined || processCensus().verdict(claim.process).state !== "gone";
|
|
32
35
|
}
|
|
33
36
|
function heldHere(claim, newRunId) {
|
|
34
|
-
if (claim.rec.holder !== newRunId || claim.process === undefined)
|
|
37
|
+
if (claim.stopped !== undefined || claim.rec.holder !== newRunId || claim.process === undefined)
|
|
35
38
|
return false;
|
|
36
39
|
const me = processFingerprint();
|
|
37
40
|
return claim.process.pid === me.pid && claim.process.host === me.host && claim.process.pidNs === me.pidNs;
|
|
@@ -298,7 +301,8 @@ export class FileWorkflowJournalStore {
|
|
|
298
301
|
if (typeof rec.holder !== "string" || typeof rec.expiresAt !== "number" || !Number.isFinite(rec.expiresAt)) {
|
|
299
302
|
return { raw, claim: undefined };
|
|
300
303
|
}
|
|
301
|
-
|
|
304
|
+
const stopped = typeof rec.stoppedBy === "string" && rec.stoppedBy.length > 0 ? { by: rec.stoppedBy } : undefined;
|
|
305
|
+
return { raw, claim: { rec, process: holderProcessOf(rec.holderProcess), stopped } };
|
|
302
306
|
}
|
|
303
307
|
catch {
|
|
304
308
|
return { raw, claim: undefined };
|
|
@@ -335,6 +339,35 @@ export class FileWorkflowJournalStore {
|
|
|
335
339
|
gate.release();
|
|
336
340
|
}
|
|
337
341
|
}
|
|
342
|
+
replaceIfUnchanged(path, judged, payload) {
|
|
343
|
+
const gate = this.gateAt(path, judged);
|
|
344
|
+
try {
|
|
345
|
+
gate.acquire();
|
|
346
|
+
}
|
|
347
|
+
catch (err) {
|
|
348
|
+
if (err instanceof FileStoreLockError && (err.code === "store.dir_in_use" || err.code === "store.dir_claiming"))
|
|
349
|
+
return "contended";
|
|
350
|
+
throw err;
|
|
351
|
+
}
|
|
352
|
+
try {
|
|
353
|
+
let now;
|
|
354
|
+
try {
|
|
355
|
+
now = readFileSync(path, "utf8");
|
|
356
|
+
}
|
|
357
|
+
catch (err) {
|
|
358
|
+
if (err.code === "ENOENT")
|
|
359
|
+
return "changed";
|
|
360
|
+
throw err;
|
|
361
|
+
}
|
|
362
|
+
if (now !== judged)
|
|
363
|
+
return "changed";
|
|
364
|
+
atomicWriteFile(this.claimsDir, path, payload);
|
|
365
|
+
return "replaced";
|
|
366
|
+
}
|
|
367
|
+
finally {
|
|
368
|
+
gate.release();
|
|
369
|
+
}
|
|
370
|
+
}
|
|
338
371
|
gateAt(path, judged) {
|
|
339
372
|
const gatePath = judged === undefined ? path : join(this.claimsDir, `${createHash("sha256").update(`${basename(path)}\n${judged}`).digest("hex").slice(0, 32)}.takeover`);
|
|
340
373
|
return new BootLock(gatePath, RESUME_CLAIM_TTL_MS);
|
|
@@ -358,7 +391,9 @@ export class FileWorkflowJournalStore {
|
|
|
358
391
|
const read = this.readClaimAt(path);
|
|
359
392
|
if (read === undefined)
|
|
360
393
|
continue;
|
|
361
|
-
if (read.claim !== undefined
|
|
394
|
+
if (read.claim !== undefined
|
|
395
|
+
? read.claim.stopped !== undefined || read.claim.rec.expiresAt + RESUME_CLAIM_REAP_GRACE_MS > now
|
|
396
|
+
: now - statSync(path).mtimeMs <= RESUME_CLAIM_TTL_MS) {
|
|
362
397
|
continue;
|
|
363
398
|
}
|
|
364
399
|
this.removeIfUnchanged(path, read.raw);
|
|
@@ -399,6 +434,9 @@ export class FileWorkflowJournalStore {
|
|
|
399
434
|
if (read === undefined)
|
|
400
435
|
continue;
|
|
401
436
|
const existing = read.claim;
|
|
437
|
+
if (existing !== undefined && existing.stopped !== undefined) {
|
|
438
|
+
return { granted: false, stopped: existing.stopped };
|
|
439
|
+
}
|
|
402
440
|
const now = Date.now();
|
|
403
441
|
if (existing !== undefined && claimBinds(existing, now)) {
|
|
404
442
|
const left = resumeClaimRemainingMember(existing.rec.expiresAt, now);
|
|
@@ -409,6 +447,9 @@ export class FileWorkflowJournalStore {
|
|
|
409
447
|
this.removeIfUnchanged(path, read.raw);
|
|
410
448
|
}
|
|
411
449
|
const winner = this.readClaimAt(path)?.claim;
|
|
450
|
+
if (winner !== undefined && winner.stopped !== undefined) {
|
|
451
|
+
return { granted: false, stopped: winner.stopped };
|
|
452
|
+
}
|
|
412
453
|
const lastLook = Date.now();
|
|
413
454
|
const bound = winner !== undefined && claimBinds(winner, lastLook) ? winner : undefined;
|
|
414
455
|
if (bound !== undefined && heldHere(bound, newRunId))
|
|
@@ -425,7 +466,7 @@ export class FileWorkflowJournalStore {
|
|
|
425
466
|
return;
|
|
426
467
|
}
|
|
427
468
|
const existing = read?.claim;
|
|
428
|
-
if (read === undefined || existing === undefined || !heldHere(existing, input.newRunId))
|
|
469
|
+
if (read === undefined || existing === undefined || existing.stopped !== undefined || !heldHere(existing, input.newRunId))
|
|
429
470
|
return;
|
|
430
471
|
if (existing.rec.expiresAt - Date.now() <= RESUME_CLAIM_RELEASE_GRACE_MS)
|
|
431
472
|
return;
|
|
@@ -435,6 +476,53 @@ export class FileWorkflowJournalStore {
|
|
|
435
476
|
catch {
|
|
436
477
|
}
|
|
437
478
|
}
|
|
479
|
+
async stopResumeClaim(input) {
|
|
480
|
+
if (typeof input.stoppedBy !== "string" || input.stoppedBy === "") {
|
|
481
|
+
throw new TypeError("workflow journal: stopResumeClaim requires a non-empty stoppedBy string");
|
|
482
|
+
}
|
|
483
|
+
const { sourceRunId, scope, stoppedBy, holder } = input;
|
|
484
|
+
const path = this.claimPathFor(sourceRunId, scope);
|
|
485
|
+
mkdirSync(this.claimsDir, { recursive: true, mode: 0o700 });
|
|
486
|
+
const record = {
|
|
487
|
+
sourceRunId,
|
|
488
|
+
holder: TOMBSTONE_CLAIM_HOLDER,
|
|
489
|
+
expiresAt: Number.MAX_SAFE_INTEGER,
|
|
490
|
+
stoppedBy,
|
|
491
|
+
stoppedAt: Date.now(),
|
|
492
|
+
};
|
|
493
|
+
const payload = JSON.stringify(record);
|
|
494
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
495
|
+
try {
|
|
496
|
+
writeThenLink(path, payload);
|
|
497
|
+
return { stopped: true };
|
|
498
|
+
}
|
|
499
|
+
catch (err) {
|
|
500
|
+
if (err.code !== "EEXIST")
|
|
501
|
+
throw err;
|
|
502
|
+
}
|
|
503
|
+
const read = this.readClaimAt(path);
|
|
504
|
+
if (read === undefined)
|
|
505
|
+
continue;
|
|
506
|
+
const existing = read.claim;
|
|
507
|
+
if (existing !== undefined && existing.stopped !== undefined) {
|
|
508
|
+
return { stopped: true };
|
|
509
|
+
}
|
|
510
|
+
const now = Date.now();
|
|
511
|
+
const binds = existing !== undefined && claimBinds(existing, now);
|
|
512
|
+
if (binds && (holder === undefined || existing.rec.holder !== holder)) {
|
|
513
|
+
return { stopped: false, holder: existing.rec.holder };
|
|
514
|
+
}
|
|
515
|
+
const replaced = this.replaceIfUnchanged(path, read.raw, payload);
|
|
516
|
+
if (replaced === "replaced")
|
|
517
|
+
return { stopped: true };
|
|
518
|
+
}
|
|
519
|
+
const winner = this.readClaimAt(path)?.claim;
|
|
520
|
+
if (winner !== undefined && winner.stopped !== undefined)
|
|
521
|
+
return { stopped: true };
|
|
522
|
+
const lastLook = Date.now();
|
|
523
|
+
const bound = winner !== undefined && claimBinds(winner, lastLook) ? winner : undefined;
|
|
524
|
+
return { stopped: false, ...(bound !== undefined ? { holder: bound.rec.holder } : {}) };
|
|
525
|
+
}
|
|
438
526
|
dispose() {
|
|
439
527
|
if (this.closed)
|
|
440
528
|
return;
|
|
@@ -95,7 +95,7 @@ export declare class FileWorkflowRunStore implements WorkflowRunStore {
|
|
|
95
95
|
/** The end of a batch of {@link deleteRun} calls (interface: {@link WorkflowRunStore.settleErasure}): the ledger compacted once. */
|
|
96
96
|
settleErasure(): Promise<void>;
|
|
97
97
|
/** The session's terminal runs, deleted each under its own id lock with the selection re-checked against the live row (interface:
|
|
98
|
-
* {@link WorkflowRunStore.deleteBySession}) — a run
|
|
98
|
+
* {@link WorkflowRunStore.deleteBySession}) — a run removed or replaced by a new running run is skipped, as `reap` skips one. */
|
|
99
99
|
deleteBySession(sessionId: string, scope: string): Promise<string[]>;
|
|
100
100
|
/** Force a compaction now (test/inspection): rewrite the snapshot from the authoritative map and
|
|
101
101
|
* truncate the live ledger (RB-167's closeForSwap recipe lives in the base). */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { arbitrateByMode, askClassMembersOf, classifyAsk } from "../../core/ask-origin.js";
|
|
2
2
|
import { deliverEngineNotice } from "../../core/engine-notice.js";
|
|
3
3
|
import { modeReleaseOf } from "../../core/gate-outcome.js";
|
|
4
|
+
import { attestationOf } from "../../core/engine-attestation.js";
|
|
4
5
|
import { createHash } from "node:crypto";
|
|
5
6
|
import { Type } from "typebox";
|
|
6
7
|
import { ARTIFACT_ACTION_CONCURRENCY_SAFE, ARTIFACT_COMMIT_THROW_OUTCOME, ARTIFACT_FAILURE_RESULT_CODE, ARTIFACT_HOST_ERROR_CODE, ARTIFACT_LIST_SCOPES, ARTIFACT_PLANE_CONTENT_ORIGIN, ARTIFACT_PUBLISH_CONTEXTS, readArtifactHostCapabilities, } from "../../core/artifact-host.js";
|
|
@@ -175,6 +176,8 @@ function readArtifactCallBinding(raw) {
|
|
|
175
176
|
}
|
|
176
177
|
const invalid = (text) => errorResult(`Error (Artifact): ${text}`, { type: "artifact", invalidArguments: true });
|
|
177
178
|
const typed = (code, text, extra = {}) => errorResult(`Error (Artifact): ${text}`, { type: "artifact", code: ARTIFACT_FAILURE_RESULT_CODE[code], ...extra });
|
|
179
|
+
const SHARED_READ_REFUSED = { mode: "was refused by the permission mode", classifier: "was refused by auto mode's classifier", ask_resolution: "was not approved" };
|
|
180
|
+
const sharedReadRefused = (url, target, refusal, withheld) => typed("refused", `reading the shared artifact ${target} ${SHARED_READ_REFUSED[refusal.deniedBy]} (${foreignLine(refusal.reason, 200)}); its ${withheld} ${withheld === "files" ? "were" : "was"} not delivered.`, { url, sharedRead: "not_approved", deniedBy: refusal.deniedBy, ...(refusal.settlement !== undefined ? { settlement: refusal.settlement } : {}) });
|
|
178
181
|
export function createArtifactTool(opts) {
|
|
179
182
|
const verdict = readArtifactHostCapabilities(opts.host);
|
|
180
183
|
if (!verdict.ok)
|
|
@@ -530,7 +533,7 @@ export function assembleArtifactTool(opts, caps, onNotice) {
|
|
|
530
533
|
return { ok: true };
|
|
531
534
|
}
|
|
532
535
|
if (verdict.kind === "denied_by_mode")
|
|
533
|
-
return { ok: false, reason: `the ${verdict.mode} permission mode refuses to read another person's artifact without approval
|
|
536
|
+
return { ok: false, reason: `the ${verdict.mode} permission mode refuses to read another person's artifact without approval`, deniedBy: "mode" };
|
|
534
537
|
return undefined;
|
|
535
538
|
};
|
|
536
539
|
const first = byMode();
|
|
@@ -545,7 +548,7 @@ export function assembleArtifactTool(opts, caps, onNotice) {
|
|
|
545
548
|
return { ok: true };
|
|
546
549
|
}
|
|
547
550
|
if (judged.kind === "deny")
|
|
548
|
-
return { ok: false, reason: judged.reason };
|
|
551
|
+
return { ok: false, reason: judged.reason, deniedBy: "classifier" };
|
|
549
552
|
return byMode(judged.also) ?? askPerson(url, question, ctx, judged.settle, judged.request);
|
|
550
553
|
});
|
|
551
554
|
};
|
|
@@ -571,10 +574,12 @@ export function assembleArtifactTool(opts, caps, onNotice) {
|
|
|
571
574
|
}, onAsk, ctx.signal, undefined, undefined, undefined, undefined, undefined, "close");
|
|
572
575
|
const allowed = resolved.action === "allow" && resolved.updatedInput === undefined;
|
|
573
576
|
settle?.(allowed);
|
|
577
|
+
const settlement = attestationOf(resolved, { toolCallId: ctx.toolCallId, toolName: ARTIFACT_TOOL_NAME })?.settlement?.kind;
|
|
578
|
+
const byResolution = { deniedBy: "ask_resolution", ...(settlement !== undefined ? { settlement } : {}) };
|
|
574
579
|
if (resolved.action !== "allow")
|
|
575
|
-
return { ok: false, reason: resolved.message ?? "not approved" };
|
|
580
|
+
return { ok: false, reason: resolved.message ?? "not approved", ...byResolution };
|
|
576
581
|
if (resolved.updatedInput !== undefined)
|
|
577
|
-
return { ok: false, reason: "the approval edited the request; an edited approval does not authorize the original target" };
|
|
582
|
+
return { ok: false, reason: "the approval edited the request; an edited approval does not authorize the original target", ...byResolution };
|
|
578
583
|
sharedReadApproved.add(url);
|
|
579
584
|
return { ok: true };
|
|
580
585
|
})().finally(() => {
|
|
@@ -602,7 +607,7 @@ export function assembleArtifactTool(opts, caps, onNotice) {
|
|
|
602
607
|
if (!sharedUrls.has(url))
|
|
603
608
|
return undefined;
|
|
604
609
|
const consent = await sharedReadConsent(url, undefined, ctx);
|
|
605
|
-
return consent.ok ? undefined :
|
|
610
|
+
return consent.ok ? undefined : sharedReadRefused(url, foreignLine(url, 200), consent, "files");
|
|
606
611
|
};
|
|
607
612
|
async function read(a, ctx) {
|
|
608
613
|
if (a.url === undefined)
|
|
@@ -621,7 +626,7 @@ export function assembleArtifactTool(opts, caps, onNotice) {
|
|
|
621
626
|
if (sharedUrls.has(a.url)) {
|
|
622
627
|
const consent = await sharedReadConsent(a.url, out.ref, ctx);
|
|
623
628
|
if (!consent.ok)
|
|
624
|
-
return
|
|
629
|
+
return sharedReadRefused(a.url, inlineUntrusted(a.url, 200), consent, "content");
|
|
625
630
|
}
|
|
626
631
|
rememberRef(out.ref);
|
|
627
632
|
const head = owner === "shared" ? `[isolated summary of a shared artifact — ${inlineUntrusted(out.ref.url, 300)}, version ${inlineUntrusted(out.ref.version, 60)}]\n` : "";
|
|
@@ -18,16 +18,19 @@
|
|
|
18
18
|
* the gate never received (its wait elapsed, the judgment threw) admits nothing.
|
|
19
19
|
*/
|
|
20
20
|
import type { ExecutionEnv } from "../../internal/harness-types.js";
|
|
21
|
+
import type { ToolCallPathTarget } from "../../core/tool-face.js";
|
|
22
|
+
import type { JudgedRead } from "../../core/judged-read.js";
|
|
21
23
|
import type { ContainmentFace } from "./containment-face.js";
|
|
22
24
|
import { type ReadDenyMatcher } from "./read-deny.js";
|
|
23
|
-
import { type ShellReadCheck } from "./shell-read-check.js";
|
|
25
|
+
import { type ReadStationCall, type ShellReadCheck } from "./shell-read-check.js";
|
|
24
26
|
/**
|
|
25
27
|
* How a leg answers a file tool's read outside its roots — ONE judgment over the two declarations that bear on it:
|
|
26
28
|
* `refusal` (the leg refuses reads outside its declared directories, `TaskSpec.blockReadsOutsideRoots`: the station refuses
|
|
27
29
|
* at the gate, before the gate's own questions — save a host policy that asks its approver inside its own `check`, which has
|
|
28
30
|
* asked by then, and the leg's approver re-asked about an approved edit that moves an in-root read outside), `tool_fence`
|
|
29
|
-
* (the read-only mount:
|
|
30
|
-
*
|
|
31
|
+
* (the read-only mount: the file tools' own fence refuses, the station judges none of them; a DECLARED read, which has no fence
|
|
32
|
+
* of its own, is refused at the gate wherever the Read tool's fence would refuse it), or
|
|
33
|
+
* `question` (the station puts it to whoever answers). The station's arm is chosen off this answer alone.
|
|
31
34
|
*/
|
|
32
35
|
export type OutsideReadDisposition = "question" | "refusal" | "tool_fence";
|
|
33
36
|
export declare function outsideReadDisposition(leg: {
|
|
@@ -41,12 +44,27 @@ export declare function outsideReadDisposition(leg: {
|
|
|
41
44
|
export declare const READ_BLOCK_REMEDY = "This task refuses reads outside its directories (blockReadsOutsideRoots); ask the user to add the directory to the task's directories.";
|
|
42
45
|
export interface FileReadStation {
|
|
43
46
|
readonly check: ShellReadCheck;
|
|
44
|
-
/** The station's membership: the
|
|
47
|
+
/** The station's membership by NAME: the engine's file tools whose catalog read target it judges. A call under no such name
|
|
48
|
+
* whose face declares a read target is a member too ({@link declaredReadOf}), judged on its own declaration. */
|
|
45
49
|
readonly tools: ReadonlySet<string>;
|
|
46
50
|
/** Did the gate put THIS call's read of `canonicalKey` outside the roots to a question it then let through? Consumed
|
|
47
51
|
* on a match: the admission covers one read of one target. */
|
|
48
52
|
readonly admitted: (toolCallId: string | undefined, canonicalKey: string) => boolean;
|
|
53
|
+
/** The judged-read port of a call the station judged as a declared read (`ToolExecuteContext.judgedReads`); `undefined` when it
|
|
54
|
+
* judged no such call under this id. */
|
|
55
|
+
readonly judgedReadsOf: (toolCallId: string) => readonly JudgedRead[] | undefined;
|
|
56
|
+
/** Is this call the station's member by its face's declaration ({@link declaredReadOf})? */
|
|
57
|
+
readonly declares: (call: ReadStationCall) => boolean;
|
|
49
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* The read target a call DECLARES on its own face, when the call is under no name of the engine's file tools: a tool the engine
|
|
61
|
+
* does not catalog (a caller's, an MCP server's under its `toolFaces`) that states `pathTarget.access: "read"`. Such a call is the
|
|
62
|
+
* file read station's member on that declaration; nothing but the station's judgment stands between the model's path and the
|
|
63
|
+
* tool, so the station refuses at the gate every target the read would refuse, and the tool reads through the port the station
|
|
64
|
+
* hands it. The slot is the declarer's whatever names the tool answers to (`declaredReadSlotOf`). `undefined` ⇒ not a declared read
|
|
65
|
+
* (a tool the engine mounted keeps its catalog slot and its own refusals).
|
|
66
|
+
*/
|
|
67
|
+
export declare function declaredReadOf(call: ReadStationCall): ToolCallPathTarget | undefined;
|
|
50
68
|
export interface FileReadStationOptions {
|
|
51
69
|
readonly env: ExecutionEnv;
|
|
52
70
|
readonly rootCanonical: string;
|
|
@@ -55,7 +73,8 @@ export interface FileReadStationOptions {
|
|
|
55
73
|
readonly readDeny?: ReadDenyMatcher;
|
|
56
74
|
readonly readFace?: ContainmentFace;
|
|
57
75
|
readonly homeDir?: string;
|
|
58
|
-
/** The file tools
|
|
76
|
+
/** The file tools the station judges by name (their catalog path target is the one judged): those the leg mounts, or none
|
|
77
|
+
* where their own fence answers (the read-only band). A declared read is judged whatever this set holds. */
|
|
59
78
|
readonly tools: ReadonlySet<string>;
|
|
60
79
|
/** A target no answer may admit (the store-isolation rule's judgment, `rootAdmittingArtifactStore`): it is left to
|
|
61
80
|
* the tool's own refusal, no question is raised for it. */
|
|
@@ -65,13 +84,28 @@ export interface FileReadStationOptions {
|
|
|
65
84
|
readonly exempt?: (canonicalKey: string) => boolean;
|
|
66
85
|
/** The station's arm ({@link outsideReadDisposition}): `question` (absent) puts an out-of-root read to a question;
|
|
67
86
|
* `refusal` refuses at the gate every read the tool would refuse itself — outside the roots, on a deny row, a target it
|
|
68
|
-
* cannot resolve, the artifact store — with the resolution's own card, admits nothing, and refuses when it cannot judge
|
|
69
|
-
|
|
87
|
+
* cannot resolve, the artifact store — with the resolution's own card, admits nothing, and refuses when it cannot judge;
|
|
88
|
+
* `tool_fence` refuses each target of a declared read the Read tool's own fence would refuse (its sentence). */
|
|
89
|
+
readonly outsideReads?: OutsideReadDisposition;
|
|
70
90
|
}
|
|
71
91
|
export declare function createFileReadStation(opts: FileReadStationOptions): FileReadStation;
|
|
72
|
-
/**
|
|
73
|
-
*
|
|
74
|
-
export
|
|
92
|
+
/** A read station as the gate input composes it: its check, its membership by name, and — for the file read station — whether a
|
|
93
|
+
* call under none of those names is its member by what its face declares. */
|
|
94
|
+
export interface ReadStationMember {
|
|
75
95
|
readonly check: ShellReadCheck;
|
|
76
96
|
readonly tools: ReadonlySet<string>;
|
|
77
|
-
|
|
97
|
+
readonly declares?: (call: ReadStationCall) => boolean;
|
|
98
|
+
}
|
|
99
|
+
/** Is `call` a member of any of `stations` — by one of its names, or by its face's declaration? */
|
|
100
|
+
export declare function readStationsHold(stations: ReadonlyArray<ReadStationMember>, call: ReadStationCall): boolean;
|
|
101
|
+
/** One gate input over the leg's read stations: a call whose own face declares a read target ({@link declaredReadOf}) is judged
|
|
102
|
+
* by the file read station, whatever names it answers to; any other call by the station whose membership holds the first of its
|
|
103
|
+
* names any station holds (the spelling first). */
|
|
104
|
+
export declare function composeReadChecks(stations: ReadonlyArray<ReadStationMember>): ShellReadCheck | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* The read check of a leg that mounts no file read station (no execution environment, or its hands are off): a call whose face
|
|
107
|
+
* declares a read and whose tool does not read through the judged-read port (`ported` answers by the tool's wire name — an MCP
|
|
108
|
+
* tool, whose server opens the path by name with nothing after the gate) is refused and never dispatched, on a fresh leg and on a
|
|
109
|
+
* resumed one alike; every other call is not its member. A tool that reads through the port is handed `no_read_station` instead.
|
|
110
|
+
*/
|
|
111
|
+
export declare function unjudgedReadsMember(ported: (toolName: string) => boolean): ReadStationMember;
|