@openrig/cli 0.7.23 → 0.7.24
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 +7 -7
- package/daemon/assets/claude-hook-bridge.cjs +575 -6
- package/daemon/assets/claude-hook-bridge.d.cts +5 -0
- package/daemon/assets/claude-permission-policies.cjs +4 -3
- package/daemon/assets/guidance/openrig-context-entry.md +1 -0
- package/daemon/assets/plugins/openrig/.claude-plugin/plugin.json +4 -3
- package/daemon/assets/plugins/openrig/.codex-plugin/plugin.json +3 -2
- package/daemon/assets/plugins/openrig/.cursor-plugin/plugin.json +1 -1
- package/daemon/assets/plugins/openrig/README.md +64 -9
- package/daemon/assets/plugins/openrig/hooks/claude.json +39 -0
- package/daemon/assets/plugins/openrig/hooks/codex.json +27 -0
- package/daemon/assets/plugins/openrig/hooks/scripts/claude-hook-bridge.cjs +715 -0
- package/daemon/assets/plugins/openrig/plugin.json +1 -1
- package/daemon/assets/plugins/openrig/scripts/run-rig.cjs +30 -0
- package/daemon/assets/plugins/openrig/skills/working-with-an-openrig-team/SKILL.md +71 -9
- package/daemon/assets/plugins/openrig-codex/.agents/plugins/marketplace.json +15 -0
- package/daemon/assets/plugins/openrig-codex/.codex-plugin/plugin.json +42 -0
- package/daemon/assets/plugins/openrig-codex/LICENSE +200 -0
- package/daemon/assets/plugins/openrig-codex/assets/logo.svg +1 -0
- package/daemon/assets/plugins/openrig-codex/hooks/codex.json +27 -0
- package/daemon/assets/plugins/openrig-codex/hooks/scripts/claude-hook-bridge.cjs +715 -0
- package/daemon/assets/plugins/openrig-codex/skills/working-with-an-openrig-team/SKILL.md +175 -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/README.md +10 -2
- package/daemon/assets/plugins/openrig-core/hooks/claude.json +9 -0
- package/daemon/assets/plugins/openrig-core/hooks/scripts/activity-relay.cjs +37 -0
- package/daemon/assets/plugins/openrig-core/hooks/scripts/compaction-restore-bridge.cjs +3 -1
- package/daemon/assets/plugins/openrig-core/hooks/scripts/permission-answer.cjs +270 -0
- package/daemon/assets/plugins/openrig-core/hooks/scripts/refocus.cjs +24 -6
- package/daemon/assets/plugins/openrig-core/skills/claude-compaction-restore/scripts/precompact-hook.mjs +7 -8
- package/daemon/assets/plugins/openrig-core/skills/claude-compaction-restore/scripts/restore-from-jsonl.mjs +45 -5
- package/daemon/assets/plugins/openrig-core/skills/openrig-user/SKILL.md +4 -2
- package/daemon/assets/plugins/openrig-core/skills/refocusing/scripts/trace-to-root.py +163 -23
- package/daemon/assets/skills/rigs/SKILL.md +122 -21
- 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 +113 -12
- package/daemon/context-packs/reference/acp-agents.md +9 -2
- package/daemon/context-packs/reference/getting-started.md +31 -7
- package/daemon/context-packs/reference/manifest.yaml +1 -1
- package/daemon/context-packs/reference/rig-spec.md +8 -0
- package/daemon/context-packs/reference/tmux-servers.md +16 -0
- package/daemon/context-packs/reference/whats-new.md +106 -12
- 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/claude-compaction-restore/scripts/precompact-hook.mjs +7 -8
- package/daemon/context-packs/skills/claude-compaction-restore/scripts/restore-from-jsonl.mjs +45 -5
- 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/core/working-with-an-openrig-team/SKILL.md +71 -9
- package/daemon/context-packs/skills/core/working-with-an-openrig-team/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/SKILL.md +4 -2
- 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/refocusing/scripts/trace-to-root.py +163 -23
- package/daemon/context-packs/skills/retiring-and-inheriting-a-seat/manifest.yaml +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 +10 -1
- package/daemon/dist/adapters/claude-code-adapter.d.ts.map +1 -1
- package/daemon/dist/adapters/claude-code-adapter.js +231 -33
- package/daemon/dist/adapters/claude-code-adapter.js.map +1 -1
- package/daemon/dist/adapters/claude-resume-launch.d.ts +3 -0
- package/daemon/dist/adapters/claude-resume-launch.d.ts.map +1 -1
- package/daemon/dist/adapters/claude-resume-launch.js +5 -0
- package/daemon/dist/adapters/claude-resume-launch.js.map +1 -1
- package/daemon/dist/adapters/claude-resume.d.ts.map +1 -1
- package/daemon/dist/adapters/claude-resume.js +59 -21
- package/daemon/dist/adapters/claude-resume.js.map +1 -1
- package/daemon/dist/adapters/community-harness-runtime-adapter.d.ts +22 -0
- package/daemon/dist/adapters/community-harness-runtime-adapter.d.ts.map +1 -1
- package/daemon/dist/adapters/community-harness-runtime-adapter.js +53 -16
- package/daemon/dist/adapters/community-harness-runtime-adapter.js.map +1 -1
- package/daemon/dist/adapters/pi-community-runtime-adapter.d.ts +9 -0
- package/daemon/dist/adapters/pi-community-runtime-adapter.d.ts.map +1 -1
- package/daemon/dist/adapters/pi-community-runtime-adapter.js +6 -0
- package/daemon/dist/adapters/pi-community-runtime-adapter.js.map +1 -1
- package/daemon/dist/adapters/pi-runtime-adapter.d.ts +3 -0
- package/daemon/dist/adapters/pi-runtime-adapter.d.ts.map +1 -1
- package/daemon/dist/adapters/pi-runtime-adapter.js +9 -3
- package/daemon/dist/adapters/pi-runtime-adapter.js.map +1 -1
- package/daemon/dist/adapters/tmux.d.ts +52 -9
- package/daemon/dist/adapters/tmux.d.ts.map +1 -1
- package/daemon/dist/adapters/tmux.js +102 -19
- package/daemon/dist/adapters/tmux.js.map +1 -1
- package/daemon/dist/build-info.js +3 -3
- package/daemon/dist/conversation-key-surface.d.ts +2 -0
- package/daemon/dist/conversation-key-surface.d.ts.map +1 -0
- package/daemon/dist/conversation-key-surface.js +5 -0
- package/daemon/dist/conversation-key-surface.js.map +1 -0
- package/daemon/dist/daemon-shutdown.d.ts +3 -0
- package/daemon/dist/daemon-shutdown.d.ts.map +1 -1
- package/daemon/dist/daemon-shutdown.js +5 -0
- package/daemon/dist/daemon-shutdown.js.map +1 -1
- 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/179_community_harness_runtime_switches.d.ts +14 -0
- package/daemon/dist/db/migrations/179_community_harness_runtime_switches.d.ts.map +1 -0
- package/daemon/dist/db/migrations/179_community_harness_runtime_switches.js +54 -0
- package/daemon/dist/db/migrations/179_community_harness_runtime_switches.js.map +1 -0
- package/daemon/dist/db/migrations/195_workflow_start_operations.d.ts +4 -0
- package/daemon/dist/db/migrations/195_workflow_start_operations.d.ts.map +1 -0
- package/daemon/dist/db/migrations/195_workflow_start_operations.js +13 -0
- package/daemon/dist/db/migrations/195_workflow_start_operations.js.map +1 -0
- package/daemon/dist/db/migrations/196_queue_item_evidence_ref_roots.d.ts +5 -0
- package/daemon/dist/db/migrations/196_queue_item_evidence_ref_roots.d.ts.map +1 -0
- package/daemon/dist/db/migrations/196_queue_item_evidence_ref_roots.js +7 -0
- package/daemon/dist/db/migrations/196_queue_item_evidence_ref_roots.js.map +1 -0
- package/daemon/dist/db/migrations/199_queue_items_native_permission_index.d.ts +9 -0
- package/daemon/dist/db/migrations/199_queue_items_native_permission_index.d.ts.map +1 -0
- package/daemon/dist/db/migrations/199_queue_items_native_permission_index.js +14 -0
- package/daemon/dist/db/migrations/199_queue_items_native_permission_index.js.map +1 -0
- package/daemon/dist/domain/agent-manifest.d.ts.map +1 -1
- package/daemon/dist/domain/agent-manifest.js +8 -0
- package/daemon/dist/domain/agent-manifest.js.map +1 -1
- package/daemon/dist/domain/background-process-evidence.d.ts +23 -0
- package/daemon/dist/domain/background-process-evidence.d.ts.map +1 -0
- package/daemon/dist/domain/background-process-evidence.js +81 -0
- package/daemon/dist/domain/background-process-evidence.js.map +1 -0
- package/daemon/dist/domain/chat-repository.d.ts +1 -1
- package/daemon/dist/domain/chat-repository.d.ts.map +1 -1
- package/daemon/dist/domain/chat-repository.js +2 -2
- package/daemon/dist/domain/chat-repository.js.map +1 -1
- package/daemon/dist/domain/claude-compaction-enforcer.d.ts +16 -6
- package/daemon/dist/domain/claude-compaction-enforcer.d.ts.map +1 -1
- package/daemon/dist/domain/claude-compaction-enforcer.js +13 -8
- package/daemon/dist/domain/claude-compaction-enforcer.js.map +1 -1
- package/daemon/dist/domain/codex-member-permissions.d.ts +35 -0
- package/daemon/dist/domain/codex-member-permissions.d.ts.map +1 -1
- package/daemon/dist/domain/codex-member-permissions.js +106 -1
- package/daemon/dist/domain/codex-member-permissions.js.map +1 -1
- package/daemon/dist/domain/community-harness-presets.d.ts +9 -0
- package/daemon/dist/domain/community-harness-presets.d.ts.map +1 -1
- package/daemon/dist/domain/community-harness-presets.js +25 -1
- package/daemon/dist/domain/community-harness-presets.js.map +1 -1
- package/daemon/dist/domain/current-work.d.ts +31 -4
- package/daemon/dist/domain/current-work.d.ts.map +1 -1
- package/daemon/dist/domain/current-work.js +48 -3
- package/daemon/dist/domain/current-work.js.map +1 -1
- package/daemon/dist/domain/feed/attention-aggregator.d.ts +5 -5
- package/daemon/dist/domain/feed/attention-aggregator.d.ts.map +1 -1
- package/daemon/dist/domain/feed/attention-aggregator.js +10 -4
- package/daemon/dist/domain/feed/attention-aggregator.js.map +1 -1
- package/daemon/dist/domain/files/path-safety.d.ts +7 -0
- package/daemon/dist/domain/files/path-safety.d.ts.map +1 -1
- package/daemon/dist/domain/files/path-safety.js +23 -0
- package/daemon/dist/domain/files/path-safety.js.map +1 -1
- package/daemon/dist/domain/frontmatter.d.ts.map +1 -1
- package/daemon/dist/domain/frontmatter.js +4 -2
- package/daemon/dist/domain/frontmatter.js.map +1 -1
- package/daemon/dist/domain/gateway/destination-resolver.d.ts +3 -0
- package/daemon/dist/domain/gateway/destination-resolver.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/destination-resolver.js +9 -0
- package/daemon/dist/domain/gateway/destination-resolver.js.map +1 -1
- package/daemon/dist/domain/gateway/human-quiet-windows.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/human-quiet-windows.js +2 -1
- package/daemon/dist/domain/gateway/human-quiet-windows.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/inbound.d.ts +6 -1
- package/daemon/dist/domain/gateway/slack/inbound.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/inbound.js +4 -1
- package/daemon/dist/domain/gateway/slack/inbound.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/message.d.ts +3 -0
- package/daemon/dist/domain/gateway/slack/message.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/message.js +3 -2
- package/daemon/dist/domain/gateway/slack/message.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/outbound-driver.d.ts +4 -0
- package/daemon/dist/domain/gateway/slack/outbound-driver.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/outbound-driver.js +1 -0
- package/daemon/dist/domain/gateway/slack/outbound-driver.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/queue-access.d.ts +2 -0
- package/daemon/dist/domain/gateway/slack/queue-access.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/queue-access.js +1 -0
- package/daemon/dist/domain/gateway/slack/queue-access.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/slack-delivery.d.ts +10 -2
- package/daemon/dist/domain/gateway/slack/slack-delivery.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/slack-delivery.js +60 -6
- package/daemon/dist/domain/gateway/slack/slack-delivery.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/slack-subsystem.d.ts +3 -13
- package/daemon/dist/domain/gateway/slack/slack-subsystem.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/slack-subsystem.js +70 -22
- package/daemon/dist/domain/gateway/slack/slack-subsystem.js.map +1 -1
- package/daemon/dist/domain/health-detectors.d.ts +4 -0
- package/daemon/dist/domain/health-detectors.d.ts.map +1 -1
- package/daemon/dist/domain/health-detectors.js +4 -1
- package/daemon/dist/domain/health-detectors.js.map +1 -1
- package/daemon/dist/domain/health-diagnosis.d.ts.map +1 -1
- package/daemon/dist/domain/health-diagnosis.js +14 -9
- package/daemon/dist/domain/health-diagnosis.js.map +1 -1
- package/daemon/dist/domain/health-passive-ceremony.d.ts +2 -0
- package/daemon/dist/domain/health-passive-ceremony.d.ts.map +1 -1
- package/daemon/dist/domain/health-passive-ceremony.js +71 -13
- package/daemon/dist/domain/health-passive-ceremony.js.map +1 -1
- package/daemon/dist/domain/history-query.d.ts +1 -1
- package/daemon/dist/domain/history-query.d.ts.map +1 -1
- package/daemon/dist/domain/history-query.js +1 -2
- package/daemon/dist/domain/history-query.js.map +1 -1
- package/daemon/dist/domain/hosts/read-through.d.ts.map +1 -1
- package/daemon/dist/domain/hosts/read-through.js +6 -0
- package/daemon/dist/domain/hosts/read-through.js.map +1 -1
- package/daemon/dist/domain/managed-restore-read-access.d.ts +18 -0
- package/daemon/dist/domain/managed-restore-read-access.d.ts.map +1 -1
- package/daemon/dist/domain/managed-restore-read-access.js +41 -1
- package/daemon/dist/domain/managed-restore-read-access.js.map +1 -1
- package/daemon/dist/domain/mission-control/audit-browse.d.ts +1 -1
- package/daemon/dist/domain/mission-control/audit-browse.d.ts.map +1 -1
- package/daemon/dist/domain/mission-control/audit-browse.js +3 -6
- package/daemon/dist/domain/mission-control/audit-browse.js.map +1 -1
- 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 +21 -4
- package/daemon/dist/domain/mission-control/mission-control-write-contract.js.map +1 -1
- package/daemon/dist/domain/native-resume-probe.d.ts +22 -0
- package/daemon/dist/domain/native-resume-probe.d.ts.map +1 -1
- package/daemon/dist/domain/native-resume-probe.js +30 -0
- package/daemon/dist/domain/native-resume-probe.js.map +1 -1
- package/daemon/dist/domain/network/network-requests.d.ts +3 -2
- package/daemon/dist/domain/network/network-requests.d.ts.map +1 -1
- package/daemon/dist/domain/network/network-requests.js +34 -8
- package/daemon/dist/domain/network/network-requests.js.map +1 -1
- package/daemon/dist/domain/node-launcher.d.ts +2 -2
- package/daemon/dist/domain/node-launcher.d.ts.map +1 -1
- package/daemon/dist/domain/node-launcher.js +9 -7
- package/daemon/dist/domain/node-launcher.js.map +1 -1
- package/daemon/dist/domain/pane-cutover.d.ts +36 -9
- package/daemon/dist/domain/pane-cutover.d.ts.map +1 -1
- package/daemon/dist/domain/pane-cutover.js +82 -13
- package/daemon/dist/domain/pane-cutover.js.map +1 -1
- package/daemon/dist/domain/projection-planner.d.ts +17 -3
- package/daemon/dist/domain/projection-planner.d.ts.map +1 -1
- package/daemon/dist/domain/projection-planner.js +9 -1
- package/daemon/dist/domain/projection-planner.js.map +1 -1
- package/daemon/dist/domain/queue-destination-check.d.ts +8 -0
- package/daemon/dist/domain/queue-destination-check.d.ts.map +1 -1
- package/daemon/dist/domain/queue-destination-check.js +17 -4
- package/daemon/dist/domain/queue-destination-check.js.map +1 -1
- package/daemon/dist/domain/queue-erasure.js +1 -1
- package/daemon/dist/domain/queue-repository.d.ts +20 -1
- package/daemon/dist/domain/queue-repository.d.ts.map +1 -1
- package/daemon/dist/domain/queue-repository.js +93 -14
- package/daemon/dist/domain/queue-repository.js.map +1 -1
- package/daemon/dist/domain/queue-stuck-sweep.d.ts +23 -3
- package/daemon/dist/domain/queue-stuck-sweep.d.ts.map +1 -1
- package/daemon/dist/domain/queue-stuck-sweep.js +618 -13
- package/daemon/dist/domain/queue-stuck-sweep.js.map +1 -1
- package/daemon/dist/domain/queue-transfer-export.d.ts +1 -1
- package/daemon/dist/domain/queue-transfer-export.d.ts.map +1 -1
- package/daemon/dist/domain/queue-transfer-export.js +3 -1
- package/daemon/dist/domain/queue-transfer-export.js.map +1 -1
- package/daemon/dist/domain/queue-transition-log.d.ts +6 -0
- package/daemon/dist/domain/queue-transition-log.d.ts.map +1 -1
- package/daemon/dist/domain/queue-transition-log.js +1 -1
- package/daemon/dist/domain/queue-transition-log.js.map +1 -1
- package/daemon/dist/domain/queue-waiting.d.ts.map +1 -1
- package/daemon/dist/domain/queue-waiting.js +7 -0
- package/daemon/dist/domain/queue-waiting.js.map +1 -1
- package/daemon/dist/domain/queue-wake-ladder.d.ts.map +1 -1
- package/daemon/dist/domain/queue-wake-ladder.js +20 -4
- package/daemon/dist/domain/queue-wake-ladder.js.map +1 -1
- package/daemon/dist/domain/rehydrate-eligibility.d.ts +8 -0
- package/daemon/dist/domain/rehydrate-eligibility.d.ts.map +1 -1
- package/daemon/dist/domain/rehydrate-eligibility.js +61 -9
- package/daemon/dist/domain/rehydrate-eligibility.js.map +1 -1
- package/daemon/dist/domain/restore-check-service.d.ts.map +1 -1
- package/daemon/dist/domain/restore-check-service.js +5 -2
- package/daemon/dist/domain/restore-check-service.js.map +1 -1
- package/daemon/dist/domain/restore-orchestrator.d.ts +3 -0
- package/daemon/dist/domain/restore-orchestrator.d.ts.map +1 -1
- package/daemon/dist/domain/restore-orchestrator.js +42 -0
- package/daemon/dist/domain/restore-orchestrator.js.map +1 -1
- package/daemon/dist/domain/return-route.d.ts +13 -2
- package/daemon/dist/domain/return-route.d.ts.map +1 -1
- package/daemon/dist/domain/return-route.js +30 -1
- package/daemon/dist/domain/return-route.js.map +1 -1
- package/daemon/dist/domain/rig-lifecycle-service.d.ts +1 -0
- package/daemon/dist/domain/rig-lifecycle-service.d.ts.map +1 -1
- package/daemon/dist/domain/rig-lifecycle-service.js +23 -2
- package/daemon/dist/domain/rig-lifecycle-service.js.map +1 -1
- package/daemon/dist/domain/rig-mode/operating-posture.d.ts.map +1 -1
- package/daemon/dist/domain/rig-mode/operating-posture.js +23 -4
- package/daemon/dist/domain/rig-mode/operating-posture.js.map +1 -1
- package/daemon/dist/domain/rig-teardown.d.ts +30 -2
- package/daemon/dist/domain/rig-teardown.d.ts.map +1 -1
- package/daemon/dist/domain/rig-teardown.js +76 -8
- package/daemon/dist/domain/rig-teardown.js.map +1 -1
- package/daemon/dist/domain/rigspec-instantiator.d.ts +11 -9
- package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
- package/daemon/dist/domain/rigspec-instantiator.js +100 -43
- package/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
- package/daemon/dist/domain/rigspec-preflight.d.ts.map +1 -1
- package/daemon/dist/domain/rigspec-preflight.js +26 -3
- package/daemon/dist/domain/rigspec-preflight.js.map +1 -1
- package/daemon/dist/domain/roster-ready-notice.d.ts +11 -0
- package/daemon/dist/domain/roster-ready-notice.d.ts.map +1 -0
- package/daemon/dist/domain/roster-ready-notice.js +35 -0
- package/daemon/dist/domain/roster-ready-notice.js.map +1 -0
- package/daemon/dist/domain/runner-permissions.d.ts +140 -5
- package/daemon/dist/domain/runner-permissions.d.ts.map +1 -1
- package/daemon/dist/domain/runner-permissions.js +593 -16
- package/daemon/dist/domain/runner-permissions.js.map +1 -1
- package/daemon/dist/domain/runtime-adapter.d.ts +3 -1
- package/daemon/dist/domain/runtime-adapter.d.ts.map +1 -1
- package/daemon/dist/domain/runtime-exit.d.ts +79 -0
- package/daemon/dist/domain/runtime-exit.d.ts.map +1 -0
- package/daemon/dist/domain/runtime-exit.js +301 -0
- package/daemon/dist/domain/runtime-exit.js.map +1 -0
- package/daemon/dist/domain/runtime-switch-materials.d.ts +4 -1
- package/daemon/dist/domain/runtime-switch-materials.d.ts.map +1 -1
- package/daemon/dist/domain/runtime-switch-materials.js +66 -13
- package/daemon/dist/domain/runtime-switch-materials.js.map +1 -1
- package/daemon/dist/domain/scope/attestation-lineage.generated.js +2 -2
- package/daemon/dist/domain/scope/attestation-lineage.generated.js.map +1 -1
- package/daemon/dist/domain/scope/logical-checkbox.d.ts.map +1 -1
- package/daemon/dist/domain/scope/logical-checkbox.js +18 -0
- package/daemon/dist/domain/scope/logical-checkbox.js.map +1 -1
- package/daemon/dist/domain/scope/scaffold-placeholder.js +2 -2
- package/daemon/dist/domain/scope/scaffold-placeholder.js.map +1 -1
- package/daemon/dist/domain/seat-attention-reconciler.d.ts.map +1 -1
- package/daemon/dist/domain/seat-attention-reconciler.js +5 -2
- package/daemon/dist/domain/seat-attention-reconciler.js.map +1 -1
- package/daemon/dist/domain/seat-handover-service.d.ts +5 -2
- package/daemon/dist/domain/seat-handover-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-handover-service.js +30 -6
- package/daemon/dist/domain/seat-handover-service.js.map +1 -1
- package/daemon/dist/domain/seat-identity-reconciler.d.ts +18 -0
- package/daemon/dist/domain/seat-identity-reconciler.d.ts.map +1 -1
- package/daemon/dist/domain/seat-identity-reconciler.js +155 -6
- package/daemon/dist/domain/seat-identity-reconciler.js.map +1 -1
- package/daemon/dist/domain/seat-launch-environment.d.ts +6 -0
- package/daemon/dist/domain/seat-launch-environment.d.ts.map +1 -1
- package/daemon/dist/domain/seat-launch-environment.js +28 -4
- package/daemon/dist/domain/seat-launch-environment.js.map +1 -1
- package/daemon/dist/domain/seat-lifecycle-service.d.ts +37 -1
- package/daemon/dist/domain/seat-lifecycle-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-lifecycle-service.js +44 -8
- package/daemon/dist/domain/seat-lifecycle-service.js.map +1 -1
- package/daemon/dist/domain/seat-pool-executor.d.ts +61 -3
- package/daemon/dist/domain/seat-pool-executor.d.ts.map +1 -1
- package/daemon/dist/domain/seat-pool-executor.js +735 -59
- package/daemon/dist/domain/seat-pool-executor.js.map +1 -1
- package/daemon/dist/domain/seat-pool-slots.d.ts +24 -0
- package/daemon/dist/domain/seat-pool-slots.d.ts.map +1 -1
- package/daemon/dist/domain/seat-pool-slots.js +50 -0
- package/daemon/dist/domain/seat-pool-slots.js.map +1 -1
- package/daemon/dist/domain/seat-runtime-switch-service.d.ts +2 -1
- package/daemon/dist/domain/seat-runtime-switch-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-runtime-switch-service.js +68 -20
- package/daemon/dist/domain/seat-runtime-switch-service.js.map +1 -1
- package/daemon/dist/domain/session-transport.d.ts.map +1 -1
- package/daemon/dist/domain/session-transport.js +9 -2
- package/daemon/dist/domain/session-transport.js.map +1 -1
- package/daemon/dist/domain/skill-catalog.d.ts.map +1 -1
- package/daemon/dist/domain/skill-catalog.js +24 -10
- package/daemon/dist/domain/skill-catalog.js.map +1 -1
- package/daemon/dist/domain/startup-orchestrator.d.ts +5 -1
- package/daemon/dist/domain/startup-orchestrator.d.ts.map +1 -1
- package/daemon/dist/domain/startup-orchestrator.js +43 -7
- package/daemon/dist/domain/startup-orchestrator.js.map +1 -1
- package/daemon/dist/domain/startup-submission-evidence.d.ts +1 -0
- package/daemon/dist/domain/startup-submission-evidence.d.ts.map +1 -1
- package/daemon/dist/domain/startup-submission-evidence.js +5 -0
- package/daemon/dist/domain/startup-submission-evidence.js.map +1 -1
- package/daemon/dist/domain/stream-reader-actions.d.ts +23 -0
- package/daemon/dist/domain/stream-reader-actions.d.ts.map +1 -1
- package/daemon/dist/domain/stream-reader-actions.js +43 -0
- package/daemon/dist/domain/stream-reader-actions.js.map +1 -1
- package/daemon/dist/domain/successor-session-launcher.d.ts +24 -3
- package/daemon/dist/domain/successor-session-launcher.d.ts.map +1 -1
- package/daemon/dist/domain/successor-session-launcher.js +54 -23
- package/daemon/dist/domain/successor-session-launcher.js.map +1 -1
- package/daemon/dist/domain/terminal/earlier-tile-attach-0723.d.ts +2 -0
- package/daemon/dist/domain/terminal/earlier-tile-attach-0723.d.ts.map +1 -0
- package/daemon/dist/domain/terminal/earlier-tile-attach-0723.js +48 -0
- package/daemon/dist/domain/terminal/earlier-tile-attach-0723.js.map +1 -0
- package/daemon/dist/domain/terminal/rex-agent-status.d.ts.map +1 -1
- package/daemon/dist/domain/terminal/rex-agent-status.js +5 -2
- package/daemon/dist/domain/terminal/rex-agent-status.js.map +1 -1
- package/daemon/dist/domain/terminal/tile-attach.d.ts +11 -5
- package/daemon/dist/domain/terminal/tile-attach.d.ts.map +1 -1
- package/daemon/dist/domain/terminal/tile-attach.js +32 -12
- package/daemon/dist/domain/terminal/tile-attach.js.map +1 -1
- package/daemon/dist/domain/transcript-redaction.d.ts +10 -8
- package/daemon/dist/domain/transcript-redaction.d.ts.map +1 -1
- package/daemon/dist/domain/transcript-redaction.js +51 -22
- package/daemon/dist/domain/transcript-redaction.js.map +1 -1
- package/daemon/dist/domain/types.d.ts +7 -1
- package/daemon/dist/domain/types.d.ts.map +1 -1
- package/daemon/dist/domain/types.js +3 -0
- package/daemon/dist/domain/types.js.map +1 -1
- package/daemon/dist/domain/whoami-service.d.ts +11 -0
- package/daemon/dist/domain/whoami-service.d.ts.map +1 -1
- package/daemon/dist/domain/whoami-service.js +13 -0
- package/daemon/dist/domain/whoami-service.js.map +1 -1
- package/daemon/dist/domain/workflow-reconciliation.d.ts.map +1 -1
- package/daemon/dist/domain/workflow-reconciliation.js +9 -0
- package/daemon/dist/domain/workflow-reconciliation.js.map +1 -1
- package/daemon/dist/domain/workflow-runtime.d.ts +2 -0
- package/daemon/dist/domain/workflow-runtime.d.ts.map +1 -1
- package/daemon/dist/domain/workflow-runtime.js +45 -2
- package/daemon/dist/domain/workflow-runtime.js.map +1 -1
- package/daemon/dist/routes/activity.d.ts.map +1 -1
- package/daemon/dist/routes/activity.js +59 -2
- package/daemon/dist/routes/activity.js.map +1 -1
- package/daemon/dist/routes/compaction.d.ts.map +1 -1
- package/daemon/dist/routes/compaction.js +26 -9
- package/daemon/dist/routes/compaction.js.map +1 -1
- package/daemon/dist/routes/queue.d.ts.map +1 -1
- package/daemon/dist/routes/queue.js +64 -25
- package/daemon/dist/routes/queue.js.map +1 -1
- package/daemon/dist/routes/require-sender-identity.d.ts +15 -0
- package/daemon/dist/routes/require-sender-identity.d.ts.map +1 -1
- package/daemon/dist/routes/require-sender-identity.js +51 -5
- package/daemon/dist/routes/require-sender-identity.js.map +1 -1
- package/daemon/dist/routes/seat.js +6 -0
- package/daemon/dist/routes/seat.js.map +1 -1
- package/daemon/dist/routes/stream.d.ts.map +1 -1
- package/daemon/dist/routes/stream.js +28 -1
- package/daemon/dist/routes/stream.js.map +1 -1
- package/daemon/dist/routes/workflow.d.ts.map +1 -1
- package/daemon/dist/routes/workflow.js +48 -41
- package/daemon/dist/routes/workflow.js.map +1 -1
- package/daemon/dist/server.d.ts.map +1 -1
- package/daemon/dist/server.js +17 -1
- package/daemon/dist/server.js.map +1 -1
- package/daemon/dist/startup.d.ts.map +1 -1
- package/daemon/dist/startup.js +34 -6
- package/daemon/dist/startup.js.map +1 -1
- package/daemon/dist/transcript-redaction-surface.d.ts +2 -0
- package/daemon/dist/transcript-redaction-surface.d.ts.map +1 -0
- package/daemon/dist/transcript-redaction-surface.js +2 -0
- package/daemon/dist/transcript-redaction-surface.js.map +1 -0
- package/daemon/docs/reference/acp-agents.md +9 -2
- package/daemon/docs/reference/agent-spec.md +22 -1
- package/daemon/docs/reference/agent-startup-guide.md +10 -0
- package/daemon/docs/reference/community-harness-examples/cursor/cursor.yaml +3 -1
- package/daemon/docs/reference/community-harness-presets.md +27 -2
- package/daemon/docs/reference/daemon-http-clients.md +57 -0
- package/daemon/docs/reference/developing.md +3 -2
- package/daemon/docs/reference/getting-started.md +31 -7
- package/daemon/docs/reference/harness-runner-contract.md +72 -0
- package/daemon/docs/reference/hosted-members.md +21 -2
- package/daemon/docs/reference/network-connector.md +32 -3
- package/daemon/docs/reference/quickstart.md +4 -4
- package/daemon/docs/reference/refocus-channel.md +48 -0
- package/daemon/docs/reference/rig-bundle.md +11 -1
- package/daemon/docs/reference/rig-spec.md +8 -0
- package/daemon/docs/reference/seat-node-targeting.md +10 -0
- package/daemon/docs/reference/seat-pools.md +76 -10
- package/daemon/docs/reference/slack-app-setup.md +15 -0
- package/daemon/docs/reference/terminal-sessions.md +71 -3
- package/daemon/docs/reference/tmux-servers.md +16 -0
- package/daemon/docs/reference/whats-new.md +106 -12
- package/daemon/specs/agents/shared/skills/core/working-with-an-openrig-team/SKILL.md +71 -9
- package/daemon/specs/rigs/launch/factory/guidance/lead-first-move.md +4 -1
- package/daemon/specs/rigs/launch/kernel/agents/operator/agent/guidance/role.md +2 -1
- package/daemon/specs/rigs/launch/starter/guidance/lead-first-move.md +4 -1
- package/dist/bin-wrapper.d.ts.map +1 -1
- package/dist/bin-wrapper.js +24 -5
- package/dist/bin-wrapper.js.map +1 -1
- package/dist/build-info.js +3 -3
- package/dist/client.d.ts +4 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +7 -1
- package/dist/client.js.map +1 -1
- package/dist/commands/add.js +1 -1
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/agent.js +1 -1
- package/dist/commands/agent.js.map +1 -1
- package/dist/commands/bundle.d.ts.map +1 -1
- package/dist/commands/bundle.js +18 -4
- package/dist/commands/bundle.js.map +1 -1
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +6 -2
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/down.d.ts.map +1 -1
- package/dist/commands/down.js +12 -1
- package/dist/commands/down.js.map +1 -1
- package/dist/commands/expand.js +1 -1
- package/dist/commands/expand.js.map +1 -1
- package/dist/commands/fork.js +1 -1
- package/dist/commands/fork.js.map +1 -1
- package/dist/commands/grow.d.ts.map +1 -1
- package/dist/commands/grow.js +9 -4
- package/dist/commands/grow.js.map +1 -1
- package/dist/commands/import.js +1 -1
- package/dist/commands/import.js.map +1 -1
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +57 -22
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/network.d.ts +2 -3
- package/dist/commands/network.d.ts.map +1 -1
- package/dist/commands/network.js +54 -9
- package/dist/commands/network.js.map +1 -1
- package/dist/commands/ps.d.ts +1 -0
- package/dist/commands/ps.d.ts.map +1 -1
- package/dist/commands/ps.js +22 -19
- package/dist/commands/ps.js.map +1 -1
- package/dist/commands/queue.d.ts +2 -0
- package/dist/commands/queue.d.ts.map +1 -1
- package/dist/commands/queue.js +29 -6
- package/dist/commands/queue.js.map +1 -1
- package/dist/commands/reconcile-session.js +1 -1
- package/dist/commands/reconcile-session.js.map +1 -1
- package/dist/commands/restore.js +1 -1
- package/dist/commands/restore.js.map +1 -1
- package/dist/commands/rig.js +2 -2
- package/dist/commands/rig.js.map +1 -1
- package/dist/commands/seat.d.ts.map +1 -1
- package/dist/commands/seat.js +55 -16
- package/dist/commands/seat.js.map +1 -1
- package/dist/commands/skill.js +1 -1
- package/dist/commands/skill.js.map +1 -1
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +3 -2
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/terminal.d.ts.map +1 -1
- package/dist/commands/terminal.js +20 -4
- package/dist/commands/terminal.js.map +1 -1
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +2 -1
- package/dist/commands/up.js.map +1 -1
- package/dist/commands/whoami.d.ts.map +1 -1
- package/dist/commands/whoami.js +6 -0
- package/dist/commands/whoami.js.map +1 -1
- package/dist/commands/workflow-follow.d.ts.map +1 -1
- package/dist/commands/workflow-follow.js +37 -34
- package/dist/commands/workflow-follow.js.map +1 -1
- package/dist/commands/workflow-render.d.ts +1 -1
- package/dist/commands/workflow-render.d.ts.map +1 -1
- package/dist/commands/workflow-render.js +2 -7
- package/dist/commands/workflow-render.js.map +1 -1
- package/dist/commands/workflow.d.ts.map +1 -1
- package/dist/commands/workflow.js +22 -2
- package/dist/commands/workflow.js.map +1 -1
- package/dist/daemon-lifecycle.d.ts +24 -0
- package/dist/daemon-lifecycle.d.ts.map +1 -1
- package/dist/daemon-lifecycle.js +45 -8
- package/dist/daemon-lifecycle.js.map +1 -1
- package/dist/lib/bundle-source.d.ts +4 -0
- package/dist/lib/bundle-source.d.ts.map +1 -1
- package/dist/lib/bundle-source.js +14 -2
- package/dist/lib/bundle-source.js.map +1 -1
- package/dist/lib/context-git.js +2 -2
- package/dist/lib/context-git.js.map +1 -1
- package/dist/lib/frontmatter.d.ts.map +1 -1
- package/dist/lib/frontmatter.js +4 -2
- package/dist/lib/frontmatter.js.map +1 -1
- package/dist/lib/scope/attestation-lineage.js +2 -2
- package/dist/lib/scope/attestation-lineage.js.map +1 -1
- package/dist/lib/scope/logical-checkbox.d.ts.map +1 -1
- package/dist/lib/scope/logical-checkbox.js +18 -0
- package/dist/lib/scope/logical-checkbox.js.map +1 -1
- package/dist/lib/scope/progress-edit.js +1 -1
- package/dist/lib/scope/progress-edit.js.map +1 -1
- package/dist/lib/scope/scaffold-placeholder.js +2 -2
- package/dist/lib/scope/scaffold-placeholder.js.map +1 -1
- package/dist/lib/terminal-cell.d.ts +5 -0
- package/dist/lib/terminal-cell.d.ts.map +1 -0
- package/dist/lib/terminal-cell.js +22 -0
- package/dist/lib/terminal-cell.js.map +1 -0
- package/dist/mcp-http.d.ts +1 -1
- package/dist/mcp-http.d.ts.map +1 -1
- package/dist/mcp-http.js +6 -3
- package/dist/mcp-http.js.map +1 -1
- package/dist/mcp-server.d.ts +5 -1
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/mcp-server.js +111 -13
- package/dist/mcp-server.js.map +1 -1
- package/dist/release-surface/extract-surface.d.ts.map +1 -1
- package/dist/release-surface/extract-surface.js +38 -20
- package/dist/release-surface/extract-surface.js.map +1 -1
- package/dist/release-surface/generate.d.ts.map +1 -1
- package/dist/release-surface/generate.js +3 -0
- package/dist/release-surface/generate.js.map +1 -1
- package/dist/release-surface/surface-diff.d.ts +1 -0
- package/dist/release-surface/surface-diff.d.ts.map +1 -1
- package/dist/release-surface/surface-diff.js +19 -18
- package/dist/release-surface/surface-diff.js.map +1 -1
- package/dist/restore-packet/redaction.d.ts +4 -26
- package/dist/restore-packet/redaction.d.ts.map +1 -1
- package/dist/restore-packet/redaction.js +19 -63
- package/dist/restore-packet/redaction.js.map +1 -1
- package/dist/terminal-orca.d.ts +7 -0
- package/dist/terminal-orca.d.ts.map +1 -0
- package/dist/terminal-orca.js +239 -0
- package/dist/terminal-orca.js.map +1 -0
- package/package.json +1 -1
- package/tui/dist/connected-assistants.d.ts +1 -1
- package/tui/dist/connected-assistants.d.ts.map +1 -1
- package/tui/dist/connected-assistants.js +3 -1
- package/tui/dist/connected-assistants.js.map +1 -1
- package/tui/dist/daemon-client.d.ts +4 -0
- package/tui/dist/daemon-client.d.ts.map +1 -1
- package/tui/dist/daemon-client.js +12 -8
- package/tui/dist/daemon-client.js.map +1 -1
- package/tui/dist/health/health-model.d.ts.map +1 -1
- package/tui/dist/health/health-model.js +2 -0
- package/tui/dist/health/health-model.js.map +1 -1
- package/tui/dist/hydrate.d.ts +3 -1
- package/tui/dist/hydrate.d.ts.map +1 -1
- package/tui/dist/hydrate.js +40 -25
- package/tui/dist/hydrate.js.map +1 -1
- package/tui/dist/live.d.ts +5 -1
- package/tui/dist/live.d.ts.map +1 -1
- package/tui/dist/live.js +20 -2
- package/tui/dist/live.js.map +1 -1
- package/tui/dist/main.js +5 -2
- package/tui/dist/main.js.map +1 -1
- package/tui/dist/pulse/pulse-model.d.ts.map +1 -1
- package/tui/dist/pulse/pulse-model.js +3 -2
- package/tui/dist/pulse/pulse-model.js.map +1 -1
- package/tui/dist/render.d.ts.map +1 -1
- package/tui/dist/render.js +6 -5
- package/tui/dist/render.js.map +1 -1
- package/tui/dist/types.d.ts +10 -4
- package/tui/dist/types.d.ts.map +1 -1
- package/ui/dist/assets/index-Chh-NS8Z.css +32 -0
- package/ui/dist/assets/index-DG_7XFcL.js +628 -0
- package/ui/dist/index.html +2 -2
- package/ui/dist/assets/index-B-sMy02c.js +0 -623
- package/ui/dist/assets/index-DiN7RwWg.css +0 -32
|
@@ -4,9 +4,18 @@
|
|
|
4
4
|
// runner reads the one answer back and gives it to that same live request. With no one to ask, or an ask closed without
|
|
5
5
|
// a choice, OpenRig's default is permit with the agent's own allow option; a person's no is never a grant, and only the
|
|
6
6
|
// seat's opt-in (`--deny`) refuses every request. Each default permit leaves one pull-only record on the stream.
|
|
7
|
+
//
|
|
8
|
+
// A native ask (slice 15) is the same contract for a harness's own permission prompt, submitted by that harness's
|
|
9
|
+
// permission hook (Claude Code's PermissionRequest): the prompt stays open in the seat's terminal while the person can
|
|
10
|
+
// answer here too. It differs where a default would decide for the person: with no one to ask it is not asked (no permit,
|
|
11
|
+
// no refusal), and the harness's prompt carries on; an ask closed without an answer is unanswered, never permitted. Its
|
|
12
|
+
// owner can also be the return route of the work the seat is running (the person's own conversation). A person's pick of
|
|
13
|
+
// an offered option, or a plain yes or no, is their own answer; only their words go to an agent to judge.
|
|
7
14
|
import { ActivityGrantStore } from "./activity-grants.js";
|
|
8
15
|
import { createHash } from "node:crypto";
|
|
9
16
|
import { isHumanSeatSessionRef } from "./session-name.js";
|
|
17
|
+
import { routeOnThisHost } from "./return-route.js";
|
|
18
|
+
import { redactTranscriptContent } from "./transcript-redaction.js";
|
|
10
19
|
import { resolveRegisteredHumanAddress } from "./gateway/human-registry.js";
|
|
11
20
|
import { resolveDefaultPerson } from "./gateway/participants.js";
|
|
12
21
|
import { MAX_OPTION_LABEL, MAX_QUESTION_TEXT } from "./human-questions.js";
|
|
@@ -44,13 +53,126 @@ const SAID_YES = new Set(["yes", "y", "yep", "yeah", "ok", "okay", "sure", "fine
|
|
|
44
53
|
"accept", "accepted", "permit", "permitted", "go", "go ahead", "do it", "lgtm"]);
|
|
45
54
|
const SAID_NO = new Set(["no", "n", "nope", "deny", "denied", "reject", "rejected", "refuse", "refused", "decline", "declined",
|
|
46
55
|
"don't", "dont", "do not", "stop", "no thanks"]);
|
|
56
|
+
/** A native ask's harness (the one whose own permission prompt it is), e.g. `permission-native-hook:claude-code`. */
|
|
57
|
+
const NATIVE_HOOK_TAG = "permission-native-hook:";
|
|
58
|
+
/** The fingerprint of the native tool call (its conversation, actor, tool and exact input), to match its later completion. */
|
|
59
|
+
const CALL_TAG = "permission-call:";
|
|
60
|
+
/** Who in the native conversation asked: `main`, or a subagent's id. */
|
|
61
|
+
const ACTOR_TAG = "permission-actor:";
|
|
62
|
+
/** Until when the harness's hook takes an answer here; after it (and a grace), an open native ask is over. */
|
|
63
|
+
const ANSWER_BY_TAG = "permission-answer-by:";
|
|
64
|
+
/** Which owner source a native ask went to: chosen-person, return-route or default-person. */
|
|
65
|
+
const ASKED_TAG = "permission-asked:";
|
|
66
|
+
/** Each option a native ask offers. An ask to a conversation can't carry questions (only a person's ask does), so its
|
|
67
|
+
* options travel as these. */
|
|
68
|
+
const OPTION_TAG = "permission-option:";
|
|
69
|
+
/** The harness's hook took the answer: recorded on the row that holds the decision, before the hook returns it. */
|
|
70
|
+
const TAKEN_NOTE = "runner-permission-taken-by-hook";
|
|
71
|
+
/** A tool call with this ask's exact input completed in the same conversation (matched by content, not by id). */
|
|
72
|
+
const COMPLETED_NOTE = "runner-permission-tool-completed";
|
|
73
|
+
/** An agent's decision on a request (`rig seat decide-permission`), whoever records it. */
|
|
74
|
+
const DECIDED_NOTE = "runner-permission-decided";
|
|
75
|
+
/** A decision an agent records with `--relay`: its report that this is the person's own answer. OpenRig didn't get that
|
|
76
|
+
* answer from the person, so it stays unconfirmed, whoever the caller is or says it is. */
|
|
77
|
+
const RELAYED_DECISION = `${DECIDED_NOTE} as relayed by`;
|
|
78
|
+
/** The words a native decision's note ends with, each as a JSON string: the person's own as OpenRig received them, and
|
|
79
|
+
* what the decider reported they said. Its other text (the decider, a checked option id) can't end the note this way. */
|
|
80
|
+
const QUOTED = String.raw `"(?:[^"\\]|\\.)*"`;
|
|
81
|
+
const DECISION_WORDS = new RegExp(`(?:, because ${QUOTED})?(?:; the person wrote (${QUOTED}))?(?:; the decider reported they said (${QUOTED}))?$`);
|
|
82
|
+
/** The rows that can be a native ask: the WHERE clause of idx_queue_items_native_permission (migration 199), repeated byte
|
|
83
|
+
* for byte, which is what lets the planner read that small index instead of every row a seat ever sent. */
|
|
84
|
+
const NATIVE_ASK_ROWS = `tags LIKE '%"${NATIVE_HOOK_TAG}%'`;
|
|
85
|
+
const NATIVE_WITHDRAW_REASONS = new Set(["answer_window_ended", "answered_in_terminal"]);
|
|
86
|
+
const NATIVE_HOOK_ID = /^[a-z][a-z0-9-]{0,39}$/;
|
|
87
|
+
const FINGERPRINT = /^[a-f0-9]{16,64}$/;
|
|
88
|
+
const NATIVE_ACTOR = /^[A-Za-z0-9_-]{1,128}$/;
|
|
89
|
+
/** How much of the exact action an ask shows, and what the hook may send of it. */
|
|
90
|
+
const MAX_ACTION_TEXT = 4000;
|
|
91
|
+
const MAX_ACTION_INPUT = 65536;
|
|
92
|
+
const MAX_WORDS = 1000;
|
|
93
|
+
/** The hook's window when it names none, and the longest it may name (openrig-core's hook names a day). */
|
|
94
|
+
const DEFAULT_HOLD_SECONDS = 300;
|
|
95
|
+
const MAX_HOLD_SECONDS = 86400;
|
|
96
|
+
/** After its window, an open native ask is given this long for its hook's own withdrawal before OpenRig ends it. */
|
|
97
|
+
const NATIVE_GRACE_MS = 60_000;
|
|
98
|
+
/** A tool call's completion settles a native ask asked within this long. */
|
|
99
|
+
const SETTLE_LOOKBACK_MS = 6 * 3600 * 1000;
|
|
100
|
+
const HARNESS_NAMES = { "claude-code": "Claude Code", codex: "Codex" };
|
|
101
|
+
const harnessName = (hook) => HARNESS_NAMES[hook] ?? hook;
|
|
102
|
+
/** A waiting hook reads its ask again as soon as each read answers (the read route holds one for 25 s at most), and 2 s
|
|
103
|
+
* after one that failed. A hook that hasn't read its ask for this long isn't reading it (it was killed outright, say), so
|
|
104
|
+
* an answer recorded now hasn't reached the prompt. */
|
|
105
|
+
const HOOK_SILENT_MS = 60_000;
|
|
106
|
+
/** When each native ask's hook last reached this daemon about it (its submit, or the start of a read), per database and in
|
|
107
|
+
* memory only: nothing is written. `since` is when this daemon began noting; a restarted daemon begins again, and a hook
|
|
108
|
+
* that's reading is noted within seconds. Past 1000 asks, the oldest note goes. */
|
|
109
|
+
const hookReads = new WeakMap();
|
|
110
|
+
function hookReadsOf(db) {
|
|
111
|
+
let reads = hookReads.get(db);
|
|
112
|
+
if (!reads) {
|
|
113
|
+
reads = { since: Date.now(), at: new Map() };
|
|
114
|
+
hookReads.set(db, reads);
|
|
115
|
+
}
|
|
116
|
+
return reads;
|
|
117
|
+
}
|
|
118
|
+
function noteHookRead(db, askId) {
|
|
119
|
+
const { at } = hookReadsOf(db);
|
|
120
|
+
at.delete(askId);
|
|
121
|
+
at.set(askId, Date.now());
|
|
122
|
+
if (at.size > 1000)
|
|
123
|
+
at.delete(at.keys().next().value);
|
|
124
|
+
}
|
|
125
|
+
const isoSeconds = (ms) => new Date(ms).toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
126
|
+
/** Whether a native ask's answer can reach its prompt now, from its hook's reads as this daemon saw them: `hookLastRead`
|
|
127
|
+
* when one was seen, and `notReached`, the plain words for whoever answered, when the hook hasn't read the ask for
|
|
128
|
+
* HOOK_SILENT_MS (nor since this daemon began noting, that long ago). Nothing is refused or undone: the answer stays
|
|
129
|
+
* recorded, and a hook that does read the ask again takes it as usual. The hook taking it (`taken`) stays the proof
|
|
130
|
+
* that it reached the hook. */
|
|
131
|
+
export function nativeAnswerReach(db, ask, now = Date.now()) {
|
|
132
|
+
const reads = hookReadsOf(db);
|
|
133
|
+
const last = reads.at.get(ask.qitemId);
|
|
134
|
+
const since = last ?? reads.since;
|
|
135
|
+
return { ...(last !== undefined ? { hookLastRead: isoSeconds(last) } : {}),
|
|
136
|
+
...(now - since > HOOK_SILENT_MS ? { notReached: `It hasn't reached ${ask.sourceSession}'s prompt: the seat's permission hook hasn't read`
|
|
137
|
+
+ ` this ask since ${isoSeconds(since)}, so nothing has taken the answer there (the hook may have been stopped). Check the seat`
|
|
138
|
+
+ ` (rig capture ${ask.sourceSession}): if its prompt is still open, an answer in its terminal reaches it.` } : {}) };
|
|
139
|
+
}
|
|
47
140
|
/** A person's typed reply that plainly says yes or no; anything else says neither. */
|
|
48
141
|
function typedYesOrNo(answer) {
|
|
49
142
|
if (!answer || typeof answer !== "object" || answer.kind !== "typed-reply")
|
|
50
143
|
return null;
|
|
51
|
-
|
|
144
|
+
return plainYesOrNo(String(answer.text ?? ""));
|
|
145
|
+
}
|
|
146
|
+
/** Words that plainly say yes or no (the same short lists a person's typed reply is read with); anything else says neither. */
|
|
147
|
+
export function plainYesOrNo(text) {
|
|
148
|
+
const words = text.trim().toLowerCase().replace(/[.!?,;:]+$/, "").replace(/\s+/g, " ");
|
|
52
149
|
return SAID_YES.has(words) ? "yes" : SAID_NO.has(words) ? "no" : null;
|
|
53
150
|
}
|
|
151
|
+
/** The harness a native ask is for (its own permission prompt), or null for a runner's ask. */
|
|
152
|
+
export function nativePermissionHook(item) {
|
|
153
|
+
return item.tags?.find((tag) => tag.startsWith(NATIVE_HOOK_TAG))?.slice(NATIVE_HOOK_TAG.length) ?? null;
|
|
154
|
+
}
|
|
155
|
+
/** Whether a native ask's window, plus a grace for its hook's own withdrawal, has passed: its hook no longer takes an
|
|
156
|
+
* answer, so one given now would reach no one. */
|
|
157
|
+
export function nativeAskPastWindow(item, now = Date.now()) {
|
|
158
|
+
const by = Date.parse(item.tags?.find((tag) => tag.startsWith(ANSWER_BY_TAG))?.slice(ANSWER_BY_TAG.length) ?? "");
|
|
159
|
+
return nativePermissionHook(item) !== null && Number.isFinite(by) && now > by + NATIVE_GRACE_MS;
|
|
160
|
+
}
|
|
161
|
+
/** The note a native ask past its window closes with. */
|
|
162
|
+
export function nativeWindowEndedNote(item) {
|
|
163
|
+
return `${WITHDRAWN_NOTE} reason=answer_window_ended: ${nativeWithdrawText("answer_window_ended", nativePermissionHook(item) ?? "claude-code")}`;
|
|
164
|
+
}
|
|
165
|
+
/** A person's words, kept whole but on one line, bounded. */
|
|
166
|
+
const oneLine = (value) => clip(value.replace(/\s+/g, " ").trim(), MAX_WORDS);
|
|
167
|
+
/** Words a native decision's note quoted as JSON (DECISION_WORDS), or null. */
|
|
168
|
+
function quoted(json) {
|
|
169
|
+
try {
|
|
170
|
+
return json ? String(JSON.parse(json)) || null : null;
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
54
176
|
/** A person's typed reply that says more than a plain yes or no: their own words, whole. */
|
|
55
177
|
function typedWords(answer) {
|
|
56
178
|
if (!answer || typeof answer !== "object" || answer.kind !== "typed-reply" || typedYesOrNo(answer))
|
|
@@ -128,9 +250,64 @@ export function parseRunnerPermissionRequest(body) {
|
|
|
128
250
|
options.push({ optionId, name, kind });
|
|
129
251
|
}
|
|
130
252
|
const toolCall = (body.toolCall ?? {});
|
|
253
|
+
const native = parseNativeParts(body);
|
|
254
|
+
if (native && "message" in native)
|
|
255
|
+
return { ok: false, message: native.message };
|
|
131
256
|
return { ok: true, request: { nativeRef, turnId, requestId, options,
|
|
132
257
|
...(body.runId ? { runId: text(body.runId), nativeTurnId: text(body.nativeTurnId) } : {}),
|
|
133
|
-
toolCall: { title: text(toolCall.title) ?? undefined, kind: text(toolCall.kind) ?? undefined } } };
|
|
258
|
+
toolCall: { title: text(toolCall.title) ?? undefined, kind: text(toolCall.kind) ?? undefined }, ...(native ?? {}) } };
|
|
259
|
+
}
|
|
260
|
+
/** A native ask's own parts (`nativeHook`, `action`, `holdSeconds`), or what's wrong with them; null for a runner's ask. */
|
|
261
|
+
function parseNativeParts(body) {
|
|
262
|
+
if (body.nativeHook === undefined)
|
|
263
|
+
return null;
|
|
264
|
+
const hook = text(body.nativeHook);
|
|
265
|
+
if (!hook || !NATIVE_HOOK_ID.test(hook))
|
|
266
|
+
return { message: "nativeHook names the harness whose own permission prompt this is, such as claude-code." };
|
|
267
|
+
const action = (body.action ?? {});
|
|
268
|
+
const tool = text(action.tool);
|
|
269
|
+
if (!tool || tool.length > 128)
|
|
270
|
+
return { message: "A native permission request needs action.tool: the tool its prompt names." };
|
|
271
|
+
if (action.callFingerprint !== undefined && (typeof action.callFingerprint !== "string" || !FINGERPRINT.test(action.callFingerprint)))
|
|
272
|
+
return { message: "action.callFingerprint is the hook's hex fingerprint of the call." };
|
|
273
|
+
if (action.agent != null && (typeof action.agent !== "string" || !NATIVE_ACTOR.test(action.agent)))
|
|
274
|
+
return { message: "action.agent is a subagent's id, or null for the main conversation." };
|
|
275
|
+
const hold = body.holdSeconds;
|
|
276
|
+
const holdSeconds = typeof hold === "number" && Number.isSafeInteger(hold) && hold >= 1 && hold <= MAX_HOLD_SECONDS ? hold : DEFAULT_HOLD_SECONDS;
|
|
277
|
+
return { nativeHook: hook, holdSeconds, action: { tool,
|
|
278
|
+
...(action.input !== undefined ? { input: action.input } : {}),
|
|
279
|
+
...(typeof action.inputText === "string" ? { inputText: action.inputText.slice(0, MAX_ACTION_INPUT) } : {}),
|
|
280
|
+
inputCut: action.inputCut === true, agent: action.agent ?? null,
|
|
281
|
+
...(typeof action.callFingerprint === "string" ? { callFingerprint: action.callFingerprint } : {}) } };
|
|
282
|
+
}
|
|
283
|
+
/** The exact action as an ask shows it: a command as its text, any other tool's input as its JSON. Text that looks like a
|
|
284
|
+
* credential (the transcript route's redaction list) is shown as [REDACTED] before anything is stored, and the display is
|
|
285
|
+
* bounded; the request itself is never changed. */
|
|
286
|
+
export function nativeActionDisplay(action) {
|
|
287
|
+
const input = action.input;
|
|
288
|
+
let raw;
|
|
289
|
+
if (typeof action.inputText === "string")
|
|
290
|
+
raw = action.inputText;
|
|
291
|
+
else if (action.tool === "Bash" && input && typeof input.command === "string")
|
|
292
|
+
raw = input.command;
|
|
293
|
+
else {
|
|
294
|
+
try {
|
|
295
|
+
raw = JSON.stringify(action.input ?? {}, null, 2) ?? "{}";
|
|
296
|
+
}
|
|
297
|
+
catch {
|
|
298
|
+
raw = "(its input couldn't be read)";
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
const redactedText = redactTranscriptContent(raw);
|
|
302
|
+
const cut = action.inputCut === true || redactedText.length > MAX_ACTION_TEXT;
|
|
303
|
+
const shown = redactedText.length > MAX_ACTION_TEXT ? redactedText.slice(0, MAX_ACTION_TEXT) : redactedText;
|
|
304
|
+
const first = shown.split("\n").map((line) => line.trim()).find((line) => line.length > 0 && line !== "{") ?? "";
|
|
305
|
+
return { title: `${action.tool}: ${clip(first, 160)}`, text: shown, redacted: redactedText !== raw, cut };
|
|
306
|
+
}
|
|
307
|
+
/** A fence that a code block's own text can't close. */
|
|
308
|
+
function fenceFor(content) {
|
|
309
|
+
const longest = Math.max(2, ...[...content.matchAll(/`+/g)].map((match) => match[0].length));
|
|
310
|
+
return "`".repeat(longest + 1);
|
|
134
311
|
}
|
|
135
312
|
export class RunnerPermissions {
|
|
136
313
|
deps;
|
|
@@ -156,6 +333,8 @@ export class RunnerPermissions {
|
|
|
156
333
|
return `qitem-runner-permission-${createHash("sha256").update(key).digest("hex").slice(0, 24)}`;
|
|
157
334
|
}
|
|
158
335
|
async submit(seat, request) {
|
|
336
|
+
if (request.nativeHook)
|
|
337
|
+
return this.submitNative(seat, request);
|
|
159
338
|
if (this.turnFenced(seat.nodeId, request))
|
|
160
339
|
return { ok: false, code: "turn_withdrawn", message: "Native turn permissions are withdrawn." };
|
|
161
340
|
const selected = this.deps.ownerOf(seat.nodeId);
|
|
@@ -247,14 +426,157 @@ export class RunnerPermissions {
|
|
|
247
426
|
counts.delete(key);
|
|
248
427
|
}
|
|
249
428
|
}
|
|
429
|
+
/** A harness's own permission prompt, submitted by its permission hook. With someone to ask, one ask opens and the hook
|
|
430
|
+
* waits on it while the prompt stays open in the seat's terminal; with no one, nothing is asked and nothing decided
|
|
431
|
+
* (`not_asked`): the prompt carries on, as it does without OpenRig. Never a default permit or a refusal. */
|
|
432
|
+
async submitNative(seat, request) {
|
|
433
|
+
const hook = request.nativeHook, action = request.action;
|
|
434
|
+
const name = harnessName(hook);
|
|
435
|
+
const notAsked = (why) => ({ ok: true, state: "not_asked",
|
|
436
|
+
reason: `${why.charAt(0).toUpperCase()}${why.slice(1)}. Nothing was decided: ${name}'s own prompt stays open in the seat's terminal.` });
|
|
437
|
+
const ids = new Set(request.options.map((option) => option.optionId));
|
|
438
|
+
if (request.options.length < 2 || request.options.length > 4 || ids.size !== request.options.length
|
|
439
|
+
|| request.options.some((option) => !OPTION_ID.test(option.optionId) || !ANSWERABLE_KINDS.has(option.kind))) {
|
|
440
|
+
return notAsked("these options can't be shown to a person: an ask takes 2-4 options with distinct ids of letters, digits, \"-\" or \"_\"");
|
|
441
|
+
}
|
|
442
|
+
const owner = this.nativeOwner(seat);
|
|
443
|
+
if (!owner.ok)
|
|
444
|
+
return notAsked(owner.why);
|
|
445
|
+
this.withdrawEarlierGenerations(seat);
|
|
446
|
+
const askId = RunnerPermissions.askIdFor(seat, request);
|
|
447
|
+
const existing = this.deps.queueRepo.getById(askId);
|
|
448
|
+
if (existing) {
|
|
449
|
+
if (tagValue(existing, TURN_TAG) === request.turnId)
|
|
450
|
+
return { ok: true, askId, created: false, askedOf: existing.destinationSession,
|
|
451
|
+
answerBy: tagValue(existing, ANSWER_BY_TAG) ?? undefined };
|
|
452
|
+
return { ok: false, code: "duplicate_request", message: `Request ${request.requestId} of this conversation was already submitted in turn ${tagValue(existing, TURN_TAG)}.` };
|
|
453
|
+
}
|
|
454
|
+
const allow = request.options.find((option) => option.kind === "allow_once") ?? request.options.find((option) => option.kind === "allow_always");
|
|
455
|
+
const reject = request.options.find((option) => option.kind === "reject_once") ?? request.options.find((option) => option.kind === "reject_always");
|
|
456
|
+
const shown = nativeActionDisplay(action);
|
|
457
|
+
const holdSeconds = request.holdSeconds ?? DEFAULT_HOLD_SECONDS;
|
|
458
|
+
const answerBy = new Date(Date.now() + holdSeconds * 1000).toISOString();
|
|
459
|
+
const window = holdSeconds % 3600 === 0 ? `${holdSeconds / 3600} hour${holdSeconds === 3600 ? "" : "s"}`
|
|
460
|
+
: holdSeconds % 60 === 0 ? `${holdSeconds / 60} minute${holdSeconds === 60 ? "" : "s"}` : `${holdSeconds} s`;
|
|
461
|
+
const fence = fenceFor(shown.text);
|
|
462
|
+
const description = action.tool === "Bash" && typeof action.input?.description === "string"
|
|
463
|
+
? oneLine(redactTranscriptContent(String(action.input.description))) : null;
|
|
464
|
+
const byRoute = owner.source === "return-route";
|
|
465
|
+
const optionNames = request.options.map((option) => option.name).join(", ");
|
|
466
|
+
const allowId = allow?.optionId ?? "allow", rejectId = reject?.optionId ?? "deny";
|
|
467
|
+
await this.deps.queueRepo.create({
|
|
468
|
+
qitemId: askId,
|
|
469
|
+
sourceSession: seat.sessionName,
|
|
470
|
+
destinationSession: owner.address,
|
|
471
|
+
// A person gets an ordinary ask, alerted where they answer (Feed, Slack). A conversation gets a task its own hooks bring
|
|
472
|
+
// it, with the options as tags: questions are for a person to click.
|
|
473
|
+
...(byRoute ? {} : { humanIntent: "decision", humanAlert: true,
|
|
474
|
+
humanQuestions: [{ id: QUESTION_ID, question: clip(`Allow ${seat.sessionName} to ${shown.title}?`, MAX_QUESTION_TEXT),
|
|
475
|
+
options: request.options.map((option) => ({ id: option.optionId, label: clip(option.name, MAX_OPTION_LABEL) })) }] }),
|
|
476
|
+
summary: clip(`Permission: ${seat.sessionName} asks to ${shown.title}`, 200),
|
|
477
|
+
tags: [RUNNER_PERMISSION_TAG, `${NODE_TAG}${seat.nodeId}`, `${GENERATION_TAG}${seat.generation}`, `${TURN_TAG}${request.turnId}`,
|
|
478
|
+
`${NATIVE_HOOK_TAG}${hook}`, `${ASKED_TAG}${owner.source}`, `${ANSWER_BY_TAG}${answerBy}`, `${ACTOR_TAG}${action.agent ?? "main"}`,
|
|
479
|
+
...request.options.map((option) => `${OPTION_TAG}${option.optionId}`),
|
|
480
|
+
...(action.callFingerprint ? [`${CALL_TAG}${action.callFingerprint}`] : []),
|
|
481
|
+
...(allow ? [`${ALLOW_TAG}${allow.optionId}`, `${ALLOW_KIND_TAG}${allow.kind}`] : []), ...(reject ? [`${REJECT_TAG}${reject.optionId}`] : [])],
|
|
482
|
+
nudge: false,
|
|
483
|
+
body: [
|
|
484
|
+
`${seat.sessionName}'s ${name} is waiting at its own permission prompt for one tool call${action.agent ? ` (from its subagent ${action.agent})` : ""}.`,
|
|
485
|
+
"",
|
|
486
|
+
`- **Why you:** ${owner.why}.`,
|
|
487
|
+
`- **Tool:** ${action.tool}${description ? `, described by ${name} as: ${description}` : ""}`,
|
|
488
|
+
"- **The exact action:**",
|
|
489
|
+
"",
|
|
490
|
+
fence,
|
|
491
|
+
shown.text,
|
|
492
|
+
fence,
|
|
493
|
+
"",
|
|
494
|
+
`Shown as ${name} gave it${shown.redacted ? ", with text that looks like a credential shown as [REDACTED]" : ""}${shown.cut ? `, cut at ${MAX_ACTION_TEXT} characters` : ""}. OpenRig changes nothing in the request: an allow lets it run exactly as ${name} asked.`,
|
|
495
|
+
`- **Its options here:** ${optionNames}. A remembered choice ("don't ask again") is only in the seat's terminal.`,
|
|
496
|
+
"",
|
|
497
|
+
...(byRoute ? [
|
|
498
|
+
"Ask your person, showing them the action above. Then record their answer:",
|
|
499
|
+
`- **A plain yes or no is their own answer.** Pass it on exactly, with no second confirmation: \`rig seat decide-permission ${askId} --option ${allowId} --relay --person-said "<their exact words>"\` (or \`--option ${rejectId}\`). It's recorded as relayed by you, with their words as you report them: unconfirmed, since OpenRig doesn't get it from them.`,
|
|
500
|
+
`- **Words or a condition** ("yes, but not on main"): judge whether this exact action meets them. If it does, \`--option ${allowId}\`; if it doesn't, \`--option ${rejectId}\`, each with \`--reason "<why>" --person-said "<their exact words>"\`. A deny takes their words back to ${seat.sessionName}'s agent so it can adapt; it's recorded as your judgment, not their no, with their words as you report them. If you can't tell what they meant, ask them again.`,
|
|
501
|
+
"- **Never decide without their answer.** If they don't answer, leave it: the prompt waits in the seat's terminal.",
|
|
502
|
+
`- **Answer here, not in ${seat.sessionName}'s terminal,** even when you see its prompt there: keys typed into the seat answer the prompt in the terminal and end this ask. The openrig plugin's \`rig_seat_decide_permission\` tool takes the same answer as the command.`,
|
|
503
|
+
] : [
|
|
504
|
+
`Answer with ${optionNames}, or in your own words. A choice, or a plain yes or no, is your own answer: it goes to the prompt as you gave it. Your own words go to this host's receiving agent, which judges whether this exact action meets them: it allows it if it does, and otherwise denies it with your words, so the agent can adapt. It asks you back when your words aren't clear.`,
|
|
505
|
+
]),
|
|
506
|
+
"",
|
|
507
|
+
`OpenRig takes an answer here until ${answerBy} (${window}). The prompt is also open in the seat's terminal, and the first answer counts. Once it's answered there, or after that time, an answer here is too late and isn't sent. Closing this without an answer decides nothing.`,
|
|
508
|
+
].join("\n"),
|
|
509
|
+
});
|
|
510
|
+
// The hook reads it next: its submit counts as its first read.
|
|
511
|
+
noteHookRead(this.deps.db, askId);
|
|
512
|
+
return { ok: true, askId, created: true, askedOf: owner.address, answerBy };
|
|
513
|
+
}
|
|
514
|
+
/** Who answers a native prompt: the person chosen for the seat (`rig seat set-permissions-to`), else the return route of
|
|
515
|
+
* the work the seat is running (the person's own conversation; `seatReturnRoute`), else the default person. Nobody, and
|
|
516
|
+
* nothing is asked. */
|
|
517
|
+
nativeOwner(seat) {
|
|
518
|
+
const selected = this.deps.ownerOf(seat.nodeId);
|
|
519
|
+
if (selected === PERMISSIONS_DENY) {
|
|
520
|
+
return { ok: false, why: "this seat's operator opted in to refusing runner permission requests (rig seat set-permissions-to --deny); OpenRig doesn't refuse a harness's own prompt" };
|
|
521
|
+
}
|
|
522
|
+
let chosenProblem = null;
|
|
523
|
+
if (selected) {
|
|
524
|
+
const chosen = resolvePermissionOwner(selected, this.deps.humanRegistry);
|
|
525
|
+
if (chosen.ok)
|
|
526
|
+
return { ok: true, address: chosen.address, source: "chosen-person",
|
|
527
|
+
why: this.latestSelection(seat.nodeId) ?? "you are the seat's chosen permission answer owner" };
|
|
528
|
+
chosenProblem = chosen.message;
|
|
529
|
+
}
|
|
530
|
+
const route = this.seatReturnRoute(seat.sessionName);
|
|
531
|
+
if (route)
|
|
532
|
+
return { ok: true, address: route.address, source: "return-route",
|
|
533
|
+
why: route.routes > 1 && !route.inProgress
|
|
534
|
+
? `your conversation handed ${seat.sessionName} its newest open work (${route.row}), and this address is that work's return route; it holds open work from ${route.routes} conversations, and none is in progress`
|
|
535
|
+
: `your conversation handed ${seat.sessionName} the work it's running (${route.row}), and this address is that work's return route${route.routes > 1 ? `; it holds open work from ${route.routes} conversations, and this one's is in progress` : ""}` };
|
|
536
|
+
const fallback = defaultPermissionOwner(this.deps.humanRegistry);
|
|
537
|
+
if (fallback.ok)
|
|
538
|
+
return { ok: true, address: fallback.address, source: "default-person",
|
|
539
|
+
why: "you are the default person, and no one else is chosen for this seat or reached by its work's return route" };
|
|
540
|
+
return { ok: false, why: `No one can be asked${chosenProblem ? ` (the person chosen for this seat: ${chosenProblem})` : ""}: the seat's work carries no return route on this host, and ${fallback.message}` };
|
|
541
|
+
}
|
|
542
|
+
/** The return route of the open work addressed to the seat (pending, in progress or blocked), with the row that carries
|
|
543
|
+
* it and how many conversations' work is open there. One route is that route. Work from several conversations gives the
|
|
544
|
+
* route of the work the seat is on, its newest in-progress row, else of its newest open row: a seat's prompt is about
|
|
545
|
+
* the work in its hands, and an older row it never claimed (a review's result, say) doesn't silence the conversation
|
|
546
|
+
* that handed it that work. A route that is the seat's own address is never one; when the chosen work's route names
|
|
547
|
+
* another host, there's none. */
|
|
548
|
+
seatReturnRoute(sessionName) {
|
|
549
|
+
let rows;
|
|
550
|
+
try {
|
|
551
|
+
rows = this.deps.db.prepare(`SELECT qitem_id, return_route, state FROM queue_items WHERE destination_session = ?
|
|
552
|
+
AND state IN ('pending','in-progress','blocked') AND return_route IS NOT NULL
|
|
553
|
+
ORDER BY state = 'in-progress' DESC, ts_created DESC, rowid DESC`).all(sessionName);
|
|
554
|
+
}
|
|
555
|
+
catch {
|
|
556
|
+
return null;
|
|
557
|
+
}
|
|
558
|
+
const routed = rows.filter((row) => routeOnThisHost(row.return_route) !== sessionName);
|
|
559
|
+
const chosen = routed[0];
|
|
560
|
+
const address = chosen ? routeOnThisHost(chosen.return_route) : null;
|
|
561
|
+
if (!chosen || !address)
|
|
562
|
+
return null;
|
|
563
|
+
return { address, row: chosen.qitem_id, routes: new Set(routed.map((row) => row.return_route)).size, inProgress: chosen.state === "in-progress" };
|
|
564
|
+
}
|
|
250
565
|
/** A grant's seat carries its launch generation: it reads only its own launch's requests. Only the current
|
|
251
566
|
* occupant's request can read pending or answered; an earlier occupant's reads stale, whatever answer it holds.
|
|
252
567
|
* `authority` is a caller's own check of the ask's seat, used in place of a second one. */
|
|
253
568
|
read(seat, askId, authority) {
|
|
569
|
+
const result = this.readAsk(seat, askId, authority);
|
|
570
|
+
const asked = result.ok ? this.deps.queueRepo.getById(askId) : null;
|
|
571
|
+
const hook = asked ? nativePermissionHook(asked) : null;
|
|
572
|
+
return result.ok && asked && hook ? { ...result, native: this.nativeFacts(asked, hook, result) } : result;
|
|
573
|
+
}
|
|
574
|
+
readAsk(seat, askId, authority) {
|
|
254
575
|
const asked = this.deps.queueRepo.getById(askId);
|
|
255
576
|
const origin = asked ? runnerPermissionOrigin(asked) : null;
|
|
256
577
|
if (!asked || !origin || (seat && origin.nodeId !== seat.nodeId))
|
|
257
578
|
return { ok: false, code: "not_found", message: `No permission request ${askId} for this seat.` };
|
|
579
|
+
const native = nativePermissionHook(asked) !== null;
|
|
258
580
|
if (this.turnFenced(origin.nodeId, { runId: tagValue(asked, RUN_TAG) ?? undefined, nativeTurnId: tagValue(asked, NATIVE_TURN_TAG) ?? undefined }))
|
|
259
581
|
return { ok: true, state: "withdrawn" };
|
|
260
582
|
const item = this.liveEnd(asked);
|
|
@@ -270,6 +592,11 @@ export class RunnerPermissions {
|
|
|
270
592
|
return (askIsCurrent && callerMatches) || unproven ? { ok: true, state: "pending" } : { ok: true, state: "stale" };
|
|
271
593
|
// Still open (pending, or claimed or parked by the person): no answer yet.
|
|
272
594
|
if (item.state === "pending" || item.state === "in-progress" || item.state === "blocked") {
|
|
595
|
+
// A native ask past its window, whose hook never withdrew it (the harness ended it, or it died): it's over.
|
|
596
|
+
if (native && this.pastWindow(asked)) {
|
|
597
|
+
this.close(item, WITHDRAWN_NOTE, "answer_window_ended", nativeWithdrawText("answer_window_ended", nativePermissionHook(asked)));
|
|
598
|
+
return { ok: true, state: "withdrawn" };
|
|
599
|
+
}
|
|
273
600
|
if ((askIsCurrent && callerMatches) || unproven)
|
|
274
601
|
return { ok: true, state: "pending" };
|
|
275
602
|
if (!askIsCurrent && !unknown)
|
|
@@ -291,7 +618,7 @@ export class RunnerPermissions {
|
|
|
291
618
|
// The person's answer, from the live row or back along the rows the request was handed through.
|
|
292
619
|
const answer = this.personAnswer(item);
|
|
293
620
|
// The options travel with the ask: a row handed to an agent to decide carries none of its own.
|
|
294
|
-
const offered = this.
|
|
621
|
+
const offered = this.offeredOptions(item);
|
|
295
622
|
const allowId = tagValue(item, ALLOW_TAG), rejectId = tagValue(item, REJECT_TAG);
|
|
296
623
|
// A refusing close (denied) is the agent's reject, and never a grant.
|
|
297
624
|
if (item.closureReason === "denied" || item.state === "denied") {
|
|
@@ -314,6 +641,9 @@ export class RunnerPermissions {
|
|
|
314
641
|
// Other words nobody decided on are kept: the request waits for an explicit decision, or the turn's end.
|
|
315
642
|
return { ok: true, state: "pending" };
|
|
316
643
|
}
|
|
644
|
+
// A native ask closed with no answer decides nothing: a close is never an approval, and the harness's prompt carries on.
|
|
645
|
+
if (native)
|
|
646
|
+
return { ok: true, state: "unanswered" };
|
|
317
647
|
// Closed with no answer at all is no answer, so OpenRig's default applies: permit.
|
|
318
648
|
if (!allowId)
|
|
319
649
|
return { ok: true, state: "refused", reason: "no_allow_offered" };
|
|
@@ -384,12 +714,16 @@ export class RunnerPermissions {
|
|
|
384
714
|
});
|
|
385
715
|
try {
|
|
386
716
|
const now = this.withWords(askId, this.read(seat, askId));
|
|
717
|
+
// A native ask's own hook reading it (the read it waits on): noted, so an answer recorded while it isn't reading says so.
|
|
718
|
+
if (now.ok && now.native)
|
|
719
|
+
noteHookRead(this.deps.db, askId);
|
|
387
720
|
if (!now.ok || now.state !== "pending" || waitMs <= 0)
|
|
388
721
|
return now;
|
|
389
722
|
const asked = this.deps.queueRepo.getById(askId);
|
|
390
723
|
liveId = this.liveEnd(asked)?.qitemId ?? askId;
|
|
391
724
|
let timer;
|
|
392
|
-
await Promise.race([changed, new Promise((resolve) => { timer = setTimeout(resolve, waitMs); })
|
|
725
|
+
await Promise.race([changed, new Promise((resolve) => { timer = setTimeout(resolve, waitMs); }),
|
|
726
|
+
...(this.deps.stopping ? [this.deps.stopping] : [])]);
|
|
393
727
|
if (timer)
|
|
394
728
|
clearTimeout(timer);
|
|
395
729
|
return this.withWords(askId, this.read(seat, askId));
|
|
@@ -401,15 +735,21 @@ export class RunnerPermissions {
|
|
|
401
735
|
/** An agent's decision on a request its person answered (`rig seat decide-permission`): one of the options the agent
|
|
402
736
|
* offered, recorded on the row that holds the request now, with who decided and why. A request that's no longer
|
|
403
737
|
* pending (decided, withdrawn or stale) returns as it is and nothing is written, so deciding twice changes nothing. */
|
|
404
|
-
decide(askId, optionId, decider, reason) {
|
|
738
|
+
decide(askId, optionId, decider, reason, relayed = {}) {
|
|
405
739
|
// One authority check for the whole decision, shared with its read. A second check could prove the seat current after
|
|
406
740
|
// the read waited on unknown authority, and record a decision on a row already closed as denied or with no answer.
|
|
407
741
|
const requested = this.deps.queueRepo.getById(askId);
|
|
742
|
+
const hook = requested ? nativePermissionHook(requested) : null;
|
|
743
|
+
// Only a harness's own prompt takes the person's answer relayed as theirs; a runner's request records the deciding agent.
|
|
744
|
+
if (relayed.relay && requested && runnerPermissionOrigin(requested) && !hook) {
|
|
745
|
+
return { ok: false, code: "relay_unsupported", message: `${askId} is a runner's request, which records the deciding agent's decision. --relay is for a seat's own ${harnessName("claude-code")} prompt. Nothing was decided.` };
|
|
746
|
+
}
|
|
408
747
|
const origin = requested ? runnerPermissionOrigin(requested) : null;
|
|
409
748
|
const authority = origin ? this.seatAuthority(origin) : null;
|
|
410
749
|
const now = this.read(null, askId, authority ?? undefined);
|
|
750
|
+
// Nothing is written: a native ask says so, since the first answer counts and a later one is told it was too late.
|
|
411
751
|
if (!now.ok || now.state !== "pending")
|
|
412
|
-
return now;
|
|
752
|
+
return hook && now.ok ? { ...now, native: { ...(now.native ?? { hook }), unchanged: true } } : now;
|
|
413
753
|
const asked = this.deps.queueRepo.getById(askId);
|
|
414
754
|
const live = this.liveEnd(asked);
|
|
415
755
|
if (!live)
|
|
@@ -425,19 +765,174 @@ export class RunnerPermissions {
|
|
|
425
765
|
// The same check proved a successor holds the seat: the ask is stale, and nothing is written.
|
|
426
766
|
if (authority && !authority.current)
|
|
427
767
|
return { ok: true, state: "stale" };
|
|
428
|
-
const
|
|
429
|
-
if (!
|
|
430
|
-
return { ok: false, code: "invalid_option", message: `${optionId} isn't one of the options the agent offered: ${
|
|
768
|
+
const offered = this.offeredOptions(live);
|
|
769
|
+
if (!offered.includes(optionId)) {
|
|
770
|
+
return { ok: false, code: "invalid_option", message: `${optionId} isn't one of the options the agent offered: ${offered.join(", ") || "none recorded"}. Nothing was decided.` };
|
|
431
771
|
}
|
|
432
|
-
//
|
|
772
|
+
// Kept apart: what OpenRig received from the person (their words or pick on the request, placed by their own answer), and
|
|
773
|
+
// what the decider reports they said, which stays its report. Neither replaces the other, and a report never reads as
|
|
774
|
+
// their own answer: only an answer OpenRig receives from the person does.
|
|
433
775
|
const typed = this.personAnswer(live);
|
|
434
|
-
const
|
|
776
|
+
const typedText = typed && typeof typed === "object" && typed.kind === "typed-reply" ? String(typed.text ?? "").trim() || null : null;
|
|
777
|
+
const received = typedText && hook ? oneLine(typedText) : typedText;
|
|
778
|
+
const said = relayed.personSaid?.trim() ? oneLine(relayed.personSaid) : null;
|
|
779
|
+
const reported = said !== null && said !== received ? said : null;
|
|
780
|
+
const why = reason ? clip(reason, MAX_AGENT_TEXT) : "";
|
|
781
|
+
// A native ask's note quotes its words as JSON, so a read can take them back from its end (DECISION_WORDS).
|
|
782
|
+
const quote = (value) => hook ? JSON.stringify(value) : `"${value}"`;
|
|
783
|
+
const words = `${why ? `, because ${hook ? quote(why) : why}` : ""}${received ? `; the person wrote ${quote(received)}`
|
|
784
|
+
: typeof typed === "string" ? `; the person chose ${typed}` : ""}${reported ? `; the decider reported they said ${quote(reported)}` : ""}`;
|
|
785
|
+
const transitionNote = hook && relayed.relay
|
|
786
|
+
? `${RELAYED_DECISION} ${decider}, unconfirmed (OpenRig didn't get this answer from the person): ${optionId}${words}`
|
|
787
|
+
: `${DECIDED_NOTE} by ${decider}, an agent, not the person: ${optionId}${words}`;
|
|
435
788
|
const recorded = this.deps.queueRepo.recordPermissionDecision({ qitemId: live.qitemId, actorSession: decider, questionId: QUESTION_ID, optionId,
|
|
436
|
-
transitionNote
|
|
789
|
+
transitionNote, ...(hook ? { resolution: nativeDecisionMessage({ decider, relay: relayed.relay === true,
|
|
790
|
+
denies: optionId === tagValue(asked, REJECT_TAG), received, reported, reason: why }) } : {}) });
|
|
437
791
|
if (!recorded)
|
|
438
792
|
return { ok: false, code: "not_recorded", message: `The decision couldn't be recorded on ${live.qitemId} (its row is ${live.state}). Nothing was decided. Read the request again.` };
|
|
439
793
|
return this.read(null, askId);
|
|
440
794
|
}
|
|
795
|
+
/** A native ask's hook took the answer it read, and is about to return it to the harness's prompt: recorded once, on the
|
|
796
|
+
* row that holds the decision. It records only that the hook has it, not that the harness applied it. */
|
|
797
|
+
taken(seat, askId, optionId) {
|
|
798
|
+
const asked = this.deps.queueRepo.getById(askId);
|
|
799
|
+
const hook = asked ? nativePermissionHook(asked) : null;
|
|
800
|
+
const origin = asked ? runnerPermissionOrigin(asked) : null;
|
|
801
|
+
if (!asked || !hook || !origin || (seat && (seat.nodeId !== origin.nodeId || (seat.generation && seat.generation !== origin.generation))))
|
|
802
|
+
return { ok: false, code: "not_found", message: `No native permission request ${askId} for this seat.` };
|
|
803
|
+
const now = this.read(seat, askId);
|
|
804
|
+
if (!now.ok || now.state !== "answered" || now.optionId !== optionId)
|
|
805
|
+
return now;
|
|
806
|
+
const live = this.liveEnd(asked);
|
|
807
|
+
if (live && !this.deps.queueRepo.listTransitions(live.qitemId).some((t) => t.transitionNote?.startsWith(TAKEN_NOTE))) {
|
|
808
|
+
const name = harnessName(hook);
|
|
809
|
+
this.deps.queueRepo.transitionLog.append({ qitemId: live.qitemId, state: live.state, actorSession: asked.sourceSession,
|
|
810
|
+
transitionNote: `${TAKEN_NOTE}: ${name}'s permission hook in ${asked.sourceSession} took this answer (${optionId}) and is returning it to the prompt. Whether ${name} applied it isn't seen by OpenRig; a completed tool call is recorded only when one with this exact input is seen.` });
|
|
811
|
+
}
|
|
812
|
+
return this.read(seat, askId);
|
|
813
|
+
}
|
|
814
|
+
/** A seat's Claude tool calls resolved (its PostToolBatch, which names every call in the batch: run, failed or denied), by
|
|
815
|
+
* their fingerprints. For each, the newest native ask from this seat's generation and actor with that fingerprint that
|
|
816
|
+
* isn't settled yet: one still open was answered in the seat's terminal, so it's withdrawn and a later answer here is
|
|
817
|
+
* too late; one decided allow gets the tool call's completion recorded; one decided deny gets nothing (its call was
|
|
818
|
+
* denied, not run). The match is by content (conversation, actor, tool and exact input), since the harness's permission
|
|
819
|
+
* request carries no tool-call id. Returns how many asks it settled. */
|
|
820
|
+
settleCompletedCalls(seat, actor, fingerprints) {
|
|
821
|
+
const since = new Date(Date.now() - SETTLE_LOOKBACK_MS).toISOString();
|
|
822
|
+
const settledHere = new Set();
|
|
823
|
+
let settled = 0;
|
|
824
|
+
// Every Claude seat's tool batch comes here, almost always with no native ask to find: the read covers only the seat's
|
|
825
|
+
// native asks in the lookback (the partial index), never every row the seat ever sent.
|
|
826
|
+
const candidates = this.deps.db.prepare(`SELECT qitem_id FROM queue_items WHERE source_session = ? AND ts_created >= ?
|
|
827
|
+
AND ${NATIVE_ASK_ROWS} AND tags LIKE ? ORDER BY ts_created DESC, rowid DESC LIMIT 20`);
|
|
828
|
+
for (const fingerprint of fingerprints.slice(0, 64)) {
|
|
829
|
+
if (typeof fingerprint !== "string" || !FINGERPRINT.test(fingerprint))
|
|
830
|
+
continue;
|
|
831
|
+
const rows = candidates.all(seat.sessionName, since, `%"${CALL_TAG}${fingerprint}"%`);
|
|
832
|
+
for (const { qitem_id } of rows) {
|
|
833
|
+
if (settledHere.has(qitem_id))
|
|
834
|
+
continue;
|
|
835
|
+
const asked = this.deps.queueRepo.getById(qitem_id);
|
|
836
|
+
const hook = asked ? nativePermissionHook(asked) : null;
|
|
837
|
+
if (!asked || !hook || !asked.tags?.includes(`${CALL_TAG}${fingerprint}`) || tagValue(asked, NODE_TAG) !== seat.nodeId
|
|
838
|
+
|| tagValue(asked, GENERATION_TAG) !== seat.generation || tagValue(asked, ACTOR_TAG) !== (actor ?? "main"))
|
|
839
|
+
continue;
|
|
840
|
+
const live = this.liveEnd(asked);
|
|
841
|
+
if (!live || live.state === "canceled")
|
|
842
|
+
continue;
|
|
843
|
+
const transitions = this.deps.queueRepo.listTransitions(live.qitemId);
|
|
844
|
+
if (transitions.some((t) => t.transitionNote?.startsWith(COMPLETED_NOTE)) || this.withdrawnAfterClose(live))
|
|
845
|
+
continue;
|
|
846
|
+
settledHere.add(qitem_id);
|
|
847
|
+
if (live.state === "pending" || live.state === "in-progress" || live.state === "blocked") {
|
|
848
|
+
this.close(live, WITHDRAWN_NOTE, "answered_in_terminal", `${nativeWithdrawText("answered_in_terminal", hook)} ${harnessName(hook)} reported a tool call with exactly this input resolved in the same conversation, without an answer from here (matched by its content; there's no tool-call id).`);
|
|
849
|
+
}
|
|
850
|
+
else {
|
|
851
|
+
const decided = this.read(null, qitem_id);
|
|
852
|
+
// A denied call resolves too, without running: this newest ask is its call, and there's no completion to record.
|
|
853
|
+
if (!decided.ok || decided.state !== "answered" || decided.optionId === tagValue(asked, REJECT_TAG))
|
|
854
|
+
break;
|
|
855
|
+
this.deps.queueRepo.transitionLog.append({ qitemId: live.qitemId, state: live.state, actorSession: asked.sourceSession,
|
|
856
|
+
transitionNote: `${COMPLETED_NOTE}: a tool call with exactly this input completed in the same ${harnessName(hook)} conversation after this allow (matched by its content; there's no tool-call id). It ran, unless the terminal's own answer came first.` });
|
|
857
|
+
}
|
|
858
|
+
settled++;
|
|
859
|
+
break;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
return settled;
|
|
863
|
+
}
|
|
864
|
+
/** The option ids the request offered: its question's (back along the rows it was handed through), else a native ask's
|
|
865
|
+
* own option tags (an ask to a conversation, which carries no questions). */
|
|
866
|
+
offeredOptions(item) {
|
|
867
|
+
const asked = this.deps.queueRepo.permissionQuestionsFor(item)?.find((question) => question.id === QUESTION_ID)?.options.map((option) => option.id);
|
|
868
|
+
if (asked?.length)
|
|
869
|
+
return asked;
|
|
870
|
+
return (item.tags ?? []).filter((tag) => tag.startsWith(OPTION_TAG)).map((tag) => tag.slice(OPTION_TAG.length));
|
|
871
|
+
}
|
|
872
|
+
/** Whether the ask's window, plus a grace for its hook's own withdrawal, has passed. */
|
|
873
|
+
pastWindow(asked) {
|
|
874
|
+
return nativeAskPastWindow(asked);
|
|
875
|
+
}
|
|
876
|
+
/** The transition that decided the row: `rig seat decide-permission`'s, a person's own direct reply, or a refusing close. */
|
|
877
|
+
decisionTransition(item) {
|
|
878
|
+
const transitions = this.deps.queueRepo.listTransitions(item.qitemId);
|
|
879
|
+
for (let i = transitions.length - 1; i >= 0 && transitions[i].state === item.state; i--) {
|
|
880
|
+
const t = transitions[i];
|
|
881
|
+
if (t.transitionNote?.startsWith("runner-permission-decided") || t.ownerNotificationKind === "human-decision-resolved")
|
|
882
|
+
return t;
|
|
883
|
+
}
|
|
884
|
+
return this.deps.queueRepo.closingTransition(item.qitemId, item.state);
|
|
885
|
+
}
|
|
886
|
+
/** What a native ask's read adds (NativeReadFacts). */
|
|
887
|
+
nativeFacts(asked, hook, result) {
|
|
888
|
+
const facts = { hook };
|
|
889
|
+
const live = this.liveEnd(asked) ?? asked;
|
|
890
|
+
const notes = [...this.deps.queueRepo.listTransitions(asked.qitemId),
|
|
891
|
+
...(live.qitemId !== asked.qitemId ? this.deps.queueRepo.listTransitions(live.qitemId) : [])].map((t) => t.transitionNote ?? "");
|
|
892
|
+
if (notes.some((note) => note.startsWith(TAKEN_NOTE)))
|
|
893
|
+
facts.taken = true;
|
|
894
|
+
if (notes.some((note) => note.startsWith(COMPLETED_NOTE)))
|
|
895
|
+
facts.toolCompleted = true;
|
|
896
|
+
if (result.state === "withdrawn" || result.state === "stale") {
|
|
897
|
+
const ended = [...notes].reverse().find((note) => note.startsWith(WITHDRAWN_NOTE) || note.startsWith(STALE_NOTE));
|
|
898
|
+
const why = ended?.match(/reason=([A-Za-z_]+)/)?.[1];
|
|
899
|
+
if (why)
|
|
900
|
+
facts.why = why;
|
|
901
|
+
}
|
|
902
|
+
if (result.state === "answered" || (result.state === "refused" && result.reason === "said_no")) {
|
|
903
|
+
const decision = this.decisionTransition(live);
|
|
904
|
+
const note = decision?.transitionNote ?? "";
|
|
905
|
+
const by = decision?.actorSession ?? live.destinationSession;
|
|
906
|
+
const denies = result.state === "refused" || result.optionId === tagValue(asked, REJECT_TAG);
|
|
907
|
+
const decided = note.startsWith(DECIDED_NOTE);
|
|
908
|
+
// The person's own answer only as OpenRig received it from them, on its human-answer path: never from a relay, from who
|
|
909
|
+
// the caller is or says it is, or from the row's answer slot, which a decision fills with its option too. An ask closed
|
|
910
|
+
// as denied any other way says who closed it, not whose answer it was.
|
|
911
|
+
const human = !decided && decision?.ownerNotificationKind === "human-decision-resolved";
|
|
912
|
+
facts.by = by;
|
|
913
|
+
if (decided || human)
|
|
914
|
+
facts.answeredAs = human ? "person" : note.startsWith(RELAYED_DECISION) ? "relayed" : "agent";
|
|
915
|
+
const typed = live.humanAnswers?.[QUESTION_ID];
|
|
916
|
+
const [, wrote, told] = decided ? DECISION_WORDS.exec(note) ?? [] : [];
|
|
917
|
+
const words = decided ? quoted(wrote) : human && typed && typeof typed === "object" && typed.kind === "typed-reply"
|
|
918
|
+
? oneLine(String(typed.text ?? "")) || null : null;
|
|
919
|
+
const reported = quoted(told);
|
|
920
|
+
if (words)
|
|
921
|
+
facts.said = words;
|
|
922
|
+
if (reported)
|
|
923
|
+
facts.reported = reported;
|
|
924
|
+
const recorded = decided ? live.resolution?.split("\n").filter(Boolean).pop() ?? null : null;
|
|
925
|
+
facts.message = recorded ?? (decided
|
|
926
|
+
? nativeDecisionMessage({ decider: by, relay: facts.answeredAs === "relayed", denies, received: words, reported, reason: "" })
|
|
927
|
+
: !human ? `Denied: ${by} closed this ask as denied in OpenRig${live.resolution ? `: "${oneLine(live.resolution)}"` : "."}`
|
|
928
|
+
: denies ? `Denied by ${by} in OpenRig: their own answer${words && plainYesOrNo(words) !== "no" ? `. They wrote: "${words}"` : "."}`
|
|
929
|
+
: `Allowed once by ${by} in OpenRig: their own answer${words && plainYesOrNo(words) !== "yes" ? `. They wrote: "${words}"` : "."}`);
|
|
930
|
+
// Until the hook takes it, say whether it's reading the ask at all.
|
|
931
|
+
if (!facts.taken)
|
|
932
|
+
Object.assign(facts, nativeAnswerReach(this.deps.db, asked));
|
|
933
|
+
}
|
|
934
|
+
return facts;
|
|
935
|
+
}
|
|
441
936
|
withdrawTurn(seat, target) {
|
|
442
937
|
if (!target.runId || !target.nativeTurnId)
|
|
443
938
|
return { confirmed: false, withdrawn: 0, pendingSubmissions: 0 };
|
|
@@ -473,7 +968,9 @@ export class RunnerPermissions {
|
|
|
473
968
|
return this.withdrawOne(seat, askId, reason);
|
|
474
969
|
}
|
|
475
970
|
withdrawOne(seat, askId, reason, requireLocal = false) {
|
|
476
|
-
|
|
971
|
+
// A native ask's hook also says why it stopped: its window ended, or the prompt was answered in the terminal.
|
|
972
|
+
const nativeReason = NATIVE_WITHDRAW_REASONS.has(reason) && (() => { const ask = this.deps.queueRepo.getById(askId); return !!ask && !!nativePermissionHook(ask); })();
|
|
973
|
+
if (!WITHDRAW_REASONS.has(reason) && !nativeReason) {
|
|
477
974
|
return { ok: false, code: "invalid_permission_request", message: "reason must be turn_cancelled, turn_ended or exited." };
|
|
478
975
|
}
|
|
479
976
|
const asked = this.deps.queueRepo.getById(askId);
|
|
@@ -488,11 +985,12 @@ export class RunnerPermissions {
|
|
|
488
985
|
return { ok: true, state: "withdrawn" };
|
|
489
986
|
// A handoff this host can't follow leaves its rows as they are; the runner just stops waiting. A row closed without a
|
|
490
987
|
// decision (its answer kept, so the request read pending) can't be canceled: the withdrawal is recorded on it instead.
|
|
988
|
+
const hook = nativePermissionHook(asked);
|
|
491
989
|
if (live && (live.state === "pending" || live.state === "in-progress" || live.state === "blocked"))
|
|
492
990
|
this.close(live, WITHDRAWN_NOTE, reason);
|
|
493
991
|
else if (live)
|
|
494
992
|
this.deps.queueRepo.update({ qitemId: live.qitemId, actorSession: live.sourceSession, state: live.state,
|
|
495
|
-
transitionNote: `${WITHDRAWN_NOTE} reason=${reason}: the runner's request ended, so any answer or decision here is not sent
|
|
993
|
+
transitionNote: `${WITHDRAWN_NOTE} reason=${reason}: ${hook ? nativeWithdrawText(reason, hook) : "the runner's request ended, so any answer or decision here is not sent."}` });
|
|
496
994
|
return !requireLocal || live ? { ok: true, state: "withdrawn" } : { ok: true, state: "pending" };
|
|
497
995
|
}
|
|
498
996
|
/** A person who closed the ask with their own words, not a choice or a plain yes or no: the read passes them back as
|
|
@@ -570,9 +1068,10 @@ export class RunnerPermissions {
|
|
|
570
1068
|
this.close(item, STALE_NOTE, "relaunched: a later occupant holds this seat");
|
|
571
1069
|
}
|
|
572
1070
|
}
|
|
573
|
-
close(item, note, reason) {
|
|
1071
|
+
close(item, note, reason, explanation) {
|
|
1072
|
+
const hook = nativePermissionHook(item);
|
|
574
1073
|
this.deps.queueRepo.update({ qitemId: item.qitemId, actorSession: item.sourceSession, state: "canceled",
|
|
575
|
-
transitionNote: `${note} reason=${reason}: the runner's request ended, so any answer here is not sent
|
|
1074
|
+
transitionNote: `${note} reason=${reason}: ${explanation ?? (hook ? nativeWithdrawText(reason, hook) : "the runner's request ended, so any answer here is not sent.")}` });
|
|
576
1075
|
}
|
|
577
1076
|
/** Who chose this seat's answer owner, and when, from the audit event. */
|
|
578
1077
|
latestSelection(nodeId) {
|
|
@@ -589,4 +1088,82 @@ export class RunnerPermissions {
|
|
|
589
1088
|
}
|
|
590
1089
|
}
|
|
591
1090
|
}
|
|
1091
|
+
/** Why a native ask ended, in the words the person reading it sees: an answer here now is too late. */
|
|
1092
|
+
function nativeWithdrawText(reason, hook) {
|
|
1093
|
+
const name = harnessName(hook);
|
|
1094
|
+
if (reason === "answer_window_ended") {
|
|
1095
|
+
return `${name}'s permission hook stopped taking an answer here when its window ended, and the prompt is waiting in the seat's terminal. Too late here: answer in the terminal. An answer here isn't sent.`;
|
|
1096
|
+
}
|
|
1097
|
+
if (reason === "answered_in_terminal") {
|
|
1098
|
+
return `the prompt ended in the seat's terminal: it was answered or cancelled there, or the seat's ${name} stopped (a relaunch, say). An answer here is too late and isn't sent.`;
|
|
1099
|
+
}
|
|
1100
|
+
return `${name}'s request ended (${reason}), so an answer here isn't sent; if the prompt is still open, it's in the seat's terminal.`;
|
|
1101
|
+
}
|
|
1102
|
+
/** The one line a native decision recorded with `rig seat decide-permission` gives the harness's agent (as a deny's
|
|
1103
|
+
* message) and the record: who decided and how (a relay stays unconfirmed: OpenRig didn't get that answer from the
|
|
1104
|
+
* person), the person's words as OpenRig received them, the words the decider reported, and an agent's reason. */
|
|
1105
|
+
function nativeDecisionMessage(input) {
|
|
1106
|
+
const { decider, relay, denies, received, reported, reason } = input;
|
|
1107
|
+
const words = `${received ? ` The person said: "${received}"` : ""}${reported ? ` ${decider} reports they said: "${reported}"` : ""}`;
|
|
1108
|
+
if (relay)
|
|
1109
|
+
return `${denies ? "Denied" : "Allowed once"}: ${decider} relayed this as the person's answer (unconfirmed: OpenRig didn't get this answer from them)${words ? `.${words}` : ", with none of their words."}`;
|
|
1110
|
+
return denies
|
|
1111
|
+
? `Not allowed: ${decider}, deciding on the person's answer, judged that this exact action doesn't meet it${reason ? ` (${reason})` : ""}. That's its judgment, not the person's own no.${words}`
|
|
1112
|
+
: `Allowed once: ${decider}, deciding on the person's answer, judged that this exact action meets it${reason ? ` (${reason})` : ""}.${words}`;
|
|
1113
|
+
}
|
|
1114
|
+
/** Whether a native ask from this seat is open and still in its window: a person can answer the prompt through OpenRig
|
|
1115
|
+
* right now, so the prompt alert waits (the wake ladder's permission leg), and so does its relay task, which would tell the
|
|
1116
|
+
* same conversation to type the answer into the seat. After the window, or once the ask is settled, the alert goes on as
|
|
1117
|
+
* before. */
|
|
1118
|
+
export function nativeAskHoldsPrompt(db, sessionName, now = Date.now()) {
|
|
1119
|
+
try {
|
|
1120
|
+
// The seat's native asks only (the partial index), not every row it ever sent: the wake ladder asks this on its ticks.
|
|
1121
|
+
// Stream the indexed asks: decided handoffs must not consume a row limit and hide an older open ask. An ask's answer-by is
|
|
1122
|
+
// at most MAX_HOLD_SECONDS after it was created, so older asks (handed-off ones stay handed-off) are never read.
|
|
1123
|
+
if (!Number.isFinite(now))
|
|
1124
|
+
return false;
|
|
1125
|
+
const since = new Date(now - MAX_HOLD_SECONDS * 1000 - NATIVE_GRACE_MS).toISOString();
|
|
1126
|
+
const rows = db.prepare(`SELECT qitem_id, state, tags FROM queue_items WHERE source_session = ? AND ts_created >= ?
|
|
1127
|
+
AND (state IN ('pending','in-progress','blocked','handed-off') OR (state = 'done' AND closure_reason = 'handed_off_to'))
|
|
1128
|
+
AND ${NATIVE_ASK_ROWS} ORDER BY ts_created DESC`).iterate(sessionName, since);
|
|
1129
|
+
const handedOff = [];
|
|
1130
|
+
for (const { qitem_id, state, tags } of rows) {
|
|
1131
|
+
let parsed;
|
|
1132
|
+
try {
|
|
1133
|
+
parsed = JSON.parse(tags ?? "[]");
|
|
1134
|
+
}
|
|
1135
|
+
catch {
|
|
1136
|
+
continue;
|
|
1137
|
+
}
|
|
1138
|
+
const by = Array.isArray(parsed) ? parsed.find((tag) => typeof tag === "string" && tag.startsWith(ANSWER_BY_TAG)) : undefined;
|
|
1139
|
+
const until = Date.parse(by?.slice(ANSWER_BY_TAG.length) ?? "");
|
|
1140
|
+
if (!Array.isArray(parsed) || !parsed.includes(RUNNER_PERMISSION_TAG) || !Number.isFinite(until) || !(now <= until))
|
|
1141
|
+
continue;
|
|
1142
|
+
// Handed on (handed-off, or done by handoff-and-complete): its chain decides, below.
|
|
1143
|
+
if (state !== "handed-off" && state !== "done")
|
|
1144
|
+
return true;
|
|
1145
|
+
handedOff.push(qitem_id);
|
|
1146
|
+
}
|
|
1147
|
+
if (handedOff.length === 0)
|
|
1148
|
+
return false;
|
|
1149
|
+
// Follow the same newest, addressed successor as liveEnd. UNION makes cycles converge. An unrepresented
|
|
1150
|
+
// handoff (including one off-host) is not proof of a decision, so it still holds until answer-by.
|
|
1151
|
+
return db.prepare(`WITH RECURSIVE chain(qitem_id, state, handed_off_to, closure_reason) AS (
|
|
1152
|
+
SELECT qitem_id, state, handed_off_to, closure_reason FROM queue_items
|
|
1153
|
+
WHERE qitem_id IN (SELECT value FROM json_each(?))
|
|
1154
|
+
UNION
|
|
1155
|
+
SELECT next.qitem_id, next.state, next.handed_off_to, next.closure_reason FROM chain
|
|
1156
|
+
JOIN queue_items next ON next.rowid = (
|
|
1157
|
+
SELECT rowid FROM queue_items WHERE handed_off_from = chain.qitem_id AND destination_session = chain.handed_off_to
|
|
1158
|
+
ORDER BY ts_created DESC, rowid DESC LIMIT 1)
|
|
1159
|
+
WHERE chain.state = 'handed-off' OR (chain.state = 'done' AND chain.closure_reason = 'handed_off_to')
|
|
1160
|
+
) SELECT 1 FROM chain WHERE state IN ('pending','in-progress','blocked')
|
|
1161
|
+
OR ((state = 'handed-off' OR (state = 'done' AND closure_reason = 'handed_off_to')) AND NOT EXISTS (
|
|
1162
|
+
SELECT 1 FROM queue_items WHERE handed_off_from = chain.qitem_id AND destination_session = chain.handed_off_to))
|
|
1163
|
+
LIMIT 1`).get(JSON.stringify(handedOff)) !== undefined;
|
|
1164
|
+
}
|
|
1165
|
+
catch {
|
|
1166
|
+
return false;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
592
1169
|
//# sourceMappingURL=runner-permissions.js.map
|