@sema-agent/core 7.58.0 → 7.60.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 +1340 -0
- package/README.md +6 -4
- package/dist/agents/agent-definition.d.ts +7 -0
- package/dist/agents/agent-definition.js +12 -0
- package/dist/agents/agent-transcript-tool.d.ts +2 -1
- package/dist/agents/agent-transcript-tool.js +3 -1
- package/dist/agents/cc-peer-directory.js +8 -8
- package/dist/agents/child-model-seat.d.ts +4 -2
- package/dist/agents/child-model-seat.js +9 -4
- package/dist/agents/cumulative-stats.js +0 -1
- package/dist/agents/inherited-tool-pool.d.ts +26 -1
- package/dist/agents/inherited-tool-pool.js +22 -0
- package/dist/agents/peer-directory.d.ts +9 -0
- package/dist/agents/peer-directory.js +6 -2
- package/dist/agents/retain-ledger.d.ts +11 -1
- package/dist/agents/retain-ledger.js +13 -2
- package/dist/agents/roster-store.d.ts +1 -1
- package/dist/agents/roster-store.js +3 -1
- package/dist/agents/send-message-tool.d.ts +8 -19
- package/dist/agents/send-message-tool.js +32 -50
- package/dist/agents/subagent.d.ts +51 -17
- package/dist/agents/subagent.js +150 -112
- package/dist/agents/tool-filter.d.ts +1 -3
- package/dist/agents/tool-filter.js +4 -12
- package/dist/bench/metrics.d.ts +3 -5
- package/dist/bench/metrics.js +0 -1
- package/dist/brain/anthropic.js +161 -45
- package/dist/brain/degrading.js +3 -1
- package/dist/brain/errors.d.ts +9 -3
- package/dist/brain/errors.js +7 -1
- package/dist/brain/failover.js +2 -1
- package/dist/brain/open-responses.js +3 -3
- package/dist/brain/openai.js +103 -53
- package/dist/brain/provider-dialect.d.ts +11 -0
- package/dist/brain/provider-dialect.js +5 -2
- package/dist/brain/reasoning-request.js +5 -4
- package/dist/brain/reasoning.d.ts +19 -0
- package/dist/brain/reasoning.js +17 -2
- package/dist/brain/request-route.d.ts +4 -1
- package/dist/brain/request-route.js +4 -1
- package/dist/brain/route-adjudicator.d.ts +84 -18
- package/dist/brain/route-adjudicator.js +90 -22
- package/dist/brain/route-conformance.js +1 -1
- package/dist/brain/status-sink.d.ts +7 -1
- package/dist/brain/status-sink.js +6 -0
- package/dist/brain/stream-engine.js +84 -49
- package/dist/brain/stream-shared.d.ts +30 -0
- package/dist/brain/stream-shared.js +34 -1
- package/dist/brain/timeout.d.ts +65 -6
- package/dist/brain/timeout.js +111 -11
- package/dist/core/a2a.d.ts +15 -5
- package/dist/core/a2a.js +34 -19
- package/dist/core/account-row.d.ts +61 -0
- package/dist/core/account-row.js +51 -0
- package/dist/core/advisor-verdict.d.ts +2 -1
- package/dist/core/advisor-verdict.js +1 -1
- package/dist/core/agent-definition.d.ts +20 -0
- package/dist/core/allow-entry.d.ts +20 -6
- package/dist/core/allow-entry.js +17 -7
- package/dist/core/approval-object.d.ts +29 -15
- package/dist/core/approval-object.js +47 -19
- package/dist/core/artifact-host.d.ts +0 -2
- package/dist/core/artifact-host.js +0 -1
- package/dist/core/auto-compaction.js +1 -1
- package/dist/core/auto-mode-defaults.d.ts +8 -0
- package/dist/core/auto-mode-defaults.js +1 -0
- package/dist/core/auto-mode-rebuild.d.ts +2 -1
- package/dist/core/auto-mode.d.ts +39 -4
- package/dist/core/auto-mode.js +63 -12
- package/dist/core/background-agent-store.d.ts +26 -4
- package/dist/core/background-agent-store.js +3 -2
- package/dist/core/background-shell.d.ts +12 -1
- package/dist/core/background-shell.js +12 -0
- package/dist/core/checkpoint-requirements.d.ts +13 -1
- package/dist/core/checkpoint-requirements.js +3 -1
- package/dist/core/checkpoint-store.d.ts +66 -25
- package/dist/core/checkpoint-store.js +22 -9
- package/dist/core/child-clamp-seats.d.ts +29 -0
- package/dist/core/child-clamp-seats.js +56 -1
- package/dist/core/compliance.d.ts +3 -3
- package/dist/core/compliance.js +1 -1
- package/dist/core/credential-echo.d.ts +52 -0
- package/dist/core/credential-echo.js +65 -0
- package/dist/core/credential-vocabulary.d.ts +13 -3
- package/dist/core/credential-vocabulary.js +12 -4
- package/dist/core/cross-boundary-taint.d.ts +4 -5
- package/dist/core/effective-path-target.d.ts +8 -2
- package/dist/core/effective-path-target.js +8 -3
- package/dist/core/engine-notice.d.ts +156 -23
- package/dist/core/engine-notice.js +19 -5
- package/dist/core/frame-settlement.d.ts +5 -0
- package/dist/core/frame-settlement.js +4 -0
- package/dist/core/gate-fold.js +8 -6
- package/dist/core/gate-lanes.js +47 -12
- package/dist/core/gate-outcome.d.ts +32 -3
- package/dist/core/gate-outcome.js +19 -1
- package/dist/core/governance-codes.d.ts +17 -1
- package/dist/core/governance-codes.js +25 -0
- package/dist/core/hands-band-screen.js +0 -1
- package/dist/core/hands-band.d.ts +0 -3
- package/dist/core/hooks.d.ts +70 -59
- package/dist/core/hooks.js +125 -80
- package/dist/core/image-admission.d.ts +106 -52
- package/dist/core/image-admission.js +184 -56
- package/dist/core/image-downsample.d.ts +36 -69
- package/dist/core/image-downsample.js +111 -73
- package/dist/core/integer-option.d.ts +21 -0
- package/dist/core/integer-option.js +13 -0
- package/dist/core/locked-config.d.ts +59 -5
- package/dist/core/locked-config.js +82 -50
- package/dist/core/mailbox-store.d.ts +45 -1
- package/dist/core/mailbox-store.js +53 -9
- package/dist/core/mcp-call-meta.d.ts +2 -2
- package/dist/core/mcp-call-meta.js +9 -10
- package/dist/core/mcp-failure.d.ts +122 -20
- package/dist/core/mcp-failure.js +73 -5
- package/dist/core/mcp-host-seat.d.ts +92 -0
- package/dist/core/mcp-host-seat.js +131 -0
- package/dist/core/mcp-probe.d.ts +7 -2
- package/dist/core/mcp-probe.js +7 -2
- package/dist/core/mcp-server-link.d.ts +22 -1
- package/dist/core/mcp-server-link.js +25 -1
- package/dist/core/mcp-server-spec.d.ts +38 -9
- package/dist/core/mcp-server-spec.js +55 -21
- package/dist/core/mcp.d.ts +27 -12
- package/dist/core/mcp.js +105 -76
- package/dist/core/memory-admission.d.ts +23 -6
- package/dist/core/memory-admission.js +19 -9
- package/dist/core/memory-engine/consolidation-driver.d.ts +2 -4
- package/dist/core/memory-engine/consolidation-driver.js +3 -3
- package/dist/core/memory-engine/consolidation.d.ts +4 -0
- package/dist/core/memory-engine/consolidation.js +1 -0
- package/dist/core/memory-engine/content-origin.d.ts +13 -0
- package/dist/core/memory-engine/content-origin.js +21 -3
- package/dist/core/memory-engine/delegation-settlement.js +5 -12
- package/dist/core/memory-engine/distiller.js +2 -2
- package/dist/core/memory-engine/dual-root.d.ts +50 -1
- package/dist/core/memory-engine/dual-root.js +44 -1
- package/dist/core/memory-engine/engine.d.ts +67 -14
- package/dist/core/memory-engine/engine.js +384 -212
- package/dist/core/memory-engine/export-bundle.d.ts +23 -0
- package/dist/core/memory-engine/export-bundle.js +23 -4
- package/dist/core/memory-engine/file-backend.d.ts +128 -55
- package/dist/core/memory-engine/file-backend.js +290 -117
- package/dist/core/memory-engine/index.d.ts +3 -2
- package/dist/core/memory-engine/index.js +2 -1
- package/dist/core/memory-engine/layout.d.ts +59 -11
- package/dist/core/memory-engine/layout.js +190 -40
- package/dist/core/memory-engine/memory-backend-contract.d.ts +1 -1
- package/dist/core/memory-engine/memory-backend-contract.js +39 -2
- package/dist/core/memory-engine/scope-contract.d.ts +13 -3
- package/dist/core/memory-engine/scope-contract.js +2 -2
- package/dist/core/memory-engine/sync-client.d.ts +51 -9
- package/dist/core/memory-engine/sync-client.js +107 -13
- package/dist/core/memory-engine/sync-report.d.ts +103 -0
- package/dist/core/memory-engine/sync-report.js +119 -0
- package/dist/core/memory-engine/sync.d.ts +8 -1
- package/dist/core/memory-engine/types.d.ts +6 -0
- package/dist/core/mode-policy.d.ts +9 -1
- package/dist/core/mode-policy.js +11 -1
- package/dist/core/model-receipt.d.ts +39 -0
- package/dist/core/model-receipt.js +139 -0
- package/dist/core/mods/agent-stations.d.ts +65 -0
- package/dist/core/mods/agent-stations.js +105 -0
- package/dist/core/mods/classic-events.d.ts +5 -1
- package/dist/core/mods/kernel/dispatch.d.ts +5 -1
- package/dist/core/mods/kernel/dispatch.js +6 -5
- package/dist/core/mods/kernel/events.d.ts +11 -4
- package/dist/core/mods/kernel/events.js +11 -7
- package/dist/core/mods/kernel/receive.d.ts +5 -0
- package/dist/core/mods/kernel/receive.js +10 -0
- package/dist/core/mods/kernel/registration.d.ts +4 -0
- package/dist/core/mods/kernel/registration.js +3 -0
- package/dist/core/mods/lifecycle-stations.d.ts +41 -0
- package/dist/core/mods/lifecycle-stations.js +35 -0
- package/dist/core/mods/stations.d.ts +73 -60
- package/dist/core/mods/stations.js +64 -40
- package/dist/core/mods/tool-call.d.ts +10 -4
- package/dist/core/mods/tool-call.js +28 -12
- package/dist/core/mounted-mcp.d.ts +5 -0
- package/dist/core/mounted-mcp.js +2 -2
- package/dist/core/namespaced-rule-name.d.ts +7 -1
- package/dist/core/namespaced-rule-name.js +13 -2
- package/dist/core/oracle-isolation.js +1 -1
- package/dist/core/own-property-receipt.d.ts +3 -0
- package/dist/core/own-property-receipt.js +3 -0
- package/dist/core/parent-spec-seat.d.ts +8 -3
- package/dist/core/parent-spec-seat.js +2 -0
- package/dist/core/park-selfcheck.js +14 -8
- package/dist/core/peer-seat.d.ts +133 -16
- package/dist/core/peer-seat.js +319 -42
- package/dist/core/permission-rule-consent.d.ts +0 -21
- package/dist/core/permission-rule-consent.js +11 -6
- package/dist/core/permission-rule-model.d.ts +20 -2
- package/dist/core/permission-rule-model.js +8 -7
- package/dist/core/present-plan-tool.d.ts +11 -3
- package/dist/core/present-plan-tool.js +2 -2
- package/dist/core/protocol-http-auth.d.ts +14 -2
- package/dist/core/protocol-http-auth.js +16 -7
- package/dist/core/read-face-seats.d.ts +7 -5
- package/dist/core/read-face-seats.js +4 -1
- package/dist/core/redaction-marks.d.ts +4 -3
- package/dist/core/redaction-marks.js +2 -2
- package/dist/core/remote-env.d.ts +146 -98
- package/dist/core/remote-env.js +113 -14
- package/dist/core/resume-startup-cause.js +1 -0
- package/dist/core/retention.js +37 -12
- package/dist/core/retired-keys.d.ts +6 -1
- package/dist/core/retired-keys.js +4 -1
- package/dist/core/rewrite-rejudge.d.ts +13 -5
- package/dist/core/rewrite-rejudge.js +9 -5
- package/dist/core/roles.d.ts +69 -3
- package/dist/core/roles.js +167 -80
- package/dist/core/rule-owner.d.ts +3 -0
- package/dist/core/runner/announce-once-ledger.d.ts +5 -4
- package/dist/core/runner/announce-once-ledger.js +4 -2
- package/dist/core/runner/assemble-result.d.ts +0 -5
- package/dist/core/runner/assemble-result.js +0 -1
- package/dist/core/runner/call-hook-stations.d.ts +17 -10
- package/dist/core/runner/call-hook-stations.js +23 -12
- package/dist/core/runner/child-tree.d.ts +7 -8
- package/dist/core/runner/child-tree.js +6 -6
- package/dist/core/runner/classifier-ladder.d.ts +10 -2
- package/dist/core/runner/classifier-ladder.js +39 -8
- package/dist/core/runner/construction-doors.js +5 -0
- package/dist/core/runner/contracts.d.ts +82 -57
- package/dist/core/runner/credential-origin-seat.js +4 -3
- package/dist/core/runner/cross-boundary-lane.d.ts +3 -5
- package/dist/core/runner/cross-boundary-lane.js +11 -2
- package/dist/core/runner/cwd-alignment-probe.d.ts +20 -0
- package/dist/core/runner/cwd-alignment-probe.js +21 -0
- package/dist/core/runner/decide-continuation.d.ts +2 -2
- package/dist/core/runner/env-capability-census.d.ts +15 -20
- package/dist/core/runner/env-capability-census.js +25 -34
- package/dist/core/runner/file-history-request.d.ts +2 -2
- package/dist/core/runner/file-history-request.js +0 -8
- package/dist/core/runner/gate-exit.d.ts +87 -11
- package/dist/core/runner/gate-exit.js +30 -8
- package/dist/core/runner/git-status-frame.d.ts +5 -2
- package/dist/core/runner/git-status-frame.js +3 -4
- package/dist/core/runner/image-removed-seat.d.ts +12 -0
- package/dist/core/runner/image-removed-seat.js +19 -0
- package/dist/core/runner/image.d.ts +7 -2
- package/dist/core/runner/image.js +14 -8
- package/dist/core/runner/inline-image.d.ts +10 -8
- package/dist/core/runner/inline-image.js +11 -9
- package/dist/core/runner/memory-consolidation-driver.js +5 -5
- package/dist/core/runner/park-commit.d.ts +1 -1
- package/dist/core/runner/park-commit.js +3 -0
- package/dist/core/runner/permission-rule-lanes.js +1 -1
- package/dist/core/runner/prepare-ask-lane.d.ts +1 -1
- package/dist/core/runner/prepare-ask-lane.js +2 -1
- package/dist/core/runner/prepare-boundary-parks.d.ts +2 -2
- package/dist/core/runner/prepare-boundary-parks.js +5 -5
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +7 -5
- package/dist/core/runner/prepare-caps-and-workflow.js +6 -3
- package/dist/core/runner/prepare-config-doors.d.ts +6 -1
- package/dist/core/runner/prepare-config-doors.js +16 -9
- package/dist/core/runner/prepare-context-lane.js +2 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +9 -3
- package/dist/core/runner/prepare-delegation-surface.js +5 -4
- package/dist/core/runner/prepare-file-history.d.ts +10 -12
- package/dist/core/runner/prepare-file-history.js +3 -12
- package/dist/core/runner/prepare-gate-stations.d.ts +4 -3
- package/dist/core/runner/prepare-gate-stations.js +4 -3
- package/dist/core/runner/prepare-hands-readface.d.ts +7 -1
- package/dist/core/runner/prepare-hands-readface.js +19 -6
- package/dist/core/runner/prepare-inherited-gate.d.ts +6 -7
- package/dist/core/runner/prepare-inherited-gate.js +22 -31
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-memory.d.ts +2 -2
- package/dist/core/runner/prepare-memory.js +12 -19
- package/dist/core/runner/prepare-park-ask.d.ts +4 -6
- package/dist/core/runner/prepare-park-ask.js +5 -9
- package/dist/core/runner/prepare-policy-chain.d.ts +8 -7
- package/dist/core/runner/prepare-policy-chain.js +136 -121
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-project-context.js +10 -7
- package/dist/core/runner/prepare-prompt-inputs.d.ts +5 -2
- package/dist/core/runner/prepare-prompt-inputs.js +10 -20
- package/dist/core/runner/prepare-protocol-tools.d.ts +5 -3
- package/dist/core/runner/prepare-protocol-tools.js +17 -2
- package/dist/core/runner/prepare-run-refs.d.ts +2 -3
- package/dist/core/runner/prepare-run-refs.js +4 -1
- package/dist/core/runner/prepare-suspend-saga.d.ts +0 -2
- package/dist/core/runner/prepare-suspend-saga.js +5 -7
- package/dist/core/runner/prepare-task.js +44 -28
- package/dist/core/runner/prepare-turn-wiring.d.ts +2 -0
- package/dist/core/runner/prepare-turn-wiring.js +7 -2
- package/dist/core/runner/prepare-wiring-manifest.d.ts +5 -4
- package/dist/core/runner/prepare-wiring-manifest.js +34 -19
- package/dist/core/runner/prepare-workspace-restore.js +3 -3
- package/dist/core/runner/reply-pricing.d.ts +30 -0
- package/dist/core/runner/reply-pricing.js +19 -0
- package/dist/core/runner/resume-admission.js +4 -2
- package/dist/core/runner/resume-apply.js +6 -1
- package/dist/core/runner/resume-checkpoint-screen.js +4 -4
- package/dist/core/runner/resume-policy-outcome.js +5 -5
- package/dist/core/runner/retired-runner-deps.js +4 -1
- package/dist/core/runner/role-seat-defaulted.d.ts +44 -0
- package/dist/core/runner/role-seat-defaulted.js +40 -0
- package/dist/core/runner/run-attachment-seats.js +3 -3
- package/dist/core/runner/run-brain-sinks.js +3 -0
- package/dist/core/runner/run-git-lane.d.ts +3 -1
- package/dist/core/runner/run-git-lane.js +1 -1
- package/dist/core/runner/run-harness-handlers.d.ts +3 -1
- package/dist/core/runner/run-harness-handlers.js +3 -1
- package/dist/core/runner/run-identity-wiring.d.ts +2 -5
- package/dist/core/runner/run-identity-wiring.js +6 -5
- package/dist/core/runner/run-leg.d.ts +2 -0
- package/dist/core/runner/run-leg.js +63 -56
- package/dist/core/runner/run-notification-lane.d.ts +3 -1
- package/dist/core/runner/run-notification-lane.js +16 -10
- package/dist/core/runner/run-settle-and-teardown.js +5 -1
- package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
- package/dist/core/runner/run-stop-and-final-verify.js +14 -6
- package/dist/core/runner/run-terminal-adoption.d.ts +2 -5
- package/dist/core/runner/run-terminal-adoption.js +9 -3
- package/dist/core/runner/run-turn-boundary.js +89 -77
- package/dist/core/runner/runtask.d.ts +8 -5
- package/dist/core/runner/runtask.js +21 -13
- package/dist/core/runner/side-call-account.d.ts +1 -1
- package/dist/core/runner/side-call-account.js +3 -18
- package/dist/core/runner/skills-seat.js +2 -2
- package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
- package/dist/core/runner/sub-agent-deny-lists.js +20 -7
- package/dist/core/runner/synthetic-tools.js +2 -2
- package/dist/core/runner/tool-disclosure.js +0 -2
- package/dist/core/runner/tool-end-body.js +2 -2
- package/dist/core/runner/tool-face-overlay.d.ts +1 -1
- package/dist/core/runner/tool-face-overlay.js +26 -19
- package/dist/core/runner/tool-occurrence.d.ts +1 -1
- package/dist/core/runner/tool-occurrence.js +2 -2
- package/dist/core/runner/tool-result-media-seat.d.ts +9 -1
- package/dist/core/runner/tool-result-media-seat.js +17 -1
- package/dist/core/runner/turn-attachments.d.ts +29 -27
- package/dist/core/runner/turn-attachments.js +27 -42
- package/dist/core/runner-deps.d.ts +32 -19
- package/dist/core/secret-env.d.ts +35 -4
- package/dist/core/secret-env.js +65 -3
- package/dist/core/sensitive-path-policy.js +3 -3
- package/dist/core/session-policy-store.d.ts +12 -3
- package/dist/core/session-policy-store.js +29 -10
- package/dist/core/session-store.d.ts +5 -7
- package/dist/core/session-store.js +50 -11
- package/dist/core/side-query.d.ts +11 -1
- package/dist/core/side-query.js +9 -0
- package/dist/core/skill-grant-binding.d.ts +31 -2
- package/dist/core/skill-grant-binding.js +31 -1
- package/dist/core/skill-grant.d.ts +17 -5
- package/dist/core/skill-grant.js +24 -6
- package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +3 -2
- package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/tool-result-store-contract.js +37 -0
- package/dist/core/stub-env.d.ts +5 -5
- package/dist/core/stub-env.js +11 -1
- package/dist/core/swappable-deps.d.ts +17 -43
- package/dist/core/swappable-deps.js +15 -5
- package/dist/core/synthetic-read-verdict.d.ts +1 -1
- package/dist/core/synthetic-read-verdict.js +2 -1
- package/dist/core/task-event.d.ts +50 -10
- package/dist/core/task-notification.d.ts +88 -5
- package/dist/core/task-notification.js +146 -17
- package/dist/core/task-registry-agent.d.ts +18 -12
- package/dist/core/task-registry-agent.js +19 -6
- package/dist/core/task-registry-monitor.d.ts +7 -0
- package/dist/core/task-registry-monitor.js +28 -1
- package/dist/core/task-registry-shared.d.ts +43 -3
- package/dist/core/task-registry-shared.js +21 -7
- package/dist/core/task-registry-workflow.js +1 -1
- package/dist/core/task-registry.d.ts +50 -35
- package/dist/core/task-registry.js +64 -23
- package/dist/core/task-result.d.ts +3 -12
- package/dist/core/task-spec.d.ts +15 -7
- package/dist/core/task-stream.d.ts +1 -1
- package/dist/core/terminal-cause.d.ts +10 -0
- package/dist/core/tool-catalog-entries.js +1 -1
- package/dist/core/tool-check-reading.d.ts +1 -0
- package/dist/core/tool-check-reading.js +3 -3
- package/dist/core/tool-face-reader.d.ts +7 -6
- package/dist/core/tool-face-reader.js +4 -3
- package/dist/core/tool-name-aliases.d.ts +19 -0
- package/dist/core/tool-name-aliases.js +54 -2
- package/dist/core/tool-policy.d.ts +21 -4
- package/dist/core/tool-policy.js +1 -1
- package/dist/core/tool-registry.d.ts +5 -5
- package/dist/core/tool-registry.js +2 -2
- package/dist/core/tool-result-store.d.ts +88 -5
- package/dist/core/tool-result-store.js +51 -12
- package/dist/core/tool-roster.d.ts +112 -5
- package/dist/core/tool-roster.js +42 -1
- package/dist/core/tool-spec.d.ts +23 -5
- package/dist/core/trace.d.ts +0 -1
- package/dist/core/types.d.ts +5 -5
- package/dist/core/types.js +2 -2
- package/dist/core/untrusted-text.js +1 -1
- package/dist/core/user-attachment.d.ts +10 -5
- package/dist/core/user-attachment.js +15 -7
- package/dist/core/wiring-manifest.d.ts +6 -3
- package/dist/engine/compaction/compaction.js +29 -3
- package/dist/engine/execution-env/node-execution-env.d.ts +11 -5
- package/dist/engine/execution-env/node-execution-env.js +21 -13
- package/dist/engine/harness/agent-harness.d.ts +26 -3
- package/dist/engine/harness/agent-harness.js +49 -16
- package/dist/engine/harness/messages.d.ts +3 -1
- package/dist/engine/harness/messages.js +3 -2
- package/dist/engine/harness/types.d.ts +119 -28
- package/dist/engine/llm/rejected-images.d.ts +46 -0
- package/dist/engine/llm/rejected-images.js +54 -0
- package/dist/engine/llm/tool-turns.d.ts +2 -1
- package/dist/engine/llm/types.d.ts +18 -7
- package/dist/engine/loop/agent-loop.d.ts +20 -12
- package/dist/engine/loop/agent-loop.js +205 -36
- package/dist/engine/loop/types.d.ts +12 -3
- package/dist/engine/lsp/node-lsp-manager.d.ts +3 -3
- package/dist/engine/lsp/node-lsp-manager.js +32 -13
- package/dist/engine/session/path-to-root.d.ts +38 -0
- package/dist/engine/session/path-to-root.js +39 -0
- package/dist/engine/session/storage-base.js +4 -21
- package/dist/index.d.ts +35 -21
- package/dist/index.js +26 -17
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +1 -0
- package/dist/internal/llm.d.ts +1 -0
- package/dist/orchestration/run-workflow-tool.d.ts +9 -3
- package/dist/orchestration/run-workflow-tool.js +59 -29
- package/dist/orchestration/workflow-governance.d.ts +1 -1
- package/dist/orchestration/workflow-governance.js +2 -1
- package/dist/orchestration/workflow-observe.d.ts +17 -1
- package/dist/orchestration/workflow-observe.js +20 -0
- package/dist/orchestration/workflow-types.d.ts +32 -7
- package/dist/orchestration/workflow.d.ts +4 -0
- package/dist/orchestration/workflow.js +762 -491
- package/dist/prompts/default.d.ts +1 -10
- package/dist/prompts/default.js +0 -2
- package/dist/shell/counting-pass.d.ts +50 -0
- package/dist/shell/counting-pass.js +502 -0
- package/dist/shell/lex.d.ts +4 -2
- package/dist/shell/lex.js +93 -34
- package/dist/shell/shell-words.d.ts +1 -1
- package/dist/shell/shell-words.js +7 -6
- package/dist/stores/file/background-agent-store.d.ts +1 -1
- package/dist/stores/file/background-agent-store.js +3 -1
- package/dist/stores/file/checkpoint-store.d.ts +127 -2
- package/dist/stores/file/checkpoint-store.js +19 -14
- package/dist/stores/file/file-history-store.d.ts +1 -1
- package/dist/stores/file/file-history-store.js +3 -1
- package/dist/stores/file/index.d.ts +4 -3
- package/dist/stores/file/index.js +17 -8
- package/dist/stores/file/mailbox-store.d.ts +1 -1
- package/dist/stores/file/mailbox-store.js +9 -11
- package/dist/stores/file/memory-store.d.ts +1 -1
- package/dist/stores/file/memory-store.js +3 -1
- package/dist/stores/file/session-policy-store.d.ts +1 -1
- package/dist/stores/file/session-policy-store.js +3 -1
- package/dist/stores/file/session-store.d.ts +1 -1
- package/dist/stores/file/session-store.js +3 -1
- package/dist/stores/file/shared-ledger.d.ts +26 -0
- package/dist/stores/file/shared-ledger.js +38 -9
- package/dist/stores/file/tool-result-store.d.ts +20 -2
- package/dist/stores/file/tool-result-store.js +74 -6
- package/dist/stores/file/usage-window-store.d.ts +1 -1
- package/dist/stores/file/usage-window-store.js +3 -1
- package/dist/stores/file/workflow-journal-store.d.ts +1 -11
- package/dist/stores/file/workflow-journal-store.js +3 -2
- package/dist/tools/fs/containment-face.d.ts +5 -0
- package/dist/tools/fs/encoding.d.ts +13 -4
- package/dist/tools/fs/encoding.js +17 -2
- package/dist/tools/fs/fs-bash-background-text.d.ts +7 -0
- package/dist/tools/fs/fs-bash-background-text.js +1 -0
- package/dist/tools/fs/fs-bash.d.ts +14 -4
- package/dist/tools/fs/fs-bash.js +29 -35
- package/dist/tools/fs/fs-pdf.d.ts +2 -2
- package/dist/tools/fs/fs-pdf.js +26 -21
- package/dist/tools/fs/fs-read.d.ts +5 -4
- package/dist/tools/fs/fs-read.js +35 -18
- package/dist/tools/fs/fs-search-tools.js +4 -1
- package/dist/tools/fs/fs-shared.d.ts +11 -13
- package/dist/tools/fs/fs-shared.js +11 -7
- package/dist/tools/fs/fs-write.js +5 -5
- package/dist/tools/fs/index.d.ts +14 -8
- package/dist/tools/fs/index.js +13 -5
- package/dist/tools/fs/program-read-model.d.ts +13 -0
- package/dist/tools/fs/program-read-model.js +15 -0
- package/dist/tools/fs/program-read-model.rows.js +1 -1
- package/dist/tools/fs/read-deny.d.ts +13 -10
- package/dist/tools/fs/read-deny.js +25 -5
- package/dist/tools/fs/read-floor.d.ts +62 -0
- package/dist/tools/fs/read-floor.js +58 -0
- package/dist/tools/fs/removal-targets.d.ts +9 -4
- package/dist/tools/fs/removal-targets.js +17 -9
- package/dist/tools/fs/search.d.ts +3 -3
- package/dist/tools/fs/search.js +4 -4
- package/dist/tools/fs/shell-read-check.d.ts +1 -1
- package/dist/tools/fs/shell-read-check.js +2 -1
- package/dist/tools/fs/shell-read-judge.d.ts +16 -8
- package/dist/tools/fs/shell-read-judge.js +10 -6
- package/dist/tools/fs/shell-read-plan.d.ts +6 -1
- package/dist/tools/fs/shell-read-plan.js +22 -15
- package/dist/tools/fs/shell-read-start.js +1 -0
- package/dist/tools/fs/shell-reentry-text.d.ts +15 -1
- package/dist/tools/fs/shell-reentry-text.js +25 -3
- package/dist/tools/monitor.d.ts +9 -4
- package/dist/tools/monitor.js +17 -8
- package/dist/tools/scheduler-tools.js +42 -4
- package/dist/tools/web.d.ts +0 -10
- package/dist/tools/web.js +1 -4
- package/package.json +5 -2
- package/test/export-surface.snapshot.json +161 -21
- package/wire-changes/core-stores-sql@7.59.0.json +29 -0
- package/wire-changes/core-stores-sql@7.60.0.json +30 -0
- package/wire-changes/core@7.59.0.json +2459 -0
- package/wire-changes/core@7.60.0.json +3274 -0
- package/wire-changes/mods-kernel@7.59.0.json +29 -0
- package/wire-changes/mods-kernel@7.60.0.json +62 -0
- package/wire-changes/primitives@7.59.0.json +29 -0
- package/wire-changes/primitives@7.60.0.json +30 -0
|
@@ -3,8 +3,9 @@ import { teamRoleOf } from "../../agents/team-role.js";
|
|
|
3
3
|
import { resolveCheckpointStore } from "../checkpoint-store.js";
|
|
4
4
|
import { createHookEnvCapabilities, mintHookInvocationIdentity } from "../hooks.js";
|
|
5
5
|
import { chainJudges } from "../mods/stations.js";
|
|
6
|
+
import { failureFields } from "../mcp-failure.js";
|
|
6
7
|
import { toolNamesOfServer } from "../mounted-mcp.js";
|
|
7
|
-
import { isRemoteExecutionEnv, missingRestoreSurface } from "../remote-env.js";
|
|
8
|
+
import { declaredSuspend, isRemoteExecutionEnv, missingRestoreSurface } from "../remote-env.js";
|
|
8
9
|
import { isVolatileOffloadStore } from "../tool-result-store.js";
|
|
9
10
|
import { durableMandateSourceOf, isLiveApproverSeat } from "../tool-policy.js";
|
|
10
11
|
import { deliverEngineNotice } from "../types.js";
|
|
@@ -12,8 +13,10 @@ import { inlineUntrusted } from "../untrusted-text.js";
|
|
|
12
13
|
import { mountWriteProtection } from "./write-protection-station.js";
|
|
13
14
|
import { autoRunOnRecommendationEffective } from "./memory-consolidation-driver.js";
|
|
14
15
|
import { GLOBAL_USAGE_KEY, usageRetryAfterMs, windowsGovernCost } from "../usage-window-store.js";
|
|
16
|
+
import { rosterEntryNamed, toolCallFaceOf } from "../tool-roster.js";
|
|
17
|
+
import { isShellFaceToolName } from "../tool-registry.js";
|
|
15
18
|
import { LSP_CONTRACT_ID, askSeatEffective, countElicitOptIns, deriveHandsSeam, deriveLspSeam, deriveWiringManifest, resolveDeclaredDurability, resolveElicitSeam, resolveQuestionSeam, resolveSubagentTranscriptTier } from "../wiring-manifest.js";
|
|
16
|
-
import { modePolicyOf } from "../mode-policy.js";
|
|
19
|
+
import { modePolicyOf, modeQuestionReaches } from "../mode-policy.js";
|
|
17
20
|
export function mcpManifestEntries(entries, statuses, rosterNames) {
|
|
18
21
|
return (entries ?? []).map((entry) => {
|
|
19
22
|
const status = statuses.find((s) => s.name === entry.name);
|
|
@@ -28,7 +31,7 @@ export function mcpManifestEntries(entries, statuses, rosterNames) {
|
|
|
28
31
|
...source,
|
|
29
32
|
status: "failed",
|
|
30
33
|
...liveness,
|
|
31
|
-
...(status
|
|
34
|
+
...failureFields(status),
|
|
32
35
|
...(status.error !== undefined ? { error: inlineUntrusted(status.error, 240) } : {}),
|
|
33
36
|
toolCount: 0,
|
|
34
37
|
};
|
|
@@ -122,18 +125,23 @@ export function prepareWiringManifest(input) {
|
|
|
122
125
|
const handWriteTools = toolRoster.entries.filter((e) => e.mountedBy === "hands" && (e.effect === "write" || e.effect === "idempotent")).map((e) => e.name);
|
|
123
126
|
const hasEffectAwareGate = policyLayers.length > 0 || chainJudges(standingModBus);
|
|
124
127
|
const rosterHolds = new Set(toolRoster.entries.map((e) => e.name));
|
|
125
|
-
const
|
|
128
|
+
const modeAsksUnstated = modePolicyOf(permissionMode.current).unstated === "ask";
|
|
129
|
+
const peerWriteUngated = modeAsksUnstated
|
|
126
130
|
? []
|
|
127
131
|
: mcp.tools.filter((t) => rosterHolds.has(t.name) && t.permissionSeat === "passthrough" && !irreversibleTools.has(t.name) && !egressTools.has(t.name) && (toolEffects.get(t.name) ?? "write") !== "read").map((t) => t.name);
|
|
128
|
-
const
|
|
132
|
+
const requestWriteTools = (spec.tools ?? [])
|
|
129
133
|
.map((t) => t.name)
|
|
130
|
-
.filter((name) => !irreversibleTools.has(name) && !egressTools.has(name)
|
|
131
|
-
|
|
132
|
-
|
|
134
|
+
.filter((name) => !irreversibleTools.has(name) && !egressTools.has(name))
|
|
135
|
+
.filter((name) => toolEffects.get(name) === "write" || (toolCallFaceOf(toolRoster, name)?.names ?? []).some(isShellFaceToolName));
|
|
136
|
+
const callerAnsweredByMode = (name) => modeAsksUnstated && rosterEntryNamed(toolRoster, name)?.source === "caller";
|
|
137
|
+
const callerWriteUnasked = requestWriteTools.filter((name) => callerAnsweredByMode(name) && !modeQuestionReaches(permissionMode.current, toolRoster, name, (spec.tools ?? []).findLast((t) => t.name === name)?.permissionSeat));
|
|
138
|
+
const firstPartyWriteUngated = hasEffectAwareGate ? [] : requestWriteTools.filter((name) => !callerAnsweredByMode(name));
|
|
139
|
+
if ((!hasEffectAwareGate && handWriteTools.length > 0) || callerWriteUnasked.length > 0 || firstPartyWriteUngated.length > 0 || peerWriteUngated.length > 0) {
|
|
133
140
|
const what = [
|
|
134
141
|
!hasEffectAwareGate && handWriteTools.length > 0 ? `hand tools [${handWriteTools.join(", ")}]` : undefined,
|
|
135
142
|
peerWriteUngated.length > 0 ? `server write tools under ${permissionMode.current} [${peerWriteUngated.join(", ")}]` : undefined,
|
|
136
|
-
|
|
143
|
+
firstPartyWriteUngated.length > 0 ? `write tools [${firstPartyWriteUngated.join(", ")}]` : undefined,
|
|
144
|
+
callerWriteUnasked.length > 0 ? `write tools under ${permissionMode.current} [${callerWriteUnasked.join(", ")}]` : undefined,
|
|
137
145
|
]
|
|
138
146
|
.filter(Boolean)
|
|
139
147
|
.join(" + ");
|
|
@@ -144,9 +152,14 @@ export function prepareWiringManifest(input) {
|
|
|
144
152
|
ungatedWarnedShapes.set(deps, shapes);
|
|
145
153
|
}
|
|
146
154
|
shapes.add(what);
|
|
147
|
-
deps.onError?.(new Error(`write-capable ${what} are present but UNGATED —
|
|
148
|
-
|
|
155
|
+
deps.onError?.(new Error(`write-capable ${what} are present but UNGATED — ` +
|
|
156
|
+
(hasEffectAwareGate
|
|
157
|
+
? `no question of the ${permissionMode.current} mode reaches their calls. `
|
|
158
|
+
: `wire an effect-aware tool policy (or a PreToolUse hook). bash/MCP irreversible actions are otherwise unadjudicated; the deployment sandbox/egress boundary is the only protection (design/77 §4, design/53 §2.H). `) +
|
|
149
159
|
(peerWriteUngated.length > 0 ? `Under ${permissionMode.current} a server's tools run with nobody stating them; a deny or ask rule naming them still gates them. ` : "") +
|
|
160
|
+
(callerWriteUnasked.length > 0
|
|
161
|
+
? `Under ${permissionMode.current} a caller's tool that declares no permission seat answers for itself: the mode's question never reaches its calls (in auto, the classifier rules only on what a rule or a policy asks); declare permissionSeat: "passthrough" on it to put each call to the mode's question. A deny or ask rule naming it still gates it. `
|
|
162
|
+
: "") +
|
|
150
163
|
`(This warning fires once per deployment per tool-set shape.)`), { phase: "config", sessionId });
|
|
151
164
|
}
|
|
152
165
|
}
|
|
@@ -154,21 +167,23 @@ export function prepareWiringManifest(input) {
|
|
|
154
167
|
const blockedToolCalls = new Set();
|
|
155
168
|
const batchHaltRef = {};
|
|
156
169
|
const blockedTracked = ["classic.PostToolUse", "classic.PreToolUse", "classic.PostToolUseFailure", "classic.PostToolBatch"].some((ev) => modBus.hasHandlers(ev));
|
|
157
|
-
const
|
|
158
|
-
const
|
|
170
|
+
const ownedRemote = ownedEnv !== undefined && isRemoteExecutionEnv(ownedEnv) ? ownedEnv : undefined;
|
|
171
|
+
const ownedSuspend = ownedRemote !== undefined ? declaredSuspend(ownedRemote) : undefined;
|
|
172
|
+
const restoreSurfaceGap = ownedRemote !== undefined && ownedSuspend === true ? missingRestoreSurface(ownedRemote) : [];
|
|
173
|
+
const suspendTargetGap = ownedEnv === undefined ? undefined
|
|
174
|
+
: ownedRemote === undefined ? "is not a RemoteExecutionEnv (it would be destroyed on suspend, so a resumed file or shell tool would act on a fresh, empty env)"
|
|
175
|
+
: ownedSuspend === "undeclared" ? "does not declare capabilities.suspendable (absent, not a boolean, or unreadable), so it is neither snapshot nor parked"
|
|
176
|
+
: restoreSurfaceGap.length > 0 ? `declares capabilities.suspendable but its adapter does not implement ${restoreSurfaceGap.join(" or ")}` : undefined;
|
|
159
177
|
const durableSuspendInfraReady = resolveCheckpointStore(spec, deps) !== undefined &&
|
|
160
178
|
!(offloadStore !== undefined && isVolatileOffloadStore(offloadStore)) &&
|
|
161
|
-
|
|
162
|
-
incompleteSuspendAdapter === undefined;
|
|
179
|
+
suspendTargetGap === undefined;
|
|
163
180
|
const resourceSuspendEligible = spec.resourceSuspend !== undefined && durableSuspendInfraReady;
|
|
164
181
|
if (spec.resourceSuspend !== undefined && !resourceSuspendEligible) {
|
|
165
182
|
const why = resolveCheckpointStore(spec, deps) === undefined
|
|
166
183
|
? "no CheckpointStore is wired"
|
|
167
184
|
: offloadStore !== undefined && isVolatileOffloadStore(offloadStore)
|
|
168
185
|
? "tool-result offload uses the in-memory store (a resume needs durable results)"
|
|
169
|
-
:
|
|
170
|
-
? `the per-task execution env declares capabilities.suspendable but its adapter does not implement ${incompleteSuspendAdapter.join(" or ")} (a snapshot nothing can restore is worse than no snapshot)`
|
|
171
|
-
: "the per-task execution env is not a RemoteExecutionEnv (it would be destroyed on suspend)";
|
|
186
|
+
: `the per-task execution env ${suspendTargetGap}`;
|
|
172
187
|
onceLedger.onError(new Error(`resourceSuspend is set but INACTIVE: ${why}; resource limits will hard-fail, not suspend`), {
|
|
173
188
|
phase: "config",
|
|
174
189
|
sessionId,
|
|
@@ -267,5 +282,5 @@ export function prepareWiringManifest(input) {
|
|
|
267
282
|
});
|
|
268
283
|
const hookContextConsumerWired = ["classic.PreToolUse", "classic.PostToolUse", "classic.PostToolUseFailure"].some((ev) => modBus.hasHandlers(ev));
|
|
269
284
|
const hookEnvFace = hookContextConsumerWired && (ownedEnv ?? deps.executionEnv) != null ? createHookEnvCapabilities(executionEnv) : undefined;
|
|
270
|
-
return { onAsk, preToolContexts, blockedToolCalls, batchHaltRef, blockedTracked,
|
|
285
|
+
return { onAsk, preToolContexts, blockedToolCalls, batchHaltRef, blockedTracked, suspendTargetGap, durableSuspendInfraReady, resourceSuspendEligible, usageGovernance, platformSuspendArmed, durableApproval, wiringManifest, writeProtection, parkLaneArmed, gateMachineryActive, hookIdentity, hookEnvFace, sessionBoxBound };
|
|
271
286
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { frozenHandleCopy, isRemoteExecutionEnv, missingRestoreSurface } from "../remote-env.js";
|
|
1
|
+
import { declaredSuspend, frozenHandleCopy, isRemoteExecutionEnv, missingRestoreSurface, pathsAreHostLocal } from "../remote-env.js";
|
|
2
2
|
import { remoteEnvFailureNote, restoreWorkspaceWithRetry } from "./remote-env-retry.js";
|
|
3
3
|
import { rebaseWorkspacePathAcross } from "./workspace-path.js";
|
|
4
4
|
export { remoteEnvFailureNote, restoreWorkspaceWithRetry } from "./remote-env-retry.js";
|
|
@@ -30,7 +30,7 @@ export async function prepareWorkspaceRestore(input) {
|
|
|
30
30
|
failResume("resume needs a RemoteExecutionEnv from executionEnvFactory to restore the workspace snapshot");
|
|
31
31
|
}
|
|
32
32
|
else if (handle.snapshotId === undefined) {
|
|
33
|
-
if (handle.restoreMode !== "park_only" && ownedEnv
|
|
33
|
+
if (handle.restoreMode !== "park_only" && declaredSuspend(ownedEnv) !== false) {
|
|
34
34
|
failResume("checkpoint workspaceHandle has no snapshotId and is not a park_only handle, but the resumed env is suspendable — refusing to resume on a possibly-unrestored workspace (corrupt checkpoint?)");
|
|
35
35
|
}
|
|
36
36
|
refuseIdentityMismatch(ownedEnv.workspaceHandle());
|
|
@@ -108,7 +108,7 @@ export async function prepareWorkspaceRestore(input) {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
const workspaceEnv = ownedEnv ?? deps.executionEnv;
|
|
111
|
-
const remote = workspaceEnv !== undefined && workspaceEnv !== null && (
|
|
111
|
+
const remote = workspaceEnv !== undefined && workspaceEnv !== null && !pathsAreHostLocal(workspaceEnv);
|
|
112
112
|
if (internals?.onWorkspaceResolved !== undefined) {
|
|
113
113
|
try {
|
|
114
114
|
internals.onWorkspaceResolved({
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Model, Usage } from "../../internal/llm.js";
|
|
2
|
+
import { type ModelPricing } from "../pricing.js";
|
|
3
|
+
import type { RunnerDeps } from "../types.js";
|
|
4
|
+
/** One reply's usage priced by the engine: the model that served it, its price table, whether a table exists at all, and the
|
|
5
|
+
* re-priced figures. */
|
|
6
|
+
export interface PricedReply {
|
|
7
|
+
readonly served: Model | undefined;
|
|
8
|
+
readonly modelId: string;
|
|
9
|
+
readonly price: ModelPricing;
|
|
10
|
+
/** A price table EXISTS for the serving model (`isModelPriced`'s predicate): `false` ⇒ `costMicroUsd` is a fabricated 0 — unknown, not free. */
|
|
11
|
+
readonly priced: boolean;
|
|
12
|
+
readonly totalInputTokens: number;
|
|
13
|
+
readonly uncachedInputTokens: number;
|
|
14
|
+
readonly costMicroUsd: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* THE one place a model call made BESIDE the main loop is priced — the run's side-call lanes (`recordSideCallUsage`) and
|
|
18
|
+
* `Runner.sideQuery`'s account line both read it, so a run's reported cost and a side query's cost are the same arithmetic. The
|
|
19
|
+
* call's model prices independently of the main loop's telemetry state. A degrading brain may have served the reply from its
|
|
20
|
+
* fallback: the model that ANSWERED is the one priced (the main loop re-points its pricing at it the same way). A fallback the
|
|
21
|
+
* catalog does not know prices from the deployment's table by id when that has one, else as unpriced spend, and takes the cache
|
|
22
|
+
* family that never undercounts.
|
|
23
|
+
*/
|
|
24
|
+
export declare function priceReply(usage: Usage, call: {
|
|
25
|
+
readonly model: Model;
|
|
26
|
+
readonly servedBy?: string;
|
|
27
|
+
}, seats: {
|
|
28
|
+
readonly pricing: RunnerDeps["pricing"];
|
|
29
|
+
readonly catalog: RunnerDeps["models"];
|
|
30
|
+
}): PricedReply;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { isModelPriced, modelCostToPricing } from "../pricing.js";
|
|
2
|
+
import { cacheFamilyOf, usageCostMicroUsd } from "./usage-accounting.js";
|
|
3
|
+
function catalogModel(id, catalog) {
|
|
4
|
+
if (catalog === undefined)
|
|
5
|
+
return undefined;
|
|
6
|
+
for (const m of Object.values(catalog))
|
|
7
|
+
if (m.id === id)
|
|
8
|
+
return m;
|
|
9
|
+
return Object.hasOwn(catalog, id) ? catalog[id] : undefined;
|
|
10
|
+
}
|
|
11
|
+
export function priceReply(usage, call, seats) {
|
|
12
|
+
const { pricing, catalog } = seats;
|
|
13
|
+
const served = call.servedBy === undefined ? call.model : catalogModel(call.servedBy, catalog);
|
|
14
|
+
const modelId = served?.id ?? call.servedBy ?? call.model.id;
|
|
15
|
+
const price = pricing?.[modelId] ?? modelCostToPricing(served?.cost);
|
|
16
|
+
const priced = served !== undefined ? isModelPriced(served, pricing) : pricing?.[modelId] !== undefined;
|
|
17
|
+
const family = served !== undefined ? cacheFamilyOf(served) : "input-excludes-cached";
|
|
18
|
+
return { served, modelId, price, priced, ...usageCostMicroUsd(family, usage, price) };
|
|
19
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CheckpointError, readPendingSteerQueue, refuseRetiredModeSeed, resolveCheckpointStore, validatePendingSteer } from "../checkpoint-store.js";
|
|
1
|
+
import { CheckpointError, judgeParkedSteerRepeat, readPendingSteerQueue, refuseRetiredModeSeed, resolveCheckpointStore, validatePendingSteer } from "../checkpoint-store.js";
|
|
2
2
|
import { assertResumeConfigRecord, checkpointStoreSeat, refuseResumeDoors } from "./prepare-config-doors.js";
|
|
3
3
|
import { asResumeConfigRefusal } from "../mode-policy.js";
|
|
4
4
|
import { describeSuppliedValue } from "./decide-continuation.js";
|
|
@@ -15,7 +15,7 @@ export async function resumeAdmission(input) {
|
|
|
15
15
|
const { token, outcome, taskConfig, runner, sessions, parentConstraintRegistry } = input;
|
|
16
16
|
let internals = input.internals;
|
|
17
17
|
if (outcome === null || typeof outcome !== "object") {
|
|
18
|
-
throw new CheckpointError("checkpoint.invalid_outcome", `resume outcome must be an object naming its gate (got ${outcome === null ? "null" : typeof outcome})
|
|
18
|
+
throw new CheckpointError("checkpoint.invalid_outcome", `resume outcome must be an object naming its gate (got ${outcome === null ? "null" : typeof outcome})`, { field: "outcome" });
|
|
19
19
|
}
|
|
20
20
|
asResumeConfigRefusal("taskConfig", () => assertResumeConfigRecord(taskConfig));
|
|
21
21
|
let config = { ...taskConfig, ...(Array.isArray(taskConfig.skills) ? { skills: detachSkillLists(taskConfig.skills) } : {}) };
|
|
@@ -80,6 +80,8 @@ export async function resumeAdmission(input) {
|
|
|
80
80
|
}
|
|
81
81
|
if (suppliedMessage !== undefined) {
|
|
82
82
|
wakeMessage = validatePendingSteer(suppliedMessage);
|
|
83
|
+
if (judgeParkedSteerRepeat(parkedSteers, wakeMessage) !== undefined)
|
|
84
|
+
wakeMessage = undefined;
|
|
83
85
|
}
|
|
84
86
|
else if (parkedSteers.length === 0) {
|
|
85
87
|
throw new CheckpointError("wake.nothing_to_deliver", "cannot wake: no message was supplied and the checkpoint holds no parked pendingSteer — an empty " +
|
|
@@ -4,6 +4,8 @@ import { chainPolicyOnLeg, chainTopAnchors } from "./child-tree.js";
|
|
|
4
4
|
import { mintHookInvocationIdentity } from "../hooks.js";
|
|
5
5
|
import { admitLegMods, classicEventBase, failedHandlerClause, screenUserPrompt } from "../mods/stations.js";
|
|
6
6
|
import { checkToolPolicyProjection, policyCannotAnswer, refuseOutOfContractDecision } from "../tool-policy.js";
|
|
7
|
+
import { requestGrantBinding } from "../skill-grant-binding.js";
|
|
8
|
+
import { skillGrantBindingMembers } from "../skill-grant.js";
|
|
7
9
|
import { callFaceSeat, parkedCallFaceOf } from "../tool-roster.js";
|
|
8
10
|
import { readCallTarget } from "../effective-path-target.js";
|
|
9
11
|
import { inlineUntrusted } from "../untrusted-text.js";
|
|
@@ -74,9 +76,11 @@ export async function resumeApply(input) {
|
|
|
74
76
|
p.then((v) => { editSignal.removeEventListener("abort", onAbort); resolve(v); }, (e) => { editSignal.removeEventListener("abort", onAbort); reject(e); });
|
|
75
77
|
});
|
|
76
78
|
};
|
|
79
|
+
const servedSkills = plainPolicyOutcome?.decision === "allow" && cp.pendingAction.kind === "tool_approval" ? skillsThatLoad(normalizeSkills(config.skills)) : [];
|
|
77
80
|
if (plainPolicyOutcome?.decision === "allow" && cp.pendingAction.kind === "tool_approval") {
|
|
78
|
-
const servedSkills = skillsThatLoad(normalizeSkills(config.skills));
|
|
79
81
|
const claimed = judgeApprovalObject(cp.pendingAction, { args: plainPolicyOutcome.updatedInput ?? cp.pendingAction.args, skills: servedSkills, skillToolName: SKILL_TOOL_NAME }, "claim");
|
|
82
|
+
if (claimed !== "match" && claimed.member === "tool")
|
|
83
|
+
throw new CheckpointError("checkpoint.unsupported_version", claimed.message, { reason: "tool_identity_missing" });
|
|
80
84
|
if (claimed !== "match")
|
|
81
85
|
throw new CheckpointError("checkpoint.invalid_outcome", claimed.message, { field: "boundGrantDigest" });
|
|
82
86
|
}
|
|
@@ -94,6 +98,7 @@ export async function resumeApply(input) {
|
|
|
94
98
|
toolName: cp.pendingAction.toolName,
|
|
95
99
|
args: editedArgs,
|
|
96
100
|
toolCallId: cp.pendingAction.toolCallId,
|
|
101
|
+
...requestGrantBinding((call, args) => skillGrantBindingMembers(call, args, servedSkills, SKILL_TOOL_NAME), cp.pendingAction, editedArgs),
|
|
97
102
|
budget: editBudget,
|
|
98
103
|
...callFaceSeat(parkedCallFaceOf(cp.pendingAction)),
|
|
99
104
|
...(cp.state.handsCwd !== undefined ? { cwd: cp.state.handsCwd } : {}),
|
|
@@ -7,7 +7,7 @@ import { constraintChainDigest, constraintChainEntryOfSuppliedLayer } from "../t
|
|
|
7
7
|
import { readFrozenSkillGrants } from "../skill-grant.js";
|
|
8
8
|
import { readFrozenSkillScopes } from "../mods/spec-seats.js";
|
|
9
9
|
import { chainInstallationGaps, chainInstallationRefusal } from "./child-tree.js";
|
|
10
|
-
import {
|
|
10
|
+
import { chainEntryFault } from "../mods/stations.js";
|
|
11
11
|
import { refusePersistedToolNames, refuseRenamedDelegationMounts } from "./sub-agent-deny-lists.js";
|
|
12
12
|
import { asResumeConfigRefusal } from "../mode-policy.js";
|
|
13
13
|
import { screenRecordedRunOrigin } from "../run-origin.js";
|
|
@@ -136,9 +136,9 @@ export function resumeCheckpointScreen(input) {
|
|
|
136
136
|
if (gaps.length > 0)
|
|
137
137
|
throw chainInstallationRefusal(gaps, true);
|
|
138
138
|
}
|
|
139
|
-
const
|
|
140
|
-
if (
|
|
141
|
-
throw new CheckpointError("resume.parent_constraint_mismatch", `${
|
|
139
|
+
const malformed = chainEntryFault(internals?.inheritedGate?.parentConstraints ?? []);
|
|
140
|
+
if (malformed !== undefined)
|
|
141
|
+
throw new CheckpointError("resume.parent_constraint_mismatch", `${malformed}; rejected pre-CAS (the checkpoint stays pending)`);
|
|
142
142
|
const resumeInternals = internals?.inheritedGate?.parentConstraints !== undefined
|
|
143
143
|
? {
|
|
144
144
|
...internals,
|
|
@@ -33,17 +33,17 @@ export function resumePolicyOutcome(input) {
|
|
|
33
33
|
if (updatedInputRaw !== undefined) {
|
|
34
34
|
const captured = capturedJsonOf(updatedInputRaw);
|
|
35
35
|
if (!captured.ok)
|
|
36
|
-
throw new CheckpointError("checkpoint.invalid_outcome", bindingRefusalOf(cp.pendingAction.kind === "tool_approval" ? cp.pendingAction.toolName : "the parked call", updatedInputRaw, captured.fault));
|
|
36
|
+
throw new CheckpointError("checkpoint.invalid_outcome", bindingRefusalOf(cp.pendingAction.kind === "tool_approval" ? cp.pendingAction.toolName : "the parked call", updatedInputRaw, captured.fault), { field: "updatedInput" });
|
|
37
37
|
updatedInput = captured.value;
|
|
38
38
|
}
|
|
39
39
|
const decision = decide.decision;
|
|
40
40
|
if (decision !== "allow" && decision !== "deny") {
|
|
41
|
-
throw new CheckpointError("checkpoint.invalid_outcome", `resume decision "${describeSuppliedValue(decision)}" is outside the policy_ask domain — a decide is exactly "allow" or "deny"; refusing pre-CAS, the checkpoint stays pending
|
|
41
|
+
throw new CheckpointError("checkpoint.invalid_outcome", `resume decision "${describeSuppliedValue(decision)}" is outside the policy_ask domain — a decide is exactly "allow" or "deny"; refusing pre-CAS, the checkpoint stays pending`, { field: "decision" });
|
|
42
42
|
}
|
|
43
43
|
refuseSuppliedKeys(decide, REFUSED_DECIDE_KEYS);
|
|
44
44
|
const hostDecision = captureHostDecision(cp, decide.hostDecision, "policy_ask", { word: decision, allows: decision === "allow" });
|
|
45
45
|
const reason = decide.reason;
|
|
46
|
-
assertOutcomeText(reason, "reason");
|
|
46
|
+
assertOutcomeText(reason, "reason", { field: "reason" });
|
|
47
47
|
const feedback = decide.feedback;
|
|
48
48
|
assertOutcomeText(feedback, "feedback", { field: "feedback" });
|
|
49
49
|
plainPolicyOutcome = {
|
|
@@ -59,7 +59,7 @@ export function resumePolicyOutcome(input) {
|
|
|
59
59
|
};
|
|
60
60
|
refuseUnfitFeedback(plainPolicyOutcome);
|
|
61
61
|
if (plainPolicyOutcome.decision === "deny" && plainPolicyOutcome.reason && sanitizeUntrustedText(plainPolicyOutcome.reason) !== plainPolicyOutcome.reason) {
|
|
62
|
-
throw new CheckpointError("checkpoint.invalid_outcome", sentinelTagRefusal("resume deny/reject reason"));
|
|
62
|
+
throw new CheckpointError("checkpoint.invalid_outcome", sentinelTagRefusal("resume deny/reject reason"), { field: "reason" });
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
if (plainPolicyOutcome !== undefined) {
|
|
@@ -74,7 +74,7 @@ export function resumePolicyOutcome(input) {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
else if (checkpointVersionOf(cp) >= CHECKPOINT_FEATURES.binding.version) {
|
|
77
|
-
throw new CheckpointError("checkpoint.invalid_outcome", `resume of a binding-version (v${checkpointVersionOf(cp)}) checkpoint whose pending tool call has no persisted boundInputHash — refusing to resume an unbound binding-version checkpoint (corruption / downgrade guard)
|
|
77
|
+
throw new CheckpointError("checkpoint.invalid_outcome", `resume of a binding-version (v${checkpointVersionOf(cp)}) checkpoint whose pending tool call has no persisted boundInputHash — refusing to resume an unbound binding-version checkpoint (corruption / downgrade guard)`, { reason: "bound_input_hash_missing" });
|
|
78
78
|
}
|
|
79
79
|
if (cp.reopenReason === "env_failed") {
|
|
80
80
|
if (cp.resolvedOutcome === undefined) {
|
|
@@ -5,6 +5,8 @@ const RETIRED_RUNNER_DEPS_KEYS = {
|
|
|
5
5
|
peerAdmission: "the peer lane's knob table is `RunnerDeps.peerLane` (the same fields: admission gate, delivery budgets, listing window)",
|
|
6
6
|
builtinWorkflows: "the engine ships no built-in named workflows — the Workflow tool's `{name}` resolves only `RunnerDeps.workflowScriptStore`; register any named workflow there",
|
|
7
7
|
graderEnvFactory: "the grader env reaches the repair loop as `RepairLoopConfig.graderEnv`, minted by the trusted control plane (`assertOracleIsolation` / `GraderEnv` unchanged)",
|
|
8
|
+
mcpImageResizer: "one image processor seat serves every image of a run: `RunnerDeps.imageProcessor` (an `ImageDownsampler`, or `false` for none; absent detects sharp once per process) — the MCP result, the Read tool, PDF pages, Bash data URIs, any tool's result, task images and attachments all pass the one admission with it",
|
|
9
|
+
"hands.readImageDownsampler": "one image processor seat serves every image of a run: `RunnerDeps.imageProcessor` (an `ImageDownsampler`, or `false` for none; absent detects sharp once per process) — the Read tool's images ride it with every other carrier's",
|
|
8
10
|
"hands.readCyberReminder": "a Read result carries only the reminders about that read (an empty file, an offset past the end, a file already in context) — no standing content-safety tail, so there is nothing to switch; a deployment that wants that sentence states it in its own `appendSystemPrompt`",
|
|
9
11
|
promptProvider: "a deployment changes prompt text through overlays: register a `prompt.compose` handler on `RunnerDeps.mods` answering `{ overlays }` (role base `replace`, a brand line `add` to the role band, a behavior or scenario `add`, a core-behavior `replace` / `append` / `drop`), choose the role base per task with `TaskSpec.promptRole`, and dispose of an MCP server's instructions with a `prompt.section` registration answering `{ text }` / `{ text: null }`",
|
|
10
12
|
allowImageUrl: "a remote image URL is judged by the one egress guard (https, the private-network floor) and the deployment's host floor — declare a CDN list as `RunnerDeps.hostFloor.only` (it bounds every structured egress: the fetch tool, task images, MCP http, A2A, WebSearch's SearXNG backend), or send the image inline",
|
|
@@ -15,5 +17,6 @@ export function assertNoRetiredRunnerDeps(deps) {
|
|
|
15
17
|
}
|
|
16
18
|
export function assertNoRetiredInheritedConstraints(internals) {
|
|
17
19
|
for (const constraint of internals?.inheritedGate?.parentConstraints ?? [])
|
|
18
|
-
|
|
20
|
+
if (constraint.policy !== undefined)
|
|
21
|
+
assertNoRetiredToolPolicyKeys(constraint.policy);
|
|
19
22
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The person's account of a role seat the engine stands in for (`model.role_defaulted`).
|
|
3
|
+
*
|
|
4
|
+
* A role seat that names a model word the deployment's catalog does not hold supplies no model: the roles family reads it as an unset
|
|
5
|
+
* seat (`seatRead`, `src/core/roles.ts` — the tier default and the fallback chain follow; a subagent seat falls to the parent's model),
|
|
6
|
+
* so the run goes on instead of refusing at every prepare. That is only honest when it is said: this prepare-time phase names each such
|
|
7
|
+
* seat once per conversation, from the SAME role maps (the merged deployment-and-task map, and the deployment's own map that a delegated child's
|
|
8
|
+
* seat reads) and the SAME catalog the reads use (`unheldRoleSeats`), whether or not a
|
|
9
|
+
* later read of this leg reaches the seat. `default` (the main model's seat) and `classifier` (its own stand-in and line,
|
|
10
|
+
* `classifier.role_defaulted`) are never named here.
|
|
11
|
+
*
|
|
12
|
+
* Root legs only: a delegated child inherits the deployment's maps and would repeat the parent's line once per spawn.
|
|
13
|
+
*/
|
|
14
|
+
import { type EngineNotice } from "../engine-notice.js";
|
|
15
|
+
import { type ModelRoles, type UnheldRoleSeat } from "../roles.js";
|
|
16
|
+
import type { Model } from "../types.js";
|
|
17
|
+
import { type AnnounceOnceLedger } from "./announce-once-ledger.js";
|
|
18
|
+
export declare const ROLE_DEFAULTED = "model.role_defaulted";
|
|
19
|
+
/** The notice for one unheld seat. `word` is bounded and quoted as every refusal of this family quotes it. */
|
|
20
|
+
export declare function roleDefaultedNotice(u: UnheldRoleSeat, ids: {
|
|
21
|
+
sessionId: string;
|
|
22
|
+
runId?: string;
|
|
23
|
+
}): EngineNotice;
|
|
24
|
+
export interface AnnounceRoleSeatsInput {
|
|
25
|
+
/** borrowed-readonly — the rebound spec's role map (the task's own seats). */
|
|
26
|
+
spec: {
|
|
27
|
+
roles?: ModelRoles;
|
|
28
|
+
};
|
|
29
|
+
/** borrowed-readonly — the deployment's maps and the catalog the reads ask, and the notice sink. */
|
|
30
|
+
deps: {
|
|
31
|
+
models?: Record<string, Model>;
|
|
32
|
+
roles?: ModelRoles;
|
|
33
|
+
onNotice?: (notice: EngineNotice) => void;
|
|
34
|
+
};
|
|
35
|
+
/** borrowed-readonly — the once-per-session ledger the notice's dedupe rides. */
|
|
36
|
+
onceLedger: Pick<AnnounceOnceLedger, "oncePerSession">;
|
|
37
|
+
/** borrowed-readonly — true for the root leg of a conversation; a delegated child names nothing (its parent already did). */
|
|
38
|
+
rootLeg: boolean;
|
|
39
|
+
sessionId: string;
|
|
40
|
+
runId: string | undefined;
|
|
41
|
+
}
|
|
42
|
+
/** The phase: one line per unheld seat per conversation (the dedupe key is the seat and the word, so a seat re-pointed at another
|
|
43
|
+
* unknown word is said again). */
|
|
44
|
+
export declare function announceRoleSeatsDefaulted(input: AnnounceRoleSeatsInput): void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { deliverEngineNotice } from "../engine-notice.js";
|
|
2
|
+
import { bindingShown, roleFallbackChain, unheldRoleSeats } from "../roles.js";
|
|
3
|
+
import { announceDigest } from "./announce-once-ledger.js";
|
|
4
|
+
export const ROLE_DEFAULTED = "model.role_defaulted";
|
|
5
|
+
const STANDS_IN = {
|
|
6
|
+
summarize: "the compaction summary runs on the conversation's own model (or the tier default for that role, when tiers are declared)",
|
|
7
|
+
subagent: "child runs go on the parent run's model",
|
|
8
|
+
verifier: "the verification gate runs on the main model",
|
|
9
|
+
consolidate: "memory consolidation runs on the summarize role's model, and is refused when that supplies none",
|
|
10
|
+
};
|
|
11
|
+
export function roleDefaultedNotice(u, ids) {
|
|
12
|
+
const shown = bindingShown(u.word);
|
|
13
|
+
return {
|
|
14
|
+
code: ROLE_DEFAULTED,
|
|
15
|
+
message: `${u.seat} names the model ${shown}, which this deployment's model catalog does not hold, so the seat is read as an unset one: ${STANDS_IN[u.role] ?? "its fallback chain decides"}. ` +
|
|
16
|
+
`Declare ${shown} in the catalog (RunnerDeps.models) or correct the seat. Said once per conversation for this seat.`,
|
|
17
|
+
detail: {
|
|
18
|
+
seat: u.seat,
|
|
19
|
+
role: u.role,
|
|
20
|
+
model: u.word.length > 80 ? `${u.word.slice(0, 80)}…` : u.word,
|
|
21
|
+
reason: "unknown_model_ref",
|
|
22
|
+
fallback: [...roleFallbackChain(u.role)],
|
|
23
|
+
sessionId: ids.sessionId,
|
|
24
|
+
...(ids.runId !== undefined ? { runId: ids.runId } : {}),
|
|
25
|
+
},
|
|
26
|
+
sessionId: ids.sessionId,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export function announceRoleSeatsDefaulted(input) {
|
|
30
|
+
if (!input.rootLeg)
|
|
31
|
+
return;
|
|
32
|
+
const seen = new Set();
|
|
33
|
+
for (const u of [...unheldRoleSeats({}, input.deps), ...unheldRoleSeats(input.spec, input.deps)]) {
|
|
34
|
+
const key = `${u.seat}\n${u.word}`;
|
|
35
|
+
if (seen.has(key))
|
|
36
|
+
continue;
|
|
37
|
+
seen.add(key);
|
|
38
|
+
input.onceLedger.oncePerSession(announceDigest(ROLE_DEFAULTED, key), () => deliverEngineNotice(input.deps.onNotice, roleDefaultedNotice(u, { sessionId: input.sessionId, ...(input.runId !== undefined ? { runId: input.runId } : {}) })));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -78,12 +78,12 @@ export async function runAttachmentSeats(input) {
|
|
|
78
78
|
return [];
|
|
79
79
|
const full = textOf(e.message);
|
|
80
80
|
if (m.engineMinted === true)
|
|
81
|
-
return [stripGitStatusUnits(full
|
|
81
|
+
return [stripGitStatusUnits(full)];
|
|
82
82
|
if (Array.isArray(m.engineSegments) && m.engineSegments.length > 0) {
|
|
83
|
-
return m.engineSegments.map((s) => stripGitStatusUnits(full.slice(Math.max(0, s.start), Math.max(0, s.end))
|
|
83
|
+
return m.engineSegments.map((s) => stripGitStatusUnits(full.slice(Math.max(0, s.start), Math.max(0, s.end))));
|
|
84
84
|
}
|
|
85
85
|
if (typeof m.enginePrefixChars === "number" && m.enginePrefixChars > 0)
|
|
86
|
-
return [stripGitStatusUnits(full.slice(0, m.enginePrefixChars)
|
|
86
|
+
return [stripGitStatusUnits(full.slice(0, m.enginePrefixChars))];
|
|
87
87
|
return [];
|
|
88
88
|
});
|
|
89
89
|
}
|
|
@@ -19,12 +19,15 @@ export function runBrainSinks(input) {
|
|
|
19
19
|
...(s.retryAtMs !== undefined ? { retryAtMs: s.retryAtMs } : {}),
|
|
20
20
|
...(s.elapsedMs !== undefined ? { elapsedMs: s.elapsedMs } : {}),
|
|
21
21
|
...(s.timeoutMs !== undefined ? { timeoutMs: s.timeoutMs } : {}),
|
|
22
|
+
...(s.waitSegment !== undefined ? { waitSegment: s.waitSegment } : {}),
|
|
23
|
+
...(s.sleptMs !== undefined ? { sleptMs: s.sleptMs } : {}),
|
|
22
24
|
...(s.attempt !== undefined ? { attempt: s.attempt } : {}),
|
|
23
25
|
...(s.maxRetries !== undefined ? { maxRetries: s.maxRetries } : {}),
|
|
24
26
|
...(s.errClass !== undefined ? { errClass: s.errClass } : {}),
|
|
25
27
|
...(s.errorStatus !== undefined ? { errorStatus: s.errorStatus } : {}),
|
|
26
28
|
...(s.providerCondition !== undefined ? { providerCondition: s.providerCondition } : {}),
|
|
27
29
|
...(s.providerConditionSource !== undefined ? { providerConditionSource: s.providerConditionSource } : {}),
|
|
30
|
+
...(s.seat !== undefined ? { seat: s.seat } : {}),
|
|
28
31
|
...ident(),
|
|
29
32
|
};
|
|
30
33
|
Object.freeze(frame);
|
|
@@ -42,7 +42,9 @@ export interface RunGitLaneInput {
|
|
|
42
42
|
type: "tool_execution_end";
|
|
43
43
|
}>) => void;
|
|
44
44
|
/** borrowed-readonly — the harness-handlers lane's turn_end closure. */
|
|
45
|
-
onTurnEnd: (
|
|
45
|
+
onTurnEnd: (event: Extract<AgentHarnessEvent, {
|
|
46
|
+
type: "turn_end";
|
|
47
|
+
}>) => void;
|
|
46
48
|
/** borrowed-readonly — the turn-boundary lane's handler, registered on `turn_boundary` AFTER the owed-frame retry
|
|
47
49
|
* so a pending announcement is re-asserted into the session ahead of the boundary's own context work. */
|
|
48
50
|
onTurnBoundary: (event: {
|
|
@@ -33,7 +33,9 @@ export interface RunHarnessHandlersResult {
|
|
|
33
33
|
onToolEnd: (event: Extract<AgentHarnessEvent, {
|
|
34
34
|
type: "tool_execution_end";
|
|
35
35
|
}>) => void;
|
|
36
|
-
onTurnEnd: (
|
|
36
|
+
onTurnEnd: (event: Extract<AgentHarnessEvent, {
|
|
37
|
+
type: "turn_end";
|
|
38
|
+
}>) => void;
|
|
37
39
|
/** The leg's workspace-frame observation (`Prepared.workspaceFrame.observe`); the run body
|
|
38
40
|
* calls it after a resume's approved-call resolution, which bypasses onToolEnd. */
|
|
39
41
|
announceWorkspaceMove: () => void;
|
|
@@ -13,6 +13,7 @@ import { hasVerifiableStructureSignal } from "./grounding-signal.js";
|
|
|
13
13
|
import { announceToolCall, batchResponseDigest, emitSettled } from "./tool-end-body.js";
|
|
14
14
|
import { neverExecuted, stampRowNotExecuted } from "./tool-not-executed.js";
|
|
15
15
|
import { extensionCallOf, noteExtensionCallDenied, requesterOf } from "../mods/extension-call.js";
|
|
16
|
+
import { noteCompletedTurn } from "../mods/lifecycle-stations.js";
|
|
16
17
|
import { createResponseModelSeat } from "./response-model-seat.js";
|
|
17
18
|
import { createToolCallIdFoldSeat } from "./tool-call-id-fold-seat.js";
|
|
18
19
|
import { createFinishReasonSeat } from "./finish-reason-seat.js";
|
|
@@ -295,8 +296,9 @@ export function createHarnessHandlers(input) {
|
|
|
295
296
|
}
|
|
296
297
|
}
|
|
297
298
|
};
|
|
298
|
-
const onTurnEnd = () => {
|
|
299
|
+
const onTurnEnd = (event) => {
|
|
299
300
|
stats.turns += 1;
|
|
301
|
+
noteCompletedTurn(prepared.modBus, rs.turn, event.message.role === "assistant" ? event.message : undefined, stats.turns, prepared.abortController.signal.aborted, rs.turn.turnUsageMissing ? undefined : rs.turn.turnUsage);
|
|
300
302
|
if (prepared.abortController.signal.aborted)
|
|
301
303
|
prepared.workCutRef.abortedBeforeTurnEnd = true;
|
|
302
304
|
const stopExtra = rs.turn.turnStopReason !== undefined ? { stopReason: rs.turn.turnStopReason } : {};
|
|
@@ -2,7 +2,7 @@ import type { PeerInboundChainRef } from "../../agents/peer-admission.js";
|
|
|
2
2
|
import { type SafeNotifier } from "../safe-notify.js";
|
|
3
3
|
import { type NotificationInjectionOutcome, type PendingSessionNotifications, type SystemInjectionPriority, type TaskNotificationPayload } from "../task-notification.js";
|
|
4
4
|
import type { PushQueue } from "../push-queue.js";
|
|
5
|
-
import type { TaskEvent, TaskSpec } from "../types.js";
|
|
5
|
+
import type { HeldUserInputs, TaskEvent, TaskSpec } from "../types.js";
|
|
6
6
|
import type { Stats } from "./assemble-result.js";
|
|
7
7
|
import { type CallerStopGate } from "./caller-stop-gate.js";
|
|
8
8
|
import type { CaptureOptOutRef, LiveHandle, ManualCompactRef, McpRedialRef, NotificationLaneBindings, NotifyRef, Prepared, RunInternals, RunnerDepsSeat, TaskIdRef } from "./contracts.js";
|
|
@@ -73,10 +73,7 @@ export interface RunIdentityWiringResult {
|
|
|
73
73
|
/** The held agent_end account, a READ FACE over this lane's own `let` (the undrained-inputs sink writes it
|
|
74
74
|
* when the run committed a durable park); the terminal-adoption lane settles it minus what the park carried. */
|
|
75
75
|
undrainedUserAtEnd: {
|
|
76
|
-
readonly current:
|
|
77
|
-
steer: number;
|
|
78
|
-
followUp: number;
|
|
79
|
-
} | undefined;
|
|
76
|
+
readonly current: HeldUserInputs | undefined;
|
|
80
77
|
};
|
|
81
78
|
/** The run's ONE isolation scope for the {@link RunInternals} observation sinks: minted here because
|
|
82
79
|
* the manifest sink below is the run's first call into one, and handed on to the harness-handlers lane
|
|
@@ -6,7 +6,7 @@ import { recordFrameReceipt, toolResultReceiptKey } from "../frame-settlement.js
|
|
|
6
6
|
import { discloseDroppedPending, renderTaskNotificationXml, taskNotificationDedupKey } from "../task-notification.js";
|
|
7
7
|
import { buildAppliedHumanInputEvent } from "../human-input-projection.js";
|
|
8
8
|
import { announceAcceptance, nextHumanInputSeq } from "./steer-admission.js";
|
|
9
|
-
import { deliverDelegationLifecycle, deliverEngineNotice, parentLegIds, undrainedUserInputNotices } from "../types.js";
|
|
9
|
+
import { deliverDelegationLifecycle, deliverEngineNotice, parentLegIds, parkedInputIdsOf, undrainedUserInputNotices } from "../types.js";
|
|
10
10
|
import { mintCallerStopGate } from "./caller-stop-gate.js";
|
|
11
11
|
export function runIdentityWiring(input) {
|
|
12
12
|
const { spec, queue, prepared, internals, taskIdRef, onReady, manualCompactRef, notifyRef, captureOptOutRef, mcpRedialRef, injectTaskNotification, deliveredAtTurnOpen, peerInboundChainRef, notificationLane, pendingSessionNotifications, runner } = input;
|
|
@@ -64,13 +64,14 @@ export function runIdentityWiring(input) {
|
|
|
64
64
|
prepared.harness.engineInjectionsHeld = () => prepared.batchHaltRef.current !== undefined;
|
|
65
65
|
let undrainedUserAtEnd;
|
|
66
66
|
let userInputLostAtEnd = false;
|
|
67
|
-
prepared.harness.onUndrainedUserInputs = (counts) => {
|
|
67
|
+
prepared.harness.onUndrainedUserInputs = (counts, parkRecords) => {
|
|
68
68
|
userInputLostAtEnd = counts.steer + counts.followUp > 0;
|
|
69
|
+
const inputIds = parkRecords !== undefined ? parkedInputIdsOf(parkRecords) : undefined;
|
|
69
70
|
if (prepared.pausedRef.current !== undefined || prepared.undeliveredContinuationRef.current.parkedSteers.length > 0) {
|
|
70
|
-
undrainedUserAtEnd = counts;
|
|
71
|
+
undrainedUserAtEnd = { steer: counts.steer, followUp: counts.followUp, ...(inputIds !== undefined ? { inputIds } : {}) };
|
|
71
72
|
return;
|
|
72
73
|
}
|
|
73
|
-
for (const notice of undrainedUserInputNotices(counts, spec.taskId ?? prepared.sessionId, prepared.sessionId, prepared.runId, parentLegIds(internals))) {
|
|
74
|
+
for (const notice of undrainedUserInputNotices({ ...counts, ...(inputIds !== undefined ? { inputIds } : {}) }, spec.taskId ?? prepared.sessionId, prepared.sessionId, prepared.runId, parentLegIds(internals))) {
|
|
74
75
|
deliverEngineNotice(runner.deps.onNotice, notice);
|
|
75
76
|
}
|
|
76
77
|
};
|
|
@@ -118,7 +119,7 @@ export function runIdentityWiring(input) {
|
|
|
118
119
|
{
|
|
119
120
|
const pendingIdle = pendingSessionNotifications.drain(prepared.sessionId);
|
|
120
121
|
if (pendingIdle !== undefined) {
|
|
121
|
-
for (const payload of discloseDroppedPending(pendingIdle)) {
|
|
122
|
+
for (const payload of discloseDroppedPending(pendingIdle, prepared.taskReadHandleOf, () => prepared.listBackgroundTasks({ settled: true }))) {
|
|
122
123
|
const parkedPriority = pendingIdle.priorities?.get(payload);
|
|
123
124
|
deliveredAtTurnOpen.add(taskNotificationDedupKey(payload));
|
|
124
125
|
queue.push({ type: "task_notification", notification: payload, ...(parkedPriority !== undefined ? { priority: parkedPriority } : {}), ...ident() });
|
|
@@ -40,6 +40,8 @@ export interface RunLegInput<R> {
|
|
|
40
40
|
rs: RunState;
|
|
41
41
|
/** borrowed-readonly — the API-boundary attribution snapshot of the objective's actor (the objective leg's speaker envelope). */
|
|
42
42
|
entryActor: ActorAssertion | undefined;
|
|
43
|
+
/** borrowed-readonly — `RunInternals.operatorObjective`: this delegated leg's objective carries a person's words. */
|
|
44
|
+
operatorObjective: boolean;
|
|
43
45
|
/** borrowed-readonly — the effective walltime window (undefined = unbounded): `<= 0` refuses the first turn. */
|
|
44
46
|
effectiveTimeoutMs: number | undefined;
|
|
45
47
|
/** borrowed-mutable — the hard walltime timer: claimed (`fired`) and cleared by the exhausted arms and the finally. */
|