@sema-agent/core 7.67.3 → 7.68.1
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 +1537 -0
- package/README.md +18 -9
- package/README.zh-CN.md +16 -8
- package/dist/agents/agent-definition.d.ts +1 -1
- package/dist/agents/agent-definition.js +4 -1
- package/dist/agents/cascade.d.ts +2 -2
- package/dist/agents/cascade.js +3 -1
- package/dist/agents/cumulative-stats.d.ts +2 -1
- package/dist/agents/cumulative-stats.js +4 -1
- package/dist/agents/list-agents-tool.d.ts +30 -0
- package/dist/agents/list-agents-tool.js +45 -3
- package/dist/agents/peer-admission.d.ts +2 -2
- package/dist/agents/peer-session-drain.d.ts +2 -0
- package/dist/agents/peer-session-drain.js +1 -0
- package/dist/agents/repair-loop.js +3 -1
- package/dist/agents/retain-ledger.d.ts +61 -8
- package/dist/agents/retain-ledger.js +25 -3
- package/dist/agents/roster-store.d.ts +4 -2
- package/dist/agents/send-message-tool.d.ts +1 -1
- package/dist/agents/send-message-tool.js +20 -15
- package/dist/agents/subagent-steps.js +2 -10
- package/dist/agents/subagent.d.ts +3 -0
- package/dist/agents/subagent.js +106 -76
- package/dist/agents/tool-filter.d.ts +20 -11
- package/dist/agents/tool-filter.js +8 -4
- package/dist/agents/verify.d.ts +3 -1
- package/dist/agents/verify.js +2 -0
- package/dist/brain/anthropic.js +4 -4
- package/dist/brain/open-responses.js +3 -1
- package/dist/brain/openai.js +3 -1
- package/dist/brain/reasoning-request.d.ts +73 -19
- package/dist/brain/reasoning-request.js +164 -72
- package/dist/brain/reasoning-stamp.d.ts +26 -0
- package/dist/brain/reasoning-stamp.js +10 -0
- package/dist/brain/reasoning.d.ts +95 -162
- package/dist/brain/reasoning.js +31 -86
- package/dist/brain/route-adjudicator.d.ts +9 -7
- package/dist/brain/route-adjudicator.js +12 -10
- package/dist/brain/status-sink.d.ts +19 -64
- package/dist/brain/status-sink.js +5 -21
- package/dist/brain/stream-engine.d.ts +11 -2
- package/dist/brain/stream-engine.js +10 -0
- package/dist/core/a2a.d.ts +17 -5
- package/dist/core/a2a.js +11 -3
- package/dist/core/allow-entry.d.ts +35 -15
- package/dist/core/allow-entry.js +47 -60
- package/dist/core/ask-headline.d.ts +68 -0
- package/dist/core/ask-headline.js +23 -0
- package/dist/core/ask-origin.d.ts +36 -8
- package/dist/core/ask-origin.js +17 -10
- package/dist/core/ask-question.d.ts +34 -7
- package/dist/core/ask-question.js +10 -1
- package/dist/core/ask-unresolvable-notice.d.ts +7 -0
- package/dist/core/ask-unresolvable-notice.js +9 -3
- package/dist/core/auto-strip.d.ts +53 -0
- package/dist/core/auto-strip.js +76 -0
- package/dist/core/background-agent-store.d.ts +45 -5
- package/dist/core/background-agent-store.js +69 -15
- package/dist/core/background-shell.d.ts +2 -2
- package/dist/core/caller-text.js +2 -2
- package/dist/core/canonical-json.d.ts +13 -0
- package/dist/core/canonical-json.js +7 -0
- package/dist/core/checkpoint-features.d.ts +66 -20
- package/dist/core/checkpoint-features.js +12 -1
- package/dist/core/checkpoint-generation.d.ts +1 -1
- package/dist/core/checkpoint-queries.d.ts +1 -1
- package/dist/core/checkpoint-queries.js +4 -1
- package/dist/core/checkpoint-requirements.d.ts +45 -2
- package/dist/core/checkpoint-requirements.js +16 -6
- package/dist/core/checkpoint-row-verdict.d.ts +1 -0
- package/dist/core/checkpoint-row-verdict.js +4 -0
- package/dist/core/checkpoint-store.d.ts +66 -38
- package/dist/core/checkpoint-store.js +15 -6
- package/dist/core/child-clamp-seats.d.ts +6 -0
- package/dist/core/child-clamp-seats.js +1 -0
- package/dist/core/config-refusal-codes.d.ts +1 -1
- package/dist/core/config-refusal-codes.js +1 -0
- package/dist/core/delegation-frames.d.ts +9 -12
- package/dist/core/delegation-frames.js +9 -8
- package/dist/core/engine-capabilities.d.ts +21 -8
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +147 -34
- package/dist/core/engine-notice.js +27 -16
- package/dist/core/engine-storage-backend.d.ts +2 -1
- package/dist/core/env-budget.js +3 -3
- package/dist/core/env-knob-announce.d.ts +10 -10
- package/dist/core/env-knob-announce.js +3 -6
- package/dist/core/file-history-store.d.ts +29 -4
- package/dist/core/file-history-store.js +13 -0
- package/dist/core/frame-settlement.d.ts +2 -1
- package/dist/core/gate-fold.js +1 -1
- package/dist/core/gate-lanes.js +56 -49
- package/dist/core/governance-codes.d.ts +39 -3
- package/dist/core/governance-codes.js +61 -3
- package/dist/core/hooks.d.ts +29 -11
- package/dist/core/hooks.js +5 -2
- package/dist/core/human-input-projection.js +3 -3
- package/dist/core/input-author.d.ts +17 -3
- package/dist/core/input-author.js +15 -3
- package/dist/core/leg-identity.d.ts +10 -28
- package/dist/core/leg-identity.js +1 -21
- package/dist/core/lsp.d.ts +18 -13
- package/dist/core/lsp.js +30 -22
- package/dist/core/mailbox-store.d.ts +1 -1
- package/dist/core/mailbox-store.js +4 -4
- package/dist/core/mcp-connection-pool.d.ts +93 -4
- package/dist/core/mcp-connection-pool.js +104 -1
- package/dist/core/mcp-failure.d.ts +38 -12
- package/dist/core/mcp-failure.js +9 -13
- package/dist/core/mcp-probe.d.ts +4 -3
- package/dist/core/mcp-server-link.d.ts +4 -2
- package/dist/core/mcp-server-link.js +4 -5
- package/dist/core/mcp-server-spec.d.ts +3 -3
- package/dist/core/mcp-server-unavailable-notice.d.ts +22 -8
- package/dist/core/mcp-server-unavailable-notice.js +18 -4
- package/dist/core/mcp.d.ts +40 -6
- package/dist/core/mcp.js +39 -13
- package/dist/core/memory-engine/content-origin.js +2 -2
- package/dist/core/memory-engine/control-objects.d.ts +2 -4
- package/dist/core/memory-engine/control-objects.js +2 -10
- package/dist/core/memory-engine/delegation-settlement.js +6 -1
- package/dist/core/memory-engine/dual-root.js +3 -0
- package/dist/core/memory-engine/engine.d.ts +6 -4
- package/dist/core/memory-engine/engine.js +32 -29
- package/dist/core/memory-engine/file-backend.d.ts +20 -5
- package/dist/core/memory-engine/file-backend.js +21 -31
- package/dist/core/memory-engine/frontmatter.d.ts +2 -0
- package/dist/core/memory-engine/frontmatter.js +4 -0
- package/dist/core/memory-engine/layout.d.ts +114 -20
- package/dist/core/memory-engine/layout.js +340 -22
- package/dist/core/memory-engine/memory-deployment.d.ts +7 -5
- package/dist/core/memory-engine/mount-failed-notice.d.ts +19 -7
- package/dist/core/memory-engine/mount-failed-notice.js +43 -10
- package/dist/core/memory-engine/sync-client.js +4 -5
- package/dist/core/model-fallbacks.d.ts +5 -1
- package/dist/core/model-fallbacks.js +3 -3
- package/dist/core/model-receipt.d.ts +2 -1
- package/dist/core/model-receipt.js +12 -1
- package/dist/core/mods/kernel/dispatch.d.ts +2 -2
- package/dist/core/mods/kernel/dispatch.js +14 -6
- package/dist/core/mods/kernel/events.d.ts +8 -5
- package/dist/core/mods/kernel/events.js +2 -2
- package/dist/core/mods/kernel/index.d.ts +1 -1
- package/dist/core/mods/kernel/registration.d.ts +9 -0
- package/dist/core/mods/package.js +1 -1
- package/dist/core/mods/session-append.d.ts +4 -2
- package/dist/core/mods/session-append.js +3 -0
- package/dist/core/mods/stations.d.ts +7 -11
- package/dist/core/mods/stations.js +4 -7
- package/dist/core/mods/tool-call.d.ts +10 -8
- package/dist/core/mods/tool-call.js +15 -18
- package/dist/core/mounted-mcp.d.ts +0 -4
- package/dist/core/mounted-mcp.js +1 -1
- package/dist/core/park-noun.d.ts +24 -0
- package/dist/core/park-noun.js +21 -0
- package/dist/core/park-resumability.d.ts +60 -0
- package/dist/core/park-resumability.js +30 -0
- package/dist/core/permission-rule-provider.d.ts +24 -2
- package/dist/core/permission-rule-provider.js +11 -8
- package/dist/core/permission-rule-store.d.ts +8 -1
- package/dist/core/permission-rule-store.js +2 -3
- package/dist/core/permission-rules.d.ts +2 -1
- package/dist/core/permission-rules.js +8 -4
- package/dist/core/persisted-rule-arms.d.ts +3 -0
- package/dist/core/persisted-rule-arms.js +2 -1
- package/dist/core/present-plan-tool.d.ts +47 -3
- package/dist/core/present-plan-tool.js +62 -4
- package/dist/core/principal-name.d.ts +1 -1
- package/dist/core/principal-name.js +5 -5
- package/dist/core/process-identity.js +10 -5
- package/dist/core/protocol-http-auth.d.ts +20 -14
- package/dist/core/protocol-http-auth.js +70 -50
- package/dist/core/read-only-shell.js +9 -5
- package/dist/core/redaction-marks.d.ts +4 -26
- package/dist/core/redaction-marks.js +9 -21
- package/dist/core/remote-env.d.ts +43 -16
- package/dist/core/remote-env.js +1 -1
- package/dist/core/request-copy-projection.d.ts +1 -1
- package/dist/core/request-copy-projection.js +40 -50
- package/dist/core/resume-config-judge.js +1 -1
- package/dist/core/resume-startup-cause.d.ts +35 -18
- package/dist/core/resume-startup-cause.js +13 -10
- package/dist/core/retention.d.ts +167 -25
- package/dist/core/retention.js +100 -20
- package/dist/core/roles.d.ts +6 -0
- package/dist/core/roles.js +11 -5
- package/dist/core/rule-lane-reads.d.ts +3 -0
- package/dist/core/rule-lane-reads.js +5 -1
- package/dist/core/rule-store-fault.d.ts +70 -0
- package/dist/core/rule-store-fault.js +102 -0
- package/dist/core/runner/advertised-writable-dirs.js +16 -31
- package/dist/core/runner/announce-once-ledger.d.ts +19 -2
- package/dist/core/runner/announce-once-ledger.js +24 -2
- package/dist/core/runner/assemble-result.d.ts +6 -0
- package/dist/core/runner/assemble-result.js +1 -1
- package/dist/core/runner/auto-strip-notice.d.ts +36 -0
- package/dist/core/runner/auto-strip-notice.js +59 -0
- package/dist/core/runner/branch-window.d.ts +3 -0
- package/dist/core/runner/branch-window.js +37 -0
- package/dist/core/runner/caller-roster.d.ts +8 -3
- package/dist/core/runner/capability-withheld-seat.js +3 -9
- package/dist/core/runner/clock-and-limits.d.ts +22 -1
- package/dist/core/runner/clock-and-limits.js +30 -0
- package/dist/core/runner/contracts.d.ts +58 -35
- package/dist/core/runner/credential-refusal-seat.d.ts +2 -0
- package/dist/core/runner/credential-refusal-seat.js +47 -0
- package/dist/core/runner/cross-boundary-lane.js +6 -4
- package/dist/core/runner/decide-continuation.js +1 -1
- package/dist/core/runner/file-history-restore.d.ts +53 -2
- package/dist/core/runner/file-history-restore.js +29 -10
- package/dist/core/runner/forward-sink.d.ts +14 -1
- package/dist/core/runner/forward-sink.js +14 -12
- package/dist/core/runner/gate-exit.d.ts +8 -7
- package/dist/core/runner/gate-exit.js +13 -13
- package/dist/core/runner/git-status-frame.js +2 -4
- package/dist/core/runner/initial-run-state.js +1 -1
- package/dist/core/runner/main-call-account.d.ts +3 -1
- package/dist/core/runner/main-call-account.js +5 -3
- package/dist/core/runner/mcp-redial.d.ts +2 -5
- package/dist/core/runner/mcp-redial.js +2 -2
- package/dist/core/runner/nested-memory-content.d.ts +7 -1
- package/dist/core/runner/nested-memory-content.js +73 -13
- package/dist/core/runner/nested-memory-lane.d.ts +44 -19
- package/dist/core/runner/nested-memory-lane.js +152 -76
- package/dist/core/runner/park-commit.js +3 -1
- package/dist/core/runner/permission-rule-lanes.d.ts +8 -2
- package/dist/core/runner/permission-rule-lanes.js +29 -3
- package/dist/core/runner/person-path-rows.d.ts +3 -11
- package/dist/core/runner/person-path-rows.js +21 -24
- package/dist/core/runner/prepare-acquire-reconcile.js +3 -1
- package/dist/core/runner/prepare-artifact.d.ts +1 -1
- package/dist/core/runner/prepare-artifact.js +20 -14
- package/dist/core/runner/prepare-ask-lane.d.ts +9 -6
- package/dist/core/runner/prepare-ask-lane.js +6 -5
- package/dist/core/runner/prepare-boundary-parks.d.ts +7 -1
- package/dist/core/runner/prepare-boundary-parks.js +27 -24
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -2
- package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
- package/dist/core/runner/prepare-config-doors.d.ts +9 -24
- package/dist/core/runner/prepare-config-doors.js +58 -41
- package/dist/core/runner/prepare-context-lane.d.ts +2 -2
- package/dist/core/runner/prepare-context-lane.js +3 -5
- package/dist/core/runner/prepare-defer-classify.d.ts +1 -1
- package/dist/core/runner/prepare-defer-classify.js +1 -1
- package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
- package/dist/core/runner/prepare-delegation-surface.js +3 -2
- package/dist/core/runner/prepare-file-history.d.ts +62 -26
- package/dist/core/runner/prepare-file-history.js +117 -46
- package/dist/core/runner/prepare-gate-stations.d.ts +4 -0
- package/dist/core/runner/prepare-gate-stations.js +6 -5
- package/dist/core/runner/prepare-hands-readface.d.ts +9 -4
- package/dist/core/runner/prepare-hands-readface.js +8 -4
- package/dist/core/runner/prepare-inherited-gate.d.ts +11 -4
- package/dist/core/runner/prepare-inherited-gate.js +6 -6
- package/dist/core/runner/prepare-listings.d.ts +1 -1
- package/dist/core/runner/prepare-listings.js +1 -1
- package/dist/core/runner/prepare-memory.js +2 -2
- package/dist/core/runner/prepare-offload-wrappers.d.ts +1 -1
- package/dist/core/runner/prepare-offload-wrappers.js +1 -1
- package/dist/core/runner/prepare-park-ask.d.ts +10 -3
- package/dist/core/runner/prepare-park-ask.js +7 -9
- package/dist/core/runner/prepare-policy-chain.d.ts +18 -9
- package/dist/core/runner/prepare-policy-chain.js +18 -13
- package/dist/core/runner/prepare-project-context.d.ts +1 -1
- package/dist/core/runner/prepare-project-context.js +5 -3
- package/dist/core/runner/prepare-prompt-assembly.js +2 -1
- package/dist/core/runner/prepare-prompt-inputs.d.ts +2 -2
- package/dist/core/runner/prepare-prompt-inputs.js +1 -1
- package/dist/core/runner/prepare-protocol-tools.d.ts +4 -5
- package/dist/core/runner/prepare-protocol-tools.js +7 -7
- package/dist/core/runner/prepare-question-face.d.ts +4 -2
- package/dist/core/runner/prepare-run-refs.d.ts +7 -2
- package/dist/core/runner/prepare-run-refs.js +8 -7
- package/dist/core/runner/prepare-safety-scan.d.ts +4 -3
- package/dist/core/runner/prepare-suspend-saga.d.ts +3 -7
- package/dist/core/runner/prepare-suspend-saga.js +4 -3
- package/dist/core/runner/prepare-task.js +66 -53
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +3 -2
- package/dist/core/runner/prepare-tool-disclosure-mount.js +2 -1
- package/dist/core/runner/prepare-turn-wiring.d.ts +3 -1
- package/dist/core/runner/prepare-turn-wiring.js +1 -1
- package/dist/core/runner/prepare-wiring-manifest.d.ts +9 -4
- package/dist/core/runner/prepare-wiring-manifest.js +14 -6
- package/dist/core/runner/prepare-workspace-restore.d.ts +4 -4
- package/dist/core/runner/prepare-workspace-restore.js +15 -6
- package/dist/core/runner/remote-env-retry.d.ts +3 -3
- package/dist/core/runner/restore-seat.d.ts +41 -0
- package/dist/core/runner/restore-seat.js +38 -0
- package/dist/core/runner/resume-admission.js +1 -1
- package/dist/core/runner/resume-apply.js +4 -3
- package/dist/core/runner/resume-checkpoint-screen.js +2 -1
- package/dist/core/runner/resume-internals-and-config.js +2 -1
- package/dist/core/runner/resume-preflight.js +2 -1
- package/dist/core/runner/rewind-files.js +22 -6
- package/dist/core/runner/rule-store-unreadable-notice.d.ts +8 -0
- package/dist/core/runner/rule-store-unreadable-notice.js +11 -0
- package/dist/core/runner/run-brain-sinks.d.ts +3 -6
- package/dist/core/runner/run-brain-sinks.js +6 -6
- package/dist/core/runner/run-compaction-machinery.d.ts +2 -2
- package/dist/core/runner/run-git-lane.d.ts +2 -0
- package/dist/core/runner/run-git-lane.js +2 -1
- package/dist/core/runner/run-harness-handlers.js +5 -4
- package/dist/core/runner/run-identity-wiring.js +20 -12
- package/dist/core/runner/run-leg.js +31 -72
- package/dist/core/runner/run-notification-lane.d.ts +3 -0
- package/dist/core/runner/run-notification-lane.js +2 -4
- package/dist/core/runner/run-reasoning-seat.d.ts +5 -6
- package/dist/core/runner/run-reasoning-seat.js +13 -18
- package/dist/core/runner/run-settle-and-teardown.js +13 -9
- package/dist/core/runner/run-terminal-adoption.js +4 -8
- package/dist/core/runner/run-turn-boundary.js +6 -3
- package/dist/core/runner/runtask.d.ts +9 -4
- package/dist/core/runner/runtask.js +29 -22
- package/dist/core/runner/session-rule-policy.d.ts +11 -1
- package/dist/core/runner/shell-env-withheld.js +2 -7
- package/dist/core/runner/side-call-account.d.ts +5 -6
- package/dist/core/runner/side-call-account.js +2 -2
- package/dist/core/runner/stream-lifecycle-verbs.d.ts +3 -0
- package/dist/core/runner/stream-lifecycle-verbs.js +5 -3
- package/dist/core/runner/stream-settle-backstop.js +4 -6
- package/dist/core/runner/stream-steer-verb.d.ts +1 -1
- package/dist/core/runner/stream-steer-verb.js +4 -4
- package/dist/core/runner/sub-agent-deny-lists.d.ts +8 -3
- package/dist/core/runner/sub-agent-deny-lists.js +7 -4
- package/dist/core/runner/teardown-bounded.d.ts +7 -0
- package/dist/core/runner/teardown-bounded.js +7 -0
- package/dist/core/runner/terminal-account.js +41 -13
- package/dist/core/runner/terminal-projection.d.ts +1 -5
- package/dist/core/runner/tool-end-body.d.ts +9 -3
- package/dist/core/runner/tool-end-body.js +6 -3
- package/dist/core/runner/tool-output-projection.d.ts +13 -4
- package/dist/core/runner/tool-output-projection.js +10 -14
- package/dist/core/runner/turn-attachments.d.ts +3 -2
- package/dist/core/runner/turn-attachments.js +12 -5
- package/dist/core/runner-deps.d.ts +6 -6
- package/dist/core/runtime-caps.d.ts +2 -1
- package/dist/core/secret-env.d.ts +20 -3
- package/dist/core/secret-env.js +13 -15
- package/dist/core/session-checkout.d.ts +115 -15
- package/dist/core/session-checkout.js +435 -136
- package/dist/core/session-policy-store.js +21 -3
- package/dist/core/session-reconcile.js +1 -0
- package/dist/core/session-store.js +2 -0
- package/dist/core/session.d.ts +11 -1
- package/dist/core/shell-run-candidates.d.ts +1 -0
- package/dist/core/shell-run-candidates.js +1 -1
- package/dist/core/shutdown-debug.d.ts +6 -5
- package/dist/core/shutdown-debug.js +5 -1
- package/dist/core/skill-grant.js +4 -1
- package/dist/core/skills-directory.js +5 -3
- package/dist/core/spec-contract.d.ts +1 -1
- package/dist/core/store-contracts/checkpoint-store-contract.js +2 -7
- package/dist/core/store-contracts/file-history-store-contract.js +26 -2
- package/dist/core/store-contracts/session-deletion-cascade-contract.js +130 -14
- package/dist/core/store-contracts/task-list-store-contract.d.ts +2 -1
- package/dist/core/store-contracts/task-list-store-contract.js +28 -1
- package/dist/core/task-event.d.ts +48 -27
- package/dist/core/task-notification.d.ts +15 -9
- package/dist/core/task-notification.js +12 -0
- package/dist/core/task-registry-agent.d.ts +24 -22
- package/dist/core/task-registry-agent.js +65 -46
- package/dist/core/task-registry-shared.d.ts +17 -5
- package/dist/core/task-registry.d.ts +17 -6
- package/dist/core/task-registry.js +6 -1
- package/dist/core/task-result.d.ts +71 -25
- package/dist/core/task-spec-members.d.ts +0 -1
- package/dist/core/task-spec-members.js +1 -1
- package/dist/core/task-spec.d.ts +60 -52
- package/dist/core/task-stream.d.ts +45 -12
- package/dist/core/terminal-cause.d.ts +45 -8
- package/dist/core/terminal-cause.js +5 -0
- package/dist/core/tool-card-bound.d.ts +32 -0
- package/dist/core/tool-card-bound.js +33 -0
- package/dist/core/tool-catalog-entries.d.ts +9 -0
- package/dist/core/tool-catalog-entries.js +48 -0
- package/dist/core/tool-errors.d.ts +4 -3
- package/dist/core/tool-face.d.ts +3 -3
- package/dist/core/tool-mount-facts.d.ts +3 -2
- package/dist/core/tool-mount-facts.js +1 -1
- package/dist/core/tool-mount-static.js +7 -5
- package/dist/core/tool-policy.d.ts +21 -19
- package/dist/core/tool-policy.js +5 -6
- package/dist/core/tool-registry.d.ts +3 -1
- package/dist/core/tool-registry.js +15 -1
- package/dist/core/tool-result-store.d.ts +9 -3
- package/dist/core/tool-result-store.js +14 -1
- package/dist/core/tool-roster.d.ts +18 -0
- package/dist/core/tool-roster.js +30 -1
- package/dist/core/tool-spec.d.ts +17 -8
- package/dist/core/trace.d.ts +35 -31
- package/dist/core/types.d.ts +2 -2
- package/dist/core/untrusted-egress.d.ts +10 -9
- package/dist/core/untrusted-egress.js +9 -9
- package/dist/core/untrusted-text.d.ts +0 -18
- package/dist/core/untrusted-text.js +7 -3
- package/dist/core/user-attachment.d.ts +9 -6
- package/dist/core/user-attachment.js +12 -10
- package/dist/core/user-row-origin.d.ts +44 -25
- package/dist/core/user-row-origin.js +30 -20
- package/dist/core/wiring-manifest.d.ts +26 -7
- package/dist/core/wiring-manifest.js +14 -11
- package/dist/core/workspace-snapshot.d.ts +3 -1
- package/dist/core/workspace-snapshot.js +1 -0
- package/dist/engine/execution-env/node-execution-env.d.ts +23 -16
- package/dist/engine/execution-env/node-execution-env.js +127 -67
- package/dist/engine/harness/agent-harness.d.ts +4 -5
- package/dist/engine/harness/agent-harness.js +2 -7
- package/dist/engine/harness/types.d.ts +51 -19
- package/dist/engine/harness/types.js +28 -1
- package/dist/engine/llm/types.d.ts +26 -14
- package/dist/engine/llm/types.js +2 -2
- package/dist/engine/loop/agent-loop.d.ts +2 -2
- package/dist/engine/loop/agent-loop.js +51 -275
- package/dist/engine/loop/types.d.ts +0 -18
- package/dist/engine/session/import-validate.d.ts +3 -0
- package/dist/engine/session/import-validate.js +34 -2
- package/dist/engine/session/repo-utils.d.ts +42 -4
- package/dist/engine/session/repo-utils.js +33 -5
- package/dist/engine/session/session.d.ts +41 -14
- package/dist/engine/session/session.js +96 -25
- package/dist/index.d.ts +21 -16
- package/dist/index.js +16 -10
- package/dist/orchestration/run-spec.d.ts +1 -1
- package/dist/orchestration/run-workflow-tool.d.ts +12 -9
- package/dist/orchestration/run-workflow-tool.js +15 -19
- package/dist/orchestration/workflow-governance.js +13 -21
- package/dist/orchestration/workflow-observe.d.ts +4 -3
- package/dist/orchestration/workflow-primitives.d.ts +1 -1
- package/dist/orchestration/workflow-record-artifact.d.ts +14 -0
- package/dist/orchestration/workflow-record-artifact.js +32 -0
- package/dist/orchestration/workflow-script-store.d.ts +9 -0
- package/dist/orchestration/workflow-script-store.js +20 -1
- package/dist/orchestration/workflow-types.d.ts +33 -3
- package/dist/orchestration/workflow.d.ts +24 -14
- package/dist/orchestration/workflow.js +52 -23
- package/dist/prompt-assembly/artifact.js +4 -8
- package/dist/prompt-assembly/catalog/engine.d.ts +263 -0
- package/dist/prompt-assembly/catalog/engine.js +30 -0
- package/dist/prompt-assembly/catalog/index.d.ts +1 -1
- package/dist/prompt-assembly/catalog/index.js +2 -2
- package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.d.ts +1 -1
- package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.js +29 -0
- package/dist/prompt-assembly/epoch.js +6 -8
- package/dist/prompt-assembly/turn-snapshot.js +8 -9
- package/dist/stores/file/background-agent-store.js +5 -6
- package/dist/stores/file/checkpoint-store.d.ts +0 -4
- package/dist/stores/file/checkpoint-store.js +7 -3
- package/dist/stores/file/file-history-store.d.ts +8 -0
- package/dist/stores/file/file-history-store.js +72 -0
- package/dist/stores/file/fs-atomic.js +17 -12
- package/dist/stores/file/index.js +11 -5
- package/dist/stores/file/mailbox-store.js +13 -4
- package/dist/stores/file/permission-rule-store.js +14 -13
- package/dist/stores/file/shared-ledger.d.ts +4 -0
- package/dist/stores/file/shared-ledger.js +4 -0
- package/dist/stores/file/task-list-store.js +12 -3
- package/dist/stores/file/workflow-run-store.js +1 -0
- package/dist/tools/fs/bash-program-position.d.ts +4 -2
- package/dist/tools/fs/bash-program-position.js +1 -1
- package/dist/tools/fs/bash-readonly-classifier.js +1 -1
- package/dist/tools/fs/bound-open.d.ts +97 -0
- package/dist/tools/fs/bound-open.js +103 -0
- package/dist/tools/fs/containment-face.d.ts +2 -2
- package/dist/tools/fs/fs-pdf.d.ts +7 -1
- package/dist/tools/fs/fs-pdf.js +31 -23
- package/dist/tools/fs/fs-read.d.ts +24 -17
- package/dist/tools/fs/fs-read.js +84 -53
- package/dist/tools/fs/fs-shared.d.ts +14 -12
- package/dist/tools/fs/fs-shared.js +5 -4
- package/dist/tools/fs/fs-write.d.ts +2 -2
- package/dist/tools/fs/fs-write.js +20 -12
- package/dist/tools/fs/index.d.ts +4 -4
- package/dist/tools/fs/index.js +2 -2
- package/dist/tools/fs/notebook.d.ts +1 -1
- package/dist/tools/fs/pdf.d.ts +12 -3
- package/dist/tools/fs/pdf.js +22 -9
- package/dist/tools/fs/read-deny-home.d.ts +3 -2
- package/dist/tools/fs/read-deny-home.js +8 -11
- package/dist/tools/fs/safety.d.ts +3 -2
- package/dist/tools/fs/shell-read-check.js +10 -9
- package/dist/tools/monitor.d.ts +6 -5
- package/dist/tools/task-list.d.ts +16 -6
- package/dist/tools/task-list.js +4 -0
- package/dist/tools/web.d.ts +9 -1
- package/dist/tools/web.js +8 -3
- package/dist/tools/worktree.d.ts +7 -5
- package/dist/tools/worktree.js +4 -3
- package/package.json +4 -3
- package/test/export-surface.snapshot.json +93 -7
- package/wire-changes/core-stores-sql@7.68.0.json +39 -0
- package/wire-changes/core-stores-sql@7.68.1.json +39 -0
- package/wire-changes/core@7.68.0.json +4257 -0
- package/wire-changes/core@7.68.1.json +95 -0
- package/wire-changes/mods-kernel@7.68.0.json +129 -0
- package/wire-changes/mods-kernel@7.68.1.json +39 -0
- package/wire-changes/primitives@7.68.0.json +253 -0
- package/wire-changes/primitives@7.68.1.json +39 -0
- package/wire-changes/wiki-gate@7.68.0.json +39 -0
- package/wire-changes/wiki-gate@7.68.1.json +39 -0
- package/dist/core/runner/credential-origin-seat.d.ts +0 -2
- package/dist/core/runner/credential-origin-seat.js +0 -20
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { describeThrown } from "./tool-policy.js";
|
|
2
2
|
import { ORG_ADJUDICATION_TIMEOUT_MS, settleOrgVerdictWithin } from "./permission-rule-org.js";
|
|
3
3
|
import { isRuleBehavior, RULE_BEHAVIORS } from "./permission-rule-model.js";
|
|
4
|
+
import { readRuleStoreFaults } from "./rule-store-fault.js";
|
|
4
5
|
function isPlainOwnRecord(x) {
|
|
5
6
|
try {
|
|
6
7
|
if (x === null || typeof x !== "object" || Array.isArray(x))
|
|
@@ -113,7 +114,10 @@ export function normalizePersistedRuleHit(hit) {
|
|
|
113
114
|
return unreadableAnswer(hit === null ? "the answer is `null` — a lane with no rule for the call answers `undefined`" : "the answer is not a plain object");
|
|
114
115
|
if (ownDataValue(hit, "unreadable") === true) {
|
|
115
116
|
const reason = ownDataValue(hit, "reason");
|
|
116
|
-
|
|
117
|
+
if (typeof reason === "string")
|
|
118
|
+
return { unreadable: true, reason };
|
|
119
|
+
const faults = readRuleStoreFaults(ownDataValue(hit, "faults"));
|
|
120
|
+
return faults !== undefined ? { unreadable: true, faults } : { unreadable: true };
|
|
117
121
|
}
|
|
118
122
|
const rulesRaw = ownDataValue(hit, "rules");
|
|
119
123
|
const behavior = ownDataValue(hit, "behavior");
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why a person's stored permission rules could not be read — the ONE cause vocabulary, its ONE reader and the sentences
|
|
3
|
+
* that say it.
|
|
4
|
+
*
|
|
5
|
+
* The rule store refuses a read with an error that carries its kind: the code (`permission_rules.bucket_damaged` /
|
|
6
|
+
* `bucket_unreadable` / `later_grammar`, {@link PERMISSION_RULES_DAMAGED_BUCKET_CODE}…), the system error's name (`errno`) and,
|
|
7
|
+
* for a store directory the engine refuses to use, which way it is unsafe (`unsafe`: `"permissions"` — writable by group or
|
|
8
|
+
* others — or `"owner"` — another account's). {@link ruleStoreFaultReasonOf} is the only place those members are read into a
|
|
9
|
+
* word; every sentence and every notice member below is a projection of that word, so no consumer reads a refusal's prose.
|
|
10
|
+
*
|
|
11
|
+
* A fault names the partition(s) of the person's rules it took out (`sources`: the durable partition is the `user` and `project`
|
|
12
|
+
* sources, the session partition the `session` source) and a reason. It carries no path: where the store lives is the operator's
|
|
13
|
+
* disclosure line's, never a user's.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* The causes a read of the person's rules fails for — each one has its own clause and its own way out below.
|
|
17
|
+
*
|
|
18
|
+
* Four of them are the FILE store's words: `not_readable` and `read_failed` (the code `bucket_unreadable`), `unsafe_permissions` and
|
|
19
|
+
* `owner_mismatch` (the code `bucket_damaged` with its `unsafe` member) say "the folder or file that holds them". A store that is no
|
|
20
|
+
* file — a host's own — states only the causes that are true of it (`damaged` when the rules it serves are not in a form this engine
|
|
21
|
+
* reads, `no_answer`, `unclassified`, `later_grammar`): a store that stamps one of the four gets the sentence of a store that is a file.
|
|
22
|
+
*/
|
|
23
|
+
export declare const RULE_STORE_FAULT_REASONS: readonly ["not_readable", "read_failed", "unsafe_permissions", "owner_mismatch", "damaged", "later_grammar", "no_answer", "unclassified"];
|
|
24
|
+
export type RuleStoreFaultReason = (typeof RULE_STORE_FAULT_REASONS)[number];
|
|
25
|
+
/** The sources of the person's rules a partition serves (`org` is not a personal source and has its own status). */
|
|
26
|
+
export type RuleStoreSource = "user" | "project" | "session";
|
|
27
|
+
/** One read failure of one or more partitions of the person's rules. */
|
|
28
|
+
export interface RuleStoreFault {
|
|
29
|
+
/** The sources whose rows this failure took out of the read, in `user`, `project`, `session` order (empty = not said). */
|
|
30
|
+
readonly sources: readonly RuleStoreSource[];
|
|
31
|
+
readonly reason: RuleStoreFaultReason;
|
|
32
|
+
}
|
|
33
|
+
/** How a store directory the engine refuses to use is unsafe, as the file store states it on the refusal it throws (an own member
|
|
34
|
+
* beside `code` and `errno`): `permissions` — writable by group or others; `owner` — owned by another account. Absent for any
|
|
35
|
+
* other refusal. */
|
|
36
|
+
export type RuleStoreUnsafe = "permissions" | "owner";
|
|
37
|
+
/**
|
|
38
|
+
* The reason a store's refusal stands for — the one reading of its `code`, `errno` and `unsafe` members:
|
|
39
|
+
* · `later_grammar` — a newer engine wrote the bucket;
|
|
40
|
+
* · `bucket_unreadable` — the system refused or failed the read: `EACCES` / `EPERM` is `not_readable` (a permission), any other
|
|
41
|
+
* error `read_failed`;
|
|
42
|
+
* · `bucket_damaged` — `unsafe_permissions` / `owner_mismatch` where the refusal says which way the directory is unsafe, else
|
|
43
|
+
* `damaged` (a link, a file that is not a regular file, bytes that are not a rule file);
|
|
44
|
+
* · anything else — a store that states no code of ours — `unclassified`.
|
|
45
|
+
* `no_answer` is not a refusal's: a read that did not answer in time has no error to read, and the reader that waited says it.
|
|
46
|
+
*/
|
|
47
|
+
export declare function ruleStoreFaultReasonOf(err: unknown): RuleStoreFaultReason;
|
|
48
|
+
/** The sources in words (`user`, `user and project`, `user, project and session`). */
|
|
49
|
+
export declare function ruleStoreSourcesWord(sources: readonly RuleStoreSource[]): string;
|
|
50
|
+
/**
|
|
51
|
+
* The run's `permission.rule_store_unavailable` sentence (audience: the person): which partition, why, what it costs meanwhile, and
|
|
52
|
+
* what to repair. No path, no permission mode (the class is one no mode releases): until a read succeeds every call asks a person.
|
|
53
|
+
*/
|
|
54
|
+
export declare function ruleStoreUnreadableNoticeSentence(at: "prepare" | "call", faults: readonly RuleStoreFault[] | undefined): string;
|
|
55
|
+
/**
|
|
56
|
+
* The store form's ask message — the sentence the approval card carries and, when nobody can be asked, the sentence the model reads as
|
|
57
|
+
* the call's result. Names the partition and the cause, no path; tells the model what to do instead of retrying.
|
|
58
|
+
*/
|
|
59
|
+
export declare function ruleStoreUnreadableAskSentence(faults: readonly RuleStoreFault[] | undefined): string;
|
|
60
|
+
/** The identity of a fault set — what "the same thing said again" means for the person: each fault's sources and reason, order-free. */
|
|
61
|
+
export declare function ruleStoreFaultsKey(faults: readonly RuleStoreFault[]): string;
|
|
62
|
+
/** Whether a value is a reason of the closed set. */
|
|
63
|
+
export declare function isRuleStoreFaultReason(value: unknown): value is RuleStoreFaultReason;
|
|
64
|
+
/**
|
|
65
|
+
* A fault list a lane or a foreign store handed over, read once: a plain array of plain records whose `sources` are members of
|
|
66
|
+
* {@link RuleStoreSource} and whose `reason` is in the closed set — rebuilt from the values read, never the object given. Anything else
|
|
67
|
+
* reads as no faults (`undefined`): the sentences then say the cause is not given, and what the answer meant (an unreadable store) does
|
|
68
|
+
* not change.
|
|
69
|
+
*/
|
|
70
|
+
export declare function readRuleStoreFaults(value: unknown): readonly RuleStoreFault[] | undefined;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { PERMISSION_RULES_DAMAGED_BUCKET_CODE, PERMISSION_RULES_LATER_GRAMMAR_CODE, PERMISSION_RULES_UNREADABLE_BUCKET_CODE } from "./permission-rule-store.js";
|
|
2
|
+
export const RULE_STORE_FAULT_REASONS = Object.freeze(["not_readable", "read_failed", "unsafe_permissions", "owner_mismatch", "damaged", "later_grammar", "no_answer", "unclassified"]);
|
|
3
|
+
function ownMember(err, key) {
|
|
4
|
+
try {
|
|
5
|
+
if (typeof err !== "object" || err === null)
|
|
6
|
+
return undefined;
|
|
7
|
+
const d = Object.getOwnPropertyDescriptor(err, key);
|
|
8
|
+
return d !== undefined && "value" in d ? d.value : undefined;
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function ruleStoreFaultReasonOf(err) {
|
|
15
|
+
const code = ownMember(err, "code");
|
|
16
|
+
if (code === PERMISSION_RULES_LATER_GRAMMAR_CODE)
|
|
17
|
+
return "later_grammar";
|
|
18
|
+
if (code === PERMISSION_RULES_UNREADABLE_BUCKET_CODE) {
|
|
19
|
+
const errno = ownMember(err, "errno");
|
|
20
|
+
return errno === "EACCES" || errno === "EPERM" ? "not_readable" : "read_failed";
|
|
21
|
+
}
|
|
22
|
+
if (code === PERMISSION_RULES_DAMAGED_BUCKET_CODE) {
|
|
23
|
+
const unsafe = ownMember(err, "unsafe");
|
|
24
|
+
return unsafe === "permissions" ? "unsafe_permissions" : unsafe === "owner" ? "owner_mismatch" : "damaged";
|
|
25
|
+
}
|
|
26
|
+
return "unclassified";
|
|
27
|
+
}
|
|
28
|
+
const CLAUSE = Object.freeze({
|
|
29
|
+
not_readable: "the account that runs this agent is not allowed to read the folder or file that holds them",
|
|
30
|
+
read_failed: "the system reported an error while reading the file that holds them",
|
|
31
|
+
unsafe_permissions: "other accounts can write to the folder that holds them, so what is in it cannot be trusted",
|
|
32
|
+
owner_mismatch: "the folder that holds them belongs to another account",
|
|
33
|
+
damaged: "the stored rules, or what holds them, are damaged or not in the form this engine expects",
|
|
34
|
+
later_grammar: "a newer version of this engine wrote them",
|
|
35
|
+
no_answer: "the rules store did not answer in time",
|
|
36
|
+
unclassified: "the rules store reported an error",
|
|
37
|
+
});
|
|
38
|
+
const LOG_POINTER = Object.freeze({ details: "The operator's error log has the details.", folder: "The operator's error log says which folder." });
|
|
39
|
+
const WAY_OUT = Object.freeze({
|
|
40
|
+
not_readable: { act: "Give the account that runs this agent read access to that folder again.", log: "folder" },
|
|
41
|
+
read_failed: { act: "Check the disk that holds them.", log: "details" },
|
|
42
|
+
unsafe_permissions: { act: "Take write access to that folder away from other accounts (group and others).", log: "folder" },
|
|
43
|
+
owner_mismatch: { act: "Make the account that runs this agent the owner of that folder again, or restore a copy of it that account owns.", log: "folder" },
|
|
44
|
+
damaged: { act: "Restore a good copy of them, or clear them (clearing them gives up every saved rule).", log: "details" },
|
|
45
|
+
later_grammar: { act: "Run the newer version of this engine that wrote them, or restore an older copy." },
|
|
46
|
+
no_answer: { act: "Try again; if it keeps happening, check that the rules store is reachable." },
|
|
47
|
+
unclassified: { log: "details" },
|
|
48
|
+
});
|
|
49
|
+
export function ruleStoreSourcesWord(sources) {
|
|
50
|
+
return sources.length <= 1 ? sources.join("") : `${sources.slice(0, -1).join(", ")} and ${sources[sources.length - 1]}`;
|
|
51
|
+
}
|
|
52
|
+
function faultsClause(faults) {
|
|
53
|
+
if (faults.length === 1) {
|
|
54
|
+
const only = faults[0];
|
|
55
|
+
return { head: only.sources.length > 0 ? ` (${ruleStoreSourcesWord(only.sources)})` : "", clause: CLAUSE[only.reason] };
|
|
56
|
+
}
|
|
57
|
+
return { head: "", clause: faults.map((f) => `${f.sources.length > 0 ? `${ruleStoreSourcesWord(f.sources)}: ` : ""}${CLAUSE[f.reason]}`).join("; ") };
|
|
58
|
+
}
|
|
59
|
+
function waysOut(faults) {
|
|
60
|
+
const outs = faults.map((f) => WAY_OUT[f.reason]);
|
|
61
|
+
const acts = outs.flatMap((o) => (o.act !== undefined ? [o.act] : []));
|
|
62
|
+
const logs = outs.flatMap((o) => (o.log !== undefined ? [LOG_POINTER[o.log]] : []));
|
|
63
|
+
return [...new Set([...acts, ...logs])].join(" ");
|
|
64
|
+
}
|
|
65
|
+
const UNSAID = Object.freeze([Object.freeze({ sources: Object.freeze([]), reason: "unclassified" })]);
|
|
66
|
+
export function ruleStoreUnreadableNoticeSentence(at, faults) {
|
|
67
|
+
const { head, clause } = faultsClause(faults !== undefined && faults.length > 0 ? faults : UNSAID);
|
|
68
|
+
const fixes = waysOut(faults !== undefined && faults.length > 0 ? faults : UNSAID);
|
|
69
|
+
return `Your saved permission rules${head} could not be read ${at === "prepare" ? "when this run started" : "for a call on this run"}: ${clause}. Until a read of them succeeds, none of their allow rows (Read directory rows included) applies, while the deny and ask rows most recently read from them this run still apply — a deny row you removed since that read keeps refusing until then. While they cannot be read, every call is asked about rather than allowed, whatever its tool (rules nobody can read may name any), until a read of them succeeds. ${fixes} Every later check reads them again.`;
|
|
70
|
+
}
|
|
71
|
+
export function ruleStoreUnreadableAskSentence(faults) {
|
|
72
|
+
const { head, clause } = faultsClause(faults !== undefined && faults.length > 0 ? faults : UNSAID);
|
|
73
|
+
return `your saved permission rules${head} could not be read (${clause}), so whether one of them forbids this call is unknown and it needs a person's approval — if nobody can be asked, tell the person what is wrong with the rules store and carry on with the parts of the task that do not need this call`;
|
|
74
|
+
}
|
|
75
|
+
export function ruleStoreFaultsKey(faults) {
|
|
76
|
+
return faults.map((f) => `${f.sources.join("+")}:${f.reason}`).sort().join("|");
|
|
77
|
+
}
|
|
78
|
+
export function isRuleStoreFaultReason(value) {
|
|
79
|
+
return RULE_STORE_FAULT_REASONS.some((reason) => reason === value);
|
|
80
|
+
}
|
|
81
|
+
const SOURCE_ORDER = ["user", "project", "session"];
|
|
82
|
+
export function readRuleStoreFaults(value) {
|
|
83
|
+
try {
|
|
84
|
+
if (!Array.isArray(value) || value.length === 0 || value.length > SOURCE_ORDER.length)
|
|
85
|
+
return undefined;
|
|
86
|
+
const out = [];
|
|
87
|
+
for (const raw of value) {
|
|
88
|
+
const sources = ownMember(raw, "sources");
|
|
89
|
+
const reason = ownMember(raw, "reason");
|
|
90
|
+
if (!Array.isArray(sources) || !isRuleStoreFaultReason(reason))
|
|
91
|
+
return undefined;
|
|
92
|
+
const read = sources.filter((s) => SOURCE_ORDER.some((known) => known === s));
|
|
93
|
+
if (read.length !== sources.length)
|
|
94
|
+
return undefined;
|
|
95
|
+
out.push({ sources: SOURCE_ORDER.filter((s) => read.includes(s)), reason });
|
|
96
|
+
}
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -4,6 +4,7 @@ import { isWinFormPath, normalizeAbsPathLexically } from "../../tools/fs/safety.
|
|
|
4
4
|
import { validatePath } from "../effective-path-target.js";
|
|
5
5
|
import { inlineUntrusted } from "../untrusted-text.js";
|
|
6
6
|
import { envErrorDetail } from "../../tools/fs/env-error-detail.js";
|
|
7
|
+
import { readObjectAt } from "../../tools/fs/bound-open.js";
|
|
7
8
|
export const PLAN_FILE_INVALID_CODE = "config.plan_file_invalid";
|
|
8
9
|
export function planFileInvalid(value, why) {
|
|
9
10
|
let shown;
|
|
@@ -139,42 +140,26 @@ export class AdvertisedWritableDirs {
|
|
|
139
140
|
return canonical.error.code === "not_found" ? { ok: true, text: undefined } : { ok: false, reason: `${canonical.error.code}: ${envErrorDetail(canonical.error.message)}` };
|
|
140
141
|
if (canonical.value !== planFile.key)
|
|
141
142
|
return { ok: false, reason: `it now resolves to ${canonical.value} (a link replaced it or one of its directories), which is not read through` };
|
|
143
|
+
const stillTheKey = async (s) => {
|
|
144
|
+
const now = await this.env.canonicalPath(planFile.key, s);
|
|
145
|
+
return now.ok && now.value === planFile.key;
|
|
146
|
+
};
|
|
147
|
+
const opened = await readObjectAt(this.env, planFile.key, stillTheKey, signal);
|
|
148
|
+
if (!opened.ok)
|
|
149
|
+
return opened.error.code === "not_found" ? { ok: true, text: undefined } : { ok: false, reason: `${opened.error.code}: ${envErrorDetail(opened.error.message)}` };
|
|
150
|
+
const object = opened.value;
|
|
142
151
|
let bytes;
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
try {
|
|
148
|
-
if (held.value.kind !== "file")
|
|
149
|
-
return { ok: false, reason: `it is now a ${held.value.kind}` };
|
|
150
|
-
const read = await held.value.readBytes(PLAN_FILE_MAX_BYTES, signal);
|
|
151
|
-
if (!read.ok)
|
|
152
|
-
return { ok: false, reason: `${read.error.code}: ${envErrorDetail(read.error.message)}` };
|
|
153
|
-
bytes = read.value;
|
|
154
|
-
}
|
|
155
|
-
finally {
|
|
156
|
-
await held.value.close();
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
const leaf = await this.env.fileInfo(planFile.key, signal);
|
|
161
|
-
if (!leaf.ok)
|
|
162
|
-
return leaf.error.code === "not_found" ? { ok: true, text: undefined } : { ok: false, reason: `${leaf.error.code}: ${envErrorDetail(leaf.error.message)}` };
|
|
163
|
-
if (leaf.value.kind !== "file")
|
|
164
|
-
return { ok: false, reason: leaf.value.kind === "symlink" ? "it is now a symbolic link, which is not read through" : `it is now a ${leaf.value.kind}` };
|
|
165
|
-
if (leaf.value.size > PLAN_FILE_MAX_BYTES)
|
|
166
|
-
return { ok: false, reason: `it is ${leaf.value.size} bytes, over the ${PLAN_FILE_MAX_BYTES} a plan is read up to` };
|
|
167
|
-
const read = await this.env.readBinaryFile(planFile.key, signal);
|
|
152
|
+
try {
|
|
153
|
+
if (object.kind !== "file")
|
|
154
|
+
return { ok: false, reason: `it is now a ${object.kind}` };
|
|
155
|
+
const read = await object.readBytes(PLAN_FILE_MAX_BYTES, signal);
|
|
168
156
|
if (!read.ok)
|
|
169
157
|
return read.error.code === "not_found" ? { ok: true, text: undefined } : { ok: false, reason: `${read.error.code}: ${envErrorDetail(read.error.message)}` };
|
|
170
|
-
const after = await this.env.canonicalPath(planFile.key, signal);
|
|
171
|
-
const afterLeaf = await this.env.fileInfo(planFile.key, signal);
|
|
172
|
-
if (!after.ok || after.value !== planFile.key || !afterLeaf.ok || afterLeaf.value.kind !== "file")
|
|
173
|
-
return { ok: false, reason: "it changed while it was read (a link or another object replaced it), so it is not read through" };
|
|
174
|
-
if (read.value.length > PLAN_FILE_MAX_BYTES)
|
|
175
|
-
return { ok: false, reason: `it is ${read.value.length} bytes, over the ${PLAN_FILE_MAX_BYTES} a plan is read up to` };
|
|
176
158
|
bytes = read.value;
|
|
177
159
|
}
|
|
160
|
+
finally {
|
|
161
|
+
await object.close();
|
|
162
|
+
}
|
|
178
163
|
const text = new TextDecoder("utf-8").decode(bytes);
|
|
179
164
|
return { ok: true, text: text.trim() === "" ? undefined : text };
|
|
180
165
|
}
|
|
@@ -8,6 +8,11 @@ import type { RunnerDeps } from "../types.js";
|
|
|
8
8
|
* (`media-removed-seat.ts` — a session with many images can pass the bound): past it the oldest go, whichever face wrote
|
|
9
9
|
* them, and their fact is said again by a later run, never lost. The bound keeps the snapshot finite. */
|
|
10
10
|
export declare const ANNOUNCE_ONCE_MAX_DIGESTS = 200;
|
|
11
|
+
/** Say a fact about the deployment once to each notice receiver: `deliver` runs unless `sink` (the deployment's `onNotice`) has already been told `key`; a
|
|
12
|
+
* receiver is a function, as `deliverEngineNotice` reads the seat — with none (absent, or a seat holding anything else) the unit is the process. `key` is the notice's code. */
|
|
13
|
+
export declare function noticeOncePerSink(sink: ((notice: never) => void) | undefined, key: string, deliver: () => void): void;
|
|
14
|
+
/** Test seam (mirrors `__resetMalformedNoticeSeatAnnouncement`): forget what the default seat was told. Never called by production code. */
|
|
15
|
+
export declare function __resetNoticedOncePerSink(): void;
|
|
11
16
|
/** Stable digest of one announcement: `sha256(lane \n text)` as hex. Opaque on the wire; only ever
|
|
12
17
|
* compared for equality. */
|
|
13
18
|
export declare function announceDigest(lane: string, text: string): string;
|
|
@@ -49,6 +54,17 @@ export declare function droppedToolDigest(d: McpDroppedTool): string;
|
|
|
49
54
|
/** `existing ∪ add`, insertion-ordered, bounded to {@link ANNOUNCE_ONCE_MAX_DIGESTS} (oldest first
|
|
50
55
|
* out). Returns a NEW array; the input arrays are never mutated. */
|
|
51
56
|
export declare function withAnnounceDigests(existing: readonly string[] | undefined, add: readonly string[]): string[];
|
|
57
|
+
/** The session's announced record and the leg's receipt ledger, as a seat that tells the person something during the run reads them. */
|
|
58
|
+
export type RunTimeAnnounced = {
|
|
59
|
+
readonly announcedListingsRef: AnnouncedListingSnapshotInput;
|
|
60
|
+
readonly frameReceipts: {
|
|
61
|
+
listingSnapshotOwed: boolean;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
/** The run-time face of the once-per-session record (a fact met during the run, after prepare's ledger settled): `deliver` runs unless
|
|
65
|
+
* `digest` is in the session's announced record; then the digest joins it and its write is parked for the leg's flush
|
|
66
|
+
* ({@link flushOwedAnnouncedSnapshot}) — a lost append is the fact said again by a later run. Prepare's face: `oncePerSession`. */
|
|
67
|
+
export declare function tellOncePerSession(announced: RunTimeAnnounced, digest: string, deliver: () => void): void;
|
|
52
68
|
/** The session face this ledger needs: the nearest announced snapshot and the append. */
|
|
53
69
|
export interface AnnounceOnceSession {
|
|
54
70
|
getAnnouncedListing(): Promise<AnnouncedListingSnapshot | undefined>;
|
|
@@ -109,8 +125,9 @@ export interface AnnounceOnceLedger {
|
|
|
109
125
|
/** The MODEL-face pending set for this run: the currently failed servers (name/error neutralized +
|
|
110
126
|
* bounded at intake, the reminder's own bounds) MINUS the pairs already announced on this branch.
|
|
111
127
|
* As a side effect the record's `mcpFailed` arm is pruned to the pairs that are STILL failing —
|
|
112
|
-
* a recovered server leaves the record silently.
|
|
113
|
-
|
|
128
|
+
* a recovered server leaves the record silently. `remembered` answers whether the session's pool remembers a server's failure
|
|
129
|
+
* (the entry's `remembered`). Call once per prepare. */
|
|
130
|
+
mcpFailuresToAnnounce(statuses: ReadonlyArray<McpServerStatus>, remembered: (server: string) => boolean): McpUnavailableEntry[];
|
|
114
131
|
/** Remove, IN PLACE, the dropped-tool entries whose model-facing digest is already recorded (the
|
|
115
132
|
* frame was delivered on an earlier run of this session). The operator line about each entry is a
|
|
116
133
|
* separate digest — run that loop BEFORE pruning so both faces are judged on the full list. */
|
|
@@ -4,6 +4,20 @@ import { inlineUntrusted } from "../untrusted-text.js";
|
|
|
4
4
|
import { thrownText } from "../thrown-value.js";
|
|
5
5
|
export const ANNOUNCE_ONCE_MAX_DIGESTS = 200;
|
|
6
6
|
const RUNNER_ANNOUNCED = new WeakMap();
|
|
7
|
+
const SINK_NOTICED = new WeakMap();
|
|
8
|
+
const DEFAULT_SEAT_NOTICED = new Set();
|
|
9
|
+
export function noticeOncePerSink(sink, key, deliver) {
|
|
10
|
+
const told = typeof sink !== "function" ? DEFAULT_SEAT_NOTICED : (SINK_NOTICED.get(sink) ?? new Set());
|
|
11
|
+
if (typeof sink === "function")
|
|
12
|
+
SINK_NOTICED.set(sink, told);
|
|
13
|
+
if (told.has(key))
|
|
14
|
+
return;
|
|
15
|
+
told.add(key);
|
|
16
|
+
deliver();
|
|
17
|
+
}
|
|
18
|
+
export function __resetNoticedOncePerSink() {
|
|
19
|
+
DEFAULT_SEAT_NOTICED.clear();
|
|
20
|
+
}
|
|
7
21
|
const DROPPED_TOOL_MODEL_LANE = "mcp_dropped_tools";
|
|
8
22
|
export function announceDigest(lane, text) {
|
|
9
23
|
return createHash("sha256").update(lane).update("\n").update(text).digest("hex");
|
|
@@ -36,6 +50,14 @@ export function withAnnounceDigests(existing, add) {
|
|
|
36
50
|
}
|
|
37
51
|
return out.length > ANNOUNCE_ONCE_MAX_DIGESTS ? out.slice(out.length - ANNOUNCE_ONCE_MAX_DIGESTS) : out;
|
|
38
52
|
}
|
|
53
|
+
export function tellOncePerSession(announced, digest, deliver) {
|
|
54
|
+
const record = announced.announcedListingsRef;
|
|
55
|
+
if (record.advisories?.includes(digest) === true)
|
|
56
|
+
return;
|
|
57
|
+
deliver();
|
|
58
|
+
record.advisories = withAnnounceDigests(record.advisories, [digest]);
|
|
59
|
+
announced.frameReceipts.listingSnapshotOwed = true;
|
|
60
|
+
}
|
|
39
61
|
const toldAuthorization = (a) => `needs authorization (${a.reason}, ${createHash("sha256").update(JSON.stringify([a.reason, a.authorizeUrl ?? ""])).digest("hex").slice(0, 16)})`;
|
|
40
62
|
function sameFailure(a, b) {
|
|
41
63
|
return a.name === b.name && a.error === b.error;
|
|
@@ -93,10 +115,10 @@ export async function loadAnnounceOnceLedger(session, checkpointMirror, onError)
|
|
|
93
115
|
if (told.size > ANNOUNCE_ONCE_MAX_DIGESTS)
|
|
94
116
|
told.delete(told.values().next().value);
|
|
95
117
|
},
|
|
96
|
-
mcpFailuresToAnnounce: (statuses) => {
|
|
118
|
+
mcpFailuresToAnnounce: (statuses, remembered) => {
|
|
97
119
|
const current = statuses
|
|
98
120
|
.filter((s) => s.status === "failed")
|
|
99
|
-
.map((s) => ({ name: inlineUntrusted(s.name, 160), ...(s.authorization !== undefined ? { error: toldAuthorization(s.authorization), authorization: { ...s.authorization } } : s.error !== undefined ? { error: inlineUntrusted(s.error, 240) } : {}) }));
|
|
121
|
+
.map((s) => ({ name: inlineUntrusted(s.name, 160), ...(remembered(s.name) ? { remembered: true } : {}), ...(s.authorization !== undefined ? { error: toldAuthorization(s.authorization), authorization: { ...s.authorization } } : s.error !== undefined ? { error: inlineUntrusted(s.error, 240) } : {}) }));
|
|
100
122
|
const carried = mcpFailed.filter((r) => current.some((c) => sameFailure(c, r)));
|
|
101
123
|
if (carried.length !== mcpFailed.length)
|
|
102
124
|
dirty = true;
|
|
@@ -27,6 +27,8 @@ export interface Stats {
|
|
|
27
27
|
* it fails the type check instead of silently reporting a total short by its own leg. */
|
|
28
28
|
totalInputTokens: number;
|
|
29
29
|
costMicroUsd: number;
|
|
30
|
+
/** Wall time of this leg's main-loop model calls, summed (`bookMainCall`; the `brain.call` rows' `latencyMs`); a leg's run starts it at 0. */
|
|
31
|
+
apiDurationMs?: number;
|
|
30
32
|
/** Present (`true`) when at least one model round of this leg reported NO usage frame (the brain's
|
|
31
33
|
* own `usageMissing` mark on the assistant message: an aborted / errored / usage-less provider reply). The
|
|
32
34
|
* numeric fields stay required and stay what was COUNTED — with this key present they are a LOWER BOUND,
|
|
@@ -167,6 +169,8 @@ export interface ResultFlags {
|
|
|
167
169
|
* a refused `suspendVM` still ends the task exactly the way it did before — this only stops the eleven
|
|
168
170
|
* distinct codes from arriving as one anonymous `limits.max_turns_exceeded`. Empty/absent ⇒ the field is omitted. */
|
|
169
171
|
remoteEnvFailures?: TaskResult["remoteEnvFailures"];
|
|
172
|
+
/** The asks the run refused because nobody could answer them, echoed on `TaskResult.refusedAsks`; empty/absent ⇒ omitted. */
|
|
173
|
+
refusedAsks?: TaskResult["refusedAsks"];
|
|
170
174
|
/** The run's effective read posture (resolved face + normalized deny
|
|
171
175
|
* additions), echoed on `TaskResult.effectiveReadFace` / `.effectiveWriteFace` / `.effectiveReadDenyPatterns`. Pure
|
|
172
176
|
* pass-through (assembly neither adds nor filters) and INDEPENDENT of the status/errorCode chain:
|
|
@@ -208,6 +212,8 @@ export interface ResultFlags {
|
|
|
208
212
|
* lost): a live abort that found this true landed on the run's tail, not on work — slot 9 stands down
|
|
209
213
|
* and the run takes the completed floor. Absent/false = the abort's ordinary reading. */
|
|
210
214
|
answerSettled?: boolean;
|
|
215
|
+
/** The task axis the run ended past, evaluated once at the settle ({@link import("./clock-and-limits.js").limitCrossedOf}) and echoed on `TaskResult.limitCrossed` only when the terminal is `completed` (a run that owed another request fails or parks on its axis, and says it there). */
|
|
216
|
+
limitCrossed?: TaskResult["limitCrossed"];
|
|
211
217
|
budgetHit?: "exceeded" | "precall";
|
|
212
218
|
/** Which budget ceiling the hit belongs to. Set together with {@link budgetHit} at every
|
|
213
219
|
* site that records one; it picks the terminal code (`limits.max_tokens_exceeded` vs
|
|
@@ -173,5 +173,5 @@ export function assembleResult(leg, final, stats, flags) {
|
|
|
173
173
|
delete publicStats.costMicroUsd;
|
|
174
174
|
const stampHaltedByUser = haltConsumed(flags.haltConsumption);
|
|
175
175
|
const turnAbortedBy = turnAbortedByOf(flags.haltConsumption);
|
|
176
|
-
return { taskId, ...(flags.runId !== undefined ? { runId: flags.runId } : {}), sessionId, terminal, ...(flags.model !== undefined ? { model: flags.model } : {}), ...(responseModel !== undefined ? { responseModel } : {}), result: result.trim(), ...(flags.answerEntryIds !== undefined ? { resultEntryIds: [...flags.answerEntryIds] } : {}), ...(flags.intake !== undefined ? { intake: flags.intake } : {}), ...(flags.displayed !== undefined ? { resultDisplayedBy: [...flags.displayed.by] } : {}), salvagedOutput, ...(apiFailure !== undefined ? { apiFailure } : {}), ...(retryAfterMs !== undefined ? { retryAfterMs } : {}), ...(flags.rewindNotes !== undefined && flags.rewindNotes.length > 0 ? { rewindNotes: flags.rewindNotes } : {}), ...(flags.editedFiles !== undefined && flags.editedFiles.length > 0 ? { editedFiles: flags.editedFiles } : {}), ...(flags.haltedOnUserRejection === true ? { haltedOnUserRejection: true } : {}), ...(stampHaltedByUser ? { haltedByUser: true } : {}), ...(turnAbortedBy !== undefined ? { turnAbortedBy } : {}), ...(flags.remoteEnvFailures !== undefined && flags.remoteEnvFailures.length > 0 ? { remoteEnvFailures: [...flags.remoteEnvFailures] } : {}), ...(flags.strandedHumanAnswers !== undefined && flags.strandedHumanAnswers.length > 0 ? { strandedHumanAnswers: flags.strandedHumanAnswers } : {}), ...(flags.effectiveReadFace !== undefined ? { effectiveReadFace: flags.effectiveReadFace } : {}), ...(flags.effectiveWriteFace !== undefined ? { effectiveWriteFace: flags.effectiveWriteFace } : {}), ...(flags.effectiveReadDenyPatterns !== undefined && flags.effectiveReadDenyPatterns.length > 0 ? { effectiveReadDenyPatterns: flags.effectiveReadDenyPatterns } : {}), ...(flags.effectiveMemoryScopes !== undefined ? { effectiveMemoryScopes: flags.effectiveMemoryScopes } : {}), ...(flags.placementRoot !== undefined ? { placementRoot: flags.placementRoot } : {}), ...(flags.effectiveReasoning !== undefined ? { effectiveReasoning: flags.effectiveReasoning } : {}), ...(flags.compaction !== undefined ? { compaction: flags.compaction } : {}), stats: publicStats };
|
|
176
|
+
return { taskId, ...(flags.runId !== undefined ? { runId: flags.runId } : {}), sessionId, terminal, ...(flags.model !== undefined ? { model: flags.model } : {}), ...(responseModel !== undefined ? { responseModel } : {}), result: result.trim(), ...(flags.answerEntryIds !== undefined ? { resultEntryIds: [...flags.answerEntryIds] } : {}), ...(flags.intake !== undefined ? { intake: flags.intake } : {}), ...(flags.displayed !== undefined ? { resultDisplayedBy: [...flags.displayed.by] } : {}), salvagedOutput, ...(apiFailure !== undefined ? { apiFailure } : {}), ...(retryAfterMs !== undefined ? { retryAfterMs } : {}), ...(flags.rewindNotes !== undefined && flags.rewindNotes.length > 0 ? { rewindNotes: flags.rewindNotes } : {}), ...(flags.editedFiles !== undefined && flags.editedFiles.length > 0 ? { editedFiles: flags.editedFiles } : {}), ...(flags.haltedOnUserRejection === true ? { haltedOnUserRejection: true } : {}), ...(stampHaltedByUser ? { haltedByUser: true } : {}), ...(turnAbortedBy !== undefined ? { turnAbortedBy } : {}), ...(terminal.kind === "completed" && flags.limitCrossed !== undefined ? { limitCrossed: flags.limitCrossed } : {}), ...(flags.remoteEnvFailures !== undefined && flags.remoteEnvFailures.length > 0 ? { remoteEnvFailures: [...flags.remoteEnvFailures] } : {}), ...(flags.refusedAsks !== undefined && flags.refusedAsks.length > 0 ? { refusedAsks: [...flags.refusedAsks] } : {}), ...(flags.strandedHumanAnswers !== undefined && flags.strandedHumanAnswers.length > 0 ? { strandedHumanAnswers: flags.strandedHumanAnswers } : {}), ...(flags.effectiveReadFace !== undefined ? { effectiveReadFace: flags.effectiveReadFace } : {}), ...(flags.effectiveWriteFace !== undefined ? { effectiveWriteFace: flags.effectiveWriteFace } : {}), ...(flags.effectiveReadDenyPatterns !== undefined && flags.effectiveReadDenyPatterns.length > 0 ? { effectiveReadDenyPatterns: flags.effectiveReadDenyPatterns } : {}), ...(flags.effectiveMemoryScopes !== undefined ? { effectiveMemoryScopes: flags.effectiveMemoryScopes } : {}), ...(flags.placementRoot !== undefined ? { placementRoot: flags.placementRoot } : {}), ...(flags.effectiveReasoning !== undefined ? { effectiveReasoning: flags.effectiveReasoning } : {}), ...(flags.compaction !== undefined ? { compaction: flags.compaction } : {}), stats: publicStats };
|
|
177
177
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The person's account of an allow rule auto mode does not use (`permission.allow_rule_not_used_in_auto`).
|
|
3
|
+
*
|
|
4
|
+
* In `auto` the allow layer stands down the entries that would let a call skip the classifier (`auto-strip.ts`, one judgment,
|
|
5
|
+
* applied per call by every allow member). Without a word, a person who saved `Bash(npm run:*)` sees the rule listed and every
|
|
6
|
+
* `npm run` asked anyway. This seat is the word: the strip hands it each entry it took from a call that entry speaks for, and
|
|
7
|
+
* the person is told ONCE PER CONVERSATION PER RULE — the session's announced record (`tellOncePerSession`), keyed on where the
|
|
8
|
+
* rule is kept and what it says, so a later call, a later run of the conversation and a forked leg that starts from the
|
|
9
|
+
* conversation's record say nothing more. A delegated leg's notice is addressed through the leg's notice seat (`LegNotice`).
|
|
10
|
+
*/
|
|
11
|
+
import { type EngineNotice } from "../engine-notice.js";
|
|
12
|
+
import type { AutoStripReason } from "../auto-strip.js";
|
|
13
|
+
import type { PersonalRuleSource } from "../permission-rule-provider.js";
|
|
14
|
+
import type { AllowEntrySource } from "../allow-entry.js";
|
|
15
|
+
import type { ToolCallRequest } from "../tool-policy.js";
|
|
16
|
+
import type { LegNotice } from "../leg-identity.js";
|
|
17
|
+
import { type RunTimeAnnounced } from "./announce-once-ledger.js";
|
|
18
|
+
export declare const ALLOW_RULE_NOT_USED_IN_AUTO = "permission.allow_rule_not_used_in_auto";
|
|
19
|
+
/** Where the rule is kept: a stored row's source (the store's own words), or the list it was handed in on (the allow lists' words). */
|
|
20
|
+
export type AutoStripSource = PersonalRuleSource | AllowEntrySource | "skill";
|
|
21
|
+
/** One entry the strip took from a call: the rule as written, where it is kept, why, and (a skill's) the skill. */
|
|
22
|
+
export interface AutoStrippedRule {
|
|
23
|
+
readonly entry: string;
|
|
24
|
+
readonly source: AutoStripSource;
|
|
25
|
+
readonly reason: AutoStripReason;
|
|
26
|
+
readonly skill?: string;
|
|
27
|
+
}
|
|
28
|
+
/** The notice for one rule. */
|
|
29
|
+
export declare function allowRuleNotUsedInAutoNotice(r: AutoStrippedRule, call: ToolCallRequest, address: LegNotice["route"]["address"], runId: string): EngineNotice;
|
|
30
|
+
/** The leg's seat: the strip's listener, telling each rule once per conversation. */
|
|
31
|
+
export declare function createAutoStripNotice(input: {
|
|
32
|
+
onNotice: ((notice: EngineNotice) => void) | undefined;
|
|
33
|
+
legNotice: LegNotice;
|
|
34
|
+
runId: string;
|
|
35
|
+
announced: RunTimeAnnounced;
|
|
36
|
+
}): (r: AutoStrippedRule, call: ToolCallRequest) => void;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { deliverEngineNotice } from "../engine-notice.js";
|
|
2
|
+
import { renderListEntry } from "../allow-entry.js";
|
|
3
|
+
import { noticeRuleText } from "../permission-rule-model.js";
|
|
4
|
+
import { inlineUntrusted } from "../untrusted-text.js";
|
|
5
|
+
import { announceDigest, tellOncePerSession } from "./announce-once-ledger.js";
|
|
6
|
+
export const ALLOW_RULE_NOT_USED_IN_AUTO = "permission.allow_rule_not_used_in_auto";
|
|
7
|
+
function whereKept(r) {
|
|
8
|
+
switch (r.source) {
|
|
9
|
+
case "user":
|
|
10
|
+
return "saved in your user rules";
|
|
11
|
+
case "project":
|
|
12
|
+
return "saved in this project's rules";
|
|
13
|
+
case "session":
|
|
14
|
+
return "saved for this conversation";
|
|
15
|
+
case "request":
|
|
16
|
+
return "in the allowed tools this conversation was started with";
|
|
17
|
+
case "deployment":
|
|
18
|
+
return "in this deployment's allowed tools";
|
|
19
|
+
case "skill":
|
|
20
|
+
return `in the allowed-tools of the skill ${inlineUntrusted(r.skill ?? "", 80)}`;
|
|
21
|
+
default: {
|
|
22
|
+
const exhaustive = r.source;
|
|
23
|
+
return exhaustive;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function whyAndWayOut(r, call) {
|
|
28
|
+
const narrower = "To have a command approved without the classifier, save a narrower rule that names the whole command, such as Bash(npm run build); or switch to the default permission mode, where this rule applies as written.";
|
|
29
|
+
switch (r.reason) {
|
|
30
|
+
case "whole_shell":
|
|
31
|
+
return `it allows every shell command, which is too broad for auto mode to honor, so in auto mode it approves no ${inlineUntrusted(call.toolName, 80)} call on its own: unless another rule approves one, it goes to the auto-mode classifier, which may block it. ${narrower}`;
|
|
32
|
+
case "code_runner":
|
|
33
|
+
return `it allows a program that runs whatever code it is given, which is too broad for auto mode to honor, so in auto mode it approves no command on its own: unless another rule approves one, it goes to the auto-mode classifier, which may block it. ${narrower}`;
|
|
34
|
+
case "classify_all_shell":
|
|
35
|
+
return "this conversation was started with every shell command sent to the auto-mode classifier in auto mode (classifyAllShell), so no shell rule approves a command on its own here, and a narrower rule would not either. To have it apply, switch to the default permission mode, where this rule applies as written.";
|
|
36
|
+
default: {
|
|
37
|
+
const exhaustive = r.reason;
|
|
38
|
+
return exhaustive;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export function allowRuleNotUsedInAutoNotice(r, call, address, runId) {
|
|
43
|
+
return {
|
|
44
|
+
code: ALLOW_RULE_NOT_USED_IN_AUTO,
|
|
45
|
+
message: `The allow rule ${renderListEntry(r.entry)} (${whereKept(r)}) is not used in auto mode: ${whyAndWayOut(r, call)} Said once per conversation for this rule.`,
|
|
46
|
+
detail: { entry: noticeRuleText(r.entry), source: r.source, reason: r.reason, toolName: call.toolName, toolCallId: call.toolCallId, ...(r.skill !== undefined ? { skill: r.skill } : {}), ...address, runId },
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export function createAutoStripNotice(input) {
|
|
50
|
+
const { onNotice, legNotice, runId, announced } = input;
|
|
51
|
+
const toldThisLeg = new Set();
|
|
52
|
+
return (r, call) => {
|
|
53
|
+
const digest = announceDigest(ALLOW_RULE_NOT_USED_IN_AUTO, `${r.source}\n${r.skill ?? ""}\n${r.entry}`);
|
|
54
|
+
if (toldThisLeg.has(digest))
|
|
55
|
+
return;
|
|
56
|
+
toldThisLeg.add(digest);
|
|
57
|
+
tellOncePerSession(announced, digest, () => deliverEngineNotice(onNotice, allowRuleNotUsedInAutoNotice(r, call, legNotice.route.address, runId), legNotice.admission));
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { SessionStorage } from "../../internal/harness.js";
|
|
2
|
+
/** Judge the landing; answers the leaf it holds. `landing` is the leaf `at` / `before` would set, `undefined` when it could not be read. */
|
|
3
|
+
export declare function refuseBranchOutsideWindow(storage: Pick<SessionStorage, "getPathToRoot">, landing: string | null | undefined, target: string, sessionId: string): Promise<string | null>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { boundedTail } from "../session.js";
|
|
2
|
+
import { readMember } from "../thrown-value.js";
|
|
3
|
+
export async function refuseBranchOutsideWindow(storage, landing, target, sessionId) {
|
|
4
|
+
const leaf = landing === undefined ? target : landing;
|
|
5
|
+
if (leaf !== null)
|
|
6
|
+
await judgePath(storage, leaf, target, sessionId);
|
|
7
|
+
if (landing === undefined) {
|
|
8
|
+
throw refusal(`resumeAt entry "${target}" keeps a user message whose attachment frames cannot be read: the entries session "${sessionId}"'s handle loaded do not include that message (the store answered it by id), so where its attachment frames end is not known and the branch would continue without them — retry on a handle that holds the message (the whole log, or the message's own branch), or rewind with resumeAtMode "before" to drop the message and send it again with its attachments`);
|
|
9
|
+
}
|
|
10
|
+
return leaf;
|
|
11
|
+
}
|
|
12
|
+
async function judgePath(storage, leafId, target, sessionId) {
|
|
13
|
+
let path;
|
|
14
|
+
try {
|
|
15
|
+
path = await storage.getPathToRoot(leafId);
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
const code = readMember(err, "code");
|
|
19
|
+
if (code === "corrupt_session")
|
|
20
|
+
return;
|
|
21
|
+
if (code !== "not_found")
|
|
22
|
+
throw err;
|
|
23
|
+
throw outsideWindow(target, sessionId, `the store does not hold entry "${leafId}", where the branch would continue, in the part of the log it loaded`);
|
|
24
|
+
}
|
|
25
|
+
const top = path[0];
|
|
26
|
+
if (top === undefined || !top.parentId || boundedTail(path).floorEntryId !== null)
|
|
27
|
+
return;
|
|
28
|
+
throw outsideWindow(target, sessionId, `the store's read of that branch stops at entry "${top.id}", the floor of the part of the log it loaded, and no compaction on the branch keeps from there — the conversation before "${top.id}" would be dropped with no summary of it`);
|
|
29
|
+
}
|
|
30
|
+
function outsideWindow(target, sessionId, why) {
|
|
31
|
+
return refusal(`resumeAt entry "${target}" lands on a branch session "${sessionId}"'s store does not hold whole: ${why}`);
|
|
32
|
+
}
|
|
33
|
+
function refusal(message) {
|
|
34
|
+
const e = new Error(message);
|
|
35
|
+
e.code = "resume_at.outside_window";
|
|
36
|
+
return e;
|
|
37
|
+
}
|
|
@@ -43,10 +43,15 @@ declare const ROSTER_FACE: unique symbol;
|
|
|
43
43
|
export type RosterFace = ToolSpec & {
|
|
44
44
|
readonly [ROSTER_FACE]: true;
|
|
45
45
|
};
|
|
46
|
-
/** A task spec whose tool roster is faces — what the
|
|
47
|
-
export type
|
|
46
|
+
/** A task spec whose tool roster is faces — what the snapshot hands the config doors. */
|
|
47
|
+
export type CallerRosterSpec = Omit<TaskSpec, "tools"> & {
|
|
48
48
|
tools?: RosterFace[];
|
|
49
49
|
};
|
|
50
|
+
/** The spec the doors rebind ({@link CallerRosterSpec}, its `durableApproval` the opt-in alone — the host's `false` is lifted off it into
|
|
51
|
+
* the leg's one fact) — what the driver and every phase that reads the roster hold after the doors. */
|
|
52
|
+
export type RosterSpec = Omit<CallerRosterSpec, "durableApproval"> & {
|
|
53
|
+
durableApproval?: import("../task-spec.js").DurableApprovalOptIn;
|
|
54
|
+
};
|
|
50
55
|
/** What the refusal compares: the caller's own spec (re-read, never mutated here) and the objects the snapshot read
|
|
51
56
|
* (`undefined` when the roster was not an array — an omitted roster snapshots as no entries, a non-array value is the
|
|
52
57
|
* doors' to judge and is not compared). */
|
|
@@ -91,7 +96,7 @@ export declare function rebindProductEntry(entry: object, enrich: ToolCtxEnriche
|
|
|
91
96
|
* own data, so the copy is that snapshot with `tools` replaced by its own frozen array of faces when the request carried one.
|
|
92
97
|
* The caller's own object is kept for {@link refuseLateRosterChanges} only; the read's refusal is handed back for prepare's door. */
|
|
93
98
|
export declare function snapshotCallerRoster(handedSpec: TaskSpec): {
|
|
94
|
-
spec:
|
|
99
|
+
spec: CallerRosterSpec;
|
|
95
100
|
roster: CallerRosterSnapshot;
|
|
96
101
|
refusal: CallerSpecRead["refusal"];
|
|
97
102
|
};
|
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
import { runWithCapabilityWithheld } from "../../brain/status-sink.js";
|
|
2
2
|
import { deliverEngineNotice } from "../engine-notice.js";
|
|
3
|
-
import { announceDigest,
|
|
3
|
+
import { announceDigest, tellOncePerSession } from "./announce-once-ledger.js";
|
|
4
4
|
const CAPABILITY_DOWNGRADED = "model.capability_downgraded";
|
|
5
5
|
export function createCapabilityWithheldScope(ids, announced) {
|
|
6
6
|
const announce = (report) => {
|
|
7
|
-
const digest = announceDigest(CAPABILITY_DOWNGRADED, `${report.modelId}\n${report.capability}`);
|
|
8
|
-
const record = announced.announcedListingsRef;
|
|
9
|
-
if (record.advisories?.includes(digest) === true)
|
|
10
|
-
return;
|
|
11
7
|
const why = report.cause === "declared_off"
|
|
12
8
|
? `its catalog entry declares no image input (Model.input has no "image")`
|
|
13
9
|
: `its catalog entry does not declare image input, and images are not sent to an entry that does not`;
|
|
14
|
-
deliverEngineNotice(ids.onNotice, {
|
|
10
|
+
tellOncePerSession(announced, announceDigest(CAPABILITY_DOWNGRADED, `${report.modelId}\n${report.capability}`), () => deliverEngineNotice(ids.onNotice, {
|
|
15
11
|
code: CAPABILITY_DOWNGRADED,
|
|
16
12
|
message: `Images in this conversation are not being sent to model "${report.modelId}": ${why}, so each image reaches the model as a one-line placeholder. ` +
|
|
17
13
|
`If the model reads images, declare it (input: ["text","image"]); otherwise switch to a model that reads images. Said once per conversation for this model.`,
|
|
18
14
|
detail: { model: report.modelId, capability: report.capability, status: report.cause, sessionId: ids.sessionId, runId: ids.runId },
|
|
19
|
-
});
|
|
20
|
-
record.advisories = withAnnounceDigests(record.advisories, [digest]);
|
|
21
|
-
announced.frameReceipts.listingSnapshotOwed = true;
|
|
15
|
+
}));
|
|
22
16
|
};
|
|
23
17
|
return (fn) => runWithCapabilityWithheld(announce, fn);
|
|
24
18
|
}
|