@sema-agent/core 7.54.1 → 7.56.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 +950 -0
- package/dist/agents/agent-transcript-tool.js +2 -1
- package/dist/agents/builtin-agents.d.ts +12 -14
- package/dist/agents/cascade.js +1 -1
- package/dist/agents/cc-peer-directory.d.ts +36 -0
- package/dist/agents/cc-peer-directory.js +139 -0
- package/dist/agents/cc-peer-wire.d.ts +105 -0
- package/dist/agents/cc-peer-wire.js +98 -0
- package/dist/agents/cc-uds-peer-channel.d.ts +40 -0
- package/dist/agents/cc-uds-peer-channel.js +457 -0
- package/dist/agents/child-model-seat.d.ts +0 -11
- package/dist/agents/child-model-seat.js +0 -3
- package/dist/agents/cross-session-envelope.d.ts +4 -1
- package/dist/agents/cross-session-envelope.js +8 -1
- package/dist/agents/cross-session-judge.d.ts +2 -2
- package/dist/agents/list-agents-tool.d.ts +3 -1
- package/dist/agents/list-agents-tool.js +9 -8
- package/dist/agents/observer.d.ts +4 -5
- package/dist/agents/observer.js +2 -1
- package/dist/agents/peer-admission.d.ts +6 -0
- package/dist/agents/peer-admission.js +4 -1
- package/dist/agents/peer-directory.d.ts +65 -13
- package/dist/agents/peer-directory.js +90 -25
- package/dist/agents/peer-notices.d.ts +1 -1
- package/dist/agents/peer-session-drain.d.ts +3 -1
- package/dist/agents/peer-session-drain.js +3 -2
- package/dist/agents/read-inbox-tool.js +2 -1
- package/dist/agents/repair-loop.js +2 -2
- package/dist/agents/retain-ledger.d.ts +1 -1
- package/dist/agents/roster-store.d.ts +1 -1
- package/dist/agents/send-message-tool.d.ts +10 -0
- package/dist/agents/send-message-tool.js +37 -8
- package/dist/agents/subagent.d.ts +39 -82
- package/dist/agents/subagent.js +109 -106
- package/dist/agents/tool-filter.d.ts +31 -46
- package/dist/agents/tool-filter.js +13 -33
- package/dist/agents/verify.d.ts +6 -5
- package/dist/agents/verify.js +3 -3
- package/dist/brain/anthropic.js +43 -81
- package/dist/brain/errors.d.ts +15 -0
- package/dist/brain/errors.js +10 -0
- package/dist/brain/media-degrade.d.ts +18 -7
- package/dist/brain/media-degrade.js +13 -2
- package/dist/brain/model-capability.d.ts +37 -0
- package/dist/brain/model-capability.js +34 -0
- package/dist/brain/model-presets.d.ts +6 -12
- package/dist/brain/model-presets.js +1 -6
- package/dist/brain/open-responses.js +27 -35
- package/dist/brain/openai.js +30 -98
- package/dist/brain/provider-dialect.d.ts +39 -3
- package/dist/brain/provider-dialect.js +28 -0
- package/dist/brain/reasoning-request.d.ts +96 -0
- package/dist/brain/reasoning-request.js +174 -0
- package/dist/brain/reasoning.d.ts +12 -12
- package/dist/brain/reasoning.js +4 -3
- package/dist/brain/request-params.d.ts +62 -9
- package/dist/brain/request-params.js +42 -7
- package/dist/brain/retry.d.ts +1 -1
- package/dist/brain/route-adjudicator.d.ts +15 -0
- package/dist/brain/route-adjudicator.js +15 -0
- package/dist/brain/status-sink.d.ts +20 -0
- package/dist/brain/status-sink.js +7 -0
- package/dist/brain/stream-engine.js +6 -5
- package/dist/brain/stream-shared.d.ts +1 -1
- package/dist/core/a2a.d.ts +2 -1
- package/dist/core/a2a.js +19 -13
- package/dist/core/advisor-verdict.d.ts +120 -0
- package/dist/core/advisor-verdict.js +92 -0
- package/dist/core/agent-definition.d.ts +17 -8
- package/dist/core/allow-entry.d.ts +69 -36
- package/dist/core/allow-entry.js +81 -52
- package/dist/core/allow-rule-shadow.d.ts +10 -3
- package/dist/core/approval-object.d.ts +2 -1
- package/dist/core/approval-object.js +6 -6
- package/dist/core/ask-origin.d.ts +127 -29
- package/dist/core/ask-origin.js +87 -25
- package/dist/core/ask-question.d.ts +51 -8
- package/dist/core/ask-question.js +12 -7
- package/dist/core/ask-unresolvable-notice.d.ts +8 -3
- package/dist/core/ask-unresolvable-notice.js +16 -2
- package/dist/core/auto-compaction.d.ts +11 -8
- package/dist/core/auto-compaction.js +4 -2
- package/dist/core/auto-mode-arming.d.ts +2 -2
- package/dist/core/auto-mode-defaults.d.ts +8 -8
- package/dist/core/auto-mode-prompt-assets.d.ts +3 -3
- package/dist/core/auto-mode-prompt.d.ts +1 -1
- package/dist/core/auto-mode.d.ts +17 -9
- package/dist/core/auto-mode.js +9 -6
- package/dist/core/background-agent-store.d.ts +3 -3
- package/dist/core/canonical-json.d.ts +1 -1
- package/dist/core/canonical-json.js +2 -2
- package/dist/core/checkpoint-generation.d.ts +53 -0
- package/dist/core/checkpoint-generation.js +35 -0
- package/dist/core/checkpoint-queries.d.ts +180 -0
- package/dist/core/checkpoint-queries.js +272 -0
- package/dist/core/checkpoint-requirements.d.ts +19 -4
- package/dist/core/checkpoint-requirements.js +8 -14
- package/dist/core/checkpoint-store.d.ts +165 -72
- package/dist/core/checkpoint-store.js +79 -82
- package/dist/core/child-clamp-seats.d.ts +6 -0
- package/dist/core/child-clamp-seats.js +3 -16
- package/dist/core/compliance.d.ts +2 -2
- package/dist/core/context-edit.d.ts +6 -7
- package/dist/core/cross-boundary-taint.d.ts +11 -4
- package/dist/core/cross-boundary-taint.js +3 -3
- package/dist/core/decision-receipt.d.ts +37 -3
- package/dist/core/decision-receipt.js +19 -19
- package/dist/core/delegation-not-started.d.ts +6 -0
- package/dist/core/delegation-not-started.js +17 -0
- package/dist/core/effective-path-target.d.ts +1 -1
- package/dist/core/engine-attestation.d.ts +93 -0
- package/dist/core/engine-attestation.js +70 -0
- package/dist/core/engine-capabilities.d.ts +4 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +45 -12
- package/dist/core/exec-output-tail.d.ts +1 -1
- package/dist/core/file-history-retention.d.ts +1 -1
- package/dist/core/file-history-store.d.ts +147 -21
- package/dist/core/file-history-store.js +58 -32
- package/dist/core/gate-fold.d.ts +1 -1
- package/dist/core/gate-fold.js +24 -11
- package/dist/core/gate-lanes.js +81 -68
- package/dist/core/gate-outcome.d.ts +40 -6
- package/dist/core/gate-outcome.js +56 -0
- package/dist/core/governance-codes.d.ts +17 -3
- package/dist/core/governance-codes.js +16 -0
- package/dist/core/hands-band.d.ts +1 -1
- package/dist/core/hooks.d.ts +21 -20
- package/dist/core/hooks.js +3 -1
- package/dist/core/host-floor.d.ts +128 -0
- package/dist/core/host-floor.js +206 -0
- package/dist/core/host-target.d.ts +84 -0
- package/dist/core/host-target.js +92 -0
- package/dist/core/image-downsample.d.ts +1 -1
- package/dist/core/lsp-diagnostics.d.ts +4 -4
- package/dist/core/lsp.d.ts +3 -3
- package/dist/core/mailbox-store.d.ts +4 -0
- package/dist/core/mcp-connection-pool.d.ts +18 -2
- package/dist/core/mcp-connection-pool.js +53 -6
- package/dist/core/mcp-failure.d.ts +23 -4
- package/dist/core/mcp-failure.js +26 -11
- package/dist/core/mcp-listing-drift.d.ts +10 -0
- package/dist/core/mcp-listing-drift.js +6 -0
- package/dist/core/mcp-server-link.d.ts +173 -0
- package/dist/core/mcp-server-link.js +127 -0
- package/dist/core/mcp-server-spec.d.ts +4 -2
- package/dist/core/mcp-session-end.d.ts +26 -0
- package/dist/core/mcp-session-end.js +29 -0
- package/dist/core/mcp-startup-request.d.ts +17 -0
- package/dist/core/mcp-startup-request.js +17 -0
- package/dist/core/mcp.d.ts +17 -13
- package/dist/core/mcp.js +240 -189
- package/dist/core/media-byte-cap.d.ts +1 -1
- package/dist/core/memory-engine/delegation-settlement.js +15 -24
- package/dist/core/memory-engine/engine.d.ts +9 -9
- package/dist/core/memory-engine/engine.js +4 -4
- package/dist/core/memory-engine/layout.d.ts +60 -8
- package/dist/core/memory-engine/layout.js +65 -6
- package/dist/core/memory-engine/provenance-wording.d.ts +1 -1
- package/dist/core/memory-engine/tools.js +4 -1
- package/dist/core/mode-policy.d.ts +1 -1
- package/dist/core/model-seat.d.ts +10 -3
- package/dist/core/mods/classic-events.d.ts +67 -0
- package/dist/core/mods/classic-events.js +1 -0
- package/dist/core/mods/dollar.d.ts +13 -0
- package/dist/core/mods/extension-call.d.ts +31 -0
- package/dist/core/mods/extension-call.js +43 -0
- package/dist/core/mods/kernel/dispatch.d.ts +20 -3
- package/dist/core/mods/kernel/dispatch.js +140 -69
- package/dist/core/mods/kernel/events.d.ts +47 -11
- package/dist/core/mods/kernel/events.js +66 -42
- package/dist/core/mods/kernel/index.d.ts +4 -4
- package/dist/core/mods/kernel/index.js +2 -2
- package/dist/core/mods/kernel/receive.d.ts +39 -5
- package/dist/core/mods/kernel/receive.js +290 -17
- package/dist/core/mods/kernel/registration.d.ts +33 -2
- package/dist/core/mods/kernel/registration.js +6 -7
- package/dist/core/mods/kernel/site-rules.d.ts +44 -16
- package/dist/core/mods/kernel/site-rules.js +24 -42
- package/dist/core/mods/spec-seats.d.ts +69 -0
- package/dist/core/mods/spec-seats.js +114 -0
- package/dist/core/mods/stations.d.ts +28 -8
- package/dist/core/mods/stations.js +29 -13
- package/dist/core/mods/tool-call.d.ts +79 -0
- package/dist/core/mods/tool-call.js +152 -0
- package/dist/core/namespaced-rule-name.d.ts +44 -24
- package/dist/core/namespaced-rule-name.js +50 -43
- package/dist/core/output-style.d.ts +1 -1
- package/dist/core/param-rule-reach.d.ts +15 -0
- package/dist/core/param-rule-reach.js +30 -0
- package/dist/core/parent-spec-seat.d.ts +13 -1
- package/dist/core/parent-spec-seat.js +6 -0
- package/dist/core/park-selfcheck.js +1 -0
- package/dist/core/pause-registry.d.ts +16 -5
- package/dist/core/pause-registry.js +6 -2
- package/dist/core/peer-channel.d.ts +70 -0
- package/dist/core/peer-channel.js +1 -0
- package/dist/core/permission-rule-consent.d.ts +30 -5
- package/dist/core/permission-rule-consent.js +147 -50
- package/dist/core/permission-rule-model.d.ts +245 -65
- package/dist/core/permission-rule-model.js +421 -107
- package/dist/core/permission-rule-org.d.ts +6 -2
- package/dist/core/permission-rule-org.js +7 -3
- package/dist/core/permission-rule-provider.d.ts +6 -2
- package/dist/core/permission-rule-provider.js +41 -11
- package/dist/core/permission-rule-store.d.ts +22 -26
- package/dist/core/permission-rule-store.js +12 -6
- package/dist/core/permission-rule-sync.d.ts +11 -2
- package/dist/core/permission-rule-sync.js +11 -3
- package/dist/core/permission-rule-syntax.d.ts +5 -4
- package/dist/core/permission-rule-syntax.js +2 -2
- package/dist/core/permission-rules.d.ts +53 -15
- package/dist/core/permission-rules.js +125 -100
- package/dist/core/persisted-rule-arms.d.ts +6 -4
- package/dist/core/persisted-rule-arms.js +10 -12
- package/dist/core/present-plan-tool.js +3 -1
- package/dist/core/principal-name.d.ts +20 -0
- package/dist/core/principal-name.js +22 -0
- package/dist/core/prompt-section-seat.js +4 -6
- package/dist/core/protocol-http-auth.d.ts +26 -5
- package/dist/core/protocol-http-auth.js +137 -4
- package/dist/core/protocol-naming.d.ts +2 -2
- package/dist/core/read-only-shell-table.d.ts +1 -1
- package/dist/core/read-only-shell.d.ts +1 -1
- package/dist/core/retired-keys.d.ts +16 -0
- package/dist/core/retired-keys.js +16 -4
- package/dist/core/rewrite-rejudge.d.ts +60 -0
- package/dist/core/rewrite-rejudge.js +36 -0
- package/dist/core/roles.d.ts +34 -3
- package/dist/core/roles.js +66 -53
- package/dist/core/rule-lane-reads.d.ts +20 -15
- package/dist/core/rule-lane-reads.js +45 -17
- package/dist/core/rule-offer-read.d.ts +53 -0
- package/dist/core/rule-offer-read.js +146 -0
- package/dist/core/rule-owner.d.ts +46 -0
- package/dist/core/rule-owner.js +29 -0
- package/dist/core/runner/advisor-instructions.d.ts +70 -0
- package/dist/core/runner/advisor-instructions.js +61 -0
- package/dist/core/runner/advisor-tool.d.ts +33 -0
- package/dist/core/runner/advisor-tool.js +112 -0
- package/dist/core/runner/announce-once-ledger.d.ts +18 -26
- package/dist/core/runner/announce-once-ledger.js +19 -46
- package/dist/core/runner/approval-feedback.js +6 -3
- package/dist/core/runner/assemble-result.d.ts +2 -1
- package/dist/core/runner/assemble-result.js +1 -1
- package/dist/core/runner/call-hook-stations.d.ts +3 -2
- package/dist/core/runner/caller-roster.d.ts +21 -2
- package/dist/core/runner/caller-roster.js +38 -0
- package/dist/core/runner/capability-withheld-seat.d.ts +5 -0
- package/dist/core/runner/capability-withheld-seat.js +24 -0
- package/dist/core/runner/classifier-ladder.d.ts +33 -13
- package/dist/core/runner/classifier-ladder.js +15 -14
- package/dist/core/runner/compaction-restate.d.ts +10 -6
- package/dist/core/runner/compaction-restate.js +9 -3
- package/dist/core/runner/construction-doors.js +3 -0
- package/dist/core/runner/contracts.d.ts +40 -33
- package/dist/core/runner/conversation-segment.d.ts +28 -0
- package/dist/core/runner/conversation-segment.js +42 -0
- package/dist/core/runner/cross-boundary-lane.d.ts +21 -16
- package/dist/core/runner/cross-boundary-lane.js +58 -34
- package/dist/core/runner/decide-continuation.d.ts +7 -4
- package/dist/core/runner/decide-continuation.js +2 -2
- package/dist/core/runner/denial-limit-arms.d.ts +4 -4
- package/dist/core/runner/denial-limit-arms.js +1 -1
- package/dist/core/runner/derived-route-fallback.d.ts +24 -24
- package/dist/core/runner/derived-route-fallback.js +9 -7
- package/dist/core/runner/file-history-request.d.ts +18 -0
- package/dist/core/runner/file-history-request.js +21 -13
- package/dist/core/runner/file-history-restore.d.ts +45 -0
- package/dist/core/runner/file-history-restore.js +46 -0
- package/dist/core/runner/gate-exit.d.ts +9 -3
- package/dist/core/runner/gate-exit.js +11 -5
- package/dist/core/runner/image.d.ts +7 -17
- package/dist/core/runner/image.js +9 -60
- package/dist/core/runner/initial-run-state.js +1 -1
- package/dist/core/runner/permission-rule-lanes.d.ts +6 -6
- package/dist/core/runner/permission-rule-lanes.js +38 -15
- package/dist/core/runner/person-path-rows.d.ts +12 -9
- package/dist/core/runner/person-path-rows.js +19 -8
- package/dist/core/runner/prepare-advisor.d.ts +63 -0
- package/dist/core/runner/prepare-advisor.js +77 -0
- package/dist/core/runner/prepare-ask-lane.d.ts +2 -2
- package/dist/core/runner/prepare-ask-lane.js +5 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -6
- package/dist/core/runner/prepare-caps-and-workflow.js +5 -4
- package/dist/core/runner/prepare-config-doors.d.ts +31 -38
- package/dist/core/runner/prepare-config-doors.js +57 -34
- package/dist/core/runner/prepare-defer-classify.d.ts +4 -3
- package/dist/core/runner/prepare-defer-classify.js +7 -8
- package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
- package/dist/core/runner/prepare-delegation-surface.js +1 -1
- package/dist/core/runner/prepare-file-history.d.ts +48 -8
- package/dist/core/runner/prepare-file-history.js +41 -73
- package/dist/core/runner/prepare-gate-stations.d.ts +2 -5
- package/dist/core/runner/prepare-gate-stations.js +12 -8
- package/dist/core/runner/prepare-hands-readface.d.ts +2 -8
- package/dist/core/runner/prepare-hands-readface.js +15 -14
- package/dist/core/runner/prepare-inherited-gate.d.ts +11 -7
- package/dist/core/runner/prepare-inherited-gate.js +8 -6
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-park-ask.js +12 -12
- package/dist/core/runner/prepare-policy-chain.d.ts +7 -4
- package/dist/core/runner/prepare-policy-chain.js +68 -81
- package/dist/core/runner/prepare-project-context.d.ts +5 -2
- package/dist/core/runner/prepare-project-context.js +6 -3
- package/dist/core/runner/prepare-prompt-assembly.d.ts +5 -7
- package/dist/core/runner/prepare-prompt-assembly.js +10 -8
- package/dist/core/runner/prepare-prompt-inputs.d.ts +11 -9
- package/dist/core/runner/prepare-prompt-inputs.js +4 -6
- package/dist/core/runner/prepare-protocol-tools.d.ts +4 -2
- package/dist/core/runner/prepare-protocol-tools.js +5 -4
- package/dist/core/runner/prepare-safety-scan.d.ts +9 -12
- package/dist/core/runner/prepare-safety-scan.js +8 -23
- package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
- package/dist/core/runner/prepare-suspend-saga.js +5 -6
- package/dist/core/runner/prepare-task.d.ts +1 -1
- package/dist/core/runner/prepare-task.js +41 -35
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +7 -4
- package/dist/core/runner/prepare-tool-disclosure-mount.js +24 -18
- package/dist/core/runner/prepare-turn-wiring.d.ts +0 -4
- package/dist/core/runner/prepare-turn-wiring.js +2 -7
- package/dist/core/runner/prepare-wiring-manifest.d.ts +11 -4
- package/dist/core/runner/prepare-wiring-manifest.js +3 -3
- package/dist/core/runner/resume-admission.js +1 -1
- package/dist/core/runner/resume-apply.js +11 -12
- package/dist/core/runner/resume-checkpoint-screen.js +3 -0
- package/dist/core/runner/resume-claim.d.ts +4 -2
- package/dist/core/runner/resume-claim.js +15 -8
- package/dist/core/runner/resume-policy-outcome.js +1 -1
- package/dist/core/runner/retired-runner-deps.js +2 -1
- package/dist/core/runner/rewind-files.d.ts +15 -0
- package/dist/core/runner/rewind-files.js +132 -0
- package/dist/core/runner/run-attachment-seats.js +2 -2
- package/dist/core/runner/run-brain-sinks.d.ts +4 -1
- package/dist/core/runner/run-brain-sinks.js +4 -2
- package/dist/core/runner/run-compaction-machinery.d.ts +1 -1
- package/dist/core/runner/run-compaction-machinery.js +2 -12
- package/dist/core/runner/run-git-lane.d.ts +1 -0
- package/dist/core/runner/run-harness-handlers.js +14 -7
- package/dist/core/runner/run-leg.d.ts +1 -1
- package/dist/core/runner/run-leg.js +43 -18
- package/dist/core/runner/run-settle-and-teardown.js +3 -2
- package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
- package/dist/core/runner/run-turn-boundary.d.ts +1 -0
- package/dist/core/runner/run-turn-boundary.js +15 -22
- package/dist/core/runner/runtask.d.ts +3 -0
- package/dist/core/runner/runtask.js +8 -9
- package/dist/core/runner/session-read-file-states.d.ts +15 -0
- package/dist/core/runner/session-read-file-states.js +28 -0
- package/dist/core/runner/session-rule-policy.d.ts +22 -21
- package/dist/core/runner/session-rule-policy.js +17 -31
- package/dist/core/runner/shell-env-withheld.d.ts +33 -0
- package/dist/core/runner/shell-env-withheld.js +51 -0
- package/dist/core/runner/side-call-account.d.ts +32 -8
- package/dist/core/runner/side-call-account.js +23 -1
- package/dist/core/runner/skills-seat.js +6 -2
- package/dist/core/runner/stream-settle-backstop.js +1 -1
- package/dist/core/runner/strict-output-schema.d.ts +1 -1
- package/dist/core/runner/sub-agent-deny-lists.js +4 -6
- package/dist/core/runner/synthetic-tools.d.ts +16 -13
- package/dist/core/runner/synthetic-tools.js +8 -3
- package/dist/core/runner/tool-disclosure.d.ts +10 -12
- package/dist/core/runner/tool-disclosure.js +3 -4
- package/dist/core/runner/tool-end-body.d.ts +1 -1
- package/dist/core/runner/tool-end-body.js +10 -9
- package/dist/core/runner/tool-face-overlay.d.ts +2 -1
- package/dist/core/runner/tool-face-overlay.js +17 -1
- package/dist/core/runner/tool-not-executed.d.ts +5 -0
- package/dist/core/runner/tool-not-executed.js +11 -0
- package/dist/core/runner/tool-occurrence.d.ts +8 -0
- package/dist/core/runner/tool-occurrence.js +7 -0
- package/dist/core/runner/tool-progress-lane.d.ts +2 -2
- package/dist/core/runner/tool-turn-repair-seat.d.ts +3 -2
- package/dist/core/runner/turn-attachments.d.ts +91 -80
- package/dist/core/runner/turn-attachments.js +62 -37
- package/dist/core/runner-deps.d.ts +42 -42
- package/dist/core/runtime-caps.d.ts +4 -4
- package/dist/core/safety-axis-vocab.d.ts +6 -4
- package/dist/core/safety-axis-vocab.js +6 -5
- package/dist/core/safety-merge-corpus.js +26 -2
- package/dist/core/same-plain-value.d.ts +40 -0
- package/dist/core/same-plain-value.js +49 -0
- package/dist/core/scheduler.d.ts +1 -1
- package/dist/core/secret-env.d.ts +26 -3
- package/dist/core/secret-env.js +44 -8
- package/dist/core/select-model.js +3 -3
- package/dist/core/sensitive-path-policy.d.ts +1 -1
- package/dist/core/sensitive-path-policy.js +1 -1
- package/dist/core/session-policy-store.d.ts +102 -35
- package/dist/core/session-policy-store.js +210 -48
- package/dist/core/session-reconcile.d.ts +2 -2
- package/dist/core/session-store.d.ts +106 -37
- package/dist/core/session-store.js +165 -91
- package/dist/core/session.d.ts +101 -57
- package/dist/core/session.js +53 -0
- package/dist/core/shared-memory/tools.js +3 -1
- package/dist/core/shared-memory/types.d.ts +1 -1
- package/dist/core/shell-read-silence.d.ts +11 -12
- package/dist/core/shell-read-silence.js +9 -5
- package/dist/core/shell-run-candidates.js +3 -1
- package/dist/core/shell-wrapper-projection.js +1 -1
- package/dist/core/shell-wrapper-table.d.ts +14 -7
- package/dist/core/shell-wrapper-table.js +5 -4
- package/dist/core/side-query.d.ts +10 -0
- package/dist/core/side-query.js +15 -1
- package/dist/core/skill-grant.d.ts +7 -2
- package/dist/core/skill-grant.js +5 -0
- package/dist/core/skills-directory.js +6 -2
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +11 -1
- package/dist/core/store-contracts/checkpoint-store-contract.js +168 -3
- package/dist/core/store-contracts/file-history-store-contract.js +74 -4
- package/dist/core/store-contracts/peer-directory-contract.d.ts +7 -2
- package/dist/core/store-contracts/peer-directory-contract.js +14 -2
- package/dist/core/store-contracts/session-policy-store-contract.d.ts +7 -0
- package/dist/core/store-contracts/session-policy-store-contract.js +130 -0
- package/dist/core/store-contracts/session-repo-contract.js +176 -0
- package/dist/core/store-contracts/session-store-contract.d.ts +6 -8
- package/dist/core/store-contracts/session-store-contract.js +361 -51
- package/dist/core/store-contracts/workflow-journal-store-contract.js +26 -1
- package/dist/core/stub-env.d.ts +2 -0
- package/dist/core/stub-env.js +1 -0
- package/dist/core/surrogate-safe-slice.d.ts +3 -3
- package/dist/core/synthetic-read-verdict.js +3 -3
- package/dist/core/task-event.d.ts +42 -8
- package/dist/core/task-notification.d.ts +19 -15
- package/dist/core/task-registry-agent.d.ts +4 -4
- package/dist/core/task-registry-shared.d.ts +4 -4
- package/dist/core/task-registry-shared.js +1 -0
- package/dist/core/task-registry.d.ts +13 -4
- package/dist/core/task-registry.js +14 -2
- package/dist/core/task-result.d.ts +21 -3
- package/dist/core/task-spec.d.ts +69 -64
- package/dist/core/task-stream.d.ts +6 -6
- package/dist/core/task-tool-shape.d.ts +4 -4
- package/dist/core/tighten-task-spec.d.ts +1 -1
- package/dist/core/tighten-task-spec.js +2 -1
- package/dist/core/tool-catalog-entries.d.ts +36 -2
- package/dist/core/tool-catalog-entries.js +69 -43
- package/dist/core/tool-check-reading.d.ts +11 -0
- package/dist/core/tool-check-reading.js +11 -6
- package/dist/core/tool-conformance.js +1 -0
- package/dist/core/tool-errors.d.ts +2 -2
- package/dist/core/tool-face-reader.js +5 -3
- package/dist/core/tool-face.d.ts +21 -2
- package/dist/core/tool-face.js +1 -1
- package/dist/core/tool-model-gate.d.ts +5 -5
- package/dist/core/tool-name-aliases.d.ts +29 -8
- package/dist/core/tool-name-aliases.js +22 -4
- package/dist/core/tool-name-readings.d.ts +10 -43
- package/dist/core/tool-name-readings.js +2 -11
- package/dist/core/tool-policy.d.ts +85 -196
- package/dist/core/tool-policy.js +150 -175
- package/dist/core/tool-registry.d.ts +14 -7
- package/dist/core/tool-registry.js +17 -7
- package/dist/core/tool-result-store.js +5 -1
- package/dist/core/tool-roster.d.ts +57 -33
- package/dist/core/tool-roster.js +56 -68
- package/dist/core/tool-spec-members.js +8 -3
- package/dist/core/tool-spec.d.ts +53 -31
- package/dist/core/tools.js +51 -10
- package/dist/core/trace.d.ts +6 -2
- package/dist/core/types.d.ts +1 -1
- package/dist/core/untrusted-egress.d.ts +1 -1
- package/dist/core/untrusted-text.d.ts +1 -1
- package/dist/core/user-attachment.d.ts +8 -1
- package/dist/core/user-attachment.js +64 -4
- package/dist/core/warm-resume.d.ts +1 -1
- package/dist/core/wiring-manifest.d.ts +58 -0
- package/dist/core/wiring-manifest.js +14 -5
- package/dist/core/workflow-journal-store.d.ts +62 -0
- package/dist/core/workflow-journal-store.js +78 -2
- package/dist/core/workflow-run-store.d.ts +6 -0
- package/dist/core/workflow-run-store.js +2 -0
- package/dist/engine/compaction/compaction.d.ts +9 -9
- package/dist/engine/compaction/compaction.js +3 -2
- package/dist/engine/execution-env/node-execution-env.d.ts +26 -8
- package/dist/engine/execution-env/node-execution-env.js +54 -24
- package/dist/engine/harness/agent-harness.d.ts +39 -9
- package/dist/engine/harness/agent-harness.js +87 -33
- package/dist/engine/harness/types.d.ts +58 -9
- package/dist/engine/harness/types.js +12 -1
- package/dist/engine/llm/types.d.ts +36 -19
- package/dist/engine/llm/validation.d.ts +4 -1
- package/dist/engine/llm/validation.js +13 -1
- package/dist/engine/loop/agent-loop.d.ts +23 -1
- package/dist/engine/loop/agent-loop.js +26 -34
- package/dist/engine/loop/types.d.ts +31 -19
- package/dist/engine/lsp/node-lsp-manager.d.ts +2 -2
- package/dist/engine/session/memory-repo.d.ts +18 -12
- package/dist/engine/session/memory-repo.js +24 -9
- package/dist/engine/session/parent-chain-guard.d.ts +3 -2
- package/dist/engine/session/parent-chain-guard.js +1 -1
- package/dist/engine/session/repo-utils.d.ts +32 -3
- package/dist/engine/session/repo-utils.js +50 -5
- package/dist/index.d.ts +47 -23
- package/dist/index.js +35 -17
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +3 -3
- package/dist/internal/harness.js +2 -2
- package/dist/internal/llm.d.ts +2 -2
- package/dist/internal/llm.js +1 -1
- package/dist/orchestration/goal.js +2 -2
- package/dist/orchestration/run-workflow-tool.d.ts +8 -6
- package/dist/orchestration/run-workflow-tool.js +10 -6
- package/dist/orchestration/workflow-size-guideline.d.ts +4 -4
- package/dist/orchestration/workflow-types.d.ts +18 -0
- package/dist/orchestration/workflow-types.js +6 -0
- package/dist/orchestration/workflow.d.ts +5 -13
- package/dist/orchestration/workflow.js +57 -49
- package/dist/prompt-assembly/artifact.d.ts +2 -2
- package/dist/prompt-assembly/artifact.js +5 -3
- package/dist/prompt-assembly/assemble.d.ts +3 -2
- package/dist/prompt-assembly/assemble.js +1 -1
- package/dist/prompt-assembly/catalog/schema.d.ts +43 -12
- package/dist/prompt-assembly/catalog/schema.js +34 -2
- package/dist/prompt-assembly/catalog/sections.js +0 -1
- package/dist/prompt-assembly/composer.d.ts +3 -1
- package/dist/prompt-assembly/composer.js +1 -1
- package/dist/prompt-assembly/event-registry.js +2 -0
- package/dist/prompt-assembly/overlay.js +3 -3
- package/dist/prompt-assembly/renderers.d.ts +1 -1
- package/dist/prompt-assembly/renderers.js +0 -3
- package/dist/prompt-assembly/role-base.d.ts +15 -0
- package/dist/prompt-assembly/role-base.js +9 -0
- package/dist/prompt-assembly/select.d.ts +39 -14
- package/dist/prompt-assembly/select.js +47 -16
- package/dist/prompt-assembly/sugar.d.ts +17 -11
- package/dist/prompt-assembly/sugar.js +8 -3
- package/dist/prompt-assembly/tool-catalog.d.ts +39 -2
- package/dist/prompt-assembly/tool-catalog.js +117 -4
- package/dist/prompt-assembly/turn-snapshot.d.ts +4 -10
- package/dist/prompt-assembly/turn-snapshot.js +0 -3
- package/dist/prompt-assembly/types.d.ts +0 -7
- package/dist/prompts/default.d.ts +14 -14
- package/dist/scenarios/full-body.d.ts +15 -15
- package/dist/scenarios/full-body.js +4 -3
- package/dist/shell/lex.js +10 -1
- package/dist/stores/file/adoption/adopt.d.ts +4 -3
- package/dist/stores/file/adoption/adopt.js +27 -33
- package/dist/stores/file/adoption/marker.d.ts +6 -13
- package/dist/stores/file/adoption/marker.js +9 -17
- package/dist/stores/file/checkpoint-store.d.ts +24 -0
- package/dist/stores/file/checkpoint-store.js +45 -7
- package/dist/stores/file/file-history-store.d.ts +20 -19
- package/dist/stores/file/file-history-store.js +157 -141
- package/dist/stores/file/fs-atomic.d.ts +15 -0
- package/dist/stores/file/fs-atomic.js +89 -14
- package/dist/stores/file/index.d.ts +1 -1
- package/dist/stores/file/index.js +2 -1
- package/dist/stores/file/mailbox-store.d.ts +3 -0
- package/dist/stores/file/mailbox-store.js +3 -1
- package/dist/stores/file/permission-rule-adopt.d.ts +1 -1
- package/dist/stores/file/permission-rule-adopt.js +18 -18
- package/dist/stores/file/permission-rule-store.d.ts +18 -2
- package/dist/stores/file/permission-rule-store.js +31 -18
- package/dist/stores/file/session-policy-store.d.ts +3 -3
- package/dist/stores/file/session-store.d.ts +54 -16
- package/dist/stores/file/session-store.js +114 -85
- package/dist/stores/file/workflow-journal-store.d.ts +10 -4
- package/dist/stores/file/workflow-journal-store.js +28 -13
- package/dist/tools/artifact/artifact-text.d.ts +1 -1
- package/dist/tools/artifact/artifact-tool.js +5 -3
- package/dist/tools/fs/bash-program-position.d.ts +19 -2
- package/dist/tools/fs/bash-program-position.js +56 -9
- package/dist/tools/fs/bash-readonly-classifier.d.ts +3 -3
- package/dist/tools/fs/fs-bash.d.ts +2 -2
- package/dist/tools/fs/fs-bash.js +8 -6
- package/dist/tools/fs/fs-glob.d.ts +86 -0
- package/dist/tools/fs/fs-glob.js +226 -0
- package/dist/tools/fs/fs-read.js +14 -14
- package/dist/tools/fs/fs-search-tools.js +7 -7
- package/dist/tools/fs/fs-shared.d.ts +8 -8
- package/dist/tools/fs/gh-rate-limit.d.ts +1 -1
- package/dist/tools/fs/notebook.d.ts +2 -2
- package/dist/tools/fs/pattern-kill-guard.d.ts +22 -0
- package/dist/tools/fs/pattern-kill-guard.js +397 -0
- package/dist/tools/fs/pdf.d.ts +9 -6
- package/dist/tools/fs/pdf.js +3 -3
- package/dist/tools/fs/program-read-model.d.ts +57 -7
- package/dist/tools/fs/program-read-model.js +11 -1
- package/dist/tools/fs/program-read-model.rows.js +78 -21
- package/dist/tools/fs/read-deny-home.js +3 -2
- package/dist/tools/fs/read-deny.d.ts +29 -7
- package/dist/tools/fs/read-deny.js +63 -22
- package/dist/tools/fs/removal-targets.d.ts +18 -8
- package/dist/tools/fs/removal-targets.js +47 -20
- package/dist/tools/fs/safety.d.ts +9 -9
- package/dist/tools/fs/search.d.ts +16 -6
- package/dist/tools/fs/search.js +20 -26
- package/dist/tools/fs/shell-read-argv.js +89 -12
- package/dist/tools/fs/shell-read-bindings.d.ts +31 -0
- package/dist/tools/fs/shell-read-bindings.js +41 -0
- package/dist/tools/fs/shell-read-check.js +12 -20
- package/dist/tools/fs/shell-read-environment.d.ts +5 -1
- package/dist/tools/fs/shell-read-environment.js +3 -2
- package/dist/tools/fs/shell-read-establish.d.ts +15 -0
- package/dist/tools/fs/shell-read-establish.js +19 -20
- package/dist/tools/fs/shell-read-judge.d.ts +4 -0
- package/dist/tools/fs/shell-read-judge.js +5 -2
- package/dist/tools/fs/shell-read-plan.js +24 -16
- package/dist/tools/fs/shell-read-start.d.ts +6 -1
- package/dist/tools/fs/shell-read-write-targets.d.ts +5 -1
- package/dist/tools/fs/shell-read-write-targets.js +2 -3
- package/dist/tools/fs/shell-reentry-text.d.ts +9 -0
- package/dist/tools/fs/shell-reentry-text.js +40 -2
- package/dist/tools/loop-tick.d.ts +2 -2
- package/dist/tools/scheduler-tools.js +5 -1
- package/dist/tools/task-list.d.ts +7 -7
- package/dist/tools/task-list.js +5 -1
- package/dist/tools/todo.js +65 -64
- package/dist/tools/web.d.ts +20 -15
- package/dist/tools/web.js +55 -69
- package/dist/tools/worktree.d.ts +3 -3
- package/dist/tools/worktree.js +3 -1
- package/package.json +1 -1
- package/test/export-surface.snapshot.json +5894 -5638
- package/wire-changes/core@7.55.0.json +3318 -0
- package/wire-changes/core@7.56.0.json +3891 -0
- package/wire-changes/mods-kernel@7.56.0.json +303 -0
- package/dist/core/store-contracts/session-store-incarnation-contract.d.ts +0 -39
- package/dist/core/store-contracts/session-store-incarnation-contract.js +0 -95
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
import { randomBytes, timingSafeEqual } from "node:crypto";
|
|
2
|
+
import { createServer, Socket } from "node:net";
|
|
3
|
+
import { chmod, lstat, mkdir, readdir, readFile, rename, unlink, writeFile } from "node:fs/promises";
|
|
4
|
+
import { dirname, isAbsolute, join, resolve as resolvePath } from "node:path";
|
|
5
|
+
import { CrossSessionCodecError, decodeCcPeerFrame } from "./cross-session-envelope.js";
|
|
6
|
+
import { peerSendVerdictSeverity } from "./cross-session-judge.js";
|
|
7
|
+
import { peerAxisToken, peerWireHopToken, resolvePeerLaneConfig } from "./peer-admission.js";
|
|
8
|
+
import { judgePeerRecordFile, peerSessionBoxHandle, vetPeerRegistryDirectory } from "./peer-directory.js";
|
|
9
|
+
import { defaultCcProcessProbe } from "./cc-peer-directory.js";
|
|
10
|
+
import { CC_PEER_FIRST_LINE_DEADLINE_MS, CC_PEER_KEY_FILE_MAX_BYTES, CC_PEER_KEY_FILE_RE, CC_PEER_LINE_MAX_CHARS, CC_PEER_SEND_TIMEOUT_MS, CC_PEER_SOCKET_PATH_MAX_BYTES, CC_PEER_TOKEN_RE, ccPeerAddress, ccPeerKeyFileName, ccPeerSocketDigest, ccRegistrationRow, encodeCcAuthLine, encodeCcNudgeLine, encodeCcUserLine, parseCcPeerLine, } from "./cc-peer-wire.js";
|
|
11
|
+
export class CcPeerChannelError extends Error {
|
|
12
|
+
code;
|
|
13
|
+
path;
|
|
14
|
+
constructor(code, message, path) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = "CcPeerChannelError";
|
|
17
|
+
this.code = code;
|
|
18
|
+
if (path !== undefined)
|
|
19
|
+
this.path = path;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const LISTENING_SLOTS = new Set();
|
|
23
|
+
const NUDGE_TIMEOUT_MS = 1_000;
|
|
24
|
+
const STALE_PROBE_MS = 250;
|
|
25
|
+
function errCode(e) {
|
|
26
|
+
const c = e?.code;
|
|
27
|
+
return typeof c === "string" ? c : undefined;
|
|
28
|
+
}
|
|
29
|
+
async function writeFileAtomic0600(path, text) {
|
|
30
|
+
const tmp = `${path}.tmp.${randomBytes(6).toString("hex")}`;
|
|
31
|
+
try {
|
|
32
|
+
await writeFile(tmp, text, { mode: 0o600, flag: "wx" });
|
|
33
|
+
await rename(tmp, path);
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
await unlink(tmp).catch(() => undefined);
|
|
37
|
+
throw e;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function probeSocket(path, ms) {
|
|
41
|
+
return new Promise((resolve) => {
|
|
42
|
+
const s = new Socket();
|
|
43
|
+
const done = (answer) => {
|
|
44
|
+
s.destroy();
|
|
45
|
+
resolve(answer);
|
|
46
|
+
};
|
|
47
|
+
s.setTimeout(ms, () => done("unknown"));
|
|
48
|
+
s.once("connect", () => done("live"));
|
|
49
|
+
s.once("error", (e) => done(errCode(e) === "ECONNREFUSED" ? "stale" : "unknown"));
|
|
50
|
+
s.connect({ path });
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
export function createCcUdsPeerChannel(opts) {
|
|
54
|
+
const platform = opts.platform ?? process.platform;
|
|
55
|
+
const pid = opts.pid ?? process.pid;
|
|
56
|
+
const probe = opts.probe ?? defaultCcProcessProbe;
|
|
57
|
+
const now = opts.now ?? Date.now;
|
|
58
|
+
const uid = opts.uid ?? (typeof process.getuid === "function" ? process.getuid() : undefined);
|
|
59
|
+
const vetOpts = { ...(uid !== undefined ? { uid } : {}), platform };
|
|
60
|
+
let listening;
|
|
61
|
+
const ensureVettedDir = async (dir) => {
|
|
62
|
+
try {
|
|
63
|
+
await lstat(dir);
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
if (errCode(e) !== "ENOENT")
|
|
67
|
+
throw e;
|
|
68
|
+
await mkdir(dir, { recursive: true, mode: 0o700 });
|
|
69
|
+
}
|
|
70
|
+
const verdict = await vetPeerRegistryDirectory(dir, vetOpts);
|
|
71
|
+
if (!verdict.ok)
|
|
72
|
+
throw new CcPeerChannelError(verdict.code, `the directory ${verdict.path} is not one this engine can trust (${verdict.code}) — the socket lane was not opened`, verdict.path);
|
|
73
|
+
};
|
|
74
|
+
const vetPeerSocket = async (address) => {
|
|
75
|
+
if (platform === "win32")
|
|
76
|
+
return { ok: false, code: "peer_send.not_reachable", text: "the reference agent's socket lane is not available on this platform" };
|
|
77
|
+
if (!isAbsolute(address) || Buffer.byteLength(address) > CC_PEER_SOCKET_PATH_MAX_BYTES)
|
|
78
|
+
return { ok: false, code: "peer_send.invalid_target", text: `${JSON.stringify(address.slice(0, 120))} is not a usable local socket address` };
|
|
79
|
+
const verdict = await vetPeerRegistryDirectory(dirname(address), vetOpts);
|
|
80
|
+
if (!verdict.ok)
|
|
81
|
+
return { ok: false, code: "peer_send.invalid_target", text: `the peer's socket directory is not one this engine trusts (${verdict.code}: ${verdict.path})` };
|
|
82
|
+
let st;
|
|
83
|
+
try {
|
|
84
|
+
st = await lstat(address);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return { ok: false, code: "peer_send.not_reachable", text: "no socket exists at that address (the session is gone)" };
|
|
88
|
+
}
|
|
89
|
+
if (st.isSymbolicLink())
|
|
90
|
+
return { ok: false, code: "peer_send.invalid_target", text: "the peer's socket address is a link" };
|
|
91
|
+
if (!st.isSocket())
|
|
92
|
+
return { ok: false, code: "peer_send.invalid_target", text: "the peer's address is not a socket" };
|
|
93
|
+
return { ok: true };
|
|
94
|
+
};
|
|
95
|
+
const readPeerToken = async (address) => {
|
|
96
|
+
const digest = ccPeerSocketDigest(address);
|
|
97
|
+
let names;
|
|
98
|
+
try {
|
|
99
|
+
names = await readdir(opts.registryDir);
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
const candidates = names
|
|
105
|
+
.map((n) => ({ n, m: CC_PEER_KEY_FILE_RE.exec(n) }))
|
|
106
|
+
.filter((c) => c.m !== null && c.m[2] === digest)
|
|
107
|
+
.map((c) => ({ file: c.n, pid: Number.parseInt(c.m[1], 10) }))
|
|
108
|
+
.sort((a, b) => Number(probe.processExists(b.pid)) - Number(probe.processExists(a.pid)));
|
|
109
|
+
for (const c of candidates) {
|
|
110
|
+
const path = join(opts.registryDir, c.file);
|
|
111
|
+
try {
|
|
112
|
+
const st = await lstat(path);
|
|
113
|
+
if (!judgePeerRecordFile({ uid: st.uid, mode: st.mode, isFile: st.isFile(), size: st.size }, uid, platform).ok || st.size > CC_PEER_KEY_FILE_MAX_BYTES)
|
|
114
|
+
continue;
|
|
115
|
+
const parsed = JSON.parse(await readFile(path, "utf8"));
|
|
116
|
+
const token = parsed !== null && typeof parsed === "object" ? parsed["peerToken"] : undefined;
|
|
117
|
+
if (typeof token === "string" && CC_PEER_TOKEN_RE.test(token))
|
|
118
|
+
return token;
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return undefined;
|
|
124
|
+
};
|
|
125
|
+
const send = (address, payload, timeoutMs) => new Promise((resolve) => {
|
|
126
|
+
const sock = new Socket();
|
|
127
|
+
let written = false;
|
|
128
|
+
let settled = false;
|
|
129
|
+
const settle = (v) => {
|
|
130
|
+
if (settled)
|
|
131
|
+
return;
|
|
132
|
+
settled = true;
|
|
133
|
+
sock.destroy();
|
|
134
|
+
resolve(v);
|
|
135
|
+
};
|
|
136
|
+
sock.setTimeout(timeoutMs, () => settle(written ? { ok: false, code: "peer_send.send_uncertain", text: "the frame was written but the connection did not close in time — it may have arrived" } : { ok: false, code: "peer_send.timeout", text: `the peer did not accept the connection within ${timeoutMs} ms` }));
|
|
137
|
+
sock.once("error", (e) => {
|
|
138
|
+
const c = errCode(e);
|
|
139
|
+
if (written)
|
|
140
|
+
return settle({ ok: false, code: "peer_send.send_uncertain", text: `the frame was written, then the connection failed (${c ?? "error"}) — it may have arrived` });
|
|
141
|
+
if (c === "ENOENT")
|
|
142
|
+
return settle({ ok: false, code: "peer_send.not_reachable", text: "no socket exists at that address (the session is gone)" });
|
|
143
|
+
if (c === "ECONNREFUSED")
|
|
144
|
+
return settle({ ok: false, code: "peer_send.stale_socket", text: "the socket file is there but nothing is listening on it (the session ended)" });
|
|
145
|
+
if (c === "EAGAIN" || c === "EBUSY")
|
|
146
|
+
return settle({ ok: false, code: "peer_send.socket_busy", text: "the peer's socket is momentarily busy — retry shortly" });
|
|
147
|
+
return settle({ ok: false, code: "peer_send.other", text: `the connection failed (${c ?? "error"})` });
|
|
148
|
+
});
|
|
149
|
+
sock.once("connect", () => {
|
|
150
|
+
sock.write(payload, () => {
|
|
151
|
+
written = true;
|
|
152
|
+
sock.end();
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
sock.once("close", (hadError) => {
|
|
156
|
+
if (!hadError)
|
|
157
|
+
settle(written ? { ok: true } : { ok: false, code: "peer_send.send_uncertain", text: "the connection closed before the frame was confirmed written" });
|
|
158
|
+
});
|
|
159
|
+
sock.connect({ path: address });
|
|
160
|
+
});
|
|
161
|
+
const prepareSocketPath = async (socketPath) => {
|
|
162
|
+
await ensureVettedDir(dirname(socketPath));
|
|
163
|
+
await ensureVettedDir(opts.registryDir);
|
|
164
|
+
let existing;
|
|
165
|
+
try {
|
|
166
|
+
existing = await lstat(socketPath);
|
|
167
|
+
}
|
|
168
|
+
catch (e) {
|
|
169
|
+
if (errCode(e) !== "ENOENT")
|
|
170
|
+
throw e;
|
|
171
|
+
}
|
|
172
|
+
if (existing === undefined)
|
|
173
|
+
return;
|
|
174
|
+
const inUse = (why) => new CcPeerChannelError("address_in_use", `${socketPath} is in use (${why}) — the socket lane was not opened`, socketPath);
|
|
175
|
+
if (!existing.isSocket())
|
|
176
|
+
throw inUse("it is not a socket");
|
|
177
|
+
if (uid !== undefined && existing.uid !== uid)
|
|
178
|
+
throw inUse("another user's socket");
|
|
179
|
+
const state = await probeSocket(socketPath, STALE_PROBE_MS);
|
|
180
|
+
if (state !== "stale")
|
|
181
|
+
throw inUse(state === "live" ? "a process listens there" : "it could not be proven stale");
|
|
182
|
+
const again = await lstat(socketPath).catch(() => undefined);
|
|
183
|
+
if (again === undefined)
|
|
184
|
+
return;
|
|
185
|
+
if (again.ino !== existing.ino || again.dev !== existing.dev)
|
|
186
|
+
throw inUse("it changed while it was probed");
|
|
187
|
+
await unlink(socketPath);
|
|
188
|
+
};
|
|
189
|
+
const refusal = (code, text) => ({ ok: false, code, severity: peerSendVerdictSeverity(code), message: text });
|
|
190
|
+
return {
|
|
191
|
+
async listen(self) {
|
|
192
|
+
if (platform === "win32")
|
|
193
|
+
throw new CcPeerChannelError("unsupported_platform", "the reference agent's socket lane (its named-pipe arm) is not implemented on this platform — the socket lane was not opened");
|
|
194
|
+
if (listening !== undefined)
|
|
195
|
+
throw new CcPeerChannelError("already_listening", `this channel already listens at ${listening.address}`);
|
|
196
|
+
const socketPath = opts.socketPath;
|
|
197
|
+
if (!isAbsolute(socketPath) || Buffer.byteLength(socketPath) > CC_PEER_SOCKET_PATH_MAX_BYTES) {
|
|
198
|
+
throw new CcPeerChannelError("socket_path_too_long", `the socket path must be absolute and at most ${CC_PEER_SOCKET_PATH_MAX_BYTES} bytes (got ${Buffer.byteLength(socketPath)})`, socketPath);
|
|
199
|
+
}
|
|
200
|
+
const box = peerSessionBoxHandle(self.sessionId);
|
|
201
|
+
const laneConfig = resolvePeerLaneConfig(opts.lane);
|
|
202
|
+
const slot = `${pid}\u0000${resolvePath(opts.registryDir)}`;
|
|
203
|
+
if (LISTENING_SLOTS.has(slot))
|
|
204
|
+
throw new CcPeerChannelError("already_listening", `this process already listens through ${opts.registryDir} (its key file and registry row are named by the pid)`);
|
|
205
|
+
LISTENING_SLOTS.add(slot);
|
|
206
|
+
const release = (e) => {
|
|
207
|
+
LISTENING_SLOTS.delete(slot);
|
|
208
|
+
throw e;
|
|
209
|
+
};
|
|
210
|
+
await prepareSocketPath(socketPath).catch(release);
|
|
211
|
+
const token = randomBytes(16).toString("hex");
|
|
212
|
+
const tokenBytes = Buffer.from(token, "utf8");
|
|
213
|
+
const tokenMatches = (t) => {
|
|
214
|
+
if (t === undefined)
|
|
215
|
+
return false;
|
|
216
|
+
const b = Buffer.from(t, "utf8");
|
|
217
|
+
return b.length === tokenBytes.length && timingSafeEqual(b, tokenBytes);
|
|
218
|
+
};
|
|
219
|
+
const emit = (event) => {
|
|
220
|
+
try {
|
|
221
|
+
self.onEvent?.(event);
|
|
222
|
+
}
|
|
223
|
+
catch {
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
const drop = (reason, detail) => emit({ kind: "dropped", reason, ...(detail !== undefined ? { detail } : {}) });
|
|
227
|
+
let chain = Promise.resolve();
|
|
228
|
+
let pending = 0;
|
|
229
|
+
const enqueue = (work) => {
|
|
230
|
+
if (pending >= laneConfig.maxQueuedPeerMessages)
|
|
231
|
+
return drop("box_full", `${pending} frames already waiting for the box`);
|
|
232
|
+
pending++;
|
|
233
|
+
chain = chain
|
|
234
|
+
.then(work)
|
|
235
|
+
.catch((e) => drop("append_failed", e instanceof Error ? e.message.slice(0, 200) : "error"))
|
|
236
|
+
.then(() => {
|
|
237
|
+
pending--;
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
const appendUser = async (line) => {
|
|
241
|
+
if (line.toSession !== undefined && line.toSession !== self.sessionId)
|
|
242
|
+
return drop("session_mismatch");
|
|
243
|
+
if (line.attachments)
|
|
244
|
+
return drop("unhandled_frame", "file_attachments");
|
|
245
|
+
let queued = 0;
|
|
246
|
+
try {
|
|
247
|
+
queued = await opts.mailbox.peekCount(self.scope, box);
|
|
248
|
+
}
|
|
249
|
+
catch {
|
|
250
|
+
}
|
|
251
|
+
if (queued >= laneConfig.maxQueuedPeerMessages)
|
|
252
|
+
return drop("box_full", `${queued} queued`);
|
|
253
|
+
const decoded = decodeCcPeerFrame(line.content);
|
|
254
|
+
const fields = decoded.ok ? decoded.fields : {};
|
|
255
|
+
const body = decoded.ok ? decoded.body : line.content;
|
|
256
|
+
const peerMeta = {
|
|
257
|
+
...(fields.fromSession !== undefined ? { fromSession: fields.fromSession, senderKey: peerAxisToken(self.scope, "s", fields.fromSession) } : {}),
|
|
258
|
+
...(fields.fromMode !== undefined ? { fromMode: fields.fromMode } : {}),
|
|
259
|
+
kind: "peer_message",
|
|
260
|
+
};
|
|
261
|
+
const from = fields.fromName ?? line.from;
|
|
262
|
+
const seq = await opts.mailbox.append(self.scope, box, { ...(from !== undefined ? { from } : {}), content: body, sentAt: now(), hopChain: fields.hopChain !== undefined ? [...fields.hopChain] : [], peerMeta });
|
|
263
|
+
emit({ kind: "appended", seq });
|
|
264
|
+
};
|
|
265
|
+
const connections = new Set();
|
|
266
|
+
const deadlineMs = opts.firstLineDeadlineMs ?? CC_PEER_FIRST_LINE_DEADLINE_MS;
|
|
267
|
+
const server = createServer({ allowHalfOpen: true }, (sock) => {
|
|
268
|
+
connections.add(sock);
|
|
269
|
+
sock.setEncoding("utf8");
|
|
270
|
+
let timer = setTimeout(() => {
|
|
271
|
+
timer = undefined;
|
|
272
|
+
drop("first_line_deadline");
|
|
273
|
+
sock.destroy();
|
|
274
|
+
}, deadlineMs);
|
|
275
|
+
timer.unref();
|
|
276
|
+
const clear = () => {
|
|
277
|
+
if (timer !== undefined)
|
|
278
|
+
clearTimeout(timer);
|
|
279
|
+
timer = undefined;
|
|
280
|
+
};
|
|
281
|
+
let authed = false;
|
|
282
|
+
let buf = "";
|
|
283
|
+
const handle = (raw) => {
|
|
284
|
+
if (raw.trim() === "") {
|
|
285
|
+
if (authed)
|
|
286
|
+
return true;
|
|
287
|
+
drop("unauthenticated", "a blank line");
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
const line = parseCcPeerLine(raw);
|
|
291
|
+
if (!authed) {
|
|
292
|
+
if (line.kind !== "auth") {
|
|
293
|
+
drop("unauthenticated", line.kind === "malformed" ? line.why : `a '${line.kind}' line`);
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
if (!tokenMatches(line.token)) {
|
|
297
|
+
drop("bad_token");
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
authed = true;
|
|
301
|
+
return true;
|
|
302
|
+
}
|
|
303
|
+
switch (line.kind) {
|
|
304
|
+
case "auth":
|
|
305
|
+
return true;
|
|
306
|
+
case "malformed":
|
|
307
|
+
drop("malformed_line", line.why);
|
|
308
|
+
return true;
|
|
309
|
+
case "unhandled":
|
|
310
|
+
drop("unhandled_frame", line.action !== undefined ? `${line.type}:${line.action}` : line.type);
|
|
311
|
+
return true;
|
|
312
|
+
case "nudge":
|
|
313
|
+
enqueue(async () => {
|
|
314
|
+
emit({ kind: "nudged" });
|
|
315
|
+
try {
|
|
316
|
+
self.onNudge?.();
|
|
317
|
+
}
|
|
318
|
+
catch {
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
return true;
|
|
322
|
+
case "user":
|
|
323
|
+
enqueue(() => appendUser(line));
|
|
324
|
+
return true;
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
sock.on("data", (chunk) => {
|
|
328
|
+
buf += chunk;
|
|
329
|
+
if (buf.length > CC_PEER_LINE_MAX_CHARS) {
|
|
330
|
+
drop("line_too_long");
|
|
331
|
+
buf = "";
|
|
332
|
+
sock.destroy();
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
for (let nl = buf.indexOf("\n"); nl !== -1; nl = buf.indexOf("\n")) {
|
|
336
|
+
const raw = buf.slice(0, nl);
|
|
337
|
+
buf = buf.slice(nl + 1);
|
|
338
|
+
clear();
|
|
339
|
+
if (!handle(raw)) {
|
|
340
|
+
buf = "";
|
|
341
|
+
sock.destroy();
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
sock.on("end", () => {
|
|
347
|
+
if (buf.trim() !== "" && !sock.destroyed) {
|
|
348
|
+
clear();
|
|
349
|
+
handle(buf);
|
|
350
|
+
}
|
|
351
|
+
buf = "";
|
|
352
|
+
sock.end();
|
|
353
|
+
});
|
|
354
|
+
sock.on("error", () => undefined);
|
|
355
|
+
sock.on("close", () => {
|
|
356
|
+
clear();
|
|
357
|
+
connections.delete(sock);
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
server.on("error", () => undefined);
|
|
361
|
+
await new Promise((resolve, reject) => {
|
|
362
|
+
const onError = (e) => reject(errCode(e) === "EADDRINUSE" ? new CcPeerChannelError("address_in_use", `another process listens at ${socketPath}`, socketPath) : e);
|
|
363
|
+
server.once("error", onError);
|
|
364
|
+
server.listen(socketPath, () => {
|
|
365
|
+
server.removeListener("error", onError);
|
|
366
|
+
resolve();
|
|
367
|
+
});
|
|
368
|
+
}).catch(release);
|
|
369
|
+
server.unref();
|
|
370
|
+
const keyPath = join(opts.registryDir, ccPeerKeyFileName(pid, socketPath));
|
|
371
|
+
const rowPath = join(opts.registryDir, `${pid}.json`);
|
|
372
|
+
let closed = false;
|
|
373
|
+
const close = async () => {
|
|
374
|
+
if (closed)
|
|
375
|
+
return;
|
|
376
|
+
closed = true;
|
|
377
|
+
listening = undefined;
|
|
378
|
+
LISTENING_SLOTS.delete(slot);
|
|
379
|
+
for (const s of connections)
|
|
380
|
+
s.destroy();
|
|
381
|
+
connections.clear();
|
|
382
|
+
await new Promise((resolve) => server.close(() => resolve()));
|
|
383
|
+
await unlink(socketPath).catch(() => undefined);
|
|
384
|
+
await unlink(keyPath).catch(() => undefined);
|
|
385
|
+
await unlink(rowPath).catch(() => undefined);
|
|
386
|
+
await chain.catch(() => undefined);
|
|
387
|
+
};
|
|
388
|
+
try {
|
|
389
|
+
await chmod(socketPath, 0o600);
|
|
390
|
+
const procStart = await probe.processStartToken(pid);
|
|
391
|
+
await writeFileAtomic0600(keyPath, JSON.stringify({ peerToken: token, ...(procStart !== undefined ? { procStart } : {}) }));
|
|
392
|
+
const at = now();
|
|
393
|
+
const reg = opts.registration ?? {};
|
|
394
|
+
await writeFileAtomic0600(rowPath, JSON.stringify(ccRegistrationRow({
|
|
395
|
+
pid,
|
|
396
|
+
sessionId: self.sessionId,
|
|
397
|
+
socketPath,
|
|
398
|
+
startedAt: reg.startedAt ?? at,
|
|
399
|
+
updatedAt: at,
|
|
400
|
+
...(reg.cwd !== undefined ? { cwd: reg.cwd } : {}),
|
|
401
|
+
...(reg.name !== undefined ? { name: reg.name } : {}),
|
|
402
|
+
...(reg.entrypoint !== undefined ? { entrypoint: reg.entrypoint } : {}),
|
|
403
|
+
...(procStart !== undefined ? { procStart } : {}),
|
|
404
|
+
...(typeof opts.mailbox.identity === "string" && opts.mailbox.identity !== "" ? { storeIdentity: opts.mailbox.identity } : {}),
|
|
405
|
+
})));
|
|
406
|
+
}
|
|
407
|
+
catch (e) {
|
|
408
|
+
await close();
|
|
409
|
+
throw new CcPeerChannelError("publish_failed", `the socket was bound but its key file or registry row could not be published (${errCode(e) ?? (e instanceof Error ? e.message : "error")}) — no peer could authenticate or find it, so the socket lane was closed`, opts.registryDir);
|
|
410
|
+
}
|
|
411
|
+
listening = { address: socketPath, sessionId: self.sessionId };
|
|
412
|
+
return { address: socketPath, close };
|
|
413
|
+
},
|
|
414
|
+
async dial(address, message) {
|
|
415
|
+
const vetted = await vetPeerSocket(address);
|
|
416
|
+
if (!vetted.ok)
|
|
417
|
+
return refusal(vetted.code, vetted.text);
|
|
418
|
+
let line;
|
|
419
|
+
try {
|
|
420
|
+
const from = listening !== undefined && message.fromSession === listening.sessionId ? ccPeerAddress(listening.address) : undefined;
|
|
421
|
+
line = encodeCcUserLine({
|
|
422
|
+
fields: {
|
|
423
|
+
...(from !== undefined ? { from } : {}),
|
|
424
|
+
...(message.fromSession !== undefined ? { fromSession: message.fromSession } : {}),
|
|
425
|
+
hopChain: message.hopChain.map(peerWireHopToken),
|
|
426
|
+
...(message.fromName !== undefined ? { fromName: message.fromName } : {}),
|
|
427
|
+
...(message.fromMode !== undefined ? { fromMode: message.fromMode } : {}),
|
|
428
|
+
},
|
|
429
|
+
body: message.body,
|
|
430
|
+
...(from !== undefined ? { from } : {}),
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
catch (e) {
|
|
434
|
+
if (e instanceof CrossSessionCodecError)
|
|
435
|
+
return refusal("peer_send.other", `the frame could not be spelled (${e.code})`);
|
|
436
|
+
throw e;
|
|
437
|
+
}
|
|
438
|
+
if (encodeCcAuthLine("0".repeat(32)).length + line.length > CC_PEER_LINE_MAX_CHARS)
|
|
439
|
+
return refusal("peer_send.too_large", `the frame is ${line.length} characters; the peer's line wall is ${CC_PEER_LINE_MAX_CHARS}`);
|
|
440
|
+
const token = await readPeerToken(address);
|
|
441
|
+
const sent = await send(address, `${token !== undefined ? encodeCcAuthLine(token) : ""}${line}`, opts.sendTimeoutMs ?? CC_PEER_SEND_TIMEOUT_MS);
|
|
442
|
+
return sent.ok ? { ok: true, disposition: "delivered", via: "uds" } : refusal(sent.code, sent.text);
|
|
443
|
+
},
|
|
444
|
+
async nudge(address) {
|
|
445
|
+
try {
|
|
446
|
+
if (!(await vetPeerSocket(address)).ok)
|
|
447
|
+
return false;
|
|
448
|
+
const token = await readPeerToken(address);
|
|
449
|
+
const sent = await send(address, `${token !== undefined ? encodeCcAuthLine(token) : ""}${encodeCcNudgeLine()}`, opts.nudgeTimeoutMs ?? NUDGE_TIMEOUT_MS);
|
|
450
|
+
return sent.ok;
|
|
451
|
+
}
|
|
452
|
+
catch {
|
|
453
|
+
return false;
|
|
454
|
+
}
|
|
455
|
+
},
|
|
456
|
+
};
|
|
457
|
+
}
|
|
@@ -18,17 +18,6 @@ export declare function deploymentStatesSubagentModel(roles: ModelRoles | undefi
|
|
|
18
18
|
* already reflects when the parent ran on it).
|
|
19
19
|
*/
|
|
20
20
|
export declare function deploymentSubagentThinking(roles: ModelRoles | undefined): ThinkingLevel | undefined;
|
|
21
|
-
/**
|
|
22
|
-
* Did the deployment STATE a system prompt for its subagents — and which? The `systemPrompt` member of an
|
|
23
|
-
* object-form `roles.subagent` entry; a string ref, a `Model` object or an entry without the member states
|
|
24
|
-
* none. The third axis, read off the SAME seat as {@link deploymentSubagentThinking}. It has no parent rung:
|
|
25
|
-
* a child never inherits its PARENT's system prompt, only the deployment's statement for subagents. Which
|
|
26
|
-
* station needs to read it: one whose default persona is written onto the spec itself (the workflow lane
|
|
27
|
-
* frames an empty `systemPrompt` with the workflow-subagent persona, so the preset must be written first, as
|
|
28
|
-
* a custom persona to that frame); the delegation station's default rides the trusted internals channel
|
|
29
|
-
* below the role chain, so prepare reads the preset there without this helper.
|
|
30
|
-
*/
|
|
31
|
-
export declare function deploymentSubagentSystemPrompt(roles: ModelRoles | undefined): string | undefined;
|
|
32
21
|
/**
|
|
33
22
|
* The child run's THINKING seat — {@link childModelSeat}'s sister, the same rung order on the other axis
|
|
34
23
|
* (#651): an EXPLICIT level for this spawn wins (the agent definition's `thinking`; a fork's explicit is the
|
|
@@ -23,9 +23,6 @@ export function deploymentStatesSubagentModel(roles) {
|
|
|
23
23
|
export function deploymentSubagentThinking(roles) {
|
|
24
24
|
return subagentRolePresets(roles)?.thinking;
|
|
25
25
|
}
|
|
26
|
-
export function deploymentSubagentSystemPrompt(roles) {
|
|
27
|
-
return subagentRolePresets(roles)?.systemPrompt;
|
|
28
|
-
}
|
|
29
26
|
function subagentRolePresets(roles) {
|
|
30
27
|
const s = roles?.subagent;
|
|
31
28
|
if (s == null || typeof s === "string")
|
|
@@ -128,12 +128,15 @@ export interface CcPeerFrameFields {
|
|
|
128
128
|
hopChain?: string[];
|
|
129
129
|
fromName?: string;
|
|
130
130
|
fromMode?: PermissionModeClass;
|
|
131
|
+
/** The sending plugin's display name (CC 2.1.296 sixth attribute, (cli296.js:237185) "from-plugin", after `from-mode`; canonicalized like
|
|
132
|
+
* `from-name`). Display only — the reference attributes a plugin's message by it, no judgment reads it. */
|
|
133
|
+
fromPlugin?: string;
|
|
131
134
|
}
|
|
132
135
|
/** CC `ygt` — the carry window: keep the newest 32. */
|
|
133
136
|
export declare function clampHopChain(chain: readonly string[]): string[];
|
|
134
137
|
/**
|
|
135
138
|
* Serialize the CC wire envelope (what goes into a UDS user frame's `message.content`). Attribute
|
|
136
|
-
* order `from` → `from-session` → `hop-chain` → `from-name` → `from-mode`. Unlike CC's own
|
|
139
|
+
* order `from` → `from-session` → `hop-chain` → `from-name` → `from-mode` → `from-plugin`. Unlike CC's own
|
|
137
140
|
* constructor, which silently DROPS an ill-formed `from-session`/`hop-chain`, this throws on them: the
|
|
138
141
|
* values are ours, and a producer bug must not become an attribute-less frame on the wire.
|
|
139
142
|
* @throws CrossSessionCodecError
|
|
@@ -170,6 +170,11 @@ export function encodeCcPeerFrame(fields, body) {
|
|
|
170
170
|
assert(isPermissionModeClass(fields.fromMode), "cross_session.invalid_from_mode", `"from-mode" must be one of ${PERMISSION_MODE_CLASSES.join("|")}`);
|
|
171
171
|
attrs.push(`from-mode="${fields.fromMode}"`);
|
|
172
172
|
}
|
|
173
|
+
if (fields.fromPlugin !== undefined) {
|
|
174
|
+
const plugin = typeof fields.fromPlugin === "string" ? canonicalPeerDisplayName(fields.fromPlugin) : "";
|
|
175
|
+
if (plugin !== "")
|
|
176
|
+
attrs.push(`from-plugin="${plugin}"`);
|
|
177
|
+
}
|
|
173
178
|
const header = attrs.length > 0 ? ` ${attrs.join(" ")}` : "";
|
|
174
179
|
return `<${CROSS_SESSION_MESSAGE_TAG}${header}>\n${escapeEnvelopeTag(CROSS_SESSION_MESSAGE_TAG, body)}\n</${CROSS_SESSION_MESSAGE_TAG}>`;
|
|
175
180
|
}
|
|
@@ -179,12 +184,13 @@ const CC_WIRE_RE = new RegExp(`^<${CROSS_SESSION_MESSAGE_TAG}` +
|
|
|
179
184
|
`(?: hop-chain="(${HOP_CHAIN_RE.source.slice(1, -1)})")?` +
|
|
180
185
|
`(?: from-name="([^"<>\\n\\r]+)")?` +
|
|
181
186
|
`(?: from-mode="(bypass|prompting)")?` +
|
|
187
|
+
`(?: from-plugin="([^"<>\\n\\r]+)")?` +
|
|
182
188
|
`>\\n([\\s\\S]*)\\n</${CROSS_SESSION_MESSAGE_TAG}>$`);
|
|
183
189
|
export function decodeCcPeerFrame(text) {
|
|
184
190
|
const m = CC_WIRE_RE.exec(text);
|
|
185
191
|
if (m === null)
|
|
186
192
|
return { ok: false, reason: "not_an_envelope" };
|
|
187
|
-
const [, from, fromSession, hopChain, fromName, fromMode, body] = m;
|
|
193
|
+
const [, from, fromSession, hopChain, fromName, fromMode, fromPlugin, body] = m;
|
|
188
194
|
if (from !== undefined && !isCanonicalPeerAddress(from))
|
|
189
195
|
return { ok: false, reason: "roundtrip_mismatch" };
|
|
190
196
|
const fields = {
|
|
@@ -193,6 +199,7 @@ export function decodeCcPeerFrame(text) {
|
|
|
193
199
|
...(hopChain !== undefined ? { hopChain: hopChain.split(",") } : {}),
|
|
194
200
|
...(fromName !== undefined ? { fromName } : {}),
|
|
195
201
|
...(fromMode !== undefined ? { fromMode: fromMode } : {}),
|
|
202
|
+
...(fromPlugin !== undefined ? { fromPlugin } : {}),
|
|
196
203
|
};
|
|
197
204
|
if (encodeCcPeerFrame(fields, body) !== text)
|
|
198
205
|
return { ok: false, reason: "roundtrip_mismatch" };
|
|
@@ -62,7 +62,7 @@ export declare function resolveCrossSessionInboundSetting(layers: CrossSessionIn
|
|
|
62
62
|
*/
|
|
63
63
|
export declare function principalInboundLayers(layers: CrossSessionInboundSettingLayers): CrossSessionInboundSettingLayers;
|
|
64
64
|
/**
|
|
65
|
-
* Why a message was held. The first eight are
|
|
65
|
+
* Why a message was held. The first eight are the reference's closed set, reachable exactly
|
|
66
66
|
* where CC reaches them. `invalid-mode-attestation` is a sema-only arm: CC's envelope parser drops a
|
|
67
67
|
* non-vocabulary `from-mode` before any judgment (the state is unreachable there); sema receives the
|
|
68
68
|
* attestation as a TYPED store/wire field, where a garbage value is a producer bug that must hold
|
|
@@ -73,7 +73,7 @@ export declare function principalInboundLayers(layers: CrossSessionInboundSettin
|
|
|
73
73
|
*/
|
|
74
74
|
export type CrossSessionHoldCause = "mode-mismatch" | "no-mode-asserted" | "explicit-setting" | "managed-setting" | "repo-setting" | "invalid-setting" | "bypass-default" | "mode-unknown" | "invalid-mode-attestation" | "cross-principal-default";
|
|
75
75
|
export declare const CROSS_SESSION_HOLD_CAUSES: readonly CrossSessionHoldCause[];
|
|
76
|
-
/**
|
|
76
|
+
/** The reference's wording for the eight inherited causes; the sema arm has its own sentence. */
|
|
77
77
|
export declare function describeCrossSessionHoldCause(cause: CrossSessionHoldCause): string;
|
|
78
78
|
export type CrossSessionInboundVerdict = {
|
|
79
79
|
verdict: "deliver";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
2
|
import type { TaskAccess } from "../core/task-registry.js";
|
|
3
3
|
import { type RosterEntry } from "./roster-store.js";
|
|
4
|
-
import { type PeerDirectory, type PeerPresence, type PeerSessionRecord } from "./peer-directory.js";
|
|
4
|
+
import { type PeerDirectory, type PeerPresence, type PeerSessionRecord, type PeerSessionWhere } from "./peer-directory.js";
|
|
5
5
|
import type { SubagentTranscriptTier } from "../core/wiring-manifest.js";
|
|
6
6
|
import { formatAgo, type AgentState, type AgentStateSource } from "../core/agent-state.js";
|
|
7
7
|
import type { CheckpointSeat } from "../core/checkpoint-seat.js";
|
|
@@ -89,6 +89,8 @@ export interface ListAgentsRow {
|
|
|
89
89
|
cwd?: string;
|
|
90
90
|
/** Peer rows: the session's self-reported presence, when it reported any. */
|
|
91
91
|
presence?: PeerPresence;
|
|
92
|
+
/** Peer rows: where the session runs, as the directory's row says it ({@link PeerSessionWhere}). */
|
|
93
|
+
where?: PeerSessionWhere;
|
|
92
94
|
/** What SendMessage accepts: on both AGENT lanes the registry `task_id` VERBATIM (no prefixing or
|
|
93
95
|
* re-minting), never the child's session id — a different domain, tabled in INTEGRATION-CORE §1.6a.
|
|
94
96
|
* Peer rows carry the `session.<id>` box handle instead. */
|
|
@@ -3,9 +3,9 @@ import { defineTool } from "../core/tools.js";
|
|
|
3
3
|
import { inlineUntrusted } from "../core/untrusted-text.js";
|
|
4
4
|
import { formatPeerNameRef } from "./cross-session-ref.js";
|
|
5
5
|
import { entryAccessible } from "./roster-store.js";
|
|
6
|
-
import { mintPeerSessionCandidates, PEER_PRESENCE_MAX_CHARS, peerSessionBoxHandle } from "./peer-directory.js";
|
|
6
|
+
import { listPeerDirectory, mintPeerSessionCandidates, PEER_PRESENCE_MAX_CHARS, PEER_SESSION_WHERE_LABELS, peerSessionBoxHandle } from "./peer-directory.js";
|
|
7
7
|
import { PEER_LANE_DEFAULTS } from "./peer-admission.js";
|
|
8
|
-
import { toolFace } from "../core/tool-catalog-entries.js";
|
|
8
|
+
import { mountRuleFace, toolFace } from "../core/tool-catalog-entries.js";
|
|
9
9
|
import { thrownText } from "../core/thrown-value.js";
|
|
10
10
|
import { assertNoRetiredKeys } from "../core/retired-keys.js";
|
|
11
11
|
import { agentActivityClause, agentApprovalClause, formatAgo, readAgentState } from "../core/agent-state.js";
|
|
@@ -45,8 +45,7 @@ const PEER_ROW_STATE = {
|
|
|
45
45
|
function peerRowState(r) {
|
|
46
46
|
if (r.liveness === "dead")
|
|
47
47
|
return "offline";
|
|
48
|
-
|
|
49
|
-
return tempo !== undefined && Object.hasOwn(PEER_ROW_STATE, tempo) ? PEER_ROW_STATE[tempo] : "unknown";
|
|
48
|
+
return r.tempo !== undefined ? PEER_ROW_STATE[r.tempo] : "unknown";
|
|
50
49
|
}
|
|
51
50
|
function renderPresence(p) {
|
|
52
51
|
const parts = [...(p.agent !== undefined ? [`agent=${inlineUntrusted(p.agent, PEER_PRESENCE_MAX_CHARS)}`] : []), ...(p.intent !== undefined ? [`intent=${inlineUntrusted(p.intent, PEER_PRESENCE_MAX_CHARS)}`] : [])];
|
|
@@ -62,10 +61,11 @@ export function createListAgentsTool(opts) {
|
|
|
62
61
|
return defineTool({
|
|
63
62
|
name: LIST_AGENTS_TOOL_NAME,
|
|
64
63
|
...toolFace("list-agents"),
|
|
64
|
+
ruleFace: mountRuleFace("list-agents"),
|
|
65
65
|
isConcurrencySafe: () => true,
|
|
66
66
|
description: `List the agents${peers ? " and peer sessions" : ""} you can message with SendMessage. ` +
|
|
67
67
|
(peers
|
|
68
|
-
? `Peer sessions are other sessions of this engine running for the same user, shown as \`name [ref] · state · active <N> ago · <directory> · self: agent=…, intent
|
|
68
|
+
? `Peer sessions are other sessions of this engine running for the same user, shown as \`name [ref] · state · active <N> ago · <directory> · self: agent=…, intent=… · peer session <where>\` (where it runs: ${Object.values(PEER_SESSION_WHERE_LABELS).join(", or ")}); send to one with its name (or \`name [ref]\` ` +
|
|
69
69
|
`when a name is ambiguous, or its \`session.<id>\` address). By default only FRESH peers are listed (working now, or active within the last ${formatAgo(windowMs)}); ` +
|
|
70
70
|
`pass includeAll: true to also list stale and offline ones. A peer that is offline or unlisted still accepts messages — they are parked ` +
|
|
71
71
|
`durably in its session box and delivered when it next runs. `
|
|
@@ -83,7 +83,7 @@ export function createListAgentsTool(opts) {
|
|
|
83
83
|
let directoryFault;
|
|
84
84
|
if (opts.peerDirectory !== undefined) {
|
|
85
85
|
try {
|
|
86
|
-
peerRows = await opts.peerDirectory
|
|
86
|
+
peerRows = await listPeerDirectory(opts.peerDirectory, { scope: opts.self.scope });
|
|
87
87
|
}
|
|
88
88
|
catch (e) {
|
|
89
89
|
directoryFault = thrownText(e);
|
|
@@ -107,6 +107,7 @@ export function createListAgentsTool(opts) {
|
|
|
107
107
|
...(r.liveness === "live" ? { lastActiveAt: r.updatedAt } : r.diedAt !== undefined ? { offlineAt: r.diedAt } : {}),
|
|
108
108
|
...(r.cwd !== undefined ? { cwd: cwdTail(r.cwd) } : {}),
|
|
109
109
|
...(presence.agent !== undefined || presence.intent !== undefined ? { presence } : {}),
|
|
110
|
+
where: r.where,
|
|
110
111
|
});
|
|
111
112
|
}
|
|
112
113
|
let registryCapped = false;
|
|
@@ -171,13 +172,13 @@ export function createListAgentsTool(opts) {
|
|
|
171
172
|
const age = r.kind !== "peer_session" ? undefined : r.lastActiveAt !== undefined ? `active ${formatAgo(now - r.lastActiveAt)} ago` : r.offlineAt !== undefined ? `offline ${formatAgo(now - r.offlineAt)} ago` : "offline";
|
|
172
173
|
const activity = r.agentState !== undefined ? agentActivityClause(r.agentState) : undefined;
|
|
173
174
|
const approval = r.agentState?.approval !== undefined ? agentApprovalClause(r.agentState.approval, r.agentState.readAt) : undefined;
|
|
174
|
-
const cols = [label, r.state, age, activity, approval, r.cwd !== undefined ? inlineUntrusted(r.cwd, 64) : undefined, r.presence !== undefined ? renderPresence(r.presence) : undefined, r.kind === "peer_session" ?
|
|
175
|
+
const cols = [label, r.state, age, activity, approval, r.cwd !== undefined ? inlineUntrusted(r.cwd, 64) : undefined, r.presence !== undefined ? renderPresence(r.presence) : undefined, r.kind === "peer_session" ? `peer session ${PEER_SESSION_WHERE_LABELS[r.where]}` : r.kind === "roster" ? rosterLabel : "agent", r.address];
|
|
175
176
|
return cols.filter((c) => c !== undefined).join(" · ");
|
|
176
177
|
});
|
|
177
178
|
const finishedCount = rows.filter((r) => r.state === "finished").length;
|
|
178
179
|
const header = rows.length === 0 ? "No agents or peer sessions are listed right now." : `${rows.length} listed:`;
|
|
179
180
|
const finishedNote = finishedCount > 0 ? `\n(${finishedCount} finished agent(s): continuable by SendMessage only ${finishedReach} — otherwise SendMessage answers with an honest refusal)` : "";
|
|
180
|
-
const fault = (directoryFault !== undefined ? `\n(peer-session directory unreadable: ${inlineUntrusted(directoryFault, 200)} — peer
|
|
181
|
+
const fault = (directoryFault !== undefined ? `\n(peer-session directory unreadable: ${inlineUntrusted(directoryFault, 200)} — no peer row is listed until its host fixes it)` : "") +
|
|
181
182
|
(registryCapped ? "\n(the live task list is at its 500-row window: older background agents may be missing from this listing — address them by task_id)" : "");
|
|
182
183
|
let content = `${header}${lines.length > 0 ? `\n${lines.join("\n")}` : ""}${finishedNote}${fault}`;
|
|
183
184
|
if (content.length > LIST_AGENTS_MAX_RESULT_CHARS)
|