@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { strict as assert } from "node:assert";
|
|
2
|
-
import { statSync } from "node:fs";
|
|
3
|
-
import { isAbsolute } from "node:path";
|
|
2
|
+
import { readdirSync, statSync } from "node:fs";
|
|
3
|
+
import { isAbsolute, join } from "node:path";
|
|
4
4
|
import { SessionError, StoredSession, uuidv7 } from "../../internal/harness.js";
|
|
5
5
|
import { promptIdentityOf, walkPromptEpochCarriers } from "../../prompt-assembly/epoch.js";
|
|
6
6
|
import { textContentHashOf } from "../canonical-json.js";
|
|
@@ -149,7 +149,7 @@ function assertActivityOrder(rows, newerToOlder, what) {
|
|
|
149
149
|
}
|
|
150
150
|
const HOOK_WORDS = { subject: "SessionStoreContractHooks", unit: "hook", moment: "at sessionStoreContract" };
|
|
151
151
|
const REQUIRED_HOOKS = ["deleteSession", "reopen"];
|
|
152
|
-
const OPTIONAL_HOOKS = ["replica", "tokenlessRow", "openRefusedRow", "composed", "runAssertion", "onOptionalMember"];
|
|
152
|
+
const OPTIONAL_HOOKS = ["replica", "tokenlessRow", "openRefusedRow", "unreadableRow", "ageIdle", "idleClockOf", "composed", "runAssertion", "onOptionalMember"];
|
|
153
153
|
const GRANT_FIXTURE_FUNCTIONS = ["current", "replaced", "ended", "unknownStatus"];
|
|
154
154
|
function receiveHooks(make, hooks) {
|
|
155
155
|
if (typeof make !== "function")
|
|
@@ -172,6 +172,8 @@ function receiveHooks(make, hooks) {
|
|
|
172
172
|
throw receiptRefusal(`${HOOK_WORDS.subject}.noTokenlessRows must say why the store holds no row written before occupant tokens (a non-empty string) when present, got ${describeRejectedValue(none)}`);
|
|
173
173
|
if (none !== undefined && readMember(got, "tokenlessRow") !== undefined)
|
|
174
174
|
throw receiptRefusal(`${HOOK_WORDS.subject} gives tokenlessRow and declares noTokenlessRows — a store holds such rows (the hook writes one) or says why it holds none, not both`);
|
|
175
|
+
if ((readMember(got, "ageIdle") === undefined) !== (readMember(got, "idleClockOf") === undefined))
|
|
176
|
+
throw receiptRefusal(`${HOOK_WORDS.subject} gives one of ageIdle and idleClockOf — the idle clock seam is the two together (put a session past the idle window, read its clock), or neither`);
|
|
175
177
|
const grants = readMember(got, "grants");
|
|
176
178
|
if (grants !== undefined) {
|
|
177
179
|
if (typeof grants !== "object" || grants === null)
|
|
@@ -230,6 +232,9 @@ async function runSessionStoreContract(make, hooks) {
|
|
|
230
232
|
deleteUnreadable: (s) => hasHead(s) && typeof s.deleteUnreadable === "function",
|
|
231
233
|
holder: (s) => s.fence !== undefined || hooks.composed !== undefined,
|
|
232
234
|
recordOwner: (s) => hasOwnership(s) && typeof s.recordOwner === "function",
|
|
235
|
+
readRow: (s) => typeof s.readRow === "function",
|
|
236
|
+
idleClock: () => hooks.ageIdle !== undefined && hooks.idleClockOf !== undefined,
|
|
237
|
+
unreadableRow: () => hooks.unreadableRow !== undefined,
|
|
233
238
|
};
|
|
234
239
|
const FACE_OWED = {
|
|
235
240
|
tokenlessRow: (s) => s.durability === "durable" && hooks.noTokenlessRows === undefined
|
|
@@ -1817,6 +1822,23 @@ async function runSessionStoreContract(make, hooks) {
|
|
|
1817
1822
|
}
|
|
1818
1823
|
assert.equal(await ownerOf(store, id, "after the refused deletes"), "kit-alice");
|
|
1819
1824
|
});
|
|
1825
|
+
faceRun("[delete] the occupant form { row: { owner, incarnation } } deletes only the occupant a read answered: the row deleted and created again under the id by the same owner is not deleted by the first occupant's guard, and is by its own; row null, a log mark and a guard naming both forms are refused", ["delete", "ownership"], async (store) => {
|
|
1826
|
+
const id = freshId();
|
|
1827
|
+
await store.register(id, "kit-alice");
|
|
1828
|
+
const first = await tokenOf(store, id, "the first occupant");
|
|
1829
|
+
assert.equal(await store.delete(id, { owner: "kit-alice" }), true);
|
|
1830
|
+
await store.register(id, "kit-alice");
|
|
1831
|
+
const second = await tokenOf(store, id, "the id created again by the same owner");
|
|
1832
|
+
assert.notEqual(second, first, "a later create under the id is a new occupant");
|
|
1833
|
+
assert.equal(await store.delete(id, { row: { owner: "kit-alice", incarnation: first } }), false, "the first occupant's guard does not take the second");
|
|
1834
|
+
assert.equal(await store.delete(id, { row: { owner: "kit-bob", incarnation: second } }), false, "another owner's occupant guard deletes nothing");
|
|
1835
|
+
assert.equal(await ownerOf(store, id, "after two refused occupant deletes"), "kit-alice");
|
|
1836
|
+
for (const guard of [{ row: null }, { row: { owner: "kit-alice", incarnation: second }, log: { length: 0, lastEntryId: null } }, { owner: "kit-alice", row: { owner: "kit-alice", incarnation: second } }]) {
|
|
1837
|
+
await thrownBy(() => Reflect.apply(store.delete, store, [id, guard]), `delete with guard ${JSON.stringify(guard)}`);
|
|
1838
|
+
}
|
|
1839
|
+
assert.equal(await store.delete(id, { row: { owner: "kit-alice", incarnation: second } }), true, "its own occupant's guard deletes it");
|
|
1840
|
+
assert.equal(await headOf(store, id), undefined, "the row is gone");
|
|
1841
|
+
});
|
|
1820
1842
|
faceRun("[delete] a row whose head reads and whose open is refused corrupt_session (the openRefusedRow hook) is judged on its head alone: another owner's guard answers false, its owner's answers true and the id answers nothing; the operator's delete, where present, answers false for it first (its head reads)", ["delete", "ownership", "openRefusedRow"], async (store) => {
|
|
1821
1843
|
const id = freshId();
|
|
1822
1844
|
await hooks.openRefusedRow(store, id, "kit-alice");
|
|
@@ -1851,6 +1873,68 @@ async function runSessionStoreContract(make, hooks) {
|
|
|
1851
1873
|
assert.equal(await store.deleteUnreadable(none), false, "no row ⇒ false");
|
|
1852
1874
|
assert.equal(await headOf(store, none), undefined, "and nothing is created under the id");
|
|
1853
1875
|
});
|
|
1876
|
+
faceRun("[readRow] a read sweeps nothing: a session past the store's idle window is still held, and still reads, after another session's read", ["readRow", "idleClock"], async (store) => {
|
|
1877
|
+
const idle = freshId();
|
|
1878
|
+
const read = freshId();
|
|
1879
|
+
await append((await store.acquire(idle)).session, userEntry("i1", null));
|
|
1880
|
+
await append((await store.acquire(read)).session, userEntry("r1", null));
|
|
1881
|
+
await hooks.ageIdle(store, idle);
|
|
1882
|
+
const agedAt = await hooks.idleClockOf(store, idle);
|
|
1883
|
+
assert.ok(agedAt !== undefined, "the aged session is held before the read");
|
|
1884
|
+
assert.ok((await store.readRow(read)) !== undefined, "the read session's row is answered");
|
|
1885
|
+
assert.equal(await hooks.idleClockOf(store, idle), agedAt, "the idle session is still held, its clock where it was: the read evicted nothing");
|
|
1886
|
+
assert.deepEqual((await store.readRow(idle))?.entries.map((e) => e.id), ["i1"], "and its row still reads, its log whole: the read deleted nothing");
|
|
1887
|
+
});
|
|
1888
|
+
faceRun("[readRow] a read is no activity: the read session's idle clock does not move, nor its listed time", ["readRow", "idleClock"], async (store) => {
|
|
1889
|
+
const id = freshId();
|
|
1890
|
+
await append((await store.acquire(id)).session, userEntry("r1", null));
|
|
1891
|
+
await hooks.ageIdle(store, id);
|
|
1892
|
+
const before = await hooks.idleClockOf(store, id);
|
|
1893
|
+
const listedBefore = typeof store.list === "function" ? rowOf(await store.list(), id)?.lastActiveAt : undefined;
|
|
1894
|
+
assert.ok(before !== undefined, "the session is held before the read");
|
|
1895
|
+
assert.ok((await store.readRow(id)) !== undefined, "the row is answered");
|
|
1896
|
+
assert.equal(await hooks.idleClockOf(store, id), before, "the read moved the session's idle clock (or evicted it)");
|
|
1897
|
+
if (typeof store.list === "function")
|
|
1898
|
+
assert.equal(rowOf(await store.list(), id)?.lastActiveAt, listedBefore, "the read moved the session's listed time");
|
|
1899
|
+
});
|
|
1900
|
+
faceRun("[readRow] a read writes nothing: no row, entry, listed time or transcript file appears or changes — an id with no row included", ["readRow"], async (store) => {
|
|
1901
|
+
const id = freshId();
|
|
1902
|
+
const none = freshId();
|
|
1903
|
+
await append((await store.acquire(id)).session, userEntry("r1", null));
|
|
1904
|
+
const dir = store.transcriptDirectory;
|
|
1905
|
+
const files = () => (typeof dir === "string" ? readdirSync(dir, { recursive: true }).map(String).sort().map((f) => `${f}:${statSync(join(dir, f)).size}:${statSync(join(dir, f)).mtimeMs}`) : []);
|
|
1906
|
+
const listed = async () => (typeof store.list === "function" ? (await store.list()).map((r) => `${r.sessionId}:${r.lastActiveAt}`).sort() : []);
|
|
1907
|
+
const head = typeof store.headOf === "function" ? await store.headOf(id) : undefined;
|
|
1908
|
+
const [filesBefore, listedBefore] = [files(), await listed()];
|
|
1909
|
+
await store.readRow(id);
|
|
1910
|
+
assert.equal(await store.readRow(none), undefined, "an id with no row answers no row");
|
|
1911
|
+
assert.deepEqual(files(), filesBefore, "no transcript file appeared or changed");
|
|
1912
|
+
assert.deepEqual(await listed(), listedBefore, "no listed row appeared or moved");
|
|
1913
|
+
if (typeof store.headOf === "function") {
|
|
1914
|
+
assert.deepEqual(await store.headOf(id), head, "the read row's head is the one it had");
|
|
1915
|
+
assert.equal(await store.headOf(none), undefined, "nothing is created under an id with no row");
|
|
1916
|
+
}
|
|
1917
|
+
});
|
|
1918
|
+
faceRun("[readRow] an id with no row resolves undefined — a definite no — and a row resolves its metadata, head and whole log of one generation", ["readRow"], async (store) => {
|
|
1919
|
+
const none = freshId();
|
|
1920
|
+
assert.equal(await store.readRow(none), undefined, "no row ⇒ undefined, never a rejection");
|
|
1921
|
+
const id = freshId();
|
|
1922
|
+
const { session } = await store.acquire(id);
|
|
1923
|
+
await append(session, userEntry("r1", null));
|
|
1924
|
+
await append(session, assistantEntry("r2", "r1"));
|
|
1925
|
+
const row = await store.readRow(id);
|
|
1926
|
+
assert.ok(row !== undefined, "a row ⇒ answered");
|
|
1927
|
+
assert.equal(row.metadata.id, id, "the row's own metadata");
|
|
1928
|
+
assert.deepEqual(row.entries.map((e) => e.id), ["r1", "r2"], "its whole log, oldest first");
|
|
1929
|
+
assert.equal(row.head.leafId, "r2", "its head names the leaf of that log");
|
|
1930
|
+
assert.equal(row.head.incarnation, (await session.getMetadata()).incarnation, "and the occupant the store handed out");
|
|
1931
|
+
});
|
|
1932
|
+
faceRun("[readRow] a row that is there and cannot be read rejects coded (corrupt_session) — never the undefined of no row", ["readRow", "unreadableRow"], async (store) => {
|
|
1933
|
+
const id = freshId();
|
|
1934
|
+
await hooks.unreadableRow(store, id);
|
|
1935
|
+
const answer = await store.readRow(id).then((row) => ({ resolved: row }), (err) => ({ rejected: readMember(err, "code") }));
|
|
1936
|
+
assert.deepEqual(answer, { rejected: "corrupt_session" }, "a row whose header cannot be read is a failed read, told apart from no row");
|
|
1937
|
+
});
|
|
1854
1938
|
await settle();
|
|
1855
1939
|
}
|
|
1856
1940
|
function firstTextBlock(entry) {
|
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
import { type WorkflowJournalStore } from "../workflow-journal-store.js";
|
|
2
2
|
import { type ContractAssertionRunner } from "./contract-harness.js";
|
|
3
|
+
/**
|
|
4
|
+
* Optional backend-specific hooks for the #5156 R1 `stopResumeClaim` arm-(b) contract cases (aging a held claim past its expiry,
|
|
5
|
+
* and — for backends that judge holder-process liveness — marking a held claim's process as gone). A backend that omits hooks
|
|
6
|
+
* still clears arms (a), (c), (d) and the non-writing arm whenever it implements `stopResumeClaim`.
|
|
7
|
+
*/
|
|
8
|
+
export interface WorkflowJournalStoreContractHooks {
|
|
9
|
+
/** Age a held claim on `(sourceRunId, scope)` past its expiry so arm (b) ("expired") runs on the real backend.
|
|
10
|
+
* May return a cleanup callback (e.g. restoring a shifted clock), invoked in a `finally` after the stop call. */
|
|
11
|
+
readonly expireClaim?: (store: WorkflowJournalStore, key: {
|
|
12
|
+
readonly sourceRunId: string;
|
|
13
|
+
readonly scope: string;
|
|
14
|
+
}) => Promise<void | (() => void)> | void | (() => void);
|
|
15
|
+
/** Mark a held claim on `(sourceRunId, scope)` as published by a process proven gone on this host (file-store arm (b)). */
|
|
16
|
+
readonly markClaimHolderGone?: (store: WorkflowJournalStore, key: {
|
|
17
|
+
readonly sourceRunId: string;
|
|
18
|
+
readonly scope: string;
|
|
19
|
+
}) => Promise<void> | void;
|
|
20
|
+
}
|
|
3
21
|
/**
|
|
4
22
|
* The full cross-backend contract for {@link WorkflowJournalStore}. Every case builds its own store via
|
|
5
23
|
* `make()`; with no runner the cases run sequentially and the first failure throws.
|
|
6
24
|
*/
|
|
7
|
-
export declare function workflowJournalStoreContract(make: () => WorkflowJournalStore, runAssertion?: ContractAssertionRunner): Promise<void>;
|
|
25
|
+
export declare function workflowJournalStoreContract(make: () => WorkflowJournalStore, runAssertion?: ContractAssertionRunner, hooks?: WorkflowJournalStoreContractHooks): Promise<void>;
|
|
@@ -24,7 +24,7 @@ const parked = (ordinal, over = {}) => ({
|
|
|
24
24
|
const OVER_CAP = "x".repeat(MAX_JOURNAL_RESULT_BYTES + 1024);
|
|
25
25
|
const isOversizeRefusal = (e) => e instanceof Error && e.code === JOURNAL_OVERSIZE_ERROR_CODE;
|
|
26
26
|
const isIncompatibleRefusal = (e) => e instanceof Error && e.code === JOURNAL_INCOMPATIBLE_ERROR_CODE;
|
|
27
|
-
export async function workflowJournalStoreContract(make, runAssertion) {
|
|
27
|
+
export async function workflowJournalStoreContract(make, runAssertion, hooks) {
|
|
28
28
|
const { run, settle } = beginContract(runAssertion);
|
|
29
29
|
run("append → load returns entries ASCENDING by ordinal, both arms verbatim; a re-append per ordinal OVERWRITES", async () => {
|
|
30
30
|
const store = make();
|
|
@@ -267,5 +267,93 @@ export async function workflowJournalStoreContract(make, runAssertion) {
|
|
|
267
267
|
await store.releaseResumeClaim(one);
|
|
268
268
|
await store.releaseResumeClaim(other);
|
|
269
269
|
});
|
|
270
|
+
run("stopResumeClaim tombstone: absent (a), given holder (c), already tombstone (d), held by another (non-writing), stopped.by on resumeClaim, permanence and scope wall", async () => {
|
|
271
|
+
const store = make();
|
|
272
|
+
if (typeof store.stopResumeClaim !== "function")
|
|
273
|
+
return;
|
|
274
|
+
assert.equal(typeof store.resumeClaim, "function", "a store that implements stopResumeClaim also implements resumeClaim");
|
|
275
|
+
assert.equal(typeof store.releaseResumeClaim, "function", "a store that implements stopResumeClaim also implements releaseResumeClaim");
|
|
276
|
+
assert.deepEqual(await store.stopResumeClaim({ sourceRunId: "stop-a", scope: "tenant-a", stoppedBy: "user" }), { stopped: true });
|
|
277
|
+
const refusedA = await store.resumeClaim({ sourceRunId: "stop-a", newRunId: "run-1", scope: "tenant-a" });
|
|
278
|
+
assert.equal(refusedA.granted, false, "arm (a): resumeClaim on a tombstone is refused");
|
|
279
|
+
assert.deepEqual(refusedA.stopped, { by: "user" }, "arm (a): resumeClaim reports explicit stopped.by");
|
|
280
|
+
assert.equal(refusedA.remainingMs, undefined, "arm (a): a tombstone has no remainingMs");
|
|
281
|
+
assert.equal((await store.resumeClaim({ sourceRunId: "stop-a", newRunId: "run-b", scope: "tenant-b" })).granted, true, "tombstone is isolated to its scope");
|
|
282
|
+
await store.releaseResumeClaim({ sourceRunId: "stop-a", newRunId: "run-b", scope: "tenant-b" });
|
|
283
|
+
for (const candidate of ["run-1", "user", "workflow:stopped", "", ...(refusedA.holder !== undefined ? [refusedA.holder] : [])]) {
|
|
284
|
+
await store.releaseResumeClaim({ sourceRunId: "stop-a", newRunId: candidate, scope: "tenant-a" });
|
|
285
|
+
const check = await store.resumeClaim({ sourceRunId: "stop-a", newRunId: candidate, scope: "tenant-a" });
|
|
286
|
+
assert.equal(check.granted, false, `release by ${JSON.stringify(candidate)} must never delete a tombstone`);
|
|
287
|
+
assert.deepEqual(check.stopped, { by: "user" });
|
|
288
|
+
}
|
|
289
|
+
if (store.deleteRun !== undefined) {
|
|
290
|
+
await store.append("stop-a", "tenant-a", { callKey: key(0), result: completed(0) });
|
|
291
|
+
await store.deleteRun("stop-a", "tenant-a");
|
|
292
|
+
const afterDelete = await store.resumeClaim({ sourceRunId: "stop-a", newRunId: "run-after-del", scope: "tenant-a" });
|
|
293
|
+
assert.equal(afterDelete.granted, false, "deleteRun must not touch tombstones");
|
|
294
|
+
assert.deepEqual(afterDelete.stopped, { by: "user" });
|
|
295
|
+
}
|
|
296
|
+
assert.deepEqual(await store.stopResumeClaim({ sourceRunId: "stop-a", scope: "tenant-a", stoppedBy: "second" }), { stopped: true }, "arm (d): re-stop without holder is idempotent");
|
|
297
|
+
assert.deepEqual(await store.stopResumeClaim({ sourceRunId: "stop-a", scope: "tenant-a", stoppedBy: "third", holder: "foreign" }), { stopped: true }, "arm (d): re-stop with foreign holder is idempotent");
|
|
298
|
+
const afterIdem = await store.resumeClaim({ sourceRunId: "stop-a", newRunId: "run-2", scope: "tenant-a" });
|
|
299
|
+
assert.equal(afterIdem.granted, false);
|
|
300
|
+
assert.deepEqual(afterIdem.stopped, { by: "user" }, "arm (d): original stoppedBy is preserved");
|
|
301
|
+
assert.equal((await store.resumeClaim({ sourceRunId: "stop-c", newRunId: "run-h1", scope: "tenant-a" })).granted, true);
|
|
302
|
+
assert.deepEqual(await store.stopResumeClaim({ sourceRunId: "stop-c", scope: "tenant-a", stoppedBy: "operator", holder: "run-h1" }), { stopped: true }, "arm (c): matching holder rewrites claim into tombstone");
|
|
303
|
+
const formerHolderClaim = await store.resumeClaim({ sourceRunId: "stop-c", newRunId: "run-h1", scope: "tenant-a" });
|
|
304
|
+
assert.equal(formerHolderClaim.granted, false, "arm (c): former holder can no longer re-claim");
|
|
305
|
+
assert.deepEqual(formerHolderClaim.stopped, { by: "operator" });
|
|
306
|
+
await store.releaseResumeClaim({ sourceRunId: "stop-c", newRunId: "run-h1", scope: "tenant-a" });
|
|
307
|
+
const afterFormerRelease = await store.resumeClaim({ sourceRunId: "stop-c", newRunId: "run-h2", scope: "tenant-a" });
|
|
308
|
+
assert.equal(afterFormerRelease.granted, false, "arm (c): former holder's release never deletes the tombstone");
|
|
309
|
+
assert.deepEqual(afterFormerRelease.stopped, { by: "operator" });
|
|
310
|
+
assert.equal((await store.resumeClaim({ sourceRunId: "stop-held", newRunId: "run-live", scope: "tenant-a" })).granted, true);
|
|
311
|
+
assert.deepEqual(await store.stopResumeClaim({ sourceRunId: "stop-held", scope: "tenant-a", stoppedBy: "user" }), { stopped: false, holder: "run-live" }, "non-writing arm (no holder) refuses naming holder");
|
|
312
|
+
assert.deepEqual(await store.stopResumeClaim({ sourceRunId: "stop-held", scope: "tenant-a", stoppedBy: "user", holder: "run-wrong" }), { stopped: false, holder: "run-live" }, "non-writing arm (wrong holder) refuses naming holder");
|
|
313
|
+
assert.equal((await store.resumeClaim({ sourceRunId: "stop-held", newRunId: "run-live", scope: "tenant-a" })).granted, true, "non-writing arm leaves holder's claim intact");
|
|
314
|
+
const stillHeld = await store.resumeClaim({ sourceRunId: "stop-held", newRunId: "run-other", scope: "tenant-a" });
|
|
315
|
+
assert.equal(stillHeld.granted, false);
|
|
316
|
+
assert.equal(stillHeld.stopped, undefined, "non-writing arm wrote no tombstone");
|
|
317
|
+
await store.releaseResumeClaim({ sourceRunId: "stop-held", newRunId: "run-live", scope: "tenant-a" });
|
|
318
|
+
assert.equal((await store.resumeClaim({ sourceRunId: "stop-held", newRunId: "run-other", scope: "tenant-a" })).granted, true, "once released, the untouched claim is free");
|
|
319
|
+
await store.releaseResumeClaim({ sourceRunId: "stop-held", newRunId: "run-other", scope: "tenant-a" });
|
|
320
|
+
assert.deepEqual(await store.stopResumeClaim({ sourceRunId: "team:stop-1", scope: "tenant-a", stoppedBy: "user" }), { stopped: true });
|
|
321
|
+
const oddRefused = await store.resumeClaim({ sourceRunId: "team:stop-1", newRunId: "run-odd", scope: "tenant-a" });
|
|
322
|
+
assert.equal(oddRefused.granted, false);
|
|
323
|
+
assert.deepEqual(oddRefused.stopped, { by: "user" });
|
|
324
|
+
});
|
|
325
|
+
if (hooks?.expireClaim !== undefined) {
|
|
326
|
+
const expireClaim = hooks.expireClaim;
|
|
327
|
+
run("stopResumeClaim tombstone arm (b): an expired claim no longer binds and is replaced with a tombstone", async () => {
|
|
328
|
+
const store = make();
|
|
329
|
+
if (typeof store.stopResumeClaim !== "function")
|
|
330
|
+
return;
|
|
331
|
+
assert.equal((await store.resumeClaim({ sourceRunId: "stop-expired", newRunId: "run-old", scope: "tenant-a" })).granted, true);
|
|
332
|
+
const restore = await expireClaim(store, { sourceRunId: "stop-expired", scope: "tenant-a" });
|
|
333
|
+
try {
|
|
334
|
+
assert.deepEqual(await store.stopResumeClaim({ sourceRunId: "stop-expired", scope: "tenant-a", stoppedBy: "expiry-stop" }), { stopped: true }, "arm (b) expired: replaces non-binding claim with tombstone");
|
|
335
|
+
}
|
|
336
|
+
finally {
|
|
337
|
+
restore?.();
|
|
338
|
+
}
|
|
339
|
+
const refused = await store.resumeClaim({ sourceRunId: "stop-expired", newRunId: "run-new", scope: "tenant-a" });
|
|
340
|
+
assert.equal(refused.granted, false);
|
|
341
|
+
assert.deepEqual(refused.stopped, { by: "expiry-stop" });
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
if (hooks?.markClaimHolderGone !== undefined) {
|
|
345
|
+
const markClaimHolderGone = hooks.markClaimHolderGone;
|
|
346
|
+
run("stopResumeClaim tombstone arm (b): a claim whose holder process is proven gone no longer binds and is replaced with a tombstone", async () => {
|
|
347
|
+
const store = make();
|
|
348
|
+
if (typeof store.stopResumeClaim !== "function")
|
|
349
|
+
return;
|
|
350
|
+
assert.equal((await store.resumeClaim({ sourceRunId: "stop-gone", newRunId: "run-dead-proc", scope: "tenant-a" })).granted, true);
|
|
351
|
+
await markClaimHolderGone(store, { sourceRunId: "stop-gone", scope: "tenant-a" });
|
|
352
|
+
assert.deepEqual(await store.stopResumeClaim({ sourceRunId: "stop-gone", scope: "tenant-a", stoppedBy: "crash-stop" }), { stopped: true }, "arm (b) holder gone: replaces non-binding claim with tombstone");
|
|
353
|
+
const refused = await store.resumeClaim({ sourceRunId: "stop-gone", newRunId: "run-new", scope: "tenant-a" });
|
|
354
|
+
assert.equal(refused.granted, false);
|
|
355
|
+
assert.deepEqual(refused.stopped, { by: "crash-stop" });
|
|
356
|
+
});
|
|
357
|
+
}
|
|
270
358
|
await settle();
|
|
271
359
|
}
|
|
@@ -400,6 +400,13 @@ export type TaskEvent = ({
|
|
|
400
400
|
} & TaskEventIdentity) | ({
|
|
401
401
|
type: "reasoning_delta";
|
|
402
402
|
delta: string;
|
|
403
|
+
} & TaskEventIdentity) | ({
|
|
404
|
+
/** A REASONING SEGMENT is complete — `text_end`'s twin for `reasoning_delta`: the brain closed the thinking block (OpenAI:
|
|
405
|
+
* when answer text starts/resumes or at attempt exit; Anthropic/Open-Responses: on provider block/item close or attempt exit;
|
|
406
|
+
* reasoning after text began is its own segment). `content` = full segment text, untrusted, non-empty only; absent if a custom brain
|
|
407
|
+
* emits none or the Runner's call guardrail / loop relay timer cuts first (terminal follows). Live `contentIndex` is arrival order, not saved index. */
|
|
408
|
+
type: "reasoning_end";
|
|
409
|
+
content: string;
|
|
403
410
|
} & TaskEventIdentity) | ({
|
|
404
411
|
type: "tool_start";
|
|
405
412
|
toolCallId: string;
|
|
@@ -1554,9 +1561,10 @@ export type TaskEvent = ({
|
|
|
1554
1561
|
tree?: string;
|
|
1555
1562
|
}>;
|
|
1556
1563
|
/** This leg's project identity, decided ONCE at leg start and fixed for the leg: `marker` = the checkout's
|
|
1557
|
-
* `.sema/project` (a `TaskSpec.
|
|
1558
|
-
*
|
|
1559
|
-
*
|
|
1564
|
+
* `.sema/project` (a `TaskSpec.project.id`, when given, equals it); `declared` = the number this leg was given —
|
|
1565
|
+
* by its host's `TaskSpec.project.id`, or, for a delegated child that declared nothing and whose own workspace
|
|
1566
|
+
* has no marker, the project seat of the leg that spawned it (a woken agent: the leg that woke it). ABSENT = none of the three, or the marker could not be
|
|
1567
|
+
* read (the deployment's `onError` was told which file and why). */
|
|
1560
1568
|
project?: {
|
|
1561
1569
|
id: string;
|
|
1562
1570
|
source: "marker" | "declared";
|
|
@@ -2,6 +2,9 @@ import type { MailboxAppendMessage, MailboxStore } from "./mailbox-store.js";
|
|
|
2
2
|
import { type EngineNotice } from "./engine-notice.js";
|
|
3
3
|
import type { DelegationUnreviewed } from "./classifier-unavailable-arm.js";
|
|
4
4
|
import type { TaskEvent } from "./task-event.js";
|
|
5
|
+
import { type SemaTaskType } from "./task-registry-shared.js";
|
|
6
|
+
import { type A2AWaitingFor } from "./a2a-task-state.js";
|
|
7
|
+
import type { AskDestination } from "./mcp-server-spec.js";
|
|
5
8
|
import { ONE_SHOT_WAIT_CEILING_DEFAULT_MS } from "../config/defaults.js";
|
|
6
9
|
export { ONE_SHOT_WAIT_CEILING_DEFAULT_MS };
|
|
7
10
|
/** The TERMINAL words of {@link TaskNotificationStatus}: the one table every "is this frame a completion?"
|
|
@@ -67,7 +70,7 @@ export interface TaskNotificationPayload {
|
|
|
67
70
|
* externally injected event, and the input type ({@link ExternalNotificationInput}) deliberately has
|
|
68
71
|
* no `task_type` field, so an outside producer can never wear an internal lane's type (a caller-declared
|
|
69
72
|
* "background_bash completed" impersonating a real child). */
|
|
70
|
-
task_type:
|
|
73
|
+
task_type: SemaTaskType | "external";
|
|
71
74
|
toolUseId?: string;
|
|
72
75
|
status: TaskNotificationStatus;
|
|
73
76
|
/** design/135 G2 (Monitor): the batched stdout lines of ONE `status:"event"` notification (lines that
|
|
@@ -89,6 +92,8 @@ export interface TaskNotificationPayload {
|
|
|
89
92
|
* born child's woken cycles (2, 3, … — its first cycle sends no notification).
|
|
90
93
|
* - `external`: caller-supplied verbatim ({@link ExternalNotificationInput.seq}) — the injector's
|
|
91
94
|
* own dedup discriminator across same-task_id+status events.
|
|
95
|
+
* - `peer_task`: per-row monotonically increasing counter (`lastSeq + 1` on every progress, reminder,
|
|
96
|
+
* reschedule, terminal, and overdue-tail frame, starting at 1, never reused).
|
|
92
97
|
* Consumers (server inbox fold / shell render) key `taskId:status[:seq]` — a frame WITHOUT seq keeps
|
|
93
98
|
* the old two-part key (single-cycle semantics), by contract. */
|
|
94
99
|
seq?: number;
|
|
@@ -104,9 +109,8 @@ export interface TaskNotificationPayload {
|
|
|
104
109
|
stoppedBy?: "user" | "parent" | "system" | (string & {});
|
|
105
110
|
/** Present only as `true`, minted by the engine: this frame must not start a turn of an idle session on its own — a host that
|
|
106
111
|
* wakes an idle session for a completion keeps this one for the session's next turn that something else starts (a person's
|
|
107
|
-
* message, a still-open run).
|
|
108
|
-
*
|
|
109
|
-
* engine version mints it yet (the peer-task lane will); ABSENT = handle the frame as before. */
|
|
112
|
+
* message, a still-open run). Minted by {@link peerTaskNotification} iff an overdue-tail late `event` arrives from an
|
|
113
|
+
* `outside` peer (wired when the peer-task lane launches); ABSENT = handle the frame as before. */
|
|
110
114
|
noWake?: true;
|
|
111
115
|
summary: string;
|
|
112
116
|
/** RB-386① — the failure reason DIGEST on a `status:"failed"` terminal notification
|
|
@@ -219,6 +223,11 @@ export interface TaskNotificationPayload {
|
|
|
219
223
|
recentSteps?: import("../agents/subagent-steps.js").SubagentStep[];
|
|
220
224
|
/** Residual lane D (core half) — files the child mutated with edit counts. Background-agent lane only. */
|
|
221
225
|
editedFiles?: import("../agents/subagent-steps.js").SubagentEditedFile[];
|
|
226
|
+
/** What the child did, counted over its whole event stream (`SubagentActions`: tool calls by tool, the shell commands with
|
|
227
|
+
* their exit codes, the files it changed — `none` included), rendered as the `<actions>` section beside the child's own
|
|
228
|
+
* words. Present only on a terminal frame of the background-agent lane whose parent run declares a member ledger
|
|
229
|
+
* (`TaskSpec.runLedger`); absent on every other frame, so a run without one reads its notifications unchanged. */
|
|
230
|
+
actions?: import("./actions-digest.js").SubagentActions;
|
|
222
231
|
/** How the child ended — the background agent row's outcome (`MemberOutcome`), the one object the row, this frame and the
|
|
223
232
|
* parent's report read: its ending word and its ONE refusal record (asks nobody could answer, calls a person or anything else
|
|
224
233
|
* refused, a verdict that never landed, a person's halt). Present on a terminal frame of the background-agent lane whenever the
|
|
@@ -265,6 +274,10 @@ export interface TaskNotificationPayload {
|
|
|
265
274
|
* re-judges the frame under the same sender at the drain. Engine-read; never rendered. */
|
|
266
275
|
senderKey?: string;
|
|
267
276
|
};
|
|
277
|
+
/** Facade carried on `task_type: "peer_task"` frames (named `peerTask` because {@link peer} is SendMessage's
|
|
278
|
+
* hop-chain carrier). Core fields are minted by the peer-task lane; `reminder` is reserved for the reminder
|
|
279
|
+
* producer, and `peerFinalBy` / `approvalBy` / `clock` are reserved for the deadline-extension producer. */
|
|
280
|
+
peerTask?: PeerTaskNotification;
|
|
268
281
|
/**
|
|
269
282
|
* design/385 §1.4 d1 — the delegated-child → parent UPLINK carrier (`SendMessage("main")`). Its
|
|
270
283
|
* PRESENCE is the render discriminator: the frame reaches the parent's model as a top-level
|
|
@@ -716,16 +729,90 @@ export declare const SHORT_REPORT_UNSTORED = "a background task's report could n
|
|
|
716
729
|
export declare function completionResultField(result: string | undefined, persist: (report: string) => Promise<import("./tool-result-store.js").TaskArtifact>, record: (ref: string) => void, notifier: Pick<import("./safe-notify.js").SafeNotifier, "notifyAsync">): Promise<{
|
|
717
730
|
readonly text: string;
|
|
718
731
|
} | undefined>;
|
|
719
|
-
/**
|
|
720
|
-
export declare const
|
|
732
|
+
/** Whether a peer accepts follow-up messages on a dispatched `peer_task`. */
|
|
733
|
+
export declare const PEER_TASK_FOLLOW_UPS: readonly ["accepted", "not_accepted"];
|
|
734
|
+
export type PeerTaskFollowUps = (typeof PEER_TASK_FOLLOW_UPS)[number];
|
|
735
|
+
/** Cancellation state of a `peer_task` row. */
|
|
736
|
+
export declare const PEER_TASK_CANCEL_STATES: readonly ["not_requested", "requested", "confirmed"];
|
|
737
|
+
export type PeerTaskCancelState = (typeof PEER_TASK_CANCEL_STATES)[number];
|
|
738
|
+
/** Peer-reported deadline clock state (`sema.deadline.clock`); not minted in this release. */
|
|
739
|
+
export declare const PEER_TASK_CLOCK_STATES: readonly ["running", "paused"];
|
|
740
|
+
export type PeerTaskClockState = (typeof PEER_TASK_CLOCK_STATES)[number];
|
|
741
|
+
/** Target of a `peer_task` reminder; not minted in this release. */
|
|
742
|
+
export declare const PEER_TASK_REMINDER_TARGETS: readonly ["peer", "peer_owner", "peer_approver"];
|
|
743
|
+
export type PeerTaskReminderTarget = (typeof PEER_TASK_REMINDER_TARGETS)[number];
|
|
744
|
+
/** Disposition of one `peer_task` reminder attempt; not minted in this release. */
|
|
745
|
+
export declare const PEER_TASK_REMINDER_DISPOSITIONS: readonly ["due", "skipped_not_sent", "sent", "received", "answered"];
|
|
746
|
+
export type PeerTaskReminderDisposition = (typeof PEER_TASK_REMINDER_DISPOSITIONS)[number];
|
|
747
|
+
/** Where the serving peer routed a received/answered reminder; not minted in this release. */
|
|
748
|
+
export declare const PEER_TASK_REMINDER_ROUTES: readonly ["pending_list", "run", "none"];
|
|
749
|
+
export type PeerTaskReminderRoute = (typeof PEER_TASK_REMINDER_ROUTES)[number];
|
|
750
|
+
/** Reminder disposition facet on a reminder `event` frame; not minted in this release. */
|
|
751
|
+
export interface PeerTaskReminderFacet {
|
|
752
|
+
readonly n: number;
|
|
753
|
+
readonly target: PeerTaskReminderTarget;
|
|
754
|
+
readonly disposition: PeerTaskReminderDisposition;
|
|
755
|
+
/** Present only when `disposition` is `"received"` or `"answered"`; not minted in this release. */
|
|
756
|
+
readonly routedTo?: PeerTaskReminderRoute;
|
|
757
|
+
}
|
|
758
|
+
/** Facade on `task_type: "peer_task"` notification frames. Every member is optional on the wire shape;
|
|
759
|
+
* `reminder` and `peerFinalBy` / `approvalBy` / `clock` are reserved and not minted in this release. */
|
|
760
|
+
export interface PeerTaskNotification {
|
|
761
|
+
readonly destination?: AskDestination;
|
|
762
|
+
readonly followUps?: PeerTaskFollowUps;
|
|
763
|
+
readonly cancel?: PeerTaskCancelState;
|
|
764
|
+
readonly waitingFor?: A2AWaitingFor;
|
|
765
|
+
readonly remoteMayContinue?: true;
|
|
766
|
+
readonly ackBy?: number;
|
|
767
|
+
readonly finalBy?: number;
|
|
768
|
+
/** Reserved for deadline-extension responses; not minted in this release. */
|
|
769
|
+
readonly peerFinalBy?: number;
|
|
770
|
+
/** Reserved for deadline-extension responses; not minted in this release. */
|
|
771
|
+
readonly approvalBy?: number;
|
|
772
|
+
/** Reserved for deadline-extension responses; not minted in this release. */
|
|
773
|
+
readonly clock?: PeerTaskClockState;
|
|
774
|
+
/** Reserved for reminder frames; not minted in this release. */
|
|
775
|
+
readonly reminder?: PeerTaskReminderFacet;
|
|
776
|
+
}
|
|
777
|
+
/** Input to {@link peerTaskNotification} (internal builder; reserved reminder and deadline-extension members are excluded). */
|
|
778
|
+
export interface PeerTaskNotificationInput {
|
|
779
|
+
readonly task_id: string;
|
|
780
|
+
readonly status: TaskNotificationStatus;
|
|
781
|
+
readonly seq: number;
|
|
782
|
+
readonly summary: string;
|
|
783
|
+
readonly result?: string;
|
|
784
|
+
readonly error?: string;
|
|
785
|
+
readonly errorCode?: string;
|
|
786
|
+
readonly stoppedBy?: TaskNotificationPayload["stoppedBy"];
|
|
787
|
+
readonly outcome?: import("./member-outcome.js").MemberOutcome;
|
|
788
|
+
readonly completionId?: string;
|
|
789
|
+
/** True iff this `status: "event"` frame carries a late result arriving inside the overdue tail. */
|
|
790
|
+
readonly overdueTail?: boolean;
|
|
791
|
+
readonly peerTask: {
|
|
792
|
+
readonly destination: AskDestination;
|
|
793
|
+
readonly followUps: PeerTaskFollowUps;
|
|
794
|
+
readonly cancel: PeerTaskCancelState;
|
|
795
|
+
readonly ackBy: number;
|
|
796
|
+
readonly finalBy: number;
|
|
797
|
+
readonly waitingFor?: A2AWaitingFor;
|
|
798
|
+
readonly remoteMayContinue?: true;
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
/** Pure builder for `peer_task` frames (internal to core; no live run emits outward frames in this release).
|
|
802
|
+
* Mints `noWake: true` iff `overdueTail === true && status === "event" && destination.boundary === "outside"`.
|
|
803
|
+
* Never mints reserved reminder or deadline-extension members (`peerFinalBy`, `approvalBy`, `clock`, `reminder`). */
|
|
804
|
+
export declare function peerTaskNotification(input: PeerTaskNotificationInput): TaskNotificationPayload;
|
|
805
|
+
/** Highest `engine_frame` codec version this engine reads (D1-b: writer picks the lowest readable version per frame). */
|
|
806
|
+
export declare const ENGINE_FRAME_CODEC_VERSION = 2;
|
|
721
807
|
/** The engine's own lanes — the only frames the durable park may encode (an `external` event never is). */
|
|
722
|
-
export declare const ENGINE_FRAME_TASK_TYPES: readonly ["background_agent", "monitor", "workflow"];
|
|
808
|
+
export declare const ENGINE_FRAME_TASK_TYPES: readonly ["background_agent", "monitor", "workflow", "peer_task"];
|
|
809
|
+
/** Lowest codec version whose reader understands `taskType` (D1-b: v2 for `peer_task`, v1 for the three original lanes). */
|
|
810
|
+
export declare function engineFrameCodecVersionFor(taskType: TaskNotificationPayload["task_type"]): number;
|
|
723
811
|
/** May this frame take the durable engine-frame park? Its lane must be one of the engine's own and it
|
|
724
812
|
* must wear no shell-less carrier. */
|
|
725
813
|
export declare function isEngineFrameParkable(payload: TaskNotificationPayload): boolean;
|
|
726
|
-
/** The record text of a durably parked engine frame: the codec version
|
|
727
|
-
*
|
|
728
|
-
* from the box seq, carried inside untouched). */
|
|
814
|
+
/** The record text of a durably parked engine frame: the lowest codec version that reads this lane
|
|
815
|
+
* ({@link engineFrameCodecVersionFor}), the injection tier, and the frame itself. */
|
|
729
816
|
export declare function encodeEngineFrame(payload: TaskNotificationPayload, priority: SystemInjectionPriority): string;
|
|
730
817
|
export type EngineFrameDecode = {
|
|
731
818
|
ok: true;
|