sneakoscope 8.0.2 → 8.0.4
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 +150 -37
- package/config/skills-hash-ledger.v1.json +1 -1
- package/crates/sks-core/Cargo.lock +1 -1
- package/crates/sks-core/Cargo.toml +1 -1
- package/dist/bin/fast-inline.js +55 -27
- package/dist/bin/install.js +6 -32
- package/dist/bin/sks-dispatch.js +1 -1
- package/dist/cli/args.js +0 -2
- package/dist/cli/cli-theme.js +18 -9
- package/dist/cli/command-manifest-lite.js +6 -6
- package/dist/cli/command-registry.js +6 -6
- package/dist/cli/feature-commands.js +9 -7
- package/dist/cli/install-helpers-codex-lb-chain.js +198 -7
- package/dist/cli/install-helpers-codex-lb-config.js +78 -10
- package/dist/cli/install-helpers-install-support.js +9 -6
- package/dist/cli/install-helpers.js +101 -49
- package/dist/cli/install-tool-helpers.js +2 -82
- package/dist/cli/output.js +6 -1
- package/dist/cli/router.js +101 -2
- package/dist/commands/codex-lb.js +119 -19
- package/dist/commands/doctor-profile.js +1 -1
- package/dist/commands/doctor.js +727 -144
- package/dist/commands/mad-sks.js +1 -5
- package/dist/config/skills-manifest.json +4 -2
- package/dist/core/agents/agent-codex-cockpit.js +0 -3
- package/dist/core/agents/agent-effort-policy.js +5 -5
- package/dist/core/agents/agent-janitor.js +0 -20
- package/dist/core/agents/agent-orchestrator.js +9 -56
- package/dist/core/agents/agent-output-validator.js +2 -3
- package/dist/core/agents/agent-patch-schema.js +2 -2
- package/dist/core/agents/agent-proof-evidence.js +0 -65
- package/dist/core/agents/agent-recursion-guard.js +1 -1
- package/dist/core/agents/agent-runner-codex-exec.js +5 -3
- package/dist/core/agents/agent-scheduler.js +327 -85
- package/dist/core/agents/agent-schema.js +1 -1
- package/dist/core/agents/agent-trust-report.js +0 -36
- package/dist/core/agents/agent-worker-pipeline.js +0 -1
- package/dist/core/agents/fast-mode-policy.js +1 -3
- package/dist/core/agents/native-cli-worker-runtime-proof.js +1 -1
- package/dist/core/agents/native-cli-worker-runtime.js +69 -647
- package/dist/core/agents/native-cli-worker.js +6 -7
- package/dist/core/agents/native-worker-backend-router.js +2 -32
- package/dist/core/agents/no-subagent-scaling-policy.js +1 -1
- package/dist/core/agents/parallel-runtime-proof.js +1 -6
- package/dist/core/agents/runtime-proof-summary.js +1 -35
- package/dist/core/architecture-hardening/contracts/contracts.js +193 -0
- package/dist/core/architecture-hardening/migration/migration.js +111 -0
- package/dist/core/architecture-hardening/state/state-service.js +155 -0
- package/dist/core/artifact-schemas.js +0 -3
- package/dist/core/codex/codex-config-guard.js +238 -52
- package/dist/core/codex-adapter.js +5 -3
- package/dist/core/codex-app/auxiliary-oauth-policy.js +36 -0
- package/dist/core/codex-app/catalog-compat/catalog-service.js +104 -0
- package/dist/core/codex-app/child-policy/child-policy.js +35 -0
- package/dist/core/codex-app/codex-app-handoff.js +0 -1
- package/dist/core/codex-app/codex-hook-lifecycle.js +1 -1
- package/dist/core/codex-app/codex-init-deep.js +1 -1
- package/dist/core/codex-app/menubar/app-bundle.js +2 -0
- package/dist/core/codex-app/menubar/constants.js +14 -1
- package/dist/core/codex-app/menubar/global-install.js +288 -0
- package/dist/core/codex-app/menubar/installer.js +79 -14
- package/dist/core/codex-app/menubar/launch-agent.js +267 -45
- package/dist/core/codex-app/menubar/paths.js +3 -0
- package/dist/core/codex-app/menubar/rollback.js +55 -7
- package/dist/core/codex-app/menubar/status.js +75 -4
- package/dist/core/codex-app/provider-child-policy.js +64 -0
- package/dist/core/codex-app/provider-mode.js +91 -0
- package/dist/core/codex-app/provider-operation-stages.js +20 -0
- package/dist/core/codex-app/provider-session-policy.js +85 -0
- package/dist/core/codex-app/session-policy/session-pinning.js +68 -0
- package/dist/core/codex-app.js +3 -2
- package/dist/core/codex-control/codex-0139-image-path-real-probe.js +3 -1
- package/dist/core/codex-control/codex-0139-web-search-probe.js +3 -1
- package/dist/core/codex-control/codex-app-server-runtime-env.js +13 -4
- package/dist/core/codex-control/codex-app-server-v2-client.js +3 -3
- package/dist/core/codex-control/codex-control-proof.js +0 -1
- package/dist/core/codex-control/codex-task-runner.js +1 -4
- package/dist/core/codex-exec-output-schema.js +4 -1
- package/dist/core/codex-lb/codex-lb-env.js +63 -72
- package/dist/core/codex-lb/codex-lb-setup.js +15 -2
- package/dist/core/codex-lb/desktop-bridge/header-policy.js +6 -0
- package/dist/core/codex-lb/desktop-bridge/http-forward.js +48 -6
- package/dist/core/codex-lb/desktop-bridge/security.js +134 -0
- package/dist/core/codex-lb/desktop-bridge/server.js +9 -3
- package/dist/core/codex-lb/desktop-bridge/state.js +26 -6
- package/dist/core/codex-lb/desktop-bridge/types.js +1 -0
- package/dist/core/codex-lb/desktop-center-credentials.js +517 -58
- package/dist/core/codex-lb/desktop-controller.js +177 -56
- package/dist/core/codex-lb/desktop-service.js +179 -40
- package/dist/core/codex-lb/legacy-migration.js +1 -3
- package/dist/core/codex-lb/native-openai-transport/transport.js +68 -0
- package/dist/core/codex-lb/probes/cli-image-tool-probe.js +1 -1
- package/dist/core/codex-lb/provider-routing/provider-router.js +58 -0
- package/dist/core/codex-lb/routing-truth.js +327 -0
- package/dist/core/codex-native/codex-native-feature-broker.js +4 -0
- package/dist/core/codex-native/codex-native-pattern-analysis.js +1 -2
- package/dist/core/codex-native/core-skill-manifest.js +1 -1
- package/dist/core/codex-plugins/codex-plugin-json.js +26 -6
- package/dist/core/codex-plugins/codex-plugin-repair.js +32 -6
- package/dist/core/commands/basic-cli.js +9 -7
- package/dist/core/commands/computer-use-command.js +1 -1
- package/dist/core/commands/image-ux-review-command.js +16 -9
- package/dist/core/commands/install-package-command.js +105 -0
- package/dist/core/commands/intent-normalization/normalizer.js +96 -0
- package/dist/core/commands/mad-sks-command.js +23 -274
- package/dist/core/commands/mad-sks-headless.js +11 -30
- package/dist/core/commands/naruto-command.js +0 -25
- package/dist/core/commands/qa-loop-command.js +104 -22
- package/dist/core/commands/remote-command.js +2 -2
- package/dist/core/commands/research-command.js +10 -5
- package/dist/core/commands/telegram-command.js +407 -0
- package/dist/core/config-adopt/config-adopt-command.js +35 -0
- package/dist/core/config-adopt/config-adopt.js +346 -0
- package/dist/core/config-adopt/index.js +3 -0
- package/dist/core/doctor/command-alias-cleanup.js +4 -1
- package/dist/core/doctor/current-project-guidance-nested.js +37 -6
- package/dist/core/doctor/current-project-guidance.js +15 -9
- package/dist/core/doctor/doctor-dirty-planner.js +1 -4
- package/dist/core/doctor/doctor-readiness-matrix.js +15 -18
- package/dist/core/doctor/retired-managed-residue-private.js +4 -3
- package/dist/core/doctor/retired-managed-residue-runtime.js +2 -2
- package/dist/core/doctor/skill-legacy-surface.js +11 -10
- package/dist/core/doctor/sks-menubar-doctor.js +4 -0
- package/dist/core/evaluation.js +0 -19
- package/dist/core/evidence/v2/evidence-key.js +105 -0
- package/dist/core/feature-fixtures.js +12 -7
- package/dist/core/feature-registry.js +52 -21
- package/dist/core/hooks-runtime/hook-context.js +9 -0
- package/dist/core/hooks-runtime/managed-skill-admission.js +54 -4
- package/dist/core/hooks-runtime/official-subagent-lifecycle.js +69 -52
- package/dist/core/hooks-runtime/stop-finalization.js +226 -0
- package/dist/core/hooks-runtime/stop-repeat-guard.js +21 -2
- package/dist/core/hooks-runtime/subagent-skill-availability-contract.js +2 -2
- package/dist/core/hooks-runtime/subagent-skill-availability-evidence.js +3 -3
- package/dist/core/hooks-runtime/subagent-skill-availability-guards.js +43 -5
- package/dist/core/hooks-runtime/subagent-skill-availability.js +64 -30
- package/dist/core/hooks-runtime/subagent-stop-hook.js +15 -2
- package/dist/core/hooks-runtime.js +179 -212
- package/dist/core/image/reference-evidence/reference-registry.js +145 -0
- package/dist/core/image-ux-review/imagegen-adapter.js +21 -9
- package/dist/core/image-ux-review/reference-policy/reference-policy.js +9 -0
- package/dist/core/imagegen/codex-lb-imagegen-target.js +8 -0
- package/dist/core/imagegen/imagegen-capability.js +59 -2
- package/dist/core/imagegen/require-imagegen.js +2 -2
- package/dist/core/init/skills.js +17 -3
- package/dist/core/init.js +3 -3
- package/dist/core/install/installed-package-smoke.js +23 -5
- package/dist/core/json/canonical.js +9 -0
- package/dist/core/locks/file-lock.js +0 -1
- package/dist/core/loops/loop-continuation-enforcer.js +65 -7
- package/dist/core/loops/loop-decomposer.js +0 -1
- package/dist/core/loops/loop-gate-runner.js +65 -4
- package/dist/core/loops/loop-gate-selector.js +0 -2
- package/dist/core/loops/loop-proof-validation.js +38 -0
- package/dist/core/loops/loop-risk-classifier.js +1 -1
- package/dist/core/loops/loop-runtime.js +14 -2
- package/dist/core/loops/loop-scheduler.js +7 -2
- package/dist/core/loops/loop-worker-runtime.js +0 -15
- package/dist/core/loops/loop-worktree-runtime.js +52 -4
- package/dist/core/managed-assets/managed-assets-manifest.js +14 -14
- package/dist/core/naruto/hardware-capacity-probe.js +9 -6
- package/dist/core/naruto/naruto-active-pool.js +2 -14
- package/dist/core/naruto/naruto-concurrency-governor.js +71 -31
- package/dist/core/naruto/naruto-loop-worker-router.js +0 -2
- package/dist/core/naruto/naruto-verification-dag.js +0 -1
- package/dist/core/naruto/naruto-write-e2e.js +1 -2
- package/dist/core/naruto/resource-pressure-monitor.js +0 -4
- package/dist/core/observability/architecture-hardening/safe-projection.js +65 -0
- package/dist/core/perf/import-graph-budget.js +0 -1
- package/dist/core/perf/release-latency-slo.js +3 -2
- package/dist/core/preflight/parallel-preflight-engine.js +2 -15
- package/dist/core/product-design-app-server.js +13 -1
- package/dist/core/proof/fake-real-proof-policy.js +2 -17
- package/dist/core/proof/route-proof-gate.js +2 -10
- package/dist/core/proof/route-proof-policy.js +1 -1
- package/dist/core/proof/runtime-evidence-policy.js +185 -0
- package/dist/core/proof/runtime-truth-matrix.js +64 -39
- package/dist/core/proof/validation.js +27 -11
- package/dist/core/provider/provider-context.js +18 -2
- package/dist/core/providers/openrouter/openrouter-account.js +3 -2
- package/dist/core/python-tools/python-tool-runner.js +1 -1
- package/dist/core/qa-loop/qa-execution-control.js +57 -0
- package/dist/core/questions.js +1 -1
- package/dist/core/release/extreme-parallel-scheduler.js +0 -3
- package/dist/core/release/gate-manifest.js +3 -7
- package/dist/core/release/gate-pack-manifest.js +3 -7
- package/dist/core/release/package-size-budget.js +2 -2
- package/dist/core/release/physical-release-gates.js +189 -0
- package/dist/core/release/publish-preflight.js +113 -0
- package/dist/core/release/release-gate-affected-selector.js +0 -2
- package/dist/core/release/release-gate-batch-runner.js +1 -1
- package/dist/core/release/release-gate-node.js +0 -1
- package/dist/core/release/release-gate-resource-governor.js +0 -1
- package/dist/core/release/release-pack-receipt.js +5 -8
- package/dist/core/release/release-real-contract.js +0 -6
- package/dist/core/release/resource-class-budget.js +0 -1
- package/dist/core/release/stage-publish.js +178 -36
- package/dist/core/research/research-adversarial-review.js +103 -9
- package/dist/core/research.js +1 -1
- package/dist/core/retention.js +0 -1
- package/dist/core/routes/constants.js +1 -1
- package/dist/core/routes/diagnostic-allowlist.js +0 -1
- package/dist/core/routes/dollar-manifest-lite.js +1 -1
- package/dist/core/routes.js +46 -15
- package/dist/core/runtime/execution-control.js +226 -0
- package/dist/core/runtime/progress-recovery/progress-recovery.js +89 -0
- package/dist/core/runtime/task-profile.js +10 -4
- package/dist/core/runtime/verification-budget.js +10 -1
- package/dist/core/safety/intent-contract/intent-contract.js +94 -0
- package/dist/core/safety/mutation-guard.js +0 -2
- package/dist/core/safety/mutation-ledger.js +0 -2
- package/dist/core/safety/requested-scope-contract.js +0 -0
- package/dist/core/search-visibility/discovery.js +1 -1
- package/dist/core/search-visibility/index.js +12 -0
- package/dist/core/search-visibility/verifier.js +112 -3
- package/dist/core/security/private-credential-file.js +209 -0
- package/dist/core/session/project-namespace.js +0 -5
- package/dist/core/skills/skill-agent-metadata.js +1 -3
- package/dist/core/strategy/adhd-orchestrating-gate.js +0 -1
- package/dist/core/subagents/agent-catalog.js +19 -34
- package/dist/core/subagents/model-policy.js +65 -24
- package/dist/core/subagents/naruto-help-contract.js +8 -8
- package/dist/core/subagents/naruto-host-credentials.js +13 -0
- package/dist/core/subagents/official-subagent-config.js +16 -6
- package/dist/core/subagents/official-subagent-preparation.js +35 -16
- package/dist/core/subagents/official-subagent-prompt.js +7 -7
- package/dist/core/subagents/official-subagent-runner.js +27 -4
- package/dist/core/subagents/role-model-preferences.js +1 -1
- package/dist/core/subagents/thread-budget.js +19 -12
- package/dist/core/subagents/wave-lifecycle.js +18 -6
- package/dist/core/telegram/access.js +58 -0
- package/dist/core/telegram/client.js +157 -0
- package/dist/core/telegram/confirmation.js +37 -0
- package/dist/core/telegram/doctor.js +154 -0
- package/dist/core/telegram/index.js +9 -0
- package/dist/core/telegram/keychain.js +317 -0
- package/dist/core/telegram/liveness.js +118 -0
- package/dist/core/telegram/poller.js +90 -0
- package/dist/core/telegram/redaction.js +15 -0
- package/dist/core/telegram/state-lock.js +416 -0
- package/dist/core/telegram/types.js +1 -0
- package/dist/core/text/strings.js +3 -0
- package/dist/core/triwiki/context-graph/store/evidence-write-lock.js +29 -0
- package/dist/core/triwiki/context-graph/store/fragment-cache.js +24 -0
- package/dist/core/triwiki/context-graph/store/snapshot-store.js +69 -21
- package/dist/core/triwiki/triwiki-gate-impact-map.js +2 -2
- package/dist/core/triwiki/triwiki-module-card.js +1 -2
- package/dist/core/update/installed-cli-resolution.js +170 -0
- package/dist/core/update/update-diagnostics.js +52 -0
- package/dist/core/update/update-migration-state.js +30 -12
- package/dist/core/update/update-operation.js +2 -1
- package/dist/core/update/update-stage-diagnostics.js +38 -0
- package/dist/core/update/update-status.js +2 -9
- package/dist/core/update-check.js +279 -91
- package/dist/core/version.js +1 -1
- package/dist/native/sks-menubar/Sources/AppDelegate.swift +19 -1
- package/dist/native/sks-menubar/Sources/AppIdentity.swift +7 -0
- package/dist/native/sks-menubar/Sources/ControlCenterWindowController.swift +6 -2
- package/dist/native/sks-menubar/Sources/OperationCoordinator.swift +159 -92
- package/dist/native/sks-menubar/Sources/OperationModels.swift +389 -0
- package/dist/native/sks-menubar/Sources/OverviewViewController.swift +57 -0
- package/dist/native/sks-menubar/Sources/ProcessClient.swift +3 -1
- package/dist/native/sks-menubar/Sources/ProvidersConnectTest.swift +115 -0
- package/dist/native/sks-menubar/Sources/ProvidersFastMode.swift +17 -0
- package/dist/native/sks-menubar/Sources/ProvidersMultiProvider.swift +3 -0
- package/dist/native/sks-menubar/Sources/ProvidersOpenRouter.swift +58 -17
- package/dist/native/sks-menubar/Sources/ProvidersReliability.swift +302 -0
- package/dist/native/sks-menubar/Sources/ProvidersRoleModels.swift +5 -0
- package/dist/native/sks-menubar/Sources/ProvidersRoutingTruth.swift +190 -0
- package/dist/native/sks-menubar/Sources/ProvidersViewController.swift +158 -126
- package/dist/native/sks-menubar/Sources/RemoteCodingViewController.swift +462 -26
- package/dist/native/sks-menubar/Sources/SKSKeychainStore.swift +344 -0
- package/dist/native/sks-menubar/Sources/SecureProcessEnvelope.swift +27 -0
- package/dist/native/sks-menubar/Sources/SingletonInstanceGuard.swift +328 -0
- package/dist/native/sks-menubar/Sources/StatusItemController.swift +10 -2
- package/dist/native/sks-menubar/Sources/TelegramPrivateFileStore.swift +498 -0
- package/dist/native/sks-menubar/Sources/TelegramPrivateFileSupport.swift +236 -0
- package/dist/native/sks-menubar/Sources/TelegramProcessGateway.swift +454 -0
- package/dist/native/sks-menubar/Sources/TelegramRuntimeSupport.swift +56 -0
- package/dist/native/sks-menubar/Sources/TelegramStateLock.swift +448 -0
- package/dist/native/sks-menubar/Sources/TelegramSupport.swift +187 -0
- package/dist/native/sks-menubar/Sources/TelegramTransport.swift +499 -0
- package/dist/native/sks-menubar/Sources/main.swift +15 -1
- package/dist/scripts/all-feature-deep-completion-check.js +5 -1
- package/dist/scripts/check-publish-tag.js +56 -0
- package/dist/scripts/codex-lb-fast-mode-truth-check.js +10 -3
- package/dist/scripts/codex-lb-fast-ui-preservation-check.js +12 -3
- package/dist/scripts/codex-lb-gpt56-fast-profile-check.js +4 -2
- package/dist/scripts/codex-native-agent-role-content-check.js +3 -3
- package/dist/scripts/codex-native-gate-lib.js +14 -7
- package/dist/scripts/current-command-surface-check.js +7 -7
- package/dist/scripts/current-surface-update-e2e-check.js +4 -3
- package/dist/scripts/current-upgrade-matrix-check.js +5 -24
- package/dist/scripts/docs-truthfulness-check.js +17 -13
- package/dist/scripts/gate-lib.js +0 -2
- package/dist/scripts/gate-policy-audit-check.js +3 -2
- package/dist/scripts/harness-benchmark-check.js +1 -1
- package/dist/scripts/init-deep-backup-retention-check.js +1 -1
- package/dist/scripts/lib/codex-sdk-gate-lib.js +1 -2
- package/dist/scripts/loop-directive-check-lib.js +28 -38
- package/dist/scripts/mad-sks-app-ui-no-mutation-check.js +14 -180
- package/dist/scripts/mad-sks-launch-sql-plane-boundary-check.js +2 -11
- package/dist/scripts/official-subagent-workflow-check.js +1 -1
- package/dist/scripts/packlist-performance-check.js +1 -2
- package/dist/scripts/prepublish-release-check-or-fast.js +32 -0
- package/dist/scripts/publish-preflight.js +12 -0
- package/dist/scripts/release-affected-selector-check.js +2 -2
- package/dist/scripts/release-gate-batch-runner-check.js +2 -2
- package/dist/scripts/release-metadata-check.js +8 -12
- package/dist/scripts/release-real-check.js +2 -54
- package/dist/scripts/runtime-domain-gate-lib.js +2 -96
- package/dist/scripts/runtime-proof-summary-check.js +2 -6
- package/dist/scripts/search-visibility-gate-lib.js +0 -1
- package/dist/scripts/sks-cli-gate-lib.js +1 -1
- package/dist/scripts/typed-routing-gate-lib.js +7 -59
- package/docs/demo.tape +1 -1
- package/infra-harness-gates.json +1 -1456
- package/package.json +10 -7
- package/release-gates.v2.json +0 -1
- package/schemas/agents/parallel-runtime-proof.schema.json +0 -2
- package/schemas/codex/agent-result.schema.json +0 -6
- package/schemas/naruto/naruto-concurrency-governor.schema.json +1 -3
- package/schemas/release/release-gate-node.schema.json +1 -1
- package/dist/commands/zellij-lane.js +0 -22
- package/dist/commands/zellij-monitor-pane.js +0 -26
- package/dist/commands/zellij-slot-column-anchor.js +0 -22
- package/dist/commands/zellij-slot-pane.js +0 -80
- package/dist/commands/zellij-viewport-pane.js +0 -57
- package/dist/commands/zellij.js +0 -422
- package/dist/core/agents/agent-runner-zellij.js +0 -164
- package/dist/core/agents/agent-slot-pane-binding-proof.js +0 -96
- package/dist/core/agents/parallel-write-fixture.js +0 -305
- package/dist/core/agents/worker-pane-communication-contract.js +0 -100
- package/dist/core/agents/zellij-lane-supervisor.js +0 -428
- package/dist/core/agents/zellij-right-lane-cockpit.js +0 -66
- package/dist/core/doctor/doctor-zellij-repair.js +0 -40
- package/dist/core/ops/upgrade-migration-fixtures.js +0 -119
- package/dist/core/proof/route-finalizer-fixtures.js +0 -21
- package/dist/core/zellij/homebrew-policy.js +0 -43
- package/dist/core/zellij/zellij-capability.js +0 -126
- package/dist/core/zellij/zellij-clipboard-config.js +0 -52
- package/dist/core/zellij/zellij-command.js +0 -149
- package/dist/core/zellij/zellij-fake-adapter.js +0 -186
- package/dist/core/zellij/zellij-lane-renderer.js +0 -706
- package/dist/core/zellij/zellij-lane-runtime.js +0 -189
- package/dist/core/zellij/zellij-launcher.js +0 -268
- package/dist/core/zellij/zellij-layout-builder.js +0 -191
- package/dist/core/zellij/zellij-monitor-renderer.js +0 -52
- package/dist/core/zellij/zellij-official-subagent-activity.js +0 -526
- package/dist/core/zellij/zellij-official-subagent-telemetry.js +0 -258
- package/dist/core/zellij/zellij-pane-proof.js +0 -226
- package/dist/core/zellij/zellij-right-column-manager.js +0 -308
- package/dist/core/zellij/zellij-screen-proof.js +0 -120
- package/dist/core/zellij/zellij-self-heal-types.js +0 -44
- package/dist/core/zellij/zellij-self-heal.js +0 -408
- package/dist/core/zellij/zellij-slot-column-anchor.js +0 -304
- package/dist/core/zellij/zellij-slot-pane-renderer.js +0 -521
- package/dist/core/zellij/zellij-slot-telemetry.js +0 -384
- package/dist/core/zellij/zellij-theme.js +0 -66
- package/dist/core/zellij/zellij-ui-mode.js +0 -34
- package/dist/core/zellij/zellij-update.js +0 -348
- package/dist/core/zellij/zellij-viewport-binder.js +0 -61
- package/dist/core/zellij/zellij-worker-pane-manager.js +0 -881
- package/dist/core/zellij/zellij-worker-pane-summary.js +0 -64
- package/dist/native/sks-menubar/Tests/AppRuntimeTestSupport.swift +0 -26
- package/dist/native/sks-menubar/Tests/OperationCoordinatorTests.swift +0 -174
- package/dist/native/sks-menubar/Tests/ProcessClientTests.swift +0 -20
- package/dist/native/sks-menubar/Tests/ProvidersViewControllerTests.swift +0 -142
- package/dist/scripts/zellij-pane-proof-check.js +0 -88
- package/dist/scripts/zellij-real-session-cleanup-check.js +0 -139
- package/dist/scripts/zellij-real-session-launch-check.js +0 -126
- package/dist/scripts/zellij-screen-proof-check.js +0 -43
- package/schemas/zellij/zellij-right-column-state.schema.json +0 -40
- package/schemas/zellij/zellij-slot-telemetry.schema.json +0 -89
- package/schemas/zellij/zellij-worker-pane.schema.json +0 -53
- package/scripts/build-clean-atomic.mjs +0 -323
|
@@ -1,881 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { appendJsonl, ensureDir, nowIso, packageRoot, readJson, writeJsonAtomic } from '../fsx.js';
|
|
3
|
-
import { appendParallelRuntimeEvent } from '../agents/parallel-runtime-proof.js';
|
|
4
|
-
import { providerPaneLabel } from '../provider/provider-badge.js';
|
|
5
|
-
import { resolveProviderContext } from '../provider/provider-context.js';
|
|
6
|
-
import { checkZellijStackedPaneCapability } from './zellij-capability.js';
|
|
7
|
-
import { runZellij, zellijCommandStdout } from './zellij-command.js';
|
|
8
|
-
import { extractZellijPaneIdFromOutput } from './zellij-lane-runtime.js';
|
|
9
|
-
import { buildZellijSlotColumnAnchorCommand } from './zellij-slot-column-anchor.js';
|
|
10
|
-
import { closeWorkerInRightColumn, prepareWorkerInRightColumn, readRightColumnState, recordSlotColumnAnchorInRightColumn, recordWorkerPaneInRightColumn } from './zellij-right-column-manager.js';
|
|
11
|
-
export const ZELLIJ_WORKER_PANE_SCHEMA = 'sks.zellij-worker-pane.v1';
|
|
12
|
-
export const ZELLIJ_WORKER_PANE_EVENT_SCHEMA = 'sks.zellij-worker-pane-event.v1';
|
|
13
|
-
export const ZELLIJ_PANE_CREATION_LOCK_METRICS_SCHEMA = 'sks.zellij-pane-creation-lock-metrics.v1';
|
|
14
|
-
export function buildWorkerPaneName(slotId, generationIndex) {
|
|
15
|
-
return `${slotId}/gen-${Math.max(1, Math.floor(Number(generationIndex) || 1))}`;
|
|
16
|
-
}
|
|
17
|
-
export function buildWorkerPaneTitle(slotId, generationIndex, context, serviceTier, backend, status, worktree, taskTitle) {
|
|
18
|
-
const task = shortWorkerTaskLabel(taskTitle);
|
|
19
|
-
if (task)
|
|
20
|
-
return `${task} · ${workerBackendTag(backend, context?.provider)} · ${status || 'launching'}`;
|
|
21
|
-
const base = buildWorkerPaneName(slotId, generationIndex);
|
|
22
|
-
const normalized = normalizePaneProviderContext(context, serviceTier);
|
|
23
|
-
const wt = worktree ? ` · WT:${worktree.id} · branch:${worktree.branch}` : '';
|
|
24
|
-
return `${base}${wt} · ${backend || 'codex-sdk'} · ${providerPaneLabel(normalized)} · ${status || 'launching'}`;
|
|
25
|
-
}
|
|
26
|
-
export function workerBackendTag(backend, provider) {
|
|
27
|
-
const text = `${String(backend || '')} ${String(provider || '')}`.toLowerCase();
|
|
28
|
-
if (/ollama|local/.test(text))
|
|
29
|
-
return 'LOCAL';
|
|
30
|
-
if (/fake|fixture/.test(text))
|
|
31
|
-
return 'fixture';
|
|
32
|
-
return 'GPT';
|
|
33
|
-
}
|
|
34
|
-
export function shortWorkerTaskLabel(value, maxChars = 24) {
|
|
35
|
-
const text = String(value || '').replace(/\s+/g, ' ').trim();
|
|
36
|
-
if (!text)
|
|
37
|
-
return '';
|
|
38
|
-
const words = text.split(' ');
|
|
39
|
-
let label = '';
|
|
40
|
-
for (const word of words.slice(0, 3)) {
|
|
41
|
-
const next = label ? `${label} ${word}` : word;
|
|
42
|
-
if (next.length > maxChars)
|
|
43
|
-
break;
|
|
44
|
-
label = next;
|
|
45
|
-
}
|
|
46
|
-
if (!label)
|
|
47
|
-
label = text.slice(0, maxChars);
|
|
48
|
-
return label;
|
|
49
|
-
}
|
|
50
|
-
export function isRealZellijWorkerPaneIdSource(value) {
|
|
51
|
-
return value === 'zellij_worker_new_pane_stdout' || value === 'zellij_worker_list_panes';
|
|
52
|
-
}
|
|
53
|
-
export function buildWorkerPaneArtifact(input) {
|
|
54
|
-
const now = nowIso();
|
|
55
|
-
const paneIdSource = input.paneIdSource || 'zellij_worker_pane_launch_failed';
|
|
56
|
-
const blockers = input.blockers || [];
|
|
57
|
-
const providerContext = normalizePaneProviderContext(input.providerContext, input.serviceTier);
|
|
58
|
-
const paneTitle = buildWorkerPaneTitle(input.slotId, input.generationIndex, providerContext, input.serviceTier, input.backend, input.statusLabel || input.status, input.worktree || null);
|
|
59
|
-
const commandText = String(input.workerCommand || '');
|
|
60
|
-
const isSlotRenderer = commandText.includes('zellij-slot-pane');
|
|
61
|
-
const paneKind = input.paneKind || (isSlotRenderer ? 'slot_status_renderer' : 'worker_codex_sdk');
|
|
62
|
-
const scalingPrimitive = input.scalingPrimitive || (isSlotRenderer
|
|
63
|
-
? 'native_cli_process_with_zellij_slot_renderer'
|
|
64
|
-
: 'native_cli_process_in_zellij_worker_pane');
|
|
65
|
-
const directionRequested = input.directionRequested || 'down';
|
|
66
|
-
const directionApplied = input.directionApplied || 'not_applied';
|
|
67
|
-
return {
|
|
68
|
-
schema: ZELLIJ_WORKER_PANE_SCHEMA,
|
|
69
|
-
generated_at: now,
|
|
70
|
-
updated_at: now,
|
|
71
|
-
ok: blockers.length === 0 && (paneIdSource === 'zellij_worker_headless_overflow' || paneIdSource === 'headless_by_design_viewport_ui' || paneIdSource === 'preallocated_layout_pane' || (isRealZellijWorkerPaneIdSource(paneIdSource) && Boolean(input.paneId))),
|
|
72
|
-
status: input.status || 'launching',
|
|
73
|
-
mission_id: input.missionId,
|
|
74
|
-
session_name: input.sessionName,
|
|
75
|
-
slot_id: input.slotId,
|
|
76
|
-
generation_index: input.generationIndex,
|
|
77
|
-
session_id: input.sessionId,
|
|
78
|
-
pane_name: paneTitle,
|
|
79
|
-
pane_title: paneTitle,
|
|
80
|
-
pane_kind: paneKind,
|
|
81
|
-
pane_id: input.paneId || null,
|
|
82
|
-
pane_id_source: paneIdSource,
|
|
83
|
-
provider: providerContext.provider,
|
|
84
|
-
service_tier: providerContext.service_tier,
|
|
85
|
-
provider_context: providerContext,
|
|
86
|
-
worktree: input.worktree || null,
|
|
87
|
-
worker_artifact_dir: input.workerArtifactDir,
|
|
88
|
-
worker_result_path: input.resultPath,
|
|
89
|
-
heartbeat_path: input.heartbeatPath,
|
|
90
|
-
patch_envelope_path: input.patchEnvelopePath,
|
|
91
|
-
stdout_log: input.stdoutLog,
|
|
92
|
-
stderr_log: input.stderrLog,
|
|
93
|
-
parent_child_transport: 'worker-result-json-and-heartbeat',
|
|
94
|
-
scaling_primitive: scalingPrimitive,
|
|
95
|
-
command: isSlotRenderer ? '<zellij-slot-pane-renderer-command>' : '<native-cli-worker-command>',
|
|
96
|
-
create_session: input.createSession || null,
|
|
97
|
-
launch: input.launch || null,
|
|
98
|
-
pane_reconciliation: input.paneReconciliation || null,
|
|
99
|
-
opened_at: now,
|
|
100
|
-
closed_at: null,
|
|
101
|
-
close: null,
|
|
102
|
-
direction_requested: directionRequested,
|
|
103
|
-
direction_applied: directionApplied,
|
|
104
|
-
column_creation_direction_requested: input.columnCreationDirectionRequested ?? null,
|
|
105
|
-
column_creation_direction_applied: input.columnCreationDirectionApplied ?? null,
|
|
106
|
-
worker_direction_requested: input.workerDirectionRequested || 'down',
|
|
107
|
-
worker_direction_applied: input.workerDirectionApplied || (directionApplied === 'down' ? 'down' : directionApplied === 'unknown' ? 'unknown' : 'not_applied'),
|
|
108
|
-
worker_stacked_requested: input.stackedRequested === true,
|
|
109
|
-
worker_stacked_applied: input.stackedApplied === true,
|
|
110
|
-
worker_stacked_fallback_mode: input.stackedFallbackMode || null,
|
|
111
|
-
worker_stacked_capability: input.stackedCapability || null,
|
|
112
|
-
slot_column_anchor_pane_id: input.slotColumnAnchorPaneId || null,
|
|
113
|
-
right_column: input.rightColumn || null,
|
|
114
|
-
sdk_thread_id: input.sdkThreadId || null,
|
|
115
|
-
sdk_run_id: input.sdkRunId || null,
|
|
116
|
-
stream_event_count: Number(input.streamEventCount || 0),
|
|
117
|
-
structured_output_valid: input.structuredOutputValid === true,
|
|
118
|
-
warnings: input.warnings || [],
|
|
119
|
-
blockers
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
export async function openHeadlessByDesignViewportWorker(input) {
|
|
123
|
-
const root = path.resolve(input.root);
|
|
124
|
-
const providerInput = { root, route: '$Naruto' };
|
|
125
|
-
const serviceTier = input.serviceTier || process.env.SKS_SERVICE_TIER;
|
|
126
|
-
if (serviceTier != null)
|
|
127
|
-
providerInput.serviceTier = serviceTier;
|
|
128
|
-
const providerContext = input.providerContext || await resolveProviderContext(providerInput);
|
|
129
|
-
await ensureDir(path.join(root, input.workerArtifactDir));
|
|
130
|
-
const record = buildWorkerPaneArtifact({
|
|
131
|
-
...input,
|
|
132
|
-
paneId: null,
|
|
133
|
-
paneIdSource: 'headless_by_design_viewport_ui',
|
|
134
|
-
createSession: null,
|
|
135
|
-
launch: null,
|
|
136
|
-
paneReconciliation: null,
|
|
137
|
-
directionRequested: 'down',
|
|
138
|
-
directionApplied: 'not_applied',
|
|
139
|
-
columnCreationDirectionRequested: null,
|
|
140
|
-
columnCreationDirectionApplied: 'not_applied',
|
|
141
|
-
workerDirectionRequested: 'down',
|
|
142
|
-
workerDirectionApplied: 'not_applied',
|
|
143
|
-
status: 'running',
|
|
144
|
-
providerContext,
|
|
145
|
-
serviceTier: input.serviceTier || providerContext.service_tier,
|
|
146
|
-
paneKind: 'slot_status_renderer',
|
|
147
|
-
scalingPrimitive: 'native_cli_process_headless_with_slot_column',
|
|
148
|
-
workerCommand: '<headless-by-design-viewport-ui>',
|
|
149
|
-
blockers: []
|
|
150
|
-
});
|
|
151
|
-
await writeWorkerPaneArtifact(root, record);
|
|
152
|
-
await appendWorkerPaneEvent(root, 'worker_headless_by_design_viewport_ui', input, {
|
|
153
|
-
slot_id: input.slotId,
|
|
154
|
-
generation_index: input.generationIndex,
|
|
155
|
-
reason: 'monitor_plus_viewports'
|
|
156
|
-
});
|
|
157
|
-
return record;
|
|
158
|
-
}
|
|
159
|
-
export async function openWorkerPane(input) {
|
|
160
|
-
const root = path.resolve(input.root);
|
|
161
|
-
const cwd = input.cwd || packageRoot();
|
|
162
|
-
const providerInput = { root, route: '$Naruto' };
|
|
163
|
-
const serviceTier = input.serviceTier || process.env.SKS_SERVICE_TIER;
|
|
164
|
-
if (serviceTier != null)
|
|
165
|
-
providerInput.serviceTier = serviceTier;
|
|
166
|
-
const providerContext = input.providerContext || await resolveProviderContext(providerInput);
|
|
167
|
-
const workerDir = path.join(root, input.workerArtifactDir);
|
|
168
|
-
await ensureDir(workerDir);
|
|
169
|
-
await appendWorkerPaneEvent(root, 'session_launch_started', input, {});
|
|
170
|
-
const createSessionRaw = await runZellij(['attach', '--create-background', input.sessionName], {
|
|
171
|
-
cwd,
|
|
172
|
-
timeoutMs: 5000,
|
|
173
|
-
optional: false
|
|
174
|
-
});
|
|
175
|
-
const createSession = normalizeExistingZellijSession(input.sessionName, createSessionRaw);
|
|
176
|
-
const requestedCap = nonNegativeInt(input.visiblePaneCap, 0);
|
|
177
|
-
const envCap = nonNegativeInt(Number(process.env.SKS_ZELLIJ_VISIBLE_PANES || 0), 0);
|
|
178
|
-
const visiblePaneCap = Math.max(1, requestedCap || envCap || 1);
|
|
179
|
-
const rightColumn = input.rightColumnMode === 'spawn-on-first-worker'
|
|
180
|
-
? await prepareWorkerInRightColumn({
|
|
181
|
-
root,
|
|
182
|
-
...(input.projectRoot ? { projectRoot: input.projectRoot } : {}),
|
|
183
|
-
missionId: input.missionId,
|
|
184
|
-
sessionName: input.sessionName,
|
|
185
|
-
worker: { slotId: input.slotId, generationIndex: input.generationIndex },
|
|
186
|
-
visiblePaneCap,
|
|
187
|
-
uiMode: input.uiMode || 'compact-slots'
|
|
188
|
-
})
|
|
189
|
-
: null;
|
|
190
|
-
if (rightColumn?.placement === 'headless') {
|
|
191
|
-
const record = buildWorkerPaneArtifact({
|
|
192
|
-
...input,
|
|
193
|
-
paneId: null,
|
|
194
|
-
paneIdSource: 'zellij_worker_headless_overflow',
|
|
195
|
-
createSession,
|
|
196
|
-
launch: null,
|
|
197
|
-
paneReconciliation: null,
|
|
198
|
-
directionRequested: 'down',
|
|
199
|
-
directionApplied: 'not_applied',
|
|
200
|
-
columnCreationDirectionRequested: null,
|
|
201
|
-
columnCreationDirectionApplied: 'not_applied',
|
|
202
|
-
workerDirectionRequested: 'down',
|
|
203
|
-
workerDirectionApplied: 'not_applied',
|
|
204
|
-
slotColumnAnchorPaneId: rightColumn.state.slot_column_anchor_pane_id || null,
|
|
205
|
-
rightColumn: {
|
|
206
|
-
mode: 'spawn-on-first-worker',
|
|
207
|
-
focus_pane_id: null,
|
|
208
|
-
y_order: null,
|
|
209
|
-
slot_column_anchor_pane_id: rightColumn.state.slot_column_anchor_pane_id || null
|
|
210
|
-
},
|
|
211
|
-
status: 'running',
|
|
212
|
-
providerContext,
|
|
213
|
-
serviceTier: input.serviceTier || providerContext.service_tier,
|
|
214
|
-
scalingPrimitive: 'native_cli_process_headless_with_slot_column',
|
|
215
|
-
blockers: []
|
|
216
|
-
});
|
|
217
|
-
await writeWorkerPaneArtifact(root, record);
|
|
218
|
-
await appendWorkerPaneEvent(root, 'worker_headless_overflow', input, {
|
|
219
|
-
slot_id: input.slotId,
|
|
220
|
-
generation_index: input.generationIndex,
|
|
221
|
-
reason: `visible_pane_cap:${visiblePaneCap}`
|
|
222
|
-
});
|
|
223
|
-
return record;
|
|
224
|
-
}
|
|
225
|
-
const paneName = buildWorkerPaneTitle(input.slotId, input.generationIndex, providerContext, input.serviceTier, input.backend, input.statusLabel || 'running', input.worktree || null, input.taskTitle || null);
|
|
226
|
-
return withZellijPaneCreationLock(input, async () => {
|
|
227
|
-
const freshState = rightColumn
|
|
228
|
-
? await readRightColumnState(root, input.missionId, input.projectRoot).catch(() => null)
|
|
229
|
-
: null;
|
|
230
|
-
let slotColumnAnchorPaneId = freshState?.slot_column_anchor_pane_id || rightColumn?.state.slot_column_anchor_pane_id || null;
|
|
231
|
-
const lastVisibleWorkerPaneId = [...(freshState?.visible_worker_panes || [])]
|
|
232
|
-
.filter((pane) => pane.pane_id && (pane.status === 'launching' || pane.status === 'running'))
|
|
233
|
-
.map((pane) => String(pane.pane_id))
|
|
234
|
-
.pop() || null;
|
|
235
|
-
const freshFocusCandidate = lastVisibleWorkerPaneId
|
|
236
|
-
|| slotColumnAnchorPaneId
|
|
237
|
-
|| freshState?.right_anchor_pane_id
|
|
238
|
-
|| rightColumn?.focusPaneId
|
|
239
|
-
|| null;
|
|
240
|
-
let anchorLaunch = null;
|
|
241
|
-
let columnCreationDirectionRequested = null;
|
|
242
|
-
let columnCreationDirectionApplied = null;
|
|
243
|
-
if (rightColumn && !freshFocusCandidate) {
|
|
244
|
-
const adoptedAnchorPaneId = createSession.ok
|
|
245
|
-
? await findExistingSlotsAnchorPaneId(input.sessionName, cwd).catch(() => null)
|
|
246
|
-
: null;
|
|
247
|
-
if (adoptedAnchorPaneId) {
|
|
248
|
-
slotColumnAnchorPaneId = adoptedAnchorPaneId;
|
|
249
|
-
await recordSlotColumnAnchorInRightColumn({
|
|
250
|
-
root,
|
|
251
|
-
...(input.projectRoot ? { projectRoot: input.projectRoot } : {}),
|
|
252
|
-
missionId: input.missionId,
|
|
253
|
-
sessionName: input.sessionName,
|
|
254
|
-
paneId: slotColumnAnchorPaneId
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
else {
|
|
258
|
-
columnCreationDirectionRequested = 'right';
|
|
259
|
-
const anchorCommand = buildZellijSlotColumnAnchorCommand({
|
|
260
|
-
cliPath: path.join(packageRoot(), 'dist', 'bin', 'sks.js'),
|
|
261
|
-
missionId: input.missionId,
|
|
262
|
-
mode: input.uiMode || 'compact-slots',
|
|
263
|
-
artifactRoot: root,
|
|
264
|
-
watch: true
|
|
265
|
-
});
|
|
266
|
-
anchorLaunch = createSession.ok
|
|
267
|
-
? await runZellij(['--session', input.sessionName, 'action', 'new-pane', '--direction', 'right', '--name', 'SLOTS', '--', 'sh', '-lc', anchorCommand], {
|
|
268
|
-
cwd,
|
|
269
|
-
timeoutMs: 5000,
|
|
270
|
-
optional: false
|
|
271
|
-
})
|
|
272
|
-
: null;
|
|
273
|
-
slotColumnAnchorPaneId = anchorLaunch?.ok ? extractZellijPaneIdFromOutput(anchorLaunch.stdout_tail) : null;
|
|
274
|
-
columnCreationDirectionApplied = anchorLaunch?.ok ? (slotColumnAnchorPaneId ? 'right' : 'unknown') : 'not_applied';
|
|
275
|
-
if (slotColumnAnchorPaneId) {
|
|
276
|
-
await recordSlotColumnAnchorInRightColumn({
|
|
277
|
-
root,
|
|
278
|
-
...(input.projectRoot ? { projectRoot: input.projectRoot } : {}),
|
|
279
|
-
missionId: input.missionId,
|
|
280
|
-
sessionName: input.sessionName,
|
|
281
|
-
paneId: slotColumnAnchorPaneId
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
const focusPaneId = lastVisibleWorkerPaneId || slotColumnAnchorPaneId || freshFocusCandidate || null;
|
|
287
|
-
const directionRequested = 'down';
|
|
288
|
-
const focus = focusPaneId
|
|
289
|
-
? await focusZellijPaneById(input.sessionName, focusPaneId, cwd)
|
|
290
|
-
: null;
|
|
291
|
-
const stackIntent = process.env.SKS_ZELLIJ_WORKER_STACKED !== '0'
|
|
292
|
-
&& Boolean(lastVisibleWorkerPaneId)
|
|
293
|
-
&& focus?.ok === true;
|
|
294
|
-
const stackedCapability = stackIntent
|
|
295
|
-
? await checkZellijStackedPaneCapability({ writeReport: false }).catch((err) => ({
|
|
296
|
-
schema: 'sks.zellij-stacked-pane-capability.v1',
|
|
297
|
-
ok: false,
|
|
298
|
-
zellij_bin: 'zellij',
|
|
299
|
-
version_text: null,
|
|
300
|
-
parsed_version: null,
|
|
301
|
-
supports_stacked_panes: false,
|
|
302
|
-
requires_update: false,
|
|
303
|
-
fallback_mode: 'headless-only',
|
|
304
|
-
blockers: [`zellij_stacked_capability_check_failed:${err?.code || err?.message || String(err)}`]
|
|
305
|
-
}))
|
|
306
|
-
: null;
|
|
307
|
-
const stackRequested = stackIntent && stackedCapability?.supports_stacked_panes === true;
|
|
308
|
-
const newPaneArgs = stackRequested
|
|
309
|
-
? ['--session', input.sessionName, 'action', 'new-pane', '--stacked', '--name', paneName, '--', 'sh', '-lc', input.workerCommand]
|
|
310
|
-
: ['--session', input.sessionName, 'action', 'new-pane', '--direction', directionRequested, '--near-current-pane', '--name', paneName, '--', 'sh', '-lc', input.workerCommand];
|
|
311
|
-
let launch = createSession.ok
|
|
312
|
-
? await runZellij(newPaneArgs, {
|
|
313
|
-
cwd,
|
|
314
|
-
timeoutMs: 5000,
|
|
315
|
-
optional: false
|
|
316
|
-
})
|
|
317
|
-
: null;
|
|
318
|
-
let stackApplied = Boolean(stackRequested && launch?.ok);
|
|
319
|
-
let directionApplied = launch?.ok ? directionRequested : 'not_applied';
|
|
320
|
-
let stackedRejectedFallback = false;
|
|
321
|
-
if (createSession.ok && launch && !launch.ok) {
|
|
322
|
-
const fallbackArgs = ['--session', input.sessionName, 'action', 'new-pane', '--direction', directionRequested, '--name', paneName, '--', 'sh', '-lc', input.workerCommand];
|
|
323
|
-
const fallback = await runZellij(fallbackArgs, {
|
|
324
|
-
cwd,
|
|
325
|
-
timeoutMs: 5000,
|
|
326
|
-
optional: false
|
|
327
|
-
});
|
|
328
|
-
if (fallback.ok) {
|
|
329
|
-
launch = fallback;
|
|
330
|
-
stackApplied = false;
|
|
331
|
-
stackedRejectedFallback = stackRequested;
|
|
332
|
-
directionApplied = rightColumn ? 'down' : 'unknown';
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
const stdoutPaneId = launch?.ok ? extractZellijPaneIdFromOutput(launch.stdout_tail) : null;
|
|
336
|
-
const reconciledPane = stdoutPaneId ? null : launch?.ok ? await reconcileZellijWorkerPaneId(input.sessionName, paneName, path.join(root, input.resultPath), cwd) : null;
|
|
337
|
-
const paneId = stdoutPaneId || reconciledPane?.pane_id || null;
|
|
338
|
-
const stackPaneIds = [...new Set([
|
|
339
|
-
...(freshState?.visible_worker_panes || [])
|
|
340
|
-
.filter((pane) => pane.pane_id && (pane.status === 'launching' || pane.status === 'running'))
|
|
341
|
-
.sort((a, b) => Number(a.y_order || 0) - Number(b.y_order || 0))
|
|
342
|
-
.map((pane) => String(pane.pane_id)),
|
|
343
|
-
paneId || ''
|
|
344
|
-
].filter(Boolean))];
|
|
345
|
-
const stackPanes = stackRequested && paneId && stackPaneIds.length >= 2
|
|
346
|
-
? await runZellij(['--session', input.sessionName, 'action', 'stack-panes', '--', ...stackPaneIds], {
|
|
347
|
-
cwd,
|
|
348
|
-
timeoutMs: 5000,
|
|
349
|
-
optional: true
|
|
350
|
-
})
|
|
351
|
-
: null;
|
|
352
|
-
const renamePane = paneId ? await renameZellijPaneById(input.sessionName, paneId, paneName, cwd) : null;
|
|
353
|
-
const paneIdSource = stdoutPaneId
|
|
354
|
-
? 'zellij_worker_new_pane_stdout'
|
|
355
|
-
: reconciledPane?.pane_id
|
|
356
|
-
? 'zellij_worker_list_panes'
|
|
357
|
-
: launch?.ok
|
|
358
|
-
? 'zellij_worker_pane_stdout_missing'
|
|
359
|
-
: 'zellij_worker_pane_launch_failed';
|
|
360
|
-
const blockers = [
|
|
361
|
-
...(createSession.ok ? [] : createSession.blockers.map((blocker) => `zellij_worker_session_${blocker}`)),
|
|
362
|
-
...(rightColumn && rightColumn.placement !== 'zellij-pane' ? [`zellij_worker_right_column_${rightColumn.placement}`] : []),
|
|
363
|
-
...(rightColumn && columnCreationDirectionRequested === 'right' && columnCreationDirectionApplied !== 'right' ? ['zellij_worker_slot_column_anchor_not_created'] : []),
|
|
364
|
-
...(anchorLaunch && !anchorLaunch.ok ? anchorLaunch.blockers.map((blocker) => `zellij_worker_slot_column_anchor_${blocker}`) : []),
|
|
365
|
-
...(launch && !launch.ok ? launch.blockers.map((blocker) => `zellij_worker_pane_${blocker}`) : []),
|
|
366
|
-
...(launch?.ok && !isRealZellijWorkerPaneIdSource(paneIdSource) ? ['zellij_worker_pane_id_real_source_missing'] : [])
|
|
367
|
-
];
|
|
368
|
-
const warnings = [
|
|
369
|
-
...(stackIntent && stackedCapability && !stackedCapability.supports_stacked_panes ? [`zellij_stacked_pane_fallback:${stackedCapability.fallback_mode}`] : []),
|
|
370
|
-
...(stackedRejectedFallback ? ['zellij_stacked_pane_rejected_fallback_down'] : []),
|
|
371
|
-
...(stackPanes && !stackPanes.ok ? stackPanes.blockers.map((blocker) => `zellij_stack_panes_reconcile_${blocker}`) : [])
|
|
372
|
-
];
|
|
373
|
-
const record = buildWorkerPaneArtifact({
|
|
374
|
-
...input,
|
|
375
|
-
paneId,
|
|
376
|
-
paneIdSource,
|
|
377
|
-
createSession,
|
|
378
|
-
launch,
|
|
379
|
-
paneReconciliation: {
|
|
380
|
-
...(reconciledPane || {}),
|
|
381
|
-
focus_pane: focus,
|
|
382
|
-
focus_degraded: focus ? focus.ok !== true : false,
|
|
383
|
-
slot_column_anchor_pane_id: slotColumnAnchorPaneId,
|
|
384
|
-
slot_column_anchor_launch: anchorLaunch,
|
|
385
|
-
rename_pane: renamePane,
|
|
386
|
-
stack_panes: stackPanes,
|
|
387
|
-
stack_pane_ids: stackPaneIds
|
|
388
|
-
},
|
|
389
|
-
directionRequested,
|
|
390
|
-
directionApplied,
|
|
391
|
-
columnCreationDirectionRequested,
|
|
392
|
-
columnCreationDirectionApplied,
|
|
393
|
-
workerDirectionRequested: 'down',
|
|
394
|
-
workerDirectionApplied: directionApplied === 'down' ? 'down' : directionApplied === 'unknown' ? 'unknown' : 'not_applied',
|
|
395
|
-
stackedRequested: stackIntent,
|
|
396
|
-
stackedApplied: stackApplied,
|
|
397
|
-
stackedFallbackMode: stackIntent ? (stackApplied ? 'native-stacked' : stackedCapability?.fallback_mode || 'down-split-stack-emulation') : null,
|
|
398
|
-
stackedCapability,
|
|
399
|
-
slotColumnAnchorPaneId,
|
|
400
|
-
rightColumn: rightColumn ? { mode: 'spawn-on-first-worker', focus_pane_id: focusPaneId, y_order: rightColumn.yOrder, slot_column_anchor_pane_id: slotColumnAnchorPaneId } : null,
|
|
401
|
-
status: blockers.length ? 'failed' : 'running',
|
|
402
|
-
providerContext,
|
|
403
|
-
serviceTier: input.serviceTier || providerContext.service_tier,
|
|
404
|
-
warnings,
|
|
405
|
-
blockers
|
|
406
|
-
});
|
|
407
|
-
await writeWorkerPaneArtifact(root, record);
|
|
408
|
-
if (rightColumn) {
|
|
409
|
-
await recordWorkerPaneInRightColumn({
|
|
410
|
-
root,
|
|
411
|
-
...(input.projectRoot ? { projectRoot: input.projectRoot } : {}),
|
|
412
|
-
missionId: input.missionId,
|
|
413
|
-
record,
|
|
414
|
-
yOrder: rightColumn.yOrder
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
await appendWorkerPaneEvent(root, 'zellij_worker_pane_created', input, {
|
|
418
|
-
ok: record.ok,
|
|
419
|
-
pane_id: record.pane_id,
|
|
420
|
-
pane_id_source: record.pane_id_source,
|
|
421
|
-
worker_stacked_requested: record.worker_stacked_requested === true,
|
|
422
|
-
worker_stacked_applied: record.worker_stacked_applied === true,
|
|
423
|
-
worker_stacked_fallback_mode: record.worker_stacked_fallback_mode || null,
|
|
424
|
-
blockers
|
|
425
|
-
});
|
|
426
|
-
await appendParallelRuntimeEvent(root, input.missionId, {
|
|
427
|
-
event_type: 'zellij_pane_created',
|
|
428
|
-
slot_id: input.slotId,
|
|
429
|
-
generation_index: input.generationIndex,
|
|
430
|
-
session_id: input.sessionId,
|
|
431
|
-
pid: null,
|
|
432
|
-
backend: String(input.backend || 'zellij'),
|
|
433
|
-
placement: 'zellij-pane',
|
|
434
|
-
meta: {
|
|
435
|
-
ok: record.ok,
|
|
436
|
-
pane_id: record.pane_id,
|
|
437
|
-
worker_stacked_requested: record.worker_stacked_requested === true,
|
|
438
|
-
worker_stacked_applied: record.worker_stacked_applied === true,
|
|
439
|
-
worker_stacked_fallback_mode: record.worker_stacked_fallback_mode || null
|
|
440
|
-
}
|
|
441
|
-
}).catch(() => undefined);
|
|
442
|
-
await appendJsonl(path.join(root, 'agent-zellij-pane-launch-ledger.jsonl'), {
|
|
443
|
-
schema: 'sks.agent-zellij-pane-launch.v1',
|
|
444
|
-
generated_at: nowIso(),
|
|
445
|
-
launch_mode: record.ok ? 'real_zellij_worker_pane_session' : 'real_zellij_worker_pane_failed',
|
|
446
|
-
agent_id: input.slotId,
|
|
447
|
-
slot_id: input.slotId,
|
|
448
|
-
generation_index: input.generationIndex,
|
|
449
|
-
session_id: input.sessionId,
|
|
450
|
-
session_name: input.sessionName,
|
|
451
|
-
pane_name: paneName,
|
|
452
|
-
pane_title: paneName,
|
|
453
|
-
pane_kind: record.pane_kind,
|
|
454
|
-
pane_id: record.pane_id,
|
|
455
|
-
pane_id_source: record.pane_id_source,
|
|
456
|
-
provider: record.provider,
|
|
457
|
-
service_tier: record.service_tier,
|
|
458
|
-
provider_context: record.provider_context,
|
|
459
|
-
direction_requested: record.direction_requested,
|
|
460
|
-
direction_applied: record.direction_applied,
|
|
461
|
-
column_creation_direction_requested: record.column_creation_direction_requested || null,
|
|
462
|
-
column_creation_direction_applied: record.column_creation_direction_applied || null,
|
|
463
|
-
worker_direction_requested: record.worker_direction_requested,
|
|
464
|
-
worker_direction_applied: record.worker_direction_applied,
|
|
465
|
-
worker_stacked_requested: record.worker_stacked_requested === true,
|
|
466
|
-
worker_stacked_applied: record.worker_stacked_applied === true,
|
|
467
|
-
worker_stacked_fallback_mode: record.worker_stacked_fallback_mode || null,
|
|
468
|
-
slot_column_anchor_pane_id: record.slot_column_anchor_pane_id || null,
|
|
469
|
-
command: record.command,
|
|
470
|
-
worker_artifact_dir: input.workerArtifactDir,
|
|
471
|
-
worker_result_path: input.resultPath,
|
|
472
|
-
heartbeat_path: input.heartbeatPath,
|
|
473
|
-
patch_envelope_path: input.patchEnvelopePath,
|
|
474
|
-
parent_child_transport: 'worker-result-json-and-heartbeat',
|
|
475
|
-
persistent_slot_lane: false,
|
|
476
|
-
scaling_primitive: record.scaling_primitive,
|
|
477
|
-
blockers
|
|
478
|
-
});
|
|
479
|
-
return record;
|
|
480
|
-
});
|
|
481
|
-
}
|
|
482
|
-
export async function closeWorkerPane(input) {
|
|
483
|
-
const root = path.resolve(input.root);
|
|
484
|
-
const success = (input.status || 'closed') === 'closed' && !(input.blockers || []).length;
|
|
485
|
-
const closeSuccess = process.env.SKS_ZELLIJ_CLOSE_WORKER_PANE !== '0';
|
|
486
|
-
const keepFailed = process.env.SKS_ZELLIJ_KEEP_FAILED_PANE === '1';
|
|
487
|
-
const closeFailed = !keepFailed && process.env.SKS_ZELLIJ_CLOSE_FAILED_PANE !== '0';
|
|
488
|
-
const paneId = input.paneRecord.pane_id;
|
|
489
|
-
const shouldClose = Boolean(paneId) && (success ? closeSuccess : closeFailed);
|
|
490
|
-
const close = shouldClose
|
|
491
|
-
? await closeZellijPaneById(input.paneRecord.session_name, paneId || '', input.cwd || packageRoot())
|
|
492
|
-
: null;
|
|
493
|
-
const rename = !shouldClose && paneId
|
|
494
|
-
? await renameZellijPaneById(input.paneRecord.session_name, paneId, `${input.paneRecord.pane_title} · ${success ? 'drained' : 'failed'}`, input.cwd || packageRoot())
|
|
495
|
-
: null;
|
|
496
|
-
const next = {
|
|
497
|
-
...input.paneRecord,
|
|
498
|
-
updated_at: nowIso(),
|
|
499
|
-
ok: input.paneRecord.ok && !(input.blockers || []).length,
|
|
500
|
-
status: input.status || ((input.blockers || []).length ? 'failed' : 'closed'),
|
|
501
|
-
closed_at: nowIso(),
|
|
502
|
-
close,
|
|
503
|
-
sdk_thread_id: input.sdkThreadId || input.paneRecord.sdk_thread_id || null,
|
|
504
|
-
sdk_run_id: input.sdkRunId || input.paneRecord.sdk_run_id || null,
|
|
505
|
-
stream_event_count: Number(input.streamEventCount || input.paneRecord.stream_event_count || 0),
|
|
506
|
-
structured_output_valid: input.structuredOutputValid === true || input.paneRecord.structured_output_valid === true,
|
|
507
|
-
worker_result_path: input.workerResultPath || input.paneRecord.worker_result_path,
|
|
508
|
-
blockers: [
|
|
509
|
-
...input.paneRecord.blockers,
|
|
510
|
-
...(input.blockers || []),
|
|
511
|
-
...(close && !close.ok ? close.blockers.map((blocker) => `zellij_worker_close_${blocker}`) : []),
|
|
512
|
-
...(rename && !rename.ok ? rename.blockers.map((blocker) => `zellij_worker_rename_${blocker}`) : [])
|
|
513
|
-
]
|
|
514
|
-
};
|
|
515
|
-
await writeWorkerPaneArtifact(root, next);
|
|
516
|
-
if (next.right_column?.mode === 'spawn-on-first-worker') {
|
|
517
|
-
await closeWorkerInRightColumn({
|
|
518
|
-
root,
|
|
519
|
-
...(input.projectRoot ? { projectRoot: input.projectRoot } : {}),
|
|
520
|
-
missionId: next.mission_id,
|
|
521
|
-
slotId: next.slot_id,
|
|
522
|
-
generationIndex: next.generation_index,
|
|
523
|
-
paneId: next.pane_id,
|
|
524
|
-
status: next.status === 'failed' ? 'failed' : close?.ok ? 'closed' : 'draining'
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
await appendWorkerPaneEvent(root, 'pane_closed', {
|
|
528
|
-
root,
|
|
529
|
-
missionId: next.mission_id,
|
|
530
|
-
sessionName: next.session_name,
|
|
531
|
-
slotId: next.slot_id,
|
|
532
|
-
generationIndex: next.generation_index,
|
|
533
|
-
sessionId: next.session_id,
|
|
534
|
-
workerArtifactDir: next.worker_artifact_dir,
|
|
535
|
-
resultPath: next.worker_result_path,
|
|
536
|
-
heartbeatPath: next.heartbeat_path,
|
|
537
|
-
patchEnvelopePath: next.patch_envelope_path,
|
|
538
|
-
stdoutLog: next.stdout_log,
|
|
539
|
-
stderrLog: next.stderr_log,
|
|
540
|
-
workerCommand: ''
|
|
541
|
-
}, { status: next.status, pane_id: next.pane_id, blockers: next.blockers });
|
|
542
|
-
return next;
|
|
543
|
-
}
|
|
544
|
-
export function evaluateZellijWorkerPaneSpawnOrder(events) {
|
|
545
|
-
const sequence = ['session_launch_started', 'zellij_worker_pane_created', 'worker_started', 'codex_sdk_thread_started', 'result_written', 'pane_closed'];
|
|
546
|
-
const seen = new Map();
|
|
547
|
-
events.forEach((event, index) => {
|
|
548
|
-
const type = String(event.event_type || event.event || '');
|
|
549
|
-
if (sequence.includes(type) && !seen.has(type))
|
|
550
|
-
seen.set(type, index);
|
|
551
|
-
});
|
|
552
|
-
const missing = sequence.filter((event) => !seen.has(event));
|
|
553
|
-
const outOfOrder = sequence.slice(1).filter((event, index) => {
|
|
554
|
-
const previous = seen.get(sequence[index] || '');
|
|
555
|
-
const current = seen.get(event);
|
|
556
|
-
return previous !== undefined && current !== undefined && current < previous;
|
|
557
|
-
});
|
|
558
|
-
return {
|
|
559
|
-
schema: 'sks.zellij-worker-pane-spawn-order-proof.v1',
|
|
560
|
-
ok: missing.length === 0 && outOfOrder.length === 0,
|
|
561
|
-
required_order: sequence,
|
|
562
|
-
observed_order: events.map((event) => String(event.event_type || event.event || '')).filter((event) => sequence.includes(event)),
|
|
563
|
-
missing,
|
|
564
|
-
out_of_order: outOfOrder,
|
|
565
|
-
blockers: [...missing.map((event) => `spawn_order_missing_${event}`), ...outOfOrder.map((event) => `spawn_order_out_of_order_${event}`)]
|
|
566
|
-
};
|
|
567
|
-
}
|
|
568
|
-
export async function readWorkerPaneRecord(root, workerArtifactDir) {
|
|
569
|
-
return readJson(path.join(path.resolve(root), workerArtifactDir, 'zellij-worker-pane.json'), null);
|
|
570
|
-
}
|
|
571
|
-
async function writeWorkerPaneArtifact(root, record) {
|
|
572
|
-
await writeJsonAtomic(path.join(root, record.worker_artifact_dir, 'zellij-worker-pane.json'), record);
|
|
573
|
-
await writeJsonAtomic(path.join(root, record.worker_artifact_dir, 'zellij-worker-pane-launch.json'), record);
|
|
574
|
-
}
|
|
575
|
-
async function appendWorkerPaneEvent(root, eventType, input, payload) {
|
|
576
|
-
await appendJsonl(path.join(root, input.workerArtifactDir, 'zellij-worker-pane-events.jsonl'), {
|
|
577
|
-
schema: ZELLIJ_WORKER_PANE_EVENT_SCHEMA,
|
|
578
|
-
ts: nowIso(),
|
|
579
|
-
event_type: eventType,
|
|
580
|
-
mission_id: input.missionId,
|
|
581
|
-
session_name: input.sessionName,
|
|
582
|
-
slot_id: input.slotId,
|
|
583
|
-
generation_index: input.generationIndex,
|
|
584
|
-
session_id: input.sessionId,
|
|
585
|
-
worker_artifact_dir: input.workerArtifactDir,
|
|
586
|
-
...payload
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
async function reconcileZellijWorkerPaneId(sessionName, paneName, resultPath, cwd) {
|
|
590
|
-
const listed = await runZellij(['--session', sessionName, 'action', 'list-panes', '--json', '--all'], {
|
|
591
|
-
cwd,
|
|
592
|
-
timeoutMs: 5000,
|
|
593
|
-
maxOutputBytes: 1024 * 1024,
|
|
594
|
-
optional: true
|
|
595
|
-
});
|
|
596
|
-
const screen = await runZellij(['--session', sessionName, 'action', 'dump-screen'], {
|
|
597
|
-
cwd,
|
|
598
|
-
timeoutMs: 5000,
|
|
599
|
-
optional: true
|
|
600
|
-
});
|
|
601
|
-
const rows = parsePaneRows(zellijCommandStdout(listed));
|
|
602
|
-
const pane = rows.find((row) => {
|
|
603
|
-
const title = String(row.title || row.name || row.pane_name || '');
|
|
604
|
-
const command = String(row.terminal_command || row.command || row.command_line || row.running_command || '');
|
|
605
|
-
const exited = row.exited === true || row.is_exited === true || row.exit_status != null;
|
|
606
|
-
return !exited && title === paneName && (command.includes(resultPath) || command.includes('SKS_ZELLIJ_WORKER_PANE'));
|
|
607
|
-
}) || rows.find((row) => {
|
|
608
|
-
const title = String(row.title || row.name || row.pane_name || '');
|
|
609
|
-
const exited = row.exited === true || row.is_exited === true || row.exit_status != null;
|
|
610
|
-
return !exited && title === paneName;
|
|
611
|
-
});
|
|
612
|
-
const paneId = pane?.pane_id ?? pane?.paneId ?? pane?.id ?? null;
|
|
613
|
-
return {
|
|
614
|
-
schema: 'sks.zellij-worker-pane-reconciliation.v1',
|
|
615
|
-
ok: Boolean(paneId),
|
|
616
|
-
pane_id: paneId == null ? null : String(paneId),
|
|
617
|
-
listed_count: rows.length,
|
|
618
|
-
command: listed,
|
|
619
|
-
dump_screen: screen,
|
|
620
|
-
blockers: paneId == null ? ['zellij_worker_pane_id_not_reconciled'] : []
|
|
621
|
-
};
|
|
622
|
-
}
|
|
623
|
-
async function findExistingSlotsAnchorPaneId(sessionName, cwd) {
|
|
624
|
-
const listed = await runZellij(['--session', sessionName, 'action', 'list-panes', '--json', '--all'], {
|
|
625
|
-
cwd,
|
|
626
|
-
timeoutMs: 5000,
|
|
627
|
-
maxOutputBytes: 1024 * 1024,
|
|
628
|
-
optional: true
|
|
629
|
-
});
|
|
630
|
-
if (!listed.ok)
|
|
631
|
-
return null;
|
|
632
|
-
const rows = parsePaneRows(zellijCommandStdout(listed));
|
|
633
|
-
const pane = rows.find((row) => {
|
|
634
|
-
if (row?.is_plugin === true)
|
|
635
|
-
return false;
|
|
636
|
-
const exited = row?.exited === true || row?.is_exited === true || row?.exit_status != null;
|
|
637
|
-
if (exited)
|
|
638
|
-
return false;
|
|
639
|
-
const title = String(row?.title || row?.name || row?.pane_name || '');
|
|
640
|
-
return title === 'SLOTS';
|
|
641
|
-
});
|
|
642
|
-
if (!pane)
|
|
643
|
-
return null;
|
|
644
|
-
const rawPaneId = pane.pane_id ?? pane.paneId;
|
|
645
|
-
if (rawPaneId != null && String(rawPaneId).trim())
|
|
646
|
-
return String(rawPaneId).trim();
|
|
647
|
-
return pane.id == null ? null : `terminal_${pane.id}`;
|
|
648
|
-
}
|
|
649
|
-
function normalizePaneProviderContext(context, serviceTier) {
|
|
650
|
-
const tier = normalizeServiceTier(serviceTier || context?.service_tier);
|
|
651
|
-
return context
|
|
652
|
-
? { ...context, service_tier: tier }
|
|
653
|
-
: {
|
|
654
|
-
schema: 'sks.provider-context.v1',
|
|
655
|
-
generated_at: nowIso(),
|
|
656
|
-
provider: 'unknown',
|
|
657
|
-
auth_mode: 'unknown',
|
|
658
|
-
route: '$Naruto',
|
|
659
|
-
service_tier: tier,
|
|
660
|
-
source: 'unknown',
|
|
661
|
-
confidence: 'low',
|
|
662
|
-
conflict: false,
|
|
663
|
-
warnings: [],
|
|
664
|
-
signals: {
|
|
665
|
-
openai_api_key_present: false,
|
|
666
|
-
codex_lb_key_present: false,
|
|
667
|
-
codex_lb_explicit: false,
|
|
668
|
-
codex_app_auth_present: false,
|
|
669
|
-
model_provider: null
|
|
670
|
-
}
|
|
671
|
-
};
|
|
672
|
-
}
|
|
673
|
-
function normalizeServiceTier(value) {
|
|
674
|
-
const text = String(value || '').toLowerCase();
|
|
675
|
-
if (text === 'fast' || text === 'priority')
|
|
676
|
-
return 'fast';
|
|
677
|
-
if (text === 'standard' || text === 'default')
|
|
678
|
-
return 'standard';
|
|
679
|
-
return 'unknown';
|
|
680
|
-
}
|
|
681
|
-
function parsePaneRows(text) {
|
|
682
|
-
if (!String(text || '').trim())
|
|
683
|
-
return [];
|
|
684
|
-
try {
|
|
685
|
-
const parsed = JSON.parse(String(text));
|
|
686
|
-
if (Array.isArray(parsed))
|
|
687
|
-
return parsed;
|
|
688
|
-
if (Array.isArray(parsed?.panes))
|
|
689
|
-
return parsed.panes;
|
|
690
|
-
return [];
|
|
691
|
-
}
|
|
692
|
-
catch {
|
|
693
|
-
return [];
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
async function renameZellijPaneById(sessionName, paneId, paneName, cwd) {
|
|
697
|
-
const numeric = Number.parseInt(paneId.replace(/^terminal_/, ''), 10);
|
|
698
|
-
const numericCandidates = Number.isFinite(numeric)
|
|
699
|
-
? [numeric, numeric + 1, numeric - 1].filter((value) => value >= 0).map(String)
|
|
700
|
-
: [];
|
|
701
|
-
const candidates = [...new Set([paneId, paneId.replace(/^terminal_/, ''), ...numericCandidates].filter(Boolean))];
|
|
702
|
-
let last = null;
|
|
703
|
-
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
704
|
-
if (attempt > 0)
|
|
705
|
-
await sleep(200 * attempt);
|
|
706
|
-
for (const candidate of candidates) {
|
|
707
|
-
last = await runZellij(['--session', sessionName, 'action', 'rename-pane', '--pane-id', candidate, paneName], {
|
|
708
|
-
cwd,
|
|
709
|
-
timeoutMs: 5000,
|
|
710
|
-
optional: true
|
|
711
|
-
});
|
|
712
|
-
if (last.ok)
|
|
713
|
-
return last;
|
|
714
|
-
const focus = await runZellij(['--session', sessionName, 'action', 'focus-pane-id', candidate], {
|
|
715
|
-
cwd,
|
|
716
|
-
timeoutMs: 5000,
|
|
717
|
-
optional: true
|
|
718
|
-
});
|
|
719
|
-
if (focus.ok) {
|
|
720
|
-
last = await runZellij(['--session', sessionName, 'action', 'rename-pane', paneName], {
|
|
721
|
-
cwd,
|
|
722
|
-
timeoutMs: 5000,
|
|
723
|
-
optional: true
|
|
724
|
-
});
|
|
725
|
-
if (last.ok)
|
|
726
|
-
return last;
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
return last;
|
|
731
|
-
}
|
|
732
|
-
async function focusZellijPaneById(sessionName, paneId, cwd) {
|
|
733
|
-
const candidates = zellijPaneIdCandidates(paneId);
|
|
734
|
-
let last = null;
|
|
735
|
-
for (const candidate of candidates) {
|
|
736
|
-
const focus = await runZellij(['--session', sessionName, 'action', 'focus-pane-id', candidate], {
|
|
737
|
-
cwd,
|
|
738
|
-
timeoutMs: 5000,
|
|
739
|
-
optional: true
|
|
740
|
-
});
|
|
741
|
-
last = focus;
|
|
742
|
-
if (focus.ok)
|
|
743
|
-
return focus;
|
|
744
|
-
if (/already focused/i.test(`${focus.stdout_tail || ''} ${focus.stderr_tail || ''}`)) {
|
|
745
|
-
return { ...focus, ok: true, blockers: [], warnings: [...focus.warnings, 'zellij_pane_already_focused'] };
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
return last;
|
|
749
|
-
}
|
|
750
|
-
export async function closeZellijPaneById(sessionName, paneId, cwd) {
|
|
751
|
-
const candidates = zellijPaneIdCandidates(paneId);
|
|
752
|
-
let last = null;
|
|
753
|
-
for (const candidate of candidates) {
|
|
754
|
-
const close = await runZellij(['--session', sessionName, 'action', 'close-pane', '--pane-id', candidate], {
|
|
755
|
-
cwd,
|
|
756
|
-
timeoutMs: 5000,
|
|
757
|
-
optional: true
|
|
758
|
-
});
|
|
759
|
-
last = close;
|
|
760
|
-
if (close.ok)
|
|
761
|
-
return close;
|
|
762
|
-
}
|
|
763
|
-
return last;
|
|
764
|
-
}
|
|
765
|
-
function zellijPaneIdCandidates(paneId) {
|
|
766
|
-
const raw = String(paneId || '').trim();
|
|
767
|
-
const numeric = raw.replace(/^terminal_/, '');
|
|
768
|
-
const parsed = Number.parseInt(numeric, 10);
|
|
769
|
-
return [...new Set([
|
|
770
|
-
raw,
|
|
771
|
-
numeric,
|
|
772
|
-
Number.isFinite(parsed) ? String(parsed) : '',
|
|
773
|
-
Number.isFinite(parsed) ? `terminal_${parsed}` : ''
|
|
774
|
-
].filter(Boolean))];
|
|
775
|
-
}
|
|
776
|
-
function sleep(ms) {
|
|
777
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
778
|
-
}
|
|
779
|
-
const zellijPaneCreationLocks = new Map();
|
|
780
|
-
async function withZellijPaneCreationLock(input, fn) {
|
|
781
|
-
const key = String(input.sessionName || 'default');
|
|
782
|
-
const requestedAt = nowIso();
|
|
783
|
-
const requestedMs = Date.now();
|
|
784
|
-
await appendWorkerPaneEvent(path.resolve(input.root), 'zellij_pane_creation_lock_requested', input, {}).catch(() => undefined);
|
|
785
|
-
await appendParallelRuntimeEvent(path.resolve(input.root), input.missionId, {
|
|
786
|
-
event_type: 'zellij_pane_creation_lock_requested',
|
|
787
|
-
slot_id: input.slotId,
|
|
788
|
-
generation_index: input.generationIndex,
|
|
789
|
-
session_id: input.sessionId,
|
|
790
|
-
pid: null,
|
|
791
|
-
backend: String(input.backend || 'zellij'),
|
|
792
|
-
placement: 'zellij-pane'
|
|
793
|
-
}).catch(() => undefined);
|
|
794
|
-
const previous = zellijPaneCreationLocks.get(key) || Promise.resolve();
|
|
795
|
-
let release;
|
|
796
|
-
const current = new Promise((resolve) => {
|
|
797
|
-
release = resolve;
|
|
798
|
-
});
|
|
799
|
-
const chained = previous.then(() => current, () => current);
|
|
800
|
-
zellijPaneCreationLocks.set(key, chained);
|
|
801
|
-
await previous.catch(() => undefined);
|
|
802
|
-
const acquiredAt = nowIso();
|
|
803
|
-
const acquiredMs = Date.now();
|
|
804
|
-
await appendWorkerPaneEvent(path.resolve(input.root), 'zellij_pane_creation_lock_acquired', input, { wait_ms: acquiredMs - requestedMs }).catch(() => undefined);
|
|
805
|
-
await appendParallelRuntimeEvent(path.resolve(input.root), input.missionId, {
|
|
806
|
-
event_type: 'zellij_pane_creation_lock_acquired',
|
|
807
|
-
slot_id: input.slotId,
|
|
808
|
-
generation_index: input.generationIndex,
|
|
809
|
-
session_id: input.sessionId,
|
|
810
|
-
pid: null,
|
|
811
|
-
backend: String(input.backend || 'zellij'),
|
|
812
|
-
placement: 'zellij-pane',
|
|
813
|
-
meta: { wait_ms: acquiredMs - requestedMs }
|
|
814
|
-
}).catch(() => undefined);
|
|
815
|
-
try {
|
|
816
|
-
return await fn();
|
|
817
|
-
}
|
|
818
|
-
finally {
|
|
819
|
-
const releasedAt = nowIso();
|
|
820
|
-
const releasedMs = Date.now();
|
|
821
|
-
const metrics = {
|
|
822
|
-
schema: ZELLIJ_PANE_CREATION_LOCK_METRICS_SCHEMA,
|
|
823
|
-
mission_id: input.missionId,
|
|
824
|
-
session_name: input.sessionName,
|
|
825
|
-
slot_id: input.slotId,
|
|
826
|
-
generation_index: input.generationIndex,
|
|
827
|
-
requested_at: requestedAt,
|
|
828
|
-
acquired_at: acquiredAt,
|
|
829
|
-
released_at: releasedAt,
|
|
830
|
-
wait_ms: acquiredMs - requestedMs,
|
|
831
|
-
held_ms: releasedMs - acquiredMs
|
|
832
|
-
};
|
|
833
|
-
await appendJsonl(paneCreationLockMetricsPath(path.resolve(input.root), input.missionId), metrics).catch(() => undefined);
|
|
834
|
-
await appendWorkerPaneEvent(path.resolve(input.root), 'zellij_pane_creation_lock_released', input, { wait_ms: metrics.wait_ms, held_ms: metrics.held_ms }).catch(() => undefined);
|
|
835
|
-
await appendParallelRuntimeEvent(path.resolve(input.root), input.missionId, {
|
|
836
|
-
event_type: 'zellij_pane_creation_lock_released',
|
|
837
|
-
slot_id: input.slotId,
|
|
838
|
-
generation_index: input.generationIndex,
|
|
839
|
-
session_id: input.sessionId,
|
|
840
|
-
pid: null,
|
|
841
|
-
backend: String(input.backend || 'zellij'),
|
|
842
|
-
placement: 'zellij-pane',
|
|
843
|
-
meta: { wait_ms: metrics.wait_ms, held_ms: metrics.held_ms }
|
|
844
|
-
}).catch(() => undefined);
|
|
845
|
-
release();
|
|
846
|
-
if (zellijPaneCreationLocks.get(key) === chained)
|
|
847
|
-
zellijPaneCreationLocks.delete(key);
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
function paneCreationLockMetricsPath(root, missionId) {
|
|
851
|
-
return path.join(missionArtifactRoot(root, missionId), 'zellij', 'pane-creation-lock-events.jsonl');
|
|
852
|
-
}
|
|
853
|
-
function missionArtifactRoot(root, missionId) {
|
|
854
|
-
const resolved = path.resolve(root);
|
|
855
|
-
if (path.basename(resolved) === 'agents')
|
|
856
|
-
return path.dirname(resolved);
|
|
857
|
-
if (path.basename(resolved) === missionId)
|
|
858
|
-
return resolved;
|
|
859
|
-
return path.join(resolved, '.sneakoscope', 'missions', missionId);
|
|
860
|
-
}
|
|
861
|
-
function normalizeExistingZellijSession(sessionName, result) {
|
|
862
|
-
if (result.ok)
|
|
863
|
-
return result;
|
|
864
|
-
if (/Session already exists/i.test(result.stderr_tail || '')) {
|
|
865
|
-
return {
|
|
866
|
-
...result,
|
|
867
|
-
ok: true,
|
|
868
|
-
blockers: [],
|
|
869
|
-
warnings: [...result.warnings, `zellij_session_already_exists:${sessionName}`]
|
|
870
|
-
};
|
|
871
|
-
}
|
|
872
|
-
return result;
|
|
873
|
-
}
|
|
874
|
-
function nonNegativeInt(value, fallback) {
|
|
875
|
-
const n = Math.floor(Number(value));
|
|
876
|
-
return Number.isFinite(n) && n >= 0 ? n : fallback;
|
|
877
|
-
}
|
|
878
|
-
function slotIndexNumber(slotId) {
|
|
879
|
-
const match = /(\d+)$/.exec(String(slotId || ''));
|
|
880
|
-
return match ? Math.max(1, Number(match[1])) : 1;
|
|
881
|
-
}
|