@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
package/dist/core/secret-env.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { types } from "node:util";
|
|
3
|
+
import { CREDENTIAL_MIN_CHARS, CREDENTIAL_VOCABULARY, envNameView, isSensitiveHeaderName, splitCamelCase } from "./credential-vocabulary.js";
|
|
2
4
|
import { DEFAULT_INHERITED_ENV_VARS } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
3
5
|
import { deliverEngineNotice } from "./engine-notice.js";
|
|
6
|
+
import { receiveOwnProperties } from "./own-property-receipt.js";
|
|
4
7
|
const GIT_CONFIG_ENV_RE = /^GIT_CONFIG_(?:COUNT|PARAMETERS|(?:KEY|VALUE)_[0-9]+)$/;
|
|
5
8
|
const PROXY_ENV_RE = /^(?:(?:https?|ftp|all|no)_proxy|npm_config_(?:https?_)?proxy|npm_config_noproxy|yarn_proxy|(?:yarn|global_agent|docker|claude_code)_(?:https?|no)_proxy|cloudsdk_proxy_[a-z]+|electron_get_use_proxy)$/i;
|
|
6
9
|
function isExemptEnvName(name) {
|
|
@@ -66,13 +69,14 @@ function carriesSchemelessUserinfo(text) {
|
|
|
66
69
|
const at = text.lastIndexOf("@", text.search(/\s|$/));
|
|
67
70
|
return !isHostPortPathBeforeAt(text.slice(0, at), text.slice(at + 1)) && !/^(?:mailto|sips?|xmpp|im|acct):/i.test(text);
|
|
68
71
|
}
|
|
69
|
-
const
|
|
72
|
+
const FLAG_WORDS = ["true", "false", "none", "null", "yes", "no", "on", "off", "enabled", "disabled", "required", "optional"];
|
|
73
|
+
const CREDENTIAL_ASSIGNMENT_RE = new RegExp(String.raw `(?:(?:^|[;&?#,{]|\/:)\s*|\s)["']?(?!-*jobserver-auth\s*[=:])(?:[a-z0-9_.-]{0,64}(?:password|passwd|pwd|secret|token|(?:account|access|api|private|subscription)[-_]?key|signature|sig|credential)|[a-z0-9_.-]{0,63}[_.-]auth)["']?\s*[=:]\s*["']?(?!(?:${FLAG_WORDS.join("|")})(?:$|[;&,\s"']))[^;&,\s"']+`, "i");
|
|
70
74
|
const WEBHOOK_URL_RE = /https:\/\/(?:hooks\.slack\.com\/(?:services|workflows|triggers)\/|(?:ptb\.|canary\.)?discord(?:app)?\.com\/api\/webhooks\/\d+\/|[\w.-]+\.webhook\.office\.com\/webhookb2\/)[\w\/@.~-]{16,}/i;
|
|
71
|
-
const SONAR_LOGIN_RE =
|
|
75
|
+
const SONAR_LOGIN_RE = new RegExp(String.raw `["']?sonar\.login["']?\s*[:=]\s*["']?[^\s"',}]{${CREDENTIAL_MIN_CHARS},}`);
|
|
72
76
|
const PRIVATE_KEY_HEADER_RE = /-----BEGIN [A-Z ]*PRIVATE KEY(?: BLOCK)?-----/;
|
|
73
|
-
const AUTHORIZATION_HEADER_RE =
|
|
77
|
+
const AUTHORIZATION_HEADER_RE = new RegExp(String.raw `\bauthorization\s*[:=]\s*["']?[a-z][a-z0-9_-]*\s+[A-Za-z0-9._~+\/=-]{${CREDENTIAL_MIN_CHARS},}`, "i");
|
|
74
78
|
const TOKEN_WORD_RE = /\b(?:[Tt]oken|TOKEN)\s+(?=[A-Za-z0-9_~+=-]*[0-9])(?=[A-Za-z0-9_~+=-]*[A-Z])(?=([A-Za-z0-9_~+=-]{20,}))\1(?![\/.])/;
|
|
75
|
-
const BEARER_BASIC_RE =
|
|
79
|
+
const BEARER_BASIC_RE = new RegExp(String.raw `\b(?:Bearer|Basic)\s+(?=[A-Za-z._~+\/=-]*[0-9]|(?:[A-Za-z0-9._~+\/=-]*?[a-z][A-Z](?![a-z])){2}|[A-Za-z0-9.-]*[_~+\/=])[A-Za-z0-9._~+\/=-]{${CREDENTIAL_MIN_CHARS},}`);
|
|
76
80
|
export function looksLikeCredentialValue(value) {
|
|
77
81
|
const text = value.length > VALUE_SCAN_LIMIT ? value.slice(0, VALUE_SCAN_LIMIT) : value;
|
|
78
82
|
for (let at = text.indexOf("://"); at !== -1; at = text.indexOf("://", at + 3)) {
|
|
@@ -149,39 +153,188 @@ const WINDOWS_REQUIRED_ENV = Object.freeze(["HOMEDRIVE", "HOMEPATH", "LOGONSERVE
|
|
|
149
153
|
function runtimeSuppliedEnv() {
|
|
150
154
|
return ["NODE_V8_COVERAGE", ...DEFAULT_INHERITED_ENV_VARS, ...(process.platform === "win32" ? WINDOWS_REQUIRED_ENV : [])];
|
|
151
155
|
}
|
|
152
|
-
const
|
|
153
|
-
const
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
156
|
+
const valueDigest = (value) => createHash("sha256").update(value, "utf16le").digest("base64");
|
|
157
|
+
const indexHas = (index, value) => {
|
|
158
|
+
const digests = index.get(value.length);
|
|
159
|
+
return digests !== undefined && digests.has(valueDigest(value));
|
|
160
|
+
};
|
|
161
|
+
const indexAdd = (index, value) => {
|
|
162
|
+
const digests = index.get(value.length);
|
|
163
|
+
if (digests === undefined)
|
|
164
|
+
index.set(value.length, new Set([valueDigest(value)]));
|
|
165
|
+
else
|
|
166
|
+
digests.add(valueDigest(value));
|
|
157
167
|
};
|
|
158
|
-
const
|
|
159
|
-
|
|
168
|
+
const WITHHELD_ENV = Symbol.for("sema.core.withheldEnvTable");
|
|
169
|
+
const NOTHING_NAMED = Object.freeze([]);
|
|
170
|
+
const isWithheldEnvTable = (t) => typeof t === "object" && t !== null && Array.isArray(t.names) && t.declared instanceof Map && t.held instanceof Map;
|
|
171
|
+
const withheldEnvOf = () => {
|
|
172
|
+
const slot = Reflect.get(globalThis, WITHHELD_ENV);
|
|
173
|
+
if (isWithheldEnvTable(slot))
|
|
174
|
+
return slot;
|
|
175
|
+
const fresh = { names: NOTHING_NAMED, declared: new Map(), held: new Map() };
|
|
176
|
+
Reflect.set(globalThis, WITHHELD_ENV, fresh);
|
|
177
|
+
return fresh;
|
|
160
178
|
};
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (
|
|
164
|
-
throw new Error(`declareWithheldEnv:
|
|
165
|
-
const
|
|
179
|
+
const kindOf = (v) => (v === null ? "null" : Array.isArray(v) ? "an array" : typeof v);
|
|
180
|
+
function listCopy(label, list) {
|
|
181
|
+
if (types.isProxy(list))
|
|
182
|
+
throw new Error(`declareWithheldEnv: ${label} must be a plain array, not a Proxy`);
|
|
183
|
+
const copy = [];
|
|
184
|
+
try {
|
|
185
|
+
for (let i = 0, n = list.length; i < n; i++)
|
|
186
|
+
copy[i] = list[i];
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
throw new Error(`declareWithheldEnv: an element of ${label} threw while it was read — refused`);
|
|
190
|
+
}
|
|
191
|
+
return Object.freeze(copy);
|
|
192
|
+
}
|
|
193
|
+
const CANNOT_BE_WITHHELD = "which a child is handed from this process's environment whatever the spawn passes (by Node, the MCP stdio transport or Windows) — it cannot be withheld";
|
|
194
|
+
function runtimeSuppliedHolderOf(value) {
|
|
195
|
+
const supplied = policyArm([...runtimeSuppliedEnv()]);
|
|
196
|
+
return Object.keys(supplied).find((k) => supplied[k] === value);
|
|
197
|
+
}
|
|
198
|
+
const PLACEHOLDER_KEY_WORDS = new Set([...FLAG_WORDS, "undefined", "placeholder", "lm-studio", "not-needed", "sk-no-key-required"]);
|
|
199
|
+
const ONE_REPEATED_CHARACTER_RE = /^(\S)\1{2,}$/u;
|
|
200
|
+
function notACredentialReason(value) {
|
|
201
|
+
const text = value.trim();
|
|
202
|
+
if (text === "")
|
|
203
|
+
return "white space only, which every blank variable equals";
|
|
204
|
+
if (text.length < CREDENTIAL_MIN_CHARS)
|
|
205
|
+
return `a string of fewer than ${CREDENTIAL_MIN_CHARS} characters, which names no secret`;
|
|
206
|
+
if (PLACEHOLDER_KEY_WORDS.has(text.toLowerCase()))
|
|
207
|
+
return "a flag or placeholder word, which names no secret";
|
|
208
|
+
if (ONE_REPEATED_CHARACTER_RE.test(text.replace(CREDENTIAL_VOCABULARY.tokenPrefix, "")))
|
|
209
|
+
return "one character repeated, which names no secret";
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
212
|
+
function credentialValueProblem(v) {
|
|
213
|
+
if (typeof v !== "string")
|
|
214
|
+
return kindOf(v);
|
|
215
|
+
if (v === "")
|
|
216
|
+
return "an empty string, which every variable set to nothing equals";
|
|
217
|
+
if (v.includes("\0") || UNPAIRED_SURROGATE_RE.test(v))
|
|
218
|
+
return `a value holding ${v.includes("\0") ? "a NUL" : "an unpaired surrogate"}, which no variable can hold`;
|
|
219
|
+
return notACredentialReason(v);
|
|
220
|
+
}
|
|
221
|
+
function credentialValueListProblem(value) {
|
|
222
|
+
for (const [i, v] of value.entries()) {
|
|
223
|
+
const why = credentialValueProblem(v);
|
|
224
|
+
if (why !== undefined)
|
|
225
|
+
return `values[${i}] is not a credential value (got ${why})`;
|
|
226
|
+
}
|
|
227
|
+
return undefined;
|
|
228
|
+
}
|
|
229
|
+
export function declareWithheldEnv(table) {
|
|
230
|
+
const given = table;
|
|
231
|
+
if (given === null || typeof given !== "object" || Array.isArray(given)) {
|
|
232
|
+
throw new Error(`declareWithheldEnv: the declaration must be a table { names, values } (got ${Array.isArray(given) ? "an array — a names-only list is no longer a declaration: pass { names, values }" : kindOf(given)})`);
|
|
233
|
+
}
|
|
234
|
+
const received = receiveOwnProperties(given, { subject: "declareWithheldEnv's table", unit: "member", moment: "at the declaration" });
|
|
235
|
+
const stray = Object.keys(received).find((k) => k !== "names" && k !== "values");
|
|
236
|
+
if (stray !== undefined)
|
|
237
|
+
throw new Error(`declareWithheldEnv: the table has a member ${JSON.stringify(stray.slice(0, 64))} — it holds names and values only`);
|
|
238
|
+
const givenNames = received.names;
|
|
239
|
+
if (!Array.isArray(givenNames))
|
|
240
|
+
throw new Error(`declareWithheldEnv: names must be an array of variable names (got ${kindOf(givenNames)})`);
|
|
241
|
+
const names = listCopy("names", givenNames);
|
|
242
|
+
const problem = variableNameListProblem("names", names);
|
|
166
243
|
if (problem !== undefined)
|
|
167
244
|
throw new Error(`declareWithheldEnv: ${problem}`);
|
|
168
245
|
const supplied = new Set(runtimeSuppliedEnv().map(envNameKey));
|
|
169
|
-
const unwithholdable =
|
|
246
|
+
const unwithholdable = names.findIndex((k) => supplied.has(envNameKey(k)));
|
|
170
247
|
if (unwithholdable !== -1)
|
|
171
|
-
throw new Error(`declareWithheldEnv: names[${unwithholdable}] is ${
|
|
172
|
-
|
|
248
|
+
throw new Error(`declareWithheldEnv: names[${unwithholdable}] is ${String(names[unwithholdable])}, ${CANNOT_BE_WITHHELD}`);
|
|
249
|
+
const givenValues = received.values;
|
|
250
|
+
if (!Array.isArray(givenValues))
|
|
251
|
+
throw new Error(`declareWithheldEnv: values must be an array of credential values (got ${kindOf(givenValues)})`);
|
|
252
|
+
const values = listCopy("values", givenValues);
|
|
253
|
+
const valueProblem = credentialValueListProblem(values);
|
|
254
|
+
if (valueProblem !== undefined)
|
|
255
|
+
throw new Error(`declareWithheldEnv: ${valueProblem}`);
|
|
256
|
+
for (const [i, v] of values.entries()) {
|
|
257
|
+
const holder = runtimeSuppliedHolderOf(v);
|
|
258
|
+
if (holder !== undefined)
|
|
259
|
+
throw new Error(`declareWithheldEnv: values[${i}] is the value of ${holder}, ${CANNOT_BE_WITHHELD}`);
|
|
260
|
+
}
|
|
261
|
+
const declared = new Map();
|
|
262
|
+
for (const v of values)
|
|
263
|
+
indexAdd(declared, v);
|
|
264
|
+
Reflect.set(globalThis, WITHHELD_ENV, { names: names, declared, held: withheldEnvOf().held });
|
|
265
|
+
}
|
|
266
|
+
export function holdOwnCredentialValues(values, onNotice) {
|
|
267
|
+
const given = [...values].filter((v) => typeof v === "string" && v.length > 0);
|
|
268
|
+
const taken = given.filter((v) => {
|
|
269
|
+
const why = notACredentialReason(v);
|
|
270
|
+
if (why !== undefined)
|
|
271
|
+
sayNotTaken(v, why, onNotice);
|
|
272
|
+
return why === undefined;
|
|
273
|
+
});
|
|
274
|
+
for (const v of taken) {
|
|
275
|
+
const holder = runtimeSuppliedHolderOf(v);
|
|
276
|
+
if (holder !== undefined)
|
|
277
|
+
throw Object.assign(new Error(`a credential the engine was handed is the value of ${holder}, ${CANNOT_BE_WITHHELD}; the credential is refused`), { code: "config.invalid_argument" });
|
|
278
|
+
}
|
|
279
|
+
const { held } = withheldEnvOf();
|
|
280
|
+
for (const v of taken)
|
|
281
|
+
indexAdd(held, v);
|
|
282
|
+
}
|
|
283
|
+
const AUTH_SCHEME_VALUE_RE = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+ +(\S[\s\S]*)$/;
|
|
284
|
+
const SCHEMED_HEADER_RE = /^(?:proxy-)?authorization$/i;
|
|
285
|
+
export function isCredentialHeaderName(name) {
|
|
286
|
+
return isSensitiveHeaderName(name);
|
|
287
|
+
}
|
|
288
|
+
export function isSchemedCredentialHeader(name) {
|
|
289
|
+
return SCHEMED_HEADER_RE.test(name);
|
|
290
|
+
}
|
|
291
|
+
export function credentialHeaderValues(headers) {
|
|
292
|
+
const out = [];
|
|
293
|
+
for (const [name, value] of Object.entries(headers ?? {})) {
|
|
294
|
+
if (typeof value !== "string" || !(isCredentialHeaderName(name) || looksLikeCredentialValue(value)))
|
|
295
|
+
continue;
|
|
296
|
+
const credentials = AUTH_SCHEME_VALUE_RE.exec(value)?.[1];
|
|
297
|
+
if (credentials !== undefined && isSchemedCredentialHeader(name) && notACredentialReason(credentials) !== undefined) {
|
|
298
|
+
out.push(credentials);
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
out.push(value);
|
|
302
|
+
if (credentials !== undefined)
|
|
303
|
+
out.push(credentials);
|
|
304
|
+
}
|
|
305
|
+
return out;
|
|
306
|
+
}
|
|
307
|
+
const intakeSaid = new Set();
|
|
308
|
+
function sayNotTaken(value, why, onNotice) {
|
|
309
|
+
const key = valueDigest(value.trim());
|
|
310
|
+
if (intakeSaid.has(key))
|
|
311
|
+
return;
|
|
312
|
+
intakeSaid.add(key);
|
|
313
|
+
try {
|
|
314
|
+
deliverEngineNotice(onNotice, {
|
|
315
|
+
code: "config.credential_not_withheld",
|
|
316
|
+
message: `a credential the engine was handed is ${why} — it is used as given, but a variable holding the same string is not withheld from a spawned child (said once per value; the value is not repeated)`,
|
|
317
|
+
detail: { reason: why },
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
catch {
|
|
321
|
+
}
|
|
173
322
|
}
|
|
174
323
|
export function __resetWithheldEnv() {
|
|
175
|
-
|
|
324
|
+
Reflect.set(globalThis, WITHHELD_ENV, { names: NOTHING_NAMED, declared: new Map(), held: new Map() });
|
|
325
|
+
intakeSaid.clear();
|
|
176
326
|
}
|
|
177
327
|
function withholdOwnCredentials(inherited, findings) {
|
|
178
|
-
|
|
328
|
+
const table = withheldEnvOf();
|
|
329
|
+
if (table.names.length === 0 && table.declared.size === 0 && table.held.size === 0)
|
|
179
330
|
return inherited;
|
|
180
|
-
const own = new Set(
|
|
331
|
+
const own = new Set(table.names.map(envNameKey));
|
|
181
332
|
const kept = [];
|
|
182
333
|
for (const key of Object.keys(inherited)) {
|
|
183
|
-
|
|
184
|
-
|
|
334
|
+
const value = inherited[key];
|
|
335
|
+
const ownValue = typeof value === "string" && (indexHas(table.declared, value) || indexHas(table.held, value));
|
|
336
|
+
if (!own.has(envNameKey(key)) && !ownValue)
|
|
337
|
+
kept.push([key, value]);
|
|
185
338
|
else
|
|
186
339
|
findings?.push({ key, kind: "own-credential", confidence: SECRET_ENV_KIND_CONFIDENCE["own-credential"], source: "secret-env" });
|
|
187
340
|
}
|
|
@@ -198,24 +351,25 @@ export function inheritedHostEnv(policy, findings) {
|
|
|
198
351
|
const problem = inheritEnvPolicyProblem(policy);
|
|
199
352
|
if (problem !== undefined)
|
|
200
353
|
throw new Error(problem);
|
|
201
|
-
|
|
354
|
+
return withholdOwnCredentials(policyArm(policy, findings), findings);
|
|
355
|
+
}
|
|
356
|
+
function policyArm(policy, findings) {
|
|
202
357
|
if (policy === "all")
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
arm = scrubSecretEnv(process.env, findings);
|
|
212
|
-
return withholdOwnCredentials(arm, findings);
|
|
358
|
+
return { ...process.env };
|
|
359
|
+
if (!Array.isArray(policy))
|
|
360
|
+
return scrubSecretEnv(process.env, findings);
|
|
361
|
+
const arm = {};
|
|
362
|
+
for (const k of policy)
|
|
363
|
+
if (process.env[k] !== undefined)
|
|
364
|
+
arm[k] = process.env[k];
|
|
365
|
+
return arm;
|
|
213
366
|
}
|
|
214
367
|
export function inheritEnvPolicyProblem(value) {
|
|
215
368
|
const shape = policyShapeProblem(value);
|
|
216
|
-
|
|
369
|
+
const { names } = withheldEnvOf();
|
|
370
|
+
if (shape !== undefined || !Array.isArray(value) || names.length === 0)
|
|
217
371
|
return shape;
|
|
218
|
-
const own = new Set(
|
|
372
|
+
const own = new Set(names.map(envNameKey));
|
|
219
373
|
const named = value.findIndex((k) => own.has(envNameKey(k)));
|
|
220
374
|
return named === -1 ? undefined : `inheritEnv[${named}] names ${value[named]}, which is this deployment's own credential and cannot be inherited by a child (a configuration error: no retry succeeds until the policy or the declaration changes)`;
|
|
221
375
|
}
|
|
@@ -21,10 +21,13 @@
|
|
|
21
21
|
* - **a row keeps its grammar**: the write judge stamps the grammar it read the entries in ({@link SESSION_RULES_GRAMMAR}), and
|
|
22
22
|
* every station reads a row's entries in the grammar the row carries ({@link readSessionRulesShape}) — a row stored before
|
|
23
23
|
* the stamp keeps the reading it was written under, so an upgrade never turns a stored entry into a grant.
|
|
24
|
+
* - **rules are read as rules or not at all**: rules whose shape cannot be read, or whose toolDeny holds an entry no grammar
|
|
25
|
+
* reads ({@link unreadableDenyEntries}), refuse every call until an operator writes them afresh — never read as fewer.
|
|
24
26
|
* - **NOT A SANDBOX**: a shell command rule reads the command line the call carries (every program run in its connector
|
|
25
27
|
* chain); the real isolation boundary is the executionEnv, never these rules.
|
|
26
28
|
*/
|
|
27
|
-
import { compileAllowList, type AllowEntryInertDetail, type AllowEntryInertReason } from "./allow-entry.js";
|
|
29
|
+
import { compileAllowList, type AllowEntryInert, type AllowEntryInertDetail, type AllowEntryInertReason } from "./allow-entry.js";
|
|
30
|
+
import type { EngineNotice } from "./engine-notice.js";
|
|
28
31
|
/** The per-session rules. All optional; an absent bucket imposes no constraint of that kind. */
|
|
29
32
|
export interface SessionPermissionRules {
|
|
30
33
|
/** If set, ONLY the calls these entries admit are allowed — a narrowing allowlist: a call no entry admits is refused.
|
|
@@ -51,11 +54,16 @@ export type SessionRuleEntryField = {
|
|
|
51
54
|
/**
|
|
52
55
|
* The rule grammar this engine reads a session's rule entries in: the `grammar` the write judge stamps on every rules value it
|
|
53
56
|
* judges ({@link judgeSessionRulesWrite}), so every store that writes through it keeps the stamp on the row. It counts
|
|
54
|
-
* revisions of what an entry MEANS and moves only when that changes
|
|
55
|
-
* a bucket's entries were tool names compared as written, so an allow entry the
|
|
56
|
-
* (`Bash(rm:*)`, `Bash(*)`) named no tool and admitted nothing
|
|
57
|
+
* revisions of what an entry MEANS and moves only when that changes:
|
|
58
|
+
* - 0, the reading before the one entry reader: a bucket's entries were tool names compared as written, so an allow entry the
|
|
59
|
+
* reader now reads as speaking for another name (`Bash(rm:*)`, `Bash(*)`) named no tool and admitted nothing — and so did
|
|
60
|
+
* `*`, one more name no tool carried, which voided nothing beside it;
|
|
61
|
+
* - 1, the one entry reader taking its tool name from the lenient rule parser (trimmed before a `(`, any character but a
|
|
62
|
+
* blank, a parenthesis or a control / format character);
|
|
63
|
+
* - 2, the rule syntax's tool-name head (`ruleSpellingOf`): a name is read as written, in the characters names are minted in.
|
|
64
|
+
* An entry this grammar reads as no rule in a row an earlier grammar wrote reads as `earlier_grammar` ({@link compileSessionRuleBucket}).
|
|
57
65
|
*/
|
|
58
|
-
export declare const SESSION_RULES_GRAMMAR =
|
|
66
|
+
export declare const SESSION_RULES_GRAMMAR = 2;
|
|
59
67
|
/** {@link SessionPermissionRules} plus the monotonic `rev` the store stamps (the OCC key). */
|
|
60
68
|
export interface StoredSessionRules extends SessionPermissionRules {
|
|
61
69
|
rev: number;
|
|
@@ -111,7 +119,8 @@ export declare class SessionPolicyError extends Error {
|
|
|
111
119
|
export interface SessionPolicyStoreOptions {
|
|
112
120
|
/** The names this deployment mounts its OWN tools under — the roster the store reads a rule entry's tool name against
|
|
113
121
|
* (`readRuleEntry`): a retired name declared here is an ordinary name to the write and to the loosening check alike.
|
|
114
|
-
* Absent = none.
|
|
122
|
+
* Absent = none. Each name keeps the caller tool name contract a deployment tool's name keeps at the mount
|
|
123
|
+
* (`callerToolNameProblem`: a name a rule can name, no `__`); one that does not is refused at construction. */
|
|
115
124
|
mountedToolNames?: Iterable<string>;
|
|
116
125
|
}
|
|
117
126
|
/** A store's declared roster from {@link SessionPolicyStoreOptions.mountedToolNames} — the one reader both bundled stores
|
|
@@ -205,20 +214,64 @@ export declare function readSessionRulesShape(value: unknown): {
|
|
|
205
214
|
* stored form is `..`-free and the tighten diff compares the form the runtime resolves. Both bundled stores and a durable twin
|
|
206
215
|
* stamp exactly this, so a structuredClone and a JSON round-trip of it are byte-identical. */
|
|
207
216
|
export declare function normalizeRules(rules: unknown): SessionPermissionRules;
|
|
217
|
+
/**
|
|
218
|
+
* THE ONE ANSWER to "can these rules' denies be read?": the `toolDeny` entries the list reading ({@link compileSessionRuleBucket},
|
|
219
|
+
* in the rules' own grammar) reads as no rule at all. Rules whose deny bucket holds one cannot be read, and rules that cannot be
|
|
220
|
+
* read are never read as fewer: they refuse every call (the run-time layer) and a non-operator write over them is a loosening
|
|
221
|
+
* ({@link loosenReasons}) — until an operator writes them afresh, and the write judge refuses such an entry. Unlike a definition
|
|
222
|
+
* file a plugin ships, which its user cannot edit, a session's rules are written by the session's own operator and can be
|
|
223
|
+
* rewritten, so a deny nobody can read costs one write instead of quietly guarding nothing. An entry the grammar reads that names
|
|
224
|
+
* no mounted tool (or `*`) is not here: it names nothing and refuses nothing, the rest of the bucket refusing as written.
|
|
225
|
+
* `roster` as in {@link compileSessionRuleBucket}; it never changes this answer (a spelling is read before a name is judged).
|
|
226
|
+
*/
|
|
227
|
+
export declare function unreadableDenyEntries(rules: SessionRulesInGrammar, roster?: ReadonlySet<string>): AllowEntryInert[];
|
|
208
228
|
/**
|
|
209
229
|
* THE LIST READING of one rule bucket of a rules value the shape reading read — what the run-time layer enforces, the tighten
|
|
210
230
|
* comparison compares and the write judge refuses on: `compileAllowList` over the one entry reader, in the bucket's direction,
|
|
211
|
-
* against `roster` when given, in the grammar the value is written in. An entry its grammar reads as nothing
|
|
212
|
-
*
|
|
231
|
+
* against `roster` when given, in the grammar the value is written in. An entry its grammar reads as nothing
|
|
232
|
+
* ({@link earlierGrammarReads}) is moved to the entries that read as nothing, reason `earlier_grammar`, before the list is
|
|
233
|
+
* compiled: it is one entry that reads as nothing, and the list beside it is read as written. The move is an ENTRY's reading and
|
|
234
|
+
* never the list's: an allow list a `*` voids (in any spelling the voiding test reads as `*`, `* (*)` included) is voided in
|
|
235
|
+
* every grammar from 1 on, so in such a row the list is read whole, as written — only grammar 0, where `*` was one more name, takes
|
|
236
|
+
* it out alone.
|
|
213
237
|
*/
|
|
214
238
|
export declare function compileSessionRuleBucket(rules: SessionRulesInGrammar, field: SessionRuleEntryField, roster?: ReadonlySet<string>): ReturnType<typeof compileAllowList>;
|
|
215
|
-
/**
|
|
216
|
-
*
|
|
217
|
-
|
|
239
|
+
/**
|
|
240
|
+
* The advisory for the entries of one bucket a stored row's earlier grammar reads as nothing ({@link compileSessionRuleBucket},
|
|
241
|
+
* `earlier_grammar`; `grammar` = the row's): the session, the bucket, the entries as written, what they do and the way out. An
|
|
242
|
+
* entry this engine's grammar reads as no rule is named with the reader's word — in `toolAllow` it admits nothing, in `toolDeny`
|
|
243
|
+
* the rules cannot be read and every call is refused ({@link unreadableDenyEntries}); the way out is a rewrite leaving it out
|
|
244
|
+
* (the write judge refuses an entry it cannot read). A grammar-0 allow entry that named no tool there is told as it always was:
|
|
245
|
+
* to make a parenthesized one the rule it now spells, or (`*`, which is no allow rule in any grammar) to leave it out.
|
|
246
|
+
*/
|
|
247
|
+
export declare function earlierGrammarAdvisory(sessionId: string, entries: readonly string[], field: SessionRuleEntryField, grammar: number): string;
|
|
248
|
+
/** The reader's word for one entry an earlier grammar reads as nothing: `no_rule` — this engine's rule grammar reads it as no
|
|
249
|
+
* rule; `named_no_tool` — a grammar-0 allow entry the bare-name comparison of its day read as naming no tool. */
|
|
250
|
+
export type EarlierGrammarReader = "no_rule" | "named_no_tool";
|
|
251
|
+
/**
|
|
252
|
+
* The notice for the entries of one bucket a stored row's earlier grammar reads as nothing (`config.session_rules_earlier_grammar`,
|
|
253
|
+
* audience `user` — the session's rules are what the person's calls are judged by): the message is {@link earlierGrammarAdvisory}
|
|
254
|
+
* verbatim, and `detail` carries the same facts for a machine — `bucket` (the field), `storedGrammar` (the row's), `entries` (every
|
|
255
|
+
* entry, each as `noticeRuleText` hands rule text to a notice, with its reader's word), `rewrite` (the way out: an operator write of
|
|
256
|
+
* a new value without the stored row's rev, which stamps `stampsGrammar`), `rulesSessionId` (whose rules — an ancestor's on a
|
|
257
|
+
* delegated child's inherited layer) and `sessionId` (the run that read them).
|
|
258
|
+
*/
|
|
259
|
+
export declare function earlierGrammarNotice(input: {
|
|
260
|
+
rulesSessionId: string;
|
|
261
|
+
sessionId: string;
|
|
262
|
+
entries: readonly string[];
|
|
263
|
+
field: SessionRuleEntryField;
|
|
264
|
+
grammar: number;
|
|
265
|
+
}): EngineNotice;
|
|
266
|
+
/** The clause a run-time refusal carries when the allowlist it judged by holds entries its earlier grammar reads as nothing
|
|
267
|
+
* ({@link compileSessionRuleBucket}; `grammar` = the row's): the grammar the rules are stored in, then which entries name no tool
|
|
268
|
+
* there (grammar 0: `*` by its spelling, the parenthesized ones counted) and how many this engine's grammar reads as no rule —
|
|
269
|
+
* counted, since a stored entry's own text is data and never reaches a sentence the model reads. Empty when none. */
|
|
270
|
+
export declare function earlierGrammarRefusalClause(entries: readonly string[], grammar: number): string;
|
|
218
271
|
/** A layer's delivery of the entries its snapshots' earlier grammar reads as nothing ({@link compileSessionRuleBucket},
|
|
219
|
-
* `earlier_grammar`)
|
|
220
|
-
* throwing sink never changes what the snapshot enforces. */
|
|
221
|
-
export declare function earlierGrammarAnnouncer(sink: ((entries: readonly string[]) => void) | undefined): (entries: readonly string[]) => void;
|
|
272
|
+
* `earlier_grammar`), one bucket at a time with the grammar its row is written in, to `sink`: once per distinct set per layer
|
|
273
|
+
* (the ledger is this closure's), an empty set is no news, and a throwing sink never changes what the snapshot enforces. */
|
|
274
|
+
export declare function earlierGrammarAnnouncer(sink: ((entries: readonly string[], field: SessionRuleEntryField, grammar: number) => void) | undefined): (entries: readonly string[], field: SessionRuleEntryField, grammar: number) => void;
|
|
222
275
|
/**
|
|
223
276
|
* THE ONE WRITE JUDGE every store applies before it stamps a row (both bundled stores, and a durable backend at the same point):
|
|
224
277
|
* the rules to stamp, or a {@link SessionPolicyError}, in this order — `conflict` (a stale `expectedRev` against `prior`'s rev),
|
|
@@ -234,9 +287,11 @@ export declare function judgeSessionRulesWrite(prior: StoredSessionRules | null,
|
|
|
234
287
|
};
|
|
235
288
|
/**
|
|
236
289
|
* Pure tighten-only diff: the reasons `next` LOOSENS `prior` (empty ⇒ `next` is a pure tightening or no-op), over the EFFECTIVE
|
|
237
|
-
* entries of each rule bucket — the list as the run-time layer enforces it ({@link effectiveEntries}).
|
|
290
|
+
* entries of each rule bucket — the list as the run-time layer enforces it ({@link effectiveEntries}). Rules whose toolDeny holds
|
|
291
|
+
* an entry no grammar reads ({@link unreadableDenyEntries}) refuse every call: as `next` they loosen nothing, and as `prior`
|
|
292
|
+
* every readable `next` loosens them (one reason, naming the entries). Any other entry that reads as
|
|
238
293
|
* nothing is in neither side's effect, so removing one relaxes nothing and adding one widens nothing (the way a session's owner
|
|
239
|
-
* takes out an entry that names nothing); an allowlist a `*` voids admits nothing, so dropping the `*` widens. toolDeny: removing an effective entry loosens. toolAllow: removing the list
|
|
294
|
+
* takes out an entry that names nothing); an allowlist a `*` voids (in this engine's grammar; in grammar 0 a `*` is one such entry beside the rest) admits nothing, so dropping the `*` widens. toolDeny: removing an effective entry loosens. toolAllow: removing the list
|
|
240
295
|
* (→ everything allowed) or adding an effective entry outside the prior set loosens; prior-undefined → any defined next only
|
|
241
296
|
* narrows. allowDirs: removing confinement, or adding a dir not within some prior dir, loosens (coarse raw containment).
|
|
242
297
|
* Entries compare as written, each side's in the grammar that side is written in (a stored row's entry that its grammar reads as
|