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,19 +1,13 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import { spawn } from 'node:child_process';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
import {
|
|
4
|
+
import { ensureDir, exists, nowIso, packageRoot, readJson, writeJsonAtomic } from '../fsx.js';
|
|
5
5
|
import { fastModeEnv } from './fast-mode-policy.js';
|
|
6
6
|
import { validateAgentWorkerResult } from './agent-worker-pipeline.js';
|
|
7
|
-
import { closeWorkerPane, openHeadlessByDesignViewportWorker } from '../zellij/zellij-worker-pane-manager.js';
|
|
8
|
-
import { closeWorkerInRightColumn, recordHeadlessWorkerInRightColumn } from '../zellij/zellij-right-column-manager.js';
|
|
9
|
-
import { resolveProviderContext } from '../provider/provider-context.js';
|
|
10
|
-
import { buildZellijSlotPaneCommand } from '../zellij/zellij-slot-pane-renderer.js';
|
|
11
|
-
import { resolveZellijWorkerPaneUiMode } from '../zellij/zellij-ui-mode.js';
|
|
12
|
-
import { appendZellijSlotTelemetry } from '../zellij/zellij-slot-telemetry.js';
|
|
13
7
|
import { appendParallelRuntimeEvent } from './parallel-runtime-proof.js';
|
|
14
8
|
import { appendAgentMessage } from './agent-message-bus.js';
|
|
15
9
|
import { markLoopWorkerInterrupted, registerLoopActiveWorker } from '../loops/loop-interrupt-registry.js';
|
|
16
|
-
export const NATIVE_CLI_WORKER_RUNTIME_SCHEMA = 'sks.native-cli-worker-runtime.
|
|
10
|
+
export const NATIVE_CLI_WORKER_RUNTIME_SCHEMA = 'sks.native-cli-worker-runtime.v3';
|
|
17
11
|
export function createNativeCliWorkerRuntimeRecorder(root, input) {
|
|
18
12
|
return new NativeCliWorkerRuntimeRecorder(root, input);
|
|
19
13
|
}
|
|
@@ -24,7 +18,6 @@ class NativeCliWorkerRuntimeRecorder {
|
|
|
24
18
|
active = new Set();
|
|
25
19
|
maxObserved = 0;
|
|
26
20
|
writeLock = Promise.resolve();
|
|
27
|
-
nextPaneToken = -1;
|
|
28
21
|
constructor(root, input) {
|
|
29
22
|
this.root = root;
|
|
30
23
|
this.input = input;
|
|
@@ -76,9 +69,8 @@ class NativeCliWorkerRuntimeRecorder {
|
|
|
76
69
|
await writeJsonAtomic(path.join(this.root, intakeRel), intake);
|
|
77
70
|
const workerEntrypoint = await resolveWorkerEntrypointPath();
|
|
78
71
|
const args = [workerEntrypoint, '--intake', path.join(this.root, intakeRel), '--json'];
|
|
79
|
-
const commandLine = [process.execPath, ...redactWorkerArgs(args)];
|
|
80
72
|
const record = {
|
|
81
|
-
schema: 'sks.native-cli-worker-session-record.
|
|
73
|
+
schema: 'sks.native-cli-worker-session-record.v2',
|
|
82
74
|
launched_at: nowIso(),
|
|
83
75
|
closed_at: null,
|
|
84
76
|
mission_id: this.input.missionId,
|
|
@@ -90,7 +82,7 @@ class NativeCliWorkerRuntimeRecorder {
|
|
|
90
82
|
backend: this.input.backend,
|
|
91
83
|
pid: null,
|
|
92
84
|
process_id: null,
|
|
93
|
-
command_line:
|
|
85
|
+
command_line: [process.execPath, ...redactWorkerArgs(args)],
|
|
94
86
|
stdout_log: stdoutRel,
|
|
95
87
|
stderr_log: stderrRel,
|
|
96
88
|
worker_artifact_dir: workerDirRel,
|
|
@@ -101,59 +93,20 @@ class NativeCliWorkerRuntimeRecorder {
|
|
|
101
93
|
fast_mode: this.input.fastModePolicy.fast_mode,
|
|
102
94
|
service_tier: this.input.fastModePolicy.service_tier,
|
|
103
95
|
cwd: workerCwd,
|
|
96
|
+
worker_placement: 'process',
|
|
97
|
+
scaling_primitive: 'native_cli_process',
|
|
104
98
|
status: 'launching',
|
|
105
99
|
exit_code: null,
|
|
106
100
|
blockers: []
|
|
107
101
|
};
|
|
108
|
-
|
|
109
|
-
const stderr = fs.createWriteStream(path.join(this.root, stderrRel), { flags: 'a' });
|
|
110
|
-
const placement = String(ctx.opts.workerPlacement || this.input.workerPlacement || (this.input.backend === 'zellij' ? 'zellij-pane' : 'process'));
|
|
111
|
-
const wantsZellijUi = placement === 'zellij-pane'
|
|
112
|
-
&& ctx.opts.zellijPaneWorker !== false
|
|
113
|
-
&& (ctx.opts.zellijSessionName || this.input.missionId);
|
|
114
|
-
const useZellijPane = Boolean(wantsZellijUi);
|
|
115
|
-
await this.telemetry(ctx, {
|
|
102
|
+
await this.lifecycle(ctx, {
|
|
116
103
|
eventType: 'slot_reserved',
|
|
117
|
-
status:
|
|
104
|
+
status: 'queued',
|
|
118
105
|
artifacts: [intakeRel, heartbeatRel, resultRel],
|
|
119
|
-
logTail:
|
|
106
|
+
logTail: 'placement=process'
|
|
120
107
|
});
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
stderr.end();
|
|
124
|
-
return this.launchWorkerInZellijPane({
|
|
125
|
-
ctx,
|
|
126
|
-
record,
|
|
127
|
-
args,
|
|
128
|
-
resultRel,
|
|
129
|
-
stdoutRel,
|
|
130
|
-
stderrRel,
|
|
131
|
-
heartbeatRel,
|
|
132
|
-
workerDirRel
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
if (placement === 'zellij-pane' && ctx.opts.zellijPaneWorker !== false && !useZellijPane) {
|
|
136
|
-
record.worker_placement = 'headless';
|
|
137
|
-
record.headless_reason = `visible_pane_cap:${this.zellijVisiblePaneCap(ctx.opts)}`;
|
|
138
|
-
await this.telemetry(ctx, {
|
|
139
|
-
eventType: 'headless_overflow',
|
|
140
|
-
status: 'headless',
|
|
141
|
-
artifacts: [intakeRel, heartbeatRel, resultRel],
|
|
142
|
-
logTail: record.headless_reason
|
|
143
|
-
});
|
|
144
|
-
await recordHeadlessWorkerInRightColumn({
|
|
145
|
-
root: this.root,
|
|
146
|
-
projectRoot: ctx.opts.projectRoot || this.input.projectRoot || ctx.opts.cwd,
|
|
147
|
-
missionId: this.input.missionId,
|
|
148
|
-
sessionName: String(ctx.opts.zellijSessionName || (this.input.missionId ? `sks-${this.input.missionId}` : 'sks-agent-runtime')),
|
|
149
|
-
slotId: String(ctx.agent.slot_id || ctx.agent.id || 'slot-001'),
|
|
150
|
-
generationIndex: Number(ctx.agent.generation_index || 1),
|
|
151
|
-
reason: record.headless_reason
|
|
152
|
-
}).catch(() => null);
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
record.worker_placement = placement === 'zellij-pane' ? 'zellij-pane' : 'process';
|
|
156
|
-
}
|
|
108
|
+
const stdout = fs.createWriteStream(path.join(this.root, stdoutRel), { flags: 'a' });
|
|
109
|
+
const stderr = fs.createWriteStream(path.join(this.root, stderrRel), { flags: 'a' });
|
|
157
110
|
const child = spawn(process.execPath, args, {
|
|
158
111
|
cwd: workerCwd,
|
|
159
112
|
env: {
|
|
@@ -170,12 +123,18 @@ class NativeCliWorkerRuntimeRecorder {
|
|
|
170
123
|
},
|
|
171
124
|
stdio: ['ignore', 'pipe', 'pipe']
|
|
172
125
|
});
|
|
126
|
+
const removeAbortListener = terminateChildOnAbort(child, ctx.opts?.signal);
|
|
173
127
|
const exitPromise = new Promise((resolve) => {
|
|
174
128
|
child.once('close', (code, signal) => resolve({ code, signal }));
|
|
175
129
|
child.once('error', () => resolve({ code: 1, signal: null }));
|
|
176
130
|
});
|
|
177
131
|
record.pid = child.pid || null;
|
|
178
132
|
record.process_id = child.pid || null;
|
|
133
|
+
record.status = 'running';
|
|
134
|
+
if (child.pid)
|
|
135
|
+
this.active.add(child.pid);
|
|
136
|
+
this.maxObserved = Math.max(this.maxObserved, this.active.size);
|
|
137
|
+
await this.record(record);
|
|
179
138
|
const loopHandle = await registerLoopWorkerHandle({
|
|
180
139
|
root: ctx.opts.projectRoot || this.input.projectRoot || ctx.opts.cwd || packageRoot(),
|
|
181
140
|
env: ctx.opts.env || {},
|
|
@@ -183,7 +142,6 @@ class NativeCliWorkerRuntimeRecorder {
|
|
|
183
142
|
sessionId: ctx.agent.session_id || null,
|
|
184
143
|
pid: child.pid || null
|
|
185
144
|
});
|
|
186
|
-
record.status = 'running';
|
|
187
145
|
await appendParallelRuntimeEvent(this.root, this.input.missionId, {
|
|
188
146
|
event_type: 'worker_process_spawned',
|
|
189
147
|
slot_id: ctx.agent.slot_id || ctx.agent.id || null,
|
|
@@ -191,22 +149,19 @@ class NativeCliWorkerRuntimeRecorder {
|
|
|
191
149
|
session_id: ctx.agent.session_id || null,
|
|
192
150
|
pid: child.pid || null,
|
|
193
151
|
backend: this.input.backend,
|
|
194
|
-
placement:
|
|
152
|
+
placement: 'process',
|
|
195
153
|
worktree_id: worktree?.id || null
|
|
196
154
|
}).catch(() => undefined);
|
|
197
|
-
await this.
|
|
155
|
+
await this.lifecycle(ctx, {
|
|
198
156
|
eventType: 'worker_spawned',
|
|
199
157
|
status: 'launching',
|
|
200
158
|
artifacts: [intakeRel, heartbeatRel, resultRel, stdoutRel, stderrRel],
|
|
201
159
|
logTail: `pid=${child.pid || 'unknown'}`
|
|
202
160
|
});
|
|
203
|
-
if (child.pid)
|
|
204
|
-
this.active.add(child.pid);
|
|
205
|
-
this.maxObserved = Math.max(this.maxObserved, this.active.size);
|
|
206
|
-
await this.record(record);
|
|
207
161
|
child.stdout?.pipe(stdout);
|
|
208
162
|
child.stderr?.pipe(stderr);
|
|
209
163
|
const exit = await exitPromise;
|
|
164
|
+
removeAbortListener();
|
|
210
165
|
stdout.end();
|
|
211
166
|
stderr.end();
|
|
212
167
|
if (child.pid)
|
|
@@ -218,21 +173,10 @@ class NativeCliWorkerRuntimeRecorder {
|
|
|
218
173
|
if (loopHandle) {
|
|
219
174
|
await markLoopWorkerInterrupted(ctx.opts.projectRoot || this.input.projectRoot || ctx.opts.cwd || packageRoot(), loopHandle.mission_id, loopHandle.worker_id, record.status === 'closed' ? 'completed' : 'failed').catch(() => undefined);
|
|
220
175
|
}
|
|
221
|
-
if (record.worker_placement === 'headless') {
|
|
222
|
-
await closeWorkerInRightColumn({
|
|
223
|
-
root: this.root,
|
|
224
|
-
projectRoot: ctx.opts.projectRoot || this.input.projectRoot || ctx.opts.cwd,
|
|
225
|
-
missionId: this.input.missionId,
|
|
226
|
-
slotId: String(ctx.agent.slot_id || ctx.agent.id || 'slot-001'),
|
|
227
|
-
generationIndex: Number(ctx.agent.generation_index || 1),
|
|
228
|
-
paneId: null,
|
|
229
|
-
status: record.status === 'closed' ? 'closed' : 'failed'
|
|
230
|
-
}).catch(() => null);
|
|
231
|
-
}
|
|
232
176
|
const parsed = await readJson(path.join(this.root, resultRel), null).catch(() => null);
|
|
233
177
|
if (!parsed) {
|
|
234
178
|
record.blockers = ['native_cli_worker_result_missing'];
|
|
235
|
-
await this.
|
|
179
|
+
await this.lifecycle(ctx, {
|
|
236
180
|
eventType: 'worker_failed',
|
|
237
181
|
status: 'failed',
|
|
238
182
|
artifacts: [stdoutRel, stderrRel],
|
|
@@ -259,11 +203,11 @@ class NativeCliWorkerRuntimeRecorder {
|
|
|
259
203
|
}
|
|
260
204
|
const result = validateAgentWorkerResult({
|
|
261
205
|
...parsed,
|
|
262
|
-
artifacts: [...(Array.isArray(parsed.artifacts) ? parsed.artifacts : []), stdoutRel, stderrRel]
|
|
206
|
+
artifacts: [...new Set([...(Array.isArray(parsed.artifacts) ? parsed.artifacts : []), stdoutRel, stderrRel])]
|
|
263
207
|
});
|
|
264
208
|
record.status = result.status === 'done' ? 'closed' : result.status;
|
|
265
209
|
record.blockers = result.blockers || [];
|
|
266
|
-
await this.
|
|
210
|
+
await this.lifecycle(ctx, {
|
|
267
211
|
eventType: result.status === 'done' ? 'worker_completed' : 'worker_failed',
|
|
268
212
|
status: result.status === 'done' ? 'completed' : 'failed',
|
|
269
213
|
artifacts: result.artifacts || [],
|
|
@@ -274,392 +218,6 @@ class NativeCliWorkerRuntimeRecorder {
|
|
|
274
218
|
await this.record(record);
|
|
275
219
|
return result;
|
|
276
220
|
}
|
|
277
|
-
async launchWorkerInZellijPane(input) {
|
|
278
|
-
const sessionName = String(input.ctx.opts.zellijSessionName || (this.input.missionId ? `sks-${this.input.missionId}` : 'sks-agent-runtime'));
|
|
279
|
-
const slotId = String(input.ctx.agent.slot_id || input.ctx.agent.id || 'slot-001');
|
|
280
|
-
const worktree = normalizeWorkerWorktree(input.ctx.agent?.worktree || input.ctx.slice?.worktree || input.ctx.opts?.worktree || null);
|
|
281
|
-
const workerCwd = worktree?.path || input.ctx.opts.cwd || packageRoot();
|
|
282
|
-
const activeToken = this.nextPaneToken--;
|
|
283
|
-
this.active.add(activeToken);
|
|
284
|
-
this.maxObserved = Math.max(this.maxObserved, this.active.size);
|
|
285
|
-
const providerContext = await resolveProviderContext({
|
|
286
|
-
root: this.root,
|
|
287
|
-
route: this.input.route,
|
|
288
|
-
serviceTier: this.input.fastModePolicy.service_tier
|
|
289
|
-
});
|
|
290
|
-
const uiMode = resolveZellijWorkerPaneUiMode(Array.isArray(input.ctx.opts.args) ? input.ctx.opts.args : [], process.env);
|
|
291
|
-
const liveWorkerPane = uiMode !== 'compact-slots';
|
|
292
|
-
const workerEnv = {
|
|
293
|
-
...(input.ctx.opts.env || {}),
|
|
294
|
-
...fastModeEnv(this.input.fastModePolicy),
|
|
295
|
-
SKS_AGENT_WORKER: '1',
|
|
296
|
-
SKS_PIPELINE_MODE: 'agent-worker',
|
|
297
|
-
SKS_DISABLE_ROUTE_RECURSION: '1',
|
|
298
|
-
SKS_PARENT_MISSION_ID: this.input.missionId,
|
|
299
|
-
SKS_AGENT_SESSION_ID: String(input.ctx.agent.session_id || ''),
|
|
300
|
-
SKS_AGENT_SLOT_ID: slotId,
|
|
301
|
-
SKS_AGENT_GENERATION_INDEX: String(input.ctx.agent.generation_index || 1),
|
|
302
|
-
...(input.ctx.opts.ollamaModel ? { SKS_OLLAMA_MODEL: String(input.ctx.opts.ollamaModel) } : {}),
|
|
303
|
-
...(input.ctx.opts.ollamaBaseUrl ? { SKS_OLLAMA_BASE_URL: String(input.ctx.opts.ollamaBaseUrl) } : {}),
|
|
304
|
-
SKS_ZELLIJ_SESSION_NAME: sessionName
|
|
305
|
-
};
|
|
306
|
-
const role = String(input.ctx.agent.naruto_role || input.ctx.agent.role || input.ctx.agent.persona_id || 'worker');
|
|
307
|
-
await this.telemetry(input.ctx, {
|
|
308
|
-
eventType: 'slot_reserved',
|
|
309
|
-
status: 'queued',
|
|
310
|
-
artifacts: [path.join(input.workerDirRel, 'worker-intake.json'), input.heartbeatRel, input.resultRel],
|
|
311
|
-
logTail: `zellij=${sessionName}`
|
|
312
|
-
});
|
|
313
|
-
const workerCommand = liveWorkerPane
|
|
314
|
-
? buildPaneWorkerCommand({
|
|
315
|
-
args: input.args,
|
|
316
|
-
stdoutPath: path.join(this.root, input.stdoutRel),
|
|
317
|
-
stderrPath: path.join(this.root, input.stderrRel),
|
|
318
|
-
heartbeatPath: path.join(this.root, input.heartbeatRel),
|
|
319
|
-
header: buildPaneWorkerHeader({
|
|
320
|
-
slotId,
|
|
321
|
-
generationIndex: Number(input.ctx.agent.generation_index || 1),
|
|
322
|
-
role,
|
|
323
|
-
backend: this.input.backend,
|
|
324
|
-
provider: providerContext.provider,
|
|
325
|
-
serviceTier: this.input.fastModePolicy.service_tier,
|
|
326
|
-
worktree,
|
|
327
|
-
task: input.ctx.slice?.description || input.ctx.slice?.title || input.ctx.slice?.id || ''
|
|
328
|
-
}),
|
|
329
|
-
env: {
|
|
330
|
-
...workerEnv,
|
|
331
|
-
SKS_ZELLIJ_WORKER_PANE: '1'
|
|
332
|
-
}
|
|
333
|
-
})
|
|
334
|
-
: buildZellijSlotPaneCommand({
|
|
335
|
-
cliPath: String(input.args[0] || ''),
|
|
336
|
-
missionId: this.input.missionId,
|
|
337
|
-
slotId,
|
|
338
|
-
generationIndex: Number(input.ctx.agent.generation_index || 1),
|
|
339
|
-
artifactDir: path.join(this.root, input.workerDirRel),
|
|
340
|
-
backend: this.input.backend,
|
|
341
|
-
role,
|
|
342
|
-
provider: providerContext.provider,
|
|
343
|
-
model: String(process.env.SKS_MODEL || process.env.OPENAI_MODEL || process.env.CODEX_MODEL || ''),
|
|
344
|
-
serviceTier: this.input.fastModePolicy.service_tier,
|
|
345
|
-
reasoningEffort: String(input.ctx.agent.model_reasoning_effort || input.ctx.agent.reasoning_effort || process.env.SKS_REASONING_EFFORT || ''),
|
|
346
|
-
currentTask: String(input.ctx.slice?.title || input.ctx.slice?.description || input.ctx.slice?.id || ''),
|
|
347
|
-
mode: uiMode,
|
|
348
|
-
watch: true
|
|
349
|
-
});
|
|
350
|
-
const processRun = liveWorkerPane
|
|
351
|
-
? null
|
|
352
|
-
: await this.spawnCompactSlotWorkerProcess({
|
|
353
|
-
args: input.args,
|
|
354
|
-
cwd: workerCwd,
|
|
355
|
-
env: workerEnv,
|
|
356
|
-
stdoutRel: input.stdoutRel,
|
|
357
|
-
stderrRel: input.stderrRel
|
|
358
|
-
});
|
|
359
|
-
let loopHandle = await registerLoopWorkerHandle({
|
|
360
|
-
root: input.ctx.opts.projectRoot || this.input.projectRoot || input.ctx.opts.cwd || packageRoot(),
|
|
361
|
-
env: input.ctx.opts.env || {},
|
|
362
|
-
agentId: String(input.ctx.agent.id || input.ctx.agent.session_id || 'agent'),
|
|
363
|
-
sessionId: input.ctx.agent.session_id || null,
|
|
364
|
-
pid: processRun?.pid || null
|
|
365
|
-
});
|
|
366
|
-
if (processRun?.pid) {
|
|
367
|
-
input.record.pid = processRun.pid;
|
|
368
|
-
input.record.process_id = processRun.pid;
|
|
369
|
-
await appendParallelRuntimeEvent(this.root, this.input.missionId, {
|
|
370
|
-
event_type: 'worker_process_spawned',
|
|
371
|
-
slot_id: slotId,
|
|
372
|
-
generation_index: Number(input.ctx.agent.generation_index || 1),
|
|
373
|
-
session_id: input.ctx.agent.session_id || null,
|
|
374
|
-
pid: processRun.pid,
|
|
375
|
-
backend: this.input.backend,
|
|
376
|
-
placement: 'headless_by_design_viewport_ui',
|
|
377
|
-
worktree_id: worktree?.id || null
|
|
378
|
-
}).catch(() => undefined);
|
|
379
|
-
await this.record(input.record);
|
|
380
|
-
}
|
|
381
|
-
const paneInput = {
|
|
382
|
-
root: this.root,
|
|
383
|
-
missionId: this.input.missionId,
|
|
384
|
-
sessionName,
|
|
385
|
-
slotId,
|
|
386
|
-
generationIndex: Number(input.ctx.agent.generation_index || 1),
|
|
387
|
-
sessionId: String(input.ctx.agent.session_id || ''),
|
|
388
|
-
workerArtifactDir: input.workerDirRel,
|
|
389
|
-
workerCommand,
|
|
390
|
-
resultPath: input.resultRel,
|
|
391
|
-
heartbeatPath: input.heartbeatRel,
|
|
392
|
-
patchEnvelopePath: input.record.patch_envelope_path,
|
|
393
|
-
stdoutLog: input.stdoutRel,
|
|
394
|
-
stderrLog: input.stderrRel,
|
|
395
|
-
cwd: workerCwd,
|
|
396
|
-
providerContext,
|
|
397
|
-
serviceTier: this.input.fastModePolicy.service_tier,
|
|
398
|
-
worktree: worktree ? { id: worktree.id, path: worktree.path, branch: worktree.branch } : null,
|
|
399
|
-
backend: this.input.backend,
|
|
400
|
-
taskTitle: String(input.ctx.slice?.title || input.ctx.slice?.description || input.ctx.slice?.id || '') || null,
|
|
401
|
-
uiMode,
|
|
402
|
-
projectRoot: input.ctx.opts.projectRoot || this.input.projectRoot || input.ctx.opts.cwd,
|
|
403
|
-
rightColumnMode: 'spawn-on-first-worker',
|
|
404
|
-
visiblePaneCap: this.zellijVisiblePaneCap(input.ctx.opts),
|
|
405
|
-
plannedAgentCount: this.input.targetActiveSlots
|
|
406
|
-
};
|
|
407
|
-
let paneRecord = await openHeadlessByDesignViewportWorker(paneInput);
|
|
408
|
-
const zellijRequired = process.env.SKS_REQUIRE_ZELLIJ === '1';
|
|
409
|
-
const launchBlockers = zellijRequired ? paneRecord.blockers || [] : [];
|
|
410
|
-
const launchWarnings = zellijRequired ? [] : paneRecord.blockers || [];
|
|
411
|
-
input.record.command_line = paneRecord.pane_id_source === 'headless_by_design_viewport_ui'
|
|
412
|
-
? ['node', '<native-cli-worker-command>', '# headless-by-design viewport UI']
|
|
413
|
-
: ['zellij', '--session', sessionName, 'action', 'new-pane', '--direction', paneRecord.direction_applied, '--name', paneRecord.pane_name, '--', 'sh', '-lc', liveWorkerPane ? '<native-cli-worker-command>' : '<zellij-slot-pane-renderer-command>'];
|
|
414
|
-
input.record.zellij_session_name = sessionName;
|
|
415
|
-
input.record.zellij_pane_id = paneRecord.pane_id || null;
|
|
416
|
-
input.record.zellij_pane_id_source = paneRecord.pane_id_source;
|
|
417
|
-
input.record.zellij_create_session = paneRecord.create_session;
|
|
418
|
-
input.record.zellij_launch = paneRecord.launch;
|
|
419
|
-
input.record.zellij_worker_pane = path.join(input.workerDirRel, 'zellij-worker-pane.json');
|
|
420
|
-
input.record.pane_kind = paneRecord.pane_kind;
|
|
421
|
-
input.record.scaling_primitive = paneRecord.scaling_primitive;
|
|
422
|
-
input.record.provider = paneRecord.provider;
|
|
423
|
-
input.record.service_tier = paneRecord.service_tier;
|
|
424
|
-
input.record.provider_context = paneRecord.provider_context;
|
|
425
|
-
input.record.worktree = worktree;
|
|
426
|
-
input.record.zellij_ui_mode = uiMode;
|
|
427
|
-
input.record.slot_visualization = liveWorkerPane ? 'worker-command-pane' : 'zellij-slot-pane-renderer';
|
|
428
|
-
if (paneRecord.pane_id_source === 'headless_by_design_viewport_ui') {
|
|
429
|
-
input.record.worker_placement = 'headless_by_design_viewport_ui';
|
|
430
|
-
input.record.slot_visualization = 'monitor-plus-viewport';
|
|
431
|
-
}
|
|
432
|
-
input.record.status = launchBlockers.length ? 'failed' : 'running';
|
|
433
|
-
input.record.blockers = launchBlockers;
|
|
434
|
-
input.record.warnings = [...(input.record.warnings || []), ...launchWarnings];
|
|
435
|
-
await this.telemetry(input.ctx, {
|
|
436
|
-
eventType: 'worker_spawned',
|
|
437
|
-
status: launchBlockers.length ? 'failed' : 'launching',
|
|
438
|
-
artifacts: [input.resultRel, input.heartbeatRel, input.stdoutRel, input.stderrRel, path.join(input.workerDirRel, 'zellij-worker-pane.json')],
|
|
439
|
-
blockers: launchBlockers,
|
|
440
|
-
logTail: paneRecord.pane_title || ''
|
|
441
|
-
});
|
|
442
|
-
await this.record(input.record);
|
|
443
|
-
if (launchBlockers.length) {
|
|
444
|
-
this.active.delete(activeToken);
|
|
445
|
-
input.record.closed_at = nowIso();
|
|
446
|
-
input.record.status = 'failed';
|
|
447
|
-
await this.telemetry(input.ctx, {
|
|
448
|
-
eventType: 'worker_failed',
|
|
449
|
-
status: 'failed',
|
|
450
|
-
artifacts: [input.stdoutRel, input.stderrRel, path.join(input.workerDirRel, 'zellij-worker-pane.json')],
|
|
451
|
-
blockers: launchBlockers,
|
|
452
|
-
logTail: 'Zellij worker pane launch failed.'
|
|
453
|
-
});
|
|
454
|
-
await this.record(input.record);
|
|
455
|
-
return validateAgentWorkerResult({
|
|
456
|
-
mission_id: this.input.missionId,
|
|
457
|
-
agent_id: input.ctx.agent.id,
|
|
458
|
-
session_id: input.ctx.agent.session_id,
|
|
459
|
-
persona_id: input.ctx.agent.persona_id || input.ctx.agent.id,
|
|
460
|
-
task_slice_id: input.ctx.slice?.id || '',
|
|
461
|
-
status: 'failed',
|
|
462
|
-
backend: this.input.backend,
|
|
463
|
-
summary: 'Zellij worker pane launch failed.',
|
|
464
|
-
artifacts: [input.stdoutRel, input.stderrRel, path.join(input.workerDirRel, 'zellij-worker-pane.json')],
|
|
465
|
-
blockers: launchBlockers,
|
|
466
|
-
unverified: [],
|
|
467
|
-
writes: [],
|
|
468
|
-
source_intelligence_refs: input.ctx.agent.source_intelligence_refs || null,
|
|
469
|
-
goal_mode_ref: input.ctx.agent.goal_mode_ref || null
|
|
470
|
-
});
|
|
471
|
-
}
|
|
472
|
-
const heartbeatSeen = await waitForWorkerHeartbeat(path.join(this.root, input.heartbeatRel), Number(process.env.SKS_ZELLIJ_WORKER_HEARTBEAT_TIMEOUT_MS || 5000));
|
|
473
|
-
if (heartbeatSeen) {
|
|
474
|
-
await this.telemetry(input.ctx, {
|
|
475
|
-
eventType: 'heartbeat',
|
|
476
|
-
status: 'running',
|
|
477
|
-
artifacts: [input.heartbeatRel],
|
|
478
|
-
logTail: await tailFile(path.join(this.root, input.heartbeatRel), 600)
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
else {
|
|
482
|
-
input.record.warnings = [...(input.record.warnings || []), 'zellij_worker_heartbeat_missing_launch_warning'];
|
|
483
|
-
}
|
|
484
|
-
await appendJsonl(path.join(this.root, input.workerDirRel, 'zellij-worker-pane-events.jsonl'), {
|
|
485
|
-
schema: 'sks.zellij-worker-pane-event.v1',
|
|
486
|
-
ts: nowIso(),
|
|
487
|
-
event_type: 'worker_started',
|
|
488
|
-
mission_id: this.input.missionId,
|
|
489
|
-
slot_id: slotId,
|
|
490
|
-
generation_index: input.ctx.agent.generation_index || null,
|
|
491
|
-
session_id: input.ctx.agent.session_id,
|
|
492
|
-
worker_artifact_dir: input.workerDirRel
|
|
493
|
-
});
|
|
494
|
-
const parsed = await this.waitForWorkerResultWithActivity({
|
|
495
|
-
resultPath: path.join(this.root, input.resultRel),
|
|
496
|
-
activityPaths: [
|
|
497
|
-
path.join(this.root, input.heartbeatRel),
|
|
498
|
-
path.join(this.root, input.stdoutRel),
|
|
499
|
-
path.join(this.root, input.stderrRel),
|
|
500
|
-
path.join(this.root, input.workerDirRel, 'codex-sdk-events.jsonl'),
|
|
501
|
-
path.join(this.root, input.workerDirRel, 'python-codex-sdk-events.jsonl'),
|
|
502
|
-
path.join(this.root, input.workerDirRel, 'local-llm-events.jsonl')
|
|
503
|
-
],
|
|
504
|
-
stdoutPath: path.join(this.root, input.stdoutRel),
|
|
505
|
-
ctx: input.ctx,
|
|
506
|
-
heartbeatRel: input.heartbeatRel,
|
|
507
|
-
resultRel: input.resultRel,
|
|
508
|
-
stdoutRel: input.stdoutRel,
|
|
509
|
-
stderrRel: input.stderrRel
|
|
510
|
-
});
|
|
511
|
-
const compactExit = processRun ? await processRun.wait(parsed ? 10000 : 1000) : null;
|
|
512
|
-
this.active.delete(activeToken);
|
|
513
|
-
input.record.closed_at = nowIso();
|
|
514
|
-
const workerProcessReport = await readJson(path.join(this.root, input.workerDirRel, 'worker-process-report.json'), null).catch(() => null);
|
|
515
|
-
const sdkThreadId = workerProcessReport?.sdk_thread_id || workerProcessReport?.backend_router_report?.sdk_thread_id || parsed?.codex_sdk_thread?.sdk_thread_id || parsed?.codex_child_report?.sdk_thread_id || null;
|
|
516
|
-
const sdkRunId = workerProcessReport?.sdk_run_id || workerProcessReport?.backend_router_report?.sdk_run_id || parsed?.codex_sdk_thread?.sdk_run_id || parsed?.codex_child_report?.sdk_run_id || null;
|
|
517
|
-
if ((workerProcessReport?.backend_child_process_ids || []).length || sdkThreadId) {
|
|
518
|
-
await appendJsonl(path.join(this.root, input.workerDirRel, 'zellij-worker-pane-events.jsonl'), {
|
|
519
|
-
schema: 'sks.zellij-worker-pane-event.v1',
|
|
520
|
-
ts: nowIso(),
|
|
521
|
-
event_type: 'codex_sdk_thread_started',
|
|
522
|
-
mission_id: this.input.missionId,
|
|
523
|
-
slot_id: slotId,
|
|
524
|
-
generation_index: input.ctx.agent.generation_index || null,
|
|
525
|
-
session_id: input.ctx.agent.session_id,
|
|
526
|
-
child_process_ids: workerProcessReport?.backend_child_process_ids || [],
|
|
527
|
-
sdk_thread_id: sdkThreadId,
|
|
528
|
-
sdk_run_id: sdkRunId
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
if (parsed) {
|
|
532
|
-
await appendJsonl(path.join(this.root, input.workerDirRel, 'zellij-worker-pane-events.jsonl'), {
|
|
533
|
-
schema: 'sks.zellij-worker-pane-event.v1',
|
|
534
|
-
ts: nowIso(),
|
|
535
|
-
event_type: 'result_written',
|
|
536
|
-
mission_id: this.input.missionId,
|
|
537
|
-
slot_id: slotId,
|
|
538
|
-
generation_index: input.ctx.agent.generation_index || null,
|
|
539
|
-
session_id: input.ctx.agent.session_id,
|
|
540
|
-
result_path: input.resultRel
|
|
541
|
-
});
|
|
542
|
-
await this.telemetry(input.ctx, {
|
|
543
|
-
eventType: 'artifact_written',
|
|
544
|
-
status: 'verifying',
|
|
545
|
-
artifacts: [input.resultRel],
|
|
546
|
-
logTail: parsed.summary || 'worker result written'
|
|
547
|
-
});
|
|
548
|
-
}
|
|
549
|
-
input.record.pid = Number(workerProcessReport?.pid || processRun?.pid) || null;
|
|
550
|
-
input.record.process_id = input.record.pid;
|
|
551
|
-
if (!loopHandle && input.record.pid) {
|
|
552
|
-
loopHandle = await registerLoopWorkerHandle({
|
|
553
|
-
root: input.ctx.opts.projectRoot || this.input.projectRoot || input.ctx.opts.cwd || packageRoot(),
|
|
554
|
-
env: input.ctx.opts.env || {},
|
|
555
|
-
agentId: String(input.ctx.agent.id || input.ctx.agent.session_id || 'agent'),
|
|
556
|
-
sessionId: input.ctx.agent.session_id || null,
|
|
557
|
-
pid: input.record.pid
|
|
558
|
-
});
|
|
559
|
-
}
|
|
560
|
-
input.record.compact_worker_exit_code = compactExit?.code ?? null;
|
|
561
|
-
input.record.compact_worker_signal = compactExit?.signal ?? null;
|
|
562
|
-
input.record.sdk_thread_id = sdkThreadId;
|
|
563
|
-
input.record.sdk_run_id = sdkRunId;
|
|
564
|
-
input.record.stream_event_count = Number(workerProcessReport?.stream_event_count || workerProcessReport?.backend_router_report?.stream_event_count || 0);
|
|
565
|
-
input.record.structured_output_valid = workerProcessReport?.structured_output_valid === true || workerProcessReport?.backend_router_report?.structured_output_valid === true;
|
|
566
|
-
input.record.exit_code = parsed ? (parsed.status === 'done' ? 0 : 1) : 1;
|
|
567
|
-
input.record.status = parsed?.status === 'done' ? 'closed' : 'failed';
|
|
568
|
-
if (loopHandle) {
|
|
569
|
-
await markLoopWorkerInterrupted(input.ctx.opts.projectRoot || this.input.projectRoot || input.ctx.opts.cwd || packageRoot(), loopHandle.mission_id, loopHandle.worker_id, input.record.status === 'closed' ? 'completed' : 'failed').catch(() => undefined);
|
|
570
|
-
}
|
|
571
|
-
const heartbeatOk = await hasHeartbeat(path.join(this.root, input.heartbeatRel));
|
|
572
|
-
input.record.blockers = [
|
|
573
|
-
...(parsed ? parsed.blockers || [] : ['zellij_worker_result_timeout']),
|
|
574
|
-
...(heartbeatOk ? [] : [])
|
|
575
|
-
];
|
|
576
|
-
if (!heartbeatOk)
|
|
577
|
-
input.record.warnings = [...(input.record.warnings || []), 'zellij_worker_heartbeat_missing'];
|
|
578
|
-
paneRecord = await closeWorkerPane({
|
|
579
|
-
root: this.root,
|
|
580
|
-
paneRecord,
|
|
581
|
-
cwd: workerCwd,
|
|
582
|
-
projectRoot: input.ctx.opts.projectRoot || this.input.projectRoot || input.ctx.opts.cwd,
|
|
583
|
-
status: input.record.status === 'closed' ? 'closed' : 'failed',
|
|
584
|
-
blockers: input.record.blockers,
|
|
585
|
-
sdkThreadId,
|
|
586
|
-
sdkRunId,
|
|
587
|
-
streamEventCount: input.record.stream_event_count,
|
|
588
|
-
structuredOutputValid: input.record.structured_output_valid,
|
|
589
|
-
workerResultPath: input.resultRel
|
|
590
|
-
});
|
|
591
|
-
input.record.zellij_worker_pane_closed_at = paneRecord.closed_at;
|
|
592
|
-
await this.record(input.record);
|
|
593
|
-
if (!parsed) {
|
|
594
|
-
await this.telemetry(input.ctx, {
|
|
595
|
-
eventType: 'worker_failed',
|
|
596
|
-
status: 'failed',
|
|
597
|
-
artifacts: [input.stdoutRel, input.stderrRel, path.join(input.workerDirRel, 'zellij-worker-pane.json')],
|
|
598
|
-
blockers: input.record.blockers,
|
|
599
|
-
logTail: 'Zellij pane worker result timed out.'
|
|
600
|
-
});
|
|
601
|
-
return validateAgentWorkerResult({
|
|
602
|
-
mission_id: this.input.missionId,
|
|
603
|
-
agent_id: input.ctx.agent.id,
|
|
604
|
-
session_id: input.ctx.agent.session_id,
|
|
605
|
-
persona_id: input.ctx.agent.persona_id || input.ctx.agent.id,
|
|
606
|
-
task_slice_id: input.ctx.slice?.id || '',
|
|
607
|
-
status: 'failed',
|
|
608
|
-
backend: this.input.backend,
|
|
609
|
-
summary: 'Zellij pane worker result timed out.',
|
|
610
|
-
artifacts: [input.stdoutRel, input.stderrRel, path.join(input.workerDirRel, 'zellij-worker-pane.json')],
|
|
611
|
-
blockers: input.record.blockers,
|
|
612
|
-
unverified: [],
|
|
613
|
-
writes: [],
|
|
614
|
-
source_intelligence_refs: input.ctx.agent.source_intelligence_refs || null,
|
|
615
|
-
goal_mode_ref: input.ctx.agent.goal_mode_ref || null
|
|
616
|
-
});
|
|
617
|
-
}
|
|
618
|
-
await this.telemetry(input.ctx, {
|
|
619
|
-
eventType: parsed.status === 'done' ? 'worker_completed' : 'worker_failed',
|
|
620
|
-
status: parsed.status === 'done' ? 'completed' : 'failed',
|
|
621
|
-
artifacts: [...new Set([...(Array.isArray(parsed.artifacts) ? parsed.artifacts : []), input.stdoutRel, input.stderrRel, path.join(input.workerDirRel, 'zellij-worker-pane.json')])],
|
|
622
|
-
blockers: input.record.blockers,
|
|
623
|
-
changedFiles: changedFilesFromWorkerResult(parsed),
|
|
624
|
-
logTail: parsed.summary || ''
|
|
625
|
-
});
|
|
626
|
-
return validateAgentWorkerResult({
|
|
627
|
-
...parsed,
|
|
628
|
-
blockers: input.record.blockers,
|
|
629
|
-
artifacts: [...new Set([...(Array.isArray(parsed.artifacts) ? parsed.artifacts : []), input.stdoutRel, input.stderrRel, path.join(input.workerDirRel, 'zellij-worker-pane.json')])]
|
|
630
|
-
});
|
|
631
|
-
}
|
|
632
|
-
async waitForWorkerResultWithActivity(input) {
|
|
633
|
-
const inactivityTimeoutMs = Math.max(1000, Number(process.env.SKS_ZELLIJ_WORKER_INACTIVITY_TIMEOUT_MS || 300000));
|
|
634
|
-
const absoluteCapRaw = Number(process.env.SKS_ZELLIJ_WORKER_RESULT_TIMEOUT_MS ?? 3600000);
|
|
635
|
-
const absoluteCapMs = Number.isFinite(absoluteCapRaw) ? absoluteCapRaw : 3600000;
|
|
636
|
-
const start = Date.now();
|
|
637
|
-
let lastActivityMs = start;
|
|
638
|
-
let lastHeartbeatEmit = 0;
|
|
639
|
-
for (;;) {
|
|
640
|
-
const result = await readJson(input.resultPath, null).catch(() => null);
|
|
641
|
-
if (result)
|
|
642
|
-
return result;
|
|
643
|
-
const now = Date.now();
|
|
644
|
-
const newestActivity = await newestMtimeMs(input.activityPaths);
|
|
645
|
-
if (newestActivity != null && newestActivity > lastActivityMs)
|
|
646
|
-
lastActivityMs = newestActivity;
|
|
647
|
-
if (absoluteCapMs > 0 && now - start >= absoluteCapMs)
|
|
648
|
-
return null;
|
|
649
|
-
if (now - lastActivityMs >= inactivityTimeoutMs)
|
|
650
|
-
return null;
|
|
651
|
-
if (now - lastHeartbeatEmit >= 10000) {
|
|
652
|
-
lastHeartbeatEmit = now;
|
|
653
|
-
await this.telemetry(input.ctx, {
|
|
654
|
-
eventType: 'heartbeat',
|
|
655
|
-
status: 'running',
|
|
656
|
-
artifacts: [input.heartbeatRel, input.resultRel, input.stdoutRel, input.stderrRel],
|
|
657
|
-
logTail: await tailFile(input.stdoutPath, 600)
|
|
658
|
-
});
|
|
659
|
-
}
|
|
660
|
-
await new Promise((resolve) => setTimeout(resolve, 250));
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
221
|
async finalize() {
|
|
664
222
|
await this.persist();
|
|
665
223
|
return this.summary();
|
|
@@ -672,27 +230,7 @@ class NativeCliWorkerRuntimeRecorder {
|
|
|
672
230
|
this.records.push(record);
|
|
673
231
|
await this.persist();
|
|
674
232
|
}
|
|
675
|
-
async
|
|
676
|
-
await appendZellijSlotTelemetry(this.root, {
|
|
677
|
-
schema: 'sks.zellij-slot-telemetry-event.v1',
|
|
678
|
-
ts: nowIso(),
|
|
679
|
-
mission_id: this.input.missionId,
|
|
680
|
-
slot_id: String(ctx.agent?.slot_id || ctx.agent?.id || 'slot-001'),
|
|
681
|
-
generation_index: Number(ctx.agent?.generation_index || 1),
|
|
682
|
-
worker_id: String(ctx.agent?.id || ctx.agent?.slot_id || 'worker'),
|
|
683
|
-
event_type: input.eventType,
|
|
684
|
-
status: input.status,
|
|
685
|
-
role: String(ctx.agent?.naruto_role || ctx.agent?.role || ctx.agent?.persona_id || ctx.agent?.id || 'worker'),
|
|
686
|
-
backend: this.input.backend,
|
|
687
|
-
service_tier: this.input.fastModePolicy.service_tier,
|
|
688
|
-
worktree_id: ctx.agent?.worktree?.id || ctx.slice?.worktree?.id || null,
|
|
689
|
-
worktree_path: ctx.agent?.worktree?.path || ctx.slice?.worktree?.path || null,
|
|
690
|
-
task_title: String(ctx.slice?.description || ctx.slice?.title || ctx.slice?.id || 'worker task'),
|
|
691
|
-
current_file: firstString([ctx.slice?.write_paths?.[0], ctx.slice?.readonly_paths?.[0], ctx.slice?.input_files?.[0]]) || null,
|
|
692
|
-
artifact_paths: input.artifacts || [],
|
|
693
|
-
log_tail: input.logTail || '',
|
|
694
|
-
blockers: input.blockers || []
|
|
695
|
-
}).catch(() => undefined);
|
|
233
|
+
async lifecycle(ctx, input) {
|
|
696
234
|
if (input.eventType === 'worker_completed' || input.eventType === 'worker_failed') {
|
|
697
235
|
await appendAgentMessage(this.root, {
|
|
698
236
|
from: String(ctx.agent?.slot_id || ctx.agent?.id || 'worker'),
|
|
@@ -702,25 +240,25 @@ class NativeCliWorkerRuntimeRecorder {
|
|
|
702
240
|
body: input.logTail || input.eventType
|
|
703
241
|
}).catch(() => undefined);
|
|
704
242
|
}
|
|
705
|
-
const parallelEvent =
|
|
706
|
-
if (parallelEvent)
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
}
|
|
723
|
-
}
|
|
243
|
+
const parallelEvent = mapLifecycleToParallelEvent(input.eventType);
|
|
244
|
+
if (!parallelEvent)
|
|
245
|
+
return;
|
|
246
|
+
await appendParallelRuntimeEvent(this.root, this.input.missionId, {
|
|
247
|
+
event_type: parallelEvent,
|
|
248
|
+
slot_id: String(ctx.agent?.slot_id || ctx.agent?.id || 'slot-001'),
|
|
249
|
+
generation_index: Number(ctx.agent?.generation_index || 1),
|
|
250
|
+
session_id: ctx.agent?.session_id == null ? null : String(ctx.agent.session_id),
|
|
251
|
+
pid: null,
|
|
252
|
+
backend: this.input.backend,
|
|
253
|
+
placement: 'process',
|
|
254
|
+
worktree_id: ctx.agent?.worktree?.id || ctx.slice?.worktree?.id || null,
|
|
255
|
+
meta: {
|
|
256
|
+
status: input.status,
|
|
257
|
+
artifacts: input.artifacts || [],
|
|
258
|
+
changed_files: input.changedFiles || [],
|
|
259
|
+
blockers: input.blockers || []
|
|
260
|
+
}
|
|
261
|
+
}).catch(() => undefined);
|
|
724
262
|
}
|
|
725
263
|
async persist() {
|
|
726
264
|
this.writeLock = this.writeLock.catch(() => undefined).then(async () => {
|
|
@@ -730,9 +268,6 @@ class NativeCliWorkerRuntimeRecorder {
|
|
|
730
268
|
}
|
|
731
269
|
summary() {
|
|
732
270
|
const closed = this.records.filter((row) => row.status === 'closed');
|
|
733
|
-
const processIds = this.records.map((row) => row.pid).filter((pid) => Number.isFinite(Number(pid)));
|
|
734
|
-
const paneBackedRecords = this.records.filter((row) => row.scaling_primitive === 'native_cli_process_in_zellij_worker_pane'
|
|
735
|
-
|| row.scaling_primitive === 'native_cli_process_with_zellij_slot_renderer');
|
|
736
271
|
return {
|
|
737
272
|
schema: NATIVE_CLI_WORKER_RUNTIME_SCHEMA,
|
|
738
273
|
generated_at: nowIso(),
|
|
@@ -740,24 +275,17 @@ class NativeCliWorkerRuntimeRecorder {
|
|
|
740
275
|
mission_id: this.input.missionId,
|
|
741
276
|
route: this.input.route,
|
|
742
277
|
backend: this.input.backend,
|
|
743
|
-
scaling_primitive:
|
|
744
|
-
? 'native_cli_process_in_zellij_worker_pane'
|
|
745
|
-
: paneBackedRecords.length
|
|
746
|
-
? 'native_cli_process_with_zellij_slot_renderer'
|
|
747
|
-
: 'native_cli_process',
|
|
748
|
-
zellij_pane_worker_sessions: paneBackedRecords.length,
|
|
278
|
+
scaling_primitive: 'native_cli_process',
|
|
749
279
|
requested_agents: this.input.requestedAgents,
|
|
750
280
|
target_active_slots: this.input.targetActiveSlots,
|
|
751
281
|
spawned_worker_process_count: this.records.length,
|
|
752
282
|
closed_worker_process_count: closed.length,
|
|
753
283
|
max_observed_worker_process_count: this.maxObserved,
|
|
754
284
|
active_worker_process_count: this.active.size,
|
|
755
|
-
visible_zellij_pane_cap: this.input.zellijVisiblePaneCap || null,
|
|
756
|
-
headless_overflow_worker_count: this.records.filter((row) => row.worker_placement === 'headless').length,
|
|
757
285
|
unique_worker_session_count: new Set(this.records.map((row) => row.session_id).filter(Boolean)).size,
|
|
758
286
|
unique_slot_count: new Set(this.records.map((row) => row.slot_id).filter(Boolean)).size,
|
|
759
287
|
unique_generation_count: new Set(this.records.map((row) => `${row.slot_id}:${row.generation_index}`).filter(Boolean)).size,
|
|
760
|
-
process_ids:
|
|
288
|
+
process_ids: this.records.map((row) => row.pid).filter((pid) => Number.isFinite(Number(pid))),
|
|
761
289
|
worker_command_lines: this.records.map((row) => row.command_line),
|
|
762
290
|
stdout_logs: this.records.map((row) => row.stdout_log),
|
|
763
291
|
stderr_logs: this.records.map((row) => row.stderr_log),
|
|
@@ -768,96 +296,30 @@ class NativeCliWorkerRuntimeRecorder {
|
|
|
768
296
|
blockers: this.records.flatMap((row) => row.blockers || [])
|
|
769
297
|
};
|
|
770
298
|
}
|
|
771
|
-
zellijVisiblePaneCap(opts = {}) {
|
|
772
|
-
const raw = Number(opts.zellijVisiblePaneCap || this.input.zellijVisiblePaneCap || this.input.targetActiveSlots || 1);
|
|
773
|
-
return Math.max(1, Math.floor(Number.isFinite(raw) ? raw : 1));
|
|
774
|
-
}
|
|
775
|
-
async spawnCompactSlotWorkerProcess(input) {
|
|
776
|
-
const stdout = fs.createWriteStream(path.join(this.root, input.stdoutRel), { flags: 'a' });
|
|
777
|
-
const stderr = fs.createWriteStream(path.join(this.root, input.stderrRel), { flags: 'a' });
|
|
778
|
-
const child = spawn(process.execPath, input.args, {
|
|
779
|
-
cwd: input.cwd,
|
|
780
|
-
env: {
|
|
781
|
-
...process.env,
|
|
782
|
-
...Object.fromEntries(Object.entries(input.env).filter(([, value]) => value != null).map(([key, value]) => [key, String(value)]))
|
|
783
|
-
},
|
|
784
|
-
stdio: ['ignore', 'pipe', 'pipe']
|
|
785
|
-
});
|
|
786
|
-
child.stdout?.pipe(stdout);
|
|
787
|
-
child.stderr?.pipe(stderr);
|
|
788
|
-
const exitPromise = new Promise((resolve) => {
|
|
789
|
-
child.on('close', (code, signal) => {
|
|
790
|
-
stdout.end();
|
|
791
|
-
stderr.end();
|
|
792
|
-
resolve({ code, signal });
|
|
793
|
-
});
|
|
794
|
-
child.on('error', () => {
|
|
795
|
-
stdout.end();
|
|
796
|
-
stderr.end();
|
|
797
|
-
resolve({ code: 1, signal: null });
|
|
798
|
-
});
|
|
799
|
-
});
|
|
800
|
-
return {
|
|
801
|
-
pid: child.pid || null,
|
|
802
|
-
wait: async (timeoutMs) => waitForChildExit(child, exitPromise, timeoutMs)
|
|
803
|
-
};
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
export function buildPaneWorkerCommand(input) {
|
|
807
|
-
const envPrefix = Object.entries(input.env)
|
|
808
|
-
.filter(([key, value]) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(key) && value != null)
|
|
809
|
-
.map(([key, value]) => `export ${key}=${shellQuote(String(value))};`)
|
|
810
|
-
.sort();
|
|
811
|
-
const command = [shellQuote(process.execPath), ...input.args.map(shellQuote)].join(' ');
|
|
812
|
-
const heartbeat = `printf '%s\\n' ${shellQuote(JSON.stringify({ schema: 'sks.zellij-worker-pane-event.v1', event: 'worker_command_exited' }))} >> ${shellQuote(input.heartbeatPath)}`;
|
|
813
|
-
const holdMs = Math.max(0, Number(process.env.SKS_ZELLIJ_WORKER_PANE_HOLD_MS || 1500));
|
|
814
|
-
const hold = holdMs > 0 ? `sleep ${shellQuote(String(Math.min(30, holdMs / 1000)))}` : ':';
|
|
815
|
-
const header = input.header ? `printf '%s\\n' ${shellQuote(input.header)} | tee -a ${shellQuote(input.stdoutPath)};` : '';
|
|
816
|
-
const exitPath = `${input.heartbeatPath}.exit`;
|
|
817
|
-
const visibleCommand = `(${command}; printf '%s' "$?" > ${shellQuote(exitPath)}) 2>&1 | tee -a ${shellQuote(input.stdoutPath)}`;
|
|
818
|
-
const readExit = `code=$(cat ${shellQuote(exitPath)} 2>/dev/null || printf '1'); rm -f ${shellQuote(exitPath)}`;
|
|
819
|
-
return `${envPrefix.join(' ')} ${header} ${visibleCommand}; ${readExit}; ${heartbeat}; ${hold}; exit $code`.trim();
|
|
820
|
-
}
|
|
821
|
-
function buildPaneWorkerHeader(input) {
|
|
822
|
-
return [
|
|
823
|
-
'SKS Worker',
|
|
824
|
-
`slot: ${input.slotId} gen: ${input.generationIndex} role: ${input.role}`,
|
|
825
|
-
`backend: ${input.backend} provider: ${input.provider} service: ${input.serviceTier}`,
|
|
826
|
-
`worktree: ${input.worktree ? `${input.worktree.id} branch: ${input.worktree.branch}` : '-'}`,
|
|
827
|
-
`task: ${String(input.task || '').slice(0, 160)}`,
|
|
828
|
-
'status: running'
|
|
829
|
-
].join('\n');
|
|
830
|
-
}
|
|
831
|
-
async function newestMtimeMs(files) {
|
|
832
|
-
let newest = null;
|
|
833
|
-
for (const file of files) {
|
|
834
|
-
try {
|
|
835
|
-
const mtime = (await fs.promises.stat(file)).mtimeMs;
|
|
836
|
-
if (newest == null || mtime > newest)
|
|
837
|
-
newest = mtime;
|
|
838
|
-
}
|
|
839
|
-
catch {
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
return newest;
|
|
843
|
-
}
|
|
844
|
-
async function waitForWorkerHeartbeat(file, timeoutMs) {
|
|
845
|
-
const deadline = Date.now() + Math.max(1000, timeoutMs);
|
|
846
|
-
while (Date.now() < deadline) {
|
|
847
|
-
if (await hasHeartbeat(file))
|
|
848
|
-
return true;
|
|
849
|
-
await new Promise((resolve) => setTimeout(resolve, 250));
|
|
850
|
-
}
|
|
851
|
-
return false;
|
|
852
299
|
}
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
300
|
+
function terminateChildOnAbort(child, signal) {
|
|
301
|
+
if (!signal)
|
|
302
|
+
return () => undefined;
|
|
303
|
+
let hardKillTimer = null;
|
|
304
|
+
const terminate = () => {
|
|
305
|
+
if (child.exitCode !== null || child.signalCode !== null)
|
|
306
|
+
return;
|
|
307
|
+
child.kill('SIGTERM');
|
|
308
|
+
hardKillTimer = setTimeout(() => {
|
|
309
|
+
if (child.exitCode === null && child.signalCode === null)
|
|
310
|
+
child.kill('SIGKILL');
|
|
311
|
+
}, 1500);
|
|
312
|
+
hardKillTimer.unref?.();
|
|
313
|
+
};
|
|
314
|
+
if (signal.aborted)
|
|
315
|
+
terminate();
|
|
316
|
+
else
|
|
317
|
+
signal.addEventListener('abort', terminate, { once: true });
|
|
318
|
+
return () => {
|
|
319
|
+
signal.removeEventListener('abort', terminate);
|
|
320
|
+
if (hardKillTimer)
|
|
321
|
+
clearTimeout(hardKillTimer);
|
|
322
|
+
};
|
|
861
323
|
}
|
|
862
324
|
async function resolveWorkerEntrypointPath() {
|
|
863
325
|
const distEntrypoint = path.join(packageRoot(), 'dist', 'core', 'agents', 'native-cli-worker-entry.js');
|
|
@@ -868,9 +330,6 @@ async function resolveWorkerEntrypointPath() {
|
|
|
868
330
|
function redactWorkerArgs(args) {
|
|
869
331
|
return args.map((arg, index) => index > 0 && args[index - 1] === '--intake' ? '<worker-intake.json>' : arg);
|
|
870
332
|
}
|
|
871
|
-
function shellQuote(value) {
|
|
872
|
-
return `'${String(value).replace(/'/g, `'\\''`)}'`;
|
|
873
|
-
}
|
|
874
333
|
function normalizeWorkerWorktree(value) {
|
|
875
334
|
const pathValue = value?.path || value?.worktree_path;
|
|
876
335
|
if (!pathValue)
|
|
@@ -882,15 +341,7 @@ function normalizeWorkerWorktree(value) {
|
|
|
882
341
|
main_repo_root: value?.main_repo_root == null ? null : String(value.main_repo_root)
|
|
883
342
|
};
|
|
884
343
|
}
|
|
885
|
-
function
|
|
886
|
-
for (const value of values) {
|
|
887
|
-
const text = String(value || '').trim();
|
|
888
|
-
if (text)
|
|
889
|
-
return text;
|
|
890
|
-
}
|
|
891
|
-
return null;
|
|
892
|
-
}
|
|
893
|
-
function mapTelemetryToParallelEvent(eventType) {
|
|
344
|
+
function mapLifecycleToParallelEvent(eventType) {
|
|
894
345
|
if (eventType === 'slot_reserved')
|
|
895
346
|
return 'slot_reserved';
|
|
896
347
|
if (eventType === 'heartbeat')
|
|
@@ -911,12 +362,6 @@ function changedFilesFromWorkerResult(result) {
|
|
|
911
362
|
]);
|
|
912
363
|
return [...new Set([...direct, ...envelopeFiles].map((file) => String(file || '').replace(/\\/g, '/').replace(/^\.\/+/, '')).filter(Boolean))];
|
|
913
364
|
}
|
|
914
|
-
function normalizeParallelPlacement(value) {
|
|
915
|
-
const text = String(value || '');
|
|
916
|
-
if (text === 'zellij-pane' || text === 'process' || text === 'headless' || text === 'headless_by_design_viewport_ui')
|
|
917
|
-
return text;
|
|
918
|
-
return 'unknown';
|
|
919
|
-
}
|
|
920
365
|
async function registerLoopWorkerHandle(input) {
|
|
921
366
|
const missionId = String(input.env.SKS_MISSION_ID || input.env.SKS_PARENT_MISSION_ID || '').trim();
|
|
922
367
|
const loopId = String(input.env.SKS_LOOP_ID || '').trim();
|
|
@@ -933,26 +378,3 @@ async function registerLoopWorkerHandle(input) {
|
|
|
933
378
|
interrupt_supported: Boolean(input.pid || input.sessionId)
|
|
934
379
|
}).catch(() => null);
|
|
935
380
|
}
|
|
936
|
-
async function tailFile(file, max) {
|
|
937
|
-
try {
|
|
938
|
-
const text = await fs.promises.readFile(file, 'utf8');
|
|
939
|
-
return text.length > max ? text.slice(-max) : text;
|
|
940
|
-
}
|
|
941
|
-
catch {
|
|
942
|
-
return '';
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
async function waitForChildExit(child, exitPromise, timeoutMs) {
|
|
946
|
-
let timer = null;
|
|
947
|
-
const timeout = new Promise((resolve) => {
|
|
948
|
-
timer = setTimeout(() => {
|
|
949
|
-
if (!child.killed)
|
|
950
|
-
child.kill();
|
|
951
|
-
resolve({ code: null, signal: 'SIGTERM' });
|
|
952
|
-
}, Math.max(1000, timeoutMs));
|
|
953
|
-
});
|
|
954
|
-
const result = await Promise.race([exitPromise, timeout]);
|
|
955
|
-
if (timer)
|
|
956
|
-
clearTimeout(timer);
|
|
957
|
-
return result;
|
|
958
|
-
}
|