@sema-agent/core 7.60.0 → 7.62.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 +917 -0
- package/README.md +2 -2
- package/dist/agents/agent-transcript-tool.d.ts +2 -2
- package/dist/agents/agent-transcript-tool.js +1 -1
- package/dist/agents/cascade.d.ts +71 -12
- package/dist/agents/cascade.js +61 -21
- package/dist/agents/composition-allowance.d.ts +53 -0
- package/dist/agents/composition-allowance.js +49 -0
- package/dist/agents/composition-placement.d.ts +29 -0
- package/dist/agents/composition-placement.js +24 -0
- package/dist/agents/cumulative-stats.d.ts +4 -0
- package/dist/agents/cumulative-stats.js +3 -0
- package/dist/agents/inherited-tool-pool.d.ts +5 -3
- package/dist/agents/inherited-tool-pool.js +2 -2
- package/dist/agents/list-agents-tool.d.ts +1 -1
- package/dist/agents/peer-held-queue.d.ts +27 -4
- package/dist/agents/peer-held-queue.js +81 -36
- package/dist/agents/peer-notice-route.d.ts +1 -1
- package/dist/agents/peer-notice-route.js +4 -3
- package/dist/agents/peer-notices.d.ts +4 -4
- package/dist/agents/peer-notices.js +8 -4
- package/dist/agents/peer-session-drain.d.ts +8 -1
- package/dist/agents/peer-session-drain.js +49 -10
- package/dist/agents/repair-loop.js +16 -6
- package/dist/agents/retain-ledger.js +3 -1
- package/dist/agents/roster-store.d.ts +1 -1
- package/dist/agents/roster-store.js +7 -4
- package/dist/agents/send-message-tool.d.ts +8 -10
- package/dist/agents/send-message-tool.js +43 -23
- package/dist/agents/subagent-completion-gate.d.ts +35 -0
- package/dist/agents/subagent-completion-gate.js +62 -0
- package/dist/agents/subagent-steps.d.ts +7 -6
- package/dist/agents/subagent.d.ts +36 -41
- package/dist/agents/subagent.js +245 -200
- package/dist/agents/suspend-guard.d.ts +47 -16
- package/dist/agents/suspend-guard.js +13 -4
- package/dist/agents/verify.d.ts +41 -14
- package/dist/agents/verify.js +41 -30
- package/dist/brain/anthropic.js +1 -0
- package/dist/brain/errors.d.ts +7 -1
- package/dist/brain/errors.js +6 -0
- package/dist/brain/failover.js +2 -1
- package/dist/brain/open-responses.js +1 -0
- package/dist/brain/openai.js +1 -0
- package/dist/brain/provider-dialect.d.ts +10 -0
- package/dist/brain/provider-dialect.js +13 -2
- package/dist/brain/stream-engine.d.ts +3 -0
- package/dist/brain/stream-engine.js +4 -0
- package/dist/core/agent-state.d.ts +1 -1
- package/dist/core/allow-entry.d.ts +59 -23
- package/dist/core/allow-entry.js +131 -38
- package/dist/core/ask-origin.d.ts +79 -0
- package/dist/core/ask-origin.js +76 -0
- package/dist/core/ask-question.d.ts +19 -13
- package/dist/core/ask-question.js +8 -2
- package/dist/core/auto-compaction.d.ts +2 -0
- package/dist/core/auto-compaction.js +2 -1
- package/dist/core/auto-mode.js +3 -5
- package/dist/core/background-agent-store.d.ts +7 -5
- package/dist/core/background-agent-store.js +12 -11
- package/dist/core/checkpoint-features.d.ts +722 -0
- package/dist/core/checkpoint-features.js +98 -0
- package/dist/core/checkpoint-requirements.d.ts +33 -5
- package/dist/core/checkpoint-requirements.js +18 -5
- package/dist/core/checkpoint-row-verdict.d.ts +99 -0
- package/dist/core/checkpoint-row-verdict.js +225 -0
- package/dist/core/checkpoint-store.d.ts +107 -738
- package/dist/core/checkpoint-store.js +45 -143
- package/dist/core/child-clamp-seats.d.ts +3 -2
- package/dist/core/child-clamp-seats.js +4 -3
- package/dist/core/closest-name.d.ts +13 -0
- package/dist/core/closest-name.js +35 -0
- package/dist/core/context-settings.js +3 -5
- package/dist/core/cross-boundary-taint.d.ts +1 -1
- package/dist/core/decision-receipt.d.ts +14 -1
- package/dist/core/decision-receipt.js +6 -3
- package/dist/core/delegation-frames.d.ts +13 -9
- package/dist/core/effective-path-target.js +2 -3
- package/dist/core/engine-attestation.d.ts +11 -1
- package/dist/core/engine-attestation.js +2 -0
- package/dist/core/engine-notice.d.ts +68 -21
- package/dist/core/engine-notice.js +9 -2
- package/dist/core/file-history-retention.d.ts +8 -0
- package/dist/core/file-history-retention.js +14 -11
- package/dist/core/file-history-store.d.ts +31 -1
- package/dist/core/file-history-store.js +31 -2
- package/dist/core/frame-settlement.d.ts +10 -0
- package/dist/core/frame-settlement.js +6 -1
- package/dist/core/fs-write-gate-policy.d.ts +3 -3
- package/dist/core/fs-write-gate-policy.js +8 -7
- package/dist/core/gate-fold.js +4 -3
- package/dist/core/gate-lanes.js +7 -4
- package/dist/core/gate-outcome.d.ts +40 -1
- package/dist/core/gate-outcome.js +10 -0
- package/dist/core/git-worktree-env.d.ts +7 -3
- package/dist/core/git-worktree-env.js +16 -13
- package/dist/core/governance-codes.d.ts +14 -4
- package/dist/core/governance-codes.js +19 -4
- package/dist/core/hooks.d.ts +25 -4
- package/dist/core/hooks.js +11 -4
- package/dist/core/host-floor.js +3 -5
- package/dist/core/human-input-projection.d.ts +1 -0
- package/dist/core/human-input-projection.js +3 -0
- package/dist/core/image-admission.d.ts +47 -7
- package/dist/core/image-admission.js +35 -4
- package/dist/core/input-author.d.ts +36 -0
- package/dist/core/input-author.js +39 -0
- package/dist/core/leg-identity.d.ts +62 -0
- package/dist/core/leg-identity.js +18 -0
- package/dist/core/locked-config.d.ts +4 -3
- package/dist/core/locked-config.js +5 -3
- package/dist/core/lsp.d.ts +5 -3
- package/dist/core/lsp.js +3 -2
- package/dist/core/mailbox-store.d.ts +85 -10
- package/dist/core/mailbox-store.js +31 -10
- package/dist/core/mcp-connection-pool.d.ts +6 -20
- package/dist/core/mcp-connection-pool.js +10 -28
- package/dist/core/mcp-failure.d.ts +76 -15
- package/dist/core/mcp-failure.js +60 -33
- package/dist/core/mcp-host-seat.d.ts +92 -53
- package/dist/core/mcp-host-seat.js +225 -46
- package/dist/core/mcp-probe.js +2 -2
- package/dist/core/mcp-server-link.d.ts +18 -6
- package/dist/core/mcp-server-link.js +19 -4
- package/dist/core/mcp-server-spec.d.ts +2 -1
- package/dist/core/mcp-session-end.d.ts +1 -2
- package/dist/core/mcp-session-end.js +1 -1
- package/dist/core/mcp.d.ts +6 -49
- package/dist/core/mcp.js +115 -111
- package/dist/core/media-byte-cap.d.ts +21 -46
- package/dist/core/media-byte-cap.js +55 -55
- package/dist/core/member-group.d.ts +7 -0
- package/dist/core/member-group.js +35 -0
- package/dist/core/memory-engine/consolidation-driver.d.ts +1 -1
- package/dist/core/memory-engine/consolidation.d.ts +1 -1
- package/dist/core/memory-engine/consolidation.js +7 -1
- package/dist/core/memory-engine/dual-root.d.ts +31 -0
- package/dist/core/memory-engine/dual-root.js +59 -11
- package/dist/core/memory-engine/engine.js +27 -24
- package/dist/core/memory-engine/file-backend.d.ts +13 -0
- package/dist/core/memory-engine/file-backend.js +35 -15
- package/dist/core/memory-engine/layout.d.ts +3 -0
- package/dist/core/memory-engine/layout.js +13 -3
- package/dist/core/memory-engine/memory-deployment.d.ts +110 -0
- package/dist/core/memory-engine/memory-deployment.js +182 -0
- package/dist/core/memory-engine/sync-client.d.ts +39 -18
- package/dist/core/memory-engine/sync-client.js +72 -14
- package/dist/core/memory-engine/sync-report.d.ts +7 -4
- package/dist/core/memory-engine/sync.d.ts +9 -1
- package/dist/core/memory-vector.d.ts +1 -1
- package/dist/core/memory.d.ts +10 -10
- package/dist/core/mode-policy.d.ts +8 -8
- package/dist/core/mode-policy.js +8 -6
- package/dist/core/mods/agent-stations.d.ts +39 -4
- package/dist/core/mods/agent-stations.js +59 -10
- package/dist/core/mods/classic-events.d.ts +9 -1
- package/dist/core/mods/dollar.d.ts +94 -1
- package/dist/core/mods/dollar.js +13 -1
- package/dist/core/mods/extension-call.d.ts +15 -1
- package/dist/core/mods/extension-call.js +7 -2
- package/dist/core/mods/kernel/dispatch.d.ts +4 -3
- package/dist/core/mods/kernel/dispatch.js +4 -4
- package/dist/core/mods/kernel/events.d.ts +14 -3
- package/dist/core/mods/kernel/events.js +18 -15
- package/dist/core/mods/kernel/registration.d.ts +3 -0
- package/dist/core/mods/kernel/registration.js +5 -0
- package/dist/core/mods/kernel/site-rules.d.ts +6 -3
- package/dist/core/mods/kernel/site-rules.js +10 -2
- package/dist/core/mods/lifecycle-stations.d.ts +36 -4
- package/dist/core/mods/lifecycle-stations.js +44 -9
- package/dist/core/mods/session-append.d.ts +118 -0
- package/dist/core/mods/session-append.js +318 -0
- package/dist/core/mods/session-compact.d.ts +48 -0
- package/dist/core/mods/session-compact.js +194 -0
- package/dist/core/mods/session-receive.d.ts +93 -0
- package/dist/core/mods/session-receive.js +138 -0
- package/dist/core/mods/session-send.d.ts +72 -0
- package/dist/core/mods/session-send.js +88 -0
- package/dist/core/mods/stations.d.ts +88 -21
- package/dist/core/mods/stations.js +149 -11
- package/dist/core/mods/tool-call.d.ts +2 -0
- package/dist/core/mods/tool-call.js +4 -4
- package/dist/core/output-style.js +3 -4
- package/dist/core/own-property-receipt.d.ts +68 -2
- package/dist/core/own-property-receipt.js +45 -2
- package/dist/core/park-selfcheck.js +4 -2
- package/dist/core/path-identity.d.ts +11 -0
- package/dist/core/path-identity.js +4 -0
- package/dist/core/path-rule-binding.d.ts +3 -1
- package/dist/core/path-rule-binding.js +3 -1
- package/dist/core/peer-seat.d.ts +3 -3
- package/dist/core/peer-seat.js +20 -8
- package/dist/core/permission-rule-consent.d.ts +21 -5
- package/dist/core/permission-rule-consent.js +21 -1
- package/dist/core/permission-rule-model.d.ts +34 -11
- package/dist/core/permission-rule-model.js +47 -10
- package/dist/core/permission-rule-org.d.ts +1 -1
- package/dist/core/permission-rule-provider.js +4 -1
- package/dist/core/permission-rules.d.ts +4 -0
- package/dist/core/permission-rules.js +11 -16
- package/dist/core/read-root-candidate.js +1 -1
- package/dist/core/remote-env.d.ts +74 -26
- package/dist/core/remote-env.js +20 -0
- package/dist/core/resume-startup-cause.d.ts +5 -4
- package/dist/core/retention-policy.d.ts +24 -23
- package/dist/core/retention-policy.js +36 -2
- package/dist/core/retention.d.ts +4 -1
- package/dist/core/retired-keys.d.ts +4 -4
- package/dist/core/row-admission.d.ts +10 -0
- package/dist/core/row-admission.js +5 -0
- package/dist/core/runner/advisor-instructions.d.ts +2 -1
- package/dist/core/runner/advisor-instructions.js +2 -1
- package/dist/core/runner/announce-once-ledger.d.ts +4 -4
- package/dist/core/runner/assemble-result.d.ts +13 -3
- package/dist/core/runner/assemble-result.js +12 -7
- package/dist/core/runner/caller-roster.d.ts +12 -9
- package/dist/core/runner/caller-roster.js +5 -2
- package/dist/core/runner/checkpoint-scope.d.ts +16 -1
- package/dist/core/runner/checkpoint-scope.js +21 -0
- package/dist/core/runner/compact-session.js +18 -3
- package/dist/core/runner/compaction-call-options.d.ts +1 -1
- package/dist/core/runner/compaction-restate.d.ts +2 -2
- package/dist/core/runner/compaction-restate.js +4 -3
- package/dist/core/runner/construction-doors.d.ts +2 -2
- package/dist/core/runner/construction-doors.js +2 -2
- package/dist/core/runner/contracts.d.ts +116 -34
- package/dist/core/runner/cross-boundary-lane.d.ts +1 -1
- package/dist/core/runner/decide-continuation.d.ts +4 -2
- package/dist/core/runner/decide-continuation.js +7 -4
- package/dist/core/runner/delegation-owner.d.ts +43 -0
- package/dist/core/runner/delegation-owner.js +59 -0
- package/dist/core/runner/denial-limit-arms.d.ts +15 -21
- package/dist/core/runner/denial-limit-arms.js +17 -10
- package/dist/core/runner/expire-settle.d.ts +44 -0
- package/dist/core/runner/expire-settle.js +55 -0
- package/dist/core/runner/git-status-frame.d.ts +3 -3
- package/dist/core/runner/git-status-frame.js +2 -1
- package/dist/core/runner/halt-attribution.d.ts +2 -1
- package/dist/core/runner/halt-attribution.js +2 -1
- package/dist/core/runner/lineage-reroot-view.d.ts +56 -0
- package/dist/core/runner/lineage-reroot-view.js +108 -0
- package/dist/core/runner/local-claims.d.ts +17 -0
- package/dist/core/runner/local-claims.js +18 -0
- package/dist/core/runner/media-removed-seat.d.ts +46 -0
- package/dist/core/runner/media-removed-seat.js +88 -0
- package/dist/core/runner/park-commit.d.ts +2 -2
- package/dist/core/runner/permission-rule-lanes.d.ts +7 -2
- package/dist/core/runner/permission-rule-lanes.js +28 -9
- package/dist/core/runner/person-path-rows.d.ts +15 -0
- package/dist/core/runner/person-path-rows.js +27 -4
- package/dist/core/runner/placement-fence.d.ts +26 -0
- package/dist/core/runner/placement-fence.js +38 -0
- package/dist/core/runner/prepare-acquire-reconcile.d.ts +4 -1
- package/dist/core/runner/prepare-acquire-reconcile.js +7 -2
- package/dist/core/runner/prepare-ask-lane.d.ts +6 -12
- package/dist/core/runner/prepare-ask-lane.js +4 -4
- package/dist/core/runner/prepare-boundary-parks.d.ts +4 -1
- package/dist/core/runner/prepare-boundary-parks.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +3 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +2 -1
- package/dist/core/runner/prepare-config-doors.d.ts +6 -6
- package/dist/core/runner/prepare-config-doors.js +19 -21
- package/dist/core/runner/prepare-context-lane.d.ts +6 -2
- package/dist/core/runner/prepare-context-lane.js +13 -13
- package/dist/core/runner/prepare-delegation-surface.d.ts +9 -9
- package/dist/core/runner/prepare-delegation-surface.js +4 -5
- package/dist/core/runner/prepare-execution-env.d.ts +5 -2
- package/dist/core/runner/prepare-execution-env.js +7 -4
- package/dist/core/runner/prepare-gate-stations.d.ts +19 -14
- package/dist/core/runner/prepare-gate-stations.js +6 -4
- package/dist/core/runner/prepare-hands-readface.d.ts +6 -6
- package/dist/core/runner/prepare-hands-readface.js +32 -11
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -0
- package/dist/core/runner/prepare-inherited-gate.js +10 -3
- package/dist/core/runner/prepare-lsp.d.ts +3 -0
- package/dist/core/runner/prepare-lsp.js +2 -2
- package/dist/core/runner/prepare-park-ask.d.ts +5 -2
- package/dist/core/runner/prepare-park-ask.js +4 -5
- package/dist/core/runner/prepare-policy-chain.d.ts +10 -21
- package/dist/core/runner/prepare-policy-chain.js +16 -25
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-prompt-inputs.d.ts +5 -4
- package/dist/core/runner/prepare-prompt-inputs.js +3 -2
- package/dist/core/runner/prepare-question-face.d.ts +6 -4
- package/dist/core/runner/prepare-question-face.js +2 -2
- package/dist/core/runner/prepare-run-refs.d.ts +3 -0
- package/dist/core/runner/prepare-run-refs.js +2 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +11 -7
- package/dist/core/runner/prepare-suspend-saga.js +17 -7
- package/dist/core/runner/prepare-task.d.ts +1 -1
- package/dist/core/runner/prepare-task.js +61 -30
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +6 -0
- package/dist/core/runner/prepare-tool-disclosure-mount.js +3 -1
- package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -0
- package/dist/core/runner/prepare-wiring-manifest.js +2 -1
- package/dist/core/runner/prepare-workspace-restore.d.ts +5 -0
- package/dist/core/runner/prepare-workspace-restore.js +10 -6
- package/dist/core/runner/read-root-grant.d.ts +1 -1
- package/dist/core/runner/read-root-grant.js +2 -1
- package/dist/core/runner/resume-admission.d.ts +8 -6
- package/dist/core/runner/resume-admission.js +23 -6
- package/dist/core/runner/resume-apply.d.ts +4 -0
- package/dist/core/runner/resume-apply.js +14 -5
- package/dist/core/runner/resume-checkpoint-screen.d.ts +9 -0
- package/dist/core/runner/resume-checkpoint-screen.js +4 -84
- package/dist/core/runner/resume-claim.d.ts +8 -3
- package/dist/core/runner/resume-claim.js +28 -12
- package/dist/core/runner/resume-internals-and-config.d.ts +2 -2
- package/dist/core/runner/resume-internals-and-config.js +10 -1
- package/dist/core/runner/resume-preflight.d.ts +3 -2
- package/dist/core/runner/resume-preflight.js +13 -26
- package/dist/core/runner/retired-runner-deps.js +2 -0
- package/dist/core/runner/run-git-lane.d.ts +2 -0
- package/dist/core/runner/run-git-lane.js +6 -2
- package/dist/core/runner/run-harness-handlers.d.ts +2 -0
- package/dist/core/runner/run-harness-handlers.js +5 -4
- package/dist/core/runner/run-identity-wiring.d.ts +2 -2
- package/dist/core/runner/run-identity-wiring.js +14 -5
- package/dist/core/runner/run-leg.d.ts +3 -3
- package/dist/core/runner/run-leg.js +64 -36
- package/dist/core/runner/run-notification-lane.js +20 -2
- package/dist/core/runner/run-recovery-lanes.js +3 -2
- package/dist/core/runner/run-settle-and-teardown.js +12 -9
- package/dist/core/runner/run-stop-and-final-verify.js +2 -1
- package/dist/core/runner/run-telemetry-and-budget-seats.d.ts +1 -1
- package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
- package/dist/core/runner/run-terminal-adoption.js +26 -17
- package/dist/core/runner/run-turn-boundary.js +34 -18
- package/dist/core/runner/runtask.d.ts +18 -3
- package/dist/core/runner/runtask.js +33 -17
- package/dist/core/runner/session-rule-policy.d.ts +1 -1
- package/dist/core/runner/session-rule-policy.js +6 -1
- package/dist/core/runner/shell-env-withheld.d.ts +1 -1
- package/dist/core/runner/steering-preview.d.ts +9 -0
- package/dist/core/runner/steering-preview.js +5 -0
- package/dist/core/runner/stream-halt-verbs.d.ts +1 -14
- package/dist/core/runner/stream-halt-verbs.js +4 -3
- package/dist/core/runner/stream-reap.d.ts +7 -6
- package/dist/core/runner/stream-reap.js +13 -16
- package/dist/core/runner/stream-settle-backstop.d.ts +3 -2
- package/dist/core/runner/stream-settle-backstop.js +5 -3
- package/dist/core/runner/stream-steer-verb.d.ts +5 -2
- package/dist/core/runner/stream-steer-verb.js +16 -7
- package/dist/core/runner/terminal-account.d.ts +11 -1
- package/dist/core/runner/terminal-account.js +20 -0
- package/dist/core/runner/terminal-projection.d.ts +8 -2
- package/dist/core/runner/terminal-projection.js +2 -2
- package/dist/core/runner/tool-disclosure.d.ts +3 -0
- package/dist/core/runner/tool-disclosure.js +5 -2
- package/dist/core/runner/tool-end-body.d.ts +3 -3
- package/dist/core/runner/tool-end-body.js +1 -1
- package/dist/core/runner/tool-face-overlay.js +2 -0
- package/dist/core/runner/tool-output-projection.d.ts +3 -3
- package/dist/core/runner/tool-output-projection.js +7 -6
- package/dist/core/runner/tool-table-view.d.ts +56 -0
- package/dist/core/runner/tool-table-view.js +51 -0
- package/dist/core/runner/turn-attachments.d.ts +8 -2
- package/dist/core/runner/turn-attachments.js +2 -2
- package/dist/core/runner/void-verifier-pause.d.ts +33 -0
- package/dist/core/runner/void-verifier-pause.js +41 -0
- package/dist/core/runner-deps.d.ts +26 -27
- package/dist/core/secret-env.d.ts +19 -16
- package/dist/core/secret-env.js +45 -27
- package/dist/core/session-log-transfer.js +9 -10
- package/dist/core/session-policy-store.d.ts +1 -1
- package/dist/core/session-policy-store.js +5 -2
- package/dist/core/session-reconcile.d.ts +3 -2
- package/dist/core/session-reconcile.js +7 -4
- package/dist/core/session-store.d.ts +3 -1
- package/dist/core/session-store.js +10 -8
- package/dist/core/session.d.ts +16 -5
- package/dist/core/shell-confinement.d.ts +37 -0
- package/dist/core/shell-confinement.js +56 -0
- package/dist/core/skill-grant.js +1 -1
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +8 -2
- package/dist/core/store-contracts/checkpoint-store-contract.js +83 -2
- package/dist/core/store-contracts/file-history-store-contract.d.ts +5 -2
- package/dist/core/store-contracts/file-history-store-contract.js +25 -1
- package/dist/core/store-contracts/mailbox-store-contract.d.ts +12 -5
- package/dist/core/store-contracts/mailbox-store-contract.js +156 -9
- package/dist/core/store-contracts/session-store-contract.js +22 -8
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/tool-result-store-contract.js +30 -0
- package/dist/core/task-event.d.ts +24 -9
- package/dist/core/task-limits.d.ts +5 -0
- package/dist/core/task-notification.d.ts +89 -12
- package/dist/core/task-notification.js +89 -14
- package/dist/core/task-registry-agent.d.ts +32 -50
- package/dist/core/task-registry-agent.js +36 -56
- package/dist/core/task-registry-monitor.d.ts +1 -1
- package/dist/core/task-registry-monitor.js +15 -60
- package/dist/core/task-registry-shared.d.ts +22 -112
- package/dist/core/task-registry-shared.js +3 -41
- package/dist/core/task-registry-workflow.js +5 -21
- package/dist/core/task-registry.d.ts +32 -62
- package/dist/core/task-registry.js +30 -110
- package/dist/core/task-result.d.ts +29 -12
- package/dist/core/task-spec-members.d.ts +39 -0
- package/dist/core/task-spec-members.js +92 -0
- package/dist/core/task-spec.d.ts +11 -11
- package/dist/core/task-tool-shape.d.ts +7 -57
- package/dist/core/task-tool-shape.js +7 -66
- package/dist/core/terminal-cause.d.ts +36 -6
- package/dist/core/terminal-cause.js +1 -0
- package/dist/core/tool-catalog-entries.js +2 -5
- package/dist/core/tool-check-reading.js +16 -10
- package/dist/core/tool-conformance.js +1 -2
- package/dist/core/tool-errors.d.ts +6 -3
- package/dist/core/tool-errors.js +2 -0
- package/dist/core/tool-face-reader.js +3 -2
- package/dist/core/tool-face.d.ts +8 -5
- package/dist/core/tool-face.js +1 -1
- package/dist/core/tool-name-aliases.d.ts +5 -29
- package/dist/core/tool-name-aliases.js +9 -5
- package/dist/core/tool-name-readings.d.ts +14 -3
- package/dist/core/tool-name-readings.js +2 -0
- package/dist/core/tool-policy.d.ts +109 -18
- package/dist/core/tool-policy.js +84 -14
- package/dist/core/tool-result-store.d.ts +23 -0
- package/dist/core/tool-result-store.js +3 -2
- package/dist/core/tool-roster.d.ts +4 -4
- package/dist/core/tool-spec.d.ts +23 -6
- package/dist/core/trace.d.ts +18 -1
- package/dist/core/types.d.ts +1 -1
- package/dist/core/types.js +1 -1
- package/dist/core/user-attachment.js +26 -21
- package/dist/core/workflow-journal-store.d.ts +1 -1
- package/dist/core/workflow-run-store.d.ts +2 -0
- package/dist/core/workflow-run-store.js +6 -5
- package/dist/core/workflow-settled-run.d.ts +5 -0
- package/dist/core/workflow-settled-run.js +7 -0
- package/dist/engine/execution-env/node-execution-env.d.ts +37 -9
- package/dist/engine/execution-env/node-execution-env.js +221 -22
- package/dist/engine/harness/agent-harness.d.ts +65 -18
- package/dist/engine/harness/agent-harness.js +90 -23
- package/dist/engine/harness/messages.d.ts +4 -3
- package/dist/engine/harness/messages.js +2 -2
- package/dist/engine/harness/types.d.ts +52 -7
- package/dist/engine/llm/media-removed.d.ts +14 -0
- package/dist/engine/llm/media-removed.js +9 -0
- package/dist/engine/llm/rejected-images.d.ts +35 -25
- package/dist/engine/llm/rejected-images.js +59 -10
- package/dist/engine/llm/types.d.ts +24 -3
- package/dist/engine/llm/types.js +7 -3
- package/dist/engine/loop/agent-loop.d.ts +6 -1
- package/dist/engine/loop/agent-loop.js +20 -11
- package/dist/engine/loop/types.d.ts +12 -3
- package/dist/engine/session/import-validate.js +7 -0
- package/dist/engine/session/parent-chain-guard.d.ts +3 -3
- package/dist/engine/session/parent-chain-guard.js +1 -1
- package/dist/engine/session/path-to-root.d.ts +18 -3
- package/dist/engine/session/path-to-root.js +15 -1
- package/dist/engine/session/repo-utils.d.ts +12 -1
- package/dist/engine/session/repo-utils.js +41 -0
- package/dist/engine/session/session.js +1 -1
- package/dist/engine/session/storage-base.d.ts +20 -0
- package/dist/engine/session/storage-base.js +28 -9
- package/dist/fixtures/index.d.ts +7 -5
- package/dist/fixtures/index.js +5 -3
- package/dist/index.d.ts +29 -18
- package/dist/index.js +19 -11
- package/dist/internal/harness-types.d.ts +2 -0
- package/dist/internal/harness.d.ts +4 -3
- package/dist/internal/harness.js +3 -2
- package/dist/internal/llm.d.ts +2 -1
- package/dist/internal/llm.js +1 -0
- package/dist/orchestration/goal.d.ts +6 -2
- package/dist/orchestration/goal.js +6 -3
- package/dist/orchestration/run-workflow-tool.d.ts +14 -17
- package/dist/orchestration/run-workflow-tool.js +43 -50
- package/dist/orchestration/workflow-types.d.ts +2 -2
- package/dist/orchestration/workflow.d.ts +7 -0
- package/dist/orchestration/workflow.js +10 -12
- package/dist/stores/file/background-agent-store.js +18 -15
- package/dist/stores/file/checkpoint-store.d.ts +2 -0
- package/dist/stores/file/checkpoint-store.js +13 -9
- package/dist/stores/file/file-history-store.js +3 -2
- package/dist/stores/file/fs-atomic.d.ts +0 -22
- package/dist/stores/file/fs-atomic.js +0 -17
- package/dist/stores/file/index.d.ts +7 -12
- package/dist/stores/file/index.js +25 -12
- package/dist/stores/file/ledger-tuning.d.ts +23 -0
- package/dist/stores/file/ledger-tuning.js +21 -0
- package/dist/stores/file/mailbox-store.js +42 -22
- package/dist/stores/file/memory-store.js +3 -2
- package/dist/stores/file/permission-rule-adopt.js +24 -21
- package/dist/stores/file/permission-rule-store.js +6 -3
- package/dist/stores/file/session-policy-store.js +3 -2
- package/dist/stores/file/session-store.d.ts +26 -7
- package/dist/stores/file/session-store.js +59 -35
- package/dist/stores/file/tool-result-store.d.ts +11 -0
- package/dist/stores/file/tool-result-store.js +57 -3
- package/dist/stores/file/usage-window-store.js +3 -2
- package/dist/stores/file/workflow-journal-store.d.ts +0 -2
- package/dist/stores/file/workflow-journal-store.js +3 -18
- package/dist/stores/file/workflow-run-store.d.ts +1 -1
- package/dist/stores/file/workflow-run-store.js +15 -10
- package/dist/tools/fs/bash-program-position.d.ts +3 -2
- package/dist/tools/fs/bash-program-position.js +7 -7
- package/dist/tools/fs/dead-cwd.d.ts +5 -5
- package/dist/tools/fs/dead-cwd.js +4 -11
- package/dist/tools/fs/fs-bash-background-text.d.ts +6 -0
- package/dist/tools/fs/fs-bash-background-text.js +6 -0
- package/dist/tools/fs/fs-bash.d.ts +3 -18
- package/dist/tools/fs/fs-bash.js +37 -124
- package/dist/tools/fs/fs-pdf.js +8 -6
- package/dist/tools/fs/fs-read.js +2 -2
- package/dist/tools/fs/fs-shared.d.ts +28 -3
- package/dist/tools/fs/fs-shared.js +15 -0
- package/dist/tools/fs/index.d.ts +1 -1
- package/dist/tools/fs/index.js +4 -14
- package/dist/tools/fs/pdf.d.ts +4 -4
- package/dist/tools/fs/pdf.js +6 -6
- package/dist/tools/fs/read-deny-home.js +8 -1
- package/dist/tools/fs/read-deny.d.ts +26 -2
- package/dist/tools/fs/read-deny.js +9 -2
- package/dist/tools/fs/read-floor.d.ts +13 -5
- package/dist/tools/fs/read-floor.js +206 -2
- package/dist/tools/fs/removal-targets.js +2 -2
- package/dist/tools/fs/search.d.ts +3 -2
- package/dist/tools/fs/search.js +6 -6
- package/dist/tools/fs/shell-read-argv.d.ts +4 -2
- package/dist/tools/fs/shell-read-argv.js +14 -3
- package/dist/tools/fs/shell-read-bindings.d.ts +18 -2
- package/dist/tools/fs/shell-read-bindings.js +148 -68
- package/dist/tools/fs/shell-read-check.js +20 -4
- package/dist/tools/fs/shell-read-establish.js +25 -9
- package/dist/tools/fs/shell-read-functions.js +2 -2
- package/dist/tools/fs/shell-read-identity.d.ts +3 -1
- package/dist/tools/fs/shell-read-identity.js +4 -2
- package/dist/tools/fs/shell-read-judge.d.ts +7 -1
- package/dist/tools/fs/shell-read-judge.js +1 -1
- package/dist/tools/fs/shell-read-object-path.d.ts +59 -0
- package/dist/tools/fs/shell-read-object-path.js +119 -0
- package/dist/tools/fs/shell-read-plan.d.ts +8 -0
- package/dist/tools/fs/shell-read-plan.js +47 -30
- package/dist/tools/fs/shell-read-start.d.ts +66 -13
- package/dist/tools/fs/shell-read-start.js +89 -17
- package/dist/tools/fs/shell-read-workdir.d.ts +29 -8
- package/dist/tools/fs/shell-read-workdir.js +31 -8
- package/dist/tools/monitor.d.ts +8 -7
- package/dist/tools/monitor.js +12 -10
- package/dist/tools/worktree.d.ts +5 -1
- package/dist/tools/worktree.js +20 -17
- package/package.json +6 -3
- package/test/export-surface.snapshot.json +112 -42
- package/wire-changes/core-stores-sql@7.61.0.json +480 -0
- package/wire-changes/core-stores-sql@7.62.0.json +30 -0
- package/wire-changes/core@7.61.0.json +4405 -0
- package/wire-changes/core@7.62.0.json +2181 -0
- package/wire-changes/mods-kernel@7.61.0.json +65 -0
- package/wire-changes/mods-kernel@7.62.0.json +42 -0
- package/wire-changes/primitives@7.61.0.json +30 -0
- package/wire-changes/primitives@7.62.0.json +30 -0
- package/dist/core/consolidate-scope.d.ts +0 -93
- package/dist/core/consolidate-scope.js +0 -98
- package/dist/core/runner/image-removed-seat.d.ts +0 -12
- package/dist/core/runner/image-removed-seat.js +0 -19
- package/dist/core/runner/memory-consolidation.d.ts +0 -109
- package/dist/core/runner/memory-consolidation.js +0 -251
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { ExecutionEnv } from "../../internal/harness-types.js";
|
|
1
|
+
import type { AgentMessage, ExecutionEnv, ReadFloor } from "../../internal/harness-types.js";
|
|
2
|
+
import type { TaskAccess, TaskRegistry } from "../task-registry.js";
|
|
3
|
+
import type { SessionMeasureSeat } from "./lifecycle-stations.js";
|
|
2
4
|
import type { AssistantMessage, Message, Model, Usage } from "../../internal/llm.js";
|
|
3
5
|
import type { CwdRef } from "../../tools/fs/fs-shared.js";
|
|
4
6
|
import { type PermissionResult, type ToolCallRequest } from "../tool-policy.js";
|
|
@@ -7,11 +9,11 @@ import type { ClassicEventMap, ClassicEventName } from "./classic-events.js";
|
|
|
7
9
|
import type { PermissionMode } from "../ask-origin.js";
|
|
8
10
|
import type { RunnerDeps } from "../runner-deps.js";
|
|
9
11
|
import type { TaskSpec } from "../task-spec.js";
|
|
10
|
-
import { type ModAnswerCheck, type ModAnswerRanks, type ModBus, type ModCallEntry, type ModMountedHandler, type ModDispatchOutcome, type ModEventPayload, type ModRegistration } from "./kernel/index.js";
|
|
12
|
+
import { type ModAnswerCheck, type ModAnswerRanks, type ModBus, type ModCallEntry, type ModEventName, type ModMountedHandler, type ModDispatchOutcome, type ModEventPayload, type ModRegistration } from "./kernel/index.js";
|
|
11
13
|
import { type SourcedOverlay } from "../../prompt-assembly/overlay.js";
|
|
12
14
|
import type { BandId } from "../../prompt-assembly/catalog/schema.js";
|
|
13
15
|
import type { ModParticipant } from "./kernel/dispatch.js";
|
|
14
|
-
import { type EngineDollar, type ModelCompleteRequest, type ModelCompleteResult, type ModSeatView } from "./dollar.js";
|
|
16
|
+
import { type EngineDollar, type ModelCompleteRequest, type ModelCompleteResult, type ModSeatView, type SessionUsage, type SessionVersion } from "./dollar.js";
|
|
15
17
|
import type { SkillSpec } from "../agent-definition.js";
|
|
16
18
|
import { type SkillScopes } from "./spec-seats.js";
|
|
17
19
|
/**
|
|
@@ -24,28 +26,30 @@ export declare const ENGINE_CORE_ANSWER: Readonly<Record<string, never>>;
|
|
|
24
26
|
export declare function engineCore(): Readonly<Record<string, never>>;
|
|
25
27
|
/** The leg's bus seat, as the stations read it. */
|
|
26
28
|
export type LegModBus = Pick<ModBus, "hasHandlers" | "dispatch">;
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
/** Does a seat raise `event` — bound, and a handler hangs on it? Every station entry reads this first, synchronously. */
|
|
30
|
+
export declare function seatHears<B extends {
|
|
31
|
+
readonly bus: Pick<ModBus, "hasHandlers">;
|
|
32
|
+
}>(binding: B | undefined, event: ModEventName): binding is B;
|
|
33
|
+
/** The `detail` member of a notice a leg raises about itself: the leg's own task id, read from its prepare's one mint ({@link legTaskIdOf}), never from the host's declaration. */
|
|
34
|
+
export declare function legNoticeTaskId(leg: {
|
|
35
|
+
readonly taskId: string;
|
|
36
|
+
}): {
|
|
37
|
+
readonly taskId: string;
|
|
38
|
+
};
|
|
32
39
|
export interface LegEvents {
|
|
33
|
-
/** The person's-prompt screen its objective passes — present when a person wrote the objective. */
|
|
34
|
-
readonly screen?: "classic.UserPromptSubmit";
|
|
35
40
|
/** The event it opens on — present on a delegated leg. */
|
|
36
41
|
readonly start?: "classic.SubagentStart";
|
|
37
42
|
/** The event it raises when it would otherwise end. */
|
|
38
43
|
readonly stop: "classic.Stop" | "classic.SubagentStop";
|
|
39
44
|
}
|
|
40
45
|
/**
|
|
41
|
-
* Both ends of a leg
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* `classic.
|
|
46
|
-
* peer) and is judged at the delegator's gate. Not the leg kind: a resumed leg's kind reads `"resume"` whoever it runs as.
|
|
46
|
+
* Both ends of a leg, from the delegation fact alone (a child resumed from its checkpoint keeps it): a delegated leg opens on
|
|
47
|
+
* `classic.SubagentStart` and ends on `classic.SubagentStop`, any other opens on nothing and ends on `classic.Stop`. Not the leg
|
|
48
|
+
* kind (a resumed leg's kind reads `"resume"` whoever it runs as), and not who wrote the objective: whether an input passes
|
|
49
|
+
* `classic.UserPromptSubmit` is the input's own fact, its author (`countsAsOperator`, input-author.ts) — a delegator's words are
|
|
50
|
+
* judged at the delegator's gate (`classic.PreToolUse` on the delegating call), an operator's resume of a child is screened.
|
|
47
51
|
*/
|
|
48
|
-
export declare function legEventsOf(identity: Pick<HookInvocationIdentity, "isDelegatedChild"> | undefined
|
|
52
|
+
export declare function legEventsOf(identity: Pick<HookInvocationIdentity, "isDelegatedChild"> | undefined): LegEvents;
|
|
49
53
|
/**
|
|
50
54
|
* The args as a judging handler receives them: the gate pass's own immutable value ({@link ownArgs} — the value itself when
|
|
51
55
|
* the gate already took it, which is every call the gate raises an event over), so the bytes a handler judges are the bytes
|
|
@@ -201,9 +205,13 @@ export declare function observePermissionDenied(input: {
|
|
|
201
205
|
readonly signal: AbortSignal | undefined;
|
|
202
206
|
readonly onHostObserverFailure: (err: Error) => void;
|
|
203
207
|
}): Promise<void>;
|
|
204
|
-
/** What a
|
|
208
|
+
/** What a prompt's screen came to, as the four entrances read it: `text` is what the entrance delivers (the prompt as it
|
|
209
|
+
* came, or as `prompt.submit` handed it on — `rewrittenBy` then names who changed it, in the order they did); `block` the
|
|
210
|
+
* refusal (a `prompt.submit` drop, or `classic.UserPromptSubmit`'s block). */
|
|
205
211
|
export type PromptScreen = {
|
|
206
212
|
readonly kind: "answered";
|
|
213
|
+
readonly text: string;
|
|
214
|
+
readonly rewrittenBy?: readonly string[];
|
|
207
215
|
readonly block?: string;
|
|
208
216
|
readonly additionalContext?: string;
|
|
209
217
|
} | Extract<ModDispatchOutcome, {
|
|
@@ -211,10 +219,31 @@ export type PromptScreen = {
|
|
|
211
219
|
}> | {
|
|
212
220
|
readonly kind: "aborted";
|
|
213
221
|
};
|
|
222
|
+
/** Who changed a text a chain carried, read off the chain as it runs (a station's `checkHandOn` and `checkAnswer` feed it). */
|
|
223
|
+
export interface TextChanges {
|
|
224
|
+
/** A handler handed `text` on (down): it changed the text when that differs from what the previous hand-on (or the
|
|
225
|
+
* original) carried. */
|
|
226
|
+
handedOn(by: string, text: string): void;
|
|
227
|
+
/** A handler answered `text` (up): it changed the text when that differs from what its `next` answered (`below`) or, when
|
|
228
|
+
* it answered without one, from the text it was handed. */
|
|
229
|
+
answered(by: string, text: string, handed: string, below: string | undefined): void;
|
|
230
|
+
/** The handlers that changed the text, in the order they did (down before up), each named once. */
|
|
231
|
+
rewrittenBy(): readonly string[];
|
|
232
|
+
}
|
|
233
|
+
/** The one reading of who changed a text, for every station whose answer is a rewritten text (`session.receive`,
|
|
234
|
+
* `prompt.submit`): a handler is named for the change it made — handing a different text on, or answering a different text
|
|
235
|
+
* than the one that came up to it — never for carrying another handler's change up. */
|
|
236
|
+
export declare function textChanges(original: string): TextChanges;
|
|
237
|
+
/** The four entrances' one predicate: does the leg hear a prompt's screen — `prompt.submit`, or `classic.UserPromptSubmit`
|
|
238
|
+
* raised in its bottom? */
|
|
239
|
+
export declare function promptScreenHasHandlers(bus: LegModBus): boolean;
|
|
214
240
|
/**
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
241
|
+
* A prompt's screen at one of the four entrances (objective, live steer, a wake's message before its claim, a parked steer
|
|
242
|
+
* redelivered): `prompt.submit` over `e` with the prompt as `text`, its bottom raising `classic.UserPromptSubmit` on the text
|
|
243
|
+
* handed down; `undefined` (nothing raised) when neither is heard ({@link promptScreenHasHandlers}). A decision event: a
|
|
244
|
+
* handler that throws, runs past its budget or breaks the site's contract ends the screen `failed`, and every entrance fails
|
|
245
|
+
* closed on it; a cancelled screen ends `aborted` at once; a dispatch the engine could not run is `failed` too. What the
|
|
246
|
+
* classic screen refused (its block, failure or cancel) is final — a `prompt.submit` handler above it does not undo it.
|
|
218
247
|
*/
|
|
219
248
|
export declare function screenUserPrompt(bus: LegModBus, e: UserPromptSubmitEvent, signal: AbortSignal | undefined): Promise<PromptScreen | undefined>;
|
|
220
249
|
/**
|
|
@@ -297,11 +326,24 @@ export interface LegFacadeSeats {
|
|
|
297
326
|
root(): string;
|
|
298
327
|
model(): string;
|
|
299
328
|
messages(): readonly Message[];
|
|
329
|
+
/** `$.session.messages({ agentId })`'s read ({@link agentRowsOf}). */
|
|
330
|
+
agentMessages(agentId: string): Promise<readonly AgentMessage[]>;
|
|
331
|
+
turns(): Promise<number>;
|
|
332
|
+
usage(): SessionUsage;
|
|
333
|
+
version(): SessionVersion;
|
|
300
334
|
now(): number;
|
|
301
335
|
tools(): readonly string[];
|
|
302
336
|
agents(): readonly string[];
|
|
303
337
|
/** `$.tool.call`'s host entry (`createToolCallEntry`, `tool-call.ts`). */
|
|
304
338
|
readonly toolCall: ModCallEntry;
|
|
339
|
+
/** `$.agent.spawn`'s host entry (`createAgentSpawnEntry`, `agent-stations.ts`). */
|
|
340
|
+
readonly agentSpawn: ModCallEntry;
|
|
341
|
+
/** `$.session.append`'s host entry (`createSessionAppendEntry`, `session-append.ts`). */
|
|
342
|
+
readonly sessionAppend: ModCallEntry;
|
|
343
|
+
/** `$.session.send`'s host entry (`createSessionSendEntry`, `session-send.ts`). */
|
|
344
|
+
readonly sessionSend: ModCallEntry;
|
|
345
|
+
/** `$.session.compact`'s host entry (`createSessionCompactEntry`, `session-compact.ts`). */
|
|
346
|
+
readonly sessionCompact: ModCallEntry;
|
|
305
347
|
}
|
|
306
348
|
/** The leg's admitted bus, its chain identity (the one its admission recorded, {@link chainOfBus}) and the binding of the
|
|
307
349
|
* facade its `$` reaches. `bus` is the leg bus every station raises on ({@link legBusOf}: an extension's own call's
|
|
@@ -315,6 +357,8 @@ export interface LegMods {
|
|
|
315
357
|
readonly chain: readonly ModChainLink[];
|
|
316
358
|
/** The leg's skill scopes (`SkillSpec.mods`): the grant table opens one on each activation, the park freezes them. */
|
|
317
359
|
readonly skillScopes: SkillScopes;
|
|
360
|
+
/** The leg's report sink (handler failures; a station's own disclosures). */
|
|
361
|
+
readonly report: (err: Error) => void;
|
|
318
362
|
/** Bind the engine facade once the leg is prepared. Until then a `$` call throws, naming the method. */
|
|
319
363
|
bindFacade(seats: LegFacadeSeats): void;
|
|
320
364
|
}
|
|
@@ -340,12 +384,21 @@ export interface LegFacadeInput {
|
|
|
340
384
|
readonly sessionId: string;
|
|
341
385
|
readonly model: Model;
|
|
342
386
|
readonly executionEnv: Pick<ExecutionEnv, "exec">;
|
|
387
|
+
/** The run's byte-floor seat: a mod's `$.process.run` is the run's own start and carries the run's base table. */
|
|
388
|
+
readonly readFloor: (toolCallId: string | undefined) => ReadFloor | undefined;
|
|
343
389
|
readonly taskRoot: string;
|
|
344
390
|
readonly cwdRef: CwdRef | undefined;
|
|
345
391
|
/** The leg's latest model request as recorded at the provider seam (the session's messages as the model last saw them). */
|
|
346
392
|
readonly lastBrainContext: () => {
|
|
347
393
|
readonly messages: readonly Message[];
|
|
348
394
|
} | undefined;
|
|
395
|
+
/** Where the leg's subagents' transcripts are read ({@link agentRowsOf}); `undefined` ⇒ there is no task list (a
|
|
396
|
+
* session-level pass), and the read refuses saying so. */
|
|
397
|
+
readonly agentSessions: AgentSessionsSeat | undefined;
|
|
398
|
+
/** The session's prompt count, read at the call (`promptCountOf` over its branch, `session-append.ts`). */
|
|
399
|
+
readonly turns: () => Promise<number>;
|
|
400
|
+
/** The leg's measurement seat (`measureSession` writes it at each turn boundary). */
|
|
401
|
+
readonly measure: SessionMeasureSeat;
|
|
349
402
|
readonly activeTools: ReadonlySet<string>;
|
|
350
403
|
readonly agentListing: {
|
|
351
404
|
readonly entries: ReadonlyArray<{
|
|
@@ -361,6 +414,20 @@ export interface LegFacadeInput {
|
|
|
361
414
|
}) => void;
|
|
362
415
|
/** `$.tool.call`'s host entry, over the leg's harness and occurrence table. */
|
|
363
416
|
readonly toolCall: ModCallEntry;
|
|
417
|
+
/** `$.agent.spawn`'s host entry, over the leg's harness and its delegation tool. */
|
|
418
|
+
readonly agentSpawn: ModCallEntry;
|
|
419
|
+
/** `$.session.append`'s host entry, over the leg's admission seat and harness. */
|
|
420
|
+
readonly sessionAppend: ModCallEntry;
|
|
421
|
+
/** `$.session.send`'s host entry, over the leg's `$.tool.call` entry and its SendMessage. */
|
|
422
|
+
readonly sessionSend: ModCallEntry;
|
|
423
|
+
/** `$.session.compact`'s host entry, over the leg's compaction station. */
|
|
424
|
+
readonly sessionCompact: ModCallEntry;
|
|
425
|
+
}
|
|
426
|
+
/** The seat a leg reads its subagents' transcripts through: its task list, only the rows its own access reaches. Each row
|
|
427
|
+
* carries the store its child's session lives in, so no store of the leg's own is read. */
|
|
428
|
+
export interface AgentSessionsSeat {
|
|
429
|
+
readonly registry: Pick<TaskRegistry, "anchoredSession">;
|
|
430
|
+
readonly access: TaskAccess;
|
|
364
431
|
}
|
|
365
432
|
/** The engine facade's seats over a prepared leg — each one a seat the leg already has (no new capability). */
|
|
366
433
|
export declare function legFacadeSeats(input: LegFacadeInput): LegFacadeSeats;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { types } from "node:util";
|
|
2
|
+
import { engineVersion } from "../version.js";
|
|
2
3
|
import { resolveModel } from "../roles.js";
|
|
3
4
|
import { brainToRuntime } from "../runtime.js";
|
|
4
5
|
import { deliverEngineNotice } from "../engine-notice.js";
|
|
5
6
|
import { extensionWords } from "../untrusted-egress.js";
|
|
6
7
|
import { askApproverIdentity, describeThrown, ownArgs } from "../tool-policy.js";
|
|
8
|
+
import { agentIdOf } from "../leg-identity.js";
|
|
7
9
|
import { admitMods } from "./kernel/index.js";
|
|
8
10
|
import { legBusOf } from "./extension-call.js";
|
|
9
11
|
import { validateOverlay } from "../../prompt-assembly/overlay.js";
|
|
@@ -16,16 +18,16 @@ export const ENGINE_CORE_ANSWER = Object.freeze({});
|
|
|
16
18
|
export function engineCore() {
|
|
17
19
|
return ENGINE_CORE_ANSWER;
|
|
18
20
|
}
|
|
19
|
-
export function
|
|
20
|
-
return
|
|
21
|
+
export function seatHears(binding, event) {
|
|
22
|
+
return binding !== undefined && binding.bus.hasHandlers(event);
|
|
21
23
|
}
|
|
22
|
-
|
|
24
|
+
export function legNoticeTaskId(leg) {
|
|
25
|
+
return { taskId: leg.taskId };
|
|
26
|
+
}
|
|
27
|
+
const TOP_LEVEL_LEG = Object.freeze({ stop: "classic.Stop" });
|
|
23
28
|
const DELEGATED_LEG = Object.freeze({ start: "classic.SubagentStart", stop: "classic.SubagentStop" });
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (identity?.isDelegatedChild !== true)
|
|
27
|
-
return PERSON_LEG;
|
|
28
|
-
return operatorObjective ? OPERATOR_RESUMED_LEG : DELEGATED_LEG;
|
|
29
|
+
export function legEventsOf(identity) {
|
|
30
|
+
return identity?.isDelegatedChild === true ? DELEGATED_LEG : TOP_LEVEL_LEG;
|
|
29
31
|
}
|
|
30
32
|
export function judgedInputOf(args) {
|
|
31
33
|
const owned = ownArgs(args);
|
|
@@ -199,7 +201,101 @@ export async function observePermissionDenied(input) {
|
|
|
199
201
|
await observeClassic(own, "classic.PermissionDenied", e, input.signal);
|
|
200
202
|
}
|
|
201
203
|
const USER_PROMPT_RANKS = Object.freeze({ of: (a) => (stringMembersOf(a, ["block"]).block ? 1 : 0), top: 1 });
|
|
204
|
+
export function textChanges(original) {
|
|
205
|
+
const changers = [];
|
|
206
|
+
const note = (by) => {
|
|
207
|
+
if (!changers.includes(by))
|
|
208
|
+
changers.push(by);
|
|
209
|
+
};
|
|
210
|
+
let before = original;
|
|
211
|
+
return {
|
|
212
|
+
handedOn: (by, text) => {
|
|
213
|
+
if (text !== before)
|
|
214
|
+
note(by);
|
|
215
|
+
before = text;
|
|
216
|
+
},
|
|
217
|
+
answered: (by, text, handed, below) => {
|
|
218
|
+
if (text !== (below ?? handed))
|
|
219
|
+
note(by);
|
|
220
|
+
},
|
|
221
|
+
rewrittenBy: () => Object.freeze([...changers]),
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
export function promptScreenHasHandlers(bus) {
|
|
225
|
+
return bus.hasHandlers("prompt.submit") || bus.hasHandlers("classic.UserPromptSubmit");
|
|
226
|
+
}
|
|
227
|
+
const PROMPT_SUBMIT_FORM = "prompt.submit takes { text } (a string) or { drop: <reason> }";
|
|
228
|
+
function readSubmitAnswer(a) {
|
|
229
|
+
if (!isPlainRecord(a))
|
|
230
|
+
return { why: PROMPT_SUBMIT_FORM };
|
|
231
|
+
const keys = Object.keys(a);
|
|
232
|
+
if (keys.length === 1 && keys[0] === "drop") {
|
|
233
|
+
const r = a["drop"];
|
|
234
|
+
return typeof r === "string" && r.trim() !== "" ? { drop: r } : { why: "a drop that is not a reason (a non-empty string)" };
|
|
235
|
+
}
|
|
236
|
+
if (keys.length === 1 && keys[0] === "text") {
|
|
237
|
+
const t = a["text"];
|
|
238
|
+
return typeof t === "string" ? { text: t } : { why: "a text that is not a string" };
|
|
239
|
+
}
|
|
240
|
+
return { why: PROMPT_SUBMIT_FORM };
|
|
241
|
+
}
|
|
242
|
+
const PROMPT_SUBMIT_RANKS = Object.freeze({ of: (a) => (isPlainRecord(a) && Object.hasOwn(a, "drop") ? 1 : 0), top: 1 });
|
|
202
243
|
export async function screenUserPrompt(bus, e, signal) {
|
|
244
|
+
if (!promptScreenHasHandlers(bus))
|
|
245
|
+
return undefined;
|
|
246
|
+
const { prompt, ...facts } = e;
|
|
247
|
+
const changes = textChanges(prompt);
|
|
248
|
+
const checkHandOn = (handed, by) => {
|
|
249
|
+
const t = handed["text"];
|
|
250
|
+
if (typeof t !== "string")
|
|
251
|
+
return "next() handed on a text that is not a string";
|
|
252
|
+
changes.handedOn(by.plugin, t);
|
|
253
|
+
return undefined;
|
|
254
|
+
};
|
|
255
|
+
const seen = {};
|
|
256
|
+
const bottom = async (handed) => {
|
|
257
|
+
const text = handed["text"];
|
|
258
|
+
const classic = await screenClassicPrompt(bus, { ...e, prompt: text }, signal);
|
|
259
|
+
if (classic !== undefined)
|
|
260
|
+
seen.classic = classic;
|
|
261
|
+
if (classic === undefined || (classic.kind === "answered" && !classic.block))
|
|
262
|
+
return Object.freeze({ text });
|
|
263
|
+
return Object.freeze({ drop: classic.kind === "answered" ? classic.block : "the classic.UserPromptSubmit screen did not clear the prompt" });
|
|
264
|
+
};
|
|
265
|
+
const checkAnswer = (a, handed, by, below) => {
|
|
266
|
+
const read = readSubmitAnswer(a);
|
|
267
|
+
if ("why" in read)
|
|
268
|
+
return read.why;
|
|
269
|
+
if ("text" in read) {
|
|
270
|
+
const up = below.length > 0 ? readSubmitAnswer(below[below.length - 1]) : undefined;
|
|
271
|
+
changes.answered(by.plugin, read.text, handed["text"], up !== undefined && "text" in up ? up.text : undefined);
|
|
272
|
+
}
|
|
273
|
+
return undefined;
|
|
274
|
+
};
|
|
275
|
+
let outcome;
|
|
276
|
+
try {
|
|
277
|
+
outcome = await bus.dispatch("prompt.submit", { ...facts, text: prompt }, { bottom, checkAnswer, checkHandOn, ranks: PROMPT_SUBMIT_RANKS, ...(signal !== undefined ? { signal } : {}) });
|
|
278
|
+
}
|
|
279
|
+
catch (err) {
|
|
280
|
+
return { kind: "failed", registration: "engine", cause: "threw", reason: `could not raise the screen: ${describeThrown(err)}`, skipped: [] };
|
|
281
|
+
}
|
|
282
|
+
const classic = seen.classic;
|
|
283
|
+
if (classic !== undefined && (classic.kind !== "answered" || classic.block))
|
|
284
|
+
return classic.kind === "answered" ? { ...classic, text: prompt } : classic;
|
|
285
|
+
if (outcome.kind !== "answered")
|
|
286
|
+
return outcome;
|
|
287
|
+
const read = readSubmitAnswer(outcome.answer);
|
|
288
|
+
const by = outcome.answeredBy ?? "engine";
|
|
289
|
+
const context = classic?.kind === "answered" && classic.additionalContext !== undefined ? { additionalContext: classic.additionalContext } : {};
|
|
290
|
+
if ("drop" in read)
|
|
291
|
+
return { kind: "answered", text: prompt, block: read.drop };
|
|
292
|
+
if ("why" in read)
|
|
293
|
+
return { kind: "failed", registration: by, cause: "violation", reason: read.why, skipped: [] };
|
|
294
|
+
if (read.text === prompt)
|
|
295
|
+
return { kind: "answered", text: prompt, ...context };
|
|
296
|
+
return { kind: "answered", text: read.text, rewrittenBy: changes.rewrittenBy(), ...context };
|
|
297
|
+
}
|
|
298
|
+
async function screenClassicPrompt(bus, e, signal) {
|
|
203
299
|
let outcome;
|
|
204
300
|
try {
|
|
205
301
|
outcome = await dispatchClassic(bus, "classic.UserPromptSubmit", e, {
|
|
@@ -386,6 +482,10 @@ function lateView() {
|
|
|
386
482
|
root: () => need("session.root").root(),
|
|
387
483
|
model: () => need("session.model").model(),
|
|
388
484
|
messages: () => need("session.messages").messages(),
|
|
485
|
+
agentMessages: (agentId) => need("session.messages").agentMessages(agentId),
|
|
486
|
+
turns: () => need("session.turns").turns(),
|
|
487
|
+
usage: () => need("session.usage").usage(),
|
|
488
|
+
version: () => need("session.version").version(),
|
|
389
489
|
},
|
|
390
490
|
now: () => need("clock.now").now(),
|
|
391
491
|
tools: () => need("tool.list").tools(),
|
|
@@ -393,7 +493,13 @@ function lateView() {
|
|
|
393
493
|
};
|
|
394
494
|
return {
|
|
395
495
|
view,
|
|
396
|
-
entries: {
|
|
496
|
+
entries: {
|
|
497
|
+
"tool.call": (args, ctx) => need("tool.call").toolCall(args, ctx),
|
|
498
|
+
"agent.spawn": (args, ctx) => need("agent.spawn").agentSpawn(args, ctx),
|
|
499
|
+
"session.append": (args, ctx) => need("session.append").sessionAppend(args, ctx),
|
|
500
|
+
"session.send": (args, ctx) => need("session.send").sessionSend(args, ctx),
|
|
501
|
+
"session.compact": (args, ctx) => need("session.compact").sessionCompact(args, ctx),
|
|
502
|
+
},
|
|
397
503
|
bind: (s) => {
|
|
398
504
|
seats = s;
|
|
399
505
|
},
|
|
@@ -416,7 +522,28 @@ export async function admitLegMods(input) {
|
|
|
416
522
|
const chain = recordAdmittedChain(bus, seats);
|
|
417
523
|
if (standing !== bus)
|
|
418
524
|
ADMITTED_CHAINS.set(standing, chain);
|
|
419
|
-
return { bus, standing, chain, skillScopes, bindFacade: late.bind };
|
|
525
|
+
return { bus, standing, chain, skillScopes, report, bindFacade: late.bind };
|
|
526
|
+
}
|
|
527
|
+
async function agentRowsOf(seat, agentId) {
|
|
528
|
+
const refused = (why) => new Error(`session.messages: agent ${agentId}: ${why}`);
|
|
529
|
+
if (seat === undefined)
|
|
530
|
+
throw refused("there is no task list here — a session-level pass has no run, so no subagents");
|
|
531
|
+
const anchor = seat.registry.anchoredSession(agentId, seat.access);
|
|
532
|
+
if (anchor === undefined)
|
|
533
|
+
throw refused("not one of this leg's subagents (no task list row this leg reaches has that id)");
|
|
534
|
+
if (anchor === null)
|
|
535
|
+
throw refused("its row names no session — not a subagent's row, or its session is not bound yet or was released");
|
|
536
|
+
const store = anchor.store;
|
|
537
|
+
if (store === undefined)
|
|
538
|
+
throw refused("its session was bound without the store that holds it");
|
|
539
|
+
let branch;
|
|
540
|
+
try {
|
|
541
|
+
branch = await (await store.acquire(anchor.sessionId, { requireExisting: true })).session.getBranch();
|
|
542
|
+
}
|
|
543
|
+
catch (err) {
|
|
544
|
+
throw refused(`its session could not be read (${describeThrown(err)})`);
|
|
545
|
+
}
|
|
546
|
+
return branch.flatMap((e) => (e.type === "message" ? [e.message] : []));
|
|
420
547
|
}
|
|
421
548
|
function replyText(reply) {
|
|
422
549
|
return reply.content.flatMap((c) => (c.type === "text" ? [c.text] : [])).join("");
|
|
@@ -426,7 +553,10 @@ export function legFacadeSeats(input) {
|
|
|
426
553
|
const answeredBy = new Map();
|
|
427
554
|
const byUsage = new WeakMap();
|
|
428
555
|
return {
|
|
429
|
-
exec: (command, options) =>
|
|
556
|
+
exec: (command, options) => {
|
|
557
|
+
const readFloor = input.readFloor(undefined);
|
|
558
|
+
return input.executionEnv.exec(command, { ...options, ...(readFloor !== undefined ? { readFloor } : {}) });
|
|
559
|
+
},
|
|
430
560
|
complete: async (request, signal) => {
|
|
431
561
|
const model = request.model !== undefined ? resolveModel(request.model, input.deps.models) : input.model;
|
|
432
562
|
answeredBy.set(model.id, model);
|
|
@@ -451,10 +581,18 @@ export function legFacadeSeats(input) {
|
|
|
451
581
|
root: () => input.taskRoot,
|
|
452
582
|
model: () => input.model.id,
|
|
453
583
|
messages: () => input.lastBrainContext()?.messages ?? [],
|
|
584
|
+
agentMessages: (agentId) => agentRowsOf(input.agentSessions, agentId),
|
|
585
|
+
turns: () => input.turns(),
|
|
586
|
+
usage: () => Object.freeze(input.measure.context !== undefined ? { context: input.measure.context } : {}),
|
|
587
|
+
version: () => Object.freeze({ version: engineVersion() }),
|
|
454
588
|
now: () => (input.deps.now ?? Date.now)(),
|
|
455
589
|
tools: () => [...input.activeTools],
|
|
456
590
|
agents: () => (input.agentListing?.entries ?? []).map((e) => e.name),
|
|
457
591
|
toolCall: input.toolCall,
|
|
592
|
+
agentSpawn: input.agentSpawn,
|
|
593
|
+
sessionAppend: input.sessionAppend,
|
|
594
|
+
sessionSend: input.sessionSend,
|
|
595
|
+
sessionCompact: input.sessionCompact,
|
|
458
596
|
};
|
|
459
597
|
}
|
|
460
598
|
export async function admitModChain(seats, onError) {
|
|
@@ -87,3 +87,5 @@ export declare function extensionCallOverlap(input: {
|
|
|
87
87
|
readonly args: unknown;
|
|
88
88
|
readonly batchSafe: (toolName: string, args: unknown) => boolean;
|
|
89
89
|
}): string | undefined;
|
|
90
|
+
/** A call result's text, as a host entry answers a refusal with it (`{ deny: <the text> }`). */
|
|
91
|
+
export declare const resultText: (content: unknown) => string;
|
|
@@ -143,7 +143,7 @@ export function createToolCallStation(input) {
|
|
|
143
143
|
const AGENT_DOOR = "runs the Agent tool: that is $.agent.spawn";
|
|
144
144
|
const OTHER_DOOR = new Map([
|
|
145
145
|
[toolFace("ask-user-question").contract.contractId, "runs the AskUserQuestion tool, which puts a question to the person: an extension's call does not ask the person"],
|
|
146
|
-
[toolFace("workflow").contract.contractId, "runs the Workflow tool, whose agents run outside the
|
|
146
|
+
[toolFace("workflow").contract.contractId, "runs the Workflow tool, whose agents run outside the tree's bound on agents running at once (RunnerDeps.delegationEntryCaps.maxConcurrent): $.agent.spawn is the door"],
|
|
147
147
|
]);
|
|
148
148
|
export function createToolCallEntry(input) {
|
|
149
149
|
return async (args, ctx) => {
|
|
@@ -152,7 +152,7 @@ export function createToolCallEntry(input) {
|
|
|
152
152
|
if (typeof tool !== "string" || tool === "")
|
|
153
153
|
throw new TypeError(`${by}: $.tool.call takes the event's input: { tool, ...args }`);
|
|
154
154
|
const toolCallId = `ext-${randomUUID()}`;
|
|
155
|
-
return runExtensionCall(input.bus, toolCallId, ctx, async (call) => {
|
|
155
|
+
return runExtensionCall(input.bus, toolCallId, "tool.call", ctx, async (call) => {
|
|
156
156
|
const finalized = await input.harness.callTool({ type: "toolCall", id: toolCallId, name: tool, arguments: { ...callInput } }, ctx.signal, (t) => {
|
|
157
157
|
const contractId = input.faceOf(t.name)?.contractId;
|
|
158
158
|
const door = declaredDelegationNameOf(input.specOf(t.name)) !== undefined ? AGENT_DOOR : contractId !== undefined ? OTHER_DOOR.get(contractId) : undefined;
|
|
@@ -160,7 +160,7 @@ export function createToolCallEntry(input) {
|
|
|
160
160
|
throw new TypeError(`${by}: $.tool.call(${extensionWords(t.name, 80)}) ${door}`);
|
|
161
161
|
});
|
|
162
162
|
if (call.denied)
|
|
163
|
-
return Object.freeze({ deny:
|
|
163
|
+
return Object.freeze({ deny: resultText(finalized.result.content) });
|
|
164
164
|
return viewOf({ ...finalized.result, isError: finalized.isError });
|
|
165
165
|
});
|
|
166
166
|
};
|
|
@@ -174,4 +174,4 @@ export function extensionCallOverlap(input) {
|
|
|
174
174
|
const exclusive = others.find((o) => o.life === "released" && !input.batchSafe(o.wireName ?? o.spelledName, o.finalInput ?? o.args));
|
|
175
175
|
return exclusive === undefined ? undefined : `${name}: an extension's call cannot run beside "${extensionWords(exclusive.wireName ?? exclusive.spelledName, 80)}", which has the run to itself`;
|
|
176
176
|
}
|
|
177
|
-
const
|
|
177
|
+
export const resultText = (content) => (Array.isArray(content) ? content.map((b) => (isPlainRecord(b) && b["type"] === "text" && typeof b["text"] === "string" ? b["text"] : "")).join("") : "");
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { describeRejectedValue } from "./tool-search-setting.js";
|
|
2
2
|
import { inlineUntrusted } from "./untrusted-text.js";
|
|
3
|
+
import { optionKeys, receiveMembers } from "./own-property-receipt.js";
|
|
4
|
+
const OUTPUT_STYLE_KEYS = optionKeys()({ name: 0, turnReminder: 0 });
|
|
3
5
|
export const OUTPUT_STYLE_NAME_MAX = 256;
|
|
4
6
|
const OUTPUT_STYLE_DEFAULT_TURN_REMINDER = "Remember to follow the specific guidelines for this style.";
|
|
5
7
|
export function renderOutputStyle(name, turnReminder) {
|
|
@@ -15,10 +17,7 @@ export function resolveOutputStyleFrame(seat) {
|
|
|
15
17
|
};
|
|
16
18
|
if (seat === null || typeof seat !== "object" || Array.isArray(seat))
|
|
17
19
|
return refuse(`must be an object { name, turnReminder? } (got ${describeRejectedValue(seat)})`);
|
|
18
|
-
const
|
|
19
|
-
if (extra.length > 0)
|
|
20
|
-
return refuse(`carries ${extra.map((k) => JSON.stringify(k)).join(", ")}, which the seat does not read (members: "name", "turnReminder")`);
|
|
21
|
-
const { name, turnReminder } = seat;
|
|
20
|
+
const { name, turnReminder } = receiveMembers(seat, { subject: "TaskSpec.outputStyle", unit: "member", moment: "when the seat is read" }, OUTPUT_STYLE_KEYS, (_, extra) => refuse(`carries ${extra.map((k) => JSON.stringify(String(k))).join(", ")}, which the seat does not read (members: "name", "turnReminder")`));
|
|
22
21
|
if (typeof name !== "string" || name.trim() === "")
|
|
23
22
|
return refuse(`.name must be a non-empty string (got ${describeRejectedValue(name)})`);
|
|
24
23
|
if (name.length > OUTPUT_STYLE_NAME_MAX)
|
|
@@ -27,8 +27,74 @@ export declare const CONFIG_RECEIPT_MODE: ReceiptMode;
|
|
|
27
27
|
* itself, a container nested deeper — a shared one measured where it sits each time it is met), every copied container frozen.
|
|
28
28
|
*/
|
|
29
29
|
export declare const DECLARATION_RECEIPT_MODE: ReceiptMode;
|
|
30
|
+
/** Only {@link optionKeys} mints an {@link OptionKeys}: a hand-written list carries no brand. */
|
|
31
|
+
declare const OPTION_KEYS: unique symbol;
|
|
32
|
+
/**
|
|
33
|
+
* A constructor's options table: the keys of the options interface `T`, exactly. The brand is a function over `keyof T`
|
|
34
|
+
* in both positions, so a table for one interface is not a table for another (a narrower one, an `Omit` of it) in either
|
|
35
|
+
* direction, and a plain string list is not one at all.
|
|
36
|
+
*/
|
|
37
|
+
export type OptionKeys<T> = readonly string[] & {
|
|
38
|
+
readonly [OPTION_KEYS]: (key: keyof T) => keyof T;
|
|
39
|
+
};
|
|
40
|
+
/** The keys of `K` outside `T`, taken arm by arm when `K` is a union (each arm's own keys, not only the keys all arms share). */
|
|
41
|
+
type SurplusKeys<K, T> = K extends unknown ? Exclude<keyof K, keyof T> : never;
|
|
42
|
+
/** The minter {@link optionKeys} hands back: `never` — not callable — for an interface with an index signature, whose keys no
|
|
43
|
+
* table can name. */
|
|
44
|
+
type OptionKeysMinter<T> = string extends keyof T ? never : number extends keyof T ? never : <K extends Record<keyof T, 0>>(table: K & Record<SurplusKeys<K, T>, never>) => OptionKeys<T>;
|
|
45
|
+
/**
|
|
46
|
+
* Mint the options table of interface `T` from a literal naming each of its keys once (`{ fsync: 0, lockWaitMs: 0 }`).
|
|
47
|
+
* Curried so `T` is written and the literal inferred: a key of `T` the literal leaves out does not compile, and neither
|
|
48
|
+
* does a key `T` lacks — whether the literal is fresh, a variable, a spread, or a union whose arms each carry one — since
|
|
49
|
+
* every key outside `T` must be `never`. An interface with an index signature has no table (the minter is not callable).
|
|
50
|
+
*/
|
|
51
|
+
export declare function optionKeys<T extends object>(): OptionKeysMinter<T>;
|
|
30
52
|
/** The OPTIONS DOOR — a constructor's options bag received by the receipt law, absent ⇒ an empty one: every option the constructor reads
|
|
31
|
-
* is read off this copy, once, and the caller's bag is never read again (a store keeps no hold of it). `owner` names the
|
|
32
|
-
|
|
53
|
+
* is read off this frozen copy, once, and the caller's bag is never read again (a store keeps no hold of it). `owner` names the
|
|
54
|
+
* constructor; `keys` is the table of the options it takes ({@link optionKeys}), and an option outside it is refused by name
|
|
55
|
+
* ({@link receiveMembers}). */
|
|
56
|
+
export declare function receiveOptions<T extends object>(given: T | undefined, owner: string, keys: OptionKeys<T>): Readonly<T>;
|
|
33
57
|
/** Read `given` by the receipt law (module note): the plain copy, every own member taken once from its captured descriptor. */
|
|
34
58
|
export declare function receiveOwnProperties<T extends object>(given: T, words: OwnPropertyReceiptWords): T;
|
|
59
|
+
/** How a door whose family has its own code refuses its stray members: the one sentence, and the stray names it names
|
|
60
|
+
* (a symbol as itself), for a refusal that also carries them as data. */
|
|
61
|
+
export type StrayMembersRefusal = (message: string, stray: readonly (string | symbol)[]) => Error;
|
|
62
|
+
/** A record's members outside a door's table: their names (a symbol as itself) and the one sentence that names them. */
|
|
63
|
+
export interface StrayMembers {
|
|
64
|
+
readonly names: readonly (string | symbol)[];
|
|
65
|
+
readonly sentence: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* THE NAME JUDGMENT of a door (module note): every own member of `given` that `keys` does not name — a string key,
|
|
69
|
+
* enumerable or not, and a symbol key — with the one sentence that names them all (each with its nearest taken name within
|
|
70
|
+
* two edits, then the members taken); `undefined` when there is none. It reads names only: no getter runs and no value is
|
|
71
|
+
* looked at. On an admitted object (a plain record that is no Proxy, or a copy a receipt made) no caller code runs; a
|
|
72
|
+
* reader whose own law reads the caller's live object judges the names that object answers (a Proxy's own-keys answer
|
|
73
|
+
* included). A reader that answers a sentence instead of throwing takes this; a door that throws takes
|
|
74
|
+
* {@link refuseStrayMembers} or {@link receiveMembers}.
|
|
75
|
+
*/
|
|
76
|
+
export declare function strayMembersOf(given: object, words: OwnPropertyReceiptWords, keys: readonly string[]): StrayMembers | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* THE MEMBER'S PRESENCE (module note): `name` is a member of `record` exactly when its value there is not `undefined` — an
|
|
79
|
+
* own key holding `undefined` and a missing key are one absence; `null`, `0`, `""` and `false` are values. The engine's one
|
|
80
|
+
* reading of whether a record carries a member; the names a caller handed over are the name judgment's question
|
|
81
|
+
* ({@link strayMembersOf}), not this one's.
|
|
82
|
+
*/
|
|
83
|
+
export declare function memberPresent(record: object, name: string): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* THE NAME-ONLY DOOR — the receipt's admission (not a Proxy, a plain record), then {@link strayMembersOf}: every own member
|
|
86
|
+
* `keys` does not name is refused, all of them in one sentence, and no getter runs. For an object the door must judge but
|
|
87
|
+
* not copy (a face whose callbacks are later called with the object itself as `this`); a door that takes a copy takes
|
|
88
|
+
* {@link receiveMembers}, which is this judgment followed by the receipt.
|
|
89
|
+
*/
|
|
90
|
+
export declare function refuseStrayMembers(given: object, words: OwnPropertyReceiptWords, keys: readonly string[], refusal?: StrayMembersRefusal): void;
|
|
91
|
+
/**
|
|
92
|
+
* Read `given` by the receipt law and refuse every own member `keys` does not name (module note): the members a door
|
|
93
|
+
* takes, and nothing else, by one reading. The names are judged ({@link refuseStrayMembers}) before the receipt runs any
|
|
94
|
+
* getter, and nothing of the caller's runs between that judgment and the receipt's one capture, so the names judged are
|
|
95
|
+
* the names read. `refusal` codes the stray-member refusal for a door whose family has its own code (the receipt's own
|
|
96
|
+
* refusals keep `config.invalid_argument`). The copy handed back is frozen: what was judged is what is held, and a
|
|
97
|
+
* callback the door's owner later calls on it (its `this`) cannot change a member.
|
|
98
|
+
*/
|
|
99
|
+
export declare function receiveMembers<T extends object>(given: T, words: OwnPropertyReceiptWords, keys: readonly string[], refusal?: StrayMembersRefusal): Readonly<T>;
|
|
100
|
+
export {};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { types } from "node:util";
|
|
2
|
+
import { closestName } from "./closest-name.js";
|
|
3
|
+
import { inlineUntrusted } from "./untrusted-text.js";
|
|
2
4
|
import { describeFault, isPlainRecord, receive } from "./mods/kernel/receive.js";
|
|
3
5
|
import { MODS_VALUE_DEPTH } from "./mods/kernel/site-rules.js";
|
|
4
6
|
export function receiptRefusal(message) {
|
|
@@ -12,14 +14,40 @@ export function refuseProxy(given, words) {
|
|
|
12
14
|
}
|
|
13
15
|
export const CONFIG_RECEIPT_MODE = Object.freeze({ accessors: "call-once", depth: 1, others: "as-is", isProxy: (v) => types.isProxy(v) });
|
|
14
16
|
export const DECLARATION_RECEIPT_MODE = Object.freeze({ accessors: "call-once", depth: MODS_VALUE_DEPTH + 1, others: "refuse", freeze: true, isProxy: (v) => types.isProxy(v) });
|
|
15
|
-
export function
|
|
16
|
-
return
|
|
17
|
+
export function optionKeys() {
|
|
18
|
+
return ((table) => Object.freeze(Object.keys(table)));
|
|
19
|
+
}
|
|
20
|
+
export function receiveOptions(given, owner, keys) {
|
|
21
|
+
return given === undefined ? Object.freeze({}) : receiveMembers(given, { subject: `${owner} options`, unit: "option", moment: `at new ${owner}` }, keys);
|
|
17
22
|
}
|
|
18
23
|
export function receiveOwnProperties(given, words) {
|
|
24
|
+
admitPlainRecord(given, words);
|
|
25
|
+
return readCaptured(given, words);
|
|
26
|
+
}
|
|
27
|
+
export function strayMembersOf(given, words, keys) {
|
|
28
|
+
const names = Reflect.ownKeys(given).filter((k) => typeof k === "symbol" || !keys.includes(k));
|
|
29
|
+
return names.length === 0 ? undefined : Object.freeze({ names: Object.freeze(names), sentence: strayMembersSentence(words, names, keys) });
|
|
30
|
+
}
|
|
31
|
+
export function memberPresent(record, name) {
|
|
32
|
+
return Reflect.get(record, name) !== undefined;
|
|
33
|
+
}
|
|
34
|
+
export function refuseStrayMembers(given, words, keys, refusal = receiptRefusal) {
|
|
35
|
+
admitPlainRecord(given, words);
|
|
36
|
+
const stray = strayMembersOf(given, words, keys);
|
|
37
|
+
if (stray !== undefined)
|
|
38
|
+
throw refusal(stray.sentence, stray.names);
|
|
39
|
+
}
|
|
40
|
+
export function receiveMembers(given, words, keys, refusal = receiptRefusal) {
|
|
41
|
+
refuseStrayMembers(given, words, keys, refusal);
|
|
42
|
+
return Object.freeze(readCaptured(given, words));
|
|
43
|
+
}
|
|
44
|
+
function admitPlainRecord(given, words) {
|
|
19
45
|
refuseProxy(given, words);
|
|
20
46
|
if (!isPlainRecord(given)) {
|
|
21
47
|
throw receiptRefusal(`${words.subject} must be a plain object (its prototype is neither Object.prototype nor null): every ${words.unit} is read once as an own property, and a ${words.unit} its prototype would supply is not read — refused rather than wired without it`);
|
|
22
48
|
}
|
|
49
|
+
}
|
|
50
|
+
function readCaptured(given, words) {
|
|
23
51
|
const received = receive(given, CONFIG_RECEIPT_MODE);
|
|
24
52
|
if (received.ok)
|
|
25
53
|
return received.value;
|
|
@@ -30,3 +58,18 @@ export function receiveOwnProperties(given, words) {
|
|
|
30
58
|
throw receiptRefusal(`${words.subject}'s prototype changed while its ${words.unit}s were read ${words.moment} — refused rather than wired from a moving object`);
|
|
31
59
|
throw receiptRefusal(`${words.subject} could not be read ${words.moment}: ${describeFault(received.fault)} — refused rather than wired without it`);
|
|
32
60
|
}
|
|
61
|
+
const STRAY_NAME_MAX = 80;
|
|
62
|
+
function strayMembersSentence(words, stray, keys) {
|
|
63
|
+
const named = stray.map((k) => {
|
|
64
|
+
if (typeof k === "symbol")
|
|
65
|
+
return `${inlineUntrusted(String(k), STRAY_NAME_MAX)} (a symbol-keyed member)`;
|
|
66
|
+
const shown = JSON.stringify(inlineUntrusted(k, STRAY_NAME_MAX));
|
|
67
|
+
const near = closestName(k, keys);
|
|
68
|
+
return near === undefined ? shown : `${shown} (did you mean ${JSON.stringify(near)}?)`;
|
|
69
|
+
});
|
|
70
|
+
const one = stray.length === 1;
|
|
71
|
+
const unit = words.unit;
|
|
72
|
+
const what = one ? `is not ${/^[aeiou]/i.test(unit) ? "an" : "a"} ${unit}` : `are not ${unit}s`;
|
|
73
|
+
const takes = keys.length === 0 ? `it takes no ${unit}s` : `the ${unit}s it takes are ${keys.map((k) => JSON.stringify(k)).join(", ")}`;
|
|
74
|
+
return `${words.subject}: ${named.join(", ")} ${what} it takes — ${takes}; refused ${words.moment} rather than read as absent (a misspelled ${unit} would leave its default in force and nothing would say so)`;
|
|
75
|
+
}
|