@sema-agent/core 7.60.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 +605 -0
- package/README.md +2 -2
- package/dist/agents/agent-transcript-tool.d.ts +2 -2
- package/dist/agents/agent-transcript-tool.js +1 -1
- package/dist/agents/cascade.d.ts +61 -10
- package/dist/agents/cascade.js +60 -20
- 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 -0
- package/dist/agents/inherited-tool-pool.d.ts +5 -3
- package/dist/agents/inherited-tool-pool.js +2 -2
- 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.js +3 -1
- package/dist/agents/roster-store.d.ts +1 -1
- package/dist/agents/roster-store.js +7 -4
- package/dist/agents/send-message-tool.d.ts +8 -10
- package/dist/agents/send-message-tool.js +43 -23
- 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 +30 -40
- package/dist/agents/subagent.js +187 -196
- package/dist/agents/suspend-guard.d.ts +9 -0
- package/dist/agents/suspend-guard.js +4 -0
- package/dist/agents/verify.d.ts +41 -14
- package/dist/agents/verify.js +37 -27
- package/dist/brain/anthropic.js +1 -0
- 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/stream-engine.d.ts +3 -0
- package/dist/brain/stream-engine.js +4 -0
- package/dist/core/agent-state.d.ts +1 -1
- package/dist/core/allow-entry.d.ts +59 -23
- package/dist/core/allow-entry.js +131 -38
- 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.js +3 -5
- package/dist/core/background-agent-store.d.ts +7 -5
- package/dist/core/background-agent-store.js +12 -11
- package/dist/core/checkpoint-requirements.d.ts +24 -3
- package/dist/core/checkpoint-requirements.js +9 -1
- package/dist/core/checkpoint-store.d.ts +78 -19
- package/dist/core/checkpoint-store.js +8 -4
- 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/context-settings.js +3 -5
- package/dist/core/cross-boundary-taint.d.ts +1 -1
- 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 +49 -18
- 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 +10 -0
- package/dist/core/frame-settlement.js +6 -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 +2 -1
- package/dist/core/gate-lanes.js +7 -4
- 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 +12 -4
- package/dist/core/governance-codes.js +16 -4
- package/dist/core/hooks.d.ts +12 -4
- package/dist/core/hooks.js +11 -4
- package/dist/core/host-floor.js +3 -5
- package/dist/core/image-admission.d.ts +48 -8
- package/dist/core/image-admission.js +35 -4
- package/dist/core/input-author.d.ts +36 -0
- package/dist/core/input-author.js +39 -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 +2 -1
- package/dist/core/locked-config.js +5 -3
- 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-connection-pool.d.ts +6 -20
- package/dist/core/mcp-connection-pool.js +10 -28
- package/dist/core/mcp-failure.d.ts +76 -15
- package/dist/core/mcp-failure.js +60 -33
- package/dist/core/mcp-host-seat.d.ts +92 -53
- package/dist/core/mcp-host-seat.js +220 -46
- package/dist/core/mcp-probe.js +2 -2
- 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 +2 -1
- 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 +6 -49
- package/dist/core/mcp.js +115 -111
- 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-engine/consolidation.d.ts +1 -1
- package/dist/core/memory-engine/consolidation.js +7 -1
- 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/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/sync-client.d.ts +39 -18
- package/dist/core/memory-engine/sync-client.js +72 -14
- package/dist/core/memory-engine/sync-report.d.ts +7 -4
- package/dist/core/memory-engine/sync.d.ts +9 -1
- package/dist/core/mode-policy.d.ts +8 -8
- package/dist/core/mode-policy.js +7 -5
- package/dist/core/mods/agent-stations.d.ts +39 -4
- package/dist/core/mods/agent-stations.js +59 -10
- 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 +4 -3
- package/dist/core/mods/kernel/dispatch.js +4 -4
- package/dist/core/mods/kernel/events.d.ts +4 -1
- package/dist/core/mods/kernel/events.js +6 -6
- 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/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 +38 -16
- package/dist/core/mods/stations.js +25 -11
- package/dist/core/mods/tool-call.d.ts +2 -0
- package/dist/core/mods/tool-call.js +4 -4
- package/dist/core/output-style.js +3 -4
- package/dist/core/own-property-receipt.d.ts +61 -2
- package/dist/core/own-property-receipt.js +42 -2
- package/dist/core/park-selfcheck.js +4 -2
- 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 +3 -3
- package/dist/core/peer-seat.js +20 -8
- package/dist/core/permission-rule-consent.d.ts +21 -5
- package/dist/core/permission-rule-consent.js +21 -1
- package/dist/core/permission-rule-model.d.ts +34 -11
- package/dist/core/permission-rule-model.js +47 -10
- 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/remote-env.d.ts +74 -26
- package/dist/core/remote-env.js +20 -0
- 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/retired-keys.d.ts +4 -4
- package/dist/core/row-admission.d.ts +10 -0
- package/dist/core/row-admission.js +5 -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 -3
- package/dist/core/runner/assemble-result.js +12 -7
- 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/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 +2 -2
- package/dist/core/runner/contracts.d.ts +98 -26
- package/dist/core/runner/cross-boundary-lane.d.ts +1 -1
- 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/expire-settle.d.ts +44 -0
- package/dist/core/runner/expire-settle.js +55 -0
- package/dist/core/runner/git-status-frame.d.ts +3 -3
- package/dist/core/runner/git-status-frame.js +2 -1
- package/dist/core/runner/halt-attribution.d.ts +2 -1
- package/dist/core/runner/halt-attribution.js +2 -1
- 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/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 +28 -9
- 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 +4 -1
- package/dist/core/runner/prepare-boundary-parks.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +2 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +1 -0
- package/dist/core/runner/prepare-config-doors.js +16 -17
- 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 +9 -9
- package/dist/core/runner/prepare-delegation-surface.js +4 -5
- 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-gate-stations.d.ts +19 -14
- package/dist/core/runner/prepare-gate-stations.js +6 -4
- package/dist/core/runner/prepare-hands-readface.d.ts +5 -5
- package/dist/core/runner/prepare-hands-readface.js +4 -4
- package/dist/core/runner/prepare-inherited-gate.d.ts +6 -0
- package/dist/core/runner/prepare-inherited-gate.js +3 -0
- package/dist/core/runner/prepare-lsp.d.ts +3 -0
- package/dist/core/runner/prepare-lsp.js +2 -2
- package/dist/core/runner/prepare-park-ask.d.ts +5 -2
- package/dist/core/runner/prepare-park-ask.js +4 -5
- package/dist/core/runner/prepare-policy-chain.d.ts +10 -21
- package/dist/core/runner/prepare-policy-chain.js +16 -25
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-prompt-inputs.d.ts +5 -4
- package/dist/core/runner/prepare-prompt-inputs.js +3 -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 -7
- package/dist/core/runner/prepare-suspend-saga.js +17 -7
- package/dist/core/runner/prepare-task.d.ts +1 -1
- package/dist/core/runner/prepare-task.js +56 -28
- 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-wiring-manifest.d.ts +3 -0
- package/dist/core/runner/prepare-wiring-manifest.js +2 -1
- package/dist/core/runner/prepare-workspace-restore.d.ts +5 -0
- package/dist/core/runner/prepare-workspace-restore.js +10 -6
- 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-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 +2 -0
- package/dist/core/runner/run-git-lane.js +2 -1
- package/dist/core/runner/run-harness-handlers.js +2 -2
- package/dist/core/runner/run-identity-wiring.d.ts +2 -2
- package/dist/core/runner/run-identity-wiring.js +14 -5
- package/dist/core/runner/run-leg.d.ts +3 -3
- package/dist/core/runner/run-leg.js +40 -29
- package/dist/core/runner/run-notification-lane.js +20 -2
- package/dist/core/runner/run-recovery-lanes.js +3 -2
- package/dist/core/runner/run-settle-and-teardown.js +9 -7
- 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 +27 -14
- package/dist/core/runner/runtask.d.ts +18 -3
- package/dist/core/runner/runtask.js +27 -11
- 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/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/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 -2
- 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-output-projection.d.ts +3 -3
- package/dist/core/runner/tool-output-projection.js +7 -6
- 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 +3 -2
- package/dist/core/runner/turn-attachments.js +1 -1
- 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 +24 -25
- package/dist/core/secret-env.d.ts +11 -11
- 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 +1 -1
- package/dist/core/session-policy-store.js +5 -2
- package/dist/core/session-reconcile.d.ts +3 -2
- package/dist/core/session-reconcile.js +7 -4
- package/dist/core/session-store.d.ts +2 -0
- package/dist/core/session-store.js +5 -7
- 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.js +1 -1
- 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 +30 -0
- package/dist/core/task-event.d.ts +17 -8
- package/dist/core/task-limits.d.ts +5 -0
- package/dist/core/task-notification.d.ts +89 -12
- package/dist/core/task-notification.js +87 -13
- package/dist/core/task-registry-agent.d.ts +5 -43
- package/dist/core/task-registry-agent.js +24 -51
- package/dist/core/task-registry-monitor.d.ts +1 -1
- package/dist/core/task-registry-monitor.js +15 -60
- package/dist/core/task-registry-shared.d.ts +15 -112
- package/dist/core/task-registry-shared.js +3 -41
- package/dist/core/task-registry-workflow.js +4 -21
- package/dist/core/task-registry.d.ts +19 -60
- package/dist/core/task-registry.js +19 -106
- package/dist/core/task-result.d.ts +24 -7
- 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 +10 -10
- 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 +2 -5
- 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.js +3 -2
- package/dist/core/tool-face.d.ts +2 -3
- package/dist/core/tool-name-aliases.d.ts +5 -29
- package/dist/core/tool-name-aliases.js +9 -5
- 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 +108 -18
- package/dist/core/tool-policy.js +84 -14
- package/dist/core/tool-result-store.d.ts +23 -0
- package/dist/core/tool-result-store.js +3 -2
- package/dist/core/tool-spec.d.ts +19 -6
- package/dist/core/trace.d.ts +18 -1
- package/dist/core/user-attachment.js +26 -21
- 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 +34 -9
- package/dist/engine/execution-env/node-execution-env.js +213 -21
- package/dist/engine/harness/agent-harness.d.ts +65 -18
- package/dist/engine/harness/agent-harness.js +90 -23
- package/dist/engine/harness/messages.d.ts +4 -3
- package/dist/engine/harness/messages.js +2 -2
- package/dist/engine/harness/types.d.ts +41 -7
- 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 +6 -1
- package/dist/engine/loop/agent-loop.js +20 -11
- package/dist/engine/loop/types.d.ts +12 -3
- 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 +21 -11
- package/dist/index.js +15 -7
- package/dist/internal/harness-types.d.ts +2 -0
- 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 +11 -17
- package/dist/orchestration/run-workflow-tool.js +19 -42
- package/dist/orchestration/workflow-governance.d.ts +1 -1
- package/dist/orchestration/workflow-types.d.ts +2 -2
- package/dist/orchestration/workflow.d.ts +4 -0
- package/dist/orchestration/workflow.js +8 -5
- package/dist/stores/file/background-agent-store.js +18 -15
- package/dist/stores/file/checkpoint-store.js +7 -4
- package/dist/stores/file/file-history-store.js +3 -2
- package/dist/stores/file/index.d.ts +5 -3
- package/dist/stores/file/index.js +23 -8
- 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.js +42 -22
- package/dist/stores/file/memory-store.js +3 -2
- 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.js +3 -2
- package/dist/stores/file/session-store.d.ts +16 -3
- package/dist/stores/file/session-store.js +21 -20
- package/dist/stores/file/tool-result-store.d.ts +11 -0
- package/dist/stores/file/tool-result-store.js +57 -3
- package/dist/stores/file/usage-window-store.js +3 -2
- package/dist/stores/file/workflow-journal-store.d.ts +0 -2
- package/dist/stores/file/workflow-journal-store.js +3 -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/dead-cwd.d.ts +5 -5
- package/dist/tools/fs/dead-cwd.js +4 -11
- package/dist/tools/fs/fs-bash-background-text.d.ts +6 -0
- package/dist/tools/fs/fs-bash-background-text.js +6 -0
- package/dist/tools/fs/fs-bash.d.ts +3 -18
- package/dist/tools/fs/fs-bash.js +37 -124
- package/dist/tools/fs/fs-pdf.js +8 -6
- package/dist/tools/fs/fs-read.js +2 -2
- package/dist/tools/fs/fs-shared.d.ts +28 -3
- package/dist/tools/fs/fs-shared.js +15 -0
- package/dist/tools/fs/index.d.ts +1 -1
- package/dist/tools/fs/index.js +4 -14
- 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 +13 -5
- package/dist/tools/fs/read-floor.js +206 -2
- package/dist/tools/fs/search.d.ts +3 -2
- package/dist/tools/fs/search.js +6 -6
- 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 +8 -7
- package/dist/tools/monitor.js +12 -10
- package/dist/tools/worktree.d.ts +5 -1
- package/dist/tools/worktree.js +20 -17
- package/package.json +6 -3
- package/test/export-surface.snapshot.json +92 -10
- package/wire-changes/core-stores-sql@7.61.0.json +480 -0
- package/wire-changes/core@7.61.0.json +4405 -0
- package/wire-changes/mods-kernel@7.61.0.json +65 -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/mcp.js
CHANGED
|
@@ -7,26 +7,27 @@ import { PeerCarrier, Reauthorized, answeredUnauthorized, carrierOf, inFlight, m
|
|
|
7
7
|
import { disposeSectionEntry, sectionAnswerWarning } from "./prompt-section-seat.js";
|
|
8
8
|
import { createToolNameClaims, mintNamespacePrefix, normalizeNameSegment } from "./protocol-naming.js";
|
|
9
9
|
import { mcpToolDropReason, refuseCollidingMcpServerNames } from "./mcp-name-judge.js";
|
|
10
|
-
import { Client } from "@modelcontextprotocol/
|
|
11
|
-
import {
|
|
10
|
+
import { Client, ProtocolError, ProtocolErrorCode } from "@modelcontextprotocol/client";
|
|
11
|
+
import { AjvJsonSchemaValidator } from "@modelcontextprotocol/client/validators/ajv";
|
|
12
|
+
import { ListResourcesResultSchema } from "@modelcontextprotocol/core";
|
|
13
|
+
import { McpConnectionPool, recordEngineDial } from "./mcp-connection-pool.js";
|
|
12
14
|
import { SessionEndingTransport, requestSite } from "./mcp-session-end.js";
|
|
13
15
|
import { mcpToolGate, UNPROVEN_GATE } from "./mcp-listing-drift.js";
|
|
14
16
|
import { ConnectionListing, Flights, IDLE_WATCHDOG_ABORT_REASON, Resendable, armMcpIdleWatchdog, callThroughLink, listingRefusal, observedFailure, owedByAnswer, reach, refusalScope } from "./mcp-server-link.js";
|
|
15
17
|
import { underStartupBound } from "./mcp-startup-request.js";
|
|
16
18
|
import { LIST_MCP_RESOURCES, MCP_RESOURCE_LIST_ALLOW, MCP_RESOURCE_READ_ALLOW, READ_MCP_RESOURCE, READ_MCP_RESOURCE_DIR, retractInstructions, tellInstructions, toldOnDial, unretractInstructions, withdrawInstructionAdds } from "./mounted-mcp.js";
|
|
17
|
-
import { StdioClientTransport } from "@modelcontextprotocol/
|
|
19
|
+
import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
|
|
18
20
|
import { describeHttpTransportFailure, failureFields, livenessOf, namingLostSession, readMcpFailure, sessionGone, unauthorizedLine } from "./mcp-failure.js";
|
|
19
21
|
import { lstat, mkdir, writeFile } from "node:fs/promises";
|
|
20
22
|
import { tmpdir } from "node:os";
|
|
21
23
|
import { join } from "node:path";
|
|
22
|
-
import {
|
|
23
|
-
import { DEFAULT_REQUEST_TIMEOUT_MSEC } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
24
|
+
import { DEFAULT_REQUEST_TIMEOUT_MSEC } from "@modelcontextprotocol/client";
|
|
24
25
|
import { resolveImageProcessor } from "./image-downsample.js";
|
|
25
26
|
import { admitImageBytes, IMAGE_ADMISSION, unprocessedSizeClause } from "./image-admission.js";
|
|
26
27
|
import { sliceHeadSafe, sliceTailSafe } from "./surrogate-safe-slice.js";
|
|
27
28
|
import { truncateError } from "./tool-errors.js";
|
|
28
29
|
import { transportKindOf } from "./mcp-server-spec.js";
|
|
29
|
-
import {
|
|
30
|
+
import { hostMount, hostSeatLine, hostSeatMissing, hostSeatVerdictOf, openHostPipe, settledBefore } from "./mcp-host-seat.js";
|
|
30
31
|
import { peerRequestRefusal } from "./host-floor.js";
|
|
31
32
|
import { delimitUntrusted, inlineUntrusted, sanitizeUntrustedText } from "./untrusted-text.js";
|
|
32
33
|
import { discloseReminderShaped, observeReminderMarkEcho } from "./reminder-disclosure.js";
|
|
@@ -159,19 +160,10 @@ const MCP_SPEC_ERROR_CODE_NAMES = new Map([
|
|
|
159
160
|
export function describeMcpSpecErrorCode(code) {
|
|
160
161
|
return typeof code === "number" ? MCP_SPEC_ERROR_CODE_NAMES.get(code) : undefined;
|
|
161
162
|
}
|
|
162
|
-
export function collapseMcpErrorPrefix(message) {
|
|
163
|
-
let out = message;
|
|
164
|
-
for (;;) {
|
|
165
|
-
const m = /^MCP error (-?\d+): (?=MCP error \1: )/.exec(out);
|
|
166
|
-
if (m === null)
|
|
167
|
-
return out;
|
|
168
|
-
out = out.slice(m[0].length);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
163
|
function sanitizeMcpErrorTextInPlace(err, declared) {
|
|
172
164
|
if (!(err instanceof Error))
|
|
173
165
|
return;
|
|
174
|
-
const sanitized = remoteWords(err
|
|
166
|
+
const sanitized = remoteWords(err.message, declared);
|
|
175
167
|
if (sanitized !== err.message)
|
|
176
168
|
err.message = sanitized;
|
|
177
169
|
}
|
|
@@ -179,13 +171,13 @@ function namedMcpFailureText(err, declared) {
|
|
|
179
171
|
const seat = hostSeatVerdictOf(err);
|
|
180
172
|
if (seat !== undefined)
|
|
181
173
|
return seat.condition;
|
|
182
|
-
const detail = remoteErrorText(err, declared
|
|
183
|
-
const
|
|
184
|
-
|
|
174
|
+
const detail = remoteErrorText(err, declared);
|
|
175
|
+
const code = thrownIs(err, ProtocolError) ? readMember(err, "code") : undefined;
|
|
176
|
+
const condition = describeMcpSpecErrorCode(code);
|
|
177
|
+
return condition !== undefined ? `${condition} (MCP protocol error ${String(code)}): ${detail}` : detail;
|
|
185
178
|
}
|
|
186
|
-
function remoteErrorText(err, declared
|
|
187
|
-
|
|
188
|
-
return remoteWords(opts?.collapse === true ? collapseMcpErrorPrefix(raw) : raw, declared);
|
|
179
|
+
function remoteErrorText(err, declared) {
|
|
180
|
+
return remoteWords(thrownText(err), declared);
|
|
189
181
|
}
|
|
190
182
|
function writeEffectWarning(writeEffect) {
|
|
191
183
|
return writeEffect
|
|
@@ -221,8 +213,9 @@ function rethrowHonestMcpError(err, ctx) {
|
|
|
221
213
|
const details = (extra) => ({ code: failure.kind, delivered: failure.delivered, server: ctx.server, ...(failure.authorization !== undefined ? { authorization: { ...failure.authorization } } : {}), ...extra });
|
|
222
214
|
switch (failure.kind) {
|
|
223
215
|
case "timeout": {
|
|
224
|
-
const data = err
|
|
225
|
-
const
|
|
216
|
+
const data = readMember(err, "data");
|
|
217
|
+
const total = typeof data === "object" && data !== null ? readMember(data, "maxTotalTimeout") : undefined;
|
|
218
|
+
const totalMs = typeof total === "number" ? total : undefined;
|
|
226
219
|
finish(markMcpFailure(new Error(totalMs !== undefined
|
|
227
220
|
? `${ctx.what} on MCP server "${serverLabel}" exceeded its total time ceiling of ${totalMs}ms (the call stayed alive — e.g. via progress notifications — but ran past the total wall-clock budget). The client stopped waiting, but the server may still be executing the request — the outcome is unknown.${writeEffectWarning(ctx.writeEffect)} (Set the MCP_TOOL_TIMEOUT_TOTAL environment variable (ms) to change this ceiling; MCP_TOOL_TIMEOUT only tunes the per-call timer, currently ${ctx.timeoutMs}ms.)`
|
|
228
221
|
: `${ctx.what} on MCP server "${serverLabel}" timed out after ${ctx.timeoutMs}ms. The client stopped waiting, but the server may still be executing the request — the outcome is unknown.${writeEffectWarning(ctx.writeEffect)} (Set the MCP_TOOL_TIMEOUT environment variable (ms) to change this limit.)`, { cause: err }), totalMs !== undefined ? details({ timeoutMs: totalMs, totalTimeout: true }) : details({ timeoutMs: ctx.timeoutMs })));
|
|
@@ -243,10 +236,10 @@ function rethrowHonestMcpError(err, ctx) {
|
|
|
243
236
|
: `${ctx.what} failed at the transport layer of MCP server "${serverLabel}": ${httpFailure.condition}. The request may or may not have executed on the server — the outcome is unknown.${writeEffectWarning(ctx.writeEffect)}${fenced}`, { cause: err }), details(failure.httpStatus !== undefined ? { httpStatus: failure.httpStatus } : undefined)));
|
|
244
237
|
}
|
|
245
238
|
case "protocol": {
|
|
246
|
-
const code = err.code;
|
|
239
|
+
const code = thrownIs(err, ProtocolError) ? err.code : undefined;
|
|
247
240
|
const condition = describeMcpSpecErrorCode(code);
|
|
248
|
-
if (condition !== undefined) {
|
|
249
|
-
finish(markMcpFailure(new Error(`${ctx.what} on MCP server "${serverLabel}" was rejected with MCP protocol error ${code} — ${condition}. The server's error text follows as external/untrusted data:\n${fenceServerText(`${ctx.server} error`, err
|
|
241
|
+
if (condition !== undefined && typeof code === "number") {
|
|
242
|
+
finish(markMcpFailure(new Error(`${ctx.what} on MCP server "${serverLabel}" was rejected with MCP protocol error ${code} — ${condition}. The server's error text follows as external/untrusted data:\n${fenceServerText(`${ctx.server} error`, thrownText(err))}`, { cause: err }), details({ specErrorCode: code })));
|
|
250
243
|
}
|
|
251
244
|
if (ctx.attributeServer) {
|
|
252
245
|
finish(markMcpFailure(new Error(`${ctx.what} on MCP server "${serverLabel}" failed. The server's error text follows as external/untrusted data:\n${fenceServerText(`${ctx.server} error`, remoteErrorText(err, ctx.declared))}`, { cause: err }), details()));
|
|
@@ -374,10 +367,10 @@ export function inferCompactSchema(value, depth = 2) {
|
|
|
374
367
|
}
|
|
375
368
|
return typeof value;
|
|
376
369
|
}
|
|
377
|
-
function buildTransport(spec, principal, kind, carrier, pieces,
|
|
370
|
+
function buildTransport(spec, principal, kind, carrier, pieces, pipe) {
|
|
378
371
|
const t = spec.transport;
|
|
379
372
|
if (kind === "host")
|
|
380
|
-
return
|
|
373
|
+
return pipe;
|
|
381
374
|
if (kind === "stdio") {
|
|
382
375
|
if (!("command" in t))
|
|
383
376
|
throw new Error(`MCP server "${spec.name}": transport kind "stdio" carries no command`);
|
|
@@ -390,7 +383,7 @@ function buildTransport(spec, principal, kind, carrier, pieces, hostSeat) {
|
|
|
390
383
|
if (!("url" in t))
|
|
391
384
|
throw new Error(`MCP server "${spec.name}": transport kind "${String(kind)}" carries no url`);
|
|
392
385
|
resolveProtocolHttpHeaders(MCP_NAMESPACE.id, t.principalHeader !== undefined ? { principalHeader: t.principalHeader } : {}, principal);
|
|
393
|
-
return new SessionEndingTransport(new URL(t.url), { fetch: peerFetch(carrier, t.principalHeader, principal) });
|
|
386
|
+
return new SessionEndingTransport(new URL(t.url), { fetch: peerFetch(carrier, t.principalHeader, principal), requestInit: { redirect: "manual" } });
|
|
394
387
|
}
|
|
395
388
|
export async function mapContent(content, serverName, imageProcessor) {
|
|
396
389
|
const processor = await resolveImageProcessor(imageProcessor);
|
|
@@ -507,7 +500,7 @@ function sanitizeMcpModelFacingValue(value, seat = "schema") {
|
|
|
507
500
|
}
|
|
508
501
|
return value;
|
|
509
502
|
}
|
|
510
|
-
const MCP_TOOL_DESCRIPTION_MAX_CHARS =
|
|
503
|
+
const MCP_TOOL_DESCRIPTION_MAX_CHARS = 4096;
|
|
511
504
|
const MCP_TOOL_DESCRIPTION_TRUNCATION_MARK = "… [truncated]";
|
|
512
505
|
function capMcpToolDescription(description) {
|
|
513
506
|
if (description.length <= MCP_TOOL_DESCRIPTION_MAX_CHARS)
|
|
@@ -727,7 +720,7 @@ export async function materializeLegMcpTools(seat, ...[specs, principal, onElici
|
|
|
727
720
|
const commitConnectedServer = (spec, s, transportKind) => {
|
|
728
721
|
const raised = [];
|
|
729
722
|
connections.push({ client: s.client, close: s.close });
|
|
730
|
-
const handle = { name: spec.name, spec, client: s.client,
|
|
723
|
+
const handle = { name: spec.name, spec, client: s.client, health: s.health, tools: s.tools, listing: s.listing, intakeAt: s.intakeAt, gates: () => intakeNow(handle).gates, definitions: () => intakeNow(handle).definitions, transportKind, announce: s.announce, instructions: s.instructions };
|
|
731
724
|
const hIdx = serverHandles.findIndex((h) => h.name === spec.name);
|
|
732
725
|
if (hIdx === -1)
|
|
733
726
|
serverHandles.push(handle);
|
|
@@ -781,11 +774,13 @@ export async function materializeLegMcpTools(seat, ...[specs, principal, onElici
|
|
|
781
774
|
const readDialKind = transportKindOf;
|
|
782
775
|
const dialKinds = entries.map(readDialKind);
|
|
783
776
|
const liveOf = (server) => serverHandles.find((h) => h.name === server);
|
|
784
|
-
const
|
|
777
|
+
const intakeNow = (h) => {
|
|
785
778
|
const latest = h.listing.latest();
|
|
786
|
-
if (latest.at !== h.
|
|
787
|
-
|
|
788
|
-
|
|
779
|
+
if (latest.at !== h.intakeAt.at) {
|
|
780
|
+
const { gates, definitions } = intakeListedTools({ tools: [...latest.entries], unproven: latest.unproven }, h.spec, linkOf(h.name), echoOf(h.spec), outputSchemaValidatorOf(h.client), imageProcessor, mcpDisclosure, isServerRevoked, h.transportKind, seat, echoReadOf(h.spec));
|
|
781
|
+
h.intakeAt = { at: latest.at, gates, definitions };
|
|
782
|
+
}
|
|
783
|
+
return h.intakeAt;
|
|
789
784
|
};
|
|
790
785
|
const linkOf = (server) => ({
|
|
791
786
|
live: () => liveOf(server),
|
|
@@ -984,7 +979,6 @@ export async function materializeLegMcpTools(seat, ...[specs, principal, onElici
|
|
|
984
979
|
const site = requestSite(h.client);
|
|
985
980
|
try {
|
|
986
981
|
const at = h.listing.open();
|
|
987
|
-
const cacheTools = h.openListing();
|
|
988
982
|
const listed = await listToolsLenient(h.client, undefined, echoOf(h.spec));
|
|
989
983
|
const answered = h.listing.answer(at, listed.tools, listed.incomplete !== undefined);
|
|
990
984
|
const mergedRaw = answered.view;
|
|
@@ -992,14 +986,13 @@ export async function materializeLegMcpTools(seat, ...[specs, principal, onElici
|
|
|
992
986
|
results.push({ server: h.name, prefix: prefixOf(h.name), status: "failed", toolCount: h.tools.length, added: [], removed: [], error: "a later listing of this server was opened and applied while this one was in the air — this one was discarded" });
|
|
993
987
|
continue;
|
|
994
988
|
}
|
|
995
|
-
const { serverTools, serverAxes, gates,
|
|
996
|
-
cacheTools(accepted, answered.kept);
|
|
989
|
+
const { serverTools, serverAxes, gates, definitions, dropped } = intakeListedTools({ tools: [...mergedRaw], unproven: answered.unproven }, h.spec, linkOf(h.name), echoOf(h.spec), outputSchemaValidatorOf(h.client), imageProcessor, mcpDisclosure, isServerRevoked, h.transportKind, seat, echoReadOf(h.spec));
|
|
997
990
|
const priorNames = h.tools.map((t) => t.name);
|
|
998
991
|
const newNames = serverTools.map((t) => t.name);
|
|
999
992
|
const added = newNames.filter((n) => !priorNames.includes(n));
|
|
1000
993
|
const removed = priorNames.filter((n) => !newNames.includes(n));
|
|
1001
994
|
h.tools = serverTools;
|
|
1002
|
-
h.
|
|
995
|
+
h.intakeAt = { at, gates, definitions };
|
|
1003
996
|
results.push({
|
|
1004
997
|
server: h.name,
|
|
1005
998
|
prefix: prefixOf(h.name),
|
|
@@ -1220,13 +1213,13 @@ async function readDirViaExtension(rs, uri, signal, timeoutMs, watchdog) {
|
|
|
1220
1213
|
page = await rs.client.request({ method: "resources/directory/read", params: { uri, ...(cursor !== undefined ? { cursor } : {}) } }, ListResourcesResultSchema, { signal: watchdog.combinedSignal, timeout: timeoutMs });
|
|
1221
1214
|
}
|
|
1222
1215
|
catch (err) {
|
|
1223
|
-
if (err instanceof
|
|
1216
|
+
if (err instanceof ProtocolError && err.code === ProtocolErrorCode.InvalidParams) {
|
|
1224
1217
|
if (pages > 0)
|
|
1225
1218
|
return { kind: "ok", resources, cursorInvalid: true };
|
|
1226
|
-
const detail = remoteErrorText(err, rs.declared
|
|
1219
|
+
const detail = remoteErrorText(err, rs.declared);
|
|
1227
1220
|
return { kind: classifyDirReadInvalidParams(detail), detail };
|
|
1228
1221
|
}
|
|
1229
|
-
if (err instanceof
|
|
1222
|
+
if (err instanceof ProtocolError && err.code === ProtocolErrorCode.MethodNotFound)
|
|
1230
1223
|
return { kind: "unsupported" };
|
|
1231
1224
|
if (pages > 0 && !signal?.aborted) {
|
|
1232
1225
|
return { kind: "ok", resources, incomplete: remoteErrorText(err, rs.declared) };
|
|
@@ -1316,7 +1309,7 @@ function buildResourceTools(resourceServers, isServerRevoked = () => false) {
|
|
|
1316
1309
|
try {
|
|
1317
1310
|
const walk = await walkMcpListPages(async (cursor, remainingMs) => {
|
|
1318
1311
|
const page = await rs.client
|
|
1319
|
-
.
|
|
1312
|
+
.request(resourcesListRequest(cursor), { signal: watchdog.combinedSignal, timeout: remainingMs })
|
|
1320
1313
|
.catch((err) => {
|
|
1321
1314
|
throw watchdog.idleSignal.reason === IDLE_WATCHDOG_ABORT_REASON ? new Error(idleWatchdogTripText(idleMs)) : err;
|
|
1322
1315
|
});
|
|
@@ -1398,7 +1391,7 @@ function buildResourceTools(resourceServers, isServerRevoked = () => false) {
|
|
|
1398
1391
|
let res;
|
|
1399
1392
|
try {
|
|
1400
1393
|
res = await rs.client
|
|
1401
|
-
.
|
|
1394
|
+
.request({ method: "resources/read", params: rs.readParams(uri) }, { signal: watchdog.combinedSignal, timeout: timeoutMs })
|
|
1402
1395
|
.catch((err) => rethrowHonestMcpError(err, { server, declared: rs.declared, what, timeoutMs, writeEffect: false, signal, attributeServer: true, site, idle: { signal: watchdog.idleSignal, idleMs }, liveness: rs.health }));
|
|
1403
1396
|
rs.health.observe?.("completed");
|
|
1404
1397
|
}
|
|
@@ -1487,7 +1480,7 @@ function buildResourceTools(resourceServers, isServerRevoked = () => false) {
|
|
|
1487
1480
|
}
|
|
1488
1481
|
const walk = await walkMcpListPages(async (cursor, remainingMs) => {
|
|
1489
1482
|
const page = await rs.client
|
|
1490
|
-
.
|
|
1483
|
+
.request(resourcesListRequest(cursor), { signal: watchdog.combinedSignal, timeout: remainingMs })
|
|
1491
1484
|
.catch((err) => rethrowHonestMcpError(err, { server, declared: rs.declared, what, timeoutMs: remainingMs, writeEffect: false, signal, attributeServer: true, site, idle: { signal: watchdog.idleSignal, idleMs }, liveness: rs.health }));
|
|
1492
1485
|
rs.health.observe?.("completed");
|
|
1493
1486
|
return { items: page.resources, ...(page.nextCursor !== undefined ? { nextCursor: page.nextCursor } : {}) };
|
|
@@ -1507,60 +1500,62 @@ function buildResourceTools(resourceServers, isServerRevoked = () => false) {
|
|
|
1507
1500
|
withContentOrigin(t, "external");
|
|
1508
1501
|
return { tools, axes };
|
|
1509
1502
|
}
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1503
|
+
const OUTPUT_SCHEMA_VALIDATORS = new WeakMap();
|
|
1504
|
+
function outputSchemaValidatorOf(client) {
|
|
1505
|
+
const validator = OUTPUT_SCHEMA_VALIDATORS.get(client);
|
|
1506
|
+
if (validator === undefined)
|
|
1507
|
+
throw new Error("internal: an MCP client this module did not dial has no recorded schema validator");
|
|
1508
|
+
return validator;
|
|
1509
|
+
}
|
|
1510
|
+
function toolDefinitionOf(t, validator) {
|
|
1511
|
+
const tool = { ...t, inputSchema: t.inputSchema };
|
|
1512
|
+
if (!t.outputSchema)
|
|
1513
|
+
return { tool };
|
|
1514
1514
|
try {
|
|
1515
|
-
|
|
1515
|
+
validator.getValidator(t.outputSchema);
|
|
1516
|
+
return { tool };
|
|
1516
1517
|
}
|
|
1517
1518
|
catch {
|
|
1519
|
+
return { tool, outputSchemaUncompilable: true };
|
|
1518
1520
|
}
|
|
1519
1521
|
}
|
|
1520
|
-
const
|
|
1521
|
-
|
|
1522
|
-
if (typeof data !== "object" || data === null)
|
|
1523
|
-
return { success: false, error: new Error("tools/list result is not an object") };
|
|
1524
|
-
const rawTools = data.tools;
|
|
1525
|
-
if (!Array.isArray(rawTools))
|
|
1526
|
-
return { success: false, error: new Error("tools/list result.tools is not an array") };
|
|
1527
|
-
const tools = [];
|
|
1528
|
-
for (const raw of rawTools) {
|
|
1529
|
-
if (typeof raw !== "object" || raw === null || typeof raw.name !== "string") {
|
|
1530
|
-
return { success: false, error: new Error("a tools/list entry is missing a string name") };
|
|
1531
|
-
}
|
|
1532
|
-
const t = raw;
|
|
1533
|
-
tools.push({
|
|
1534
|
-
name: t.name,
|
|
1535
|
-
...(typeof t.description === "string" ? { description: t.description } : {}),
|
|
1536
|
-
inputSchema: t.inputSchema,
|
|
1537
|
-
...(t.annotations !== undefined ? { annotations: t.annotations } : {}),
|
|
1538
|
-
...(t._meta !== undefined ? { _meta: t._meta } : {}),
|
|
1539
|
-
...(t.outputSchema !== undefined ? { outputSchema: t.outputSchema } : {}),
|
|
1540
|
-
...(t.execution !== undefined ? { execution: t.execution } : {}),
|
|
1541
|
-
});
|
|
1542
|
-
}
|
|
1543
|
-
const nextCursor = data.nextCursor;
|
|
1544
|
-
const cursorInvalid = nextCursor !== undefined && nextCursor !== null && typeof nextCursor !== "string";
|
|
1545
|
-
return { success: true, data: { tools, ...(typeof nextCursor === "string" ? { nextCursor } : {}), ...(cursorInvalid ? { cursorInvalid: true } : {}) } };
|
|
1546
|
-
},
|
|
1522
|
+
const LENIENT_LIST_TOOLS_RESULT_SCHEMA = {
|
|
1523
|
+
"~standard": { version: 1, vendor: "sema-core", validate: parseLenientToolsPage },
|
|
1547
1524
|
};
|
|
1548
|
-
|
|
1549
|
-
if (typeof data !== "object" || data === null
|
|
1550
|
-
return
|
|
1525
|
+
function parseLenientToolsPage(data) {
|
|
1526
|
+
if (typeof data !== "object" || data === null)
|
|
1527
|
+
return { issues: [{ message: "tools/list result is not an object" }] };
|
|
1528
|
+
const rawTools = data.tools;
|
|
1529
|
+
if (!Array.isArray(rawTools))
|
|
1530
|
+
return { issues: [{ message: "tools/list result.tools is not an array" }] };
|
|
1531
|
+
const tools = [];
|
|
1532
|
+
for (const raw of rawTools) {
|
|
1533
|
+
if (typeof raw !== "object" || raw === null || typeof raw.name !== "string") {
|
|
1534
|
+
return { issues: [{ message: "a tools/list entry is missing a string name" }] };
|
|
1535
|
+
}
|
|
1536
|
+
const t = raw;
|
|
1537
|
+
tools.push({
|
|
1538
|
+
name: t.name,
|
|
1539
|
+
...(typeof t.description === "string" ? { description: t.description } : {}),
|
|
1540
|
+
inputSchema: t.inputSchema,
|
|
1541
|
+
...(t.annotations !== undefined ? { annotations: t.annotations } : {}),
|
|
1542
|
+
...(t._meta !== undefined ? { _meta: t._meta } : {}),
|
|
1543
|
+
...(t.outputSchema !== undefined ? { outputSchema: t.outputSchema } : {}),
|
|
1544
|
+
...(t.execution !== undefined ? { execution: t.execution } : {}),
|
|
1545
|
+
});
|
|
1551
1546
|
}
|
|
1552
|
-
const
|
|
1553
|
-
const
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1547
|
+
const nextCursor = data.nextCursor;
|
|
1548
|
+
const cursorInvalid = nextCursor !== undefined && nextCursor !== null && typeof nextCursor !== "string";
|
|
1549
|
+
return { value: { tools, ...(typeof nextCursor === "string" ? { nextCursor } : {}), ...(cursorInvalid ? { cursorInvalid: true } : {}) } };
|
|
1550
|
+
}
|
|
1551
|
+
function resourcesListRequest(cursor) {
|
|
1552
|
+
return cursor === undefined ? { method: "resources/list" } : { method: "resources/list", params: { cursor } };
|
|
1557
1553
|
}
|
|
1558
|
-
const LENIENT_CALL_TOOL_RESULT_SCHEMA = { safeParse: parseCallToolResultLenient };
|
|
1559
1554
|
async function listToolsLenient(client, options, declared) {
|
|
1560
1555
|
if (!client.getServerCapabilities()?.tools)
|
|
1561
1556
|
return { tools: [], toolsCapabilityAbsent: true };
|
|
1562
1557
|
const walk = await walkMcpListPages(async (cursor, remainingMs) => {
|
|
1563
|
-
const page = await client.request({ method: "tools/list", params: cursor === undefined ? {} : { cursor } },
|
|
1558
|
+
const page = await client.request({ method: "tools/list", params: cursor === undefined ? {} : { cursor } }, LENIENT_LIST_TOOLS_RESULT_SCHEMA, { ...options, timeout: remainingMs });
|
|
1564
1559
|
return {
|
|
1565
1560
|
items: page.tools,
|
|
1566
1561
|
...(page.nextCursor !== undefined ? { nextCursor: page.nextCursor } : {}),
|
|
@@ -1584,11 +1579,18 @@ async function connectServer(spec, principal, onElicit, imageProcessor, reminder
|
|
|
1584
1579
|
const announce = {};
|
|
1585
1580
|
const startupMs = mcpStartupTimeoutMs(spec);
|
|
1586
1581
|
const startupOpts = startupMs !== undefined ? { timeout: startupMs } : undefined;
|
|
1582
|
+
const answersOneLeg = elicitOn || transportKind === "host";
|
|
1583
|
+
const poolKey = pool !== undefined && !answersOneLeg ? McpConnectionPool.keyOf(spec, principal, transportKind, startupMs) : undefined;
|
|
1587
1584
|
const dialClient = async (stop = dialOpts?.signal) => {
|
|
1588
1585
|
stop?.throwIfAborted();
|
|
1589
|
-
const
|
|
1586
|
+
const outputSchemaValidator = new AjvJsonSchemaValidator();
|
|
1587
|
+
const client = new Client({ name: `sema-core/${spec.name}`, version: "0.1.0" }, {
|
|
1588
|
+
capabilities: elicitOn ? { elicitation: { form: {} } } : {},
|
|
1589
|
+
jsonSchemaValidator: outputSchemaValidator,
|
|
1590
|
+
});
|
|
1591
|
+
OUTPUT_SCHEMA_VALIDATORS.set(client, outputSchemaValidator);
|
|
1590
1592
|
if (elicitOn) {
|
|
1591
|
-
client.setRequestHandler(
|
|
1593
|
+
client.setRequestHandler("elicitation/create", async (request, ctx) => {
|
|
1592
1594
|
health.pendingElicitations++;
|
|
1593
1595
|
try {
|
|
1594
1596
|
const p = request.params;
|
|
@@ -1598,7 +1600,7 @@ async function connectServer(spec, principal, onElicit, imageProcessor, reminder
|
|
|
1598
1600
|
...(p.requestedSchema !== undefined ? { requestedSchema: p.requestedSchema } : {}),
|
|
1599
1601
|
...(principal !== undefined ? { principal } : {}),
|
|
1600
1602
|
};
|
|
1601
|
-
const answer = await onElicit(req,
|
|
1603
|
+
const answer = await onElicit(req, ctx.mcpReq.signal);
|
|
1602
1604
|
return answer.action === "accept" ? { action: "accept", content: answer.content ?? {} } : { action: answer.action };
|
|
1603
1605
|
}
|
|
1604
1606
|
finally {
|
|
@@ -1608,11 +1610,12 @@ async function connectServer(spec, principal, onElicit, imageProcessor, reminder
|
|
|
1608
1610
|
});
|
|
1609
1611
|
}
|
|
1610
1612
|
const pieces = transportKind === "stdio" ? await dialOpts.carrier.next(stop) : undefined;
|
|
1611
|
-
const
|
|
1613
|
+
const pipe = transportKind === "host" ? await openHostPipe(dialOpts.hostSeat, spec.name, stop) : undefined;
|
|
1614
|
+
const transport = buildTransport(spec, principal, transportKind, dialOpts.carrier, pieces, pipe);
|
|
1612
1615
|
const hangUp = () => void client.close().catch(() => undefined);
|
|
1613
1616
|
stop?.addEventListener("abort", hangUp, { once: true });
|
|
1614
1617
|
try {
|
|
1615
|
-
await client.connect(transport, startupOpts);
|
|
1618
|
+
await settledBefore(client.connect(transport, startupOpts), pipe !== undefined ? stop : undefined);
|
|
1616
1619
|
}
|
|
1617
1620
|
catch (err) {
|
|
1618
1621
|
await client.close().catch(() => undefined);
|
|
@@ -1624,16 +1627,18 @@ async function connectServer(spec, principal, onElicit, imageProcessor, reminder
|
|
|
1624
1627
|
stop?.removeEventListener("abort", hangUp);
|
|
1625
1628
|
}
|
|
1626
1629
|
recordCarrier(client, dialOpts.carrier);
|
|
1630
|
+
if (poolKey !== undefined)
|
|
1631
|
+
recordEngineDial(client, poolKey);
|
|
1627
1632
|
return client;
|
|
1628
1633
|
};
|
|
1629
|
-
const
|
|
1630
|
-
const
|
|
1631
|
-
const
|
|
1634
|
+
const mount = transportKind === "host" ? hostMount(startupMs, dialOpts.signal) : undefined;
|
|
1635
|
+
const mountStop = mount?.signal ?? dialOpts?.signal;
|
|
1636
|
+
const lease = pool !== undefined && poolKey !== undefined ? await pool.acquire(poolKey, dialClient, dialOpts) : undefined;
|
|
1637
|
+
const client = lease !== undefined ? lease.client : await dialClient(mountStop).catch((err) => {
|
|
1638
|
+
mount?.end();
|
|
1639
|
+
throw err;
|
|
1640
|
+
});
|
|
1632
1641
|
const close = () => (lease !== undefined ? lease.release() : client.close());
|
|
1633
|
-
const openListing = () => {
|
|
1634
|
-
const write = lease?.openListing();
|
|
1635
|
-
return (tools, retained) => (write !== undefined ? write(tools, (all) => cacheMcpToolMetadata(client, all), retained) : cacheMcpToolMetadata(client, tools));
|
|
1636
|
-
};
|
|
1637
1642
|
try {
|
|
1638
1643
|
const onClosed = () => {
|
|
1639
1644
|
health.dead = true;
|
|
@@ -1645,13 +1650,11 @@ async function connectServer(spec, principal, onElicit, imageProcessor, reminder
|
|
|
1645
1650
|
client.onclose = onClosed;
|
|
1646
1651
|
const listing = lease?.listing ?? new ConnectionListing();
|
|
1647
1652
|
const at = listing.open();
|
|
1648
|
-
const cacheTools = openListing();
|
|
1649
1653
|
const declared = (carrierOf(client) ?? dialOpts.carrier).sent;
|
|
1650
1654
|
const echo = carrierEcho(carrierOf(client) ?? dialOpts.carrier, dialOpts.announceEcho);
|
|
1651
|
-
const listed = await underStartupBound(startupMs,
|
|
1655
|
+
const listed = await underStartupBound(startupMs, mountStop, (options) => listToolsLenient(client, options, declared)).finally(() => mount?.end());
|
|
1652
1656
|
const answered = listing.answer(at, listed.tools, listed.incomplete !== undefined, dialOpts.carried);
|
|
1653
|
-
const { serverTools, serverAxes, gates, dropped, advisories
|
|
1654
|
-
cacheTools(accepted, answered.kept);
|
|
1657
|
+
const { serverTools, serverAxes, gates, definitions, dropped, advisories } = intakeListedTools({ tools: [...answered.view], unproven: answered.unproven }, spec, dialOpts.link, declared, outputSchemaValidatorOf(client), imageProcessor, reminderDisclosure, isServerRevoked, transportKind, seat, echo);
|
|
1655
1658
|
const caps = client.getServerCapabilities();
|
|
1656
1659
|
const resourceInfo = caps?.resources
|
|
1657
1660
|
? {
|
|
@@ -1675,13 +1678,12 @@ async function connectServer(spec, principal, onElicit, imageProcessor, reminder
|
|
|
1675
1678
|
status,
|
|
1676
1679
|
client,
|
|
1677
1680
|
close,
|
|
1678
|
-
openListing,
|
|
1679
1681
|
health,
|
|
1680
1682
|
announce,
|
|
1681
1683
|
tools: serverTools,
|
|
1682
1684
|
axes: serverAxes,
|
|
1683
1685
|
listing,
|
|
1684
|
-
|
|
1686
|
+
intakeAt: { at, gates, definitions },
|
|
1685
1687
|
dropped,
|
|
1686
1688
|
schemaAdvisories: advisories,
|
|
1687
1689
|
...(listed.toolsCapabilityAbsent === true ? { toolsCapabilityAbsent: true } : {}),
|
|
@@ -1698,13 +1700,13 @@ async function connectServer(spec, principal, onElicit, imageProcessor, reminder
|
|
|
1698
1700
|
throw err;
|
|
1699
1701
|
}
|
|
1700
1702
|
}
|
|
1701
|
-
function intakeListedTools(listed, spec, link, declared, imageProcessor, reminderDisclosure, isServerRevoked, transportKind, seat, echo = NO_CREDENTIAL_ECHO) {
|
|
1703
|
+
function intakeListedTools(listed, spec, link, declared, validator, imageProcessor, reminderDisclosure, isServerRevoked, transportKind, seat, echo = NO_CREDENTIAL_ECHO) {
|
|
1702
1704
|
const declaredContentOrigin = spec.contentOrigin;
|
|
1703
1705
|
const serverTools = [];
|
|
1704
1706
|
const serverAxes = [];
|
|
1705
1707
|
const gates = new Map();
|
|
1706
1708
|
const dropped = [];
|
|
1707
|
-
const
|
|
1709
|
+
const definitions = new Map();
|
|
1708
1710
|
const advisories = [];
|
|
1709
1711
|
const claimToolName = createToolNameClaims(MCP_NAMESPACE, spec.name);
|
|
1710
1712
|
for (const t of listed.tools) {
|
|
@@ -1802,11 +1804,13 @@ function intakeListedTools(listed, spec, link, declared, imageProcessor, reminde
|
|
|
1802
1804
|
const callMeta = mcpCallMeta(toolCallId, seat?.of(toolCallId), spec.sessionMetaKey, seat?.sessionId);
|
|
1803
1805
|
let answeredWith = declared;
|
|
1804
1806
|
const attempt = async (conn, resent, last) => {
|
|
1807
|
+
const definition = conn.definitions().get(namespacedName);
|
|
1805
1808
|
const site = requestSite(conn.client);
|
|
1806
1809
|
const watchdog = armMcpIdleWatchdog(conn.health, idleMs, signal);
|
|
1807
1810
|
try {
|
|
1808
1811
|
const res = await conn.client
|
|
1809
|
-
.callTool({ name: remoteName, arguments: (params ?? {}), ...(callMeta !== undefined ? { _meta: callMeta } : {}) },
|
|
1812
|
+
.callTool({ name: remoteName, arguments: (params ?? {}), ...(callMeta !== undefined ? { _meta: callMeta } : {}) }, {
|
|
1813
|
+
toolDefinition: definition.tool,
|
|
1810
1814
|
signal: watchdog.combinedSignal,
|
|
1811
1815
|
timeout: timeoutMs,
|
|
1812
1816
|
resetTimeoutOnProgress: true,
|
|
@@ -1913,9 +1917,9 @@ function intakeListedTools(listed, spec, link, declared, imageProcessor, reminde
|
|
|
1913
1917
|
},
|
|
1914
1918
|
};
|
|
1915
1919
|
serverTools.push(declaredContentOrigin !== undefined ? withContentOrigin(mounted, declaredContentOrigin) : mounted);
|
|
1916
|
-
|
|
1920
|
+
definitions.set(namespacedName, toolDefinitionOf(t, validator));
|
|
1917
1921
|
}
|
|
1918
|
-
return { serverTools, serverAxes, gates, dropped, advisories
|
|
1922
|
+
return { serverTools, serverAxes, gates, definitions, dropped, advisories };
|
|
1919
1923
|
}
|
|
1920
1924
|
function asServerWarning(spec, err, declared) {
|
|
1921
1925
|
const warning = new Error(`mcp: server "${spec.name}" failed to connect — skipped (${namedMcpFailureText(err, declared)})`, { cause: sanitizedCause(err, declared) });
|
|
@@ -1,33 +1,8 @@
|
|
|
1
1
|
import type { AgentMessage } from "../internal/harness-types.js";
|
|
2
|
-
import type
|
|
3
|
-
|
|
4
|
-
* Aggregate MEDIA (image) byte budget — the multimodal sibling of {@link AGGREGATE_TOOL_RESULT_BUDGET_CHARS}
|
|
5
|
-
* (which only counts TEXT, design/64 §17.2). batch-C added image reads (`Read` → `ImageContent`); each is bounded
|
|
6
|
-
* per-image (`MAX_IMAGE_READ_BYTES`), but N images accumulate ACROSS turns in the context and would otherwise grow
|
|
7
|
-
* the request unboundedly (a real gap — the reference added the same cap, `tengu_media_byte_cap`, validating it).
|
|
8
|
-
*
|
|
9
|
-
* This caps the SUM of inline image bytes across the whole message list: while over budget, the OLDEST images are
|
|
10
|
-
* stripped (replaced with a short text marker) until it fits — recent media (most relevant) is kept. Like the text
|
|
11
|
-
* budget it is a REQUEST-ONLY, NON-DESTRUCTIVE transform (returns a new array; the durable session keeps the full
|
|
12
|
-
* image, and the model can re-`Read` the file if it still needs it) applied in the `harness.on("context")` hook,
|
|
13
|
-
* and DETERMINISTIC (same messages + limit → same strip set → byte-identical request → prompt-cache safe).
|
|
14
|
-
*/
|
|
15
|
-
/** Default aggregate inline-media budget (bytes). Generous — only the pathological "N parallel huge image reads"
|
|
16
|
-
* case strips. Bounds the request while leaving normal multimodal use untouched. Overridable per-deployment. */
|
|
17
|
-
export declare const AGGREGATE_MEDIA_BUDGET_BYTES: number;
|
|
18
|
-
/** The one reading of a deployment's media budget (`RunnerDeps.mediaByteCapBytes`, screened by {@link checkedMediaByteCap}
|
|
19
|
-
* at `new Runner`), for both of its readers — the request strip below and the `tool_end.output` projection: absent ⇒
|
|
20
|
-
* {@link AGGREGATE_MEDIA_BUDGET_BYTES}; a finite positive number ⇒ itself; `0` or `Infinity` ⇒ no budget, `Infinity`
|
|
21
|
-
* (a direct caller of {@link capAggregateMediaBytes} that passes a negative or `NaN` meets the same no-op). */
|
|
22
|
-
export declare function mediaBudgetBytes(cap: number | undefined): number;
|
|
23
|
-
/** The deployment's media budget, screened once at `new Runner`: absent, a non-negative number of bytes, or `Infinity`
|
|
24
|
-
* (`0` and `Infinity` both mean "no budget"). A non-number, `NaN` or a negative is refused (`config.invalid_argument`),
|
|
25
|
-
* never read as "no budget". */
|
|
26
|
-
export declare function checkedMediaByteCap(value: unknown, seat: string): void;
|
|
2
|
+
import { type DocumentContent, type ImageContent } from "../internal/llm.js";
|
|
3
|
+
import { type RequestMediaLimits } from "./image-admission.js";
|
|
27
4
|
/** A media block: an image or a document whose payload is a base64 string. */
|
|
28
5
|
export type MediaBlock = ImageContent | DocumentContent;
|
|
29
|
-
/** The media type a block claims — its `type`, read once, when that is a media type — or `undefined` for any other value. */
|
|
30
|
-
export declare function claimedMediaType(block: unknown): MediaBlock["type"] | undefined;
|
|
31
6
|
/** Whether a value is a media block: its `type` is a media type and its `data` a string. A block of a media type with no
|
|
32
7
|
* string `data` is not one — a {@link MediaDescriptor} is such a block. */
|
|
33
8
|
export declare function isMediaBlock(block: unknown): block is MediaBlock;
|
|
@@ -49,24 +24,24 @@ export type MediaDescriptor = {
|
|
|
49
24
|
export declare function mediaBlockDescriptor(block: MediaBlock): MediaDescriptor;
|
|
50
25
|
/** The one summary of media blocks that leave together: how many, and their decoded size. */
|
|
51
26
|
export declare function omittedMediaDescriptor(blocks: readonly MediaBlock[]): MediaDescriptor;
|
|
52
|
-
/** Decoded byte size of a base64 media payload (4 base64 chars ≈ 3 bytes)
|
|
53
|
-
* PDF read: `document` blocks (base64 PDFs) count against the SAME aggregate budget — same class of inline
|
|
54
|
-
* media bytes, same unbounded-accumulation failure mode. */
|
|
27
|
+
/** Decoded byte size of a base64 media payload (4 base64 chars ≈ 3 bytes) — what a descriptor states of the block. */
|
|
55
28
|
export declare function imageBytes(b: ImageContent | DocumentContent): number;
|
|
56
|
-
/**
|
|
57
|
-
export interface
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
29
|
+
/** One block the trim took out: the input's own block object, and its type and base64 as the trim read them (once). */
|
|
30
|
+
export interface RemovedMedia {
|
|
31
|
+
block: object;
|
|
32
|
+
type: MediaBlock["type"];
|
|
33
|
+
data: string;
|
|
34
|
+
}
|
|
35
|
+
/** What one request's trim did: the request's messages (the input array itself when nothing went), the blocks that went
|
|
36
|
+
* (oldest first) and their base64 characters, and the request's media as it came — how many blocks, how many base64
|
|
37
|
+
* characters. */
|
|
38
|
+
export interface RequestMediaTrim {
|
|
39
|
+
messages: AgentMessage[];
|
|
40
|
+
removed: RemovedMedia[];
|
|
41
|
+
removedBase64Chars: number;
|
|
42
|
+
items: number;
|
|
43
|
+
base64Chars: number;
|
|
62
44
|
}
|
|
63
|
-
/**
|
|
64
|
-
*
|
|
65
|
-
|
|
66
|
-
* shallow-cloned array with the stripped messages replaced (originals untouched). `onStripped` fires once if anything
|
|
67
|
-
* was removed.
|
|
68
|
-
*/
|
|
69
|
-
export declare function capAggregateMediaBytes(messages: AgentMessage[], opts: {
|
|
70
|
-
limitBytes: number;
|
|
71
|
-
onStripped?: (info: MediaStripInfo) => void;
|
|
72
|
-
}): AgentMessage[];
|
|
45
|
+
/** Trim the media of `messages` to `limits` (see the module head). A block's size is its base64 length (CC `Pkn`), `0` for
|
|
46
|
+
* one that carries no base64 string — such a block counts toward `maxItems` and is never cut for the budget. */
|
|
47
|
+
export declare function trimRequestMedia(messages: AgentMessage[], limits: RequestMediaLimits): RequestMediaTrim;
|