@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
|
@@ -260,6 +260,15 @@ async function readAuxiliaryHome(env, home, opts, signal) {
|
|
|
260
260
|
sayAuxiliary("a probe did not answer", opts.configRoot === true ? "config_root" : "auxiliary");
|
|
261
261
|
return reading;
|
|
262
262
|
}
|
|
263
|
+
export function homeViewUnreadSentence(subject, unread, face = "read") {
|
|
264
|
+
return `"${subject}" could not be judged against the ${face} deny list: "${unread}" cannot be identified against the home directories the home-anchored rows are placed under, so whether such a row covers it is unknown; refused — a deny judgment that did not finish is not a pass. Retry once the environment answers identity lookups.`;
|
|
265
|
+
}
|
|
266
|
+
export class HomeViewUnreadError extends Error {
|
|
267
|
+
constructor(subject, unread) {
|
|
268
|
+
super(homeViewUnreadSentence(subject, unread));
|
|
269
|
+
this.name = "HomeViewUnreadError";
|
|
270
|
+
}
|
|
271
|
+
}
|
|
263
272
|
function homeViewSourceOver(env, auxiliary) {
|
|
264
273
|
const declared = declaredHomeOf(env);
|
|
265
274
|
let declaredChain;
|
|
@@ -285,12 +294,10 @@ function homeViewSourceOver(env, auxiliary) {
|
|
|
285
294
|
const at = judgmentEnv ?? env;
|
|
286
295
|
const identity = at.fileIdentity;
|
|
287
296
|
let index;
|
|
288
|
-
const unread = [];
|
|
289
297
|
const indexOf = () => (index ??= (async () => {
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
unread.push(at);
|
|
298
|
+
const declaredChain = await readDeclared(at);
|
|
299
|
+
const chains = [declaredChain, ...(await Promise.all(auxiliary)).map((a) => a.chain)];
|
|
300
|
+
const unread = declaredChain.unread[0];
|
|
294
301
|
const out = new Map();
|
|
295
302
|
for (const { own } of chains)
|
|
296
303
|
if (own !== undefined && !out.has(own.id))
|
|
@@ -299,7 +306,7 @@ function homeViewSourceOver(env, auxiliary) {
|
|
|
299
306
|
for (const { dir, id } of ancestors)
|
|
300
307
|
if (!out.has(id))
|
|
301
308
|
out.set(id, dir);
|
|
302
|
-
return out.size > 0 ? out : undefined;
|
|
309
|
+
return { ...(out.size > 0 ? { ids: out } : {}), ...(unread !== undefined ? { unread } : {}) };
|
|
303
310
|
})());
|
|
304
311
|
const views = new Map();
|
|
305
312
|
const viewOf = (path, leafIsFile) => {
|
|
@@ -308,25 +315,26 @@ function homeViewSourceOver(env, auxiliary) {
|
|
|
308
315
|
if (v === undefined) {
|
|
309
316
|
v = (async () => {
|
|
310
317
|
const index = await indexOf();
|
|
311
|
-
|
|
312
|
-
|
|
318
|
+
const chain = index.unread !== undefined ? { unread: index.unread } : {};
|
|
319
|
+
if (index.ids === undefined || typeof identity !== "function")
|
|
320
|
+
return chain;
|
|
313
321
|
if (!leafIsFile) {
|
|
314
322
|
const id = await identityOf(at, identity, path, signal);
|
|
315
323
|
if (identityUnread(id))
|
|
316
|
-
return
|
|
324
|
+
return { unread: path };
|
|
317
325
|
if (id?.ok === true) {
|
|
318
|
-
const
|
|
319
|
-
if (
|
|
320
|
-
return
|
|
326
|
+
const dir = index.ids.get(id.value);
|
|
327
|
+
if (dir !== undefined)
|
|
328
|
+
return { ...chain, view: dir };
|
|
321
329
|
}
|
|
322
330
|
else if (id?.error.code === "not_supported")
|
|
323
|
-
return
|
|
331
|
+
return chain;
|
|
324
332
|
}
|
|
325
333
|
const parent = normalizeAbsPathLexically(`${path}/..`);
|
|
326
334
|
if (parent === path)
|
|
327
|
-
return
|
|
335
|
+
return chain;
|
|
328
336
|
const up = await viewOf(parent, false);
|
|
329
|
-
return up === undefined ?
|
|
337
|
+
return up.view === undefined ? up : { ...up, view: joinForFamily(pathFamilyOf({ root: path }), up.view, path.slice(parent.length).replace(/^[\\/]+/, "")) };
|
|
330
338
|
})();
|
|
331
339
|
views.set(key, v);
|
|
332
340
|
}
|
|
@@ -335,12 +343,11 @@ function homeViewSourceOver(env, auxiliary) {
|
|
|
335
343
|
return {
|
|
336
344
|
async of(path, opts) {
|
|
337
345
|
if (typeof identity !== "function" || (declared === undefined && auxiliary.length === 0) || !isAbsoluteForFamily("own", path))
|
|
338
|
-
return
|
|
346
|
+
return {};
|
|
339
347
|
const spelled = normalizeAbsPathLexically(path);
|
|
340
|
-
const view = await viewOf(spelled, opts?.leaf === "file");
|
|
341
|
-
return view
|
|
348
|
+
const { view, unread } = await viewOf(spelled, opts?.leaf === "file");
|
|
349
|
+
return { ...(view !== undefined && view !== spelled ? { view } : {}), ...(unread !== undefined ? { unread } : {}) };
|
|
342
350
|
},
|
|
343
|
-
unread,
|
|
344
351
|
};
|
|
345
352
|
},
|
|
346
353
|
};
|
|
@@ -379,6 +386,7 @@ export function readDenyOver(current, homeViews) {
|
|
|
379
386
|
return current().rgProbeGlobs;
|
|
380
387
|
},
|
|
381
388
|
unexcludableUnder: (scope) => current().unexcludableUnder?.(scope) ?? false,
|
|
389
|
+
rowUnderRoot: (scope) => current().rowUnderRoot?.(scope) ?? null,
|
|
382
390
|
rowAtOrBelow: (path) => current().rowAtOrBelow?.(path) ?? null,
|
|
383
391
|
homeViews: homeViews ?? { views: (signal) => current().homeViews.views(signal) },
|
|
384
392
|
};
|
|
@@ -464,15 +472,8 @@ export function readDenyPlacedLater(unplaced, place) {
|
|
|
464
472
|
const homeViews = {
|
|
465
473
|
views(signal, judgmentEnv) {
|
|
466
474
|
let views;
|
|
467
|
-
const unread = [];
|
|
468
475
|
return {
|
|
469
|
-
of: async (path, opts) =>
|
|
470
|
-
const inner = await (views ??= settled().then((m) => m.homeViews.views(signal, judgmentEnv)));
|
|
471
|
-
const view = await inner.of(path, opts);
|
|
472
|
-
unread.splice(0, unread.length, ...inner.unread);
|
|
473
|
-
return view;
|
|
474
|
-
},
|
|
475
|
-
unread,
|
|
476
|
+
of: async (path, opts) => (await (views ??= settled().then((m) => m.homeViews.views(signal, judgmentEnv)))).of(path, opts),
|
|
476
477
|
};
|
|
477
478
|
},
|
|
478
479
|
};
|
|
@@ -48,6 +48,17 @@ export interface ReadDenyHit {
|
|
|
48
48
|
* sends the reader chasing a path the pattern does not match. */
|
|
49
49
|
matchedView?: string;
|
|
50
50
|
}
|
|
51
|
+
/** A recursive read's root relation to the table ({@link ReadDenyMatcher.rowUnderRoot}): the row the root NAMES or contains
|
|
52
|
+
* (`unplaced` absent), or — when it names none — a home-anchored row compiled under no home (`unplaced: true`), which cannot be
|
|
53
|
+
* placed and so may lie under any root. */
|
|
54
|
+
export type ReadDenyRootHit = ReadDenyHit & {
|
|
55
|
+
readonly unplaced?: true;
|
|
56
|
+
};
|
|
57
|
+
/** The same relation as the shell read boundary takes it ({@link ReadDenySeat.denyUnder}): the pattern of the row the root
|
|
58
|
+
* names (a deny), `{ unplaced }` for a row the root may hold that no home places, or null. */
|
|
59
|
+
export type ReadDenyRootAnswer = string | {
|
|
60
|
+
readonly unplaced: string;
|
|
61
|
+
} | null;
|
|
51
62
|
/** The two faces of the deny table: what a READ must not reach, and what a WRITE must not reach. */
|
|
52
63
|
export declare const DENY_FACES: readonly ["read", "write"];
|
|
53
64
|
export type DenyFace = (typeof DENY_FACES)[number];
|
|
@@ -167,14 +178,11 @@ export interface ReadDenyMatcher {
|
|
|
167
178
|
/** Judge ONE path view (segment-window semantics). Returns the first matching entry, or null.
|
|
168
179
|
* `aliasResolved` = the key's MINTER reports the real filesystem already collapsed any win32
|
|
169
180
|
* component alias in it (canonicalizeTarget's realpath arm); unset ⇒ both readings are judged,
|
|
170
|
-
* which is the fail-closed default.
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
* reading of a rule against a command's arguments), while the segment rows (the built-in tiers, the
|
|
174
|
-
* deployment's patterns) reach every path a read can open. Unset ⇒ every row, the fail-closed default. */
|
|
181
|
+
* which is the fail-closed default. Every row of the table judges the path — a segment row (built-in tier,
|
|
182
|
+
* deployment pattern) and a rule row alike: a path is judged by what a command NAMES, never by a tree
|
|
183
|
+
* enumerated below it. */
|
|
175
184
|
matchPath(path: string, opts?: {
|
|
176
185
|
readonly aliasResolved?: boolean;
|
|
177
|
-
readonly walked?: boolean;
|
|
178
186
|
}): ReadDenyHit | null;
|
|
179
187
|
/** §3.3 target judgment: canonical view + lexical view + every hop of the leaf symlink chain (`hops`,
|
|
180
188
|
* each an unresolved spelling some link wrote); ANY hit decides. `aliasResolved` applies to the
|
|
@@ -195,6 +203,16 @@ export interface ReadDenyMatcher {
|
|
|
195
203
|
* differently by whether the entry's content matched — so a search over such a scope takes the walker, which prunes
|
|
196
204
|
* by path before reading. A scope that is not rooted answers true. */
|
|
197
205
|
unexcludableUnder?(scope: string): boolean;
|
|
206
|
+
/** The segment row the absolute directory `scope` NAMES or contains, judged on locations alone, never on what exists
|
|
207
|
+
* there: a placed row (home-anchored or rooted, or where one of those really leads) whose location lies at or below the
|
|
208
|
+
* scope, or a spelled row whose run — leading wildcards dropped — starts at the scope's own segments (`secrets/**`, with or
|
|
209
|
+
* without a leading double-star segment, for `…/secrets` and for `…/secrets/sub`; not for `…/sub` that merely holds a `secrets` directory below
|
|
210
|
+
* it, and a double-star-led `.env` row names no directory at all). A home-anchored row compiled under NO home names a root
|
|
211
|
+
* where its spelled run does and otherwise answers `unplaced` (a row that cannot be placed holds wider: any root may hold
|
|
212
|
+
* it), after every row the root names. Rule rows never answer here: a person's `Read(<path>)` rule judges explicit operands
|
|
213
|
+
* only. `null` for a scope that is not rooted. The one answer a recursive read's root gets about the table
|
|
214
|
+
* ({@link unexcludableUnder} asks the placed subset for the search faces). */
|
|
215
|
+
rowUnderRoot?(scope: string): ReadDenyRootHit | null;
|
|
198
216
|
/** A row that lies AT or BELOW `path` — the path is inside one of the row's matches, or a match would run on below the
|
|
199
217
|
* path from its own segments ({@link rowMeetsPath}) — so moving, copying or removing the path changes what the row
|
|
200
218
|
* covers. A rule row's reach below a path is not enumerable: any rule row answers. */
|
|
@@ -216,10 +234,10 @@ export declare function seatReady(seat: unknown, signal?: AbortSignal): Promise<
|
|
|
216
234
|
* this module is the leaf every face depends on). `denyMatch` judges one LEXICALLY RESOLVED operand,
|
|
217
235
|
* returning the matched pattern or null; PRESENT-IFF there is something to judge. */
|
|
218
236
|
export interface ReadDenySeat {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
237
|
+
denyMatch?: (resolvedPath: string) => string | null;
|
|
238
|
+
/** {@link ReadDenyMatcher.rowUnderRoot} for one lexically resolved directory, as {@link ReadDenyRootAnswer}; present exactly
|
|
239
|
+
* when `denyMatch` is. */
|
|
240
|
+
denyUnder?: (resolvedPath: string) => ReadDenyRootAnswer;
|
|
223
241
|
/** {@link ReadDenyMatcher.rowAtOrBelow} for one lexically resolved path; present exactly when `denyMatch` is. */
|
|
224
242
|
denyAtOrBelow?: (resolvedPath: string) => string | null;
|
|
225
243
|
denyEntries: readonly string[];
|
|
@@ -306,6 +324,14 @@ export interface ReadDenyBuiltinRow {
|
|
|
306
324
|
* and a false refusal on a fixture is the cheap direction (deny errs strict). A home-anchored row
|
|
307
325
|
* (`~/…`, {@link READ_DENY_HOME_WORD}) is matched only below the home directory.
|
|
308
326
|
*
|
|
327
|
+
* Two COLUMNS, one table: a name that is a credential wherever it is found is spelled unanchored (a key
|
|
328
|
+
* copied into a repo is as hot as the original); a name that is the PERSON's file in the home but the
|
|
329
|
+
* project's own configuration anywhere else is spelled home-anchored. `.npmrc` / `.pypirc` are the second
|
|
330
|
+
* kind: `~/.npmrc` holds the person's registry tokens, while a project's `.npmrc` is read on every install
|
|
331
|
+
* question and routinely carries an `${NPM_TOKEN}` placeholder — refusing it cost ordinary work in every mode
|
|
332
|
+
* and bought nothing the home row does not already hold. The same file read through a link from a project
|
|
333
|
+
* into the home still meets the home row on its canonical view.
|
|
334
|
+
*
|
|
309
335
|
* NOT listed, deliberately: `.env`/`.env.*` (ruled out — workspace material; the WRITE guard still
|
|
310
336
|
* covers them; the ENGINE's own `.env` under its data root is a different file and IS listed, see the
|
|
311
337
|
* agent-config tier); `*.pem`/`*.key`/`*.p12`/`*.pfx` (repo certificates/test keys are routinely
|
|
@@ -403,6 +429,9 @@ export interface CompiledSegmentPattern {
|
|
|
403
429
|
* itself rooted (anchored at the filesystem root, {@link ReadDenyEntry}). A view that is not rooted cannot be placed: a
|
|
404
430
|
* home-anchored row's own run is held anywhere in it (the row cannot be placed, so it holds wider); these two judge it not. */
|
|
405
431
|
rootedOnly?: true;
|
|
432
|
+
/** A home-anchored row compiled under NO home: it cannot be placed, so it holds wider on both relations a path has to it —
|
|
433
|
+
* its run matches anywhere in a path, and any recursive read's root may hold it ({@link rowNamedByRoot}). */
|
|
434
|
+
unplacedHome?: true;
|
|
406
435
|
}
|
|
407
436
|
/**
|
|
408
437
|
* Compile one segment-glob pattern (shared engine). `fold`:
|
|
@@ -457,7 +486,8 @@ export declare function checkedReadDenyHomes(homes: unknown, seat?: string): rea
|
|
|
457
486
|
* ({@link READ_DENY_HOME_WORD}) is placed under: the declared home, the account home and, where the environment's
|
|
458
487
|
* canonical spelling of one differs, that one too (the faces judge canonical keys beside the spelled views). Absolute
|
|
459
488
|
* spellings only — any other shape refuses loudly, naming `readDenyHomes`. EMPTY = the environment declares no
|
|
460
|
-
* home: a home-anchored entry then matches its run anywhere
|
|
489
|
+
* home: a home-anchored entry then matches its run anywhere and any recursive read's root may hold it
|
|
490
|
+
* ({@link ReadDenyMatcher.rowUnderRoot}) — a row that cannot be placed holds wider, never narrower, on both relations.
|
|
461
491
|
*
|
|
462
492
|
* `linked` — where a home-anchored or a rooted row's LITERAL HEAD ({@link readDenyRunHead}) really leads, keyed by the row's
|
|
463
493
|
* pattern: the canonical locations a mount resolved (`readDenyLinksOf`, read-deny-home.ts) where
|
|
@@ -166,7 +166,11 @@ export function readDenySeat(matcher) {
|
|
|
166
166
|
if (matcher === undefined || entries.length === 0)
|
|
167
167
|
return { denyEntries: entries };
|
|
168
168
|
return {
|
|
169
|
-
denyMatch: (p
|
|
169
|
+
denyMatch: (p) => matcher.matchPath(p)?.pattern ?? null,
|
|
170
|
+
denyUnder: (p) => {
|
|
171
|
+
const hit = matcher.rowUnderRoot?.(p) ?? null;
|
|
172
|
+
return hit === null ? null : hit.unplaced === true ? { unplaced: hit.pattern } : hit.pattern;
|
|
173
|
+
},
|
|
170
174
|
denyAtOrBelow: (p) => (matcher.rowAtOrBelow !== undefined ? (matcher.rowAtOrBelow(p)?.pattern ?? null) : entries[0]),
|
|
171
175
|
denyEntries: entries,
|
|
172
176
|
};
|
|
@@ -211,8 +215,8 @@ export const READ_FACE_BUILTIN_DENY_TABLE = [
|
|
|
211
215
|
{ pattern: ".git-credentials", tier: "credentials" },
|
|
212
216
|
{ pattern: ".docker/config.json", tier: "credentials" },
|
|
213
217
|
{ pattern: ".config/gh", tier: "credentials" },
|
|
214
|
-
{ pattern: "
|
|
215
|
-
{ pattern: "
|
|
218
|
+
{ pattern: "~/.npmrc", tier: "credentials" },
|
|
219
|
+
{ pattern: "~/.pypirc", tier: "credentials" },
|
|
216
220
|
{ pattern: ".local/share/keyrings", tier: "credentials" },
|
|
217
221
|
{ pattern: "Library/Keychains", tier: "credentials" },
|
|
218
222
|
{ pattern: ".credentials.json", tier: "credentials" },
|
|
@@ -402,6 +406,40 @@ function rowMeetsPath(pat, segs, rooted) {
|
|
|
402
406
|
}
|
|
403
407
|
return false;
|
|
404
408
|
}
|
|
409
|
+
function isAnySegment(re) {
|
|
410
|
+
return /^\^(\[\^\/\]\*)+\$$/.test(re.source);
|
|
411
|
+
}
|
|
412
|
+
function rowNamedByRoot(pat, segs, rooted) {
|
|
413
|
+
if (pat.anchors !== undefined)
|
|
414
|
+
return rooted && rowMeetsPath(pat, segs, rooted) ? "named" : "none";
|
|
415
|
+
if (pat.rootedOnly === true)
|
|
416
|
+
return "none";
|
|
417
|
+
let k = 0;
|
|
418
|
+
while (k < pat.segments.length && isAnySegment(pat.segments[k]))
|
|
419
|
+
k++;
|
|
420
|
+
const run = pat.segments.slice(k);
|
|
421
|
+
for (let i = 0; run.length > 0 && i < segs.length; i++) {
|
|
422
|
+
const m = Math.min(run.length, segs.length - i);
|
|
423
|
+
if (run.slice(0, m).every((re, j) => re.test(segs[i + j])))
|
|
424
|
+
return "named";
|
|
425
|
+
}
|
|
426
|
+
return pat.unplacedHome === true && rooted ? "unplaced" : "none";
|
|
427
|
+
}
|
|
428
|
+
function rowNamedByRootOf(rows, path) {
|
|
429
|
+
const rooted = isAbsoluteForFamily("own", path);
|
|
430
|
+
const views = segmentViewsOf(path);
|
|
431
|
+
let unplaced;
|
|
432
|
+
for (const pat of rows) {
|
|
433
|
+
for (const view of views) {
|
|
434
|
+
const relation = rowNamedByRoot(pat, pat.foldAscii ? view.map(asciiLower) : view, rooted);
|
|
435
|
+
if (relation === "named")
|
|
436
|
+
return { pattern: pat.raw };
|
|
437
|
+
if (relation === "unplaced")
|
|
438
|
+
unplaced ??= pat.raw;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
return unplaced === undefined ? null : { pattern: unplaced, unplaced: true };
|
|
442
|
+
}
|
|
405
443
|
function rowAtOrBelowOf(rows, path) {
|
|
406
444
|
const rooted = isAbsoluteForFamily("own", path);
|
|
407
445
|
const views = segmentViewsOf(path);
|
|
@@ -517,8 +555,10 @@ export function compileReadDeny(additions = [], layer = "additions", builtin, ru
|
|
|
517
555
|
throw new Error(`readDenyPatterns: pattern ${JSON.stringify(e.pattern)} compiled to zero segments.`);
|
|
518
556
|
if (isRootedReadDenyPattern(e.pattern))
|
|
519
557
|
return { ...c, raw: e.pattern, anchors: [[]], rootedOnly: true };
|
|
520
|
-
if (!homeAnchored
|
|
558
|
+
if (!homeAnchored)
|
|
521
559
|
return { ...c, raw: e.pattern };
|
|
560
|
+
if (homeSegments.length === 0)
|
|
561
|
+
return { ...c, raw: e.pattern, unplacedHome: true };
|
|
522
562
|
return { ...c, raw: e.pattern, anchors: homeSegments.map((segs) => (fold === "ascii" ? segs.map(asciiLower) : segs)) };
|
|
523
563
|
});
|
|
524
564
|
if (!(linked instanceof Map))
|
|
@@ -560,8 +600,13 @@ export function compileReadDeny(additions = [], layer = "additions", builtin, ru
|
|
|
560
600
|
return { pattern: hit };
|
|
561
601
|
return ruleRows.length === 0 ? null : { pattern: ruleRows[0].rule };
|
|
562
602
|
};
|
|
603
|
+
const rowUnderRoot = (scope) => {
|
|
604
|
+
if (judged.length === 0 || !isAbsoluteForFamily("own", scope))
|
|
605
|
+
return null;
|
|
606
|
+
return rowNamedByRootOf(judged, normalizeAbsPathLexically(scope));
|
|
607
|
+
};
|
|
563
608
|
const matchPath = (path, opts) => {
|
|
564
|
-
const hit = denyTableHit(
|
|
609
|
+
const hit = denyTableHit(tableRows, { views: [{ path, kind: "lexical", ...(opts?.aliasResolved === true ? { aliasResolved: true } : {}) }] });
|
|
565
610
|
return hit === null ? null : { pattern: hit.pattern };
|
|
566
611
|
};
|
|
567
612
|
return {
|
|
@@ -572,6 +617,7 @@ export function compileReadDeny(additions = [], layer = "additions", builtin, ru
|
|
|
572
617
|
rgExclusionGlobs,
|
|
573
618
|
rgProbeGlobs,
|
|
574
619
|
unexcludableUnder,
|
|
620
|
+
rowUnderRoot,
|
|
575
621
|
rowAtOrBelow,
|
|
576
622
|
};
|
|
577
623
|
}
|
|
@@ -3,24 +3,9 @@ import { type HomeViewSource } from "./read-deny-home.js";
|
|
|
3
3
|
import type { AssertAllKeysHandled } from "../../core/ask-origin.js";
|
|
4
4
|
import type { ExecutionEnv } from "../../internal/harness-types.js";
|
|
5
5
|
import { protectivePathTargetOf, type ToolCallLike } from "../../core/tool-registry.js";
|
|
6
|
-
/**
|
|
7
|
-
* CC parity: Read/Edit/Write take the file path as `file_path`. Read the target the same way
|
|
8
|
-
* EVERYWHERE the path is consumed from a tool-call's args — not just the tool body but ALSO every gate that
|
|
9
|
-
* extracts the write target to confine it (sensitive-path, session allowDirs, the fs-write gate). A gate that only
|
|
10
|
-
* read `args.path` would see `undefined` for a `file_path` call and either fail-OPEN (circumvent the guard — a real
|
|
11
|
-
* hole) or fail-closed (deny a legitimate write). Single source.
|
|
12
|
-
*
|
|
13
|
-
* The `path` arm is deliberately BROADER than what Read/Edit/Write accept: their schema requires
|
|
14
|
-
* `file_path` (fs-shared.ts FILE_PATH_PARAMS; Write alone repairs the `path` spelling onto it BEFORE validation,
|
|
15
|
-
* `coerceWriteArguments`, so a gate never sees the alias there), but this reader is
|
|
16
|
-
* shared with gates that judge OTHER tool vocabularies — Glob's real `path` parameter, deployment-authored tools —
|
|
17
|
-
* and a gate must never see LESS than the tool it is confining might act on. So the asymmetry is the design: the
|
|
18
|
-
* schema decides what a caller may send, this decides what gets judged, and this side over-reads on purpose.
|
|
19
|
-
*/
|
|
20
|
-
export declare function fileArgPath(args: unknown): string | undefined;
|
|
21
6
|
/**
|
|
22
7
|
* The WRITE TARGET of a path-confinable write call, tool-aware — single source for every gate that
|
|
23
|
-
* confines a write target, same discipline as {@link fileArgPath}
|
|
8
|
+
* confines a write target, same discipline as {@link fileArgPath} (core/tool-registry.ts):
|
|
24
9
|
*
|
|
25
10
|
* · canonical `NotebookEdit` → `notebook_path` FIRST, `file_path`/`path` only as fallback. The tool
|
|
26
11
|
* itself writes `notebook_path`; its schema tolerates extra keys, so a stray/decoy `file_path` on a
|
|
@@ -111,7 +96,8 @@ export interface FsViolation {
|
|
|
111
96
|
* then additionalDirectories), canonical form. */
|
|
112
97
|
roots?: readonly string[];
|
|
113
98
|
/** Set ONLY on `read_path_denied` — the deny-list pattern (verbatim entry text)
|
|
114
|
-
* the judged target matched.
|
|
99
|
+
* the judged target matched. Absent on the refusal of a deny judgment that could not finish (a home view nobody could
|
|
100
|
+
* read, read-deny-home.ts `HomeView.unread`): no row matched, so none is named and no deny card is minted. */
|
|
115
101
|
pattern?: string;
|
|
116
102
|
message: string;
|
|
117
103
|
}
|
|
@@ -194,10 +180,6 @@ export declare function hasBinaryExtension(path: string): boolean;
|
|
|
194
180
|
/** The MIME type to return an image file AS (a visual `ImageContent` block), or `undefined` if `path` is not a
|
|
195
181
|
* Read-supported image. Pure — no I/O. */
|
|
196
182
|
export declare function imageMimeForRead(path: string): string | undefined;
|
|
197
|
-
/** Verify the raw bytes actually ARE the image format the extension claims (magic-number sniff). Extension alone
|
|
198
|
-
* is forgeable: a `.png` holding text / an empty file / a truncated blob would otherwise become a malformed
|
|
199
|
-
* `ImageContent` that makes the NEXT provider request fail (400). Pure — no I/O. */
|
|
200
|
-
export declare function imageMagicMatches(bytes: Uint8Array, mimeType: string): boolean;
|
|
201
183
|
/** One contiguous byte pattern that must appear at a fixed offset for its signature to match. */
|
|
202
184
|
export interface BinaryMagicSegment {
|
|
203
185
|
/** Byte offset the pattern starts at — 0 for a leading signature, 257 for tar's `ustar`, and so on. */
|
|
@@ -217,7 +199,7 @@ export interface BinaryMagicSignature {
|
|
|
217
199
|
/**
|
|
218
200
|
* Magic-byte criteria for the formats {@link hasBinaryExtension} names. That list carries 103
|
|
219
201
|
* extensions; without this table only PDF (`pdfMagicMatches`, in the PDF lane) and the four API image
|
|
220
|
-
* formats (
|
|
202
|
+
* formats (`imageMagicMatches`, core/image-admission.ts) have a content criterion, so for every other listed format the
|
|
221
203
|
* NAME is the only evidence available. Where the content IS reachable that leaves identification to
|
|
222
204
|
* the statistical fallback ({@link isBinaryContent}),
|
|
223
205
|
* which samples the first 8192 decoded characters and passes anything whose control-character ratio
|
|
@@ -295,10 +277,6 @@ export declare function pathFamilyOf(bases: {
|
|
|
295
277
|
readonly root?: string | undefined;
|
|
296
278
|
readonly cwd?: string | undefined;
|
|
297
279
|
}): PathFamily | undefined;
|
|
298
|
-
/** UNC under the win family: two leading separators, a host, a share — either separator, as `path.win32`
|
|
299
|
-
* reads it. The ONE UNC recognizer behind {@link isAbsoluteForFamily}, {@link pathIdentityOf} and
|
|
300
|
-
* {@link joinForFamily}. */
|
|
301
|
-
export declare function isUncSpelling(p: string): boolean;
|
|
302
280
|
/** Where a reading takes its family from: a tree's ({@link PathFamily}), or `"own"` — an address with no tree to place
|
|
303
281
|
* it reads its OWN spelling as the family source (the {@link pathFamilyOf} of that spelling), so a treeless `C:\x` and a
|
|
304
282
|
* treeless `/x` are each read in their own family rather than one of them being declared relative. */
|
package/dist/tools/fs/safety.js
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { readDenySentence } from "./read-deny.js";
|
|
3
|
-
import { homeViewsOf } from "./read-deny-home.js";
|
|
3
|
+
import { homeViewsOf, homeViewUnreadSentence } from "./read-deny-home.js";
|
|
4
4
|
import { skipsRootsContainment } from "./containment-face.js";
|
|
5
5
|
import { sliceHeadSafe } from "../../core/surrogate-safe-slice.js";
|
|
6
|
-
import { pathTargetValue, protectivePathTargetOf } from "../../core/tool-registry.js";
|
|
6
|
+
import { fileArgPath, pathTargetValue, protectivePathTargetOf } from "../../core/tool-registry.js";
|
|
7
7
|
import { readPath } from "../../core/effective-path-target.js";
|
|
8
|
+
import { isUncSpelling } from "../../core/unc-spelling.js";
|
|
8
9
|
import { withGateTimeout, DEFAULT_GATE_AWAIT_TIMEOUT_MS } from "../../core/gate-bounded-await.js";
|
|
9
10
|
import { thrownText } from "../../core/thrown-value.js";
|
|
10
|
-
export function fileArgPath(args) {
|
|
11
|
-
const a = args;
|
|
12
|
-
const fp = a?.file_path;
|
|
13
|
-
if (typeof fp === "string" && fp.length > 0)
|
|
14
|
-
return fp;
|
|
15
|
-
const p = a?.path;
|
|
16
|
-
return typeof p === "string" && p.length > 0 ? p : undefined;
|
|
17
|
-
}
|
|
18
11
|
export function writeTargetPath(call, pt = protectivePathTargetOf(call)) {
|
|
19
12
|
if (pt !== undefined)
|
|
20
13
|
return pathTargetValue(call.args, pt);
|
|
@@ -152,21 +145,6 @@ export function imageMimeForRead(path) {
|
|
|
152
145
|
return undefined;
|
|
153
146
|
return IMAGE_MIME_BY_EXT[path.slice(dot).toLowerCase()];
|
|
154
147
|
}
|
|
155
|
-
export function imageMagicMatches(bytes, mimeType) {
|
|
156
|
-
const b = bytes;
|
|
157
|
-
switch (mimeType) {
|
|
158
|
-
case "image/png":
|
|
159
|
-
return b.length >= 8 && b[0] === 0x89 && b[1] === 0x50 && b[2] === 0x4e && b[3] === 0x47 && b[4] === 0x0d && b[5] === 0x0a && b[6] === 0x1a && b[7] === 0x0a;
|
|
160
|
-
case "image/jpeg":
|
|
161
|
-
return b.length >= 3 && b[0] === 0xff && b[1] === 0xd8 && b[2] === 0xff;
|
|
162
|
-
case "image/gif":
|
|
163
|
-
return b.length >= 6 && b[0] === 0x47 && b[1] === 0x49 && b[2] === 0x46 && b[3] === 0x38 && (b[4] === 0x37 || b[4] === 0x39) && b[5] === 0x61;
|
|
164
|
-
case "image/webp":
|
|
165
|
-
return b.length >= 12 && b[0] === 0x52 && b[1] === 0x49 && b[2] === 0x46 && b[3] === 0x46 && b[8] === 0x57 && b[9] === 0x45 && b[10] === 0x42 && b[11] === 0x50;
|
|
166
|
-
default:
|
|
167
|
-
return false;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
148
|
const asciiBytes = (s) => Array.from(s, (c) => c.charCodeAt(0));
|
|
171
149
|
export const BINARY_MAGIC_SIGNATURES = [
|
|
172
150
|
{ format: "ZIP archive", segments: [{ offset: 0, bytes: [0x50, 0x4b, 0x03, 0x04] }] },
|
|
@@ -312,9 +290,6 @@ export function pathFamilyOf(bases) {
|
|
|
312
290
|
const tree = bases.root ?? bases.cwd;
|
|
313
291
|
return tree === undefined ? undefined : isWinFormPath(tree) ? "win" : "posix";
|
|
314
292
|
}
|
|
315
|
-
export function isUncSpelling(p) {
|
|
316
|
-
return /^[\\/]{2}[^\\/]+[\\/]+[^\\/]/.test(p);
|
|
317
|
-
}
|
|
318
293
|
export function familyFor(source, p) {
|
|
319
294
|
return source === "own" ? (isWinFormPath(p) ? "win" : "posix") : source;
|
|
320
295
|
}
|
|
@@ -481,13 +456,16 @@ export async function resolveKey(env, rootCanonical, path, signal, baseCwd, addi
|
|
|
481
456
|
const judged = { aliasResolved: canon.aliasResolved === true, hops: views.hops };
|
|
482
457
|
const lexical = views.lexical?.kind === "path" ? spellingOfIdentity(views.lexical.identity, views.lexical.family) : undefined;
|
|
483
458
|
let hit = readDeny.matchTarget(key, lexical, judged);
|
|
459
|
+
const write = readDeny.face === "write";
|
|
484
460
|
if (hit === null) {
|
|
485
|
-
const
|
|
486
|
-
if (
|
|
487
|
-
hit = readDeny.matchTarget(key,
|
|
461
|
+
const home = await homeViewsOf(env, readDeny, signal).of(key);
|
|
462
|
+
if (home.view !== undefined)
|
|
463
|
+
hit = readDeny.matchTarget(key, home.view, judged);
|
|
464
|
+
if (hit === null && home.unread !== undefined) {
|
|
465
|
+
return { ok: false, violation: { code: write ? "write_path_denied" : "read_path_denied", message: homeViewUnreadSentence(path, home.unread, write ? "write" : "read"), target: key } };
|
|
466
|
+
}
|
|
488
467
|
}
|
|
489
468
|
if (hit !== null) {
|
|
490
|
-
const write = readDeny.face === "write";
|
|
491
469
|
return {
|
|
492
470
|
ok: false,
|
|
493
471
|
violation: {
|
package/dist/tools/fs/search.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { isTimeCutCode } from "../../internal/harness.js";
|
|
1
2
|
import { delimitUntrusted } from "../../core/untrusted-text.js";
|
|
2
3
|
import { MAX_EXEC_OUTPUT_BYTES } from "../../core/exec-output-tail.js";
|
|
3
4
|
import { anchorSpelling, hasBinaryExtension, isWinFormPath, pathFamilyOf } from "./safety.js";
|
|
4
|
-
import { homeViewsOf } from "./read-deny-home.js";
|
|
5
|
+
import { HomeViewUnreadError, homeViewsOf } from "./read-deny-home.js";
|
|
5
6
|
import { createEntryDenyJudge } from "./dir-entries.js";
|
|
6
7
|
import { thrownText } from "../../core/thrown-value.js";
|
|
7
8
|
const WALK_MAX_FILES = 5000;
|
|
@@ -1163,9 +1164,11 @@ async function rgOutputDenyTripwireAt(env, stdout, mode, deny, opts, signal) {
|
|
|
1163
1164
|
const path = absolute(record.path);
|
|
1164
1165
|
if (placed.has(path))
|
|
1165
1166
|
continue;
|
|
1166
|
-
const
|
|
1167
|
-
if (view !== undefined)
|
|
1168
|
-
placed.set(path, view);
|
|
1167
|
+
const home = await views.of(path, { leaf: "file" });
|
|
1168
|
+
if (home.view !== undefined)
|
|
1169
|
+
placed.set(path, home.view);
|
|
1170
|
+
if (home.unread !== undefined && deny.matchPath(path) === null && (home.view === undefined || deny.matchPath(home.view) === null))
|
|
1171
|
+
throw new HomeViewUnreadError(path, home.unread);
|
|
1169
1172
|
}
|
|
1170
1173
|
const judge = placed.size === 0 ? deny : { matchPath: (p) => deny.matchPath(p) ?? (placed.has(p) ? deny.matchPath(placed.get(p)) : null) };
|
|
1171
1174
|
return rgOutputDenyTripwire(stdout, mode, judge, opts);
|
|
@@ -1235,7 +1238,7 @@ export async function rgGrepDetailed(env, root, p, signal, deny) {
|
|
|
1235
1238
|
const err = res.error;
|
|
1236
1239
|
if (err.code === "aborted" || signal?.aborted === true)
|
|
1237
1240
|
throw err;
|
|
1238
|
-
if (err.code
|
|
1241
|
+
if (isTimeCutCode(err.code)) {
|
|
1239
1242
|
const partial = err.partialStdout ?? "";
|
|
1240
1243
|
if (partial.trim().length > 0) {
|
|
1241
1244
|
if (deny !== undefined) {
|
|
@@ -1337,12 +1340,14 @@ async function rgDenyExistenceProbe(env, root, deny, target, signal) {
|
|
|
1337
1340
|
export async function runGrepDetailed(env, root, p, signal, deny) {
|
|
1338
1341
|
const scope = p.path ? anchorSpelling(pathFamilyOf({ root }), root, p.path) : root;
|
|
1339
1342
|
const unexcludableUnder = async () => {
|
|
1340
|
-
if (deny
|
|
1343
|
+
if (deny === undefined)
|
|
1341
1344
|
return false;
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1345
|
+
const home = await homeViewsOf(env, deny, signal).of(scope);
|
|
1346
|
+
if (home.unread !== undefined)
|
|
1347
|
+
throw new HomeViewUnreadError(scope, home.unread);
|
|
1348
|
+
if (deny.unexcludableUnder === undefined)
|
|
1349
|
+
return false;
|
|
1350
|
+
return deny.unexcludableUnder(scope) || (home.view !== undefined && deny.unexcludableUnder(home.view));
|
|
1346
1351
|
};
|
|
1347
1352
|
if (!(await unexcludableUnder()) && (await detectRipgrep(env)))
|
|
1348
1353
|
return rgGrepDetailed(env, root, p, signal, deny);
|
|
@@ -21,8 +21,9 @@ export interface WordContext {
|
|
|
21
21
|
readonly table: BindingTable;
|
|
22
22
|
/** Shell text the arithmetic evaluator runs (a substitution in a subscript it evaluates): the segment re-enters it. */
|
|
23
23
|
readonly reentered: string[];
|
|
24
|
-
/**
|
|
25
|
-
* standard input
|
|
24
|
+
/** Why the segment's reads are not established — program text the station does not read (inline text in a language that
|
|
25
|
+
* may open files, or a program read from standard input), or the list its operands come from
|
|
26
|
+
* ({@link deliveredOperandsSentence}). */
|
|
26
27
|
programText?: string;
|
|
27
28
|
/** Some program text was found in a slot (whether or not it may open files). */
|
|
28
29
|
programTextSeen: boolean;
|