@sema-agent/core 7.48.0 → 7.49.1
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 +457 -0
- package/README.md +2 -2
- package/dist/agents/cascade.d.ts +2 -5
- package/dist/agents/child-failure.d.ts +20 -0
- package/dist/agents/child-failure.js +28 -0
- package/dist/agents/cross-session-ref.d.ts +11 -3
- package/dist/agents/cross-session-ref.js +6 -0
- package/dist/agents/cumulative-stats.d.ts +12 -15
- package/dist/agents/cumulative-stats.js +1 -1
- package/dist/agents/extra-tool-names.js +1 -1
- package/dist/agents/inherited-tool-pool.d.ts +17 -13
- package/dist/agents/inherited-tool-pool.js +4 -3
- package/dist/agents/peer-session-drain.d.ts +3 -2
- package/dist/agents/peer-session-drain.js +5 -4
- package/dist/agents/send-message-tool.js +2 -9
- package/dist/agents/subagent.d.ts +10 -29
- package/dist/agents/subagent.js +65 -53
- package/dist/agents/suspend-guard.d.ts +1 -1
- package/dist/agents/tool-filter.d.ts +76 -65
- package/dist/agents/tool-filter.js +122 -92
- package/dist/agents/verify.d.ts +4 -7
- package/dist/agents/verify.js +6 -7
- package/dist/bench/metrics.d.ts +1 -2
- package/dist/brain/anthropic.js +133 -79
- package/dist/brain/errors.d.ts +53 -6
- package/dist/brain/errors.js +22 -2
- package/dist/brain/input-too-long.d.ts +40 -19
- package/dist/brain/input-too-long.js +3 -16
- package/dist/brain/open-responses.js +19 -10
- package/dist/brain/openai.js +123 -32
- package/dist/brain/provider-dialect.d.ts +214 -0
- package/dist/brain/provider-dialect.js +186 -0
- package/dist/brain/request-params.d.ts +27 -8
- package/dist/brain/request-params.js +7 -12
- package/dist/brain/request-route.d.ts +84 -0
- package/dist/brain/request-route.js +41 -0
- package/dist/brain/retry.d.ts +8 -0
- package/dist/brain/retry.js +10 -4
- package/dist/brain/route-adjudicator.d.ts +7 -0
- package/dist/brain/route-adjudicator.js +5 -1
- package/dist/brain/status-sink.d.ts +20 -0
- package/dist/brain/status-sink.js +11 -0
- package/dist/brain/stream-engine.d.ts +52 -1
- package/dist/brain/stream-engine.js +81 -24
- package/dist/brain/stream-shared.d.ts +57 -11
- package/dist/brain/stream-shared.js +28 -2
- package/dist/core/a2a.d.ts +1 -0
- package/dist/core/agent-config-dir.js +3 -2
- package/dist/core/allow-entry.d.ts +21 -12
- package/dist/core/allow-entry.js +38 -31
- package/dist/core/arg-summary.d.ts +21 -28
- package/dist/core/arg-summary.js +235 -88
- package/dist/core/ask-origin.d.ts +42 -24
- package/dist/core/ask-origin.js +18 -13
- package/dist/core/auto-mode-prompt-assets.d.ts +2 -2
- package/dist/core/auto-mode-prompt-assets.js +1 -1
- package/dist/core/auto-mode-prompt.d.ts +11 -1
- package/dist/core/auto-mode-prompt.js +13 -10
- package/dist/core/auto-mode-rebuild.d.ts +7 -0
- package/dist/core/auto-mode-rebuild.js +4 -1
- package/dist/core/canonical-json.d.ts +3 -0
- package/dist/core/canonical-json.js +2 -1
- package/dist/core/checkpoint-requirements.d.ts +892 -0
- package/dist/core/checkpoint-requirements.js +333 -0
- package/dist/core/checkpoint-store.d.ts +94 -65
- package/dist/core/checkpoint-store.js +14 -26
- package/dist/core/child-clamp-seats.d.ts +228 -69
- package/dist/core/child-clamp-seats.js +211 -17
- package/dist/core/classifier-unavailable-arm.d.ts +5 -1
- package/dist/core/classifier-unavailable-arm.js +3 -3
- package/dist/core/compliance.d.ts +3 -0
- package/dist/core/compliance.js +9 -4
- package/dist/core/credential-vocabulary.d.ts +140 -0
- package/dist/core/credential-vocabulary.js +131 -0
- package/dist/core/decision-receipt.js +1 -1
- package/dist/core/effective-path-target.d.ts +73 -16
- package/dist/core/effective-path-target.js +63 -33
- package/dist/core/engine-notice.d.ts +43 -11
- package/dist/core/file-history-store.js +2 -2
- package/dist/core/fs-write-gate-policy.d.ts +4 -0
- package/dist/core/fs-write-gate-policy.js +22 -5
- package/dist/core/gate-bounded-await.d.ts +28 -13
- package/dist/core/gate-bounded-await.js +41 -4
- package/dist/core/gate-fold.d.ts +1 -1
- package/dist/core/gate-fold.js +24 -25
- package/dist/core/gate-lanes.js +16 -15
- package/dist/core/gate-outcome.d.ts +20 -5
- package/dist/core/gate-outcome.js +5 -0
- package/dist/core/governance-codes.d.ts +11 -4
- package/dist/core/governance-codes.js +14 -3
- package/dist/core/hooks.d.ts +21 -0
- package/dist/core/locked-config.d.ts +8 -0
- package/dist/core/locked-config.js +14 -2
- package/dist/core/lsp.js +3 -5
- package/dist/core/mailbox-store.d.ts +3 -4
- package/dist/core/mcp-connection-pool.d.ts +75 -0
- package/dist/core/mcp-connection-pool.js +128 -0
- package/dist/core/mcp-failure.d.ts +2 -1
- package/dist/core/mcp-failure.js +13 -2
- package/dist/core/mcp.d.ts +4 -0
- package/dist/core/mcp.js +70 -43
- package/dist/core/memory-engine/content-origin.js +2 -14
- package/dist/core/memory-engine/engine.d.ts +32 -22
- package/dist/core/memory-engine/engine.js +103 -55
- package/dist/core/memory-engine/file-backend.d.ts +13 -30
- package/dist/core/memory-engine/file-backend.js +37 -252
- package/dist/core/memory-engine/index.d.ts +1 -1
- package/dist/core/memory-engine/index.js +1 -1
- package/dist/core/memory-engine/layout.d.ts +139 -9
- package/dist/core/memory-engine/layout.js +350 -7
- package/dist/core/memory-engine/scope-contract.d.ts +10 -0
- package/dist/core/memory-engine/scope-contract.js +8 -0
- package/dist/core/memory-engine/session-incarnation.d.ts +14 -4
- package/dist/core/memory-engine/session-incarnation.js +5 -2
- package/dist/core/memory-engine/types.d.ts +10 -1
- package/dist/core/memory.js +5 -17
- package/dist/core/model-seat.d.ts +4 -4
- package/dist/core/model-seat.js +1 -1
- package/dist/core/mounted-mcp.d.ts +57 -0
- package/dist/core/mounted-mcp.js +19 -0
- package/dist/core/namespaced-rule-name.d.ts +29 -0
- package/dist/core/namespaced-rule-name.js +52 -0
- package/dist/core/park-selfcheck.d.ts +1 -1
- package/dist/core/park-selfcheck.js +16 -6
- package/dist/core/path-guard-rows.d.ts +99 -0
- package/dist/core/path-guard-rows.js +45 -0
- package/dist/core/path-identity.d.ts +22 -16
- package/dist/core/path-identity.js +10 -10
- package/dist/core/path-rule-binding.d.ts +2 -1
- package/dist/core/path-rule-binding.js +3 -1
- package/dist/core/pause-registry.d.ts +16 -2
- package/dist/core/pause-registry.js +6 -0
- package/dist/core/permission-rule-consent.js +0 -7
- package/dist/core/permission-rule-model.d.ts +68 -24
- package/dist/core/permission-rule-model.js +105 -24
- package/dist/core/permission-rule-store.js +2 -2
- package/dist/core/permission-rules.d.ts +3 -30
- package/dist/core/permission-rules.js +4 -54
- package/dist/core/read-root-candidate.d.ts +1 -3
- package/dist/core/read-root-candidate.js +4 -15
- package/dist/core/real-approval.d.ts +4 -3
- package/dist/core/retired-keys.d.ts +13 -0
- package/dist/core/retired-keys.js +14 -0
- package/dist/core/roles.d.ts +2 -3
- package/dist/core/roles.js +15 -6
- package/dist/core/runner/assemble-result.d.ts +0 -7
- package/dist/core/runner/assemble-result.js +19 -31
- package/dist/core/runner/caller-roster.d.ts +78 -0
- package/dist/core/runner/caller-roster.js +219 -0
- package/dist/core/runner/checkpoint-scope.d.ts +16 -16
- package/dist/core/runner/checkpoint-scope.js +2 -2
- package/dist/core/runner/child-tree.js +2 -2
- package/dist/core/runner/contracts.d.ts +68 -35
- package/dist/core/runner/decide-continuation.d.ts +51 -3
- package/dist/core/runner/decide-continuation.js +76 -21
- package/dist/core/runner/denial-limit-arms.d.ts +17 -5
- package/dist/core/runner/denial-limit-arms.js +11 -9
- package/dist/core/runner/extra-body-dropped-seat.d.ts +8 -0
- package/dist/core/runner/extra-body-dropped-seat.js +22 -0
- package/dist/core/runner/finish-reason-seat.d.ts +9 -0
- package/dist/core/runner/finish-reason-seat.js +40 -0
- package/dist/core/runner/gate-exit.d.ts +44 -32
- package/dist/core/runner/gate-exit.js +112 -25
- package/dist/core/runner/inherited-ask-grants.js +6 -4
- package/dist/core/runner/mcp-redial.d.ts +3 -3
- package/dist/core/runner/mcp-redial.js +3 -4
- package/dist/core/runner/permission-rule-lanes.d.ts +1 -2
- package/dist/core/runner/permission-rule-lanes.js +5 -4
- package/dist/core/runner/prepare-artifact.d.ts +4 -0
- package/dist/core/runner/prepare-artifact.js +2 -1
- package/dist/core/runner/prepare-ask-lane.d.ts +2 -0
- package/dist/core/runner/prepare-ask-lane.js +12 -6
- package/dist/core/runner/prepare-boundary-parks.d.ts +5 -8
- package/dist/core/runner/prepare-boundary-parks.js +4 -7
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +11 -15
- package/dist/core/runner/prepare-caps-and-workflow.js +19 -27
- package/dist/core/runner/prepare-config-doors.d.ts +9 -9
- package/dist/core/runner/prepare-config-doors.js +10 -5
- package/dist/core/runner/prepare-defer-classify.d.ts +2 -2
- package/dist/core/runner/prepare-defer-classify.js +5 -3
- package/dist/core/runner/prepare-delegation-surface.d.ts +1 -1
- package/dist/core/runner/prepare-delegation-surface.js +3 -3
- package/dist/core/runner/prepare-gate-stations.d.ts +4 -4
- package/dist/core/runner/prepare-gate-stations.js +9 -7
- package/dist/core/runner/prepare-hands-readface.d.ts +7 -7
- package/dist/core/runner/prepare-hands-readface.js +7 -7
- package/dist/core/runner/prepare-inherited-gate.d.ts +7 -6
- package/dist/core/runner/prepare-inherited-gate.js +14 -15
- package/dist/core/runner/prepare-listings.d.ts +7 -24
- package/dist/core/runner/prepare-listings.js +4 -5
- package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -0
- package/dist/core/runner/prepare-memory-engine-session.js +4 -3
- package/dist/core/runner/prepare-memory.d.ts +6 -0
- package/dist/core/runner/prepare-memory.js +13 -13
- package/dist/core/runner/prepare-offload-wrappers.d.ts +5 -0
- package/dist/core/runner/prepare-offload-wrappers.js +3 -3
- package/dist/core/runner/prepare-park-ask.d.ts +7 -8
- package/dist/core/runner/prepare-park-ask.js +17 -10
- package/dist/core/runner/prepare-policy-chain.js +24 -44
- package/dist/core/runner/prepare-project-context.d.ts +1 -1
- package/dist/core/runner/prepare-project-context.js +3 -4
- package/dist/core/runner/prepare-protocol-tools.d.ts +9 -3
- package/dist/core/runner/prepare-protocol-tools.js +3 -4
- package/dist/core/runner/prepare-run-refs.d.ts +3 -0
- package/dist/core/runner/prepare-run-refs.js +2 -1
- package/dist/core/runner/prepare-safety-scan.d.ts +4 -8
- package/dist/core/runner/prepare-safety-scan.js +1 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +7 -1
- package/dist/core/runner/prepare-suspend-saga.js +28 -12
- package/dist/core/runner/prepare-task.d.ts +1 -1
- package/dist/core/runner/prepare-task.js +67 -56
- package/dist/core/runner/prepare-wiring-manifest.d.ts +11 -10
- package/dist/core/runner/prepare-wiring-manifest.js +5 -8
- package/dist/core/runner/resume-apply.js +7 -14
- package/dist/core/runner/resume-checkpoint-screen.js +11 -4
- package/dist/core/runner/resume-internals-and-config.js +2 -2
- package/dist/core/runner/resume-policy-outcome.js +5 -32
- package/dist/core/runner/resume-review-outcome.js +4 -1
- package/dist/core/runner/retired-runner-deps.d.ts +6 -0
- package/dist/core/runner/retired-runner-deps.js +10 -1
- package/dist/core/runner/run-brain-sinks.d.ts +4 -0
- package/dist/core/runner/run-brain-sinks.js +5 -2
- package/dist/core/runner/run-harness-handlers.js +29 -36
- package/dist/core/runner/run-leg.d.ts +0 -2
- package/dist/core/runner/run-leg.js +32 -33
- package/dist/core/runner/run-terminal-adoption.js +4 -3
- package/dist/core/runner/runtask.js +8 -8
- package/dist/core/runner/session-rule-policy.js +5 -5
- package/dist/core/runner/stream-settle-backstop.js +7 -4
- package/dist/core/runner/sub-agent-deny-lists.d.ts +51 -12
- package/dist/core/runner/sub-agent-deny-lists.js +111 -80
- package/dist/core/runner/terminal-account.d.ts +48 -0
- package/dist/core/runner/terminal-account.js +186 -0
- package/dist/core/runner/tool-end-body.d.ts +54 -17
- package/dist/core/runner/tool-end-body.js +27 -2
- package/dist/core/runner/tool-face-overlay.d.ts +3 -1
- package/dist/core/runner/tool-face-overlay.js +6 -4
- package/dist/core/runner/tool-occurrence.d.ts +106 -0
- package/dist/core/runner/tool-occurrence.js +123 -0
- package/dist/core/runner/tool-progress-lane.d.ts +16 -8
- package/dist/core/runner/tool-progress-lane.js +25 -34
- package/dist/core/runner/tool-turn-repair-seat.d.ts +28 -4
- package/dist/core/runner/tool-turn-repair-seat.js +36 -13
- package/dist/core/runner/turn-attachments.d.ts +1 -1
- package/dist/core/runner/write-protection-station.d.ts +21 -9
- package/dist/core/runner/write-protection-station.js +20 -17
- package/dist/core/runner-deps.d.ts +12 -22
- package/dist/core/secret-env.d.ts +16 -5
- package/dist/core/secret-env.js +23 -63
- package/dist/core/sensitive-path-policy.d.ts +19 -18
- package/dist/core/sensitive-path-policy.js +73 -49
- package/dist/core/session-reconcile.d.ts +3 -0
- package/dist/core/session-reconcile.js +5 -4
- package/dist/core/session-store.d.ts +5 -0
- package/dist/core/session-store.js +12 -0
- package/dist/core/session.d.ts +13 -0
- package/dist/core/shared-memory/normalize.d.ts +17 -4
- package/dist/core/shared-memory/normalize.js +7 -7
- package/dist/core/shell-lexer.js +5 -4
- package/dist/core/shell-wrapper-projection.js +1 -1
- package/dist/core/skill-grant.js +1 -1
- package/dist/core/store-contracts/checkpoint-store-contract.js +13 -0
- package/dist/core/store-contracts/mailbox-store-contract.d.ts +7 -14
- package/dist/core/store-contracts/session-store-incarnation-contract.d.ts +27 -0
- package/dist/core/store-contracts/session-store-incarnation-contract.js +92 -0
- package/dist/core/stub-env.d.ts +2 -0
- package/dist/core/stub-env.js +1 -0
- package/dist/core/synthetic-read-verdict.js +2 -2
- package/dist/core/task-event.d.ts +59 -5
- package/dist/core/task-result.d.ts +1 -1
- package/dist/core/task-spec.d.ts +42 -9
- package/dist/core/terminal-cause.d.ts +94 -11
- package/dist/core/tighten-task-spec.d.ts +5 -4
- package/dist/core/tighten-task-spec.js +20 -25
- package/dist/core/tool-catalog-entries.d.ts +5 -7
- package/dist/core/tool-catalog-entries.js +14 -15
- package/dist/core/tool-face.d.ts +47 -0
- package/dist/core/tool-face.js +5 -0
- package/dist/core/tool-model-gate.d.ts +5 -5
- package/dist/core/tool-name-aliases.d.ts +26 -2
- package/dist/core/tool-name-aliases.js +13 -0
- package/dist/core/tool-name-list.d.ts +30 -0
- package/dist/core/tool-name-list.js +55 -0
- package/dist/core/tool-name-readings.d.ts +1 -9
- package/dist/core/tool-name-readings.js +1 -3
- package/dist/core/tool-policy.d.ts +195 -85
- package/dist/core/tool-policy.js +165 -380
- package/dist/core/tool-registry.d.ts +44 -1
- package/dist/core/tool-registry.js +26 -0
- package/dist/core/tool-roster.d.ts +19 -1
- package/dist/core/tool-roster.js +21 -2
- package/dist/core/tool-spec-members.d.ts +45 -0
- package/dist/core/tool-spec-members.js +169 -0
- package/dist/core/tool-spec.d.ts +46 -8
- package/dist/core/tools.d.ts +6 -2
- package/dist/core/tools.js +8 -4
- package/dist/core/untrusted-egress.js +29 -26
- package/dist/core/untrusted-text.d.ts +13 -10
- package/dist/core/untrusted-text.js +6 -44
- package/dist/core/workflow-journal-store.d.ts +4 -1
- package/dist/core/write-protect.d.ts +65 -29
- package/dist/core/write-protect.js +235 -177
- package/dist/engine/compaction/compaction.d.ts +2 -2
- package/dist/engine/execution-env/node-execution-env.d.ts +5 -23
- package/dist/engine/execution-env/node-execution-env.js +16 -38
- package/dist/engine/execution-env/symlink-chain.d.ts +23 -0
- package/dist/engine/execution-env/symlink-chain.js +32 -0
- package/dist/engine/harness/types.d.ts +7 -0
- package/dist/engine/llm/tool-turns.d.ts +3 -0
- package/dist/engine/llm/tool-turns.js +1 -0
- package/dist/engine/llm/types.d.ts +59 -23
- package/dist/engine/loop/agent-loop.js +16 -2
- package/dist/engine/session/memory-repo.js +11 -3
- package/dist/engine/session/repo-utils.d.ts +8 -0
- package/dist/engine/session/repo-utils.js +13 -0
- package/dist/index.d.ts +20 -23
- package/dist/index.js +17 -20
- package/dist/internal/harness.d.ts +1 -1
- package/dist/internal/harness.js +1 -1
- package/dist/internal/llm.d.ts +2 -2
- package/dist/internal/llm.js +1 -1
- package/dist/orchestration/governance-baseline-validity.js +1 -1
- package/dist/orchestration/run-spec.js +3 -3
- package/dist/orchestration/run-workflow-tool.d.ts +16 -35
- package/dist/orchestration/run-workflow-tool.js +38 -78
- package/dist/orchestration/workflow-governance.d.ts +21 -25
- package/dist/orchestration/workflow-governance.js +38 -78
- package/dist/orchestration/workflow-primitives.d.ts +7 -22
- package/dist/orchestration/workflow-primitives.js +5 -12
- package/dist/orchestration/workflow-types.d.ts +1 -1
- package/dist/orchestration/workflow.d.ts +61 -11
- package/dist/orchestration/workflow.js +189 -117
- package/dist/scenarios/full-body.d.ts +1 -1
- package/dist/shell/lex.d.ts +0 -21
- package/dist/shell/lex.js +250 -68
- package/dist/shell/shell-words.d.ts +35 -0
- package/dist/shell/shell-words.js +65 -0
- package/dist/stores/file/checkpoint-store.d.ts +5 -5
- package/dist/stores/file/checkpoint-store.js +5 -2
- package/dist/stores/file/index.d.ts +0 -8
- package/dist/stores/file/index.js +0 -12
- package/dist/stores/file/session-store.d.ts +3 -0
- package/dist/stores/file/session-store.js +44 -19
- package/dist/tools/artifact/artifact-tool.js +2 -0
- package/dist/tools/fs/bash-program-position.d.ts +12 -4
- package/dist/tools/fs/bash-program-position.js +32 -9
- package/dist/tools/fs/bash-readonly-classifier.d.ts +1 -1
- package/dist/tools/fs/bash-readonly-classifier.js +8 -7
- package/dist/tools/fs/containment-face.d.ts +4 -0
- package/dist/tools/fs/containment-face.js +3 -0
- package/dist/tools/fs/fs-shared.d.ts +10 -0
- package/dist/tools/fs/fs-shared.js +18 -0
- package/dist/tools/fs/fs-write.js +4 -2
- package/dist/tools/fs/index.d.ts +1 -1
- package/dist/tools/fs/program-read-model.d.ts +46 -20
- package/dist/tools/fs/program-read-model.js +50 -20
- package/dist/tools/fs/program-read-model.rows.d.ts +0 -14
- package/dist/tools/fs/program-read-model.rows.js +16 -15
- package/dist/tools/fs/read-deny-home.d.ts +33 -47
- package/dist/tools/fs/read-deny-home.js +35 -49
- package/dist/tools/fs/read-deny.d.ts +23 -22
- package/dist/tools/fs/read-deny.js +114 -89
- package/dist/tools/fs/removal-targets.d.ts +56 -23
- package/dist/tools/fs/removal-targets.js +65 -87
- package/dist/tools/fs/safety.d.ts +29 -22
- package/dist/tools/fs/safety.js +17 -11
- package/dist/tools/fs/search.js +10 -8
- package/dist/tools/fs/shell-read-argv.js +1 -1
- package/dist/tools/fs/shell-read-bindings.d.ts +169 -37
- package/dist/tools/fs/shell-read-bindings.js +324 -86
- package/dist/tools/fs/shell-read-builtins.d.ts +35 -0
- package/dist/tools/fs/shell-read-builtins.js +43 -0
- package/dist/tools/fs/shell-read-check.d.ts +15 -1
- package/dist/tools/fs/shell-read-check.js +67 -43
- package/dist/tools/fs/shell-read-establish.js +6 -6
- package/dist/tools/fs/shell-read-functions.d.ts +22 -0
- package/dist/tools/fs/shell-read-functions.js +29 -0
- package/dist/tools/fs/shell-read-judge.d.ts +51 -18
- package/dist/tools/fs/shell-read-judge.js +40 -4
- package/dist/tools/fs/shell-read-plan.d.ts +12 -6
- package/dist/tools/fs/shell-read-plan.js +118 -113
- package/dist/tools/fs/shell-read-start.d.ts +29 -6
- package/dist/tools/fs/shell-read-start.js +16 -9
- package/dist/tools/fs/shell-read-word.js +4 -0
- package/dist/tools/fs/shell-read-workdir.d.ts +156 -0
- package/dist/tools/fs/shell-read-workdir.js +281 -0
- package/dist/tools/fs/shell-read-write-targets.d.ts +5 -2
- package/dist/tools/fs/shell-read-write-targets.js +14 -5
- package/dist/tools/fs/shell-reentry-text.d.ts +4 -6
- package/dist/tools/fs/shell-reentry-text.js +3 -11
- package/dist/tools/task-list.d.ts +1 -2
- package/dist/tools/web.js +1 -1
- package/package.json +4 -1
- package/test/export-surface.snapshot.json +107 -143
- package/wire-changes/core@7.49.0.json +4765 -0
- package/dist/agents/teacher.d.ts +0 -159
- package/dist/agents/teacher.js +0 -577
- package/dist/agents/team.d.ts +0 -226
- package/dist/agents/team.js +0 -257
- package/dist/core/strategy-store.d.ts +0 -238
- package/dist/core/strategy-store.js +0 -253
- package/dist/orchestration/builtin-workflows.d.ts +0 -133
- package/dist/orchestration/builtin-workflows.js +0 -159
- package/dist/scenarios/env.d.ts +0 -40
- package/dist/scenarios/env.js +0 -39
- package/dist/scenarios/scenario-registry.d.ts +0 -110
- package/dist/scenarios/scenario-registry.js +0 -140
- package/dist/scenarios/teacher-quickstart.d.ts +0 -40
- package/dist/scenarios/teacher-quickstart.js +0 -12
- package/dist/stores/cc/lockfile.d.ts +0 -10
- package/dist/stores/cc/lockfile.js +0 -98
- package/dist/stores/cc/mailbox-store.d.ts +0 -20
- package/dist/stores/cc/mailbox-store.js +0 -255
- package/dist/stores/cc/roster-adapter.d.ts +0 -12
- package/dist/stores/cc/roster-adapter.js +0 -117
- package/dist/stores/cc/sidecar-transcript.d.ts +0 -97
- package/dist/stores/cc/sidecar-transcript.js +0 -264
- package/dist/stores/cc/task-list-store.d.ts +0 -2
- package/dist/stores/cc/task-list-store.js +0 -125
- package/dist/stores/file/strategy-store.d.ts +0 -97
- package/dist/stores/file/strategy-store.js +0 -341
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { MCP_NAMESPACE, protocolOf } from "./protocol-table.js";
|
|
2
|
-
import { splitNamespacedName } from "./tool-name-aliases.js";
|
|
3
2
|
import { catalogRuleFaceOf, isShellFaceToolName, pathTargetOf } from "./tool-registry.js";
|
|
4
3
|
import { indexOfUnescaped, lastIndexOfUnescaped, parsePermissionRule } from "./permission-rule-syntax.js";
|
|
5
4
|
import { COMMAND_RULE_TOOL, NAME_RULE_FACES, PATH_RULE_BASE_LABEL, PATH_RULE_FACES, callPathFaceOf, isUsablePathBase, laneToolNamesOf, nameRuleAdmits, nameRuleSubjectOf, parseRuleText, programRunReachOf, ruleBasesNeeded, ruleToolGrammarOf } from "./permission-rule-model.js";
|
|
6
5
|
import { pathFamilyOf } from "../tools/fs/safety.js";
|
|
7
6
|
import { callTargetReadingOf, callTargetViewsOf } from "./effective-path-target.js";
|
|
8
|
-
import { bindPathRules,
|
|
7
|
+
import { bindPathRules, judgeRuleRows, policyAnchors, rowsWhereTheyLead } from "./path-rule-binding.js";
|
|
9
8
|
import { ruleDenialSentence } from "./rule-denial-sentence.js";
|
|
10
9
|
import { heldValues } from "./tool-name-readings.js";
|
|
11
10
|
export { parsePermissionRule };
|
|
@@ -31,57 +30,8 @@ const DEFAULT_CAPS = {
|
|
|
31
30
|
maxStars: 16,
|
|
32
31
|
maxScalarValueChars: 16_384,
|
|
33
32
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
let v = 0;
|
|
37
|
-
let star = -1;
|
|
38
|
-
let mark = 0;
|
|
39
|
-
while (v < value.length) {
|
|
40
|
-
if (p < pattern.length && pattern[p] === value[v] && pattern[p] !== "*") {
|
|
41
|
-
p++;
|
|
42
|
-
v++;
|
|
43
|
-
}
|
|
44
|
-
else if (p < pattern.length && pattern[p] === "*") {
|
|
45
|
-
star = p++;
|
|
46
|
-
mark = v;
|
|
47
|
-
}
|
|
48
|
-
else if (star >= 0) {
|
|
49
|
-
p = star + 1;
|
|
50
|
-
v = ++mark;
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
while (p < pattern.length && pattern[p] === "*")
|
|
57
|
-
p++;
|
|
58
|
-
return p === pattern.length;
|
|
59
|
-
}
|
|
60
|
-
function parseNamespacedRuleName(name) {
|
|
61
|
-
const split = splitNamespacedName(name);
|
|
62
|
-
if (split === undefined || split.peer === "")
|
|
63
|
-
return undefined;
|
|
64
|
-
return split.tool !== undefined ? { protocol: split.ns.id, peer: split.peer, tool: split.tool } : { protocol: split.ns.id, peer: split.peer };
|
|
65
|
-
}
|
|
66
|
-
export function namespacedRuleNameCovers(ruleName, toolName) {
|
|
67
|
-
const rule = parseNamespacedRuleName(ruleName);
|
|
68
|
-
if (rule === undefined)
|
|
69
|
-
return false;
|
|
70
|
-
const target = parseNamespacedRuleName(toolName);
|
|
71
|
-
if (target === undefined)
|
|
72
|
-
return false;
|
|
73
|
-
if (rule.protocol !== target.protocol)
|
|
74
|
-
return false;
|
|
75
|
-
if (rule.peer !== target.peer)
|
|
76
|
-
return false;
|
|
77
|
-
if (rule.tool === undefined || rule.tool === "*")
|
|
78
|
-
return true;
|
|
79
|
-
return target.tool !== undefined && rule.tool.includes("*") && wildcardMatch(rule.tool, target.tool);
|
|
80
|
-
}
|
|
81
|
-
export function isNamespacedCoveringRuleName(name) {
|
|
82
|
-
const parsed = parseNamespacedRuleName(name);
|
|
83
|
-
return parsed !== undefined && (parsed.tool === undefined || parsed.tool.includes("*"));
|
|
84
|
-
}
|
|
33
|
+
import { isNamespacedCoveringRuleName, namespacedRuleNameCovers, wildcardMatch } from "./namespaced-rule-name.js";
|
|
34
|
+
export { isNamespacedCoveringRuleName, namespacedRuleNameCovers, wildcardMatch };
|
|
85
35
|
export function catalogRuleFaceView(toolName) {
|
|
86
36
|
const face = catalogRuleFaceOf(toolName);
|
|
87
37
|
if (face === undefined)
|
|
@@ -395,7 +345,7 @@ export function createPermissionRulePolicy(rules, opts) {
|
|
|
395
345
|
if (views !== undefined) {
|
|
396
346
|
const { of } = boundAt(policyAnchors(pathBases, req.pathRuleAnchors));
|
|
397
347
|
const rows = rowsWhereTheyLead(pathLane.map((r) => of.get(r)), callTargetReadingOf(req)?.leads ?? NO_LEADS);
|
|
398
|
-
const hit =
|
|
348
|
+
const hit = judgeRuleRows(rows, views, "tighten");
|
|
399
349
|
const rule = hit === undefined ? undefined : pathLane.find((r) => of.get(r).spec === hit.row.spec);
|
|
400
350
|
if (hit !== undefined && hit.unreadable === undefined)
|
|
401
351
|
return { rule: rule };
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* that the seat cannot become an unbounded prose channel onto an approval card. */
|
|
3
|
-
export declare const READ_ROOT_CANDIDATE_DIR_MAX = 1024;
|
|
1
|
+
export { READ_ROOT_CANDIDATE_DIR_MAX } from "./effective-path-target.js";
|
|
4
2
|
/**
|
|
5
3
|
* The validator for a probe's {@link import("./tool-spec.js").ReversibilityVerdict.readRootCandidate}: the
|
|
6
4
|
* errand `normalizeProbeCause` does for the cause, fail-closed on the disclosure alone — a malformed value
|
|
@@ -1,24 +1,13 @@
|
|
|
1
1
|
import { isPlainRecord, safeDataValue } from "./checkpoint-store.js";
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
2
|
+
import { validatePath } from "./effective-path-target.js";
|
|
3
|
+
export { READ_ROOT_CANDIDATE_DIR_MAX } from "./effective-path-target.js";
|
|
4
4
|
export function normalizeReadRootCandidate(value) {
|
|
5
5
|
if (!isPlainRecord(value))
|
|
6
6
|
return undefined;
|
|
7
7
|
if (safeDataValue(value, "clearsThisAsk") !== true)
|
|
8
8
|
return undefined;
|
|
9
|
-
const dir = safeDataValue(value, "dir");
|
|
10
|
-
if (
|
|
11
|
-
return undefined;
|
|
12
|
-
if (/[\u0000-\u001f\u007f\u2028\u2029]/.test(dir))
|
|
13
|
-
return undefined;
|
|
14
|
-
if (!isAbsolutePathForm(dir))
|
|
15
|
-
return undefined;
|
|
16
|
-
const folded = normalizeAbsPathLexically(dir);
|
|
17
|
-
if (folded !== dir || normalizeAbsPathLexically(`${dir}/..`) === dir)
|
|
18
|
-
return undefined;
|
|
19
|
-
if (hasWin32AliasedComponent(dir))
|
|
20
|
-
return undefined;
|
|
21
|
-
if (!win32NamespaceScreen(dir, pathFamilyOf({ root: dir })).ok)
|
|
9
|
+
const dir = validatePath(safeDataValue(value, "dir"), { intent: "validate-grant" });
|
|
10
|
+
if (dir === undefined)
|
|
22
11
|
return undefined;
|
|
23
12
|
let covers;
|
|
24
13
|
try {
|
|
@@ -8,14 +8,15 @@
|
|
|
8
8
|
import type { Checkpoint } from "./checkpoint-store.js";
|
|
9
9
|
import type { HostDecider } from "./gate-outcome.js";
|
|
10
10
|
import type { OrgGateVerdict } from "./hooks.js";
|
|
11
|
-
import type { AskRequest, PermissionResult,
|
|
11
|
+
import type { AskRequest, PermissionResult, ResolverArmResult } from "./tool-policy.js";
|
|
12
12
|
/** The synchronous seat's refusal of a configuration's allow: one settlement word for both forms
|
|
13
13
|
* (`blanket_allow_refused`, nobody's — no person decided), a sentence that says which configuration it was. */
|
|
14
|
-
export declare function unjudgedAllowRefused(req: AskRequest, by: "blanket" | "policy"): Extract<
|
|
14
|
+
export declare function unjudgedAllowRefused(req: AskRequest, by: "blanket" | "policy"): Extract<ResolverArmResult, {
|
|
15
15
|
action: "deny";
|
|
16
16
|
}>;
|
|
17
17
|
/** A durable row demands a person when its gate carries the real-approval bit (the gate's own, which every resume
|
|
18
|
-
* check reads; the pending action's `requiresRealApproval` is its display twin).
|
|
18
|
+
* check reads; the pending action's `requiresRealApproval` is its display twin). A plan-pause gate carries no bit, so
|
|
19
|
+
* the same predicate lets the deployment's policy decide a plan pause — and would refuse it the day a gate stamps one. */
|
|
19
20
|
export declare function rowDemandsAPerson(cp: Checkpoint): boolean;
|
|
20
21
|
/** A question a decide is held against, in each form a station holds one: the parked row, a policy's re-check of an
|
|
21
22
|
* approver's edit, the organization's CURRENT verdict about the call, and the request an approver was handed (the card a
|
|
@@ -25,3 +25,16 @@ export declare function assertNoRetiredKeys(bag: object, table: Readonly<Record<
|
|
|
25
25
|
* (`config.spec_retired_key`), never read as absence: a mode a caller believes it declared must not silently run
|
|
26
26
|
* as another. */
|
|
27
27
|
export declare const RETIRED_TASK_SPEC_KEYS: Readonly<Record<string, string>>;
|
|
28
|
+
/** The RETIRED `ToolPolicy` members — a policy still carrying one is refused by name (`config.deps_retired_key`) wherever
|
|
29
|
+
* the engine reads a policy's members: the intake of the caller's policy (prepare, and a resume before its claim), the
|
|
30
|
+
* by-name member reader the wrap and the path-rule installation share, and `combinePolicies`. A member the policy no
|
|
31
|
+
* longer declares is dropped by every one of them, so a guard stated in it would read as stated while guarding nothing. */
|
|
32
|
+
export declare const RETIRED_TOOL_POLICY_KEYS: Readonly<Record<string, string>>;
|
|
33
|
+
/** The RETIRED `ShellReadBoundary` members — a boundary a consumer hands to `judgeShellRead` that still carries one is
|
|
34
|
+
* refused by name (`config.deps_retired_key`); the station reads one write seat, so a retired one would leave every write
|
|
35
|
+
* target unjudged by its rows. (The engine's own station builds its boundaries itself.) */
|
|
36
|
+
export declare const RETIRED_SHELL_READ_BOUNDARY_KEYS: Readonly<Record<string, string>>;
|
|
37
|
+
/** The `ToolPolicy` door ({@link RETIRED_TOOL_POLICY_KEYS}); `undefined` is no policy. */
|
|
38
|
+
export declare function assertNoRetiredToolPolicyKeys(policy: object | undefined): void;
|
|
39
|
+
/** The `ShellReadBoundary` door ({@link RETIRED_SHELL_READ_BOUNDARY_KEYS}). */
|
|
40
|
+
export declare function assertNoRetiredShellReadBoundaryKeys(boundary: object): void;
|
|
@@ -30,3 +30,17 @@ export const RETIRED_TASK_SPEC_KEYS = Object.freeze({
|
|
|
30
30
|
"attachments.planModeReminder": "the read-only planning posture is stated whenever the leg's mode is `plan` (first turn, every 5 turns, and an exit frame when it ends) — drop the key",
|
|
31
31
|
"skills[].manifest": "a skill's tools are its `allowedTools` / `disallowedTools` now — an allow-rule and a deny-rule source for the run the skill is activated in, never a fence; move `manifest.allowTools` to `allowedTools`. To fence tools write deny rules (or a delegated agent definition's `allowTools`); to fence write paths use session `allowDirs`",
|
|
32
32
|
});
|
|
33
|
+
export const RETIRED_TOOL_POLICY_KEYS = Object.freeze({
|
|
34
|
+
writeTargetGuard: "the guarded write targets are stated as rows now — `ToolPolicy.writeGuardRows`, an async provider of the one path table's `PathGuardRow`s the leg's ONE write judgment reads for every writer the policy cannot see as a call (the shell's file commands). A wrapper carries it through `wrapToolPolicy`, which reads every member a policy declares",
|
|
35
|
+
});
|
|
36
|
+
export const RETIRED_SHELL_READ_BOUNDARY_KEYS = Object.freeze({
|
|
37
|
+
writeProtectionJudge: 'the station asks ONE write judgment, `ShellReadBoundary.writeTargetJudge`, over the write-protection table and the deployment\'s guarded write rows together — it answers `"protected"`, `"guarded"` or `undefined`, not a boolean',
|
|
38
|
+
writeTargetGuard: 'the deployment\'s guarded write rows join the same one judgment, `ShellReadBoundary.writeTargetJudge` (`"guarded"` for a target a `ToolPolicy.writeGuardRows` row covers) — the boundary has no second write seat',
|
|
39
|
+
});
|
|
40
|
+
export function assertNoRetiredToolPolicyKeys(policy) {
|
|
41
|
+
if (policy !== undefined)
|
|
42
|
+
assertNoRetiredKeys(policy, RETIRED_TOOL_POLICY_KEYS, "ToolPolicy");
|
|
43
|
+
}
|
|
44
|
+
export function assertNoRetiredShellReadBoundaryKeys(boundary) {
|
|
45
|
+
assertNoRetiredKeys(boundary, RETIRED_SHELL_READ_BOUNDARY_KEYS, "ShellReadBoundary");
|
|
46
|
+
}
|
package/dist/core/roles.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ThinkingLevel } from "../internal/harness-types.js";
|
|
2
2
|
import type { Model } from "../internal/llm.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type ModelRef, type ModelRole, type ModelRoles, type RoleSpec } from "./types.js";
|
|
4
4
|
export type { ModelRole, RoleSpec, ModelRoles } from "./types.js";
|
|
5
5
|
export { MODEL_ROLES } from "./types.js";
|
|
6
6
|
/** Resolve a string ModelRef against the catalog (a Model object passes through). */
|
|
@@ -85,10 +85,9 @@ export declare function parseModelMention(text: string, allowedNames: Iterable<s
|
|
|
85
85
|
* 各 role 未显式配置时自动落到语义档位——用户/壳只感知档位,roles 降级为内部路由层:
|
|
86
86
|
* - `default` → `pro`(主力档兜底;用户/部署 roles.default / TaskSpec.model 恒可覆盖);
|
|
87
87
|
* - `summarize` → `flash`(压缩本该便宜;flash 未绑沿降档链到 lite);
|
|
88
|
-
* - `advisor` → 第一档(`ultra` 起,未绑降档到 max/pro——teacher 用最强的);
|
|
89
88
|
* - `verifier` → `pro`;
|
|
90
89
|
* - `classifier` → `flash`(design/143 批2b:auto-mode 权限分类腿是便宜档;flash 未绑沿降档链到 lite);
|
|
91
|
-
* - `subagent
|
|
90
|
+
* - `subagent` 无档位默认 = 走 FALLBACK 继承主模型(LLM 可经 model 参数自选档);
|
|
92
91
|
* - `consolidate` 同样无档位默认,但它的 FALLBACK 刻意只有 `summarize` 一站(design/376,见
|
|
93
92
|
* {@link FALLBACK} 的注):未配即响亮拒,不静默骑主模型。
|
|
94
93
|
* 未配 tiers 的部署:catalog 无 TIERS_ACTIVE 标记 → 表整体 INERT,行为与从前逐字节一致
|
package/dist/core/roles.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { selectModel } from "./select-model.js";
|
|
2
|
+
import { MODEL_ROLES } from "./types.js";
|
|
2
3
|
export { MODEL_ROLES } from "./types.js";
|
|
3
4
|
export function resolveModel(ref, models) {
|
|
4
5
|
if (typeof ref !== "string") {
|
|
@@ -113,7 +114,6 @@ export function parseModelMention(text, allowedNames) {
|
|
|
113
114
|
export const ROLE_TIER_DEFAULTS = {
|
|
114
115
|
default: "pro",
|
|
115
116
|
summarize: "flash",
|
|
116
|
-
advisor: DEFAULT_TIER_ORDER[0],
|
|
117
117
|
verifier: "pro",
|
|
118
118
|
classifier: "flash",
|
|
119
119
|
};
|
|
@@ -127,9 +127,6 @@ const FALLBACK = {
|
|
|
127
127
|
default: [],
|
|
128
128
|
summarize: ["default"],
|
|
129
129
|
subagent: ["default"],
|
|
130
|
-
team: ["default"],
|
|
131
|
-
synthesize: ["team", "default"],
|
|
132
|
-
advisor: ["default"],
|
|
133
130
|
verifier: ["default"],
|
|
134
131
|
classifier: ["summarize", "default"],
|
|
135
132
|
consolidate: ["summarize"],
|
|
@@ -175,7 +172,19 @@ function mergeRoleSpec(base, over) {
|
|
|
175
172
|
systemPrompt: o.systemPrompt ?? b.systemPrompt,
|
|
176
173
|
};
|
|
177
174
|
}
|
|
175
|
+
function assertKnownRole(word, seat) {
|
|
176
|
+
if (typeof word === "string" && MODEL_ROLES.includes(word))
|
|
177
|
+
return;
|
|
178
|
+
const shown = typeof word === "string" ? JSON.stringify(word).slice(0, 80) : `<${word === null ? "null" : typeof word}>`;
|
|
179
|
+
const e = new Error(`${seat} names the model role ${shown}, which is not one of ${MODEL_ROLES.join(" / ")} — a word outside the vocabulary binds nothing and resolves nothing; bind the model on one of these roles, or name it on TaskSpec.model`);
|
|
180
|
+
e.code = "config.unknown_role";
|
|
181
|
+
throw e;
|
|
182
|
+
}
|
|
178
183
|
function mergeRoles(base, over) {
|
|
184
|
+
for (const key of Object.keys(base ?? {}))
|
|
185
|
+
assertKnownRole(key, "RunnerDeps.roles key");
|
|
186
|
+
for (const key of Object.keys(over ?? {}))
|
|
187
|
+
assertKnownRole(key, "TaskSpec.roles key");
|
|
179
188
|
const out = { ...base };
|
|
180
189
|
for (const role of Object.keys(over ?? {})) {
|
|
181
190
|
out[role] = mergeRoleSpec(base?.[role], over?.[role]);
|
|
@@ -192,8 +201,9 @@ function partsModel(parts, models) {
|
|
|
192
201
|
return undefined;
|
|
193
202
|
}
|
|
194
203
|
export function resolveTaskModel(spec, deps) {
|
|
204
|
+
const start = spec.modelRole ?? "default";
|
|
205
|
+
assertKnownRole(start, "modelRole");
|
|
195
206
|
if (spec.model) {
|
|
196
|
-
const start = spec.modelRole ?? "default";
|
|
197
207
|
const startParts = specParts(mergeRoles(deps.roles, spec.roles)[start]);
|
|
198
208
|
return {
|
|
199
209
|
model: resolveModel(spec.model, deps.models),
|
|
@@ -202,7 +212,6 @@ export function resolveTaskModel(spec, deps) {
|
|
|
202
212
|
systemPrompt: startParts.systemPrompt,
|
|
203
213
|
};
|
|
204
214
|
}
|
|
205
|
-
const start = spec.modelRole ?? "default";
|
|
206
215
|
const merged = mergeRoles(deps.roles, spec.roles);
|
|
207
216
|
const startSystemPrompt = specParts(merged[start]).systemPrompt;
|
|
208
217
|
for (const role of [start, ...FALLBACK[start]]) {
|
|
@@ -214,13 +214,6 @@ export interface ResultFlags {
|
|
|
214
214
|
* somehow set — are gone with the commit-side routing that fed them. */
|
|
215
215
|
paused?: PausedCause;
|
|
216
216
|
}
|
|
217
|
-
/**
|
|
218
|
-
* Extract a machine-readable code from a thrown error (e.g. `SessionError.code`, a Node error code).
|
|
219
|
-
* Walks the `cause` chain because the harness wraps lower-level errors (e.g. a `SessionError("conflict")`
|
|
220
|
-
* append failure surfaces as an `AgentHarnessError("unknown")` whose cause is the real one) — so we
|
|
221
|
-
* prefer the first specific code over a generic `"unknown"` wrapper.
|
|
222
|
-
*/
|
|
223
|
-
export declare function errorCodeOf(err: unknown): string | undefined;
|
|
224
217
|
/**
|
|
225
218
|
* WHY the run ended — the ONE terminal arbitration ({@link TerminalCause}). First match wins, in the
|
|
226
219
|
* slot order documented on {@link assembleResult} (a public contract: do not reorder). Every plane
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isDegenerateCutMessage } from "../../brain/terminal-cause.js";
|
|
2
2
|
import { extractErrorCode, isProviderEchoShape, refusedTheRequest, stripErrorCodePrefix } from "../../brain/errors.js";
|
|
3
|
+
import { completedTerminalOf, modelOutputInvalidOfMessage, providerVerdictOf, requestRouteOfMessage, thrownFailureOf } from "./terminal-account.js";
|
|
3
4
|
import { terminalProjection } from "./terminal-projection.js";
|
|
4
5
|
import { haltConsumed } from "./halt-attribution.js";
|
|
5
6
|
import { providerReportedModel } from "../message-utils.js";
|
|
@@ -22,21 +23,6 @@ function thrownMessage(threw) {
|
|
|
22
23
|
}
|
|
23
24
|
return describeRejectedValue(threw);
|
|
24
25
|
}
|
|
25
|
-
export function errorCodeOf(err) {
|
|
26
|
-
let cur = err;
|
|
27
|
-
let fallback;
|
|
28
|
-
for (let depth = 0; cur !== null && cur !== undefined && typeof cur === "object" && depth < 8; depth++) {
|
|
29
|
-
const code = readMember(cur, "code");
|
|
30
|
-
if (typeof code === "string" && code) {
|
|
31
|
-
if (code !== "unknown") {
|
|
32
|
-
return code;
|
|
33
|
-
}
|
|
34
|
-
fallback ??= code;
|
|
35
|
-
}
|
|
36
|
-
cur = readMember(cur, "cause");
|
|
37
|
-
}
|
|
38
|
-
return fallback;
|
|
39
|
-
}
|
|
40
26
|
function stripThinkTags(text) {
|
|
41
27
|
let t = text.replace(/<think>[\s\S]*?<\/think>/gi, "");
|
|
42
28
|
const lower = t.toLowerCase();
|
|
@@ -95,15 +81,11 @@ export function terminalCauseOf(final, stats, flags) {
|
|
|
95
81
|
terminal = { kind: "failed", code: "suspend.loop", message };
|
|
96
82
|
}
|
|
97
83
|
else if (flags.threw) {
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
: flags.conflict
|
|
104
|
-
? "conflict"
|
|
105
|
-
: errorCodeOf(flags.threw);
|
|
106
|
-
terminal = { kind: "failed", ...(code !== undefined ? { code } : {}), message };
|
|
84
|
+
const thrown = thrownFailureOf(flags.threw, thrownMessage(flags.threw));
|
|
85
|
+
const axisCode = flags.abortedForTimeout ? "limits.max_walltime_exceeded" : flags.abortedForTurns ? "limits.max_turns_exceeded" : flags.conflict ? "conflict" : undefined;
|
|
86
|
+
const code = axisCode ?? thrown.code;
|
|
87
|
+
const detail = axisCode === undefined ? thrown.detail : undefined;
|
|
88
|
+
terminal = { kind: "failed", ...(code !== undefined ? { code } : {}), message: thrown.message, ...(detail !== undefined ? { detail } : {}) };
|
|
107
89
|
}
|
|
108
90
|
else if (flags.blockedReason) {
|
|
109
91
|
terminal = { kind: "blocked", reason: flags.blockedReason, ...(flags.blockedDetail !== undefined ? { detail: flags.blockedDetail } : {}) };
|
|
@@ -134,7 +116,7 @@ export function terminalCauseOf(final, stats, flags) {
|
|
|
134
116
|
...(typeof apiRequestId === "string" && isProviderEchoShape(apiRequestId) ? { requestId: apiRequestId } : {}),
|
|
135
117
|
};
|
|
136
118
|
}
|
|
137
|
-
let
|
|
119
|
+
let messageNamed = true;
|
|
138
120
|
const lifted = extractErrorCode(message);
|
|
139
121
|
if (lifted) {
|
|
140
122
|
code = lifted;
|
|
@@ -142,22 +124,28 @@ export function terminalCauseOf(final, stats, flags) {
|
|
|
142
124
|
}
|
|
143
125
|
else if (flags.gitCoreOverBudget) {
|
|
144
126
|
code = "irreducible_core_over_budget";
|
|
145
|
-
|
|
127
|
+
messageNamed = false;
|
|
146
128
|
}
|
|
147
129
|
else if (flags.conflict) {
|
|
148
130
|
code = "conflict";
|
|
149
|
-
|
|
131
|
+
messageNamed = false;
|
|
150
132
|
}
|
|
151
133
|
else {
|
|
152
134
|
code = "provider.error";
|
|
153
135
|
}
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
136
|
+
const outputInvalid = apiError ? undefined : modelOutputInvalidOfMessage(final);
|
|
137
|
+
let detail;
|
|
138
|
+
if (messageNamed && apiError && typeof apiStatus === "number" && refusedTheRequest(apiStatus)) {
|
|
139
|
+
const route = requestRouteOfMessage(final);
|
|
140
|
+
detail = { kind: "provider_rejected", status: apiStatus, ...(typeof apiCode === "string" && isProviderEchoShape(apiCode) ? { code: apiCode } : {}), ...providerVerdictOf(final), ...(route !== undefined ? { route } : {}) };
|
|
141
|
+
}
|
|
142
|
+
else if (messageNamed && outputInvalid !== undefined) {
|
|
143
|
+
detail = { kind: "model_output_invalid", ...outputInvalid };
|
|
144
|
+
}
|
|
157
145
|
terminal = { kind: "failed", code, message, ...(detail !== undefined ? { detail } : {}) };
|
|
158
146
|
}
|
|
159
147
|
else {
|
|
160
|
-
terminal =
|
|
148
|
+
terminal = completedTerminalOf(final);
|
|
161
149
|
}
|
|
162
150
|
return { terminal, apiFailure };
|
|
163
151
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The caller roster's ONE snapshot (#1167). A run's tool roster is the caller's `spec.tools` as it stands when prepare
|
|
3
|
+
* starts reading the request — before its first await — and nothing later, down to each entry's members: the driver
|
|
4
|
+
* rebinds onto a private copy of the spec whose `tools` is an own, fixed data property — a frozen array of frozen entry
|
|
5
|
+
* FACES, each member read once (an omitted roster stays omitted, a value that is no array stays as read), never the
|
|
6
|
+
* caller's accessor or an inherited one. The safety scan, the mount, the listings and every other phase read those faces,
|
|
7
|
+
* so no phase can read the caller's objects a second time after a caller microtask had the chance to change them —
|
|
8
|
+
* not the array (a push, a reassignment of `spec.tools`) and not an entry (a name, an effect or egress mark, a schema,
|
|
9
|
+
* the `execute` function swapped in place, a getter or a Proxy answering differently on a later read).
|
|
10
|
+
*
|
|
11
|
+
* The snapshot holds no live entry. Every object entry (a function included) becomes a face: its own enumerable members
|
|
12
|
+
* (string and symbol keys — what the mount's spread carries) plus every ToolSpec member name read through an ordinary
|
|
13
|
+
* property read (how the phases read a declaration — non-enumerable, inherited or Proxy-answered included), each read once;
|
|
14
|
+
* every declaration value is deep-copied and frozen by the one copier. A primitive is immutable and stays as read. A
|
|
15
|
+
* read that throws refuses the run at the snapshot. Whether the ToolSpec arm can build the entry ({@link specArmCanConstruct})
|
|
16
|
+
* is asked of the entry once, there, and recorded on its face ({@link specArmCanBuild}); the mount refuses an entry it
|
|
17
|
+
* cannot build from that record, so an `execute` that grows on the caller's object later is never read. The mount calls a
|
|
18
|
+
* spec face's `execute` with the caller's own object as `this` ({@link callerEntryOrigin}). A `defineTool` product's face is
|
|
19
|
+
* what every phase reads in its place, and the mount keeps the one authenticated rebind of the product object itself
|
|
20
|
+
* ({@link rebindProductEntry}; the factory's seal refuses a product whose `execute` was replaced or which is not the object
|
|
21
|
+
* it stamped): the factory rebuilds the product from its own members at the mount, and the run is refused when the rebuilt
|
|
22
|
+
* product no longer answers as its face did. The tool a product mounts as is built from that face around the rebound
|
|
23
|
+
* `execute`, never the rebuilt object itself (it shares list members and accessors with the caller's product): the
|
|
24
|
+
* brand is asked once, here at the snapshot, and no object the caller can reach is ever a mounted tool.
|
|
25
|
+
*
|
|
26
|
+
* An array the caller changes after that instant is refused instead of run without the change:
|
|
27
|
+
* {@link refuseLateRosterChanges}, called once at the end of prepare, re-reads the caller's `spec.tools` and refuses
|
|
28
|
+
* the run with the declaration door's code (`config.tool_mount_denied`) naming every entry that is not, in order, the
|
|
29
|
+
* object the snapshot read (a getter that hands back a fresh array of the same objects is not a change). A change to an
|
|
30
|
+
* entry's members is not compared — the run never reads them again. A change after prepare returned is read by nothing.
|
|
31
|
+
*/
|
|
32
|
+
import type { AgentTool } from "../../internal/harness.js";
|
|
33
|
+
import type { TaskSpec } from "../types.js";
|
|
34
|
+
import type { ToolSpec } from "../tool-spec.js";
|
|
35
|
+
import { type ToolCtxEnricher } from "../tools.js";
|
|
36
|
+
declare const ROSTER_FACE: unique symbol;
|
|
37
|
+
/** A roster entry as the snapshot minted it. The brand is private to this module and {@link rosterFaceOf} is the only
|
|
38
|
+
* function that returns one, so a phase that takes `RosterFace`s cannot be handed a live caller object: code that tries
|
|
39
|
+
* to put one into the roster does not compile. */
|
|
40
|
+
export type RosterFace = ToolSpec & {
|
|
41
|
+
readonly [ROSTER_FACE]: true;
|
|
42
|
+
};
|
|
43
|
+
/** A task spec whose tool roster is faces — what the driver and every phase that reads the roster hold after the snapshot. */
|
|
44
|
+
export type RosterSpec = Omit<TaskSpec, "tools"> & {
|
|
45
|
+
tools?: RosterFace[];
|
|
46
|
+
};
|
|
47
|
+
/** What the refusal compares: the caller's own spec (re-read, never mutated here) and the objects the snapshot read
|
|
48
|
+
* (`undefined` when the roster was not an array — an omitted roster snapshots as no entries, a non-array value is the
|
|
49
|
+
* doors' to judge and is not compared). */
|
|
50
|
+
export interface CallerRosterSnapshot {
|
|
51
|
+
readonly caller: TaskSpec;
|
|
52
|
+
readonly handed: readonly unknown[] | undefined;
|
|
53
|
+
}
|
|
54
|
+
/** The object a snapshot face was read from (the entry itself when it was held as handed). */
|
|
55
|
+
export declare function callerEntryOrigin(entry: object): object;
|
|
56
|
+
/** Can the mount's ToolSpec arm build this roster entry? Only the verdict recorded at the snapshot answers: an object that
|
|
57
|
+
* is no face of this snapshot, a primitive, a product's face, is not built from. */
|
|
58
|
+
export declare function specArmCanBuild(entry: RosterFace): boolean;
|
|
59
|
+
/** One entry of the roster, and the ONLY place a {@link RosterFace} is minted. Every object entry (a function included) becomes a frozen face, so no entry the snapshot holds is a
|
|
60
|
+
* live object: a primitive is immutable and stays as read; a `defineTool` product's face names the product for its sealed
|
|
61
|
+
* rebind; an entry the ToolSpec arm cannot build gets a face too, and the mount refuses it from the verdict recorded here —
|
|
62
|
+
* an `execute` or a mark that grows on the caller's object afterwards is never read. A read that throws refuses the run. */
|
|
63
|
+
export declare function rosterFaceOf(t: unknown, index: number): RosterFace;
|
|
64
|
+
/** The mount's arm for a roster entry that is the face of a `defineTool` product: the exact product object is rebound to
|
|
65
|
+
* the run's ctx through the factory's sealed seat, compared with its face ({@link refuseProductDrift}), and the tool the
|
|
66
|
+
* run mounts is built from the face around the rebound `execute` ({@link mountedProduct}). `undefined` when the entry is
|
|
67
|
+
* not a product's face (the mount's ToolSpec arm takes it). */
|
|
68
|
+
export declare function rebindProductEntry(entry: object, enrich: ToolCtxEnricher): AgentTool | undefined;
|
|
69
|
+
/** Take the snapshot and rebind onto a private spec copy carrying it. The copy keeps the caller's prototype and every own
|
|
70
|
+
* property descriptor (an inherited or non-enumerable request field reads exactly as it did on the caller's spec); only
|
|
71
|
+
* `tools` becomes the copy's own frozen array of faces when the request carried one. */
|
|
72
|
+
export declare function snapshotCallerRoster(spec: TaskSpec): {
|
|
73
|
+
spec: RosterSpec;
|
|
74
|
+
roster: CallerRosterSnapshot;
|
|
75
|
+
};
|
|
76
|
+
/** Refuse the run when the caller's `spec.tools` no longer holds exactly the objects the snapshot read, in order. */
|
|
77
|
+
export declare function refuseLateRosterChanges(roster: CallerRosterSnapshot): void;
|
|
78
|
+
export {};
|