@sema-agent/core 7.67.2 → 7.68.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 +1533 -0
- package/README.md +18 -9
- package/README.zh-CN.md +16 -8
- package/dist/agents/agent-definition.d.ts +1 -1
- package/dist/agents/agent-definition.js +4 -1
- package/dist/agents/cascade.d.ts +2 -2
- package/dist/agents/cascade.js +3 -1
- package/dist/agents/cumulative-stats.d.ts +2 -1
- package/dist/agents/cumulative-stats.js +4 -1
- package/dist/agents/list-agents-tool.d.ts +30 -0
- package/dist/agents/list-agents-tool.js +45 -3
- package/dist/agents/peer-admission.d.ts +2 -2
- package/dist/agents/peer-session-drain.d.ts +2 -0
- package/dist/agents/peer-session-drain.js +1 -0
- package/dist/agents/repair-loop.js +3 -1
- package/dist/agents/retain-ledger.d.ts +61 -8
- package/dist/agents/retain-ledger.js +25 -3
- package/dist/agents/roster-store.d.ts +4 -2
- package/dist/agents/send-message-tool.d.ts +1 -1
- package/dist/agents/send-message-tool.js +20 -15
- package/dist/agents/subagent-steps.js +2 -10
- package/dist/agents/subagent.d.ts +3 -0
- package/dist/agents/subagent.js +106 -76
- package/dist/agents/tool-filter.d.ts +20 -11
- package/dist/agents/tool-filter.js +8 -4
- package/dist/agents/verify.d.ts +3 -1
- package/dist/agents/verify.js +2 -0
- package/dist/brain/anthropic.js +4 -4
- package/dist/brain/errors.d.ts +20 -0
- package/dist/brain/errors.js +114 -0
- package/dist/brain/open-responses.js +3 -1
- package/dist/brain/openai.js +3 -1
- package/dist/brain/provider-message.d.ts +5 -3
- package/dist/brain/provider-message.js +35 -8
- package/dist/brain/reasoning-request.d.ts +73 -19
- package/dist/brain/reasoning-request.js +164 -72
- package/dist/brain/reasoning-stamp.d.ts +26 -0
- package/dist/brain/reasoning-stamp.js +10 -0
- package/dist/brain/reasoning.d.ts +95 -162
- package/dist/brain/reasoning.js +31 -86
- package/dist/brain/route-adjudicator.d.ts +9 -7
- package/dist/brain/route-adjudicator.js +12 -10
- package/dist/brain/status-sink.d.ts +19 -64
- package/dist/brain/status-sink.js +5 -21
- package/dist/brain/stream-engine.d.ts +11 -2
- package/dist/brain/stream-engine.js +10 -0
- package/dist/core/a2a.d.ts +17 -5
- package/dist/core/a2a.js +11 -3
- package/dist/core/allow-entry.d.ts +35 -15
- package/dist/core/allow-entry.js +47 -60
- package/dist/core/ask-headline.d.ts +68 -0
- package/dist/core/ask-headline.js +23 -0
- package/dist/core/ask-origin.d.ts +36 -8
- package/dist/core/ask-origin.js +17 -10
- package/dist/core/ask-question.d.ts +34 -7
- package/dist/core/ask-question.js +10 -1
- package/dist/core/ask-unresolvable-notice.d.ts +7 -0
- package/dist/core/ask-unresolvable-notice.js +9 -3
- package/dist/core/auto-strip.d.ts +53 -0
- package/dist/core/auto-strip.js +76 -0
- package/dist/core/background-agent-store.d.ts +45 -5
- package/dist/core/background-agent-store.js +69 -15
- package/dist/core/background-shell.d.ts +2 -2
- package/dist/core/caller-text.js +2 -2
- package/dist/core/canonical-json.d.ts +13 -0
- package/dist/core/canonical-json.js +7 -0
- package/dist/core/checkpoint-features.d.ts +66 -20
- package/dist/core/checkpoint-features.js +12 -1
- package/dist/core/checkpoint-generation.d.ts +1 -1
- package/dist/core/checkpoint-queries.d.ts +1 -1
- package/dist/core/checkpoint-queries.js +4 -1
- package/dist/core/checkpoint-requirements.d.ts +25 -1
- package/dist/core/checkpoint-requirements.js +5 -1
- package/dist/core/checkpoint-row-verdict.d.ts +1 -0
- package/dist/core/checkpoint-row-verdict.js +4 -0
- package/dist/core/checkpoint-store.d.ts +66 -38
- package/dist/core/checkpoint-store.js +15 -6
- package/dist/core/child-clamp-seats.d.ts +6 -0
- package/dist/core/child-clamp-seats.js +1 -0
- package/dist/core/config-refusal-codes.d.ts +1 -1
- package/dist/core/config-refusal-codes.js +1 -0
- package/dist/core/delegation-frames.d.ts +9 -12
- package/dist/core/delegation-frames.js +9 -8
- package/dist/core/engine-capabilities.d.ts +21 -8
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +147 -34
- package/dist/core/engine-notice.js +27 -16
- package/dist/core/engine-storage-backend.d.ts +2 -1
- package/dist/core/env-budget.js +3 -3
- package/dist/core/env-knob-announce.d.ts +10 -10
- package/dist/core/env-knob-announce.js +3 -6
- package/dist/core/file-history-store.d.ts +29 -4
- package/dist/core/file-history-store.js +13 -0
- package/dist/core/frame-settlement.d.ts +2 -1
- package/dist/core/gate-fold.js +1 -1
- package/dist/core/gate-lanes.js +56 -49
- package/dist/core/governance-codes.d.ts +39 -3
- package/dist/core/governance-codes.js +61 -3
- package/dist/core/hooks.d.ts +29 -11
- package/dist/core/hooks.js +5 -2
- package/dist/core/human-input-projection.js +3 -3
- package/dist/core/input-author.d.ts +17 -3
- package/dist/core/input-author.js +15 -3
- package/dist/core/leg-identity.d.ts +10 -28
- package/dist/core/leg-identity.js +1 -21
- package/dist/core/lsp.d.ts +18 -13
- package/dist/core/lsp.js +30 -22
- package/dist/core/mailbox-store.d.ts +1 -1
- package/dist/core/mailbox-store.js +4 -4
- package/dist/core/mcp-connection-pool.d.ts +93 -4
- package/dist/core/mcp-connection-pool.js +104 -1
- package/dist/core/mcp-failure.d.ts +38 -12
- package/dist/core/mcp-failure.js +9 -13
- package/dist/core/mcp-probe.d.ts +4 -3
- package/dist/core/mcp-server-link.d.ts +4 -2
- package/dist/core/mcp-server-link.js +4 -5
- package/dist/core/mcp-server-spec.d.ts +3 -3
- package/dist/core/mcp-server-unavailable-notice.d.ts +22 -8
- package/dist/core/mcp-server-unavailable-notice.js +18 -4
- package/dist/core/mcp.d.ts +40 -6
- package/dist/core/mcp.js +39 -13
- package/dist/core/memory-engine/content-origin.js +2 -2
- package/dist/core/memory-engine/control-objects.d.ts +2 -4
- package/dist/core/memory-engine/control-objects.js +2 -10
- package/dist/core/memory-engine/delegation-settlement.js +6 -1
- package/dist/core/memory-engine/dual-root.js +3 -0
- package/dist/core/memory-engine/engine.d.ts +6 -4
- package/dist/core/memory-engine/engine.js +32 -29
- package/dist/core/memory-engine/file-backend.d.ts +20 -5
- package/dist/core/memory-engine/file-backend.js +21 -31
- package/dist/core/memory-engine/frontmatter.d.ts +2 -0
- package/dist/core/memory-engine/frontmatter.js +4 -0
- package/dist/core/memory-engine/layout.d.ts +114 -20
- package/dist/core/memory-engine/layout.js +340 -22
- package/dist/core/memory-engine/memory-deployment.d.ts +7 -5
- package/dist/core/memory-engine/mount-failed-notice.d.ts +19 -7
- package/dist/core/memory-engine/mount-failed-notice.js +43 -10
- package/dist/core/memory-engine/sync-client.js +4 -5
- package/dist/core/model-fallbacks.d.ts +5 -1
- package/dist/core/model-fallbacks.js +3 -3
- package/dist/core/model-receipt.d.ts +2 -1
- package/dist/core/model-receipt.js +12 -1
- package/dist/core/mods/kernel/dispatch.d.ts +2 -2
- package/dist/core/mods/kernel/dispatch.js +14 -6
- package/dist/core/mods/kernel/events.d.ts +8 -5
- package/dist/core/mods/kernel/events.js +2 -2
- package/dist/core/mods/kernel/index.d.ts +1 -1
- package/dist/core/mods/kernel/registration.d.ts +9 -0
- package/dist/core/mods/package.js +1 -1
- package/dist/core/mods/session-append.d.ts +4 -2
- package/dist/core/mods/session-append.js +3 -0
- package/dist/core/mods/stations.d.ts +7 -11
- package/dist/core/mods/stations.js +4 -7
- package/dist/core/mods/tool-call.d.ts +10 -8
- package/dist/core/mods/tool-call.js +15 -18
- package/dist/core/mounted-mcp.d.ts +0 -4
- package/dist/core/mounted-mcp.js +1 -1
- package/dist/core/park-noun.d.ts +24 -0
- package/dist/core/park-noun.js +21 -0
- package/dist/core/park-resumability.d.ts +60 -0
- package/dist/core/park-resumability.js +30 -0
- package/dist/core/permission-rule-provider.d.ts +24 -2
- package/dist/core/permission-rule-provider.js +11 -8
- package/dist/core/permission-rule-store.d.ts +8 -1
- package/dist/core/permission-rule-store.js +2 -3
- package/dist/core/permission-rules.d.ts +2 -1
- package/dist/core/permission-rules.js +8 -4
- package/dist/core/persisted-rule-arms.d.ts +3 -0
- package/dist/core/persisted-rule-arms.js +2 -1
- package/dist/core/present-plan-tool.d.ts +47 -3
- package/dist/core/present-plan-tool.js +62 -4
- package/dist/core/principal-name.d.ts +1 -1
- package/dist/core/principal-name.js +5 -5
- package/dist/core/process-identity.js +10 -5
- package/dist/core/protocol-http-auth.d.ts +30 -9
- package/dist/core/protocol-http-auth.js +113 -59
- package/dist/core/read-only-shell.js +9 -5
- package/dist/core/redaction-marks.d.ts +4 -26
- package/dist/core/redaction-marks.js +9 -21
- package/dist/core/remote-env.d.ts +43 -16
- package/dist/core/remote-env.js +1 -1
- package/dist/core/request-copy-projection.d.ts +1 -1
- package/dist/core/request-copy-projection.js +40 -50
- package/dist/core/resume-config-judge.js +1 -1
- package/dist/core/resume-startup-cause.d.ts +35 -18
- package/dist/core/resume-startup-cause.js +13 -10
- package/dist/core/retention.d.ts +167 -25
- package/dist/core/retention.js +100 -20
- package/dist/core/roles.d.ts +6 -0
- package/dist/core/roles.js +11 -5
- package/dist/core/rule-lane-reads.d.ts +3 -0
- package/dist/core/rule-lane-reads.js +5 -1
- package/dist/core/rule-store-fault.d.ts +70 -0
- package/dist/core/rule-store-fault.js +102 -0
- package/dist/core/runner/advertised-writable-dirs.js +16 -31
- package/dist/core/runner/announce-once-ledger.d.ts +19 -2
- package/dist/core/runner/announce-once-ledger.js +24 -2
- package/dist/core/runner/assemble-result.d.ts +6 -0
- package/dist/core/runner/assemble-result.js +1 -1
- package/dist/core/runner/auto-strip-notice.d.ts +36 -0
- package/dist/core/runner/auto-strip-notice.js +59 -0
- package/dist/core/runner/branch-window.d.ts +3 -0
- package/dist/core/runner/branch-window.js +37 -0
- package/dist/core/runner/caller-roster.d.ts +8 -3
- package/dist/core/runner/capability-withheld-seat.js +3 -9
- package/dist/core/runner/clock-and-limits.d.ts +22 -1
- package/dist/core/runner/clock-and-limits.js +30 -0
- package/dist/core/runner/contracts.d.ts +58 -35
- package/dist/core/runner/credential-refusal-seat.d.ts +2 -0
- package/dist/core/runner/credential-refusal-seat.js +47 -0
- package/dist/core/runner/cross-boundary-lane.js +6 -4
- package/dist/core/runner/decide-continuation.js +1 -1
- package/dist/core/runner/file-history-restore.d.ts +53 -2
- package/dist/core/runner/file-history-restore.js +29 -10
- package/dist/core/runner/forward-sink.d.ts +14 -1
- package/dist/core/runner/forward-sink.js +14 -12
- package/dist/core/runner/gate-exit.d.ts +8 -7
- package/dist/core/runner/gate-exit.js +13 -13
- package/dist/core/runner/git-status-frame.js +2 -4
- package/dist/core/runner/initial-run-state.js +1 -1
- package/dist/core/runner/main-call-account.d.ts +3 -1
- package/dist/core/runner/main-call-account.js +5 -3
- package/dist/core/runner/mcp-redial.d.ts +2 -5
- package/dist/core/runner/mcp-redial.js +2 -2
- package/dist/core/runner/nested-memory-content.d.ts +7 -1
- package/dist/core/runner/nested-memory-content.js +73 -13
- package/dist/core/runner/nested-memory-lane.d.ts +44 -19
- package/dist/core/runner/nested-memory-lane.js +152 -76
- package/dist/core/runner/park-commit.js +3 -1
- package/dist/core/runner/permission-rule-lanes.d.ts +8 -2
- package/dist/core/runner/permission-rule-lanes.js +29 -3
- package/dist/core/runner/person-path-rows.d.ts +3 -11
- package/dist/core/runner/person-path-rows.js +21 -24
- package/dist/core/runner/prepare-acquire-reconcile.js +3 -1
- package/dist/core/runner/prepare-artifact.d.ts +1 -1
- package/dist/core/runner/prepare-artifact.js +20 -14
- package/dist/core/runner/prepare-ask-lane.d.ts +9 -6
- package/dist/core/runner/prepare-ask-lane.js +6 -5
- package/dist/core/runner/prepare-boundary-parks.d.ts +7 -1
- package/dist/core/runner/prepare-boundary-parks.js +27 -24
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -2
- package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
- package/dist/core/runner/prepare-config-doors.d.ts +9 -24
- package/dist/core/runner/prepare-config-doors.js +58 -41
- package/dist/core/runner/prepare-context-lane.d.ts +2 -2
- package/dist/core/runner/prepare-context-lane.js +3 -5
- package/dist/core/runner/prepare-defer-classify.d.ts +1 -1
- package/dist/core/runner/prepare-defer-classify.js +1 -1
- package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
- package/dist/core/runner/prepare-delegation-surface.js +3 -2
- package/dist/core/runner/prepare-file-history.d.ts +62 -26
- package/dist/core/runner/prepare-file-history.js +117 -46
- package/dist/core/runner/prepare-gate-stations.d.ts +4 -0
- package/dist/core/runner/prepare-gate-stations.js +6 -5
- package/dist/core/runner/prepare-hands-readface.d.ts +9 -4
- package/dist/core/runner/prepare-hands-readface.js +8 -4
- package/dist/core/runner/prepare-inherited-gate.d.ts +11 -4
- package/dist/core/runner/prepare-inherited-gate.js +6 -6
- package/dist/core/runner/prepare-listings.d.ts +1 -1
- package/dist/core/runner/prepare-listings.js +1 -1
- package/dist/core/runner/prepare-memory.js +2 -2
- package/dist/core/runner/prepare-offload-wrappers.d.ts +1 -1
- package/dist/core/runner/prepare-offload-wrappers.js +1 -1
- package/dist/core/runner/prepare-park-ask.d.ts +10 -3
- package/dist/core/runner/prepare-park-ask.js +7 -9
- package/dist/core/runner/prepare-policy-chain.d.ts +18 -9
- package/dist/core/runner/prepare-policy-chain.js +18 -13
- package/dist/core/runner/prepare-project-context.d.ts +1 -1
- package/dist/core/runner/prepare-project-context.js +5 -3
- package/dist/core/runner/prepare-prompt-assembly.js +2 -1
- package/dist/core/runner/prepare-prompt-inputs.d.ts +2 -2
- package/dist/core/runner/prepare-prompt-inputs.js +1 -1
- package/dist/core/runner/prepare-protocol-tools.d.ts +4 -5
- package/dist/core/runner/prepare-protocol-tools.js +7 -7
- package/dist/core/runner/prepare-question-face.d.ts +4 -2
- package/dist/core/runner/prepare-run-refs.d.ts +7 -2
- package/dist/core/runner/prepare-run-refs.js +8 -7
- package/dist/core/runner/prepare-safety-scan.d.ts +4 -3
- package/dist/core/runner/prepare-suspend-saga.d.ts +3 -7
- package/dist/core/runner/prepare-suspend-saga.js +4 -3
- package/dist/core/runner/prepare-task.js +66 -53
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +3 -2
- package/dist/core/runner/prepare-tool-disclosure-mount.js +2 -1
- package/dist/core/runner/prepare-turn-wiring.d.ts +3 -1
- package/dist/core/runner/prepare-turn-wiring.js +1 -1
- package/dist/core/runner/prepare-wiring-manifest.d.ts +9 -4
- package/dist/core/runner/prepare-wiring-manifest.js +14 -6
- package/dist/core/runner/prepare-workspace-restore.d.ts +4 -4
- package/dist/core/runner/prepare-workspace-restore.js +15 -6
- package/dist/core/runner/remote-env-retry.d.ts +3 -3
- package/dist/core/runner/restore-seat.d.ts +41 -0
- package/dist/core/runner/restore-seat.js +38 -0
- package/dist/core/runner/resume-admission.js +1 -1
- package/dist/core/runner/resume-apply.js +4 -3
- package/dist/core/runner/resume-checkpoint-screen.js +2 -1
- package/dist/core/runner/resume-internals-and-config.js +2 -1
- package/dist/core/runner/resume-preflight.js +2 -1
- package/dist/core/runner/rewind-files.js +22 -6
- package/dist/core/runner/rule-store-unreadable-notice.d.ts +8 -0
- package/dist/core/runner/rule-store-unreadable-notice.js +11 -0
- package/dist/core/runner/run-brain-sinks.d.ts +3 -6
- package/dist/core/runner/run-brain-sinks.js +6 -6
- package/dist/core/runner/run-compaction-machinery.d.ts +2 -2
- package/dist/core/runner/run-git-lane.d.ts +2 -0
- package/dist/core/runner/run-git-lane.js +2 -1
- package/dist/core/runner/run-harness-handlers.js +5 -4
- package/dist/core/runner/run-identity-wiring.js +20 -12
- package/dist/core/runner/run-leg.js +31 -72
- package/dist/core/runner/run-notification-lane.d.ts +3 -0
- package/dist/core/runner/run-notification-lane.js +2 -4
- package/dist/core/runner/run-reasoning-seat.d.ts +5 -6
- package/dist/core/runner/run-reasoning-seat.js +13 -18
- package/dist/core/runner/run-settle-and-teardown.js +13 -9
- package/dist/core/runner/run-terminal-adoption.js +4 -8
- package/dist/core/runner/run-turn-boundary.js +6 -3
- package/dist/core/runner/runtask.d.ts +9 -4
- package/dist/core/runner/runtask.js +29 -22
- package/dist/core/runner/session-rule-policy.d.ts +11 -1
- package/dist/core/runner/shell-env-withheld.js +2 -7
- package/dist/core/runner/side-call-account.d.ts +5 -6
- package/dist/core/runner/side-call-account.js +2 -2
- package/dist/core/runner/stream-lifecycle-verbs.d.ts +3 -0
- package/dist/core/runner/stream-lifecycle-verbs.js +5 -3
- package/dist/core/runner/stream-settle-backstop.js +4 -6
- package/dist/core/runner/stream-steer-verb.d.ts +1 -1
- package/dist/core/runner/stream-steer-verb.js +4 -4
- package/dist/core/runner/sub-agent-deny-lists.d.ts +8 -3
- package/dist/core/runner/sub-agent-deny-lists.js +7 -4
- package/dist/core/runner/teardown-bounded.d.ts +7 -0
- package/dist/core/runner/teardown-bounded.js +7 -0
- package/dist/core/runner/terminal-account.js +41 -13
- package/dist/core/runner/terminal-projection.d.ts +1 -5
- package/dist/core/runner/tool-end-body.d.ts +9 -3
- package/dist/core/runner/tool-end-body.js +6 -3
- package/dist/core/runner/tool-output-projection.d.ts +13 -4
- package/dist/core/runner/tool-output-projection.js +10 -14
- package/dist/core/runner/turn-attachments.d.ts +3 -2
- package/dist/core/runner/turn-attachments.js +12 -5
- package/dist/core/runner-deps.d.ts +6 -6
- package/dist/core/runtime-caps.d.ts +2 -1
- package/dist/core/secret-env.d.ts +20 -3
- package/dist/core/secret-env.js +13 -15
- package/dist/core/session-checkout.d.ts +115 -15
- package/dist/core/session-checkout.js +435 -136
- package/dist/core/session-policy-store.js +21 -3
- package/dist/core/session-reconcile.js +1 -0
- package/dist/core/session-store.js +2 -0
- package/dist/core/session.d.ts +11 -1
- package/dist/core/shell-run-candidates.d.ts +1 -0
- package/dist/core/shell-run-candidates.js +1 -1
- package/dist/core/shutdown-debug.d.ts +6 -5
- package/dist/core/shutdown-debug.js +5 -1
- package/dist/core/skill-grant.js +4 -1
- package/dist/core/skills-directory.js +5 -3
- package/dist/core/spec-contract.d.ts +1 -1
- package/dist/core/store-contracts/checkpoint-store-contract.js +2 -7
- package/dist/core/store-contracts/file-history-store-contract.js +26 -2
- package/dist/core/store-contracts/session-deletion-cascade-contract.js +130 -14
- package/dist/core/store-contracts/task-list-store-contract.d.ts +2 -1
- package/dist/core/store-contracts/task-list-store-contract.js +28 -1
- package/dist/core/task-event.d.ts +48 -27
- package/dist/core/task-notification.d.ts +15 -9
- package/dist/core/task-notification.js +12 -0
- package/dist/core/task-registry-agent.d.ts +24 -22
- package/dist/core/task-registry-agent.js +65 -46
- package/dist/core/task-registry-shared.d.ts +17 -5
- package/dist/core/task-registry.d.ts +17 -6
- package/dist/core/task-registry.js +6 -1
- package/dist/core/task-result.d.ts +71 -25
- package/dist/core/task-spec-members.d.ts +0 -1
- package/dist/core/task-spec-members.js +1 -1
- package/dist/core/task-spec.d.ts +60 -52
- package/dist/core/task-stream.d.ts +45 -12
- package/dist/core/terminal-cause.d.ts +45 -8
- package/dist/core/terminal-cause.js +5 -0
- package/dist/core/tool-card-bound.d.ts +32 -0
- package/dist/core/tool-card-bound.js +33 -0
- package/dist/core/tool-catalog-entries.d.ts +9 -0
- package/dist/core/tool-catalog-entries.js +48 -0
- package/dist/core/tool-errors.d.ts +4 -3
- package/dist/core/tool-face.d.ts +3 -3
- package/dist/core/tool-mount-facts.d.ts +3 -2
- package/dist/core/tool-mount-facts.js +1 -1
- package/dist/core/tool-mount-static.js +7 -5
- package/dist/core/tool-policy.d.ts +21 -19
- package/dist/core/tool-policy.js +5 -6
- package/dist/core/tool-registry.d.ts +3 -1
- package/dist/core/tool-registry.js +15 -1
- package/dist/core/tool-result-store.d.ts +9 -3
- package/dist/core/tool-result-store.js +14 -1
- package/dist/core/tool-roster.d.ts +6 -0
- package/dist/core/tool-roster.js +18 -0
- package/dist/core/tool-spec.d.ts +17 -8
- package/dist/core/trace.d.ts +35 -31
- package/dist/core/types.d.ts +2 -2
- package/dist/core/untrusted-egress.d.ts +19 -7
- package/dist/core/untrusted-egress.js +26 -7
- package/dist/core/untrusted-text.d.ts +6 -18
- package/dist/core/untrusted-text.js +11 -4
- package/dist/core/user-attachment.d.ts +9 -6
- package/dist/core/user-attachment.js +12 -10
- package/dist/core/user-row-origin.d.ts +44 -25
- package/dist/core/user-row-origin.js +30 -20
- package/dist/core/wiring-manifest.d.ts +26 -7
- package/dist/core/wiring-manifest.js +14 -11
- package/dist/core/workspace-snapshot.d.ts +3 -1
- package/dist/core/workspace-snapshot.js +1 -0
- package/dist/engine/execution-env/node-execution-env.d.ts +23 -16
- package/dist/engine/execution-env/node-execution-env.js +127 -67
- package/dist/engine/harness/agent-harness.d.ts +4 -5
- package/dist/engine/harness/agent-harness.js +2 -7
- package/dist/engine/harness/types.d.ts +51 -19
- package/dist/engine/harness/types.js +28 -1
- package/dist/engine/llm/types.d.ts +26 -14
- package/dist/engine/llm/types.js +2 -2
- package/dist/engine/loop/agent-loop.d.ts +2 -2
- package/dist/engine/loop/agent-loop.js +51 -275
- package/dist/engine/loop/types.d.ts +0 -18
- package/dist/engine/session/import-validate.d.ts +3 -0
- package/dist/engine/session/import-validate.js +34 -2
- package/dist/engine/session/repo-utils.d.ts +42 -4
- package/dist/engine/session/repo-utils.js +33 -5
- package/dist/engine/session/session.d.ts +41 -14
- package/dist/engine/session/session.js +96 -25
- package/dist/index.d.ts +21 -16
- package/dist/index.js +16 -10
- package/dist/orchestration/run-spec.d.ts +1 -1
- package/dist/orchestration/run-workflow-tool.d.ts +12 -9
- package/dist/orchestration/run-workflow-tool.js +15 -19
- package/dist/orchestration/workflow-governance.js +13 -21
- package/dist/orchestration/workflow-observe.d.ts +4 -3
- package/dist/orchestration/workflow-primitives.d.ts +1 -1
- package/dist/orchestration/workflow-record-artifact.d.ts +14 -0
- package/dist/orchestration/workflow-record-artifact.js +32 -0
- package/dist/orchestration/workflow-script-store.d.ts +9 -0
- package/dist/orchestration/workflow-script-store.js +20 -1
- package/dist/orchestration/workflow-types.d.ts +33 -3
- package/dist/orchestration/workflow.d.ts +24 -14
- package/dist/orchestration/workflow.js +52 -23
- package/dist/prompt-assembly/artifact.js +4 -8
- package/dist/prompt-assembly/catalog/engine.d.ts +263 -0
- package/dist/prompt-assembly/catalog/engine.js +30 -0
- package/dist/prompt-assembly/catalog/index.d.ts +1 -1
- package/dist/prompt-assembly/catalog/index.js +2 -2
- package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.d.ts +1 -1
- package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.js +29 -0
- package/dist/prompt-assembly/epoch.js +6 -8
- package/dist/prompt-assembly/turn-snapshot.js +8 -9
- package/dist/stores/file/background-agent-store.js +5 -6
- package/dist/stores/file/checkpoint-store.d.ts +0 -4
- package/dist/stores/file/checkpoint-store.js +7 -3
- package/dist/stores/file/file-history-store.d.ts +8 -0
- package/dist/stores/file/file-history-store.js +72 -0
- package/dist/stores/file/fs-atomic.js +17 -12
- package/dist/stores/file/index.js +11 -5
- package/dist/stores/file/mailbox-store.js +13 -4
- package/dist/stores/file/permission-rule-store.js +14 -13
- package/dist/stores/file/shared-ledger.d.ts +4 -0
- package/dist/stores/file/shared-ledger.js +4 -0
- package/dist/stores/file/task-list-store.js +12 -3
- package/dist/stores/file/workflow-run-store.js +1 -0
- package/dist/tools/fs/bash-program-position.d.ts +4 -2
- package/dist/tools/fs/bash-program-position.js +1 -1
- package/dist/tools/fs/bash-readonly-classifier.js +1 -1
- package/dist/tools/fs/bound-open.d.ts +97 -0
- package/dist/tools/fs/bound-open.js +103 -0
- package/dist/tools/fs/containment-face.d.ts +2 -2
- package/dist/tools/fs/fs-pdf.d.ts +7 -1
- package/dist/tools/fs/fs-pdf.js +31 -23
- package/dist/tools/fs/fs-read.d.ts +24 -17
- package/dist/tools/fs/fs-read.js +84 -53
- package/dist/tools/fs/fs-shared.d.ts +14 -12
- package/dist/tools/fs/fs-shared.js +5 -4
- package/dist/tools/fs/fs-write.d.ts +2 -2
- package/dist/tools/fs/fs-write.js +20 -12
- package/dist/tools/fs/index.d.ts +4 -4
- package/dist/tools/fs/index.js +2 -2
- package/dist/tools/fs/notebook.d.ts +1 -1
- package/dist/tools/fs/pdf.d.ts +12 -3
- package/dist/tools/fs/pdf.js +22 -9
- package/dist/tools/fs/read-deny-home.d.ts +3 -2
- package/dist/tools/fs/read-deny-home.js +8 -11
- package/dist/tools/fs/safety.d.ts +3 -2
- package/dist/tools/fs/shell-read-check.js +10 -9
- package/dist/tools/monitor.d.ts +6 -5
- package/dist/tools/task-list.d.ts +16 -6
- package/dist/tools/task-list.js +4 -0
- package/dist/tools/web.d.ts +9 -1
- package/dist/tools/web.js +8 -3
- package/dist/tools/worktree.d.ts +7 -5
- package/dist/tools/worktree.js +4 -3
- package/package.json +4 -3
- package/test/export-surface.snapshot.json +93 -7
- package/wire-changes/core-stores-sql@7.67.3.json +39 -0
- package/wire-changes/core-stores-sql@7.68.0.json +39 -0
- package/wire-changes/core@7.67.3.json +65 -0
- package/wire-changes/core@7.68.0.json +4257 -0
- package/wire-changes/mods-kernel@7.67.3.json +39 -0
- package/wire-changes/mods-kernel@7.68.0.json +129 -0
- package/wire-changes/primitives@7.67.3.json +39 -0
- package/wire-changes/primitives@7.68.0.json +253 -0
- package/wire-changes/wiki-gate@7.67.3.json +39 -0
- package/wire-changes/wiki-gate@7.68.0.json +39 -0
- package/dist/core/runner/credential-origin-seat.d.ts +0 -2
- package/dist/core/runner/credential-origin-seat.js +0 -20
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DENIED_BY_MAY_ECHO, screenGateOutcome, SETTLEMENT_IS_REFUSAL } from "../gate-outcome.js";
|
|
2
2
|
import { ASK_CLASSES, askFaceOf, classifyAsk, headlessApprovalRemedy, unresolvedAskDenialMessage, unresolvedAskQuestionOf } from "../ask-origin.js";
|
|
3
|
+
import { NOT_RESUMABLE_CARRY_ON, notResumableWayOut } from "../park-resumability.js";
|
|
3
4
|
import { wireOf } from "../tool-name-readings.js";
|
|
4
5
|
import { isProtectedWrite } from "../tool-registry.js";
|
|
5
6
|
import { attestationOf, decisionText, foldHookAsk, licenseCovers } from "../tool-policy.js";
|
|
@@ -163,7 +164,7 @@ export function createSettlementLedger(call) {
|
|
|
163
164
|
},
|
|
164
165
|
};
|
|
165
166
|
}
|
|
166
|
-
|
|
167
|
+
function cloneObserverInput(input) {
|
|
167
168
|
try {
|
|
168
169
|
return structuredClone(input);
|
|
169
170
|
}
|
|
@@ -175,6 +176,10 @@ export function cloneObserverInput(input) {
|
|
|
175
176
|
return input;
|
|
176
177
|
}
|
|
177
178
|
}
|
|
179
|
+
export function permissionDeniedOf(refusal) {
|
|
180
|
+
const { toolName, finalInput, toolCallId, reason, gate, identity, permissionMode } = refusal;
|
|
181
|
+
return { toolName, input: cloneObserverInput(finalInput), toolCallId, reason, gate, ...(identity !== undefined ? { identity } : {}), ...(permissionMode !== undefined ? { permissionMode } : {}) };
|
|
182
|
+
}
|
|
178
183
|
const RECORD_RECEIPT = Object.freeze({ accessors: "refuse", depth: MAX_DEPTH, others: "refuse", contain: true, isProxy: (v) => types.isProxy(v) });
|
|
179
184
|
export function frozenInputSnapshot(input) {
|
|
180
185
|
const received = receive(input, RECORD_RECEIPT);
|
|
@@ -265,7 +270,7 @@ export async function engineFailClosedExit(pass, reason, extension) {
|
|
|
265
270
|
const { input, toolName, toolCallId, notifyPermissionDenied } = pass;
|
|
266
271
|
const gate = directDeny("hook", extension);
|
|
267
272
|
const finalInput = frozenInputSnapshot(pass.currentInput);
|
|
268
|
-
await notifyPermissionDenied({ toolName,
|
|
273
|
+
await notifyPermissionDenied(permissionDeniedOf({ toolName, finalInput, toolCallId, reason, gate, identity: input.identity }));
|
|
269
274
|
return { block: true, reason: formatHookFeedback(reason, input.reminderMark), gate, finalInput, preToolContext: pass.preToolContext };
|
|
270
275
|
}
|
|
271
276
|
export const unownedArgsMessage = (subject, reason) => `${subject} could not be taken into the gate's own copy (${reason}) — denied fail-closed`;
|
|
@@ -325,24 +330,19 @@ export async function exitGate(pass) {
|
|
|
325
330
|
const tableSeat = unresolvable !== undefined ? askUnresolvableRemedySeat(unresolvable) : undefined;
|
|
326
331
|
const remedySeat = tableSeat === "absent" && input.askSeatForm === "declared_none" && pass.askClassification?.classes.has("content_question") !== true ? "declared_none" : tableSeat === "unavailable" && input.askSeatForm === "policy_callback" ? "policy" : tableSeat;
|
|
327
332
|
const bindingRefusal = attestationOf(pass.decision, { toolCallId, toolName })?.bindingRefusal;
|
|
328
|
-
const
|
|
333
|
+
const wayOut = input.notResumable !== undefined ? notResumableWayOut(input.notResumable.source, input.notResumable.mandated, pass.askClassification?.classes.has("content_question") === true ? "answer" : "approval") : undefined;
|
|
334
|
+
const headless = bindingRefusal !== undefined ? undefined : remedySeat !== undefined ? headlessApprovalRemedy({ mode: input.permissionMode?.(), classification: foldCause !== undefined ? ancestorUnresolvedClassification(pass.req) : pass.askClassification, approverSeat: remedySeat, coveredWrite: isProtectedWrite(pass.req), ...(pass.shellUnplacedOptions !== undefined ? { unplacedOptions: pass.shellUnplacedOptions } : {}), ...(wayOut !== undefined ? { notResumableWayOut: wayOut } : {}) }) : undefined;
|
|
329
335
|
const remedy = headless?.sentence;
|
|
330
336
|
const base = parkFailedBase(decisionText(pass.decision) ?? `tool "${toolName}" denied by policy`, toolName, unresolvable, pass.parkFailed !== undefined);
|
|
331
|
-
const
|
|
337
|
+
const tail = remedy !== undefined ? ` — ${remedy}` : unresolvable !== undefined && wayOut !== undefined && bindingRefusal === undefined ? `. To go on: ${wayOut}. ${NOT_RESUMABLE_CARRY_ON}` : "";
|
|
338
|
+
const denyReason = withParkFailureCause(`${tail.startsWith(".") ? base.replace(/\.$/, "") : base}${tail}`, pass.parkFailed, unresolvable !== undefined);
|
|
332
339
|
if (unresolvable !== undefined) {
|
|
333
340
|
const cause = unresolvable;
|
|
334
341
|
const noticeRemedy = bindingRefusal ?? remedy;
|
|
335
|
-
pass.notifier.notify(() => input.onAskUnresolvable?.({ toolName, toolCallId, cause, parkLaneExisted: pass.suspendAsk !== undefined, ...(noticeRemedy !== undefined ? { remedy: noticeRemedy } : {}), ...(headless !== undefined ? { remedies: headless.remedies } : {}) }), "toolGate.onAskUnresolvable");
|
|
342
|
+
pass.notifier.notify(() => input.onAskUnresolvable?.({ toolName, toolCallId, cause, parkLaneExisted: pass.suspendAsk !== undefined, ...(noticeRemedy !== undefined ? { remedy: noticeRemedy } : {}), ...(headless !== undefined ? { remedies: headless.remedies } : {}), ...(wayOut !== undefined ? { notResumableWayOut: wayOut } : {}) }), "toolGate.onAskUnresolvable");
|
|
336
343
|
}
|
|
337
344
|
const finalInput = frozenInputSnapshot(pass.currentInput);
|
|
338
|
-
await notifyPermissionDenied({
|
|
339
|
-
toolName,
|
|
340
|
-
input: cloneObserverInput(finalInput),
|
|
341
|
-
toolCallId,
|
|
342
|
-
reason: denyReason,
|
|
343
|
-
gate,
|
|
344
|
-
...(input.identity !== undefined ? { identity: input.identity } : {}),
|
|
345
|
-
});
|
|
345
|
+
await notifyPermissionDenied(permissionDeniedOf({ toolName, finalInput, toolCallId, reason: denyReason, gate, identity: input.identity }));
|
|
346
346
|
return {
|
|
347
347
|
block: true,
|
|
348
348
|
reason: formatHookFeedback(denyReason, input.reminderMark),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { textContentHashOf } from "../canonical-json.js";
|
|
2
2
|
import { GIT_SNAPSHOT_CC_PREAMBLE, buildGitSnapshot } from "../../prompts/default.js";
|
|
3
3
|
import { inlineUntrusted } from "../untrusted-text.js";
|
|
4
4
|
import { openSystemReminder } from "../reminder-mint.js";
|
|
@@ -44,9 +44,7 @@ export function renderGitStatusFrameBody(outcome) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
export function hashGitStatusFrame(kind, body, canonicalRoot) {
|
|
47
|
-
return `
|
|
48
|
-
.update(`${GIT_STATUS_FRAME_FORMAT_VERSION}\u0000${canonicalRoot}\u0000${kind}\u0000${body}`)
|
|
49
|
-
.digest("hex")}`;
|
|
47
|
+
return textContentHashOf(`${GIT_STATUS_FRAME_FORMAT_VERSION}\u0000${canonicalRoot}\u0000${kind}\u0000${body}`);
|
|
50
48
|
}
|
|
51
49
|
export function resolveGitStatusFrame(outcome, canonicalRoot, degradedMaterial) {
|
|
52
50
|
const body = renderGitStatusFrameBody(outcome);
|
|
@@ -2,7 +2,7 @@ export function createRunState() {
|
|
|
2
2
|
return {
|
|
3
3
|
telemetry: { requestedModel: undefined, cacheFamily: "input-excludes-cached", pricing: { inputPer1M: 0, outputPer1M: 0 }, pricingConfigured: true, unpricedSpend: false, tracer: undefined, taskId: "", runId: "", taskStart: 0, taskStartMonotonic: 0, cacheBreakReported: false },
|
|
4
4
|
degrade: { degradeToModel: undefined, degraded: undefined, budgetSwitched: false, outputErrorStreak: 0, outputInvalid: false, recordDegraded: () => { }, priceOf: () => ({ pricing: { inputPer1M: 0, outputPer1M: 0 }, pricingConfigured: false, cacheFamily: "input-excludes-cached" }), fallbackSeat: { observe: () => { } } },
|
|
5
|
-
limits: { turnsExceeded: false, budgetHit: undefined, budgetAxis: undefined, platformTerminal: undefined, outputRetryCap: 0, effectiveMaxTurns: undefined },
|
|
5
|
+
limits: { turnsExceeded: false, budgetHit: undefined, budgetAxis: undefined, platformTerminal: undefined, outputRetryCap: 0, effectiveMaxTurns: undefined, walltimeCrossedMs: undefined, budgetOverAtTurnCap: undefined },
|
|
6
6
|
budget: { remainingMicroUsd: undefined, maxCostMicroUsd: undefined, remainingTokens: undefined, maxTokensWindow: undefined, overBudget: () => undefined, streamCancel: false, callOutputChars: 0, lastStreamBudgetCheck: 0, projectedOverBudget: () => undefined },
|
|
7
7
|
turn: { callStartAt: undefined, firstTokenAt: undefined, turnUsage: undefined, turnUsageMissing: false, turnCacheMarks: {}, turnStopReason: undefined, turnResponseModel: undefined, toolBatch: [] },
|
|
8
8
|
counters: { approachNoticesSent: 0, walltimeSyncBackstopFired: false, compactionFloor: 0, trimForceBackoff: false, compactionPasses: 0, repetitionCuts: 0, repetitionSpared: 0, repetitionEvents: [], REPETITION_EVENTS_CAP: 0, preemptIgnoredReported: false, wroteThisRun: false, finalVerifyInjections: 0, groundingSignalPreR9: false, groundingSignalPostR9: false, cadenceTurns: 0 },
|
|
@@ -24,8 +24,10 @@ export interface BookedCall {
|
|
|
24
24
|
* more than one call). Integer micro-USD, summed per call, so a mid-task model or price change is accounted correctly.
|
|
25
25
|
* `usageMissing` = the call's usage is a lower bound (the caller marks the turn and the leg; the cache account leaves the main
|
|
26
26
|
* lane out of the hit rate). A cache member the call did not report marks the turn's frame as it marks the leg's stats.
|
|
27
|
+
* `apiMs` is the call's API wall time: from the engine's issue stamp (the row's `callStartedAt`) to the row's own `ts`, 0 where the call has
|
|
28
|
+
* no stamp (a hop a walk left behind, a call beside the loop); it is summed into the turn's and the leg's `apiDurationMs` here, beside the tokens.
|
|
27
29
|
*/
|
|
28
|
-
export declare function bookMainCall(rs: RunState, stats: Stats, model: Model, usage: Usage, usageMissing: boolean): BookedCall;
|
|
30
|
+
export declare function bookMainCall(rs: RunState, stats: Stats, model: Model, usage: Usage, usageMissing: boolean, apiMs: number): BookedCall;
|
|
29
31
|
/** Carry one booking's cache marks onto the upcoming `turn_end` (the harness-handlers lane also calls it for a turn that booked no
|
|
30
32
|
* call at all). */
|
|
31
33
|
export declare function noteTurnCacheMarks(rs: RunState, marks: CacheMemberMarks): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { emitTrace } from "../trace.js";
|
|
2
2
|
import { bookCacheOperands, cacheTraceMembersOf } from "./cache-hit-account.js";
|
|
3
3
|
import { usageCostMicroUsd } from "./usage-accounting.js";
|
|
4
|
-
export function bookMainCall(rs, stats, model, usage, usageMissing) {
|
|
4
|
+
export function bookMainCall(rs, stats, model, usage, usageMissing, apiMs) {
|
|
5
5
|
const price = rs.degrade.priceOf(model);
|
|
6
6
|
const { totalInputTokens: turnTotal, uncachedInputTokens: turnUncached, costMicroUsd: turnCostMicroUsd } = usageCostMicroUsd(price.cacheFamily, usage, price.pricing);
|
|
7
7
|
if (!price.pricingConfigured)
|
|
@@ -14,14 +14,16 @@ export function bookMainCall(rs, stats, model, usage, usageMissing) {
|
|
|
14
14
|
stats.cacheWriteTokensLong += usage.cacheWriteLong ?? 0;
|
|
15
15
|
stats.outputTokens += usage.output || 0;
|
|
16
16
|
stats.costMicroUsd += turnCostMicroUsd;
|
|
17
|
+
stats.apiDurationMs = (stats.apiDurationMs ?? 0) + apiMs;
|
|
17
18
|
const marks = bookCacheOperands(stats, "main", { family: price.cacheFamily, usage }, usageMissing, turnTotal);
|
|
18
|
-
rs.turn.turnUsage ??= { inputTokens: 0, totalInputTokens: 0, outputTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0, costMicroUsd: 0 };
|
|
19
|
+
rs.turn.turnUsage ??= { inputTokens: 0, totalInputTokens: 0, outputTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0, costMicroUsd: 0, apiDurationMs: 0 };
|
|
19
20
|
rs.turn.turnUsage.inputTokens += turnUncached;
|
|
20
21
|
rs.turn.turnUsage.totalInputTokens += turnTotal;
|
|
21
22
|
rs.turn.turnUsage.outputTokens += usage.output || 0;
|
|
22
23
|
rs.turn.turnUsage.cacheReadTokens += usage.cacheRead ?? 0;
|
|
23
24
|
rs.turn.turnUsage.cacheWriteTokens += usage.cacheWrite ?? 0;
|
|
24
25
|
rs.turn.turnUsage.costMicroUsd += turnCostMicroUsd;
|
|
26
|
+
rs.turn.turnUsage.apiDurationMs += apiMs;
|
|
25
27
|
noteTurnCacheMarks(rs, marks);
|
|
26
28
|
return { turnTotal, turnUncached, turnCostMicroUsd, priced: price.pricingConfigured };
|
|
27
29
|
}
|
|
@@ -39,7 +41,7 @@ export function bookLeftHops(rs, stats, reading) {
|
|
|
39
41
|
rs.turn.turnUsageMissing = true;
|
|
40
42
|
stats.usageMissing = true;
|
|
41
43
|
}
|
|
42
|
-
const billed = bookMainCall(rs, stats, attempt.model, attempt.usage, attempt.usageMissing === true);
|
|
44
|
+
const billed = bookMainCall(rs, stats, attempt.model, attempt.usage, attempt.usageMissing === true, 0);
|
|
43
45
|
emitTrace(rs.telemetry.tracer, () => ({
|
|
44
46
|
kind: "brain.call", version: 1, taskId: rs.telemetry.taskId, model: attempt.model.id, provider: attempt.model.provider, turn: stats.turns + 1,
|
|
45
47
|
promptTokens: billed.turnUncached, totalInputTokens: billed.turnTotal, completionTokens: attempt.usage.output || 0,
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { AgentTool } from "../../internal/harness.js";
|
|
17
17
|
import type { McpDroppedTool, McpReconnectResult, MaterializedMcp, McpToolAxis } from "../mcp.js";
|
|
18
|
-
import type { RunnerDeps,
|
|
18
|
+
import type { RunnerDeps, ToolEffect } from "../types.js";
|
|
19
19
|
import type { IrreversibilityTier, ToolFaceSnapshot } from "./contracts.js";
|
|
20
20
|
import type { RosterBuilder, ToolRosterDeltaSeat } from "../tool-roster.js";
|
|
21
21
|
import type { McpInstructionsEntry } from "../prompt-section-seat.js";
|
|
@@ -34,10 +34,7 @@ export interface McpRosterDelta {
|
|
|
34
34
|
/** The seats a roster application writes through. Every one of them is borrowed from the phase that
|
|
35
35
|
* minted it — this module owns nothing. */
|
|
36
36
|
export interface McpRosterApplyInput {
|
|
37
|
-
/** borrowed-readonly — the
|
|
38
|
-
* change may mount, beside the selector (`valveLeaves`). */
|
|
39
|
-
spec: Pick<TaskSpec, "excludeAllTools">;
|
|
40
|
-
/** borrowed-readonly — the frozen tool face; its selector keeps a tool the leg may not use from ever
|
|
37
|
+
/** borrowed-readonly — the frozen tool face; its selector (the whole-face switch inside it) keeps a tool the leg may not use from ever
|
|
41
38
|
* being mounted by a face the model or a host can trigger. */
|
|
42
39
|
toolFaceSnapshot: Pick<ToolFaceSnapshot, "selector">;
|
|
43
40
|
/** borrowed-readonly — the per-server face overlay (the phase's `withFaces`). */
|
|
@@ -20,10 +20,10 @@ function settleInstructions(lane, delta, taught) {
|
|
|
20
20
|
tellInstructions(lane, delta.instructions);
|
|
21
21
|
}
|
|
22
22
|
export function applyMcpRosterDelta(input, delta) {
|
|
23
|
-
const {
|
|
23
|
+
const { toolFaceSnapshot, withFaces, remoteToolOffload, foldProtocolAxes, toolEffects, axisExplicitNegatives, roster } = input;
|
|
24
24
|
const domainNow = () => toolNamesOfServer(roster.tools.map((t) => t.name), delta.server);
|
|
25
25
|
const before = domainNow();
|
|
26
|
-
const leaves = valveLeaves(
|
|
26
|
+
const leaves = valveLeaves(toolFaceSnapshot.selector);
|
|
27
27
|
const pushable = delta.tools.filter(leaves);
|
|
28
28
|
const valveExcluded = delta.tools.filter((t) => !leaves(t)).map((t) => t.name);
|
|
29
29
|
const clearDomain = (m) => {
|
|
@@ -10,10 +10,16 @@ export declare const INSTRUCTION_FILE_MAX_BYTES: number;
|
|
|
10
10
|
/** One file's cap: max(40 000, window × 0.05 × characters per token, to the nearest whole character). */
|
|
11
11
|
export declare function instructionFileCap(contextWindow: number, charsPerToken: number): number;
|
|
12
12
|
/** A file as the lane shows it. `content` is the text after the frontmatter and the comments; `globs` is present only on a
|
|
13
|
-
* file whose frontmatter names paths it applies to; `
|
|
13
|
+
* file whose frontmatter names paths it applies to; `noLimit` is present (true) when the frontmatter names `paths:` and
|
|
14
|
+
* nothing in it limits the file — the key is there and reads as no glob (nothing under it, an empty list, only `**`, a value
|
|
15
|
+
* that is not a string, a mapping); `spansLines` is present (true) when one glob of it was written over several lines — globs
|
|
16
|
+
* on lines of their own with no comma between them read as one text, which matches no file; `includes` are the include paths
|
|
17
|
+
* as written (relative ones unresolved). */
|
|
14
18
|
export interface InstructionText {
|
|
15
19
|
readonly content: string;
|
|
16
20
|
readonly globs?: readonly string[];
|
|
21
|
+
readonly noLimit?: true;
|
|
22
|
+
readonly spansLines?: true;
|
|
17
23
|
readonly includes: readonly string[];
|
|
18
24
|
}
|
|
19
25
|
/** Read one instruction file's text (already in the decoded coordinate). `withIncludes`: extract the `@` include paths. */
|
|
@@ -10,10 +10,16 @@ export function instructionFileCap(contextWindow, charsPerToken) {
|
|
|
10
10
|
return Math.max(INSTRUCTION_FILE_MIN_CHARS, Math.round(window * INSTRUCTION_FILE_WINDOW_SHARE * charsPerToken));
|
|
11
11
|
}
|
|
12
12
|
export function processInstructionText(text, withIncludes) {
|
|
13
|
-
const { body, paths } = splitFrontmatter(text);
|
|
13
|
+
const { body, paths, spansLines } = splitFrontmatter(text);
|
|
14
14
|
const globs = paths === undefined ? undefined : ruleGlobsOf(paths);
|
|
15
15
|
const content = body.includes("<!--") ? stripBlockComments(body) : body;
|
|
16
|
-
return {
|
|
16
|
+
return {
|
|
17
|
+
content,
|
|
18
|
+
...(globs !== undefined ? { globs } : {}),
|
|
19
|
+
...(paths !== undefined && globs === undefined ? { noLimit: true } : {}),
|
|
20
|
+
...(spansLines === true && globs !== undefined ? { spansLines: true } : {}),
|
|
21
|
+
includes: withIncludes && content.includes("@") ? includePathsOf(content) : [],
|
|
22
|
+
};
|
|
17
23
|
}
|
|
18
24
|
function splitFrontmatter(text) {
|
|
19
25
|
const lines = text.split("\n");
|
|
@@ -23,25 +29,79 @@ function splitFrontmatter(text) {
|
|
|
23
29
|
if (end < 0)
|
|
24
30
|
return { body: text };
|
|
25
31
|
const body = lines.slice(end + 1).join("\n");
|
|
26
|
-
const block = lines.slice(1, end);
|
|
32
|
+
const block = lines.slice(1, end).map((l) => (l.endsWith("\r") ? l.slice(0, -1) : l));
|
|
27
33
|
const at = block.findIndex((l) => /^paths[ \t]*:/.test(l));
|
|
28
34
|
if (at < 0)
|
|
29
35
|
return { body };
|
|
30
|
-
const
|
|
36
|
+
const value = pathsValueOf(block[at].replace(/^paths[ \t]*:/, "").trim(), block.slice(at + 1));
|
|
37
|
+
return { body, paths: value.values, ...(value.spansLines === true ? { spansLines: true } : {}) };
|
|
38
|
+
}
|
|
39
|
+
const spansLinesOf = (lines) => (splitTopLevel(lines.join("\n")).some((p) => p.includes("\n")) ? { spansLines: true } : {});
|
|
40
|
+
function pathsValueOf(raw, below) {
|
|
41
|
+
const rest = unquote(raw);
|
|
31
42
|
if (rest.startsWith("[") && rest.endsWith("]"))
|
|
32
|
-
return {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
return { values: splitTopLevel(rest.slice(1, -1)).flatMap(globText) };
|
|
44
|
+
const header = /^([|>])(?:([1-9])[+-]?|[+-]([1-9])?)?$/.exec(raw);
|
|
45
|
+
if (header !== null) {
|
|
46
|
+
const lines = blockScalarLines(below, Number(header[2] ?? header[3] ?? 0));
|
|
47
|
+
const text = lines.join("\n");
|
|
48
|
+
return { values: [header[1] === ">" ? text.replace(/([^\n])\n(?=[^\n ])/g, "$1 ") : text], ...spansLinesOf(lines) };
|
|
49
|
+
}
|
|
50
|
+
if (rest !== raw)
|
|
51
|
+
return { values: globText(raw) };
|
|
52
|
+
const blank = (l) => /^[ \t]*(?:#.*)?$/.test(l);
|
|
53
|
+
const first = below.find((l) => !blank(l));
|
|
54
|
+
if (raw === "" && first !== undefined && /^[ \t]*-(?:[ \t]|$)/.test(first)) {
|
|
55
|
+
const items = [];
|
|
56
|
+
for (const l of below) {
|
|
57
|
+
if (blank(l))
|
|
58
|
+
continue;
|
|
59
|
+
const m = /^[ \t]*-(?:[ \t]+(.*))?$/.exec(l);
|
|
60
|
+
if (m === null)
|
|
61
|
+
break;
|
|
62
|
+
items.push(...globText((m[1] ?? "").trim()));
|
|
63
|
+
}
|
|
64
|
+
return { values: items };
|
|
65
|
+
}
|
|
66
|
+
const folded = raw === "" ? [] : [raw];
|
|
67
|
+
for (const l of below) {
|
|
68
|
+
if (l.trim() === "")
|
|
69
|
+
continue;
|
|
70
|
+
if (/^[ \t]*#/.test(l)) {
|
|
71
|
+
if (folded.length > 0)
|
|
72
|
+
break;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (!/^[ \t]/.test(l))
|
|
76
|
+
break;
|
|
77
|
+
folded.push(l.trim());
|
|
78
|
+
}
|
|
79
|
+
const value = folded.join(" ");
|
|
80
|
+
return /:(?:[ \t]|$)/.test(value) ? { values: [] } : { values: globText(value), ...spansLinesOf(folded) };
|
|
81
|
+
}
|
|
82
|
+
function blockScalarLines(below, explicitIndent) {
|
|
83
|
+
let indent = explicitIndent;
|
|
84
|
+
const lines = [];
|
|
85
|
+
for (const l of below) {
|
|
86
|
+
if (l.trim() === "") {
|
|
87
|
+
lines.push("");
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const n = l.length - l.trimStart().length;
|
|
91
|
+
if (indent === 0)
|
|
92
|
+
indent = n;
|
|
93
|
+
if (n === 0 || n < indent)
|
|
39
94
|
break;
|
|
40
|
-
|
|
95
|
+
lines.push(l.slice(indent));
|
|
41
96
|
}
|
|
42
|
-
return
|
|
97
|
+
return lines;
|
|
43
98
|
}
|
|
44
99
|
const unquote = (s) => (s.length >= 2 && ((s.startsWith('"') && s.endsWith('"')) || (s.startsWith("'") && s.endsWith("'"))) ? s.slice(1, -1) : s);
|
|
100
|
+
const PLAIN_NON_STRING = /^(?:~|null|Null|NULL|true|True|TRUE|false|False|FALSE|[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)(?:[eE][-+]?[0-9]+)?|0x[0-9a-fA-F]+|0o[0-7]+|[-+]?\.(?:inf|Inf|INF)|\.(?:nan|NaN|NAN))$/;
|
|
101
|
+
const globText = (raw) => {
|
|
102
|
+
const text = unquote(raw);
|
|
103
|
+
return text === raw && PLAIN_NON_STRING.test(raw) ? [] : [text];
|
|
104
|
+
};
|
|
45
105
|
function splitTopLevel(s) {
|
|
46
106
|
const out = [];
|
|
47
107
|
let depth = 0;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The INSTRUCTION-FILE LANE — the one reader of the family the deployment declared (`TaskSpec.instructionFamily`)
|
|
3
3
|
* at every level of the task root: the root's own level (the session's instructions, the reference's user context) and the
|
|
4
|
-
* directories a run accesses below it (the reference's `nested_memory`).
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* directories a run accesses below it (the reference's `nested_memory`). Under the declaration's `additionalDirectories`
|
|
5
|
+
* opt-in, each additional working directory the request declared is a further ROOT: its own level is read as the task
|
|
6
|
+
* root's is (the reference's additional-directory loop), for the declaration's first family — no level below it and no
|
|
7
|
+
* second family. What is owed rides the next request as attachment frames — origin `project_instructions` for a root's own
|
|
8
|
+
* level, `nested_memory` for a level below the task root and for a rule the deployment holds (the user-attachment seat's
|
|
9
|
+
* frame, delivery record and settlement).
|
|
7
10
|
*
|
|
8
|
-
* ONE LAW. A family member F of a level D is OWED exactly when (i) D is
|
|
9
|
-
* below
|
|
11
|
+
* ONE LAW. A family member F of a level D is OWED exactly when (i) D is a root, or the read state holds an entry below D
|
|
12
|
+
* (and below the task root) that an access recorded (not this lane's own, not a context seed); (ii) the read state holds no entry of F at
|
|
10
13
|
* F's current contents; (iii) F passes the Read tool's admission. The law is a function of the read state; a load looks at
|
|
11
14
|
* the root's level every time, and at a level below it when an entry under that level changed since the last load (an
|
|
12
15
|
* access, a retirement) — so a member below the root that changes while nothing under its directory does is found at the
|
|
@@ -18,11 +21,17 @@
|
|
|
18
21
|
* longer applies, and its receipt deletes the entry while it is still this lane's own (the transcript's replay reads the
|
|
19
22
|
* withdrawal the same way). The delivered entries of a level are what is checked, not the members a listing finds.
|
|
20
23
|
*
|
|
21
|
-
* Bounds: a load makes at most {@link NESTED_MEMORY_PROBES_PER_LOAD} probes (a stat, a read, a listing)
|
|
22
|
-
* three files' cap of frames; what is left waits for the next load
|
|
23
|
-
*
|
|
24
|
+
* Bounds: a load makes at most {@link NESTED_MEMORY_PROBES_PER_LOAD} probes (a stat, a read, a listing) times the roots it
|
|
25
|
+
* reads (pooled) and carries at most three files' cap of frames; what is left waits for the next load in the levels' order
|
|
26
|
+
* (each root's own level in root order — the task root's, then each additional root's in declaration order — then the
|
|
27
|
+
* levels below the task root; a file two levels name is read under the first), and a rule or a rules directory the lane has
|
|
28
|
+
* already asked about waits behind the waiting ones of its level (a root's rule directory larger than one load's probes is
|
|
29
|
+
* read whole across loads). A file the model could not Read is not loaded, and the user is told once per session
|
|
30
|
+
* (`instructions.withheld`); a file that cannot be read is said
|
|
24
31
|
* to the operator once per session. The reference: Claude Code 2.1.316's session loader `vHo` (cli316.js:270117)
|
|
25
|
-
* c27352 (the same local reader as the tools: the delegate slot `D_e` has no writer),
|
|
32
|
+
* c27352 (the same local reader as the tools: the delegate slot `D_e` has no writer), its additional-directory loop c30240
|
|
33
|
+
* (after the working directory's chain; `QQ` c24020 is empty unless opted in; the rules there `conditionalRule: false`,
|
|
34
|
+
* kept by c23650; no second family), the triggers (Read L272461 c20127,
|
|
26
35
|
* Write L270129 c22955, Edit L273001 c4841), the producer `XCn` / `_Cn` L272682 c19910 – c22950, the directory chain `pet`
|
|
27
36
|
* L272682 c19311, the family `_zr` / `I_e` L270117 c34536 – c35427, the entry stamp `ZGr` L272461 c1348.
|
|
28
37
|
*/
|
|
@@ -34,7 +43,7 @@ import type { ToolCallFace } from "../tool-policy.js";
|
|
|
34
43
|
import { type InstructionLayer, type MintedAttachmentFrame } from "../user-attachment.js";
|
|
35
44
|
import type { ReminderDisclosureCounts } from "../reminder-disclosure.js";
|
|
36
45
|
import type { TaskSpec } from "../task-spec.js";
|
|
37
|
-
import type { RunnerDeps, TaskEvent, TaskEventIdentity } from "../types.js";
|
|
46
|
+
import type { EngineNotice, RunnerDeps, TaskEvent, TaskEventIdentity } from "../types.js";
|
|
38
47
|
import type { WiringManifest } from "../wiring-manifest.js";
|
|
39
48
|
import type { Prepared } from "./contracts.js";
|
|
40
49
|
/** At most this many names in `files` (and in `alternate.files`). */
|
|
@@ -43,7 +52,8 @@ export declare const NESTED_MEMORY_MAX_NAMES = 8;
|
|
|
43
52
|
export declare const NESTED_MEMORY_NAME_MAX = 255;
|
|
44
53
|
/** At most this many `hostRules`. */
|
|
45
54
|
export declare const NESTED_MEMORY_MAX_HOST_RULES = 20;
|
|
46
|
-
/** The probes one load makes at most (a stat, a read, a directory listing each count
|
|
55
|
+
/** The probes one load makes at most, times the number of roots it reads (a stat, a read, a directory listing each count
|
|
56
|
+
* one; the allowances are pooled): a further root's own level — looked at on every load — brings its own share. */
|
|
47
57
|
export declare const NESTED_MEMORY_PROBES_PER_LOAD = 32;
|
|
48
58
|
/** One load's frames, at most this many files' cap (the frames counted whole: sentences, labels and data). */
|
|
49
59
|
export declare const NESTED_MEMORY_FRAME_BUDGET_FILES = 3;
|
|
@@ -57,10 +67,14 @@ export declare const INSTRUCTIONS_WITHHELD = "instructions.withheld";
|
|
|
57
67
|
/** Why an instruction file was not loaded — the notice's `detail.reason`. */
|
|
58
68
|
export declare const INSTRUCTIONS_WITHHELD_REASONS: readonly ["rule_denied", "outside_roots", "approval_required", "admission_unknown", "target_moved"];
|
|
59
69
|
export type InstructionsWithheldReason = (typeof INSTRUCTIONS_WITHHELD_REASONS)[number];
|
|
70
|
+
/** The notice a run prepared with no instruction family declared is the first, for its notice receiver, to say. */
|
|
71
|
+
export declare const INSTRUCTIONS_FAMILY_UNDECLARED = "instructions.family_undeclared";
|
|
72
|
+
/** The operator's sentence for that absence: what no run reads, and the one thing that makes them read it. */
|
|
73
|
+
export declare function instructionsFamilyUndeclaredNotice(sessionId: string): EngineNotice;
|
|
60
74
|
/**
|
|
61
75
|
* The lane's capability descriptor — what a host reads to decide whether to declare the family here and stop loading
|
|
62
|
-
* instruction files itself: the declaration's seat, the frames' origins (a level below the root;
|
|
63
|
-
* the echo and the notice it raises, its limits.
|
|
76
|
+
* instruction files itself: the declaration's seat, the frames' origins (a level below the root; a root's own level — the
|
|
77
|
+
* task root's, an additional directory's under the opt-in), the echo and the notice it raises, its limits.
|
|
64
78
|
*/
|
|
65
79
|
export declare const NESTED_MEMORY_LANE: Readonly<{
|
|
66
80
|
declaration: "TaskSpec.instructionFamily";
|
|
@@ -86,6 +100,7 @@ export interface ScreenedNestedMemory {
|
|
|
86
100
|
readonly when: "absent" | "also";
|
|
87
101
|
};
|
|
88
102
|
readonly includes: boolean;
|
|
103
|
+
readonly additionalDirectories: boolean;
|
|
89
104
|
readonly hostRules: ReadonlyArray<{
|
|
90
105
|
readonly level: "user" | "managed" | "project";
|
|
91
106
|
readonly name: string;
|
|
@@ -106,7 +121,9 @@ export declare function screenNestedMemory(spec: Pick<TaskSpec, "instructionFami
|
|
|
106
121
|
/** What the lane reads with: the hands' environment and reader, the run's served-read judge (every ask held: nobody asked
|
|
107
122
|
* for this file, so it is shown only where the model's own `Read` of it would be served with nobody asked) and the face
|
|
108
123
|
* the run's roster gives `Read` (read at each judgment; none ⇒ the model could not read the file itself), the live read
|
|
109
|
-
* state, the canonical task root
|
|
124
|
+
* state, the canonical task root and the additional working directories the request declared (each its declared spelling
|
|
125
|
+
* and the one canonical form the hands resolved it to, in declaration order; read as roots only under the declaration's
|
|
126
|
+
* opt-in); the prepared leg (read at each load) for the model and the records. */
|
|
110
127
|
export interface NestedMemoryLaneSeat {
|
|
111
128
|
readonly declaration: ScreenedNestedMemory;
|
|
112
129
|
readonly env: ExecutionEnv;
|
|
@@ -115,12 +132,19 @@ export interface NestedMemoryLaneSeat {
|
|
|
115
132
|
readonly readFace: () => ToolCallFace | undefined;
|
|
116
133
|
readonly state: ReadFileState;
|
|
117
134
|
readonly root: string;
|
|
135
|
+
readonly additionalRoots?: ReadonlyArray<DeclaredRoot>;
|
|
118
136
|
readonly signal: AbortSignal;
|
|
119
137
|
readonly mark: string | undefined;
|
|
120
138
|
readonly counts: ReminderDisclosureCounts | undefined;
|
|
121
139
|
readonly deps: Pick<RunnerDeps, "onNotice" | "onError">;
|
|
122
140
|
readonly leg: () => Pick<Prepared, "harness" | "session" | "sessionId" | "runId" | "announcedListingsRef" | "frameReceipts" | "hookIdentity"> | undefined;
|
|
123
141
|
}
|
|
142
|
+
/** An additional working directory as the request declared it (`TaskSpec.additionalDirectories`, the spelling) and as the
|
|
143
|
+
* hands resolved it (the canonical form the file tools' fence holds). */
|
|
144
|
+
export interface DeclaredRoot {
|
|
145
|
+
readonly directory: string;
|
|
146
|
+
readonly canonical: string;
|
|
147
|
+
}
|
|
124
148
|
/** Told each delivered frame at its receipt: the file's key (a deployment rule's name), the layer it belongs to, and
|
|
125
149
|
* whether the frame withdrew a file delivered earlier. */
|
|
126
150
|
export type InstructionEcho = (label: string, layer: InstructionLayer, withdrawn: boolean) => void;
|
|
@@ -139,7 +163,7 @@ export declare function instructionEchoTo(queue: {
|
|
|
139
163
|
}): InstructionEcho;
|
|
140
164
|
/**
|
|
141
165
|
* The instruction files' COMPACTION arm: a landed compaction retired the entries of the frames it summarized away, so the
|
|
142
|
-
*
|
|
166
|
+
* roots' own levels (owed on every load) and every level whose access the kept tail still holds owe again. One load, its
|
|
143
167
|
* frames written to the transcript as engine messages before any reader of the new baseline (the next request first), each
|
|
144
168
|
* committed on its own append — what one could not write stays owed for the next load. Never throws.
|
|
145
169
|
*/
|
|
@@ -167,10 +191,11 @@ export interface NestedMemoryLane {
|
|
|
167
191
|
readonly triggers?: readonly string[];
|
|
168
192
|
readonly echo: InstructionEcho;
|
|
169
193
|
}): Promise<NestedMemoryLoad | undefined>;
|
|
170
|
-
/**
|
|
171
|
-
*
|
|
172
|
-
|
|
173
|
-
|
|
194
|
+
/** Each root's members the conversation holds (a read-state entry) or a load has on its way, relative to that root,
|
|
195
|
+
* `/`-separated — the declared names first, in declaration order, then the rules by path: the task root's
|
|
196
|
+
* (`selected`) and, under the opt-in, each additional root's in declaration order (the wiring manifest's member). */
|
|
197
|
+
selected(): NonNullable<WiringManifest["instructions"]>;
|
|
198
|
+
/** Is this key a member of the declared family — at a root's own level, or at any level — read off the declaration
|
|
174
199
|
* and the path alone (a member's name, or a markdown file under a rules directory), whoever wrote its entry? */
|
|
175
200
|
isMember(key: string, at: "root" | "any"): boolean;
|
|
176
201
|
}
|