@sema-agent/core 7.58.0 → 7.60.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1340 -0
- package/README.md +6 -4
- package/dist/agents/agent-definition.d.ts +7 -0
- package/dist/agents/agent-definition.js +12 -0
- package/dist/agents/agent-transcript-tool.d.ts +2 -1
- package/dist/agents/agent-transcript-tool.js +3 -1
- package/dist/agents/cc-peer-directory.js +8 -8
- package/dist/agents/child-model-seat.d.ts +4 -2
- package/dist/agents/child-model-seat.js +9 -4
- package/dist/agents/cumulative-stats.js +0 -1
- package/dist/agents/inherited-tool-pool.d.ts +26 -1
- package/dist/agents/inherited-tool-pool.js +22 -0
- package/dist/agents/peer-directory.d.ts +9 -0
- package/dist/agents/peer-directory.js +6 -2
- package/dist/agents/retain-ledger.d.ts +11 -1
- package/dist/agents/retain-ledger.js +13 -2
- package/dist/agents/roster-store.d.ts +1 -1
- package/dist/agents/roster-store.js +3 -1
- package/dist/agents/send-message-tool.d.ts +8 -19
- package/dist/agents/send-message-tool.js +32 -50
- package/dist/agents/subagent.d.ts +51 -17
- package/dist/agents/subagent.js +150 -112
- package/dist/agents/tool-filter.d.ts +1 -3
- package/dist/agents/tool-filter.js +4 -12
- package/dist/bench/metrics.d.ts +3 -5
- package/dist/bench/metrics.js +0 -1
- package/dist/brain/anthropic.js +161 -45
- package/dist/brain/degrading.js +3 -1
- package/dist/brain/errors.d.ts +9 -3
- package/dist/brain/errors.js +7 -1
- package/dist/brain/failover.js +2 -1
- package/dist/brain/open-responses.js +3 -3
- package/dist/brain/openai.js +103 -53
- package/dist/brain/provider-dialect.d.ts +11 -0
- package/dist/brain/provider-dialect.js +5 -2
- package/dist/brain/reasoning-request.js +5 -4
- package/dist/brain/reasoning.d.ts +19 -0
- package/dist/brain/reasoning.js +17 -2
- package/dist/brain/request-route.d.ts +4 -1
- package/dist/brain/request-route.js +4 -1
- package/dist/brain/route-adjudicator.d.ts +84 -18
- package/dist/brain/route-adjudicator.js +90 -22
- package/dist/brain/route-conformance.js +1 -1
- package/dist/brain/status-sink.d.ts +7 -1
- package/dist/brain/status-sink.js +6 -0
- package/dist/brain/stream-engine.js +84 -49
- package/dist/brain/stream-shared.d.ts +30 -0
- package/dist/brain/stream-shared.js +34 -1
- package/dist/brain/timeout.d.ts +65 -6
- package/dist/brain/timeout.js +111 -11
- package/dist/core/a2a.d.ts +15 -5
- package/dist/core/a2a.js +34 -19
- package/dist/core/account-row.d.ts +61 -0
- package/dist/core/account-row.js +51 -0
- package/dist/core/advisor-verdict.d.ts +2 -1
- package/dist/core/advisor-verdict.js +1 -1
- package/dist/core/agent-definition.d.ts +20 -0
- package/dist/core/allow-entry.d.ts +20 -6
- package/dist/core/allow-entry.js +17 -7
- package/dist/core/approval-object.d.ts +29 -15
- package/dist/core/approval-object.js +47 -19
- package/dist/core/artifact-host.d.ts +0 -2
- package/dist/core/artifact-host.js +0 -1
- package/dist/core/auto-compaction.js +1 -1
- package/dist/core/auto-mode-defaults.d.ts +8 -0
- package/dist/core/auto-mode-defaults.js +1 -0
- package/dist/core/auto-mode-rebuild.d.ts +2 -1
- package/dist/core/auto-mode.d.ts +39 -4
- package/dist/core/auto-mode.js +63 -12
- package/dist/core/background-agent-store.d.ts +26 -4
- package/dist/core/background-agent-store.js +3 -2
- package/dist/core/background-shell.d.ts +12 -1
- package/dist/core/background-shell.js +12 -0
- package/dist/core/checkpoint-requirements.d.ts +13 -1
- package/dist/core/checkpoint-requirements.js +3 -1
- package/dist/core/checkpoint-store.d.ts +66 -25
- package/dist/core/checkpoint-store.js +22 -9
- package/dist/core/child-clamp-seats.d.ts +29 -0
- package/dist/core/child-clamp-seats.js +56 -1
- package/dist/core/compliance.d.ts +3 -3
- package/dist/core/compliance.js +1 -1
- package/dist/core/credential-echo.d.ts +52 -0
- package/dist/core/credential-echo.js +65 -0
- package/dist/core/credential-vocabulary.d.ts +13 -3
- package/dist/core/credential-vocabulary.js +12 -4
- package/dist/core/cross-boundary-taint.d.ts +4 -5
- package/dist/core/effective-path-target.d.ts +8 -2
- package/dist/core/effective-path-target.js +8 -3
- package/dist/core/engine-notice.d.ts +156 -23
- package/dist/core/engine-notice.js +19 -5
- package/dist/core/frame-settlement.d.ts +5 -0
- package/dist/core/frame-settlement.js +4 -0
- package/dist/core/gate-fold.js +8 -6
- package/dist/core/gate-lanes.js +47 -12
- package/dist/core/gate-outcome.d.ts +32 -3
- package/dist/core/gate-outcome.js +19 -1
- package/dist/core/governance-codes.d.ts +17 -1
- package/dist/core/governance-codes.js +25 -0
- package/dist/core/hands-band-screen.js +0 -1
- package/dist/core/hands-band.d.ts +0 -3
- package/dist/core/hooks.d.ts +70 -59
- package/dist/core/hooks.js +125 -80
- package/dist/core/image-admission.d.ts +106 -52
- package/dist/core/image-admission.js +184 -56
- package/dist/core/image-downsample.d.ts +36 -69
- package/dist/core/image-downsample.js +111 -73
- package/dist/core/integer-option.d.ts +21 -0
- package/dist/core/integer-option.js +13 -0
- package/dist/core/locked-config.d.ts +59 -5
- package/dist/core/locked-config.js +82 -50
- package/dist/core/mailbox-store.d.ts +45 -1
- package/dist/core/mailbox-store.js +53 -9
- package/dist/core/mcp-call-meta.d.ts +2 -2
- package/dist/core/mcp-call-meta.js +9 -10
- package/dist/core/mcp-failure.d.ts +122 -20
- package/dist/core/mcp-failure.js +73 -5
- package/dist/core/mcp-host-seat.d.ts +92 -0
- package/dist/core/mcp-host-seat.js +131 -0
- package/dist/core/mcp-probe.d.ts +7 -2
- package/dist/core/mcp-probe.js +7 -2
- package/dist/core/mcp-server-link.d.ts +22 -1
- package/dist/core/mcp-server-link.js +25 -1
- package/dist/core/mcp-server-spec.d.ts +38 -9
- package/dist/core/mcp-server-spec.js +55 -21
- package/dist/core/mcp.d.ts +27 -12
- package/dist/core/mcp.js +105 -76
- package/dist/core/memory-admission.d.ts +23 -6
- package/dist/core/memory-admission.js +19 -9
- package/dist/core/memory-engine/consolidation-driver.d.ts +2 -4
- package/dist/core/memory-engine/consolidation-driver.js +3 -3
- package/dist/core/memory-engine/consolidation.d.ts +4 -0
- package/dist/core/memory-engine/consolidation.js +1 -0
- package/dist/core/memory-engine/content-origin.d.ts +13 -0
- package/dist/core/memory-engine/content-origin.js +21 -3
- package/dist/core/memory-engine/delegation-settlement.js +5 -12
- package/dist/core/memory-engine/distiller.js +2 -2
- package/dist/core/memory-engine/dual-root.d.ts +50 -1
- package/dist/core/memory-engine/dual-root.js +44 -1
- package/dist/core/memory-engine/engine.d.ts +67 -14
- package/dist/core/memory-engine/engine.js +384 -212
- package/dist/core/memory-engine/export-bundle.d.ts +23 -0
- package/dist/core/memory-engine/export-bundle.js +23 -4
- package/dist/core/memory-engine/file-backend.d.ts +128 -55
- package/dist/core/memory-engine/file-backend.js +290 -117
- package/dist/core/memory-engine/index.d.ts +3 -2
- package/dist/core/memory-engine/index.js +2 -1
- package/dist/core/memory-engine/layout.d.ts +59 -11
- package/dist/core/memory-engine/layout.js +190 -40
- package/dist/core/memory-engine/memory-backend-contract.d.ts +1 -1
- package/dist/core/memory-engine/memory-backend-contract.js +39 -2
- package/dist/core/memory-engine/scope-contract.d.ts +13 -3
- package/dist/core/memory-engine/scope-contract.js +2 -2
- package/dist/core/memory-engine/sync-client.d.ts +51 -9
- package/dist/core/memory-engine/sync-client.js +107 -13
- package/dist/core/memory-engine/sync-report.d.ts +103 -0
- package/dist/core/memory-engine/sync-report.js +119 -0
- package/dist/core/memory-engine/sync.d.ts +8 -1
- package/dist/core/memory-engine/types.d.ts +6 -0
- package/dist/core/mode-policy.d.ts +9 -1
- package/dist/core/mode-policy.js +11 -1
- package/dist/core/model-receipt.d.ts +39 -0
- package/dist/core/model-receipt.js +139 -0
- package/dist/core/mods/agent-stations.d.ts +65 -0
- package/dist/core/mods/agent-stations.js +105 -0
- package/dist/core/mods/classic-events.d.ts +5 -1
- package/dist/core/mods/kernel/dispatch.d.ts +5 -1
- package/dist/core/mods/kernel/dispatch.js +6 -5
- package/dist/core/mods/kernel/events.d.ts +11 -4
- package/dist/core/mods/kernel/events.js +11 -7
- package/dist/core/mods/kernel/receive.d.ts +5 -0
- package/dist/core/mods/kernel/receive.js +10 -0
- package/dist/core/mods/kernel/registration.d.ts +4 -0
- package/dist/core/mods/kernel/registration.js +3 -0
- package/dist/core/mods/lifecycle-stations.d.ts +41 -0
- package/dist/core/mods/lifecycle-stations.js +35 -0
- package/dist/core/mods/stations.d.ts +73 -60
- package/dist/core/mods/stations.js +64 -40
- package/dist/core/mods/tool-call.d.ts +10 -4
- package/dist/core/mods/tool-call.js +28 -12
- package/dist/core/mounted-mcp.d.ts +5 -0
- package/dist/core/mounted-mcp.js +2 -2
- package/dist/core/namespaced-rule-name.d.ts +7 -1
- package/dist/core/namespaced-rule-name.js +13 -2
- package/dist/core/oracle-isolation.js +1 -1
- package/dist/core/own-property-receipt.d.ts +3 -0
- package/dist/core/own-property-receipt.js +3 -0
- package/dist/core/parent-spec-seat.d.ts +8 -3
- package/dist/core/parent-spec-seat.js +2 -0
- package/dist/core/park-selfcheck.js +14 -8
- package/dist/core/peer-seat.d.ts +133 -16
- package/dist/core/peer-seat.js +319 -42
- package/dist/core/permission-rule-consent.d.ts +0 -21
- package/dist/core/permission-rule-consent.js +11 -6
- package/dist/core/permission-rule-model.d.ts +20 -2
- package/dist/core/permission-rule-model.js +8 -7
- package/dist/core/present-plan-tool.d.ts +11 -3
- package/dist/core/present-plan-tool.js +2 -2
- package/dist/core/protocol-http-auth.d.ts +14 -2
- package/dist/core/protocol-http-auth.js +16 -7
- package/dist/core/read-face-seats.d.ts +7 -5
- package/dist/core/read-face-seats.js +4 -1
- package/dist/core/redaction-marks.d.ts +4 -3
- package/dist/core/redaction-marks.js +2 -2
- package/dist/core/remote-env.d.ts +146 -98
- package/dist/core/remote-env.js +113 -14
- package/dist/core/resume-startup-cause.js +1 -0
- package/dist/core/retention.js +37 -12
- package/dist/core/retired-keys.d.ts +6 -1
- package/dist/core/retired-keys.js +4 -1
- package/dist/core/rewrite-rejudge.d.ts +13 -5
- package/dist/core/rewrite-rejudge.js +9 -5
- package/dist/core/roles.d.ts +69 -3
- package/dist/core/roles.js +167 -80
- package/dist/core/rule-owner.d.ts +3 -0
- package/dist/core/runner/announce-once-ledger.d.ts +5 -4
- package/dist/core/runner/announce-once-ledger.js +4 -2
- package/dist/core/runner/assemble-result.d.ts +0 -5
- package/dist/core/runner/assemble-result.js +0 -1
- package/dist/core/runner/call-hook-stations.d.ts +17 -10
- package/dist/core/runner/call-hook-stations.js +23 -12
- package/dist/core/runner/child-tree.d.ts +7 -8
- package/dist/core/runner/child-tree.js +6 -6
- package/dist/core/runner/classifier-ladder.d.ts +10 -2
- package/dist/core/runner/classifier-ladder.js +39 -8
- package/dist/core/runner/construction-doors.js +5 -0
- package/dist/core/runner/contracts.d.ts +82 -57
- package/dist/core/runner/credential-origin-seat.js +4 -3
- package/dist/core/runner/cross-boundary-lane.d.ts +3 -5
- package/dist/core/runner/cross-boundary-lane.js +11 -2
- package/dist/core/runner/cwd-alignment-probe.d.ts +20 -0
- package/dist/core/runner/cwd-alignment-probe.js +21 -0
- package/dist/core/runner/decide-continuation.d.ts +2 -2
- package/dist/core/runner/env-capability-census.d.ts +15 -20
- package/dist/core/runner/env-capability-census.js +25 -34
- package/dist/core/runner/file-history-request.d.ts +2 -2
- package/dist/core/runner/file-history-request.js +0 -8
- package/dist/core/runner/gate-exit.d.ts +87 -11
- package/dist/core/runner/gate-exit.js +30 -8
- package/dist/core/runner/git-status-frame.d.ts +5 -2
- package/dist/core/runner/git-status-frame.js +3 -4
- package/dist/core/runner/image-removed-seat.d.ts +12 -0
- package/dist/core/runner/image-removed-seat.js +19 -0
- package/dist/core/runner/image.d.ts +7 -2
- package/dist/core/runner/image.js +14 -8
- package/dist/core/runner/inline-image.d.ts +10 -8
- package/dist/core/runner/inline-image.js +11 -9
- package/dist/core/runner/memory-consolidation-driver.js +5 -5
- package/dist/core/runner/park-commit.d.ts +1 -1
- package/dist/core/runner/park-commit.js +3 -0
- package/dist/core/runner/permission-rule-lanes.js +1 -1
- package/dist/core/runner/prepare-ask-lane.d.ts +1 -1
- package/dist/core/runner/prepare-ask-lane.js +2 -1
- package/dist/core/runner/prepare-boundary-parks.d.ts +2 -2
- package/dist/core/runner/prepare-boundary-parks.js +5 -5
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +7 -5
- package/dist/core/runner/prepare-caps-and-workflow.js +6 -3
- package/dist/core/runner/prepare-config-doors.d.ts +6 -1
- package/dist/core/runner/prepare-config-doors.js +16 -9
- package/dist/core/runner/prepare-context-lane.js +2 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +9 -3
- package/dist/core/runner/prepare-delegation-surface.js +5 -4
- package/dist/core/runner/prepare-file-history.d.ts +10 -12
- package/dist/core/runner/prepare-file-history.js +3 -12
- package/dist/core/runner/prepare-gate-stations.d.ts +4 -3
- package/dist/core/runner/prepare-gate-stations.js +4 -3
- package/dist/core/runner/prepare-hands-readface.d.ts +7 -1
- package/dist/core/runner/prepare-hands-readface.js +19 -6
- package/dist/core/runner/prepare-inherited-gate.d.ts +6 -7
- package/dist/core/runner/prepare-inherited-gate.js +22 -31
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-memory.d.ts +2 -2
- package/dist/core/runner/prepare-memory.js +12 -19
- package/dist/core/runner/prepare-park-ask.d.ts +4 -6
- package/dist/core/runner/prepare-park-ask.js +5 -9
- package/dist/core/runner/prepare-policy-chain.d.ts +8 -7
- package/dist/core/runner/prepare-policy-chain.js +136 -121
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-project-context.js +10 -7
- package/dist/core/runner/prepare-prompt-inputs.d.ts +5 -2
- package/dist/core/runner/prepare-prompt-inputs.js +10 -20
- package/dist/core/runner/prepare-protocol-tools.d.ts +5 -3
- package/dist/core/runner/prepare-protocol-tools.js +17 -2
- package/dist/core/runner/prepare-run-refs.d.ts +2 -3
- package/dist/core/runner/prepare-run-refs.js +4 -1
- package/dist/core/runner/prepare-suspend-saga.d.ts +0 -2
- package/dist/core/runner/prepare-suspend-saga.js +5 -7
- package/dist/core/runner/prepare-task.js +44 -28
- package/dist/core/runner/prepare-turn-wiring.d.ts +2 -0
- package/dist/core/runner/prepare-turn-wiring.js +7 -2
- package/dist/core/runner/prepare-wiring-manifest.d.ts +5 -4
- package/dist/core/runner/prepare-wiring-manifest.js +34 -19
- package/dist/core/runner/prepare-workspace-restore.js +3 -3
- package/dist/core/runner/reply-pricing.d.ts +30 -0
- package/dist/core/runner/reply-pricing.js +19 -0
- package/dist/core/runner/resume-admission.js +4 -2
- package/dist/core/runner/resume-apply.js +6 -1
- package/dist/core/runner/resume-checkpoint-screen.js +4 -4
- package/dist/core/runner/resume-policy-outcome.js +5 -5
- package/dist/core/runner/retired-runner-deps.js +4 -1
- package/dist/core/runner/role-seat-defaulted.d.ts +44 -0
- package/dist/core/runner/role-seat-defaulted.js +40 -0
- package/dist/core/runner/run-attachment-seats.js +3 -3
- package/dist/core/runner/run-brain-sinks.js +3 -0
- package/dist/core/runner/run-git-lane.d.ts +3 -1
- package/dist/core/runner/run-git-lane.js +1 -1
- package/dist/core/runner/run-harness-handlers.d.ts +3 -1
- package/dist/core/runner/run-harness-handlers.js +3 -1
- package/dist/core/runner/run-identity-wiring.d.ts +2 -5
- package/dist/core/runner/run-identity-wiring.js +6 -5
- package/dist/core/runner/run-leg.d.ts +2 -0
- package/dist/core/runner/run-leg.js +63 -56
- package/dist/core/runner/run-notification-lane.d.ts +3 -1
- package/dist/core/runner/run-notification-lane.js +16 -10
- package/dist/core/runner/run-settle-and-teardown.js +5 -1
- package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
- package/dist/core/runner/run-stop-and-final-verify.js +14 -6
- package/dist/core/runner/run-terminal-adoption.d.ts +2 -5
- package/dist/core/runner/run-terminal-adoption.js +9 -3
- package/dist/core/runner/run-turn-boundary.js +89 -77
- package/dist/core/runner/runtask.d.ts +8 -5
- package/dist/core/runner/runtask.js +21 -13
- package/dist/core/runner/side-call-account.d.ts +1 -1
- package/dist/core/runner/side-call-account.js +3 -18
- package/dist/core/runner/skills-seat.js +2 -2
- package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
- package/dist/core/runner/sub-agent-deny-lists.js +20 -7
- package/dist/core/runner/synthetic-tools.js +2 -2
- package/dist/core/runner/tool-disclosure.js +0 -2
- package/dist/core/runner/tool-end-body.js +2 -2
- package/dist/core/runner/tool-face-overlay.d.ts +1 -1
- package/dist/core/runner/tool-face-overlay.js +26 -19
- package/dist/core/runner/tool-occurrence.d.ts +1 -1
- package/dist/core/runner/tool-occurrence.js +2 -2
- package/dist/core/runner/tool-result-media-seat.d.ts +9 -1
- package/dist/core/runner/tool-result-media-seat.js +17 -1
- package/dist/core/runner/turn-attachments.d.ts +29 -27
- package/dist/core/runner/turn-attachments.js +27 -42
- package/dist/core/runner-deps.d.ts +32 -19
- package/dist/core/secret-env.d.ts +35 -4
- package/dist/core/secret-env.js +65 -3
- package/dist/core/sensitive-path-policy.js +3 -3
- package/dist/core/session-policy-store.d.ts +12 -3
- package/dist/core/session-policy-store.js +29 -10
- package/dist/core/session-store.d.ts +5 -7
- package/dist/core/session-store.js +50 -11
- package/dist/core/side-query.d.ts +11 -1
- package/dist/core/side-query.js +9 -0
- package/dist/core/skill-grant-binding.d.ts +31 -2
- package/dist/core/skill-grant-binding.js +31 -1
- package/dist/core/skill-grant.d.ts +17 -5
- package/dist/core/skill-grant.js +24 -6
- package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +3 -2
- package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/tool-result-store-contract.js +37 -0
- package/dist/core/stub-env.d.ts +5 -5
- package/dist/core/stub-env.js +11 -1
- package/dist/core/swappable-deps.d.ts +17 -43
- package/dist/core/swappable-deps.js +15 -5
- package/dist/core/synthetic-read-verdict.d.ts +1 -1
- package/dist/core/synthetic-read-verdict.js +2 -1
- package/dist/core/task-event.d.ts +50 -10
- package/dist/core/task-notification.d.ts +88 -5
- package/dist/core/task-notification.js +146 -17
- package/dist/core/task-registry-agent.d.ts +18 -12
- package/dist/core/task-registry-agent.js +19 -6
- package/dist/core/task-registry-monitor.d.ts +7 -0
- package/dist/core/task-registry-monitor.js +28 -1
- package/dist/core/task-registry-shared.d.ts +43 -3
- package/dist/core/task-registry-shared.js +21 -7
- package/dist/core/task-registry-workflow.js +1 -1
- package/dist/core/task-registry.d.ts +50 -35
- package/dist/core/task-registry.js +64 -23
- package/dist/core/task-result.d.ts +3 -12
- package/dist/core/task-spec.d.ts +15 -7
- package/dist/core/task-stream.d.ts +1 -1
- package/dist/core/terminal-cause.d.ts +10 -0
- package/dist/core/tool-catalog-entries.js +1 -1
- package/dist/core/tool-check-reading.d.ts +1 -0
- package/dist/core/tool-check-reading.js +3 -3
- package/dist/core/tool-face-reader.d.ts +7 -6
- package/dist/core/tool-face-reader.js +4 -3
- package/dist/core/tool-name-aliases.d.ts +19 -0
- package/dist/core/tool-name-aliases.js +54 -2
- package/dist/core/tool-policy.d.ts +21 -4
- package/dist/core/tool-policy.js +1 -1
- package/dist/core/tool-registry.d.ts +5 -5
- package/dist/core/tool-registry.js +2 -2
- package/dist/core/tool-result-store.d.ts +88 -5
- package/dist/core/tool-result-store.js +51 -12
- package/dist/core/tool-roster.d.ts +112 -5
- package/dist/core/tool-roster.js +42 -1
- package/dist/core/tool-spec.d.ts +23 -5
- package/dist/core/trace.d.ts +0 -1
- package/dist/core/types.d.ts +5 -5
- package/dist/core/types.js +2 -2
- package/dist/core/untrusted-text.js +1 -1
- package/dist/core/user-attachment.d.ts +10 -5
- package/dist/core/user-attachment.js +15 -7
- package/dist/core/wiring-manifest.d.ts +6 -3
- package/dist/engine/compaction/compaction.js +29 -3
- package/dist/engine/execution-env/node-execution-env.d.ts +11 -5
- package/dist/engine/execution-env/node-execution-env.js +21 -13
- package/dist/engine/harness/agent-harness.d.ts +26 -3
- package/dist/engine/harness/agent-harness.js +49 -16
- package/dist/engine/harness/messages.d.ts +3 -1
- package/dist/engine/harness/messages.js +3 -2
- package/dist/engine/harness/types.d.ts +119 -28
- package/dist/engine/llm/rejected-images.d.ts +46 -0
- package/dist/engine/llm/rejected-images.js +54 -0
- package/dist/engine/llm/tool-turns.d.ts +2 -1
- package/dist/engine/llm/types.d.ts +18 -7
- package/dist/engine/loop/agent-loop.d.ts +20 -12
- package/dist/engine/loop/agent-loop.js +205 -36
- package/dist/engine/loop/types.d.ts +12 -3
- package/dist/engine/lsp/node-lsp-manager.d.ts +3 -3
- package/dist/engine/lsp/node-lsp-manager.js +32 -13
- package/dist/engine/session/path-to-root.d.ts +38 -0
- package/dist/engine/session/path-to-root.js +39 -0
- package/dist/engine/session/storage-base.js +4 -21
- package/dist/index.d.ts +35 -21
- package/dist/index.js +26 -17
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +1 -0
- package/dist/internal/llm.d.ts +1 -0
- package/dist/orchestration/run-workflow-tool.d.ts +9 -3
- package/dist/orchestration/run-workflow-tool.js +59 -29
- package/dist/orchestration/workflow-governance.d.ts +1 -1
- package/dist/orchestration/workflow-governance.js +2 -1
- package/dist/orchestration/workflow-observe.d.ts +17 -1
- package/dist/orchestration/workflow-observe.js +20 -0
- package/dist/orchestration/workflow-types.d.ts +32 -7
- package/dist/orchestration/workflow.d.ts +4 -0
- package/dist/orchestration/workflow.js +762 -491
- package/dist/prompts/default.d.ts +1 -10
- package/dist/prompts/default.js +0 -2
- package/dist/shell/counting-pass.d.ts +50 -0
- package/dist/shell/counting-pass.js +502 -0
- package/dist/shell/lex.d.ts +4 -2
- package/dist/shell/lex.js +93 -34
- package/dist/shell/shell-words.d.ts +1 -1
- package/dist/shell/shell-words.js +7 -6
- package/dist/stores/file/background-agent-store.d.ts +1 -1
- package/dist/stores/file/background-agent-store.js +3 -1
- package/dist/stores/file/checkpoint-store.d.ts +127 -2
- package/dist/stores/file/checkpoint-store.js +19 -14
- package/dist/stores/file/file-history-store.d.ts +1 -1
- package/dist/stores/file/file-history-store.js +3 -1
- package/dist/stores/file/index.d.ts +4 -3
- package/dist/stores/file/index.js +17 -8
- package/dist/stores/file/mailbox-store.d.ts +1 -1
- package/dist/stores/file/mailbox-store.js +9 -11
- package/dist/stores/file/memory-store.d.ts +1 -1
- package/dist/stores/file/memory-store.js +3 -1
- package/dist/stores/file/session-policy-store.d.ts +1 -1
- package/dist/stores/file/session-policy-store.js +3 -1
- package/dist/stores/file/session-store.d.ts +1 -1
- package/dist/stores/file/session-store.js +3 -1
- package/dist/stores/file/shared-ledger.d.ts +26 -0
- package/dist/stores/file/shared-ledger.js +38 -9
- package/dist/stores/file/tool-result-store.d.ts +20 -2
- package/dist/stores/file/tool-result-store.js +74 -6
- package/dist/stores/file/usage-window-store.d.ts +1 -1
- package/dist/stores/file/usage-window-store.js +3 -1
- package/dist/stores/file/workflow-journal-store.d.ts +1 -11
- package/dist/stores/file/workflow-journal-store.js +3 -2
- package/dist/tools/fs/containment-face.d.ts +5 -0
- package/dist/tools/fs/encoding.d.ts +13 -4
- package/dist/tools/fs/encoding.js +17 -2
- package/dist/tools/fs/fs-bash-background-text.d.ts +7 -0
- package/dist/tools/fs/fs-bash-background-text.js +1 -0
- package/dist/tools/fs/fs-bash.d.ts +14 -4
- package/dist/tools/fs/fs-bash.js +29 -35
- package/dist/tools/fs/fs-pdf.d.ts +2 -2
- package/dist/tools/fs/fs-pdf.js +26 -21
- package/dist/tools/fs/fs-read.d.ts +5 -4
- package/dist/tools/fs/fs-read.js +35 -18
- package/dist/tools/fs/fs-search-tools.js +4 -1
- package/dist/tools/fs/fs-shared.d.ts +11 -13
- package/dist/tools/fs/fs-shared.js +11 -7
- package/dist/tools/fs/fs-write.js +5 -5
- package/dist/tools/fs/index.d.ts +14 -8
- package/dist/tools/fs/index.js +13 -5
- package/dist/tools/fs/program-read-model.d.ts +13 -0
- package/dist/tools/fs/program-read-model.js +15 -0
- package/dist/tools/fs/program-read-model.rows.js +1 -1
- package/dist/tools/fs/read-deny.d.ts +13 -10
- package/dist/tools/fs/read-deny.js +25 -5
- package/dist/tools/fs/read-floor.d.ts +62 -0
- package/dist/tools/fs/read-floor.js +58 -0
- package/dist/tools/fs/removal-targets.d.ts +9 -4
- package/dist/tools/fs/removal-targets.js +17 -9
- package/dist/tools/fs/search.d.ts +3 -3
- package/dist/tools/fs/search.js +4 -4
- package/dist/tools/fs/shell-read-check.d.ts +1 -1
- package/dist/tools/fs/shell-read-check.js +2 -1
- package/dist/tools/fs/shell-read-judge.d.ts +16 -8
- package/dist/tools/fs/shell-read-judge.js +10 -6
- package/dist/tools/fs/shell-read-plan.d.ts +6 -1
- package/dist/tools/fs/shell-read-plan.js +22 -15
- package/dist/tools/fs/shell-read-start.js +1 -0
- package/dist/tools/fs/shell-reentry-text.d.ts +15 -1
- package/dist/tools/fs/shell-reentry-text.js +25 -3
- package/dist/tools/monitor.d.ts +9 -4
- package/dist/tools/monitor.js +17 -8
- package/dist/tools/scheduler-tools.js +42 -4
- package/dist/tools/web.d.ts +0 -10
- package/dist/tools/web.js +1 -4
- package/package.json +5 -2
- package/test/export-surface.snapshot.json +161 -21
- package/wire-changes/core-stores-sql@7.59.0.json +29 -0
- package/wire-changes/core-stores-sql@7.60.0.json +30 -0
- package/wire-changes/core@7.59.0.json +2459 -0
- package/wire-changes/core@7.60.0.json +3274 -0
- package/wire-changes/mods-kernel@7.59.0.json +29 -0
- package/wire-changes/mods-kernel@7.60.0.json +62 -0
- package/wire-changes/primitives@7.59.0.json +29 -0
- package/wire-changes/primitives@7.60.0.json +30 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createAssistantMessageEventStream, ensureToolTurnInvariants, findToolByName, snapshotActorAssertion, stripEngineMetadata, userAttachmentOf } from "../llm/index.js";
|
|
2
|
+
import { imageRefusalAt, isImageRefusal, removeRejectedImages } from "../llm/rejected-images.js";
|
|
2
3
|
import { finalizeToolOutcome, isBatchSafeToolCall, runAgentLoop, runToolCall } from "../loop/agent-loop.js";
|
|
3
4
|
import { resolveAgentCoreStreamFn } from "../loop/runtime-deps.js";
|
|
4
5
|
import { normalizeEngineSegments } from "../../core/untrusted-text.js";
|
|
@@ -224,12 +225,26 @@ export class AgentHarness {
|
|
|
224
225
|
thinkingLevel;
|
|
225
226
|
onUndrainedEngineNotes;
|
|
226
227
|
onToolTurnRepaired;
|
|
228
|
+
onImagesRemoved;
|
|
229
|
+
priorImageRefusals;
|
|
227
230
|
runHistory;
|
|
228
231
|
onUndrainedUserInputs;
|
|
229
232
|
onEngineNoteConsumed;
|
|
230
233
|
onUserInputConsumed;
|
|
231
234
|
onFrameCommitted;
|
|
232
235
|
engineInjectionsHeld;
|
|
236
|
+
imageRefusalView(messages) {
|
|
237
|
+
const view = removeRejectedImages(messages);
|
|
238
|
+
const met = view.removals.filter((r) => this.priorImageRefusals?.has(r.refusalAt) !== true);
|
|
239
|
+
if (met.length > 0) {
|
|
240
|
+
try {
|
|
241
|
+
this.onImagesRemoved?.(met);
|
|
242
|
+
}
|
|
243
|
+
catch {
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return view.messages;
|
|
247
|
+
}
|
|
233
248
|
holdToolTurnLaw(messages) {
|
|
234
249
|
const view = ensureToolTurnInvariants(messages, this.runHistory);
|
|
235
250
|
if (view.repairs.length > 0) {
|
|
@@ -264,13 +279,17 @@ export class AgentHarness {
|
|
|
264
279
|
}
|
|
265
280
|
}
|
|
266
281
|
}
|
|
267
|
-
|
|
268
|
-
const inFlight = (lane) => this.drainedPendingInjection.filter((m) => !engineAuthoredInjections.has(m) && drainedFromLane.get(m) === lane)
|
|
282
|
+
pendingUserInputFramesByLane() {
|
|
283
|
+
const inFlight = (lane) => this.drainedPendingInjection.filter((m) => !engineAuthoredInjections.has(m) && drainedFromLane.get(m) === lane);
|
|
269
284
|
return {
|
|
270
|
-
steer: this.steerQueue.filter((m) => !engineAuthoredInjections.has(m))
|
|
271
|
-
followUp: this.followUpQueue.filter((m) => !engineAuthoredInjections.has(m))
|
|
285
|
+
steer: [...inFlight("steer"), ...this.steerQueue.filter((m) => !engineAuthoredInjections.has(m))],
|
|
286
|
+
followUp: [...inFlight("followUp"), ...this.followUpQueue.filter((m) => !engineAuthoredInjections.has(m))],
|
|
272
287
|
};
|
|
273
288
|
}
|
|
289
|
+
pendingUserInputsByLane() {
|
|
290
|
+
const frames = this.pendingUserInputFramesByLane();
|
|
291
|
+
return { steer: frames.steer.length, followUp: frames.followUp.length };
|
|
292
|
+
}
|
|
274
293
|
hasPendingUserInput() {
|
|
275
294
|
if (this.aborting)
|
|
276
295
|
return false;
|
|
@@ -280,7 +299,12 @@ export class AgentHarness {
|
|
|
280
299
|
const counts = this.pendingUserInputsByLane();
|
|
281
300
|
if ((counts.steer > 0 || counts.followUp > 0) && this.onUndrainedUserInputs) {
|
|
282
301
|
try {
|
|
283
|
-
this.
|
|
302
|
+
const frames = this.pendingUserInputFramesByLane();
|
|
303
|
+
const records = (lane) => lane.flatMap((m) => {
|
|
304
|
+
const r = userInputParkRecords.get(m);
|
|
305
|
+
return r !== undefined ? [r] : [];
|
|
306
|
+
});
|
|
307
|
+
this.onUndrainedUserInputs(counts, { steer: records(frames.steer), followUp: records(frames.followUp) });
|
|
284
308
|
}
|
|
285
309
|
catch {
|
|
286
310
|
}
|
|
@@ -305,7 +329,7 @@ export class AgentHarness {
|
|
|
305
329
|
activeRun;
|
|
306
330
|
loopTrace;
|
|
307
331
|
onToolInputValidationFault;
|
|
308
|
-
|
|
332
|
+
toolResultMedia;
|
|
309
333
|
resilience;
|
|
310
334
|
maxToolConcurrency;
|
|
311
335
|
streamingToolExecution;
|
|
@@ -342,7 +366,11 @@ export class AgentHarness {
|
|
|
342
366
|
this.executeTool = options.executeTool;
|
|
343
367
|
this.loopTrace = options.loopTrace;
|
|
344
368
|
this.onToolInputValidationFault = options.onToolInputValidationFault;
|
|
345
|
-
this.
|
|
369
|
+
this.toolResultMedia = {
|
|
370
|
+
...(options.imageProcessor !== undefined ? { imageProcessor: options.imageProcessor } : {}),
|
|
371
|
+
...(options.onToolMediaRefused !== undefined ? { onToolMediaRefused: options.onToolMediaRefused } : {}),
|
|
372
|
+
...(options.onImageUnprocessed !== undefined ? { onImageUnprocessed: options.onImageUnprocessed } : {}),
|
|
373
|
+
};
|
|
346
374
|
this.resilience = options.resilience;
|
|
347
375
|
this.maxToolConcurrency = options.maxToolConcurrency;
|
|
348
376
|
this.streamingToolExecution = options.streamingToolExecution;
|
|
@@ -661,7 +689,7 @@ export class AgentHarness {
|
|
|
661
689
|
...(this.abortResultDetails !== undefined ? { abortResultDetails: this.abortResultDetails } : {}),
|
|
662
690
|
...(this.executeTool !== undefined ? { executeTool: this.executeTool } : {}),
|
|
663
691
|
...(this.onToolInputValidationFault !== undefined ? { onToolInputValidationFault: this.onToolInputValidationFault } : {}),
|
|
664
|
-
...
|
|
692
|
+
...this.toolResultMedia,
|
|
665
693
|
...(this.resilience !== undefined ? { resilience: this.resilience } : {}),
|
|
666
694
|
...(this.maxToolConcurrency !== undefined ? { maxToolConcurrency: this.maxToolConcurrency } : {}),
|
|
667
695
|
...(this.streamingToolExecution === true && (this.getHandlers("tool_call")?.size ?? 0) === 0
|
|
@@ -671,17 +699,19 @@ export class AgentHarness {
|
|
|
671
699
|
shouldStopAfterTurn: () => this.consultStopLatch("post_turn"),
|
|
672
700
|
shouldHaltBeforeTurn: () => this.consultStopLatch("pre_turn"),
|
|
673
701
|
transformContext: async (messages, signal) => {
|
|
674
|
-
const
|
|
702
|
+
const view = this.imageRefusalView(messages);
|
|
703
|
+
const result = await this.emitHook({ type: "context", messages: [...view], ...(signal !== undefined ? { signal } : {}) });
|
|
675
704
|
if (result?.adoptSessionRebuild !== true) {
|
|
676
|
-
return result?.messages ??
|
|
705
|
+
return result?.messages ?? view;
|
|
677
706
|
}
|
|
678
707
|
await this.flushPendingSessionWrites();
|
|
679
708
|
const nextTurnState = await this.createTurnState();
|
|
680
709
|
setTurnState(nextTurnState);
|
|
681
710
|
const rebuiltContext = this.createContext(nextTurnState, runPromptOverride);
|
|
682
|
-
const
|
|
711
|
+
const rebuiltView = this.imageRefusalView(rebuiltContext.messages);
|
|
712
|
+
const recheck = await this.emitHook({ type: "context", messages: [...rebuiltView], ...(signal !== undefined ? { signal } : {}), recheck: true });
|
|
683
713
|
return {
|
|
684
|
-
messages: recheck?.messages ??
|
|
714
|
+
messages: recheck?.messages ?? rebuiltView,
|
|
685
715
|
adoptedContext: {
|
|
686
716
|
messages: rebuiltContext.messages,
|
|
687
717
|
systemPrompt: rebuiltContext.systemPrompt,
|
|
@@ -830,7 +860,7 @@ export class AgentHarness {
|
|
|
830
860
|
usageMissing: true,
|
|
831
861
|
stopReason: "error",
|
|
832
862
|
...(typeof errorMessage === "string" ? { errorMessage } : {}),
|
|
833
|
-
...(errorKind === "length_empty" || errorKind === "degenerate" || errorKind === "input_too_long" ? { errorKind } : {}),
|
|
863
|
+
...(errorKind === "length_empty" || errorKind === "degenerate" || errorKind === "input_too_long" || errorKind === "image_unprocessable" ? { errorKind } : {}),
|
|
834
864
|
timestamp: failure.timestamp,
|
|
835
865
|
};
|
|
836
866
|
try {
|
|
@@ -920,6 +950,7 @@ export class AgentHarness {
|
|
|
920
950
|
this.promptReceipt = options?.onCommitted !== undefined ? { message: userMessage, commit: options.onCommitted } : undefined;
|
|
921
951
|
const trailingMessages = (options?.trailing ?? []).map(createTrailingMessage);
|
|
922
952
|
this.runHistory = new WeakSet(turnState.messages.filter((m) => m.role === "assistant"));
|
|
953
|
+
this.priorImageRefusals = new Set(turnState.messages.filter(isImageRefusal).map(imageRefusalAt));
|
|
923
954
|
const beforeResult = await this.emitHook({
|
|
924
955
|
type: "before_agent_start",
|
|
925
956
|
prompt: text,
|
|
@@ -1280,7 +1311,7 @@ export class AgentHarness {
|
|
|
1280
1311
|
return patch;
|
|
1281
1312
|
}
|
|
1282
1313
|
finalizeToolCall(toolCall, args, executed) {
|
|
1283
|
-
return finalizeToolOutcome(toolCall, executed, (result, isError) => this.afterToolCallHook(toolCall, args, result, isError), this.
|
|
1314
|
+
return finalizeToolOutcome(toolCall, executed, (result, isError) => this.afterToolCallHook(toolCall, args, result, isError), this.toolResultMedia);
|
|
1284
1315
|
}
|
|
1285
1316
|
async callTool(toolCall, signal, admit) {
|
|
1286
1317
|
const run = this.activeRun;
|
|
@@ -1430,7 +1461,7 @@ export class AgentHarness {
|
|
|
1430
1461
|
return out;
|
|
1431
1462
|
}
|
|
1432
1463
|
dropParkedUserInputs(records) {
|
|
1433
|
-
const dropped = { steer: 0, followUp: 0 };
|
|
1464
|
+
const dropped = { steer: 0, followUp: 0, records: { steer: [], followUp: [] } };
|
|
1434
1465
|
if (records.length === 0)
|
|
1435
1466
|
return dropped;
|
|
1436
1467
|
const migrated = new Set(records);
|
|
@@ -1445,8 +1476,10 @@ export class AgentHarness {
|
|
|
1445
1476
|
userInputParkRecords.delete(frame);
|
|
1446
1477
|
q.splice(i, 1);
|
|
1447
1478
|
i--;
|
|
1448
|
-
if (lane !== undefined)
|
|
1479
|
+
if (lane !== undefined) {
|
|
1449
1480
|
dropped[lane] += 1;
|
|
1481
|
+
dropped.records[lane].push(record);
|
|
1482
|
+
}
|
|
1450
1483
|
}
|
|
1451
1484
|
}
|
|
1452
1485
|
return dropped;
|
|
@@ -26,5 +26,7 @@ export declare const NORMALIZED_CONTENT_PREFIX = "[invalid content block normali
|
|
|
26
26
|
* `convertToLlm` (provider leg) and `serializeConversation` (compaction leg) — one helper, two mouths.
|
|
27
27
|
*/
|
|
28
28
|
export declare function normalizeLlmMessageContent<T extends Message>(message: T): T;
|
|
29
|
-
/** Convert harness transcript messages into the LLM-facing message sequence.
|
|
29
|
+
/** Convert harness transcript messages into the LLM-facing message sequence. A provider's image refusal (live or its
|
|
30
|
+
* record) removes the images it refused ({@link removeRejectedImages}) for every leg — provider and compaction alike;
|
|
31
|
+
* the request leg applies it earlier, where its view starts, so there this pass is the identity. */
|
|
30
32
|
export declare function convertToLlm(messages: AgentMessage[]): Message[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isSyntheticApiErrorMessage } from "./types.js";
|
|
2
|
+
import { removeRejectedImages } from "../llm/rejected-images.js";
|
|
2
3
|
import { parseSessionTimestampMs, requireSessionTimestampMs } from "../session/timestamps.js";
|
|
3
4
|
export function asAgentMessage(message) {
|
|
4
5
|
return message;
|
|
@@ -107,8 +108,8 @@ export function normalizeLlmMessageContent(message) {
|
|
|
107
108
|
return changed ? { ...message, content: blocks } : message;
|
|
108
109
|
}
|
|
109
110
|
export function convertToLlm(messages) {
|
|
110
|
-
return messages
|
|
111
|
-
.map((m) => {
|
|
111
|
+
return removeRejectedImages(messages)
|
|
112
|
+
.messages.map((m) => {
|
|
112
113
|
const message = m;
|
|
113
114
|
switch (message.role) {
|
|
114
115
|
case "bashExecution":
|
|
@@ -340,6 +340,15 @@ export interface ExecutionEnvExecOptions {
|
|
|
340
340
|
* behavior. Envs without detach support ignore this (opt-in, backward compatible).
|
|
341
341
|
*/
|
|
342
342
|
autoBackgroundOnTimeout?: boolean;
|
|
343
|
+
/** VENDORED EDIT (the byte floor) — the read-deny table in force for the call starting this command ({@link ReadFloor}); what its processes OPEN is the environment's to keep,
|
|
344
|
+
* and whether it keeps it is its declaration ({@link ExecutionEnvCapabilities.keepsReadFloor}). Carried by every start whose output the engine relays to the model. */
|
|
345
|
+
readFloor?: ReadFloor;
|
|
346
|
+
}
|
|
347
|
+
/** The read-deny table one command start carries ({@link ExecutionEnvExecOptions.readFloor}); what an environment keeps of it is INTEGRATION-CORE §11.1. */
|
|
348
|
+
export interface ReadFloor {
|
|
349
|
+
readonly rows: readonly string[];
|
|
350
|
+
/** The row denying an absolute path in this environment's namespace, or `null`: the read station's own judgment. Never throws. */
|
|
351
|
+
denies(absolutePath: string): string | null;
|
|
343
352
|
}
|
|
344
353
|
/**
|
|
345
354
|
* Filesystem capability used by the harness.
|
|
@@ -482,8 +491,114 @@ export interface Shell {
|
|
|
482
491
|
/** Release shell resources. Must be best-effort and must not throw or reject. */
|
|
483
492
|
cleanup(): Promise<void>;
|
|
484
493
|
}
|
|
494
|
+
/**
|
|
495
|
+
* #2891 — what an execution environment can do and where its actions land: the ONE place each of these questions is
|
|
496
|
+
* answered, declared by the ADAPTER on every environment ({@link ExecutionEnv.capabilities}), local or remote.
|
|
497
|
+
*
|
|
498
|
+
* Every key is REQUIRED and has no default reading: for each one, either answer an absent value could be given is
|
|
499
|
+
* wrong for some environment, so an adapter states it. A value that is absent, not a boolean, or cannot be received (a
|
|
500
|
+
* throwing getter, a Proxy — a JS adapter's block) — and a member outside the eight keys — is announced once per run at
|
|
501
|
+
* the admission point (`config.execution_env_capability_invalid`, `detail.key` naming it, or `capabilities` for a block
|
|
502
|
+
* that is no object or cannot be received), and each reader takes that key's SAFE side, written beside the readers
|
|
503
|
+
* (`UNDECLARED_CAPABILITY_READING`, `src/core/remote-env.ts`). Every key is read through its one reader there.
|
|
504
|
+
*
|
|
505
|
+
* What an INTERFACE answers is a different question: whether a group of methods can be called (the remote seam's
|
|
506
|
+
* lifecycle, a background shell, a scheduler, an optional filesystem method). Implementing a group of methods never
|
|
507
|
+
* declares a capability, and a capability never stands in for a method.
|
|
508
|
+
*
|
|
509
|
+
* The block is a constant of the adapter: the engine receives it ONCE per environment object (at its first read, a
|
|
510
|
+
* run's admission point) into a frozen copy every reader reads; a later change by the host is never read.
|
|
511
|
+
*/
|
|
512
|
+
export interface ExecutionEnvCapabilities {
|
|
513
|
+
/** True iff the commands run inside a sandbox that IS the security boundary (container, microVM, pod); false for
|
|
514
|
+
* a real target (the engine's own host, an SSH host, a device). Every consumer of a `true` here RELAXES something
|
|
515
|
+
* (autonomy, a policy tier, a containment leg the sandbox is then answerable for), so only the boolean `true`
|
|
516
|
+
* counts. Undeclared ⇒ `false`. Read through `isIsolated`. */
|
|
517
|
+
readonly isolation: boolean;
|
|
518
|
+
/** True iff the environment can be snapshot (`suspendVM`) and restored; false for one that cannot (a local
|
|
519
|
+
* process, an SSH host, a device).
|
|
520
|
+
*
|
|
521
|
+
* ⚠️ LOAD-BEARING INVARIANT: `suspendable: false` on a remote environment also asserts the workspace is
|
|
522
|
+
* EXTERNALLY DURABLE — it persists on the target across the environment object's lifetime (true for SSH hosts and
|
|
523
|
+
* devices). The durable-park-only suspend degrade rests on this: it skips `suspendVM` and trusts the factory to
|
|
524
|
+
* reconnect to the SAME workspace on resume. An adapter for a non-suspendable EPHEMERAL backend (a snapshot-less
|
|
525
|
+
* container torn down with its transport) must NOT be modeled as `suspendable: false` remote — it would silently
|
|
526
|
+
* take the park-only branch and resume onto a fresh empty workspace. Model such a backend as a per-task
|
|
527
|
+
* environment without durable suspend instead (the human gate refuses it), or split this key before building one.
|
|
528
|
+
* Undeclared ⇒ neither suspendable nor parkable. Read through `declaredSuspend` (three states) and `isSuspendable`
|
|
529
|
+
* (a declared `true` with the remote interface and its restore surface). */
|
|
530
|
+
readonly suspendable: boolean;
|
|
531
|
+
/** True iff the commands this environment runs are processes on a table that holds THIS process — the table the
|
|
532
|
+
* engine itself and the processes above it are on, so a kill the model writes there can reach them. `true` for an
|
|
533
|
+
* environment that spawns the commands as this process's own descendants (`NodeExecutionEnv`, a host lane) and for
|
|
534
|
+
* one whose commands run in a PID namespace that contains this process's (the host of the container the engine
|
|
535
|
+
* runs in); `false` only for one whose commands run where this process is not: another machine (SSH host, device,
|
|
536
|
+
* cloud sandbox) or a PID namespace this process is not in (a sandbox container, a pod). Not {@link isolation}: a
|
|
537
|
+
* non-isolated SSH host is a real machine and still another table. The self-preservation guard of the Bash tool
|
|
538
|
+
* asks its question exactly when this is `true`, and does not ask where it is `false`.
|
|
539
|
+
*
|
|
540
|
+
* What a `true` buys is the guard's question exactly as a `NodeExecutionEnv` gets it, limits included: on this
|
|
541
|
+
* process's own table, of the platform's `pgrep`, with the kill's words as written, from this process's own
|
|
542
|
+
* working directory. It is put as for this process's descendants, so for commands on the same table that are not
|
|
543
|
+
* (SSH to `localhost`) BSD's `pgrep` leaves its OWN caller's ancestors out where the real kill would not, and from
|
|
544
|
+
* an enclosing namespace the question sees only this process's namespace, not the ancestors above it.
|
|
545
|
+
*
|
|
546
|
+
* Undeclared ⇒ the guard refuses every pattern kill that needs the question on this environment (`pkill -P $$`
|
|
547
|
+
* runs), naming this declaration. Read through `processTableOf`. */
|
|
548
|
+
readonly sharesProcessTable: boolean;
|
|
549
|
+
/** True iff this environment's {@link FileSystem.canonicalPath} is the AUTHORITY on where a path lands — it
|
|
550
|
+
* answers for the very filesystem the commands run on, so a failure to answer is a failure of the resolver rather
|
|
551
|
+
* than a namespace it cannot see into. A `true` makes the read boundary's execute-time recheck REFUSE a chain its
|
|
552
|
+
* resolver cannot answer at all instead of passing the written spelling through; `false` keeps the lexical
|
|
553
|
+
* verdict for a chain the resolver answers `not_supported` (no file face). A resolver that FAILS (any other
|
|
554
|
+
* non-answer) is a failure either way. `NodeExecutionEnv` declares `true` (its resolver always answers `/`, so the
|
|
555
|
+
* arm has no case to fire on); an environment with no path resolution surface declares `false`. Undeclared ⇒
|
|
556
|
+
* `true` (silence refuses). Read through `canonicalPathIsAuthoritative`. */
|
|
557
|
+
readonly canonicalPathAuthoritative: boolean;
|
|
558
|
+
/** True iff a path this environment names is the same file on the ENGINE HOST's filesystem — the engine may
|
|
559
|
+
* present this environment's cwd as a host path (the workflow workspace observer's `worktreeDir`) and record
|
|
560
|
+
* host-path receipts for it. `true` for `NodeExecutionEnv` and for a host lane that drives the engine's own
|
|
561
|
+
* machine; `false` for an environment whose paths never map onto the host (an in-memory environment, a sandbox
|
|
562
|
+
* or container the host does not mount at the same paths, another machine). Undeclared ⇒ `false`. Read through
|
|
563
|
+
* `pathsAreHostLocal`. */
|
|
564
|
+
readonly hostLocalPaths: boolean;
|
|
565
|
+
/** True iff content produced by THIS environment (every FileSystem / Shell result — stdout, file bytes, listings,
|
|
566
|
+
* names) originates from a target OUTSIDE the deployment's trust boundary (a personal device, an unmanaged host).
|
|
567
|
+
* `true` feeds three existing channels, no new vocabulary:
|
|
568
|
+
* - memory: the run's hand-tool results are treated as external-class content — the session mark
|
|
569
|
+
* (`memory.session_polluted`) and the origin carriage at harvest, via the same fold `execIsExternalContent`
|
|
570
|
+
* upgrades through (this key ORs into that fold for the run);
|
|
571
|
+
* - env facts / prompt renderer: one declarative line disclosing the execution locus and trust posture;
|
|
572
|
+
* - audit: TaskResult / checkpoint carry it implicitly through `WorkspaceHandle{provider, deviceId}`.
|
|
573
|
+
* Suspend / resume: the run-level fold is PRESENCE-persisted on the checkpoint (`CheckpointState.externalContentTarget`,
|
|
574
|
+
* monotonic) and resume joins persisted OR live declaration — a run minted under a declaring adapter never
|
|
575
|
+
* silently downgrades on an undeclaring or older one. ONE declaration, two readers: the content-class fold above
|
|
576
|
+
* (no gate, policy or roster reads that fold) and the cross-boundary taint (it arms the run tree's taint bit; a
|
|
577
|
+
* call's `env` leg is judged by whether the environment THAT CALL reaches declares this, never by the
|
|
578
|
+
* fold). ORTHOGONAL to {@link isolation}: an SSH environment to an organization-managed build host can be
|
|
579
|
+
* non-isolated and still declare `false`. Undeclared ⇒ each consumer's safe side: the content fold reads it as outside,
|
|
580
|
+
* and a call that reaches the environment owes what reaching the target and what leaving it both owe. Read through
|
|
581
|
+
* `targetIsExternal` (three states). */
|
|
582
|
+
readonly externalContentTarget: boolean;
|
|
583
|
+
/** True iff the filesystem and shell faces reach a target. `false` only for a placeholder whose every operation
|
|
584
|
+
* refuses (each filesystem operation `not_supported`, every `exec` `shell_unavailable` — `StubExecutionEnv`, the
|
|
585
|
+
* environment of a run without hands). Undeclared ⇒ no shell face mounts, and the project marker is still read
|
|
586
|
+
* through it, never past its read limits. Read through `performsIo` (three states). */
|
|
587
|
+
readonly io: boolean;
|
|
588
|
+
/** True iff this environment keeps the byte floor a command start carries ({@link ExecutionEnvExecOptions.readFloor}):
|
|
589
|
+
* every path its `denies` answers non-null for stays unreadable to every program the command runs, judged where the
|
|
590
|
+
* environment itself resolves the path — or the environment refuses a start whose whole table it cannot keep
|
|
591
|
+
* (`spawn_error`, naming the row) rather than run with fewer rows (INTEGRATION-CORE §11.1). `false` for an
|
|
592
|
+
* environment that cannot confine a process (`NodeExecutionEnv`, a host lane, an SSH host, a device): a run whose
|
|
593
|
+
* read-deny table is non-empty on such an environment is announced (`config.read_deny_floor_unkept`), or refused
|
|
594
|
+
* at prepare when the deployment sets `RunnerDeps.readDenyFloorRequired`. `StubExecutionEnv` declares `true`:
|
|
595
|
+
* it refuses every start, so no byte can be read through it. Undeclared ⇒ `false`. Read through `keepsReadFloor`. */
|
|
596
|
+
readonly keepsReadFloor: boolean;
|
|
597
|
+
}
|
|
485
598
|
/** Filesystem and process execution environment used by the harness. */
|
|
486
599
|
export interface ExecutionEnv extends FileSystem, Shell {
|
|
600
|
+
/** What this environment can do and where its actions land — {@link ExecutionEnvCapabilities}, every key required. */
|
|
601
|
+
readonly capabilities: ExecutionEnvCapabilities;
|
|
487
602
|
/**
|
|
488
603
|
* design/164 件四 — the environment's PLATFORM LIFETIME in milliseconds: how long this sandbox/VM is
|
|
489
604
|
* allowed to exist before the platform reclaims it, counted from {@link lifetimeStartedAt}. Declared by
|
|
@@ -514,34 +629,6 @@ export interface ExecutionEnv extends FileSystem, Shell {
|
|
|
514
629
|
* mechanism exists to prevent.
|
|
515
630
|
*/
|
|
516
631
|
readonly lifetimeStartedAt?: number;
|
|
517
|
-
/**
|
|
518
|
-
* #211 (design/199 seam) — does this environment's path NAMESPACE live on the CONTROL-PLANE HOST's
|
|
519
|
-
* filesystem? Declared by the ADAPTER: `false` for a virtual/sandboxed env whose paths never map
|
|
520
|
-
* onto the host (an in-memory env, a container the host cannot mount) — consumers that record
|
|
521
|
-
* host-path receipts (the workflow workspace observer's `worktreeDir`) then refuse to present this
|
|
522
|
-
* env's cwd as a host path. Omitted ⇒ the historical structural inference stays in force
|
|
523
|
-
* (isRemoteExecutionEnv shape detection; a plain NodeExecutionEnv is host-local). `true` is a
|
|
524
|
-
* harmless explicit spelling of the local default.
|
|
525
|
-
*/
|
|
526
|
-
readonly hostLocalPaths?: boolean;
|
|
527
|
-
/**
|
|
528
|
-
* design/380 O9 — declared by the ADAPTER: content produced by THIS env (every FileSystem/Shell
|
|
529
|
-
* result — stdout, file bytes, listings, names) originates from a target OUTSIDE the deployment's
|
|
530
|
-
* trust boundary (a personal device, an unmanaged host). Omitted ⇒ historic behavior (trusted-side
|
|
531
|
-
* results). `true` feeds three EXISTING channels, no new vocabulary:
|
|
532
|
-
* - memory: the run's hand-tool results are treated as external-class content — the session mark
|
|
533
|
-
* (`memory.session_polluted`) + the design/336 origin carriage at harvest, via the same fold
|
|
534
|
-
* `execIsExternalContent` upgrades through (this flag ORs into that fold for the run);
|
|
535
|
-
* - env facts / prompt renderer: one declarative line disclosing the execution locus + trust posture;
|
|
536
|
-
* - audit: TaskResult/checkpoint carry it implicitly through WorkspaceHandle{provider, deviceId}.
|
|
537
|
-
* Suspend/resume: the run-level fold is PRESENCE-persisted on the checkpoint
|
|
538
|
-
* (`CheckpointState.externalContentTarget`, monotonic) and resume joins persisted OR live
|
|
539
|
-
* declaration — a run minted under a declaring adapter never silently downgrades on an
|
|
540
|
-
* undeclared/older one. ONE declaration, two readers: the content-class fold above (the design/378 red line binds that fold — no gate/policy/roster reads it) and the
|
|
541
|
-
* cross-boundary taint (it arms the run tree's taint bit; a call's `env` leg is judged by whether the env it reaches declares this flag AT THAT MOMENT, never by the fold).
|
|
542
|
-
* ORTHOGONAL to `capabilities.isolation` — an SSH env to an organization-managed build host can be non-isolated yet omit this flag.
|
|
543
|
-
*/
|
|
544
|
-
readonly externalContentTarget?: boolean;
|
|
545
632
|
/**
|
|
546
633
|
* #644 — declared by the ADAPTER: the HOME DIRECTORY of the user this environment runs as, as an absolute
|
|
547
634
|
* path in the environment's own namespace. The base a `~/`-relative permission rule (`Edit(~/.ssh/**)`)
|
|
@@ -1544,6 +1631,10 @@ export interface AgentHarnessOptions<TSkill extends Skill = Skill, TPromptTempla
|
|
|
1544
1631
|
/** Loop-config pass-through — see `AgentLoopConfig.onToolMediaRefused` (the tool-result seat's account of the media it
|
|
1545
1632
|
* refused); the harness's own finalization of a resumed approved call reports through the same sink. */
|
|
1546
1633
|
onToolMediaRefused?: import("../loop/types.js").AgentLoopConfig["onToolMediaRefused"];
|
|
1634
|
+
/** Loop-config pass-through — see `AgentLoopConfig.imageProcessor` (the tool-result seat's processor). */
|
|
1635
|
+
imageProcessor?: import("../loop/types.js").AgentLoopConfig["imageProcessor"];
|
|
1636
|
+
/** Loop-config pass-through — see `AgentLoopConfig.onImageUnprocessed` (an image that goes on unprocessed over the soft target). */
|
|
1637
|
+
onImageUnprocessed?: import("../loop/types.js").AgentLoopConfig["onImageUnprocessed"];
|
|
1547
1638
|
/**
|
|
1548
1639
|
* design/131 (拍): per-task resilience intent flags, forwarded to every provider
|
|
1549
1640
|
* call (`StreamOptions.resilience`) so the deployment's decorator stack (degrading / failover /
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The request view's reading of a provider's image refusal — restored on the way to the brain, never in the transcript.
|
|
3
|
+
*
|
|
4
|
+
* A turn the provider failed with `errorKind: "image_unprocessable"` (an image in the request could not be processed;
|
|
5
|
+
* classified at the brain boundary off the provider's envelope) is a MARKER, live in the loop's context and persisted
|
|
6
|
+
* as the transcript's API-failure record alike. Reading the messages in order, each marker:
|
|
7
|
+
* - replaces every image of the NEWEST earlier message that still carries one (a user message, a tool result, a
|
|
8
|
+
* custom message — never an assistant's) by a text block saying which image was removed and why;
|
|
9
|
+
* - leaves the view itself (a failure is not model output).
|
|
10
|
+
* An earlier marker has already emptied its carrier, so a second marker reaches the next older one: the request that
|
|
11
|
+
* failed loses one carrier's images per refusal, and a provider that names no position is still answered (the newest
|
|
12
|
+
* carrier is the one the failed request added last). Nothing else moves; messages without a marker before them are
|
|
13
|
+
* the same objects, and a view with no marker is the same array — the same transcript yields the same request bytes.
|
|
14
|
+
*
|
|
15
|
+
* The transcript keeps the images: a later reader of the session sees what was read, and every request built from it
|
|
16
|
+
* — the next turn, a resumed session, a compaction summary — reads the same record and removes the same images.
|
|
17
|
+
*/
|
|
18
|
+
/** The `errorKind` a provider's image refusal carries (`AssistantMessage.errorKind`). */
|
|
19
|
+
export declare const IMAGE_REFUSAL_KIND = "image_unprocessable";
|
|
20
|
+
/** The text that stands in for the `ordinal`-th image (1-based) of a carrier the provider refused an image of. */
|
|
21
|
+
export declare function rejectedImagePlaceholder(ordinal: number): string;
|
|
22
|
+
/** Is this message a turn the provider failed because an image in the request could not be processed — the live
|
|
23
|
+
* failure or its persisted record? */
|
|
24
|
+
export declare function isImageRefusal(message: unknown): boolean;
|
|
25
|
+
/** One carrier whose images a marker removed: the marker, the carrier (both the view's input objects), how many, and
|
|
26
|
+
* the refusal's own time — the one identity a refusal keeps across its live failure, its persisted record and every
|
|
27
|
+
* rebuilt copy of either (the record is minted with the failure's timestamp). */
|
|
28
|
+
export interface RejectedImageRemoval {
|
|
29
|
+
readonly marker: object;
|
|
30
|
+
readonly carrier: object;
|
|
31
|
+
readonly images: number;
|
|
32
|
+
readonly refusalAt: number;
|
|
33
|
+
}
|
|
34
|
+
/** A refusal's identity ({@link RejectedImageRemoval.refusalAt}). */
|
|
35
|
+
export declare function imageRefusalAt(message: unknown): number;
|
|
36
|
+
/**
|
|
37
|
+
* The request view of `messages` under every image refusal they hold ({@link isImageRefusal}): each marker removed and
|
|
38
|
+
* the images of its carrier replaced. `removals` lists, in order, the carriers emptied — empty when no marker found
|
|
39
|
+
* an image to remove.
|
|
40
|
+
*/
|
|
41
|
+
export declare function removeRejectedImages<T>(messages: readonly T[]): {
|
|
42
|
+
messages: T[];
|
|
43
|
+
removals: RejectedImageRemoval[];
|
|
44
|
+
};
|
|
45
|
+
/** Does `marker`, standing in `messages`, remove images in their request view — was there a carrier left for it? */
|
|
46
|
+
export declare function imageRefusalRemoves(messages: readonly unknown[], marker: object): boolean;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export const IMAGE_REFUSAL_KIND = "image_unprocessable";
|
|
2
|
+
export function rejectedImagePlaceholder(ordinal) {
|
|
3
|
+
return `[image ${ordinal} removed: rejected by provider: ${IMAGE_REFUSAL_KIND}]`;
|
|
4
|
+
}
|
|
5
|
+
export function isImageRefusal(message) {
|
|
6
|
+
const m = message;
|
|
7
|
+
return m?.role === "assistant" && m.isApiErrorMessage === true && m.errorKind === IMAGE_REFUSAL_KIND;
|
|
8
|
+
}
|
|
9
|
+
export function imageRefusalAt(message) {
|
|
10
|
+
const at = message?.timestamp;
|
|
11
|
+
return typeof at === "number" ? at : Number.NaN;
|
|
12
|
+
}
|
|
13
|
+
function imageCount(message) {
|
|
14
|
+
const m = message;
|
|
15
|
+
if (m === null || m === undefined || m.role === "assistant" || !Array.isArray(m.content))
|
|
16
|
+
return 0;
|
|
17
|
+
let n = 0;
|
|
18
|
+
for (const block of m.content)
|
|
19
|
+
if (block?.type === "image")
|
|
20
|
+
n++;
|
|
21
|
+
return n;
|
|
22
|
+
}
|
|
23
|
+
function withoutImages(message) {
|
|
24
|
+
let ordinal = 0;
|
|
25
|
+
const content = message.content.map((block) => block?.type === "image" ? { type: "text", text: rejectedImagePlaceholder(++ordinal) } : block);
|
|
26
|
+
return { ...message, content };
|
|
27
|
+
}
|
|
28
|
+
export function removeRejectedImages(messages) {
|
|
29
|
+
if (!messages.some(isImageRefusal))
|
|
30
|
+
return { messages: messages, removals: [] };
|
|
31
|
+
const out = [];
|
|
32
|
+
const carriers = [];
|
|
33
|
+
const removals = [];
|
|
34
|
+
for (const m of messages) {
|
|
35
|
+
if (!isImageRefusal(m)) {
|
|
36
|
+
out.push(m);
|
|
37
|
+
carriers.push(undefined);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
for (let j = out.length - 1; j >= 0; j--) {
|
|
41
|
+
const images = imageCount(out[j]);
|
|
42
|
+
if (images === 0)
|
|
43
|
+
continue;
|
|
44
|
+
removals.push({ marker: m, carrier: (carriers[j] ?? out[j]), images, refusalAt: imageRefusalAt(m) });
|
|
45
|
+
carriers[j] = (carriers[j] ?? out[j]);
|
|
46
|
+
out[j] = withoutImages(out[j]);
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return { messages: out, removals };
|
|
51
|
+
}
|
|
52
|
+
export function imageRefusalRemoves(messages, marker) {
|
|
53
|
+
return removeRejectedImages(messages).removals.some((r) => r.marker === marker);
|
|
54
|
+
}
|
|
@@ -73,7 +73,8 @@ export type DropsTableCoversEveryForm = AssertAllKeysHandled<Exclude<ToolTurnRep
|
|
|
73
73
|
* view of facts the model is already told in the turn itself. Closed:
|
|
74
74
|
* · `truncated` — calls whose argument bytes were cut before they parsed: dropped, the model asked to re-issue them;
|
|
75
75
|
* · `unnamed` — calls that arrived with no tool name: dropped the same way;
|
|
76
|
-
* · `bad_frame` — provider stream frames that were not valid JSON
|
|
76
|
+
* · `bad_frame` — provider stream frames that were not valid JSON, or held members in no shape the stream defines:
|
|
77
|
+
* what could not be read was dropped, so the response may be missing content;
|
|
77
78
|
* · `missing_result_synthesized` — a call with no recorded result, closed in the request view as interrupted with its
|
|
78
79
|
* outcome unknown (the `missing_result` repair).
|
|
79
80
|
* The first three are a brain's stream facts ({@link StreamDropCause}), stamped on the turn's own message; the fourth is
|
|
@@ -601,8 +601,15 @@ export interface AssistantMessage {
|
|
|
601
601
|
* twin). The loop's prompt-too-long recovery reads THIS seat first; the historic prose regex
|
|
602
602
|
* over `errorMessage` remains as the fallback for brains that do not stamp it (additive — the
|
|
603
603
|
* stamping obligation above extends to this member for cuts a Brain can classify structurally,
|
|
604
|
-
* but unlike the two cut kinds there is no retired fallback: prose detection still works).
|
|
605
|
-
|
|
604
|
+
* but unlike the two cut kinds there is no retired fallback: prose detection still works).
|
|
605
|
+
*
|
|
606
|
+
* `"image_unprocessable"`: the provider refused the request because an image in it could not be processed
|
|
607
|
+
* (it does not decode, its type does not match its bytes, its pixels exceed the model's limit) — classified at the
|
|
608
|
+
* brain boundary off the provider's envelope (`brain/provider-dialect.ts`, `IMAGE_UNPROCESSABLE_RE`). Such a turn —
|
|
609
|
+
* live, or as the transcript's persisted record of it — is the request view's instruction to remove the images of
|
|
610
|
+
* the newest earlier message still carrying any (`engine/llm/rejected-images.ts`, at `convertToLlm`); the loop
|
|
611
|
+
* re-sends the turn without them. */
|
|
612
|
+
errorKind?: "length_empty" | "degenerate" | "input_too_long" | "image_unprocessable";
|
|
606
613
|
/** The AUTHORITATIVE-NEGATIVE twin of `errorKind: "input_too_long"`: the brain's provenance-checked
|
|
607
614
|
* classifier RAN and ruled this failure NOT input-too-long (wrong status family, or the provider's
|
|
608
615
|
* own envelope states a different error). The loop's prompt-too-long recovery treats it as a hard
|
|
@@ -631,8 +638,9 @@ export interface AssistantMessage {
|
|
|
631
638
|
* trailing call was already dropped by the finalize malformed path). Additive — absent everywhere else.
|
|
632
639
|
*/
|
|
633
640
|
partialFinalized?: true;
|
|
634
|
-
/** A stream-end word (`finish_reason`) outside the set the brain reads, in the echo shape (`?` past it
|
|
635
|
-
*
|
|
641
|
+
/** A stream-end word (`finish_reason`) outside the set the brain reads, in the echo shape (`?` past it, and `?` for an
|
|
642
|
+
* ending seat — `finish_reason` / `stop_reason` — that held no word at all): the turn is kept, the Runner announces it
|
|
643
|
+
* (`route.finish_reason_unknown`), a completed run states it on `terminal.detail`. */
|
|
636
644
|
finishReasonUnknown?: string;
|
|
637
645
|
/** Frames after the stream's first terminal statement (which decided this turn) that were not acted on — a later
|
|
638
646
|
* ending (finish / stop reason), error or content — announced by the Runner (`route.stream_end_ignored`): the
|
|
@@ -1040,12 +1048,15 @@ export interface ImagesModel<TApi extends ImagesApi = ImagesApi> extends Omit<Mo
|
|
|
1040
1048
|
/** The resolved credential a request would carry, tagged with its source (see {@link RouteCredentialSource}). */
|
|
1041
1049
|
export interface RouteCredential {
|
|
1042
1050
|
source: RouteCredentialSource;
|
|
1043
|
-
/** The key
|
|
1044
|
-
*
|
|
1051
|
+
/** The key the request carries in its lane's key header, when the credential rides the apiKey knob — never blank as
|
|
1052
|
+
* `resolveRouteCredential` resolves it. A BLANK key handed over (the empty string, or white space only —
|
|
1053
|
+
* `isBlankCredential`) is the keyless door: its source keeps its rank, so a lower source's credential never rides in
|
|
1054
|
+
* its place, and the resolved credential has no `apiKey` (`{ source: "per-model" }` carries nothing). */
|
|
1045
1055
|
apiKey?: string;
|
|
1046
1056
|
/** True when the credential rides (also) as credential HEADERS (`isCredentialHeaderName`: `authorization`,
|
|
1047
1057
|
* `x-api-key`, `api-key`, a gateway's `Helicone-Auth`, …, any case) — alone, or beside the apiKey knob when one
|
|
1048
|
-
* source sets both
|
|
1058
|
+
* source sets both — and one of them holds a value that is not blank (a bag of blank credential headers keeps its
|
|
1059
|
+
* rank and rides nothing). The winning bag is named by {@link RouteCredential.carrierBag}. */
|
|
1049
1060
|
headersBorne?: boolean;
|
|
1050
1061
|
/** Which header bag carries a headers-borne credential (resolution precedence: options > model > config, one rank
|
|
1051
1062
|
* per source; within the hook's answer (`options`) and within the deployment config (`config`) the knob and the
|
|
@@ -36,6 +36,8 @@ export type LoopContinueReason =
|
|
|
36
36
|
| "follow_up_injected"
|
|
37
37
|
/** ④b recovery: a prompt-too-long failure was recovered (compacted context) and retried in-turn. */
|
|
38
38
|
| "reactive_compact_retry"
|
|
39
|
+
/** The provider refused an image; the request view removed it and the turn was re-sent in-turn. */
|
|
40
|
+
| "image_refusal_retry"
|
|
39
41
|
/** ④b recovery: a `length`-stopped answer triggered a synthetic continue nudge for another turn. */
|
|
40
42
|
| "max_output_tokens_recovery"
|
|
41
43
|
/** S2 recovery (design/119): a `toolUse` stop with ZERO parseable tool calls got a retry nudge. */
|
|
@@ -69,12 +71,9 @@ export type LoopTerminalReason =
|
|
|
69
71
|
* path and was reported as a plain `"completed"`, indistinguishable from a turn that genuinely had
|
|
70
72
|
* nothing left to do.
|
|
71
73
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* 成功恢复过的畸形调用,和刚刚才第一次触发畸形调用但恰好撞上早已用尽的预算,在这个 reason 面前不可
|
|
76
|
-
* 区分;调用方若需要"最近是否连续失败"这类更细的语义,需要自行在更高层维护窗口计数,这个 reason 只
|
|
77
|
-
* 承诺"预算耗尽"这一件事。 */
|
|
74
|
+
* `malformedToolUseRetries` 数的是**连续**畸形轮:任何带可解析工具调用的轮(即工具真的跑了)都把它
|
|
75
|
+
* 清零,与上游「重试至多两次、成功即复位」同形——"exhausted" 说的是"刚刚连续 maxRetries + 1 个轮次
|
|
76
|
+
* 全部畸形",不是"这个 run 总共累计过多少次畸形"。早先已恢复成功的畸形调用不再占用后来的预算。 */
|
|
78
77
|
| "malformed_tool_use_exhausted"
|
|
79
78
|
/** RB-258(RB-206 口径追查的衍生发现;RB-206 的同族对仗):the model kept ending its turn on the
|
|
80
79
|
* provider's output cap (`length`) with no tool calls, and the bounded truncated-output continue
|
|
@@ -88,9 +87,9 @@ export type LoopTerminalReason =
|
|
|
88
87
|
* - Only the CONFIGURED lane reports it. With `recovery.truncatedOutput` absent (the loop default
|
|
89
88
|
* is OFF) there is no budget to exhaust, so a `length` stop still ends as a plain `completed` —
|
|
90
89
|
* the pre-④b behavior, unchanged.
|
|
91
|
-
* - `truncatedOutputContinues` counts CONSECUTIVE nudges and RESETS on any non-`length` turn (
|
|
92
|
-
* `malformedToolUseRetries
|
|
93
|
-
* `length` maxContinues+1 times in a row", not "this run has burnt N recoveries in total".
|
|
90
|
+
* - `truncatedOutputContinues` counts CONSECUTIVE nudges and RESETS on any non-`length` turn (as
|
|
91
|
+
* `malformedToolUseRetries` resets on any turn whose tool calls ran). So this reason means "the model
|
|
92
|
+
* just ended `length` maxContinues+1 times in a row", not "this run has burnt N recoveries in total".
|
|
94
93
|
* - Like every other terminal, it stops the loop BEFORE drain point B — a follow-up queue / Stop-hook
|
|
95
94
|
* continuation no longer gets consulted on this path. That is the point (a stop-gate rescue would
|
|
96
95
|
* re-enter the same wall with a spent budget), and queued follow-ups stay queued for the next
|
|
@@ -172,11 +171,17 @@ export declare function isBatchSafeToolCall(tool: AgentTool | undefined, toolCal
|
|
|
172
171
|
export type ExecutedToolCallOutcome = {
|
|
173
172
|
result: AgentToolResult<unknown>;
|
|
174
173
|
isError: boolean;
|
|
174
|
+
/** Present (`true`) exactly when the call's body never started: the run was aborted between the gate and the body, or the host's
|
|
175
|
+
* execution station ({@link AgentLoopConfig.executeTool}) settled the call without running it. Rides the end event as
|
|
176
|
+
* `notExecuted`, like {@link ImmediateToolCallOutcome.notExecuted}. */
|
|
177
|
+
notExecuted?: true;
|
|
175
178
|
};
|
|
176
179
|
type FinalizedToolCallOutcome = {
|
|
177
180
|
toolCall: AgentToolCall;
|
|
178
181
|
result: AgentToolResult<unknown>;
|
|
179
182
|
isError: boolean;
|
|
183
|
+
/** The loop's own mark that the call settled without its body starting (see {@link ImmediateToolCallOutcome.notExecuted}); rides the end event. */
|
|
184
|
+
notExecuted?: true;
|
|
180
185
|
};
|
|
181
186
|
/**
|
|
182
187
|
* THE reading a value gets on its way to becoming a call's arguments: the tool's own preparation (`prepareArguments` —
|
|
@@ -215,13 +220,16 @@ export declare const TOOL_INPUT_VALIDATION_TIMEOUT_MS = 10000;
|
|
|
215
220
|
* same function, so the two cannot drift into two dialects of one finalization: the `afterToolCall` patch
|
|
216
221
|
* (content / details / terminate / isError), the D4 posture on a throwing hook, the delivery mark, and last
|
|
217
222
|
* the media admission — the tool-result seat every supply of media reaches after the last hand that can change
|
|
218
|
-
* it (`
|
|
219
|
-
*
|
|
223
|
+
* it (`toolResultMediaBlocks`, then `admitToolResultMediaBlocks` with the run's image processor `media.imageProcessor`,
|
|
224
|
+
* resolved only once a block claims media): a refused block becomes its text placeholder in the result,
|
|
225
|
+
* `media.onToolMediaRefused` hears the call's refusals once, and `media.onImageUnprocessed` hears an image that goes on
|
|
226
|
+
* unprocessed over the soft target. `after` absent and no media ⇒ the executed outcome stands as is (same object), with
|
|
227
|
+
* nothing awaited.
|
|
220
228
|
*/
|
|
221
229
|
export declare function finalizeToolOutcome<C extends {
|
|
222
230
|
id: string;
|
|
223
231
|
name: string;
|
|
224
|
-
}>(toolCall: C, executed: ExecutedToolCallOutcome, after: ((result: AgentToolResult<unknown>, isError: boolean) => Promise<AfterToolCallResult | undefined>) | undefined,
|
|
232
|
+
}>(toolCall: C, executed: ExecutedToolCallOutcome, after: ((result: AgentToolResult<unknown>, isError: boolean) => Promise<AfterToolCallResult | undefined>) | undefined, media?: Pick<AgentLoopConfig, "imageProcessor" | "onToolMediaRefused" | "onImageUnprocessed">): Promise<ExecutedToolCallOutcome & {
|
|
225
233
|
toolCall: C;
|
|
226
234
|
}>;
|
|
227
235
|
export {};
|