@chankov/agent-fleet 2.1.2 → 2.2.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/.pi/agent-fleet/hooks/coms-stop-hook.mjs +53 -13
- package/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/README.md +223 -0
- package/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/bootstrap-profile-0.167.json +5627 -0
- package/.pi/agent-fleet/scripts/fleet-codex-local-mcp.ts +4 -0
- package/.pi/agent-fleet/scripts/fleet.ts +13 -17
- package/.pi/agent-fleet/scripts/flow.ts +2 -2
- package/.pi/agent-fleet/scripts/lib/codex-bootstrap-files.ts +46 -0
- package/.pi/agent-fleet/scripts/lib/codex-bootstrap-probe.ts +44 -0
- package/.pi/agent-fleet/scripts/lib/codex-bootstrap-producer.ts +131 -0
- package/.pi/agent-fleet/scripts/lib/codex-daemon-observer.ts +137 -0
- package/.pi/agent-fleet/scripts/lib/codex-desktop-discovery.ts +84 -0
- package/.pi/agent-fleet/scripts/lib/codex-desktop-preflight.ts +130 -0
- package/.pi/agent-fleet/scripts/lib/codex-desktop-queue-host.ts +20 -13
- package/.pi/agent-fleet/scripts/lib/codex-measurement.ts +218 -0
- package/.pi/agent-fleet/scripts/lib/codex-native-presence.ts +61 -0
- package/.pi/agent-fleet/scripts/lib/codex-probe-transcript.ts +135 -0
- package/.pi/agent-fleet/scripts/lib/codex-send-lineage.ts +72 -0
- package/.pi/agent-fleet/scripts/lib/codex-unix-queue-rpc.ts +23 -13
- package/.pi/agent-fleet/scripts/lib/fleet-codex-allowlist-store.ts +100 -14
- package/.pi/agent-fleet/scripts/lib/fleet-codex-answers.ts +1 -1
- package/.pi/agent-fleet/scripts/lib/fleet-codex-bootstrap.ts +204 -0
- package/.pi/agent-fleet/scripts/lib/fleet-codex-connections.ts +9 -3
- package/.pi/agent-fleet/scripts/lib/fleet-codex-event-runtime.ts +32 -16
- package/.pi/agent-fleet/scripts/lib/fleet-codex-local-mcp.ts +41 -21
- package/.pi/agent-fleet/scripts/lib/fleet-codex-permission-transport.ts +21 -0
- package/.pi/agent-fleet/scripts/lib/fleet-command.ts +4 -8
- package/.pi/agent-fleet/scripts/lib/flow-maintenance.ts +2 -1
- package/.pi/agent-fleet/scripts/lib/team-project.ts +0 -2
- package/.pi/agent-fleet/scripts/team-up.ts +5 -12
- package/.pi/agent-fleet/scripts/workflows/lib/git.ts +9 -0
- package/.pi/agent-fleet/scripts/workflows/lib/quality.ts +17 -4
- package/.pi/agents/model-profiles.yaml +0 -2
- package/.pi/harnesses/agent-hub/README.md +116 -67
- package/.pi/harnesses/agent-hub/capability-packs.ts +7 -4
- package/.pi/harnesses/agent-hub/codex-bootstrap.ts +117 -0
- package/.pi/harnesses/agent-hub/commands/context.ts +0 -4
- package/.pi/harnesses/agent-hub/commands/recover.ts +2 -1
- package/.pi/harnesses/agent-hub/config/agents.ts +3 -1
- package/.pi/harnesses/agent-hub/config/model-profiles.ts +3 -0
- package/.pi/harnesses/agent-hub/context/assertions-artifacts.ts +14 -1
- package/.pi/harnesses/agent-hub/dispatch-native-prepare.ts +17 -0
- package/.pi/harnesses/agent-hub/dispatch-native-spawn.ts +3 -1
- package/.pi/harnesses/agent-hub/dispatch-native-types.ts +4 -0
- package/.pi/harnesses/agent-hub/dispatch-native.ts +9 -3
- package/.pi/harnesses/agent-hub/drift-watchdog.js +5 -10
- package/.pi/harnesses/agent-hub/execution-trace.ts +1 -1
- package/.pi/harnesses/agent-hub/filesystem-tool.ts +1 -1
- package/.pi/harnesses/agent-hub/footer.ts +2 -3
- package/.pi/harnesses/agent-hub/helpers.ts +4 -5
- package/.pi/harnesses/agent-hub/history-projection.ts +1 -1
- package/.pi/harnesses/agent-hub/index.ts +213 -196
- package/.pi/harnesses/agent-hub/input/shortcuts.ts +0 -7
- package/.pi/harnesses/agent-hub/lifecycle/session-orchestration.ts +0 -2
- package/.pi/harnesses/agent-hub/no-progress.ts +14 -9
- package/.pi/harnesses/agent-hub/operator-current-state.ts +5 -1
- package/.pi/harnesses/agent-hub/package.json +1 -1
- package/.pi/harnesses/agent-hub/policy/roster.ts +12 -3
- package/.pi/harnesses/agent-hub/policy/work-mode.ts +10 -49
- package/.pi/harnesses/agent-hub/poll-command.ts +12 -4
- package/.pi/harnesses/agent-hub/proactive-snapshot.ts +12 -4
- package/.pi/harnesses/agent-hub/process-obligations.ts +42 -9
- package/.pi/harnesses/agent-hub/prompts/context.ts +17 -0
- package/.pi/harnesses/agent-hub/prompts/fragments.ts +9 -1
- package/.pi/harnesses/agent-hub/prompts/session-start.ts +2 -3
- package/.pi/harnesses/agent-hub/prompts/system-prompt.ts +25 -8
- package/.pi/harnesses/agent-hub/provider-semaphore.js +5 -0
- package/.pi/harnesses/agent-hub/review-continuity.ts +5 -2
- package/.pi/harnesses/agent-hub/review-reuse.ts +2 -1
- package/.pi/harnesses/agent-hub/run-budget.js +22 -2
- package/.pi/harnesses/agent-hub/scope-gate.js +38 -0
- package/.pi/harnesses/agent-hub/scope-overlap.ts +46 -0
- package/.pi/harnesses/agent-hub/task-brief.ts +98 -0
- package/.pi/harnesses/agent-hub/tool-catalog-runtime.ts +4 -0
- package/.pi/harnesses/agent-hub/tool-catalog-state.ts +5 -3
- package/.pi/harnesses/agent-hub/tools/action-executors.ts +5 -7
- package/.pi/harnesses/agent-hub/tools/context.ts +2 -0
- package/.pi/harnesses/agent-hub/tools/dispatch-agent.ts +2 -1
- package/.pi/harnesses/agent-hub/tools/dispatch-execution.ts +184 -33
- package/.pi/harnesses/agent-hub/tools/poll-panel-core.ts +30 -0
- package/.pi/harnesses/agent-hub/tools/poll-panel.ts +33 -0
- package/.pi/harnesses/agent-hub/tools/run-flow.ts +41 -10
- package/.pi/harnesses/agent-hub/tools/team-adjust.ts +1 -1
- package/.pi/harnesses/agent-hub/ui/fleet-dashboard.ts +12 -2
- package/.pi/harnesses/agent-hub/work-mode.ts +44 -49
- package/.pi/harnesses/agent-hub/write-isolation.ts +53 -8
- package/.pi/harnesses/coms/package.json +1 -1
- package/.pi/harnesses/damage-control-continue/package.json +1 -1
- package/.pi/harnesses/lib/codex-compat.ts +97 -0
- package/.pi/harnesses/lib/codex-contract.ts +259 -0
- package/.pi/harnesses/lib/codex-notification-profile.ts +75 -0
- package/.pi/harnesses/lib/coms-core.ts +8 -4
- package/.pi/harnesses/lib/context-budget-child-prompt.ts +1 -1
- package/.pi/harnesses/lib/context-budget-hub-prompt.ts +6 -3
- package/.pi/harnesses/lib/fleet-bootstrap-channel.ts +148 -0
- package/.pi/harnesses/lib/fleet-codex-catalog.ts +30 -0
- package/.pi/harnesses/lib/fleet-codex-chat-view.ts +43 -0
- package/.pi/harnesses/lib/fleet-codex-namespace.ts +2 -0
- package/.pi/harnesses/lib/fleet-codex-policy-snapshot.ts +10 -0
- package/.pi/harnesses/lib/fleet-connection-control.ts +20 -3
- package/.pi/harnesses/lib/fleet-notification-admission.ts +32 -0
- package/.pi/harnesses/lib/fleet-notification-bootstrap.ts +152 -0
- package/.pi/harnesses/lib/fleet-notification-validation.ts +80 -25
- package/.pi/harnesses/lib/fleet-target-identity.ts +9 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/README.md +347 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/desktop-plugins/agent-fleet-herdr/plugin.js +1291 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/desktop-plugins/agent-fleet-herdr/presentation.js +672 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/desktop-plugins/agent-fleet-monitor/plugin.js +19 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/desktop-plugins/agent-fleet-monitor/state.js +10 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/gates/gate-o-capability.md +8 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/gates/gate-o-validator-fixtures.json +1 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/activity.py +773 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/coms_registry.py +134 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/coms_send.py +350 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/herdr_source.py +193 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/manifest.json +4 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/plugin_api.py +444 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/sessions.py +205 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/tasks.py +300 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/watch.py +819 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/plugin.yaml +8 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-monitor/dashboard/adapter.py +139 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-monitor/dashboard/manifest.json +11 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-monitor/dashboard/plugin_api.py +50 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-conductor/SKILL.md +84 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-liaison/SKILL.md +84 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-watchdog/SKILL.md +76 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-watchdog/manifest.json +1 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog.py +249 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_actions.py +124 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_contract.py +76 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_delivery.py +10 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_engine.py +128 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_judgment.py +41 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_recovery.py +103 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_state.py +163 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_transport.py +138 -0
- package/.versions/2.2.0/.pi/agent-fleet/hermes/watchdog-tests/__init__.py +0 -0
- package/.versions/2.2.0/.pi/agent-fleet/hooks/coms-stop-hook.mjs +124 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/claude-code-preflight.ts +70 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/coms-claude-bridge.ts +440 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/coms-cli.ts +430 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/coms-hermes-bridge.ts +416 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/exec-at-target.ts +10 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/0.167-shared.json +1900 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/README.md +223 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/assessment.md +83 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/bootstrap-profile-0.167.json +5627 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/bootstrap-profile.md +43 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/bootstrap.md +45 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/capture-profile.ts +53 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/capture.ts +102 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/catalog.md +91 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/channel.md +21 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/measurement.md +133 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/measurements.json +74 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/notification-profile-0.167.json +2679 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/observer.md +101 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/opaque-response.md +57 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/open-sent.md +68 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/probe-reader.md +51 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/profile.md +71 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/projection.md +147 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/reconnect.md +40 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/response-unions.md +74 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/semver.md +124 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/surface.md +73 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/fleet-codex-allowlist-store-child.ts +31 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/response-fixture.ts +23 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fleet-codex-local-mcp.mjs +26 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fleet-codex-local-mcp.ts +63 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/fleet.ts +244 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/flow.ts +166 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/hermes-monitor-capability-runner.ts +25 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/hermes-monitor-scenario.ts +474 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/hermes-watchdog-capability-probe.ts +45 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/install-hermes-plugin.sh +180 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/claude-bridge-core.ts +208 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/codex-bootstrap-files.ts +46 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/codex-bootstrap-probe.ts +44 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/codex-bootstrap-producer.ts +131 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/codex-daemon-observer.ts +137 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/codex-desktop-discovery.ts +84 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/codex-desktop-preflight.ts +130 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/codex-desktop-queue-host.ts +113 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/codex-measurement.ts +218 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/codex-native-presence.ts +61 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/codex-probe-transcript.ts +135 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/codex-send-lineage.ts +72 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/codex-unix-queue-rpc.ts +101 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/coms-envelope.ts +582 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fake-herdr-server.ts +88 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-allowlist-store.ts +453 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-allowlist.ts +175 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-answer-transport.ts +73 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-answers.ts +74 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-bootstrap.ts +204 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-connections.ts +76 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-event-reply.ts +58 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-event-runtime.ts +132 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-instruction-store.ts +428 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-instruction-transport.ts +160 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-instructions.ts +175 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-local-mcp.ts +435 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-native-history.ts +215 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-observation-store.ts +208 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-observe-transport.ts +49 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-observe.ts +93 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-overview.ts +52 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-permission-transport.ts +44 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-permissions.ts +83 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-readonly.ts +213 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-relay-latency.ts +45 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-response-read.ts +26 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-response-transport.ts +38 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-resync.ts +212 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-command.ts +264 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/flow-command.ts +107 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/flow-maintenance.ts +239 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/herdr-layout.ts +281 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/hermes-bridge-core.ts +241 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/hermes-monitor-events.ts +1 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/hermes-monitor-herdr.ts +2 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/hermes-monitor-model.ts +3 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/hermes-monitor-registry.ts +2 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/hermes-monitor-socket.ts +2 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/hermes-monitor-store.ts +2 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/monitor-env.ts +146 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/peer-launch.ts +318 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/peer-target.ts +1 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/persona-banner.ts +62 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/persona-dirs.ts +25 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/resource-closure.js +1 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/runtime-dependencies.js +124 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/session-launch.ts +56 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/spawn-stagger.ts +101 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/team-project.ts +176 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/team-snapshot.ts +160 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/package-lock.json +57 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/package.json +10 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/peer-banner.ts +41 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/peer-launch.ts +289 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/pi-session.ts +9 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/team-snapshot.ts +245 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/team-up.ts +378 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/agent-phase.ts +181 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/changes.ts +61 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/debate.ts +149 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/env.ts +36 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/envelopes.ts +169 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/gates.ts +81 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/git.ts +108 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/isolated-snapshot.ts +130 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/merge.ts +95 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/model-profile.ts +22 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/model-visibility.ts +92 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/permissions.ts +137 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/personas.ts +57 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/poll.ts +86 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/project-policy.ts +37 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/quality.ts +78 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/run.ts +109 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/scout-data-boundary.ts +55 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/trace.ts +52 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/voices.ts +128 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/writer-lease-race.worker.mjs +36 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/writer-lease.ts +148 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/tsconfig.json +22 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/wf-build-test.ts +61 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/wf-debate.ts +87 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/wf-document.ts +50 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/wf-poll.ts +95 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/wf-quality.ts +20 -0
- package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/wf-scout.ts +40 -0
- package/.versions/2.2.0/.pi/agents/dispatch-policy.yaml +32 -0
- package/.versions/2.2.0/.pi/agents/model-profiles.yaml +132 -0
- package/.versions/2.2.0/.pi/agents/peers.yaml +147 -0
- package/.versions/2.2.0/.pi/agents/teams.yaml +41 -0
- package/.versions/2.2.0/.pi/agents/voices.yaml +13 -0
- package/.versions/2.2.0/.pi/damage-control-rules.yaml +297 -0
- package/.versions/2.2.0/.pi/extensions/btw/README.md +120 -0
- package/.versions/2.2.0/.pi/extensions/btw/index.ts +916 -0
- package/.versions/2.2.0/.pi/extensions/btw/package.json +6 -0
- package/.versions/2.2.0/.pi/extensions/btw/state.js +179 -0
- package/.versions/2.2.0/.pi/extensions/chrome-devtools-mcp/README.md +55 -0
- package/.versions/2.2.0/.pi/extensions/chrome-devtools-mcp/index.ts +93 -0
- package/.versions/2.2.0/.pi/extensions/chrome-devtools-mcp/package.json +6 -0
- package/.versions/2.2.0/.pi/extensions/compact-and-continue/README.md +42 -0
- package/.versions/2.2.0/.pi/extensions/compact-and-continue/index.ts +136 -0
- package/.versions/2.2.0/.pi/extensions/compact-and-continue/package.json +6 -0
- package/.versions/2.2.0/.pi/extensions/mcp-bridge/README.md +46 -0
- package/.versions/2.2.0/.pi/extensions/mcp-bridge/index.ts +206 -0
- package/.versions/2.2.0/.pi/extensions/mcp-bridge/package.json +6 -0
- package/.versions/2.2.0/.pi/extensions/package-lock.json +1175 -0
- package/.versions/2.2.0/.pi/extensions/package.json +9 -0
- package/.versions/2.2.0/.pi/extensions/pi-voice-stt/README.md +224 -0
- package/.versions/2.2.0/.pi/extensions/pi-voice-stt/config.ts +199 -0
- package/.versions/2.2.0/.pi/extensions/pi-voice-stt/examples/stt.json +35 -0
- package/.versions/2.2.0/.pi/extensions/pi-voice-stt/index.ts +248 -0
- package/.versions/2.2.0/.pi/extensions/pi-voice-stt/package.json +6 -0
- package/.versions/2.2.0/.pi/extensions/pi-voice-stt/providers.ts +214 -0
- package/.versions/2.2.0/.pi/extensions/pi-voice-stt/recorder.ts +158 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/README.md +1633 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/acceptance.ts +204 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/access-approval.ts +266 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/action-authorization.ts +10 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/agentic-contract.ts +43 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/agentic-evidence.ts +64 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/agentic-hub.ts +55 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/agentic-runtime.ts +56 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/agentic-sources-worker.mjs +4 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/agentic-sources.ts +74 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/agentic-state.ts +23 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/approval-wait.ts +1 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/artifacts.js +146 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/assertion-ledger.js +68 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/assist-profile.ts +19 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/backend-policy.js +174 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/bounded-output.ts +26 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/budget-recovery.ts +123 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/capability-confirmation.ts +47 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/capability-packs.ts +187 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/codex-bootstrap.ts +117 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/agent-model-thinking.ts +10 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/agent-model.ts +10 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/agent-models-substitute.ts +10 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/agents-add.ts +9 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/agents-drop.ts +9 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/agents-history.ts +9 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/agents-kill.ts +10 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/agents-list.ts +9 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/agents-restart.ts +10 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/agents-save.ts +9 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/agents-team.ts +9 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/audit.ts +9 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/compound.ts +9 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/coms.ts +9 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/config.ts +9 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/context-command.ts +9 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/context.ts +43 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/debate.ts +9 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/dispatch-policy.ts +9 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/handoff.ts +10 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/hub-report.ts +9 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/models.ts +10 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/poll.ts +9 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/recover.ts +62 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/retry.ts +10 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/task-triage-recover.ts +12 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/task-triage-waive.ts +12 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/watchdog.ts +9 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/zoom.ts +10 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/config/agents.ts +183 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/config/model-profiles.ts +240 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/config/overrides.ts +166 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/context/agent-state.ts +30 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/context/assertions-artifacts.ts +234 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/context/budgets.ts +152 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/context/hub-state.ts +40 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/context-budget-snapshot.ts +105 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/context-compaction-monitor.ts +35 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/context-compaction-preflight.ts +21 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/context-compaction-runtime.ts +69 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/context-compaction.ts +34 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/context-continuity-broker.ts +44 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/context-continuity-child.ts +83 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/context-continuity-client.ts +22 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/context-continuity-compat.ts +45 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/context-continuity-owners.ts +17 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/context-continuity-registry.ts +8 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/context-continuity.ts +82 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/context-pressure.ts +222 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/context-window.js +108 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/damage-guard-approval.ts +83 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/damage-guard-broker.ts +125 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/damage-guard-contract.ts +22 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/damage-guard-descendant.ts +76 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/damage-guard-hub.ts +263 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/damage-guard-identity.ts +12 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/damage-guard-owners.ts +59 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/damage-guard-state.ts +43 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/damage-guard-test-tsconfig.json +19 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/debate-command.ts +176 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/delegate.ts +478 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/deterministic-fs.ts +195 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/diagnostic-probe-extension.ts +26 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/diagnostic-series-budget.ts +178 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-coms.ts +258 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-core.ts +27 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-native-complete.ts +176 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-native-prepare.ts +318 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-native-spawn.ts +264 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-native-types.ts +297 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-native.ts +242 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-observability.ts +225 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-triage-contract.ts +27 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-triage-eval.ts +77 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-triage-policy.ts +29 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-triage-runtime.ts +55 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-triage-state.ts +33 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/docs-lane.js +123 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/drift-judge.ts +352 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/drift-runtime.ts +480 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/drift-system1-policy.ts +39 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/drift-system1.ts +469 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/drift-watchdog.js +344 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/evidence-manifest.ts +51 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/evidence-rules.js +96 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/execution-evidence.ts +96 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/execution-trace.ts +241 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/external-blocker.js +92 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/adapters.ts +88 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/broker-client.ts +62 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/broker.ts +128 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/child-extension.ts +42 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/descendant.ts +67 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/discovery-worker.mjs +15 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/discovery.ts +126 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/evaluate.ts +57 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/hub.ts +170 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/native-context.ts +8 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/native-fixture.test-support.ts +108 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/owners.ts +100 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/results.ts +55 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/runtime.ts +130 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/semantic-profiles.ts +18 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/sources.ts +69 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/state.ts +22 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/filesystem-tool.ts +166 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/fixtures/registration-surface.json +68 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/fixtures/t0a-synthetic/catalog.ts +189 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/footer.ts +29 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/helpers.ts +269 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/history-projection.ts +116 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/hub-state-audit.js +41 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/index.ts +2722 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/input/completions.ts +82 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/input/shortcuts.ts +16 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/lifecycle/context-pressure.ts +231 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/lifecycle/monitor-session.ts +104 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/lifecycle/session-orchestration.ts +143 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/lifecycle/turn-handlers.ts +90 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/monitor-control.ts +9 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/monitor-invoke-journal.ts +131 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/monitor-invoke.ts +92 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/monitor-lifecycle.ts +13 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/monitor-publisher.ts +59 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/monitor-recovery.ts +3 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/monitor-runtime.ts +3 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/monitor-session-bridge.ts +266 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/no-progress.ts +627 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/operator-current-state.ts +57 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/operator-watchdog.ts +97 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/orchestration-activation.ts +109 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/orchestration-metrics.ts +78 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/orchestration-route.ts +68 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/package.json +7 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/peer-spawn-plan.ts +116 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/permission-channel.ts +87 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/permission-relay.ts +84 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/policy/models.ts +153 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/policy/profile-activation.ts +62 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/policy/profile-runtime.ts +120 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/policy/roster.ts +103 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/policy/work-mode.ts +103 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/poll-command.ts +184 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/presentation.ts +54 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/private-config-current-state.ts +81 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/private-config-fixtures.ts +26 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/private-config-review.ts +100 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-config.ts +22 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-evaluate.ts +138 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-external-git.ts +82 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-external.ts +142 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-feedback.ts +104 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-findings.ts +115 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-local.ts +89 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-observer.ts +106 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-rules.ts +171 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-runtime.ts +318 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-selection.ts +68 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-snapshot-worker.mjs +12 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-snapshot.ts +287 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-types.ts +70 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/process-obligations.ts +210 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/prompts/context.ts +72 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/prompts/fragments.ts +94 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/prompts/session-start.ts +89 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/prompts/system-prompt.ts +142 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/provider-semaphore.js +143 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/reconcile.ts +26 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/recover-policy.ts +44 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/recover-state.ts +104 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/recovery-contract.ts +151 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/rerun-policy.ts +40 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/research/controls.ts +74 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/research/runtime.ts +215 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/research/spawn-run.ts +221 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/research-watchdog.ts +40 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/return-contract.js +371 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/return-extract.js +77 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/review-closure.ts +43 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/review-continuity.ts +76 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/review-findings.js +96 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/review-reuse.ts +48 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/review-verdict.ts +6 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/routing-observation.ts +41 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/routing-proposal.ts +46 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/run-budget.js +362 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/run-namespace.js +93 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/runtime-receipts.ts +63 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/runtime-test-check.ts +85 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/safety-routing.ts +28 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/scope-gate.js +271 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/scope-overlap.ts +46 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/session-audit.ts +331 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/session-health.js +110 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/session-start.ts +42 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/spawn.ts +702 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/specialist-result-receipt.ts +13 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/specialist-result.ts +78 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/system1-activity.ts +625 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/system1-communication-store.ts +225 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/system1-report.ts +275 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/system1-runtime.ts +271 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/task-brief.ts +98 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/task-continuation.ts +4 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/task-resume-contract.ts +80 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/task-triage-authorization.ts +170 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/task-triage-config.ts +21 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/task-triage-contract.ts +14 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/task-triage-live-stage-boundary.mjs +49 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/task-triage-obligations.ts +120 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/task-triage-policy.ts +16 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/task-triage-review-contract.mjs +43 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/task-triage-reviewer-only-contract.mjs +156 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/task-triage-reviewer-only-diagnostics.mjs +112 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/task-triage-runtime.ts +130 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/task-triage-stage-guard.ts +21 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/task-triage-state.ts +46 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/timeline.ts +72 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/tool-catalog-runtime.ts +83 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/tool-catalog-state.ts +125 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/tool-protocol.ts +134 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/action-executors.ts +214 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/ask-system1-files.ts +15 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/ask-system1.ts +25 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/coms-tools.ts +139 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/context.ts +149 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/dispatch-agent.ts +93 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/dispatch-execution.ts +928 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/dispatch-triage.ts +16 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/execution-orchestration.ts +22 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/fleet-tools.ts +201 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/herdr-executors.ts +100 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/poll-panel-core.ts +30 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/poll-panel.ts +33 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/run-flow.ts +177 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/set-task-tier.ts +31 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/spawn-research.ts +67 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/team-adjust.ts +29 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/verification-contract.ts +81 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/tsconfig.json +22 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/types.ts +66 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/activity-dots.ts +25 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/context-budget.ts +89 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/detail-panel.ts +192 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/fleet-actions.ts +78 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/fleet-dashboard.ts +173 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/fleet-editor.ts +44 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/fleet-source.ts +179 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/grid.ts +159 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/history-store.ts +137 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/history.ts +234 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/pool.ts +103 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/running-strip.ts +2 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/system1-communication.ts +59 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/zoom.ts +206 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/unknown-tool-counter.ts +116 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/version.ts +42 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/watchdog-evaluation.ts +110 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/work-mode.ts +183 -0
- package/.versions/2.2.0/.pi/harnesses/agent-hub/write-isolation.ts +232 -0
- package/.versions/2.2.0/.pi/harnesses/ask-user-remote/README.md +59 -0
- package/.versions/2.2.0/.pi/harnesses/ask-user-remote/index.ts +571 -0
- package/.versions/2.2.0/.pi/harnesses/ask-user-remote/questions.ts +206 -0
- package/.versions/2.2.0/.pi/harnesses/ask-user-remote/race-core.js +124 -0
- package/.versions/2.2.0/.pi/harnesses/ask-user-remote/runtime-ask.ts +90 -0
- package/.versions/2.2.0/.pi/harnesses/coms/README.md +105 -0
- package/.versions/2.2.0/.pi/harnesses/coms/index.ts +308 -0
- package/.versions/2.2.0/.pi/harnesses/coms/package.json +7 -0
- package/.versions/2.2.0/.pi/harnesses/coms/version.ts +42 -0
- package/.versions/2.2.0/.pi/harnesses/damage-control-continue/README.md +161 -0
- package/.versions/2.2.0/.pi/harnesses/damage-control-continue/index.ts +659 -0
- package/.versions/2.2.0/.pi/harnesses/damage-control-continue/package.json +7 -0
- package/.versions/2.2.0/.pi/harnesses/damage-control-continue/result-screen.ts +98 -0
- package/.versions/2.2.0/.pi/harnesses/damage-control-continue/system1-child.ts +45 -0
- package/.versions/2.2.0/.pi/harnesses/damage-control-continue/system1-client.ts +85 -0
- package/.versions/2.2.0/.pi/harnesses/damage-control-continue/system1-guard.ts +65 -0
- package/.versions/2.2.0/.pi/harnesses/damage-control-continue/version.ts +42 -0
- package/.versions/2.2.0/.pi/harnesses/lib/approval-wait.ts +17 -0
- package/.versions/2.2.0/.pi/harnesses/lib/bash-policy-analysis.ts +185 -0
- package/.versions/2.2.0/.pi/harnesses/lib/changed-file-diagnostics.ts +642 -0
- package/.versions/2.2.0/.pi/harnesses/lib/clarification-policy.ts +9 -0
- package/.versions/2.2.0/.pi/harnesses/lib/codex-compat.ts +97 -0
- package/.versions/2.2.0/.pi/harnesses/lib/codex-contract.ts +259 -0
- package/.versions/2.2.0/.pi/harnesses/lib/codex-notification-profile.ts +75 -0
- package/.versions/2.2.0/.pi/harnesses/lib/coms-core-io.ts +422 -0
- package/.versions/2.2.0/.pi/harnesses/lib/coms-core.ts +738 -0
- package/.versions/2.2.0/.pi/harnesses/lib/coms-instruction-receipts.ts +113 -0
- package/.versions/2.2.0/.pi/harnesses/lib/coms-observation.ts +74 -0
- package/.versions/2.2.0/.pi/harnesses/lib/coms-registry-entry.ts +99 -0
- package/.versions/2.2.0/.pi/harnesses/lib/coms-response-read.ts +107 -0
- package/.versions/2.2.0/.pi/harnesses/lib/context-budget-child-prompt.ts +214 -0
- package/.versions/2.2.0/.pi/harnesses/lib/context-budget-hub-prompt.ts +124 -0
- package/.versions/2.2.0/.pi/harnesses/lib/context-budget-view.ts +112 -0
- package/.versions/2.2.0/.pi/harnesses/lib/context-budget.ts +114 -0
- package/.versions/2.2.0/.pi/harnesses/lib/context-compaction-policy.js +35 -0
- package/.versions/2.2.0/.pi/harnesses/lib/damage-action-hash.ts +28 -0
- package/.versions/2.2.0/.pi/harnesses/lib/damage-auto-policy.ts +52 -0
- package/.versions/2.2.0/.pi/harnesses/lib/damage-control-presentation.ts +14 -0
- package/.versions/2.2.0/.pi/harnesses/lib/damage-control-shared.ts +276 -0
- package/.versions/2.2.0/.pi/harnesses/lib/damage-guard-port.ts +25 -0
- package/.versions/2.2.0/.pi/harnesses/lib/damage-policy.ts +35 -0
- package/.versions/2.2.0/.pi/harnesses/lib/damage-result-evidence.ts +25 -0
- package/.versions/2.2.0/.pi/harnesses/lib/damage-result-view.ts +16 -0
- package/.versions/2.2.0/.pi/harnesses/lib/deterministic-handle-path.ts +25 -0
- package/.versions/2.2.0/.pi/harnesses/lib/exact-permission-port.ts +38 -0
- package/.versions/2.2.0/.pi/harnesses/lib/execution-trace.ts +45 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fixtures/context-budget-profiles.json +11 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fixtures/hub-prompt-operator.legacy.txt +73 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fixtures/hub-prompt-orchestrator.legacy.txt +73 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-bootstrap-channel.ts +148 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-codex-catalog.ts +30 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-codex-chat-view.ts +43 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-codex-event-bridge.ts +82 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-codex-namespace.ts +2 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-codex-policy-snapshot.ts +10 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-config/cli-bridge.ts +111 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-config/mutations.ts +201 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-config/snapshot.ts +417 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-config/transition.ts +68 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-config/ui.ts +269 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-config/view.ts +338 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-connection-control.ts +94 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-dashboard-ops.ts +178 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-dashboard-view.ts +174 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-detail-view.ts +339 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-event-source.ts +21 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-notification-admission.ts +32 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-notification-bootstrap.ts +152 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-notification-validation.ts +122 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-overlay.ts +26 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-panel.ts +34 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-question-reference.ts +42 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-read-model.ts +609 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-selection.ts +24 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-strip-controller.ts +75 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-strip-view.ts +179 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-target-identity.ts +9 -0
- package/.versions/2.2.0/.pi/harnesses/lib/fleet-transcript-store.ts +244 -0
- package/.versions/2.2.0/.pi/harnesses/lib/herdr-client.ts +472 -0
- package/.versions/2.2.0/.pi/harnesses/lib/herdr-presence.ts +399 -0
- package/.versions/2.2.0/.pi/harnesses/lib/hermes-monitor-events.ts +136 -0
- package/.versions/2.2.0/.pi/harnesses/lib/hermes-monitor-herdr.ts +28 -0
- package/.versions/2.2.0/.pi/harnesses/lib/hermes-monitor-model.ts +18 -0
- package/.versions/2.2.0/.pi/harnesses/lib/hermes-monitor-registry.ts +6 -0
- package/.versions/2.2.0/.pi/harnesses/lib/hermes-monitor-socket.ts +163 -0
- package/.versions/2.2.0/.pi/harnesses/lib/hermes-monitor-store.ts +31 -0
- package/.versions/2.2.0/.pi/harnesses/lib/identical-dialog.ts +27 -0
- package/.versions/2.2.0/.pi/harnesses/lib/installation-state.js +62 -0
- package/.versions/2.2.0/.pi/harnesses/lib/peer-target.ts +24 -0
- package/.versions/2.2.0/.pi/harnesses/lib/policy-roots.js +117 -0
- package/.versions/2.2.0/.pi/harnesses/lib/policy-roots.ts +32 -0
- package/.versions/2.2.0/.pi/harnesses/lib/process-shared.ts +9 -0
- package/.versions/2.2.0/.pi/harnesses/lib/resource-closure.js +26 -0
- package/.versions/2.2.0/.pi/harnesses/lib/safe-source-read.js +29 -0
- package/.versions/2.2.0/.pi/harnesses/lib/semantic-approval.ts +80 -0
- package/.versions/2.2.0/.pi/harnesses/lib/session-target.ts +62 -0
- package/.versions/2.2.0/.pi/harnesses/lib/spawned-peers.js +191 -0
- package/.versions/2.2.0/.pi/harnesses/lib/system1/config-agentic.js +15 -0
- package/.versions/2.2.0/.pi/harnesses/lib/system1/config-context-compaction.js +16 -0
- package/.versions/2.2.0/.pi/harnesses/lib/system1/config-damage-guard.js +24 -0
- package/.versions/2.2.0/.pi/harnesses/lib/system1/config-file-discovery.js +23 -0
- package/.versions/2.2.0/.pi/harnesses/lib/system1/config-json.js +37 -0
- package/.versions/2.2.0/.pi/harnesses/lib/system1/config-loader.js +53 -0
- package/.versions/2.2.0/.pi/harnesses/lib/system1/config-proactive.js +68 -0
- package/.versions/2.2.0/.pi/harnesses/lib/system1/config-triage.js +42 -0
- package/.versions/2.2.0/.pi/harnesses/lib/system1/config-v2.js +112 -0
- package/.versions/2.2.0/.pi/harnesses/lib/system1/config.js +50 -0
- package/.versions/2.2.0/.pi/harnesses/lib/system1/contracts.ts +154 -0
- package/.versions/2.2.0/.pi/harnesses/lib/system1/demo.ts +95 -0
- package/.versions/2.2.0/.pi/harnesses/lib/system1/jev.ts +503 -0
- package/.versions/2.2.0/.pi/harnesses/lib/system1/payload-screen.ts +65 -0
- package/.versions/2.2.0/.pi/harnesses/lib/system1/selection.js +11 -0
- package/.versions/2.2.0/.pi/harnesses/lib/system1/service.ts +245 -0
- package/.versions/2.2.0/.pi/harnesses/lib/system1/worktree-scopes.js +110 -0
- package/.versions/2.2.0/.pi/harnesses/lib/system1/worktree-scopes.ts +13 -0
- package/.versions/2.2.0/.pi/harnesses/lib/system1/worktree-service.ts +24 -0
- package/.versions/2.2.0/.pi/harnesses/lib/target-capabilities.js +7 -0
- package/.versions/2.2.0/.pi/harnesses/lib/update-check.ts +227 -0
- package/.versions/2.2.0/.pi/harnesses/lib/workspace-context.js +115 -0
- package/.versions/2.2.0/.pi/harnesses/lib/workspace-context.ts +22 -0
- package/.versions/2.2.0/.pi/harnesses/package-lock.json +2121 -0
- package/.versions/2.2.0/.pi/harnesses/package.json +13 -0
- package/.versions/2.2.0/.pi/prompts/af-build.md +27 -0
- package/.versions/2.2.0/.pi/prompts/af-code-simplify.md +22 -0
- package/.versions/2.2.0/.pi/prompts/af-constraints.md +31 -0
- package/.versions/2.2.0/.pi/prompts/af-plan.md +17 -0
- package/.versions/2.2.0/.pi/prompts/af-review.md +16 -0
- package/.versions/2.2.0/.pi/prompts/af-set-hermes-telegram.md +15 -0
- package/.versions/2.2.0/.pi/prompts/af-set-hermes-watchdog.md +6 -0
- package/.versions/2.2.0/.pi/prompts/af-setup-rules.md +20 -0
- package/.versions/2.2.0/.pi/prompts/af-ship.md +17 -0
- package/.versions/2.2.0/.pi/prompts/af-spec.md +15 -0
- package/.versions/2.2.0/.pi/prompts/af-test.md +19 -0
- package/.versions/2.2.0/.pi/skills/bowser/SKILL.md +145 -0
- package/.versions/2.2.0/.version +1 -0
- package/.versions/2.2.0/agents/architect.md +24 -0
- package/.versions/2.2.0/agents/bowser.md +28 -0
- package/.versions/2.2.0/agents/builder.md +55 -0
- package/.versions/2.2.0/agents/code-reviewer.md +209 -0
- package/.versions/2.2.0/agents/deep-researcher.md +32 -0
- package/.versions/2.2.0/agents/documenter.md +22 -0
- package/.versions/2.2.0/agents/plan-reviewer.md +83 -0
- package/.versions/2.2.0/agents/planner.md +107 -0
- package/.versions/2.2.0/agents/releaser.md +24 -0
- package/.versions/2.2.0/agents/researcher.md +30 -0
- package/.versions/2.2.0/agents/security-auditor.md +167 -0
- package/.versions/2.2.0/agents/test-engineer.md +153 -0
- package/.versions/2.2.0/agents/web-debugger.md +44 -0
- package/.versions/2.2.0/agents/web-performance-auditor.md +194 -0
- package/.versions/2.2.0/bin/catalog/harness-runtime-closure.json +85 -0
- package/.versions/2.2.0/docs/ARCHITECTURE.md +1291 -0
- package/.versions/2.2.0/docs/agent-fleet-setup.md +1161 -0
- package/.versions/2.2.0/docs/claude-code-coms-bridge.md +147 -0
- package/.versions/2.2.0/docs/codex-local-mcp.md +520 -0
- package/.versions/2.2.0/docs/codex-session-bridge.md +44 -0
- package/.versions/2.2.0/docs/codex-setup.md +183 -0
- package/.versions/2.2.0/docs/coms-hermes-bridge.md +188 -0
- package/.versions/2.2.0/docs/fleet-native-voice.md +151 -0
- package/.versions/2.2.0/docs/getting-started.md +126 -0
- package/.versions/2.2.0/docs/npm-install.md +535 -0
- package/.versions/2.2.0/docs/pi-extensions.md +450 -0
- package/.versions/2.2.0/docs/pi-setup.md +92 -0
- package/.versions/2.2.0/docs/skill-anatomy.md +150 -0
- package/.versions/2.2.0/install-manifest.json +3226 -0
- package/.versions/2.2.0/justfile +246 -0
- package/.versions/2.2.0/manifest-meta.json +1098 -0
- package/.versions/2.2.0/references/accessibility-checklist.md +160 -0
- package/.versions/2.2.0/references/communication-contract.md +26 -0
- package/.versions/2.2.0/references/definition-of-done.md +67 -0
- package/.versions/2.2.0/references/fleet-coordination-patterns.md +171 -0
- package/.versions/2.2.0/references/observability-checklist.md +92 -0
- package/.versions/2.2.0/references/orchestration-patterns.md +370 -0
- package/.versions/2.2.0/references/performance-checklist.md +236 -0
- package/.versions/2.2.0/references/prompting-patterns.md +380 -0
- package/.versions/2.2.0/references/security-checklist.md +245 -0
- package/.versions/2.2.0/references/testing-patterns.md +235 -0
- package/.versions/2.2.0/references/workflow-authoring.md +304 -0
- package/.versions/2.2.0/skills/_internal/grilling.md +59 -0
- package/.versions/2.2.0/skills/browser-testing-with-devtools/SKILL.md +351 -0
- package/.versions/2.2.0/skills/code-review-and-quality/SKILL.md +396 -0
- package/.versions/2.2.0/skills/compound-learning/SKILL.md +137 -0
- package/.versions/2.2.0/skills/constraint-driven-development/SKILL.md +338 -0
- package/.versions/2.2.0/skills/constraint-driven-development/references/floor-guard.md +99 -0
- package/.versions/2.2.0/skills/context-engineering/SKILL.md +341 -0
- package/.versions/2.2.0/skills/deprecation-and-migration/SKILL.md +247 -0
- package/.versions/2.2.0/skills/designing-agents/SKILL.md +394 -0
- package/.versions/2.2.0/skills/designing-agents/pi-harness-authoring.md +222 -0
- package/.versions/2.2.0/skills/drafting-workflows/SKILL.md +143 -0
- package/.versions/2.2.0/skills/drafting-workflows/scripts/make-workflow.ts +177 -0
- package/.versions/2.2.0/skills/fleet-connect/SKILL.md +29 -0
- package/.versions/2.2.0/skills/fleet-connect.zip +0 -0
- package/.versions/2.2.0/skills/fleet-native-voice/SKILL.md +103 -0
- package/.versions/2.2.0/skills/fleet-native-voice/agents/openai.yaml +4 -0
- package/.versions/2.2.0/skills/fleet-native-voice.zip +0 -0
- package/.versions/2.2.0/skills/frontend-ui-engineering/SKILL.md +328 -0
- package/.versions/2.2.0/skills/git-workflow-and-versioning/SKILL.md +316 -0
- package/.versions/2.2.0/skills/idea-refine/SKILL.md +182 -0
- package/.versions/2.2.0/skills/idea-refine/examples.md +238 -0
- package/.versions/2.2.0/skills/idea-refine/frameworks.md +99 -0
- package/.versions/2.2.0/skills/idea-refine/refinement-criteria.md +113 -0
- package/.versions/2.2.0/skills/idea-refine/scripts/idea-refine.sh +15 -0
- package/.versions/2.2.0/skills/incremental-implementation/SKILL.md +353 -0
- package/.versions/2.2.0/skills/incremental-implementation.zip +0 -0
- package/.versions/2.2.0/skills/interview-me/SKILL.md +226 -0
- package/.versions/2.2.0/skills/orchestration-verification/SKILL.md +182 -0
- package/.versions/2.2.0/skills/peer-coms/SKILL.md +90 -0
- package/.versions/2.2.0/skills/performance-optimization/SKILL.md +496 -0
- package/.versions/2.2.0/skills/planning-and-task-breakdown/SKILL.md +318 -0
- package/.versions/2.2.0/skills/planning-and-task-breakdown.zip +0 -0
- package/.versions/2.2.0/skills/repository-ai-setup/SKILL.md +135 -0
- package/.versions/2.2.0/skills/repository-ai-setup/references/agent-fleet-ai-state.template.json +4 -0
- package/.versions/2.2.0/skills/repository-ai-setup/references/apply-contract.md +74 -0
- package/.versions/2.2.0/skills/repository-ai-setup/references/provenance-template.md +16 -0
- package/.versions/2.2.0/skills/repository-ai-setup/references/setup-flow.md +108 -0
- package/.versions/2.2.0/skills/repository-ai-setup/references/verify-setup.md +20 -0
- package/.versions/2.2.0/skills/repository-ai-setup.zip +0 -0
- package/.versions/2.2.0/skills/security-and-hardening/SKILL.md +524 -0
- package/.versions/2.2.0/skills/spec-driven-development/SKILL.md +295 -0
- package/.versions/2.2.0/skills/spec-driven-development.zip +0 -0
- package/.versions/2.2.0/skills/using-agent-skills/SKILL.md +198 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/LICENSE +21 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/README.md +430 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/api-and-interface-design/SKILL.md +367 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/browser-testing-with-devtools/SKILL.md +317 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/ci-cd-and-automation/SKILL.md +390 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/code-review-and-quality/SKILL.md +396 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/code-simplification/SKILL.md +331 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/constraint-driven-development/SKILL.md +311 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/constraint-driven-development/references/floor-guard.md +99 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/context-engineering/SKILL.md +337 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/debugging-and-error-recovery/SKILL.md +300 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/deprecation-and-migration/SKILL.md +247 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/documentation-and-adrs/SKILL.md +288 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/doubt-driven-development/SKILL.md +243 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/frontend-ui-engineering/SKILL.md +328 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/git-workflow-and-versioning/SKILL.md +355 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/idea-refine/SKILL.md +178 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/idea-refine/examples.md +238 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/idea-refine/frameworks.md +99 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/idea-refine/refinement-criteria.md +113 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/idea-refine/scripts/idea-refine.sh +15 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/incremental-implementation/SKILL.md +249 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/interview-me/SKILL.md +225 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/observability-and-instrumentation/SKILL.md +238 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/performance-optimization/SKILL.md +496 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/planning-and-task-breakdown/SKILL.md +257 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/security-and-hardening/SKILL.md +524 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/shipping-and-launch/SKILL.md +330 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/source-driven-development/SKILL.md +216 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/spec-driven-development/SKILL.md +245 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/test-driven-development/SKILL.md +398 -0
- package/.versions/2.2.0/vendor/agent-skills-upstream/skills/using-agent-skills/SKILL.md +192 -0
- package/CHANGELOG.md +33 -0
- package/README.md +7 -10
- package/bin/lib/set-codex-mcp.js +1 -1
- package/bin/lib/validate-overrides.js +8 -1
- package/docs/ARCHITECTURE.md +122 -26
- package/docs/MIGRATION-agent-fleet.md +26 -5
- package/docs/agent-fleet-setup.md +44 -26
- package/docs/claude-code-coms-bridge.md +1 -1
- package/docs/codex-local-mcp.md +29 -12
- package/docs/codex-session-bridge.md +2 -2
- package/docs/codex-setup.md +1 -1
- package/docs/fleet-native-voice.md +10 -4
- package/docs/npm-install.md +1 -1
- package/docs/pi-extensions.md +13 -18
- package/docs/system1-agentic.md +1 -1
- package/docs/system1-file-discovery.md +2 -2
- package/docs/workflows.md +24 -1
- package/install-manifest.json +15 -28
- package/justfile +3 -4
- package/manifest-meta.json +13 -2
- package/package.json +4 -2
- package/skills/fleet-connect/SKILL.md +20 -16
- package/skills/fleet-connect.zip +0 -0
- package/skills/fleet-native-voice.zip +0 -0
- package/.pi/harnesses/agent-hub/commands/work-mode.ts +0 -29
- package/.pi/harnesses/agent-hub/work-mode-controls.ts +0 -56
- package/agents/orchestrator.md +0 -22
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import {createHash} from 'node:crypto';
|
|
2
|
+
import {constants,lstatSync,openSync,readSync,closeSync,readlinkSync,type BigIntStats} from 'node:fs';
|
|
3
|
+
import {open,lstat,readlink,type FileHandle} from 'node:fs/promises';
|
|
4
|
+
import {isAbsolute,resolve,join,dirname} from 'node:path';
|
|
5
|
+
import {bootstrapNamespace,namespaceKey,type BootstrapPresence} from '../../../harnesses/lib/fleet-bootstrap-channel.ts';
|
|
6
|
+
import {compareCodexVersions} from '../../../harnesses/lib/codex-compat.ts';
|
|
7
|
+
import {privateDirectory,writePrivateJson} from './codex-bootstrap-files.ts';
|
|
8
|
+
import {readDesktopPackageVersion,desktopPackageCurrent,type DesktopPackageEvidence,type AutomaticDesktopData} from './codex-desktop-discovery.ts';
|
|
9
|
+
import {validNativeObservation} from './codex-native-presence.ts';
|
|
10
|
+
|
|
11
|
+
const same=(a:unknown,b:unknown)=>JSON.stringify(a)===JSON.stringify(b);
|
|
12
|
+
const sameNative=(a:BootstrapPresence,b:BootstrapPresence)=>same(a.namespace,b.namespace)&&a.hostInstance===b.hostInstance&&a.protocolVersion===b.protocolVersion&&same(a.clientInfo,b.clientInfo);
|
|
13
|
+
const identity=(s:BigIntStats)=>[s.dev,s.ino,s.uid,s.mode,s.size,s.mtimeNs,s.ctimeNs].join(':');
|
|
14
|
+
const plain=(v:unknown):v is Record<string,any>=>!!v&&typeof v==='object'&&!Array.isArray(v);
|
|
15
|
+
const own=(v:unknown,keys:string[]):v is Record<string,any>=>plain(v)&&Object.keys(v).length===keys.length&&keys.every(k=>Object.hasOwn(v,k));
|
|
16
|
+
function normalizeObservation(value:unknown):BootstrapPresence{
|
|
17
|
+
if(!validNativeObservation(value)||!value.clientInfo)throw Error('desktop_preflight_inputs');
|
|
18
|
+
return {namespace:{hostProfile:value.namespace.hostProfile,principal:value.namespace.principal,threadId:value.namespace.threadId},hostInstance:value.hostInstance,protocolVersion:value.protocolVersion,clientInfo:{name:value.clientInfo.name,version:value.clientInfo.version},catalog:[...value.catalog]};
|
|
19
|
+
}
|
|
20
|
+
const safePath=(v:unknown):v is string=>typeof v==='string'&&v.length<=4096&&isAbsolute(v)&&resolve(v)===v&&!/[\u0000-\u001f\u007f]/.test(v);
|
|
21
|
+
const decode=(b:Uint8Array)=>new TextDecoder('utf-8',{fatal:true}).decode(b);
|
|
22
|
+
type ProcessIdentity={pid:number;startTicks:string;executable:string;fileIdentity:string;sha256:string};
|
|
23
|
+
export type DesktopPreflightRecord={schema:'fleet-desktop-native-mapping/v1';observation:BootstrapPresence;desktop:ProcessIdentity;desktopVersion:string;desktopPackage?:DesktopPackageEvidence;versionSource:'operator_observed_running_desktop_version'|'automatically_observed_desktop_package_version';socketPath:string;codexHome:string;binaryPath:string|null;capturedAt:number;mappingSource:'native_pi_operator_observed_desktop_and_loaded_catalog'|'native_pi_confirmed_automatic_desktop_mapping'|'automatic_desktop_observation_pending_pi_confirmation'};
|
|
24
|
+
|
|
25
|
+
/** Read-only PID/executable checks plus explicit native Pi operator mapping.
|
|
26
|
+
* This does not discover a Desktop, infer identity/catalog from clientInfo, or
|
|
27
|
+
* mint rights/activation. capture MUST be called only by the native preflight UI
|
|
28
|
+
* after operator verifies the exact Desktop/chat and actual loaded catalog.
|
|
29
|
+
* File is server-owned mapping policy, not consent; every bootstrap reconfirms.
|
|
30
|
+
* Production procRoot is /proc. Tests use only an explicitly injected fake tree. */
|
|
31
|
+
export class DesktopPreflightRegistry {
|
|
32
|
+
private readonly root:string;private readonly procRoot:string;private readonly confirm:(review:Readonly<{observation:BootstrapPresence;desktop:ProcessIdentity;desktopVersion:string;socketPath:string;codexHome:string;binaryPath:string|null}>,signal:AbortSignal)=>Promise<boolean>;
|
|
33
|
+
readonly #digests=new Map<string,string>();
|
|
34
|
+
readonly #proofs=new WeakMap<DesktopPreflightRecord,{record:DesktopPreflightRecord;file:string;fileIdentity:string;rootIdentity:string;version?:DesktopPackageEvidence}>();
|
|
35
|
+
readonly #drafts=new WeakMap<DesktopPreflightRecord,{record:DesktopPreflightRecord;version:DesktopPackageEvidence}>();
|
|
36
|
+
constructor(options:{root:string;procRoot?:string;confirm:DesktopPreflightRegistry['confirm']}){if(!safePath(options.root)||!safePath(options.procRoot??'/proc'))throw Error('desktop_preflight_options');this.root=options.root;this.procRoot=options.procRoot??'/proc';this.confirm=options.confirm;}
|
|
37
|
+
#check(signal:AbortSignal,deadline:number){if(signal.aborted||performance.now()>=deadline)throw Error('desktop_preflight_cancelled_or_overdue');}
|
|
38
|
+
async #io<T>(signal:AbortSignal,deadline:number,work:()=>Promise<T>){this.#check(signal,deadline);const v=await work();this.#check(signal,deadline);return v;}
|
|
39
|
+
async #small(path:string,max:number,signal:AbortSignal,deadline:number){const file=await open(path,constants.O_RDONLY|constants.O_NOFOLLOW);try{const buffer=Buffer.alloc(max+1);const {bytesRead}=await this.#io(signal,deadline,()=>file.read(buffer,0,buffer.length,0));if(bytesRead>max)throw Error('desktop_preflight_limit');return buffer.subarray(0,bytesRead);}finally{await file.close();}}
|
|
40
|
+
async #process(pid:number,signal:AbortSignal,deadline:number){
|
|
41
|
+
if(!Number.isSafeInteger(pid)||pid<1||pid>2147483647||typeof process.getuid!=='function')throw Error('desktop_preflight_pid');
|
|
42
|
+
const base=join(this.procRoot,String(pid)),stat=await this.#io(signal,deadline,()=>lstat(base,{bigint:true}));if(!stat.isDirectory()||stat.isSymbolicLink()||stat.uid!==BigInt(process.getuid()))throw Error('desktop_preflight_process_owner');
|
|
43
|
+
const raw=decode(await this.#small(join(base,'stat'),16384,signal,deadline)),end=raw.lastIndexOf(') '),parts=raw.slice(end+2).trim().split(/\s+/);
|
|
44
|
+
if(!raw.startsWith(pid+' (')||end<0||!/^\d{1,32}$/.test(parts[19]??''))throw Error('desktop_preflight_process_invalid');
|
|
45
|
+
const executable=await this.#io(signal,deadline,()=>readlink(join(base,'exe')));if(!safePath(executable))throw Error('desktop_preflight_executable_unavailable');
|
|
46
|
+
return {pid,startTicks:parts[19],executable};
|
|
47
|
+
}
|
|
48
|
+
async #desktop(pid:number,signal:AbortSignal):Promise<ProcessIdentity>{
|
|
49
|
+
const deadline=performance.now()+10000,before=await this.#process(pid,signal,deadline);let file:FileHandle|undefined;
|
|
50
|
+
try{
|
|
51
|
+
const stat=await this.#io(signal,deadline,()=>lstat(before.executable,{bigint:true}));
|
|
52
|
+
if(!stat.isFile()||stat.isSymbolicLink()||(stat.uid!==BigInt(process.getuid!())&&stat.uid!==0n)||(stat.mode&0o022n)!==0n||(stat.mode&0o111n)===0n||stat.size<1n||stat.size>512n*1024n*1024n)throw Error('desktop_preflight_executable_unsafe');
|
|
53
|
+
this.#check(signal,deadline);file=await open(before.executable,constants.O_RDONLY|constants.O_NOFOLLOW);this.#check(signal,deadline);
|
|
54
|
+
const held=await this.#io(signal,deadline,()=>file!.stat({bigint:true}));if(identity(held)!==identity(stat))throw Error('desktop_preflight_executable_changed');
|
|
55
|
+
const key=identity(held)+':'+before.executable;let digest=this.#digests.get(key);
|
|
56
|
+
if(!digest){const hash=createHash('sha256'),buffer=Buffer.alloc(65536);let offset=0;while(offset<Number(held.size)){const result=await this.#io(signal,deadline,()=>file!.read(buffer,0,Math.min(buffer.length,Number(held.size)-offset),offset));if(!result.bytesRead)throw Error('desktop_preflight_executable_changed');hash.update(buffer.subarray(0,result.bytesRead));offset+=result.bytesRead;}digest=hash.digest('hex');}
|
|
57
|
+
if(identity(await this.#io(signal,deadline,()=>file!.stat({bigint:true})))!==identity(held)||identity(await this.#io(signal,deadline,()=>lstat(before.executable,{bigint:true})))!==identity(held)||!same(before,await this.#process(pid,signal,deadline)))throw Error('desktop_preflight_executable_changed');
|
|
58
|
+
await file.close();file=undefined;this.#check(signal,deadline);if(this.#digests.size>=64)this.#digests.delete(this.#digests.keys().next().value!);this.#digests.set(key,digest);
|
|
59
|
+
return {...before,fileIdentity:identity(held),sha256:digest};
|
|
60
|
+
}finally{await file?.close();}
|
|
61
|
+
}
|
|
62
|
+
#file(namespace:BootstrapPresence['namespace']){if(!bootstrapNamespace(namespace))throw Error('desktop_preflight_namespace');return join(this.root,'mapping-'+createHash('sha256').update(namespaceKey(namespace)).digest('hex')+'.json');}
|
|
63
|
+
async #parent(create:boolean){
|
|
64
|
+
try{await privateDirectory(dirname(this.root));await privateDirectory(this.root,create);}catch(e){if((e as Error).message==='bootstrap_directory_unsafe')throw Error('desktop_preflight_root_unsafe');throw e;}
|
|
65
|
+
}
|
|
66
|
+
async capture(observation:BootstrapPresence,options:{desktopPid:number;desktopVersion:string;socketPath:string;codexHome:string;binaryPath?:string},signal:AbortSignal):Promise<DesktopPreflightRecord>{
|
|
67
|
+
const seen=normalizeObservation(observation),selected=structuredClone(options);
|
|
68
|
+
if(!bootstrapNamespace(seen.namespace)||!seen.clientInfo||compareCodexVersions(selected.desktopVersion,selected.desktopVersion)!==0||!safePath(selected.socketPath)||selected.socketPath.length>100||!safePath(selected.codexHome)||selected.binaryPath!==undefined&&!safePath(selected.binaryPath))throw Error('desktop_preflight_inputs');
|
|
69
|
+
const desktop=await this.#desktop(selected.desktopPid,signal),review={observation:seen,desktop,desktopVersion:selected.desktopVersion,socketPath:selected.socketPath,codexHome:selected.codexHome,binaryPath:selected.binaryPath??null};
|
|
70
|
+
if(await this.confirm(structuredClone(review),signal)!==true||signal.aborted)throw Error('desktop_preflight_not_confirmed');
|
|
71
|
+
if(!same(desktop,await this.#desktop(selected.desktopPid,signal)))throw Error('desktop_preflight_changed');
|
|
72
|
+
const record:DesktopPreflightRecord={schema:'fleet-desktop-native-mapping/v1',observation:seen,desktop,desktopVersion:review.desktopVersion,socketPath:review.socketPath,codexHome:review.codexHome,binaryPath:review.binaryPath,versionSource:'operator_observed_running_desktop_version',capturedAt:Date.now(),mappingSource:'native_pi_operator_observed_desktop_and_loaded_catalog'};
|
|
73
|
+
await this.#parent(true);await writePrivateJson(this.#file(seen.namespace),record,{signal});return structuredClone(record);
|
|
74
|
+
}
|
|
75
|
+
/** Process-local draft only: no mapping/consent/admission or filesystem writes. */
|
|
76
|
+
async observeAutomatic(observation:BootstrapPresence,options:AutomaticDesktopData,signal:AbortSignal):Promise<DesktopPreflightRecord>{
|
|
77
|
+
const seen=normalizeObservation(observation),selected=structuredClone(options);
|
|
78
|
+
if(!safePath(selected.socketPath)||selected.socketPath.length>100||!safePath(selected.codexHome)||selected.binaryPath!==undefined&&!safePath(selected.binaryPath))throw Error('desktop_preflight_inputs');
|
|
79
|
+
const desktop=await this.#desktop(selected.desktopPid,signal),version=await readDesktopPackageVersion(desktop.executable,signal);
|
|
80
|
+
if(version.version!==selected.desktopVersion||!same(desktop,await this.#desktop(selected.desktopPid,signal)))throw Error('desktop_preflight_changed');
|
|
81
|
+
const record:DesktopPreflightRecord={schema:'fleet-desktop-native-mapping/v1',observation:seen,desktop,desktopVersion:version.version,desktopPackage:version,versionSource:'automatically_observed_desktop_package_version',socketPath:selected.socketPath,codexHome:selected.codexHome,binaryPath:selected.binaryPath??null,capturedAt:Date.now(),mappingSource:'automatic_desktop_observation_pending_pi_confirmation'};
|
|
82
|
+
this.#drafts.set(record,{record:structuredClone(record),version});return record;
|
|
83
|
+
}
|
|
84
|
+
isAutomaticDraft(record:DesktopPreflightRecord){return this.#drafts.has(record);}
|
|
85
|
+
observedCurrentNow(record:DesktopPreflightRecord,observation:BootstrapPresence){
|
|
86
|
+
const draft=this.#drafts.get(record);return draft?validNativeObservation(observation)&&same(record,draft.record)&&sameNative(record.observation,observation)&&desktopPackageCurrent(draft.version)&&this.#processCurrent(record.desktop):this.currentNow(record,observation);
|
|
87
|
+
}
|
|
88
|
+
identityFingerprint(record:DesktopPreflightRecord){const proof=this.#drafts.get(record)??this.#proofs.get(record);if(!proof||!same(record,proof.record))throw Error('desktop_preflight_changed');return createHash('sha256').update(JSON.stringify([record.desktop,record.desktopVersion,record.socketPath,record.codexHome,record.binaryPath,proof.version?.fileIdentity??null])).digest('hex');}
|
|
89
|
+
/** The callback is the genuine combined native Pi interaction, never a tool boolean. */
|
|
90
|
+
async confirmAutomatic(record:DesktopPreflightRecord,observation:BootstrapPresence,confirm:()=>Promise<boolean>,signal:AbortSignal,scopeCurrent:()=>void=()=>{}):Promise<DesktopPreflightRecord|null>{
|
|
91
|
+
if(!this.#drafts.has(record)||!this.observedCurrentNow(record,observation)||signal.aborted)throw Error('desktop_preflight_changed');
|
|
92
|
+
if(await confirm()!==true||signal.aborted)return null;
|
|
93
|
+
const guard=()=>{scopeCurrent();if(signal.aborted||!this.observedCurrentNow(record,observation))throw Error('desktop_preflight_changed');};guard();
|
|
94
|
+
await privateDirectory(dirname(this.root),true);await this.#parent(true);guard();await writePrivateJson(this.#file(observation.namespace),{...record,mappingSource:'native_pi_confirmed_automatic_desktop_mapping'},{signal,guard});
|
|
95
|
+
const current=await this.current(observation,signal);if(!current)throw Error('bootstrap_file_publication_unknown');try{guard();}catch{throw Error('bootstrap_file_publication_unknown');}this.#drafts.delete(record);return current;
|
|
96
|
+
}
|
|
97
|
+
async current(observation:BootstrapPresence,signal:AbortSignal):Promise<DesktopPreflightRecord|null>{
|
|
98
|
+
const deadline=performance.now()+12000;let file:FileHandle|undefined;
|
|
99
|
+
try{
|
|
100
|
+
const seen=normalizeObservation(observation);
|
|
101
|
+
await this.#parent(false);const path=this.#file(seen.namespace),before=await this.#io(signal,deadline,()=>lstat(path,{bigint:true}));
|
|
102
|
+
if(!before.isFile()||before.isSymbolicLink()||before.uid!==BigInt(process.getuid!())||(before.mode&0o077n)!==0n||before.nlink!==1n||before.size<1n||before.size>32768n)return null;
|
|
103
|
+
file=await open(path,constants.O_RDONLY|constants.O_NOFOLLOW);const at=await file.stat({bigint:true});if(identity(at)!==identity(before))return null;
|
|
104
|
+
const data=Buffer.alloc(Number(at.size)+1),read=await file.read(data,0,data.length,0);if(read.bytesRead!==Number(at.size)||identity(await file.stat({bigint:true}))!==identity(at))return null;
|
|
105
|
+
const raw=JSON.parse(decode(data.subarray(0,read.bytesRead)));
|
|
106
|
+
if(!own(raw,['schema','observation','desktop','desktopVersion','versionSource','socketPath','codexHome','binaryPath','capturedAt','mappingSource',...(Object.hasOwn(raw,'desktopPackage')?['desktopPackage']:[])])||!own(raw.desktop,['pid','startTicks','executable','fileIdentity','sha256']))return null;
|
|
107
|
+
const record:DesktopPreflightRecord={schema:raw.schema,observation:normalizeObservation(raw.observation),desktop:{pid:raw.desktop.pid,startTicks:raw.desktop.startTicks,executable:raw.desktop.executable,fileIdentity:raw.desktop.fileIdentity,sha256:raw.desktop.sha256},desktopVersion:raw.desktopVersion,...(Object.hasOwn(raw,'desktopPackage')?{desktopPackage:raw.desktopPackage}:{}),versionSource:raw.versionSource,socketPath:raw.socketPath,codexHome:raw.codexHome,binaryPath:raw.binaryPath,capturedAt:raw.capturedAt,mappingSource:raw.mappingSource};
|
|
108
|
+
const automatic=record.mappingSource==='native_pi_confirmed_automatic_desktop_mapping'&&record.versionSource==='automatically_observed_desktop_package_version',manual=record.mappingSource==='native_pi_operator_observed_desktop_and_loaded_catalog'&&record.versionSource==='operator_observed_running_desktop_version';
|
|
109
|
+
if(!plain(record)||record.schema!=='fleet-desktop-native-mapping/v1'||!automatic&&!manual||compareCodexVersions(record.desktopVersion,record.desktopVersion)!==0||!sameNative(record.observation,seen)||!Number.isSafeInteger(record.capturedAt)||record.capturedAt<0||record.capturedAt>Date.now()+1000||!safePath(record.socketPath)||record.socketPath.length>100||!safePath(record.codexHome)||record.binaryPath!==null&&!safePath(record.binaryPath)||!same(record.desktop,await this.#desktop(record.desktop.pid,signal)))return null;
|
|
110
|
+
if(identity(await lstat(path,{bigint:true}))!==identity(at))return null;await file.close();file=undefined;this.#check(signal,deadline);
|
|
111
|
+
if(automatic&&!own(record.desktopPackage,['version','path','fileIdentity'])||manual&&record.desktopPackage!==undefined)return null;
|
|
112
|
+
const version=automatic?await readDesktopPackageVersion(record.desktop.executable,signal):undefined;if(version&&(version.version!==record.desktopVersion||!same(version,record.desktopPackage)))return null;
|
|
113
|
+
const root=await lstat(this.root,{bigint:true}),result=structuredClone(record);this.#check(signal,deadline);this.#proofs.set(result,{record:structuredClone(record),file:path,fileIdentity:identity(at),rootIdentity:[root.dev,root.ino,root.uid,root.mode].join(':'),...(version?{version}:{})});return result;
|
|
114
|
+
}catch{return null;}finally{await file?.close();}
|
|
115
|
+
}
|
|
116
|
+
/** Only a record freshly returned by current() has this process-local proof.
|
|
117
|
+
* Bounded synchronous reads are used immediately before bytes/publication;
|
|
118
|
+
* never called from cached status/render and never infer authority from JSON. */
|
|
119
|
+
currentNow(record:DesktopPreflightRecord,observation:BootstrapPresence):boolean{
|
|
120
|
+
const proof=this.#proofs.get(record);if(!proof||!validNativeObservation(observation)||!same(record,proof.record)||!sameNative(record.observation,observation)||proof.version&&!desktopPackageCurrent(proof.version))return false;
|
|
121
|
+
try{const root=lstatSync(this.root,{bigint:true});return !root.isSymbolicLink()&&[root.dev,root.ino,root.uid,root.mode].join(':')===proof.rootIdentity&&identity(lstatSync(proof.file,{bigint:true}))===proof.fileIdentity&&this.#processCurrent(record.desktop);}catch{return false;}
|
|
122
|
+
}
|
|
123
|
+
#processCurrent(desktop:ProcessIdentity):boolean{
|
|
124
|
+
let fd:number|undefined;
|
|
125
|
+
try{
|
|
126
|
+
const dir=join(this.procRoot,String(desktop.pid)),parent=lstatSync(dir);if(!parent.isDirectory()||parent.isSymbolicLink()||parent.uid!==process.getuid?.()||readlinkSync(join(dir,'exe'))!==desktop.executable||identity(lstatSync(desktop.executable,{bigint:true}))!==desktop.fileIdentity)return false;
|
|
127
|
+
fd=openSync(join(dir,'stat'),constants.O_RDONLY|constants.O_NOFOLLOW);const buffer=Buffer.alloc(16385),size=readSync(fd,buffer,0,buffer.length,0);if(size>16384)return false;const raw=decode(buffer.subarray(0,size)),end=raw.lastIndexOf(') ');return raw.startsWith(desktop.pid+' (')&&end>0&&raw.slice(end+2).trim().split(/\s+/)[19]===desktop.startTicks;
|
|
128
|
+
}catch{return false;}finally{if(fd!==undefined)closeSync(fd);}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {createHash} from 'node:crypto';
|
|
2
|
+
import {QueueRpcError} from './codex-unix-queue-rpc.ts';
|
|
2
3
|
import {decodeQuestionReference,withinFleetReferenceLimit} from '../../../harnesses/lib/fleet-question-reference.ts';
|
|
3
4
|
import {InstructionLedger,targetKey,validInstructionTarget} from './fleet-codex-instruction-store.ts';
|
|
4
5
|
import type {ConversationKey,TargetEpoch} from './fleet-codex-allowlist.ts';
|
|
5
6
|
import type {AddressedFleetEvent,CodexEventBinding,CodexEventHost,EventDelivery} from '../../../harnesses/lib/fleet-codex-event-bridge.ts';
|
|
6
7
|
import type {CodexUnixQueueRpc} from './codex-unix-queue-rpc.ts';
|
|
7
8
|
export {desktopQueuePin,matchesDesktopQueueTuple,type DesktopQueueApproval} from '../../../harnesses/lib/fleet-notification-validation.ts';
|
|
8
|
-
import {matchesDesktopQueueTuple,type
|
|
9
|
+
import {matchesDesktopQueueTuple,type NotificationQueueApproval} from '../../../harnesses/lib/fleet-notification-validation.ts';
|
|
10
|
+
import {bootstrapAdmissionCurrent,revokeBootstrapAdmission,type BootstrapAdmission,type BootstrapCompatibility} from '../../../harnesses/lib/fleet-notification-admission.ts';
|
|
9
11
|
const uuid=/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/;
|
|
10
12
|
const sha=(value:unknown)=>createHash('sha256').update(JSON.stringify(value)).digest('hex');
|
|
11
13
|
const same=(a:unknown,b:unknown)=>sha(a)===sha(b);
|
|
@@ -16,13 +18,17 @@ const same=(a:unknown,b:unknown)=>sha(a)===sha(b);
|
|
|
16
18
|
export class CodexDesktopQueueHost implements CodexEventHost {
|
|
17
19
|
private readonly wire:Pick<CodexUnixQueueRpc,'request'>;
|
|
18
20
|
private readonly ledger:InstructionLedger;
|
|
19
|
-
private readonly approval:()=>
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
private readonly approval:()=>NotificationQueueApproval|null;
|
|
22
|
+
private readonly bootstrap?:{admission:BootstrapAdmission;compat:BootstrapCompatibility};private readonly stateRoot:string;private readonly onContextInvalid?:()=>void;
|
|
23
|
+
constructor(options:{rpc:Pick<CodexUnixQueueRpc,'request'>;stateRoot:string;currentApproval:()=>NotificationQueueApproval|null;bootstrap?:{admission:BootstrapAdmission;compat:BootstrapCompatibility};onContextInvalid?:()=>void}){
|
|
24
|
+
this.wire=options.rpc;this.ledger=new InstructionLedger(options.stateRoot+'.desktop-events');this.approval=options.currentApproval;this.stateRoot=options.stateRoot;this.onContextInvalid=options.onContextInvalid;
|
|
25
|
+
if(options.bootstrap)this.bootstrap={admission:options.bootstrap.admission,compat:structuredClone(options.bootstrap.compat)};
|
|
22
26
|
}
|
|
23
|
-
private
|
|
27
|
+
private contextError(error:unknown){if(this.bootstrap&&error instanceof QueueRpcError&&['VERSION_CHANGED','SOCKET_CHANGED'].includes(error.code)){revokeBootstrapAdmission(this.bootstrap.admission);try{this.onContextInvalid?.();}catch{}}}
|
|
28
|
+
private pin(){return this.bootstrap?{pin:{daemonVersion:this.bootstrap.compat.daemonVersion,socketEpoch:this.bootstrap.compat.socketEpoch}}:{};}
|
|
29
|
+
private approved(binding:CodexEventBinding):NotificationQueueApproval|null{
|
|
24
30
|
const a=this.approval();
|
|
25
|
-
if(!a||!same(a.binding,binding)||!uuid.test(binding.threadId)||!validInstructionTarget(a.target)||targetKey(a.target)!==binding.fleetOwner||!Number.isSafeInteger(a.authorityRevision)||a.authorityRevision<1||!Number.isSafeInteger(a.confirmedUntil)||a.confirmedUntil<=Date.now()||a.transportOrigin!=='user_input'
|
|
31
|
+
if(!a||!same(a.binding,binding)||!uuid.test(binding.threadId)||!validInstructionTarget(a.target)||targetKey(a.target)!==binding.fleetOwner||!Number.isSafeInteger(a.authorityRevision)||a.authorityRevision<1||!Number.isSafeInteger(a.confirmedUntil)||a.confirmedUntil<=Date.now()||a.transportOrigin!=='user_input'||!(this.bootstrap?a.mappingEvidence==='validated_native_host_context_and_read_only_probe'&&bootstrapAdmissionCurrent(this.bootstrap.admission,{approval:a,compat:this.bootstrap.compat,stateRoot:this.stateRoot}):a.mappingEvidence==='externally_confirmed_loaded_desktop'&&matchesDesktopQueueTuple(a)))return null;
|
|
26
32
|
return structuredClone(a);
|
|
27
33
|
}
|
|
28
34
|
private context(binding:CodexEventBinding):ConversationKey{return {hostProfile:binding.hostInstance,principal:'fleet-event-queue',threadId:binding.threadId};}
|
|
@@ -30,11 +36,11 @@ export class CodexDesktopQueueHost implements CodexEventHost {
|
|
|
30
36
|
if(signal.aborted||!this.approved(binding))return false;
|
|
31
37
|
try{
|
|
32
38
|
// Metadata read only; notLoaded on daemon is EXPECTED, never resume to fake wake.
|
|
33
|
-
const result:any=await this.wire.request('thread/read',{threadId:binding.threadId,includeTurns:false},{signal});
|
|
39
|
+
const result:any=await this.wire.request('thread/read',{threadId:binding.threadId,includeTurns:false},{signal,...this.pin(),...(this.bootstrap?{beforeWrite:()=>{if(!this.approved(binding))throw Error('bootstrap_context_changed');}}:{})});
|
|
34
40
|
return !signal.aborted&&!!this.approved(binding)&&result?.thread?.id===binding.threadId&&result?.thread?.status?.type==='notLoaded';
|
|
35
|
-
}catch{return false;}
|
|
41
|
+
}catch(error){this.contextError(error);return false;}
|
|
36
42
|
}
|
|
37
|
-
private packet(binding:CodexEventBinding,event:AddressedFleetEvent,approval:
|
|
43
|
+
private packet(binding:CodexEventBinding,event:AddressedFleetEvent,approval:NotificationQueueApproval){
|
|
38
44
|
if(event.bindingId!==binding.id||event.bindingEpoch!==binding.epoch||event.fleetOwner!==binding.fleetOwner||!/^[A-Za-z0-9][A-Za-z0-9._-]{0,95}$/.test(event.id)||!['message','question','permission'].includes(event.kind)||!withinFleetReferenceLimit(event.kind,event.reference)||!Number.isSafeInteger(event.createdAt)||!Number.isSafeInteger(event.deadline)||event.createdAt>event.deadline)throw Error('invalid_event');
|
|
39
45
|
const probe=event.kind==='message'&&event.reference==='fleet:probe/'+event.id;
|
|
40
46
|
if(!probe){
|
|
@@ -69,7 +75,7 @@ export class CodexDesktopQueueHost implements CodexEventHost {
|
|
|
69
75
|
try{reserved=this.ledger.reserve(context,{requestId:event.id,target:approval.target,digest},{alias:binding.id,policyRevision:approval.authorityRevision});}catch{return {status:'unknown'};}
|
|
70
76
|
if(!reserved.created)return {status:'unknown'};
|
|
71
77
|
try{
|
|
72
|
-
const result:any=await this.wire.request('thread/queue/add',{threadId:binding.threadId,clientUserMessageId,input:[{type:'text',text,text_elements:[]}]},{signal,beforeWrite:()=>{
|
|
78
|
+
const result:any=await this.wire.request('thread/queue/add',{threadId:binding.threadId,clientUserMessageId,input:[{type:'text',text,text_elements:[]}]},{signal,...this.pin(),beforeWrite:()=>{
|
|
73
79
|
if(signal.aborted||event.deadline<=Date.now()||!same(this.approved(binding),approval))throw Error('stale_before_write');
|
|
74
80
|
this.ledger.markAttempt(context,event.id);
|
|
75
81
|
}});
|
|
@@ -79,7 +85,8 @@ export class CodexDesktopQueueHost implements CodexEventHost {
|
|
|
79
85
|
this.ledger.record(context,event.id,{state:'result',detail:'queue_ack_not_model_delivery',result:JSON.stringify(receipt),truncated:false});
|
|
80
86
|
// A stale binding never inherits a late ACK. Durable history still records exactly what happened.
|
|
81
87
|
return signal.aborted||event.deadline<=Date.now()||!same(this.approved(binding),approval)?{status:'unknown'}:receipt;
|
|
82
|
-
}catch{
|
|
88
|
+
}catch(error){
|
|
89
|
+
this.contextError(error);
|
|
83
90
|
try{const r=this.ledger.lookup(context,event.id)!;this.ledger.record(context,event.id,{state:r.attempted?'unknown':'not_sent',detail:'queue_attempt_uncertain_no_replay',result:null,truncated:false});}catch{}
|
|
84
91
|
return {status:'unknown'};
|
|
85
92
|
}
|
|
@@ -93,13 +100,13 @@ export class CodexDesktopQueueHost implements CodexEventHost {
|
|
|
93
100
|
const matches:any[]=[];let cursor:string|null=null;
|
|
94
101
|
for(let page=0;page<4;page++){
|
|
95
102
|
let result:any;
|
|
96
|
-
try{result=await this.wire.request('thread/queue/list',{threadId:binding.threadId,limit:100,cursor},{signal});}catch{return {status:'unknown',reason:'queue_read_unavailable',remote:'not_replayed'};}
|
|
103
|
+
try{result=await this.wire.request('thread/queue/list',{threadId:binding.threadId,limit:100,cursor},{signal,...this.pin(),...(this.bootstrap?{beforeWrite:()=>{if(!this.approved(binding))throw Error('bootstrap_context_changed');}}:{})});}catch(error){this.contextError(error);return {status:'unknown',reason:'queue_read_unavailable',remote:'not_replayed'};}
|
|
97
104
|
if(!Array.isArray(result?.data))return {status:'unknown'};
|
|
98
105
|
for(const item of result.data)if(item.clientUserMessageId===clientUserMessageId)matches.push(item);
|
|
99
106
|
cursor=result.nextCursor??null;if(cursor===null)break;if(typeof cursor!=='string'||page===3)return {status:'unknown',reason:'incomplete_queue_read'};
|
|
100
107
|
}
|
|
101
108
|
if(!same(this.approved(binding),approval))return {status:'stale'};
|
|
102
|
-
if(matches.length===1&&matches[0].input
|
|
109
|
+
if(matches.length===1&&Array.isArray(matches[0].input)&&matches[0].input.length===1&&matches[0].input[0]?.type==='text'&&matches[0].input[0]?.text===text)return {status:'observed_in_queue',submissionId:matches[0].id,modelDelivery:'not_established',remote:'not_replayed'};
|
|
103
110
|
// Empty queue can mean consumed, deleted, changed, or never enqueued: never infer model delivery.
|
|
104
111
|
return {status:matches.length?'conflict':'unknown',modelDelivery:'not_established',remote:'not_replayed'};
|
|
105
112
|
}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import {spawn} from 'node:child_process';
|
|
2
|
+
import {createHash} from 'node:crypto';
|
|
3
|
+
import {constants,type BigIntStats} from 'node:fs';
|
|
4
|
+
import {lstat,mkdir,mkdtemp,open,realpath,rm,stat,type FileHandle} from 'node:fs/promises';
|
|
5
|
+
import {delimiter,dirname,isAbsolute,join} from 'node:path';
|
|
6
|
+
import {tmpdir} from 'node:os';
|
|
7
|
+
import {compareCodexVersions,codexDaemonVersionFromUserAgent} from '../../../harnesses/lib/codex-compat.ts';
|
|
8
|
+
|
|
9
|
+
export class CodexMeasurementError extends Error {
|
|
10
|
+
readonly code: string;
|
|
11
|
+
constructor(code: string) { super(code); this.code = code; }
|
|
12
|
+
}
|
|
13
|
+
function fail(code: string): never { throw new CodexMeasurementError(code); }
|
|
14
|
+
const epoch = (value: unknown): value is string => typeof value === 'string' && value.length > 0 && value.length <= 1024 && !/[\u0000-\u0020\u007f]/.test(value);
|
|
15
|
+
const version = (value: unknown): value is string => typeof value === 'string' && compareCodexVersions(value, value) === 0;
|
|
16
|
+
const sha = (bytes: string | Buffer) => createHash('sha256').update(bytes).digest('hex');
|
|
17
|
+
type Options = {timeoutMs?: number; signal?: AbortSignal};
|
|
18
|
+
function deadline(options: Options, fallback: number) {
|
|
19
|
+
const timeout = options.timeoutMs ?? fallback, signal = options.signal;
|
|
20
|
+
if (!Number.isSafeInteger(timeout) || timeout < 1 || timeout > 30000) fail('invalid_timeout');
|
|
21
|
+
const controller = new AbortController(), expires = performance.now() + timeout; let reason = 'measurement_cancelled';
|
|
22
|
+
const stop = (code: string) => { if (!controller.signal.aborted) { reason = code; controller.abort(); } };
|
|
23
|
+
const abort = () => stop(performance.now() >= expires ? 'measurement_timeout' : 'measurement_cancelled');
|
|
24
|
+
if (signal?.aborted) fail(reason);
|
|
25
|
+
signal?.addEventListener('abort', abort, {once: true});
|
|
26
|
+
const timer = setTimeout(() => stop('measurement_timeout'), timeout);
|
|
27
|
+
// A fulfilled callback/microtask can run before an already-due timer. Never
|
|
28
|
+
// publish an overdue observation merely because that timer has not run yet.
|
|
29
|
+
const check = () => { if (performance.now() >= expires) stop('measurement_timeout'); if (controller.signal.aborted) fail(reason); };
|
|
30
|
+
return {signal: controller.signal, check, error: () => new CodexMeasurementError(reason), close: () => { clearTimeout(timer); signal?.removeEventListener('abort', abort); controller.abort(); }};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface DaemonObservationRpc {
|
|
34
|
+
/** Trusted connect-only provider. Both callbacks must honor abort and clean up
|
|
35
|
+
* their own transport. They must not start/resume/queue/approve anything.
|
|
36
|
+
* Existing CodexUnixQueueRpc is NOT loosened or automatically wired here.
|
|
37
|
+
*/
|
|
38
|
+
socketEpoch(signal: AbortSignal): unknown | Promise<unknown>;
|
|
39
|
+
/** socketEpoch is captured/checked connection metadata, NEVER a server result
|
|
40
|
+
* or an ambient path snapshot. The provider must fence against expectedEpoch.
|
|
41
|
+
*/
|
|
42
|
+
initialize(signal: AbortSignal, expectedEpoch: string): Promise<{result: unknown; socketEpoch: string}>;
|
|
43
|
+
}
|
|
44
|
+
export type DaemonMeasurement = {kind: 'initialize_version_observation'; version: string; socketEpoch: string};
|
|
45
|
+
/** Version claim from the measured UA grammar only; NOT Desktop identity, MCP
|
|
46
|
+
* clientInfo, current consumer presence or persistent approval evidence.
|
|
47
|
+
*/
|
|
48
|
+
export async function measureDaemon(rpc: DaemonObservationRpc, options: Options = {}): Promise<DaemonMeasurement> {
|
|
49
|
+
const scope = deadline(options, 3000);
|
|
50
|
+
const cancelled = new Promise<never>((_, reject) => scope.signal.addEventListener('abort', () => reject(scope.error()), {once: true}));
|
|
51
|
+
const work = async (): Promise<DaemonMeasurement> => {
|
|
52
|
+
scope.check(); const before = await rpc.socketEpoch(scope.signal); scope.check();
|
|
53
|
+
if (!epoch(before)) fail('invalid_socket_epoch');
|
|
54
|
+
const initialized = await rpc.initialize(scope.signal, before); scope.check();
|
|
55
|
+
if (!initialized || typeof initialized !== 'object' || !epoch(initialized.socketEpoch) || initialized.socketEpoch !== before) fail('initialize_epoch_mismatch');
|
|
56
|
+
const observed = initialized.result;
|
|
57
|
+
const ua = observed && typeof observed === 'object' && !Array.isArray(observed) ? (observed as {userAgent?: unknown}).userAgent : undefined;
|
|
58
|
+
// Shared exact measured prefix; no guessed alias or clientInfo/CLI fallback.
|
|
59
|
+
const observedVersion=codexDaemonVersionFromUserAgent(ua);
|
|
60
|
+
if (!observedVersion) fail('daemon_version_unavailable');
|
|
61
|
+
const after = await rpc.socketEpoch(scope.signal); scope.check();
|
|
62
|
+
if (!epoch(after) || before !== after) fail('socket_epoch_changed');
|
|
63
|
+
return {kind: 'initialize_version_observation', version: observedVersion, socketEpoch: before};
|
|
64
|
+
};
|
|
65
|
+
try { return await Promise.race([work(), cancelled]); }
|
|
66
|
+
catch (error) { if (error instanceof CodexMeasurementError) throw error; throw new CodexMeasurementError('daemon_observation_failed'); }
|
|
67
|
+
finally { scope.close(); }
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Revalidate the previously selected CLI bytes/alias identity without running
|
|
71
|
+
* any command. A cached schema snapshot is not permission to trust a changed
|
|
72
|
+
* executable. This remains byte identity, not daemon/Desktop process identity. */
|
|
73
|
+
export async function schemaExportStillCurrent(binary:string,evidence:{binaryEpoch:string;binarySha256:string},options:Options={}){
|
|
74
|
+
const scope=deadline(options,2000);try{if(typeof process.getuid!=='function')return false;scope.check();const current=await binarySnapshot(binary,scope.check,process.getuid());scope.check();return current.epoch===evidence.binaryEpoch&¤t.sha256===evidence.binarySha256;}finally{scope.close();}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const sourceFiles = ['ClientRequest.json','ClientNotification.json','JSONRPCResponse.json','JSONRPCError.json','v1/InitializeResponse.json','v2/ThreadReadResponse.json','v2/ThreadLoadedListResponse.json','v2/ThreadQueueAddResponse.json','v2/ThreadQueueListResponse.json'] as const;
|
|
78
|
+
const maxBinaryBytes = 512 * 1024 * 1024, maxFileBytes = 16 * 1024 * 1024, maxTotalBytes = 32 * 1024 * 1024;
|
|
79
|
+
const stamp = (s: BigIntStats) => [s.dev,s.ino,s.size,s.mode,s.uid,s.gid,s.nlink,s.mtimeNs,s.ctimeNs].map(String).join(':');
|
|
80
|
+
async function binarySnapshot(path: string, check: () => void, owner: number) {
|
|
81
|
+
check(); const alias = await lstat(path, {bigint: true}); const resolved = await realpath(path);
|
|
82
|
+
const uid = BigInt(owner), checked = new Set<string>();
|
|
83
|
+
// A safe file mode alone cannot stop another UID replacing it through a
|
|
84
|
+
// writable ancestor. Execute only through physically trusted parent chains.
|
|
85
|
+
for (const parent of [dirname(resolved), await realpath(dirname(path))]) {
|
|
86
|
+
for (let dir = parent; !checked.has(dir); dir = dirname(dir)) {
|
|
87
|
+
check(); checked.add(dir); const s = await lstat(dir, {bigint: true});
|
|
88
|
+
if (!s.isDirectory() || s.isSymbolicLink() || (s.uid !== uid && s.uid !== 0n) || ((Number(s.mode) & 0o022) !== 0 && (Number(s.mode) & 0o1000) === 0)) fail('unsafe_binary_parent');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const before = await lstat(resolved, {bigint: true});
|
|
92
|
+
if (!before.isFile() || before.isSymbolicLink() || (before.uid !== uid && before.uid !== 0n) || (alias.uid !== uid && alias.uid !== 0n) || (Number(before.mode) & 0o6022) !== 0 || (Number(before.mode) & 0o111) === 0) fail('unsafe_binary');
|
|
93
|
+
if (before.size < 1n || before.size > BigInt(maxBinaryBytes)) fail('binary_limit');
|
|
94
|
+
const handle = await open(resolved, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
95
|
+
const hash = createHash('sha256'); let total = 0;
|
|
96
|
+
try {
|
|
97
|
+
if (stamp(await handle.stat({bigint: true})) !== stamp(before)) fail('binary_changed');
|
|
98
|
+
const buffer = Buffer.alloc(1024 * 1024);
|
|
99
|
+
while (true) { check(); const {bytesRead} = await handle.read(buffer, 0, buffer.length, null); if (!bytesRead) break; total += bytesRead; if (total > maxBinaryBytes) fail('binary_limit'); hash.update(buffer.subarray(0, bytesRead)); }
|
|
100
|
+
if (total !== Number(before.size) || stamp(await handle.stat({bigint: true})) !== stamp(before) || stamp(await stat(resolved, {bigint: true})) !== stamp(before) || stamp(await lstat(path, {bigint: true})) !== stamp(alias) || await realpath(path) !== resolved) fail('binary_changed');
|
|
101
|
+
} finally { await handle.close(); }
|
|
102
|
+
check(); const digest = hash.digest('hex');
|
|
103
|
+
return {path: resolved, sha256: digest, epoch: sha(JSON.stringify([path,resolved,stamp(alias),stamp(before),digest]))};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Fixed local subcommands only. Minimal isolated HOME/CODEX_HOME; no inherited
|
|
107
|
+
* agent grants, auth, NODE_OPTIONS or model/provider configuration. This is not
|
|
108
|
+
* an OS/network sandbox: the explicitly selected executable must be trusted.
|
|
109
|
+
*/
|
|
110
|
+
function command(binary: string, args: string[], cwd: string, env: NodeJS.ProcessEnv, scope: ReturnType<typeof deadline>): Promise<Buffer> {
|
|
111
|
+
scope.check();
|
|
112
|
+
return new Promise((resolve, reject) => {
|
|
113
|
+
let error: CodexMeasurementError | undefined, stdout = 0, stderr = 0;
|
|
114
|
+
const chunks: Buffer[] = [];
|
|
115
|
+
const child = spawn(binary, args, {cwd, env, shell: false, detached: true, windowsHide: true, stdio: ['ignore','pipe','pipe']});
|
|
116
|
+
const kill = () => { if (child.pid) try { process.kill(-child.pid, 'SIGKILL'); } catch { child.kill('SIGKILL'); } };
|
|
117
|
+
const abort = () => { error ??= scope.error(); kill(); };
|
|
118
|
+
scope.signal.addEventListener('abort', abort, {once: true});
|
|
119
|
+
child.on('error', () => { error ??= new CodexMeasurementError('binary_command_failed'); });
|
|
120
|
+
child.stdout.on('data', (data: Buffer) => { stdout += data.length; if (stdout > 16384) { error ??= new CodexMeasurementError('command_output_limit'); kill(); } else chunks.push(data); });
|
|
121
|
+
child.stderr.on('data', (data: Buffer) => { stderr += data.length; if (stderr > 16384) { error ??= new CodexMeasurementError('command_output_limit'); kill(); } });
|
|
122
|
+
child.on('close', code => { scope.signal.removeEventListener('abort', abort); if (error) reject(error); else if (code !== 0) reject(new CodexMeasurementError('binary_command_failed')); else resolve(Buffer.concat(chunks)); });
|
|
123
|
+
if (scope.signal.aborted) abort();
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export type SchemaExportObservation = {
|
|
128
|
+
kind: 'schema_export_observation'; version: string; socketEpoch: string;
|
|
129
|
+
binarySha256: string; binaryEpoch: string;
|
|
130
|
+
documents: Record<string, unknown>; sourceHashes: Record<string, string>;
|
|
131
|
+
};
|
|
132
|
+
/** Offline fixed schema export in an owned 0700 temp root, only after EXACT CLI
|
|
133
|
+
* version match (including build metadata). No install/update/start commands.
|
|
134
|
+
* Returns data after cleanup, never a ready/compatible verdict. Epoch freshness
|
|
135
|
+
* must be rechecked by the future caller; no live RPC adapter is installed here.
|
|
136
|
+
*/
|
|
137
|
+
export async function exportSchema(binary: string, daemon: DaemonMeasurement, options: Options = {}): Promise<SchemaExportObservation> {
|
|
138
|
+
const uid = process.getuid?.();
|
|
139
|
+
if (process.platform === 'win32' || uid === undefined) fail('unsupported_platform');
|
|
140
|
+
if (typeof binary !== 'string' || !isAbsolute(binary) || binary.includes('\0')) fail('invalid_binary_path');
|
|
141
|
+
const observedVersion = daemon?.version, socketEpoch = daemon?.socketEpoch;
|
|
142
|
+
if (daemon?.kind !== 'initialize_version_observation' || !version(observedVersion) || !epoch(socketEpoch)) fail('invalid_daemon_measurement');
|
|
143
|
+
const scope = deadline(options, 30000);
|
|
144
|
+
let root: string | undefined, rootIdentity: string | undefined, rootHandle: FileHandle | undefined;
|
|
145
|
+
let hasResult = false;
|
|
146
|
+
try {
|
|
147
|
+
scope.check();
|
|
148
|
+
const requestedTemp = tmpdir(); if (!isAbsolute(requestedTemp)) fail('unsafe_temp_parent');
|
|
149
|
+
const base = await realpath(requestedTemp), parent = await lstat(base);
|
|
150
|
+
if (!parent.isDirectory() || (parent.uid !== uid && parent.uid !== 0) || ((parent.mode & 0o022) !== 0 && (parent.mode & 0o1000) === 0)) fail('unsafe_temp_parent');
|
|
151
|
+
root = await mkdtemp(join(base, 'fleet-codex-schema-')); rootIdentity = stamp(await lstat(root, {bigint: true}));
|
|
152
|
+
// Pin the directory inode through cleanup: unlink/recreate cannot reuse it and
|
|
153
|
+
// masquerade as our original root while this handle remains open.
|
|
154
|
+
rootHandle = await open(root, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_DIRECTORY);
|
|
155
|
+
if (stamp(await rootHandle.stat({bigint: true})).split(':').slice(0,2).join(':') !== rootIdentity.split(':').slice(0,2).join(':')) fail('unsafe_export_root');
|
|
156
|
+
const home = join(root, 'home'), codexHome = join(root, 'codex-home'), temp = join(root, 'tmp'), output = join(root, 'schema');
|
|
157
|
+
for (const dir of [home,codexHome,temp,output]) await mkdir(dir, {mode: 0o700});
|
|
158
|
+
const env = {PATH: [dirname(process.execPath),'/usr/bin','/bin'].join(delimiter), HOME: home, CODEX_HOME: codexHome, TMPDIR: temp, TMP: temp, TEMP: temp, LANG: 'C.UTF-8', LC_ALL: 'C.UTF-8', TERM: 'dumb', NO_COLOR: '1'};
|
|
159
|
+
const privateRoot = async () => {
|
|
160
|
+
const current = await lstat(root!, {bigint: true});
|
|
161
|
+
if (!current.isDirectory() || current.isSymbolicLink() || current.uid !== BigInt(uid) || (Number(current.mode) & 0o077) !== 0 || stamp(current).split(':').slice(0,2).join(':') !== rootIdentity?.split(':').slice(0,2).join(':')) fail('unsafe_export_root');
|
|
162
|
+
};
|
|
163
|
+
await privateRoot();
|
|
164
|
+
const before = await binarySnapshot(binary, scope.check, uid);
|
|
165
|
+
const rawVersion = new TextDecoder('utf-8', {fatal: true}).decode(await command(before.path, ['--version'], root, env, scope));
|
|
166
|
+
const match = /^codex-cli ([^\r\n ]+)(?:\r?\n)?$/.exec(rawVersion);
|
|
167
|
+
if (!match || !version(match[1]) || match[1] !== observedVersion) fail('export_version_mismatch');
|
|
168
|
+
await privateRoot();
|
|
169
|
+
if ((await binarySnapshot(binary, scope.check, uid)).epoch !== before.epoch) fail('binary_changed');
|
|
170
|
+
await command(before.path, ['app-server','generate-json-schema','--experimental','--out',output], root, env, scope);
|
|
171
|
+
await privateRoot();
|
|
172
|
+
if ((await binarySnapshot(binary, scope.check, uid)).epoch !== before.epoch) fail('binary_changed');
|
|
173
|
+
const documents: Record<string, unknown> = {}, sourceHashes: Record<string, string> = {}; let total = 0;
|
|
174
|
+
for (const file of sourceFiles) {
|
|
175
|
+
scope.check();
|
|
176
|
+
const path = join(output, file);
|
|
177
|
+
for (const dir of file.includes('/') ? [output,dirname(path)] : [output]) { const s = await lstat(dir); if (!s.isDirectory() || s.isSymbolicLink() || s.uid !== uid) fail('unsafe_schema_output'); }
|
|
178
|
+
const entry = await lstat(path, {bigint: true});
|
|
179
|
+
if (!entry.isFile() || entry.isSymbolicLink() || entry.nlink !== 1n) fail('unsafe_schema_output');
|
|
180
|
+
const handle = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
181
|
+
let bytes: Buffer;
|
|
182
|
+
try {
|
|
183
|
+
const initial = await handle.stat({bigint: true});
|
|
184
|
+
if (stamp(initial) !== stamp(entry)) fail('schema_output_changed');
|
|
185
|
+
if (!initial.isFile() || initial.nlink !== 1n || initial.uid !== BigInt(uid)) fail('unsafe_schema_output');
|
|
186
|
+
if (initial.size < 1n || initial.size > BigInt(maxFileBytes) || total + Number(initial.size) > maxTotalBytes) fail('schema_output_limit');
|
|
187
|
+
const buffer = Buffer.alloc(Number(initial.size) + 1); let offset = 0;
|
|
188
|
+
while (offset < buffer.length) { scope.check(); const {bytesRead} = await handle.read(buffer, offset, buffer.length - offset, null); if (!bytesRead) break; offset += bytesRead; }
|
|
189
|
+
bytes = buffer.subarray(0, offset);
|
|
190
|
+
if (bytes.length !== Number(initial.size) || stamp(await handle.stat({bigint: true})) !== stamp(initial)) fail('schema_output_changed');
|
|
191
|
+
} finally { await handle.close(); }
|
|
192
|
+
total += bytes.length;
|
|
193
|
+
let parsed: unknown;
|
|
194
|
+
try { parsed = JSON.parse(new TextDecoder('utf-8', {fatal: true}).decode(bytes)); } catch { fail('invalid_schema_document'); }
|
|
195
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) fail('invalid_schema_document');
|
|
196
|
+
documents[file] = parsed; sourceHashes[file] = sha(bytes);
|
|
197
|
+
}
|
|
198
|
+
scope.check(); hasResult = true;
|
|
199
|
+
return {kind: 'schema_export_observation', version: observedVersion, socketEpoch, binarySha256: before.sha256, binaryEpoch: before.epoch, documents, sourceHashes};
|
|
200
|
+
} catch (error) { if (error instanceof CodexMeasurementError) throw error; if (scope.signal.aborted) throw scope.error(); throw new CodexMeasurementError('schema_export_failed'); }
|
|
201
|
+
finally {
|
|
202
|
+
try {
|
|
203
|
+
try {
|
|
204
|
+
if (root) {
|
|
205
|
+
// Directory timestamps change as children are created; bind only dev+inode.
|
|
206
|
+
try {
|
|
207
|
+
const current = await lstat(root, {bigint: true});
|
|
208
|
+
if (stamp(current).split(':').slice(0,2).join(':') !== rootIdentity?.split(':').slice(0,2).join(':') || !current.isDirectory() || current.isSymbolicLink() || current.uid !== BigInt(uid)) fail('unsafe_export_cleanup');
|
|
209
|
+
await rm(root, {recursive: true, force: false});
|
|
210
|
+
} catch (error) { if (error instanceof CodexMeasurementError) throw error; throw new CodexMeasurementError('schema_export_cleanup_failed'); }
|
|
211
|
+
}
|
|
212
|
+
} finally { if (rootHandle) try { await rootHandle.close(); } catch { fail('schema_export_cleanup_failed'); } }
|
|
213
|
+
// Cleanup is mandatory even after cancellation. A completed observation may
|
|
214
|
+
// leave the helper only if its budget/caller is still live after cleanup.
|
|
215
|
+
if (hasResult) scope.check();
|
|
216
|
+
} finally { scope.close(); }
|
|
217
|
+
}
|
|
218
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {createHash,randomUUID} from 'node:crypto';
|
|
2
|
+
import {opendir,lstat,unlink} from 'node:fs/promises';
|
|
3
|
+
import {join} from 'node:path';
|
|
4
|
+
import {namespaceKey,bootstrapNamespace,type BootstrapPresence} from '../../../harnesses/lib/fleet-bootstrap-channel.ts';
|
|
5
|
+
import type {ConversationKey,TargetEpoch} from './fleet-codex-allowlist.ts';
|
|
6
|
+
import {validInstructionTarget} from '../../../harnesses/lib/fleet-target-identity.ts';
|
|
7
|
+
import {privateDirectory,readPrivateJson,writePrivateJson,privateFileIdentity,canonicalPrivatePath} from './codex-bootstrap-files.ts';
|
|
8
|
+
const TTL=600000,uuid=(v:unknown):v is string=>typeof v==='string'&&/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/.test(v);
|
|
9
|
+
const object=(v:unknown):v is Record<string,any>=>!!v&&typeof v==='object'&&!Array.isArray(v);
|
|
10
|
+
export type NativePresence={schema:'fleet-native-presence/v1';observation:BootstrapPresence;observedAt:number};
|
|
11
|
+
export type NativeAttachRequest={schema:'fleet-native-attach-request/v1';id:string;namespace:ConversationKey;hostInstance:string;owner:TargetEpoch;createdAt:number};
|
|
12
|
+
const hash=(c:ConversationKey)=>createHash('sha256').update(namespaceKey(c)).digest('hex');
|
|
13
|
+
export function validNativeObservation(v:unknown):v is BootstrapPresence{return object(v)&&Object.keys(v).sort().join(',')==='catalog,clientInfo,hostInstance,namespace,protocolVersion'&&bootstrapNamespace(v.namespace)&&uuid(v.hostInstance)&&v.protocolVersion==='2025-06-18'&&(v.clientInfo===null||object(v.clientInfo)&&Object.keys(v.clientInfo).sort().join(',')==='name,version'&&typeof v.clientInfo.name==='string'&&typeof v.clientInfo.version==='string'&&[v.clientInfo.name,v.clientInfo.version].every(x=>x.length>=1&&x.length<=256&&!/[\u0000-\u001f\u007f]/.test(x)))&&Array.isArray(v.catalog)&&v.catalog.length<=128&&Array.from(v.catalog).every(x=>typeof x==='string'&&/^[A-Za-z0-9._-]{1,128}$/.test(x))&&new Set(v.catalog).size===v.catalog.length;}
|
|
14
|
+
/** Private metadata rendezvous, not policy/config/consent. No new listener or
|
|
15
|
+
* broadcast to unrelated AF projects. Native publishes only observed context;
|
|
16
|
+
* AF may ask its exact owner to attach, but only a later Pi-confirmed coordinator
|
|
17
|
+
* command can reach the Codex writer. No directory repair/foreign file cleanup. */
|
|
18
|
+
export class NativePresenceDirectory {
|
|
19
|
+
readonly root:string;readonly #now:()=>number;readonly #issued=new Map<string,{path:string;identity:string}>();
|
|
20
|
+
constructor(root:string,now=Date.now){if(!canonicalPrivatePath(root))throw Error('native_presence_root');this.root=root;this.#now=now;}
|
|
21
|
+
#time(){const now=this.#now();if(!Number.isSafeInteger(now)||now<0)throw Error('native_presence_clock');return now;}
|
|
22
|
+
#path(o:BootstrapPresence){return join(this.root,'presence-'+hash(o.namespace)+'-'+o.hostInstance+'.json');}
|
|
23
|
+
async publish(value:BootstrapPresence,signal?:AbortSignal){
|
|
24
|
+
const seen=structuredClone(value);if(!validNativeObservation(seen))throw Error('native_presence_invalid');const record:NativePresence={schema:'fleet-native-presence/v1',observation:seen,observedAt:this.#time()};
|
|
25
|
+
await writePrivateJson(this.#path(seen),record,{signal,createParent:true});return structuredClone(record);
|
|
26
|
+
}
|
|
27
|
+
async #files(prefix:'presence-'|'request-',signal?:AbortSignal){
|
|
28
|
+
try{await privateDirectory(this.root);}catch(e){if((e as any)?.code==='ENOENT')return [];throw e;}
|
|
29
|
+
const dir=await opendir(this.root),files:{name:string;value:any;identity:string}[]=[];let count=0,total=0;
|
|
30
|
+
try{for await(const entry of dir){if(signal?.aborted)throw Error('native_presence_cancelled');if(++count>128)throw Error('native_presence_limit');if(!entry.name.startsWith(prefix)||!entry.name.endsWith('.json'))continue;
|
|
31
|
+
let at:Awaited<ReturnType<typeof readPrivateJson>>;try{at=await readPrivateJson(join(this.root,entry.name),32768,signal);}catch(e){if(!(e instanceof Error)||e.message!=='bootstrap_file_changed')throw e;at=await readPrivateJson(join(this.root,entry.name),32768,signal);}if(!at)throw Error('native_presence_changed');total+=Buffer.byteLength(JSON.stringify(at.value));if(total>1048576)throw Error('native_presence_limit');files.push({name:entry.name,...at});
|
|
32
|
+
}}finally{try{await dir.close();}catch(e){if((e as any)?.code!=='ERR_DIR_CLOSED')throw e;}}return files;
|
|
33
|
+
}
|
|
34
|
+
async list(signal?:AbortSignal){
|
|
35
|
+
const result:Readonly<NativePresence&{fresh:boolean}>[]=[];const now=this.#time();
|
|
36
|
+
for(const file of await this.#files('presence-',signal)){
|
|
37
|
+
const v=file.value;if(!object(v)||Object.keys(v).sort().join(',')!=='observation,observedAt,schema'||v.schema!=='fleet-native-presence/v1'||!validNativeObservation(v.observation)||!Number.isSafeInteger(v.observedAt)||v.observedAt>now+1000||file.name!=='presence-'+hash(v.observation.namespace)+'-'+v.observation.hostInstance+'.json')throw Error('native_presence_invalid');
|
|
38
|
+
result.push({...structuredClone(v as NativePresence),fresh:now-v.observedAt<TTL});
|
|
39
|
+
}return result;
|
|
40
|
+
}
|
|
41
|
+
async requestAttach(seen:NativePresence,owner:TargetEpoch,signal?:AbortSignal){
|
|
42
|
+
const selected={schema:seen.schema,observation:structuredClone(seen.observation),observedAt:seen.observedAt},target=structuredClone(owner),now=this.#time();if(selected.schema!=='fleet-native-presence/v1'||!validNativeObservation(selected.observation)||!validInstructionTarget(target)||!Number.isSafeInteger(selected.observedAt)||now-selected.observedAt>=TTL||selected.observedAt>now+1000)throw Error('native_presence_stale');
|
|
43
|
+
await privateDirectory(this.root);const current=await readPrivateJson(this.#path(selected.observation),32768,signal);if(!current||current.value?.schema!==selected.schema||JSON.stringify(current.value.observation)!==JSON.stringify(selected.observation)||!Number.isSafeInteger(current.value.observedAt)||current.value.observedAt<selected.observedAt||this.#time()-current.value.observedAt>=TTL||current.value.observedAt>this.#time()+1000)throw Error('native_presence_changed');
|
|
44
|
+
const request:NativeAttachRequest={schema:'fleet-native-attach-request/v1',id:randomUUID(),namespace:selected.observation.namespace,hostInstance:selected.observation.hostInstance,owner:target,createdAt:this.#time()};
|
|
45
|
+
const path=join(this.root,'request-'+request.id+'.json');if(this.#issued.size>=32)throw Error('native_presence_request_capacity');const identity=await writePrivateJson(path,request,{signal,expected:null});this.#issued.set(request.id,{path,identity});return request.id;
|
|
46
|
+
}
|
|
47
|
+
async requests(hostInstance:string,signal?:AbortSignal){
|
|
48
|
+
const result:{request:NativeAttachRequest;path:string;identity:string}[]=[];const now=this.#time();
|
|
49
|
+
for(const file of await this.#files('request-',signal)){
|
|
50
|
+
const v=file.value;if(!object(v)||Object.keys(v).sort().join(',')!=='createdAt,hostInstance,id,namespace,owner,schema'||v.schema!=='fleet-native-attach-request/v1'||!uuid(v.id)||!uuid(v.hostInstance)||!bootstrapNamespace(v.namespace)||!validInstructionTarget(v.owner)||!Number.isSafeInteger(v.createdAt)||v.createdAt>now+1000||file.name!=='request-'+v.id+'.json')throw Error('native_presence_request_invalid');
|
|
51
|
+
if(now-v.createdAt>=5000){await this.consume(join(this.root,file.name),file.identity).catch(()=>{});continue;}
|
|
52
|
+
if(v.hostInstance===hostInstance)result.push({request:structuredClone(v as NativeAttachRequest),path:join(this.root,file.name),identity:file.identity});
|
|
53
|
+
}return result;
|
|
54
|
+
}
|
|
55
|
+
async consume(path:string,expected:string){
|
|
56
|
+
if(!path.startsWith(this.root+'/')||!/^request-[a-f0-9-]{36}\.json$/.test(path.slice(this.root.length+1)))throw Error('native_presence_path');
|
|
57
|
+
const current=await lstat(path);if(privateFileIdentity(current)!==expected)throw Error('native_presence_changed');await unlink(path);
|
|
58
|
+
}
|
|
59
|
+
async cancelAttach(id:string){const issued=this.#issued.get(id);if(!issued)return;this.#issued.delete(id);try{await this.consume(issued.path,issued.identity);}catch(e){if((e as any)?.code!=='ENOENT')throw e;}}
|
|
60
|
+
async remove(observed:BootstrapPresence){const path=this.#path(observed),old=await readPrivateJson(path);if(!old)return;if(old.value?.observation?.hostInstance!==observed.hostInstance)throw Error('native_presence_changed');const at=await lstat(path);if(privateFileIdentity(at)!==old.identity)throw Error('native_presence_changed');await unlink(path);}
|
|
61
|
+
}
|