@openrig/cli 0.7.7 → 0.7.8
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/README.md +5 -5
- package/daemon/assets/openshell/Dockerfile +15 -0
- package/daemon/assets/openshell/README.md +137 -0
- package/daemon/assets/openshell/agents/coordinator/agent.yaml +20 -0
- package/daemon/assets/openshell/agents/coordinator/role.md +1 -0
- package/daemon/assets/openshell/agents/worker/agent.yaml +20 -0
- package/daemon/assets/openshell/agents/worker/role.md +3 -0
- package/daemon/assets/openshell/claude-code-provider.yaml +55 -0
- package/daemon/assets/openshell/driver-v1.schema.json +81 -0
- package/daemon/assets/openshell/guest.py +306 -0
- package/daemon/assets/openshell/policy.yaml +33 -0
- package/daemon/assets/openshell/preset.yaml +12 -0
- package/daemon/assets/openshell/rig.yaml +20 -0
- package/daemon/assets/plugins/openrig-core/.claude-plugin/plugin.json +1 -1
- package/daemon/assets/plugins/openrig-core/.codex-plugin/plugin.json +1 -1
- package/daemon/assets/plugins/openrig-core/skills/seat-continuity-and-handover/SKILL.md +1 -1
- package/daemon/context-packs/help/manifest.yaml +1 -1
- package/daemon/context-packs/onboarding-width/manifest.yaml +1 -1
- package/daemon/context-packs/onboarding-width/public-what-you-can-do.md +16 -6
- package/daemon/context-packs/reference/getting-started.md +8 -3
- package/daemon/context-packs/reference/manifest.yaml +1 -1
- package/daemon/context-packs/reference/rig-spec.md +69 -12
- package/daemon/context-packs/reference/whats-new.md +119 -15
- package/daemon/context-packs/skills/agent-operated-software/manifest.yaml +1 -1
- package/daemon/context-packs/skills/agent-operated-workflows/manifest.yaml +1 -1
- package/daemon/context-packs/skills/applying-a-permission-policy/manifest.yaml +1 -1
- package/daemon/context-packs/skills/claude-compaction-restore/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/agent-starters/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/agent-startup-and-context-ingestion/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/cross-host-rig-commands/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/human-in-the-loop/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/messaging-the-human/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/openrig-architect/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/openrig-cmux/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/openrig-herdr/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/openrig-skills/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/openrig-software-factory/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/openrig-upgrade/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/rig-bundles-and-shareable-artifacts/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/rig-lifecycle/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/session-source-fork/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/specification-system/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/topology-mutation-and-seat-management/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/watchdog/manifest.yaml +1 -1
- package/daemon/context-packs/skills/delegating-work/manifest.yaml +1 -1
- package/daemon/context-packs/skills/forming-an-openrig-mental-model/manifest.yaml +1 -1
- package/daemon/context-packs/skills/loading-addressable-markdown/manifest.yaml +1 -1
- package/daemon/context-packs/skills/mission-slice-sop/manifest.yaml +1 -1
- package/daemon/context-packs/skills/openrig-operating-model/manifest.yaml +1 -1
- package/daemon/context-packs/skills/openrig-user/manifest.yaml +1 -1
- package/daemon/context-packs/skills/orienting-to-an-inherited-seat/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/backlog-capture/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/context-builder/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/exec-summary/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/office-hours/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/plan-review/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/requirements-writer/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/ui-mockup/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pods/development-team/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pods/orchestration-team/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pods/oversight-team/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pods/review-team/manifest.yaml +1 -1
- package/daemon/context-packs/skills/process/agent-browser/manifest.yaml +1 -1
- package/daemon/context-packs/skills/process/context-engineering/manifest.yaml +1 -1
- package/daemon/context-packs/skills/process/dogfood/manifest.yaml +1 -1
- package/daemon/context-packs/skills/process/frontend-design/manifest.yaml +1 -1
- package/daemon/context-packs/skills/process/systematic-debugging/manifest.yaml +1 -1
- package/daemon/context-packs/skills/process/test-driven-development/manifest.yaml +1 -1
- package/daemon/context-packs/skills/process/verification-before-completion/manifest.yaml +1 -1
- package/daemon/context-packs/skills/queue-handoff/manifest.yaml +1 -1
- package/daemon/context-packs/skills/refocusing/manifest.yaml +1 -1
- package/daemon/context-packs/skills/retiring-and-inheriting-a-seat/manifest.yaml +1 -1
- package/daemon/context-packs/skills/seat-continuity-and-handover/SKILL.md +1 -1
- package/daemon/context-packs/skills/seat-continuity-and-handover/manifest.yaml +1 -1
- package/daemon/context-packs/skills/session-compaction-and-restore/manifest.yaml +1 -1
- package/daemon/context-packs/skills/software-for-agents/manifest.yaml +1 -1
- package/daemon/context-packs/world-example/manifest.yaml +1 -1
- package/daemon/context-packs/world-public/manifest.yaml +1 -1
- package/daemon/dist/adapters/claude-code-adapter.d.ts.map +1 -1
- package/daemon/dist/adapters/claude-code-adapter.js +37 -6
- package/daemon/dist/adapters/claude-code-adapter.js.map +1 -1
- package/daemon/dist/adapters/claude-resume.d.ts +2 -1
- package/daemon/dist/adapters/claude-resume.d.ts.map +1 -1
- package/daemon/dist/adapters/claude-resume.js +6 -3
- package/daemon/dist/adapters/claude-resume.js.map +1 -1
- package/daemon/dist/adapters/codex-runtime-adapter.d.ts +4 -7
- package/daemon/dist/adapters/codex-runtime-adapter.d.ts.map +1 -1
- package/daemon/dist/adapters/codex-runtime-adapter.js +86 -33
- package/daemon/dist/adapters/codex-runtime-adapter.js.map +1 -1
- package/daemon/dist/adapters/community-harness-runtime-adapter.d.ts +13 -1
- package/daemon/dist/adapters/community-harness-runtime-adapter.d.ts.map +1 -1
- package/daemon/dist/adapters/community-harness-runtime-adapter.js +28 -1
- package/daemon/dist/adapters/community-harness-runtime-adapter.js.map +1 -1
- package/daemon/dist/adapters/openshell-driver.d.ts +39 -0
- package/daemon/dist/adapters/openshell-driver.d.ts.map +1 -0
- package/daemon/dist/adapters/openshell-driver.js +139 -0
- package/daemon/dist/adapters/openshell-driver.js.map +1 -0
- package/daemon/dist/adapters/openshell-podman-observer.d.ts +30 -0
- package/daemon/dist/adapters/openshell-podman-observer.d.ts.map +1 -0
- package/daemon/dist/adapters/openshell-podman-observer.js +94 -0
- package/daemon/dist/adapters/openshell-podman-observer.js.map +1 -0
- package/daemon/dist/adapters/pi-openrouter-charge.d.ts +1 -0
- package/daemon/dist/adapters/pi-openrouter-charge.d.ts.map +1 -1
- package/daemon/dist/adapters/pi-openrouter-charge.js +17 -3
- package/daemon/dist/adapters/pi-openrouter-charge.js.map +1 -1
- package/daemon/dist/adapters/tmux-control.d.ts +12 -6
- package/daemon/dist/adapters/tmux-control.d.ts.map +1 -1
- package/daemon/dist/adapters/tmux-control.js +42 -21
- package/daemon/dist/adapters/tmux-control.js.map +1 -1
- package/daemon/dist/adapters/tmux-server.d.ts +6 -3
- package/daemon/dist/adapters/tmux-server.d.ts.map +1 -1
- package/daemon/dist/adapters/tmux-server.js +13 -8
- package/daemon/dist/adapters/tmux-server.js.map +1 -1
- package/daemon/dist/adapters/tmux.d.ts +8 -2
- package/daemon/dist/adapters/tmux.d.ts.map +1 -1
- package/daemon/dist/adapters/tmux.js +38 -11
- package/daemon/dist/adapters/tmux.js.map +1 -1
- package/daemon/dist/build-info.js +3 -3
- package/daemon/dist/db/all-migrations.d.ts.map +1 -1
- package/daemon/dist/db/all-migrations.js +8 -0
- package/daemon/dist/db/all-migrations.js.map +1 -1
- package/daemon/dist/db/migrations/142_node_claude_mcp.d.ts +3 -0
- package/daemon/dist/db/migrations/142_node_claude_mcp.d.ts.map +1 -0
- package/daemon/dist/db/migrations/142_node_claude_mcp.js +5 -0
- package/daemon/dist/db/migrations/142_node_claude_mcp.js.map +1 -0
- package/daemon/dist/db/migrations/143_activity_grants.d.ts +8 -0
- package/daemon/dist/db/migrations/143_activity_grants.d.ts.map +1 -0
- package/daemon/dist/db/migrations/143_activity_grants.js +22 -0
- package/daemon/dist/db/migrations/143_activity_grants.js.map +1 -0
- package/daemon/dist/db/migrations/144_environment_bindings.d.ts +4 -0
- package/daemon/dist/db/migrations/144_environment_bindings.d.ts.map +1 -0
- package/daemon/dist/db/migrations/144_environment_bindings.js +31 -0
- package/daemon/dist/db/migrations/144_environment_bindings.js.map +1 -0
- package/daemon/dist/db/migrations/145_node_permissions_to.d.ts +5 -0
- package/daemon/dist/db/migrations/145_node_permissions_to.d.ts.map +1 -0
- package/daemon/dist/db/migrations/145_node_permissions_to.js +7 -0
- package/daemon/dist/db/migrations/145_node_permissions_to.js.map +1 -0
- package/daemon/dist/domain/active-occupant.d.ts +2 -0
- package/daemon/dist/domain/active-occupant.d.ts.map +1 -1
- package/daemon/dist/domain/active-occupant.js +9 -1
- package/daemon/dist/domain/active-occupant.js.map +1 -1
- package/daemon/dist/domain/activity-grants.d.ts +63 -0
- package/daemon/dist/domain/activity-grants.d.ts.map +1 -0
- package/daemon/dist/domain/activity-grants.js +106 -0
- package/daemon/dist/domain/activity-grants.js.map +1 -0
- package/daemon/dist/domain/agent-images/agent-image-library-service.d.ts.map +1 -1
- package/daemon/dist/domain/agent-images/agent-image-library-service.js +5 -2
- package/daemon/dist/domain/agent-images/agent-image-library-service.js.map +1 -1
- package/daemon/dist/domain/claude-compaction-enforcer.d.ts +11 -4
- package/daemon/dist/domain/claude-compaction-enforcer.d.ts.map +1 -1
- package/daemon/dist/domain/claude-compaction-enforcer.js +34 -10
- package/daemon/dist/domain/claude-compaction-enforcer.js.map +1 -1
- package/daemon/dist/domain/claude-mcp.d.ts +10 -0
- package/daemon/dist/domain/claude-mcp.d.ts.map +1 -0
- package/daemon/dist/domain/claude-mcp.js +19 -0
- package/daemon/dist/domain/claude-mcp.js.map +1 -0
- package/daemon/dist/domain/codex-owned-plugin-trust.d.ts.map +1 -1
- package/daemon/dist/domain/codex-owned-plugin-trust.js +2 -1
- package/daemon/dist/domain/codex-owned-plugin-trust.js.map +1 -1
- package/daemon/dist/domain/community-harness-presets.d.ts +2 -1
- package/daemon/dist/domain/community-harness-presets.d.ts.map +1 -1
- package/daemon/dist/domain/community-harness-presets.js +3 -2
- package/daemon/dist/domain/community-harness-presets.js.map +1 -1
- package/daemon/dist/domain/context-monitor.d.ts +2 -2
- package/daemon/dist/domain/context-monitor.d.ts.map +1 -1
- package/daemon/dist/domain/context-monitor.js +8 -2
- package/daemon/dist/domain/context-monitor.js.map +1 -1
- package/daemon/dist/domain/desired-claude-activity-hooks.d.ts +21 -0
- package/daemon/dist/domain/desired-claude-activity-hooks.d.ts.map +1 -0
- package/daemon/dist/domain/desired-claude-activity-hooks.js +30 -0
- package/daemon/dist/domain/desired-claude-activity-hooks.js.map +1 -0
- package/daemon/dist/domain/draft-aware-delivery.d.ts.map +1 -1
- package/daemon/dist/domain/draft-aware-delivery.js +6 -2
- package/daemon/dist/domain/draft-aware-delivery.js.map +1 -1
- package/daemon/dist/domain/environment-artifacts.d.ts +49 -0
- package/daemon/dist/domain/environment-artifacts.d.ts.map +1 -0
- package/daemon/dist/domain/environment-artifacts.js +158 -0
- package/daemon/dist/domain/environment-artifacts.js.map +1 -0
- package/daemon/dist/domain/environment-lifecycle.d.ts +119 -0
- package/daemon/dist/domain/environment-lifecycle.d.ts.map +1 -0
- package/daemon/dist/domain/environment-lifecycle.js +461 -0
- package/daemon/dist/domain/environment-lifecycle.js.map +1 -0
- package/daemon/dist/domain/environment-platform.d.ts +121 -0
- package/daemon/dist/domain/environment-platform.d.ts.map +1 -0
- package/daemon/dist/domain/environment-platform.js +280 -0
- package/daemon/dist/domain/environment-platform.js.map +1 -0
- package/daemon/dist/domain/environment-startup.d.ts +41 -0
- package/daemon/dist/domain/environment-startup.d.ts.map +1 -0
- package/daemon/dist/domain/environment-startup.js +281 -0
- package/daemon/dist/domain/environment-startup.js.map +1 -0
- package/daemon/dist/domain/expected-conversation.d.ts +20 -0
- package/daemon/dist/domain/expected-conversation.d.ts.map +1 -0
- package/daemon/dist/domain/expected-conversation.js +101 -0
- package/daemon/dist/domain/expected-conversation.js.map +1 -0
- package/daemon/dist/domain/gateway/operator-delivery-engine.d.ts +8 -1
- package/daemon/dist/domain/gateway/operator-delivery-engine.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/operator-delivery-engine.js +61 -4
- package/daemon/dist/domain/gateway/operator-delivery-engine.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/inbound.d.ts +2 -0
- package/daemon/dist/domain/gateway/slack/inbound.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/inbound.js +40 -8
- package/daemon/dist/domain/gateway/slack/inbound.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/message.d.ts +16 -0
- package/daemon/dist/domain/gateway/slack/message.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/message.js +216 -7
- package/daemon/dist/domain/gateway/slack/message.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/queue-access.d.ts +14 -0
- package/daemon/dist/domain/gateway/slack/queue-access.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/queue-access.js +9 -1
- package/daemon/dist/domain/gateway/slack/queue-access.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/slack-delivery.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/slack-delivery.js +9 -4
- package/daemon/dist/domain/gateway/slack/slack-delivery.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/slack-subsystem.d.ts +2 -0
- package/daemon/dist/domain/gateway/slack/slack-subsystem.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/slack-subsystem.js +6 -1
- package/daemon/dist/domain/gateway/slack/slack-subsystem.js.map +1 -1
- package/daemon/dist/domain/hosts/hosts-registry-writer.d.ts +22 -0
- package/daemon/dist/domain/hosts/hosts-registry-writer.d.ts.map +1 -1
- package/daemon/dist/domain/hosts/hosts-registry-writer.js +116 -0
- package/daemon/dist/domain/hosts/hosts-registry-writer.js.map +1 -1
- package/daemon/dist/domain/kernel-hook-review.d.ts +16 -0
- package/daemon/dist/domain/kernel-hook-review.d.ts.map +1 -0
- package/daemon/dist/domain/kernel-hook-review.js +49 -0
- package/daemon/dist/domain/kernel-hook-review.js.map +1 -0
- package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts +3 -0
- package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts.map +1 -1
- package/daemon/dist/domain/mission-control/mission-control-write-contract.js +20 -5
- package/daemon/dist/domain/mission-control/mission-control-write-contract.js.map +1 -1
- package/daemon/dist/domain/model-divergence/current-generation-record.d.ts.map +1 -1
- package/daemon/dist/domain/model-divergence/current-generation-record.js +10 -6
- package/daemon/dist/domain/model-divergence/current-generation-record.js.map +1 -1
- package/daemon/dist/domain/native-process-lineage.d.ts +3 -0
- package/daemon/dist/domain/native-process-lineage.d.ts.map +1 -1
- package/daemon/dist/domain/native-process-lineage.js +34 -1
- package/daemon/dist/domain/native-process-lineage.js.map +1 -1
- package/daemon/dist/domain/native-resume-probe.d.ts +2 -1
- package/daemon/dist/domain/native-resume-probe.d.ts.map +1 -1
- package/daemon/dist/domain/native-resume-probe.js +4 -2
- package/daemon/dist/domain/native-resume-probe.js.map +1 -1
- package/daemon/dist/domain/node-inventory.d.ts.map +1 -1
- package/daemon/dist/domain/node-inventory.js +18 -8
- package/daemon/dist/domain/node-inventory.js.map +1 -1
- package/daemon/dist/domain/node-launcher.d.ts +3 -0
- package/daemon/dist/domain/node-launcher.d.ts.map +1 -1
- package/daemon/dist/domain/node-launcher.js +6 -0
- package/daemon/dist/domain/node-launcher.js.map +1 -1
- package/daemon/dist/domain/outbox-handler.d.ts +12 -0
- package/daemon/dist/domain/outbox-handler.d.ts.map +1 -1
- package/daemon/dist/domain/outbox-handler.js +32 -3
- package/daemon/dist/domain/outbox-handler.js.map +1 -1
- package/daemon/dist/domain/policies/parked-owner-consumer.d.ts +10 -0
- package/daemon/dist/domain/policies/parked-owner-consumer.d.ts.map +1 -1
- package/daemon/dist/domain/policies/parked-owner-consumer.js +60 -4
- package/daemon/dist/domain/policies/parked-owner-consumer.js.map +1 -1
- package/daemon/dist/domain/provider/claude-seat-switch.d.ts +9 -3
- package/daemon/dist/domain/provider/claude-seat-switch.d.ts.map +1 -1
- package/daemon/dist/domain/provider/claude-seat-switch.js +100 -17
- package/daemon/dist/domain/provider/claude-seat-switch.js.map +1 -1
- package/daemon/dist/domain/provider/provider-service-impl.js +1 -1
- package/daemon/dist/domain/provider/provider-service-impl.js.map +1 -1
- package/daemon/dist/domain/provider/provider-service.d.ts +32 -2
- package/daemon/dist/domain/provider/provider-service.d.ts.map +1 -1
- package/daemon/dist/domain/provider/provider-types.d.ts +1 -1
- package/daemon/dist/domain/provider/provider-types.d.ts.map +1 -1
- package/daemon/dist/domain/queue-repository.d.ts +36 -5
- package/daemon/dist/domain/queue-repository.d.ts.map +1 -1
- package/daemon/dist/domain/queue-repository.js +155 -37
- package/daemon/dist/domain/queue-repository.js.map +1 -1
- package/daemon/dist/domain/queue-stuck-sweep.d.ts +1 -1
- package/daemon/dist/domain/queue-stuck-sweep.d.ts.map +1 -1
- package/daemon/dist/domain/queue-stuck-sweep.js +31 -0
- package/daemon/dist/domain/queue-stuck-sweep.js.map +1 -1
- package/daemon/dist/domain/queue-wake-ladder.d.ts +3 -0
- package/daemon/dist/domain/queue-wake-ladder.d.ts.map +1 -1
- package/daemon/dist/domain/queue-wake-ladder.js +124 -25
- package/daemon/dist/domain/queue-wake-ladder.js.map +1 -1
- package/daemon/dist/domain/restore-check-service.d.ts +2 -7
- package/daemon/dist/domain/restore-check-service.d.ts.map +1 -1
- package/daemon/dist/domain/restore-check-service.js.map +1 -1
- package/daemon/dist/domain/restore-orchestrator.d.ts +35 -3
- package/daemon/dist/domain/restore-orchestrator.d.ts.map +1 -1
- package/daemon/dist/domain/restore-orchestrator.js +166 -21
- package/daemon/dist/domain/restore-orchestrator.js.map +1 -1
- package/daemon/dist/domain/resume-metadata-refresher.d.ts +2 -1
- package/daemon/dist/domain/resume-metadata-refresher.d.ts.map +1 -1
- package/daemon/dist/domain/resume-metadata-refresher.js +20 -6
- package/daemon/dist/domain/resume-metadata-refresher.js.map +1 -1
- package/daemon/dist/domain/rig-expansion-service.js +1 -1
- package/daemon/dist/domain/rig-expansion-service.js.map +1 -1
- package/daemon/dist/domain/rig-repository.d.ts +10 -0
- package/daemon/dist/domain/rig-repository.d.ts.map +1 -1
- package/daemon/dist/domain/rig-repository.js +37 -0
- package/daemon/dist/domain/rig-repository.js.map +1 -1
- package/daemon/dist/domain/rigspec-codec.d.ts.map +1 -1
- package/daemon/dist/domain/rigspec-codec.js +4 -0
- package/daemon/dist/domain/rigspec-codec.js.map +1 -1
- package/daemon/dist/domain/rigspec-exporter.d.ts +8 -0
- package/daemon/dist/domain/rigspec-exporter.d.ts.map +1 -1
- package/daemon/dist/domain/rigspec-exporter.js +60 -2
- package/daemon/dist/domain/rigspec-exporter.js.map +1 -1
- package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
- package/daemon/dist/domain/rigspec-instantiator.js +19 -4
- package/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
- package/daemon/dist/domain/rigspec-schema.d.ts.map +1 -1
- package/daemon/dist/domain/rigspec-schema.js +24 -1
- package/daemon/dist/domain/rigspec-schema.js.map +1 -1
- package/daemon/dist/domain/runner-permissions.d.ts +135 -0
- package/daemon/dist/domain/runner-permissions.d.ts.map +1 -0
- package/daemon/dist/domain/runner-permissions.js +318 -0
- package/daemon/dist/domain/runner-permissions.js.map +1 -0
- package/daemon/dist/domain/runtime-adapter.d.ts +10 -0
- package/daemon/dist/domain/runtime-adapter.d.ts.map +1 -1
- package/daemon/dist/domain/runtime-adapter.js.map +1 -1
- package/daemon/dist/domain/seat-effort.d.ts +6 -0
- package/daemon/dist/domain/seat-effort.d.ts.map +1 -1
- package/daemon/dist/domain/seat-effort.js +0 -2
- package/daemon/dist/domain/seat-effort.js.map +1 -1
- package/daemon/dist/domain/seat-handover-planner.js +1 -1
- package/daemon/dist/domain/seat-handover-planner.js.map +1 -1
- package/daemon/dist/domain/seat-handover-service.d.ts +2 -0
- package/daemon/dist/domain/seat-handover-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-handover-service.js +45 -28
- package/daemon/dist/domain/seat-handover-service.js.map +1 -1
- package/daemon/dist/domain/seat-lifecycle-service.d.ts +24 -2
- package/daemon/dist/domain/seat-lifecycle-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-lifecycle-service.js +62 -1
- package/daemon/dist/domain/seat-lifecycle-service.js.map +1 -1
- package/daemon/dist/domain/seat-restart-in-place.d.ts.map +1 -1
- package/daemon/dist/domain/seat-restart-in-place.js +6 -1
- package/daemon/dist/domain/seat-restart-in-place.js.map +1 -1
- package/daemon/dist/domain/seat-runtime-switch-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-runtime-switch-service.js +4 -0
- package/daemon/dist/domain/seat-runtime-switch-service.js.map +1 -1
- package/daemon/dist/domain/seat-skill-storage.d.ts +6 -4
- package/daemon/dist/domain/seat-skill-storage.d.ts.map +1 -1
- package/daemon/dist/domain/seat-skill-storage.js +25 -5
- package/daemon/dist/domain/seat-skill-storage.js.map +1 -1
- package/daemon/dist/domain/seat-status-service.d.ts +5 -0
- package/daemon/dist/domain/seat-status-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-status-service.js +9 -0
- package/daemon/dist/domain/seat-status-service.js.map +1 -1
- package/daemon/dist/domain/self-attach-service.d.ts +8 -1
- package/daemon/dist/domain/self-attach-service.d.ts.map +1 -1
- package/daemon/dist/domain/self-attach-service.js +26 -0
- package/daemon/dist/domain/self-attach-service.js.map +1 -1
- package/daemon/dist/domain/session-transport.d.ts +10 -0
- package/daemon/dist/domain/session-transport.d.ts.map +1 -1
- package/daemon/dist/domain/session-transport.js +112 -10
- package/daemon/dist/domain/session-transport.js.map +1 -1
- package/daemon/dist/domain/snapshot-capture.d.ts.map +1 -1
- package/daemon/dist/domain/snapshot-capture.js +14 -0
- package/daemon/dist/domain/snapshot-capture.js.map +1 -1
- package/daemon/dist/domain/startup-orchestrator.d.ts.map +1 -1
- package/daemon/dist/domain/startup-orchestrator.js +32 -1
- package/daemon/dist/domain/startup-orchestrator.js.map +1 -1
- package/daemon/dist/domain/successor-session-launcher.d.ts +1 -0
- package/daemon/dist/domain/successor-session-launcher.d.ts.map +1 -1
- package/daemon/dist/domain/successor-session-launcher.js +1 -0
- package/daemon/dist/domain/successor-session-launcher.js.map +1 -1
- package/daemon/dist/domain/terminal/herdr-follow-view.d.ts.map +1 -1
- package/daemon/dist/domain/terminal/herdr-follow-view.js +22 -4
- package/daemon/dist/domain/terminal/herdr-follow-view.js.map +1 -1
- package/daemon/dist/domain/terminal/scope-task-terminal-view.d.ts +12 -1
- package/daemon/dist/domain/terminal/scope-task-terminal-view.d.ts.map +1 -1
- package/daemon/dist/domain/terminal/scope-task-terminal-view.js +120 -18
- package/daemon/dist/domain/terminal/scope-task-terminal-view.js.map +1 -1
- package/daemon/dist/domain/terminal/terminal-following.js +1 -1
- package/daemon/dist/domain/terminal/terminal-following.js.map +1 -1
- package/daemon/dist/domain/terminal/terminal-provider.d.ts +2 -0
- package/daemon/dist/domain/terminal/terminal-provider.d.ts.map +1 -1
- package/daemon/dist/domain/terminal/terminal-service.d.ts +3 -2
- package/daemon/dist/domain/terminal/terminal-service.d.ts.map +1 -1
- package/daemon/dist/domain/terminal/terminal-service.js +18 -27
- package/daemon/dist/domain/terminal/terminal-service.js.map +1 -1
- package/daemon/dist/domain/terminal/view-composer.d.ts +6 -3
- package/daemon/dist/domain/terminal/view-composer.d.ts.map +1 -1
- package/daemon/dist/domain/terminal/view-composer.js +15 -5
- package/daemon/dist/domain/terminal/view-composer.js.map +1 -1
- package/daemon/dist/domain/tmux-server-selection.d.ts +47 -0
- package/daemon/dist/domain/tmux-server-selection.d.ts.map +1 -0
- package/daemon/dist/domain/tmux-server-selection.js +220 -0
- package/daemon/dist/domain/tmux-server-selection.js.map +1 -0
- package/daemon/dist/domain/transcript-store.d.ts.map +1 -1
- package/daemon/dist/domain/transcript-store.js +8 -5
- package/daemon/dist/domain/transcript-store.js.map +1 -1
- package/daemon/dist/domain/types.d.ts +38 -0
- package/daemon/dist/domain/types.d.ts.map +1 -1
- package/daemon/dist/domain/types.js.map +1 -1
- package/daemon/dist/domain/user-settings/settings-browser.d.ts.map +1 -1
- package/daemon/dist/domain/user-settings/settings-browser.js +3 -1
- package/daemon/dist/domain/user-settings/settings-browser.js.map +1 -1
- package/daemon/dist/domain/user-settings/settings-store.d.ts +1 -1
- package/daemon/dist/domain/user-settings/settings-store.d.ts.map +1 -1
- package/daemon/dist/domain/user-settings/settings-store.js +9 -0
- package/daemon/dist/domain/user-settings/settings-store.js.map +1 -1
- package/daemon/dist/domain/watchdog-delivery.d.ts +1 -0
- package/daemon/dist/domain/watchdog-delivery.d.ts.map +1 -1
- package/daemon/dist/domain/watchdog-delivery.js +15 -3
- package/daemon/dist/domain/watchdog-delivery.js.map +1 -1
- package/daemon/dist/domain/watchdog-policy-engine.d.ts +2 -0
- package/daemon/dist/domain/watchdog-policy-engine.d.ts.map +1 -1
- package/daemon/dist/domain/watchdog-policy-engine.js +3 -1
- package/daemon/dist/domain/watchdog-policy-engine.js.map +1 -1
- package/daemon/dist/domain/workflow-runtime.d.ts +1 -1
- package/daemon/dist/index.d.ts +4 -0
- package/daemon/dist/index.d.ts.map +1 -1
- package/daemon/dist/index.js +14 -0
- package/daemon/dist/index.js.map +1 -1
- package/daemon/dist/routes/activity.d.ts +4 -0
- package/daemon/dist/routes/activity.d.ts.map +1 -1
- package/daemon/dist/routes/activity.js +258 -18
- package/daemon/dist/routes/activity.js.map +1 -1
- package/daemon/dist/routes/compaction.js +4 -2
- package/daemon/dist/routes/compaction.js.map +1 -1
- package/daemon/dist/routes/environments.d.ts +3 -0
- package/daemon/dist/routes/environments.d.ts.map +1 -0
- package/daemon/dist/routes/environments.js +104 -0
- package/daemon/dist/routes/environments.js.map +1 -0
- package/daemon/dist/routes/hosts.d.ts.map +1 -1
- package/daemon/dist/routes/hosts.js +80 -4
- package/daemon/dist/routes/hosts.js.map +1 -1
- package/daemon/dist/routes/provider.d.ts.map +1 -1
- package/daemon/dist/routes/provider.js +53 -7
- package/daemon/dist/routes/provider.js.map +1 -1
- package/daemon/dist/routes/restore-check.d.ts.map +1 -1
- package/daemon/dist/routes/restore-check.js +5 -19
- package/daemon/dist/routes/restore-check.js.map +1 -1
- package/daemon/dist/routes/rigs.js +3 -0
- package/daemon/dist/routes/rigs.js.map +1 -1
- package/daemon/dist/routes/rigspec.d.ts.map +1 -1
- package/daemon/dist/routes/rigspec.js +8 -3
- package/daemon/dist/routes/rigspec.js.map +1 -1
- package/daemon/dist/routes/seat.d.ts.map +1 -1
- package/daemon/dist/routes/seat.js +29 -2
- package/daemon/dist/routes/seat.js.map +1 -1
- package/daemon/dist/routes/sessions.d.ts.map +1 -1
- package/daemon/dist/routes/sessions.js +66 -20
- package/daemon/dist/routes/sessions.js.map +1 -1
- package/daemon/dist/routes/transport.d.ts.map +1 -1
- package/daemon/dist/routes/transport.js +23 -2
- package/daemon/dist/routes/transport.js.map +1 -1
- package/daemon/dist/server.d.ts +6 -0
- package/daemon/dist/server.d.ts.map +1 -1
- package/daemon/dist/server.js +56 -1
- package/daemon/dist/server.js.map +1 -1
- package/daemon/dist/startup.d.ts +2 -0
- package/daemon/dist/startup.d.ts.map +1 -1
- package/daemon/dist/startup.js +61 -26
- package/daemon/dist/startup.js.map +1 -1
- package/daemon/docs/reference/agent-startup-guide.md +4 -0
- package/daemon/docs/reference/author-contracts.md +6 -6
- package/daemon/docs/reference/community-harness-examples/dsh/README.md +71 -0
- package/daemon/docs/reference/community-harness-examples/dsh/dsh.yaml +20 -0
- package/daemon/docs/reference/community-harness-examples/dsh/openrig-dsh-runner.mjs +543 -0
- package/daemon/docs/reference/community-harness-examples/openshell/README.md +5 -0
- package/daemon/docs/reference/community-harness-presets.md +25 -1
- package/daemon/docs/reference/execution-platform-contract.md +1 -1
- package/daemon/docs/reference/getting-started.md +8 -3
- package/daemon/docs/reference/harness-runner-contract.md +151 -16
- package/daemon/docs/reference/pi-tool-selection-recovery.md +83 -0
- package/daemon/docs/reference/quickstart.md +1 -1
- package/daemon/docs/reference/rig-spec.md +69 -12
- package/daemon/docs/reference/runner-conformance/README.md +75 -0
- package/daemon/docs/reference/runner-conformance/check-runner.mjs +698 -0
- package/daemon/docs/reference/runner-conformance/fake-acp-agent.mjs +143 -0
- package/daemon/docs/reference/terminal-sessions.md +85 -9
- package/daemon/docs/reference/tmux-servers.md +166 -0
- package/daemon/docs/reference/whats-new.md +119 -15
- package/dist/acp/connector.d.ts.map +1 -1
- package/dist/acp/connector.js +6 -1
- package/dist/acp/connector.js.map +1 -1
- package/dist/build-info.js +3 -3
- package/dist/client.d.ts +3 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +28 -0
- package/dist/client.js.map +1 -1
- package/dist/commands/attach.d.ts +1 -0
- package/dist/commands/attach.d.ts.map +1 -1
- package/dist/commands/attach.js +8 -2
- package/dist/commands/attach.js.map +1 -1
- package/dist/commands/compact.d.ts.map +1 -1
- package/dist/commands/compact.js +7 -4
- package/dist/commands/compact.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +8 -3
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/daemon.d.ts.map +1 -1
- package/dist/commands/daemon.js +7 -1
- package/dist/commands/daemon.js.map +1 -1
- package/dist/commands/destroy.d.ts.map +1 -1
- package/dist/commands/destroy.js +2 -0
- package/dist/commands/destroy.js.map +1 -1
- package/dist/commands/doctor.d.ts +8 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +79 -5
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/env.js +1 -1
- package/dist/commands/env.js.map +1 -1
- package/dist/commands/environment.d.ts +8 -0
- package/dist/commands/environment.d.ts.map +1 -0
- package/dist/commands/environment.js +194 -0
- package/dist/commands/environment.js.map +1 -0
- package/dist/commands/export.d.ts.map +1 -1
- package/dist/commands/export.js +5 -2
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/host.d.ts.map +1 -1
- package/dist/commands/host.js +77 -7
- package/dist/commands/host.js.map +1 -1
- package/dist/commands/provider.d.ts.map +1 -1
- package/dist/commands/provider.js +2 -0
- package/dist/commands/provider.js.map +1 -1
- package/dist/commands/queue.d.ts.map +1 -1
- package/dist/commands/queue.js +12 -2
- package/dist/commands/queue.js.map +1 -1
- package/dist/commands/seat.d.ts.map +1 -1
- package/dist/commands/seat.js +54 -4
- package/dist/commands/seat.js.map +1 -1
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +18 -0
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/terminal.d.ts +2 -0
- package/dist/commands/terminal.d.ts.map +1 -1
- package/dist/commands/terminal.js +31 -2
- package/dist/commands/terminal.js.map +1 -1
- package/dist/commands/tui.d.ts +3 -2
- package/dist/commands/tui.d.ts.map +1 -1
- package/dist/commands/tui.js.map +1 -1
- package/dist/config-store.d.ts +3 -1
- package/dist/config-store.d.ts.map +1 -1
- package/dist/config-store.js +10 -0
- package/dist/config-store.js.map +1 -1
- package/dist/cross-host-target.d.ts.map +1 -1
- package/dist/cross-host-target.js +3 -1
- package/dist/cross-host-target.js.map +1 -1
- package/dist/daemon-lifecycle.d.ts +6 -0
- package/dist/daemon-lifecycle.d.ts.map +1 -1
- package/dist/daemon-lifecycle.js +66 -4
- package/dist/daemon-lifecycle.js.map +1 -1
- package/dist/daemon-reachability.d.ts +2 -1
- package/dist/daemon-reachability.d.ts.map +1 -1
- package/dist/daemon-reachability.js +3 -2
- package/dist/daemon-reachability.js.map +1 -1
- package/dist/destroy-helpers.d.ts +3 -2
- package/dist/destroy-helpers.d.ts.map +1 -1
- package/dist/destroy-helpers.js +6 -3
- package/dist/destroy-helpers.js.map +1 -1
- package/dist/host-bindings.js +1 -1
- package/dist/host-bindings.js.map +1 -1
- package/dist/host-registry.d.ts +22 -0
- package/dist/host-registry.d.ts.map +1 -1
- package/dist/host-registry.js +121 -0
- package/dist/host-registry.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lazy-program.d.ts.map +1 -1
- package/dist/lazy-program.js +1 -0
- package/dist/lazy-program.js.map +1 -1
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/mcp-server.js +36 -2
- package/dist/mcp-server.js.map +1 -1
- package/dist/openrig-compat.d.ts +1 -1
- package/dist/openrig-compat.d.ts.map +1 -1
- package/dist/openrig-compat.js +2 -2
- package/dist/openrig-compat.js.map +1 -1
- package/dist/shared-tui.d.ts +4 -2
- package/dist/shared-tui.d.ts.map +1 -1
- package/dist/shared-tui.js +4 -11
- package/dist/shared-tui.js.map +1 -1
- package/dist/terminal-window.d.ts.map +1 -1
- package/dist/terminal-window.js +34 -29
- package/dist/terminal-window.js.map +1 -1
- package/dist/tmux-attachment.d.ts +17 -0
- package/dist/tmux-attachment.d.ts.map +1 -0
- package/dist/tmux-attachment.js +89 -0
- package/dist/tmux-attachment.js.map +1 -0
- package/package.json +2 -2
- package/tui/dist/hydrate.d.ts.map +1 -1
- package/tui/dist/hydrate.js +8 -3
- package/tui/dist/hydrate.js.map +1 -1
- package/tui/dist/render.d.ts.map +1 -1
- package/tui/dist/render.js +7 -1
- package/tui/dist/render.js.map +1 -1
- package/tui/dist/terminals/terminal-model.d.ts.map +1 -1
- package/tui/dist/terminals/terminal-model.js +2 -1
- package/tui/dist/terminals/terminal-model.js.map +1 -1
- package/ui/dist/assets/{index-CMBgYrS7.js → index-Ch6UxNld.js} +88 -88
- package/ui/dist/index.html +1 -1
|
@@ -0,0 +1,698 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// OpenRig runner conformance check: point it at your runner and see which promises of the runner contract
|
|
3
|
+
// (docs/reference/harness-runner-contract.md) it keeps. It needs Node and tmux, and no OpenRig daemon:
|
|
4
|
+
// - your runner starts in a private tmux server, with the environment a runner-preset launch gives it;
|
|
5
|
+
// - the fake ACP agent beside this file stands in for your agent (your runner starts it where it would start the real one);
|
|
6
|
+
// - a small local endpoint stands in for OpenRig's activity route, and records what your runner posts;
|
|
7
|
+
// - input arrives the way `rig send` delivers it: one bracketed paste with raw newlines, then Enter.
|
|
8
|
+
//
|
|
9
|
+
// node check-runner.mjs --runner '<command>' [--name <preset name>] [--resume] [--first-input]
|
|
10
|
+
// [--cases 1,2,4] [--wait-ms 8000] [--pass-env NAME] [--json] [--keep]
|
|
11
|
+
//
|
|
12
|
+
// `{agent}` in the command is replaced with the fake agent's path, an executable that takes any arguments your runner
|
|
13
|
+
// adds. For example: --runner 'my-runner --agent-command {agent}'. --resume and --first-input say your preset declares
|
|
14
|
+
// `resume: true` and `first_input: true`; without them those cases are skipped, since OpenRig wouldn't pass that input.
|
|
15
|
+
// The runner gets a clean environment: PATH, HOME, USER, SHELL, LANG and TMPDIR, the OpenRig variables, and any
|
|
16
|
+
// --pass-env names. Exit status: 0 when nothing fails, 1 when a case fails, 2 for a usage or setup problem.
|
|
17
|
+
//
|
|
18
|
+
// It checks the runner's side only. How OpenRig reads those posts (working, idle, needs input) is OpenRig's own tests'
|
|
19
|
+
// job, and one real run with your agent is still the useful check (section 10 of the contract). Passing this is
|
|
20
|
+
// evidence for the versions you ran, not certification.
|
|
21
|
+
import { spawnSync } from "node:child_process";
|
|
22
|
+
import { randomBytes } from "node:crypto";
|
|
23
|
+
import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
24
|
+
import { createServer } from "node:http";
|
|
25
|
+
import { tmpdir } from "node:os";
|
|
26
|
+
import { dirname, join } from "node:path";
|
|
27
|
+
import { fileURLToPath } from "node:url";
|
|
28
|
+
|
|
29
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
30
|
+
const usage = "usage: node check-runner.mjs --runner '<command with {agent}>' [--name <preset>] [--resume] [--first-input] [--cases 1,2] [--wait-ms 8000] [--pass-env NAME] [--json] [--keep]";
|
|
31
|
+
|
|
32
|
+
function parseArgs(argv) {
|
|
33
|
+
const opts = { name: "runner", cases: undefined, passEnv: [], resume: false, firstInput: false, json: false, keep: false, waitMs: 8000 };
|
|
34
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
35
|
+
const flag = argv[i];
|
|
36
|
+
const value = () => { if (i + 1 >= argv.length) throw new Error(`${flag} needs a value`); return argv[++i]; };
|
|
37
|
+
if (flag === "--runner") opts.runner = value();
|
|
38
|
+
else if (flag === "--name") opts.name = value();
|
|
39
|
+
else if (flag === "--cases") opts.cases = value().split(",").map((c) => c.trim()).filter(Boolean);
|
|
40
|
+
else if (flag === "--pass-env") opts.passEnv.push(value());
|
|
41
|
+
else if (flag === "--wait-ms") opts.waitMs = Number(value());
|
|
42
|
+
else if (flag === "--resume") opts.resume = true;
|
|
43
|
+
else if (flag === "--first-input") opts.firstInput = true;
|
|
44
|
+
else if (flag === "--json") opts.json = true;
|
|
45
|
+
else if (flag === "--keep") opts.keep = true;
|
|
46
|
+
else throw new Error(`unknown option ${flag}`);
|
|
47
|
+
}
|
|
48
|
+
if (!opts.runner) throw new Error("--runner is required");
|
|
49
|
+
if (!opts.runner.includes("{agent}")) throw new Error("--runner must contain {agent}, where your runner takes its agent command");
|
|
50
|
+
if (!/^[A-Za-z0-9._-]+$/.test(opts.name)) throw new Error("--name must be a preset name (letters, digits, '.', '_' or '-')");
|
|
51
|
+
if (!(opts.waitMs > 0)) throw new Error("--wait-ms must be a positive number");
|
|
52
|
+
return opts;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let opts;
|
|
56
|
+
try { opts = parseArgs(process.argv.slice(2)); } catch (error) { console.error(`${error.message}\n${usage}`); process.exit(2); }
|
|
57
|
+
if (spawnSync("tmux", ["-V"]).status !== 0) { console.error("tmux is required: the check drives your runner in a tmux pane, as OpenRig does."); process.exit(2); }
|
|
58
|
+
|
|
59
|
+
const socket = `openrig-runner-check-${process.pid}`;
|
|
60
|
+
const tmux = (...args) => spawnSync("tmux", ["-L", socket, ...args], { encoding: "utf8" });
|
|
61
|
+
const sh = (value) => `'${String(value).replaceAll("'", "'\\''")}'`;
|
|
62
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
63
|
+
// Settling times and per-step bounds grow with --wait-ms on a slow machine; they never shrink below these values. The
|
|
64
|
+
// fake agent's own delays and holds grow by the same factor, so each settle keeps its place against what it measures.
|
|
65
|
+
const scale = (ms) => Math.round(ms * Math.max(1, opts.waitMs / 8000));
|
|
66
|
+
async function waitFor(read, ms = opts.waitMs) {
|
|
67
|
+
const deadline = Date.now() + ms;
|
|
68
|
+
for (;;) {
|
|
69
|
+
const value = read();
|
|
70
|
+
if (value) return value;
|
|
71
|
+
if (Date.now() > deadline) return undefined;
|
|
72
|
+
await sleep(50);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// The stand-in for OpenRig's activity route and, for a launch that scripts one, its answered permission routes (section 7).
|
|
77
|
+
// Each launch has its own token; a request without one is refused, as OpenRig does.
|
|
78
|
+
const posts = [];
|
|
79
|
+
const tokens = new Map();
|
|
80
|
+
const OPTION_ID = /^[A-Za-z0-9_-]{1,40}$/;
|
|
81
|
+
const ANSWERABLE = new Set(["allow_once", "allow_always", "reject_once", "reject_always"]);
|
|
82
|
+
const text = (value) => typeof value === "string" && value.trim() ? value.trim() : null;
|
|
83
|
+
// A JSON-RPC id or prompt number as the runner passed it: a number reads as its decimal string, so 7 and "7" match.
|
|
84
|
+
const idText = (value) => typeof value === "number" && Number.isFinite(value) ? String(value) : text(value);
|
|
85
|
+
const server = createServer((req, res) => {
|
|
86
|
+
let raw = "";
|
|
87
|
+
req.on("data", (chunk) => { raw += chunk; });
|
|
88
|
+
req.on("end", () => {
|
|
89
|
+
const token = (req.headers.authorization ?? "").replace(/^Bearer /, "");
|
|
90
|
+
let body;
|
|
91
|
+
try { body = raw ? JSON.parse(raw) : undefined; } catch { body = undefined; }
|
|
92
|
+
const url = new URL(req.url, "http://stand-in");
|
|
93
|
+
posts.push({ at: Date.now(), method: req.method, path: url.pathname, query: Object.fromEntries(url.searchParams), token, body, raw });
|
|
94
|
+
const send = (status, payload) => res.writeHead(status, { "content-type": "application/json" }).end(JSON.stringify(payload));
|
|
95
|
+
const h = tokens.get(token);
|
|
96
|
+
if (req.method === "POST" && url.pathname === "/api/activity/hooks") {
|
|
97
|
+
if (!h) return send(401, { ok: false });
|
|
98
|
+
return body ? send(200, { ok: true }) : send(400, { ok: false, code: "invalid_json" });
|
|
99
|
+
}
|
|
100
|
+
const ask = url.pathname.match(/^\/api\/activity\/permission-requests(?:\/([^/]+)(\/withdraw)?)?$/);
|
|
101
|
+
if (!ask) return send(404, { ok: false, code: "not_found" });
|
|
102
|
+
if (!h) return send(401, { ok: false });
|
|
103
|
+
// Without a scripted ask, the stand-in is an OpenRig that predates the answered path: 404, so the runner permits.
|
|
104
|
+
if (!h.asks) return send(404, { ok: false, code: "not_found" });
|
|
105
|
+
// A scripted `drop` closes the connection unanswered: an OpenRig the runner can't reach.
|
|
106
|
+
const drop = req.method === "POST" && !ask[1] ? h.asks.script.submit?.drop : req.method === "GET" && h.asks.script.read?.drop;
|
|
107
|
+
if (drop) return void res.socket.destroy();
|
|
108
|
+
if (req.method === "POST" && !ask[1]) return submitAsk(h, body, raw, send);
|
|
109
|
+
const entry = h.asks.byId.get(decodeURIComponent(ask[1] ?? ""));
|
|
110
|
+
if (!entry) return send(404, { ok: false, code: "not_found" });
|
|
111
|
+
if (req.method === "GET" && h.asks.script.read) return send(h.asks.script.read.status, { ok: false, code: h.asks.script.read.code });
|
|
112
|
+
if (req.method === "POST" && ask[2]) {
|
|
113
|
+
if (!["turn_cancelled", "turn_ended", "exited"].includes(body?.reason)) return send(400, { ok: false, code: "invalid_permission_request" });
|
|
114
|
+
entry.withdrawn = body.reason;
|
|
115
|
+
entry.wake();
|
|
116
|
+
return send(200, { ok: true, ...askState(h, entry) });
|
|
117
|
+
}
|
|
118
|
+
if (req.method === "GET" && !ask[2]) {
|
|
119
|
+
const waitMs = Math.min(Number(url.searchParams.get("waitSeconds") ?? 0), 25) * 1000;
|
|
120
|
+
const reply = () => send(200, { ok: true, ...askState(h, entry) });
|
|
121
|
+
if (askState(h, entry).state !== "pending" || !(waitMs > 0)) return reply();
|
|
122
|
+
const timer = setTimeout(() => { entry.waiters.delete(reply); reply(); }, waitMs);
|
|
123
|
+
entry.waiters.add(() => { clearTimeout(timer); reply(); });
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
return send(404, { ok: false, code: "not_found" });
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// What the scripted ask reads as now: an answer once its time has come, `withdrawn` after a withdraw, otherwise pending. A
|
|
131
|
+
// `late` answer is what the stand-in reports after a withdraw, so a runner that keeps reading and delivers it is caught.
|
|
132
|
+
function askState(h, entry) {
|
|
133
|
+
const script = h.asks.script;
|
|
134
|
+
if (entry.withdrawn) return script.late ?? { state: "withdrawn" };
|
|
135
|
+
if (script.answer && Date.now() >= entry.created + (script.answer.afterMs ?? 0)) {
|
|
136
|
+
const { state, optionId, reason } = script.answer;
|
|
137
|
+
return { state, ...(optionId ? { optionId } : {}), ...(reason ? { reason } : {}) };
|
|
138
|
+
}
|
|
139
|
+
return { state: "pending" };
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Submit, checked as OpenRig checks it: the seat and generation, nativeRef as a string, turnId and requestId as a string
|
|
143
|
+
// or a number. When no one can be asked, OpenRig permits with the agent's allow_once, else allow_always: here when the
|
|
144
|
+
// script says so, or for options a person can't be shown (2-4 with distinct ids). With no allow option it refuses.
|
|
145
|
+
function submitAsk(h, body, raw, send) {
|
|
146
|
+
const script = h.asks.script;
|
|
147
|
+
const problems = [];
|
|
148
|
+
if (!body) return send(400, { ok: false, code: "invalid_json" });
|
|
149
|
+
if (body.sessionName !== h.session) return send(404, { ok: false, code: "session_not_found" });
|
|
150
|
+
if (!text(body.nativeRef)) problems.push(`nativeRef must be a non-empty string (got ${JSON.stringify(body.nativeRef)})`);
|
|
151
|
+
for (const key of ["turnId", "requestId"]) if (!idText(body[key])) problems.push(`${key} must be a non-empty string or a number (got ${JSON.stringify(body[key])})`);
|
|
152
|
+
const options = Array.isArray(body.options) ? body.options : null;
|
|
153
|
+
if (!options) problems.push("options must be an array");
|
|
154
|
+
else if (options.some((o) => !text(o?.optionId) || !text(o?.name) || !text(o?.kind))) problems.push("each option needs optionId, name and kind");
|
|
155
|
+
h.asks.submitted.push({ body, problems });
|
|
156
|
+
if (problems.length) return send(400, { ok: false, code: "invalid_permission_request", error: problems.join("; ") });
|
|
157
|
+
if (body.generation !== h.generation) return send(409, { ok: false, code: "stale_generation" });
|
|
158
|
+
if (script.submit?.status) return send(script.submit.status, { ok: false, code: script.submit.code });
|
|
159
|
+
const allow = options.find((o) => o.kind === "allow_once") ?? options.find((o) => o.kind === "allow_always");
|
|
160
|
+
const permit = (reason) => allow ? send(200, { ok: true, state: "permitted", optionId: allow.optionId, reason })
|
|
161
|
+
: send(422, { ok: false, code: "options_unsupported" });
|
|
162
|
+
if (script.submit?.permitted) return permit("no one can be asked");
|
|
163
|
+
if (options.length < 2 || options.length > 4 || new Set(options.map((o) => o.optionId)).size !== options.length
|
|
164
|
+
|| options.some((o) => !OPTION_ID.test(o.optionId) || !ANSWERABLE.has(o.kind))) return permit("these options can't be shown to a person");
|
|
165
|
+
const requestId = idText(body.requestId), turnId = idText(body.turnId);
|
|
166
|
+
const key = JSON.stringify([body.generation, text(body.nativeRef), requestId]);
|
|
167
|
+
const earlier = h.asks.byKey.get(key);
|
|
168
|
+
if (earlier) return send(200, { ok: true, askId: earlier.askId, created: false });
|
|
169
|
+
if ([...h.asks.byKey.values()].some((e) => e.requestId === requestId && e.turnId !== turnId)) return send(409, { ok: false, code: "duplicate_request" });
|
|
170
|
+
const entry = { askId: `ask-${h.label}-${h.asks.byKey.size + 1}`, requestId, turnId, created: Date.now(), waiters: new Set() };
|
|
171
|
+
entry.wake = () => { for (const w of [...entry.waiters]) w(); entry.waiters.clear(); };
|
|
172
|
+
if (script.answer) setTimeout(entry.wake, script.answer.afterMs ?? 0);
|
|
173
|
+
h.asks.byKey.set(key, entry);
|
|
174
|
+
h.asks.byId.set(entry.askId, entry);
|
|
175
|
+
return send(200, { ok: true, askId: entry.askId, created: true });
|
|
176
|
+
}
|
|
177
|
+
await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
|
|
178
|
+
const base = `http://127.0.0.1:${server.address().port}`;
|
|
179
|
+
|
|
180
|
+
const launches = [];
|
|
181
|
+
async function launch(label, { scenario = {}, env = {}, asks } = {}) {
|
|
182
|
+
const dir = mkdtempSync(join(tmpdir(), `runner-check-${label}-`));
|
|
183
|
+
const cwd = join(dir, "work");
|
|
184
|
+
mkdirSync(cwd);
|
|
185
|
+
mkdirSync(join(dir, "home"));
|
|
186
|
+
mkdirSync(join(dir, "launch"));
|
|
187
|
+
const id = randomBytes(4).toString("hex");
|
|
188
|
+
const h = {
|
|
189
|
+
label, dir, cwd, token: randomBytes(16).toString("hex"), session: `check-${label}@runner-check`, nodeId: `node-${label}-${id}`,
|
|
190
|
+
generation: `gen-${id}`, attempt: `attempt-${id}`, recordPath: join(dir, "launch", "record.json"), agentLog: join(dir, "agent.jsonl"),
|
|
191
|
+
target: `check-${label}`,
|
|
192
|
+
};
|
|
193
|
+
if (asks) h.asks = { script: asks, byKey: new Map(), byId: new Map(), submitted: [] };
|
|
194
|
+
tokens.set(h.token, h);
|
|
195
|
+
writeFileSync(join(dir, "scenario.json"), JSON.stringify(scenario));
|
|
196
|
+
const agent = join(dir, "agent");
|
|
197
|
+
writeFileSync(agent, `#!/bin/sh\nexec ${sh(process.execPath)} ${sh(join(here, "fake-acp-agent.mjs"))} --scenario ${sh(join(dir, "scenario.json"))} --log ${sh(h.agentLog)} "$@"\n`);
|
|
198
|
+
chmodSync(agent, 0o755);
|
|
199
|
+
const vars = {
|
|
200
|
+
PATH: process.env.PATH, HOME: process.env.HOME, USER: process.env.USER, SHELL: process.env.SHELL, LANG: process.env.LANG,
|
|
201
|
+
TMPDIR: process.env.TMPDIR, TERM: "xterm-256color",
|
|
202
|
+
...Object.fromEntries(opts.passEnv.map((name) => [name, process.env[name]])),
|
|
203
|
+
OPENRIG_HOME: join(dir, "home"), OPENRIG_URL: base, OPENRIG_ACTIVITY_HOOK_TOKEN: h.token, OPENRIG_SESSION_NAME: h.session,
|
|
204
|
+
OPENRIG_NODE_ID: h.nodeId, OPENRIG_RUNTIME: opts.name, OPENRIG_OCCUPANT_GENERATION: h.generation,
|
|
205
|
+
OPENRIG_LAUNCH_RESULT: h.recordPath, OPENRIG_LAUNCH_ATTEMPT: h.attempt, ...env,
|
|
206
|
+
};
|
|
207
|
+
const assignments = Object.entries(vars).filter(([, value]) => value !== undefined).map(([key, value]) => `${key}=${sh(value)}`).join(" ");
|
|
208
|
+
const command = opts.runner.replaceAll("{agent}", sh(agent));
|
|
209
|
+
writeFileSync(join(dir, "launch.sh"), `#!/bin/sh\ncd ${sh(cwd)} || exit 1\nexec /usr/bin/env -i ${assignments} /bin/sh -c ${sh(command)}\n`);
|
|
210
|
+
chmodSync(join(dir, "launch.sh"), 0o755);
|
|
211
|
+
const started = tmux("new-session", "-d", "-s", h.target, "-x", "200", "-y", "50", join(dir, "launch.sh"));
|
|
212
|
+
if (started.status !== 0) throw new Error(`tmux couldn't start the runner: ${started.stderr.trim()}`);
|
|
213
|
+
Object.assign(h, {
|
|
214
|
+
log: () => !existsSync(h.agentLog) ? [] : readFileSync(h.agentLog, "utf8").split("\n").filter(Boolean).map((line) => JSON.parse(line)),
|
|
215
|
+
received: (method) => h.log().filter((e) => e.dir === "in" && e.msg.method === method),
|
|
216
|
+
sent: (method) => h.log().filter((e) => e.dir === "out" && e.msg.method === method),
|
|
217
|
+
answerTo: (method) => { const ask = h.sent(method)[0]; return ask && h.log().find((e) => e.dir === "in" && e.msg.id === ask.msg.id && !e.msg.method); },
|
|
218
|
+
replyTo: (entry) => h.log().find((e) => e.dir === "out" && e.msg.id === entry.msg.id && !e.msg.method),
|
|
219
|
+
events: (event) => h.log().filter((e) => e.dir === "event" && e.event === event),
|
|
220
|
+
prompts: () => h.received("session/prompt").map((e) => (e.msg.params?.prompt ?? []).filter((b) => b.type === "text").map((b) => b.text).join("")),
|
|
221
|
+
posts: () => posts.filter((p) => p.path === "/api/activity/hooks" && (p.token === h.token || p.body?.sessionName === h.session)),
|
|
222
|
+
permissionCalls: (method, suffix = "") => posts.filter((p) => p.token === h.token && p.method === method
|
|
223
|
+
&& p.path.startsWith("/api/activity/permission-requests") && p.path.endsWith(suffix)),
|
|
224
|
+
hooks: (event, subtype) => h.posts().filter((p) => p.body?.hookEvent === event && (subtype === undefined || p.body?.subtype === subtype)),
|
|
225
|
+
record: () => { if (!existsSync(h.recordPath)) return undefined; try { return JSON.parse(readFileSync(h.recordPath, "utf8")); } catch { return { unreadable: true }; } },
|
|
226
|
+
paste: (text) => {
|
|
227
|
+
const file = join(dir, `paste-${randomBytes(3).toString("hex")}`);
|
|
228
|
+
writeFileSync(file, text);
|
|
229
|
+
const buffer = `b-${randomBytes(3).toString("hex")}`;
|
|
230
|
+
tmux("load-buffer", "-b", buffer, file);
|
|
231
|
+
tmux("paste-buffer", "-t", h.target, "-b", buffer, "-d", "-r", "-p");
|
|
232
|
+
tmux("send-keys", "-t", h.target, "Enter");
|
|
233
|
+
},
|
|
234
|
+
keys: (...keys) => tmux("send-keys", "-t", h.target, ...keys),
|
|
235
|
+
stop: () => tmux("kill-session", "-t", h.target),
|
|
236
|
+
screen: () => tmux("capture-pane", "-p", "-t", h.target).stdout ?? "",
|
|
237
|
+
});
|
|
238
|
+
launches.push(h);
|
|
239
|
+
return h;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// An ordinary send arrives inside an envelope, so a line in it that reads /abort is still just text.
|
|
243
|
+
const message = (h, body) => `From: checker@runner-check\nTo: ${h.session}\n---\n${body}`;
|
|
244
|
+
const nonExitStops = (h, after = 0) => h.hooks("Stop").filter((p) => p.at >= after && !String(p.body?.subtype ?? "").endsWith("_exited"));
|
|
245
|
+
const ready = (h, ms) => waitFor(() => h.record()?.nativeRef && h.record(), ms);
|
|
246
|
+
|
|
247
|
+
function result(id, title, { proposed = false } = {}) {
|
|
248
|
+
const r = { id, title, status: "pass", checks: [], ...(proposed ? { proposed: true } : {}) };
|
|
249
|
+
r.check = (name, ok, detail) => { r.checks.push({ name, ok: Boolean(ok), ...(ok ? {} : { detail }) }); if (!ok) r.status = "fail"; return ok; };
|
|
250
|
+
r.skip = (reason) => { r.status = "skip"; r.reason = reason; return r; };
|
|
251
|
+
return r;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const cases = {
|
|
255
|
+
async "1"() {
|
|
256
|
+
const r = result("1", "Handshake: the launch record comes only after the conversation is open");
|
|
257
|
+
const h = await launch("1", { scenario: { newDelayMs: scale(2000), sessionId: "fake-session-1" } });
|
|
258
|
+
const asked = await waitFor(() => h.received("session/new")[0]);
|
|
259
|
+
if (!r.check("the runner opens a conversation with session/new", asked, "no session/new arrived")) return r;
|
|
260
|
+
await sleep(scale(800));
|
|
261
|
+
r.check("no launch record while session/new is still unanswered", !h.record(), `a record was written early: ${JSON.stringify(h.record())}`);
|
|
262
|
+
const record = await ready(h);
|
|
263
|
+
r.check("a launch record arrives after session/new is answered", record, `no record with a nativeRef at ${h.recordPath}`);
|
|
264
|
+
if (!record) return r;
|
|
265
|
+
const answered = h.replyTo(asked);
|
|
266
|
+
r.check("the record is written after the answer", answered && statSync(h.recordPath).mtimeMs >= answered.at - 5, "the record's time precedes the answer");
|
|
267
|
+
r.check("format 1, this attempt, this preset", record.format === 1 && record.attempt === h.attempt && record.harness === opts.name,
|
|
268
|
+
`format=${record.format} attempt=${record.attempt} harness=${record.harness}`);
|
|
269
|
+
r.check("nativeRef is the agent's conversation id", record.nativeRef === "fake-session-1", `nativeRef=${record.nativeRef}`);
|
|
270
|
+
r.check("producer names the runner's versions", typeof record.producer === "string" && record.producer.trim(), "no producer");
|
|
271
|
+
return r;
|
|
272
|
+
},
|
|
273
|
+
|
|
274
|
+
async "1b"() {
|
|
275
|
+
const r = result("1b", "A failed handshake writes no launch record and claims no turn");
|
|
276
|
+
for (const [label, scenario] of [["initialize error", { initialize: "error" }], ["initialize exit", { initialize: "exit" }],
|
|
277
|
+
["session/new error", { newSession: "error" }], ["session/new exit", { newSession: "exit" }]]) {
|
|
278
|
+
const h = await launch(`1b-${label.replace(/[^a-z]+/g, "-")}`, { scenario });
|
|
279
|
+
await waitFor(() => h.events("exit")[0] || h.log().some((e) => e.dir === "out" && e.msg.error), opts.waitMs);
|
|
280
|
+
await sleep(scale(1500));
|
|
281
|
+
const record = h.record();
|
|
282
|
+
r.check(`${label}: no conversation in a launch record`, !record?.nativeRef, `record: ${JSON.stringify(record)}`);
|
|
283
|
+
r.check(`${label}: no accepted prompt or idle report`, h.hooks("UserPromptSubmit").length === 0 && nonExitStops(h).length === 0,
|
|
284
|
+
`posts: ${h.posts().map((p) => `${p.body?.hookEvent}/${p.body?.subtype}`).join(", ")}`);
|
|
285
|
+
}
|
|
286
|
+
return r;
|
|
287
|
+
},
|
|
288
|
+
|
|
289
|
+
async "2"() {
|
|
290
|
+
const r = result("2", "Input framing, queued messages and cancel");
|
|
291
|
+
const h = await launch("2", { scenario: { turns: [{}, { holdMs: scale(15000) }, { holdMs: scale(2500), ignoreCancel: true }, {}] } });
|
|
292
|
+
if (!r.check("the runner opens its conversation", await ready(h), "no launch record")) return r;
|
|
293
|
+
const block = message(h, "first line\n/abort\nthird line");
|
|
294
|
+
h.paste(block);
|
|
295
|
+
await waitFor(() => h.prompts().length >= 1);
|
|
296
|
+
await waitFor(() => nonExitStops(h).length >= 1, scale(3000));
|
|
297
|
+
await sleep(scale(500));
|
|
298
|
+
r.check("one pasted block is exactly one session/prompt", h.prompts().length === 1, `got ${h.prompts().length} prompts`);
|
|
299
|
+
r.check("the prompt holds the whole block, byte for byte", h.prompts()[0] === block, `got ${JSON.stringify(h.prompts()[0])}`);
|
|
300
|
+
|
|
301
|
+
h.paste(message(h, "please hold"));
|
|
302
|
+
if (!r.check("the next block starts the next turn", await waitFor(() => h.prompts().length >= 2), "no second prompt")) return r;
|
|
303
|
+
// A block that arrives while the agent works, with a line reading /abort, is still one message for later.
|
|
304
|
+
const queued = message(h, "sent while the agent works\n/abort\nstill part of the message");
|
|
305
|
+
h.paste(queued);
|
|
306
|
+
await sleep(scale(1200));
|
|
307
|
+
r.check("a block sent mid-turn waits for the next turn", h.prompts().length === 2, `got ${h.prompts().length} prompts during the turn`);
|
|
308
|
+
r.check("a line reading /abort inside a block isn't control", h.received("session/cancel").length === 0, "the runner sent session/cancel");
|
|
309
|
+
|
|
310
|
+
const before = Date.now();
|
|
311
|
+
h.paste("/abort");
|
|
312
|
+
const cancel = await waitFor(() => h.received("session/cancel")[0], scale(3000));
|
|
313
|
+
r.check("a block that is exactly /abort sends session/cancel", cancel, "no session/cancel");
|
|
314
|
+
const stopped = await waitFor(() => nonExitStops(h, before)[0], scale(3000));
|
|
315
|
+
r.check("the cancelled turn reports Stop/cancelled", stopped?.body?.subtype === "cancelled", `got ${stopped ? `Stop/${stopped.body.subtype}` : "no Stop"}`);
|
|
316
|
+
await sleep(scale(300));
|
|
317
|
+
r.check("one /abort sends one session/cancel", h.received("session/cancel").length === 1, `got ${h.received("session/cancel").length}`);
|
|
318
|
+
r.check("the waiting block becomes the next prompt", await waitFor(() => h.prompts()[2] === queued, scale(4000)), `prompts: ${JSON.stringify(h.prompts().slice(2))}`);
|
|
319
|
+
|
|
320
|
+
const interrupted = Date.now();
|
|
321
|
+
await sleep(scale(200));
|
|
322
|
+
h.keys("C-c");
|
|
323
|
+
r.check("Ctrl-C outside a paste sends session/cancel", await waitFor(() => h.received("session/cancel").length >= 2, scale(3000)), "no second session/cancel");
|
|
324
|
+
const ended = await waitFor(() => nonExitStops(h, interrupted)[0], scale(6000));
|
|
325
|
+
r.check("cancelled is reported only on the agent's own stop reason", ended?.body?.subtype === "end_turn",
|
|
326
|
+
`the agent ended the turn end_turn; the runner reported ${ended ? `Stop/${ended.body.subtype}` : "no Stop"}`);
|
|
327
|
+
return r;
|
|
328
|
+
},
|
|
329
|
+
|
|
330
|
+
async "3"() {
|
|
331
|
+
const r = result("3", "Activity: turn boundaries, posted in order with the seat's identity");
|
|
332
|
+
const h = await launch("3");
|
|
333
|
+
if (!r.check("the runner opens its conversation", await ready(h), "no launch record")) return r;
|
|
334
|
+
h.paste(message(h, "a short turn"));
|
|
335
|
+
const accepted = await waitFor(() => h.hooks("UserPromptSubmit", "accepted")[0]);
|
|
336
|
+
r.check("UserPromptSubmit/accepted when the prompt is given", accepted, `posts: ${h.posts().map((p) => p.body?.hookEvent).join(", ")}`);
|
|
337
|
+
r.check("the accepted post names a turnId", accepted && accepted.body.turnId !== undefined && accepted.body.turnId !== "", "no turnId");
|
|
338
|
+
const end = await waitFor(() => h.hooks("Stop", "end_turn")[0]);
|
|
339
|
+
r.check("Stop/end_turn when the turn ends", end, "no Stop/end_turn");
|
|
340
|
+
r.check("accepted comes before the turn's end", accepted && end && accepted.at <= end.at, "out of order");
|
|
341
|
+
const all = h.posts();
|
|
342
|
+
const missing = all.flatMap((p) => ["sessionName", "nodeId", "runtime", "generation", "sequence", "occurredAt", "hookEvent", "subtype"]
|
|
343
|
+
.filter((k) => p.body?.[k] === undefined).map((k) => `${p.body?.hookEvent ?? "?"} lacks ${k}`));
|
|
344
|
+
r.check("every post carries the contract's fields", missing.length === 0, missing.join("; "));
|
|
345
|
+
r.check("every post uses the hook token", all.every((p) => p.token === h.token), "a post without the bearer token");
|
|
346
|
+
r.check("every post names this seat and preset",
|
|
347
|
+
all.every((p) => p.body?.sessionName === h.session && p.body?.nodeId === h.nodeId && p.body?.runtime === opts.name),
|
|
348
|
+
all.map((p) => `${p.body?.sessionName}/${p.body?.nodeId}/${p.body?.runtime}`).join(", "));
|
|
349
|
+
const seqs = all.map((p) => Number(p.body?.sequence));
|
|
350
|
+
r.check("sequence rises with each post", seqs.every((s, i) => Number.isFinite(s) && (i === 0 || s > seqs[i - 1])), `sequences: ${seqs.join(", ")}`);
|
|
351
|
+
const beats = all.filter((p) => p.body?.livenessSeconds !== undefined);
|
|
352
|
+
r.check("livenessSeconds, when given, is a whole number from 1 to 3600",
|
|
353
|
+
beats.every((p) => Number.isInteger(p.body.livenessSeconds) && p.body.livenessSeconds >= 1 && p.body.livenessSeconds <= 3600),
|
|
354
|
+
beats.map((p) => p.body.livenessSeconds).join(", "));
|
|
355
|
+
return r;
|
|
356
|
+
},
|
|
357
|
+
|
|
358
|
+
// Section 7's default is permit: when no one can be asked, the agent gets its own allow option at once, allow_once before
|
|
359
|
+
// allow_always. Only the seat's opt-in refusal (denied_by_seat), or a request with no allow option, is refused at once,
|
|
360
|
+
// shown, and held as needs input until the next prompt, even when the turn is cancelled.
|
|
361
|
+
async "4"() {
|
|
362
|
+
const r = result("4", "Permissions: permitted when no one can be asked; refused and held only on denied_by_seat or no allow option");
|
|
363
|
+
const option = (optionId, kind) => ({ optionId, name: optionId, kind });
|
|
364
|
+
const withAlways = [option("allow-once", "allow_once"), option("allow-always", "allow_always"), option("reject-once", "reject_once")];
|
|
365
|
+
const rejectOnly = [option("reject-once", "reject_once"), option("reject-always", "reject_always")];
|
|
366
|
+
const cells = [
|
|
367
|
+
// label, the stand-in's answered path (none: an OpenRig without it, which answers 404), the options, permitted, and
|
|
368
|
+
// whether /abort cancels the turn after the refusal
|
|
369
|
+
["404", undefined, withAlways, true],
|
|
370
|
+
["unreachable", { submit: { drop: true } }, withAlways, true],
|
|
371
|
+
["denied_by_seat", { submit: { status: 409, code: "denied_by_seat" } }, withAlways, false],
|
|
372
|
+
["denied_by_seat, then /abort", { submit: { status: 409, code: "denied_by_seat" } }, withAlways, false, true],
|
|
373
|
+
["no allow option", undefined, rejectOnly, false],
|
|
374
|
+
];
|
|
375
|
+
await Promise.all(cells.map(async ([label, asks, options, permitted, abort]) => {
|
|
376
|
+
const turns = [{ permission: { options }, holdMs: scale(abort ? 4000 : 1500) }, {}];
|
|
377
|
+
const h = await launch(`4-${label.replace(/[^a-z0-9]+/g, "-")}`, { scenario: { turns }, asks });
|
|
378
|
+
if (!r.check(`${label}: the runner opens its conversation`, await ready(h), "no launch record")) return;
|
|
379
|
+
h.paste(message(h, "edit the notes"));
|
|
380
|
+
const asked = await waitFor(() => h.sent("session/request_permission")[0]);
|
|
381
|
+
if (!r.check(`${label}: the agent's permission request is sent`, asked, "the turn never reached the request")) return;
|
|
382
|
+
// A runner may take a moment to find OpenRig unreachable; everything else is answered at once.
|
|
383
|
+
const answer = await waitFor(() => h.answerTo("session/request_permission"), scale(label === "unreachable" ? 10000 : 3000));
|
|
384
|
+
if (!r.check(`${label}: the request is answered, not left pending`, answer, "no answer")) return;
|
|
385
|
+
if (label !== "unreachable") r.check(`${label}: it's answered at once (within 2 s)`, answer.at - asked.at <= 2000, `${answer.at - asked.at} ms`);
|
|
386
|
+
const got = answer.msg.result?.outcome;
|
|
387
|
+
if (permitted) {
|
|
388
|
+
r.check(`${label}: the agent gets its allow_once option`, got?.outcome === "selected" && got.optionId === "allow-once",
|
|
389
|
+
`answer: ${JSON.stringify(answer.msg.result ?? answer.msg.error)}`);
|
|
390
|
+
r.check(`${label}: the turn's end is reported as usual`, await waitFor(() => h.hooks("Stop", "end_turn")[0], scale(4000)),
|
|
391
|
+
"no Stop/end_turn after the permit");
|
|
392
|
+
r.check(`${label}: nothing is held as needs input`, h.hooks("Notification", "permission_prompt").length === 0, "the runner posted permission_prompt");
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
r.check(`${label}: the answer is a refusal, never an allow option`, got?.outcome === "cancelled",
|
|
396
|
+
`answer: ${JSON.stringify(answer.msg.result ?? answer.msg.error)}`);
|
|
397
|
+
const shown = await waitFor(() => h.hooks("Notification", "permission_prompt")[0], scale(3000));
|
|
398
|
+
r.check(`${label}: Notification/permission_prompt is posted`, shown, "no permission_prompt post");
|
|
399
|
+
if (label === "denied_by_seat") r.check(`${label}: what was asked is shown in the pane`, await waitFor(() => h.screen().includes("Edit notes.txt"), scale(3000)),
|
|
400
|
+
"the pane never showed the tool call's title, Edit notes.txt");
|
|
401
|
+
// A cancelled turn is still a turn's end: the refusal stays held until the next accepted prompt.
|
|
402
|
+
if (abort) {
|
|
403
|
+
h.paste("/abort");
|
|
404
|
+
r.check(`${label}: /abort sends session/cancel`, await waitFor(() => h.received("session/cancel")[0], scale(3000)), "no session/cancel");
|
|
405
|
+
}
|
|
406
|
+
await waitFor(() => h.log().some((e) => e.dir === "out" && e.msg.result?.stopReason), scale(abort ? 6000 : 4000));
|
|
407
|
+
await sleep(scale(800));
|
|
408
|
+
r.check(`${label}: no idle Stop or beat while holding that attention`, shown && nonExitStops(h, shown.at).length === 0,
|
|
409
|
+
`posted ${nonExitStops(h, shown?.at ?? 0).map((p) => `Stop/${p.body.subtype}`).join(", ")}`);
|
|
410
|
+
const next = Date.now();
|
|
411
|
+
h.paste(message(h, "carry on"));
|
|
412
|
+
r.check(`${label}: the next prompt is accepted as usual, which clears it`,
|
|
413
|
+
await waitFor(() => h.hooks("UserPromptSubmit", "accepted").some((p) => p.at >= next)), "no accepted post for the next prompt");
|
|
414
|
+
}));
|
|
415
|
+
return r;
|
|
416
|
+
},
|
|
417
|
+
|
|
418
|
+
// Section 7's answered path: the runner submits the live request, delivers the option that comes back (the person's
|
|
419
|
+
// answer, or OpenRig's permit) once while that request is live, and withdraws it when the turn or the agent ends.
|
|
420
|
+
async "4b"() {
|
|
421
|
+
const r = result("4b", "Answered permissions: the person's answer or OpenRig's permit reaches the live request, and nothing else does");
|
|
422
|
+
const options = ["allow-once", "reject-once"];
|
|
423
|
+
const submits = (h) => h.permissionCalls("POST").filter((p) => p.path === "/api/activity/permission-requests");
|
|
424
|
+
const withdraws = (h) => h.permissionCalls("POST", "/withdraw");
|
|
425
|
+
const answers = (h) => { const asked = h.sent("session/request_permission")[0];
|
|
426
|
+
return asked ? h.log().filter((e) => e.dir === "in" && e.msg.id === asked.msg.id && !e.msg.method) : []; };
|
|
427
|
+
const outcome = (h) => answers(h)[0]?.msg.result?.outcome;
|
|
428
|
+
const open = async (label, asks, turns = [{ permission: true }, {}]) => {
|
|
429
|
+
const h = await launch(`4b-${label}`, { scenario: { turns }, asks });
|
|
430
|
+
if (!await ready(h)) { r.check(`${label}: the runner opens its conversation`, false, "no launch record"); return undefined; }
|
|
431
|
+
h.paste(message(h, "edit the notes"));
|
|
432
|
+
await waitFor(() => h.sent("session/request_permission")[0]);
|
|
433
|
+
return h;
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
// An answer from the chosen person: the offered option, once, and the turn then reports as usual.
|
|
437
|
+
for (const [label, optionId] of [["allow", "allow-once"], ["deny", "reject-once"]]) {
|
|
438
|
+
const h = await open(label, { answer: { afterMs: 400, state: "answered", optionId } });
|
|
439
|
+
if (!h) continue;
|
|
440
|
+
const submitted = await waitFor(() => submits(h)[0], scale(3000));
|
|
441
|
+
if (!r.check(`${label}: the request is submitted to /api/activity/permission-requests`, submitted, "no submit")) continue;
|
|
442
|
+
const asked = h.sent("session/request_permission")[0];
|
|
443
|
+
const accepted = h.hooks("UserPromptSubmit", "accepted")[0];
|
|
444
|
+
const sent = submitted.body ?? {};
|
|
445
|
+
if (label === "allow") {
|
|
446
|
+
r.check("the submit passes OpenRig's checks", h.asks.submitted[0]?.problems.length === 0, h.asks.submitted[0]?.problems.join("; "));
|
|
447
|
+
r.check("it uses the hook token", submitted.token === h.token, "no bearer token");
|
|
448
|
+
r.check("requestId is the agent's JSON-RPC id", idText(sent.requestId) === String(asked?.msg.id), `requestId=${JSON.stringify(sent.requestId)}`);
|
|
449
|
+
r.check("turnId is the accepted prompt's", accepted && idText(sent.turnId) === String(accepted.body.turnId), `turnId=${JSON.stringify(sent.turnId)}`);
|
|
450
|
+
r.check("nativeRef and generation name this conversation and occupant", sent.nativeRef === h.record()?.nativeRef && sent.generation === h.generation,
|
|
451
|
+
`nativeRef=${sent.nativeRef} generation=${sent.generation}`);
|
|
452
|
+
r.check("the agent's options are passed on as offered", JSON.stringify((sent.options ?? []).map((o) => o.optionId)) === JSON.stringify(options),
|
|
453
|
+
JSON.stringify(sent.options));
|
|
454
|
+
}
|
|
455
|
+
const delivered = await waitFor(() => outcome(h), scale(4000));
|
|
456
|
+
r.check(`${label}: the agent gets the chosen option`, delivered?.outcome === "selected" && delivered.optionId === optionId, `got ${JSON.stringify(delivered)}`);
|
|
457
|
+
await waitFor(() => h.hooks("Stop", "end_turn")[0], scale(3000));
|
|
458
|
+
await sleep(scale(300));
|
|
459
|
+
r.check(`${label}: it's delivered once`, answers(h).length === 1, `${answers(h).length} answers`);
|
|
460
|
+
if (label === "allow") {
|
|
461
|
+
r.check("OpenRig records the prompt; the runner doesn't post permission_prompt itself", h.hooks("Notification", "permission_prompt").length === 0,
|
|
462
|
+
"the runner posted permission_prompt for a created ask");
|
|
463
|
+
const reads = h.permissionCalls("GET");
|
|
464
|
+
// Section 7 bounds the wait at 25 s and no lower; OpenRig's read takes 0 to 25 or none.
|
|
465
|
+
r.check("each read waits at most 25 s", reads.length > 0 && reads.every((p) => p.query.waitSeconds === undefined || Number(p.query.waitSeconds) <= 25),
|
|
466
|
+
reads.map((p) => p.query.waitSeconds ?? "(none)").join(", "));
|
|
467
|
+
r.check("after the answer, the turn's end is reported as usual", h.hooks("Stop", "end_turn").length > 0, "no Stop/end_turn after delivery");
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// OpenRig's permit, at submit or at a read, is delivered like an answer. So is the runner's own permit when OpenRig
|
|
472
|
+
// can't give an answer: a refusal section 7's table marks "permits" (two of them 409s, like stale_generation, so the
|
|
473
|
+
// code decides, never the status; a revoked grant can still be the live occupant's, since one is reissued after a lost
|
|
474
|
+
// response), a read that gets no answer, or a status, code or read state the section doesn't list. A refusal saying
|
|
475
|
+
// the request isn't the current occupant's, and a refused, stale or withdrawn read, can't take an answer: the agent
|
|
476
|
+
// gets cancelled, and nothing is held.
|
|
477
|
+
const outcomes = [
|
|
478
|
+
["permitted at submit", { submit: { permitted: true } }, "allow-once"],
|
|
479
|
+
["permitted at read", { answer: { afterMs: 300, state: "permitted", optionId: "allow-once" } }, "allow-once"],
|
|
480
|
+
["duplicate_request", { submit: { status: 409, code: "duplicate_request" } }, "allow-once"],
|
|
481
|
+
["activity_grant_pending", { submit: { status: 409, code: "activity_grant_pending" } }, "allow-once"],
|
|
482
|
+
["activity_grant_revoked", { submit: { status: 401, code: "activity_grant_revoked" } }, "allow-once"],
|
|
483
|
+
["unreachable read", { read: { drop: true } }, "allow-once"],
|
|
484
|
+
["unlisted read status (500)", { read: { status: 500, code: "internal_error" } }, "allow-once"],
|
|
485
|
+
["unlisted read state (deferred)", { answer: { afterMs: 300, state: "deferred" } }, "allow-once"],
|
|
486
|
+
["stale_generation", { submit: { status: 409, code: "stale_generation" } }, null],
|
|
487
|
+
["activity_grant_stale read", { read: { status: 409, code: "activity_grant_stale" } }, null],
|
|
488
|
+
["refused read (said_no)", { answer: { afterMs: 300, state: "refused", reason: "said_no" } }, null],
|
|
489
|
+
["stale ask", { answer: { afterMs: 300, state: "stale" } }, null],
|
|
490
|
+
["withdrawn ask", { answer: { afterMs: 300, state: "withdrawn" } }, null],
|
|
491
|
+
];
|
|
492
|
+
await Promise.all(outcomes.map(async ([label, asks, optionId]) => {
|
|
493
|
+
const h = await open(label.replace(/[^a-z0-9]+/g, "-"), asks, [{ permission: true, holdMs: scale(800) }, {}]);
|
|
494
|
+
if (!h) return;
|
|
495
|
+
// A runner may retry a read that got no answer a few times before it permits.
|
|
496
|
+
const got = await waitFor(() => outcome(h), scale(label === "unreachable read" ? 10000 : 4000));
|
|
497
|
+
if (!optionId) {
|
|
498
|
+
r.check(`${label}: the agent gets cancelled`, got?.outcome === "cancelled", `got ${JSON.stringify(got)}`);
|
|
499
|
+
r.check(`${label}: nothing is held`, await waitFor(() => h.hooks("Stop", "end_turn")[0], scale(3000))
|
|
500
|
+
&& !h.hooks("Notification", "permission_prompt").length, "no Stop/end_turn after the cancel, or the runner posted permission_prompt");
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
r.check(`${label}: the agent gets its allow_once option`, got?.outcome === "selected" && got.optionId === optionId, `got ${JSON.stringify(got)}`);
|
|
504
|
+
await waitFor(() => h.hooks("Stop", "end_turn")[0], scale(3000));
|
|
505
|
+
await sleep(scale(300));
|
|
506
|
+
r.check(`${label}: it's delivered once`, answers(h).length === 1, `${answers(h).length} answers`);
|
|
507
|
+
r.check(`${label}: the turn's end is reported as usual`, h.hooks("Stop", "end_turn").length > 0, "no Stop/end_turn after the permit");
|
|
508
|
+
if (label === "permitted at submit") r.check(`${label}: there's no ask to read`, h.permissionCalls("GET").length === 0,
|
|
509
|
+
`${h.permissionCalls("GET").length} reads`);
|
|
510
|
+
// A read that got no answer leaves OpenRig's ask open, so it must not stay in the person's Feed after the turn.
|
|
511
|
+
if (label === "unreachable read" || label.startsWith("unlisted read")) r.check(`${label}: the ask is still withdrawn at the turn's end`,
|
|
512
|
+
await waitFor(() => withdraws(h).some((w) => w.body?.reason === "turn_ended"), scale(3000)), `withdraws: ${JSON.stringify(withdraws(h).map((w) => w.body))}`);
|
|
513
|
+
}));
|
|
514
|
+
|
|
515
|
+
// No answer: the request stays pending and visible, a pasted message isn't an answer, and /abort withdraws it, after
|
|
516
|
+
// which a late answer isn't delivered.
|
|
517
|
+
{
|
|
518
|
+
const h = await open("pending", { late: { state: "answered", optionId: "allow-once" } });
|
|
519
|
+
if (h) {
|
|
520
|
+
await sleep(scale(1500));
|
|
521
|
+
r.check("pending: the runner keeps reading the ask", h.permissionCalls("GET").length >= 1, "no read of the ask");
|
|
522
|
+
r.check("pending: nothing is delivered while no one has answered", answers(h).length === 0, `got ${JSON.stringify(outcome(h))}`);
|
|
523
|
+
r.check("pending: no idle Stop while it waits", nonExitStops(h).length === 0, nonExitStops(h).map((p) => p.body.subtype).join(", "));
|
|
524
|
+
h.paste(message(h, "allow it"));
|
|
525
|
+
await sleep(scale(800));
|
|
526
|
+
r.check("pending: a pasted message isn't an answer", answers(h).length === 0, `got ${JSON.stringify(outcome(h))}`);
|
|
527
|
+
h.paste("/abort");
|
|
528
|
+
const withdrawn = await waitFor(() => withdraws(h)[0], scale(3000));
|
|
529
|
+
r.check("pending: /abort withdraws the ask with turn_cancelled", withdrawn?.body?.reason === "turn_cancelled", `withdraw: ${JSON.stringify(withdrawn?.body)}`);
|
|
530
|
+
r.check("pending: the agent's request is answered cancelled", (await waitFor(() => outcome(h), scale(3000)))?.outcome === "cancelled",
|
|
531
|
+
`got ${JSON.stringify(outcome(h))}`);
|
|
532
|
+
// Once the ask is withdrawn no person is still waiting, so the cancelled turn's own end is reported as usual (the
|
|
533
|
+
// pasted message above runs as the next turn, so only that turn's Stop/cancelled counts).
|
|
534
|
+
r.check("pending: after /abort, the turn's end is reported, holding nothing",
|
|
535
|
+
await waitFor(() => h.hooks("Stop", "cancelled").some((p) => p.at >= (withdrawn?.at ?? 0)), scale(3000)), "no Stop/cancelled after the withdraw");
|
|
536
|
+
await sleep(scale(1200));
|
|
537
|
+
r.check("pending: an answer after the withdraw isn't delivered", answers(h).every((a) => a.msg.result?.outcome?.outcome !== "selected"),
|
|
538
|
+
`answers: ${JSON.stringify(answers(h).map((a) => a.msg.result))}`);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
// The turn ending, or the agent exiting, while the ask waits also withdraws it.
|
|
542
|
+
for (const [label, permission, reason] of [["turn end", { waitMs: scale(1500) }, "turn_ended"], ["agent exit", { exitAfterMs: scale(1500) }, "exited"]]) {
|
|
543
|
+
const h = await open(label.replace(/[^a-z]+/g, "-"), {}, [{ permission }, {}]);
|
|
544
|
+
if (!h) continue;
|
|
545
|
+
const withdrawn = await waitFor(() => withdraws(h)[0], scale(4000));
|
|
546
|
+
r.check(`${label}: the ask is withdrawn with ${reason}`, withdrawn?.body?.reason === reason, `withdraw: ${JSON.stringify(withdrawn?.body)}`);
|
|
547
|
+
if (reason === "turn_ended") r.check(`${label}: nothing is held once the ask is withdrawn`,
|
|
548
|
+
await waitFor(() => nonExitStops(h, withdrawn?.at ?? 0).length > 0, scale(3000)), "no Stop after the withdraw");
|
|
549
|
+
}
|
|
550
|
+
return r;
|
|
551
|
+
},
|
|
552
|
+
|
|
553
|
+
async "5"() {
|
|
554
|
+
const r = result("5", "Generation: every post carries the launch's occupant generation");
|
|
555
|
+
const h = await launch("5");
|
|
556
|
+
if (!r.check("the runner opens its conversation", await ready(h), "no launch record")) return r;
|
|
557
|
+
h.paste(message(h, "a short turn"));
|
|
558
|
+
await waitFor(() => h.hooks("Stop", "end_turn")[0]);
|
|
559
|
+
const all = h.posts();
|
|
560
|
+
r.check("the runner posted something", all.length > 0, "no posts");
|
|
561
|
+
r.check("generation is OPENRIG_OCCUPANT_GENERATION on every post", all.every((p) => p.body?.generation === h.generation),
|
|
562
|
+
all.map((p) => p.body?.generation).join(", "));
|
|
563
|
+
return r;
|
|
564
|
+
},
|
|
565
|
+
|
|
566
|
+
async "6"() {
|
|
567
|
+
const r = result("6", "Resume: the same conversation, or an honest missing or unconfirmed");
|
|
568
|
+
if (!opts.resume) return r.skip("the preset doesn't declare resume (--resume): OpenRig passes OPENRIG_RESUME_REF only to one that does");
|
|
569
|
+
const reopenCalls = (h) => [...h.received("session/load"), ...h.received("session/resume")];
|
|
570
|
+
{
|
|
571
|
+
const h = await launch("6-same", { scenario: { knownSessions: ["fake-old-1"] }, env: { OPENRIG_RESUME_REF: "fake-old-1" } });
|
|
572
|
+
const record = await ready(h);
|
|
573
|
+
const call = reopenCalls(h)[0];
|
|
574
|
+
r.check("same: the agent is asked to reopen OPENRIG_RESUME_REF", call?.msg.params?.sessionId === "fake-old-1",
|
|
575
|
+
call ? `asked for ${call.msg.params?.sessionId}` : "no session/load or session/resume");
|
|
576
|
+
r.check("same: in the launch's working folder", call && realpathSync(String(call.msg.params?.cwd ?? "")) === realpathSync(h.cwd),
|
|
577
|
+
`cwd=${call?.msg.params?.cwd}`);
|
|
578
|
+
r.check("same: the record reports that conversation", record?.nativeRef === "fake-old-1", `record: ${JSON.stringify(h.record())}`);
|
|
579
|
+
r.check("same: no new conversation starts", h.received("session/new").length === 0, "session/new was sent");
|
|
580
|
+
}
|
|
581
|
+
{
|
|
582
|
+
const h = await launch("6-missing", { scenario: { reopenError: "missing" }, env: { OPENRIG_RESUME_REF: "fake-gone" } });
|
|
583
|
+
const record = await waitFor(() => h.record());
|
|
584
|
+
r.check("missing: the agent's own not-found is reported as error: missing", record?.error === "missing" && !record.nativeRef,
|
|
585
|
+
`record: ${JSON.stringify(record)}`);
|
|
586
|
+
await sleep(scale(800));
|
|
587
|
+
r.check("missing: no new conversation starts", h.received("session/new").length === 0, "session/new was sent");
|
|
588
|
+
}
|
|
589
|
+
{
|
|
590
|
+
const h = await launch("6-other", { scenario: { reopenError: "error" }, env: { OPENRIG_RESUME_REF: "fake-elsewhere" } });
|
|
591
|
+
await waitFor(() => reopenCalls(h)[0] && h.log().some((e) => e.dir === "out" && e.msg.error));
|
|
592
|
+
await sleep(scale(2500));
|
|
593
|
+
const record = h.record();
|
|
594
|
+
r.check("other failure: not reported missing or resumed", !record || (record.error && record.error !== "missing" && !record.nativeRef),
|
|
595
|
+
`record: ${JSON.stringify(record)}`);
|
|
596
|
+
r.check("other failure: no new conversation starts", h.received("session/new").length === 0, "session/new was sent");
|
|
597
|
+
}
|
|
598
|
+
return r;
|
|
599
|
+
},
|
|
600
|
+
|
|
601
|
+
async "7"() {
|
|
602
|
+
const r = result("7", "Death mid-turn: Stop/<preset>_exited, never an idle report");
|
|
603
|
+
const h = await launch("7", { scenario: { turns: [{ exit: true }] } });
|
|
604
|
+
if (!r.check("the runner opens its conversation", await ready(h), "no launch record")) return r;
|
|
605
|
+
h.paste(message(h, "this turn kills the agent"));
|
|
606
|
+
const died = await waitFor(() => h.events("exit")[0]);
|
|
607
|
+
if (!r.check("the agent exits mid-turn", died, "the agent didn't exit")) return r;
|
|
608
|
+
const exited = await waitFor(() => h.hooks("Stop", `${opts.name}_exited`)[0], scale(4000));
|
|
609
|
+
r.check(`Stop/${opts.name}_exited is posted`, exited, `posts: ${h.posts().map((p) => `${p.body?.hookEvent}/${p.body?.subtype}`).join(", ")}`);
|
|
610
|
+
r.check("no idle Stop after the exit", nonExitStops(h, died.at).length === 0, nonExitStops(h, died.at).map((p) => p.body.subtype).join(", "));
|
|
611
|
+
return r;
|
|
612
|
+
},
|
|
613
|
+
|
|
614
|
+
async "7b"() {
|
|
615
|
+
const r = result("7b", "Errors: a failed prompt is a runtime error, not a permission request");
|
|
616
|
+
const h = await launch("7b", { scenario: { turns: [{ error: true }, {}] } });
|
|
617
|
+
if (!r.check("the runner opens its conversation", await ready(h), "no launch record")) return r;
|
|
618
|
+
h.paste(message(h, "this prompt fails"));
|
|
619
|
+
const posted = await waitFor(() => h.hooks("Notification", "runtime_error")[0]);
|
|
620
|
+
r.check("a failed session/prompt posts Notification/runtime_error", posted,
|
|
621
|
+
`posts: ${h.posts().map((p) => `${p.body?.hookEvent}/${p.body?.subtype}`).join(", ")}`);
|
|
622
|
+
r.check("it isn't reported as a permission request", h.hooks("Notification", "permission_prompt").length === 0, "permission_prompt posted");
|
|
623
|
+
return r;
|
|
624
|
+
},
|
|
625
|
+
|
|
626
|
+
// Section 9 marks this duty "(Proposed)", and a runner may list in `limits` what keeps running, so the result is reported
|
|
627
|
+
// on its own: never a pass or a fail, and never the exit status.
|
|
628
|
+
async "7c"() {
|
|
629
|
+
const r = result("7c", "Shutdown: closing the pane ends the agent (proposed in section 9; advisory)", { proposed: true });
|
|
630
|
+
const h = await launch("7c", { scenario: { stubborn: true } });
|
|
631
|
+
if (!r.check("the runner opens its conversation", await ready(h), "no launch record")) return r;
|
|
632
|
+
const pid = h.events("started")[0]?.pid;
|
|
633
|
+
h.stop();
|
|
634
|
+
const gone = await waitFor(() => { try { process.kill(pid, 0); return false; } catch { return true; } }, scale(5000));
|
|
635
|
+
r.check("closing the pane ends the agent process", gone, `agent pid ${pid} still running ${scale(5000) / 1000} s later; list it in limits if that's expected`);
|
|
636
|
+
if (!gone) try { process.kill(pid, "SIGKILL"); } catch { /* already gone */ }
|
|
637
|
+
return r;
|
|
638
|
+
},
|
|
639
|
+
|
|
640
|
+
async "8"() {
|
|
641
|
+
const r = result("8", "Unknown requests from the agent get -32601, and the runner carries on");
|
|
642
|
+
const h = await launch("8", { scenario: { unknownRequest: true } });
|
|
643
|
+
const answer = await waitFor(() => h.answerTo("fake/unknown_method"));
|
|
644
|
+
r.check("the unknown request is answered -32601", answer?.msg.error?.code === -32601, `answer: ${JSON.stringify(answer?.msg ?? null)}`);
|
|
645
|
+
if (!r.check("the runner opens its conversation", await ready(h), "no launch record")) return r;
|
|
646
|
+
h.paste(message(h, "still working?"));
|
|
647
|
+
r.check("the next prompt still goes through", await waitFor(() => h.prompts().length === 1), "no prompt after the unknown request");
|
|
648
|
+
return r;
|
|
649
|
+
},
|
|
650
|
+
|
|
651
|
+
async "9"() {
|
|
652
|
+
const r = result("9", "First input: OPENRIG_FIRST_INPUT's exact bytes are the first prompt");
|
|
653
|
+
if (!opts.firstInput) return r.skip("the preset doesn't declare first_input (--first-input): OpenRig passes no OPENRIG_FIRST_INPUT");
|
|
654
|
+
const dir = mkdtempSync(join(tmpdir(), "runner-check-first-"));
|
|
655
|
+
const file = join(dir, "first-input");
|
|
656
|
+
const text = "Read the plan first.\n\n Then say ready.\n";
|
|
657
|
+
writeFileSync(file, text, { mode: 0o600 });
|
|
658
|
+
const h = await launch("9", { env: { OPENRIG_FIRST_INPUT: file } });
|
|
659
|
+
const first = await waitFor(() => h.prompts()[0]);
|
|
660
|
+
r.check("the first prompt is the file's bytes, newlines and spaces included", first === text, `got ${JSON.stringify(first)}`);
|
|
661
|
+
if (!opts.keep) rmSync(dir, { recursive: true, force: true });
|
|
662
|
+
return r;
|
|
663
|
+
},
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
const order = ["1", "1b", "2", "3", "4", "4b", "5", "6", "7", "7b", "7c", "8", "9"];
|
|
667
|
+
const selected = opts.cases ?? order;
|
|
668
|
+
const unknown = selected.filter((id) => !order.includes(id));
|
|
669
|
+
if (unknown.length) { console.error(`unknown case ${unknown.join(", ")}; cases are ${order.join(", ")}`); process.exit(2); }
|
|
670
|
+
let results;
|
|
671
|
+
try {
|
|
672
|
+
results = await Promise.all(order.filter((id) => selected.includes(id)).map(async (id) => {
|
|
673
|
+
try { return await cases[id](); } catch (error) { return { id, title: id, status: "fail", checks: [{ name: "the case ran", ok: false, detail: error.message }] }; }
|
|
674
|
+
}));
|
|
675
|
+
} finally {
|
|
676
|
+
tmux("kill-server");
|
|
677
|
+
server.close();
|
|
678
|
+
// A runner or agent can still be writing its last lines as its pane closes, so cleanup waits a moment and never fails the report.
|
|
679
|
+
await sleep(scale(300));
|
|
680
|
+
if (!opts.keep) for (const h of launches) try { rmSync(h.dir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 }); } catch { /* left in the temp folder */ }
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
// A proposed duty's result is advisory: it says whether the runner met it, outside pass, fail and the exit status.
|
|
684
|
+
for (const r of results) if (r.proposed && r.status !== "skip") { r.met = r.status === "pass"; r.status = "advisory"; }
|
|
685
|
+
const summary = Object.fromEntries(["pass", "fail", "skip", "advisory"].map((s) => [s, results.filter((r) => r.status === s).length]));
|
|
686
|
+
if (opts.json) {
|
|
687
|
+
console.log(JSON.stringify({ check: "openrig-runner-conformance", format: 1, runner: opts.runner, name: opts.name, results, summary }, null, 2));
|
|
688
|
+
} else {
|
|
689
|
+
console.log(`OpenRig runner conformance check (docs/reference/harness-runner-contract.md)\nrunner: ${opts.runner}\npreset: ${opts.name}\n`);
|
|
690
|
+
for (const r of results) {
|
|
691
|
+
const label = r.status === "advisory" ? "NOTE" : r.status.toUpperCase();
|
|
692
|
+
const outcome = r.status === "advisory" ? (r.met ? ": met" : ": not met") : r.reason ? `: ${r.reason}` : "";
|
|
693
|
+
console.log(`${label.padEnd(5)} ${r.id.padEnd(3)} ${r.title}${outcome}`);
|
|
694
|
+
for (const c of r.checks.filter((c) => !c.ok)) console.log(` x ${c.name}: ${c.detail}`);
|
|
695
|
+
}
|
|
696
|
+
console.log(`\n${summary.pass} pass, ${summary.fail} fail, ${summary.skip} skipped, ${summary.advisory} advisory (not counted)${opts.keep ? `; launch folders kept under ${tmpdir()}` : ""}`);
|
|
697
|
+
}
|
|
698
|
+
process.exit(summary.fail ? 1 : 0);
|