@sema-agent/core 7.67.2 → 7.68.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 +1533 -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/errors.d.ts +20 -0
- package/dist/brain/errors.js +114 -0
- package/dist/brain/open-responses.js +3 -1
- package/dist/brain/openai.js +3 -1
- package/dist/brain/provider-message.d.ts +5 -3
- package/dist/brain/provider-message.js +35 -8
- 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 +25 -1
- package/dist/core/checkpoint-requirements.js +5 -1
- 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 +30 -9
- package/dist/core/protocol-http-auth.js +113 -59
- 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 +6 -0
- package/dist/core/tool-roster.js +18 -0
- 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 +19 -7
- package/dist/core/untrusted-egress.js +26 -7
- package/dist/core/untrusted-text.d.ts +6 -18
- package/dist/core/untrusted-text.js +11 -4
- 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.67.3.json +39 -0
- package/wire-changes/core-stores-sql@7.68.0.json +39 -0
- package/wire-changes/core@7.67.3.json +65 -0
- package/wire-changes/core@7.68.0.json +4257 -0
- package/wire-changes/mods-kernel@7.67.3.json +39 -0
- package/wire-changes/mods-kernel@7.68.0.json +129 -0
- package/wire-changes/primitives@7.67.3.json +39 -0
- package/wire-changes/primitives@7.68.0.json +253 -0
- package/wire-changes/wiki-gate@7.67.3.json +39 -0
- package/wire-changes/wiki-gate@7.68.0.json +39 -0
- package/dist/core/runner/credential-origin-seat.d.ts +0 -2
- package/dist/core/runner/credential-origin-seat.js +0 -20
|
@@ -3,6 +3,7 @@ import { hostname, uptime } from "node:os";
|
|
|
3
3
|
import { hrtime } from "node:process";
|
|
4
4
|
import { execFileSync } from "node:child_process";
|
|
5
5
|
import { inheritedHostEnv } from "./secret-env.js";
|
|
6
|
+
import { deliverEngineNotice } from "./engine-notice.js";
|
|
6
7
|
const UNCHECKABLE_TEXT = Object.freeze({
|
|
7
8
|
another_host: "it was written on another host",
|
|
8
9
|
another_pid_namespace: "it was written in another pid namespace (another container, or one this process cannot name)",
|
|
@@ -49,11 +50,15 @@ function announceStartTimeDegrade(reason) {
|
|
|
49
50
|
if (startTimeProbeUnavailable)
|
|
50
51
|
return;
|
|
51
52
|
startTimeProbeUnavailable = true;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
`
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
deliverEngineNotice(undefined, {
|
|
54
|
+
code: "config.process_start_time_unavailable",
|
|
55
|
+
message: `[sema] this host cannot report process start times (${reason}), so a record naming a process — a file store's ` +
|
|
56
|
+
`directory lock, a run claim, a memory writer's session account — is judged by PID ALONE. A record left behind ` +
|
|
57
|
+
`by a crashed process whose pid the OS has since handed to an unrelated process then reads as a LIVE owner: a ` +
|
|
58
|
+
`lock or claim stays refused until it is removed by hand, and a writer's account stays open until its session ` +
|
|
59
|
+
`resumes or the host closes it.`,
|
|
60
|
+
detail: { reason },
|
|
61
|
+
});
|
|
57
62
|
}
|
|
58
63
|
const START_TIME_PROBE_ATTEMPTS = 3;
|
|
59
64
|
function probeStartTimes(pid) {
|
|
@@ -59,7 +59,8 @@ export declare function underDeclaredHeaders(defaults: Readonly<Record<string, s
|
|
|
59
59
|
export declare const httpTrimmed: (value: string) => string;
|
|
60
60
|
/**
|
|
61
61
|
* A peer's error text with what the peer was SENT taken out of it. Both kinds of removal are found on the ORIGINAL text (so no marker is
|
|
62
|
-
* rescanned and no replacement can disturb what another one reads) and the ranges they take are merged, one marker per merged range
|
|
62
|
+
* rescanned and no replacement can disturb what another one reads) and the ranges they take are merged, one marker per merged range (the
|
|
63
|
+
* bare mark: the place says what was there — a value the request carried, a cookie's value): every
|
|
63
64
|
* occurrence of a declared value in any spelling {@link requestEchoSpellings} derives from it (as declared and as sent, its credentials
|
|
64
65
|
* part, JSON-escaped with or without `\/`, percent-encoded, form-urlencoded, `+` for a space), in any letter case, longest first, and every `Cookie` / `Set-Cookie` member
|
|
65
66
|
* whole — a header line to its end, a record member's string, array or object to its close. The two never disarm each other: a declared
|
|
@@ -67,9 +68,10 @@ export declare const httpTrimmed: (value: string) => string;
|
|
|
67
68
|
* from outside takes its own range and the member's value goes with it. A declared value that is also an ordinary word or number (`en`, `1`,
|
|
68
69
|
* `application/json`) goes wherever it occurs in the remote's words, in any case — a legibility cost, never a leak; the failure's closed
|
|
69
70
|
* fields (code, status, delivery) are not text. A declaration too large for one matcher (tens of thousands of characters, which no header
|
|
70
|
-
* carries) makes the whole text the marker: the pass never throws and never shows what it could not match. A
|
|
71
|
-
* a
|
|
72
|
-
*
|
|
71
|
+
* carries) makes the whole text the marker: the pass never throws and never shows what it could not match. A mark the text already holds
|
|
72
|
+
* (a member of the marks table) is atomic, by the renderer's one law (`renderWithheld`): a hit that is exactly a mark is no hit, and one
|
|
73
|
+
* that reaches into a mark — or lies inside one: a declared value can be a piece of a mark's words — takes the whole mark with it, so the
|
|
74
|
+
* pass over its own output answers the same text.
|
|
73
75
|
*/
|
|
74
76
|
export declare function scrubRequestEcho(text: string, declared: readonly string[]): string;
|
|
75
77
|
/**
|
|
@@ -88,12 +90,31 @@ export declare function eraseSentCredentials(text: string, credentials: readonly
|
|
|
88
90
|
* ({@link scrubRequestEcho}: `declared` is required, so no mint reads a remote's words without naming its request), then the credential
|
|
89
91
|
* vocabulary. Words with no declared value in them read exactly as the vocabulary renders them. Where a declared value is there, the
|
|
90
92
|
* values the vocabulary finds in the ORIGINAL words are taken out with it, so neither disarms the other: removing a declared `Bearer`
|
|
91
|
-
* cannot hide the token after it from the vocabulary, and the vocabulary rewriting part of a declared value cannot leave the rest.
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
93
|
+
* cannot hide the token after it from the vocabulary, and the vocabulary rewriting part of a declared value cannot leave the rest. Each
|
|
94
|
+
* is written as its own member — a declared value the bare mark, a value the vocabulary found its row's — and a region they share as
|
|
95
|
+
* one, its widest span's (the renderer's one law; of a declared value and a vocabulary find over the same region, the find's: the member
|
|
96
|
+
* the words' other faces write there). `found` are values the vocabulary found in another spelling of the same words (a reader that
|
|
97
|
+
* carries the words in one spelling and read them in another), written as the bare mark; they and the values found here are taken out
|
|
98
|
+
* wherever they stand, a Cookie member's name included (only a declared value spares it). A caller that bounds the text for display cuts
|
|
99
|
+
* what this returns, never the remote's raw words, so a cut can leave no part of a value. The function is a fixed point (its own output
|
|
100
|
+
* answers the same text). A store, a log or an event lane that receives the result does not redact again: persistence is not an exit,
|
|
101
|
+
* the mint is.
|
|
95
102
|
*/
|
|
96
|
-
export declare function remoteWords(text: string, declared: readonly string[]): Egress<"same-principal">;
|
|
103
|
+
export declare function remoteWords(text: string, declared: readonly string[], found?: readonly string[]): Egress<"same-principal">;
|
|
104
|
+
/**
|
|
105
|
+
* What {@link remoteWords} withholds of `text`, as [start, end) spans in the text's coordinates — THE answer to "which characters of
|
|
106
|
+
* these words does their remote-words reading not carry", for a reader that carries the same words in another spelling and must carry
|
|
107
|
+
* no less: the regions its echo pass withholds and the spans its vocabulary pass then withholds in those marked words
|
|
108
|
+
* ({@link egressCredentialReading}: the label a rendering keeps is not in the span), read back through the marks (a span that touches a
|
|
109
|
+
* mark reaches the whole region the mark stands for). Where the marked words cannot be read back (see {@link writtenRegions}), the whole
|
|
110
|
+
* text; and checked against the reading's own output: where the text outside the spans does not stand in it as written
|
|
111
|
+
* ({@link carriesTheRest}), the spans missed a removal, and the answer is the whole text.
|
|
112
|
+
*/
|
|
113
|
+
export declare function remoteWordsSpans(text: string, declared: readonly string[], found?: readonly string[]): Array<readonly [number, number]>;
|
|
114
|
+
/** Whether `rendered` carries, as written and in order, every character of `text` outside `spans`: the text between the spans (merged)
|
|
115
|
+
* stands in `rendered` piece by piece — the first at its start, the last at its end, each other one after the one before. Exported for
|
|
116
|
+
* its pins; not on the package barrel. */
|
|
117
|
+
export declare function carriesTheRest(text: string, spans: ReadonlyArray<readonly [number, number]>, rendered: string): boolean;
|
|
97
118
|
/** Whether a resolved header set carries anything the declaration bound to its endpoints — a request that does follows no redirect (the
|
|
98
119
|
* next hop is not a declared endpoint; A2A's follow law reads this). */
|
|
99
120
|
export declare function carriesDeclaredHeaders(headers: Record<string, string> | undefined): boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isLoopbackHost } from "./host-floor.js";
|
|
2
2
|
import { authSchemeCredentials } from "./secret-env.js";
|
|
3
|
-
import { egressText } from "./untrusted-egress.js";
|
|
4
|
-
import {
|
|
3
|
+
import { egressCredentialReading, egressText } from "./untrusted-egress.js";
|
|
4
|
+
import { REDACTION_MARKS, renderWithheld } from "@sema-agent/primitives";
|
|
5
5
|
import { inlineUntrusted } from "./untrusted-text.js";
|
|
6
6
|
import { callerText } from "./caller-text.js";
|
|
7
7
|
export const MCP_ASSERTION_HEADER = "connector-assertion";
|
|
@@ -106,73 +106,127 @@ function structuredEnd(text, at) {
|
|
|
106
106
|
return text.length;
|
|
107
107
|
}
|
|
108
108
|
export function scrubRequestEcho(text, declared) {
|
|
109
|
-
return
|
|
109
|
+
return renderWithheld(text, requestEchoSpans(text, sentValues(declared)));
|
|
110
110
|
}
|
|
111
111
|
export function eraseSentCredentials(text, credentials) {
|
|
112
112
|
if (credentials.length === 0 || text === "")
|
|
113
113
|
return text;
|
|
114
|
-
return
|
|
114
|
+
return renderWithheld(text, needleSpans(text, sentValues(credentials), []));
|
|
115
115
|
}
|
|
116
|
-
function
|
|
117
|
-
|
|
118
|
-
return text;
|
|
119
|
-
removed.sort((a, b) => a[0] - b[0] || b[1] - a[1]);
|
|
120
|
-
let out = "";
|
|
121
|
-
let kept = 0;
|
|
122
|
-
let wrote = false;
|
|
123
|
-
for (const [start, end] of removed) {
|
|
124
|
-
if (wrote && start <= kept) {
|
|
125
|
-
kept = Math.max(kept, end);
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
out += text.slice(kept, start) + REDACTION_MARK;
|
|
129
|
-
kept = end;
|
|
130
|
-
wrote = true;
|
|
131
|
-
}
|
|
132
|
-
return out + text.slice(kept);
|
|
116
|
+
function sentValues(values) {
|
|
117
|
+
return values.map((value) => ({ value, mark: REDACTION_MARKS.bare }));
|
|
133
118
|
}
|
|
134
|
-
function
|
|
119
|
+
function requestEchoSpans(text, needles, found = []) {
|
|
135
120
|
const members = cookieMembers(text);
|
|
136
|
-
return [...members.map(([,
|
|
121
|
+
return [...members.map(([, start, end]) => ({ start, end, mark: REDACTION_MARKS.bare })), ...needleSpans(text, needles, members), ...needleSpans(text, found, [])];
|
|
137
122
|
}
|
|
138
|
-
function
|
|
139
|
-
const
|
|
140
|
-
for (const value of
|
|
123
|
+
function needleSpans(text, needles, members) {
|
|
124
|
+
const byMark = new Map();
|
|
125
|
+
for (const { value, mark } of needles) {
|
|
126
|
+
const forms = byMark.get(mark) ?? new Set();
|
|
141
127
|
for (const spelling of requestEchoSpellings(value))
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (
|
|
150
|
-
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
128
|
+
if (spelling !== "")
|
|
129
|
+
forms.add(spelling);
|
|
130
|
+
byMark.set(mark, forms);
|
|
131
|
+
}
|
|
132
|
+
const spans = [];
|
|
133
|
+
for (const [mark, forms] of byMark) {
|
|
134
|
+
const hits = valueHits(text, [...forms]);
|
|
135
|
+
if (hits === undefined)
|
|
136
|
+
return [{ start: 0, end: text.length, mark: REDACTION_MARKS.oversized }];
|
|
137
|
+
for (const [start, end] of hits)
|
|
138
|
+
if (!members.some(([name, from]) => start >= name && end <= from))
|
|
139
|
+
spans.push({ start, end, mark });
|
|
140
|
+
}
|
|
141
|
+
return spans;
|
|
155
142
|
}
|
|
156
143
|
function vocabularyValues(text) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (
|
|
174
|
-
return
|
|
175
|
-
|
|
144
|
+
return egressCredentialReading(text).spans.map(([from, end, mark]) => ({ value: text.slice(from, end), mark }));
|
|
145
|
+
}
|
|
146
|
+
export function remoteWords(text, declared, found = []) {
|
|
147
|
+
return egressText("same-principal", renderWithheld(text, echoTaken(text, declared, found)));
|
|
148
|
+
}
|
|
149
|
+
function echoTaken(text, declared, found) {
|
|
150
|
+
const sent = sentValues(declared);
|
|
151
|
+
const foundElsewhere = sentValues(found);
|
|
152
|
+
if (requestEchoSpans(text, sent, foundElsewhere).length === 0)
|
|
153
|
+
return [];
|
|
154
|
+
return requestEchoSpans(text, sent, [...foundElsewhere, ...vocabularyValues(text)]);
|
|
155
|
+
}
|
|
156
|
+
export function remoteWordsSpans(text, declared, found = []) {
|
|
157
|
+
const taken = echoTaken(text, declared, found);
|
|
158
|
+
const marked = renderWithheld(text, taken);
|
|
159
|
+
const regions = writtenRegions(text, taken, marked);
|
|
160
|
+
if (regions === undefined)
|
|
161
|
+
return [[0, text.length]];
|
|
162
|
+
const reading = egressCredentialReading(marked);
|
|
163
|
+
const lo = new Int32Array(marked.length);
|
|
164
|
+
const hi = new Int32Array(marked.length);
|
|
165
|
+
let at = 0;
|
|
166
|
+
let kept = 0;
|
|
167
|
+
const keep = (until) => {
|
|
168
|
+
for (; kept < until; kept++, at++)
|
|
169
|
+
[lo[at], hi[at]] = [kept, kept + 1];
|
|
170
|
+
};
|
|
171
|
+
for (const { start, end, length } of regions) {
|
|
172
|
+
keep(start);
|
|
173
|
+
for (let k = 0; k < length; k++, at++)
|
|
174
|
+
[lo[at], hi[at]] = [start, end];
|
|
175
|
+
kept = end;
|
|
176
|
+
}
|
|
177
|
+
keep(text.length);
|
|
178
|
+
const spans = [...regions.map(({ start, end }) => [start, end]), ...reading.spans.filter(([start, end]) => end > start).map(([start, end]) => [lo[start], hi[end - 1]])];
|
|
179
|
+
return carriesTheRest(text, spans, reading.rendered) ? spans : [[0, text.length]];
|
|
180
|
+
}
|
|
181
|
+
export function carriesTheRest(text, spans, rendered) {
|
|
182
|
+
const pieces = [];
|
|
183
|
+
let kept = 0;
|
|
184
|
+
for (const [start, end] of mergedRanges(spans)) {
|
|
185
|
+
pieces.push(text.slice(kept, start));
|
|
186
|
+
kept = end;
|
|
187
|
+
}
|
|
188
|
+
const last = text.slice(kept);
|
|
189
|
+
if (pieces.length === 0)
|
|
190
|
+
return rendered === last;
|
|
191
|
+
if (!rendered.startsWith(pieces[0]))
|
|
192
|
+
return false;
|
|
193
|
+
let at = pieces[0].length;
|
|
194
|
+
for (const piece of pieces.slice(1)) {
|
|
195
|
+
const found = rendered.indexOf(piece, at);
|
|
196
|
+
if (found < 0)
|
|
197
|
+
return false;
|
|
198
|
+
at = found + piece.length;
|
|
199
|
+
}
|
|
200
|
+
return rendered.length - last.length >= at && rendered.endsWith(last);
|
|
201
|
+
}
|
|
202
|
+
const MARK_MEMBERS = Object.values(REDACTION_MARKS);
|
|
203
|
+
function mergedRanges(ranges) {
|
|
204
|
+
const merged = [];
|
|
205
|
+
for (const [start, end] of [...ranges].sort((a, b) => a[0] - b[0] || b[1] - a[1])) {
|
|
206
|
+
const last = merged[merged.length - 1];
|
|
207
|
+
if (last !== undefined && start <= last[1])
|
|
208
|
+
last[1] = Math.max(last[1], end);
|
|
209
|
+
else
|
|
210
|
+
merged.push([start, end]);
|
|
211
|
+
}
|
|
212
|
+
return merged;
|
|
213
|
+
}
|
|
214
|
+
function writtenRegions(text, spans, marked) {
|
|
215
|
+
const regions = [];
|
|
216
|
+
let kept = 0;
|
|
217
|
+
let at = 0;
|
|
218
|
+
for (const [start, end] of mergedRanges(spans.map(({ start, end }) => [start, end]))) {
|
|
219
|
+
if (!marked.startsWith(text.slice(kept, start), at))
|
|
220
|
+
return undefined;
|
|
221
|
+
at += start - kept;
|
|
222
|
+
const member = MARK_MEMBERS.find((m) => marked.startsWith(m, at));
|
|
223
|
+
if (member === undefined)
|
|
224
|
+
return undefined;
|
|
225
|
+
regions.push({ start, end, length: member.length });
|
|
226
|
+
at += member.length;
|
|
227
|
+
kept = end;
|
|
228
|
+
}
|
|
229
|
+
return marked.length - at === text.length - kept && marked.endsWith(text.slice(kept)) ? regions : undefined;
|
|
176
230
|
}
|
|
177
231
|
function cookieMembers(text) {
|
|
178
232
|
const members = [];
|
|
@@ -206,7 +260,7 @@ function valueHits(text, forms) {
|
|
|
206
260
|
}
|
|
207
261
|
}
|
|
208
262
|
catch {
|
|
209
|
-
return
|
|
263
|
+
return undefined;
|
|
210
264
|
}
|
|
211
265
|
return hits;
|
|
212
266
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { posix } from "node:path";
|
|
2
|
-
import { lexedWordOf, readShellCommand } from "./shell-run-candidates.js";
|
|
2
|
+
import { DURATION_RE, lexedWordOf, readShellCommand } from "./shell-run-candidates.js";
|
|
3
3
|
import { readOnlyRefusalSentence, unlistedReaderSentence } from "../tools/fs/bash-readonly-classifier.js";
|
|
4
4
|
import { descriptorsOfPlan, newLineDescriptors, standardDeviceUnrebound } from "../tools/fs/shell-read-device.js";
|
|
5
5
|
import { planShellReads } from "../tools/fs/shell-read-plan.js";
|
|
@@ -10,7 +10,7 @@ const NOT = (reason) => ({ readOnly: false, reason });
|
|
|
10
10
|
const READ_ONLY = { readOnly: true };
|
|
11
11
|
export const CD_GIT_COMPOUND_SENTENCE = "This command changes directory before running a version-control command, which can pick up untrusted hooks or repository configuration from the target directory. Approve only if you trust it.";
|
|
12
12
|
export function changesDirectoryBeforeGit(shape, cwd) {
|
|
13
|
-
const programs = shape.segments.map((s) =>
|
|
13
|
+
const programs = shape.segments.map((s) => peelWrapperPrefix(s.argv.slice(leadingAssignmentCount(s.argv)).map((w) => w.text))[0] ?? "");
|
|
14
14
|
if (shape.segments.length < 2 || !programs.includes("cd") || !programs.includes("git"))
|
|
15
15
|
return false;
|
|
16
16
|
const cds = shape.segments.filter((_, i) => programs[i] === "cd");
|
|
@@ -149,7 +149,8 @@ function literalAssignmentValue(a) {
|
|
|
149
149
|
return oneRegion;
|
|
150
150
|
return only.quotedBy === '"' && oneRegion && !/[$`\\]/.test(only.literal);
|
|
151
151
|
}
|
|
152
|
-
|
|
152
|
+
const BUILTINS_TIMEOUT_CANNOT_RUN = new Set(["[[", "alias", "cd", "help", "history", "type"]);
|
|
153
|
+
function peelWrapperPrefix(words) {
|
|
153
154
|
let t = words;
|
|
154
155
|
for (;;) {
|
|
155
156
|
if (t[0] === "command") {
|
|
@@ -169,8 +170,11 @@ function peelBuiltinPrefix(words) {
|
|
|
169
170
|
t = t.slice(r);
|
|
170
171
|
}
|
|
171
172
|
else
|
|
172
|
-
|
|
173
|
+
break;
|
|
173
174
|
}
|
|
175
|
+
while (t[0] === "timeout" && DURATION_RE.test(t[1] ?? "") && t.length > 2 && !BUILTINS_TIMEOUT_CANNOT_RUN.has(t[2]))
|
|
176
|
+
t = t.slice(2);
|
|
177
|
+
return t;
|
|
174
178
|
}
|
|
175
179
|
function segmentVerdict(seg, line, bindings, readers, refused) {
|
|
176
180
|
for (const r of seg.redirections) {
|
|
@@ -191,7 +195,7 @@ function segmentVerdict(seg, line, bindings, readers, refused) {
|
|
|
191
195
|
const run = seg.argv.slice(k);
|
|
192
196
|
if (run.length === 0)
|
|
193
197
|
return NOT("a bare assignment runs no program");
|
|
194
|
-
const words =
|
|
198
|
+
const words = peelWrapperPrefix(run.map((w) => w.text));
|
|
195
199
|
const program = words[0];
|
|
196
200
|
const unlisted = unlistedObjection(program, readers);
|
|
197
201
|
if (unlisted !== undefined)
|
|
@@ -1,29 +1,7 @@
|
|
|
1
|
-
import type { SecretNotation } from "@sema-agent/primitives";
|
|
2
|
-
/** The marks, by what they stand for. `whole` is the bare mark (a span removed whole — a credential value, a floor); the
|
|
3
|
-
* others name the shape that was withheld: `credentials` a URL's userinfo, `url` a whole URL, `path` an
|
|
4
|
-
* absolute filesystem path. A mark the engine writes is exactly one of these four. Frozen: the table is exported to hosts, and every
|
|
5
|
-
* pass reads it at call time, so a write by a reader would change what the engine writes. */
|
|
6
|
-
export declare const REDACTION_MARKS: Readonly<{
|
|
7
|
-
readonly whole: "[redacted]";
|
|
8
|
-
readonly credentials: "[redacted-credentials]";
|
|
9
|
-
readonly url: "[redacted-url]";
|
|
10
|
-
readonly path: "[redacted-path]";
|
|
11
|
-
}>;
|
|
12
|
-
/** The bare mark — what a host compares against to tell that the engine withheld a value. */
|
|
13
|
-
export declare const REDACTION_MARK: "[redacted]";
|
|
14
|
-
/** The engine's notation for the credential renderer (`renderSecrets`): a credential value is the bare mark, a URL userinfo
|
|
15
|
-
* the credentials mark, and a text no reading can afford is the bare mark whole. Built from the table, so it follows it. */
|
|
16
|
-
export declare const REDACTION_NOTATION: SecretNotation;
|
|
17
|
-
/** The spelling a request-route rendering writes for a withheld query value or URL user (`«redacted»`) — shown to a person
|
|
18
|
-
* in a refusal or a route display, never written by a redaction pass. It is not a member of {@link REDACTION_MARKS}: the
|
|
19
|
-
* marks the readers below recognize are that table's four, and this spelling is not one of them. */
|
|
20
|
-
export declare const WITHHELD_VALUE_MARK = "\u00ABredacted\u00BB";
|
|
21
1
|
/** What stands where a reader of a value did not read it — a member past a bound, a value nested past a depth, a value whose
|
|
22
2
|
* members could not be listed, a gate record's member that is not data: `[not recorded: <why>]`, `why` in the engine's own
|
|
23
|
-
* words. Not a redaction mark: nothing here was withheld for what it said (the readers
|
|
3
|
+
* words. Not a redaction mark: nothing here was withheld for what it said (the marks' readers do not count it), it was not read. */
|
|
24
4
|
export declare function notRecordedMark(why: string): string;
|
|
25
|
-
/** Where
|
|
26
|
-
*
|
|
27
|
-
export declare function
|
|
28
|
-
/** Where the marks sit in `s`, all of them, as [start, end) spans, leftmost first. */
|
|
29
|
-
export declare function redactionMarkerSpans(s: string): Array<[number, number]>;
|
|
5
|
+
/** Where a cut of `s` at `at` lands so that no mark is split (half a mark is no mark): `at` itself, or the start of the mark it
|
|
6
|
+
* would land inside. Reads the marks lazily, only up to the cut. */
|
|
7
|
+
export declare function markSafeCut(s: string, at: number): number;
|
|
@@ -1,25 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
whole: "[redacted]",
|
|
3
|
-
credentials: "[redacted-credentials]",
|
|
4
|
-
url: "[redacted-url]",
|
|
5
|
-
path: "[redacted-path]",
|
|
6
|
-
});
|
|
7
|
-
export const REDACTION_MARK = REDACTION_MARKS.whole;
|
|
8
|
-
export const REDACTION_NOTATION = Object.freeze({
|
|
9
|
-
value: REDACTION_MARKS.whole,
|
|
10
|
-
byKind: Object.freeze({ "url-credentials": REDACTION_MARKS.credentials }),
|
|
11
|
-
overStrip: REDACTION_MARKS.whole,
|
|
12
|
-
});
|
|
13
|
-
export const WITHHELD_VALUE_MARK = "«redacted»";
|
|
1
|
+
import { eachRedactionMarkerSpan } from "@sema-agent/primitives";
|
|
14
2
|
export function notRecordedMark(why) {
|
|
15
3
|
return `[not recorded: ${why}]`;
|
|
16
4
|
}
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return
|
|
5
|
+
export function markSafeCut(s, at) {
|
|
6
|
+
for (const [start, end] of eachRedactionMarkerSpan(s)) {
|
|
7
|
+
if (start >= at)
|
|
8
|
+
break;
|
|
9
|
+
if (at < end)
|
|
10
|
+
return start;
|
|
11
|
+
}
|
|
12
|
+
return at;
|
|
25
13
|
}
|
|
@@ -94,8 +94,9 @@ export declare function placementTargetOf(handle: WorkspaceHandle): PlacementTar
|
|
|
94
94
|
/**
|
|
95
95
|
* The target an environment reports for itself, read ONCE per leg — at the point the leg's workspace settles: its
|
|
96
96
|
* `workspaceHandle()`'s {@link placementTargetOf}. `undefined` when there is nothing to read: the environment is not a
|
|
97
|
-
* remote one, or its handle cannot answer yet (a lazy-connect adapter
|
|
98
|
-
* no target of its own, so what it
|
|
97
|
+
* remote one, or its handle cannot answer yet (a lazy-connect adapter that is still unconnected — its establishment at
|
|
98
|
+
* the leg's restore seat failed in a way the run starts past — throws). That leg has no target of its own, so what it
|
|
99
|
+
* spawns carries no fence.
|
|
99
100
|
*/
|
|
100
101
|
export declare function reportedPlacementTarget(env: ExecutionEnv | undefined): PlacementTarget | undefined;
|
|
101
102
|
/**
|
|
@@ -290,15 +291,20 @@ export type RemoteExecutionErrorCode =
|
|
|
290
291
|
* re-drives committed side effects) — retrying them burns budget or, worse, re-drives a rejected
|
|
291
292
|
* credential or a committed op.
|
|
292
293
|
*
|
|
293
|
-
* ONE list,
|
|
294
|
-
* retries only IDEMPOTENT ops on these codes (see {@link withRetry}'s red line — a
|
|
295
|
-
* `suspendVM` is never retried)
|
|
296
|
-
* ops it does NOT retry, so a deployment can decide (refresh the credential and re-resume vs give up)
|
|
297
|
-
*
|
|
294
|
+
* ONE list, three consumers, so a caller's retry decision, its DISCLOSURE and whether the run starts at all can
|
|
295
|
+
* never disagree: the engine retries only IDEMPOTENT ops on these codes (see {@link withRetry}'s red line — a
|
|
296
|
+
* snapshot-taking `suspendVM` is never retried); it stamps `retryable` on the failure it reports to the caller for
|
|
297
|
+
* the ops it does NOT retry, so a deployment can decide (refresh the credential and re-resume vs give up) without
|
|
298
|
+
* parsing prose; and the leg's restore seat reads it when the environment answers its establishment call
|
|
299
|
+
* ({@link RemoteExecutionEnv.connect}, or `resumeVM` on a leg that restores a snapshot). Starting the run past a
|
|
300
|
+
* failed establishment IS a retry — the first operation establishes again — so the seat starts it only on a code
|
|
301
|
+
* this list holds, on `unknown` (it says nothing about the environment) and on `aborted` the run's own cancel did
|
|
302
|
+
* not cause; any other code is this environment's standing refusal and fails the run before it starts, with that code.
|
|
303
|
+
* An `env.`-namespaced code ({@link RemoteExecutionError.code}) is never in this list.
|
|
298
304
|
*/
|
|
299
305
|
export declare const RETRYABLE_REMOTE_ERROR_CODES: readonly RemoteExecutionErrorCode[];
|
|
300
|
-
/** Is `code` in the {@link RETRYABLE_REMOTE_ERROR_CODES} family? */
|
|
301
|
-
export declare function isRetryableRemoteErrorCode(code:
|
|
306
|
+
/** Is `code` in the {@link RETRYABLE_REMOTE_ERROR_CODES} family? A deployment's `env.` code never is. */
|
|
307
|
+
export declare function isRetryableRemoteErrorCode(code: RemoteExecutionError["code"]): boolean;
|
|
302
308
|
/**
|
|
303
309
|
* Error surfaced by {@link RemoteExecutionEnv} lifecycle ops and by {@link RemoteExecutionEnv.execStream}'s
|
|
304
310
|
* iterator. Mirrors the vendored `ExecutionError` shape but carries the remote-specific code set; it is kept
|
|
@@ -306,8 +312,14 @@ export declare function isRetryableRemoteErrorCode(code: RemoteExecutionErrorCod
|
|
|
306
312
|
* design/45 suspend/resume *runtime* lands and the Runner/orchestrator layer must thread `"suspended"`.
|
|
307
313
|
*/
|
|
308
314
|
export declare class RemoteExecutionError extends Error {
|
|
309
|
-
|
|
310
|
-
|
|
315
|
+
/**
|
|
316
|
+
* A {@link RemoteExecutionErrorCode}, or a deployment's own `env.`-namespaced code for a refusal of this environment
|
|
317
|
+
* that the closed set has no word for (the namespace the terminal code table reads as the execution environment's,
|
|
318
|
+
* `env.` ⇒ `config`). Either is read through {@link RETRYABLE_REMOTE_ERROR_CODES}: an `env.` code is never in it, so
|
|
319
|
+
* answered at the restore seat it fails the run before it starts, carried to the terminal verbatim.
|
|
320
|
+
*/
|
|
321
|
+
readonly code: RemoteExecutionErrorCode | `env.${string}`;
|
|
322
|
+
constructor(code: RemoteExecutionError["code"], message: string, cause?: Error);
|
|
311
323
|
}
|
|
312
324
|
/**
|
|
313
325
|
* A remote, stateful, suspendable {@link ExecutionEnv} (design/48 §5). Extends the base with workspace identity,
|
|
@@ -341,13 +353,28 @@ export interface RemoteExecutionEnv extends ExecutionEnv {
|
|
|
341
353
|
/**
|
|
342
354
|
* Identity of the connected workspace (design/48 §5 gap 1). Synchronous: it is data the env already holds.
|
|
343
355
|
*
|
|
344
|
-
* The engine reads it once per leg, when the leg's workspace settles
|
|
345
|
-
* ({@link
|
|
346
|
-
*
|
|
347
|
-
*
|
|
356
|
+
* The engine reads it once per leg, when the leg's workspace settles — after the leg's restore seat established the
|
|
357
|
+
* environment ({@link connect} / {@link resumeVM}) — to learn which target the leg is on ({@link reportedPlacementTarget}):
|
|
358
|
+
* the fence every agent the leg spawns or wakes is minted under. A target-bound adapter (one whose handle states
|
|
359
|
+
* `deviceId`) answers it from construction on; an adapter that cannot answer even after the establishment call (it
|
|
360
|
+
* throws) gives its leg no target, and that leg's agents carry no fence.
|
|
348
361
|
*/
|
|
349
362
|
workspaceHandle(): WorkspaceHandle;
|
|
350
|
-
/**
|
|
363
|
+
/**
|
|
364
|
+
* Provision/attach the remote workspace and inject secrets. Returns the resulting {@link WorkspaceHandle}.
|
|
365
|
+
*
|
|
366
|
+
* The engine calls this once per leg, at the leg's restore seat, on an environment its factory minted for that leg —
|
|
367
|
+
* every leg that does not restore a snapshot (a leg that restores one calls {@link resumeVM} there instead) — with the
|
|
368
|
+
* run's cancel signal as `abortSignal`. It MUST be idempotent: on an environment that is already connected it answers
|
|
369
|
+
* the current handle and provisions nothing (the seat is commonly NOT the first connection: a delegated child, a
|
|
370
|
+
* factory that writes into the environment before handing it over, a parked leg's reconnected environment). A connect
|
|
371
|
+
* that answers a failure has either provisioned nothing, or left what it provisioned where the next connect finds and
|
|
372
|
+
* reuses it — never a second workspace beside the first. How the engine reads a failure is
|
|
373
|
+
* {@link RETRYABLE_REMOTE_ERROR_CODES}: a code in it, `unknown` or `aborted` lets the run start, and its first
|
|
374
|
+
* operation meets the environment as it would have; any other code is this environment's standing refusal and fails
|
|
375
|
+
* the run before it starts, with that code. A connect that throws, or answers anything but this method's result shape
|
|
376
|
+
* (an `error` with a string `code`), is read as `unknown`.
|
|
377
|
+
*/
|
|
351
378
|
connect(config?: RemoteConnectConfig): Promise<{
|
|
352
379
|
ok: true;
|
|
353
380
|
value: WorkspaceHandle;
|
package/dist/core/remote-env.js
CHANGED
|
@@ -46,7 +46,7 @@ export const RETRYABLE_REMOTE_ERROR_CODES = [
|
|
|
46
46
|
"transport_lost",
|
|
47
47
|
];
|
|
48
48
|
export function isRetryableRemoteErrorCode(code) {
|
|
49
|
-
return RETRYABLE_REMOTE_ERROR_CODES.
|
|
49
|
+
return RETRYABLE_REMOTE_ERROR_CODES.some((retryable) => retryable === code);
|
|
50
50
|
}
|
|
51
51
|
export class RemoteExecutionError extends Error {
|
|
52
52
|
code;
|
|
@@ -8,7 +8,7 @@ export interface CopyProjectionInput {
|
|
|
8
8
|
readonly degraded?: ReadonlySet<string>;
|
|
9
9
|
/** This leg's startup seed: canonical key → the whole-file content hash its system prompt holds. */
|
|
10
10
|
readonly seeded?: ReadonlyMap<string, string>;
|
|
11
|
-
/** The session's reminder mark, for the marked sentences a frame
|
|
11
|
+
/** The session's reminder mark, for the marked sentences a frame carries. */
|
|
12
12
|
readonly mark?: string;
|
|
13
13
|
/** The results the tool-turn law folded, and the recorded results each folds, in order. */
|
|
14
14
|
readonly folds?: ReadonlyMap<object, readonly object[]>;
|