@sema-agent/core 7.51.2 → 7.53.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 +698 -2
- package/README.md +3 -1
- package/dist/agents/agent-transcript-tool.d.ts +1 -1
- package/dist/agents/cascade.js +4 -0
- package/dist/agents/cross-session-envelope.d.ts +8 -0
- package/dist/agents/cross-session-envelope.js +6 -0
- package/dist/agents/cross-session-judge.d.ts +21 -1
- package/dist/agents/cross-session-judge.js +8 -0
- package/dist/agents/cross-session-ref.d.ts +5 -0
- package/dist/agents/cross-session-ref.js +1 -0
- package/dist/agents/cumulative-stats.d.ts +3 -0
- package/dist/agents/cumulative-stats.js +3 -0
- package/dist/agents/list-agents-tool.d.ts +1 -1
- package/dist/agents/org-delivery-gate.d.ts +122 -0
- package/dist/agents/org-delivery-gate.js +69 -0
- package/dist/agents/peer-held-queue.d.ts +9 -4
- package/dist/agents/peer-held-queue.js +6 -5
- package/dist/agents/peer-session-drain.d.ts +35 -5
- package/dist/agents/peer-session-drain.js +271 -180
- package/dist/agents/read-inbox-tool.d.ts +8 -1
- package/dist/agents/read-inbox-tool.js +5 -1
- package/dist/agents/repair-loop.js +4 -0
- package/dist/agents/send-message-tool.d.ts +11 -16
- package/dist/agents/send-message-tool.js +11 -13
- package/dist/agents/subagent.d.ts +3 -0
- package/dist/agents/subagent.js +105 -76
- package/dist/agents/tool-filter.d.ts +58 -13
- package/dist/agents/tool-filter.js +34 -14
- package/dist/bench/metrics.d.ts +1 -0
- package/dist/brain/anthropic.d.ts +6 -1
- package/dist/brain/anthropic.js +17 -13
- package/dist/brain/model-presets.d.ts +4 -5
- package/dist/brain/model-presets.js +6 -5
- package/dist/brain/open-responses.js +16 -12
- package/dist/brain/openai.js +16 -12
- package/dist/brain/request-params.d.ts +12 -33
- package/dist/brain/request-params.js +5 -2
- package/dist/brain/request-route.d.ts +9 -8
- package/dist/brain/request-route.js +1 -0
- package/dist/brain/route-adjudicator.d.ts +123 -47
- package/dist/brain/route-adjudicator.js +171 -42
- package/dist/brain/route-conformance.js +2 -2
- package/dist/brain/routing.d.ts +24 -1
- package/dist/brain/routing.js +54 -19
- package/dist/brain/status-sink.d.ts +18 -0
- package/dist/brain/status-sink.js +7 -0
- package/dist/brain/timeout.js +5 -4
- package/dist/core/a2a.d.ts +5 -2
- package/dist/core/a2a.js +30 -13
- package/dist/core/allow-entry.d.ts +42 -9
- package/dist/core/allow-entry.js +25 -18
- package/dist/core/auto-compaction.d.ts +80 -20
- package/dist/core/auto-compaction.js +65 -18
- package/dist/core/auto-promote.d.ts +2 -1
- package/dist/core/auto-promote.js +2 -2
- package/dist/core/caller-tool-name.d.ts +9 -0
- package/dist/core/caller-tool-name.js +13 -0
- package/dist/core/checkpoint-requirements.d.ts +7 -1
- package/dist/core/checkpoint-requirements.js +2 -0
- package/dist/core/checkpoint-store.d.ts +57 -24
- package/dist/core/checkpoint-store.js +3 -3
- package/dist/core/child-clamp-seats.d.ts +6 -0
- package/dist/core/child-clamp-seats.js +2 -1
- package/dist/core/compliance.js +3 -1
- package/dist/core/credential-vocabulary.d.ts +33 -8
- package/dist/core/credential-vocabulary.js +32 -7
- package/dist/core/decision-receipt.d.ts +2 -2
- package/dist/core/delegation-frames.d.ts +9 -2
- package/dist/core/delegation-name.d.ts +18 -0
- package/dist/core/delegation-name.js +47 -0
- package/dist/core/effective-path-target.d.ts +25 -6
- package/dist/core/effective-path-target.js +24 -2
- package/dist/core/engine-capabilities.d.ts +8 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +49 -21
- package/dist/core/frontmatter-fence.d.ts +10 -0
- package/dist/core/frontmatter-fence.js +6 -0
- package/dist/core/gate-fold.js +8 -25
- package/dist/core/gate-lanes.js +358 -274
- package/dist/core/gate-outcome.d.ts +11 -6
- package/dist/core/governance-codes.d.ts +11 -4
- package/dist/core/governance-codes.js +12 -3
- package/dist/core/hands-band-screen.d.ts +7 -0
- package/dist/core/hands-band-screen.js +32 -0
- package/dist/core/hooks.d.ts +283 -739
- package/dist/core/hooks.js +100 -193
- package/dist/{tools/fs → core}/image-admission.d.ts +21 -3
- package/dist/{tools/fs → core}/image-admission.js +24 -6
- package/dist/core/locked-config.d.ts +84 -32
- package/dist/core/locked-config.js +128 -42
- package/dist/core/mcp-connection-pool.d.ts +4 -1
- package/dist/core/mcp-connection-pool.js +7 -2
- package/dist/core/mcp-probe.d.ts +12 -9
- package/dist/core/mcp-probe.js +3 -3
- package/dist/core/mcp-server-spec.d.ts +104 -10
- package/dist/core/mcp-server-spec.js +183 -33
- package/dist/core/mcp.d.ts +31 -20
- package/dist/core/mcp.js +66 -56
- package/dist/core/memory-engine/data-plane.js +5 -1
- package/dist/core/memory-engine/distiller.js +16 -2
- package/dist/core/memory-engine/engine.d.ts +22 -30
- package/dist/core/memory-engine/engine.js +16 -10
- package/dist/core/memory-engine/frontmatter.d.ts +6 -0
- package/dist/core/memory-engine/frontmatter.js +19 -16
- package/dist/core/memory.d.ts +2 -2
- package/dist/core/mode-policy.d.ts +5 -16
- package/dist/core/mode-policy.js +7 -19
- package/dist/core/model-seat.d.ts +4 -1
- package/dist/core/mods/dollar.d.ts +109 -0
- package/dist/core/mods/dollar.js +154 -0
- package/dist/core/mods/host.d.ts +23 -0
- package/dist/core/mods/host.js +21 -0
- package/dist/core/mods/kernel/budget.d.ts +43 -0
- package/dist/core/mods/kernel/budget.js +83 -0
- package/dist/core/mods/kernel/dispatch.d.ts +100 -0
- package/dist/core/mods/kernel/dispatch.js +699 -0
- package/dist/core/mods/kernel/events.d.ts +245 -0
- package/dist/core/mods/kernel/events.js +210 -0
- package/dist/core/mods/kernel/index.d.ts +6 -0
- package/dist/core/mods/kernel/index.js +5 -0
- package/dist/core/mods/kernel/receive.d.ts +94 -0
- package/dist/core/mods/kernel/receive.js +188 -0
- package/dist/core/mods/kernel/registration.d.ts +131 -0
- package/dist/core/mods/kernel/registration.js +102 -0
- package/dist/core/mods/kernel/site-rules.d.ts +149 -0
- package/dist/core/mods/kernel/site-rules.js +296 -0
- package/dist/core/mods/stations.d.ts +344 -0
- package/dist/core/mods/stations.js +437 -0
- package/dist/core/mounted-mcp.d.ts +57 -0
- package/dist/core/mounted-mcp.js +71 -2
- package/dist/core/own-property-receipt.d.ts +13 -0
- package/dist/core/own-property-receipt.js +13 -23
- package/dist/core/parent-spec-seat.d.ts +18 -7
- package/dist/core/parent-spec-seat.js +6 -2
- package/dist/core/path-identity.js +2 -1
- package/dist/core/permission-rule-model.d.ts +58 -9
- package/dist/core/permission-rule-model.js +81 -7
- package/dist/core/permission-rule-org.d.ts +163 -33
- package/dist/core/permission-rule-org.js +205 -71
- package/dist/core/permission-rule-syntax.d.ts +15 -0
- package/dist/core/permission-rule-syntax.js +24 -16
- package/dist/core/permission-rules.d.ts +14 -2
- package/dist/core/permission-rules.js +63 -23
- package/dist/core/prompt-section-seat.d.ts +15 -27
- package/dist/core/prompt-section-seat.js +73 -40
- package/dist/core/protocol-http-auth.d.ts +3 -1
- package/dist/core/protocol-http-auth.js +2 -0
- package/dist/core/reminder-mint.d.ts +2 -2
- package/dist/core/remote-env.d.ts +24 -12
- package/dist/core/remote-env.js +1 -0
- package/dist/core/resume-startup-cause.d.ts +16 -1
- package/dist/core/resume-startup-cause.js +4 -1
- package/dist/core/retention.js +7 -2
- package/dist/core/retired-keys.d.ts +12 -2
- package/dist/core/retired-keys.js +15 -1
- package/dist/core/roles.js +60 -10
- package/dist/core/rule-lane-reads.js +1 -1
- package/dist/core/runner/announce-once-ledger.d.ts +31 -1
- package/dist/core/runner/announce-once-ledger.js +22 -0
- package/dist/core/runner/assemble-result.d.ts +9 -0
- package/dist/core/runner/assemble-result.js +3 -1
- package/dist/core/runner/call-hook-stations.d.ts +23 -27
- package/dist/core/runner/call-hook-stations.js +58 -42
- package/dist/core/runner/caller-stop-gate.d.ts +25 -0
- package/dist/core/runner/caller-stop-gate.js +7 -0
- package/dist/core/runner/compaction-seams.d.ts +8 -22
- package/dist/core/runner/compaction-seams.js +28 -53
- package/dist/core/runner/construction-doors.js +11 -1
- package/dist/core/runner/contracts.d.ts +86 -83
- package/dist/core/runner/credential-origin-seat.d.ts +2 -0
- package/dist/core/runner/credential-origin-seat.js +19 -0
- package/dist/core/runner/extra-body-dropped-seat.d.ts +2 -6
- package/dist/core/runner/gate-exit.d.ts +47 -36
- package/dist/core/runner/gate-exit.js +12 -5
- package/dist/core/runner/image.js +1 -2
- package/dist/core/runner/inline-image.js +1 -1
- package/dist/core/runner/mcp-redial.d.ts +52 -10
- package/dist/core/runner/mcp-redial.js +38 -9
- package/dist/core/runner/notice-seat-input.d.ts +11 -0
- package/dist/core/runner/notice-seat-input.js +1 -0
- package/dist/core/runner/permission-rule-lanes.d.ts +5 -2
- package/dist/core/runner/permission-rule-lanes.js +22 -10
- package/dist/core/runner/person-path-rows.d.ts +3 -1
- package/dist/core/runner/person-path-rows.js +3 -2
- package/dist/core/runner/prepare-acquire-reconcile.js +5 -1
- package/dist/core/runner/prepare-ask-lane.d.ts +5 -7
- package/dist/core/runner/prepare-ask-lane.js +6 -15
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -2
- package/dist/core/runner/prepare-caps-and-workflow.js +25 -8
- package/dist/core/runner/prepare-config-doors.d.ts +52 -1
- package/dist/core/runner/prepare-config-doors.js +168 -143
- package/dist/core/runner/prepare-defer-classify.js +7 -11
- package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
- package/dist/core/runner/prepare-delegation-surface.js +7 -5
- package/dist/core/runner/prepare-gate-stations.d.ts +8 -11
- package/dist/core/runner/prepare-gate-stations.js +11 -10
- package/dist/core/runner/prepare-hands-readface.d.ts +1 -1
- package/dist/core/runner/prepare-hands-readface.js +2 -1
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -12
- package/dist/core/runner/prepare-inherited-gate.js +10 -23
- package/dist/core/runner/prepare-listings.d.ts +1 -1
- package/dist/core/runner/prepare-listings.js +4 -2
- package/dist/core/runner/prepare-memory-engine-session.d.ts +0 -6
- package/dist/core/runner/prepare-memory-engine-session.js +20 -7
- package/dist/core/runner/prepare-memory.d.ts +3 -2
- package/dist/core/runner/prepare-memory.js +6 -2
- package/dist/core/runner/prepare-offload-wrappers.d.ts +4 -4
- package/dist/core/runner/prepare-offload-wrappers.js +2 -1
- package/dist/core/runner/prepare-park-ask.js +10 -14
- package/dist/core/runner/prepare-policy-chain.d.ts +17 -15
- package/dist/core/runner/prepare-policy-chain.js +104 -109
- package/dist/core/runner/prepare-project-context.d.ts +1 -1
- package/dist/core/runner/prepare-project-context.js +11 -12
- package/dist/core/runner/prepare-prompt-assembly.d.ts +45 -40
- package/dist/core/runner/prepare-prompt-assembly.js +138 -101
- package/dist/core/runner/prepare-prompt-inputs.d.ts +28 -23
- package/dist/core/runner/prepare-prompt-inputs.js +11 -10
- package/dist/core/runner/prepare-protocol-tools.d.ts +11 -7
- package/dist/core/runner/prepare-protocol-tools.js +20 -13
- package/dist/core/runner/prepare-question-face.d.ts +4 -2
- package/dist/core/runner/prepare-question-face.js +4 -3
- package/dist/core/runner/prepare-safety-scan.js +6 -10
- package/dist/core/runner/prepare-suspend-saga.d.ts +6 -0
- package/dist/core/runner/prepare-suspend-saga.js +7 -5
- package/dist/core/runner/prepare-task.js +41 -23
- package/dist/core/runner/prepare-turn-wiring.d.ts +13 -15
- package/dist/core/runner/prepare-turn-wiring.js +29 -27
- package/dist/core/runner/prepare-wiring-manifest.d.ts +13 -9
- package/dist/core/runner/prepare-wiring-manifest.js +14 -11
- package/dist/core/runner/resume-admission.d.ts +4 -1
- package/dist/core/runner/resume-admission.js +7 -5
- package/dist/core/runner/resume-apply.d.ts +5 -2
- package/dist/core/runner/resume-apply.js +24 -42
- package/dist/core/runner/resume-checkpoint-screen.d.ts +1 -0
- package/dist/core/runner/resume-checkpoint-screen.js +9 -1
- package/dist/core/runner/resume-internals-and-config.d.ts +3 -3
- package/dist/core/runner/resume-internals-and-config.js +3 -8
- package/dist/core/runner/resume-preflight.js +38 -16
- package/dist/core/runner/retired-runner-deps.d.ts +5 -6
- package/dist/core/runner/retired-runner-deps.js +4 -5
- package/dist/core/runner/run-brain-sinks.d.ts +3 -2
- package/dist/core/runner/run-brain-sinks.js +5 -1
- package/dist/core/runner/run-compaction-machinery.d.ts +7 -1
- package/dist/core/runner/run-compaction-machinery.js +7 -33
- package/dist/core/runner/run-harness-handlers.js +4 -2
- package/dist/core/runner/run-identity-wiring.d.ts +3 -1
- package/dist/core/runner/run-identity-wiring.js +3 -2
- package/dist/core/runner/run-leg.js +103 -95
- package/dist/core/runner/run-notification-lane.js +1 -0
- package/dist/core/runner/run-recovery-lanes.d.ts +3 -0
- package/dist/core/runner/run-recovery-lanes.js +14 -11
- package/dist/core/runner/run-settle-and-teardown.js +9 -28
- package/dist/core/runner/run-stop-and-final-verify.js +18 -25
- package/dist/core/runner/run-terminal-adoption.d.ts +3 -0
- package/dist/core/runner/run-terminal-adoption.js +34 -22
- package/dist/core/runner/run-tool-mount-facts.js +5 -3
- package/dist/core/runner/run-turn-boundary.js +32 -37
- package/dist/core/runner/runtask.d.ts +6 -7
- package/dist/core/runner/runtask.js +15 -73
- package/dist/core/runner/session-rule-policy.d.ts +5 -5
- package/dist/core/runner/session-rule-policy.js +13 -8
- package/dist/core/runner/side-call-account.d.ts +68 -0
- package/dist/core/runner/side-call-account.js +61 -0
- package/dist/core/runner/skills-seat.d.ts +15 -0
- package/dist/core/runner/skills-seat.js +57 -0
- package/dist/core/runner/stream-halt-verbs.js +12 -17
- package/dist/core/runner/stream-lifecycle-verbs.js +8 -5
- package/dist/core/runner/stream-steer-verb.d.ts +1 -1
- package/dist/core/runner/stream-steer-verb.js +20 -38
- package/dist/core/runner/sub-agent-deny-lists.d.ts +124 -23
- package/dist/core/runner/sub-agent-deny-lists.js +230 -71
- package/dist/core/runner/synthetic-tools.d.ts +5 -2
- package/dist/core/runner/synthetic-tools.js +2 -12
- package/dist/core/runner/tool-end-body.d.ts +5 -6
- package/dist/core/runner/tool-end-body.js +6 -4
- package/dist/core/runner/tool-not-executed.d.ts +15 -0
- package/dist/core/runner/tool-not-executed.js +30 -0
- package/dist/core/runner/tool-occurrence.d.ts +8 -7
- package/dist/core/runner/tool-occurrence.js +5 -5
- package/dist/core/runner/tool-result-media-seat.d.ts +1 -1
- package/dist/core/runner-deps.d.ts +43 -36
- package/dist/core/safety-merge-corpus.js +18 -2
- package/dist/core/secret-env.d.ts +88 -20
- package/dist/core/secret-env.js +192 -38
- package/dist/core/session-policy-store.d.ts +71 -16
- package/dist/core/session-policy-store.js +138 -28
- package/dist/core/session-reconcile.d.ts +4 -0
- package/dist/core/session-reconcile.js +2 -1
- package/dist/core/shell-read-silence.js +3 -32
- package/dist/core/side-query.d.ts +5 -3
- package/dist/core/skill-grant.d.ts +3 -2
- package/dist/core/skill-grant.js +17 -9
- package/dist/core/skills-directory.d.ts +31 -11
- package/dist/core/skills-directory.js +655 -104
- package/dist/core/store-contracts/mailbox-store-contract.js +13 -0
- package/dist/core/task-event.d.ts +49 -3
- package/dist/core/task-notification.js +2 -2
- package/dist/core/task-result.d.ts +8 -0
- package/dist/core/task-spec.d.ts +20 -19
- package/dist/core/task-stream.d.ts +14 -4
- package/dist/core/tighten-task-spec.d.ts +4 -3
- package/dist/core/tighten-task-spec.js +2 -4
- package/dist/core/tool-check-reading.d.ts +74 -0
- package/dist/core/tool-check-reading.js +80 -0
- package/dist/core/tool-policy.d.ts +62 -18
- package/dist/core/tool-policy.js +86 -15
- package/dist/core/tool-registry.d.ts +20 -0
- package/dist/core/tool-registry.js +4 -0
- package/dist/core/tool-spec.d.ts +10 -6
- package/dist/core/tools.js +2 -0
- package/dist/core/trace.d.ts +51 -32
- package/dist/core/types.d.ts +2 -2
- package/dist/core/types.js +1 -1
- package/dist/core/unc-spelling.d.ts +10 -0
- package/dist/core/unc-spelling.js +3 -0
- package/dist/core/untrusted-egress.d.ts +8 -0
- package/dist/core/untrusted-egress.js +4 -1
- package/dist/core/untrusted-text.d.ts +16 -0
- package/dist/core/untrusted-text.js +7 -2
- package/dist/core/user-attachment.d.ts +25 -4
- package/dist/core/user-attachment.js +63 -42
- package/dist/core/wiring-manifest.d.ts +18 -15
- package/dist/core/wiring-manifest.js +2 -2
- package/dist/engine/compaction/utils.js +1 -2
- package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
- package/dist/engine/execution-env/symlink-chain.js +1 -1
- package/dist/engine/harness/agent-harness.d.ts +1 -1
- package/dist/engine/harness/agent-harness.js +5 -4
- package/dist/engine/harness/types.d.ts +20 -16
- package/dist/engine/harness/types.js +7 -1
- package/dist/engine/llm/types.d.ts +12 -7
- package/dist/engine/loop/agent-loop.d.ts +12 -1
- package/dist/engine/loop/agent-loop.js +18 -6
- package/dist/engine/loop/types.d.ts +8 -2
- package/dist/engine/lsp/node-lsp-manager.d.ts +2 -2
- package/dist/engine/session/import-validate.js +3 -10
- package/dist/engine/session/session.d.ts +4 -4
- package/dist/engine/session/session.js +4 -4
- package/dist/index.d.ts +33 -23
- package/dist/index.js +23 -15
- package/dist/internal/harness.d.ts +2 -1
- package/dist/internal/harness.js +2 -1
- package/dist/orchestration/goal.d.ts +24 -1
- package/dist/orchestration/goal.js +3 -2
- package/dist/orchestration/run-spec.d.ts +4 -6
- package/dist/orchestration/run-spec.js +39 -63
- package/dist/orchestration/run-workflow-tool.js +1 -2
- package/dist/orchestration/workflow.d.ts +11 -3
- package/dist/orchestration/workflow.js +11 -2
- package/dist/prompt-assembly/artifact-store.d.ts +72 -56
- package/dist/prompt-assembly/artifact-store.js +60 -52
- package/dist/prompt-assembly/artifact.d.ts +90 -76
- package/dist/prompt-assembly/artifact.js +197 -145
- package/dist/prompt-assembly/assemble.d.ts +36 -29
- package/dist/prompt-assembly/assemble.js +34 -220
- package/dist/prompt-assembly/bands.d.ts +20 -0
- package/dist/prompt-assembly/bands.js +18 -0
- package/dist/prompt-assembly/catalog/constitution.d.ts +23 -0
- package/dist/prompt-assembly/catalog/constitution.js +69 -0
- package/dist/prompt-assembly/catalog/core-behavior.d.ts +9 -0
- package/dist/prompt-assembly/catalog/core-behavior.js +85 -0
- package/dist/prompt-assembly/catalog/index.d.ts +11 -0
- package/dist/prompt-assembly/catalog/index.js +60 -0
- package/dist/prompt-assembly/catalog/memory.d.ts +13 -0
- package/dist/prompt-assembly/catalog/memory.js +6 -0
- package/dist/prompt-assembly/catalog/modes.d.ts +15 -0
- package/dist/prompt-assembly/catalog/modes.js +137 -0
- package/dist/prompt-assembly/catalog/role.d.ts +10 -0
- package/dist/prompt-assembly/catalog/role.js +157 -0
- package/dist/prompt-assembly/catalog/schema.d.ts +138 -0
- package/dist/prompt-assembly/catalog/schema.js +25 -0
- package/dist/prompt-assembly/catalog/sections.d.ts +9 -0
- package/dist/prompt-assembly/catalog/sections.js +98 -0
- package/dist/prompt-assembly/catalog/team.d.ts +4 -0
- package/dist/prompt-assembly/catalog/team.js +258 -0
- package/dist/prompt-assembly/composer.d.ts +26 -28
- package/dist/prompt-assembly/composer.js +124 -46
- package/dist/prompt-assembly/epoch.d.ts +89 -79
- package/dist/prompt-assembly/epoch.js +115 -142
- package/dist/prompt-assembly/explain.d.ts +58 -34
- package/dist/prompt-assembly/explain.js +21 -24
- package/dist/prompt-assembly/overlay.d.ts +137 -0
- package/dist/prompt-assembly/overlay.js +339 -0
- package/dist/prompt-assembly/renderers.d.ts +21 -0
- package/dist/prompt-assembly/renderers.js +39 -0
- package/dist/prompt-assembly/section-usage.d.ts +3 -3
- package/dist/prompt-assembly/section-usage.js +1 -1
- package/dist/prompt-assembly/select.d.ts +71 -0
- package/dist/prompt-assembly/select.js +106 -0
- package/dist/prompt-assembly/sugar.d.ts +31 -0
- package/dist/prompt-assembly/sugar.js +20 -0
- package/dist/prompt-assembly/turn-snapshot.d.ts +3 -2
- package/dist/prompt-assembly/types.d.ts +45 -148
- package/dist/prompts/coordinator.d.ts +2 -21
- package/dist/prompts/coordinator.js +3 -255
- package/dist/prompts/cowork.d.ts +27 -16
- package/dist/prompts/cowork.js +2 -23
- package/dist/prompts/default.d.ts +38 -511
- package/dist/prompts/default.js +20 -288
- package/dist/prompts/supervisor.d.ts +6 -71
- package/dist/prompts/supervisor.js +6 -117
- package/dist/stores/file/permission-rule-store.d.ts +1 -1
- package/dist/stores/file/permission-rule-store.js +2 -1
- package/dist/tools/artifact/artifact-tool.js +4 -3
- package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -5
- package/dist/tools/fs/dir-entries.d.ts +4 -2
- package/dist/tools/fs/dir-entries.js +16 -4
- package/dist/tools/fs/fs-bash.d.ts +1 -1
- package/dist/tools/fs/fs-bash.js +22 -11
- package/dist/tools/fs/fs-pdf.js +17 -13
- package/dist/tools/fs/fs-read.js +4 -3
- package/dist/tools/fs/fs-shared.d.ts +1 -10
- package/dist/tools/fs/fs-shared.js +3 -4
- package/dist/tools/fs/fs-write.js +2 -1
- package/dist/tools/fs/notebook.js +1 -1
- package/dist/tools/fs/pdf.d.ts +20 -10
- package/dist/tools/fs/pdf.js +19 -10
- package/dist/tools/fs/program-read-model.d.ts +68 -8
- package/dist/tools/fs/program-read-model.js +112 -33
- package/dist/tools/fs/program-read-model.rows.js +30 -10
- package/dist/tools/fs/read-deny-home.d.ts +25 -9
- package/dist/tools/fs/read-deny-home.js +28 -27
- package/dist/tools/fs/read-deny.d.ts +41 -11
- package/dist/tools/fs/read-deny.js +51 -5
- package/dist/tools/fs/safety.d.ts +4 -26
- package/dist/tools/fs/safety.js +10 -32
- package/dist/tools/fs/search.js +15 -10
- package/dist/tools/fs/shell-read-argv.d.ts +3 -2
- package/dist/tools/fs/shell-read-argv.js +118 -38
- package/dist/tools/fs/shell-read-establish.d.ts +5 -5
- package/dist/tools/fs/shell-read-establish.js +11 -61
- package/dist/tools/fs/shell-read-identity.js +6 -3
- package/dist/tools/fs/shell-read-judge.d.ts +13 -15
- package/dist/tools/fs/shell-read-judge.js +18 -4
- package/dist/tools/fs/shell-read-plan.d.ts +2 -2
- package/dist/tools/web.js +1 -1
- package/package.json +13 -1
- package/test/export-surface.snapshot.json +306 -103
- package/wire-changes/core@7.52.0.json +5859 -0
- package/wire-changes/core@7.53.0.json +1946 -0
- package/dist/core/hook-seats.d.ts +0 -66
- package/dist/core/hook-seats.js +0 -37
- package/dist/prompt-assembly/packs/sema-default.d.ts +0 -2
- package/dist/prompt-assembly/packs/sema-default.js +0 -147
- package/dist/prompts/simple-sections.d.ts +0 -58
- package/dist/prompts/simple-sections.js +0 -43
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { types } from "node:util";
|
|
2
|
+
import { describeFault, isPlainRecord, receive } from "./mods/kernel/receive.js";
|
|
3
|
+
import { MODS_VALUE_DEPTH } from "./mods/kernel/site-rules.js";
|
|
2
4
|
export function receiptRefusal(message) {
|
|
3
5
|
const e = new Error(message);
|
|
4
6
|
e.code = "config.invalid_argument";
|
|
@@ -8,32 +10,20 @@ export function refuseProxy(given, words) {
|
|
|
8
10
|
if (types.isProxy(given))
|
|
9
11
|
throw receiptRefusal(`${words.subject} must be a plain object, not a Proxy: its ${words.unit}s are read once off its own descriptors, and a Proxy would run its traps in that read — refused rather than wired through it`);
|
|
10
12
|
}
|
|
13
|
+
export const CONFIG_RECEIPT_MODE = Object.freeze({ accessors: "call-once", depth: 1, others: "as-is", isProxy: (v) => types.isProxy(v) });
|
|
14
|
+
export const DECLARATION_RECEIPT_MODE = Object.freeze({ accessors: "call-once", depth: MODS_VALUE_DEPTH + 1, others: "refuse", freeze: true, isProxy: (v) => types.isProxy(v) });
|
|
11
15
|
export function receiveOwnProperties(given, words) {
|
|
12
16
|
refuseProxy(given, words);
|
|
13
|
-
|
|
14
|
-
if (proto !== Object.prototype && proto !== null) {
|
|
17
|
+
if (!isPlainRecord(given)) {
|
|
15
18
|
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`);
|
|
16
19
|
}
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
const get = Object.hasOwn(d, "get") ? d.get : undefined;
|
|
27
|
-
try {
|
|
28
|
-
value = get === undefined ? undefined : get.call(given);
|
|
29
|
-
}
|
|
30
|
-
catch {
|
|
31
|
-
throw receiptRefusal(`${words.subject}.${name} threw while it was read ${words.moment} — a ${words.unit} is read once, here; refused rather than wired without it`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
Object.defineProperty(received, name, { value, enumerable: true, writable: true, configurable: true });
|
|
35
|
-
}
|
|
36
|
-
if (Object.getPrototypeOf(given) !== proto)
|
|
20
|
+
const received = receive(given, CONFIG_RECEIPT_MODE);
|
|
21
|
+
if (received.ok)
|
|
22
|
+
return received.value;
|
|
23
|
+
const name = received.fault.path[0] ?? "";
|
|
24
|
+
if (received.fault.kind === "getter-threw")
|
|
25
|
+
throw receiptRefusal(`${words.subject}.${name} threw while it was read ${words.moment} — a ${words.unit} is read once, here; refused rather than wired without it`);
|
|
26
|
+
if (received.fault.kind === "prototype-moved")
|
|
37
27
|
throw receiptRefusal(`${words.subject}'s prototype changed while its ${words.unit}s were read ${words.moment} — refused rather than wired from a moving object`);
|
|
38
|
-
|
|
28
|
+
throw receiptRefusal(`${words.subject} could not be read ${words.moment}: ${describeFault(received.fault)} — refused rather than wired without it`);
|
|
39
29
|
}
|
|
@@ -9,11 +9,12 @@
|
|
|
9
9
|
* The checkpoint seat (`./checkpoint-seat.ts`) is the same shape for one field; this seat carries the rest.
|
|
10
10
|
*/
|
|
11
11
|
import type { OnQuestion } from "./ask-question.js";
|
|
12
|
-
import type {
|
|
12
|
+
import type { ModRegistration } from "./mods/kernel/index.js";
|
|
13
|
+
import type { EngineDollar } from "./mods/dollar.js";
|
|
13
14
|
import type { ToolExecuteContext } from "./tool-spec.js";
|
|
14
15
|
import type { TaskSpec } from "./types.js";
|
|
15
16
|
/** The fields of a spec the seat carries — one `Pick`, shared by the mint's input and the apply's target. */
|
|
16
|
-
export type ParentSpecSeatFields = Pick<TaskSpec, "principal" | "oneShot" | "clientContext" | "onQuestion" | "
|
|
17
|
+
export type ParentSpecSeatFields = Pick<TaskSpec, "principal" | "oneShot" | "clientContext" | "onQuestion" | "mods" | "additionalDirectories" | "additionalReadDirectories" | "envFacts" | "memoryPersistenceCapable" | "memory" | "compaction" | "skillListingBudgetFraction" | "skillListingMaxDescChars" | "fileHistory" | "promptForm" | "promptBinding">;
|
|
17
18
|
/**
|
|
18
19
|
* The seat a run hands its children. Every member is the parent's own value, frozen at mint (arrays copied and
|
|
19
20
|
* frozen; the facts object copied). Members present iff the parent carries them — an absent member is "nothing to
|
|
@@ -23,10 +24,13 @@ export type ParentSpecSeatFields = Pick<TaskSpec, "principal" | "oneShot" | "cli
|
|
|
23
24
|
* · `clientContext` — the user's TZ/email facts (the child's environment block localizes the same way).
|
|
24
25
|
* · `onQuestion` — the parent's FROZEN question face (`spec.onQuestion ?? deps.onQuestion`, the value the parent's
|
|
25
26
|
* own AskUserQuestion resolves at): the child's question tool MOUNTS on it, so without it the child has no tool.
|
|
26
|
-
* · `
|
|
27
|
-
* the user's settings). A deployment's `RunnerDeps.
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* · `mods` — the parent's TASK seat of the mods bus (`spec.mods`, the request-level registrations a host mounts from
|
|
28
|
+
* the user's settings). A deployment's `RunnerDeps.mods` already serve every leg; the task seat did not, so a
|
|
29
|
+
* `classic.Stop` handler a user wired ran for the leader and never for its teammates (CC runs one chain for the
|
|
30
|
+
* session and its subagents, the event carrying `agentId`). A child dispatches the travelled registrations as its
|
|
31
|
+
* own task seat (its events carry the child's identity); an ancestor's chain still rides the constraint fold, and
|
|
32
|
+
* collapses into the child's own phase 1 when the installation is the same. Same law as `onQuestion`: a child's
|
|
33
|
+
* own value wins, the seat fills an unset one.
|
|
30
34
|
* · `additionalDirectories` / `additionalReadDirectories` — the fs-fence widening (deployment property).
|
|
31
35
|
* · `envFacts` — the sandbox facts (profile / egress / scratchpad).
|
|
32
36
|
* · `memoryPersistenceCapable` — the deployment's DECLARED persistence statement: `false` is a REMOVAL (floor),
|
|
@@ -45,13 +49,18 @@ export type ParentSpecSeatFields = Pick<TaskSpec, "principal" | "oneShot" | "cli
|
|
|
45
49
|
* and every leg multiplies it by its own.
|
|
46
50
|
* · `fileHistory` — the request's file-history off switch (`"disabled"`, its only word), for the edits its delegates
|
|
47
51
|
* make on its behalf too. An ORDINARY member (fill law); with one word no child can author it back on.
|
|
52
|
+
* · `promptForm` — the host form of the system prompt (`"minimal"`, its only word: the core-behavior band is out). A
|
|
53
|
+
* host's product choice for the whole delegation tree, so every engine-built child (both delegation lanes and the
|
|
54
|
+
* observer sidecar) composes the same set of sections. An ORDINARY member (fill law).
|
|
55
|
+
* · `promptBinding` — the binding (a deployment's scenario name), a prompt selector value. A child composes its
|
|
56
|
+
* parent's center artifact, so its overlays' `when.binding` reads the same binding. An ORDINARY member (fill law).
|
|
48
57
|
*/
|
|
49
58
|
export interface ParentSpecSeat {
|
|
50
59
|
readonly principal?: string;
|
|
51
60
|
readonly oneShot?: true;
|
|
52
61
|
readonly clientContext?: TaskSpec["clientContext"];
|
|
53
62
|
readonly onQuestion?: OnQuestion;
|
|
54
|
-
readonly
|
|
63
|
+
readonly mods?: readonly ModRegistration<EngineDollar>[];
|
|
55
64
|
readonly additionalDirectories?: readonly string[];
|
|
56
65
|
readonly additionalReadDirectories?: readonly string[];
|
|
57
66
|
readonly envFacts?: TaskSpec["envFacts"];
|
|
@@ -61,6 +70,8 @@ export interface ParentSpecSeat {
|
|
|
61
70
|
readonly skillListingBudgetFraction?: number;
|
|
62
71
|
readonly skillListingMaxDescChars?: number;
|
|
63
72
|
readonly fileHistory?: "disabled";
|
|
73
|
+
readonly promptForm?: "minimal";
|
|
74
|
+
readonly promptBinding?: string;
|
|
64
75
|
}
|
|
65
76
|
/** Mint the seat off the parent's REBOUND spec and its frozen question face (spec over deps — the caller resolves it once,
|
|
66
77
|
* the same value the parent's own question routing reads). Absent fields stay absent; `oneShot` only when `true`. */
|
|
@@ -4,7 +4,7 @@ export function parentSpecSeatOf(spec, frozenOnQuestion) {
|
|
|
4
4
|
...(spec.oneShot === true ? { oneShot: true } : {}),
|
|
5
5
|
...(spec.clientContext !== undefined ? { clientContext: spec.clientContext } : {}),
|
|
6
6
|
...(frozenOnQuestion !== undefined ? { onQuestion: frozenOnQuestion } : {}),
|
|
7
|
-
...(spec.
|
|
7
|
+
...(spec.mods !== undefined ? { mods: spec.mods } : {}),
|
|
8
8
|
...(spec.additionalDirectories !== undefined ? { additionalDirectories: Object.freeze([...spec.additionalDirectories]) } : {}),
|
|
9
9
|
...(spec.additionalReadDirectories !== undefined ? { additionalReadDirectories: Object.freeze([...spec.additionalReadDirectories]) } : {}),
|
|
10
10
|
...(spec.envFacts !== undefined ? { envFacts: Object.freeze({ ...spec.envFacts }) } : {}),
|
|
@@ -13,6 +13,8 @@ export function parentSpecSeatOf(spec, frozenOnQuestion) {
|
|
|
13
13
|
...(spec.skillListingBudgetFraction !== undefined ? { skillListingBudgetFraction: spec.skillListingBudgetFraction } : {}),
|
|
14
14
|
...(spec.skillListingMaxDescChars !== undefined ? { skillListingMaxDescChars: spec.skillListingMaxDescChars } : {}),
|
|
15
15
|
...(spec.fileHistory !== undefined ? { fileHistory: spec.fileHistory } : {}),
|
|
16
|
+
...(spec.promptForm !== undefined ? { promptForm: spec.promptForm } : {}),
|
|
17
|
+
...(spec.promptBinding !== undefined ? { promptBinding: spec.promptBinding } : {}),
|
|
16
18
|
...(spec.memory?.enabled === false ? { memoryOff: true } : {}),
|
|
17
19
|
});
|
|
18
20
|
}
|
|
@@ -25,7 +27,7 @@ export function applyParentSpecSeat(child, seat) {
|
|
|
25
27
|
...fill("principal", seat.principal),
|
|
26
28
|
...fill("clientContext", seat.clientContext),
|
|
27
29
|
...fill("onQuestion", seat.onQuestion),
|
|
28
|
-
...fill("
|
|
30
|
+
...fill("mods", seat.mods),
|
|
29
31
|
...fill("additionalDirectories", (seat.additionalDirectories !== undefined ? [...seat.additionalDirectories] : undefined)),
|
|
30
32
|
...fill("additionalReadDirectories", (seat.additionalReadDirectories !== undefined ? [...seat.additionalReadDirectories] : undefined)),
|
|
31
33
|
...fill("envFacts", (seat.envFacts !== undefined ? { ...seat.envFacts } : undefined)),
|
|
@@ -33,6 +35,8 @@ export function applyParentSpecSeat(child, seat) {
|
|
|
33
35
|
...fill("skillListingBudgetFraction", seat.skillListingBudgetFraction),
|
|
34
36
|
...fill("skillListingMaxDescChars", seat.skillListingMaxDescChars),
|
|
35
37
|
...fill("fileHistory", seat.fileHistory),
|
|
38
|
+
...fill("promptForm", seat.promptForm),
|
|
39
|
+
...fill("promptBinding", seat.promptBinding),
|
|
36
40
|
...(seat.oneShot === true ? { oneShot: true } : {}),
|
|
37
41
|
...(seat.memoryPersistenceCapable === false ? { memoryPersistenceCapable: false } : fill("memoryPersistenceCapable", seat.memoryPersistenceCapable)),
|
|
38
42
|
...(seat.memoryOff === true ? { memory: memoryTurnedOff(child.memory) } : {}),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { anchorSpelling,
|
|
1
|
+
import { anchorSpelling, win32NamespaceScreen } from "../tools/fs/safety.js";
|
|
2
|
+
import { isUncSpelling } from "./unc-spelling.js";
|
|
2
3
|
export async function symlinkChainHops(env, path, signal, family, baseCwd) {
|
|
3
4
|
if (typeof env.canonicalChain !== "function")
|
|
4
5
|
return { ok: false, cause: "the environment declares no symlink-chain reader", asked: false };
|
|
@@ -161,15 +161,43 @@ export declare function callPathFaceOf(call: ToolCallLike): DenyFace | undefined
|
|
|
161
161
|
* it, whatever the call's tool is called (a caller's tool declaring a read path target is on the read face too)? */
|
|
162
162
|
export declare function faceRowsSpeakFor(face: DenyFace | undefined): boolean;
|
|
163
163
|
/**
|
|
164
|
-
* The tools whose rule content NAMES THE VALUE of one parameter instead of a command or a path —
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
164
|
+
* The tools whose rule content NAMES THE VALUE of one parameter instead of a command or a path — ONE grammar (the name grammar,
|
|
165
|
+
* match `name`), one row per tool, the row declaring the tool's SPELLING of it:
|
|
166
|
+
* · BARE — the reference's `Skill(<name>)` / `Skill(<prefix>:*)`: `param` is the argument the rule's content is read against,
|
|
167
|
+
* `params` every scalar argument the tool carries (the parameter spelling `Tool(<param>:<pattern>)` those names used to reach
|
|
168
|
+
* is retired for such a tool, see {@link parseNameRuleContent}). The Skill tool's real schema keys are pinned equal to
|
|
169
|
+
* `params` (test/backlog1318).
|
|
170
|
+
* · KEYED — `words` present: the reference's `Artifact(action:<word>)`, the content carrying the argument's own key. `params`
|
|
171
|
+
* is that one key; `words` is the closed set of values the tool itself declares for it (the row points at the tool's own
|
|
172
|
+
* set, never a copy), and a rule names exactly one of them — no prefix form, no `*`.
|
|
173
|
+
* Whatever the spelling, a rule of this grammar says "the call's value of `param` is this value", read by the one subject
|
|
174
|
+
* reader ({@link nameRuleSubjectOf}), the one predicate ({@link nameRuleAdmits}), the one precedence walk
|
|
175
|
+
* ({@link adjudicatePersistedNameRules}) and the one offer ({@link suggestRuleForName}).
|
|
168
176
|
*/
|
|
169
177
|
export declare const NAME_RULE_FACES: Readonly<Record<string, {
|
|
170
178
|
readonly param: string;
|
|
171
179
|
readonly params: readonly string[];
|
|
180
|
+
readonly words?: readonly string[];
|
|
172
181
|
}>>;
|
|
182
|
+
/**
|
|
183
|
+
* Why a call of a KEYED value tool that names no value for the key cannot be read against that key's deny / ask rules, or
|
|
184
|
+
* undefined (a bare-spelling tool, or no value tool). Every judge reads a call's arguments as the tool reads them
|
|
185
|
+
* (`argsAsTheToolReads`: its argument preparation, then the schema's coercions); a call that STILL names no value for the key
|
|
186
|
+
* runs a value no argument shows — a default filled in inside the tool's execution (a caller's tool mounted under the keyed
|
|
187
|
+
* name, or answering to it, with no argument preparation of its own). Whether a rule by the key reaches such a call is
|
|
188
|
+
* unknown, so every reader REFUSES it on the key's deny or ask rule — a refusal, never an ask a person could approve past a
|
|
189
|
+
* deny, and no allow by the key reaches it. A tool whose reading always names the key (the built-in `Artifact`: an absent
|
|
190
|
+
* action reads as `publish`) never meets this. A bare-spelling tool's call that names nothing is reached by nothing: no
|
|
191
|
+
* default stands behind it.
|
|
192
|
+
*/
|
|
193
|
+
export declare function keyedValueAbsentReason(tool: string): string | undefined;
|
|
194
|
+
/**
|
|
195
|
+
* Does the name grammar read this content of this tool? Every content of a bare-spelling tool; on a keyed tool only content
|
|
196
|
+
* keyed by its own parameter (`action:…` on `Artifact`) — another key (`Artifact(url:…)`) is a rule on another argument,
|
|
197
|
+
* which the persisted grammar has no form for and the caller policy reads with its generic parameter lane. Undefined grammar
|
|
198
|
+
* ⇒ false.
|
|
199
|
+
*/
|
|
200
|
+
export declare function nameGrammarReads(tool: string, content: string): boolean;
|
|
173
201
|
/**
|
|
174
202
|
* The tools whose rule content names the HOST of the URL one parameter carries — the reference's `WebFetch(domain:<host>)`
|
|
175
203
|
* form, one row per tool: `param` is the URL argument the host is read from ({@link domainRuleSubjectOf}). Read by
|
|
@@ -182,8 +210,9 @@ export declare const DOMAIN_RULE_FACES: Readonly<Record<string, {
|
|
|
182
210
|
* Which tools a rule may name — the model's tool set is DERIVED, never a hand-kept list: the command rule word
|
|
183
211
|
* ({@link COMMAND_RULE_TOOL}) takes the COMMAND grammar — the other shell-face tools take none of their own, their command is
|
|
184
212
|
* judged by the `Bash(…)` rules ({@link laneToolNamesOf}); every tool the catalog declares a path target for (Read / Edit / Write /
|
|
185
|
-
* Glob / NotebookEdit / …, `pathTargetOf`) takes the PATH grammar; the tools of {@link NAME_RULE_FACES} take the NAME grammar
|
|
186
|
-
* the tools of {@link DOMAIN_RULE_FACES} the
|
|
213
|
+
* Glob / NotebookEdit / …, `pathTargetOf`) takes the PATH grammar; the tools of {@link NAME_RULE_FACES} take the NAME grammar
|
|
214
|
+
* (each in its row's spelling: bare `Skill(<name>)`, keyed `Artifact(action:<word>)`); the tools of {@link DOMAIN_RULE_FACES} the
|
|
215
|
+
* DOMAIN grammar.
|
|
187
216
|
* A rule on any other tool has no content this model can judge and is refused (`unsupported.tool`). The tool set therefore
|
|
188
217
|
* moves with the catalog's declarations, exactly as the protective fences' covered set does.
|
|
189
218
|
*/
|
|
@@ -355,6 +384,21 @@ export interface ParsedRule {
|
|
|
355
384
|
/** Upper bound on a rule text. Rules are human-authored one-liners; anything longer is a mistake or an
|
|
356
385
|
* attempt to make the store unreadable. */
|
|
357
386
|
export declare const MAX_RULE_TEXT_CHARS = 512;
|
|
387
|
+
/**
|
|
388
|
+
* The most code points of a rule's ORIGINAL text a notice's machine-read slot carries: twice the grammar's own bound. A text past
|
|
389
|
+
* {@link MAX_RULE_TEXT_CHARS} reads as no rule whatever follows its first characters, so the slot keeps room to show it as far as a person
|
|
390
|
+
* needs to recognise it and no further; every text a rule can be is carried whole. Not exported from the package root: a consumer reads
|
|
391
|
+
* the slot and never judges its length (it is not a relay that must refuse what the engine did not mint).
|
|
392
|
+
*/
|
|
393
|
+
export declare const NOTICE_RULE_TEXT_MAX: number;
|
|
394
|
+
/**
|
|
395
|
+
* A rule's (or allow-list entry's) text as a notice's machine-read slot carries it: the original string, untouched, when it is at most
|
|
396
|
+
* {@link NOTICE_RULE_TEXT_MAX} code points; a longer one is cut to that many and ends in the engine's one truncation mark
|
|
397
|
+
* ({@link INLINE_TRUNCATION_MARK}), so the longest slot is `NOTICE_RULE_TEXT_MAX + INLINE_TRUNCATION_MARK_CODEPOINTS` (1 025) code points.
|
|
398
|
+
* The ONE reading both `permission.allowed_tool_not_granted` (`detail.entries[].entry`) and `permission.rule_row_dropped`
|
|
399
|
+
* (`detail.rows[].rule`) hand their rule text over through — what spells it for a person is the sentence, never this slot.
|
|
400
|
+
*/
|
|
401
|
+
export declare function noticeRuleText(text: string): string;
|
|
358
402
|
/**
|
|
359
403
|
* Interpreter names whose PREFIX form is refused everywhere a rule can enter the store (minting,
|
|
360
404
|
* import, file reload, every backend). `Bash(node:*)` reads as one narrow-looking rule and means "run
|
|
@@ -956,7 +1000,9 @@ export declare function commandCoverageOf(rules: readonly PersistedRule[], call:
|
|
|
956
1000
|
};
|
|
957
1001
|
/** The answer of {@link adjudicatePersistedRules}: which behavior decided, and the rule(s) it stands
|
|
958
1002
|
* on — a one-element set for a deny/ask (the first table-order rule of the deciding behavior that
|
|
959
|
-
* reaches the call
|
|
1003
|
+
* reaches the call; for a keyed tool's call naming no value for its key, a DENY standing on the first deny — else ask —
|
|
1004
|
+
* row of that key, which the call cannot be read against: {@link adjudicatePersistedNameRules}) and the allow
|
|
1005
|
+
* direction's coverage SET ({@link findAdmittingRule}). */
|
|
960
1006
|
export interface PersistedRuleVerdict {
|
|
961
1007
|
readonly behavior: RuleBehavior;
|
|
962
1008
|
readonly rules: readonly PersistedRule[];
|
|
@@ -1032,8 +1078,11 @@ export declare function adjudicatePersistedPathRules(rules: readonly PersistedRu
|
|
|
1032
1078
|
* ({@link NAME_RULE_FACES}), judged on the one string the call names (`nameRuleSubjectOf`). A rule of the tool speaks for the call
|
|
1033
1079
|
* when it is live, of this behavior, in scope ({@link eligiblePersisted}, the one predicate) and {@link nameRuleAdmits} the name; the
|
|
1034
1080
|
* first behavior in {@link RULE_BEHAVIORS_BY_PRECEDENCE} whose rules speak decides, the first table-order rule of it is the answer.
|
|
1035
|
-
* Every behavior is judged with the one predicate — a name has no "program run" the tightening direction could read wider
|
|
1036
|
-
*
|
|
1081
|
+
* Every behavior is judged with the one predicate — a name has no "program run" the tightening direction could read wider.
|
|
1082
|
+
* A call that names nothing (read as the tool reads it): on a bare-spelling tool it is reached by no rule; on a KEYED tool it
|
|
1083
|
+
* cannot be read against the key's rules ({@link keyedValueAbsentReason}) and is REFUSED — a deny verdict standing on the
|
|
1084
|
+
* first eligible deny row of the key, else its first ask row (an ask a person could approve would let a deny be approved
|
|
1085
|
+
* past) — and no allow row reaches it.
|
|
1037
1086
|
*/
|
|
1038
1087
|
export declare function adjudicatePersistedNameRules(rules: readonly PersistedRule[], call: {
|
|
1039
1088
|
tool: string;
|
|
@@ -3,13 +3,15 @@ import { shellWordsOf } from "../shell/shell-words.js";
|
|
|
3
3
|
import { parsePermissionRule } from "./permission-rule-syntax.js";
|
|
4
4
|
import { compileReadDeny } from "../tools/fs/read-deny.js";
|
|
5
5
|
import { carriesShellRedirection, parseLeadingCommandName, splitShellCompoundSegments } from "../tools/fs/bash-readonly-classifier.js";
|
|
6
|
-
import { inlineUntrusted } from "./untrusted-text.js";
|
|
6
|
+
import { INLINE_TRUNCATION_MARK, inlineUntrusted } from "./untrusted-text.js";
|
|
7
7
|
import { isShellFaceToolName, pathTargetOf, protectivePathTargetOf } from "./tool-registry.js";
|
|
8
8
|
import { heldValues } from "./tool-name-readings.js";
|
|
9
9
|
import { carriesDotSegment, isAbsoluteForFamily, isIdentityDir, isPathIdentity, isShellRootedSpellingUnmapped, isUncIdentity, pathFamilyOf, pathIdentityOf } from "../tools/fs/safety.js";
|
|
10
10
|
import { bindPathRules, judgeRuleRows, rowsWhereTheyLead } from "./path-rule-binding.js";
|
|
11
11
|
import { readShellCommand } from "./shell-lexer.js";
|
|
12
12
|
import { lineDescriptorsOfText, readOnlyLineObjection, readOnlyShellVerdict } from "./read-only-shell.js";
|
|
13
|
+
import { ARTIFACT_ACTIONS } from "./artifact-host.js";
|
|
14
|
+
import { ARTIFACT_TOOL_NAME } from "./tool-catalog-entries.js";
|
|
13
15
|
export const RULE_BEHAVIORS = Object.freeze(["deny", "ask", "allow"]);
|
|
14
16
|
const RULE_BEHAVIOR_SET = new Set(RULE_BEHAVIORS);
|
|
15
17
|
export function isRuleBehavior(v) {
|
|
@@ -43,7 +45,25 @@ export function faceRowsSpeakFor(face) {
|
|
|
43
45
|
}
|
|
44
46
|
export const NAME_RULE_FACES = Object.freeze({
|
|
45
47
|
Skill: Object.freeze({ param: "skill", params: Object.freeze(["skill", "args"]) }),
|
|
48
|
+
[ARTIFACT_TOOL_NAME]: Object.freeze({ param: "action", params: Object.freeze(["action"]), words: ARTIFACT_ACTIONS }),
|
|
46
49
|
});
|
|
50
|
+
function keyedValueParamOf(tool) {
|
|
51
|
+
const face = Object.hasOwn(NAME_RULE_FACES, tool) ? NAME_RULE_FACES[tool] : undefined;
|
|
52
|
+
return face?.words !== undefined ? face.param : undefined;
|
|
53
|
+
}
|
|
54
|
+
export function keyedValueAbsentReason(tool) {
|
|
55
|
+
const key = keyedValueParamOf(tool);
|
|
56
|
+
return key === undefined ? undefined : `the ${tool} call names no ${key} as the tool reads it, so the ${key} it runs is not one its arguments show — a rule by ${key} cannot be read against it`;
|
|
57
|
+
}
|
|
58
|
+
export function nameGrammarReads(tool, content) {
|
|
59
|
+
if (ruleToolGrammarOf(tool) !== "name")
|
|
60
|
+
return false;
|
|
61
|
+
const key = keyedValueParamOf(tool);
|
|
62
|
+
if (key === undefined)
|
|
63
|
+
return true;
|
|
64
|
+
const colon = content.indexOf(":");
|
|
65
|
+
return colon > 0 && content.slice(0, colon).trim() === key;
|
|
66
|
+
}
|
|
47
67
|
export const DOMAIN_RULE_FACES = Object.freeze({
|
|
48
68
|
WebFetch: Object.freeze({ param: "url" }),
|
|
49
69
|
});
|
|
@@ -95,6 +115,20 @@ function isCommandMatch(match) {
|
|
|
95
115
|
return match === "exact" || match === "prefix" || match === "wildcard";
|
|
96
116
|
}
|
|
97
117
|
export const MAX_RULE_TEXT_CHARS = 512;
|
|
118
|
+
export const NOTICE_RULE_TEXT_MAX = 2 * MAX_RULE_TEXT_CHARS;
|
|
119
|
+
export function noticeRuleText(text) {
|
|
120
|
+
if (text.length <= NOTICE_RULE_TEXT_MAX)
|
|
121
|
+
return text;
|
|
122
|
+
let kept = 0;
|
|
123
|
+
let end = 0;
|
|
124
|
+
for (const ch of text) {
|
|
125
|
+
if (kept === NOTICE_RULE_TEXT_MAX)
|
|
126
|
+
return `${text.slice(0, end)}${INLINE_TRUNCATION_MARK}`;
|
|
127
|
+
end += ch.length;
|
|
128
|
+
kept += 1;
|
|
129
|
+
}
|
|
130
|
+
return text;
|
|
131
|
+
}
|
|
98
132
|
export const BARE_INTERPRETER_NAMES = new Set([
|
|
99
133
|
"node", "deno", "bun", "python", "python2", "python3", "perl", "ruby", "php", "osascript",
|
|
100
134
|
"java", "dotnet", "mono", "lua", "luajit", "julia", "Rscript", "tclsh", "groovy", "scala",
|
|
@@ -243,6 +277,13 @@ function ruleLaneShapeOf(command, reading) {
|
|
|
243
277
|
}
|
|
244
278
|
const CONTROL_CHARS_RE = /[\u0000-\u0008\u000A-\u001F\u007F-\u009F\p{Cf}\u2028\u2029]/u;
|
|
245
279
|
const CONTROL_CHARS_GLOBAL_RE = new RegExp(CONTROL_CHARS_RE.source, "gu");
|
|
280
|
+
const RULE_SPELLING_REJECT_BYTES = "<>";
|
|
281
|
+
const RULE_SPELLING_REJECT_RE = new RegExp(`[${RULE_SPELLING_REJECT_BYTES}]`);
|
|
282
|
+
function valueRuleFormsSentence() {
|
|
283
|
+
return Object.entries(NAME_RULE_FACES)
|
|
284
|
+
.map(([tool, face]) => (face.words !== undefined ? `${tool}(${face.param}:<${face.param}>) rules` : `${tool}(<${face.param}>) rules`))
|
|
285
|
+
.join(", ");
|
|
286
|
+
}
|
|
246
287
|
const DISCLOSED_RULE_TEXT_MAX_CHARS = 120;
|
|
247
288
|
export function escapeForDisclosure(value) {
|
|
248
289
|
let text;
|
|
@@ -293,13 +334,16 @@ export function parseRuleText(text, behavior) {
|
|
|
293
334
|
}
|
|
294
335
|
if (parsed.toolName !== COMMAND_RULE_TOOL) {
|
|
295
336
|
const grammar = ruleToolGrammarOf(parsed.toolName);
|
|
337
|
+
if (grammar === undefined) {
|
|
338
|
+
return reject("unsupported.tool", `only Bash command rules, rules on path-targeting tools (Read, Edit, Write, …), ${valueRuleFormsSentence()} and WebFetch domain rules have a rule form in this version (got "${parsed.toolName}")`);
|
|
339
|
+
}
|
|
340
|
+
if (!tighten && RULE_SPELLING_REJECT_RE.test(parsed.ruleContent)) {
|
|
341
|
+
return reject("invalid.grammar", `"${text}" carries a shell redirection byte (${[...RULE_SPELLING_REJECT_BYTES].map((b) => `\`${b}\``).join(" or ")}) — no path, name or host allow spells one, and the grant would not read as what it looks like`);
|
|
342
|
+
}
|
|
296
343
|
if (grammar === "name")
|
|
297
344
|
return parseNameRuleContent(text, parsed.toolName, parsed.ruleContent, behavior);
|
|
298
345
|
if (grammar === "domain")
|
|
299
346
|
return parseDomainRuleContent(text, parsed.toolName, parsed.ruleContent, behavior);
|
|
300
|
-
if (grammar !== "path") {
|
|
301
|
-
return reject("unsupported.tool", `only Bash command rules, rules on path-targeting tools (Read, Edit, Write, …), Skill name rules and WebFetch domain rules have a rule form in this version (got "${parsed.toolName}")`);
|
|
302
|
-
}
|
|
303
347
|
return parsePathRuleContent(text, parsed.toolName, parsed.ruleContent, behavior);
|
|
304
348
|
}
|
|
305
349
|
const content = parsed.ruleContent;
|
|
@@ -353,14 +397,18 @@ export function parseRuleText(text, behavior) {
|
|
|
353
397
|
export function formatRuleText(command, match, tool) {
|
|
354
398
|
if (match === "subpath")
|
|
355
399
|
return `${tool}(//${command.startsWith("/") ? command.slice(1) : command}/**)`;
|
|
356
|
-
if (match === "path"
|
|
400
|
+
if (match === "path")
|
|
357
401
|
return `${tool}(${command})`;
|
|
402
|
+
if (match === "name")
|
|
403
|
+
return `${tool}(${keyedValueParamOf(tool) !== undefined ? `${keyedValueParamOf(tool)}:` : ""}${command})`;
|
|
358
404
|
if (match === "host" || match === "subdomain")
|
|
359
405
|
return `${tool}(domain:${match === "subdomain" ? "*." : ""}${command})`;
|
|
360
406
|
return `${tool}(${command}${match === "prefix" || match === "name_prefix" ? ":*" : match === "wildcard" ? " *" : ""})`;
|
|
361
407
|
}
|
|
362
408
|
function parseNameRuleContent(text, tool, content, behavior, verifyCanonical = true) {
|
|
363
409
|
const face = NAME_RULE_FACES[tool];
|
|
410
|
+
if (face?.words !== undefined)
|
|
411
|
+
return parseKeyedValueRuleContent(text, tool, content, behavior, { param: face.param, words: face.words });
|
|
364
412
|
const bare = content.startsWith("/") ? content.slice(1) : content;
|
|
365
413
|
const colon = bare.indexOf(":");
|
|
366
414
|
if (face !== undefined && colon > 0 && face.params.includes(bare.slice(0, colon).trim())) {
|
|
@@ -389,6 +437,24 @@ function parseNameRuleContent(text, tool, content, behavior, verifyCanonical = t
|
|
|
389
437
|
}
|
|
390
438
|
return { rule };
|
|
391
439
|
}
|
|
440
|
+
function parseKeyedValueRuleContent(text, tool, content, behavior, face) {
|
|
441
|
+
const vocabulary = face.words.join(", ");
|
|
442
|
+
const colon = content.indexOf(":");
|
|
443
|
+
if (colon <= 0 || content.slice(0, colon).trim() !== face.param) {
|
|
444
|
+
return reject("invalid.grammar", `${tool} rules name the ${face.param}: ${tool}(${face.param}:<${face.param}>) with one of ${vocabulary} ("${text}") — a bare value, or a rule on another argument, has no rule form here`);
|
|
445
|
+
}
|
|
446
|
+
const word = content.slice(colon + 1).trim();
|
|
447
|
+
if (word === "") {
|
|
448
|
+
return reject("invalid.grammar", `the ${face.param} in "${text}" is empty — ${tool} rules name the ${face.param} exactly as the call carries it`);
|
|
449
|
+
}
|
|
450
|
+
if (word.includes("*")) {
|
|
451
|
+
return reject("unsupported.wildcard", `a \`*\` in the ${face.param} of "${text}" has no rule form — ${tool} rules name one ${face.param} (${vocabulary}); the whole tool is the bare ${tool} entry`);
|
|
452
|
+
}
|
|
453
|
+
if (!face.words.includes(word)) {
|
|
454
|
+
return reject("invalid.grammar", `"${word}" is not one of the ${face.param} values ${tool} declares (${vocabulary}) — the rule would never reach a call`);
|
|
455
|
+
}
|
|
456
|
+
return { rule: { behavior, rule: formatRuleText(word, "name", tool), tool, match: "name", command: word } };
|
|
457
|
+
}
|
|
392
458
|
export function nameRuleAdmits(rule, name) {
|
|
393
459
|
if (rule.match === "name")
|
|
394
460
|
return name === rule.command;
|
|
@@ -802,7 +868,7 @@ export function directoryIdentityOf(spelling, bases) {
|
|
|
802
868
|
const r = pathIdentityOf(spelling, pathFamilyOf(bases), bases.root ?? bases.cwd);
|
|
803
869
|
return r.ok ? r.identity : undefined;
|
|
804
870
|
}
|
|
805
|
-
const CD_TARGET_REJECT_CHARS =
|
|
871
|
+
const CD_TARGET_REJECT_CHARS = new RegExp(String.raw `[*?[\]{}$` + "`" + String.raw `\\'"\n\r` + RULE_SPELLING_REJECT_BYTES + "]");
|
|
806
872
|
function cdSegmentDirectoryOf(segment, opts) {
|
|
807
873
|
if (/[^\S \t]/.test(segment))
|
|
808
874
|
return undefined;
|
|
@@ -1033,8 +1099,16 @@ export function adjudicatePersistedPathRules(rules, call, views, anchorsOf, lead
|
|
|
1033
1099
|
return undefined;
|
|
1034
1100
|
}
|
|
1035
1101
|
export function adjudicatePersistedNameRules(rules, call) {
|
|
1036
|
-
if (call.name === undefined)
|
|
1102
|
+
if (call.name === undefined) {
|
|
1103
|
+
if (keyedValueAbsentReason(call.tool) === undefined)
|
|
1104
|
+
return undefined;
|
|
1105
|
+
for (const behavior of ["deny", "ask"]) {
|
|
1106
|
+
const row = rules.find((rule) => rule.match === "name" && eligiblePersisted(rule, call, behavior));
|
|
1107
|
+
if (row !== undefined)
|
|
1108
|
+
return { behavior: "deny", rules: [row] };
|
|
1109
|
+
}
|
|
1037
1110
|
return undefined;
|
|
1111
|
+
}
|
|
1038
1112
|
for (const behavior of RULE_BEHAVIORS_BY_PRECEDENCE) {
|
|
1039
1113
|
for (const rule of rules) {
|
|
1040
1114
|
if (eligiblePersisted(rule, call, behavior) && nameRuleAdmits(rule, call.name))
|