sneakoscope 6.0.3 → 6.1.2

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.
Files changed (378) hide show
  1. package/README.md +29 -12
  2. package/config/codex-releases/{rust-v0.142.0.json → rust-v0.144.1.json} +6 -6
  3. package/crates/sks-core/Cargo.lock +1 -1
  4. package/crates/sks-core/Cargo.toml +1 -1
  5. package/dist/bin/fast-inline.js +18 -14
  6. package/dist/bin/sks-dispatch.js +2 -4
  7. package/dist/cli/args.js +2 -0
  8. package/dist/cli/command-manifest-lite.js +2 -3
  9. package/dist/cli/command-registry.js +3 -4
  10. package/dist/cli/help-fast.js +1 -1
  11. package/dist/cli/install-helpers.js +348 -763
  12. package/dist/cli/install-tool-helpers.js +287 -0
  13. package/dist/cli/router.js +91 -6
  14. package/dist/commands/codex-lb.js +188 -53
  15. package/dist/commands/codex.js +44 -5
  16. package/dist/commands/doctor.js +302 -46
  17. package/dist/commands/tmux.js +5 -1
  18. package/dist/commands/versioning.js +7 -0
  19. package/dist/commands/zellij-monitor-pane.js +2 -0
  20. package/dist/commands/zellij-viewport-pane.js +3 -1
  21. package/dist/commands/zellij.js +1 -1
  22. package/dist/config/skills-manifest.json +59 -59
  23. package/dist/core/agent-bridge/agent-manifest.js +48 -0
  24. package/dist/core/agents/agent-central-ledger.js +9 -0
  25. package/dist/core/agents/agent-cleanup-executor.js +334 -41
  26. package/dist/core/agents/agent-cleanup.js +20 -1
  27. package/dist/core/agents/agent-command-surface.js +3 -1
  28. package/dist/core/agents/agent-effort-policy.js +30 -38
  29. package/dist/core/agents/agent-janitor.js +9 -10
  30. package/dist/core/agents/agent-namespace-safety.js +56 -0
  31. package/dist/core/agents/agent-orchestrator.js +25 -3
  32. package/dist/core/agents/agent-output-validator.js +1 -1
  33. package/dist/core/agents/agent-plan.js +100 -21
  34. package/dist/core/agents/agent-role-config.js +43 -49
  35. package/dist/core/agents/agent-runner-codex-exec.js +18 -3
  36. package/dist/core/agents/agent-runner-process.js +1 -0
  37. package/dist/core/agents/agent-schema.js +3 -2
  38. package/dist/core/agents/fast-mode-policy.js +3 -5
  39. package/dist/core/agents/native-cli-session-swarm.js +1 -1
  40. package/dist/core/agents/native-worker-backend-router.js +2 -1
  41. package/dist/core/agents/work-partition/repo-inventory.js +68 -7
  42. package/dist/core/agents/zellij-right-lane-cockpit.js +2 -2
  43. package/dist/core/code-structure.js +5 -4
  44. package/dist/core/codex/agent-config-file-repair.js +94 -193
  45. package/dist/core/codex/codex-cli-update.js +723 -0
  46. package/dist/core/codex/codex-config-guard.js +38 -11
  47. package/dist/core/codex/codex-project-config-policy.js +3 -6
  48. package/dist/core/codex/codex-startup-config-postcheck.js +52 -42
  49. package/dist/core/codex-adapter.js +35 -22
  50. package/dist/core/codex-app/codex-agent-role-sync.js +13 -54
  51. package/dist/core/codex-app/codex-app-fast-ui-repair.js +51 -20
  52. package/dist/core/codex-app/codex-app-launcher.js +48 -17
  53. package/dist/core/codex-app/codex-app-restart.js +23 -2
  54. package/dist/core/codex-app/codex-app-ui-state-snapshot.js +11 -3
  55. package/dist/core/codex-app/sks-menubar.js +136 -5
  56. package/dist/core/codex-app.js +35 -14
  57. package/dist/core/codex-compat/codex-hook-warning-detector.js +10 -1
  58. package/dist/core/codex-compat/codex-release-manifest.js +6 -6
  59. package/dist/core/codex-control/codex-0139-doctor-real-probe.js +7 -1
  60. package/dist/core/codex-control/codex-0139-image-path-real-probe.js +29 -12
  61. package/dist/core/codex-control/codex-0139-probe-runner.js +103 -28
  62. package/dist/core/codex-control/codex-0139-real-probe-summary.js +7 -3
  63. package/dist/core/codex-control/codex-0139-real-probes.js +21 -6
  64. package/dist/core/codex-control/codex-0139-sandbox-real-probe.js +39 -13
  65. package/dist/core/codex-control/codex-0139-web-search-probe.js +28 -14
  66. package/dist/core/codex-control/{codex-0142-capability.js → codex-0144-capability.js} +22 -22
  67. package/dist/core/codex-control/codex-0144-collab-agent-real-probe.js +63 -0
  68. package/dist/core/codex-control/codex-lb-launch-recovery.js +278 -0
  69. package/dist/core/codex-control/codex-multi-agent-event-normalizer.js +5 -1
  70. package/dist/core/codex-control/codex-reliability-shield.js +93 -30
  71. package/dist/core/codex-control/codex-sdk-adapter.js +96 -13
  72. package/dist/core/codex-control/codex-sdk-config-policy.js +2 -1
  73. package/dist/core/codex-control/codex-sdk-sandbox-policy.js +6 -3
  74. package/dist/core/codex-control/codex-task-runner.js +62 -9
  75. package/dist/core/codex-control/python-codex-sdk-adapter.js +30 -3
  76. package/dist/core/codex-exec-output-schema.js +35 -6
  77. package/dist/core/codex-lb/codex-lb-env.js +30 -1
  78. package/dist/core/codex-lb/codex-lb-tool-catalog.js +478 -0
  79. package/dist/core/codex-lb/codex-lb-tool-output-recovery.js +291 -0
  80. package/dist/core/codex-native/codex-native-feature-broker.js +31 -38
  81. package/dist/core/codex-native/codex-native-feature-matrix.js +2 -2
  82. package/dist/core/codex-native/codex-native-repair-transaction.js +1 -1
  83. package/dist/core/codex-native/core-skill-manifest.js +8 -4
  84. package/dist/core/codex-native/native-capability-postcheck.js +16 -8
  85. package/dist/core/codex-native/native-capability-repair-matrix.js +76 -27
  86. package/dist/core/codex-plugins/codex-plugin-json.js +67 -21
  87. package/dist/core/codex-plugins/codex-plugin-repair.js +118 -0
  88. package/dist/core/codex-runtime/codex-desktop-config-policy.js +305 -0
  89. package/dist/core/commands/agent-bridge-command.js +23 -2
  90. package/dist/core/commands/agent-command.js +38 -5
  91. package/dist/core/commands/basic-cli.js +77 -30
  92. package/dist/core/commands/command-utils.js +1 -1
  93. package/dist/core/commands/gc-command.js +27 -4
  94. package/dist/core/commands/image-ux-review-command.js +55 -24
  95. package/dist/core/commands/mad-sks-command.js +182 -137
  96. package/dist/core/commands/naruto-command.js +643 -1153
  97. package/dist/core/commands/pipeline-command.js +1 -0
  98. package/dist/core/commands/research-command.js +293 -231
  99. package/dist/core/commands/run-command.js +100 -23
  100. package/dist/core/commands/team-command.js +2 -3
  101. package/dist/core/commands/team-legacy-observe-command.js +94 -359
  102. package/dist/core/commands/wiki-command.js +179 -83
  103. package/dist/core/computer-use-live-evidence.js +166 -3
  104. package/dist/core/computer-use-status.js +5 -2
  105. package/dist/core/daemon/sksd-hook-daemon-entrypoint.js +2 -2
  106. package/dist/core/daemon/sksd-hook-daemon.js +171 -28
  107. package/dist/core/daemon/sksd-hook-dispatch.js +2 -2
  108. package/dist/core/db-safety.js +2 -2
  109. package/dist/core/decision-lattice.js +6 -6
  110. package/dist/core/dfix/verification-selector.js +6 -4
  111. package/dist/core/doctor/browser-use-repair.js +54 -13
  112. package/dist/core/doctor/codex-0139-doctor.js +3 -2
  113. package/dist/core/doctor/codex-startup-config-repair.js +8 -3
  114. package/dist/core/doctor/computer-use-repair.js +28 -39
  115. package/dist/core/doctor/doctor-codex-startup-repair.js +24 -149
  116. package/dist/core/doctor/doctor-context7-repair.js +1 -1
  117. package/dist/core/doctor/doctor-dirty-planner.js +1 -1
  118. package/dist/core/doctor/doctor-native-capability-repair.js +74 -3
  119. package/dist/core/doctor/imagegen-repair.js +47 -12
  120. package/dist/core/doctor/legacy-global-hook-cleanup.js +179 -0
  121. package/dist/core/feature-fixture-executor.js +71 -7
  122. package/dist/core/feature-fixture-runner.js +53 -12
  123. package/dist/core/feature-fixtures.js +47 -14
  124. package/dist/core/feature-registry.js +53 -58
  125. package/dist/core/fsx.js +54 -6
  126. package/dist/core/harness-conflicts.js +19 -10
  127. package/dist/core/hooks-runtime/code-pack-freshness-preflight.js +5 -4
  128. package/dist/core/hooks-runtime/hook-invocation-dedupe.js +147 -0
  129. package/dist/core/hooks-runtime/hook-io.js +14 -4
  130. package/dist/core/hooks-runtime/light-turn.js +70 -0
  131. package/dist/core/hooks-runtime/payload-signals.js +270 -0
  132. package/dist/core/hooks-runtime/team-digest.js +0 -1
  133. package/dist/core/hooks-runtime/tool-output-quarantine.js +93 -0
  134. package/dist/core/hooks-runtime.js +418 -250
  135. package/dist/core/image/image-artifact-path-contract.js +8 -6
  136. package/dist/core/image/image-artifact-registry.js +5 -1
  137. package/dist/core/image-ux-review/imagegen-adapter.js +5 -2
  138. package/dist/core/imagegen/imagegen-capability.js +10 -13
  139. package/dist/core/imagegen/require-imagegen.js +37 -11
  140. package/dist/core/init/skills.js +16 -30
  141. package/dist/core/init.js +144 -36
  142. package/dist/core/managed-assets/managed-assets-manifest.js +417 -14
  143. package/dist/core/mission.js +24 -1
  144. package/dist/core/naruto/naruto-work-graph.js +70 -4
  145. package/dist/core/ops/reporting.js +3 -0
  146. package/dist/core/pipeline-internals/runtime-core.js +578 -180
  147. package/dist/core/pipeline-internals/runtime-gates.js +191 -49
  148. package/dist/core/ppt/style-tokens.js +1 -1
  149. package/dist/core/ppt-review/index.js +1 -1
  150. package/dist/core/ppt-review/slide-exporter.js +23 -17
  151. package/dist/core/ppt-review/slide-imagegen-review.js +1 -1
  152. package/dist/core/ppt-review/slide-issue-extraction.js +4 -2
  153. package/dist/core/preflight/parallel-preflight-engine.js +50 -1
  154. package/dist/core/product-design-plugin.js +2 -2
  155. package/dist/core/proof/route-finalizer.js +1 -1
  156. package/dist/core/proof/route-proof-gate.js +7 -2
  157. package/dist/core/proof-field.js +3 -3
  158. package/dist/core/provider/model-router.js +38 -32
  159. package/dist/core/recallpulse/policy.js +12 -28
  160. package/dist/core/recallpulse.js +11 -6
  161. package/dist/core/release/gate-manifest.js +18 -12
  162. package/dist/core/release/gate-pack-manifest.js +1 -1
  163. package/dist/core/release/npm-pack-proof.js +247 -0
  164. package/dist/core/release/package-dist-snapshot.js +151 -0
  165. package/dist/core/release/package-size-budget.js +5 -0
  166. package/dist/core/release/release-authorization-snapshot.js +115 -0
  167. package/dist/core/release/release-gate-affected-selector.js +15 -3
  168. package/dist/core/release/release-gate-cache-v2.js +30 -0
  169. package/dist/core/release/release-gate-contract.js +161 -0
  170. package/dist/core/release/release-gate-dag.js +44 -3
  171. package/dist/core/release/release-gate-hermetic-env.js +28 -17
  172. package/dist/core/release/release-real-contract.js +496 -0
  173. package/dist/core/release-parallel-full-coverage.js +31 -143
  174. package/dist/core/research/claim-evidence-matrix.js +41 -6
  175. package/dist/core/research/experiment-plan.js +14 -10
  176. package/dist/core/research/falsification.js +9 -2
  177. package/dist/core/research/implementation-blueprint-densifier.js +82 -60
  178. package/dist/core/research/implementation-blueprint.js +32 -26
  179. package/dist/core/research/mock-result.js +122 -11
  180. package/dist/core/research/replication-pack.js +15 -8
  181. package/dist/core/research/research-adversarial-review.js +1068 -0
  182. package/dist/core/research/research-claim-builder.js +69 -17
  183. package/dist/core/research/research-claim-synthesizer.js +343 -0
  184. package/dist/core/research/research-cycle-runner.js +53 -3
  185. package/dist/core/research/research-falsification-runner.js +176 -0
  186. package/dist/core/research/research-final-reviewer.js +44 -125
  187. package/dist/core/research/research-realistic-report.js +14 -6
  188. package/dist/core/research/research-review-artifact-digest.js +66 -0
  189. package/dist/core/research/research-source-evidence.js +144 -0
  190. package/dist/core/research/research-source-layer-catalog.js +68 -0
  191. package/dist/core/research/research-source-ledger-merge.js +250 -12
  192. package/dist/core/research/research-source-shards.js +26 -70
  193. package/dist/core/research/research-stage-runner.js +237 -247
  194. package/dist/core/research/research-super-search.js +184 -0
  195. package/dist/core/research/research-synthesis-prompt.js +20 -1
  196. package/dist/core/research/research-synthesis-writer.js +86 -5
  197. package/dist/core/research/research-work-graph.js +25 -18
  198. package/dist/core/research/source-quality-report.js +21 -0
  199. package/dist/core/research.js +429 -280
  200. package/dist/core/retention/retention-budget.js +25 -6
  201. package/dist/core/retention.js +980 -101
  202. package/dist/core/routes/constants.js +1 -1
  203. package/dist/core/routes/dollar-manifest-lite.js +11 -11
  204. package/dist/core/routes/evidence.js +4 -4
  205. package/dist/core/routes/ppt-policy.js +1 -1
  206. package/dist/core/routes.js +92 -64
  207. package/dist/core/runtime/task-profile.js +66 -0
  208. package/dist/core/runtime/verification-budget.js +12 -0
  209. package/dist/core/secret-redaction.js +4 -0
  210. package/dist/core/security/high-risk-contracts.js +6 -6
  211. package/dist/core/stop-gate/stop-gate-check.js +49 -12
  212. package/dist/core/subagents/agent-catalog.js +215 -0
  213. package/dist/core/subagents/model-policy.js +118 -0
  214. package/dist/core/subagents/naruto-help-contract.js +40 -0
  215. package/dist/core/subagents/official-subagent-config.js +488 -0
  216. package/dist/core/subagents/official-subagent-preparation.js +251 -0
  217. package/dist/core/subagents/official-subagent-prompt.js +137 -0
  218. package/dist/core/subagents/official-subagent-runner.js +129 -0
  219. package/dist/core/subagents/subagent-evidence.js +663 -0
  220. package/dist/core/subagents/terminology.js +16 -0
  221. package/dist/core/subagents/thread-budget.js +21 -0
  222. package/dist/core/subagents/triwiki-attention.js +65 -0
  223. package/dist/core/super-search/runtime-helpers.js +173 -19
  224. package/dist/core/super-search/runtime.js +140 -15
  225. package/dist/core/super-search/source-records.js +49 -8
  226. package/dist/core/team-review-policy.js +15 -0
  227. package/dist/core/triwiki/code-pack.js +8 -2
  228. package/dist/core/triwiki/triwiki-cache-key.js +108 -29
  229. package/dist/core/triwiki/triwiki-module-card.js +1 -1
  230. package/dist/core/triwiki-attention.js +13 -6
  231. package/dist/core/triwiki-provenance.js +274 -0
  232. package/dist/core/triwiki-runtime.js +21 -7
  233. package/dist/core/triwiki-wrongness/wrongness-ledger.js +187 -61
  234. package/dist/core/triwiki-wrongness/wrongness-retrieval.js +11 -2
  235. package/dist/core/triwiki-wrongness/wrongness-trust-policy.js +2 -0
  236. package/dist/core/update-check.js +23 -15
  237. package/dist/core/version-manager.js +51 -1
  238. package/dist/core/version.js +1 -1
  239. package/dist/core/wiki-coordinate.js +128 -12
  240. package/dist/core/work-order-ledger.js +208 -10
  241. package/dist/core/zellij/zellij-command.js +12 -1
  242. package/dist/core/zellij/zellij-dashboard-pane.js +3 -3
  243. package/dist/core/zellij/zellij-fake-adapter.js +3 -1
  244. package/dist/core/zellij/zellij-launcher.js +51 -21
  245. package/dist/core/zellij/zellij-layout-builder.js +14 -5
  246. package/dist/core/zellij/zellij-official-subagent-activity.js +477 -0
  247. package/dist/core/zellij/zellij-official-subagent-telemetry.js +264 -0
  248. package/dist/core/zellij/zellij-pane-proof.js +32 -6
  249. package/dist/core/zellij/zellij-slot-pane-renderer.js +17 -5
  250. package/dist/core/zellij/zellij-slot-telemetry.js +15 -3
  251. package/dist/core/zellij/zellij-ui-mode.js +1 -1
  252. package/dist/core/zellij/zellij-viewport-binder.js +3 -0
  253. package/dist/core/zellij/zellij-worker-pane-manager.js +5 -3
  254. package/dist/scripts/agent-fast-mode-default-check.js +48 -29
  255. package/dist/scripts/agent-role-config-repair-check.js +34 -15
  256. package/dist/scripts/agent-wiki-context-proof-check.js +16 -2
  257. package/dist/scripts/all-feature-deep-completion-check.js +14 -4
  258. package/dist/scripts/architecture-guard-check.js +8 -1
  259. package/dist/scripts/build-dist.js +17 -5
  260. package/dist/scripts/canonical-test-runner.js +188 -0
  261. package/dist/scripts/check-command-module-budget.js +38 -16
  262. package/dist/scripts/check-legacy-free.js +1 -1
  263. package/dist/scripts/check-route-modularity.js +0 -1
  264. package/dist/scripts/check-ts-contracts.js +1 -1
  265. package/dist/scripts/codex-0139-interrupt-agent-check.js +5 -1
  266. package/dist/scripts/{codex-0142-app-server-v2-check.js → codex-0144-app-server-v2-check.js} +11 -10
  267. package/dist/scripts/{codex-0142-binary-identity-check.js → codex-0144-binary-identity-check.js} +4 -4
  268. package/dist/scripts/codex-0144-capability-check.js +21 -0
  269. package/dist/scripts/{codex-0139-real-probes-check.js → codex-0144-core-real-probes-check.js} +19 -5
  270. package/dist/scripts/{codex-0142-doctor-wiring-check.js → codex-0144-doctor-wiring-check.js} +6 -6
  271. package/dist/scripts/{codex-0142-manifest-check.js → codex-0144-manifest-check.js} +11 -3
  272. package/dist/scripts/{codex-0142-policy-check.js → codex-0144-policy-check.js} +2 -2
  273. package/dist/scripts/{codex-0142-thread-store-check.js → codex-0144-thread-store-check.js} +3 -3
  274. package/dist/scripts/codex-app-provider-model-ui-check.js +53 -19
  275. package/dist/scripts/codex-app-ui-preservation-check.js +35 -4
  276. package/dist/scripts/codex-control-all-pipelines-check.js +7 -3
  277. package/dist/scripts/codex-control-side-effect-scope-check.js +2 -2
  278. package/dist/scripts/codex-control-tool-output-continuity-audit-check.js +27 -0
  279. package/dist/scripts/codex-effort-auto-discovery-check.js +1 -1
  280. package/dist/scripts/codex-lb-fast-mode-truth-check.js +1 -0
  281. package/dist/scripts/{codex-lb-gpt55-fast-profile-check.js → codex-lb-gpt56-fast-profile-check.js} +56 -5
  282. package/dist/scripts/codex-model-metadata-check.js +1 -1
  283. package/dist/scripts/codex-native-agent-role-content-check.js +15 -7
  284. package/dist/scripts/codex-native-repair-transaction-check.js +3 -1
  285. package/dist/scripts/codex-sdk-all-pipelines-check.js +7 -4
  286. package/dist/scripts/codex-sdk-research-pipeline-check.js +30 -8
  287. package/dist/scripts/codex-sdk-sandbox-policy-check.js +5 -1
  288. package/dist/scripts/codex-sdk-version-compat-check.js +2 -1
  289. package/dist/scripts/db-route-materialization-check.js +33 -0
  290. package/dist/scripts/dfix-fixture-check.js +1 -1
  291. package/dist/scripts/docs-truthfulness-check.js +4 -2
  292. package/dist/scripts/doctor-codex-startup-repair-check.js +47 -25
  293. package/dist/scripts/doctor-context7-repair-check.js +2 -1
  294. package/dist/scripts/doctor-fix-production-blackbox.js +12 -2
  295. package/dist/scripts/doctor-fixes-codex-app-fast-ui-check.js +34 -7
  296. package/dist/scripts/doctor-imagegen-repair-check.js +14 -4
  297. package/dist/scripts/doctor-startup-config-repair-blackbox.js +9 -3
  298. package/dist/scripts/doctor-startup-config-repair-check.js +13 -3
  299. package/dist/scripts/install-update-preserves-config-check.js +7 -2
  300. package/dist/scripts/legacy-gate-inventory-check.js +7 -5
  301. package/dist/scripts/legacy-strong-inventory-check.js +7 -5
  302. package/dist/scripts/legacy-upgrade-matrix-check.js +4 -4
  303. package/dist/scripts/lib/native-cli-session-swarm-check-lib.js +173 -13
  304. package/dist/scripts/mad-sks-app-ui-no-mutation-check.js +165 -6
  305. package/dist/scripts/managed-role-manifest-parity-check.js +5 -4
  306. package/dist/scripts/mutation-callsite-coverage-check.js +0 -11
  307. package/dist/scripts/naruto-codex-e2e-check.js +14 -7
  308. package/dist/scripts/naruto-shadow-clone-swarm-check.js +4 -201
  309. package/dist/scripts/npm-publish-performance-check.js +20 -12
  310. package/dist/scripts/official-subagent-workflow-check.js +145 -0
  311. package/dist/scripts/package-published-contract-check.js +6 -20
  312. package/dist/scripts/packlist-performance-check.js +17 -3
  313. package/dist/scripts/parallel-verification-engine-check.js +2 -2
  314. package/dist/scripts/postinstall-safe-side-effects-check.js +8 -3
  315. package/dist/scripts/ppt-no-mock-as-real-check.js +3 -1
  316. package/dist/scripts/prepublish-release-check-or-fast.js +23 -86
  317. package/dist/scripts/product-design-plugin-routing-check.js +1 -1
  318. package/dist/scripts/release-affected-selector-check.js +74 -1
  319. package/dist/scripts/release-check-stamp.js +324 -239
  320. package/dist/scripts/release-dag-full-coverage-check.js +7 -15
  321. package/dist/scripts/release-dynamic-presets-check.js +10 -1
  322. package/dist/scripts/release-gate-dag-runner-check.js +3 -3
  323. package/dist/scripts/release-gate-dag-runner.js +35 -11
  324. package/dist/scripts/release-gate-existence-audit.js +1 -2
  325. package/dist/scripts/release-gate-script-parity-check.js +1 -1
  326. package/dist/scripts/release-parallel-full-coverage-check.js +12 -6
  327. package/dist/scripts/release-parallel-speed-budget-check.js +18 -2
  328. package/dist/scripts/release-real-check.js +390 -157
  329. package/dist/scripts/release-registry-check.js +61 -16
  330. package/dist/scripts/release-runtime-truth-matrix-check.js +22 -0
  331. package/dist/scripts/research-blueprint-densifier-check.js +2 -2
  332. package/dist/scripts/research-real-cycle-no-legacy-final-md-check.js +11 -7
  333. package/dist/scripts/route-proof-artifact-structure-check.js +1 -0
  334. package/dist/scripts/search-visibility-gate-lib.js +1 -1
  335. package/dist/scripts/seo-geo-route-identity-check.js +30 -4
  336. package/dist/scripts/sizecheck.js +4 -4
  337. package/dist/scripts/sks-1-11-gate-lib.js +53 -6
  338. package/dist/scripts/sks-3-1-4-directive-check-lib.js +8 -2
  339. package/dist/scripts/sks-3-1-5-directive-check-lib.js +3 -2
  340. package/dist/scripts/sks-3-1-6-directive-check-lib.js +5 -3
  341. package/dist/scripts/sks-menubar-install-check.js +8 -0
  342. package/dist/scripts/sks-uninstall-regression-check.js +1 -1
  343. package/dist/scripts/sksd-daemon-check.js +16 -6
  344. package/dist/scripts/trust-fixture-check.js +32 -10
  345. package/dist/scripts/write-build-manifest.js +2 -1
  346. package/dist/scripts/wrongness-fixture-check.js +1 -1
  347. package/dist/scripts/zellij-layout-valid-check.js +36 -11
  348. package/dist/scripts/zellij-pane-proof-check.js +33 -2
  349. package/dist/scripts/zellij-real-session-cleanup-check.js +122 -2
  350. package/dist/scripts/zellij-real-session-launch-check.js +76 -5
  351. package/dist/scripts/zellij-slot-pane-renderer-check.js +4 -4
  352. package/dist/scripts/zellij-spawn-on-demand-layout-check.js +3 -3
  353. package/docs/demo.tape +1 -1
  354. package/infra-harness-gates.json +1486 -0
  355. package/package.json +32 -19
  356. package/release-gates.v2.json +4060 -0
  357. package/runtime-required-scripts.json +9 -0
  358. package/schemas/codex/{app-server-0.142 → app-server-0.144}/codex_app_server_protocol.v2.schemas.json +1146 -781
  359. package/schemas/codex/codex-0139-real-probe-result.schema.json +39 -5
  360. package/schemas/codex/ppt-slide-issue-ledger.schema.json +2 -1
  361. package/dist/commands/db.js +0 -6
  362. package/dist/core/codex-control/codex-0139-multi-agent-real-probe.js +0 -107
  363. package/dist/core/commands/db-command.js +0 -146
  364. package/dist/core/research/prompt.js +0 -15
  365. package/dist/scripts/agent-native-release-gate.js +0 -274
  366. package/dist/scripts/codex-0142-capability-check.js +0 -21
  367. package/dist/scripts/codex-control-tool-call-sequence-repair-check.js +0 -14
  368. package/dist/scripts/command-performance-scorecard-check.js +0 -204
  369. package/dist/scripts/config-managed-merge-callsite-coverage-check.js +0 -212
  370. package/dist/scripts/dollar-performance-scorecard-check.js +0 -257
  371. package/dist/scripts/gate-timing-check.js +0 -16
  372. package/dist/scripts/ops-maturity-scorecard-check.js +0 -12
  373. package/dist/scripts/performance-baseline-check.js +0 -12
  374. package/dist/scripts/performance-improvement-report-check.js +0 -58
  375. package/dist/scripts/release-parallel-check.js +0 -389
  376. package/dist/scripts/release-runner-efficiency-check.js +0 -15
  377. package/dist/scripts/retention-long-run-smoke-check.js +0 -299
  378. package/docs/assets/sneakoscope-architecture-pipeline.jpg +0 -0
@@ -72,33 +72,14 @@ async function runImageUxReview(root, command, args = []) {
72
72
  const shouldGenerateCallouts = flag(args, '--generate-callouts') || flag(args, '--fix');
73
73
  if (missionId)
74
74
  return rebuildExistingMission(root, command, [missionId, ...args], { fixRequested: flag(args, '--fix') });
75
- const fromChromeExtension = flag(args, '--from-chrome-extension') || Boolean(readOption(args, '--from-chrome-extension', null));
76
- const fromComputerUse = flag(args, '--from-computer-use') || Boolean(readOption(args, '--from-computer-use', null));
77
- const chromePreflight = fromChromeExtension ? await codexChromeExtensionStatus() : null;
78
- if (chromePreflight && !chromePreflight.ok) {
79
- const result = {
80
- schema: 'sks.image-ux-review-run.v1',
81
- ok: false,
82
- status: 'blocked',
83
- blocker: 'codex_chrome_extension_setup_required',
84
- chrome_extension: chromePreflight,
85
- guidance: [
86
- 'Install/enable the Codex Chrome Extension first, then tell SKS installation is complete before resuming web UX review.'
87
- ]
88
- };
75
+ const sourcePreflight = await imageUxReviewSourcePreflight(args);
76
+ const { fromChromeExtension, fromComputerUse, chromePreflight } = sourcePreflight;
77
+ if (sourcePreflight.result) {
78
+ const result = sourcePreflight.result;
89
79
  process.exitCode = 1;
90
80
  if (flag(args, '--json'))
91
81
  return printJson(result);
92
- console.error('UX Review blocked: install/enable the Codex Chrome Extension first, then tell SKS installation is complete before resuming.');
93
- console.error(chromePreflight.docs_url);
94
- return result;
95
- }
96
- if (fromComputerUse && !flag(args, '--native') && !flag(args, '--non-web')) {
97
- const result = { schema: 'sks.image-ux-review-run.v1', ok: false, status: 'blocked', blocker: 'web_ux_review_requires_codex_chrome_extension_not_computer_use' };
98
- process.exitCode = 1;
99
- if (flag(args, '--json'))
100
- return printJson(result);
101
- console.error('UX Review blocked: web/browser UX review requires Codex Chrome Extension, not Computer Use. Use --from-chrome-extension after setup, or provide a screenshot with --image.');
82
+ printImageUxReviewSourcePreflightBlock(result);
102
83
  return result;
103
84
  }
104
85
  if (!imagePath && !fromChromeExtension && !fromComputerUse) {
@@ -219,6 +200,56 @@ async function runImageUxReview(root, command, args = []) {
219
200
  console.log(`Image UX review: ${result.ok ? 'ok' : 'blocked'} ${id}`);
220
201
  return result;
221
202
  }
203
+ /**
204
+ * Read-only source validation shared with the active-route dispatcher. A
205
+ * blocked result is terminal and guarantees that the run cannot create a
206
+ * mission or write route evidence.
207
+ */
208
+ export async function imageUxReviewSourcePreflight(args = []) {
209
+ const fromChromeExtension = flag(args, '--from-chrome-extension') || Boolean(readOption(args, '--from-chrome-extension', null));
210
+ const fromComputerUse = flag(args, '--from-computer-use') || Boolean(readOption(args, '--from-computer-use', null));
211
+ const chromePreflight = fromChromeExtension ? await codexChromeExtensionStatus() : null;
212
+ if (chromePreflight && !chromePreflight.ok) {
213
+ return {
214
+ fromChromeExtension,
215
+ fromComputerUse,
216
+ chromePreflight,
217
+ result: {
218
+ schema: 'sks.image-ux-review-run.v1',
219
+ ok: false,
220
+ status: 'blocked',
221
+ blocker: 'codex_chrome_extension_setup_required',
222
+ chrome_extension: chromePreflight,
223
+ guidance: [
224
+ 'Install/enable the Codex Chrome Extension first, then tell SKS installation is complete before resuming web UX review.'
225
+ ]
226
+ }
227
+ };
228
+ }
229
+ if (fromComputerUse && !flag(args, '--native') && !flag(args, '--non-web')) {
230
+ return {
231
+ fromChromeExtension,
232
+ fromComputerUse,
233
+ chromePreflight,
234
+ result: {
235
+ schema: 'sks.image-ux-review-run.v1',
236
+ ok: false,
237
+ status: 'blocked',
238
+ blocker: 'web_ux_review_requires_codex_chrome_extension_not_computer_use'
239
+ }
240
+ };
241
+ }
242
+ return { fromChromeExtension, fromComputerUse, chromePreflight, result: null };
243
+ }
244
+ function printImageUxReviewSourcePreflightBlock(result) {
245
+ if (result.blocker === 'codex_chrome_extension_setup_required') {
246
+ console.error('UX Review blocked: install/enable the Codex Chrome Extension first, then tell SKS installation is complete before resuming.');
247
+ if (result.chrome_extension?.docs_url)
248
+ console.error(result.chrome_extension.docs_url);
249
+ return;
250
+ }
251
+ console.error('UX Review blocked: web/browser UX review requires Codex Chrome Extension, not Computer Use. Use --from-chrome-extension after setup, or provide a screenshot with --image.');
252
+ }
222
253
  async function calloutsImageUxReview(root, command, args = []) {
223
254
  const imagePath = readOption(args, '--image', null) || readOption(args, '--screenshot', null);
224
255
  if (!imagePath) {
@@ -23,10 +23,12 @@ import { writeCodex0138CapabilityArtifacts } from '../codex-control/codex-0138-c
23
23
  import { writeCodex0139CapabilityArtifacts } from '../codex-control/codex-0139-capability.js';
24
24
  import { resolveCodexNativeInvocationPlan } from '../codex-native/codex-native-invocation-router.js';
25
25
  import { repairZellijForSks } from '../zellij/zellij-self-heal.js';
26
+ import { SKS_ZELLIJ_HOST_MISSION_ENV } from '../zellij/zellij-official-subagent-telemetry.js';
26
27
  import { buildMadGlmLaunchArtifact, buildMadGlmLaunchProfileNoWrite, resolveMadGlmLaunchKey, writeMadGlmCodexWrapper } from '../providers/glm/glm-mad-launch.js';
27
28
  import { GLM_MAD_MODE } from '../providers/glm/glm-52-settings.js';
28
29
  import { assertNonGlmMadRoute } from '../routes/model-mode-router.js';
29
30
  import { evaluateGate } from '../stop-gate/gate-evaluator.js';
31
+ import { CODEX_LB_TOOL_OUTPUT_RECOVERY_OVERRIDE_FLAG, codexLbToolOutputRecoveryOverrideAcknowledged } from '../codex-lb/codex-lb-tool-output-recovery.js';
30
32
  const MAD_SKS_DEFAULT_TTL_MS = 10 * 60 * 1000;
31
33
  export async function madHighCommand(args = [], deps = {}) {
32
34
  const rawArgsForHelp = (args || []).map((arg) => String(arg));
@@ -188,7 +190,16 @@ export async function madHighCommand(args = [], deps = {}) {
188
190
  // readability + repair checks still run. SKS_LAUNCH_FULL_CODEX_PROBE=1 restores the
189
191
  // old behavior.
190
192
  const allowMadRepair = rawArgs.includes('--repair-config') || rawArgs.includes('--fix') || rawArgs.includes('--yes-repair');
191
- const launchPreflightOpts = { fix: allowMadRepair, launchFast: process.env.SKS_LAUNCH_FULL_CODEX_PROBE !== '1', profile: profile.profile_name, sandbox: 'danger-full-access', serviceTier: 'fast' };
193
+ const allowUnverifiedToolOutputRecovery = codexLbToolOutputRecoveryOverrideAcknowledged({ args: rawArgs });
194
+ const launchPreflightOpts = {
195
+ fix: allowMadRepair,
196
+ launchFast: process.env.SKS_LAUNCH_FULL_CODEX_PROBE !== '1',
197
+ profile: profile.profile_name,
198
+ sandbox: 'danger-full-access',
199
+ serviceTier: 'fast',
200
+ skipCodexLbToolOutputRecovery: glmMadLaunch,
201
+ allowUnverifiedToolOutputRecovery
202
+ };
192
203
  let launchPreflight = await runCodexLaunchPreflight(launchRoot, launchPreflightOpts);
193
204
  // Fresh-project bootstrap: when the ONLY blocker is that the managed Codex config does
194
205
  // not exist yet (`.codex/config.toml` absent), regenerate it — exactly what the blocker
@@ -224,141 +235,162 @@ export async function madHighCommand(args = [], deps = {}) {
224
235
  return launchPreflight;
225
236
  }
226
237
  const madLaunch = await activateMadZellijPermissionState(process.cwd(), args);
227
- const glmRuntime = glmMadLaunch ? await prepareMadGlmLaunchRuntime(madLaunch, { ...deps, glmArgs: deps?.glmArgs || rawArgs }) : null;
228
- if (glmMadLaunch && !glmRuntime?.ok) {
229
- process.exitCode = 1;
230
- return glmRuntime;
231
- }
232
- if (madDbGrant.requested) {
233
- const grantReport = {
234
- schema: 'sks.mad-sks-launch-grants.v2',
235
- generated_at: nowIso(),
236
- mission_id: madLaunch.mission_id,
237
- mad_sks_active: true,
238
- mad_db_active: false,
239
- mad_db_default_grant: false,
240
- mad_db_grant_source: madDbGrant.source,
241
- mad_db_requires_first_class_route: true,
242
- mad_db_cli: 'sks mad-db run|exec|apply-migration',
243
- mad_db_capability_file: null,
244
- standalone_mad_db_enable_still_requires_ack: true
245
- };
246
- await writeJsonAtomic(path.join(madLaunch.dir, 'mad-sks-launch-grants.json'), grantReport);
247
- await appendJsonlBounded(path.join(madLaunch.dir, 'events.jsonl'), { ts: nowIso(), type: 'mad_db.first_class_route_required', grant_source: madDbGrant.source, cli: grantReport.mad_db_cli });
248
- }
249
- const updateNotice = {
250
- schema: 'sks.update-notice.v1',
251
- checked_at: nowIso(),
252
- package_name: deps.packageName || 'sneakoscope',
253
- current_version: deps.packageVersion || PACKAGE_VERSION,
254
- latest_version: null,
255
- update_available: false,
256
- source: 'deferred_background',
257
- cache_ttl_ms: 0,
258
- message: 'SKS update notice refresh deferred until after MAD UI launch.'
259
- };
260
- void checkSksUpdateNotice({
261
- packageName: deps.packageName || 'sneakoscope',
262
- currentVersion: deps.packageVersion || PACKAGE_VERSION,
263
- missionDir: madLaunch.dir
264
- }).then((notice) => appendJsonlBounded(path.join(madLaunch.dir, 'events.jsonl'), { ts: nowIso(), type: 'mad_sks.update_notice_refreshed_background', non_blocking: true, update_available: notice.update_available === true, source: notice.source })).catch((err) => appendJsonlBounded(path.join(madLaunch.dir, 'events.jsonl'), { ts: nowIso(), type: 'mad_sks.update_notice_background_failed', error: err?.message || String(err) }));
265
- await appendJsonlBounded(path.join(madLaunch.dir, 'events.jsonl'), { ts: nowIso(), type: 'mad_sks.update_notice_checked', non_blocking: true, update_available: updateNotice.update_available === true, source: updateNotice.source });
266
- console.log(`SKS MAD ready: ${glmRuntime?.profile?.profile_name || madHighProfileName()} | gate ${madLaunch.mission_id}`);
267
- if (glmRuntime?.profile)
268
- console.log(`GLM MAD launch active: ${glmRuntime.profile.model} via OpenRouter; GPT fallback blocked.`);
269
- if (madDbGrant.requested)
270
- console.log('MAD-DB flag observed; deprecated route now redirects to MAD-SKS SQL-plane: sks mad-sks sql|apply-migration.');
271
- if (updateNotice.update_available === true)
272
- console.log(`SKS update notice: ${updateNotice.latest_version} available (non-blocking).`);
273
- console.log('Scoped high-power maintenance authority active; add explicit --allow-* flags for packages, services, network, browser/Computer Use, generated assets, file permissions, or system/admin scopes. SQL-plane execution is available through MAD-SKS sql-plane and still requires control-plane denial, read-back proof, and read-only restoration.');
274
- const launchLb = lb.status === 'present' ? { ...lb, status: 'configured' } : lb;
275
- const zellijVisiblePaneSetting = readOption(cleanArgs, '--zellij-visible-panes', process.env.SKS_ZELLIJ_VISIBLE_PANES || process.env.SKS_ZELLIJ_VISIBLE_PANE_CAP || '8');
276
- const zellijViewportSetting = readOption(cleanArgs, '--zellij-viewports', process.env.SKS_ZELLIJ_VIEWPORTS || '4');
277
- const zellijRefreshMsSetting = readOption(cleanArgs, '--zellij-refresh-ms', process.env.SKS_ZELLIJ_REFRESH_MS || '1000');
278
- const madSksEnv = {
279
- SKS_PROTECTED_CORE_POLICY: madLaunch.gate.protected_core_policy,
280
- SKS_MAD_SKS_TARGET_ROOT: madLaunch.gate.cwd,
281
- SKS_MAD_SKS_PROTECTED_CORE_DIGEST: madLaunch.gate.protected_core_digest,
282
- SKS_ZELLIJ_VISIBLE_PANES: String(zellijVisiblePaneSetting),
283
- SKS_ZELLIJ_VIEWPORTS: String(Math.max(0, Math.min(Number(zellijViewportSetting || 4), 6))),
284
- SKS_ZELLIJ_REFRESH_MS: String(zellijRefreshMsSetting),
285
- };
286
- const explicitWorkspace = readOption(cleanArgs, '--workspace', readOption(cleanArgs, '--session', null));
287
- const launchProfile = glmRuntime?.profile || profile;
288
- const launchOpts = glmRuntime
289
- ? buildGlmMadLaunchOpts(cleanArgs, {
290
- codexArgs: launchProfile.launch_args,
291
- conciseBlockers: true,
292
- madSksEnv,
293
- launchEnv: madSksEnv,
294
- codexBin: glmRuntime.wrapper.wrapper_path,
295
- explicitWorkspace
296
- })
297
- : codexLbImmediateLaunchOpts(cleanArgs, launchLb, { codexArgs: launchProfile.launch_args, conciseBlockers: true, madSksEnv, launchEnv: madSksEnv });
298
- // Only the auto-derived stable `sks-mad-<cwd>` name accumulates panes across
299
- // runs; when the user names a session explicitly (or codex-lb already minted a
300
- // fresh unique session) respect it and skip the reset.
301
- const autoDerivedMadSession = !explicitWorkspace && !launchOpts.session;
302
- const workspace = explicitWorkspace || launchOpts.session || `sks-mad-${sanitizeZellijSessionName(process.cwd())}`;
303
- const launch = headlessZellij
304
- ? await writeMadHeadlessZellijFallback(madLaunch, workspace)
305
- : await launchMadZellijUi([...cleanArgs, '--workspace', workspace], { ...launchOpts, missionId: madLaunch.mission_id, root: madLaunch.root, cwd: process.cwd(), ledgerRoot: path.join(madLaunch.dir, 'agents'), slotCount: 0, freshSession: autoDerivedMadSession, requireZellij: process.env.SKS_REQUIRE_ZELLIJ === '1' });
306
- const afterLaunchUi = beforeUi ? await writeCodexAppUiSnapshot(launchRoot, `mad-after-launch-${uiSnapshotId}`).catch(() => null) : null;
307
- const launchUiDiff = beforeUi && afterLaunchUi ? diffCodexAppUiSnapshots(beforeUi, afterLaunchUi) : null;
308
- if (launchUiDiff) {
309
- await writeJsonAtomic(path.join(madLaunch.dir, 'codex-app-ui-diff.json'), launchUiDiff);
310
- if (!launchUiDiff.ok) {
311
- console.error('SKS MAD launch changed Codex App UI state. Run `sks doctor --fix`.');
238
+ const launchLifecycleTasks = [...(madLaunch.lifecycle_tasks || [])];
239
+ try {
240
+ const glmRuntime = glmMadLaunch ? await prepareMadGlmLaunchRuntime(madLaunch, { ...deps, glmArgs: deps?.glmArgs || rawArgs }) : null;
241
+ if (glmMadLaunch && !glmRuntime?.ok) {
312
242
  process.exitCode = 1;
313
- return launchUiDiff;
243
+ return glmRuntime;
314
244
  }
315
- }
316
- if (!launch.ok) {
317
- console.log(`MAD Zellij action: ${formatMadZellijAction(launch)}`);
318
- return launch;
319
- }
320
- await writeJsonAtomic(path.join(madLaunch.dir, 'zellij-initial-ui.json'), {
321
- schema: 'sks.zellij-initial-ui.v1',
322
- ok: true,
323
- mission_id: madLaunch.mission_id,
324
- session_name: launch.session_name || null,
325
- live_panes: !headlessZellij,
326
- initial_panes: 'orchestrator-monitor-viewports',
327
- dashboard_created: true,
328
- worker_panes_created: 0,
329
- viewport_panes_created: Number(madSksEnv.SKS_ZELLIJ_VIEWPORTS),
330
- ui_architecture: 'monitor_plus_viewports',
331
- right_column_mode: 'monitor-plus-viewports'
332
- });
333
- const madNativeSwarmPromise = startMadNativeSwarm(madLaunch.root, madLaunch, args, launchProfile, {
334
- env: {
335
- ...madSksEnv,
336
- ...(launch.session_name ? { SKS_ZELLIJ_SESSION_NAME: launch.session_name } : {})
337
- },
338
- glmLaunch: glmRuntime ? { provider: glmRuntime.profile.provider, model: glmRuntime.profile.model } : null,
339
- zellijSessionName: launch.session_name || null,
340
- workerPlacement: headlessZellij ? 'process' : shouldAutoAttachZellij(args) ? 'zellij-pane' : 'process',
341
- zellijVisiblePaneCap: Number(process.env.SKS_ZELLIJ_VISIBLE_PANE_CAP || zellijVisiblePaneSetting || 8)
342
- }).catch((err) => appendJsonlBounded(path.join(madLaunch.dir, 'events.jsonl'), { ts: nowIso(), type: 'mad_sks.native_swarm_background_failed', error: err?.message || String(err) }));
343
- void madNativeSwarmPromise;
344
- // The launcher only creates a detached background session. In an interactive
345
- // terminal, immediately attach so the session actually opens for the user
346
- // instead of leaving them to copy/paste the attach command by hand.
347
- if (!headlessZellij && shouldAutoAttachZellij(args)) {
348
- console.log(`Opening Zellij session: ${launch.session_name} (detach with Ctrl+q, re-attach later with: ${launch.attach_command_with_env})`);
349
- const attached = attachZellijSessionInteractive(launch.session_name, { cwd: process.cwd(), configPath: launch.clipboard_config_path });
350
- if (!attached.ok) {
351
- console.log(`Could not open the Zellij session automatically${attached.error ? ` (${attached.error})` : ''}.`);
352
- if (launch.attach_command_with_env)
353
- console.log(`Attach with: ${launch.attach_command_with_env}`);
245
+ if (madDbGrant.requested) {
246
+ const grantReport = {
247
+ schema: 'sks.mad-sks-launch-grants.v2',
248
+ generated_at: nowIso(),
249
+ mission_id: madLaunch.mission_id,
250
+ mad_sks_active: true,
251
+ mad_db_active: false,
252
+ mad_db_default_grant: false,
253
+ mad_db_grant_source: madDbGrant.source,
254
+ mad_db_requires_first_class_route: true,
255
+ mad_db_cli: 'sks mad-db run|exec|apply-migration',
256
+ mad_db_capability_file: null,
257
+ standalone_mad_db_enable_still_requires_ack: true
258
+ };
259
+ await writeJsonAtomic(path.join(madLaunch.dir, 'mad-sks-launch-grants.json'), grantReport);
260
+ await appendJsonlBounded(path.join(madLaunch.dir, 'events.jsonl'), { ts: nowIso(), type: 'mad_db.first_class_route_required', grant_source: madDbGrant.source, cli: grantReport.mad_db_cli });
261
+ }
262
+ const updateNotice = {
263
+ schema: 'sks.update-notice.v1',
264
+ checked_at: nowIso(),
265
+ package_name: deps.packageName || 'sneakoscope',
266
+ current_version: deps.packageVersion || PACKAGE_VERSION,
267
+ latest_version: null,
268
+ update_available: false,
269
+ source: 'deferred_background',
270
+ cache_ttl_ms: 0,
271
+ message: 'SKS update notice refresh deferred until after MAD UI launch.'
272
+ };
273
+ const updateNoticePromise = checkSksUpdateNotice({
274
+ packageName: deps.packageName || 'sneakoscope',
275
+ currentVersion: deps.packageVersion || PACKAGE_VERSION,
276
+ missionDir: madLaunch.dir
277
+ }).then((notice) => appendJsonlBounded(path.join(madLaunch.dir, 'events.jsonl'), { ts: nowIso(), type: 'mad_sks.update_notice_refreshed_background', non_blocking: true, update_available: notice.update_available === true, source: notice.source })).catch((err) => appendJsonlBounded(path.join(madLaunch.dir, 'events.jsonl'), { ts: nowIso(), type: 'mad_sks.update_notice_background_failed', error: err?.message || String(err) }));
278
+ launchLifecycleTasks.push(updateNoticePromise);
279
+ await appendJsonlBounded(path.join(madLaunch.dir, 'events.jsonl'), { ts: nowIso(), type: 'mad_sks.update_notice_checked', non_blocking: true, update_available: updateNotice.update_available === true, source: updateNotice.source });
280
+ console.log(`SKS MAD ready: ${glmRuntime?.profile?.profile_name || madHighProfileName()} | gate ${madLaunch.mission_id}`);
281
+ if (glmRuntime?.profile)
282
+ console.log(`GLM MAD launch active: ${glmRuntime.profile.model} via OpenRouter; GPT fallback blocked.`);
283
+ if (madDbGrant.requested)
284
+ console.log('MAD-DB flag observed; deprecated route now redirects to MAD-SKS SQL-plane: sks mad-sks sql|apply-migration.');
285
+ if (updateNotice.update_available === true)
286
+ console.log(`SKS update notice: ${updateNotice.latest_version} available (non-blocking).`);
287
+ console.log('Scoped high-power maintenance authority active; add explicit --allow-* flags for packages, services, network, browser/Computer Use, generated assets, file permissions, or system/admin scopes. SQL-plane execution is available through MAD-SKS sql-plane and still requires control-plane denial, read-back proof, and read-only restoration.');
288
+ const launchLb = lb.status === 'present' ? { ...lb, status: 'configured' } : lb;
289
+ const zellijVisiblePaneSetting = readOption(cleanArgs, '--zellij-visible-panes', process.env.SKS_ZELLIJ_VISIBLE_PANES || process.env.SKS_ZELLIJ_VISIBLE_PANE_CAP || '8');
290
+ const zellijViewportSetting = readOption(cleanArgs, '--zellij-viewports', process.env.SKS_ZELLIJ_VIEWPORTS || '1');
291
+ const zellijRefreshMsSetting = readOption(cleanArgs, '--zellij-refresh-ms', process.env.SKS_ZELLIJ_REFRESH_MS || '1000');
292
+ const madSksEnv = {
293
+ SKS_PROTECTED_CORE_POLICY: madLaunch.gate.protected_core_policy,
294
+ SKS_MAD_SKS_TARGET_ROOT: madLaunch.gate.cwd,
295
+ SKS_MAD_SKS_PROTECTED_CORE_DIGEST: madLaunch.gate.protected_core_digest,
296
+ [SKS_ZELLIJ_HOST_MISSION_ENV]: madLaunch.mission_id,
297
+ SKS_ZELLIJ_VISIBLE_PANES: String(zellijVisiblePaneSetting),
298
+ SKS_ZELLIJ_VIEWPORTS: String(Math.max(0, Math.min(Number(zellijViewportSetting || 1), 3))),
299
+ SKS_ZELLIJ_REFRESH_MS: String(zellijRefreshMsSetting),
300
+ };
301
+ const explicitWorkspace = readOption(cleanArgs, '--workspace', readOption(cleanArgs, '--session', null));
302
+ const launchProfile = glmRuntime?.profile || profile;
303
+ const launchOpts = glmRuntime
304
+ ? buildGlmMadLaunchOpts(cleanArgs, {
305
+ codexArgs: launchProfile.launch_args,
306
+ conciseBlockers: true,
307
+ madSksEnv,
308
+ launchEnv: madSksEnv,
309
+ recoveryAllowUnverified: allowUnverifiedToolOutputRecovery,
310
+ codexBin: glmRuntime.wrapper.wrapper_path,
311
+ explicitWorkspace
312
+ })
313
+ : codexLbImmediateLaunchOpts(cleanArgs, launchLb, { codexArgs: launchProfile.launch_args, conciseBlockers: true, madSksEnv, launchEnv: madSksEnv, recoveryAllowUnverified: allowUnverifiedToolOutputRecovery });
314
+ // Only the auto-derived stable `sks-mad-<cwd>` name accumulates panes across
315
+ // runs; when the user names a session explicitly (or codex-lb already minted a
316
+ // fresh unique session) respect it and skip the reset.
317
+ const autoDerivedMadSession = !explicitWorkspace && !launchOpts.session;
318
+ const workspace = explicitWorkspace || launchOpts.session || `sks-mad-${sanitizeZellijSessionName(process.cwd())}`;
319
+ const launch = headlessZellij
320
+ ? await writeMadHeadlessZellijFallback(madLaunch, workspace)
321
+ : await launchMadZellijUi([...cleanArgs, '--workspace', workspace], { ...launchOpts, missionId: madLaunch.mission_id, root: madLaunch.root, cwd: process.cwd(), ledgerRoot: path.join(madLaunch.dir, 'agents'), slotCount: 0, freshSession: autoDerivedMadSession, requireZellij: process.env.SKS_REQUIRE_ZELLIJ === '1' });
322
+ const afterLaunchUi = beforeUi ? await writeCodexAppUiSnapshot(launchRoot, `mad-after-launch-${uiSnapshotId}`).catch(() => null) : null;
323
+ const launchUiDiff = beforeUi && afterLaunchUi ? diffCodexAppUiSnapshots(beforeUi, afterLaunchUi) : null;
324
+ if (launchUiDiff) {
325
+ await writeJsonAtomic(path.join(madLaunch.dir, 'codex-app-ui-diff.json'), launchUiDiff);
326
+ if (!launchUiDiff.ok) {
327
+ console.error('SKS MAD launch changed Codex App UI state. Run `sks doctor --fix`.');
328
+ process.exitCode = 1;
329
+ return launchUiDiff;
330
+ }
331
+ }
332
+ if (!launch.ok) {
333
+ console.log(`MAD Zellij action: ${formatMadZellijAction(launch)}`);
334
+ return launch;
335
+ }
336
+ await writeJsonAtomic(path.join(madLaunch.dir, 'zellij-initial-ui.json'), {
337
+ schema: 'sks.zellij-initial-ui.v1',
338
+ ok: true,
339
+ mission_id: madLaunch.mission_id,
340
+ session_name: launch.session_name || null,
341
+ live_panes: !headlessZellij,
342
+ initial_panes: 'orchestrator-monitor-viewports',
343
+ dashboard_created: true,
344
+ worker_panes_created: 0,
345
+ viewport_panes_created: Number(madSksEnv.SKS_ZELLIJ_VIEWPORTS),
346
+ ui_architecture: 'monitor_plus_viewports',
347
+ right_column_mode: 'monitor-plus-viewports'
348
+ });
349
+ const madNativeSwarmPromise = startMadNativeSwarm(madLaunch.root, madLaunch, args, launchProfile, {
350
+ env: {
351
+ ...madSksEnv,
352
+ ...(launch.session_name ? { SKS_ZELLIJ_SESSION_NAME: launch.session_name } : {})
353
+ },
354
+ glmLaunch: glmRuntime ? { provider: glmRuntime.profile.provider, model: glmRuntime.profile.model } : null,
355
+ zellijSessionName: launch.session_name || null,
356
+ workerPlacement: headlessZellij ? 'process' : shouldAutoAttachZellij(args) ? 'zellij-pane' : 'process',
357
+ zellijVisiblePaneCap: Number(process.env.SKS_ZELLIJ_VISIBLE_PANE_CAP || zellijVisiblePaneSetting || 8)
358
+ }).catch((err) => appendJsonlBounded(path.join(madLaunch.dir, 'events.jsonl'), { ts: nowIso(), type: 'mad_sks.native_swarm_background_failed', error: err?.message || String(err) }));
359
+ launchLifecycleTasks.push(madNativeSwarmPromise);
360
+ // The launcher only creates a detached background session. In an interactive
361
+ // terminal, immediately attach so the session actually opens for the user
362
+ // instead of leaving them to copy/paste the attach command by hand.
363
+ if (!headlessZellij && shouldAutoAttachZellij(args)) {
364
+ console.log(`Opening Zellij session: ${launch.session_name} (detach with Ctrl+q, re-attach later with: ${launch.attach_command_with_env})`);
365
+ const attached = attachZellijSessionInteractive(launch.session_name, { cwd: process.cwd(), configPath: launch.clipboard_config_path });
366
+ if (!attached.ok) {
367
+ console.log(`Could not open the Zellij session automatically${attached.error ? ` (${attached.error})` : ''}.`);
368
+ if (launch.attach_command_with_env)
369
+ console.log(`Attach with: ${launch.attach_command_with_env}`);
370
+ }
371
+ return launch;
354
372
  }
373
+ if (launch.attach_command_with_env)
374
+ console.log(`Attach with: ${launch.attach_command_with_env}`);
375
+ if (headlessZellij)
376
+ console.log('MAD launch running headless: live_panes=false.');
355
377
  return launch;
356
378
  }
357
- if (launch.attach_command_with_env)
358
- console.log(`Attach with: ${launch.attach_command_with_env}`);
359
- if (headlessZellij)
360
- console.log('MAD launch running headless: live_panes=false.');
361
- return launch;
379
+ finally {
380
+ await settleMadLaunchLifecycle(launchLifecycleTasks, madLaunch.dir);
381
+ }
382
+ }
383
+ export async function settleMadLaunchLifecycle(tasks, dir) {
384
+ if (tasks.length === 0)
385
+ return;
386
+ const settled = await Promise.allSettled(tasks);
387
+ await appendJsonlBounded(path.join(dir, 'events.jsonl'), {
388
+ ts: nowIso(),
389
+ type: 'mad_sks.launch_lifecycle_settled',
390
+ task_count: settled.length,
391
+ fulfilled_count: settled.filter((row) => row.status === 'fulfilled').length,
392
+ rejected_count: settled.filter((row) => row.status === 'rejected').length
393
+ }).catch(() => undefined);
362
394
  }
363
395
  function isMadGlmLaunch(args = [], deps = {}) {
364
396
  const list = (args || []).map((arg) => String(arg));
@@ -592,18 +624,26 @@ export async function startMadNativeSwarm(root, madLaunch, args = [], profile =
592
624
  }
593
625
  export function resolveMadNativeSwarmOptions(args = [], profile = {}, opts = {}) {
594
626
  const list = (args || []).map((arg) => String(arg));
627
+ const operatorEnabled = list.includes('--mad-native-swarm')
628
+ || list.includes('--mad-swarm')
629
+ || list.includes('--mad-agents')
630
+ || list.includes('--mad-swarm-agents')
631
+ || list.includes('--mad-swarm-prompt')
632
+ || process.env.SKS_MAD_NATIVE_SWARM === '1';
595
633
  const operatorDisabled = list.includes('--no-swarm') || list.includes('--no-mad-swarm') || process.env.SKS_MAD_NATIVE_SWARM === '0';
596
634
  const glmRequested = list.includes('--glm') || opts.glmLaunch?.provider === 'openrouter';
597
635
  const glmNativeSwarmDisabled = glmRequested && process.env.SKS_GLM_MAD_ALLOW_GPT_SWARM !== '1';
598
- const disabled = operatorDisabled || glmNativeSwarmDisabled;
599
- const agents = clampInt(readOption(list, '--mad-agents', readOption(list, '--mad-swarm-agents', process.env.SKS_MAD_SWARM_AGENTS || opts.agents || 5)), 1, 20);
636
+ const disabled = !operatorEnabled || operatorDisabled || glmNativeSwarmDisabled;
637
+ const agents = clampInt(readOption(list, '--mad-agents', readOption(list, '--mad-swarm-agents', process.env.SKS_MAD_SWARM_AGENTS || opts.agents || 1)), 1, 20);
600
638
  const workItems = clampInt(readOption(list, '--mad-swarm-work-items', process.env.SKS_MAD_SWARM_WORK_ITEMS || opts.workItems || agents), agents, 100);
601
639
  const backend = defaultMadSwarmBackend(list, opts);
602
640
  return {
603
641
  enabled: !disabled,
604
642
  disabled_reason: operatorDisabled
605
643
  ? 'operator_disabled_mad_native_swarm'
606
- : glmNativeSwarmDisabled ? 'glm_mad_native_swarm_disabled_to_block_gpt_fallback' : null,
644
+ : !operatorEnabled
645
+ ? 'official_subagent_runtime_default'
646
+ : glmNativeSwarmDisabled ? 'glm_mad_native_swarm_disabled_to_block_gpt_fallback' : null,
607
647
  agents,
608
648
  workItems,
609
649
  backend,
@@ -691,7 +731,6 @@ async function activateMadZellijPermissionState(cwd = process.cwd(), args = [])
691
731
  const has = (scope) => allowedScopes.has(scope);
692
732
  const dbWriteAllowed = has('db_write');
693
733
  const { id, dir } = await createMission(root, { mode: 'mad-sks', prompt: `${activatedBy} Zellij scoped high-power maintenance session` });
694
- void refreshMadNativeLaunchArtifacts(root, id, dir).catch((err) => appendJsonlBounded(path.join(dir, 'events.jsonl'), { ts: nowIso(), type: 'mad_sks.native_artifact_background_failed', error: err?.message || String(err) }));
695
734
  const protectedCore = resolveProtectedCore({ packageRoot: packageRoot(), targetRoot: cwd });
696
735
  // The interactive launch 'before' snapshot is only persisted (env + policy json)
697
736
  // and is never compared against an 'after' snapshot during the session, so the
@@ -782,7 +821,9 @@ async function activateMadZellijPermissionState(cwd = process.cwd(), args = [])
782
821
  stop_gate: 'mad-sks-gate.json',
783
822
  prompt: gate.activated_by
784
823
  });
785
- return { mission_id: id, dir, gate, root };
824
+ const nativeArtifactsPromise = refreshMadNativeLaunchArtifacts(root, id, dir)
825
+ .catch((err) => appendJsonlBounded(path.join(dir, 'events.jsonl'), { ts: nowIso(), type: 'mad_sks.native_artifact_background_failed', error: err?.message || String(err) }));
826
+ return { mission_id: id, dir, gate, root, lifecycle_tasks: [nativeArtifactsPromise] };
786
827
  }
787
828
  async function refreshMadNativeLaunchArtifacts(root, missionId, dir) {
788
829
  await writeCodex0138CapabilityArtifacts(root, { missionId }).catch(() => null);
@@ -832,6 +873,8 @@ function baseMadLaunchOnlyFlags() {
832
873
  '--confirm-destructive-delete',
833
874
  '--no-swarm',
834
875
  '--no-mad-swarm',
876
+ '--mad-native-swarm',
877
+ '--mad-swarm',
835
878
  '--mad-agents',
836
879
  '--mad-swarm-agents',
837
880
  '--mad-swarm-work-items',
@@ -844,7 +887,8 @@ function baseMadLaunchOnlyFlags() {
844
887
  '-y',
845
888
  '--dry-run',
846
889
  '--plan-only',
847
- '--ack'
890
+ '--ack',
891
+ CODEX_LB_TOOL_OUTPUT_RECOVERY_OVERRIDE_FLAG
848
892
  ]);
849
893
  }
850
894
  function glmMadLaunchOnlyFlags() {
@@ -873,6 +917,7 @@ function madLaunchValueFlags(includeGlmFlags = false) {
873
917
  '--mad-swarm-backend',
874
918
  '--mad-swarm-prompt',
875
919
  '--zellij-visible-panes',
920
+ '--zellij-viewports',
876
921
  '--zellij-refresh-ms',
877
922
  '--ack'
878
923
  ]);