@openrig/cli 0.7.2 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/daemon/assets/plugins/openrig-core/.claude-plugin/plugin.json +1 -1
- package/daemon/assets/plugins/openrig-core/.codex-plugin/plugin.json +1 -1
- package/daemon/assets/plugins/openrig-core/skills/claude-compaction-restore/SKILL.md +2 -2
- package/daemon/assets/plugins/openrig-core/skills/messaging-the-human/SKILL.md +37 -3
- 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 +64 -11
- package/daemon/context-packs/reference/getting-started.md +7 -5
- package/daemon/context-packs/reference/manifest.yaml +1 -1
- package/daemon/context-packs/reference/rig-spec.md +86 -3
- package/daemon/context-packs/reference/whats-new.md +147 -281
- 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/SKILL.md +2 -2
- package/daemon/context-packs/skills/claude-compaction-restore/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/agent-starters/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/agent-startup-and-context-ingestion/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/cross-host-rig-commands/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/human-in-the-loop/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/messaging-the-human/SKILL.md +37 -3
- 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/SKILL.md +5 -2
- package/daemon/context-packs/skills/core/openrig-herdr/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/openrig-skills/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/openrig-software-factory/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/openrig-upgrade/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/rig-bundles-and-shareable-artifacts/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/rig-lifecycle/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/session-source-fork/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/specification-system/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/topology-mutation-and-seat-management/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/watchdog/manifest.yaml +1 -1
- package/daemon/context-packs/skills/delegating-work/manifest.yaml +1 -1
- package/daemon/context-packs/skills/forming-an-openrig-mental-model/manifest.yaml +1 -1
- package/daemon/context-packs/skills/loading-addressable-markdown/manifest.yaml +1 -1
- package/daemon/context-packs/skills/mission-slice-sop/manifest.yaml +1 -1
- package/daemon/context-packs/skills/openrig-operating-model/manifest.yaml +1 -1
- package/daemon/context-packs/skills/openrig-user/manifest.yaml +1 -1
- package/daemon/context-packs/skills/orienting-to-an-inherited-seat/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/backlog-capture/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/context-builder/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/exec-summary/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/office-hours/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/plan-review/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/requirements-writer/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/ui-mockup/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pods/development-team/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pods/orchestration-team/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pods/oversight-team/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pods/review-team/manifest.yaml +1 -1
- package/daemon/context-packs/skills/process/agent-browser/SKILL.md +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/systematic-debugging/root-cause-tracing.md +1 -1
- package/daemon/context-packs/skills/process/test-driven-development/manifest.yaml +1 -1
- package/daemon/context-packs/skills/process/verification-before-completion/manifest.yaml +1 -1
- package/daemon/context-packs/skills/queue-handoff/manifest.yaml +1 -1
- package/daemon/context-packs/skills/refocusing/manifest.yaml +1 -1
- package/daemon/context-packs/skills/retiring-and-inheriting-a-seat/manifest.yaml +1 -1
- package/daemon/context-packs/skills/seat-continuity-and-handover/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/codex-resume.d.ts +2 -1
- package/daemon/dist/adapters/codex-resume.d.ts.map +1 -1
- package/daemon/dist/adapters/codex-resume.js +12 -6
- package/daemon/dist/adapters/codex-resume.js.map +1 -1
- package/daemon/dist/adapters/codex-runtime-adapter.d.ts +9 -1
- package/daemon/dist/adapters/codex-runtime-adapter.d.ts.map +1 -1
- package/daemon/dist/adapters/codex-runtime-adapter.js +374 -49
- package/daemon/dist/adapters/codex-runtime-adapter.js.map +1 -1
- package/daemon/dist/adapters/pi-resume.js +1 -1
- package/daemon/dist/adapters/pi-resume.js.map +1 -1
- package/daemon/dist/adapters/pi-runner-protocol.d.ts +3 -3
- package/daemon/dist/adapters/pi-runner-protocol.js +2 -2
- package/daemon/dist/adapters/pi-runner.d.ts +1 -1
- package/daemon/dist/adapters/pi-runner.js +2 -2
- package/daemon/dist/adapters/pi-runner.js.map +1 -1
- package/daemon/dist/adapters/tmux-server.d.ts +0 -3
- package/daemon/dist/adapters/tmux-server.d.ts.map +1 -1
- package/daemon/dist/adapters/tmux-server.js +0 -5
- package/daemon/dist/adapters/tmux-server.js.map +1 -1
- package/daemon/dist/adapters/tmux.d.ts +13 -0
- package/daemon/dist/adapters/tmux.d.ts.map +1 -1
- package/daemon/dist/adapters/tmux.js +53 -3
- package/daemon/dist/adapters/tmux.js.map +1 -1
- package/daemon/dist/attention-surface.d.ts +16 -1
- package/daemon/dist/attention-surface.d.ts.map +1 -1
- package/daemon/dist/attention-surface.js.map +1 -1
- package/daemon/dist/build-info.js +3 -3
- package/daemon/dist/context-pack-taxonomy-surface.js +1 -1
- package/daemon/dist/context-pack-taxonomy-surface.js.map +1 -1
- package/daemon/dist/db/all-migrations.d.ts.map +1 -1
- package/daemon/dist/db/all-migrations.js +2 -0
- package/daemon/dist/db/all-migrations.js.map +1 -1
- package/daemon/dist/db/migrations/137_node_codex_permissions.d.ts +3 -0
- package/daemon/dist/db/migrations/137_node_codex_permissions.d.ts.map +1 -0
- package/daemon/dist/db/migrations/137_node_codex_permissions.js +7 -0
- package/daemon/dist/db/migrations/137_node_codex_permissions.js.map +1 -0
- package/daemon/dist/domain/active-occupant.js +1 -1
- package/daemon/dist/domain/active-occupant.js.map +1 -1
- package/daemon/dist/domain/agent-activity-store.d.ts +1 -1
- package/daemon/dist/domain/agent-activity-store.js +2 -2
- package/daemon/dist/domain/agent-activity-store.js.map +1 -1
- package/daemon/dist/domain/agent-resolver.js +1 -1
- package/daemon/dist/domain/agent-resolver.js.map +1 -1
- package/daemon/dist/domain/bind-plan.js +1 -1
- package/daemon/dist/domain/bind-plan.js.map +1 -1
- package/daemon/dist/domain/bootstrap-orchestrator.js +1 -1
- package/daemon/dist/domain/bootstrap-orchestrator.js.map +1 -1
- package/daemon/dist/domain/bundle-skills-router.js +2 -2
- package/daemon/dist/domain/bundle-skills-router.js.map +1 -1
- package/daemon/dist/domain/codex-member-permissions.d.ts +56 -0
- package/daemon/dist/domain/codex-member-permissions.d.ts.map +1 -0
- package/daemon/dist/domain/codex-member-permissions.js +140 -0
- package/daemon/dist/domain/codex-member-permissions.js.map +1 -0
- package/daemon/dist/domain/codex-owned-plugin-trust.d.ts.map +1 -1
- package/daemon/dist/domain/codex-owned-plugin-trust.js +2 -1
- package/daemon/dist/domain/codex-owned-plugin-trust.js.map +1 -1
- package/daemon/dist/domain/context-packs/context-pack-library-service.js +2 -2
- package/daemon/dist/domain/context-packs/context-pack-library-service.js.map +1 -1
- package/daemon/dist/domain/execution-candidate-reader.d.ts +16 -0
- package/daemon/dist/domain/execution-candidate-reader.d.ts.map +1 -0
- package/daemon/dist/domain/execution-candidate-reader.js +77 -0
- package/daemon/dist/domain/execution-candidate-reader.js.map +1 -0
- package/daemon/dist/domain/execution-view.d.ts.map +1 -1
- package/daemon/dist/domain/execution-view.js +16 -6
- package/daemon/dist/domain/execution-view.js.map +1 -1
- package/daemon/dist/domain/feed-perspective.d.ts +14 -0
- package/daemon/dist/domain/feed-perspective.d.ts.map +1 -0
- package/daemon/dist/domain/feed-perspective.js +36 -0
- package/daemon/dist/domain/feed-perspective.js.map +1 -0
- package/daemon/dist/domain/gateway/channel-operations.d.ts +1 -1
- package/daemon/dist/domain/gateway/channel-operations.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/human-registry.d.ts +11 -4
- package/daemon/dist/domain/gateway/human-registry.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/human-registry.js +36 -5
- package/daemon/dist/domain/gateway/human-registry.js.map +1 -1
- package/daemon/dist/domain/gateway/operator-delivery-engine.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/operator-delivery-engine.js +5 -2
- package/daemon/dist/domain/gateway/operator-delivery-engine.js.map +1 -1
- package/daemon/dist/domain/gateway/participants.d.ts +180 -0
- package/daemon/dist/domain/gateway/participants.d.ts.map +1 -0
- package/daemon/dist/domain/gateway/participants.js +434 -0
- package/daemon/dist/domain/gateway/participants.js.map +1 -0
- package/daemon/dist/domain/gateway/slack/inbound-admission.d.ts +2 -2
- package/daemon/dist/domain/gateway/slack/inbound-admission.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/inbound-admission.js +73 -6
- package/daemon/dist/domain/gateway/slack/inbound-admission.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/inbound.d.ts +18 -1
- package/daemon/dist/domain/gateway/slack/inbound.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/inbound.js +27 -11
- package/daemon/dist/domain/gateway/slack/inbound.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/message.d.ts +2 -0
- package/daemon/dist/domain/gateway/slack/message.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/message.js +14 -6
- package/daemon/dist/domain/gateway/slack/message.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/open-asks.d.ts +50 -0
- package/daemon/dist/domain/gateway/slack/open-asks.d.ts.map +1 -0
- package/daemon/dist/domain/gateway/slack/open-asks.js +215 -0
- package/daemon/dist/domain/gateway/slack/open-asks.js.map +1 -0
- package/daemon/dist/domain/gateway/slack/outbound-driver.d.ts +2 -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 +15 -1
- package/daemon/dist/domain/gateway/slack/queue-access.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/queue-access.js +98 -29
- package/daemon/dist/domain/gateway/slack/queue-access.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/slack-delivery.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/slack-delivery.js +1 -0
- package/daemon/dist/domain/gateway/slack/slack-delivery.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/slack-subsystem.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/slack-subsystem.js +56 -2
- package/daemon/dist/domain/gateway/slack/slack-subsystem.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/state-store.d.ts +3 -0
- package/daemon/dist/domain/gateway/slack/state-store.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/state-store.js +18 -0
- package/daemon/dist/domain/gateway/slack/state-store.js.map +1 -1
- package/daemon/dist/domain/hot-potato-enforcer.d.ts +1 -1
- package/daemon/dist/domain/mission-control/mission-control-read-layer.d.ts.map +1 -1
- package/daemon/dist/domain/mission-control/mission-control-read-layer.js +3 -1
- package/daemon/dist/domain/mission-control/mission-control-read-layer.js.map +1 -1
- package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts +16 -0
- package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts.map +1 -1
- package/daemon/dist/domain/mission-control/mission-control-write-contract.js +64 -16
- package/daemon/dist/domain/mission-control/mission-control-write-contract.js.map +1 -1
- package/daemon/dist/domain/native-permission-store.d.ts +3 -2
- package/daemon/dist/domain/native-permission-store.d.ts.map +1 -1
- package/daemon/dist/domain/native-permission-store.js +14 -1
- package/daemon/dist/domain/native-permission-store.js.map +1 -1
- package/daemon/dist/domain/native-resume-probe.d.ts +9 -0
- package/daemon/dist/domain/native-resume-probe.d.ts.map +1 -1
- package/daemon/dist/domain/native-resume-probe.js +37 -2
- package/daemon/dist/domain/native-resume-probe.js.map +1 -1
- package/daemon/dist/domain/node-inventory.d.ts +1 -1
- package/daemon/dist/domain/permission-account.d.ts.map +1 -1
- package/daemon/dist/domain/permission-account.js +44 -9
- package/daemon/dist/domain/permission-account.js.map +1 -1
- package/daemon/dist/domain/permission-drift-observer.js +1 -1
- package/daemon/dist/domain/permission-drift-observer.js.map +1 -1
- package/daemon/dist/domain/policies/delivery-digest-flush.d.ts +6 -2
- package/daemon/dist/domain/policies/delivery-digest-flush.d.ts.map +1 -1
- package/daemon/dist/domain/policies/delivery-digest-flush.js +34 -9
- package/daemon/dist/domain/policies/delivery-digest-flush.js.map +1 -1
- package/daemon/dist/domain/policies/quiet-release.d.ts +14 -0
- package/daemon/dist/domain/policies/quiet-release.d.ts.map +1 -1
- package/daemon/dist/domain/policies/quiet-release.js +13 -2
- package/daemon/dist/domain/policies/quiet-release.js.map +1 -1
- package/daemon/dist/domain/profile-resolution-worker.d.ts +1 -1
- package/daemon/dist/domain/profile-resolution-worker.d.ts.map +1 -1
- package/daemon/dist/domain/profile-resolution-worker.js +5 -5
- package/daemon/dist/domain/profile-resolution-worker.js.map +1 -1
- package/daemon/dist/domain/queue-destination-check.d.ts +5 -0
- package/daemon/dist/domain/queue-destination-check.d.ts.map +1 -1
- package/daemon/dist/domain/queue-destination-check.js +5 -1
- package/daemon/dist/domain/queue-destination-check.js.map +1 -1
- package/daemon/dist/domain/queue-repository.d.ts +23 -5
- package/daemon/dist/domain/queue-repository.d.ts.map +1 -1
- package/daemon/dist/domain/queue-repository.js +49 -23
- package/daemon/dist/domain/queue-repository.js.map +1 -1
- package/daemon/dist/domain/restore-orchestrator.d.ts +4 -0
- package/daemon/dist/domain/restore-orchestrator.d.ts.map +1 -1
- package/daemon/dist/domain/restore-orchestrator.js +17 -5
- package/daemon/dist/domain/restore-orchestrator.js.map +1 -1
- package/daemon/dist/domain/review/compose.js +1 -1
- package/daemon/dist/domain/review/compose.js.map +1 -1
- package/daemon/dist/domain/review/gather.js +1 -1
- package/daemon/dist/domain/review/gather.js.map +1 -1
- package/daemon/dist/domain/rig-expansion-service.d.ts.map +1 -1
- package/daemon/dist/domain/rig-expansion-service.js +1 -0
- package/daemon/dist/domain/rig-expansion-service.js.map +1 -1
- package/daemon/dist/domain/rig-repository.d.ts +1 -0
- package/daemon/dist/domain/rig-repository.d.ts.map +1 -1
- package/daemon/dist/domain/rig-repository.js +15 -0
- package/daemon/dist/domain/rig-repository.js.map +1 -1
- package/daemon/dist/domain/rig-teardown.d.ts +3 -0
- package/daemon/dist/domain/rig-teardown.d.ts.map +1 -1
- package/daemon/dist/domain/rig-teardown.js +3 -0
- package/daemon/dist/domain/rig-teardown.js.map +1 -1
- package/daemon/dist/domain/rigspec-codec.d.ts.map +1 -1
- package/daemon/dist/domain/rigspec-codec.js +4 -0
- package/daemon/dist/domain/rigspec-codec.js.map +1 -1
- package/daemon/dist/domain/rigspec-exporter.d.ts.map +1 -1
- package/daemon/dist/domain/rigspec-exporter.js +12 -1
- package/daemon/dist/domain/rigspec-exporter.js.map +1 -1
- package/daemon/dist/domain/rigspec-instantiator.d.ts +2 -0
- package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
- package/daemon/dist/domain/rigspec-instantiator.js +150 -128
- package/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
- package/daemon/dist/domain/rigspec-schema.d.ts.map +1 -1
- package/daemon/dist/domain/rigspec-schema.js +24 -1
- package/daemon/dist/domain/rigspec-schema.js.map +1 -1
- package/daemon/dist/domain/runtime-adapter.d.ts +2 -0
- package/daemon/dist/domain/runtime-adapter.d.ts.map +1 -1
- package/daemon/dist/domain/runtime-adapter.js +2 -0
- package/daemon/dist/domain/runtime-adapter.js.map +1 -1
- package/daemon/dist/domain/scope/dot-id.js +2 -2
- package/daemon/dist/domain/scope/dot-id.js.map +1 -1
- package/daemon/dist/domain/scope/scaffold-placeholder.d.ts +1 -1
- package/daemon/dist/domain/scope/scaffold-placeholder.js +1 -1
- package/daemon/dist/domain/scope/scope-audit.js +1 -1
- package/daemon/dist/domain/scope/scope-audit.js.map +1 -1
- package/daemon/dist/domain/scope/types.d.ts.map +1 -1
- package/daemon/dist/domain/scope/types.js +2 -3
- package/daemon/dist/domain/scope/types.js.map +1 -1
- package/daemon/dist/domain/seat-handover-service.d.ts +1 -1
- package/daemon/dist/domain/seat-handover-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-handover-service.js +6 -2
- package/daemon/dist/domain/seat-handover-service.js.map +1 -1
- package/daemon/dist/domain/seat-lifecycle-service.d.ts +23 -8
- package/daemon/dist/domain/seat-lifecycle-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-lifecycle-service.js +153 -12
- package/daemon/dist/domain/seat-lifecycle-service.js.map +1 -1
- package/daemon/dist/domain/seat-restart-in-place.d.ts +2 -2
- package/daemon/dist/domain/seat-restart-in-place.d.ts.map +1 -1
- package/daemon/dist/domain/seat-restart-in-place.js +2 -2
- package/daemon/dist/domain/seat-restart-in-place.js.map +1 -1
- package/daemon/dist/domain/seat-runtime-switch-service.d.ts +9 -2
- package/daemon/dist/domain/seat-runtime-switch-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-runtime-switch-service.js +53 -5
- package/daemon/dist/domain/seat-runtime-switch-service.js.map +1 -1
- package/daemon/dist/domain/seat-status-service.d.ts +1 -0
- package/daemon/dist/domain/seat-status-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-status-service.js +11 -0
- package/daemon/dist/domain/seat-status-service.js.map +1 -1
- package/daemon/dist/domain/seat-structural-activity-service.js +1 -1
- package/daemon/dist/domain/seat-structural-activity-service.js.map +1 -1
- package/daemon/dist/domain/session-registry.d.ts +2 -0
- package/daemon/dist/domain/session-registry.d.ts.map +1 -1
- package/daemon/dist/domain/session-registry.js +3 -1
- package/daemon/dist/domain/session-registry.js.map +1 -1
- package/daemon/dist/domain/session-transport.d.ts +43 -1
- package/daemon/dist/domain/session-transport.d.ts.map +1 -1
- package/daemon/dist/domain/session-transport.js +195 -25
- package/daemon/dist/domain/session-transport.js.map +1 -1
- package/daemon/dist/domain/skill-library-discovery.js +2 -2
- package/daemon/dist/domain/skill-library-discovery.js.map +1 -1
- package/daemon/dist/domain/slices/slice-indexer.d.ts +4 -4
- package/daemon/dist/domain/slices/slice-indexer.js +17 -17
- package/daemon/dist/domain/slices/slice-indexer.js.map +1 -1
- package/daemon/dist/domain/startup-orchestrator.d.ts +0 -16
- package/daemon/dist/domain/startup-orchestrator.d.ts.map +1 -1
- package/daemon/dist/domain/startup-orchestrator.js +7 -60
- package/daemon/dist/domain/startup-orchestrator.js.map +1 -1
- package/daemon/dist/domain/startup-submission-evidence.d.ts +26 -0
- package/daemon/dist/domain/startup-submission-evidence.d.ts.map +1 -1
- package/daemon/dist/domain/startup-submission-evidence.js +54 -0
- package/daemon/dist/domain/startup-submission-evidence.js.map +1 -1
- package/daemon/dist/domain/successor-session-launcher.d.ts +1 -0
- package/daemon/dist/domain/successor-session-launcher.d.ts.map +1 -1
- package/daemon/dist/domain/successor-session-launcher.js +1 -0
- package/daemon/dist/domain/successor-session-launcher.js.map +1 -1
- package/daemon/dist/domain/toml-tables.d.ts +20 -0
- package/daemon/dist/domain/toml-tables.d.ts.map +1 -0
- package/daemon/dist/domain/toml-tables.js +101 -0
- package/daemon/dist/domain/toml-tables.js.map +1 -0
- package/daemon/dist/domain/types.d.ts +25 -0
- package/daemon/dist/domain/types.d.ts.map +1 -1
- package/daemon/dist/domain/types.js.map +1 -1
- package/daemon/dist/domain/user-settings/settings-store.d.ts.map +1 -1
- package/daemon/dist/domain/user-settings/settings-store.js +5 -6
- package/daemon/dist/domain/user-settings/settings-store.js.map +1 -1
- package/daemon/dist/domain/view-projector.d.ts +1 -0
- package/daemon/dist/domain/view-projector.d.ts.map +1 -1
- package/daemon/dist/domain/view-projector.js +15 -2
- package/daemon/dist/domain/view-projector.js.map +1 -1
- package/daemon/dist/domain/workflow-human-destination.d.ts.map +1 -1
- package/daemon/dist/domain/workflow-human-destination.js +5 -3
- package/daemon/dist/domain/workflow-human-destination.js.map +1 -1
- package/daemon/dist/domain/workflow-projector.d.ts +1 -0
- package/daemon/dist/domain/workflow-projector.d.ts.map +1 -1
- package/daemon/dist/domain/workflow-projector.js +19 -3
- package/daemon/dist/domain/workflow-projector.js.map +1 -1
- package/daemon/dist/domain/workflow-runtime.d.ts +2 -2
- package/daemon/dist/domain/workflow-runtime.d.ts.map +1 -1
- package/daemon/dist/domain/workflow-runtime.js +6 -4
- package/daemon/dist/domain/workflow-runtime.js.map +1 -1
- package/daemon/dist/gateway-human-registry-surface.d.ts +1 -0
- package/daemon/dist/gateway-human-registry-surface.d.ts.map +1 -1
- package/daemon/dist/gateway-human-registry-surface.js +1 -0
- package/daemon/dist/gateway-human-registry-surface.js.map +1 -1
- package/daemon/dist/index.js +2 -2
- package/daemon/dist/index.js.map +1 -1
- package/daemon/dist/lib/pane-envelope.d.ts +4 -0
- package/daemon/dist/lib/pane-envelope.d.ts.map +1 -1
- package/daemon/dist/lib/pane-envelope.js +1 -1
- package/daemon/dist/lib/pane-envelope.js.map +1 -1
- package/daemon/dist/routes/activity.js +1 -1
- package/daemon/dist/routes/activity.js.map +1 -1
- package/daemon/dist/routes/agent-images.d.ts.map +1 -1
- package/daemon/dist/routes/agent-images.js +10 -0
- package/daemon/dist/routes/agent-images.js.map +1 -1
- package/daemon/dist/routes/attention.d.ts.map +1 -1
- package/daemon/dist/routes/attention.js +15 -3
- package/daemon/dist/routes/attention.js.map +1 -1
- package/daemon/dist/routes/bundles.js +1 -1
- package/daemon/dist/routes/bundles.js.map +1 -1
- package/daemon/dist/routes/gateway.d.ts.map +1 -1
- package/daemon/dist/routes/gateway.js +42 -0
- package/daemon/dist/routes/gateway.js.map +1 -1
- package/daemon/dist/routes/hosts.d.ts.map +1 -1
- package/daemon/dist/routes/hosts.js +5 -2
- package/daemon/dist/routes/hosts.js.map +1 -1
- package/daemon/dist/routes/mission-control.d.ts.map +1 -1
- package/daemon/dist/routes/mission-control.js +5 -1
- package/daemon/dist/routes/mission-control.js.map +1 -1
- package/daemon/dist/routes/plugins.js +1 -1
- package/daemon/dist/routes/plugins.js.map +1 -1
- package/daemon/dist/routes/queue.d.ts.map +1 -1
- package/daemon/dist/routes/queue.js +34 -8
- package/daemon/dist/routes/queue.js.map +1 -1
- package/daemon/dist/routes/rigs.js +2 -0
- package/daemon/dist/routes/rigs.js.map +1 -1
- package/daemon/dist/routes/runtime-switch-custody.js +1 -1
- package/daemon/dist/routes/scope-audit.js +1 -1
- package/daemon/dist/routes/scope-audit.js.map +1 -1
- package/daemon/dist/routes/seat.d.ts.map +1 -1
- package/daemon/dist/routes/seat.js +49 -15
- package/daemon/dist/routes/seat.js.map +1 -1
- package/daemon/dist/routes/sessions.js +15 -3
- package/daemon/dist/routes/sessions.js.map +1 -1
- package/daemon/dist/routes/skills.js +1 -1
- package/daemon/dist/routes/skills.js.map +1 -1
- package/daemon/dist/routes/slices.js +1 -1
- package/daemon/dist/routes/slices.js.map +1 -1
- package/daemon/dist/routes/transcripts.js +2 -2
- package/daemon/dist/routes/transcripts.js.map +1 -1
- package/daemon/dist/routes/transport.d.ts.map +1 -1
- package/daemon/dist/routes/transport.js +12 -3
- package/daemon/dist/routes/transport.js.map +1 -1
- package/daemon/dist/routes/workflow.js +1 -1
- package/daemon/dist/routes/workflow.js.map +1 -1
- package/daemon/dist/startup.js +1 -1
- package/daemon/dist/startup.js.map +1 -1
- package/daemon/dist/terminal/TerminalSessionBroker.d.ts +18 -2
- package/daemon/dist/terminal/TerminalSessionBroker.d.ts.map +1 -1
- package/daemon/dist/terminal/TerminalSessionBroker.js +55 -9
- package/daemon/dist/terminal/TerminalSessionBroker.js.map +1 -1
- package/daemon/dist/terminal/window-pin.d.ts +41 -0
- package/daemon/dist/terminal/window-pin.d.ts.map +1 -0
- package/daemon/dist/terminal/window-pin.js +103 -0
- package/daemon/dist/terminal/window-pin.js.map +1 -0
- package/daemon/docs/reference/a2a-agents.md +16 -4
- package/daemon/docs/reference/agent-startup-guide.md +34 -2
- package/daemon/docs/reference/community-harness-examples/hermes/config.yaml.example +2 -1
- package/daemon/docs/reference/community-harness-presets.md +72 -2
- package/daemon/docs/reference/gateway-participants.md +165 -0
- package/daemon/docs/reference/getting-started.md +7 -5
- package/daemon/docs/reference/quickstart.md +13 -1
- package/daemon/docs/reference/rig-spec.md +86 -3
- package/daemon/docs/reference/seat-delivery.md +10 -1
- package/daemon/docs/reference/seat-node-targeting.md +17 -0
- package/daemon/docs/reference/slack-app-setup.md +20 -2
- package/daemon/docs/reference/whats-new.md +147 -281
- package/daemon/specs/agents/shared/skills/core/messaging-the-human/SKILL.md +37 -3
- package/daemon/specs/agents/shared/skills/core/openrig-herdr/SKILL.md +5 -2
- package/daemon/specs/agents/shared/skills/process/agent-browser/SKILL.md +1 -1
- package/daemon/specs/agents/shared/skills/process/systematic-debugging/root-cause-tracing.md +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 +4 -1
- package/dist/client.js.map +1 -1
- package/dist/commands/acp.js +1 -1
- package/dist/commands/capture.d.ts +27 -0
- package/dist/commands/capture.d.ts.map +1 -1
- package/dist/commands/capture.js +62 -4
- package/dist/commands/capture.js.map +1 -1
- package/dist/commands/doctor.d.ts +9 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +18 -2
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/down.d.ts.map +1 -1
- package/dist/commands/down.js +3 -0
- package/dist/commands/down.js.map +1 -1
- package/dist/commands/export.d.ts.map +1 -1
- package/dist/commands/export.js +10 -5
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/gateway.d.ts.map +1 -1
- package/dist/commands/gateway.js +309 -23
- package/dist/commands/gateway.js.map +1 -1
- package/dist/commands/queue.d.ts.map +1 -1
- package/dist/commands/queue.js +26 -8
- package/dist/commands/queue.js.map +1 -1
- package/dist/commands/rig-mode.d.ts +1 -2
- package/dist/commands/rig-mode.d.ts.map +1 -1
- package/dist/commands/rig-mode.js +2 -2
- package/dist/commands/rig-mode.js.map +1 -1
- package/dist/commands/scope.d.ts.map +1 -1
- package/dist/commands/scope.js +12 -4
- package/dist/commands/scope.js.map +1 -1
- package/dist/commands/seat.d.ts.map +1 -1
- package/dist/commands/seat.js +35 -5
- package/dist/commands/seat.js.map +1 -1
- package/dist/commands/send.d.ts +3 -0
- package/dist/commands/send.d.ts.map +1 -1
- package/dist/commands/send.js +16 -18
- package/dist/commands/send.js.map +1 -1
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +10 -2
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/skill.js +1 -1
- package/dist/commands/skill.js.map +1 -1
- package/dist/commands/slack.d.ts +10 -0
- package/dist/commands/slack.d.ts.map +1 -1
- package/dist/commands/slack.js +70 -2
- package/dist/commands/slack.js.map +1 -1
- package/dist/config-store.d.ts.map +1 -1
- package/dist/config-store.js +3 -2
- package/dist/config-store.js.map +1 -1
- package/dist/daemon-lifecycle.d.ts +1 -1
- package/dist/daemon-lifecycle.js +2 -2
- package/dist/daemon-lifecycle.js.map +1 -1
- package/dist/fetch-with-timeout.d.ts.map +1 -1
- package/dist/fetch-with-timeout.js +3 -1
- package/dist/fetch-with-timeout.js.map +1 -1
- package/dist/lib/scope/dot-id.js +2 -2
- package/dist/lib/scope/dot-id.js.map +1 -1
- package/dist/lib/scope/scaffold-placeholder.d.ts +1 -1
- package/dist/lib/scope/scaffold-placeholder.js +1 -1
- package/dist/lib/scope/scope-audit.js +1 -1
- package/dist/lib/scope/scope-audit.js.map +1 -1
- package/dist/lib/scope/types.d.ts.map +1 -1
- package/dist/lib/scope/types.js +2 -3
- package/dist/lib/scope/types.js.map +1 -1
- package/dist/long-request-fetch.d.ts +9 -0
- package/dist/long-request-fetch.d.ts.map +1 -0
- package/dist/long-request-fetch.js +48 -0
- package/dist/long-request-fetch.js.map +1 -0
- package/dist/mcp-server.js +1 -1
- package/dist/mcp-server.js.map +1 -1
- package/dist/release-surface/affected-skills.d.ts.map +1 -1
- package/dist/release-surface/affected-skills.js +1 -2
- package/dist/release-surface/affected-skills.js.map +1 -1
- package/dist/remote-host-ops.d.ts +1 -0
- package/dist/remote-host-ops.d.ts.map +1 -1
- package/dist/remote-host-ops.js +2 -2
- package/dist/remote-host-ops.js.map +1 -1
- package/dist/tmux-health.d.ts +26 -0
- package/dist/tmux-health.d.ts.map +1 -1
- package/dist/tmux-health.js +42 -0
- package/dist/tmux-health.js.map +1 -1
- package/package.json +1 -1
- package/tui/dist/attention/attention-model.d.ts +19 -0
- package/tui/dist/attention/attention-model.d.ts.map +1 -1
- package/tui/dist/attention/attention-model.js +38 -6
- package/tui/dist/attention/attention-model.js.map +1 -1
- package/tui/dist/commands/registry.d.ts.map +1 -1
- package/tui/dist/commands/registry.js +4 -1
- package/tui/dist/commands/registry.js.map +1 -1
- package/tui/dist/daemon-client.d.ts +13 -8
- package/tui/dist/daemon-client.d.ts.map +1 -1
- package/tui/dist/daemon-client.js +18 -10
- package/tui/dist/daemon-client.js.map +1 -1
- package/tui/dist/demo-data.js +17 -17
- package/tui/dist/demo-data.js.map +1 -1
- package/tui/dist/hydrate.d.ts +1 -1
- package/tui/dist/hydrate.d.ts.map +1 -1
- package/tui/dist/hydrate.js +31 -10
- package/tui/dist/hydrate.js.map +1 -1
- package/tui/dist/live-events.js +1 -1
- package/tui/dist/live-events.js.map +1 -1
- package/tui/dist/main.js +27 -7
- package/tui/dist/main.js.map +1 -1
- package/tui/dist/page-read.js +1 -1
- package/tui/dist/page-read.js.map +1 -1
- package/tui/dist/render.d.ts.map +1 -1
- package/tui/dist/render.js +51 -7
- package/tui/dist/render.js.map +1 -1
- package/tui/dist/state.d.ts.map +1 -1
- package/tui/dist/state.js +5 -1
- package/tui/dist/state.js.map +1 -1
- package/tui/dist/terminals/open-window.d.ts +8 -3
- package/tui/dist/terminals/open-window.d.ts.map +1 -1
- package/tui/dist/terminals/open-window.js +21 -6
- package/tui/dist/terminals/open-window.js.map +1 -1
- package/tui/dist/terminals/terminal-model.d.ts +1 -1
- package/tui/dist/terminals/terminal-model.d.ts.map +1 -1
- package/tui/dist/terminals/terminal-model.js +1 -1
- package/tui/dist/terminals/terminal-model.js.map +1 -1
- package/tui/dist/types.d.ts +10 -1
- package/tui/dist/types.d.ts.map +1 -1
- package/ui/dist/assets/{index-DLP1ipGq.js → index-DV0UNxFw.js} +1 -1
- package/ui/dist/index.html +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { codexEnvelopeArgs } from "../domain/codex-rebuild-permissions.js";
|
|
2
|
+
import { codexMemberEnvelope, observeCodexEnvelope, readProfileFingerprint } from "../domain/codex-member-permissions.js";
|
|
2
3
|
import { operationalLaunchArg } from "./kernel-authority.js";
|
|
3
4
|
import nodePath from "node:path";
|
|
4
5
|
import fs from "node:fs";
|
|
@@ -36,6 +37,7 @@ const codexHookTrust = createRequire(import.meta.url)("../../assets/plugins/open
|
|
|
36
37
|
import { listNativeProcesses, observeCodexPaneProcess, observeCodexForkProcess, verifyCodexPaneProcess, verifyPaneIdleShell } from "../domain/native-process-lineage.js";
|
|
37
38
|
import { recordSeatSkillWrite, seatPluginSkillsLossNote, seatProjectionComplete, seatSkillWriteRefusal } from "../domain/seat-skill-storage.js";
|
|
38
39
|
import { codexPluginContentHash, planOwnedCodexContentApproval, recordOwnedCodexApproval } from "../domain/codex-owned-plugin-trust.js";
|
|
40
|
+
import { findTomlTable, opensTomlTable, parseTomlRoot, tomlArrayTableHeaderPath, tomlDefines, tomlTableHeaderPath } from "../domain/toml-tables.js";
|
|
39
41
|
// The managed resume check's poll window: a quick phase, then an extended one for a slow boot.
|
|
40
42
|
const RESUME_QUICK_ATTEMPTS = 6;
|
|
41
43
|
const RESUME_EXTENDED_ATTEMPTS = 24;
|
|
@@ -70,6 +72,7 @@ export class CodexRuntimeAdapter {
|
|
|
70
72
|
// so no real codex subprocess runs. Contract not weakened — production uses
|
|
71
73
|
// the real probe by default.
|
|
72
74
|
verifyProfilePreflight;
|
|
75
|
+
profileFingerprint;
|
|
73
76
|
// #69: whether the installed Codex supports --no-daemon. Startup wires the real probe;
|
|
74
77
|
// absent (unit tests, other embedders) keeps the existing invocation unchanged.
|
|
75
78
|
detectDaemonSupport;
|
|
@@ -113,6 +116,7 @@ export class CodexRuntimeAdapter {
|
|
|
113
116
|
this.fs = deps.fsOps;
|
|
114
117
|
this.codexHome = deps.codexHome;
|
|
115
118
|
this.seatHome = deps.seatHome;
|
|
119
|
+
this.profileFingerprint = deps.profileFingerprint ?? readProfileFingerprint;
|
|
116
120
|
this.launchPath = deps.launchPath;
|
|
117
121
|
this.detectDaemonSupport = deps.detectDaemonSupport;
|
|
118
122
|
this.readNetworkDefault = deps.readNetworkDefault;
|
|
@@ -491,6 +495,10 @@ export class CodexRuntimeAdapter {
|
|
|
491
495
|
return;
|
|
492
496
|
}
|
|
493
497
|
const withHooks = upsertCodexActivityHooks(existing, relay);
|
|
498
|
+
if (!changesOnlyOpenRigActivityHooks(existing, withHooks, `node "${relay}"`)) {
|
|
499
|
+
console.error(`[openrig] codex activity hooks skipped: ${configPath} can't be read as TOML, or writing OpenRig's hooks would change anything else; left untouched`);
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
494
502
|
if (withHooks !== existing) {
|
|
495
503
|
this.fs.mkdirp(nodePath.dirname(configPath));
|
|
496
504
|
this.fs.writeFile(configPath, withHooks);
|
|
@@ -527,7 +535,7 @@ export class CodexRuntimeAdapter {
|
|
|
527
535
|
}
|
|
528
536
|
const command = `node "${relay}"`;
|
|
529
537
|
const keySource = canonicalCodexHookSource(hooksPath);
|
|
530
|
-
const stripped = upsertCodexFeaturesHooksEnabled(stripCodexActivityHooks(existing));
|
|
538
|
+
const stripped = upsertCodexFeaturesHooksEnabled(stripCodexActivityHooks(existing, command));
|
|
531
539
|
let before = null;
|
|
532
540
|
let expected = null;
|
|
533
541
|
try {
|
|
@@ -601,10 +609,14 @@ export class CodexRuntimeAdapter {
|
|
|
601
609
|
// group's position among this event's groups, not its position inside our block.
|
|
602
610
|
// Count only the groups before the marker: a person's groups after it do not
|
|
603
611
|
// move ours, and their trust/disable records must not be written as ours.
|
|
604
|
-
|
|
612
|
+
// Without a marker (Codex's save left our groups where they sit), each group's own position.
|
|
613
|
+
const begin = content.indexOf(OPENRIG_ACTIVITY_HOOKS_BEGIN);
|
|
614
|
+
const parsed = parseToml(begin >= 0 ? content.slice(0, begin) : content);
|
|
605
615
|
let next = content;
|
|
606
616
|
for (const event of OPENRIG_ACTIVITY_HOOK_EVENTS) {
|
|
607
|
-
const groupIndex =
|
|
617
|
+
const groupIndex = begin >= 0 ? parsed.hooks?.[event]?.length ?? 0 : openRigInlineGroupIndex(parsed, event);
|
|
618
|
+
if (groupIndex < 0)
|
|
619
|
+
continue;
|
|
608
620
|
const { key, hash } = computeCodexHookTrust(event, { keySource, command, timeoutSec: 5, groupIndex });
|
|
609
621
|
next = upsertCodexHookTrust(next, key, hash);
|
|
610
622
|
}
|
|
@@ -621,7 +633,12 @@ export class CodexRuntimeAdapter {
|
|
|
621
633
|
const configPath = this.resolveCodexConfigPath(home);
|
|
622
634
|
const hooksPath = nodePath.join(nodePath.dirname(configPath), "hooks.json");
|
|
623
635
|
const existing = this.fs.exists(configPath) ? this.fs.readFile(configPath) : null;
|
|
624
|
-
|
|
636
|
+
const current = this.activityRelayPath ? `node "${this.activityRelayPath}"` : undefined;
|
|
637
|
+
let updated = existing === null ? null : stripCodexActivityHooks(existing, current);
|
|
638
|
+
if (existing !== null && updated !== existing && !changesOnlyOpenRigActivityHooks(existing, updated, current)) {
|
|
639
|
+
console.error(`[openrig] codex activity hook removal skipped for ${configPath}: it can't be read as TOML, or removing OpenRig's hooks would change anything else; left untouched`);
|
|
640
|
+
updated = existing;
|
|
641
|
+
}
|
|
625
642
|
if (this.fs.exists(hooksPath)) {
|
|
626
643
|
// Only OpenRig's groups leave. Codex keys trust and disables by position, so each later group's state moves with it.
|
|
627
644
|
try {
|
|
@@ -884,6 +901,35 @@ export class CodexRuntimeAdapter {
|
|
|
884
901
|
return updatePrompt.failure;
|
|
885
902
|
return this.verifyResumeLaunch(tmuxSession, updatePrompt, { resumeToken, ...(home ? { home } : this.ownHomeOpt({ nodeId })) });
|
|
886
903
|
}
|
|
904
|
+
/** The setter's check of a profile, in the config home this seat's launches use: its own CODEX_HOME, else the
|
|
905
|
+
* daemon's, resolved as launch resolves it. An absent file is reported, not refused: Codex loads a missing profile as
|
|
906
|
+
* an empty layer. A real load failure fails here as it does at launch. */
|
|
907
|
+
async observeProfile(profile, cwd, nodeId) {
|
|
908
|
+
const observedAt = new Date().toISOString();
|
|
909
|
+
const home = this.homeFor({ nodeId });
|
|
910
|
+
const own = this.ownHome({ nodeId });
|
|
911
|
+
if (!home) {
|
|
912
|
+
return { vantage: "unestablished", home: null, file: "unverified", load: "not_run", observedAt,
|
|
913
|
+
detail: "Neither this seat's env: nor the daemon sets CODEX_HOME, so this seat's pane keeps its own; OpenRig didn't check the profile there. Each launch still runs the native profile check." };
|
|
914
|
+
}
|
|
915
|
+
const path = nodePath.join(home, `${profile}.config.toml`);
|
|
916
|
+
// The hash is optional evidence, read without blocking; the native loader check below decides.
|
|
917
|
+
const print = await this.profileFingerprint(path).catch((error) => ({ state: "unreadable", reason: error.message }));
|
|
918
|
+
const base = { vantage: "configured_codex_home", home, file: print.state,
|
|
919
|
+
...(print.state === "present" ? { sha256: print.sha256 } : {}), observedAt };
|
|
920
|
+
let probe;
|
|
921
|
+
// Only a confirmed native load failure is refused; a check that couldn't run is reported, not refused.
|
|
922
|
+
try {
|
|
923
|
+
probe = await (own ? this.verifyProfilePreflight(profile, cwd, own) : this.verifyProfilePreflight(profile, cwd));
|
|
924
|
+
}
|
|
925
|
+
catch (error) {
|
|
926
|
+
return { ...base, load: "not_run", detail: `The native profile check couldn't run (${error.message}); each launch runs it again.` };
|
|
927
|
+
}
|
|
928
|
+
if (!probe.ok)
|
|
929
|
+
return { ...base, load: "failed", detail: `${probe.error}${probe.migrationHint ? `\n Fix: ${probe.migrationHint}` : ""}` };
|
|
930
|
+
const unread = print.state === "unreadable" ? ` Its bytes weren't read for a hash (${print.reason}).` : "";
|
|
931
|
+
return { ...base, load: "ok", detail: print.state === "absent" ? `${path} is absent; Codex loads it as an empty layer, so base config applies.` : `${path} loads.${unread}` };
|
|
932
|
+
}
|
|
887
933
|
/** Launch flags shared by fresh, fork and resume, decided once per launch. With `running`, the probed and
|
|
888
934
|
* prepared parts come from the running Codex instead, and no Codex process is started to decide them. */
|
|
889
935
|
async prepareLaunch(binding, name, running, opts) {
|
|
@@ -909,14 +955,15 @@ export class CodexRuntimeAdapter {
|
|
|
909
955
|
const effortArg = effort ? ` -c ${shellQuote(`model_reasoning_effort="${effort}"`)}` : "";
|
|
910
956
|
const profile = binding.codexConfigProfile?.trim();
|
|
911
957
|
const profileArg = profile ? ` -p ${shellQuote(profile)}` : "";
|
|
912
|
-
|
|
913
|
-
|
|
958
|
+
// A handover rebuild's observed predecessor envelope, else the seat's own envelope, replaces the posture decision.
|
|
959
|
+
const memberEnvelope = binding.codexRebuildPermissions || !binding.codexPermissions ? undefined : codexMemberEnvelope(binding.codexPermissions);
|
|
960
|
+
const envelope = binding.codexRebuildPermissions ?? memberEnvelope;
|
|
961
|
+
const posture = envelope
|
|
962
|
+
? profileArg + codexEnvelopeArgs(envelope)
|
|
914
963
|
: codexPostureArg(profileArg, process.env, binding.launchPosture);
|
|
915
|
-
const appliedLaunch =
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
: observeCodexSandbox(posture);
|
|
919
|
-
const postureArg = posture + operationalLaunchArg(this.runtime, binding);
|
|
964
|
+
const appliedLaunch = envelope ? observeCodexEnvelope(envelope) : observeCodexSandbox(posture);
|
|
965
|
+
// The seat's envelope is not full access, so a policy's full_bypass extras don't follow it.
|
|
966
|
+
const postureArg = posture + operationalLaunchArg(this.runtime, memberEnvelope ? { ...binding, kernelAuthority: false, launchPosture: undefined } : binding);
|
|
920
967
|
if (running) {
|
|
921
968
|
// The running Codex already loaded its profile; drift in -p is the caller's to compare.
|
|
922
969
|
// Its own --add-dirs, git dirs included, carry over as they ran; none are resolved again. They follow the
|
|
@@ -943,8 +990,9 @@ export class CodexRuntimeAdapter {
|
|
|
943
990
|
}
|
|
944
991
|
// Codex rejects writable --add-dir roots under a read-only sandbox. Only
|
|
945
992
|
// suppress OpenRig's generated roots when later project layers cannot make it writable.
|
|
946
|
-
|
|
947
|
-
|
|
993
|
+
// A seat envelope states its sandbox: read-only gets no generated roots; workspace-write keeps them.
|
|
994
|
+
const suppressAutoAddDirs = memberEnvelope ? memberEnvelope.sandboxPolicy.type === "read-only"
|
|
995
|
+
: Boolean(!binding.codexRebuildPermissions && profile && posture === profileArg && this.profileRemainsReadOnly(profile, binding.cwd, home));
|
|
948
996
|
// Issue #121: fresh, resume and fork get the same git metadata dirs, so a restored or forked seat can still commit.
|
|
949
997
|
// A rebuild keeps the writable roots its observed envelope names instead.
|
|
950
998
|
const gitDirArg = binding.codexRebuildPermissions || suppressAutoAddDirs
|
|
@@ -952,7 +1000,7 @@ export class CodexRuntimeAdapter {
|
|
|
952
1000
|
// The seat's own topology folder, so it can keep its LEARNED.md and recap: the same launches and the same suppression.
|
|
953
1001
|
const seatFolder = binding.codexRebuildPermissions || suppressAutoAddDirs ? undefined : this.prepareSeatFolder?.(name);
|
|
954
1002
|
const seatFolderArg = seatFolder ? ` --add-dir ${shellQuote(seatFolder)}` : "";
|
|
955
|
-
const teamWorkspaceArg = !
|
|
1003
|
+
const teamWorkspaceArg = !envelope && binding.teamPermissionDefault && !profile
|
|
956
1004
|
&& appliedLaunch.state === "observed" && appliedLaunch.value === "workspace-write"
|
|
957
1005
|
? codexTeamWorkspaceArg(this.prepareTeamWorkspace, name) : "";
|
|
958
1006
|
const queueStateDirArg = binding.codexRebuildPermissions || suppressAutoAddDirs
|
|
@@ -965,8 +1013,8 @@ export class CodexRuntimeAdapter {
|
|
|
965
1013
|
}
|
|
966
1014
|
const daemonOptOut = daemonSupport?.kind === "supported";
|
|
967
1015
|
const daemonArg = daemonOptOut ? " --no-daemon" : "";
|
|
968
|
-
// #275: on the plain floor, network access unless Codex reports an opt-out or policy.
|
|
969
|
-
const networkArg =
|
|
1016
|
+
// #275: on the plain floor, network access unless Codex reports an opt-out or policy. An envelope states its own.
|
|
1017
|
+
const networkArg = envelope ? ""
|
|
970
1018
|
: await codexNetworkDefaultArg(own && this.readNetworkDefault ? ((cwd) => this.readNetworkDefault(cwd, own)) : this.readNetworkDefault, appliedLaunch, binding.cwd, name);
|
|
971
1019
|
// The launch facts keep the probed daemon choice, so a printed recovery command can repeat it; no probe, no fact.
|
|
972
1020
|
const launchFacts = daemonSupport ? { ...appliedLaunch, daemonOptOut } : appliedLaunch;
|
|
@@ -1361,6 +1409,9 @@ export class CodexRuntimeAdapter {
|
|
|
1361
1409
|
assertFragmentOpensWithTable(fragment, entry.absolutePath, entry.effectiveId);
|
|
1362
1410
|
const rendered = upsertManagedCodexConfigFragment(existing, entry.effectiveId, fragment);
|
|
1363
1411
|
assertRendersAsLoadableToml(rendered, configPath, entry.effectiveId);
|
|
1412
|
+
if (!changesOnlyFragmentTables(existing, rendered, entry.effectiveId, fragment)) {
|
|
1413
|
+
throw new Error(`Codex config projection '${entry.effectiveId}' would change more than its own tables in ${configPath}; left unchanged.`);
|
|
1414
|
+
}
|
|
1364
1415
|
this.fs.writeFile(configPath, rendered);
|
|
1365
1416
|
return true;
|
|
1366
1417
|
}
|
|
@@ -1791,10 +1842,13 @@ function hashContent(content) {
|
|
|
1791
1842
|
return createHash("sha256").update(content).digest("hex");
|
|
1792
1843
|
}
|
|
1793
1844
|
function upsertCodexProjectTrust(content, projectPath) {
|
|
1845
|
+
const path = ["projects", projectPath];
|
|
1794
1846
|
const header = `[projects.${JSON.stringify(projectPath)}]`;
|
|
1795
1847
|
const lines = content.length > 0 ? content.split("\n") : [];
|
|
1796
|
-
const headerIndex = lines
|
|
1848
|
+
const headerIndex = findTomlTable(lines, path);
|
|
1797
1849
|
if (headerIndex === -1) {
|
|
1850
|
+
if (tomlDefines(content, path))
|
|
1851
|
+
return content;
|
|
1798
1852
|
const trimmed = content.trimEnd();
|
|
1799
1853
|
const prefix = trimmed.length > 0 ? `${trimmed}\n\n` : "";
|
|
1800
1854
|
return `${prefix}${header}\ntrust_level = "trusted"\n`;
|
|
@@ -1885,16 +1939,19 @@ export function computeCodexHookTrust(event, input) {
|
|
|
1885
1939
|
/**
|
|
1886
1940
|
* OPR.0.4.3.33 — idempotent, non-clobbering, section-scoped writer for a single
|
|
1887
1941
|
* `[hooks.state."<key>"] trusted_hash = "<hash>"` record. Mirrors upsertCodexProjectTrust:
|
|
1888
|
-
* find
|
|
1942
|
+
* find the table by its key in any spelling (or create it), splice ONLY its `trusted_hash` line, leave every other
|
|
1889
1943
|
* `[hooks.state]` / `[projects]` entry and the managed hook block byte-identical. Same key+hash
|
|
1890
1944
|
* ⇒ no-op. Only called for our authored inline or verified owned plugin keys (never blanket trust).
|
|
1891
1945
|
*/
|
|
1892
1946
|
export function upsertCodexHookTrust(content, key, hash, field = "trusted_hash") {
|
|
1947
|
+
const path = ["hooks", "state", key];
|
|
1893
1948
|
const header = `[hooks.state.${JSON.stringify(key)}]`;
|
|
1894
1949
|
const trustLine = `${field} = ${JSON.stringify(hash)}`;
|
|
1895
1950
|
const lines = content.length > 0 ? content.split("\n") : [];
|
|
1896
|
-
const headerIndex = lines
|
|
1951
|
+
const headerIndex = findTomlTable(lines, path);
|
|
1897
1952
|
if (headerIndex === -1) {
|
|
1953
|
+
if (tomlDefines(content, path))
|
|
1954
|
+
return content;
|
|
1898
1955
|
const trimmed = content.trimEnd();
|
|
1899
1956
|
const prefix = trimmed.length > 0 ? `${trimmed}\n\n` : "";
|
|
1900
1957
|
return `${prefix}${header}\n${trustLine}\n`;
|
|
@@ -1996,13 +2053,103 @@ function upsertCodexActivityHooks(content, relayPath) {
|
|
|
1996
2053
|
.join("\n\n");
|
|
1997
2054
|
const block = `${OPENRIG_ACTIVITY_HOOKS_BEGIN}\n${stanzas}\n${OPENRIG_ACTIVITY_HOOKS_END}\n`;
|
|
1998
2055
|
let next = upsertCodexFeaturesHooksEnabled(content);
|
|
1999
|
-
const pattern = new RegExp(`${escapeRegExp(OPENRIG_ACTIVITY_HOOKS_BEGIN)}[\\s\\S]
|
|
2056
|
+
const pattern = new RegExp(`${escapeRegExp(OPENRIG_ACTIVITY_HOOKS_BEGIN)}([\\s\\S]*?)${escapeRegExp(OPENRIG_ACTIVITY_HOOKS_END)}\\n?`, "m");
|
|
2000
2057
|
if (pattern.test(next)) {
|
|
2001
|
-
|
|
2058
|
+
// literal: a string would expand `$` patterns in the path
|
|
2059
|
+
return next.replace(pattern, (_span, inner) => {
|
|
2060
|
+
const kept = keptInActivityBlock(inner, `node "${relayPath}"`);
|
|
2061
|
+
return kept ? `${block}\n${kept}\n` : block;
|
|
2062
|
+
});
|
|
2002
2063
|
}
|
|
2064
|
+
// Codex's own saves can leave our markers apart from our groups. Groups that already run OpenRig's relay are ours
|
|
2065
|
+
// where they sit: point them at this relay rather than append a second set, which Codex would run twice.
|
|
2066
|
+
const relayGroups = retargetOpenRigRelayGroups(next, command, `node "${relayPath}"`);
|
|
2067
|
+
if (relayGroups !== null)
|
|
2068
|
+
return relayGroups;
|
|
2003
2069
|
const prefix = next.replace(/\n*$/, "");
|
|
2004
2070
|
return prefix.length > 0 ? `${prefix}\n\n${block}` : block;
|
|
2005
2071
|
}
|
|
2072
|
+
/**
|
|
2073
|
+
* What else sits between OpenRig's activity-hook markers. When Codex saves config.toml (its "Trust all", say), a
|
|
2074
|
+
* table it rewrites loses its file position and is printed after the last hook group, which can be inside our
|
|
2075
|
+
* block: Codex 0.164.0 rewrites all of `[hooks.state]` this way. Every section but OpenRig's own activity groups is
|
|
2076
|
+
* kept whole, with the comments just above it.
|
|
2077
|
+
*/
|
|
2078
|
+
function keptInActivityBlock(inner, current) {
|
|
2079
|
+
const lines = inner.split("\n");
|
|
2080
|
+
return tomlSections(inner, current).filter((section) => !section.openRig)
|
|
2081
|
+
.map(({ start, end }) => lines.slice(start, end).join("\n")).join("\n").trim();
|
|
2082
|
+
}
|
|
2083
|
+
/** Point every inline group that runs OpenRig's relay (from any install) at `command` (TOML text), in place; null when
|
|
2084
|
+
* there's none, or the file can't be read as TOML. Only those groups' own `command` lines change: a person's groups,
|
|
2085
|
+
* their other text and every position stay as they are. */
|
|
2086
|
+
function retargetOpenRigRelayGroups(content, command, current) {
|
|
2087
|
+
let document;
|
|
2088
|
+
try {
|
|
2089
|
+
document = parseToml(content);
|
|
2090
|
+
}
|
|
2091
|
+
catch {
|
|
2092
|
+
return null;
|
|
2093
|
+
}
|
|
2094
|
+
if (!OPENRIG_ACTIVITY_HOOK_EVENTS.some((event) => openRigInlineGroupIndex(document, event) >= 0))
|
|
2095
|
+
return null;
|
|
2096
|
+
const lines = content.split("\n");
|
|
2097
|
+
const topLevel = lineStartsAtDocumentLevel(content);
|
|
2098
|
+
for (const { header, end, path, openRig } of tomlSections(content, current)) {
|
|
2099
|
+
if (!openRig || path.length !== 3)
|
|
2100
|
+
continue;
|
|
2101
|
+
for (let at = header + 1; at < end; at++)
|
|
2102
|
+
if (topLevel[at] && /^\s*command\s*=/.test(lines[at]))
|
|
2103
|
+
lines[at] = `command = ${command}`;
|
|
2104
|
+
}
|
|
2105
|
+
return lines.join("\n");
|
|
2106
|
+
}
|
|
2107
|
+
/** `text` split at its real table headers, never at text inside a string or an array. Lines before the first header
|
|
2108
|
+
* belong to no section. */
|
|
2109
|
+
function tomlSections(text, current) {
|
|
2110
|
+
const lines = text.split("\n");
|
|
2111
|
+
const topLevel = lineStartsAtDocumentLevel(text);
|
|
2112
|
+
const sections = [];
|
|
2113
|
+
for (const [at, line] of lines.entries()) {
|
|
2114
|
+
if (!topLevel[at] || !line.trim().startsWith("["))
|
|
2115
|
+
continue;
|
|
2116
|
+
const path = tomlArrayTableHeaderPath(line) ?? tomlTableHeaderPath(line);
|
|
2117
|
+
if (!path)
|
|
2118
|
+
continue;
|
|
2119
|
+
let start = at;
|
|
2120
|
+
while (start > 0 && topLevel[start - 1] && /^\s*(?:#.*)?$/.test(lines[start - 1]))
|
|
2121
|
+
start--;
|
|
2122
|
+
const previous = sections.at(-1);
|
|
2123
|
+
if (previous)
|
|
2124
|
+
previous.end = start;
|
|
2125
|
+
sections.push({ start, header: at, end: lines.length, path, openRig: false });
|
|
2126
|
+
}
|
|
2127
|
+
const events = OPENRIG_ACTIVITY_HOOK_EVENTS;
|
|
2128
|
+
const under = (section, event) => section.path[0] === "hooks" && section.path[1] === event;
|
|
2129
|
+
for (let first = 0; first < sections.length; first++) {
|
|
2130
|
+
const { path } = sections[first];
|
|
2131
|
+
const event = path[1];
|
|
2132
|
+
if (path[0] !== "hooks" || !events.includes(event) || path.length > 3 || (path.length === 3 && path[2] !== "hooks"))
|
|
2133
|
+
continue;
|
|
2134
|
+
let last = first;
|
|
2135
|
+
while (path.length === 2 && last + 1 < sections.length && sections[last + 1].path.length > 2 && under(sections[last + 1], event))
|
|
2136
|
+
last++;
|
|
2137
|
+
let group;
|
|
2138
|
+
try {
|
|
2139
|
+
const hooks = parseToml(lines.slice(sections[first].start, sections[last].end).join("\n")).hooks?.[event];
|
|
2140
|
+
// A group's own header gives a list holding it; a handler stanza on its own reads as the group it adds to.
|
|
2141
|
+
group = path.length === 2 ? (Array.isArray(hooks) && hooks.length === 1 ? hooks[0] : null) : hooks;
|
|
2142
|
+
}
|
|
2143
|
+
catch {
|
|
2144
|
+
group = null;
|
|
2145
|
+
}
|
|
2146
|
+
if (runsOnlyOpenRigRelay(group, current))
|
|
2147
|
+
for (let at = first; at <= last; at++)
|
|
2148
|
+
sections[at].openRig = true;
|
|
2149
|
+
first = last;
|
|
2150
|
+
}
|
|
2151
|
+
return sections;
|
|
2152
|
+
}
|
|
2006
2153
|
function canonicalCodexHookSource(path) {
|
|
2007
2154
|
// Codex keys hook trust by the canonical source path; a file not on the real filesystem keeps its plain path.
|
|
2008
2155
|
try {
|
|
@@ -2077,13 +2224,45 @@ function openRigInlineGroupIndex(document, event) {
|
|
|
2077
2224
|
return !!handler && handler.type === "command" && Number(handler.timeout) === 5 && isOpenRigRelayCommand(handler.command);
|
|
2078
2225
|
});
|
|
2079
2226
|
}
|
|
2227
|
+
/** An inline group that runs nothing but OpenRig's relay: every command on it or its handlers is OpenRig's shipped relay,
|
|
2228
|
+
* from any install, or `current`. A person's group with a command of their own is theirs. */
|
|
2229
|
+
function runsOnlyOpenRigRelay(group, current) {
|
|
2230
|
+
if (group === null || typeof group !== "object")
|
|
2231
|
+
return false;
|
|
2232
|
+
const { command, hooks } = group;
|
|
2233
|
+
const commands = [...(command === undefined ? [] : [command]),
|
|
2234
|
+
...(Array.isArray(hooks) ? hooks.map((handler) => handler?.command) : [])];
|
|
2235
|
+
return commands.length > 0 && commands.every((value) => isOpenRigRelayCommand(value) || (current !== undefined && value === current));
|
|
2236
|
+
}
|
|
2237
|
+
/** Whether `next` changes nothing in `content` but OpenRig's inline activity groups and the `[features].hooks` flag
|
|
2238
|
+
* OpenRig sets, and still parses. A config that doesn't parse is left as it is. */
|
|
2239
|
+
function changesOnlyOpenRigActivityHooks(content, next, current) {
|
|
2240
|
+
const rest = (text) => {
|
|
2241
|
+
const { hooks, features, ...other } = parseToml(text);
|
|
2242
|
+
const { hooks: _flag, ...otherFeatures } = features ?? {};
|
|
2243
|
+
const otherHooks = Object.fromEntries(Object.entries(hooks ?? {}).flatMap(([event, value]) => {
|
|
2244
|
+
const groups = OPENRIG_ACTIVITY_HOOK_EVENTS.includes(event) && Array.isArray(value)
|
|
2245
|
+
? value.filter((group) => !runsOnlyOpenRigRelay(group, current)) : value;
|
|
2246
|
+
return Array.isArray(groups) && groups.length === 0 ? [] : [[event, groups]];
|
|
2247
|
+
}));
|
|
2248
|
+
return { ...other, ...(Object.keys(otherFeatures).length > 0 ? { features: otherFeatures } : {}),
|
|
2249
|
+
...(Object.keys(otherHooks).length > 0 ? { hooks: otherHooks } : {}) };
|
|
2250
|
+
};
|
|
2251
|
+
try {
|
|
2252
|
+
return isDeepStrictEqual(rest(content), rest(next));
|
|
2253
|
+
}
|
|
2254
|
+
catch {
|
|
2255
|
+
return false;
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2080
2258
|
/** Write `enabled = false` into one `[hooks.state."<key>"]` table (the trust write creates it first). */
|
|
2081
2259
|
function upsertCodexHookDisabled(content, key) {
|
|
2260
|
+
const path = ["hooks", "state", key];
|
|
2082
2261
|
const header = `[hooks.state.${JSON.stringify(key)}]`;
|
|
2083
2262
|
const lines = content.split("\n");
|
|
2084
|
-
const at = lines
|
|
2263
|
+
const at = findTomlTable(lines, path);
|
|
2085
2264
|
if (at < 0)
|
|
2086
|
-
return `${content.replace(/\n*$/, "")}\n\n${header}\nenabled = false\n`;
|
|
2265
|
+
return tomlDefines(content, path) ? content : `${content.replace(/\n*$/, "")}\n\n${header}\nenabled = false\n`;
|
|
2087
2266
|
let end = lines.length;
|
|
2088
2267
|
for (let i = at + 1; i < lines.length; i++)
|
|
2089
2268
|
if (lines[i].trim().startsWith("[")) {
|
|
@@ -2112,23 +2291,19 @@ function rekeyCodexHookState(state, prefix, newIndexOf) {
|
|
|
2112
2291
|
}
|
|
2113
2292
|
return next;
|
|
2114
2293
|
}
|
|
2115
|
-
/** The same move on config.toml's text: rename each moved group's `[hooks.state
|
|
2116
|
-
* group's table.
|
|
2294
|
+
/** The same move on config.toml's text: rename each moved group's `[hooks.state.<key>]` header (any key spelling), and
|
|
2295
|
+
* drop a removed group's table. An inline or dotted entry isn't touched; the caller compares the parsed result before writing. */
|
|
2117
2296
|
function rekeyCodexHookStateText(content, prefix, newIndexOf) {
|
|
2118
2297
|
const out = [];
|
|
2119
2298
|
let dropping = false;
|
|
2120
|
-
|
|
2299
|
+
const lines = content.split("\n");
|
|
2300
|
+
const root = parseTomlRoot(lines);
|
|
2301
|
+
for (const [at, line] of lines.entries()) {
|
|
2121
2302
|
const trimmed = line.trim();
|
|
2122
2303
|
if (trimmed.startsWith("[")) {
|
|
2123
2304
|
dropping = false;
|
|
2124
|
-
const
|
|
2125
|
-
|
|
2126
|
-
try {
|
|
2127
|
-
key = quoted ? JSON.parse(quoted) : undefined;
|
|
2128
|
-
}
|
|
2129
|
-
catch {
|
|
2130
|
-
key = undefined;
|
|
2131
|
-
}
|
|
2305
|
+
const path = tomlTableHeaderPath(trimmed);
|
|
2306
|
+
const key = path?.length === 3 && path[0] === "hooks" && path[1] === "state" && opensTomlTable(lines, at, root) ? path[2] : undefined;
|
|
2132
2307
|
const tail = key?.startsWith(prefix) ? /^(\d+):(\d+)$/.exec(key.slice(prefix.length)) : null;
|
|
2133
2308
|
if (tail) {
|
|
2134
2309
|
const index = newIndexOf(Number(tail[1]));
|
|
@@ -2151,11 +2326,15 @@ function rekeyCodexHookStateText(content, prefix, newIndexOf) {
|
|
|
2151
2326
|
* leaves all other content — user-owned hooks, [features], project trust — untouched. Returns the
|
|
2152
2327
|
* input unchanged when the block is absent.
|
|
2153
2328
|
*/
|
|
2154
|
-
function stripCodexActivityHooks(content) {
|
|
2155
|
-
const pattern = new RegExp(`\\n*${escapeRegExp(OPENRIG_ACTIVITY_HOOKS_BEGIN)}[\\s\\S]
|
|
2329
|
+
function stripCodexActivityHooks(content, current) {
|
|
2330
|
+
const pattern = new RegExp(`\\n*${escapeRegExp(OPENRIG_ACTIVITY_HOOKS_BEGIN)}([\\s\\S]*?)${escapeRegExp(OPENRIG_ACTIVITY_HOOKS_END)}[ \\t]*\\n?`, "m");
|
|
2156
2331
|
if (!pattern.test(content))
|
|
2157
2332
|
return content;
|
|
2158
|
-
|
|
2333
|
+
// Tables Codex printed inside the block (its rewritten `[hooks.state]`) aren't ours to remove.
|
|
2334
|
+
return content.replace(pattern, (_span, inner) => {
|
|
2335
|
+
const kept = keptInActivityBlock(inner, current);
|
|
2336
|
+
return kept ? `\n\n${kept}\n` : "\n";
|
|
2337
|
+
});
|
|
2159
2338
|
}
|
|
2160
2339
|
/** Ensure `[features].hooks = true` (canonical key; not the deprecated codex_hooks alias). */
|
|
2161
2340
|
function upsertCodexFeaturesHooksEnabled(content) {
|
|
@@ -2399,23 +2578,169 @@ function dropCollidingFragmentTables(fragment, userOwned) {
|
|
|
2399
2578
|
dropped,
|
|
2400
2579
|
};
|
|
2401
2580
|
}
|
|
2402
|
-
|
|
2581
|
+
/** `content`'s lines and this fragment's marker pair: the first document-level BEGIN and the first END after it. */
|
|
2582
|
+
function fragmentMarkerPair(content, id) {
|
|
2403
2583
|
const start = `# BEGIN OPENRIG MANAGED CODEX CONFIG FRAGMENT: ${id}`;
|
|
2404
2584
|
const end = `# END OPENRIG MANAGED CODEX CONFIG FRAGMENT: ${id}`;
|
|
2405
|
-
const
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2585
|
+
const lines = content.split("\n");
|
|
2586
|
+
const topLevel = lineStartsAtDocumentLevel(content);
|
|
2587
|
+
const isMarker = (at) => topLevel[at] === true && (lines[at].trim() === start || lines[at].trim() === end);
|
|
2588
|
+
const begin = lines.findIndex((line, at) => isMarker(at) && line.trim() === start);
|
|
2589
|
+
const close = begin < 0 ? -1 : lines.findIndex((line, at) => at > begin && isMarker(at) && line.trim() === end);
|
|
2590
|
+
return { start, end, lines, isMarker, begin, close };
|
|
2591
|
+
}
|
|
2592
|
+
function upsertManagedCodexConfigFragment(content, id, fragment) {
|
|
2593
|
+
const { start, end, lines, isMarker, begin, close } = fragmentMarkerPair(content, id);
|
|
2594
|
+
const inBlock = (at) => close >= 0 && at > begin && at < close;
|
|
2595
|
+
// Codex 0.164.0 prints every table it rewrites (all of `[mcp_servers]` on `codex mcp add`) after the others, and the
|
|
2596
|
+
// comment above the first goes with it, so a save can leave our markers apart from our tables. Outside the block, a
|
|
2597
|
+
// fragment table still holding exactly the fragment's values is ours where Codex left it, and our stray markers go.
|
|
2598
|
+
const ours = fragmentTableValues(fragment);
|
|
2599
|
+
const drop = new Set();
|
|
2600
|
+
for (const section of tomlSections(content)) {
|
|
2601
|
+
const value = ours.get(JSON.stringify(section.path));
|
|
2602
|
+
if (inBlock(section.header) || value === undefined)
|
|
2603
|
+
continue;
|
|
2604
|
+
let stop = section.end;
|
|
2605
|
+
while (stop - 1 > section.header && /^\s*(?:#.*)?$/.test(lines[stop - 1]))
|
|
2606
|
+
stop--;
|
|
2607
|
+
if (!isDeepStrictEqual(tomlTableValue(lines.slice(section.header, stop).join("\n"), section.path), value))
|
|
2608
|
+
continue;
|
|
2609
|
+
for (let at = section.start; at < stop; at++)
|
|
2610
|
+
if (at >= section.header || !/\S/.test(lines[at]))
|
|
2611
|
+
drop.add(at);
|
|
2612
|
+
}
|
|
2613
|
+
lines.forEach((_, at) => { if (isMarker(at) && !(close >= 0 && (at === begin || at === close)))
|
|
2614
|
+
drop.add(at); });
|
|
2615
|
+
const outside = (from, to) => lines.slice(from, to).filter((_, offset) => !drop.has(from + offset));
|
|
2616
|
+
if (close >= 0) {
|
|
2617
|
+
// Codex can print a table of its own between our markers (a new `[features]`, say): that's the person's, and it's
|
|
2618
|
+
// kept after the block. Our tables and array-of-tables entries inside are replaced whole.
|
|
2619
|
+
const inner = lines.slice(begin + 1, close);
|
|
2620
|
+
const roots = fragmentArrayRoots(fragment);
|
|
2621
|
+
const theirs = tomlSections(inner.join("\n"))
|
|
2622
|
+
.filter((section) => !ours.has(JSON.stringify(section.path)) && !underTomlRoot(section.path, roots))
|
|
2623
|
+
.map(({ start: from, end: to }) => inner.slice(from, to).join("\n")).join("\n").trim();
|
|
2624
|
+
const before = outside(0, begin);
|
|
2625
|
+
const after = outside(close + 1, lines.length);
|
|
2626
|
+
const { kept } = dropCollidingFragmentTables(fragment, [...before, theirs, ...after].join("\n"));
|
|
2627
|
+
const block = `${start}\n${kept}\n${end}${theirs ? `\n\n${theirs}` : ""}`;
|
|
2628
|
+
return [...before, block, ...(after.length > 0 ? after : [""])].join("\n");
|
|
2629
|
+
}
|
|
2630
|
+
const rest = outside(0, lines.length).join("\n");
|
|
2631
|
+
const { kept } = dropCollidingFragmentTables(fragment, rest);
|
|
2412
2632
|
const block = `${start}\n${kept}\n${end}\n`;
|
|
2413
|
-
|
|
2414
|
-
return content.replace(pattern, () => block); // literal: a string would expand `$` patterns in the fragment
|
|
2415
|
-
}
|
|
2416
|
-
const prefix = content.replace(/\n*$/, "");
|
|
2633
|
+
const prefix = rest.replace(/\n*$/, "");
|
|
2417
2634
|
return prefix.length > 0 ? `${prefix}\n\n${block}` : block;
|
|
2418
2635
|
}
|
|
2636
|
+
/** The fragment's tables by key path (JSON), each with the values it sets. A table under one of its array-of-tables
|
|
2637
|
+
* roots is part of that entry, not a table of its own. */
|
|
2638
|
+
function fragmentTableValues(fragment) {
|
|
2639
|
+
const roots = fragmentArrayRoots(fragment);
|
|
2640
|
+
const values = new Map();
|
|
2641
|
+
for (const block of splitAtTableHeaders(fragment)) {
|
|
2642
|
+
const path = block.header === null ? null : tomlTableHeaderPath(block.header);
|
|
2643
|
+
if (path && !underTomlRoot(path, roots))
|
|
2644
|
+
values.set(JSON.stringify(path), tomlTableValue(block.text, path));
|
|
2645
|
+
}
|
|
2646
|
+
return values;
|
|
2647
|
+
}
|
|
2648
|
+
/** The fragment's array-of-tables roots: each `[[path]]` that isn't under another (`[[hooks.Stop]]`, whose
|
|
2649
|
+
* `[[hooks.Stop.hooks]]` belong to its entry). An entry has no single path, so it's only ever recognized between our
|
|
2650
|
+
* markers. */
|
|
2651
|
+
function fragmentArrayRoots(fragment) {
|
|
2652
|
+
const roots = [];
|
|
2653
|
+
for (const { header } of splitAtTableHeaders(fragment)) {
|
|
2654
|
+
const path = header === null ? null : tomlArrayTableHeaderPath(header);
|
|
2655
|
+
if (path && !underTomlRoot(path, roots))
|
|
2656
|
+
roots.push(path);
|
|
2657
|
+
}
|
|
2658
|
+
return roots;
|
|
2659
|
+
}
|
|
2660
|
+
function underTomlRoot(path, roots) {
|
|
2661
|
+
return roots.some((root) => root.length <= path.length && root.every((key, at) => path[at] === key));
|
|
2662
|
+
}
|
|
2663
|
+
/** The array-of-tables entries between this fragment's markers in `content`, by root (JSON): OpenRig's, whatever they
|
|
2664
|
+
* now hold. */
|
|
2665
|
+
function blockArrayEntries(content, id, roots) {
|
|
2666
|
+
const entries = new Map();
|
|
2667
|
+
const { lines, begin, close } = fragmentMarkerPair(content, id);
|
|
2668
|
+
if (close < 0 || roots.length === 0)
|
|
2669
|
+
return entries;
|
|
2670
|
+
const inner = lines.slice(begin + 1, close);
|
|
2671
|
+
const text = tomlSections(inner.join("\n")).filter((section) => underTomlRoot(section.path, roots))
|
|
2672
|
+
.map(({ start: from, end: to }) => inner.slice(from, to).join("\n")).join("\n");
|
|
2673
|
+
for (const root of roots) {
|
|
2674
|
+
const value = tomlTableValue(text, root);
|
|
2675
|
+
if (Array.isArray(value))
|
|
2676
|
+
entries.set(JSON.stringify(root), value);
|
|
2677
|
+
}
|
|
2678
|
+
return entries;
|
|
2679
|
+
}
|
|
2680
|
+
/** The value one table's text sets at `path`, or undefined when it doesn't parse. */
|
|
2681
|
+
function tomlTableValue(text, path) {
|
|
2682
|
+
let node;
|
|
2683
|
+
try {
|
|
2684
|
+
node = parseToml(text);
|
|
2685
|
+
}
|
|
2686
|
+
catch {
|
|
2687
|
+
return undefined;
|
|
2688
|
+
}
|
|
2689
|
+
for (const key of path)
|
|
2690
|
+
node = node !== null && typeof node === "object" ? node[key] : undefined;
|
|
2691
|
+
return node;
|
|
2692
|
+
}
|
|
2693
|
+
/** Whether `next` changes nothing in `content` but the fragment's own tables and the array-of-tables entries between
|
|
2694
|
+
* its markers: the person's settings, and every table and entry Codex wrote, read the same. Both must parse. */
|
|
2695
|
+
function changesOnlyFragmentTables(content, next, id, fragment) {
|
|
2696
|
+
const paths = [...fragmentTableValues(fragment).keys()].map((key) => JSON.parse(key));
|
|
2697
|
+
const roots = fragmentArrayRoots(fragment);
|
|
2698
|
+
const rest = (text) => {
|
|
2699
|
+
const root = parseToml(text);
|
|
2700
|
+
for (const path of paths)
|
|
2701
|
+
withoutTomlPath(root, path);
|
|
2702
|
+
for (const [key, entries] of blockArrayEntries(text, id, roots))
|
|
2703
|
+
withoutTomlPath(root, JSON.parse(key), entries);
|
|
2704
|
+
return root;
|
|
2705
|
+
};
|
|
2706
|
+
try {
|
|
2707
|
+
return isDeepStrictEqual(rest(content), rest(next));
|
|
2708
|
+
}
|
|
2709
|
+
catch {
|
|
2710
|
+
return false;
|
|
2711
|
+
}
|
|
2712
|
+
}
|
|
2713
|
+
/** Delete `path` from a parsed document in place, or with `entries`, one equal entry for each from the array there; and
|
|
2714
|
+
* any table that leaves empty. */
|
|
2715
|
+
function withoutTomlPath(node, path, entries) {
|
|
2716
|
+
const [key, ...more] = path;
|
|
2717
|
+
if (key === undefined || !Object.hasOwn(node, key))
|
|
2718
|
+
return;
|
|
2719
|
+
const child = node[key];
|
|
2720
|
+
if (more.length === 0) {
|
|
2721
|
+
if (entries === undefined) {
|
|
2722
|
+
delete node[key];
|
|
2723
|
+
return;
|
|
2724
|
+
}
|
|
2725
|
+
if (!Array.isArray(child))
|
|
2726
|
+
return;
|
|
2727
|
+
for (const entry of entries) {
|
|
2728
|
+
for (let at = child.length - 1; at >= 0; at--)
|
|
2729
|
+
if (isDeepStrictEqual(child[at], entry)) {
|
|
2730
|
+
child.splice(at, 1);
|
|
2731
|
+
break;
|
|
2732
|
+
}
|
|
2733
|
+
}
|
|
2734
|
+
if (child.length === 0)
|
|
2735
|
+
delete node[key];
|
|
2736
|
+
return;
|
|
2737
|
+
}
|
|
2738
|
+
if (child === null || typeof child !== "object" || Array.isArray(child))
|
|
2739
|
+
return;
|
|
2740
|
+
withoutTomlPath(child, more, entries);
|
|
2741
|
+
if (Object.keys(child).length === 0)
|
|
2742
|
+
delete node[key];
|
|
2743
|
+
}
|
|
2419
2744
|
/**
|
|
2420
2745
|
* Refuse to hand Codex a config it cannot load. Throwing here (rather than
|
|
2421
2746
|
* writing and hoping) is what keeps a malformed render off disk entirely:
|