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.
Files changed (376) hide show
  1. package/README.md +150 -37
  2. package/config/skills-hash-ledger.v1.json +1 -1
  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 +55 -27
  6. package/dist/bin/install.js +6 -32
  7. package/dist/bin/sks-dispatch.js +1 -1
  8. package/dist/cli/args.js +0 -2
  9. package/dist/cli/cli-theme.js +18 -9
  10. package/dist/cli/command-manifest-lite.js +6 -6
  11. package/dist/cli/command-registry.js +6 -6
  12. package/dist/cli/feature-commands.js +9 -7
  13. package/dist/cli/install-helpers-codex-lb-chain.js +198 -7
  14. package/dist/cli/install-helpers-codex-lb-config.js +78 -10
  15. package/dist/cli/install-helpers-install-support.js +9 -6
  16. package/dist/cli/install-helpers.js +101 -49
  17. package/dist/cli/install-tool-helpers.js +2 -82
  18. package/dist/cli/output.js +6 -1
  19. package/dist/cli/router.js +101 -2
  20. package/dist/commands/codex-lb.js +119 -19
  21. package/dist/commands/doctor-profile.js +1 -1
  22. package/dist/commands/doctor.js +727 -144
  23. package/dist/commands/mad-sks.js +1 -5
  24. package/dist/config/skills-manifest.json +4 -2
  25. package/dist/core/agents/agent-codex-cockpit.js +0 -3
  26. package/dist/core/agents/agent-effort-policy.js +5 -5
  27. package/dist/core/agents/agent-janitor.js +0 -20
  28. package/dist/core/agents/agent-orchestrator.js +9 -56
  29. package/dist/core/agents/agent-output-validator.js +2 -3
  30. package/dist/core/agents/agent-patch-schema.js +2 -2
  31. package/dist/core/agents/agent-proof-evidence.js +0 -65
  32. package/dist/core/agents/agent-recursion-guard.js +1 -1
  33. package/dist/core/agents/agent-runner-codex-exec.js +5 -3
  34. package/dist/core/agents/agent-scheduler.js +327 -85
  35. package/dist/core/agents/agent-schema.js +1 -1
  36. package/dist/core/agents/agent-trust-report.js +0 -36
  37. package/dist/core/agents/agent-worker-pipeline.js +0 -1
  38. package/dist/core/agents/fast-mode-policy.js +1 -3
  39. package/dist/core/agents/native-cli-worker-runtime-proof.js +1 -1
  40. package/dist/core/agents/native-cli-worker-runtime.js +69 -647
  41. package/dist/core/agents/native-cli-worker.js +6 -7
  42. package/dist/core/agents/native-worker-backend-router.js +2 -32
  43. package/dist/core/agents/no-subagent-scaling-policy.js +1 -1
  44. package/dist/core/agents/parallel-runtime-proof.js +1 -6
  45. package/dist/core/agents/runtime-proof-summary.js +1 -35
  46. package/dist/core/architecture-hardening/contracts/contracts.js +193 -0
  47. package/dist/core/architecture-hardening/migration/migration.js +111 -0
  48. package/dist/core/architecture-hardening/state/state-service.js +155 -0
  49. package/dist/core/artifact-schemas.js +0 -3
  50. package/dist/core/codex/codex-config-guard.js +238 -52
  51. package/dist/core/codex-adapter.js +5 -3
  52. package/dist/core/codex-app/auxiliary-oauth-policy.js +36 -0
  53. package/dist/core/codex-app/catalog-compat/catalog-service.js +104 -0
  54. package/dist/core/codex-app/child-policy/child-policy.js +35 -0
  55. package/dist/core/codex-app/codex-app-handoff.js +0 -1
  56. package/dist/core/codex-app/codex-hook-lifecycle.js +1 -1
  57. package/dist/core/codex-app/codex-init-deep.js +1 -1
  58. package/dist/core/codex-app/menubar/app-bundle.js +2 -0
  59. package/dist/core/codex-app/menubar/constants.js +14 -1
  60. package/dist/core/codex-app/menubar/global-install.js +288 -0
  61. package/dist/core/codex-app/menubar/installer.js +79 -14
  62. package/dist/core/codex-app/menubar/launch-agent.js +267 -45
  63. package/dist/core/codex-app/menubar/paths.js +3 -0
  64. package/dist/core/codex-app/menubar/rollback.js +55 -7
  65. package/dist/core/codex-app/menubar/status.js +75 -4
  66. package/dist/core/codex-app/provider-child-policy.js +64 -0
  67. package/dist/core/codex-app/provider-mode.js +91 -0
  68. package/dist/core/codex-app/provider-operation-stages.js +20 -0
  69. package/dist/core/codex-app/provider-session-policy.js +85 -0
  70. package/dist/core/codex-app/session-policy/session-pinning.js +68 -0
  71. package/dist/core/codex-app.js +3 -2
  72. package/dist/core/codex-control/codex-0139-image-path-real-probe.js +3 -1
  73. package/dist/core/codex-control/codex-0139-web-search-probe.js +3 -1
  74. package/dist/core/codex-control/codex-app-server-runtime-env.js +13 -4
  75. package/dist/core/codex-control/codex-app-server-v2-client.js +3 -3
  76. package/dist/core/codex-control/codex-control-proof.js +0 -1
  77. package/dist/core/codex-control/codex-task-runner.js +1 -4
  78. package/dist/core/codex-exec-output-schema.js +4 -1
  79. package/dist/core/codex-lb/codex-lb-env.js +63 -72
  80. package/dist/core/codex-lb/codex-lb-setup.js +15 -2
  81. package/dist/core/codex-lb/desktop-bridge/header-policy.js +6 -0
  82. package/dist/core/codex-lb/desktop-bridge/http-forward.js +48 -6
  83. package/dist/core/codex-lb/desktop-bridge/security.js +134 -0
  84. package/dist/core/codex-lb/desktop-bridge/server.js +9 -3
  85. package/dist/core/codex-lb/desktop-bridge/state.js +26 -6
  86. package/dist/core/codex-lb/desktop-bridge/types.js +1 -0
  87. package/dist/core/codex-lb/desktop-center-credentials.js +517 -58
  88. package/dist/core/codex-lb/desktop-controller.js +177 -56
  89. package/dist/core/codex-lb/desktop-service.js +179 -40
  90. package/dist/core/codex-lb/legacy-migration.js +1 -3
  91. package/dist/core/codex-lb/native-openai-transport/transport.js +68 -0
  92. package/dist/core/codex-lb/probes/cli-image-tool-probe.js +1 -1
  93. package/dist/core/codex-lb/provider-routing/provider-router.js +58 -0
  94. package/dist/core/codex-lb/routing-truth.js +327 -0
  95. package/dist/core/codex-native/codex-native-feature-broker.js +4 -0
  96. package/dist/core/codex-native/codex-native-pattern-analysis.js +1 -2
  97. package/dist/core/codex-native/core-skill-manifest.js +1 -1
  98. package/dist/core/codex-plugins/codex-plugin-json.js +26 -6
  99. package/dist/core/codex-plugins/codex-plugin-repair.js +32 -6
  100. package/dist/core/commands/basic-cli.js +9 -7
  101. package/dist/core/commands/computer-use-command.js +1 -1
  102. package/dist/core/commands/image-ux-review-command.js +16 -9
  103. package/dist/core/commands/install-package-command.js +105 -0
  104. package/dist/core/commands/intent-normalization/normalizer.js +96 -0
  105. package/dist/core/commands/mad-sks-command.js +23 -274
  106. package/dist/core/commands/mad-sks-headless.js +11 -30
  107. package/dist/core/commands/naruto-command.js +0 -25
  108. package/dist/core/commands/qa-loop-command.js +104 -22
  109. package/dist/core/commands/remote-command.js +2 -2
  110. package/dist/core/commands/research-command.js +10 -5
  111. package/dist/core/commands/telegram-command.js +407 -0
  112. package/dist/core/config-adopt/config-adopt-command.js +35 -0
  113. package/dist/core/config-adopt/config-adopt.js +346 -0
  114. package/dist/core/config-adopt/index.js +3 -0
  115. package/dist/core/doctor/command-alias-cleanup.js +4 -1
  116. package/dist/core/doctor/current-project-guidance-nested.js +37 -6
  117. package/dist/core/doctor/current-project-guidance.js +15 -9
  118. package/dist/core/doctor/doctor-dirty-planner.js +1 -4
  119. package/dist/core/doctor/doctor-readiness-matrix.js +15 -18
  120. package/dist/core/doctor/retired-managed-residue-private.js +4 -3
  121. package/dist/core/doctor/retired-managed-residue-runtime.js +2 -2
  122. package/dist/core/doctor/skill-legacy-surface.js +11 -10
  123. package/dist/core/doctor/sks-menubar-doctor.js +4 -0
  124. package/dist/core/evaluation.js +0 -19
  125. package/dist/core/evidence/v2/evidence-key.js +105 -0
  126. package/dist/core/feature-fixtures.js +12 -7
  127. package/dist/core/feature-registry.js +52 -21
  128. package/dist/core/hooks-runtime/hook-context.js +9 -0
  129. package/dist/core/hooks-runtime/managed-skill-admission.js +54 -4
  130. package/dist/core/hooks-runtime/official-subagent-lifecycle.js +69 -52
  131. package/dist/core/hooks-runtime/stop-finalization.js +226 -0
  132. package/dist/core/hooks-runtime/stop-repeat-guard.js +21 -2
  133. package/dist/core/hooks-runtime/subagent-skill-availability-contract.js +2 -2
  134. package/dist/core/hooks-runtime/subagent-skill-availability-evidence.js +3 -3
  135. package/dist/core/hooks-runtime/subagent-skill-availability-guards.js +43 -5
  136. package/dist/core/hooks-runtime/subagent-skill-availability.js +64 -30
  137. package/dist/core/hooks-runtime/subagent-stop-hook.js +15 -2
  138. package/dist/core/hooks-runtime.js +179 -212
  139. package/dist/core/image/reference-evidence/reference-registry.js +145 -0
  140. package/dist/core/image-ux-review/imagegen-adapter.js +21 -9
  141. package/dist/core/image-ux-review/reference-policy/reference-policy.js +9 -0
  142. package/dist/core/imagegen/codex-lb-imagegen-target.js +8 -0
  143. package/dist/core/imagegen/imagegen-capability.js +59 -2
  144. package/dist/core/imagegen/require-imagegen.js +2 -2
  145. package/dist/core/init/skills.js +17 -3
  146. package/dist/core/init.js +3 -3
  147. package/dist/core/install/installed-package-smoke.js +23 -5
  148. package/dist/core/json/canonical.js +9 -0
  149. package/dist/core/locks/file-lock.js +0 -1
  150. package/dist/core/loops/loop-continuation-enforcer.js +65 -7
  151. package/dist/core/loops/loop-decomposer.js +0 -1
  152. package/dist/core/loops/loop-gate-runner.js +65 -4
  153. package/dist/core/loops/loop-gate-selector.js +0 -2
  154. package/dist/core/loops/loop-proof-validation.js +38 -0
  155. package/dist/core/loops/loop-risk-classifier.js +1 -1
  156. package/dist/core/loops/loop-runtime.js +14 -2
  157. package/dist/core/loops/loop-scheduler.js +7 -2
  158. package/dist/core/loops/loop-worker-runtime.js +0 -15
  159. package/dist/core/loops/loop-worktree-runtime.js +52 -4
  160. package/dist/core/managed-assets/managed-assets-manifest.js +14 -14
  161. package/dist/core/naruto/hardware-capacity-probe.js +9 -6
  162. package/dist/core/naruto/naruto-active-pool.js +2 -14
  163. package/dist/core/naruto/naruto-concurrency-governor.js +71 -31
  164. package/dist/core/naruto/naruto-loop-worker-router.js +0 -2
  165. package/dist/core/naruto/naruto-verification-dag.js +0 -1
  166. package/dist/core/naruto/naruto-write-e2e.js +1 -2
  167. package/dist/core/naruto/resource-pressure-monitor.js +0 -4
  168. package/dist/core/observability/architecture-hardening/safe-projection.js +65 -0
  169. package/dist/core/perf/import-graph-budget.js +0 -1
  170. package/dist/core/perf/release-latency-slo.js +3 -2
  171. package/dist/core/preflight/parallel-preflight-engine.js +2 -15
  172. package/dist/core/product-design-app-server.js +13 -1
  173. package/dist/core/proof/fake-real-proof-policy.js +2 -17
  174. package/dist/core/proof/route-proof-gate.js +2 -10
  175. package/dist/core/proof/route-proof-policy.js +1 -1
  176. package/dist/core/proof/runtime-evidence-policy.js +185 -0
  177. package/dist/core/proof/runtime-truth-matrix.js +64 -39
  178. package/dist/core/proof/validation.js +27 -11
  179. package/dist/core/provider/provider-context.js +18 -2
  180. package/dist/core/providers/openrouter/openrouter-account.js +3 -2
  181. package/dist/core/python-tools/python-tool-runner.js +1 -1
  182. package/dist/core/qa-loop/qa-execution-control.js +57 -0
  183. package/dist/core/questions.js +1 -1
  184. package/dist/core/release/extreme-parallel-scheduler.js +0 -3
  185. package/dist/core/release/gate-manifest.js +3 -7
  186. package/dist/core/release/gate-pack-manifest.js +3 -7
  187. package/dist/core/release/package-size-budget.js +2 -2
  188. package/dist/core/release/physical-release-gates.js +189 -0
  189. package/dist/core/release/publish-preflight.js +113 -0
  190. package/dist/core/release/release-gate-affected-selector.js +0 -2
  191. package/dist/core/release/release-gate-batch-runner.js +1 -1
  192. package/dist/core/release/release-gate-node.js +0 -1
  193. package/dist/core/release/release-gate-resource-governor.js +0 -1
  194. package/dist/core/release/release-pack-receipt.js +5 -8
  195. package/dist/core/release/release-real-contract.js +0 -6
  196. package/dist/core/release/resource-class-budget.js +0 -1
  197. package/dist/core/release/stage-publish.js +178 -36
  198. package/dist/core/research/research-adversarial-review.js +103 -9
  199. package/dist/core/research.js +1 -1
  200. package/dist/core/retention.js +0 -1
  201. package/dist/core/routes/constants.js +1 -1
  202. package/dist/core/routes/diagnostic-allowlist.js +0 -1
  203. package/dist/core/routes/dollar-manifest-lite.js +1 -1
  204. package/dist/core/routes.js +46 -15
  205. package/dist/core/runtime/execution-control.js +226 -0
  206. package/dist/core/runtime/progress-recovery/progress-recovery.js +89 -0
  207. package/dist/core/runtime/task-profile.js +10 -4
  208. package/dist/core/runtime/verification-budget.js +10 -1
  209. package/dist/core/safety/intent-contract/intent-contract.js +94 -0
  210. package/dist/core/safety/mutation-guard.js +0 -2
  211. package/dist/core/safety/mutation-ledger.js +0 -2
  212. package/dist/core/safety/requested-scope-contract.js +0 -0
  213. package/dist/core/search-visibility/discovery.js +1 -1
  214. package/dist/core/search-visibility/index.js +12 -0
  215. package/dist/core/search-visibility/verifier.js +112 -3
  216. package/dist/core/security/private-credential-file.js +209 -0
  217. package/dist/core/session/project-namespace.js +0 -5
  218. package/dist/core/skills/skill-agent-metadata.js +1 -3
  219. package/dist/core/strategy/adhd-orchestrating-gate.js +0 -1
  220. package/dist/core/subagents/agent-catalog.js +19 -34
  221. package/dist/core/subagents/model-policy.js +65 -24
  222. package/dist/core/subagents/naruto-help-contract.js +8 -8
  223. package/dist/core/subagents/naruto-host-credentials.js +13 -0
  224. package/dist/core/subagents/official-subagent-config.js +16 -6
  225. package/dist/core/subagents/official-subagent-preparation.js +35 -16
  226. package/dist/core/subagents/official-subagent-prompt.js +7 -7
  227. package/dist/core/subagents/official-subagent-runner.js +27 -4
  228. package/dist/core/subagents/role-model-preferences.js +1 -1
  229. package/dist/core/subagents/thread-budget.js +19 -12
  230. package/dist/core/subagents/wave-lifecycle.js +18 -6
  231. package/dist/core/telegram/access.js +58 -0
  232. package/dist/core/telegram/client.js +157 -0
  233. package/dist/core/telegram/confirmation.js +37 -0
  234. package/dist/core/telegram/doctor.js +154 -0
  235. package/dist/core/telegram/index.js +9 -0
  236. package/dist/core/telegram/keychain.js +317 -0
  237. package/dist/core/telegram/liveness.js +118 -0
  238. package/dist/core/telegram/poller.js +90 -0
  239. package/dist/core/telegram/redaction.js +15 -0
  240. package/dist/core/telegram/state-lock.js +416 -0
  241. package/dist/core/telegram/types.js +1 -0
  242. package/dist/core/text/strings.js +3 -0
  243. package/dist/core/triwiki/context-graph/store/evidence-write-lock.js +29 -0
  244. package/dist/core/triwiki/context-graph/store/fragment-cache.js +24 -0
  245. package/dist/core/triwiki/context-graph/store/snapshot-store.js +69 -21
  246. package/dist/core/triwiki/triwiki-gate-impact-map.js +2 -2
  247. package/dist/core/triwiki/triwiki-module-card.js +1 -2
  248. package/dist/core/update/installed-cli-resolution.js +170 -0
  249. package/dist/core/update/update-diagnostics.js +52 -0
  250. package/dist/core/update/update-migration-state.js +30 -12
  251. package/dist/core/update/update-operation.js +2 -1
  252. package/dist/core/update/update-stage-diagnostics.js +38 -0
  253. package/dist/core/update/update-status.js +2 -9
  254. package/dist/core/update-check.js +279 -91
  255. package/dist/core/version.js +1 -1
  256. package/dist/native/sks-menubar/Sources/AppDelegate.swift +19 -1
  257. package/dist/native/sks-menubar/Sources/AppIdentity.swift +7 -0
  258. package/dist/native/sks-menubar/Sources/ControlCenterWindowController.swift +6 -2
  259. package/dist/native/sks-menubar/Sources/OperationCoordinator.swift +159 -92
  260. package/dist/native/sks-menubar/Sources/OperationModels.swift +389 -0
  261. package/dist/native/sks-menubar/Sources/OverviewViewController.swift +57 -0
  262. package/dist/native/sks-menubar/Sources/ProcessClient.swift +3 -1
  263. package/dist/native/sks-menubar/Sources/ProvidersConnectTest.swift +115 -0
  264. package/dist/native/sks-menubar/Sources/ProvidersFastMode.swift +17 -0
  265. package/dist/native/sks-menubar/Sources/ProvidersMultiProvider.swift +3 -0
  266. package/dist/native/sks-menubar/Sources/ProvidersOpenRouter.swift +58 -17
  267. package/dist/native/sks-menubar/Sources/ProvidersReliability.swift +302 -0
  268. package/dist/native/sks-menubar/Sources/ProvidersRoleModels.swift +5 -0
  269. package/dist/native/sks-menubar/Sources/ProvidersRoutingTruth.swift +190 -0
  270. package/dist/native/sks-menubar/Sources/ProvidersViewController.swift +158 -126
  271. package/dist/native/sks-menubar/Sources/RemoteCodingViewController.swift +462 -26
  272. package/dist/native/sks-menubar/Sources/SKSKeychainStore.swift +344 -0
  273. package/dist/native/sks-menubar/Sources/SecureProcessEnvelope.swift +27 -0
  274. package/dist/native/sks-menubar/Sources/SingletonInstanceGuard.swift +328 -0
  275. package/dist/native/sks-menubar/Sources/StatusItemController.swift +10 -2
  276. package/dist/native/sks-menubar/Sources/TelegramPrivateFileStore.swift +498 -0
  277. package/dist/native/sks-menubar/Sources/TelegramPrivateFileSupport.swift +236 -0
  278. package/dist/native/sks-menubar/Sources/TelegramProcessGateway.swift +454 -0
  279. package/dist/native/sks-menubar/Sources/TelegramRuntimeSupport.swift +56 -0
  280. package/dist/native/sks-menubar/Sources/TelegramStateLock.swift +448 -0
  281. package/dist/native/sks-menubar/Sources/TelegramSupport.swift +187 -0
  282. package/dist/native/sks-menubar/Sources/TelegramTransport.swift +499 -0
  283. package/dist/native/sks-menubar/Sources/main.swift +15 -1
  284. package/dist/scripts/all-feature-deep-completion-check.js +5 -1
  285. package/dist/scripts/check-publish-tag.js +56 -0
  286. package/dist/scripts/codex-lb-fast-mode-truth-check.js +10 -3
  287. package/dist/scripts/codex-lb-fast-ui-preservation-check.js +12 -3
  288. package/dist/scripts/codex-lb-gpt56-fast-profile-check.js +4 -2
  289. package/dist/scripts/codex-native-agent-role-content-check.js +3 -3
  290. package/dist/scripts/codex-native-gate-lib.js +14 -7
  291. package/dist/scripts/current-command-surface-check.js +7 -7
  292. package/dist/scripts/current-surface-update-e2e-check.js +4 -3
  293. package/dist/scripts/current-upgrade-matrix-check.js +5 -24
  294. package/dist/scripts/docs-truthfulness-check.js +17 -13
  295. package/dist/scripts/gate-lib.js +0 -2
  296. package/dist/scripts/gate-policy-audit-check.js +3 -2
  297. package/dist/scripts/harness-benchmark-check.js +1 -1
  298. package/dist/scripts/init-deep-backup-retention-check.js +1 -1
  299. package/dist/scripts/lib/codex-sdk-gate-lib.js +1 -2
  300. package/dist/scripts/loop-directive-check-lib.js +28 -38
  301. package/dist/scripts/mad-sks-app-ui-no-mutation-check.js +14 -180
  302. package/dist/scripts/mad-sks-launch-sql-plane-boundary-check.js +2 -11
  303. package/dist/scripts/official-subagent-workflow-check.js +1 -1
  304. package/dist/scripts/packlist-performance-check.js +1 -2
  305. package/dist/scripts/prepublish-release-check-or-fast.js +32 -0
  306. package/dist/scripts/publish-preflight.js +12 -0
  307. package/dist/scripts/release-affected-selector-check.js +2 -2
  308. package/dist/scripts/release-gate-batch-runner-check.js +2 -2
  309. package/dist/scripts/release-metadata-check.js +8 -12
  310. package/dist/scripts/release-real-check.js +2 -54
  311. package/dist/scripts/runtime-domain-gate-lib.js +2 -96
  312. package/dist/scripts/runtime-proof-summary-check.js +2 -6
  313. package/dist/scripts/search-visibility-gate-lib.js +0 -1
  314. package/dist/scripts/sks-cli-gate-lib.js +1 -1
  315. package/dist/scripts/typed-routing-gate-lib.js +7 -59
  316. package/docs/demo.tape +1 -1
  317. package/infra-harness-gates.json +1 -1456
  318. package/package.json +10 -7
  319. package/release-gates.v2.json +0 -1
  320. package/schemas/agents/parallel-runtime-proof.schema.json +0 -2
  321. package/schemas/codex/agent-result.schema.json +0 -6
  322. package/schemas/naruto/naruto-concurrency-governor.schema.json +1 -3
  323. package/schemas/release/release-gate-node.schema.json +1 -1
  324. package/dist/commands/zellij-lane.js +0 -22
  325. package/dist/commands/zellij-monitor-pane.js +0 -26
  326. package/dist/commands/zellij-slot-column-anchor.js +0 -22
  327. package/dist/commands/zellij-slot-pane.js +0 -80
  328. package/dist/commands/zellij-viewport-pane.js +0 -57
  329. package/dist/commands/zellij.js +0 -422
  330. package/dist/core/agents/agent-runner-zellij.js +0 -164
  331. package/dist/core/agents/agent-slot-pane-binding-proof.js +0 -96
  332. package/dist/core/agents/parallel-write-fixture.js +0 -305
  333. package/dist/core/agents/worker-pane-communication-contract.js +0 -100
  334. package/dist/core/agents/zellij-lane-supervisor.js +0 -428
  335. package/dist/core/agents/zellij-right-lane-cockpit.js +0 -66
  336. package/dist/core/doctor/doctor-zellij-repair.js +0 -40
  337. package/dist/core/ops/upgrade-migration-fixtures.js +0 -119
  338. package/dist/core/proof/route-finalizer-fixtures.js +0 -21
  339. package/dist/core/zellij/homebrew-policy.js +0 -43
  340. package/dist/core/zellij/zellij-capability.js +0 -126
  341. package/dist/core/zellij/zellij-clipboard-config.js +0 -52
  342. package/dist/core/zellij/zellij-command.js +0 -149
  343. package/dist/core/zellij/zellij-fake-adapter.js +0 -186
  344. package/dist/core/zellij/zellij-lane-renderer.js +0 -706
  345. package/dist/core/zellij/zellij-lane-runtime.js +0 -189
  346. package/dist/core/zellij/zellij-launcher.js +0 -268
  347. package/dist/core/zellij/zellij-layout-builder.js +0 -191
  348. package/dist/core/zellij/zellij-monitor-renderer.js +0 -52
  349. package/dist/core/zellij/zellij-official-subagent-activity.js +0 -526
  350. package/dist/core/zellij/zellij-official-subagent-telemetry.js +0 -258
  351. package/dist/core/zellij/zellij-pane-proof.js +0 -226
  352. package/dist/core/zellij/zellij-right-column-manager.js +0 -308
  353. package/dist/core/zellij/zellij-screen-proof.js +0 -120
  354. package/dist/core/zellij/zellij-self-heal-types.js +0 -44
  355. package/dist/core/zellij/zellij-self-heal.js +0 -408
  356. package/dist/core/zellij/zellij-slot-column-anchor.js +0 -304
  357. package/dist/core/zellij/zellij-slot-pane-renderer.js +0 -521
  358. package/dist/core/zellij/zellij-slot-telemetry.js +0 -384
  359. package/dist/core/zellij/zellij-theme.js +0 -66
  360. package/dist/core/zellij/zellij-ui-mode.js +0 -34
  361. package/dist/core/zellij/zellij-update.js +0 -348
  362. package/dist/core/zellij/zellij-viewport-binder.js +0 -61
  363. package/dist/core/zellij/zellij-worker-pane-manager.js +0 -881
  364. package/dist/core/zellij/zellij-worker-pane-summary.js +0 -64
  365. package/dist/native/sks-menubar/Tests/AppRuntimeTestSupport.swift +0 -26
  366. package/dist/native/sks-menubar/Tests/OperationCoordinatorTests.swift +0 -174
  367. package/dist/native/sks-menubar/Tests/ProcessClientTests.swift +0 -20
  368. package/dist/native/sks-menubar/Tests/ProvidersViewControllerTests.swift +0 -142
  369. package/dist/scripts/zellij-pane-proof-check.js +0 -88
  370. package/dist/scripts/zellij-real-session-cleanup-check.js +0 -139
  371. package/dist/scripts/zellij-real-session-launch-check.js +0 -126
  372. package/dist/scripts/zellij-screen-proof-check.js +0 -43
  373. package/schemas/zellij/zellij-right-column-state.schema.json +0 -40
  374. package/schemas/zellij/zellij-slot-telemetry.schema.json +0 -89
  375. package/schemas/zellij/zellij-worker-pane.schema.json +0 -53
  376. package/scripts/build-clean-atomic.mjs +0 -323
@@ -1,52 +0,0 @@
1
- import { resolveZellijTheme, paint, statusBadge, progressBar, elapsed, ANSI_CODES } from './zellij-theme.js';
2
- export function renderZellijMonitor(input) {
3
- const theme = resolveZellijTheme();
4
- const width = theme.width;
5
- const slots = Object.entries(input.snapshot?.slots || {}).map(([key, value]) => ({ key, ...value }));
6
- const now = Date.now();
7
- const by = (statuses) => slots.filter((slot) => statuses.includes(String(slot.status || '').toLowerCase()));
8
- const running = by(['running']);
9
- const verifying = by(['verifying']);
10
- const queued = by(['queued', 'launching']);
11
- const done = by(['done', 'completed', 'drained']);
12
- const failed = by(['failed', 'blocked', 'timed_out']);
13
- const generations = [...new Set(slots.map((slot) => Number(slot.generation_index || 1)))].sort((a, b) => b - a);
14
- const line1 = [
15
- paint(theme, ANSI_CODES.green, `run ${running.length}`),
16
- paint(theme, ANSI_CODES.cyan, `verify ${verifying.length}`),
17
- paint(theme, ANSI_CODES.gray, `queue ${queued.length}`),
18
- paint(theme, ANSI_CODES.green, `done ${done.length}`),
19
- paint(theme, ANSI_CODES.red, `fail ${failed.length}`)
20
- ].join(' ');
21
- const line2 = paint(theme, ANSI_CODES.dim, `gen-${generations[0] || 1} active | spawned ${slots.length} total | flush #${input.snapshot?.flush_count ?? '-'}`);
22
- const maxRows = Math.max(4, Number(process.env.SKS_ZELLIJ_MONITOR_ROWS || 12));
23
- const activityTs = (slot) => Date.parse(String(slot.latest_ts || '')) || 0;
24
- const visible = [...failed.filter((slot) => now - activityTs(slot) < 3 * 60_000), ...running, ...verifying, ...queued]
25
- .sort((a, b) => activityTs(b) - activityTs(a) || String(a.key).localeCompare(String(b.key)))
26
- .slice(0, maxRows);
27
- const failedKeys = new Set(failed.map((slot) => slot.key));
28
- const rows = visible.map((slot) => {
29
- const prog = slot.progress?.total > 0
30
- ? progressBar(theme, slot.progress.done, slot.progress.total, 6)
31
- : paint(theme, ANSI_CODES.dim, elapsed(slot.latest_ts) || '');
32
- const doing = firstMeaningfulLine(slot.task_title) || slot.current_file || '';
33
- return `${statusBadge(theme, slot.status)} ${String(slot.slot_id).padEnd(9)} g${slot.generation_index ?? 1} ${String(slot.role || '').slice(0, 9).padEnd(9)} ${prog} ${clip(doing, width - 42)}`;
34
- });
35
- const hiddenActive = Math.max(0, running.length + verifying.length + queued.length - visible.filter((slot) => !failedKeys.has(slot.key)).length);
36
- const footerParts = [
37
- hiddenActive ? `+${hiddenActive} more active` : null,
38
- done.length ? `+${done.length} done` : null,
39
- failed.length ? `+${failed.length} failed` : null
40
- ].filter((part) => Boolean(part));
41
- const footer = paint(theme, ANSI_CODES.dim, footerParts.join(' | ') || 'all agents visible');
42
- return [line1, line2, paint(theme, ANSI_CODES.dim, '-'.repeat(Math.max(10, width - 2))), ...rows, footer].join('\n');
43
- }
44
- function firstMeaningfulLine(s) {
45
- return String(s || '')
46
- .split('\n')
47
- .map((line) => line.trim())
48
- .find((line) => line && !/^Parent |^Naruto owner|^Allocation|^Read-only/i.test(line)) || '';
49
- }
50
- function clip(s, w) {
51
- return s.length > w ? `${s.slice(0, Math.max(0, w - 1))}…` : s;
52
- }
@@ -1,526 +0,0 @@
1
- import fsp from 'node:fs/promises';
2
- import os from 'node:os';
3
- import path from 'node:path';
4
- import { nowIso, sha256 } from '../fsx.js';
5
- import { appendZellijSlotTelemetry, readZellijSlotTelemetrySnapshot } from './zellij-slot-telemetry.js';
6
- const DEFAULT_TAIL_BYTES = 256 * 1024;
7
- const DEFAULT_HEAD_BYTES = 1024 * 1024;
8
- const DEFAULT_REFRESH_MIN_MS = 2_000;
9
- const DEFAULT_HEARTBEAT_MS = 5_000;
10
- const MAX_DISCOVERY_DAY_DIRS = 45;
11
- const MIN_SUPPORTED_CODEX_ROLLOUT_VERSION = '0.144.1';
12
- const rolloutPathCache = new Map();
13
- export async function readOfficialSubagentRolloutActivity(input) {
14
- const threadId = safeThreadId(input.threadId);
15
- if (!threadId)
16
- return null;
17
- const env = input.env || process.env;
18
- const codexHome = path.resolve(String(env.CODEX_HOME || path.join(env.HOME || os.homedir(), '.codex')));
19
- const rolloutPath = await locateOfficialSubagentRollout(codexHome, threadId, input.startedAt);
20
- if (!rolloutPath)
21
- return null;
22
- const identity = await readRolloutIdentity(rolloutPath);
23
- if (!identity
24
- || identity.thread_id !== threadId
25
- || identity.official_subagent !== true
26
- || !versionAtLeast(identity.cli_version, MIN_SUPPORTED_CODEX_ROLLOUT_VERSION))
27
- return null;
28
- const tailBytes = boundedInt(input.tailBytes ?? env.SKS_ZELLIJ_OFFICIAL_ACTIVITY_TAIL_BYTES, DEFAULT_TAIL_BYTES, 64 * 1024, 1024 * 1024);
29
- const tail = await readRolloutTail(rolloutPath, tailBytes);
30
- if (!tail)
31
- return null;
32
- const birthMs = Date.parse(identity.spawned_at);
33
- const startMs = Date.parse(String(input.startedAt || ''));
34
- const activityCutoffMs = Math.max(Number.isFinite(birthMs) ? birthMs : 0, Number.isFinite(startMs) ? startMs : 0);
35
- const rows = tail.rows.filter((row) => {
36
- const ts = Date.parse(String(row?.timestamp || ''));
37
- return Number.isFinite(ts) && ts > activityCutoffMs;
38
- });
39
- if (!rows.length)
40
- return null;
41
- const summaries = [];
42
- let model = null;
43
- let reasoningEffort = null;
44
- for (const row of rows) {
45
- if (row?.type === 'turn_context') {
46
- model = firstKnown(row?.payload?.model, model);
47
- reasoningEffort = firstKnown(row?.payload?.effort, row?.payload?.reasoning_effort, reasoningEffort);
48
- }
49
- const summary = summarizeRolloutRow(row, input.projectRoot || null);
50
- if (summary)
51
- summaries.push(summary);
52
- }
53
- if (!model || !reasoningEffort) {
54
- const headBytes = boundedInt(env.SKS_ZELLIJ_OFFICIAL_ACTIVITY_HEAD_BYTES, DEFAULT_HEAD_BYTES, 64 * 1024, 8 * 1024 * 1024);
55
- const head = await readRolloutHeadTurnContext(rolloutPath, headBytes, activityCutoffMs);
56
- model = model || firstKnown(head?.model);
57
- reasoningEffort = reasoningEffort || firstKnown(head?.effort, head?.reasoning_effort);
58
- }
59
- const latest = summaries.at(-1);
60
- if (!latest) {
61
- const sourceUpdatedAt = new Date(tail.mtime_ms).toISOString();
62
- return {
63
- thread_id: threadId,
64
- rollout_path: rolloutPath,
65
- observed_at: nowIso(),
66
- source_updated_at: sourceUpdatedAt,
67
- source_size: tail.size,
68
- activity_hash: sha256(`${threadId}:${tail.size}:${sourceUpdatedAt}:heartbeat`).slice(0, 24),
69
- activity_kind: 'heartbeat',
70
- event_type: 'heartbeat',
71
- task_title: 'agent active',
72
- current_file: null,
73
- log_tail: 'Codex subagent is active; waiting for the next visible activity item.',
74
- model,
75
- reasoning_effort: reasoningEffort
76
- };
77
- }
78
- const visible = uniqueSummaries(summaries).slice(-4);
79
- const sourceUpdatedAt = latest.timestamp || new Date(tail.mtime_ms).toISOString();
80
- const activityHash = sha256(JSON.stringify({
81
- thread_id: threadId,
82
- source_size: tail.size,
83
- latest: latest.identity,
84
- source_updated_at: sourceUpdatedAt
85
- })).slice(0, 24);
86
- return {
87
- thread_id: threadId,
88
- rollout_path: rolloutPath,
89
- observed_at: nowIso(),
90
- source_updated_at: sourceUpdatedAt,
91
- source_size: tail.size,
92
- activity_hash: activityHash,
93
- activity_kind: latest.kind,
94
- event_type: latest.eventType,
95
- task_title: latest.title,
96
- current_file: latest.currentFile,
97
- log_tail: boundedText(visible.map((row) => row.line).join('\n'), 1200) || latest.line,
98
- model,
99
- reasoning_effort: reasoningEffort
100
- };
101
- }
102
- export async function refreshOfficialSubagentZellijActivity(input) {
103
- const snapshot = await readZellijSlotTelemetrySnapshot(input.root, input.missionId).catch(() => null);
104
- if (!snapshot)
105
- return { written: false, refreshed_threads: [], blockers: ['zellij_slot_snapshot_missing'] };
106
- const env = input.env || process.env;
107
- const refreshMinMs = boundedInt(env.SKS_ZELLIJ_OFFICIAL_ACTIVITY_MIN_MS, DEFAULT_REFRESH_MIN_MS, 0, 60_000);
108
- const heartbeatMs = boundedInt(env.SKS_ZELLIJ_OFFICIAL_ACTIVITY_HEARTBEAT_MS, DEFAULT_HEARTBEAT_MS, 1_000, 60_000);
109
- const refreshed = [];
110
- const blockers = [];
111
- for (const slot of Object.values(snapshot.slots || {})) {
112
- if (slot.backend !== 'official-codex-subagent')
113
- continue;
114
- if (!['running', 'launching'].includes(String(slot.status || '').toLowerCase()))
115
- continue;
116
- const activity = await readOfficialSubagentRolloutActivity({
117
- threadId: slot.worker_id,
118
- startedAt: slot.started_at,
119
- projectRoot: input.root,
120
- env
121
- }).catch(() => null);
122
- if (!activity)
123
- continue;
124
- const ageMs = Math.max(0, Date.now() - (Date.parse(slot.latest_ts) || 0));
125
- const sameActivity = slot.activity_hash === activity.activity_hash;
126
- if (ageMs < refreshMinMs || (sameActivity && ageMs < heartbeatMs))
127
- continue;
128
- const eventType = sameActivity ? 'heartbeat' : activity.event_type;
129
- const provider = knownOrUndefined(slot.provider);
130
- const serviceTier = knownOrUndefined(slot.service_tier);
131
- const model = knownOrUndefined(activity.model) || knownOrUndefined(slot.model);
132
- const reasoningEffort = knownOrUndefined(activity.reasoning_effort) || knownOrUndefined(slot.reasoning_effort);
133
- try {
134
- await appendZellijSlotTelemetry(input.root, {
135
- schema: 'sks.zellij-slot-telemetry-event.v1',
136
- ts: nowIso(),
137
- mission_id: input.missionId,
138
- slot_id: slot.slot_id,
139
- generation_index: slot.generation_index,
140
- worker_id: slot.worker_id,
141
- event_type: eventType,
142
- status: 'running',
143
- role: slot.role,
144
- backend: slot.backend,
145
- ...(provider ? { provider } : {}),
146
- ...(serviceTier ? { service_tier: serviceTier } : {}),
147
- ...(model ? { model } : {}),
148
- ...(reasoningEffort ? { reasoning_effort: reasoningEffort } : {}),
149
- task_id: slot.worker_id,
150
- task_title: sameActivity ? slot.task_title : activity.task_title,
151
- current_file: sameActivity ? slot.current_file : activity.current_file,
152
- artifact_paths: slot.artifact_paths,
153
- log_tail: sameActivity ? slot.log_tail : activity.log_tail,
154
- blockers: slot.blockers,
155
- activity_source: 'codex_rollout',
156
- activity_hash: activity.activity_hash
157
- });
158
- refreshed.push(slot.worker_id);
159
- }
160
- catch (error) {
161
- blockers.push(`official_subagent_activity_write_failed:${slot.worker_id}:${String(error?.message || error)}`);
162
- }
163
- }
164
- return { written: refreshed.length > 0, refreshed_threads: refreshed, blockers };
165
- }
166
- async function locateOfficialSubagentRollout(codexHome, threadId, startedAt) {
167
- const cacheKey = `${codexHome}\u0000${threadId}`;
168
- const cached = rolloutPathCache.get(cacheKey);
169
- if (cached?.file && await isFile(cached.file))
170
- return cached.file;
171
- if (cached && !cached.file && Date.now() - cached.checked_at_ms < 2_000)
172
- return null;
173
- const sessionsRoot = path.join(codexHome, 'sessions');
174
- const expectedNameSuffix = `-${threadId}.jsonl`;
175
- for (const dir of candidateDateDirs(sessionsRoot, startedAt)) {
176
- const file = await findExactRolloutInDir(dir, expectedNameSuffix);
177
- if (file) {
178
- rolloutPathCache.set(cacheKey, { checked_at_ms: Date.now(), file });
179
- return file;
180
- }
181
- }
182
- const fallback = await findRecentRollout(sessionsRoot, expectedNameSuffix);
183
- rolloutPathCache.set(cacheKey, { checked_at_ms: Date.now(), file: fallback });
184
- return fallback;
185
- }
186
- function candidateDateDirs(sessionsRoot, startedAt) {
187
- const dates = [];
188
- const parsed = Date.parse(String(startedAt || ''));
189
- if (Number.isFinite(parsed))
190
- dates.push(new Date(parsed));
191
- const now = new Date();
192
- for (let day = -2; day <= 1; day += 1)
193
- dates.push(new Date(now.getTime() + day * 24 * 60 * 60 * 1000));
194
- const out = new Set();
195
- for (const date of dates) {
196
- out.add(path.join(sessionsRoot, String(date.getFullYear()).padStart(4, '0'), String(date.getMonth() + 1).padStart(2, '0'), String(date.getDate()).padStart(2, '0')));
197
- out.add(path.join(sessionsRoot, String(date.getUTCFullYear()).padStart(4, '0'), String(date.getUTCMonth() + 1).padStart(2, '0'), String(date.getUTCDate()).padStart(2, '0')));
198
- }
199
- return [...out];
200
- }
201
- async function findExactRolloutInDir(dir, expectedNameSuffix) {
202
- const entries = await fsp.readdir(dir, { withFileTypes: true }).catch(() => []);
203
- const match = entries.find((entry) => entry.isFile() && entry.name.endsWith(expectedNameSuffix));
204
- return match ? path.join(dir, match.name) : null;
205
- }
206
- async function findRecentRollout(sessionsRoot, expectedNameSuffix) {
207
- const years = await childDirsDescending(sessionsRoot);
208
- let checkedDays = 0;
209
- for (const year of years) {
210
- for (const month of await childDirsDescending(year)) {
211
- for (const day of await childDirsDescending(month)) {
212
- const found = await findExactRolloutInDir(day, expectedNameSuffix);
213
- if (found)
214
- return found;
215
- checkedDays += 1;
216
- if (checkedDays >= MAX_DISCOVERY_DAY_DIRS)
217
- return null;
218
- }
219
- }
220
- }
221
- return null;
222
- }
223
- async function childDirsDescending(dir) {
224
- const entries = await fsp.readdir(dir, { withFileTypes: true }).catch(() => []);
225
- return entries
226
- .filter((entry) => entry.isDirectory())
227
- .map((entry) => path.join(dir, entry.name))
228
- .sort((left, right) => right.localeCompare(left));
229
- }
230
- async function readRolloutIdentity(file) {
231
- const handle = await fsp.open(file, 'r').catch(() => null);
232
- if (!handle)
233
- return null;
234
- try {
235
- const firstLine = await readFirstLine(handle, 1024 * 1024);
236
- if (!firstLine)
237
- return null;
238
- const row = JSON.parse(firstLine);
239
- if (row?.type !== 'session_meta')
240
- return null;
241
- const payload = objectValue(row.payload);
242
- const source = objectValue(payload.source);
243
- const subagent = objectValue(source.subagent);
244
- const threadSpawn = objectValue(subagent.thread_spawn);
245
- const officialSubagent = Object.keys(subagent).length > 0 && Object.keys(threadSpawn).length > 0;
246
- return {
247
- thread_id: String(payload.id || payload.session_id || '').trim(),
248
- spawned_at: String(row.timestamp || payload.timestamp || ''),
249
- cli_version: String(payload.cli_version || ''),
250
- official_subagent: officialSubagent
251
- };
252
- }
253
- catch {
254
- return null;
255
- }
256
- finally {
257
- await handle.close().catch(() => undefined);
258
- }
259
- }
260
- async function readFirstLine(handle, maxBytes) {
261
- const chunkBytes = 64 * 1024;
262
- const parts = [];
263
- let total = 0;
264
- while (total < maxBytes) {
265
- const length = Math.min(chunkBytes, maxBytes - total);
266
- const buffer = Buffer.alloc(length);
267
- const read = await handle.read(buffer, 0, length, total);
268
- if (read.bytesRead <= 0)
269
- break;
270
- const part = buffer.subarray(0, read.bytesRead);
271
- const newline = part.indexOf(0x0A);
272
- if (newline >= 0) {
273
- parts.push(part.subarray(0, newline));
274
- break;
275
- }
276
- parts.push(part);
277
- total += read.bytesRead;
278
- if (read.bytesRead < length)
279
- break;
280
- }
281
- return Buffer.concat(parts).toString('utf8').replace(/\r$/, '');
282
- }
283
- async function readRolloutTail(file, bytes) {
284
- const handle = await fsp.open(file, 'r').catch(() => null);
285
- if (!handle)
286
- return null;
287
- try {
288
- const stat = await handle.stat();
289
- const length = Math.min(stat.size, bytes);
290
- const start = Math.max(0, stat.size - length);
291
- const buffer = Buffer.alloc(length);
292
- await handle.read(buffer, 0, length, start);
293
- let text = buffer.toString('utf8');
294
- if (start > 0) {
295
- const firstNewline = text.indexOf('\n');
296
- text = firstNewline >= 0 ? text.slice(firstNewline + 1) : '';
297
- }
298
- const rows = text
299
- .split(/\r?\n/)
300
- .map((line) => line.trim())
301
- .filter(Boolean)
302
- .map((line) => {
303
- try {
304
- return JSON.parse(line);
305
- }
306
- catch {
307
- return null;
308
- }
309
- })
310
- .filter(Boolean);
311
- return { rows, size: stat.size, mtime_ms: stat.mtimeMs };
312
- }
313
- finally {
314
- await handle.close().catch(() => undefined);
315
- }
316
- }
317
- async function readRolloutHeadTurnContext(file, maxBytes, activityCutoffMs) {
318
- const handle = await fsp.open(file, 'r').catch(() => null);
319
- if (!handle)
320
- return null;
321
- try {
322
- const stat = await handle.stat();
323
- const length = Math.min(stat.size, Math.max(64 * 1024, maxBytes));
324
- const buffer = Buffer.alloc(length);
325
- const read = await handle.read(buffer, 0, length, 0);
326
- let text = buffer.subarray(0, read.bytesRead).toString('utf8');
327
- if (read.bytesRead === length && stat.size > length) {
328
- const lastNewline = text.lastIndexOf('\n');
329
- text = lastNewline >= 0 ? text.slice(0, lastNewline) : '';
330
- }
331
- for (const line of text.split(/\r?\n/)) {
332
- const trimmed = line.trim();
333
- if (!trimmed || !trimmed.includes('"turn_context"'))
334
- continue;
335
- let row = null;
336
- try {
337
- row = JSON.parse(trimmed);
338
- }
339
- catch {
340
- continue;
341
- }
342
- if (row?.type !== 'turn_context')
343
- continue;
344
- const ts = Date.parse(String(row?.timestamp || ''));
345
- if (!Number.isFinite(ts) || ts <= activityCutoffMs)
346
- continue;
347
- const payload = objectValue(row.payload);
348
- return {
349
- model: firstKnown(payload.model),
350
- effort: firstKnown(payload.effort),
351
- reasoning_effort: firstKnown(payload.reasoning_effort)
352
- };
353
- }
354
- return null;
355
- }
356
- catch {
357
- return null;
358
- }
359
- finally {
360
- await handle.close().catch(() => undefined);
361
- }
362
- }
363
- function summarizeRolloutRow(row, projectRoot) {
364
- const timestamp = String(row?.timestamp || '');
365
- const payload = objectValue(row?.payload);
366
- const outer = String(row?.type || '');
367
- const type = String(payload.type || '');
368
- const id = firstKnown(payload.id, payload.call_id, payload.turn_id, `${timestamp}:${outer}:${type}`) || `${timestamp}:${outer}:${type}`;
369
- if (outer === 'event_msg') {
370
- if (type === 'agent_reasoning')
371
- return activity(timestamp, id, 'reasoning', 'task_progress', 'reasoning through the assigned slice', 'reasoning · private reasoning text is intentionally hidden', null);
372
- if (type === 'agent_message') {
373
- const text = boundedVisibleText(payload.message, 280);
374
- if (!text)
375
- return null;
376
- const phase = String(payload.phase || 'commentary');
377
- return activity(timestamp, id, 'commentary', 'task_progress', `agent ${phase}: ${text}`, `${phase} · ${text}`, null);
378
- }
379
- if (type === 'patch_apply_end') {
380
- const files = Object.keys(objectValue(payload.changes));
381
- const currentFile = files[0] ? displayPath(files[0], projectRoot) : null;
382
- const succeeded = payload.success === true || String(payload.status || '') === 'completed';
383
- const title = `${succeeded ? 'applied' : 'failed'} patch${files.length ? ` · ${files.length} file${files.length === 1 ? '' : 's'}` : ''}`;
384
- return activity(timestamp, id, 'patch', succeeded ? 'patch_candidate' : 'task_progress', title, `${title}${currentFile ? ` · ${currentFile}` : ''}`, currentFile);
385
- }
386
- if (type === 'web_search_end') {
387
- const query = boundedVisibleText(payload.query, 180);
388
- return activity(timestamp, id, 'web_search', 'task_progress', query ? `searched: ${query}` : 'completed web search', query ? `web search · ${query}` : 'web search completed', null);
389
- }
390
- if (type === 'mcp_tool_call_end') {
391
- const invocation = objectValue(payload.invocation);
392
- const server = firstKnown(invocation.server, invocation.server_name);
393
- const tool = firstKnown(invocation.tool, invocation.tool_name, invocation.name);
394
- const label = [server, tool].filter(Boolean).join('/') || 'MCP tool';
395
- return activity(timestamp, id, 'mcp', 'task_progress', `completed ${label}`, `mcp · ${label} completed`, null);
396
- }
397
- if (type === 'task_started')
398
- return activity(timestamp, id, 'turn', 'task_started', 'started agent turn', 'turn · started', null);
399
- if (type === 'task_complete')
400
- return activity(timestamp, id, 'turn', 'task_progress', 'finished assigned turn; returning to parent', 'turn · complete, parent lifecycle verdict pending', null);
401
- if (type === 'turn_aborted')
402
- return activity(timestamp, id, 'turn', 'task_progress', 'agent turn interrupted', 'turn · interrupted', null);
403
- if (type === 'context_compacted')
404
- return activity(timestamp, id, 'context', 'task_progress', 'compacted agent context', 'context · compacted', null);
405
- return null;
406
- }
407
- if (outer !== 'response_item')
408
- return null;
409
- if (type === 'custom_tool_call' || type === 'function_call' || type === 'local_shell_call') {
410
- const name = firstKnown(payload.name, type === 'local_shell_call' ? 'shell' : null) || 'tool';
411
- const status = knownOrUndefined(payload.status);
412
- const label = `${name} tool${status ? ` · ${status}` : ''}`;
413
- return activity(timestamp, id, 'tool', 'task_progress', `using ${name}`, label, null);
414
- }
415
- if (type === 'web_search_call')
416
- return activity(timestamp, id, 'web_search', 'task_progress', 'running web search', 'web search · running', null);
417
- if (type === 'message' && String(payload.role || '').toLowerCase() === 'assistant') {
418
- const text = boundedVisibleText(extractMessageText(payload.content), 280);
419
- if (!text)
420
- return null;
421
- return activity(timestamp, id, 'commentary', 'task_progress', `agent message: ${text}`, `message · ${text}`, null);
422
- }
423
- return null;
424
- }
425
- function activity(timestamp, identity, kind, eventType, title, line, currentFile) {
426
- return {
427
- timestamp,
428
- identity,
429
- kind,
430
- eventType,
431
- title: boundedText(title, 240) || 'agent active',
432
- line: boundedText(line, 360) || 'agent active',
433
- currentFile
434
- };
435
- }
436
- function uniqueSummaries(rows) {
437
- const out = [];
438
- for (const row of rows) {
439
- if (out.at(-1)?.line === row.line)
440
- continue;
441
- out.push(row);
442
- }
443
- return out;
444
- }
445
- function extractMessageText(value) {
446
- if (typeof value === 'string')
447
- return value;
448
- if (!Array.isArray(value))
449
- return '';
450
- return value
451
- .map((item) => firstKnown(item?.text, item?.content, item?.input_text) || '')
452
- .filter(Boolean)
453
- .join(' ');
454
- }
455
- function displayPath(value, projectRoot) {
456
- const absolute = path.resolve(value);
457
- if (projectRoot) {
458
- const relative = path.relative(path.resolve(projectRoot), absolute);
459
- if (relative && !relative.startsWith('..') && !path.isAbsolute(relative))
460
- return relative;
461
- }
462
- return path.basename(absolute);
463
- }
464
- function boundedVisibleText(value, max) {
465
- const text = String(value || '')
466
- .replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g, '')
467
- .replace(/\b(?:sk|sess|rk)-[A-Za-z0-9_-]{12,}\b/g, '[redacted-token]')
468
- .replace(/\b(authorization|api[_-]?key|access[_-]?token|password)\s*[:=]\s*[^\s,;]+/gi, '$1=[redacted]')
469
- .replace(/\s+/g, ' ')
470
- .trim();
471
- return boundedText(text, max);
472
- }
473
- function boundedText(value, max) {
474
- const text = String(value || '').replace(/\s+$/g, '').trim();
475
- if (!text)
476
- return null;
477
- return text.length > max ? `${text.slice(0, Math.max(0, max - 1))}…` : text;
478
- }
479
- function firstKnown(...values) {
480
- for (const value of values) {
481
- const text = String(value || '').replace(/\s+/g, ' ').trim();
482
- if (text && text.toLowerCase() !== 'unknown' && text !== '?')
483
- return text;
484
- }
485
- return null;
486
- }
487
- function knownOrUndefined(value) {
488
- return firstKnown(value) || undefined;
489
- }
490
- function safeThreadId(value) {
491
- const text = String(value || '').trim();
492
- return /^[A-Za-z0-9._:-]+$/.test(text) ? text : '';
493
- }
494
- function objectValue(value) {
495
- return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
496
- }
497
- function boundedInt(value, fallback, min, max) {
498
- const parsed = Math.floor(Number(value ?? fallback));
499
- const number = Number.isFinite(parsed) ? parsed : fallback;
500
- return Math.max(min, Math.min(number, max));
501
- }
502
- async function isFile(file) {
503
- return fsp.stat(file).then((stat) => stat.isFile()).catch(() => false);
504
- }
505
- function versionAtLeast(value, minimum) {
506
- const current = versionParts(value);
507
- const required = versionParts(minimum);
508
- if (!current || !required)
509
- return false;
510
- for (let index = 0; index < Math.max(current.length, required.length); index += 1) {
511
- const left = current[index] || 0;
512
- const right = required[index] || 0;
513
- if (left > right)
514
- return true;
515
- if (left < right)
516
- return false;
517
- }
518
- return true;
519
- }
520
- function versionParts(value) {
521
- const match = String(value || '').match(/^(\d+)\.(\d+)\.(\d+)/);
522
- return match ? match.slice(1).map((part) => Number(part)) : null;
523
- }
524
- export function officialSubagentActivitySlot(snapshot, threadId) {
525
- return Object.values(snapshot?.slots || {}).find((slot) => slot.worker_id === threadId) || null;
526
- }