@sema-agent/core 7.59.0 → 7.61.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 +1169 -0
- package/README.md +2 -2
- 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 +4 -3
- package/dist/agents/agent-transcript-tool.js +4 -2
- package/dist/agents/cascade.d.ts +61 -10
- package/dist/agents/cascade.js +60 -20
- package/dist/agents/child-model-seat.js +6 -3
- package/dist/agents/composition-allowance.d.ts +53 -0
- package/dist/agents/composition-allowance.js +49 -0
- package/dist/agents/composition-placement.d.ts +29 -0
- package/dist/agents/composition-placement.js +24 -0
- package/dist/agents/cumulative-stats.d.ts +4 -0
- package/dist/agents/cumulative-stats.js +3 -1
- package/dist/agents/inherited-tool-pool.d.ts +28 -1
- package/dist/agents/inherited-tool-pool.js +22 -0
- package/dist/agents/list-agents-tool.d.ts +1 -1
- package/dist/agents/peer-notice-route.d.ts +1 -1
- package/dist/agents/peer-notice-route.js +4 -3
- package/dist/agents/peer-notices.d.ts +4 -4
- package/dist/agents/peer-notices.js +8 -4
- package/dist/agents/peer-session-drain.d.ts +8 -1
- package/dist/agents/peer-session-drain.js +36 -7
- package/dist/agents/repair-loop.js +16 -6
- package/dist/agents/retain-ledger.d.ts +11 -1
- package/dist/agents/retain-ledger.js +16 -3
- package/dist/agents/roster-store.d.ts +2 -2
- package/dist/agents/roster-store.js +8 -3
- package/dist/agents/send-message-tool.d.ts +14 -27
- package/dist/agents/send-message-tool.js +47 -54
- package/dist/agents/subagent-completion-gate.d.ts +35 -0
- package/dist/agents/subagent-completion-gate.js +62 -0
- package/dist/agents/subagent-steps.d.ts +7 -6
- package/dist/agents/subagent.d.ts +52 -28
- package/dist/agents/subagent.js +276 -246
- package/dist/agents/suspend-guard.d.ts +9 -0
- package/dist/agents/suspend-guard.js +4 -0
- package/dist/agents/tool-filter.d.ts +1 -3
- package/dist/agents/tool-filter.js +4 -12
- package/dist/agents/verify.d.ts +41 -14
- package/dist/agents/verify.js +37 -27
- package/dist/bench/metrics.d.ts +3 -5
- package/dist/bench/metrics.js +0 -1
- package/dist/brain/anthropic.js +1 -0
- package/dist/brain/degrading.js +3 -1
- package/dist/brain/errors.d.ts +7 -1
- package/dist/brain/errors.js +6 -0
- package/dist/brain/failover.js +2 -1
- package/dist/brain/open-responses.js +1 -0
- package/dist/brain/openai.js +1 -0
- package/dist/brain/provider-dialect.d.ts +10 -0
- package/dist/brain/provider-dialect.js +13 -2
- package/dist/brain/route-adjudicator.js +3 -1
- package/dist/brain/status-sink.d.ts +7 -1
- package/dist/brain/status-sink.js +6 -0
- package/dist/brain/stream-engine.d.ts +3 -0
- package/dist/brain/stream-engine.js +4 -0
- package/dist/brain/timeout.d.ts +3 -1
- package/dist/brain/timeout.js +18 -5
- package/dist/core/a2a.d.ts +15 -5
- package/dist/core/a2a.js +34 -19
- package/dist/core/agent-definition.d.ts +20 -0
- package/dist/core/agent-state.d.ts +1 -1
- package/dist/core/allow-entry.d.ts +61 -23
- package/dist/core/allow-entry.js +134 -39
- package/dist/core/artifact-host.d.ts +0 -2
- package/dist/core/artifact-host.js +0 -1
- package/dist/core/ask-origin.d.ts +79 -0
- package/dist/core/ask-origin.js +76 -0
- package/dist/core/ask-question.d.ts +19 -13
- package/dist/core/ask-question.js +8 -2
- package/dist/core/auto-compaction.d.ts +2 -0
- package/dist/core/auto-compaction.js +2 -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 +66 -17
- package/dist/core/background-agent-store.d.ts +17 -6
- package/dist/core/background-agent-store.js +15 -13
- package/dist/core/background-shell.d.ts +12 -1
- package/dist/core/background-shell.js +12 -0
- package/dist/core/checkpoint-requirements.d.ts +24 -3
- package/dist/core/checkpoint-requirements.js +9 -1
- package/dist/core/checkpoint-store.d.ts +86 -32
- package/dist/core/checkpoint-store.js +10 -5
- package/dist/core/child-clamp-seats.d.ts +3 -2
- package/dist/core/child-clamp-seats.js +4 -3
- package/dist/core/closest-name.d.ts +13 -0
- package/dist/core/closest-name.js +35 -0
- package/dist/core/compliance.d.ts +1 -1
- package/dist/core/context-settings.js +3 -5
- 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 +5 -6
- package/dist/core/decision-receipt.d.ts +14 -1
- package/dist/core/decision-receipt.js +6 -3
- package/dist/core/delegation-frames.d.ts +13 -9
- package/dist/core/effective-path-target.js +2 -3
- package/dist/core/engine-attestation.d.ts +11 -1
- package/dist/core/engine-attestation.js +2 -0
- package/dist/core/engine-notice.d.ts +106 -32
- package/dist/core/file-history-retention.d.ts +8 -0
- package/dist/core/file-history-retention.js +14 -11
- package/dist/core/file-history-store.d.ts +31 -1
- package/dist/core/file-history-store.js +31 -2
- package/dist/core/frame-settlement.d.ts +15 -0
- package/dist/core/frame-settlement.js +10 -1
- package/dist/core/fs-write-gate-policy.d.ts +3 -3
- package/dist/core/fs-write-gate-policy.js +8 -7
- package/dist/core/gate-fold.js +9 -6
- package/dist/core/gate-lanes.js +46 -12
- package/dist/core/gate-outcome.d.ts +40 -1
- package/dist/core/gate-outcome.js +10 -0
- package/dist/core/git-worktree-env.d.ts +7 -3
- package/dist/core/git-worktree-env.js +16 -13
- package/dist/core/governance-codes.d.ts +19 -3
- package/dist/core/governance-codes.js +27 -3
- package/dist/core/hands-band-screen.js +0 -1
- package/dist/core/hands-band.d.ts +0 -3
- package/dist/core/hooks.d.ts +51 -60
- package/dist/core/hooks.js +131 -78
- package/dist/core/host-floor.js +3 -5
- package/dist/core/image-admission.d.ts +145 -52
- package/dist/core/image-admission.js +202 -47
- package/dist/core/image-downsample.d.ts +36 -69
- package/dist/core/image-downsample.js +111 -73
- package/dist/core/input-author.d.ts +36 -0
- package/dist/core/input-author.js +39 -0
- package/dist/core/integer-option.d.ts +21 -0
- package/dist/core/integer-option.js +13 -0
- package/dist/core/leg-identity.d.ts +62 -0
- package/dist/core/leg-identity.js +18 -0
- package/dist/core/locked-config.d.ts +55 -3
- package/dist/core/locked-config.js +84 -51
- package/dist/core/lsp.d.ts +5 -3
- package/dist/core/lsp.js +3 -2
- package/dist/core/mailbox-store.d.ts +85 -10
- package/dist/core/mailbox-store.js +31 -10
- package/dist/core/mcp-call-meta.d.ts +2 -2
- package/dist/core/mcp-call-meta.js +9 -10
- package/dist/core/mcp-connection-pool.d.ts +6 -20
- package/dist/core/mcp-connection-pool.js +10 -28
- package/dist/core/mcp-failure.d.ts +83 -16
- package/dist/core/mcp-failure.js +67 -30
- package/dist/core/mcp-host-seat.d.ts +131 -0
- package/dist/core/mcp-host-seat.js +305 -0
- package/dist/core/mcp-probe.d.ts +7 -2
- package/dist/core/mcp-probe.js +9 -4
- package/dist/core/mcp-server-link.d.ts +18 -6
- package/dist/core/mcp-server-link.js +19 -4
- package/dist/core/mcp-server-spec.d.ts +39 -9
- package/dist/core/mcp-server-spec.js +55 -21
- package/dist/core/mcp-session-end.d.ts +1 -2
- package/dist/core/mcp-session-end.js +1 -1
- package/dist/core/mcp.d.ts +23 -55
- package/dist/core/mcp.js +172 -156
- package/dist/core/media-byte-cap.d.ts +21 -46
- package/dist/core/media-byte-cap.js +55 -55
- package/dist/core/member-group.d.ts +7 -0
- package/dist/core/member-group.js +35 -0
- package/dist/core/memory-admission.d.ts +23 -6
- package/dist/core/memory-admission.js +19 -9
- package/dist/core/memory-engine/consolidation.d.ts +1 -1
- package/dist/core/memory-engine/consolidation.js +7 -1
- 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/dual-root.d.ts +31 -0
- package/dist/core/memory-engine/dual-root.js +59 -11
- package/dist/core/memory-engine/engine.js +27 -24
- package/dist/core/memory-engine/file-backend.d.ts +13 -0
- package/dist/core/memory-engine/file-backend.js +35 -15
- package/dist/core/memory-engine/index.d.ts +2 -1
- package/dist/core/memory-engine/index.js +2 -1
- package/dist/core/memory-engine/layout.d.ts +3 -0
- package/dist/core/memory-engine/layout.js +13 -3
- package/dist/core/memory-engine/memory-deployment.d.ts +110 -0
- package/dist/core/memory-engine/memory-deployment.js +182 -0
- 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 +68 -13
- package/dist/core/memory-engine/sync-client.js +147 -18
- package/dist/core/memory-engine/sync-report.d.ts +106 -0
- package/dist/core/memory-engine/sync-report.js +119 -0
- package/dist/core/memory-engine/sync.d.ts +13 -3
- package/dist/core/mode-policy.d.ts +15 -7
- package/dist/core/mode-policy.js +18 -6
- 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 +100 -0
- package/dist/core/mods/agent-stations.js +154 -0
- package/dist/core/mods/dollar.d.ts +62 -0
- package/dist/core/mods/extension-call.d.ts +15 -1
- package/dist/core/mods/extension-call.js +7 -2
- package/dist/core/mods/kernel/dispatch.d.ts +9 -4
- package/dist/core/mods/kernel/dispatch.js +8 -8
- package/dist/core/mods/kernel/events.d.ts +13 -4
- package/dist/core/mods/kernel/events.js +14 -10
- 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 +3 -0
- package/dist/core/mods/kernel/registration.js +5 -0
- package/dist/core/mods/kernel/site-rules.d.ts +6 -3
- package/dist/core/mods/kernel/site-rules.js +10 -2
- package/dist/core/mods/lifecycle-stations.d.ts +41 -0
- package/dist/core/mods/lifecycle-stations.js +35 -0
- package/dist/core/mods/session-append.d.ts +115 -0
- package/dist/core/mods/session-append.js +311 -0
- package/dist/core/mods/session-compact.d.ts +48 -0
- package/dist/core/mods/session-compact.js +194 -0
- package/dist/core/mods/session-receive.d.ts +93 -0
- package/dist/core/mods/session-receive.js +141 -0
- package/dist/core/mods/session-send.d.ts +72 -0
- package/dist/core/mods/session-send.js +88 -0
- package/dist/core/mods/stations.d.ts +89 -75
- package/dist/core/mods/stations.js +57 -53
- package/dist/core/mods/tool-call.d.ts +12 -4
- package/dist/core/mods/tool-call.js +32 -16
- 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/output-style.js +3 -4
- package/dist/core/own-property-receipt.d.ts +62 -0
- package/dist/core/own-property-receipt.js +43 -0
- package/dist/core/park-selfcheck.js +12 -10
- package/dist/core/path-identity.d.ts +11 -0
- package/dist/core/path-identity.js +4 -0
- package/dist/core/path-rule-binding.d.ts +3 -1
- package/dist/core/path-rule-binding.js +3 -1
- package/dist/core/peer-seat.d.ts +66 -11
- package/dist/core/peer-seat.js +199 -42
- package/dist/core/permission-rule-consent.d.ts +21 -26
- package/dist/core/permission-rule-consent.js +22 -3
- package/dist/core/permission-rule-model.d.ts +38 -13
- package/dist/core/permission-rule-model.js +54 -16
- package/dist/core/permission-rule-org.d.ts +1 -1
- package/dist/core/permission-rule-provider.js +4 -1
- package/dist/core/permission-rules.d.ts +4 -0
- package/dist/core/permission-rules.js +11 -16
- 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 +218 -122
- package/dist/core/remote-env.js +133 -14
- package/dist/core/retention-policy.d.ts +24 -23
- package/dist/core/retention-policy.js +36 -2
- package/dist/core/retention.d.ts +4 -1
- package/dist/core/retention.js +37 -12
- package/dist/core/retired-keys.d.ts +8 -3
- package/dist/core/retired-keys.js +4 -1
- package/dist/core/rewrite-rejudge.d.ts +12 -5
- package/dist/core/rewrite-rejudge.js +9 -5
- package/dist/core/roles.d.ts +37 -3
- package/dist/core/roles.js +126 -78
- package/dist/core/row-admission.d.ts +10 -0
- package/dist/core/row-admission.js +5 -0
- package/dist/core/rule-owner.d.ts +3 -0
- package/dist/core/runner/advisor-instructions.d.ts +2 -1
- package/dist/core/runner/advisor-instructions.js +2 -1
- package/dist/core/runner/announce-once-ledger.d.ts +4 -4
- package/dist/core/runner/assemble-result.d.ts +13 -8
- package/dist/core/runner/assemble-result.js +12 -8
- package/dist/core/runner/call-hook-stations.d.ts +17 -10
- package/dist/core/runner/call-hook-stations.js +21 -10
- package/dist/core/runner/caller-roster.d.ts +12 -9
- package/dist/core/runner/caller-roster.js +5 -2
- package/dist/core/runner/checkpoint-scope.d.ts +16 -1
- package/dist/core/runner/checkpoint-scope.js +21 -0
- 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/compact-session.js +14 -2
- package/dist/core/runner/compaction-call-options.d.ts +1 -1
- package/dist/core/runner/compaction-restate.d.ts +2 -2
- package/dist/core/runner/compaction-restate.js +4 -3
- package/dist/core/runner/construction-doors.d.ts +2 -2
- package/dist/core/runner/construction-doors.js +7 -2
- package/dist/core/runner/contracts.d.ts +158 -65
- package/dist/core/runner/cross-boundary-lane.d.ts +4 -6
- package/dist/core/runner/cross-boundary-lane.js +11 -2
- package/dist/core/runner/decide-continuation.d.ts +4 -2
- package/dist/core/runner/decide-continuation.js +7 -4
- package/dist/core/runner/denial-limit-arms.d.ts +15 -21
- package/dist/core/runner/denial-limit-arms.js +17 -10
- 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/expire-settle.d.ts +44 -0
- package/dist/core/runner/expire-settle.js +55 -0
- 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 +75 -7
- package/dist/core/runner/gate-exit.js +20 -1
- package/dist/core/runner/git-status-frame.d.ts +5 -2
- package/dist/core/runner/git-status-frame.js +4 -4
- package/dist/core/runner/halt-attribution.d.ts +2 -1
- package/dist/core/runner/halt-attribution.js +2 -1
- 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/local-claims.d.ts +17 -0
- package/dist/core/runner/local-claims.js +18 -0
- package/dist/core/runner/media-removed-seat.d.ts +46 -0
- package/dist/core/runner/media-removed-seat.js +88 -0
- package/dist/core/runner/memory-consolidation-driver.js +4 -4
- package/dist/core/runner/park-commit.d.ts +2 -2
- package/dist/core/runner/permission-rule-lanes.d.ts +5 -1
- package/dist/core/runner/permission-rule-lanes.js +29 -10
- package/dist/core/runner/person-path-rows.js +1 -1
- package/dist/core/runner/placement-fence.d.ts +26 -0
- package/dist/core/runner/placement-fence.js +38 -0
- package/dist/core/runner/prepare-ask-lane.d.ts +6 -12
- package/dist/core/runner/prepare-ask-lane.js +4 -4
- package/dist/core/runner/prepare-boundary-parks.d.ts +6 -3
- package/dist/core/runner/prepare-boundary-parks.js +4 -4
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +6 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +5 -3
- package/dist/core/runner/prepare-config-doors.d.ts +6 -1
- package/dist/core/runner/prepare-config-doors.js +30 -26
- package/dist/core/runner/prepare-context-lane.d.ts +6 -2
- package/dist/core/runner/prepare-context-lane.js +13 -13
- package/dist/core/runner/prepare-delegation-surface.d.ts +13 -11
- package/dist/core/runner/prepare-delegation-surface.js +7 -8
- package/dist/core/runner/prepare-execution-env.d.ts +5 -2
- package/dist/core/runner/prepare-execution-env.js +7 -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 +23 -17
- package/dist/core/runner/prepare-gate-stations.js +10 -7
- package/dist/core/runner/prepare-hands-readface.d.ts +8 -6
- package/dist/core/runner/prepare-hands-readface.js +19 -11
- package/dist/core/runner/prepare-inherited-gate.d.ts +11 -4
- package/dist/core/runner/prepare-inherited-gate.js +12 -5
- package/dist/core/runner/prepare-lsp.d.ts +3 -0
- package/dist/core/runner/prepare-lsp.js +2 -2
- 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 +2 -2
- package/dist/core/runner/prepare-park-ask.d.ts +8 -7
- package/dist/core/runner/prepare-park-ask.js +6 -12
- package/dist/core/runner/prepare-policy-chain.d.ts +15 -25
- package/dist/core/runner/prepare-policy-chain.js +131 -128
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-project-context.js +8 -5
- package/dist/core/runner/prepare-prompt-inputs.d.ts +4 -0
- package/dist/core/runner/prepare-prompt-inputs.js +4 -2
- package/dist/core/runner/prepare-protocol-tools.d.ts +5 -3
- package/dist/core/runner/prepare-protocol-tools.js +9 -2
- package/dist/core/runner/prepare-question-face.d.ts +6 -4
- package/dist/core/runner/prepare-question-face.js +2 -2
- package/dist/core/runner/prepare-run-refs.d.ts +3 -0
- package/dist/core/runner/prepare-run-refs.js +2 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +11 -9
- package/dist/core/runner/prepare-suspend-saga.js +21 -13
- package/dist/core/runner/prepare-task.d.ts +1 -1
- package/dist/core/runner/prepare-task.js +84 -42
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +6 -0
- package/dist/core/runner/prepare-tool-disclosure-mount.js +3 -1
- 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 +7 -3
- package/dist/core/runner/prepare-wiring-manifest.js +34 -19
- package/dist/core/runner/prepare-workspace-restore.d.ts +5 -0
- package/dist/core/runner/prepare-workspace-restore.js +12 -8
- package/dist/core/runner/read-root-grant.d.ts +1 -1
- package/dist/core/runner/read-root-grant.js +2 -1
- package/dist/core/runner/resume-admission.d.ts +5 -3
- package/dist/core/runner/resume-admission.js +17 -3
- package/dist/core/runner/resume-apply.js +3 -1
- package/dist/core/runner/resume-checkpoint-screen.js +4 -4
- package/dist/core/runner/resume-claim.d.ts +8 -3
- package/dist/core/runner/resume-claim.js +28 -12
- package/dist/core/runner/resume-internals-and-config.d.ts +2 -2
- package/dist/core/runner/resume-internals-and-config.js +10 -1
- package/dist/core/runner/resume-preflight.d.ts +3 -2
- package/dist/core/runner/resume-preflight.js +13 -26
- package/dist/core/runner/retired-runner-deps.js +6 -1
- package/dist/core/runner/run-attachment-seats.js +3 -3
- package/dist/core/runner/run-brain-sinks.js +1 -0
- package/dist/core/runner/run-git-lane.d.ts +3 -1
- package/dist/core/runner/run-git-lane.js +3 -2
- package/dist/core/runner/run-harness-handlers.d.ts +3 -1
- package/dist/core/runner/run-harness-handlers.js +5 -3
- package/dist/core/runner/run-identity-wiring.d.ts +2 -2
- package/dist/core/runner/run-identity-wiring.js +15 -6
- package/dist/core/runner/run-leg.d.ts +3 -3
- package/dist/core/runner/run-leg.js +65 -56
- package/dist/core/runner/run-notification-lane.d.ts +3 -1
- package/dist/core/runner/run-notification-lane.js +36 -12
- package/dist/core/runner/run-recovery-lanes.js +3 -2
- package/dist/core/runner/run-settle-and-teardown.js +14 -8
- package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
- package/dist/core/runner/run-stop-and-final-verify.js +12 -4
- package/dist/core/runner/run-telemetry-and-budget-seats.d.ts +1 -1
- package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
- package/dist/core/runner/run-terminal-adoption.js +26 -17
- package/dist/core/runner/run-turn-boundary.js +37 -19
- package/dist/core/runner/runtask.d.ts +25 -7
- package/dist/core/runner/runtask.js +46 -22
- package/dist/core/runner/session-rule-policy.d.ts +1 -1
- package/dist/core/runner/session-rule-policy.js +6 -1
- package/dist/core/runner/shell-env-withheld.d.ts +1 -1
- package/dist/core/runner/skills-seat.js +2 -2
- package/dist/core/runner/stream-halt-verbs.d.ts +1 -14
- package/dist/core/runner/stream-halt-verbs.js +4 -3
- package/dist/core/runner/stream-reap.d.ts +7 -6
- package/dist/core/runner/stream-reap.js +13 -16
- package/dist/core/runner/stream-settle-backstop.d.ts +3 -2
- package/dist/core/runner/stream-settle-backstop.js +5 -3
- package/dist/core/runner/stream-steer-verb.d.ts +5 -2
- package/dist/core/runner/stream-steer-verb.js +8 -7
- package/dist/core/runner/sub-agent-deny-lists.js +10 -7
- package/dist/core/runner/synthetic-tools.js +2 -2
- package/dist/core/runner/terminal-account.d.ts +11 -1
- package/dist/core/runner/terminal-account.js +20 -0
- package/dist/core/runner/terminal-projection.d.ts +8 -2
- package/dist/core/runner/terminal-projection.js +2 -2
- package/dist/core/runner/tool-disclosure.d.ts +3 -0
- package/dist/core/runner/tool-disclosure.js +5 -4
- package/dist/core/runner/tool-end-body.d.ts +3 -3
- package/dist/core/runner/tool-end-body.js +1 -1
- 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-output-projection.d.ts +3 -3
- package/dist/core/runner/tool-output-projection.js +7 -6
- 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/tool-table-view.d.ts +56 -0
- package/dist/core/runner/tool-table-view.js +51 -0
- package/dist/core/runner/turn-attachments.d.ts +6 -7
- package/dist/core/runner/turn-attachments.js +4 -17
- package/dist/core/runner/void-verifier-pause.d.ts +33 -0
- package/dist/core/runner/void-verifier-pause.js +41 -0
- package/dist/core/runner-deps.d.ts +55 -43
- package/dist/core/secret-env.d.ts +14 -13
- package/dist/core/secret-env.js +8 -9
- package/dist/core/session-log-transfer.js +9 -10
- package/dist/core/session-policy-store.d.ts +10 -3
- package/dist/core/session-policy-store.js +21 -3
- package/dist/core/session-reconcile.d.ts +3 -2
- package/dist/core/session-reconcile.js +7 -4
- package/dist/core/session-store.d.ts +5 -2
- package/dist/core/session-store.js +53 -16
- package/dist/core/session.d.ts +2 -1
- package/dist/core/shell-confinement.d.ts +37 -0
- package/dist/core/shell-confinement.js +56 -0
- package/dist/core/skill-grant.d.ts +9 -0
- package/dist/core/skill-grant.js +18 -0
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +2 -2
- package/dist/core/store-contracts/checkpoint-store-contract.js +15 -2
- package/dist/core/store-contracts/file-history-store-contract.d.ts +5 -2
- package/dist/core/store-contracts/file-history-store-contract.js +25 -1
- package/dist/core/store-contracts/mailbox-store-contract.d.ts +12 -5
- package/dist/core/store-contracts/mailbox-store-contract.js +156 -9
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/tool-result-store-contract.js +67 -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/task-event.d.ts +35 -10
- package/dist/core/task-limits.d.ts +5 -0
- package/dist/core/task-notification.d.ts +172 -12
- package/dist/core/task-notification.js +209 -12
- package/dist/core/task-registry-agent.d.ts +23 -55
- package/dist/core/task-registry-agent.js +41 -56
- package/dist/core/task-registry-monitor.d.ts +8 -1
- package/dist/core/task-registry-monitor.js +43 -61
- package/dist/core/task-registry-shared.d.ts +52 -114
- package/dist/core/task-registry-shared.js +24 -48
- package/dist/core/task-registry-workflow.js +5 -22
- package/dist/core/task-registry.d.ts +64 -90
- package/dist/core/task-registry.js +73 -119
- package/dist/core/task-result.d.ts +27 -19
- package/dist/core/task-spec-members.d.ts +39 -0
- package/dist/core/task-spec-members.js +92 -0
- package/dist/core/task-spec.d.ts +13 -16
- package/dist/core/task-stream.d.ts +1 -1
- package/dist/core/task-tool-shape.d.ts +7 -57
- package/dist/core/task-tool-shape.js +7 -66
- package/dist/core/terminal-cause.d.ts +30 -0
- package/dist/core/terminal-cause.js +1 -0
- package/dist/core/tool-catalog-entries.js +3 -6
- package/dist/core/tool-check-reading.js +16 -10
- package/dist/core/tool-conformance.js +1 -2
- package/dist/core/tool-errors.d.ts +6 -3
- package/dist/core/tool-errors.js +2 -0
- package/dist/core/tool-face-reader.d.ts +7 -6
- package/dist/core/tool-face-reader.js +6 -4
- package/dist/core/tool-face.d.ts +2 -3
- package/dist/core/tool-name-aliases.d.ts +23 -28
- package/dist/core/tool-name-aliases.js +63 -7
- package/dist/core/tool-name-readings.d.ts +14 -3
- package/dist/core/tool-name-readings.js +2 -0
- package/dist/core/tool-policy.d.ts +113 -22
- package/dist/core/tool-policy.js +85 -15
- 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 +111 -5
- package/dist/core/tool-result-store.js +52 -12
- package/dist/core/tool-spec.d.ts +39 -10
- package/dist/core/trace.d.ts +18 -2
- package/dist/core/types.d.ts +3 -3
- package/dist/core/types.js +1 -1
- package/dist/core/untrusted-text.js +1 -1
- package/dist/core/user-attachment.d.ts +10 -5
- package/dist/core/user-attachment.js +40 -27
- package/dist/core/workflow-journal-store.d.ts +1 -1
- package/dist/core/workflow-run-store.d.ts +2 -0
- package/dist/core/workflow-run-store.js +6 -5
- package/dist/core/workflow-settled-run.d.ts +5 -0
- package/dist/core/workflow-settled-run.js +7 -0
- package/dist/engine/execution-env/node-execution-env.d.ts +37 -7
- package/dist/engine/execution-env/node-execution-env.js +224 -21
- package/dist/engine/harness/agent-harness.d.ts +66 -19
- package/dist/engine/harness/agent-harness.js +98 -27
- package/dist/engine/harness/messages.d.ts +4 -3
- package/dist/engine/harness/messages.js +2 -2
- package/dist/engine/harness/types.d.ts +151 -34
- package/dist/engine/llm/media-removed.d.ts +14 -0
- package/dist/engine/llm/media-removed.js +9 -0
- package/dist/engine/llm/rejected-images.d.ts +35 -25
- package/dist/engine/llm/rejected-images.js +59 -10
- package/dist/engine/llm/types.d.ts +24 -3
- package/dist/engine/llm/types.js +7 -3
- package/dist/engine/loop/agent-loop.d.ts +18 -13
- package/dist/engine/loop/agent-loop.js +173 -32
- package/dist/engine/loop/types.d.ts +21 -5
- 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/import-validate.js +7 -0
- package/dist/fixtures/index.d.ts +7 -5
- package/dist/fixtures/index.js +5 -3
- package/dist/index.d.ts +41 -23
- package/dist/index.js +29 -16
- package/dist/internal/harness-types.d.ts +3 -1
- package/dist/internal/llm.d.ts +2 -1
- package/dist/internal/llm.js +1 -0
- package/dist/orchestration/goal.d.ts +6 -2
- package/dist/orchestration/goal.js +6 -3
- package/dist/orchestration/run-workflow-tool.d.ts +20 -20
- package/dist/orchestration/run-workflow-tool.js +63 -56
- package/dist/orchestration/workflow-governance.d.ts +1 -1
- package/dist/orchestration/workflow-governance.js +2 -1
- package/dist/orchestration/workflow-types.d.ts +2 -2
- package/dist/orchestration/workflow.d.ts +8 -0
- package/dist/orchestration/workflow.js +33 -9
- package/dist/prompts/default.d.ts +1 -10
- package/dist/prompts/default.js +0 -2
- package/dist/stores/file/background-agent-store.d.ts +1 -1
- package/dist/stores/file/background-agent-store.js +19 -14
- package/dist/stores/file/checkpoint-store.d.ts +127 -2
- package/dist/stores/file/checkpoint-store.js +24 -16
- package/dist/stores/file/file-history-store.d.ts +1 -1
- package/dist/stores/file/file-history-store.js +4 -1
- package/dist/stores/file/index.d.ts +9 -6
- package/dist/stores/file/index.js +33 -9
- package/dist/stores/file/ledger-tuning.d.ts +23 -0
- package/dist/stores/file/ledger-tuning.js +21 -0
- package/dist/stores/file/mailbox-store.d.ts +1 -1
- package/dist/stores/file/mailbox-store.js +43 -21
- package/dist/stores/file/memory-store.d.ts +1 -1
- package/dist/stores/file/memory-store.js +4 -1
- package/dist/stores/file/permission-rule-adopt.js +24 -21
- package/dist/stores/file/permission-rule-store.js +6 -3
- package/dist/stores/file/session-policy-store.d.ts +1 -1
- package/dist/stores/file/session-policy-store.js +4 -1
- package/dist/stores/file/session-store.d.ts +17 -4
- package/dist/stores/file/session-store.js +22 -19
- 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 +31 -2
- package/dist/stores/file/tool-result-store.js +129 -7
- package/dist/stores/file/usage-window-store.d.ts +1 -1
- package/dist/stores/file/usage-window-store.js +4 -1
- package/dist/stores/file/workflow-journal-store.d.ts +1 -13
- package/dist/stores/file/workflow-journal-store.js +4 -18
- package/dist/stores/file/workflow-run-store.d.ts +1 -1
- package/dist/stores/file/workflow-run-store.js +15 -10
- package/dist/tools/fs/containment-face.d.ts +5 -0
- package/dist/tools/fs/dead-cwd.d.ts +5 -5
- package/dist/tools/fs/dead-cwd.js +4 -11
- 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 +13 -0
- package/dist/tools/fs/fs-bash-background-text.js +7 -0
- package/dist/tools/fs/fs-bash.d.ts +11 -22
- package/dist/tools/fs/fs-bash.js +58 -154
- package/dist/tools/fs/fs-pdf.d.ts +2 -2
- package/dist/tools/fs/fs-pdf.js +34 -27
- 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 +39 -16
- package/dist/tools/fs/fs-shared.js +25 -6
- package/dist/tools/fs/fs-write.js +5 -5
- package/dist/tools/fs/index.d.ts +15 -9
- package/dist/tools/fs/index.js +12 -18
- package/dist/tools/fs/pdf.d.ts +4 -4
- package/dist/tools/fs/pdf.js +6 -6
- package/dist/tools/fs/read-deny-home.js +8 -1
- package/dist/tools/fs/read-deny.d.ts +26 -2
- package/dist/tools/fs/read-deny.js +9 -2
- package/dist/tools/fs/read-floor.d.ts +57 -6
- package/dist/tools/fs/read-floor.js +241 -2
- 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 +6 -5
- package/dist/tools/fs/search.js +10 -10
- package/dist/tools/fs/shell-read-establish.js +3 -1
- package/dist/tools/fs/shell-read-identity.d.ts +3 -1
- package/dist/tools/fs/shell-read-identity.js +4 -2
- package/dist/tools/fs/shell-read-judge.d.ts +7 -1
- package/dist/tools/fs/shell-read-judge.js +1 -1
- package/dist/tools/monitor.d.ts +12 -10
- package/dist/tools/monitor.js +22 -13
- package/dist/tools/scheduler-tools.js +42 -4
- package/dist/tools/web.d.ts +0 -10
- package/dist/tools/web.js +1 -4
- package/dist/tools/worktree.d.ts +5 -1
- package/dist/tools/worktree.js +20 -17
- package/package.json +8 -3
- package/test/export-surface.snapshot.json +166 -30
- package/wire-changes/core-stores-sql@7.60.0.json +30 -0
- package/wire-changes/core-stores-sql@7.61.0.json +480 -0
- package/wire-changes/core@7.60.0.json +3274 -0
- package/wire-changes/core@7.61.0.json +4405 -0
- package/wire-changes/mods-kernel@7.60.0.json +62 -0
- package/wire-changes/mods-kernel@7.61.0.json +65 -0
- package/wire-changes/primitives@7.60.0.json +30 -0
- package/wire-changes/primitives@7.61.0.json +30 -0
- package/dist/core/runner/image-removed-seat.d.ts +0 -12
- package/dist/core/runner/image-removed-seat.js +0 -19
package/dist/core/hooks.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { argsAsTheToolReads, stampArgsReading } from "./effective-path-target.js";
|
|
2
|
-
import { extensionAuthors, noteRewrite, screeningAuthorship } from "./rewrite-rejudge.js";
|
|
3
|
-
import {
|
|
4
|
-
import { createSettlementLedger, engineFailClosedExit, hookDenyExit, unownedArgsExit } from "./runner/gate-exit.js";
|
|
5
|
-
import {
|
|
2
|
+
import { extensionAuthors, noteRewrite, readRejudge, rewriteChasedSentence, screeningAuthorship } from "./rewrite-rejudge.js";
|
|
3
|
+
import { decisionText, describeThrown, extensionQuestionText, foldHookAsk, isEngineRefusal, ownArgs, ownedReading, refuseOutOfContractDecision } from "./tool-policy.js";
|
|
4
|
+
import { createSettlementLedger, engineFailClosedExit, hookDenyExit, settledScreen, settledScreenExit, takeInheritedScreen, unownedArgsExit } from "./runner/gate-exit.js";
|
|
5
|
+
import { composeCallSignal } from "./runner/abort-race.js";
|
|
6
|
+
import { classicEventBase, dispatchClassic, ENGINE_CORE_ANSWER, failedHandlerClause, judgedInputOf, observePermissionDenied } from "./mods/stations.js";
|
|
6
7
|
import { runGateFold } from "./gate-fold.js";
|
|
7
8
|
import { runGateLanes } from "./gate-lanes.js";
|
|
8
9
|
export { normalizeOrgGateVerdict, normalizePersistedRuleHit } from "./rule-lane-reads.js";
|
|
9
|
-
import {
|
|
10
|
-
import { isAskOrigin, screenAskClassMembers } from "./ask-origin.js";
|
|
10
|
+
import { hookAskReasonOf, isAskOrigin, receiveAskReasons, screenAskClassMembers } from "./ask-origin.js";
|
|
11
11
|
import { isAutoModeFallbackCause } from "./auto-mode.js";
|
|
12
12
|
import { inlineUntrusted } from "./untrusted-text.js";
|
|
13
13
|
export { formatHookFeedback } from "./reminder-mint.js";
|
|
@@ -111,13 +111,19 @@ function preToolUseRefusedReason(subject, failed) {
|
|
|
111
111
|
: "";
|
|
112
112
|
return `a PreToolUse hook ${failedHandlerClause(failed)} while screening ${subject}; the call was NOT executed (fail-closed).${tail}`;
|
|
113
113
|
}
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
114
|
+
function hookAskOf(r, answeredBy, toolName) {
|
|
115
|
+
const { questionCause, ...ask } = r;
|
|
116
|
+
const entry = hookAskReasonOf(answeredBy, questionCause ?? "asked", decisionText(ask));
|
|
117
|
+
return { ...ask, ...(answeredBy !== undefined ? { message: extensionQuestionText(toolName, entry) } : {}), askReasons: Object.freeze([entry]) };
|
|
118
|
+
}
|
|
119
|
+
export function createPreToolUseScreening(input, readSettled = (decision) => ({ decision })) {
|
|
120
|
+
const own = input.modBus !== undefined && input.modBus.hasHandlers("classic.PreToolUse") ? input.modBus : undefined;
|
|
121
|
+
const inherited = (input.inheritedInstallations ?? []).filter((i) => i.bus.hasHandlers("classic.PreToolUse", i.judges));
|
|
122
|
+
if (own === undefined && inherited.length === 0)
|
|
117
123
|
return undefined;
|
|
118
124
|
const { toolCallId, toolName } = input.event;
|
|
119
125
|
const screenedName = wireOf("gate.preToolUse", input.event);
|
|
120
|
-
const eventOf = (args) => {
|
|
126
|
+
const eventOf = (args, env) => {
|
|
121
127
|
const cwd = input.trackedCwd?.();
|
|
122
128
|
return {
|
|
123
129
|
...classicEventBase(input.identity, input.observedPermissionMode?.()),
|
|
@@ -125,77 +131,114 @@ export function createPreToolUseScreening(input) {
|
|
|
125
131
|
tool_use_id: toolCallId,
|
|
126
132
|
input: judgedInputOf(args),
|
|
127
133
|
...(typeof cwd === "string" ? { cwd } : {}),
|
|
128
|
-
...(
|
|
134
|
+
...(env !== undefined ? { env } : {}),
|
|
129
135
|
};
|
|
130
136
|
};
|
|
137
|
+
const raise = async (bus, participant, env, args, subject, readAs, signal) => {
|
|
138
|
+
let outcome;
|
|
139
|
+
const authorship = screeningAuthorship(readAs);
|
|
140
|
+
try {
|
|
141
|
+
outcome = await dispatchClassic(bus, "classic.PreToolUse", eventOf(args, env), { ...(signal !== undefined ? { signal } : {}), ...(participant !== undefined ? { participant } : {}), checkAnswer: (a, e, by, below) => preToolUseAnswerViolation(a) ?? authorship.record(a, e, by, below), ranks: PRE_TOOL_USE_RANKS });
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
return { kind: "refused", reason: preToolUseRefusedReason(subject, { kind: "failed", registration: "engine", cause: "threw", reason: `could not raise the screening: ${describeThrown(err)}`, skipped: [] }) };
|
|
145
|
+
}
|
|
146
|
+
if (outcome === undefined || outcome.kind === "aborted")
|
|
147
|
+
return { kind: "refused", reason: preToolUseRefusedReason(subject, undefined) };
|
|
148
|
+
if (outcome.kind === "failed")
|
|
149
|
+
return { kind: "refused", reason: preToolUseRefusedReason(subject, outcome), extension: outcome.registration };
|
|
150
|
+
const r = screenPreToolUseResult(outcome.answer);
|
|
151
|
+
const answer = r === null || r === false || r === undefined ? undefined : r.action === "ask" ? hookAskOf(r, outcome.answeredBy, toolName) : r;
|
|
152
|
+
const rewrittenBy = authorship.of(outcome.answer);
|
|
153
|
+
return { kind: "answered", answer, ...(outcome.answeredBy !== undefined ? { answeredBy: outcome.answeredBy } : {}), rewrittenBy: answer?.updatedInput === undefined ? [] : rewrittenBy.length > 0 || outcome.answeredBy === undefined ? rewrittenBy : [outcome.answeredBy] };
|
|
154
|
+
};
|
|
155
|
+
const seats = [
|
|
156
|
+
...(own !== undefined ? [{ look: ((args, subject, readAs, signal) => raise(own, undefined, input.hookEnv, args, subject, readAs, signal)) }] : []),
|
|
157
|
+
...inherited.map((installation) => ({ installation, look: ((args, subject, readAs, signal) => raise(installation.bus, installation.judges, installation.env, args, subject, readAs, signal)) })),
|
|
158
|
+
];
|
|
159
|
+
const deniedReason = (answer) => decisionText(answer) ?? `tool "${toolName}" blocked by a PreToolUse hook`;
|
|
131
160
|
return {
|
|
132
161
|
screen: async (args, subject, readAs) => {
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const answer = r === null || r === false ? undefined : r;
|
|
147
|
-
const rewrittenBy = authorship.of(outcome.answer);
|
|
148
|
-
return { kind: "answered", answer, ...(outcome.answeredBy !== undefined ? { answeredBy: outcome.answeredBy } : {}), ...(answer?.updatedInput !== undefined ? { rewrittenBy: rewrittenBy.length > 0 || outcome.answeredBy === undefined ? rewrittenBy : [outcome.answeredBy] } : {}) };
|
|
149
|
-
},
|
|
150
|
-
deniedReason: (answer) => decisionText(answer) ?? `tool "${toolName}" blocked by a PreToolUse hook`,
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
export function createPreToolUseConstraintPolicy(chain, env) {
|
|
154
|
-
const judges = (p) => !p.observe;
|
|
155
|
-
const minted = brandPolicyAskClass({
|
|
156
|
-
check: async (req, signal) => {
|
|
157
|
-
if (!chain.hasHandlers("classic.PreToolUse", judges))
|
|
158
|
-
return { action: "allow" };
|
|
159
|
-
const unasked = unaskedSeatAnswer(req, signal, { aborted: `the inherited PreToolUse screening of "${req.toolName}" was not consulted: the run or turn was already interrupted`, unreachable: `the inherited PreToolUse screening of "${req.toolName}" was not consulted: nobody can be asked about this call` }, "hook");
|
|
160
|
-
if (unasked !== undefined)
|
|
161
|
-
return unasked;
|
|
162
|
-
const subject = `this call to "${req.toolName}"`;
|
|
163
|
-
let outcome;
|
|
164
|
-
try {
|
|
165
|
-
outcome = await chain.dispatch("classic.PreToolUse", { tool: req.toolName, tool_use_id: req.toolCallId, input: judgedInputOf(req.args), ...(env !== undefined ? { env } : {}) }, {
|
|
166
|
-
bottom: engineCore,
|
|
167
|
-
participant: judges,
|
|
168
|
-
...(signal !== undefined ? { signal } : {}),
|
|
169
|
-
checkAnswer: (a) => (a === ENGINE_CORE_ANSWER ? undefined : preToolUseAnswerViolation(a)),
|
|
170
|
-
ranks: PRE_TOOL_USE_RANKS,
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
catch (err) {
|
|
174
|
-
return { action: "deny", message: preToolUseRefusedReason(subject, { kind: "failed", registration: "engine", cause: "threw", reason: `could not raise the screening: ${describeThrown(err)}`, skipped: [] }), decisionReason: "hook" };
|
|
175
|
-
}
|
|
176
|
-
if (outcome.kind === "aborted")
|
|
177
|
-
return abortedSeatDeny(req, `the inherited PreToolUse screening of "${req.toolName}" ended when the run or turn was interrupted`, "hook");
|
|
178
|
-
if (outcome.kind === "failed")
|
|
179
|
-
return { action: "deny", message: preToolUseRefusedReason(subject, outcome), decisionReason: "hook" };
|
|
180
|
-
const r = screenPreToolUseResult(outcome.answer);
|
|
181
|
-
if (r === undefined || r === null || r === false)
|
|
182
|
-
return { action: "allow" };
|
|
183
|
-
if (r.action === "deny") {
|
|
184
|
-
return { action: "deny", message: decisionText(r) ?? `tool "${req.toolName}" blocked by a PreToolUse hook`, decisionReason: "hook" };
|
|
185
|
-
}
|
|
186
|
-
if (r.action === "ask") {
|
|
162
|
+
const as = readAs ?? {};
|
|
163
|
+
const signal = input.abortSignal !== undefined ? composeCallSignal(input.abortSignal, input.callSignal) : input.callSignal;
|
|
164
|
+
let bytes = args;
|
|
165
|
+
let form;
|
|
166
|
+
const authors = [];
|
|
167
|
+
const contexts = [];
|
|
168
|
+
let ownAnswer;
|
|
169
|
+
let ownBy;
|
|
170
|
+
const allowedBy = new Map();
|
|
171
|
+
const floated = new Map();
|
|
172
|
+
const answered = (answer, answeredBy, approved) => {
|
|
173
|
+
const shown = form !== undefined && answer?.action !== "deny" ? { ...answer, updatedInput: form.raw } : answer;
|
|
174
|
+
const asks = [...floated.values()];
|
|
187
175
|
return {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
...(
|
|
192
|
-
|
|
176
|
+
kind: "answered",
|
|
177
|
+
answer: shown,
|
|
178
|
+
...(answeredBy !== undefined ? { answeredBy } : {}),
|
|
179
|
+
...(form !== undefined && answer?.action !== "deny" ? { rewrittenBy: authors } : {}),
|
|
180
|
+
contexts,
|
|
181
|
+
...(inherited.length > 0 ? { inherited: { allowedBy: [...allowedBy.values()], ...(asks.length > 0 ? { floated: asks.reduce((a, b) => foldHookAsk(a, b)) } : {}), ...(approved !== undefined ? { approved } : {}) } } : {}),
|
|
193
182
|
};
|
|
183
|
+
};
|
|
184
|
+
const judgedOf = () => (bytes !== args ? { judged: bytes } : {});
|
|
185
|
+
const lookAt = async (i, second) => {
|
|
186
|
+
const seat = seats[i];
|
|
187
|
+
const r = await seat.look(bytes, subject, as, signal);
|
|
188
|
+
if (r.kind === "refused")
|
|
189
|
+
return { ...r, ...judgedOf() };
|
|
190
|
+
const a = r.answer;
|
|
191
|
+
if (a?.additionalContext)
|
|
192
|
+
contexts.push(a.additionalContext);
|
|
193
|
+
if (a?.action === "deny")
|
|
194
|
+
return { ...answered(a, r.answeredBy), ...judgedOf() };
|
|
195
|
+
const read = readRejudge(as, bytes, a);
|
|
196
|
+
if (second && read.kind === "rewritten")
|
|
197
|
+
return { kind: "refused", reason: rewriteChasedSentence(toolName), ...judgedOf() };
|
|
198
|
+
if (a?.updatedInput !== undefined) {
|
|
199
|
+
form = { raw: a.updatedInput };
|
|
200
|
+
authors.push(...r.rewrittenBy.filter((by) => !authors.includes(by)));
|
|
201
|
+
}
|
|
202
|
+
if (read.kind === "rewritten") {
|
|
203
|
+
bytes = read.form;
|
|
204
|
+
for (let j = 0; j < i; j++) {
|
|
205
|
+
const ended = await lookAt(j, true);
|
|
206
|
+
if (ended !== undefined)
|
|
207
|
+
return ended;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
const verdict = a === undefined ? undefined : (({ updatedInput: _form, ...v }) => v)(a);
|
|
211
|
+
if (seat.installation === undefined) {
|
|
212
|
+
ownAnswer = verdict;
|
|
213
|
+
ownBy = r.answeredBy;
|
|
214
|
+
return undefined;
|
|
215
|
+
}
|
|
216
|
+
allowedBy.delete(i);
|
|
217
|
+
floated.delete(i);
|
|
218
|
+
if (verdict?.action === "allow" && r.answeredBy !== undefined)
|
|
219
|
+
allowedBy.set(i, r.answeredBy);
|
|
220
|
+
if (verdict?.action !== "ask")
|
|
221
|
+
return undefined;
|
|
222
|
+
const ask = { action: "ask", message: decisionText(verdict) ?? `approval required for "${toolName}" (an inherited PreToolUse hook)`, decisionReason: "hook", ...(verdict.requiresRealApproval === true ? { requiresRealApproval: true } : {}), ...(verdict.askReasons !== undefined ? { askReasons: verdict.askReasons } : {}) };
|
|
223
|
+
const call = Object.freeze({ toolName, toolCallId, args: bytes, ...(as.face !== undefined ? { face: as.face } : {}) });
|
|
224
|
+
const settled = readSettled(await seat.installation.settle(ask, call, signal));
|
|
225
|
+
if (settled.decision.action === "deny")
|
|
226
|
+
return settledScreen(settled, judgedOf());
|
|
227
|
+
if (settled.decision.action === "allow" && settled.decision.updatedInput !== undefined)
|
|
228
|
+
return answered(ownAnswer, ownBy, { ...settled.decision, updatedInput: settled.decision.updatedInput });
|
|
229
|
+
if (settled.decision.action === "ask")
|
|
230
|
+
floated.set(i, settled.decision);
|
|
231
|
+
return undefined;
|
|
232
|
+
};
|
|
233
|
+
for (let i = 0; i < seats.length; i++) {
|
|
234
|
+
const ended = await lookAt(i, false);
|
|
235
|
+
if (ended !== undefined)
|
|
236
|
+
return ended;
|
|
194
237
|
}
|
|
195
|
-
return
|
|
238
|
+
return answered(ownAnswer, ownBy);
|
|
196
239
|
},
|
|
197
|
-
|
|
198
|
-
|
|
240
|
+
deniedReason,
|
|
241
|
+
};
|
|
199
242
|
}
|
|
200
243
|
export function askCarryRowMembers(carry) {
|
|
201
244
|
if (carry === undefined)
|
|
@@ -203,11 +246,13 @@ export function askCarryRowMembers(carry) {
|
|
|
203
246
|
const origin = carry.origin;
|
|
204
247
|
const why = carry.classifierNoRuling;
|
|
205
248
|
const classed = screenAskClassMembers(carry.askClass, carry.classes);
|
|
249
|
+
const askReasons = receiveAskReasons(carry.askReasons);
|
|
206
250
|
return {
|
|
207
251
|
...(carry.denialLimitFallback !== undefined ? { denialLimitFallback: { ...carry.denialLimitFallback } } : {}),
|
|
208
252
|
...(isAutoModeFallbackCause(why) ? { classifierNoRuling: why } : {}),
|
|
209
253
|
...(isAskOrigin(origin) ? { origin } : {}),
|
|
210
254
|
...(classed !== undefined ? classed : {}),
|
|
255
|
+
...(askReasons !== undefined ? { askReasons } : {}),
|
|
211
256
|
};
|
|
212
257
|
}
|
|
213
258
|
export async function runToolGate(input) {
|
|
@@ -224,7 +269,12 @@ export async function runToolGate(input) {
|
|
|
224
269
|
const onHostObserverFailure = (err) => void notifier.notify(() => { throw err; }, "toolGate.permissionDenied");
|
|
225
270
|
return observePermissionDenied({ legBus: input.modBus, hostObserver: input.permissionDenied, payload: seen, signal: input.abortSignal, onHostObserverFailure });
|
|
226
271
|
};
|
|
227
|
-
const
|
|
272
|
+
const ledger = createSettlementLedger({ toolCallId, toolName });
|
|
273
|
+
const screening = createPreToolUseScreening(input, (settled) => {
|
|
274
|
+
const read = ledger.fromDecision(settled);
|
|
275
|
+
const cause = ledger.causeOf(read.decision);
|
|
276
|
+
return { ...read, ...(cause !== undefined ? { cause } : {}) };
|
|
277
|
+
});
|
|
228
278
|
const pass = {
|
|
229
279
|
input,
|
|
230
280
|
event,
|
|
@@ -235,7 +285,7 @@ export async function runToolGate(input) {
|
|
|
235
285
|
toolCallId,
|
|
236
286
|
callSignal,
|
|
237
287
|
notifier,
|
|
238
|
-
ledger
|
|
288
|
+
ledger,
|
|
239
289
|
notifyPermissionDenied: notifyPermissionDeniedSeat,
|
|
240
290
|
screening,
|
|
241
291
|
afterFold: runGateLanes,
|
|
@@ -256,14 +306,16 @@ export async function runToolGate(input) {
|
|
|
256
306
|
return await unownedArgsExit(pass, owned.reason);
|
|
257
307
|
if (screening !== undefined) {
|
|
258
308
|
const screened = await screening.screen(pass.currentInput, `this call to "${toolName}"`, pass.req);
|
|
309
|
+
if ((screened.kind !== "answered" || screened.answer?.action === "deny") && screened.judged !== undefined)
|
|
310
|
+
pass.currentInput = screened.judged;
|
|
259
311
|
if (screened.kind === "refused") {
|
|
260
312
|
return await engineFailClosedExit(pass, screened.reason, screened.extension);
|
|
261
313
|
}
|
|
314
|
+
if (screened.kind === "settled")
|
|
315
|
+
return await settledScreenExit(pass, screened);
|
|
316
|
+
pass.preToolContext.push(...screened.contexts);
|
|
262
317
|
const r = screened.answer;
|
|
263
318
|
if (r) {
|
|
264
|
-
if (r.additionalContext) {
|
|
265
|
-
pass.preToolContext.push(r.additionalContext);
|
|
266
|
-
}
|
|
267
319
|
if (r.action === "deny") {
|
|
268
320
|
return hookDenyExit(pass, screening.deniedReason(r), screened.answeredBy);
|
|
269
321
|
}
|
|
@@ -278,6 +330,7 @@ export async function runToolGate(input) {
|
|
|
278
330
|
if (r.action === "allow")
|
|
279
331
|
pass.hookAllowedBy = screened.answeredBy !== undefined ? [screened.answeredBy] : [];
|
|
280
332
|
}
|
|
333
|
+
takeInheritedScreen(pass, screened.inherited);
|
|
281
334
|
}
|
|
282
335
|
return await runGateFold(pass);
|
|
283
336
|
}
|
package/dist/core/host-floor.js
CHANGED
|
@@ -2,7 +2,7 @@ import { isIP } from "node:net";
|
|
|
2
2
|
import { HOST_UNREADABLE_SENTENCE, callHostTargetOf, hostOfUrl, hostPatternAdmits, readHostPattern, spelledHostPattern } from "./host-target.js";
|
|
3
3
|
import { inlineUntrusted } from "./untrusted-text.js";
|
|
4
4
|
import { describeFault, isPlainRecord, receive } from "./mods/kernel/receive.js";
|
|
5
|
-
import { DECLARATION_RECEIPT_MODE } from "./own-property-receipt.js";
|
|
5
|
+
import { DECLARATION_RECEIPT_MODE, optionKeys, refuseStrayMembers } from "./own-property-receipt.js";
|
|
6
6
|
function isPrivateV4(ip) {
|
|
7
7
|
const o = ip.split(".").map(Number);
|
|
8
8
|
if (o.length !== 4 || o.some((n) => !Number.isInteger(n) || n < 0 || n > 255))
|
|
@@ -48,7 +48,7 @@ export function isPrivateHost(host) {
|
|
|
48
48
|
return /^fe[89ab]/.test(h) || /^f[cd]/.test(h) || /^fe[c-f]/.test(h);
|
|
49
49
|
}
|
|
50
50
|
export const HOST_FLOOR_INVALID_CODE = "config.host_floor_invalid";
|
|
51
|
-
const
|
|
51
|
+
const FLOOR_KEYS = optionKeys()({ deny: 0, only: 0 });
|
|
52
52
|
function floorInvalid(what) {
|
|
53
53
|
return Object.assign(new Error(`RunnerDeps.hostFloor ${what} — a host floor that does not read is refused whole, never half-armed (an entry is a host pattern: \`example.com\` or \`*.example.com\`).`), { code: HOST_FLOOR_INVALID_CODE });
|
|
54
54
|
}
|
|
@@ -95,9 +95,7 @@ export function compileHostFloor(declared) {
|
|
|
95
95
|
return undefined;
|
|
96
96
|
if (!isPlainRecord(value))
|
|
97
97
|
throw floorInvalid(`must be a record { deny?, only? } (got ${value === null ? "null" : Array.isArray(value) ? "a list" : typeof value})`);
|
|
98
|
-
|
|
99
|
-
if (unknownMember !== undefined)
|
|
100
|
-
throw floorInvalid(`has a member "${inlineUntrusted(unknownMember, 60)}" — its members are \`deny\` and \`only\``);
|
|
98
|
+
refuseStrayMembers(value, { subject: "RunnerDeps.hostFloor", unit: "member", moment: "when the floor is compiled" }, FLOOR_KEYS, (_, [stray]) => floorInvalid(`has a member "${inlineUntrusted(String(stray), 60)}" — its members are \`deny\` and \`only\``));
|
|
101
99
|
const deny = readEntries(value.deny, "deny") ?? [];
|
|
102
100
|
const only = readEntries(value.only, "only");
|
|
103
101
|
for (const o of only ?? []) {
|
|
@@ -1,74 +1,130 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The ONE admission an image's bytes pass before they reach the model as an `ImageContent` block —
|
|
3
|
-
* whether a file supplied them (the Read tool's image lane), a caller did (`TaskSpec.images`' inline
|
|
4
|
-
* arm, a user attachment) or a tool returned them (the tool-result seat below). Four steps, in this order:
|
|
5
|
-
*
|
|
6
|
-
* ① the claimed type is one the content API accepts (png / jpeg / gif / webp — the four
|
|
7
|
-
* {@link imageMagicMatches} can verify);
|
|
8
|
-
* ② the raw bytes are within the read cap (5 MiB without a downsampler, 64 MiB with one);
|
|
9
|
-
* ③ the bytes open with the claimed type's header — its signature and the first structure the format requires
|
|
10
|
-
* ({@link IMAGE_HEADER_CHECKS}); an empty / text / mis-named "png", or an Apple-optimized PNG, would otherwise
|
|
11
|
-
* become a malformed block that 400s the NEXT whole provider request;
|
|
12
|
-
* ④ optional downsample (when a downsampler is supplied; a processing failure keeps the original
|
|
13
|
-
* bytes, CC's catch → createImageResponse(original)), then the provider's hard limit, which is on the
|
|
14
|
-
* BASE64 length, not raw bytes.
|
|
15
|
-
*
|
|
16
|
-
* The answer is structured; each carrier words its own refusal (the Read tool speaks to the model, the
|
|
17
|
-
* task door to the caller). The block it admits is built from the bytes it checked — never from a
|
|
18
|
-
* caller's string it did not decode. A document's bytes pass the same shape of admission
|
|
19
|
-
* ({@link admitDocumentBytes}: `application/pdf`, the whole-send cap, the `%PDF-` signature).
|
|
20
|
-
*
|
|
21
|
-
* THE TOOL-RESULT SEAT ({@link admitToolResultMedia}): every executed call's result passes the loop's one
|
|
22
|
-
* post-execution half (`finalizeToolOutcome`) — an engine tool's, an MCP tool's converted content, a host
|
|
23
|
-
* tool's own return, a resumed approved call's, and whatever a `tool_result` hook put in their place — so
|
|
24
|
-
* the media blocks of every supply are admitted there, once, after the last hand that can change them and
|
|
25
|
-
* before the frame and the transcript read them. A block whose bytes the admission refuses becomes a text
|
|
26
|
-
* block that names the tool, the refusal and the size — never the bytes, and never silently nothing.
|
|
27
|
-
*/
|
|
28
1
|
import type { DocumentContent, ImageContent } from "../internal/llm.js";
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
/** Byte cap on a Read-image WITHOUT a downsampler: an image file is returned AS a visual
|
|
32
|
-
* `ImageContent` block (base64) rather than refused. Bounded so a huge image cannot blow the request.
|
|
33
|
-
* This stat-time cap only bounds the READ; the accept/refuse decision is the base64 gate below (the
|
|
34
|
-
* provider limit is on base64 LENGTH, so the effective no-sharp accept bound is raw ≤ 3.75MB). */
|
|
35
|
-
export declare const MAX_IMAGE_READ_BYTES: number;
|
|
36
|
-
/** Byte cap on a Read-image WITH a downsampler: sharp can shrink a big photo to CC's 2000×2000/3.75MB
|
|
37
|
-
* target, so the smaller hard refusal does not apply (CC readImageWithTokenBudget reads the file
|
|
38
|
-
* unbounded; we keep an OOM sanity bound — deliberate delta, camera photos fit comfortably). */
|
|
39
|
-
export declare const MAX_IMAGE_DOWNSAMPLE_INPUT_BYTES: number;
|
|
2
|
+
import type { ImageDimensions, ImageDownsampler } from "./image-downsample.js";
|
|
3
|
+
import type { MediaBlock } from "./media-byte-cap.js";
|
|
40
4
|
/** Max raw size sent whole as a document block (CC `PDF_TARGET_RAW_SIZE`). */
|
|
41
5
|
export declare const PDF_TARGET_RAW_SIZE: number;
|
|
42
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Every number an image passes on its way to the model, in one table — the admission and its processor read it, and so
|
|
8
|
+
* does every carrier that words a refusal; a downstream that bounds an image by the same limit reads the same field.
|
|
9
|
+
* - `hard`: what refuses. `formats` (the header rows above), `readBytes` (the raw read cap — without a processor the bytes
|
|
10
|
+
* ship as they are, so the cap is the raw size whose base64 fits `imageBase64Chars`, the one bound that binds there;
|
|
11
|
+
* with one it is larger, since the processor shrinks what was read, and the 64 MiB bound is an OOM sanity bound, CC
|
|
12
|
+
* reads the file whole), `urlBytes` (a fetched image's body), `rejectEdge` (the longest edge the bytes that ship may
|
|
13
|
+
* state — `fI` (cli309.js:253044), the 2000 box, its no-flag reject width), `imageBase64Chars` (the provider's
|
|
14
|
+
* single-image limit, on the base64 length — CC `fI` `maxBase64Size`).
|
|
15
|
+
* - `soft`: what the processor aims at, best effort. `frameEdge` and `rawBytes` are the frame ladder's box and byte rung
|
|
16
|
+
* (CC `fI` `maxWidth` / `targetRawSize`: 3.75 MB raw = 5 MiB base64); `targetBytes` is the byte-target step's goal
|
|
17
|
+
* (`SZ` (cli309.js:253044), the bytes `N$o` compresses toward).
|
|
18
|
+
* - `request`: what one provider request may carry of the media the conversation holds (CC `eSn` (cli309.js:265961) and
|
|
19
|
+
* its constants `Xai` / `Jai` (cli309.js:253044)), every size in base64 characters — the unit the provider counts. Over `maxItems`
|
|
20
|
+
* media blocks (images and documents together; `largeWindow.maxItems` for a model whose window is at least
|
|
21
|
+
* `largeWindow.fromContextWindow` tokens) the oldest go until `maxItems - margin` remain; over the budget the oldest go
|
|
22
|
+
* until `hysteresisBase64Chars` under it. `budgetBase64Chars` is the default budget a deployment may replace
|
|
23
|
+
* (`RunnerDeps.mediaBudgetBase64Chars`); it is not CC's first-party 24 MiB, because a sema deployment mostly serves
|
|
24
|
+
* endpoints CC treats as third-party, for which CC's own budget is 75 MiB. There is no document-only budget: CC holds
|
|
25
|
+
* one for its first-party endpoint alone.
|
|
26
|
+
*/
|
|
27
|
+
export declare const IMAGE_ADMISSION: Readonly<{
|
|
28
|
+
readonly hard: Readonly<{
|
|
29
|
+
formats: Readonly<Record<"image/png" | "image/jpeg" | "image/gif" | "image/webp", (b: Uint8Array) => boolean>>;
|
|
30
|
+
readBytes: Readonly<{
|
|
31
|
+
withoutProcessor: number;
|
|
32
|
+
withProcessor: number;
|
|
33
|
+
}>;
|
|
34
|
+
urlBytes: number;
|
|
35
|
+
rejectEdge: 2000;
|
|
36
|
+
imageBase64Chars: number;
|
|
37
|
+
}>;
|
|
38
|
+
readonly soft: Readonly<{
|
|
39
|
+
frameEdge: 2000;
|
|
40
|
+
rawBytes: number;
|
|
41
|
+
targetBytes: 512000;
|
|
42
|
+
}>;
|
|
43
|
+
readonly request: Readonly<{
|
|
44
|
+
maxItems: 100;
|
|
45
|
+
largeWindow: Readonly<{
|
|
46
|
+
fromContextWindow: 1000000;
|
|
47
|
+
maxItems: 600;
|
|
48
|
+
}>;
|
|
49
|
+
margin: 20;
|
|
50
|
+
budgetBase64Chars: number;
|
|
51
|
+
hysteresisBase64Chars: number;
|
|
52
|
+
}>;
|
|
53
|
+
}>;
|
|
54
|
+
/** What one request may carry, resolved for a model and a deployment's budget: the media-block count, the margin a count
|
|
55
|
+
* cut leaves under it, the base64 budget (`Infinity`: none) and the hysteresis a budget cut leaves under that. */
|
|
56
|
+
export interface RequestMediaLimits {
|
|
57
|
+
maxItems: number;
|
|
58
|
+
margin: number;
|
|
59
|
+
budgetBase64Chars: number;
|
|
60
|
+
hysteresisBase64Chars: number;
|
|
61
|
+
}
|
|
62
|
+
/** The one reading of a deployment's request media budget (`RunnerDeps.mediaBudgetBase64Chars`, screened by
|
|
63
|
+
* {@link checkedRequestMediaBudget} at `new Runner`), for both of its readers — the request trim and the `tool_end.output`
|
|
64
|
+
* projection: absent ⇒ `IMAGE_ADMISSION.request.budgetBase64Chars`; `0` or `Infinity` ⇒ no budget (`Infinity`). */
|
|
65
|
+
export declare function requestMediaBudget(knob: number | undefined): number;
|
|
66
|
+
/** The limits a request on `model` under the deployment's budget `knob` is trimmed to. */
|
|
67
|
+
export declare function requestMediaLimits(model: {
|
|
68
|
+
readonly contextWindow?: unknown;
|
|
69
|
+
}, knob: number | undefined): RequestMediaLimits;
|
|
70
|
+
/** The deployment's request media budget, screened once at `new Runner`: absent, `0` or `Infinity` (no budget), or a whole
|
|
71
|
+
* number of base64 characters no smaller than twice the hysteresis. Anything else — a non-number, `NaN`, a negative, a
|
|
72
|
+
* fraction, a budget a cut would empty — is refused (`config.invalid_argument`), never read as a default or as none. */
|
|
73
|
+
export declare function checkedRequestMediaBudget(value: unknown, seat: string): void;
|
|
74
|
+
/** Verify the raw bytes actually ARE the image format the claimed type names (`IMAGE_ADMISSION.hard.formats`). Extension
|
|
43
75
|
* alone is forgeable: a `.png` holding text / an empty file / a truncated blob / an Apple-optimized PNG would otherwise
|
|
44
76
|
* become a malformed `ImageContent` that makes the NEXT provider request fail (400). Pure — no I/O. */
|
|
45
77
|
export declare function imageMagicMatches(bytes: Uint8Array, mimeType: string): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* The pixel size an image's own header states, read without decoding (`WN` (cli309.js:257745)): PNG's `IHDR`, GIF's screen
|
|
80
|
+
* descriptor, a JPEG's first start-of-frame segment, WebP's `VP8 ` / `VP8L` / `VP8X` header. `undefined` when the header
|
|
81
|
+
* states none this reader finds. Pure — the admission reads it for the bytes that ship.
|
|
82
|
+
*/
|
|
83
|
+
export declare function readImageHeaderDimensions(b: Uint8Array): {
|
|
84
|
+
width: number;
|
|
85
|
+
height: number;
|
|
86
|
+
} | undefined;
|
|
46
87
|
/** True when the bytes start with the `%PDF-` magic. Magic outranks extension both ways: a mis-named
|
|
47
88
|
* `.pdf` without it is refused, and a non-`.pdf` file carrying it is read AS a PDF. */
|
|
48
89
|
export declare function pdfMagicMatches(bytes: Uint8Array): boolean;
|
|
49
90
|
/** The image types the content API accepts — the only ones a signature check can verify. */
|
|
50
91
|
export declare const ADMITTED_IMAGE_MIME_TYPES: readonly ["image/png", "image/jpeg", "image/gif", "image/webp"];
|
|
51
|
-
/** The raw-byte read cap for an image, with or without a
|
|
52
|
-
export declare function imageReadCap(
|
|
92
|
+
/** The raw-byte read cap for an image, with or without a processor (`IMAGE_ADMISSION.hard.readBytes`). */
|
|
93
|
+
export declare function imageReadCap(processor: ImageDownsampler | "none"): number;
|
|
53
94
|
export type ImageAdmission = {
|
|
54
95
|
ok: true;
|
|
55
96
|
block: ImageContent;
|
|
56
|
-
/** The raw byte count of the bytes checked (before any
|
|
97
|
+
/** The raw byte count of the bytes checked (before any processing). */
|
|
57
98
|
originalSize: number;
|
|
58
|
-
/** Measured by the
|
|
99
|
+
/** Measured by the processor; absent when the bytes went on as they are (never fabricated). */
|
|
59
100
|
dimensions?: ImageDimensions;
|
|
60
|
-
/** True when the
|
|
101
|
+
/** True when the processor actually changed the pixel size. */
|
|
61
102
|
resized: boolean;
|
|
62
103
|
} | {
|
|
63
104
|
ok: false;
|
|
64
105
|
reason: "mime_unsupported" | "magic_mismatch";
|
|
65
106
|
rawBytes: number;
|
|
107
|
+
}
|
|
108
|
+
/** The bytes that would ship state no pixel size in their header. */
|
|
109
|
+
| {
|
|
110
|
+
ok: false;
|
|
111
|
+
reason: "dimensions_unreadable";
|
|
112
|
+
rawBytes: number;
|
|
66
113
|
} | {
|
|
67
114
|
ok: false;
|
|
68
115
|
reason: "raw_too_large";
|
|
69
116
|
rawBytes: number;
|
|
70
117
|
cap: number;
|
|
71
118
|
}
|
|
119
|
+
/** The bytes that would ship state an edge over `IMAGE_ADMISSION.hard.rejectEdge` (`limit`). */
|
|
120
|
+
| {
|
|
121
|
+
ok: false;
|
|
122
|
+
reason: "dimensions_too_large";
|
|
123
|
+
rawBytes: number;
|
|
124
|
+
width: number;
|
|
125
|
+
height: number;
|
|
126
|
+
limit: number;
|
|
127
|
+
}
|
|
72
128
|
/** `base64` is the encoding that failed the limit (the caller words the refusal from its length). */
|
|
73
129
|
| {
|
|
74
130
|
ok: false;
|
|
@@ -76,7 +132,21 @@ export type ImageAdmission = {
|
|
|
76
132
|
rawBytes: number;
|
|
77
133
|
base64: string;
|
|
78
134
|
};
|
|
79
|
-
|
|
135
|
+
/** Why the bytes that would have shipped were refused on their stated size (`dimensions_unreadable` / `dimensions_too_large`)
|
|
136
|
+
* — the one wording every carrier's refusal and the tool-result seat's placeholder read. */
|
|
137
|
+
export declare function unprocessedSizeClause(a: {
|
|
138
|
+
reason: "dimensions_unreadable";
|
|
139
|
+
} | {
|
|
140
|
+
reason: "dimensions_too_large";
|
|
141
|
+
width: number;
|
|
142
|
+
height: number;
|
|
143
|
+
limit: number;
|
|
144
|
+
}): string;
|
|
145
|
+
/** One image's bytes through the admission (see the module head). `processor` is the run's, resolved from its one seat
|
|
146
|
+
* (`resolveImageProcessor`), or `"none"`: it is never optional, so no carrier admits without saying which. */
|
|
147
|
+
export declare function admitImageBytes(bytes: Uint8Array, claimedMime: string, processor: ImageDownsampler | "none"): Promise<ImageAdmission>;
|
|
148
|
+
/** The admitted type the bytes' own header names (the first of the four header rows they open with), or `undefined`. */
|
|
149
|
+
export declare function sniffImageMime(bytes: Uint8Array): (typeof ADMITTED_IMAGE_MIME_TYPES)[number] | undefined;
|
|
80
150
|
/** The document types the content API accepts — the one a signature check can verify. */
|
|
81
151
|
export declare const ADMITTED_DOCUMENT_MIME_TYPES: readonly ["application/pdf"];
|
|
82
152
|
export type DocumentAdmission = {
|
|
@@ -98,14 +168,17 @@ export type DocumentAdmission = {
|
|
|
98
168
|
export declare function admitDocumentBytes(bytes: Uint8Array, claimedMime: string): DocumentAdmission;
|
|
99
169
|
/** Why the tool-result seat refused a media block: the admissions' own words (an image's four — a document's are among
|
|
100
170
|
* them), or `undecodable` — the block carried no base64 string to decode. */
|
|
101
|
-
export type MediaRefusalReason = "undecodable" | "mime_unsupported" | "raw_too_large" | "magic_mismatch" | "base64_too_large";
|
|
171
|
+
export type MediaRefusalReason = "undecodable" | "mime_unsupported" | "raw_too_large" | "magic_mismatch" | "dimensions_unreadable" | "dimensions_too_large" | "base64_too_large";
|
|
102
172
|
/** One media block the seat refused: its type, the refusal, its decoded size, the bound it exceeded (the raw-byte cap for
|
|
103
|
-
* `raw_too_large`, the
|
|
173
|
+
* `raw_too_large`, the reject edge for `dimensions_too_large` — with the size its header states —, the base64 length
|
|
174
|
+
* limit for `base64_too_large`), and its media type when it can be one. */
|
|
104
175
|
export interface ToolResultMediaRefusal {
|
|
105
176
|
type: MediaBlock["type"];
|
|
106
177
|
reason: MediaRefusalReason;
|
|
107
178
|
bytes: number;
|
|
108
179
|
limit?: number;
|
|
180
|
+
width?: number;
|
|
181
|
+
height?: number;
|
|
109
182
|
mimeType?: string;
|
|
110
183
|
}
|
|
111
184
|
/** What the seat made of one result's content: every media block rebuilt from its checked bytes or replaced, in its slot,
|
|
@@ -114,10 +187,30 @@ export interface ToolResultMediaAdmission {
|
|
|
114
187
|
content: unknown[];
|
|
115
188
|
refused: ToolResultMediaRefusal[];
|
|
116
189
|
}
|
|
190
|
+
/** The media type a block claims — its `type`, read once, when that is a media type — or `undefined` for any other value. */
|
|
191
|
+
export declare function claimedMediaType(block: unknown): MediaBlock["type"] | undefined;
|
|
192
|
+
/**
|
|
193
|
+
* The decoded size of the first image block that goes to the model over `IMAGE_ADMISSION.soft.targetBytes` with no
|
|
194
|
+
* processor to bring it down — the one fact the run's operator notice reads (`config.image_processor_unavailable`), at
|
|
195
|
+
* every place images enter a run (the tool-result seat, the task's images, a person's attachments). `undefined` with a
|
|
196
|
+
* processor, or when none does.
|
|
197
|
+
*/
|
|
198
|
+
export declare function firstUnprocessedOverTarget(blocks: readonly unknown[], processor: ImageDownsampler | "none"): number | undefined;
|
|
199
|
+
/**
|
|
200
|
+
* The tool-result seat's one read of an executed call's content: its blocks, read once into a new array, when one claims a
|
|
201
|
+
* media type; `undefined` otherwise (the content stands as it is). Synchronous and total — a content whose blocks cannot be
|
|
202
|
+
* read is not media this seat can admit or refuse. A carrier resolves the run's processor only once this answers blocks,
|
|
203
|
+
* so a call with no media in its result awaits nothing.
|
|
204
|
+
*/
|
|
205
|
+
export declare function toolResultMediaBlocks(content: unknown): unknown[] | undefined;
|
|
206
|
+
/**
|
|
207
|
+
* The tool-result seat's admission over blocks {@link toolResultMediaBlocks} read: each media block admitted with the run's
|
|
208
|
+
* `processor` — rebuilt from the bytes it checked (an image a carrier already brought within the target and the frame passes
|
|
209
|
+
* unchanged), or replaced in its slot by a placeholder naming `toolName` and the refusal.
|
|
210
|
+
*/
|
|
211
|
+
export declare function admitToolResultMediaBlocks(blocks: readonly unknown[], toolName: string, processor: ImageDownsampler | "none"): Promise<ToolResultMediaAdmission>;
|
|
117
212
|
/**
|
|
118
|
-
* The tool-result seat
|
|
119
|
-
*
|
|
120
|
-
* block admitted — rebuilt from the bytes it checked, or replaced in its slot by a placeholder naming `toolName` and the
|
|
121
|
-
* refusal. Total: a content whose blocks cannot be read is not media this seat can admit or refuse, and is left as it is.
|
|
213
|
+
* The tool-result seat over one executed call's content with a processor in hand: {@link toolResultMediaBlocks}, then
|
|
214
|
+
* {@link admitToolResultMediaBlocks} — `undefined` when no block claims a media type (nothing is awaited).
|
|
122
215
|
*/
|
|
123
|
-
export declare function admitToolResultMedia(content: unknown, toolName: string): Promise<ToolResultMediaAdmission> | undefined;
|
|
216
|
+
export declare function admitToolResultMedia(content: unknown, toolName: string, processor: ImageDownsampler | "none"): Promise<ToolResultMediaAdmission> | undefined;
|