@sema-agent/core 7.59.0 → 7.60.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 +564 -0
- package/dist/agents/agent-definition.d.ts +7 -0
- package/dist/agents/agent-definition.js +12 -0
- package/dist/agents/agent-transcript-tool.d.ts +2 -1
- package/dist/agents/agent-transcript-tool.js +3 -1
- package/dist/agents/child-model-seat.js +6 -3
- package/dist/agents/cumulative-stats.js +0 -1
- package/dist/agents/inherited-tool-pool.d.ts +26 -1
- package/dist/agents/inherited-tool-pool.js +22 -0
- package/dist/agents/retain-ledger.d.ts +11 -1
- package/dist/agents/retain-ledger.js +13 -2
- package/dist/agents/roster-store.d.ts +1 -1
- package/dist/agents/roster-store.js +3 -1
- package/dist/agents/send-message-tool.d.ts +8 -19
- package/dist/agents/send-message-tool.js +11 -38
- package/dist/agents/subagent.d.ts +51 -17
- package/dist/agents/subagent.js +117 -78
- package/dist/agents/tool-filter.d.ts +1 -3
- package/dist/agents/tool-filter.js +4 -12
- package/dist/bench/metrics.d.ts +3 -5
- package/dist/bench/metrics.js +0 -1
- package/dist/brain/degrading.js +3 -1
- package/dist/brain/route-adjudicator.js +3 -1
- package/dist/brain/status-sink.d.ts +7 -1
- package/dist/brain/status-sink.js +6 -0
- package/dist/brain/timeout.d.ts +3 -1
- package/dist/brain/timeout.js +18 -5
- package/dist/core/a2a.d.ts +15 -5
- package/dist/core/a2a.js +34 -19
- package/dist/core/agent-definition.d.ts +20 -0
- package/dist/core/allow-entry.d.ts +2 -0
- package/dist/core/allow-entry.js +3 -1
- package/dist/core/artifact-host.d.ts +0 -2
- package/dist/core/artifact-host.js +0 -1
- package/dist/core/auto-mode-defaults.d.ts +8 -0
- package/dist/core/auto-mode-defaults.js +1 -0
- package/dist/core/auto-mode-rebuild.d.ts +2 -1
- package/dist/core/auto-mode.d.ts +39 -4
- package/dist/core/auto-mode.js +63 -12
- package/dist/core/background-agent-store.d.ts +10 -1
- package/dist/core/background-agent-store.js +3 -2
- package/dist/core/background-shell.d.ts +12 -1
- package/dist/core/background-shell.js +12 -0
- package/dist/core/checkpoint-store.d.ts +8 -13
- package/dist/core/checkpoint-store.js +4 -3
- package/dist/core/compliance.d.ts +1 -1
- package/dist/core/credential-echo.d.ts +52 -0
- package/dist/core/credential-echo.js +65 -0
- package/dist/core/credential-vocabulary.d.ts +13 -3
- package/dist/core/credential-vocabulary.js +12 -4
- package/dist/core/cross-boundary-taint.d.ts +4 -5
- package/dist/core/engine-notice.d.ts +58 -15
- package/dist/core/frame-settlement.d.ts +5 -0
- package/dist/core/frame-settlement.js +4 -0
- package/dist/core/gate-fold.js +7 -5
- package/dist/core/gate-lanes.js +39 -8
- package/dist/core/governance-codes.d.ts +9 -1
- package/dist/core/governance-codes.js +12 -0
- package/dist/core/hands-band-screen.js +0 -1
- package/dist/core/hands-band.d.ts +0 -3
- package/dist/core/hooks.d.ts +39 -56
- package/dist/core/hooks.js +123 -77
- package/dist/core/image-admission.d.ts +104 -51
- package/dist/core/image-admission.js +170 -46
- package/dist/core/image-downsample.d.ts +36 -69
- package/dist/core/image-downsample.js +111 -73
- package/dist/core/integer-option.d.ts +21 -0
- package/dist/core/integer-option.js +13 -0
- package/dist/core/locked-config.d.ts +54 -3
- package/dist/core/locked-config.js +81 -50
- package/dist/core/mcp-call-meta.d.ts +2 -2
- package/dist/core/mcp-call-meta.js +9 -10
- package/dist/core/mcp-failure.d.ts +9 -3
- package/dist/core/mcp-failure.js +10 -0
- package/dist/core/mcp-host-seat.d.ts +92 -0
- package/dist/core/mcp-host-seat.js +131 -0
- package/dist/core/mcp-probe.d.ts +7 -2
- package/dist/core/mcp-probe.js +7 -2
- package/dist/core/mcp-server-spec.d.ts +38 -9
- package/dist/core/mcp-server-spec.js +55 -21
- package/dist/core/mcp.d.ts +17 -6
- package/dist/core/mcp.js +67 -55
- package/dist/core/memory-admission.d.ts +23 -6
- package/dist/core/memory-admission.js +19 -9
- package/dist/core/memory-engine/content-origin.d.ts +13 -0
- package/dist/core/memory-engine/content-origin.js +21 -3
- package/dist/core/memory-engine/index.d.ts +2 -1
- package/dist/core/memory-engine/index.js +2 -1
- package/dist/core/memory-engine/scope-contract.d.ts +13 -3
- package/dist/core/memory-engine/scope-contract.js +2 -2
- package/dist/core/memory-engine/sync-client.d.ts +45 -11
- package/dist/core/memory-engine/sync-client.js +82 -11
- package/dist/core/memory-engine/sync-report.d.ts +103 -0
- package/dist/core/memory-engine/sync-report.js +119 -0
- package/dist/core/memory-engine/sync.d.ts +4 -2
- package/dist/core/mode-policy.d.ts +9 -1
- package/dist/core/mode-policy.js +11 -1
- package/dist/core/model-receipt.d.ts +39 -0
- package/dist/core/model-receipt.js +139 -0
- package/dist/core/mods/agent-stations.d.ts +65 -0
- package/dist/core/mods/agent-stations.js +105 -0
- package/dist/core/mods/kernel/dispatch.d.ts +5 -1
- package/dist/core/mods/kernel/dispatch.js +4 -4
- package/dist/core/mods/kernel/events.d.ts +10 -4
- package/dist/core/mods/kernel/events.js +10 -6
- package/dist/core/mods/kernel/receive.d.ts +5 -0
- package/dist/core/mods/kernel/receive.js +10 -0
- package/dist/core/mods/lifecycle-stations.d.ts +41 -0
- package/dist/core/mods/lifecycle-stations.js +35 -0
- package/dist/core/mods/stations.d.ts +51 -59
- package/dist/core/mods/stations.js +32 -42
- package/dist/core/mods/tool-call.d.ts +10 -4
- package/dist/core/mods/tool-call.js +28 -12
- package/dist/core/mounted-mcp.d.ts +5 -0
- package/dist/core/mounted-mcp.js +2 -2
- package/dist/core/namespaced-rule-name.d.ts +7 -1
- package/dist/core/namespaced-rule-name.js +13 -2
- package/dist/core/oracle-isolation.js +1 -1
- package/dist/core/own-property-receipt.d.ts +3 -0
- package/dist/core/own-property-receipt.js +3 -0
- package/dist/core/park-selfcheck.js +8 -8
- package/dist/core/peer-seat.d.ts +63 -8
- package/dist/core/peer-seat.js +179 -34
- package/dist/core/permission-rule-consent.d.ts +0 -21
- package/dist/core/permission-rule-consent.js +1 -2
- package/dist/core/permission-rule-model.d.ts +4 -2
- package/dist/core/permission-rule-model.js +7 -6
- package/dist/core/protocol-http-auth.d.ts +14 -2
- package/dist/core/protocol-http-auth.js +16 -7
- package/dist/core/read-face-seats.d.ts +7 -5
- package/dist/core/read-face-seats.js +4 -1
- package/dist/core/redaction-marks.d.ts +4 -3
- package/dist/core/redaction-marks.js +2 -2
- package/dist/core/remote-env.d.ts +146 -98
- package/dist/core/remote-env.js +113 -14
- package/dist/core/retention.js +37 -12
- package/dist/core/retired-keys.d.ts +6 -1
- package/dist/core/retired-keys.js +4 -1
- package/dist/core/rewrite-rejudge.d.ts +12 -5
- package/dist/core/rewrite-rejudge.js +9 -5
- package/dist/core/roles.d.ts +37 -3
- package/dist/core/roles.js +126 -78
- package/dist/core/rule-owner.d.ts +3 -0
- package/dist/core/runner/assemble-result.d.ts +0 -5
- package/dist/core/runner/assemble-result.js +0 -1
- package/dist/core/runner/call-hook-stations.d.ts +17 -10
- package/dist/core/runner/call-hook-stations.js +21 -10
- package/dist/core/runner/child-tree.d.ts +7 -8
- package/dist/core/runner/child-tree.js +6 -6
- package/dist/core/runner/classifier-ladder.d.ts +10 -2
- package/dist/core/runner/classifier-ladder.js +39 -8
- package/dist/core/runner/construction-doors.js +5 -0
- package/dist/core/runner/contracts.d.ts +62 -41
- package/dist/core/runner/cross-boundary-lane.d.ts +3 -5
- package/dist/core/runner/cross-boundary-lane.js +11 -2
- package/dist/core/runner/env-capability-census.d.ts +15 -20
- package/dist/core/runner/env-capability-census.js +25 -34
- package/dist/core/runner/file-history-request.d.ts +2 -2
- package/dist/core/runner/file-history-request.js +0 -8
- package/dist/core/runner/gate-exit.d.ts +75 -7
- package/dist/core/runner/gate-exit.js +20 -1
- package/dist/core/runner/git-status-frame.d.ts +5 -2
- package/dist/core/runner/git-status-frame.js +3 -4
- package/dist/core/runner/image.d.ts +7 -2
- package/dist/core/runner/image.js +14 -8
- package/dist/core/runner/inline-image.d.ts +10 -8
- package/dist/core/runner/inline-image.js +11 -9
- package/dist/core/runner/memory-consolidation-driver.js +4 -4
- package/dist/core/runner/permission-rule-lanes.js +1 -1
- package/dist/core/runner/prepare-boundary-parks.d.ts +2 -2
- package/dist/core/runner/prepare-boundary-parks.js +3 -3
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
- package/dist/core/runner/prepare-config-doors.d.ts +6 -1
- package/dist/core/runner/prepare-config-doors.js +14 -9
- package/dist/core/runner/prepare-delegation-surface.d.ts +5 -3
- package/dist/core/runner/prepare-delegation-surface.js +4 -4
- package/dist/core/runner/prepare-file-history.d.ts +10 -12
- package/dist/core/runner/prepare-file-history.js +3 -12
- package/dist/core/runner/prepare-gate-stations.d.ts +4 -3
- package/dist/core/runner/prepare-gate-stations.js +4 -3
- package/dist/core/runner/prepare-hands-readface.d.ts +3 -1
- package/dist/core/runner/prepare-hands-readface.js +15 -7
- package/dist/core/runner/prepare-inherited-gate.d.ts +5 -4
- package/dist/core/runner/prepare-inherited-gate.js +9 -5
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-memory.d.ts +2 -2
- package/dist/core/runner/prepare-memory.js +2 -2
- package/dist/core/runner/prepare-park-ask.d.ts +3 -5
- package/dist/core/runner/prepare-park-ask.js +3 -8
- package/dist/core/runner/prepare-policy-chain.d.ts +5 -4
- package/dist/core/runner/prepare-policy-chain.js +120 -108
- package/dist/core/runner/prepare-project-context.js +8 -5
- package/dist/core/runner/prepare-prompt-inputs.d.ts +4 -1
- package/dist/core/runner/prepare-prompt-inputs.js +3 -2
- package/dist/core/runner/prepare-protocol-tools.d.ts +5 -3
- package/dist/core/runner/prepare-protocol-tools.js +9 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +0 -2
- package/dist/core/runner/prepare-suspend-saga.js +5 -7
- package/dist/core/runner/prepare-task.js +41 -27
- package/dist/core/runner/prepare-turn-wiring.d.ts +2 -0
- package/dist/core/runner/prepare-turn-wiring.js +7 -2
- package/dist/core/runner/prepare-wiring-manifest.d.ts +4 -3
- package/dist/core/runner/prepare-wiring-manifest.js +32 -18
- package/dist/core/runner/prepare-workspace-restore.js +3 -3
- package/dist/core/runner/resume-checkpoint-screen.js +4 -4
- package/dist/core/runner/retired-runner-deps.js +4 -1
- package/dist/core/runner/run-attachment-seats.js +3 -3
- package/dist/core/runner/run-brain-sinks.js +1 -0
- package/dist/core/runner/run-git-lane.d.ts +3 -1
- package/dist/core/runner/run-git-lane.js +1 -1
- package/dist/core/runner/run-harness-handlers.d.ts +3 -1
- package/dist/core/runner/run-harness-handlers.js +3 -1
- package/dist/core/runner/run-identity-wiring.js +1 -1
- package/dist/core/runner/run-leg.js +26 -28
- package/dist/core/runner/run-notification-lane.d.ts +3 -1
- package/dist/core/runner/run-notification-lane.js +16 -10
- package/dist/core/runner/run-settle-and-teardown.js +5 -1
- package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
- package/dist/core/runner/run-stop-and-final-verify.js +12 -4
- package/dist/core/runner/run-turn-boundary.js +12 -7
- package/dist/core/runner/runtask.d.ts +7 -4
- package/dist/core/runner/runtask.js +19 -11
- package/dist/core/runner/skills-seat.js +2 -2
- package/dist/core/runner/sub-agent-deny-lists.js +10 -7
- package/dist/core/runner/synthetic-tools.js +2 -2
- package/dist/core/runner/tool-disclosure.js +0 -2
- package/dist/core/runner/tool-face-overlay.d.ts +1 -1
- package/dist/core/runner/tool-face-overlay.js +26 -19
- package/dist/core/runner/tool-result-media-seat.d.ts +9 -1
- package/dist/core/runner/tool-result-media-seat.js +17 -1
- package/dist/core/runner/turn-attachments.d.ts +3 -5
- package/dist/core/runner/turn-attachments.js +3 -16
- package/dist/core/runner-deps.d.ts +31 -18
- package/dist/core/secret-env.d.ts +3 -2
- package/dist/core/session-policy-store.d.ts +9 -2
- package/dist/core/session-policy-store.js +16 -1
- package/dist/core/session-store.d.ts +3 -2
- package/dist/core/session-store.js +50 -11
- package/dist/core/skill-grant.d.ts +9 -0
- package/dist/core/skill-grant.js +18 -0
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/tool-result-store-contract.js +37 -0
- package/dist/core/stub-env.d.ts +5 -5
- package/dist/core/stub-env.js +11 -1
- package/dist/core/swappable-deps.d.ts +17 -43
- package/dist/core/swappable-deps.js +15 -5
- package/dist/core/synthetic-read-verdict.d.ts +1 -1
- package/dist/core/task-event.d.ts +18 -2
- package/dist/core/task-notification.d.ts +88 -5
- package/dist/core/task-notification.js +130 -7
- package/dist/core/task-registry-agent.d.ts +18 -12
- package/dist/core/task-registry-agent.js +18 -6
- package/dist/core/task-registry-monitor.d.ts +7 -0
- package/dist/core/task-registry-monitor.js +28 -1
- package/dist/core/task-registry-shared.d.ts +38 -3
- package/dist/core/task-registry-shared.js +21 -7
- package/dist/core/task-registry-workflow.js +1 -1
- package/dist/core/task-registry.d.ts +50 -35
- package/dist/core/task-registry.js +64 -23
- package/dist/core/task-result.d.ts +3 -12
- package/dist/core/task-spec.d.ts +3 -6
- package/dist/core/task-stream.d.ts +1 -1
- package/dist/core/tool-catalog-entries.js +1 -1
- package/dist/core/tool-face-reader.d.ts +7 -6
- package/dist/core/tool-face-reader.js +4 -3
- package/dist/core/tool-name-aliases.d.ts +19 -0
- package/dist/core/tool-name-aliases.js +54 -2
- package/dist/core/tool-policy.d.ts +5 -4
- package/dist/core/tool-policy.js +1 -1
- package/dist/core/tool-registry.d.ts +5 -5
- package/dist/core/tool-registry.js +2 -2
- package/dist/core/tool-result-store.d.ts +88 -5
- package/dist/core/tool-result-store.js +51 -12
- package/dist/core/tool-spec.d.ts +20 -4
- package/dist/core/trace.d.ts +0 -1
- package/dist/core/types.d.ts +3 -3
- package/dist/core/types.js +1 -1
- package/dist/core/untrusted-text.js +1 -1
- package/dist/core/user-attachment.d.ts +10 -5
- package/dist/core/user-attachment.js +14 -6
- package/dist/engine/execution-env/node-execution-env.d.ts +7 -2
- package/dist/engine/execution-env/node-execution-env.js +12 -1
- package/dist/engine/harness/agent-harness.d.ts +1 -1
- package/dist/engine/harness/agent-harness.js +8 -4
- package/dist/engine/harness/types.d.ts +112 -29
- package/dist/engine/loop/agent-loop.d.ts +12 -12
- package/dist/engine/loop/agent-loop.js +153 -21
- package/dist/engine/loop/types.d.ts +9 -2
- package/dist/engine/lsp/node-lsp-manager.d.ts +3 -3
- package/dist/engine/lsp/node-lsp-manager.js +32 -13
- package/dist/index.d.ts +22 -14
- package/dist/index.js +15 -10
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/orchestration/run-workflow-tool.d.ts +9 -3
- package/dist/orchestration/run-workflow-tool.js +59 -29
- package/dist/orchestration/workflow-governance.d.ts +1 -1
- package/dist/orchestration/workflow-governance.js +2 -1
- package/dist/orchestration/workflow.d.ts +4 -0
- package/dist/orchestration/workflow.js +25 -4
- package/dist/prompts/default.d.ts +1 -10
- package/dist/prompts/default.js +0 -2
- package/dist/stores/file/background-agent-store.d.ts +1 -1
- package/dist/stores/file/background-agent-store.js +3 -1
- package/dist/stores/file/checkpoint-store.d.ts +127 -2
- package/dist/stores/file/checkpoint-store.js +19 -14
- package/dist/stores/file/file-history-store.d.ts +1 -1
- package/dist/stores/file/file-history-store.js +3 -1
- package/dist/stores/file/index.d.ts +4 -3
- package/dist/stores/file/index.js +17 -8
- package/dist/stores/file/mailbox-store.d.ts +1 -1
- package/dist/stores/file/mailbox-store.js +3 -1
- package/dist/stores/file/memory-store.d.ts +1 -1
- package/dist/stores/file/memory-store.js +3 -1
- package/dist/stores/file/session-policy-store.d.ts +1 -1
- package/dist/stores/file/session-policy-store.js +3 -1
- package/dist/stores/file/session-store.d.ts +1 -1
- package/dist/stores/file/session-store.js +3 -1
- package/dist/stores/file/shared-ledger.d.ts +26 -0
- package/dist/stores/file/shared-ledger.js +38 -9
- package/dist/stores/file/tool-result-store.d.ts +20 -2
- package/dist/stores/file/tool-result-store.js +74 -6
- package/dist/stores/file/usage-window-store.d.ts +1 -1
- package/dist/stores/file/usage-window-store.js +3 -1
- package/dist/stores/file/workflow-journal-store.d.ts +1 -11
- package/dist/stores/file/workflow-journal-store.js +3 -2
- package/dist/tools/fs/containment-face.d.ts +5 -0
- package/dist/tools/fs/encoding.d.ts +13 -4
- package/dist/tools/fs/encoding.js +17 -2
- package/dist/tools/fs/fs-bash-background-text.d.ts +7 -0
- package/dist/tools/fs/fs-bash-background-text.js +1 -0
- package/dist/tools/fs/fs-bash.d.ts +8 -4
- package/dist/tools/fs/fs-bash.js +26 -35
- package/dist/tools/fs/fs-pdf.d.ts +2 -2
- package/dist/tools/fs/fs-pdf.js +26 -21
- package/dist/tools/fs/fs-read.d.ts +5 -4
- package/dist/tools/fs/fs-read.js +35 -18
- package/dist/tools/fs/fs-search-tools.js +4 -1
- package/dist/tools/fs/fs-shared.d.ts +11 -13
- package/dist/tools/fs/fs-shared.js +11 -7
- package/dist/tools/fs/fs-write.js +5 -5
- package/dist/tools/fs/index.d.ts +14 -8
- package/dist/tools/fs/index.js +8 -4
- package/dist/tools/fs/read-floor.d.ts +44 -1
- package/dist/tools/fs/read-floor.js +35 -0
- package/dist/tools/fs/removal-targets.d.ts +9 -4
- package/dist/tools/fs/removal-targets.js +17 -9
- package/dist/tools/fs/search.d.ts +3 -3
- package/dist/tools/fs/search.js +4 -4
- package/dist/tools/monitor.d.ts +5 -4
- package/dist/tools/monitor.js +15 -8
- package/dist/tools/scheduler-tools.js +42 -4
- package/dist/tools/web.d.ts +0 -10
- package/dist/tools/web.js +1 -4
- package/package.json +4 -2
- package/test/export-surface.snapshot.json +75 -21
- package/wire-changes/core-stores-sql@7.60.0.json +30 -0
- package/wire-changes/core@7.60.0.json +3274 -0
- package/wire-changes/mods-kernel@7.60.0.json +62 -0
- package/wire-changes/primitives@7.60.0.json +30 -0
|
@@ -4,7 +4,7 @@ import { defineTool, errorResult } from "../../core/tools.js";
|
|
|
4
4
|
import { sha256, resolveKey, violationText, violationDetails, requireRead, checkStale, checkEditMatch, checkNoChange, resolveQuoteMatch, adaptNewStringQuotes, resolveEscapeMatch, adaptNewStringEscapes, escapeMatchWasAttempted, ESCAPE_MATCH_MISS_NOTE, deletionOldString, countOccurrences, READ_REFUSED_ESCAPE_HINT, } from "./safety.js";
|
|
5
5
|
import { decodeTextBytes, encodeTextForFile, normalizeEditText, normalizeFileText } from "./encoding.js";
|
|
6
6
|
import { seatForCall } from "./read-deny.js";
|
|
7
|
-
import { MAX_EDIT_BYTES, decodeEditBytes, tooLargeToEditMessage,
|
|
7
|
+
import { MAX_EDIT_BYTES, decodeEditBytes, tooLargeToEditMessage, malformedBodyMessage, persistedTextOf, notReadRefusalText, enoentMessage, FILE_STATE_TRAILER, FILE_PATH_PARAMS, coerceWriteArguments, ipynbRedirect, countLines, applyRecordedEdit, } from "./fs-shared.js";
|
|
8
8
|
import { toolFace } from "../../core/tool-catalog-entries.js";
|
|
9
9
|
import { fileArgPath } from "../../core/tool-registry.js";
|
|
10
10
|
import { thrownText } from "../../core/thrown-value.js";
|
|
@@ -209,7 +209,7 @@ export function createEditFileTool(env, state, rootCanonical, cwdRef, additional
|
|
|
209
209
|
return errorResult(preDecResult.message);
|
|
210
210
|
const preDec = preDecResult.value;
|
|
211
211
|
if (preDec.malformed)
|
|
212
|
-
return errorResult(
|
|
212
|
+
return errorResult(malformedBodyMessage("Edit", path, preDec.malformed));
|
|
213
213
|
if (preDec.text.trim() !== "")
|
|
214
214
|
return errorResult(`Error (Edit): Cannot create new file - file already exists.`);
|
|
215
215
|
const priorRead = state.get(r.key);
|
|
@@ -255,7 +255,7 @@ export function createEditFileTool(env, state, rootCanonical, cwdRef, additional
|
|
|
255
255
|
return errorResult(decodedResult.message);
|
|
256
256
|
const decoded = decodedResult.value;
|
|
257
257
|
if (decoded.malformed)
|
|
258
|
-
return errorResult(
|
|
258
|
+
return errorResult(malformedBodyMessage("Edit", path, decoded.malformed));
|
|
259
259
|
const original = decoded.text;
|
|
260
260
|
const entry = state.get(r.key);
|
|
261
261
|
const readWasTruncated = entry?.truncated === true;
|
|
@@ -383,7 +383,7 @@ export function createWriteFileTool(env, state, rootCanonical, cwdRef, additiona
|
|
|
383
383
|
return errorResult(`Error (Write): cannot re-read "${path}" to verify it is unchanged: ${readBin.error.message}`);
|
|
384
384
|
const decodedPrev = decodeTextBytes(readBin.value);
|
|
385
385
|
if (decodedPrev.malformed)
|
|
386
|
-
return errorResult(
|
|
386
|
+
return errorResult(malformedBodyMessage("Write", path, decodedPrev.malformed));
|
|
387
387
|
const stale = checkStale(state.get(r.key), sha256(decodedPrev.text));
|
|
388
388
|
if (stale)
|
|
389
389
|
return errorResult(violationText("Write", stale));
|
|
@@ -494,7 +494,7 @@ export function createNotebookEditTool(env, state, rootCanonical, cwdRef, additi
|
|
|
494
494
|
return errorResult(`Error (NotebookEdit): cannot read "${notebook_path}": ${readBin.error.message}`);
|
|
495
495
|
const decodedNb = decodeTextBytes(readBin.value);
|
|
496
496
|
if (decodedNb.malformed)
|
|
497
|
-
return errorResult(
|
|
497
|
+
return errorResult(malformedBodyMessage("NotebookEdit", notebook_path, decodedNb.malformed));
|
|
498
498
|
const nbText = decodedNb.text;
|
|
499
499
|
const stale = checkStale(state.get(r.key), sha256(nbText));
|
|
500
500
|
if (stale)
|
package/dist/tools/fs/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export { BASH_CLASSIFY_EXTRA_ALLOW, bashClassifyDefaultAllow } from "./bash-read
|
|
|
17
17
|
import { type ReadDenyEntry } from "./read-deny.js";
|
|
18
18
|
import { type ContainmentFace } from "./containment-face.js";
|
|
19
19
|
export * from "./containment-face.js";
|
|
20
|
-
import { type CwdRef
|
|
20
|
+
import { type CwdRef } from "./fs-shared.js";
|
|
21
21
|
/** Options for {@link createHandsToolkit}. */
|
|
22
22
|
export interface HandsToolkitOptions {
|
|
23
23
|
/** CC --add-dir parity: extra allowed containment roots (canonical). Widens file-tool containment
|
|
@@ -113,10 +113,9 @@ export interface HandsToolkitOptions {
|
|
|
113
113
|
* console line prints verbatim (last-resort loudness). Threaded per toolkit build — never a
|
|
114
114
|
* global. */
|
|
115
115
|
onNotice?: (n: import("../../core/types.js").EngineNotice) => void;
|
|
116
|
-
/** See createBashTool's taskOpts.oneShot
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* `mountBackgroundTaskTools: true`) the TaskOutput poll receipt. Absent ⇒ the unbranched wording. */
|
|
116
|
+
/** See createBashTool's taskOpts.oneShot for the full contract: this run has no later turn for an async background
|
|
117
|
+
* notification to land in, and its ending waits for loop-type tasks only — threaded to the Bash background-launch
|
|
118
|
+
* receipt. Absent ⇒ the unbranched wording. */
|
|
120
119
|
oneShot?: boolean;
|
|
121
120
|
/** CC `Zry`/`WZi.#m` parity: see createBashTool's taskOpts field of the same name for the full
|
|
122
121
|
* contract. Threaded from {@link HandsBandOptions.autoBackgroundOnTimeout} (a deployment-level
|
|
@@ -132,9 +131,10 @@ export interface HandsToolkitOptions {
|
|
|
132
131
|
* of the same name. Runner-wired (reads the harness's own accepted-but-unserved account); absent ⇒ the
|
|
133
132
|
* shell never auto-backgrounds a running command, exactly as before. */
|
|
134
133
|
queuedHumanInput?: () => boolean;
|
|
135
|
-
/**
|
|
136
|
-
*
|
|
137
|
-
|
|
134
|
+
/** The run's image processor seat (`RunnerDeps.imageProcessor`), for every image this band hands the model (Read, a
|
|
135
|
+
* rendered PDF page, a Bash data URI): a processor; `false` = none (deterministic no-sharp behavior); undefined =
|
|
136
|
+
* auto-detect the optional sharp dependency once per process. */
|
|
137
|
+
imageProcessor?: import("../../core/image-downsample.js").ImageDownsampler | false;
|
|
138
138
|
/** PDF degradation chain: the SERVING model's PDF capability profile (prepare-task derives it via
|
|
139
139
|
* {@link import("./fs-pdf.js").pdfModelCapabilitiesOf}). A model without native document input gets pdftotext text extraction →
|
|
140
140
|
* rendered page images (vision) → an honest placeholder, instead of a brain-level placeholder. Default
|
|
@@ -180,6 +180,12 @@ export interface HandsToolkitOptions {
|
|
|
180
180
|
* of an inactive tier is a satisfied intent (no-op); a name matching NO table row throws at wiring
|
|
181
181
|
* time (never silently ignored). Deployment seat ONLY, same clamp argument as the tiers key. */
|
|
182
182
|
readDenyBuiltinExclude?: readonly string[];
|
|
183
|
+
/** Mirror of `RunnerDeps.readDenyFloorRequired`, for a band that compiles its OWN table (no Runner face carried):
|
|
184
|
+
* `true` ⇒ building the band throws `config.read_deny_floor_unkept` when that table holds a row and `env` does not
|
|
185
|
+
* declare it keeps the byte floor; absent / `false` ⇒ the same fact is announced once per construction through
|
|
186
|
+
* {@link onNotice}. A non-boolean value throws (`config.read_face_seat`). A band handed the Runner's face judges
|
|
187
|
+
* nothing: the Runner judged that table when it compiled it. */
|
|
188
|
+
readDenyFloorRequired?: boolean;
|
|
183
189
|
/** The spellings of the execution environment's home a home-anchored deny row (`~/…`) is placed under
|
|
184
190
|
* ({@link import("./read-deny-home.js").readDenyHomesOf}: the declared home and the account home, each with its canonical
|
|
185
191
|
* spelling). Absolute path strings only — any other shape throws at wiring time, naming the seat. The Runner passes the
|
package/dist/tools/fs/index.js
CHANGED
|
@@ -17,7 +17,7 @@ export { BASH_CLASSIFY_EXTRA_ALLOW, bashClassifyDefaultAllow } from "./bash-read
|
|
|
17
17
|
import { checkedReadDenyHomes, compileReadDeny, compileWriteDeny, readDenyBuiltinConfigOf, readDenyRowAnchor } from "./read-deny.js";
|
|
18
18
|
import { withGateTimeout } from "../../core/gate-bounded-await.js";
|
|
19
19
|
import { carriedReadFaceOf, carryHomeViews, homeViewsAt, placeReadDenyAtHome, placementViewsOf, readDenyPlacedLater, sayPlacementLost } from "./read-deny-home.js";
|
|
20
|
-
import { readFloorSeat } from "./read-floor.js";
|
|
20
|
+
import { judgeReadFloorKept, readFloorSeat, screenReadDenyFloorRequired } from "./read-floor.js";
|
|
21
21
|
import { deploymentFaceClampNotice, resolveContainmentFace } from "./containment-face.js";
|
|
22
22
|
export * from "./containment-face.js";
|
|
23
23
|
import {} from "./fs-shared.js";
|
|
@@ -45,6 +45,9 @@ export function createHandsToolkit(env, readFileState, rootCanonical, opts = {})
|
|
|
45
45
|
: (canonicalKey, c) => readAdmission?.(c.toolCallId, canonicalKey) === true || (bgOutput?.(canonicalKey, c) ?? false);
|
|
46
46
|
const { readDeny, writeDeny, afterPlacement } = carriedFace !== undefined ? { readDeny: carriedFace.readDeny, writeDeny: carriedFace.writeDeny, afterPlacement: (tool) => tool } : bandOwnTables(env, opts);
|
|
47
47
|
const readFloor = readFloorSeat(readDeny);
|
|
48
|
+
const floorRequired = screenReadDenyFloorRequired(opts.readDenyFloorRequired, "HandsToolkitOptions.readDenyFloorRequired") === true;
|
|
49
|
+
if (carriedFace === undefined)
|
|
50
|
+
judgeReadFloorKept({ env, table: readDeny, floor: readFloor?.(undefined), required: floorRequired, onNotice: opts.onNotice });
|
|
48
51
|
const readFace = resolveContainmentFace({
|
|
49
52
|
kind: "read",
|
|
50
53
|
depsFace: opts.readFace,
|
|
@@ -69,7 +72,7 @@ export function createHandsToolkit(env, readFileState, rootCanonical, opts = {})
|
|
|
69
72
|
rootCanonical,
|
|
70
73
|
...(readCwd !== undefined ? { cwdRef: readCwd } : {}),
|
|
71
74
|
...(readFaceRoots !== undefined ? { additionalRoots: readFaceRoots } : {}),
|
|
72
|
-
|
|
75
|
+
imageProcessor: opts.imageProcessor,
|
|
73
76
|
...(opts.pdfModelCapabilities !== undefined ? { pdfCapabilities: opts.pdfModelCapabilities } : {}),
|
|
74
77
|
...(bgOutputReadExemption !== undefined ? { bgOutputReadExemption } : {}),
|
|
75
78
|
...(readDeny !== undefined ? { readDeny } : {}),
|
|
@@ -80,7 +83,7 @@ export function createHandsToolkit(env, readFileState, rootCanonical, opts = {})
|
|
|
80
83
|
if (opts.modelFileReaderSeat !== undefined)
|
|
81
84
|
opts.modelFileReaderSeat.current = reader;
|
|
82
85
|
const tools = [
|
|
83
|
-
afterPlacement(createReadFileTool(env, readFileState, rootCanonical, readCwd, readFaceRoots, opts.
|
|
86
|
+
afterPlacement(createReadFileTool(env, readFileState, rootCanonical, readCwd, readFaceRoots, opts.imageProcessor, opts.pdfModelCapabilities, bgOutputReadExemption, readDeny, readFace, opts.reminderMark, opts.reminderDisclosureCounts, reader)),
|
|
84
87
|
];
|
|
85
88
|
if (handsWriteHalfMounts({ readOnly })) {
|
|
86
89
|
tools.push(createEditFileTool(env, readFileState, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny), createWriteFileTool(env, readFileState, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny), createNotebookEditTool(env, readFileState, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny));
|
|
@@ -94,6 +97,7 @@ export function createHandsToolkit(env, readFileState, rootCanonical, opts = {})
|
|
|
94
97
|
...(opts.onNotice !== undefined ? { onNotice: opts.onNotice } : {}),
|
|
95
98
|
...(opts.shellReadAdmission !== undefined ? { shellReadAdmission: opts.shellReadAdmission } : {}),
|
|
96
99
|
...(readFloor !== undefined ? { readFloor } : {}),
|
|
100
|
+
...(opts.imageProcessor !== undefined ? { imageProcessor: opts.imageProcessor } : {}),
|
|
97
101
|
...(opts.onToolProgress !== undefined ? { onToolProgress: opts.onToolProgress } : {}),
|
|
98
102
|
})
|
|
99
103
|
: createBashTool(env, rootCanonical, commitCoAuthor, cwdRef, {
|
|
@@ -111,6 +115,7 @@ export function createHandsToolkit(env, readFileState, rootCanonical, opts = {})
|
|
|
111
115
|
...(additionalRoots !== undefined ? { additionalRoots } : {}),
|
|
112
116
|
...(opts.shellReadAdmission !== undefined ? { shellReadAdmission: opts.shellReadAdmission } : {}),
|
|
113
117
|
...(readFloor !== undefined ? { readFloor } : {}),
|
|
118
|
+
...(opts.imageProcessor !== undefined ? { imageProcessor: opts.imageProcessor } : {}),
|
|
114
119
|
...(opts.bashDefaultTimeoutMs !== undefined ? { bashDefaultTimeoutMs: opts.bashDefaultTimeoutMs } : {}),
|
|
115
120
|
...(opts.bashMaxTimeoutMs !== undefined ? { bashMaxTimeoutMs: opts.bashMaxTimeoutMs } : {}),
|
|
116
121
|
...(opts.onNotice !== undefined ? { onNotice: opts.onNotice } : {}),
|
|
@@ -125,7 +130,6 @@ export function createHandsToolkit(env, readFileState, rootCanonical, opts = {})
|
|
|
125
130
|
owner: opts.taskOwner,
|
|
126
131
|
scope: opts.taskScope,
|
|
127
132
|
...sessionAxis,
|
|
128
|
-
...(opts.oneShot !== undefined ? { oneShot: opts.oneShot } : {}),
|
|
129
133
|
notificationWired: opts.taskNotification !== undefined,
|
|
130
134
|
})
|
|
131
135
|
: createEnvTaskOutputTool(env), opts.taskRegistry
|
|
@@ -7,8 +7,13 @@
|
|
|
7
7
|
* OPENS. Both read the same rows through the same judgment: this module derives nothing — the rows are the ones the
|
|
8
8
|
* engine's refusals cite (`readDenySeat`) and the judgment is the table's own `matchPath`, read off the table the call
|
|
9
9
|
* is pinned to (`seatForCall`). A floor never loosens the station: what the station refuses never starts.
|
|
10
|
+
*
|
|
11
|
+
* Whether the environment KEEPS the floor is its declaration (`capabilities.keepsReadFloor`), judged once per table
|
|
12
|
+
* owner by {@link judgeReadFloorKept}: a non-empty table on an environment that does not keep it is announced, or
|
|
13
|
+
* refused when the deployment requires the floor.
|
|
10
14
|
*/
|
|
11
|
-
import type { ReadFloor } from "../../internal/harness-types.js";
|
|
15
|
+
import type { ExecutionEnv, ReadFloor } from "../../internal/harness-types.js";
|
|
16
|
+
import { type EngineNotice } from "../../core/engine-notice.js";
|
|
12
17
|
import { type ReadDenyMatcher } from "./read-deny.js";
|
|
13
18
|
/** The floor ONE call's command start carries, read off the table that call judges with — `undefined` when the table
|
|
14
19
|
* holds no row (an empty table keeps nothing, and the start then carries no floor: the options are the ones a start
|
|
@@ -17,3 +22,41 @@ export type ReadFloorSeat = (toolCallId: string | undefined) => ReadFloor | unde
|
|
|
17
22
|
/** The seat over a face's deny table (the run's, or a library-direct band's own); `undefined` for no table. Built once per
|
|
18
23
|
* mount; each call reads its own pinned table through it. */
|
|
19
24
|
export declare function readFloorSeat(table: ReadDenyMatcher | undefined): ReadFloorSeat | undefined;
|
|
25
|
+
/** The value gate of the floor requirement (`RunnerDeps.readDenyFloorRequired`, mirrored on `HandsToolkitOptions`), the one
|
|
26
|
+
* gate of every door that admits it: a boolean, or absent (`undefined`, read as "not required"); anything else refuses
|
|
27
|
+
* (`config.read_face_seat`), because a requirement that cannot be read is no requirement and must not read as one side. */
|
|
28
|
+
export declare function screenReadDenyFloorRequired(value: unknown, seat: string): boolean | undefined;
|
|
29
|
+
/** The code a non-empty read-deny table on an environment that does not keep the byte floor carries: the operator's notice,
|
|
30
|
+
* and the prepare refusal when the deployment requires the floor — one fact, one word, two loudness dialects. */
|
|
31
|
+
export declare const READ_DENY_FLOOR_UNKEPT = "config.read_deny_floor_unkept";
|
|
32
|
+
/** What {@link judgeReadFloorKept} is handed: the table's owner states the environment, its table, the floor its own engine
|
|
33
|
+
* starts carry off that table (the base table's), and whether the deployment requires the floor. */
|
|
34
|
+
export interface ReadFloorJudgment {
|
|
35
|
+
readonly env: Pick<ExecutionEnv, "capabilities">;
|
|
36
|
+
readonly table: ReadDenyMatcher | undefined;
|
|
37
|
+
readonly floor: ReadFloor | undefined;
|
|
38
|
+
readonly required: boolean;
|
|
39
|
+
readonly onNotice: ((notice: EngineNotice) => void) | undefined;
|
|
40
|
+
/** The run the judgment is for, carried on the notice (a library-direct band has none). */
|
|
41
|
+
readonly attribution?: {
|
|
42
|
+
readonly sessionId?: string;
|
|
43
|
+
readonly runId?: string;
|
|
44
|
+
};
|
|
45
|
+
/** The owner's once-latch when it judges more than one table (a run: every table it compiles): the notice is said the
|
|
46
|
+
* first time and never again for that owner; a refusal is never latched. Absent ⇒ every judgment may say it. */
|
|
47
|
+
readonly said?: {
|
|
48
|
+
done: boolean;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The ONE judgment of whether a table owner's byte floor is kept, taken where the table is compiled: the Runner's prepare
|
|
53
|
+
* for a run (each delegated child on its own environment), a library-direct hand band for the table it compiles itself —
|
|
54
|
+
* never a band handed the Runner's face. Judged on the table's AUTHORITATIVE row count, the rows its refusals cite:
|
|
55
|
+
* · no row ⇒ nothing to keep, no judgment;
|
|
56
|
+
* · rows, and no floor for the owner's engine starts to carry ⇒ an engine defect, refused loudly (the starts would run with
|
|
57
|
+
* fewer rows than the table holds);
|
|
58
|
+
* · rows, on an environment that declares it keeps the floor ⇒ nothing to say;
|
|
59
|
+
* · rows, on one that does not: `required` ⇒ refused with {@link READ_DENY_FLOOR_UNKEPT}; otherwise that word once, to the
|
|
60
|
+
* operator — a recursive read under a root still reads the rows below it there, so the notice is no protection.
|
|
61
|
+
*/
|
|
62
|
+
export declare function judgeReadFloorKept(j: ReadFloorJudgment): void;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { deliverEngineNotice } from "../../core/engine-notice.js";
|
|
2
|
+
import { keepsReadFloor } from "../../core/remote-env.js";
|
|
1
3
|
import { readDenySeat, seatForCall } from "./read-deny.js";
|
|
2
4
|
import { isAbsoluteForFamily } from "./safety.js";
|
|
3
5
|
export function readFloorSeat(table) {
|
|
@@ -21,3 +23,36 @@ function readFloorOf(table) {
|
|
|
21
23
|
};
|
|
22
24
|
return Object.freeze({ rows, denies });
|
|
23
25
|
}
|
|
26
|
+
export function screenReadDenyFloorRequired(value, seat) {
|
|
27
|
+
if (value === undefined || typeof value === "boolean")
|
|
28
|
+
return value;
|
|
29
|
+
const e = new Error(`${seat} must be a boolean or absent (got ${value === null ? "null" : typeof value}) — a requirement that cannot be read is no requirement, so it refuses loudly instead of reading as one side.`);
|
|
30
|
+
e.code = "config.read_face_seat";
|
|
31
|
+
throw e;
|
|
32
|
+
}
|
|
33
|
+
export const READ_DENY_FLOOR_UNKEPT = "config.read_deny_floor_unkept";
|
|
34
|
+
export function judgeReadFloorKept(j) {
|
|
35
|
+
const rowCount = j.table === undefined ? 0 : readDenySeat(j.table).denyEntries.length;
|
|
36
|
+
if (rowCount === 0)
|
|
37
|
+
return;
|
|
38
|
+
if (j.floor === undefined || j.floor.rows.length !== rowCount) {
|
|
39
|
+
throw new Error(`the read-deny table holds ${rowCount} row(s) but the floor its engine starts would carry holds ${j.floor?.rows.length ?? 0} — refused rather than start commands with fewer rows than the table refuses (an engine defect).`);
|
|
40
|
+
}
|
|
41
|
+
if (keepsReadFloor(j.env))
|
|
42
|
+
return;
|
|
43
|
+
if (j.required) {
|
|
44
|
+
const e = new Error(`The run's read-deny table holds ${rowCount} row(s), and the execution environment does not declare that it keeps the byte floor (capabilities.keepsReadFloor is not true), while the deployment requires the floor (readDenyFloorRequired) — refused before any command starts. Run it on an environment that keeps the floor, or unset the requirement.`);
|
|
45
|
+
e.code = READ_DENY_FLOOR_UNKEPT;
|
|
46
|
+
throw e;
|
|
47
|
+
}
|
|
48
|
+
if (j.said !== undefined) {
|
|
49
|
+
if (j.said.done)
|
|
50
|
+
return;
|
|
51
|
+
j.said.done = true;
|
|
52
|
+
}
|
|
53
|
+
deliverEngineNotice(j.onNotice, {
|
|
54
|
+
code: READ_DENY_FLOOR_UNKEPT,
|
|
55
|
+
message: `The run's read-deny table holds ${rowCount} row(s), and the execution environment does not declare that it keeps the byte floor (capabilities.keepsReadFloor is not true): the engine refuses what a command names, but a recursive read under a root reads the files below it on this environment, deny rows included, and their bytes reach the conversation. To refuse such runs instead, set readDenyFloorRequired.`,
|
|
56
|
+
detail: { rowCount, ...(j.attribution?.sessionId !== undefined ? { sessionId: j.attribution.sessionId } : {}), ...(j.attribution?.runId !== undefined ? { runId: j.attribution.runId } : {}) },
|
|
57
|
+
});
|
|
58
|
+
}
|
|
@@ -7,7 +7,7 @@ import type { ToolCallRequest } from "../../core/tool-policy.js";
|
|
|
7
7
|
export declare const SHELL_REMOVAL_COMMANDS: readonly ["rm", "rmdir"];
|
|
8
8
|
export type ShellRemovalCommand = (typeof SHELL_REMOVAL_COMMANDS)[number];
|
|
9
9
|
/** What makes a removal target dangerous, in the order a card names it. */
|
|
10
|
-
export type DangerousRemovalKind = "filesystem_root" | "home" | "workspace" | "top_level";
|
|
10
|
+
export type DangerousRemovalKind = "filesystem_root" | "home" | "workspace" | "top_level" | "mounted_drive";
|
|
11
11
|
/** The protected locations a removal is judged against. `homes`: the environment's declared home and every other spelling
|
|
12
12
|
* of it (its canonical one); `workspace`: the task root, the working directory, the additional working directories. */
|
|
13
13
|
export interface RemovalSeat {
|
|
@@ -26,9 +26,14 @@ export interface DangerousRemoval {
|
|
|
26
26
|
* implementation's set — the filesystem root (a drive root, a UNC share root), a home directory
|
|
27
27
|
* (every spelling the seat holds), a workspace directory or any of its ANCESTORS (the task root, the working directory, an
|
|
28
28
|
* additional working directory — whether the home lies inside the task root or the task root inside the home), a top-level
|
|
29
|
-
* directory (one segment below the root)
|
|
29
|
+
* directory (one segment below the root) — and, for an `rm` that walks what it removes (`rm`: present; `recursive`: it
|
|
30
|
+
* selects a recursive option; or the path names every entry of a directory), a mounted drive ({@link MOUNTED_DRIVE_KEY}):
|
|
31
|
+
* the folder that holds drives, a drive, or an entry at a drive's top level. `undefined` for a relative path or any other
|
|
32
|
+
* target.
|
|
30
33
|
*/
|
|
31
|
-
export declare function dangerousRemovalOf(path: string, seat: RemovalSeat
|
|
34
|
+
export declare function dangerousRemovalOf(path: string, seat: RemovalSeat, rm?: {
|
|
35
|
+
readonly recursive: boolean;
|
|
36
|
+
}): DangerousRemovalKind | undefined;
|
|
32
37
|
/** What one removal finding asks: a protected location (`dangerous_delete`; `untrackedFrom` — the segment the working
|
|
33
38
|
* directory stops being tracked at, where the target is relative and was judged where the text stood then); a recursive
|
|
34
39
|
* forced removal whose target the
|
|
@@ -68,7 +73,7 @@ export declare const KNOWN_SAFE_ROOTS: readonly string[];
|
|
|
68
73
|
* OPERANDS (every write target that is not one of its option words: a word some implementation's reading of the
|
|
69
74
|
* program's row writes, {@link writeReadings}) as the plan established it on the WRITE face (the entry the program
|
|
70
75
|
* unlinks, and the deny-floor shadow of a home word the plan did not place) is judged by {@link dangerousRemovalOf},
|
|
71
|
-
* save one the program refuses by its own first step ({@link refusedByRemoval}: `.`, `..`). In a recursive forced removal ({@link
|
|
76
|
+
* save one the program refuses by its own first step ({@link refusedByRemoval}: `.`, `..`). In a recursive forced removal ({@link selectsOptions}), an operand
|
|
72
77
|
* the shell rewrites from a value the plan's table does not settle — a name with no value here or one set in a form the
|
|
73
78
|
* table cannot read, a substitution, a parameter operator, a positional parameter — is an unverifiable target, save a
|
|
74
79
|
* literal path below a known-safe root the shell still provides there ({@link belowKnownSafeRoot}); so are the operands
|
|
@@ -24,11 +24,14 @@ function removalKey(path) {
|
|
|
24
24
|
function driveOf(path, key) {
|
|
25
25
|
return isWinFormPath(path) && key.length >= 2 && key[1] === ":" ? key.slice(0, 2) : "";
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
const MOUNTED_DRIVE_KEY = /^\/(?:system\/)?volumes(?:\/[^/]+){0,2}$|^\/mnt\/(?:[^/]+|[a-z]\/[^/]+)$|^\/(?:run\/)?media(?:\/[^/]+){0,3}$/;
|
|
28
|
+
const NAMES_EVERY_ENTRY = /(?:[\\/]+\*+)+[\\/]*$/;
|
|
29
|
+
export function dangerousRemovalOf(path, seat, rm) {
|
|
28
30
|
if (!isAbsoluteForFamily("own", path))
|
|
29
31
|
return undefined;
|
|
30
32
|
const k = removalKey(path);
|
|
31
|
-
const
|
|
33
|
+
const drive = driveOf(path, k);
|
|
34
|
+
const rest = k.slice(drive.length);
|
|
32
35
|
if (rest === "/" || /^\/\/[^/]+\/[^/]+$/.test(k))
|
|
33
36
|
return "filesystem_root";
|
|
34
37
|
if (seat.homes.some((h) => isAbsoluteForFamily("own", h) && removalKey(h) === k))
|
|
@@ -38,6 +41,8 @@ export function dangerousRemovalOf(path, seat) {
|
|
|
38
41
|
return "workspace";
|
|
39
42
|
if (/^\/[^/]+$/.test(rest))
|
|
40
43
|
return "top_level";
|
|
44
|
+
if (rm !== undefined && (rm.recursive || NAMES_EVERY_ENTRY.test(path)) && drive === "" && !k.startsWith("//") && MOUNTED_DRIVE_KEY.test(rest))
|
|
45
|
+
return "mounted_drive";
|
|
41
46
|
return undefined;
|
|
42
47
|
}
|
|
43
48
|
function tildeNamesAHome(spelled) {
|
|
@@ -47,10 +52,10 @@ function tildeNamesAHome(spelled) {
|
|
|
47
52
|
const key = removalKey(`/~home${m[2] ?? ""}`);
|
|
48
53
|
return key === "/~home" || !key.startsWith("/~home/");
|
|
49
54
|
}
|
|
50
|
-
function removalKindOf(read, seat) {
|
|
55
|
+
function removalKindOf(read, seat, rm) {
|
|
51
56
|
const floors = read.established === "unestablishable" && read.candidate.bases === "unmodelled" ? read.spellings : [];
|
|
52
57
|
for (const view of [read.target, read.origin, ...floors]) {
|
|
53
|
-
const kind = view === undefined ? undefined : dangerousRemovalOf(view, seat);
|
|
58
|
+
const kind = view === undefined ? undefined : dangerousRemovalOf(view, seat, rm);
|
|
54
59
|
if (kind !== undefined)
|
|
55
60
|
return kind;
|
|
56
61
|
}
|
|
@@ -76,11 +81,12 @@ function optionsReceived(row, args) {
|
|
|
76
81
|
const shellChooses = chosenAt >= 0 && writeReadings(row, present.slice(0, chosenAt + 1).map((w) => w.spelled)).some((r) => r.written.length === 0);
|
|
77
82
|
return { refused: rowRefusesArgv(row, asWritten), shellChooses };
|
|
78
83
|
}
|
|
79
|
-
|
|
84
|
+
const TRAVERSAL = (o) => o.selects === "traversal";
|
|
85
|
+
const FORCED = (o) => o.mode === "forced";
|
|
86
|
+
function selectsOptions(row, args, shellChooses, ...wanted) {
|
|
80
87
|
return implementationsOf(row).some((view) => {
|
|
81
88
|
const selected = selectedOptions(view, args, "one-implementation");
|
|
82
|
-
|
|
83
|
-
return selects((o) => o.selects === "traversal") && selects((o) => o.mode === "forced");
|
|
89
|
+
return wanted.every((has) => selected.some(has) || (shellChooses && declaresOption(view, has)));
|
|
84
90
|
});
|
|
85
91
|
}
|
|
86
92
|
export function removalFindingsOf(established, seat, safeRoots = KNOWN_SAFE_ROOTS, enclosingRelocated = false) {
|
|
@@ -98,7 +104,8 @@ export function removalFindingsOf(established, seat, safeRoots = KNOWN_SAFE_ROOT
|
|
|
98
104
|
const { row, named } = removal;
|
|
99
105
|
const removed = new Set(writeReadings(row, spelled).flatMap((r) => r.written.map((w) => w.at)));
|
|
100
106
|
const options = new Set(args.filter((_, at) => !removed.has(at)).map((w) => w.raw));
|
|
101
|
-
const forced =
|
|
107
|
+
const forced = selectsOptions(row, spelled, received.shellChooses, TRAVERSAL, FORCED);
|
|
108
|
+
const rm = removal.program === "rm" || !named ? { recursive: selectsOptions(row, spelled, received.shellChooses, TRAVERSAL) } : undefined;
|
|
102
109
|
if (forced && segment.reentry === "argv")
|
|
103
110
|
out.push({ guard: "unverifiable_delete", program: removal.program, operand: segment.text.trim(), source: "stream" });
|
|
104
111
|
const relocated = enclosingRelocated || readProgramPosition(segment.argv).launcherMovesBase;
|
|
@@ -107,7 +114,7 @@ export function removalFindingsOf(established, seat, safeRoots = KNOWN_SAFE_ROOT
|
|
|
107
114
|
continue;
|
|
108
115
|
if (refusedByRemoval(read))
|
|
109
116
|
continue;
|
|
110
|
-
const kind = removalKindOf(read, seat);
|
|
117
|
+
const kind = removalKindOf(read, seat, rm);
|
|
111
118
|
if (kind !== undefined) {
|
|
112
119
|
const untracked = read.candidate.bases === "unmodelled" ? established.plan.segments.find((s) => s.bases === "unmodelled")?.text.trim() : undefined;
|
|
113
120
|
out.push({ guard: "dangerous_delete", kind, program: removal.program, operand: read.candidate.raw, target: read.target ?? read.candidate.floorSpelled ?? read.candidate.spelled, ...(untracked !== undefined ? { untrackedFrom: untracked } : {}) });
|
|
@@ -191,6 +198,7 @@ const DANGEROUS_REMOVAL_SENTENCE = {
|
|
|
191
198
|
home: (p, t) => `\`${p}\` would remove a home directory (${t})`,
|
|
192
199
|
workspace: (p, t) => `\`${p}\` would remove a workspace directory — the task root, the working directory or an additional working directory — or one of its ancestors (${t})`,
|
|
193
200
|
top_level: (p, t) => `\`${p}\` would remove a top-level system directory (${t})`,
|
|
201
|
+
mounted_drive: (p, t) => `\`${p}\` would remove a mounted drive, the folder that holds mounted drives, or a file or folder at the top level of a drive (${t}) — if you meant something deeper inside, name it by its full path`,
|
|
194
202
|
};
|
|
195
203
|
const UNVERIFIABLE_REMOVAL_SENTENCE = {
|
|
196
204
|
rewritten: (p, o) => `\`${p}\` recursive+force target ${o} is rewritten by the shell from a value this command does not settle (a name with no value here or one it sets in a form the guard cannot read, a substitution, a parameter operator) — the deleted path cannot be verified from this command`,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExecutionEnv } from "../../internal/harness-types.js";
|
|
1
|
+
import type { ExecutionEnv, ReadFloor } from "../../internal/harness-types.js";
|
|
2
2
|
import { type HomeViewsCarrier } from "./read-deny-home.js";
|
|
3
3
|
import { type FsGlob } from "./fs-glob.js";
|
|
4
4
|
/** The JS scanner's own output ceiling, in bytes of emitted content rows. Pinned to the
|
|
@@ -312,10 +312,10 @@ export declare function rgOutputDenyTripwire(stdout: string, mode: GrepOutputMod
|
|
|
312
312
|
* re-scan — partial results ship with a caveat; only a zero-output failure degrades to
|
|
313
313
|
* {@link jsGrep}, and that degradation is declared in both text and structure. An external abort
|
|
314
314
|
* propagates as the interruption it is (no fallback rerun). */
|
|
315
|
-
export declare function rgGrepDetailed(env: ExecutionEnv, root: string, p: GrepParams, signal?: AbortSignal, deny?: ReadDenyJudge): Promise<GrepRunResult>;
|
|
315
|
+
export declare function rgGrepDetailed(env: ExecutionEnv, root: string, p: GrepParams, signal?: AbortSignal, deny?: ReadDenyJudge, readFloor?: ReadFloor): Promise<GrepRunResult>;
|
|
316
316
|
/** grep dispatch: ripgrep when the env has it, else the hardened JS fallback.
|
|
317
317
|
* Returns the degradation facts alongside the text so the tool layer can surface them structurally. */
|
|
318
|
-
export declare function runGrepDetailed(env: ExecutionEnv, root: string, p: GrepParams, signal?: AbortSignal, deny?: ReadDenyJudge): Promise<GrepRunResult>;
|
|
318
|
+
export declare function runGrepDetailed(env: ExecutionEnv, root: string, p: GrepParams, signal?: AbortSignal, deny?: ReadDenyJudge, readFloor?: ReadFloor): Promise<GrepRunResult>;
|
|
319
319
|
/** Text-only wrapper of {@link runGrepDetailed}. */
|
|
320
320
|
export declare function runGrep(env: ExecutionEnv, root: string, p: GrepParams, signal?: AbortSignal): Promise<string>;
|
|
321
321
|
/** glob: find files by name pattern, with optional sub-path scoping; returns RELATIVE paths. */
|
package/dist/tools/fs/search.js
CHANGED
|
@@ -1174,7 +1174,7 @@ async function jsGrepFallback(env, root, p, signal, reason, deny) {
|
|
|
1174
1174
|
...(denyOut.withheld !== undefined ? { withheld: denyOut.withheld } : {}),
|
|
1175
1175
|
};
|
|
1176
1176
|
}
|
|
1177
|
-
export async function rgGrepDetailed(env, root, p, signal, deny) {
|
|
1177
|
+
export async function rgGrepDetailed(env, root, p, signal, deny, readFloor) {
|
|
1178
1178
|
const mode = p.output_mode ?? "files_with_matches";
|
|
1179
1179
|
const flags = ["--null", "-H", "--no-messages", "--no-require-git", "--hidden"];
|
|
1180
1180
|
for (const d of VCS_DIRS)
|
|
@@ -1209,7 +1209,7 @@ export async function rgGrepDetailed(env, root, p, signal, deny) {
|
|
|
1209
1209
|
flags.push(g.flag, shellQuote(g.glob));
|
|
1210
1210
|
const target = p.path ? shellQuote(p.path) : ".";
|
|
1211
1211
|
const cmd = `rg ${flags.join(" ")} -e ${shellQuote(p.pattern)} -- ${target}`;
|
|
1212
|
-
const res = await env.exec(cmd, { cwd: root, timeout: 60, abortSignal: signal });
|
|
1212
|
+
const res = await env.exec(cmd, { cwd: root, timeout: 60, abortSignal: signal, ...(readFloor !== undefined ? { readFloor } : {}) });
|
|
1213
1213
|
if (!res.ok) {
|
|
1214
1214
|
const err = res.error;
|
|
1215
1215
|
if (err.code === "aborted" || signal?.aborted === true)
|
|
@@ -1313,7 +1313,7 @@ async function rgDenyExistenceProbe(env, root, deny, target, signal) {
|
|
|
1313
1313
|
return { kind: "probe_failed" };
|
|
1314
1314
|
}
|
|
1315
1315
|
}
|
|
1316
|
-
export async function runGrepDetailed(env, root, p, signal, deny) {
|
|
1316
|
+
export async function runGrepDetailed(env, root, p, signal, deny, readFloor) {
|
|
1317
1317
|
const scope = p.path ? anchorSpelling(pathFamilyOf({ root }), root, p.path) : root;
|
|
1318
1318
|
const unexcludableUnder = async () => {
|
|
1319
1319
|
if (deny === undefined)
|
|
@@ -1326,7 +1326,7 @@ export async function runGrepDetailed(env, root, p, signal, deny) {
|
|
|
1326
1326
|
return deny.unexcludableUnder(scope) || (home.view !== undefined && deny.unexcludableUnder(home.view));
|
|
1327
1327
|
};
|
|
1328
1328
|
if (!(await unexcludableUnder()) && (await detectRipgrep(env)))
|
|
1329
|
-
return rgGrepDetailed(env, root, p, signal, deny);
|
|
1329
|
+
return rgGrepDetailed(env, root, p, signal, deny, readFloor);
|
|
1330
1330
|
const denyOut = {};
|
|
1331
1331
|
const { text, rows } = await jsGrepDetailed(env, root, p, signal, undefined, deny, denyOut);
|
|
1332
1332
|
return { text, ...(rows !== undefined ? { rows } : {}), ...(denyOut.withheld !== undefined ? { withheld: denyOut.withheld } : {}) };
|
package/dist/tools/monitor.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* CC-parity semantics (live-harness schema, the archived ground truth):
|
|
7
7
|
* ① every stdout LINE becomes one event; ② lines within the 200ms batch window coalesce into ONE
|
|
8
8
|
* notification; ③ process exit ends the watch (exit code reported); ④ non-persistent watches are killed at
|
|
9
|
-
* `timeout_ms` (default 5min, max 60min); ⑤ stderr never notifies but is
|
|
9
|
+
* `timeout_ms` (default 5min, max 60min); ⑤ stderr never notifies but is mirrored to the output file (with stdout);
|
|
10
10
|
* ⑥ an event storm is SUPPRESSED first and auto-stops the monitor only if it persists (RB-334, CC `PCo`
|
|
11
11
|
* 220:403278-403321 two-level control — the suppressed count and the overload duration are disclosed
|
|
12
12
|
* on both the suppression frame and the stop notification).
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
* in-window non-persistent watch alive (process on the dispose except-list, watcher ticking, row kept), so
|
|
26
26
|
* cross-turn watching — CC's main Monitor use case — works with the default persistent:false too; its
|
|
27
27
|
* between-turns events AND its timeout/exit terminal ride the same pending lane.
|
|
28
|
-
* The handle is a first-class m* registry task:
|
|
28
|
+
* The handle is a first-class m* registry task: its output file is the full record (Read-exempt like a background
|
|
29
|
+
* Bash's, `TaskRegistry.isBackgroundOutputFile`), TaskStop stops the
|
|
29
30
|
* watch (design/134 stoppedBy attribution applies automatically).
|
|
30
31
|
*
|
|
31
32
|
* Security posture: `command` is an arbitrary shell script ⇒ effect:"write", same as Bash; the catalog puts Monitor on the
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
*/
|
|
41
42
|
import type { AgentTool, ExecutionEnv } from "../internal/harness-types.js";
|
|
42
43
|
import { type MonitorTimers, type TaskRegistry } from "../core/task-registry.js";
|
|
43
|
-
import type
|
|
44
|
+
import { type TaskNotificationPayload } from "../core/task-notification.js";
|
|
44
45
|
import type { ToolResultStore } from "../core/tool-result-store.js";
|
|
45
46
|
import type { ShellReadAdmission } from "./fs/shell-read-check.js";
|
|
46
47
|
import type { ReadFloorSeat } from "./fs/read-floor.js";
|
|
@@ -53,7 +54,7 @@ export interface MonitorToolOptions {
|
|
|
53
54
|
* turn; reaped by the deployment's session release via `reapSessionBackground`). */
|
|
54
55
|
sessionId?: string;
|
|
55
56
|
/** The notification sink (the run-local task-notification lane). Without it the monitor still runs and
|
|
56
|
-
*
|
|
57
|
+
* mirrors its output file, but no events reach the model (the tool reply says so honestly). */
|
|
57
58
|
onTaskNotification?: (n: TaskNotificationPayload, opts?: {
|
|
58
59
|
priority?: "now" | "next" | "later";
|
|
59
60
|
}) => void;
|
package/dist/tools/monitor.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
2
|
import { defineTool, errorResult } from "../core/tools.js";
|
|
3
|
-
import { envDeclaresRetain, hasBackgroundShell, retainsBackgroundProcesses } from "../core/background-shell.js";
|
|
3
|
+
import { createBackgroundOutputFile, envDeclaresRetain, hasBackgroundShell, retainsBackgroundProcesses } from "../core/background-shell.js";
|
|
4
4
|
import { MONITOR_DEFAULT_TIMEOUT_MS, MONITOR_MAX_TIMEOUT_MS, } from "../core/task-registry.js";
|
|
5
|
+
import { resolveCompletionSink } from "../core/task-notification.js";
|
|
5
6
|
import { toolFace } from "../core/tool-catalog-entries.js";
|
|
6
7
|
import { isDeadCwd, diagnoseDeadCwd } from "./fs/dead-cwd.js";
|
|
7
8
|
import { thrownText } from "../core/thrown-value.js";
|
|
@@ -11,8 +12,8 @@ const MONITOR_DESCRIPTION = "Run a shell command in the background and watch its
|
|
|
11
12
|
"multiple lines arriving within a short window (~200ms) are batched into a single notification.\n" +
|
|
12
13
|
"- When the command exits, the watch ends and one final notification reports its exit code. A watch that " +
|
|
13
14
|
`exceeds its timeout is killed and reported (default ${MONITOR_DEFAULT_TIMEOUT_MS}ms, max ${MONITOR_MAX_TIMEOUT_MS}ms).\n` +
|
|
14
|
-
"- stderr does NOT trigger notifications, but it is captured —
|
|
15
|
-
"
|
|
15
|
+
"- stderr does NOT trigger notifications, but it is captured — stdout and stderr are both appended to the output " +
|
|
16
|
+
"file the start receipt names; Read that file any time.\n" +
|
|
16
17
|
"- A monitor that produces too many events is rate-limited: excess batches are suppressed (a notification tells you how many), and a watch that stays over the limit is stopped automatically.\n" +
|
|
17
18
|
"- Set persistent: true for a session-resident watch with no watch timeout of its own; it still ends when " +
|
|
18
19
|
"the execution environment's background time budget expires, when you stop it with TaskStop(task_id), or " +
|
|
@@ -90,10 +91,13 @@ export function createMonitorTool(env, opts) {
|
|
|
90
91
|
const sessionScoped = isPersistent && opts.sessionId !== undefined;
|
|
91
92
|
const owner = sessionScoped ? opts.sessionId : (ctx.taskId ?? opts.owner);
|
|
92
93
|
const scope = ctx.principal ?? opts.scope;
|
|
93
|
-
const onNotify = opts.onTaskNotification;
|
|
94
|
+
const onNotify = resolveCompletionSink(ctx.onTaskNotification, opts.onTaskNotification);
|
|
95
|
+
const outputFile = await createBackgroundOutputFile(env, "monitor-task-");
|
|
94
96
|
let taskId;
|
|
95
97
|
try {
|
|
96
98
|
taskId = opts.registry.registerMonitor({
|
|
99
|
+
...(outputFile !== undefined ? { outputFile } : {}),
|
|
100
|
+
...(ctx.taskArtifacts !== undefined ? { taskArtifacts: ctx.taskArtifacts } : {}),
|
|
97
101
|
env,
|
|
98
102
|
shellId: spawn.value.shellId,
|
|
99
103
|
description,
|
|
@@ -126,7 +130,7 @@ export function createMonitorTool(env, opts) {
|
|
|
126
130
|
return errorResult(killDetail === undefined
|
|
127
131
|
? `Error (Monitor): the watch process was started but could not be registered (${why}); it has been terminated.`
|
|
128
132
|
: `Error (Monitor): the watch process was started but could not be registered (${why}), and it could NOT be terminated either (${killDetail}). ` +
|
|
129
|
-
`It may still be running as background shell ${spawn.value.shellId}; no task id was minted, so
|
|
133
|
+
`It may still be running as background shell ${spawn.value.shellId}; no task id was minted, so TaskStop cannot reach it — ` +
|
|
130
134
|
"stop it out of band (the environment's own background time budget and its teardown sweep are the remaining backstops).");
|
|
131
135
|
}
|
|
132
136
|
const bgTimeout = envBackgroundWallSec(env.backgroundCapabilities, spawnTimeoutSec);
|
|
@@ -159,12 +163,15 @@ export function createMonitorTool(env, opts) {
|
|
|
159
163
|
: envWallWins
|
|
160
164
|
? `The watch may run up to ${envWallMs}ms — the execution environment's background time budget (${bgTimeout}s) is shorter than the ${timeoutMs}ms watch timeout${clampNote}, and the shorter of the two wins.`
|
|
161
165
|
: `The watch may run up to ${timeoutMs}ms${clampNote}.`;
|
|
166
|
+
const fileClause = outputFile !== undefined
|
|
167
|
+
? `Output file: ${outputFile} (stdout and stderr are appended there — Read it any time).`
|
|
168
|
+
: "No output file could be created for this watch.";
|
|
162
169
|
const content = onNotify !== undefined
|
|
163
170
|
? `Monitoring in background; task_id=${taskId}. Each stdout line becomes a notification event (lines within ` +
|
|
164
171
|
`~200ms are batched); you'll get a final notification with the exit code when it ends — do not poll. ` +
|
|
165
|
-
`${lifetime}
|
|
166
|
-
: `Monitoring in background; task_id=${taskId}. No notification channel is wired in this mount
|
|
167
|
-
|
|
172
|
+
`${lifetime} ${fileClause} TaskStop("${taskId}") stops the watch.`
|
|
173
|
+
: `Monitoring in background; task_id=${taskId}. No notification channel is wired in this mount, so no event or final notification will reach you. ` +
|
|
174
|
+
`${fileClause} Stop it with TaskStop("${taskId}"). ${lifetime}`;
|
|
168
175
|
return {
|
|
169
176
|
content,
|
|
170
177
|
details: {
|