@sema-agent/core 7.69.1 → 7.70.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 +2477 -0
- package/dist/agents/agent-definition.d.ts +18 -0
- package/dist/agents/agent-definition.js +10 -0
- package/dist/agents/agent-transcript-tool.d.ts +2 -1
- package/dist/agents/agent-transcript-tool.js +2 -0
- package/dist/agents/cascade.d.ts +10 -0
- package/dist/agents/cascade.js +33 -5
- package/dist/agents/cc-peer-directory.d.ts +1 -1
- package/dist/agents/cc-peer-directory.js +2 -1
- package/dist/agents/child-model-seat.d.ts +1 -1
- package/dist/agents/composition-allowance.d.ts +63 -19
- package/dist/agents/composition-allowance.js +62 -45
- package/dist/agents/composition-placement.d.ts +22 -4
- package/dist/agents/composition-placement.js +10 -1
- package/dist/agents/cross-session-envelope.d.ts +4 -5
- package/dist/agents/cross-session-envelope.js +4 -5
- package/dist/agents/inherited-tool-pool.js +1 -2
- package/dist/agents/list-agents-tool.js +2 -1
- package/dist/agents/parked-resume-drive.d.ts +38 -0
- package/dist/agents/parked-resume-drive.js +57 -0
- package/dist/agents/peer-admission.js +4 -3
- package/dist/agents/peer-held-queue.d.ts +4 -2
- package/dist/agents/peer-held-queue.js +2 -1
- package/dist/agents/peer-session-drain.d.ts +2 -0
- package/dist/agents/peer-session-drain.js +49 -29
- package/dist/agents/repair-loop.js +15 -11
- package/dist/agents/retain-ledger.d.ts +71 -18
- package/dist/agents/retain-ledger.js +45 -13
- package/dist/agents/roster-store.d.ts +11 -3
- package/dist/agents/roster-store.js +6 -2
- package/dist/agents/send-message-tool.d.ts +2 -1
- package/dist/agents/send-message-tool.js +10 -7
- package/dist/agents/subagent.d.ts +24 -7
- package/dist/agents/subagent.js +256 -144
- package/dist/agents/tool-filter.js +1 -1
- package/dist/agents/verify.d.ts +4 -1
- package/dist/agents/verify.js +22 -16
- package/dist/agents/yield-adoption.js +2 -1
- package/dist/bench/metrics.js +2 -2
- package/dist/brain/anthropic.d.ts +2 -1
- package/dist/brain/anthropic.js +3 -3
- package/dist/brain/circuit-breaker.js +1 -1
- package/dist/brain/model-lane.d.ts +2 -1
- package/dist/brain/model-lane.js +22 -9
- package/dist/brain/open-responses.d.ts +77 -1
- package/dist/brain/open-responses.js +1 -1
- package/dist/brain/openai.d.ts +2 -1
- package/dist/brain/openai.js +3 -3
- package/dist/brain/reasoning.d.ts +8 -1
- package/dist/brain/reasoning.js +3 -0
- package/dist/brain/reference-model-traits.d.ts +13 -12
- package/dist/brain/reference-model-traits.js +11 -10
- package/dist/brain/request-route.d.ts +1 -1
- package/dist/brain/request-route.js +2 -2
- package/dist/brain/route-adjudicator.d.ts +72 -2
- package/dist/brain/route-adjudicator.js +210 -69
- package/dist/brain/route-conformance.js +35 -0
- package/dist/brain/routing.js +2 -2
- package/dist/brain/spend-meter.d.ts +56 -0
- package/dist/brain/spend-meter.js +263 -0
- package/dist/brain/stream-shared.d.ts +1 -1
- package/dist/brain/stream-shared.js +3 -1
- package/dist/core/a2a-bound-grant.d.ts +110 -0
- package/dist/core/a2a-bound-grant.js +83 -0
- package/dist/core/a2a-task-state.d.ts +153 -51
- package/dist/core/a2a-task-state.js +85 -45
- package/dist/core/a2a.d.ts +62 -14
- package/dist/core/a2a.js +298 -57
- package/dist/core/agent-config-dir.d.ts +53 -6
- package/dist/core/agent-config-dir.js +59 -6
- package/dist/core/agent-definition.d.ts +1 -1
- package/dist/core/agent-state.d.ts +10 -1
- package/dist/core/agent-state.js +11 -4
- package/dist/core/allow-entry.d.ts +80 -42
- package/dist/core/allow-entry.js +119 -61
- package/dist/core/allow-rule-shadow.d.ts +25 -3
- package/dist/core/allow-rule-shadow.js +7 -0
- package/dist/core/approval-object.js +2 -2
- package/dist/core/artifact-host.d.ts +109 -6
- package/dist/core/artifact-host.js +68 -0
- package/dist/core/ask-headline.d.ts +10 -9
- package/dist/core/ask-headline.js +9 -3
- package/dist/core/ask-origin.d.ts +88 -28
- package/dist/core/ask-origin.js +73 -43
- package/dist/core/ask-question.d.ts +76 -38
- package/dist/core/ask-question.js +151 -22
- package/dist/core/ask-unresolvable-notice.d.ts +66 -10
- package/dist/core/ask-unresolvable-notice.js +38 -14
- package/dist/core/auto-compaction.d.ts +3 -49
- package/dist/core/auto-compaction.js +3 -8
- package/dist/core/auto-mode-directive.d.ts +17 -5
- package/dist/core/auto-mode-directive.js +12 -3
- package/dist/core/auto-mode.d.ts +34 -5
- package/dist/core/auto-mode.js +43 -5
- package/dist/core/background-agent-store.d.ts +100 -11
- package/dist/core/background-agent-store.js +64 -6
- package/dist/core/background-shell.d.ts +9 -0
- package/dist/core/background-shell.js +10 -0
- package/dist/core/caller-text.d.ts +2 -2
- package/dist/core/caller-tool-name.d.ts +6 -0
- package/dist/core/caller-tool-name.js +2 -1
- package/dist/core/checkpoint-features.d.ts +38 -422
- package/dist/core/checkpoint-features.js +44 -0
- package/dist/core/checkpoint-queries.d.ts +14 -3
- package/dist/core/checkpoint-queries.js +9 -4
- package/dist/core/checkpoint-requirements.d.ts +69 -2
- package/dist/core/checkpoint-requirements.js +12 -2
- package/dist/core/checkpoint-row-verdict.d.ts +70 -17
- package/dist/core/checkpoint-row-verdict.js +75 -29
- package/dist/core/checkpoint-store.d.ts +75 -69
- package/dist/core/checkpoint-store.js +24 -22
- package/dist/core/classifier-unavailable-arm.d.ts +6 -1
- package/dist/core/classifier-unavailable-arm.js +8 -5
- package/dist/core/config-refusal-codes.d.ts +7 -5
- package/dist/core/config-refusal-codes.js +7 -2
- package/dist/core/config-refusal-input.d.ts +46 -0
- package/dist/core/config-refusal-input.js +62 -0
- package/dist/core/context-edit.d.ts +18 -1
- package/dist/core/context-edit.js +13 -2
- package/dist/core/context-guard.d.ts +60 -13
- package/dist/core/context-guard.js +77 -35
- package/dist/core/context-settings.d.ts +2 -1
- package/dist/core/context-settings.js +10 -6
- package/dist/core/corrupt-session-form.d.ts +97 -0
- package/dist/core/corrupt-session-form.js +54 -0
- package/dist/core/cross-boundary-taint.d.ts +3 -3
- package/dist/core/data-root.d.ts +32 -0
- package/dist/core/data-root.js +86 -0
- package/dist/core/decision-receipt.d.ts +2 -0
- package/dist/core/decision-receipt.js +3 -2
- package/dist/core/declaration-words.d.ts +37 -0
- package/dist/core/declaration-words.js +21 -0
- package/dist/core/delegation-frames.d.ts +76 -35
- package/dist/core/delegation-frames.js +21 -1
- package/dist/core/durable-sync.d.ts +9 -0
- package/dist/core/durable-sync.js +37 -0
- package/dist/core/engine-capabilities.d.ts +110 -3
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +259 -139
- package/dist/core/engine-notice.js +13 -19
- package/dist/core/engine-version.js +1 -1
- package/dist/core/entries-not-applied.d.ts +22 -0
- package/dist/core/entries-not-applied.js +26 -0
- package/dist/core/exec-gate.d.ts +8 -1
- package/dist/core/exec-gate.js +24 -9
- package/dist/core/exec-outcome.d.ts +102 -0
- package/dist/core/exec-outcome.js +79 -0
- package/dist/core/existing-target.d.ts +45 -0
- package/dist/core/existing-target.js +54 -8
- package/dist/core/fast-tier-door.d.ts +2 -2
- package/dist/core/fast-tier-door.js +3 -3
- package/dist/core/file-history-store.d.ts +138 -19
- package/dist/core/file-history-store.js +124 -33
- package/dist/core/gate-fold.js +8 -1
- package/dist/core/gate-lanes.js +65 -38
- package/dist/core/gate-outcome.d.ts +3 -1
- package/dist/core/gate-outcome.js +7 -1
- package/dist/core/git-worktree-env.d.ts +25 -5
- package/dist/core/git-worktree-env.js +38 -13
- package/dist/core/governance-codes.d.ts +179 -40
- package/dist/core/governance-codes.js +450 -43
- package/dist/core/hands-band.d.ts +1 -1
- package/dist/core/hooks.d.ts +75 -13
- package/dist/core/hooks.js +4 -0
- package/dist/core/host-floor.d.ts +1 -1
- package/dist/core/host-floor.js +1 -1
- package/dist/core/identity-rekey.d.ts +2 -1
- package/dist/core/identity-rekey.js +5 -5
- package/dist/core/image-admission.d.ts +2 -2
- package/dist/core/image-admission.js +1 -1
- package/dist/core/isolation-scope.d.ts +42 -17
- package/dist/core/isolation-scope.js +12 -4
- package/dist/core/leg-identity.d.ts +17 -2
- package/dist/core/leg-identity.js +6 -1
- package/dist/core/locked-config.d.ts +86 -16
- package/dist/core/locked-config.js +100 -34
- package/dist/core/mailbox-store.d.ts +4 -0
- package/dist/core/mailbox-store.js +7 -0
- package/dist/core/mcp-failure.d.ts +13 -4
- package/dist/core/mcp-failure.js +10 -0
- package/dist/core/mcp-injection-drop.d.ts +30 -13
- package/dist/core/mcp-injection-drop.js +25 -7
- package/dist/core/mcp-leg-wait.d.ts +88 -0
- package/dist/core/mcp-leg-wait.js +100 -0
- package/dist/core/mcp-name-judge.js +1 -2
- package/dist/core/mcp-probe.d.ts +30 -1
- package/dist/core/mcp-probe.js +5 -3
- package/dist/core/mcp-read-bound.d.ts +51 -0
- package/dist/core/mcp-read-bound.js +49 -0
- package/dist/core/mcp-server-link.js +4 -3
- package/dist/core/mcp-server-spec.d.ts +97 -26
- package/dist/core/mcp-server-spec.js +51 -19
- package/dist/core/mcp-server-unavailable-notice.d.ts +15 -6
- package/dist/core/mcp-server-unavailable-notice.js +12 -11
- package/dist/core/mcp-stderr-lines.d.ts +69 -0
- package/dist/core/mcp-stderr-lines.js +333 -0
- package/dist/core/mcp.d.ts +32 -9
- package/dist/core/mcp.js +187 -44
- package/dist/core/member-outcome.d.ts +281 -0
- package/dist/core/member-outcome.js +293 -0
- package/dist/core/memory-engine/consolidation.js +3 -3
- package/dist/core/memory-engine/content-origin.js +5 -4
- package/dist/core/memory-engine/control-objects.js +6 -4
- package/dist/core/memory-engine/distiller.js +2 -2
- package/dist/core/memory-engine/dual-root.d.ts +12 -5
- package/dist/core/memory-engine/dual-root.js +13 -7
- package/dist/core/memory-engine/engine.d.ts +27 -31
- package/dist/core/memory-engine/engine.js +103 -61
- package/dist/core/memory-engine/file-backend.d.ts +16 -3
- package/dist/core/memory-engine/file-backend.js +15 -20
- package/dist/core/memory-engine/index-copies.d.ts +8 -6
- package/dist/core/memory-engine/index-copies.js +2 -1
- package/dist/core/memory-engine/index.d.ts +3 -2
- package/dist/core/memory-engine/index.js +3 -2
- package/dist/core/memory-engine/layout.d.ts +166 -23
- package/dist/core/memory-engine/layout.js +235 -40
- package/dist/core/memory-engine/memory-backend-contract.js +20 -20
- package/dist/core/memory-engine/memory-deployment.d.ts +29 -16
- package/dist/core/memory-engine/memory-deployment.js +30 -20
- package/dist/core/memory-engine/mount-failed-notice.d.ts +64 -0
- package/dist/core/memory-engine/mount-failed-notice.js +50 -2
- package/dist/core/memory-engine/projection-ledger.d.ts +48 -0
- package/dist/core/memory-engine/projection-ledger.js +130 -0
- package/dist/core/memory-engine/scope-contract.js +2 -2
- package/dist/core/memory-engine/sync-client.js +1 -2
- package/dist/core/memory-engine/types.d.ts +10 -4
- package/dist/core/memory.js +3 -5
- package/dist/core/mode-policy.d.ts +82 -16
- package/dist/core/mode-policy.js +63 -29
- package/dist/core/model-seat.d.ts +13 -1
- package/dist/core/mods/classic-events.d.ts +13 -1
- package/dist/core/mods/dollar.js +2 -1
- package/dist/core/mods/extension-call.d.ts +3 -0
- package/dist/core/mods/extension-call.js +3 -0
- package/dist/core/mods/kernel/dispatch.d.ts +4 -0
- package/dist/core/mods/kernel/dispatch.js +3 -3
- package/dist/core/mods/kernel/events.d.ts +11 -3
- package/dist/core/mods/kernel/events.js +4 -4
- package/dist/core/mods/message-display.d.ts +6 -3
- package/dist/core/mods/message-display.js +13 -5
- package/dist/core/mods/stations.d.ts +8 -1
- package/dist/core/mods/stations.js +5 -3
- package/dist/core/mods/teammate-stations.d.ts +75 -0
- package/dist/core/mods/teammate-stations.js +108 -0
- package/dist/core/mounted-mcp.js +1 -2
- package/dist/core/namespaced-rule-name.d.ts +1 -1
- package/dist/core/namespaced-rule-name.js +1 -1
- package/dist/core/notice-fact.d.ts +28 -0
- package/dist/core/notice-fact.js +25 -0
- package/dist/core/owner-identity.d.ts +8 -3
- package/dist/core/owner-identity.js +6 -3
- package/dist/core/parent-spec-seat.d.ts +16 -6
- package/dist/core/parent-spec-seat.js +28 -6
- package/dist/core/park-resumability.d.ts +10 -5
- package/dist/core/park-resumability.js +3 -0
- package/dist/core/park-selfcheck.js +2 -1
- package/dist/core/peer-seat.d.ts +1 -2
- package/dist/core/permission-rule-consent.d.ts +50 -1
- package/dist/core/permission-rule-consent.js +121 -14
- package/dist/core/permission-rule-model.d.ts +135 -39
- package/dist/core/permission-rule-model.js +151 -24
- package/dist/core/permission-rule-org.d.ts +13 -0
- package/dist/core/permission-rule-org.js +8 -0
- package/dist/core/permission-rule-provider.d.ts +107 -7
- package/dist/core/permission-rule-provider.js +434 -29
- package/dist/core/permission-rule-session.js +3 -1
- package/dist/core/permission-rule-store.d.ts +19 -2
- package/dist/core/permission-rule-store.js +29 -10
- package/dist/core/permission-rule-sync.js +5 -2
- package/dist/core/permission-rules.js +8 -3
- package/dist/core/persisted-rule-arms.d.ts +10 -4
- package/dist/core/persisted-rule-arms.js +16 -11
- package/dist/core/persisted-rule-buckets.d.ts +66 -0
- package/dist/core/persisted-rule-buckets.js +57 -0
- package/dist/core/plan-review-facts.d.ts +33 -0
- package/dist/core/plan-review-facts.js +25 -0
- package/dist/core/prefix-declaration.d.ts +50 -0
- package/dist/core/prefix-declaration.js +13 -0
- package/dist/core/present-plan-tool.d.ts +13 -3
- package/dist/core/present-plan-tool.js +14 -3
- package/dist/core/pricing.d.ts +5 -1
- package/dist/core/pricing.js +8 -5
- package/dist/core/principal-name.d.ts +55 -5
- package/dist/core/principal-name.js +57 -16
- package/dist/core/process-identity.d.ts +11 -7
- package/dist/core/process-identity.js +26 -36
- package/dist/core/process-table.d.ts +67 -0
- package/dist/core/process-table.js +177 -0
- package/dist/core/protocol-http-auth.d.ts +75 -12
- package/dist/core/protocol-http-auth.js +223 -26
- package/dist/core/protocol-revocation.d.ts +29 -10
- package/dist/core/protocol-revocation.js +9 -5
- package/dist/core/read-only-shell.d.ts +1 -1
- package/dist/core/read-only-shell.js +1 -1
- package/dist/core/read-root-grant-screen.d.ts +17 -6
- package/dist/core/read-root-grant-screen.js +15 -5
- package/dist/core/reminder-mint.d.ts +6 -0
- package/dist/core/reminder-mint.js +13 -0
- package/dist/core/remote-env.d.ts +111 -3
- package/dist/core/remote-env.js +20 -0
- package/dist/core/request-copy-projection.js +97 -18
- package/dist/core/resource-limit-reasons.d.ts +52 -0
- package/dist/core/resource-limit-reasons.js +6 -0
- package/dist/core/resume-at-refusal.d.ts +10 -6
- package/dist/core/resume-at-refusal.js +2 -2
- package/dist/core/resume-config-judge.d.ts +3 -2
- package/dist/core/resume-config-judge.js +2 -1
- package/dist/core/resume-startup-cause.d.ts +18 -4
- package/dist/core/resume-startup-cause.js +30 -6
- package/dist/core/retention.d.ts +12 -2
- package/dist/core/retention.js +6 -1
- package/dist/core/retired-keys.d.ts +5 -0
- package/dist/core/retired-keys.js +12 -0
- package/dist/core/rewind-conversation.d.ts +54 -0
- package/dist/core/rewind-conversation.js +1 -0
- package/dist/core/roles.d.ts +61 -3
- package/dist/core/roles.js +81 -28
- package/dist/core/rule-lane-reads.d.ts +2 -1
- package/dist/core/rule-lane-reads.js +54 -29
- package/dist/core/rule-offer-read.js +5 -2
- package/dist/core/rule-owner.d.ts +6 -1
- package/dist/core/rule-owner.js +8 -2
- package/dist/core/rule-store-fault.d.ts +4 -2
- package/dist/core/rule-store-fault.js +4 -1
- package/dist/core/runner/advertised-writable-dirs.d.ts +17 -0
- package/dist/core/runner/advertised-writable-dirs.js +15 -9
- package/dist/core/runner/announce-once-ledger.js +12 -11
- package/dist/core/runner/assemble-result.d.ts +15 -6
- package/dist/core/runner/assemble-result.js +12 -5
- package/dist/core/runner/auto-strip-notice.d.ts +1 -1
- package/dist/core/runner/branch-window.d.ts +25 -2
- package/dist/core/runner/branch-window.js +47 -11
- package/dist/core/runner/chain-refusal-throw.d.ts +19 -0
- package/dist/core/runner/chain-refusal-throw.js +30 -0
- package/dist/core/runner/changes-git.d.ts +21 -0
- package/dist/core/runner/changes-git.js +291 -0
- package/dist/core/runner/changes-history.d.ts +80 -0
- package/dist/core/runner/changes-history.js +351 -0
- package/dist/core/runner/checkpoint-scope.d.ts +16 -8
- package/dist/core/runner/checkpoint-scope.js +6 -4
- package/dist/core/runner/child-tree.d.ts +31 -20
- package/dist/core/runner/child-tree.js +24 -9
- package/dist/core/runner/classifier-ladder.d.ts +4 -2
- package/dist/core/runner/classifier-ladder.js +14 -12
- package/dist/core/runner/clock-and-limits.d.ts +0 -3
- package/dist/core/runner/clock-and-limits.js +1 -2
- package/dist/core/runner/compact-session.js +19 -50
- package/dist/core/runner/compaction-restate.js +2 -1
- package/dist/core/runner/constraint-layers.d.ts +101 -0
- package/dist/core/runner/constraint-layers.js +96 -0
- package/dist/core/runner/construction-doors.js +2 -0
- package/dist/core/runner/content-ask-bindings.d.ts +3 -3
- package/dist/core/runner/continuation-gate.d.ts +8 -4
- package/dist/core/runner/continuation-gate.js +2 -0
- package/dist/core/runner/continues-from.d.ts +7 -0
- package/dist/core/runner/continues-from.js +9 -0
- package/dist/core/runner/contracts.d.ts +144 -44
- package/dist/core/runner/decide-continuation.d.ts +2 -2
- package/dist/core/runner/denial-limit-arms.js +3 -4
- package/dist/core/runner/earlier-grammar-notice.js +5 -3
- package/dist/core/runner/env-capability-census.js +2 -1
- package/dist/core/runner/file-history-restore.d.ts +35 -9
- package/dist/core/runner/file-history-restore.js +36 -9
- package/dist/core/runner/finish-reason-seat.js +13 -4
- package/dist/core/runner/gate-exit.d.ts +8 -0
- package/dist/core/runner/gate-exit.js +36 -11
- package/dist/core/runner/halt-attribution.js +1 -1
- package/dist/core/runner/initial-run-state.d.ts +1 -1
- package/dist/core/runner/initial-run-state.js +2 -2
- package/dist/core/runner/left-as-is-seat.js +1 -1
- package/dist/core/runner/mcp-redial.d.ts +15 -4
- package/dist/core/runner/mcp-redial.js +53 -6
- package/dist/core/runner/memory-capture-optout.d.ts +7 -11
- package/dist/core/runner/memory-capture-optout.js +7 -4
- package/dist/core/runner/memory-phase-refusals.d.ts +19 -0
- package/dist/core/runner/memory-phase-refusals.js +18 -0
- package/dist/core/runner/messages-omitted-seat.d.ts +24 -1
- package/dist/core/runner/messages-omitted-seat.js +30 -9
- package/dist/core/runner/model-fallback-seat.d.ts +18 -5
- package/dist/core/runner/model-fallback-seat.js +29 -24
- package/dist/core/runner/model-lane-seat.d.ts +23 -1
- package/dist/core/runner/model-lane-seat.js +20 -2
- package/dist/core/runner/nested-memory-lane.d.ts +64 -57
- package/dist/core/runner/nested-memory-lane.js +310 -110
- package/dist/core/runner/park-commit.d.ts +26 -5
- package/dist/core/runner/park-commit.js +19 -8
- package/dist/core/runner/permission-rule-lanes.d.ts +5 -0
- package/dist/core/runner/permission-rule-lanes.js +44 -11
- package/dist/core/runner/person-path-rows.d.ts +124 -21
- package/dist/core/runner/person-path-rows.js +179 -20
- package/dist/core/runner/prefix-ledger.d.ts +57 -3
- package/dist/core/runner/prefix-ledger.js +98 -8
- package/dist/core/runner/prepare-acquire-reconcile.d.ts +2 -1
- package/dist/core/runner/prepare-acquire-reconcile.js +13 -65
- package/dist/core/runner/prepare-advisor.js +2 -1
- package/dist/core/runner/prepare-artifact.d.ts +4 -1
- package/dist/core/runner/prepare-artifact.js +3 -3
- package/dist/core/runner/prepare-ask-lane.d.ts +4 -0
- package/dist/core/runner/prepare-ask-lane.js +7 -5
- package/dist/core/runner/prepare-boundary-parks.js +9 -3
- package/dist/core/runner/prepare-caps-and-workflow.js +37 -25
- package/dist/core/runner/prepare-config-doors.d.ts +13 -14
- package/dist/core/runner/prepare-config-doors.js +121 -122
- package/dist/core/runner/prepare-context-lane.d.ts +32 -11
- package/dist/core/runner/prepare-context-lane.js +77 -48
- package/dist/core/runner/prepare-defer-classify.d.ts +12 -0
- package/dist/core/runner/prepare-defer-classify.js +29 -7
- package/dist/core/runner/prepare-delegation-surface.d.ts +2 -0
- package/dist/core/runner/prepare-delegation-surface.js +8 -4
- package/dist/core/runner/prepare-execution-env.d.ts +3 -0
- package/dist/core/runner/prepare-execution-env.js +10 -5
- package/dist/core/runner/prepare-file-history.js +4 -1
- package/dist/core/runner/prepare-gate-stations.d.ts +10 -0
- package/dist/core/runner/prepare-gate-stations.js +15 -6
- package/dist/core/runner/prepare-hands-readface.d.ts +28 -7
- package/dist/core/runner/prepare-hands-readface.js +83 -23
- package/dist/core/runner/prepare-inherited-gate.d.ts +20 -11
- package/dist/core/runner/prepare-inherited-gate.js +27 -16
- package/dist/core/runner/prepare-memory-engine-session.js +4 -2
- package/dist/core/runner/prepare-memory.d.ts +8 -1
- package/dist/core/runner/prepare-memory.js +37 -33
- package/dist/core/runner/prepare-offload-wrappers.d.ts +7 -7
- package/dist/core/runner/prepare-offload-wrappers.js +26 -17
- package/dist/core/runner/prepare-park-ask.d.ts +8 -11
- package/dist/core/runner/prepare-park-ask.js +11 -8
- package/dist/core/runner/prepare-policy-chain.d.ts +24 -1
- package/dist/core/runner/prepare-policy-chain.js +53 -28
- package/dist/core/runner/prepare-project-context.d.ts +4 -0
- package/dist/core/runner/prepare-project-context.js +9 -8
- package/dist/core/runner/prepare-prompt-assembly.js +2 -2
- package/dist/core/runner/prepare-protocol-tools.d.ts +2 -2
- package/dist/core/runner/prepare-protocol-tools.js +44 -24
- package/dist/core/runner/prepare-question-face.d.ts +4 -9
- package/dist/core/runner/prepare-question-face.js +8 -3
- package/dist/core/runner/prepare-suspend-saga.d.ts +7 -1
- package/dist/core/runner/prepare-suspend-saga.js +10 -4
- package/dist/core/runner/prepare-task.d.ts +2 -2
- package/dist/core/runner/prepare-task.js +141 -57
- package/dist/core/runner/prepare-tool-disclosure-mount.js +10 -5
- package/dist/core/runner/prepare-turn-wiring.d.ts +3 -1
- package/dist/core/runner/prepare-turn-wiring.js +10 -8
- package/dist/core/runner/prepare-wiring-manifest.d.ts +6 -19
- package/dist/core/runner/prepare-wiring-manifest.js +17 -35
- package/dist/core/runner/prepare-workspace-restore.d.ts +4 -11
- package/dist/core/runner/prepare-workspace-restore.js +1 -14
- package/dist/core/runner/read-root-grant.d.ts +48 -13
- package/dist/core/runner/read-root-grant.js +53 -19
- package/dist/core/runner/read-session-changes.d.ts +9 -0
- package/dist/core/runner/read-session-changes.js +192 -0
- package/dist/core/runner/remote-env-retry.d.ts +4 -4
- package/dist/core/runner/resume-admission.d.ts +11 -7
- package/dist/core/runner/resume-admission.js +25 -15
- package/dist/core/runner/resume-apply.js +2 -1
- package/dist/core/runner/resume-checkpoint-screen.d.ts +7 -2
- package/dist/core/runner/resume-checkpoint-screen.js +32 -17
- package/dist/core/runner/resume-internals-and-config.d.ts +3 -0
- package/dist/core/runner/resume-internals-and-config.js +10 -7
- package/dist/core/runner/resume-policy-outcome.d.ts +4 -3
- package/dist/core/runner/resume-policy-outcome.js +2 -2
- package/dist/core/runner/retired-name-policy.d.ts +15 -0
- package/dist/core/runner/retired-name-policy.js +37 -0
- package/dist/core/runner/retired-runner-deps.js +3 -1
- package/dist/core/runner/rewind-conversation.d.ts +10 -0
- package/dist/core/runner/rewind-conversation.js +100 -0
- package/dist/core/runner/rewind-files.js +37 -20
- package/dist/core/runner/rewind-target.d.ts +28 -0
- package/dist/core/runner/rewind-target.js +58 -0
- package/dist/core/runner/role-resolution-table.d.ts +3 -16
- package/dist/core/runner/role-resolution-table.js +1 -3
- package/dist/core/runner/role-seat-defaulted.d.ts +14 -5
- package/dist/core/runner/role-seat-defaulted.js +17 -13
- package/dist/core/runner/rule-store-unreadable-notice.d.ts +8 -6
- package/dist/core/runner/rule-store-unreadable-notice.js +6 -4
- package/dist/core/runner/run-compaction-machinery.js +2 -2
- package/dist/core/runner/run-harness-handlers.js +43 -11
- package/dist/core/runner/run-identity-wiring.d.ts +2 -0
- package/dist/core/runner/run-identity-wiring.js +3 -2
- package/dist/core/runner/run-leg.js +19 -28
- package/dist/core/runner/run-notification-lane.js +2 -2
- package/dist/core/runner/run-settle-and-teardown.js +32 -17
- package/dist/core/runner/run-stop-and-final-verify.js +66 -69
- package/dist/core/runner/run-telemetry-and-budget-seats.js +14 -8
- package/dist/core/runner/run-turn-boundary.js +3 -6
- package/dist/core/runner/runtask.d.ts +22 -16
- package/dist/core/runner/runtask.js +18 -8
- package/dist/core/runner/sandbox-network-seat.js +1 -1
- package/dist/core/runner/seat-model-doors.d.ts +6 -5
- package/dist/core/runner/seat-model-doors.js +4 -3
- package/dist/core/runner/session-file-state-replay.d.ts +47 -8
- package/dist/core/runner/session-file-state-replay.js +97 -11
- package/dist/core/runner/session-files-open.d.ts +64 -0
- package/dist/core/runner/session-files-open.js +33 -0
- package/dist/core/runner/session-read-file-states.d.ts +37 -41
- package/dist/core/runner/session-read-file-states.js +14 -6
- package/dist/core/runner/session-rule-policy.d.ts +5 -0
- package/dist/core/runner/session-rule-policy.js +16 -9
- package/dist/core/runner/session-verb-doors.d.ts +41 -4
- package/dist/core/runner/session-verb-doors.js +66 -11
- package/dist/core/runner/shared-read-classifier.d.ts +14 -3
- package/dist/core/runner/shared-read-classifier.js +14 -6
- package/dist/core/runner/shell-env-withheld.d.ts +4 -2
- package/dist/core/runner/shell-env-withheld.js +3 -2
- package/dist/core/runner/side-call-account.d.ts +47 -5
- package/dist/core/runner/side-call-account.js +37 -3
- package/dist/core/runner/skipped-rules-notice.d.ts +5 -5
- package/dist/core/runner/skipped-rules-notice.js +3 -3
- package/dist/core/runner/stream-settle-backstop.js +5 -4
- package/dist/core/runner/sub-agent-deny-lists.d.ts +26 -7
- package/dist/core/runner/sub-agent-deny-lists.js +23 -15
- package/dist/core/runner/task-start-doors.d.ts +7 -3
- package/dist/core/runner/task-start-doors.js +72 -31
- package/dist/core/runner/terminal-account.js +14 -8
- package/dist/core/runner/terminal-projection.d.ts +3 -2
- package/dist/core/runner/terminal-projection.js +2 -2
- package/dist/core/runner/tool-defer-gate.d.ts +1 -1
- package/dist/core/runner/tool-end-body.d.ts +8 -1
- package/dist/core/runner/tool-end-body.js +4 -3
- package/dist/core/runner/tool-face-overlay.js +6 -4
- package/dist/core/runner/tool-result-media-seat.d.ts +2 -1
- package/dist/core/runner/tool-table-view.js +1 -1
- package/dist/core/runner/trim-stretch.d.ts +43 -0
- package/dist/core/runner/trim-stretch.js +34 -0
- package/dist/core/runner/turn-attachments.js +7 -2
- package/dist/core/runner/unreadable-person-rows.d.ts +39 -0
- package/dist/core/runner/unreadable-person-rows.js +20 -0
- package/dist/core/runner/verdict-refusal.d.ts +22 -7
- package/dist/core/runner/verdict-refusal.js +35 -3
- package/dist/core/runner/workspace-sync.d.ts +49 -0
- package/dist/core/runner/workspace-sync.js +170 -0
- package/dist/core/runner-deps.d.ts +57 -32
- package/dist/core/scheduler.d.ts +34 -14
- package/dist/core/secret-env.d.ts +168 -18
- package/dist/core/secret-env.js +291 -56
- package/dist/core/sensitive-path-policy.js +3 -2
- package/dist/core/session-changes.d.ts +260 -0
- package/dist/core/session-changes.js +40 -0
- package/dist/core/session-checkout.d.ts +87 -3
- package/dist/core/session-checkout.js +134 -6
- package/dist/core/session-log-transfer.js +13 -7
- package/dist/core/session-policy-store.d.ts +40 -12
- package/dist/core/session-policy-store.js +51 -25
- package/dist/core/session-store.d.ts +23 -10
- package/dist/core/session-store.js +40 -13
- package/dist/core/session.d.ts +56 -9
- package/dist/core/session.js +8 -1
- package/dist/core/shell-read-silence.d.ts +3 -3
- package/dist/core/shell-read-silence.js +3 -1
- package/dist/core/shell-run-candidates.d.ts +23 -6
- package/dist/core/shell-run-candidates.js +34 -11
- package/dist/core/skill-grant.d.ts +11 -6
- package/dist/core/skill-grant.js +23 -15
- package/dist/core/spend-account.d.ts +232 -0
- package/dist/core/spend-account.js +286 -0
- package/dist/core/store-contracts/background-agent-store-contract.js +85 -0
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +6 -2
- package/dist/core/store-contracts/checkpoint-store-contract.js +60 -6
- package/dist/core/store-contracts/file-history-store-contract.js +4 -4
- package/dist/core/store-contracts/mailbox-store-contract.d.ts +2 -1
- package/dist/core/store-contracts/mailbox-store-contract.js +22 -11
- package/dist/core/store-contracts/peer-directory-contract.js +8 -0
- package/dist/core/store-contracts/permission-rule-sync-contract.js +3 -3
- package/dist/core/store-contracts/session-deletion-cascade-contract.js +23 -4
- package/dist/core/store-contracts/session-policy-store-contract.js +9 -0
- package/dist/core/store-contracts/session-repo-contract.js +38 -1
- package/dist/core/store-contracts/session-store-contract.d.ts +21 -2
- package/dist/core/store-contracts/session-store-contract.js +369 -5
- package/dist/core/store-contracts/tool-result-store-contract.js +8 -7
- package/dist/core/store-contracts/workflow-journal-store-contract.js +33 -0
- package/dist/core/task-event.d.ts +57 -53
- package/dist/core/task-limits.d.ts +15 -8
- package/dist/core/task-notification.d.ts +17 -12
- package/dist/core/task-notification.js +20 -9
- package/dist/core/task-registry-agent.d.ts +35 -30
- package/dist/core/task-registry-agent.js +102 -32
- package/dist/core/task-registry-monitor.js +2 -1
- package/dist/core/task-registry-shared.d.ts +83 -16
- package/dist/core/task-registry-shared.js +26 -7
- package/dist/core/task-registry-workflow.d.ts +9 -1
- package/dist/core/task-registry-workflow.js +11 -3
- package/dist/core/task-registry.d.ts +26 -27
- package/dist/core/task-registry.js +42 -12
- package/dist/core/task-result.d.ts +145 -35
- package/dist/core/task-spec-members.d.ts +21 -3
- package/dist/core/task-spec-members.js +11 -2
- package/dist/core/task-spec.d.ts +42 -45
- package/dist/core/task-start-judge.js +10 -3
- package/dist/core/task-stream.d.ts +2 -1
- package/dist/core/terminal-cause.d.ts +30 -2
- package/dist/core/tool-catalog-entries.js +1 -1
- package/dist/core/tool-errors.js +1 -0
- package/dist/core/tool-face-reader.d.ts +3 -2
- package/dist/core/tool-gate-phase.d.ts +16 -0
- package/dist/core/tool-gate-phase.js +1 -0
- package/dist/core/tool-mount-plan.d.ts +7 -0
- package/dist/core/tool-mount-plan.js +25 -1
- package/dist/core/tool-mount-static.js +3 -2
- package/dist/core/tool-name-aliases.d.ts +81 -106
- package/dist/core/tool-name-aliases.js +60 -155
- package/dist/core/tool-name-readings.d.ts +2 -0
- package/dist/core/tool-name-readings.js +9 -1
- package/dist/core/tool-policy.d.ts +165 -60
- package/dist/core/tool-policy.js +105 -69
- package/dist/core/tool-registry.d.ts +2 -0
- package/dist/core/tool-registry.js +3 -0
- package/dist/core/tool-result-bytes.d.ts +27 -3
- package/dist/core/tool-result-bytes.js +53 -0
- package/dist/core/tool-result-store.d.ts +11 -4
- package/dist/core/tool-result-store.js +6 -2
- package/dist/core/tool-roster.d.ts +33 -22
- package/dist/core/tool-roster.js +28 -18
- package/dist/core/tool-spec-members.d.ts +12 -0
- package/dist/core/tool-spec-members.js +31 -0
- package/dist/core/tool-spec.d.ts +41 -28
- package/dist/core/trace.d.ts +21 -64
- package/dist/core/trace.js +2 -3
- package/dist/core/types.d.ts +7 -7
- package/dist/core/types.js +2 -2
- package/dist/core/unavailable-landing.d.ts +72 -0
- package/dist/core/unavailable-landing.js +18 -0
- package/dist/core/untrusted-egress.d.ts +27 -5
- package/dist/core/untrusted-egress.js +30 -8
- package/dist/core/usage-window-store.d.ts +11 -1
- package/dist/core/usage-window-store.js +5 -0
- package/dist/core/user-attachment.d.ts +74 -48
- package/dist/core/user-attachment.js +137 -69
- package/dist/core/user-row-origin.d.ts +10 -0
- package/dist/core/user-row-origin.js +6 -0
- package/dist/core/wiring-manifest.d.ts +94 -24
- package/dist/core/wiring-manifest.js +65 -13
- package/dist/core/workflow-journal-store.d.ts +16 -7
- package/dist/core/workflow-journal-store.js +34 -6
- package/dist/core/workflow-run-store-contract.js +102 -0
- package/dist/core/workflow-run-store.d.ts +95 -4
- package/dist/core/workflow-run-store.js +74 -11
- package/dist/engine/compaction/compaction.d.ts +15 -3
- package/dist/engine/compaction/compaction.js +29 -10
- package/dist/engine/execution-env/kill-tree.js +44 -49
- package/dist/engine/execution-env/node-execution-env.d.ts +3 -1
- package/dist/engine/execution-env/node-execution-env.js +18 -11
- package/dist/engine/harness/agent-harness.d.ts +13 -0
- package/dist/engine/harness/agent-harness.js +16 -1
- package/dist/engine/harness/types.d.ts +100 -30
- package/dist/engine/harness/types.js +36 -4
- package/dist/engine/llm/rejected-images.js +1 -1
- package/dist/engine/llm/types.d.ts +22 -2
- package/dist/engine/llm/types.js +5 -2
- package/dist/engine/loop/agent-loop.js +43 -11
- package/dist/engine/loop/types.d.ts +11 -0
- package/dist/engine/session/import-validate.d.ts +9 -0
- package/dist/engine/session/import-validate.js +50 -9
- package/dist/engine/session/memory-repo.d.ts +5 -1
- package/dist/engine/session/memory-repo.js +8 -3
- package/dist/engine/session/parent-chain-guard.js +1 -1
- package/dist/engine/session/path-to-root.js +1 -1
- package/dist/engine/session/repo-utils.d.ts +19 -12
- package/dist/engine/session/repo-utils.js +12 -7
- package/dist/engine/session/session.d.ts +30 -10
- package/dist/engine/session/session.js +52 -20
- package/dist/engine/session/storage-base.js +2 -2
- package/dist/fixtures/index.d.ts +3 -1
- package/dist/fixtures/index.js +3 -0
- package/dist/host-env.d.ts +17 -0
- package/dist/host-env.js +1 -0
- package/dist/index.d.ts +83 -41
- package/dist/index.js +64 -30
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +5 -3
- package/dist/internal/harness.js +4 -3
- package/dist/internal/llm.d.ts +1 -1
- package/dist/internal/llm.js +1 -1
- package/dist/orchestration/run-workflow-tool.d.ts +40 -12
- package/dist/orchestration/run-workflow-tool.js +205 -102
- package/dist/orchestration/workflow-catalog.d.ts +254 -0
- package/dist/orchestration/workflow-catalog.js +702 -0
- package/dist/orchestration/workflow-governance.d.ts +1 -1
- package/dist/orchestration/workflow-meta.d.ts +11 -1
- package/dist/orchestration/workflow-meta.js +48 -0
- package/dist/orchestration/workflow-observe.d.ts +8 -10
- package/dist/orchestration/workflow-observe.js +6 -1
- package/dist/orchestration/workflow-park-adoption.d.ts +71 -33
- package/dist/orchestration/workflow-park-adoption.js +153 -40
- package/dist/orchestration/workflow-requirements.d.ts +51 -0
- package/dist/orchestration/workflow-requirements.js +54 -0
- package/dist/orchestration/workflow-script-runner.d.ts +18 -0
- package/dist/orchestration/workflow-script-store.d.ts +19 -64
- package/dist/orchestration/workflow-script-store.js +1 -24
- package/dist/orchestration/workflow-types.d.ts +173 -41
- package/dist/orchestration/workflow-types.js +22 -4
- package/dist/orchestration/workflow.d.ts +56 -42
- package/dist/orchestration/workflow.js +654 -139
- package/dist/prompt-assembly/catalog/core-behavior.js +6 -2
- package/dist/prompt-assembly/catalog/engine.d.ts +36 -0
- package/dist/prompt-assembly/catalog/engine.js +4 -0
- package/dist/prompt-assembly/catalog/events.d.ts +16 -0
- package/dist/prompt-assembly/catalog/events.js +2 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.js +7 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.js +4 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/events.js +2 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/mechanism.js +2 -2
- package/dist/prompt-assembly/catalog/mechanism.js +2 -2
- package/dist/prompt-assembly/catalog/schema.d.ts +5 -2
- package/dist/prompt-assembly/catalog/schema.js +1 -0
- package/dist/prompt-assembly/epoch.d.ts +26 -0
- package/dist/prompt-assembly/epoch.js +29 -0
- package/dist/prompt-assembly/event-registry.js +2 -0
- package/dist/prompt-assembly/tool-catalog.d.ts +1 -1
- package/dist/prompt-assembly/turn-snapshot.d.ts +1 -1
- package/dist/prompts/default.d.ts +2 -2
- package/dist/shell/lex.d.ts +10 -7
- package/dist/shell/lex.js +56 -6
- package/dist/stores/file/adoption/adopt.d.ts +12 -0
- package/dist/stores/file/adoption/adopt.js +78 -31
- package/dist/stores/file/adoption/marker.d.ts +48 -26
- package/dist/stores/file/adoption/marker.js +24 -11
- package/dist/stores/file/background-agent-store.d.ts +5 -0
- package/dist/stores/file/background-agent-store.js +26 -5
- package/dist/stores/file/data-root-declaration.js +2 -1
- package/dist/stores/file/descriptor-seat.d.ts +100 -0
- package/dist/stores/file/descriptor-seat.js +150 -0
- package/dist/stores/file/file-history-store.js +2 -1
- package/dist/stores/file/fs-atomic.d.ts +126 -78
- package/dist/stores/file/fs-atomic.js +313 -253
- package/dist/stores/file/index.d.ts +10 -1
- package/dist/stores/file/index.js +28 -16
- package/dist/stores/file/ledger-damage.js +6 -10
- package/dist/stores/file/lock-reading.d.ts +158 -0
- package/dist/stores/file/lock-reading.js +252 -0
- package/dist/stores/file/mailbox-store.d.ts +8 -5
- package/dist/stores/file/mailbox-store.js +23 -14
- package/dist/stores/file/permission-rule-adopt.js +11 -11
- package/dist/stores/file/permission-rule-store.d.ts +14 -3
- package/dist/stores/file/permission-rule-store.js +33 -37
- package/dist/stores/file/process-anchor.d.ts +85 -0
- package/dist/stores/file/process-anchor.js +392 -0
- package/dist/stores/file/session-policy-store.d.ts +18 -2
- package/dist/stores/file/session-policy-store.js +71 -5
- package/dist/stores/file/session-store.d.ts +19 -1
- package/dist/stores/file/session-store.js +51 -19
- package/dist/stores/file/shared-ledger.d.ts +3 -3
- package/dist/stores/file/task-list-store.js +1 -1
- package/dist/stores/file/tool-result-store.js +2 -1
- package/dist/stores/file/usage-window-store.js +1 -1
- package/dist/stores/file/workflow-journal-store.d.ts +5 -2
- package/dist/stores/file/workflow-journal-store.js +12 -25
- package/dist/stores/file/workflow-run-store.d.ts +5 -0
- package/dist/stores/file/workflow-run-store.js +19 -12
- package/dist/tools/artifact/artifact-text.d.ts +29 -11
- package/dist/tools/artifact/artifact-text.js +13 -6
- package/dist/tools/artifact/artifact-tool.d.ts +35 -5
- package/dist/tools/artifact/artifact-tool.js +240 -45
- package/dist/tools/artifact/conformance.d.ts +27 -5
- package/dist/tools/artifact/conformance.js +420 -45
- package/dist/tools/artifact/local-stub.d.ts +2 -2
- package/dist/tools/artifact/local-stub.js +29 -26
- package/dist/tools/fs/bash-failure-output.d.ts +64 -0
- package/dist/tools/fs/bash-failure-output.js +40 -0
- package/dist/tools/fs/bash-program-position.d.ts +7 -3
- package/dist/tools/fs/bash-program-position.js +9 -6
- package/dist/tools/fs/bash-readonly-classifier.d.ts +4 -3
- package/dist/tools/fs/bound-open.d.ts +9 -8
- package/dist/tools/fs/bound-open.js +6 -4
- package/dist/tools/fs/dead-cwd.d.ts +8 -0
- package/dist/tools/fs/dead-cwd.js +7 -7
- package/dist/tools/fs/file-read-check.d.ts +8 -6
- package/dist/tools/fs/file-read-check.js +8 -4
- package/dist/tools/fs/file-write-check.d.ts +14 -0
- package/dist/tools/fs/file-write-check.js +35 -0
- package/dist/tools/fs/find-actions.d.ts +186 -0
- package/dist/tools/fs/find-actions.js +538 -0
- package/dist/tools/fs/fs-bash.d.ts +6 -3
- package/dist/tools/fs/fs-bash.js +67 -60
- package/dist/tools/fs/fs-pdf.js +16 -5
- package/dist/tools/fs/fs-read.js +5 -3
- package/dist/tools/fs/fs-shared.d.ts +67 -3
- package/dist/tools/fs/fs-shared.js +70 -34
- package/dist/tools/fs/fs-write.d.ts +23 -3
- package/dist/tools/fs/fs-write.js +137 -33
- package/dist/tools/fs/index.d.ts +15 -2
- package/dist/tools/fs/index.js +8 -4
- package/dist/tools/fs/program-read-model.d.ts +17 -1
- package/dist/tools/fs/program-read-model.js +7 -2
- package/dist/tools/fs/program-read-model.rows.js +5 -1
- package/dist/tools/fs/read-deny-home.js +12 -5
- package/dist/tools/fs/read-floor.d.ts +16 -0
- package/dist/tools/fs/read-floor.js +10 -5
- package/dist/tools/fs/removal-targets.d.ts +22 -4
- package/dist/tools/fs/removal-targets.js +116 -6
- package/dist/tools/fs/safety.d.ts +2 -0
- package/dist/tools/fs/safety.js +9 -2
- package/dist/tools/fs/shell-read-bindings.d.ts +56 -7
- package/dist/tools/fs/shell-read-bindings.js +175 -26
- package/dist/tools/fs/shell-read-check.d.ts +11 -2
- package/dist/tools/fs/shell-read-check.js +31 -5
- package/dist/tools/fs/shell-read-command-environment.d.ts +56 -0
- package/dist/tools/fs/shell-read-command-environment.js +75 -0
- package/dist/tools/fs/shell-read-establish.js +62 -16
- package/dist/tools/fs/shell-read-judge.d.ts +52 -7
- package/dist/tools/fs/shell-read-judge.js +63 -21
- package/dist/tools/fs/shell-read-lost-walk.d.ts +19 -0
- package/dist/tools/fs/shell-read-lost-walk.js +35 -0
- package/dist/tools/fs/shell-read-plan.d.ts +4 -0
- package/dist/tools/fs/shell-read-plan.js +47 -13
- package/dist/tools/fs/shell-read-sourced.d.ts +4 -3
- package/dist/tools/fs/shell-read-sourced.js +28 -3
- package/dist/tools/fs/shell-read-start.d.ts +7 -0
- package/dist/tools/fs/shell-read-word.js +1 -0
- package/dist/tools/fs/shell-read-workdir.d.ts +9 -11
- package/dist/tools/fs/shell-read-workdir.js +20 -26
- package/dist/tools/fs/shell-read-write-targets.d.ts +13 -5
- package/dist/tools/fs/shell-read-write-targets.js +51 -9
- package/dist/tools/monitor.d.ts +2 -1
- package/dist/tools/monitor.js +2 -0
- package/dist/tools/scheduler-tools.d.ts +7 -4
- package/dist/tools/scheduler-tools.js +60 -20
- package/dist/tools/task-list.d.ts +11 -1
- package/dist/tools/task-list.js +187 -134
- package/dist/tools/todo.d.ts +1 -1
- package/dist/tools/worktree.js +10 -9
- package/package.json +6 -2
- package/test/export-surface.snapshot.json +592 -22
- package/wire-changes/core-stores-sql@7.68.7.json +39 -0
- package/wire-changes/core-stores-sql@7.70.0.json +414 -0
- package/wire-changes/core@7.68.7.json +140 -0
- package/wire-changes/core@7.70.0.json +14689 -0
- package/wire-changes/mods-kernel@7.68.7.json +39 -0
- package/wire-changes/mods-kernel@7.70.0.json +75 -0
- package/wire-changes/primitives@7.68.7.json +39 -0
- package/wire-changes/primitives@7.70.0.json +807 -0
- package/wire-changes/wiki-gate@7.68.7.json +39 -0
- package/wire-changes/wiki-gate@7.70.0.json +40 -0
- package/dist/core/cache-break-detector.d.ts +0 -98
- package/dist/core/cache-break-detector.js +0 -146
- package/dist/core/compaction-retired-members.d.ts +0 -12
- package/dist/core/compaction-retired-members.js +0 -22
- package/dist/core/loopback-host.d.ts +0 -18
- package/dist/core/loopback-host.js +0 -40
- package/dist/core/protocol-naming.d.ts +0 -95
- package/dist/core/protocol-naming.js +0 -70
- package/dist/core/protocol-table.d.ts +0 -88
- package/dist/core/protocol-table.js +0 -47
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { ABSOLUTE_HOST_PATH_MAX, isAbsoluteHostPath } from "@sema-agent/primitives";
|
|
1
2
|
import { userAttachmentOf } from "../../internal/llm.js";
|
|
2
3
|
import { normalizeFileText } from "../../tools/fs/encoding.js";
|
|
3
|
-
import { countLines, witnessesAfterDelivery } from "../../tools/fs/fs-shared.js";
|
|
4
|
-
import { expandHomeTilde, lexicalViewOf, pathFamilyOf, sha256, startsWithDriveLetter, withinAnyRoot } from "../../tools/fs/safety.js";
|
|
4
|
+
import { countLines, retireRead, witnessesAfterDelivery } from "../../tools/fs/fs-shared.js";
|
|
5
|
+
import { expandHomeTilde, isAbsoluteForFamily, lexicalViewOf, pathFamilyOf, sha256, startsWithDriveLetter, withinAnyRoot } from "../../tools/fs/safety.js";
|
|
5
6
|
import { relativeUnderRoot } from "../sensitive-path-policy.js";
|
|
6
7
|
import { ORG_ADJUDICATION_TIMEOUT_MS } from "../permission-rule-org.js";
|
|
7
8
|
import { isInstructionLaneEntry, mintInstructionFrames } from "../user-attachment.js";
|
|
@@ -18,18 +19,21 @@ import { cutInstructionText, INSTRUCTION_FILE_MAX_BYTES, INSTRUCTION_INCLUDE_MAX
|
|
|
18
19
|
export const NESTED_MEMORY_MAX_NAMES = 8;
|
|
19
20
|
export const NESTED_MEMORY_NAME_MAX = 255;
|
|
20
21
|
export const NESTED_MEMORY_MAX_HOST_RULES = 20;
|
|
22
|
+
export const NESTED_MEMORY_MAX_APPROVED_PATHS = 32;
|
|
23
|
+
export const HOST_TEXT_LEVELS = Object.freeze(["user", "managed", "project", "local"]);
|
|
24
|
+
const OWNER_OF_LEVEL = { user: "deployment", managed: "deployment", project: "repository", local: "local" };
|
|
21
25
|
export const NESTED_MEMORY_PROBES_PER_LOAD = 32;
|
|
22
26
|
export const NESTED_MEMORY_FRAME_BUDGET_FILES = 3;
|
|
23
27
|
export const NESTED_MEMORY_STAT_BATCH = 8;
|
|
24
28
|
export const NESTED_MEMORY_PROBE_FACE = "nested-memory";
|
|
25
29
|
export const INSTRUCTIONS_WITHHELD = "instructions.withheld";
|
|
26
|
-
export const INSTRUCTIONS_WITHHELD_REASONS = Object.freeze(["rule_denied", "outside_roots", "approval_required", "admission_unknown", "target_moved", "outside_its_root"]);
|
|
30
|
+
export const INSTRUCTIONS_WITHHELD_REASONS = Object.freeze(["rule_denied", "outside_roots", "approval_required", "admission_unknown", "target_moved", "outside_its_root", "too_many_texts", "unanchored"]);
|
|
27
31
|
export const INSTRUCTIONS_FAMILY_UNDECLARED = "instructions.family_undeclared";
|
|
28
32
|
export function instructionsFamilyUndeclaredNotice(sessionId) {
|
|
29
33
|
return {
|
|
30
34
|
code: INSTRUCTIONS_FAMILY_UNDECLARED,
|
|
31
35
|
message: "No instruction family is declared for this deployment's runs (`TaskSpec.instructionFamily` is absent), so no run reads any instruction file (CLAUDE.md or another) into the model's context. " +
|
|
32
|
-
"To have them read, declare the family on the task spec: `instructionFamily: { files: [...] }` names the files each directory is read for (`rulesDirs`, `alternate`, `includes`, `additionalDirectories` and `hostRules` are its other members). " +
|
|
36
|
+
"To have them read, declare the family on the task spec: `instructionFamily: { files: [...] }` names the files each directory is read for (`rulesDirs`, `alternate`, `localFiles`, `includes`, `additionalDirectories`, `externalIncludes` and `hostRules` — the host's texts, each `{ level, name, text, rule? }` — are its other members). " +
|
|
33
37
|
"Said once to each notice receiver (once per process with none wired); `projectMemory: \"disabled\"` on a request is the off switch that says it on purpose.",
|
|
34
38
|
detail: { sessionId },
|
|
35
39
|
};
|
|
@@ -41,7 +45,7 @@ export const NESTED_MEMORY_LANE = Object.freeze({
|
|
|
41
45
|
rootOrigin: "project_instructions",
|
|
42
46
|
echo: "steering_injected",
|
|
43
47
|
notice: INSTRUCTIONS_WITHHELD,
|
|
44
|
-
limits: Object.freeze({ maxNames: NESTED_MEMORY_MAX_NAMES, maxNameChars: NESTED_MEMORY_NAME_MAX, maxHostRules: NESTED_MEMORY_MAX_HOST_RULES, maxIncludeDepth: INSTRUCTION_INCLUDE_MAX_DEPTH, probesPerLoad: NESTED_MEMORY_PROBES_PER_LOAD }),
|
|
48
|
+
limits: Object.freeze({ maxNames: NESTED_MEMORY_MAX_NAMES, maxNameChars: NESTED_MEMORY_NAME_MAX, maxHostRules: NESTED_MEMORY_MAX_HOST_RULES, maxApprovedPaths: NESTED_MEMORY_MAX_APPROVED_PATHS, maxApprovedPathChars: ABSOLUTE_HOST_PATH_MAX, maxIncludeDepth: INSTRUCTION_INCLUDE_MAX_DEPTH, probesPerLoad: NESTED_MEMORY_PROBES_PER_LOAD }),
|
|
45
49
|
});
|
|
46
50
|
const refuse = (at, problem) => Object.assign(new Error(`${at}: ${problem}`), { code: "config.invalid_argument" });
|
|
47
51
|
const isPlain = (v) => v !== null && typeof v === "object" && !Array.isArray(v) && [Object.prototype, null].includes(Object.getPrototypeOf(v));
|
|
@@ -99,7 +103,7 @@ export function screenNestedMemory(spec, projectMemory) {
|
|
|
99
103
|
const retired = retiredKeyOf(v, RETIRED_INSTRUCTION_FAMILY_KEYS);
|
|
100
104
|
if (retired !== undefined)
|
|
101
105
|
throw retiredKeyRefusal({ key: `instructionFamily.${retired.key}`, replacement: retired.replacement }, "TaskSpec");
|
|
102
|
-
onlyKeys(v, ["files", "rulesDirs", "alternate", "includes", "additionalDirectories", "hostRules"], FIELD);
|
|
106
|
+
onlyKeys(v, ["files", "rulesDirs", "alternate", "localFiles", "includes", "additionalDirectories", "externalIncludes", "hostRules"], FIELD);
|
|
103
107
|
const flag = (key) => {
|
|
104
108
|
const f = v[key];
|
|
105
109
|
if (f !== undefined && typeof f !== "boolean")
|
|
@@ -124,46 +128,76 @@ export function screenNestedMemory(spec, projectMemory) {
|
|
|
124
128
|
const altRules = a["rulesDirs"] === undefined ? [] : screenNames(a["rulesDirs"], `${at}.rulesDirs`, seenDirs);
|
|
125
129
|
alternate = Object.freeze({ files: Object.freeze(altFiles), rulesDirs: Object.freeze(altRules), when });
|
|
126
130
|
}
|
|
131
|
+
const localFiles = v["localFiles"] === undefined ? [] : screenNames(v["localFiles"], `${FIELD}.localFiles`, seen);
|
|
127
132
|
const includes = flag("includes");
|
|
128
133
|
const additionalDirectories = flag("additionalDirectories");
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
134
|
+
const approvals = screenApprovedPaths(v["externalIncludes"]);
|
|
135
|
+
const host = v["hostRules"] === undefined ? { kept: [], skipped: [], names: [] } : screenHostRules(v["hostRules"]);
|
|
136
|
+
if (files.length === 0 && rulesDirs.length === 0 && alternate === undefined && localFiles.length === 0 && v["hostRules"] === undefined)
|
|
137
|
+
throw refuse(FIELD, "names nothing to load (no files, rulesDirs, alternate, localFiles or hostRules) — omit it instead.");
|
|
132
138
|
if (projectMemory === "disabled")
|
|
133
139
|
return undefined;
|
|
134
|
-
return Object.freeze({ files: Object.freeze(files), rulesDirs: Object.freeze(rulesDirs), ...(alternate !== undefined ? { alternate } : {}), includes, additionalDirectories, hostRules: Object.freeze(
|
|
140
|
+
return Object.freeze({ files: Object.freeze(files), rulesDirs: Object.freeze(rulesDirs), ...(alternate !== undefined ? { alternate } : {}), localFiles: Object.freeze(localFiles), includes, additionalDirectories, externalIncludes: Object.freeze(approvals.kept), externalIncludesSkipped: Object.freeze(approvals.skipped), hostRules: Object.freeze(host.kept), hostNames: Object.freeze(host.names), hostSkipped: Object.freeze(host.skipped) });
|
|
141
|
+
}
|
|
142
|
+
function screenApprovedPaths(v) {
|
|
143
|
+
const at = `${FIELD}.externalIncludes`;
|
|
144
|
+
if (v === undefined || v === false)
|
|
145
|
+
return { kept: [], skipped: [] };
|
|
146
|
+
if (!Array.isArray(v))
|
|
147
|
+
throw refuse(at, `must be false or a list of the absolute paths approved (got ${describeRejectedValue(v)}) — no approval covers every file: list each file by the value the engine named it by (\`instructions.withheld\`'s \`detail.target\`).`);
|
|
148
|
+
const entries = Array.from(v).map((p, i) => {
|
|
149
|
+
if (typeof p !== "string")
|
|
150
|
+
throw refuse(`${at}[${i}]`, `must be a string (got ${describeRejectedValue(p)}).`);
|
|
151
|
+
if (p.length <= ABSOLUTE_HOST_PATH_MAX && (p.includes("\u0000") || !isAbsoluteForFamily("own", p)))
|
|
152
|
+
throw refuse(`${at}[${i}]`, "must be an absolute path without NUL — the value the engine named the file by (`detail.target`, or `detail.path`), not the `@` text as written.");
|
|
153
|
+
return p;
|
|
154
|
+
});
|
|
155
|
+
const kept = [];
|
|
156
|
+
const skipped = [];
|
|
157
|
+
for (const [i, p] of entries.entries()) {
|
|
158
|
+
const why = i >= NESTED_MEMORY_MAX_APPROVED_PATHS ? "over_count" : p.length > ABSOLUTE_HOST_PATH_MAX ? "long_path" : undefined;
|
|
159
|
+
if (why === undefined)
|
|
160
|
+
kept.push(p);
|
|
161
|
+
else
|
|
162
|
+
skipped.push(Object.freeze({ path: p, why }));
|
|
163
|
+
}
|
|
164
|
+
return { kept, skipped };
|
|
135
165
|
}
|
|
136
166
|
function screenHostRules(v) {
|
|
137
167
|
const at = `${FIELD}.hostRules`;
|
|
138
168
|
if (!Array.isArray(v))
|
|
139
169
|
throw refuse(at, `must be an array (got ${describeRejectedValue(v)}).`);
|
|
140
|
-
|
|
141
|
-
throw refuse(at, `has ${v.length} rules, over ${NESTED_MEMORY_MAX_HOST_RULES}.`);
|
|
142
|
-
const names = new Set();
|
|
143
|
-
return Array.from(v).map((r, i) => {
|
|
170
|
+
const entries = Array.from(v).map((r, i) => {
|
|
144
171
|
const ra = `${at}[${i}]`;
|
|
145
172
|
if (!isPlain(r))
|
|
146
173
|
throw refuse(ra, `must be an object (got ${describeRejectedValue(r)}).`);
|
|
147
|
-
onlyKeys(r, ["level", "name", "
|
|
174
|
+
onlyKeys(r, ["level", "name", "text", "rule"], ra);
|
|
148
175
|
const level = r["level"];
|
|
149
|
-
if (level
|
|
150
|
-
throw refuse(`${ra}.level`, `must be
|
|
176
|
+
if (!HOST_TEXT_LEVELS.includes(level))
|
|
177
|
+
throw refuse(`${ra}.level`, `must be one of ${HOST_TEXT_LEVELS.map((l) => JSON.stringify(l)).join(", ")} (got ${describeRejectedValue(level)}).`);
|
|
151
178
|
const name = r["name"];
|
|
152
|
-
if (typeof name !== "string" || name.length === 0 || name.
|
|
153
|
-
throw refuse(`${ra}.name`, `must be a non-empty string
|
|
154
|
-
if (names.has(name))
|
|
155
|
-
throw refuse(`${ra}.name`, `repeats ${JSON.stringify(name)}.`);
|
|
156
|
-
names.add(name);
|
|
157
|
-
const paths = r["paths"];
|
|
158
|
-
if (!Array.isArray(paths) || paths.length === 0 || Array.from(paths).some((p) => typeof p !== "string" || p.length === 0))
|
|
159
|
-
throw refuse(`${ra}.paths`, `must be a non-empty array of globs (got ${describeRejectedValue(paths)}) — a rule with no paths belongs to the session's instructions.`);
|
|
179
|
+
if (typeof name !== "string" || name.length === 0 || name.includes("\u0000"))
|
|
180
|
+
throw refuse(`${ra}.name`, `must be a non-empty string without NUL (got ${describeRejectedValue(name)}).`);
|
|
160
181
|
const text = r["text"];
|
|
161
182
|
if (typeof text !== "string")
|
|
162
183
|
throw refuse(`${ra}.text`, `must be a string (got ${describeRejectedValue(text)}).`);
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
184
|
+
const rule = r["rule"];
|
|
185
|
+
if (rule !== undefined && typeof rule !== "boolean")
|
|
186
|
+
throw refuse(`${ra}.rule`, `must be a boolean (got ${describeRejectedValue(rule)}).`);
|
|
187
|
+
return Object.freeze({ level: level, name, text, rule: rule === true });
|
|
166
188
|
});
|
|
189
|
+
const kept = [];
|
|
190
|
+
const skipped = [];
|
|
191
|
+
const seen = new Set();
|
|
192
|
+
for (const [i, e] of entries.entries()) {
|
|
193
|
+
const why = i >= NESTED_MEMORY_MAX_HOST_RULES ? "over_count" : seen.has(e.name) ? "repeated" : e.name.length > ABSOLUTE_HOST_PATH_MAX ? "long_name" : Buffer.byteLength(e.text, "utf8") > INSTRUCTION_FILE_MAX_BYTES ? "large_text" : undefined;
|
|
194
|
+
seen.add(e.name);
|
|
195
|
+
if (why === undefined)
|
|
196
|
+
kept.push(e);
|
|
197
|
+
else
|
|
198
|
+
skipped.push(Object.freeze({ name: e.name, why }));
|
|
199
|
+
}
|
|
200
|
+
return { kept, skipped, names: entries.map((e) => e.name) };
|
|
167
201
|
}
|
|
168
202
|
export function instructionEchoOf(label, layer, withdrawn) {
|
|
169
203
|
return { source: layer === "root" ? "project_instructions" : "nested_memory", preview: steeringPreview(withdrawn ? `${label} (withdrawn: it no longer applies)` : label) };
|
|
@@ -203,19 +237,21 @@ const itemId = (i) => `${i.kind}\u0000${i.path}`;
|
|
|
203
237
|
const HOST_RULE_KEY = "host-rule:";
|
|
204
238
|
export function createNestedMemoryLane(seat) {
|
|
205
239
|
const decl = seat.declaration;
|
|
206
|
-
const
|
|
240
|
+
const hands = seat.env !== undefined ? seat : undefined;
|
|
241
|
+
const state = hands?.state ?? new Map();
|
|
242
|
+
const win = hands !== undefined && pathFamilyOf({ root: hands.root }) === "win";
|
|
207
243
|
const sep = win ? "\\" : "/";
|
|
208
244
|
const baseOf = (dir) => (dir.endsWith(sep) ? dir.slice(0, -1) : dir);
|
|
209
|
-
const roots = [{ base: baseOf(
|
|
210
|
-
for (const r of decl.additionalDirectories ? (
|
|
245
|
+
const roots = hands === undefined ? [] : [{ base: baseOf(hands.root), canonical: hands.root }];
|
|
246
|
+
for (const r of decl.additionalDirectories ? (hands?.additionalRoots ?? []) : []) {
|
|
211
247
|
const base = baseOf(r.canonical);
|
|
212
248
|
if (!roots.some((x) => x.base === base))
|
|
213
249
|
roots.push({ base, canonical: r.canonical, directory: r.directory });
|
|
214
250
|
}
|
|
215
251
|
const insideItsRoots = (r, key) => withinAnyRoot([roots[r].canonical, roots[0].canonical], key);
|
|
216
252
|
const absIn = (r, rel) => (rel === "" ? roots[r].base : `${roots[r].base}${sep}${win ? rel.replaceAll("/", "\\") : rel}`);
|
|
217
|
-
const relIn = (r, key) =>
|
|
218
|
-
|
|
253
|
+
const relIn = (r, key) => (roots[r] === undefined ? undefined : relUnder(roots[r].base, key));
|
|
254
|
+
const relUnder = (base, key) => {
|
|
219
255
|
const x = base === "" ? (key.startsWith(sep) ? key.slice(sep.length) : null) : relativeUnderRoot(key, base);
|
|
220
256
|
return x === null ? undefined : win ? x.replaceAll("\\", "/") : x;
|
|
221
257
|
};
|
|
@@ -234,8 +270,11 @@ export function createNestedMemoryLane(seat) {
|
|
|
234
270
|
const held = queued.get(id);
|
|
235
271
|
if (held !== undefined) {
|
|
236
272
|
const at = queue.indexOf(held);
|
|
237
|
-
if (rankOf(held) <= rankOf(i) || at < 0)
|
|
273
|
+
if (rankOf(held) <= rankOf(i) || at < 0) {
|
|
274
|
+
if (held.kind === "file" && i.kind === "file" && foundByLane(held) && foundByLane(i) && i.approved === true && held.approved !== true)
|
|
275
|
+
Object.assign(held, { approved: true, from: i.from });
|
|
238
276
|
return false;
|
|
277
|
+
}
|
|
239
278
|
queue.splice(at, 1);
|
|
240
279
|
if (i.kind === "file" && foundByLane(i) && held.kind === "file" && !foundByLane(held))
|
|
241
280
|
displaced.set(id, held);
|
|
@@ -247,11 +286,11 @@ export function createNestedMemoryLane(seat) {
|
|
|
247
286
|
const includesBy = new Map();
|
|
248
287
|
let hostRetry = false;
|
|
249
288
|
let seen;
|
|
250
|
-
let alternateOn = decl.alternate === undefined ? false : decl.alternate.when === "also" ? true : undefined;
|
|
289
|
+
let alternateOn = decl.alternate === undefined || hands === undefined ? false : decl.alternate.when === "also" ? true : undefined;
|
|
251
290
|
const entryId = (e) => `${e.hash}\u0000${e.lastReadAt ?? ""}\u0000${e.witnesses?.join("\u0001") ?? ""}`;
|
|
252
291
|
const isAccess = (e) => e.seededFromContext !== true && !isInstructionLaneEntry(e);
|
|
253
292
|
const deliveredEntry = (key) => {
|
|
254
|
-
const e =
|
|
293
|
+
const e = state.get(key);
|
|
255
294
|
return e !== undefined && isInstructionLaneEntry(e) ? e : undefined;
|
|
256
295
|
};
|
|
257
296
|
const withdrawing = new Set();
|
|
@@ -277,12 +316,14 @@ export function createNestedMemoryLane(seat) {
|
|
|
277
316
|
const activeNames = (r) => [...decl.files, ...(second(r) ? decl.alternate.files : [])];
|
|
278
317
|
const activeRules = (r) => [...decl.rulesDirs, ...(second(r) ? decl.alternate.rulesDirs : [])];
|
|
279
318
|
const memberAt = (rel, level, names, rules) => {
|
|
280
|
-
const
|
|
281
|
-
if (
|
|
319
|
+
const at = level === "" ? rel : rel.startsWith(`${level}/`) ? rel.slice(level.length + 1) : undefined;
|
|
320
|
+
if (at === undefined)
|
|
282
321
|
return undefined;
|
|
283
|
-
if (names.includes(
|
|
322
|
+
if (names.includes(at))
|
|
284
323
|
return "name";
|
|
285
|
-
|
|
324
|
+
if (decl.localFiles.includes(at))
|
|
325
|
+
return "local";
|
|
326
|
+
return rules.some((d) => at.startsWith(`${d}/`) && at.endsWith(".md")) ? "rule" : undefined;
|
|
286
327
|
};
|
|
287
328
|
const declaredOf = roots.map((_, r) => ({
|
|
288
329
|
names: [...decl.files, ...(r === 0 ? (decl.alternate?.files ?? []) : [])],
|
|
@@ -309,15 +350,20 @@ export function createNestedMemoryLane(seat) {
|
|
|
309
350
|
const join = (name) => absIn(r, level === "" ? name : `${level}/${name}`);
|
|
310
351
|
const names = activeNames(r);
|
|
311
352
|
const rules = activeRules(r);
|
|
353
|
+
const locals = () => decl.localFiles.forEach((name) => add({ kind: "file", root: r, level, path: join(name), rule: "none", depth: 0, owner: "local" }));
|
|
312
354
|
for (const name of names)
|
|
313
355
|
add({ kind: "file", root: r, level, path: join(name), rule: "none", depth: 0 });
|
|
356
|
+
if (level !== "")
|
|
357
|
+
locals();
|
|
314
358
|
for (const dir of rules)
|
|
315
359
|
add({ kind: "listing", root: r, level, path: join(dir) });
|
|
316
|
-
|
|
360
|
+
if (level === "")
|
|
361
|
+
locals();
|
|
362
|
+
for (const [key, e] of state) {
|
|
317
363
|
const rel = relIn(r, key);
|
|
318
364
|
const member = rel === undefined || rel === "" || !isInstructionLaneEntry(e) ? undefined : memberAt(rel, level, names, rules);
|
|
319
365
|
if (member !== undefined)
|
|
320
|
-
add({ kind: "file", root: r, level, path: key, rule: member === "
|
|
366
|
+
add({ kind: "file", root: r, level, path: key, rule: member === "rule" ? "any" : "none", depth: 0, ...(member === "local" ? { owner: "local" } : {}) });
|
|
321
367
|
}
|
|
322
368
|
return items;
|
|
323
369
|
};
|
|
@@ -332,13 +378,37 @@ export function createNestedMemoryLane(seat) {
|
|
|
332
378
|
queue.unshift(...back);
|
|
333
379
|
};
|
|
334
380
|
let primed;
|
|
381
|
+
const hostTexts = decl.hostRules.map((t) => {
|
|
382
|
+
const shown = processInstructionText(normalizeFileText(t.text), decl.includes);
|
|
383
|
+
return { ...t, shown, owner: OWNER_OF_LEVEL[t.level], anchored: hands !== undefined && isAbsoluteHostPath(t.name), conditional: t.rule && shown.globs !== undefined };
|
|
384
|
+
});
|
|
385
|
+
const anchorOf = (t) => {
|
|
386
|
+
if (!t.anchored || t.level === "user" || t.level === "managed")
|
|
387
|
+
return roots[0].base;
|
|
388
|
+
const name = win ? t.name.replaceAll("/", "\\") : t.name;
|
|
389
|
+
for (const d of [...decl.rulesDirs, ...(decl.alternate?.rulesDirs ?? [])]) {
|
|
390
|
+
const at = name.indexOf(`${sep}${win ? d.replaceAll("/", "\\") : d}${sep}`);
|
|
391
|
+
if (at >= 0)
|
|
392
|
+
return name.slice(0, at);
|
|
393
|
+
}
|
|
394
|
+
return baseOf(lexicalViewOf("..", name));
|
|
395
|
+
};
|
|
396
|
+
const hostKeys = new Map();
|
|
397
|
+
const hostKeyOf = async (name) => {
|
|
398
|
+
if (!hostKeys.has(name)) {
|
|
399
|
+
const r = await hands.reader.resolveTarget(name, { signal: seat.signal }).catch(() => undefined);
|
|
400
|
+
hostKeys.set(name, r?.ok === true ? r.key : undefined);
|
|
401
|
+
}
|
|
402
|
+
return hostKeys.get(name);
|
|
403
|
+
};
|
|
335
404
|
const collect = async (ask, echo) => {
|
|
336
405
|
const leg = seat.leg();
|
|
337
406
|
if (leg === undefined || seat.signal.aborted)
|
|
338
407
|
return [];
|
|
339
408
|
const accesses = new Set();
|
|
340
409
|
const current = new Map();
|
|
341
|
-
|
|
410
|
+
const firstLoad = seen === undefined;
|
|
411
|
+
for (const [key, e] of state) {
|
|
342
412
|
current.set(key, entryId(e));
|
|
343
413
|
const rel = relOf(key);
|
|
344
414
|
if (rel !== undefined && rel !== "" && isAccess(e))
|
|
@@ -362,7 +432,7 @@ export function createNestedMemoryLane(seat) {
|
|
|
362
432
|
else {
|
|
363
433
|
for (const [key, id] of current) {
|
|
364
434
|
const rel = relOf(key);
|
|
365
|
-
if (rel !== undefined && rel !== "" && seen.get(key) !== id && isAccess(
|
|
435
|
+
if (rel !== undefined && rel !== "" && seen.get(key) !== id && isAccess(state.get(key)))
|
|
366
436
|
touch(rel);
|
|
367
437
|
}
|
|
368
438
|
for (const key of seen.keys()) {
|
|
@@ -376,7 +446,7 @@ export function createNestedMemoryLane(seat) {
|
|
|
376
446
|
const p = { count: 0 };
|
|
377
447
|
if (alternateOn === undefined) {
|
|
378
448
|
p.count += decl.files.length;
|
|
379
|
-
const atRoot = await Promise.all(decl.files.map((name) =>
|
|
449
|
+
const atRoot = await Promise.all(decl.files.map((name) => hands.env.fileInfo(abs(name), seat.signal).catch(() => undefined)));
|
|
380
450
|
alternateOn = !atRoot.some((info) => info?.ok === true && info.value.kind !== "directory");
|
|
381
451
|
}
|
|
382
452
|
queueOwed(roots.flatMap((_, r) => levelItems(r, "")), true);
|
|
@@ -399,13 +469,14 @@ export function createNestedMemoryLane(seat) {
|
|
|
399
469
|
fresh.push(d);
|
|
400
470
|
say();
|
|
401
471
|
};
|
|
402
|
-
const withheld = (item, reason) => once(INSTRUCTIONS_WITHHELD, item.path, reason
|
|
472
|
+
const withheld = (item, reason, past, target) => once(INSTRUCTIONS_WITHHELD, item.path, target === undefined ? reason : `${reason}\n${target}`, () => {
|
|
403
473
|
if (delegated)
|
|
404
474
|
return;
|
|
405
475
|
const path = item.path;
|
|
406
476
|
const r = rootLevelOf(path);
|
|
407
|
-
const what = item.from !== undefined ? `An instruction file that ${item.from.key} includes (\`@${item.from.spelled}\`)` : `An instruction file of ${r === 0 ? "the task root" : r > 0 ? "an additional working directory" : "a directory the model accessed"}`;
|
|
408
|
-
|
|
477
|
+
const what = past !== undefined ? `An instruction text the deployment supplied, the first of ${past} past the ${NESTED_MEMORY_MAX_HOST_RULES} a task carries,` : item.from !== undefined ? `An instruction file that ${item.from.key} includes (\`@${item.from.spelled}\`)` : `An instruction file of ${r === 0 ? "the task root" : r > 0 ? "an additional working directory" : "a directory the model accessed"}`;
|
|
478
|
+
const via = item.from !== undefined ? { includedBy: item.from.key, spelled: item.from.spelled } : {};
|
|
479
|
+
deliverEngineNotice(seat.deps.onNotice, { code: INSTRUCTIONS_WITHHELD, message: `${what} was not loaded: ${path} (${WITHHELD_TEXT[reason]}). ${WITHHELD_WAY_OUT[reason]}`, detail: { path, reason, sessionId: leg.sessionId, runId: leg.runId, ...via, ...(target !== undefined ? { target } : {}) } });
|
|
409
480
|
});
|
|
410
481
|
const tellOperator = (lane, path, why, sentence) => once(lane, path, why, () => {
|
|
411
482
|
try {
|
|
@@ -417,6 +488,13 @@ export function createNestedMemoryLane(seat) {
|
|
|
417
488
|
const unread = (path, why) => tellOperator("nested_memory_unread", path, why, `instruction file ${path} was not loaded: ${why}`);
|
|
418
489
|
const unlimited = (path) => tellOperator("nested_memory_rule_paths", path, "no_limit", `instruction rule ${path} names \`paths:\` but it reads as no limit (nothing listed, only \`**\`, or a form the engine does not recognise), so the rule applies to every file; to limit it, list the globs (\`paths:\` then \`- src/**\` lines, or \`paths: [src/**, lib/**]\`); if every file is meant, remove the key`);
|
|
419
490
|
const spansLines = (path) => tellOperator("nested_memory_rule_paths", path, "spans_lines", `instruction rule ${path} gives \`paths:\` as one text over several lines, which reads as a single glob that matches no file, so the rule is never loaded; for several globs list them (\`paths:\` then \`- src/**\` lines) or write them on one line separated by commas (\`paths: src/**, lib/**\`)`);
|
|
491
|
+
const outside = new Map();
|
|
492
|
+
const refusedOutside = (item, wide, key, target) => {
|
|
493
|
+
const held = outside.get(item.path);
|
|
494
|
+
const edge = !foundByLane(item) || item.approved === true;
|
|
495
|
+
const told = held === undefined || (edge && !held.edge) ? { item, edge, key: key ?? item.path, target } : held;
|
|
496
|
+
outside.set(item.path, { ...told, wide: wide || held?.wide === true });
|
|
497
|
+
};
|
|
420
498
|
const reads = [];
|
|
421
499
|
const withdraw = (key, item) => {
|
|
422
500
|
if (inFlight.has(key))
|
|
@@ -429,14 +507,14 @@ export function createNestedMemoryLane(seat) {
|
|
|
429
507
|
item,
|
|
430
508
|
read: {
|
|
431
509
|
supply: "path",
|
|
432
|
-
owner: "repository",
|
|
510
|
+
owner: item.kind === "file" ? (item.owner ?? "repository") : "repository",
|
|
433
511
|
layer,
|
|
434
512
|
label: key,
|
|
435
513
|
text: "",
|
|
436
514
|
withdraws: true,
|
|
437
515
|
record: () => {
|
|
438
516
|
if (deliveredEntry(key) !== undefined)
|
|
439
|
-
|
|
517
|
+
retireRead(state, key);
|
|
440
518
|
seen?.delete(key);
|
|
441
519
|
inFlight.delete(key);
|
|
442
520
|
withdrawing.delete(key);
|
|
@@ -447,10 +525,24 @@ export function createNestedMemoryLane(seat) {
|
|
|
447
525
|
};
|
|
448
526
|
const visited = new Set();
|
|
449
527
|
const deadlineAt = Date.now() + ORG_ADJUDICATION_TIMEOUT_MS;
|
|
528
|
+
let approvedKeys;
|
|
529
|
+
const approvedByRequest = async (key) => {
|
|
530
|
+
if (key === undefined || decl.externalIncludes.length === 0)
|
|
531
|
+
return false;
|
|
532
|
+
approvedKeys ??= decl.externalIncludes.map((p) => hands.reader.resolveTarget(p, { signal: seat.signal }).then(judgedKeyOf, () => undefined));
|
|
533
|
+
return Promise.any(approvedKeys.map((k) => k.then((at) => (at === key ? true : Promise.reject(new Error("another file")))))).catch(() => false);
|
|
534
|
+
};
|
|
450
535
|
const ruleApplies = (globs, r, level) => [...accesses].some((a) => {
|
|
451
536
|
const rel = relIn(r, abs(a));
|
|
452
537
|
return rel !== undefined && rel !== "" && (level === "" || rel.startsWith(`${level}/`)) && ruleGlobsMatch(globs, level === "" ? rel : rel.slice(level.length + 1));
|
|
453
538
|
});
|
|
539
|
+
const hostApplies = (t) => {
|
|
540
|
+
const anchor = anchorOf(t);
|
|
541
|
+
return [...accesses].some((a) => {
|
|
542
|
+
const rel = relUnder(anchor, abs(a));
|
|
543
|
+
return rel !== undefined && rel !== "" && ruleGlobsMatch(t.shown.globs, rel);
|
|
544
|
+
});
|
|
545
|
+
};
|
|
454
546
|
const stats = new Map();
|
|
455
547
|
const statsAhead = (first) => {
|
|
456
548
|
if (first.kind !== "file" || stats.has(first.path))
|
|
@@ -459,7 +551,7 @@ export function createNestedMemoryLane(seat) {
|
|
|
459
551
|
const batch = [first, ...queue.filter((i) => i.kind === "file" && !stats.has(i.path))].slice(0, room);
|
|
460
552
|
p.count += batch.length;
|
|
461
553
|
for (const i of batch)
|
|
462
|
-
stats.set(i.path,
|
|
554
|
+
stats.set(i.path, hands.env.fileInfo(i.path, seat.signal).catch((err) => ({ ok: false, error: { code: "io", message: thrownText(err) } })));
|
|
463
555
|
};
|
|
464
556
|
const probeFile = async (item) => {
|
|
465
557
|
asked.add(item.path);
|
|
@@ -475,42 +567,45 @@ export function createNestedMemoryLane(seat) {
|
|
|
475
567
|
}
|
|
476
568
|
if (info.value.kind === "directory")
|
|
477
569
|
return [];
|
|
478
|
-
const
|
|
479
|
-
|
|
570
|
+
const heldToItsRoots = async (key) => foundByLane(item) && item.approved !== true && !(await approvedByRequest(key));
|
|
571
|
+
const outsideItsRoot = (key, judged) => {
|
|
572
|
+
refusedOutside(item, false, key, judged);
|
|
480
573
|
return member !== undefined ? [member] : [];
|
|
481
574
|
};
|
|
482
|
-
const target = await
|
|
575
|
+
const target = await hands.reader.resolveTarget(item.path, { signal: seat.signal });
|
|
483
576
|
if (!target.ok) {
|
|
484
577
|
const card = target.refusal.details?.type;
|
|
485
578
|
if (card === "read_path_denied")
|
|
486
579
|
withheld(item, "rule_denied");
|
|
487
|
-
else if (card === "path_not_in_root")
|
|
488
|
-
|
|
580
|
+
else if (card === "path_not_in_root") {
|
|
581
|
+
const judged = judgedKeyOf(target);
|
|
582
|
+
return (await heldToItsRoots(judged)) ? outsideItsRoot(undefined, judged) : (refusedOutside(item, true), []);
|
|
583
|
+
}
|
|
489
584
|
return [];
|
|
490
585
|
}
|
|
491
586
|
const key = target.key;
|
|
492
|
-
if (
|
|
493
|
-
return outsideItsRoot();
|
|
587
|
+
if (!insideItsRoots(item.root, key) && (await heldToItsRoots(key)))
|
|
588
|
+
return outsideItsRoot(key, key);
|
|
494
589
|
if (visited.has(key) || inFlight.has(key))
|
|
495
590
|
return [];
|
|
496
|
-
const stat = info.value.kind === "symlink" ? await
|
|
591
|
+
const stat = info.value.kind === "symlink" ? await hands.env.fileInfo(key, seat.signal).catch(() => undefined) : info;
|
|
497
592
|
if (stat === undefined || !stat.ok)
|
|
498
593
|
return [];
|
|
499
594
|
const mtime = stat.value.mtimeMs;
|
|
500
|
-
const entry =
|
|
595
|
+
const entry = state.get(key);
|
|
501
596
|
if (entry !== undefined && entry.lastReadAt === mtime && (!decl.includes || includesBy.has(key))) {
|
|
502
597
|
visited.add(key);
|
|
503
598
|
return includesAt(includesBy.get(key) ?? [], item, key);
|
|
504
599
|
}
|
|
505
|
-
const face =
|
|
600
|
+
const face = hands.readFace();
|
|
506
601
|
if (face === undefined) {
|
|
507
602
|
withheld(item, "admission_unknown");
|
|
508
603
|
return [];
|
|
509
604
|
}
|
|
510
605
|
p.count++;
|
|
511
|
-
const held = await
|
|
606
|
+
const held = await hands.reader.openBound(key, seat.signal);
|
|
512
607
|
try {
|
|
513
|
-
const verdict = await
|
|
608
|
+
const verdict = await hands.judge({ file_path: item.path, face }, NESTED_MEMORY_PROBE_FACE, { deadlineAt });
|
|
514
609
|
if (verdict.verdict !== "no_objection") {
|
|
515
610
|
withheld(item, verdict.verdict === "deny" ? "rule_denied" : verdict.verdict === "ask" ? "approval_required" : "admission_unknown");
|
|
516
611
|
return [];
|
|
@@ -520,7 +615,7 @@ export function createNestedMemoryLane(seat) {
|
|
|
520
615
|
return [];
|
|
521
616
|
}
|
|
522
617
|
visited.add(key);
|
|
523
|
-
const t = await
|
|
618
|
+
const t = await hands.reader.readText(key, { signal: seat.signal }, { judgedKey: key, capBytes: INSTRUCTION_FILE_MAX_BYTES, opened: { key, opening: held } });
|
|
524
619
|
return admit(t, item, key, mtime, entry);
|
|
525
620
|
}
|
|
526
621
|
finally {
|
|
@@ -567,15 +662,15 @@ export function createNestedMemoryLane(seat) {
|
|
|
567
662
|
const layer = layerOf(item.level);
|
|
568
663
|
const read = {
|
|
569
664
|
supply: "path",
|
|
570
|
-
owner: "repository",
|
|
665
|
+
owner: item.owner ?? "repository",
|
|
571
666
|
layer,
|
|
572
667
|
label: key,
|
|
573
668
|
text: cut.text,
|
|
574
669
|
...(cut.note !== undefined ? { cut: cut.note } : {}),
|
|
575
670
|
observation: { key, entry: recorded, stampedAt: mtime },
|
|
576
671
|
record: (transmission) => {
|
|
577
|
-
const landed = { ...recorded, lastReadAt: mtime, witnesses: witnessesAfterDelivery(
|
|
578
|
-
|
|
672
|
+
const landed = { ...recorded, lastReadAt: mtime, witnesses: witnessesAfterDelivery(state.get(key), recorded, transmission) };
|
|
673
|
+
state.set(key, landed);
|
|
579
674
|
seen?.set(key, entryId(landed));
|
|
580
675
|
inFlight.delete(key);
|
|
581
676
|
echo.fn?.(key, layer, false);
|
|
@@ -586,7 +681,7 @@ export function createNestedMemoryLane(seat) {
|
|
|
586
681
|
};
|
|
587
682
|
const includeTargetsOf = (paths, from) => {
|
|
588
683
|
const dir = lexicalViewOf("..", from);
|
|
589
|
-
const home =
|
|
684
|
+
const home = hands.env.homeDir;
|
|
590
685
|
return paths.flatMap((spelled) => {
|
|
591
686
|
if (!isTextIncludeTarget(spelled))
|
|
592
687
|
return [];
|
|
@@ -597,7 +692,7 @@ export function createNestedMemoryLane(seat) {
|
|
|
597
692
|
const includesAt = (targets, item, key) => item.depth + 1 >= INSTRUCTION_INCLUDE_MAX_DEPTH
|
|
598
693
|
? []
|
|
599
694
|
: targets.flatMap((t) => {
|
|
600
|
-
const next = { kind: "file", root: item.root, level: item.level, path: t.path ?? t.spelled, rule: "none", depth: item.depth + 1, from: { key, spelled: t.spelled } };
|
|
695
|
+
const next = { kind: "file", root: item.root, level: item.level, path: t.path ?? t.spelled, rule: "none", depth: item.depth + 1, from: { key, spelled: t.spelled }, ...(item.owner !== undefined ? { owner: item.owner } : {}), ...(item.approved === true ? { approved: true } : {}) };
|
|
601
696
|
if (t.path !== undefined)
|
|
602
697
|
return [next];
|
|
603
698
|
withheld(next, "admission_unknown");
|
|
@@ -606,7 +701,7 @@ export function createNestedMemoryLane(seat) {
|
|
|
606
701
|
const probeListing = async (item) => {
|
|
607
702
|
asked.add(item.path);
|
|
608
703
|
p.count++;
|
|
609
|
-
const listed = await
|
|
704
|
+
const listed = await hands.env.listDir(item.path, seat.signal).catch((err) => ({ ok: false, error: { code: "io", message: thrownText(err) } }));
|
|
610
705
|
if (!listed.ok) {
|
|
611
706
|
if (!QUIET_ERRORS.has(listed.error.code))
|
|
612
707
|
unread(item.path, listed.error.message);
|
|
@@ -620,57 +715,126 @@ export function createNestedMemoryLane(seat) {
|
|
|
620
715
|
};
|
|
621
716
|
const budget = NESTED_MEMORY_FRAME_BUDGET_FILES * cap;
|
|
622
717
|
let chars = 0;
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
718
|
+
const drain = async () => {
|
|
719
|
+
while (queue.length > 0 && p.count < probes && !seat.signal.aborted && chars <= budget) {
|
|
720
|
+
const item = queue.shift();
|
|
721
|
+
queued.delete(itemId(item));
|
|
722
|
+
statsAhead(item);
|
|
723
|
+
const before = reads.length;
|
|
724
|
+
let more;
|
|
725
|
+
try {
|
|
726
|
+
more = item.kind === "file" ? await probeFile(item) : await probeListing(item);
|
|
727
|
+
}
|
|
728
|
+
catch (err) {
|
|
729
|
+
unread(item.path, thrownText(err));
|
|
730
|
+
more = [];
|
|
731
|
+
}
|
|
732
|
+
for (const r of reads.slice(before))
|
|
733
|
+
chars += r.read.text.length;
|
|
734
|
+
queueOwed(more.filter(claim), true);
|
|
635
735
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
if (
|
|
736
|
+
};
|
|
737
|
+
await drain();
|
|
738
|
+
const familyReads = reads.splice(0);
|
|
739
|
+
const past = decl.hostSkipped.filter((s) => s.why === "over_count");
|
|
740
|
+
if (past.length > 0)
|
|
741
|
+
withheld({ path: past[0].name }, "too_many_texts", past.length);
|
|
742
|
+
for (const s of decl.hostSkipped)
|
|
743
|
+
if (s.why !== "over_count")
|
|
744
|
+
tellOperator("nested_memory_host_text", s.name, s.why, `instruction text ${shortName(s.name)} was not loaded: ${HOST_SKIP_TEXT[s.why]}`);
|
|
745
|
+
const pastApprovals = decl.externalIncludesSkipped.filter((s) => s.why === "over_count");
|
|
746
|
+
if (pastApprovals.length > 0)
|
|
747
|
+
tellOperator("nested_memory_approval", pastApprovals[0].path, "over_count", `${FIELD}.externalIncludes lists ${NESTED_MEMORY_MAX_APPROVED_PATHS + pastApprovals.length} paths: the first ${NESTED_MEMORY_MAX_APPROVED_PATHS} are read as approvals, the ${pastApprovals.length} after them (the first: ${shortName(pastApprovals[0].path)}) are not, so a file only they approve is not loaded`);
|
|
748
|
+
for (const s of decl.externalIncludesSkipped)
|
|
749
|
+
if (s.why === "long_path")
|
|
750
|
+
tellOperator("nested_memory_approval", s.path, s.why, `${FIELD}.externalIncludes holds a path of ${s.path.length} characters, over ${ABSOLUTE_HOST_PATH_MAX}: it is not read as an approval (${shortName(s.path)})`);
|
|
751
|
+
const rootLayer = [];
|
|
752
|
+
const nestedLayer = [];
|
|
753
|
+
const hostIncludes = [];
|
|
754
|
+
if (hostTexts.length > 0 || firstLoad || hostRetry) {
|
|
641
755
|
hostRetry = false;
|
|
642
|
-
const
|
|
643
|
-
const
|
|
644
|
-
|
|
645
|
-
const cut = cutInstructionText(r.text, cap, cpt);
|
|
646
|
-
if (cut.text.trim() === "" || shownNow.get(r.name) === cut.text)
|
|
647
|
-
continue;
|
|
648
|
-
const key = `${HOST_RULE_KEY}${r.name}`;
|
|
756
|
+
const shownNow = lastHostTexts(await leg.session.buildContext().then((c) => c.messages).catch(() => ((hostRetry = true), [])));
|
|
757
|
+
const hostRead = (name, layer, owner, cut) => {
|
|
758
|
+
const key = `${HOST_RULE_KEY}${name}`;
|
|
649
759
|
inFlight.add(key);
|
|
650
|
-
|
|
760
|
+
const read = { supply: "content_text", owner, layer, label: name, text: cut?.text ?? "", ...(cut === undefined ? { withdraws: true } : cut.note !== undefined ? { cut: cut.note } : {}), record: () => (inFlight.delete(key), echo.fn?.(name, layer, cut === undefined)) };
|
|
761
|
+
(layer === "root" ? rootLayer : nestedLayer).push({ key, item: { kind: "file", root: 0, level: "", path: key, rule: "none", depth: 0 }, read });
|
|
762
|
+
};
|
|
763
|
+
for (const t of hostTexts) {
|
|
764
|
+
if (inFlight.has(`${HOST_RULE_KEY}${t.name}`))
|
|
765
|
+
continue;
|
|
766
|
+
if (t.rule && t.shown.noLimit === true)
|
|
767
|
+
unlimited(t.name);
|
|
768
|
+
if (t.rule && t.shown.spansLines === true)
|
|
769
|
+
spansLines(t.name);
|
|
770
|
+
const last = shownNow.get(t.name);
|
|
771
|
+
if (t.shown.content.trim() === "") {
|
|
772
|
+
if (last?.text !== undefined)
|
|
773
|
+
hostRead(t.name, last.layer, t.owner);
|
|
774
|
+
continue;
|
|
775
|
+
}
|
|
776
|
+
if (t.conditional && hands === undefined)
|
|
777
|
+
tellOperator("nested_memory_host_text", t.name, "no_files", `instruction rule ${t.name} applies where its \`paths:\` match a file the run accesses, and this run has no files: it is not loaded`);
|
|
778
|
+
if (t.conditional && (hands === undefined || !hostApplies(t)))
|
|
779
|
+
continue;
|
|
780
|
+
const key = t.anchored ? await hostKeyOf(t.name) : undefined;
|
|
781
|
+
if (key !== undefined && !withdrawing.has(key) && (inFlight.has(key) || deliveredEntry(key) !== undefined)) {
|
|
782
|
+
tellOperator("nested_memory_host_text", t.name, "same_file", `instruction text ${t.name} is the instruction file ${key} the lane already loads: that file's frame is the one copy, the deployment's is not loaded`);
|
|
783
|
+
continue;
|
|
784
|
+
}
|
|
785
|
+
if (key !== undefined)
|
|
786
|
+
visited.add(key);
|
|
787
|
+
const from = { kind: "file", root: 0, level: "", path: t.name, rule: "none", depth: 0, owner: t.owner, ...(t.level === "user" ? { approved: true } : {}) };
|
|
788
|
+
if (t.anchored)
|
|
789
|
+
hostIncludes.push(...includesAt(includeTargetsOf(t.shown.includes, t.name), from, t.name));
|
|
790
|
+
else
|
|
791
|
+
for (const spelled of t.shown.includes.filter(isTextIncludeTarget))
|
|
792
|
+
if (isAbsoluteHostPath(t.name) || spelled.startsWith("~/") || isAbsoluteForFamily("own", spelled))
|
|
793
|
+
withheld({ path: spelled, from: { key: t.name, spelled } }, "unanchored");
|
|
794
|
+
const cut = cutInstructionText(t.shown.content, cap, cpt);
|
|
795
|
+
const layer = t.conditional ? "nested" : "root";
|
|
796
|
+
if (last?.text !== cut.text || last.layer !== layer)
|
|
797
|
+
hostRead(t.name, layer, t.owner, cut);
|
|
651
798
|
}
|
|
799
|
+
for (const [name, last] of shownNow)
|
|
800
|
+
if (last.text !== undefined && !decl.hostNames.includes(name) && !inFlight.has(`${HOST_RULE_KEY}${name}`))
|
|
801
|
+
hostRead(name, last.layer, "deployment");
|
|
652
802
|
}
|
|
803
|
+
queueOwed(hostIncludes.filter(claim), true);
|
|
804
|
+
await drain();
|
|
805
|
+
for (const r of outside.values())
|
|
806
|
+
if (!visited.has(r.key) && !(inFlight.has(r.key) && !withdrawing.has(r.key)) && !queued.has(itemId(r.item)))
|
|
807
|
+
withheld(r.item, r.wide ? "outside_roots" : "outside_its_root", undefined, r.wide ? undefined : r.target);
|
|
808
|
+
const includeReads = reads.splice(0);
|
|
809
|
+
reads.push(...rootLayer, ...includeReads, ...familyReads, ...nestedLayer);
|
|
653
810
|
if (fresh.length > 0) {
|
|
654
811
|
leg.announcedListingsRef.advisories = withAnnounceDigests(leg.announcedListingsRef.advisories, fresh);
|
|
655
812
|
leg.frameReceipts.listingSnapshotOwed = true;
|
|
656
813
|
}
|
|
657
814
|
return reads;
|
|
658
815
|
};
|
|
816
|
+
const fitLoad = (reads, leg) => {
|
|
817
|
+
const model = leg.harness.getModel();
|
|
818
|
+
const budget = NESTED_MEMORY_FRAME_BUDGET_FILES * instructionFileCap(model.contextWindow, model.charsPerToken ?? 4);
|
|
819
|
+
const taken = [...reads];
|
|
820
|
+
const disclosure = { reader: hands?.reader, mark: seat.mark, counts: seat.counts };
|
|
821
|
+
let minted = mintInstructionFrames(taken.map((r) => r.read), disclosure);
|
|
822
|
+
const sizeOf = (frames) => frames.reduce((n, f) => n + f.seed.content.reduce((m, b) => m + (b.type === "text" ? b.text.length : 0), 0), 0);
|
|
823
|
+
while (taken.length > 1 && sizeOf(minted.frames) > budget) {
|
|
824
|
+
taken.pop();
|
|
825
|
+
minted = mintInstructionFrames(taken.map((r) => r.read), disclosure);
|
|
826
|
+
}
|
|
827
|
+
return { taken, rest: reads.slice(taken.length), minted };
|
|
828
|
+
};
|
|
659
829
|
const mint = (reads) => {
|
|
660
830
|
const leg = seat.leg();
|
|
661
831
|
if (reads.length === 0 || leg === undefined) {
|
|
662
832
|
handBack(reads);
|
|
663
833
|
return undefined;
|
|
664
834
|
}
|
|
665
|
-
const
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
const sizeOf = (frames) => frames.reduce((n, f) => n + f.seed.content.reduce((m, b) => m + (b.type === "text" ? b.text.length : 0), 0), 0);
|
|
669
|
-
while (reads.length > 1 && sizeOf(minted.frames) > budget) {
|
|
670
|
-
handBack(reads.splice(-1));
|
|
671
|
-
minted = mintInstructionFrames(reads.map((r) => r.read), seat);
|
|
672
|
-
}
|
|
673
|
-
const taken = [...reads];
|
|
835
|
+
const { taken, rest, minted } = fitLoad(reads, leg);
|
|
836
|
+
for (let i = rest.length - 1; i >= 0; i--)
|
|
837
|
+
handBack([rest[i]]);
|
|
674
838
|
return {
|
|
675
839
|
inputId: minted.inputId,
|
|
676
840
|
frames: minted.frames,
|
|
@@ -708,15 +872,25 @@ export function createNestedMemoryLane(seat) {
|
|
|
708
872
|
}
|
|
709
873
|
return mint(reads);
|
|
710
874
|
},
|
|
875
|
+
owedAhead(triggers) {
|
|
876
|
+
const leg = seat.leg();
|
|
877
|
+
if (primed === undefined || leg === undefined)
|
|
878
|
+
return [];
|
|
879
|
+
const carried = new Set(triggers);
|
|
880
|
+
const reads = primed.reads.filter((r) => !(carried.has(r.key) && r.read.withdraws !== true));
|
|
881
|
+
return reads.length === 0 ? [] : fitLoad(reads, leg).minted.frames;
|
|
882
|
+
},
|
|
711
883
|
selected() {
|
|
884
|
+
if (hands === undefined)
|
|
885
|
+
return undefined;
|
|
712
886
|
const keys = roots.map(() => new Set());
|
|
713
|
-
for (const key of [...
|
|
887
|
+
for (const key of [...state.keys(), ...inFlight]) {
|
|
714
888
|
const r = withdrawing.has(key) ? -1 : rootLevelOf(key);
|
|
715
889
|
if (r >= 0)
|
|
716
890
|
keys[r].add(key);
|
|
717
891
|
}
|
|
718
892
|
const of = (r) => {
|
|
719
|
-
const names = declaredNamesOf(r);
|
|
893
|
+
const names = [...declaredNamesOf(r), ...decl.localFiles];
|
|
720
894
|
const rank = (rel) => {
|
|
721
895
|
const i = names.indexOf(rel);
|
|
722
896
|
return i < 0 ? names.length : i;
|
|
@@ -736,19 +910,33 @@ export async function primeInstructionLane(lane, manifest, report) {
|
|
|
736
910
|
catch (err) {
|
|
737
911
|
report(asThrownError(err));
|
|
738
912
|
}
|
|
739
|
-
|
|
913
|
+
const selected = lane.selected();
|
|
914
|
+
if (selected !== undefined)
|
|
915
|
+
manifest.instructions = selected;
|
|
740
916
|
}
|
|
741
|
-
function
|
|
917
|
+
function lastHostTexts(messages) {
|
|
742
918
|
const out = new Map();
|
|
743
919
|
for (const m of messages) {
|
|
744
920
|
const a = userAttachmentOf(m);
|
|
745
|
-
if (a
|
|
921
|
+
if (a === undefined || a.supply !== "content_text" || (a.origin !== "nested_memory" && a.origin !== "project_instructions"))
|
|
746
922
|
continue;
|
|
747
923
|
const blocks = m.content.slice(a.dataBlocks.start, a.dataBlocks.end);
|
|
748
|
-
out.set(a.label, blocks.map((b) => (b.type === "text" ? (b.text ?? "") : "")).join(""));
|
|
924
|
+
out.set(a.label, { text: a.withdraws !== undefined ? undefined : blocks.map((b) => (b.type === "text" ? (b.text ?? "") : "")).join(""), layer: a.origin === "project_instructions" ? "root" : "nested" });
|
|
749
925
|
}
|
|
750
926
|
return out;
|
|
751
927
|
}
|
|
928
|
+
const HOST_SKIP_TEXT = {
|
|
929
|
+
repeated: "an earlier text has the same name, and the first one is the one loaded",
|
|
930
|
+
long_name: `its name is over ${ABSOLUTE_HOST_PATH_MAX} characters`,
|
|
931
|
+
large_text: `it is over ${INSTRUCTION_FILE_MAX_BYTES} bytes, the bound an instruction file is read at`,
|
|
932
|
+
};
|
|
933
|
+
const shortName = (name) => (name.length > 256 ? `${name.slice(0, 256)}…` : name);
|
|
934
|
+
function judgedKeyOf(r) {
|
|
935
|
+
if (r.ok)
|
|
936
|
+
return r.key;
|
|
937
|
+
const card = r.refusal.details;
|
|
938
|
+
return card?.type === "path_not_in_root" && typeof card.target === "string" ? card.target : undefined;
|
|
939
|
+
}
|
|
752
940
|
const QUIET_ERRORS = new Set(["not_found", "not_directory", "aborted"]);
|
|
753
941
|
const WITHHELD_TEXT = {
|
|
754
942
|
rule_denied: "a read rule refuses it",
|
|
@@ -757,4 +945,16 @@ const WITHHELD_TEXT = {
|
|
|
757
945
|
admission_unknown: "the engine could not confirm it may be read",
|
|
758
946
|
target_moved: "it changed while it was being checked",
|
|
759
947
|
outside_its_root: "its real location, links followed, is under neither the root directory it was found in nor the task root",
|
|
948
|
+
too_many_texts: `a task carries the first ${NESTED_MEMORY_MAX_HOST_RULES} texts the deployment supplies, in its order`,
|
|
949
|
+
unanchored: "the text that includes it is not a file of the run's — it is named by a label, or the run has no files — so its includes are not followed",
|
|
950
|
+
};
|
|
951
|
+
const WITHHELD_WAY_OUT = {
|
|
952
|
+
rule_denied: "Remove the read rule that refuses it (a built-in credential row can be removed only by the deployment), or move the file to a path no rule refuses.",
|
|
953
|
+
outside_roots: "Point the link back inside those directories or make it a real file there, or add the directory it leads to among the session's additional directories.",
|
|
954
|
+
approval_required: "Remove the ask rule or policy (yours, the deployment's or the organization's) that makes reading it ask; an allow rule does not override an ask.",
|
|
955
|
+
admission_unknown: "Check that the run has the Read tool and, for a `~/` include, that the deployment declares a home directory; a check that could not answer is retried the next time instruction files are loaded.",
|
|
956
|
+
target_moved: "Nothing to change: it is checked again the next time instruction files are loaded.",
|
|
957
|
+
outside_its_root: "A file the lane found outside that root and the task root is loaded only when this project approves instruction files outside it (an approval applies from the next run); otherwise put the file inside one of them or point the link at one — adding directories or rules does not change this.",
|
|
958
|
+
too_many_texts: "Merge the texts, or leave out the ones not needed, so that what matters is among the first.",
|
|
959
|
+
unanchored: "Copy what it says into the text that includes it: an include is followed only from a text the deployment names by its absolute path on a run that has files.",
|
|
760
960
|
};
|