zob-harness 0.1.0

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 (356) hide show
  1. package/.pi/adapters/registry.json +103 -0
  2. package/.pi/agents/architecture-cartographer.md +53 -0
  3. package/.pi/agents/chief-vision.md +39 -0
  4. package/.pi/agents/clarifier.md +58 -0
  5. package/.pi/agents/context-steward.md +52 -0
  6. package/.pi/agents/doc-steward.md +34 -0
  7. package/.pi/agents/explore.md +49 -0
  8. package/.pi/agents/factory.md +41 -0
  9. package/.pi/agents/implementer.md +44 -0
  10. package/.pi/agents/librarian.md +32 -0
  11. package/.pi/agents/oracle-merge.md +50 -0
  12. package/.pi/agents/oracle.md +55 -0
  13. package/.pi/agents/pattern-miner.md +53 -0
  14. package/.pi/agents/planner.md +39 -0
  15. package/.pi/agents/project-dna-golden-evaluator.md +32 -0
  16. package/.pi/agents/project-dna-ontology-steward.md +30 -0
  17. package/.pi/agents/project-dna-oracle.md +56 -0
  18. package/.pi/agents/project-dna-orchestrator.md +60 -0
  19. package/.pi/agents/project-dna-query-steward.md +38 -0
  20. package/.pi/agents/project-dna-safety-preflight.md +54 -0
  21. package/.pi/agents/project-dna-test-linker.md +27 -0
  22. package/.pi/agents/qa.md +38 -0
  23. package/.pi/agents/refactor-cartographer.md +28 -0
  24. package/.pi/agents/refactor-mover.md +31 -0
  25. package/.pi/agents/refactor-oracle.md +49 -0
  26. package/.pi/agents/repo-scout.md +60 -0
  27. package/.pi/agents/sample-architect.md +48 -0
  28. package/.pi/agents/specifier.md +57 -0
  29. package/.pi/agents/symbol-range-curator.md +41 -0
  30. package/.pi/agents/synthesis.md +52 -0
  31. package/.pi/agents/temp-agent-creator.md +35 -0
  32. package/.pi/autonomy-policy.json +67 -0
  33. package/.pi/budget-policy.json +54 -0
  34. package/.pi/capabilities/zob-public-runtime-capabilities.json +1700 -0
  35. package/.pi/chains/explore-plan-oracle.json +78 -0
  36. package/.pi/chains/explore-spec-clarify-plan-oracle.json +64 -0
  37. package/.pi/chains/explore-spec-plan-oracle.json +53 -0
  38. package/.pi/chains/spec-clarify-plan-oracle.json +53 -0
  39. package/.pi/chains/spec-factory-oracle.json +42 -0
  40. package/.pi/chains/spec-plan-oracle.json +42 -0
  41. package/.pi/compute-profiles/defaults.json +19 -0
  42. package/.pi/compute-profiles/overrides.json +13 -0
  43. package/.pi/compute-profiles/risk-rules.json +16 -0
  44. package/.pi/daemon-policy.json +80 -0
  45. package/.pi/damage-control-rules.json +45 -0
  46. package/.pi/extensions/zob-child-safety/index.ts +212 -0
  47. package/.pi/extensions/zob-harness/AGENTS.md +28 -0
  48. package/.pi/extensions/zob-harness/index.ts +391 -0
  49. package/.pi/extensions/zob-harness/src/AGENTS.md +25 -0
  50. package/.pi/extensions/zob-harness/src/agents.ts +82 -0
  51. package/.pi/extensions/zob-harness/src/autonomous-runtime.ts +2912 -0
  52. package/.pi/extensions/zob-harness/src/autonomy-readiness.ts +778 -0
  53. package/.pi/extensions/zob-harness/src/budget-policy.ts +308 -0
  54. package/.pi/extensions/zob-harness/src/capabilities.ts +249 -0
  55. package/.pi/extensions/zob-harness/src/child-runner.ts +249 -0
  56. package/.pi/extensions/zob-harness/src/chronicle.ts +262 -0
  57. package/.pi/extensions/zob-harness/src/compute-profile.ts +602 -0
  58. package/.pi/extensions/zob-harness/src/compute-workflow-shape.ts +168 -0
  59. package/.pi/extensions/zob-harness/src/coms-v2/AGENTS.md +16 -0
  60. package/.pi/extensions/zob-harness/src/coms-v2/envelope.ts +121 -0
  61. package/.pi/extensions/zob-harness/src/coms-v2/identity.ts +53 -0
  62. package/.pi/extensions/zob-harness/src/coms-v2/ledger-bridge.ts +67 -0
  63. package/.pi/extensions/zob-harness/src/coms-v2/local-transport.ts +147 -0
  64. package/.pi/extensions/zob-harness/src/coms-v2/pending-replies.ts +80 -0
  65. package/.pi/extensions/zob-harness/src/coms-v2/policy.ts +125 -0
  66. package/.pi/extensions/zob-harness/src/coms-v2/presence.ts +55 -0
  67. package/.pi/extensions/zob-harness/src/coms-v2/registry.ts +113 -0
  68. package/.pi/extensions/zob-harness/src/coms-v2/response-capture.ts +50 -0
  69. package/.pi/extensions/zob-harness/src/coms-v2/transcript-capture.ts +164 -0
  70. package/.pi/extensions/zob-harness/src/coms-v2/types.ts +149 -0
  71. package/.pi/extensions/zob-harness/src/coms-v2/zpeer-profile.ts +140 -0
  72. package/.pi/extensions/zob-harness/src/coms-v2/zpeer.ts +452 -0
  73. package/.pi/extensions/zob-harness/src/constants.ts +108 -0
  74. package/.pi/extensions/zob-harness/src/context-gbrain.ts +465 -0
  75. package/.pi/extensions/zob-harness/src/daemon-policy.ts +223 -0
  76. package/.pi/extensions/zob-harness/src/daemon-readiness.ts +134 -0
  77. package/.pi/extensions/zob-harness/src/daemon-runtime.ts +393 -0
  78. package/.pi/extensions/zob-harness/src/factory/AGENTS.md +24 -0
  79. package/.pi/extensions/zob-harness/src/factory/agentic-plan.ts +65 -0
  80. package/.pi/extensions/zob-harness/src/factory/quarantine.ts +319 -0
  81. package/.pi/extensions/zob-harness/src/factory/run.ts +520 -0
  82. package/.pi/extensions/zob-harness/src/factory/validation.ts +454 -0
  83. package/.pi/extensions/zob-harness/src/factory-selector.ts +318 -0
  84. package/.pi/extensions/zob-harness/src/full-autonomy-test.ts +226 -0
  85. package/.pi/extensions/zob-harness/src/git-ops.ts +868 -0
  86. package/.pi/extensions/zob-harness/src/goal-room.ts +178 -0
  87. package/.pi/extensions/zob-harness/src/goal-runtime.ts +1569 -0
  88. package/.pi/extensions/zob-harness/src/goal-todo-imports.ts +111 -0
  89. package/.pi/extensions/zob-harness/src/goal-todo-types.ts +231 -0
  90. package/.pi/extensions/zob-harness/src/goal-todos.ts +1410 -0
  91. package/.pi/extensions/zob-harness/src/goal.ts +152 -0
  92. package/.pi/extensions/zob-harness/src/governed-requests.ts +436 -0
  93. package/.pi/extensions/zob-harness/src/interactive-autonomy.ts +595 -0
  94. package/.pi/extensions/zob-harness/src/launch-apply.ts +313 -0
  95. package/.pi/extensions/zob-harness/src/merge-queue.ts +290 -0
  96. package/.pi/extensions/zob-harness/src/mission-control.ts +573 -0
  97. package/.pi/extensions/zob-harness/src/model-availability.ts +52 -0
  98. package/.pi/extensions/zob-harness/src/model-routing.ts +429 -0
  99. package/.pi/extensions/zob-harness/src/orchestration/AGENTS.md +23 -0
  100. package/.pi/extensions/zob-harness/src/orchestration/adaptive-delegation.ts +547 -0
  101. package/.pi/extensions/zob-harness/src/orchestration/adaptive-workflow.ts +585 -0
  102. package/.pi/extensions/zob-harness/src/orchestration/lead-plan.ts +192 -0
  103. package/.pi/extensions/zob-harness/src/orchestration/plan.ts +168 -0
  104. package/.pi/extensions/zob-harness/src/orchestration/room.ts +346 -0
  105. package/.pi/extensions/zob-harness/src/orchestration/run.ts +134 -0
  106. package/.pi/extensions/zob-harness/src/orchestration/supervised-readonly.ts +1147 -0
  107. package/.pi/extensions/zob-harness/src/orchestration/widget-readers.ts +132 -0
  108. package/.pi/extensions/zob-harness/src/output-contracts.ts +656 -0
  109. package/.pi/extensions/zob-harness/src/project-dna.ts +533 -0
  110. package/.pi/extensions/zob-harness/src/promotion/AGENTS.md +24 -0
  111. package/.pi/extensions/zob-harness/src/promotion/candidate.ts +336 -0
  112. package/.pi/extensions/zob-harness/src/promotion/coms.ts +127 -0
  113. package/.pi/extensions/zob-harness/src/promotion/documentation.ts +142 -0
  114. package/.pi/extensions/zob-harness/src/promotion/factory.ts +107 -0
  115. package/.pi/extensions/zob-harness/src/promotion/ledger.ts +2 -0
  116. package/.pi/extensions/zob-harness/src/promotion/temp-agent.ts +151 -0
  117. package/.pi/extensions/zob-harness/src/promotion/types.ts +149 -0
  118. package/.pi/extensions/zob-harness/src/promotion/validate.ts +6 -0
  119. package/.pi/extensions/zob-harness/src/promotion/write-lane.ts +162 -0
  120. package/.pi/extensions/zob-harness/src/prompt-packs.ts +239 -0
  121. package/.pi/extensions/zob-harness/src/queue.ts +386 -0
  122. package/.pi/extensions/zob-harness/src/rules.ts +225 -0
  123. package/.pi/extensions/zob-harness/src/runtime/AGENTS.md +26 -0
  124. package/.pi/extensions/zob-harness/src/runtime/adaptive-zmode.ts +116 -0
  125. package/.pi/extensions/zob-harness/src/runtime/auto-compaction.ts +715 -0
  126. package/.pi/extensions/zob-harness/src/runtime/commands.ts +1315 -0
  127. package/.pi/extensions/zob-harness/src/runtime/compaction-policy.ts +516 -0
  128. package/.pi/extensions/zob-harness/src/runtime/delegation-click-markers.ts +141 -0
  129. package/.pi/extensions/zob-harness/src/runtime/delegation-feed.ts +415 -0
  130. package/.pi/extensions/zob-harness/src/runtime/delegation-markdown.ts +97 -0
  131. package/.pi/extensions/zob-harness/src/runtime/delegation-monitor.ts +553 -0
  132. package/.pi/extensions/zob-harness/src/runtime/delegation-mouse.ts +205 -0
  133. package/.pi/extensions/zob-harness/src/runtime/delegation-overlay.ts +434 -0
  134. package/.pi/extensions/zob-harness/src/runtime/events.ts +736 -0
  135. package/.pi/extensions/zob-harness/src/runtime/goal-todo-overlay.ts +214 -0
  136. package/.pi/extensions/zob-harness/src/runtime/mode-intent.ts +144 -0
  137. package/.pi/extensions/zob-harness/src/runtime/plan-capture.ts +270 -0
  138. package/.pi/extensions/zob-harness/src/runtime/state.ts +403 -0
  139. package/.pi/extensions/zob-harness/src/runtime/tools-autonomous.ts +117 -0
  140. package/.pi/extensions/zob-harness/src/runtime/tools-compute.ts +136 -0
  141. package/.pi/extensions/zob-harness/src/runtime/tools-coms.ts +365 -0
  142. package/.pi/extensions/zob-harness/src/runtime/tools-context.ts +70 -0
  143. package/.pi/extensions/zob-harness/src/runtime/tools-delegation.ts +1854 -0
  144. package/.pi/extensions/zob-harness/src/runtime/tools-factory.ts +810 -0
  145. package/.pi/extensions/zob-harness/src/runtime/tools-goal-room.ts +46 -0
  146. package/.pi/extensions/zob-harness/src/runtime/tools-governed-requests.ts +38 -0
  147. package/.pi/extensions/zob-harness/src/runtime/tools-merge-queue.ts +61 -0
  148. package/.pi/extensions/zob-harness/src/runtime/tools-mission-control.ts +77 -0
  149. package/.pi/extensions/zob-harness/src/runtime/tools-orchestration.ts +106 -0
  150. package/.pi/extensions/zob-harness/src/runtime/tools-project-dna.ts +123 -0
  151. package/.pi/extensions/zob-harness/src/runtime/tools-worker-pool.ts +93 -0
  152. package/.pi/extensions/zob-harness/src/runtime/tools-workspace-claims.ts +62 -0
  153. package/.pi/extensions/zob-harness/src/runtime/tools-zcommit.ts +147 -0
  154. package/.pi/extensions/zob-harness/src/runtime/widget.ts +353 -0
  155. package/.pi/extensions/zob-harness/src/runtime/zobHarness.ts +60 -0
  156. package/.pi/extensions/zob-harness/src/safety.ts +338 -0
  157. package/.pi/extensions/zob-harness/src/sandbox.ts +1508 -0
  158. package/.pi/extensions/zob-harness/src/schemas-project-dna.ts +47 -0
  159. package/.pi/extensions/zob-harness/src/schemas.ts +695 -0
  160. package/.pi/extensions/zob-harness/src/telemetry.ts +373 -0
  161. package/.pi/extensions/zob-harness/src/topology/AGENTS.md +22 -0
  162. package/.pi/extensions/zob-harness/src/topology/chains.ts +236 -0
  163. package/.pi/extensions/zob-harness/src/topology/coms.ts +211 -0
  164. package/.pi/extensions/zob-harness/src/topology/orchestration-profiles.ts +204 -0
  165. package/.pi/extensions/zob-harness/src/topology/teams.ts +113 -0
  166. package/.pi/extensions/zob-harness/src/types/core.ts +47 -0
  167. package/.pi/extensions/zob-harness/src/types.ts +939 -0
  168. package/.pi/extensions/zob-harness/src/utils/AGENTS.md +22 -0
  169. package/.pi/extensions/zob-harness/src/utils/formatting.ts +34 -0
  170. package/.pi/extensions/zob-harness/src/utils/hashing.ts +11 -0
  171. package/.pi/extensions/zob-harness/src/utils/json.ts +28 -0
  172. package/.pi/extensions/zob-harness/src/utils/paths.ts +54 -0
  173. package/.pi/extensions/zob-harness/src/utils/records.ts +25 -0
  174. package/.pi/extensions/zob-harness/src/utils/resources.ts +38 -0
  175. package/.pi/extensions/zob-harness/src/worker-pool.ts +672 -0
  176. package/.pi/extensions/zob-harness/src/workspace-claims.ts +297 -0
  177. package/.pi/extensions/zob-switch/index.ts +180 -0
  178. package/.pi/factories/budget-preflight-dry-run/batch-manifest.json +59 -0
  179. package/.pi/factories/budget-preflight-dry-run/factory.json +94 -0
  180. package/.pi/factories/budget-preflight-dry-run/pilot-manifest.json +50 -0
  181. package/.pi/factories/budget-preflight-dry-run/smoke-manifest.json +43 -0
  182. package/.pi/factories/code-review-matrix/batch-manifest.json +61 -0
  183. package/.pi/factories/code-review-matrix/factory.json +163 -0
  184. package/.pi/factories/code-review-matrix/pilot-manifest.json +41 -0
  185. package/.pi/factories/code-review-matrix/smoke-manifest.json +35 -0
  186. package/.pi/factories/factory-forge/batch-manifest.json +56 -0
  187. package/.pi/factories/factory-forge/factory.json +84 -0
  188. package/.pi/factories/factory-forge/pilot-manifest.json +32 -0
  189. package/.pi/factories/factory-forge/smoke-manifest.json +19 -0
  190. package/.pi/factories/opencode-pattern-canonizer/batch-manifest.json +54 -0
  191. package/.pi/factories/opencode-pattern-canonizer/factory.json +86 -0
  192. package/.pi/factories/opencode-pattern-canonizer/pilot-manifest.json +39 -0
  193. package/.pi/factories/opencode-pattern-canonizer/smoke-manifest.json +26 -0
  194. package/.pi/factories/project-dna/README.md +182 -0
  195. package/.pi/factories/project-dna/batch-manifest.json +37 -0
  196. package/.pi/factories/project-dna/example-project-dna-manifest-v2.json +80 -0
  197. package/.pi/factories/project-dna/example-project-dna-manifest.json +58 -0
  198. package/.pi/factories/project-dna/factory.json +131 -0
  199. package/.pi/factories/project-dna/golden-cases-smoke.json +62 -0
  200. package/.pi/factories/project-dna/pi-agentic-ontology.json +88 -0
  201. package/.pi/factories/project-dna/pilot-manifest.json +32 -0
  202. package/.pi/factories/project-dna/schemas/benchmark-suite.schema.json +27 -0
  203. package/.pi/factories/project-dna/schemas/code-knowledge-graph.schema.json +97 -0
  204. package/.pi/factories/project-dna/schemas/context-pack.schema.json +43 -0
  205. package/.pi/factories/project-dna/schemas/golden-case.schema.json +36 -0
  206. package/.pi/factories/project-dna/schemas/manifest-v2.schema.json +128 -0
  207. package/.pi/factories/project-dna/schemas/manifest.schema.json +77 -0
  208. package/.pi/factories/project-dna/schemas/ontology.schema.json +45 -0
  209. package/.pi/factories/project-dna/schemas/project-fingerprint.schema.json +28 -0
  210. package/.pi/factories/project-dna/schemas/query-steward-report.schema.json +52 -0
  211. package/.pi/factories/project-dna/smoke-manifest.json +27 -0
  212. package/.pi/factories/roadmap-smoke-lots/batch-manifest.json +49 -0
  213. package/.pi/factories/roadmap-smoke-lots/factory.json +89 -0
  214. package/.pi/factories/roadmap-smoke-lots/pilot-manifest.json +50 -0
  215. package/.pi/factories/roadmap-smoke-lots/smoke-manifest.json +35 -0
  216. package/.pi/git-policy.json +120 -0
  217. package/.pi/mission-control/zob_coms_transport.json +64 -0
  218. package/.pi/model-catalog.example.json +345 -0
  219. package/.pi/model-economy.example.json +196 -0
  220. package/.pi/model-routing.json +86 -0
  221. package/.pi/orchestrations/adaptive-chief-vision.json +193 -0
  222. package/.pi/orchestrations/ceo-feature-build.json +182 -0
  223. package/.pi/orchestrations/readonly-dynamic-smoke.json +75 -0
  224. package/.pi/output-contracts/agent-event.v1.json +19 -0
  225. package/.pi/output-contracts/base.v1.json +24 -0
  226. package/.pi/output-contracts/brain-lookup.v1.json +21 -0
  227. package/.pi/output-contracts/clarification.v1.json +21 -0
  228. package/.pi/output-contracts/context-pack.v1.json +20 -0
  229. package/.pi/output-contracts/context-request.v1.json +21 -0
  230. package/.pi/output-contracts/context-steward.v1.json +19 -0
  231. package/.pi/output-contracts/context-writeback-proposal.v1.json +18 -0
  232. package/.pi/output-contracts/delegation-request.v1.json +21 -0
  233. package/.pi/output-contracts/explore.v1.json +52 -0
  234. package/.pi/output-contracts/factory.v1.json +48 -0
  235. package/.pi/output-contracts/guidance-steward.v1.json +18 -0
  236. package/.pi/output-contracts/implement.v1.json +40 -0
  237. package/.pi/output-contracts/launch-authorization.v1.json +21 -0
  238. package/.pi/output-contracts/lead-plan.v1.json +22 -0
  239. package/.pi/output-contracts/mission-readiness.v1.json +20 -0
  240. package/.pi/output-contracts/oracle-merge.v1.json +44 -0
  241. package/.pi/output-contracts/oracle-request.v1.json +20 -0
  242. package/.pi/output-contracts/oracle.v1.json +44 -0
  243. package/.pi/output-contracts/orchestration-profile.v1.json +22 -0
  244. package/.pi/output-contracts/plan.v1.json +48 -0
  245. package/.pi/output-contracts/prompt-pack.v1.json +20 -0
  246. package/.pi/output-contracts/qa.v1.json +40 -0
  247. package/.pi/output-contracts/research.v1.json +36 -0
  248. package/.pi/output-contracts/spec.v1.json +22 -0
  249. package/.pi/output-contracts/synthesis.v1.json +44 -0
  250. package/.pi/output-contracts/temp-agent-card.v1.json +23 -0
  251. package/.pi/output-contracts/todo-child-result.v1.json +20 -0
  252. package/.pi/output-contracts/todo-child-result.v2.json +22 -0
  253. package/.pi/output-contracts/todo-claim-validation.v1.json +22 -0
  254. package/.pi/output-contracts/todo-split-request.v1.json +20 -0
  255. package/.pi/prompts/adaptive-workflow.md +63 -0
  256. package/.pi/prompts/autonomous-runtime.md +15 -0
  257. package/.pi/prompts/benchmark-contender.md +15 -0
  258. package/.pi/prompts/benchmark-judge.md +19 -0
  259. package/.pi/prompts/clarify-spec.md +20 -0
  260. package/.pi/prompts/compute-plan.md +36 -0
  261. package/.pi/prompts/compute-preview.md +42 -0
  262. package/.pi/prompts/contract.md +29 -0
  263. package/.pi/prompts/explore.md +13 -0
  264. package/.pi/prompts/factory-run.md +36 -0
  265. package/.pi/prompts/factory.md +20 -0
  266. package/.pi/prompts/implement.md +27 -0
  267. package/.pi/prompts/model-catalog.md +68 -0
  268. package/.pi/prompts/model-economy.md +64 -0
  269. package/.pi/prompts/oracle-merge.md +18 -0
  270. package/.pi/prompts/oracle.md +13 -0
  271. package/.pi/prompts/orchestrator.md +48 -0
  272. package/.pi/prompts/parallel-review.md +21 -0
  273. package/.pi/prompts/plan.md +21 -0
  274. package/.pi/prompts/project-dna.md +90 -0
  275. package/.pi/prompts/refactor-oracle.md +23 -0
  276. package/.pi/prompts/refactor-slice.md +24 -0
  277. package/.pi/prompts/research.md +20 -0
  278. package/.pi/prompts/spec.md +19 -0
  279. package/.pi/prompts/synthesis.md +18 -0
  280. package/.pi/rules/always.md +38 -0
  281. package/.pi/rules/docs.md +32 -0
  282. package/.pi/rules/factory.md +44 -0
  283. package/.pi/rules/oracle.md +34 -0
  284. package/.pi/rules/orchestration.md +44 -0
  285. package/.pi/rules/project.md +34 -0
  286. package/.pi/rules/prompts.md +43 -0
  287. package/.pi/rules/runtime.md +43 -0
  288. package/.pi/rules/sandbox.md +43 -0
  289. package/.pi/settings.json +28 -0
  290. package/.pi/skills/zob-agentic-access/SKILL.md +20 -0
  291. package/.pi/skills/zob-autonomous-runtime/SKILL.md +41 -0
  292. package/.pi/skills/zob-commit/SKILL.md +79 -0
  293. package/.pi/skills/zob-compaction-policy/SKILL.md +92 -0
  294. package/.pi/skills/zob-compute-profile/SKILL.md +108 -0
  295. package/.pi/skills/zob-coms-safety/SKILL.md +54 -0
  296. package/.pi/skills/zob-coms-v2-live/SKILL.md +47 -0
  297. package/.pi/skills/zob-delegation-routing/SKILL.md +82 -0
  298. package/.pi/skills/zob-factory/SKILL.md +28 -0
  299. package/.pi/skills/zob-goal-todo-tree/SKILL.md +279 -0
  300. package/.pi/skills/zob-harness/SKILL.md +68 -0
  301. package/.pi/skills/zob-mission-control-coms/SKILL.md +39 -0
  302. package/.pi/skills/zob-oracle/SKILL.md +21 -0
  303. package/.pi/skills/zob-owner-pool-drill-writer/SKILL.md +244 -0
  304. package/.pi/skills/zob-owner-pool-launcher/SKILL.md +261 -0
  305. package/.pi/skills/zob-project-dna/SKILL.md +275 -0
  306. package/.pi/skills/zob-sandbox/SKILL.md +29 -0
  307. package/.pi/skills/zob-spec/SKILL.md +25 -0
  308. package/.pi/skills/zob-split-refactor/SKILL.md +39 -0
  309. package/.pi/skills/zob-tool-router/SKILL.md +104 -0
  310. package/.pi/teams/zob-core.json +122 -0
  311. package/AGENTS.md +89 -0
  312. package/CONTRIBUTING.md +56 -0
  313. package/LICENSE +21 -0
  314. package/README.md +360 -0
  315. package/SECURITY.md +35 -0
  316. package/SOURCE_INDEX.md +46 -0
  317. package/package.json +135 -0
  318. package/scripts/README.md +57 -0
  319. package/scripts/autonomy/mission-readiness-secret-smoke.mjs +90 -0
  320. package/scripts/compute-profile/plan-workflow.mjs +85 -0
  321. package/scripts/compute-profile/preview.mjs +242 -0
  322. package/scripts/compute-profile/regression-smoke.mjs +38 -0
  323. package/scripts/compute-profile/summarize.mjs +72 -0
  324. package/scripts/compute-profile/validate-policy.mjs +50 -0
  325. package/scripts/compute-profile/validate-preview.mjs +95 -0
  326. package/scripts/compute-profile/validate-workflow.mjs +58 -0
  327. package/scripts/git-ops/commit-policy-smoke.mjs +221 -0
  328. package/scripts/goal-todo/child-goal-ref-smoke.mjs +252 -0
  329. package/scripts/harness-switch/static-smoke.mjs +43 -0
  330. package/scripts/model-catalog/validate-economy.mjs +223 -0
  331. package/scripts/model-catalog/validate.mjs +199 -0
  332. package/scripts/package-surface/validate-script-refs.mjs +190 -0
  333. package/scripts/path-policy/validate-smoke.mjs +103 -0
  334. package/scripts/project-dna/bench-smoke.mjs +217 -0
  335. package/scripts/project-dna/build-capsules.mjs +207 -0
  336. package/scripts/project-dna/build-sample-spec.mjs +140 -0
  337. package/scripts/project-dna/emit-golden-cases.mjs +75 -0
  338. package/scripts/project-dna/emit-ontology.mjs +75 -0
  339. package/scripts/project-dna/generate-sample.mjs +302 -0
  340. package/scripts/project-dna/oracle-review-smoke.mjs +157 -0
  341. package/scripts/project-dna/plan-workflow.mjs +289 -0
  342. package/scripts/project-dna/query-context.mjs +276 -0
  343. package/scripts/project-dna/query-steward.mjs +149 -0
  344. package/scripts/project-dna/scan.mjs +553 -0
  345. package/scripts/project-dna/validate-5of5.mjs +159 -0
  346. package/scripts/project-dna/validate-golden-cases.mjs +78 -0
  347. package/scripts/project-dna/validate-ontology.mjs +97 -0
  348. package/scripts/project-dna/validate-sample-project.mjs +105 -0
  349. package/scripts/project-dna/validate-scaffold.mjs +383 -0
  350. package/scripts/project-dna/validate-scan-artifacts.mjs +187 -0
  351. package/scripts/project-dna/validate-workflow.mjs +166 -0
  352. package/scripts/start-pi.sh +4 -0
  353. package/scripts/worker-pool/static-smoke.mjs +54 -0
  354. package/scripts/zpeer-local-e2e-smoke.mjs +395 -0
  355. package/scripts/zpeer-static-smoke.mjs +129 -0
  356. package/tsconfig.json +12 -0
@@ -0,0 +1,205 @@
1
+ import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
+ import type { TUI } from "@earendil-works/pi-tui";
3
+
4
+ import { delegateViewLink, findDelegateActionAtColumn, findDelegateRunIdAtColumn } from "./delegation-click-markers.js";
5
+ import type { DelegationClickAction } from "./delegation-click-markers.js";
6
+ import { finishDelegationRun, startDelegationRun } from "./delegation-monitor.js";
7
+ import type { HarnessRuntimeState } from "./state.js";
8
+
9
+ export { delegateViewLink, findDelegateRunIdAtColumn } from "./delegation-click-markers.js";
10
+
11
+ const MOUSE_ENABLE = "\x1b[?1000h\x1b[?1002h\x1b[?1006h";
12
+ const MOUSE_DISABLE = "\x1b[?1006l\x1b[?1002l\x1b[?1000l";
13
+
14
+ export interface SgrMouseEvent {
15
+ button: number;
16
+ x: number;
17
+ y: number;
18
+ release: boolean;
19
+ }
20
+
21
+ interface TuiRenderSnapshot {
22
+ previousLines?: string[];
23
+ previousViewportTop?: number;
24
+ terminal?: { rows?: number };
25
+ }
26
+
27
+ export function parseSgrMouseEvent(data: string): SgrMouseEvent | undefined {
28
+ const sgr = data.match(/^\x1b\[<(\d+);(\d+);(\d+)([mM])$/);
29
+ if (sgr) {
30
+ return {
31
+ button: Number(sgr[1]),
32
+ x: Number(sgr[2]),
33
+ y: Number(sgr[3]),
34
+ release: sgr[4] === "m",
35
+ };
36
+ }
37
+
38
+ // Legacy X10/xterm mouse format: ESC [ M Cb Cx Cy.
39
+ // Some terminal/tmux combinations still emit this even when SGR mode was requested.
40
+ if (data.startsWith("\x1b[M") && data.length >= 6) {
41
+ const rawButton = Math.max(0, data.charCodeAt(3) - 32);
42
+ const x = Math.max(1, data.charCodeAt(4) - 32);
43
+ const y = Math.max(1, data.charCodeAt(5) - 32);
44
+ const release = (rawButton & 3) === 3;
45
+ return { button: release ? 0 : rawButton, x, y, release };
46
+ }
47
+
48
+ return undefined;
49
+ }
50
+
51
+ function normalizedMouseButton(button: number): number {
52
+ return button & ~(4 | 8 | 16 | 32);
53
+ }
54
+
55
+ function findDelegateActionAtMousePosition(tui: TuiRenderSnapshot | undefined, x: number, y: number): DelegationClickAction | undefined {
56
+ const lines = tui?.previousLines;
57
+ if (!Array.isArray(lines)) return undefined;
58
+ const viewportTop = typeof tui?.previousViewportTop === "number" ? tui.previousViewportTop : Math.max(0, lines.length - (tui?.terminal?.rows ?? lines.length));
59
+ const line = lines[viewportTop + y - 1];
60
+ return line ? findDelegateActionAtColumn(line, x) : undefined;
61
+ }
62
+
63
+ function ensureRunForViewAction(state: HarnessRuntimeState, action: DelegationClickAction): void {
64
+ if (action.kind !== "view") return;
65
+ if (state.delegations.runs.some((run) => run.id === action.runId)) return;
66
+ const nowMs = Date.now();
67
+ startDelegationRun(state.delegations, {
68
+ id: action.runId,
69
+ parentToolCallId: action.runId,
70
+ source: action.runId.startsWith("task_") ? "delegate_task" : "delegate_agent",
71
+ mode: "single",
72
+ agent: action.agent ?? "delegate",
73
+ task: "restored from historical delegate_agent chat row",
74
+ startedAtMs: nowMs - 1,
75
+ });
76
+ const terminalStatus = action.status && action.status !== "queued" && action.status !== "running" ? action.status : "complete";
77
+ finishDelegationRun(state.delegations, action.runId, {
78
+ status: terminalStatus,
79
+ endedAtMs: nowMs,
80
+ outputPreview: "",
81
+ stderrPreview: "",
82
+ });
83
+ }
84
+
85
+ export function enableDelegationMouseMode(tui: TUI): void {
86
+ tui.terminal.write(MOUSE_ENABLE);
87
+ }
88
+
89
+ export function disableDelegationMouseMode(tui: TUI | undefined): void {
90
+ tui?.terminal.write(MOUSE_DISABLE);
91
+ }
92
+
93
+ function overlayActive(state: HarnessRuntimeState): boolean {
94
+ return Boolean(state.delegationMouse.overlaySelect || state.delegationMouse.overlayClose || state.delegationMouse.overlayScroll);
95
+ }
96
+
97
+ function temporarilyReleaseMouseForFeedScroll(state: HarnessRuntimeState): void {
98
+ if (overlayActive(state)) return;
99
+ const tui = state.delegationMouse.tui;
100
+ if (!tui) return;
101
+ if (state.delegationMouse.enabled) {
102
+ disableDelegationMouseMode(tui);
103
+ state.delegationMouse.enabled = false;
104
+ }
105
+ state.delegationMouse.releasedUntilMs = Date.now() + 1200;
106
+ if (state.delegationMouse.mouseReenableTimer) clearTimeout(state.delegationMouse.mouseReenableTimer);
107
+ const releaseEpoch = ++state.delegationMouse.mouseReleaseEpoch;
108
+ state.delegationMouse.mouseReenableTimer = setTimeout(() => {
109
+ state.delegationMouse.mouseReenableTimer = undefined;
110
+ if (state.delegationMouse.mouseReleaseEpoch !== releaseEpoch) return;
111
+ state.delegationMouse.releasedUntilMs = undefined;
112
+ if (!state.delegationMouse.tui || state.delegations.runs.length === 0 || overlayActive(state)) return;
113
+ enableDelegationMouseMode(state.delegationMouse.tui);
114
+ state.delegationMouse.enabled = true;
115
+ }, 1200);
116
+ state.delegationMouse.mouseReenableTimer.unref?.();
117
+ }
118
+
119
+ export function handleDelegationMouseInput(ctx: ExtensionContext, state: HarnessRuntimeState, data: string): { consume: true } | undefined {
120
+ const event = parseSgrMouseEvent(data);
121
+ if (!event) return undefined;
122
+ const button = normalizedMouseButton(event.button);
123
+ if ((button === 64 || button === 65) && !event.release) {
124
+ if (state.delegationMouse.overlayScroll?.(button === 64 ? "up" : "down", event.x, event.y)) state.delegationMouse.tui?.requestRender?.();
125
+ else temporarilyReleaseMouseForFeedScroll(state);
126
+ return { consume: true };
127
+ }
128
+ const isOverlayActive = overlayActive(state);
129
+ if (button !== 0) return isOverlayActive ? undefined : { consume: true };
130
+ const action = findDelegateActionAtMousePosition(state.delegationMouse.tui as unknown as TuiRenderSnapshot | undefined, event.x, event.y);
131
+ if (!action) return isOverlayActive ? undefined : { consume: true };
132
+ if (isOverlayActive && action.kind !== "close" && action.kind !== "select") return undefined;
133
+ if (action.kind === "close") {
134
+ if (state.delegationMouse.overlayClose?.()) state.delegationMouse.tui?.requestRender?.();
135
+ return { consume: true };
136
+ }
137
+ if (action.kind === "select") {
138
+ if (state.delegationMouse.overlaySelect?.(action.runId)) state.delegationMouse.tui?.requestRender?.();
139
+ return { consume: true };
140
+ }
141
+ ensureRunForViewAction(state, action);
142
+ if ((state.delegationMouse.suppressOpenUntilMs ?? 0) > Date.now()) return { consume: true };
143
+ if (!state.delegationMouse.opening) {
144
+ state.delegationMouse.opening = true;
145
+ queueMicrotask(() => {
146
+ void import("./delegation-overlay.js")
147
+ .then(({ showDelegationOverlay }) => showDelegationOverlay(ctx, state, action.runId))
148
+ .finally(() => {
149
+ state.delegationMouse.opening = false;
150
+ });
151
+ });
152
+ }
153
+ return { consume: true };
154
+ }
155
+
156
+ export function installDelegationMouseSupport(ctx: ExtensionContext, state: HarnessRuntimeState, tui: TUI, owner?: symbol, options: { forceEnable?: boolean } = {}): void {
157
+ if (!ctx.hasUI) return;
158
+ if (options.forceEnable) {
159
+ if (state.delegationMouse.mouseReenableTimer) clearTimeout(state.delegationMouse.mouseReenableTimer);
160
+ state.delegationMouse.mouseReleaseEpoch++;
161
+ state.delegationMouse.mouseReenableTimer = undefined;
162
+ state.delegationMouse.releasedUntilMs = undefined;
163
+ state.delegationMouse.suppressOpenUntilMs = undefined;
164
+ }
165
+ const previousTui = state.delegationMouse.tui;
166
+ const ownerChanged = Boolean(owner && state.delegationMouse.widgetOwner && state.delegationMouse.widgetOwner !== owner);
167
+ const tuiChanged = Boolean(previousTui && previousTui !== tui);
168
+ if (state.delegationMouse.unsubscribe && (ownerChanged || tuiChanged)) {
169
+ state.delegationMouse.unsubscribe();
170
+ state.delegationMouse.unsubscribe = undefined;
171
+ if (state.delegationMouse.enabled) disableDelegationMouseMode(previousTui);
172
+ state.delegationMouse.enabled = false;
173
+ }
174
+ if (owner) state.delegationMouse.widgetOwner = owner;
175
+ state.delegationMouse.tui = tui;
176
+ const releasedForFeedScroll = !options.forceEnable && (state.delegationMouse.releasedUntilMs ?? 0) > Date.now() && !overlayActive(state);
177
+ if (!state.delegationMouse.enabled && !releasedForFeedScroll) {
178
+ enableDelegationMouseMode(tui);
179
+ state.delegationMouse.enabled = true;
180
+ }
181
+ if (state.delegationMouse.unsubscribe) return;
182
+ state.delegationMouse.unsubscribe = ctx.ui.onTerminalInput((data) => handleDelegationMouseInput(ctx, state, data));
183
+ }
184
+
185
+ export function disposeDelegationMouseSupport(state: HarnessRuntimeState, options: { force?: boolean; owner?: symbol } = {}): void {
186
+ if (options.owner && state.delegationMouse.widgetOwner && state.delegationMouse.widgetOwner !== options.owner && !options.force) return;
187
+ if (overlayActive(state) && !options.force) return;
188
+ if (state.delegationMouse.mouseReenableTimer) clearTimeout(state.delegationMouse.mouseReenableTimer);
189
+ state.delegationMouse.mouseReleaseEpoch++;
190
+ state.delegationMouse.mouseReenableTimer = undefined;
191
+ state.delegationMouse.releasedUntilMs = undefined;
192
+ state.delegationMouse.suppressOpenUntilMs = undefined;
193
+ state.delegationMouse.unsubscribe?.();
194
+ state.delegationMouse.unsubscribe = undefined;
195
+ if (state.delegationMouse.enabled) disableDelegationMouseMode(state.delegationMouse.tui);
196
+ state.delegationMouse.enabled = false;
197
+ state.delegationMouse.tui = undefined;
198
+ state.delegationMouse.opening = false;
199
+ state.delegationMouse.widgetOwner = undefined;
200
+ if (options.force) {
201
+ state.delegationMouse.overlaySelect = undefined;
202
+ state.delegationMouse.overlayClose = undefined;
203
+ state.delegationMouse.overlayScroll = undefined;
204
+ }
205
+ }
@@ -0,0 +1,434 @@
1
+ import type { ExtensionContext, Theme } from "@earendil-works/pi-coding-agent";
2
+ import { matchesKey, truncateToWidth, visibleWidth, type Component, type TUI } from "@earendil-works/pi-tui";
3
+
4
+ import type { DelegationMonitorState, DelegationRunView, DelegationSortMode } from "./delegation-monitor.js";
5
+ import { buildDelegationGroups, delegationCost, delegationDurationMs, delegationSignalBadge, delegationSignalColor, formatDelegationContextLabel, formatDelegationCost, formatDelegationCostLabel, formatDelegationModelLabel, formatDelegationSignalBadge, formatDuration, statusIcon } from "./delegation-monitor.js";
6
+ import { delegationFeedFingerprint, renderDelegationFeedLines } from "./delegation-feed.js";
7
+ import { delegateCloseButton, delegateSelectMarker } from "./delegation-click-markers.js";
8
+ import { disableDelegationMouseMode, enableDelegationMouseMode, handleDelegationMouseInput } from "./delegation-mouse.js";
9
+ import type { HarnessRuntimeState } from "./state.js";
10
+
11
+ interface OverlayRow {
12
+ kind: "group" | "run";
13
+ id: string;
14
+ label: string;
15
+ run?: DelegationRunView;
16
+ }
17
+
18
+ const SORT_MODES: DelegationSortMode[] = ["active", "latest", "duration", "agent"];
19
+
20
+ function padToWidth(text: string, width: number): string {
21
+ const clipped = truncateToWidth(text, Math.max(1, width), "…");
22
+ return clipped + " ".repeat(Math.max(0, width - visibleWidth(clipped)));
23
+ }
24
+
25
+ function statusColor(status: DelegationRunView["status"]): "success" | "warning" | "error" | "muted" {
26
+ if (status === "complete") return "success";
27
+ if (status === "running" || status === "queued") return "warning";
28
+ if (status === "preflight_failed" || status === "failed" || status === "aborted") return "error";
29
+ return "muted";
30
+ }
31
+
32
+ function flattenRows(state: DelegationMonitorState, sort: DelegationSortMode, nowMs: number): OverlayRow[] {
33
+ const rows: OverlayRow[] = [];
34
+ for (const group of buildDelegationGroups(state, sort, nowMs)) {
35
+ const shortId = group.parentToolCallId.slice(0, 8);
36
+ const groupCost = group.runs.reduce((total, run) => total + delegationCost(run), 0);
37
+ const groupCostLabel = group.runs.some((run) => !run.usage && (run.status === "queued" || run.status === "running"))
38
+ ? "cost pending"
39
+ : group.runs.every((run) => !run.usage)
40
+ ? "cost unavailable"
41
+ : formatDelegationCost(groupCost);
42
+ rows.push({
43
+ kind: "group",
44
+ id: `group:${group.parentToolCallId}`,
45
+ label: `${group.source} ${group.mode} #${shortId} · ${groupCostLabel} · ●${group.running} ✓${group.complete} ✗${group.failed}`,
46
+ });
47
+ for (const [index, run] of group.runs.entries()) {
48
+ const prefix = index === group.runs.length - 1 ? "└─" : "├─";
49
+ rows.push({
50
+ kind: "run",
51
+ id: run.id,
52
+ run,
53
+ label: `${prefix} ${statusIcon(run.status)} ${run.agent}`,
54
+ });
55
+ }
56
+ }
57
+ return rows;
58
+ }
59
+
60
+ export class DelegationOverlayComponent implements Component {
61
+ private selectedRunId?: string;
62
+ private listScroll = 0;
63
+ private logScroll = 0;
64
+ private sortIndex = 0;
65
+ private cachedTranscriptKey?: string;
66
+ private cachedTranscriptLines: string[] = [];
67
+ private followTail = true;
68
+ private lastMaxLogScroll = 0;
69
+ private lastListWidth = 38;
70
+ private ensureSelectionOnNextRender = true;
71
+ private filter = "";
72
+ private filterEditing = false;
73
+ private helpVisible = false;
74
+ private initialSelectionNoMatch = false;
75
+ private readonly overlaySelectHandler: (runId: string) => boolean;
76
+ private readonly overlayCloseHandler: () => boolean;
77
+ private readonly overlayScrollHandler: (direction: "up" | "down", x?: number, y?: number) => boolean;
78
+
79
+ constructor(
80
+ private readonly runtimeState: HarnessRuntimeState,
81
+ private readonly repoRoot: string,
82
+ private readonly theme: Theme,
83
+ private readonly done: () => void,
84
+ private readonly initialSelection: string | undefined,
85
+ private readonly tui: TUI,
86
+ ) {
87
+ this.overlaySelectHandler = (runId) => this.selectRun(runId);
88
+ this.overlayCloseHandler = () => {
89
+ this.close();
90
+ return true;
91
+ };
92
+ this.overlayScrollHandler = (direction, x, _y) => (this.isLeftPaneColumn(x) ? this.scrollList(direction) : this.scrollTranscript(direction));
93
+ this.runtimeState.delegationMouse.overlaySelect = this.overlaySelectHandler;
94
+ this.runtimeState.delegationMouse.overlayClose = this.overlayCloseHandler;
95
+ this.runtimeState.delegationMouse.overlayScroll = this.overlayScrollHandler;
96
+ enableDelegationMouseMode(this.tui);
97
+ this.runtimeState.delegationMouse.tui = this.tui;
98
+ this.runtimeState.delegationMouse.enabled = true;
99
+ this.runtimeState.delegationMouse.mouseReleaseEpoch++;
100
+ this.runtimeState.delegationMouse.releasedUntilMs = undefined;
101
+ if (this.runtimeState.delegationMouse.mouseReenableTimer) clearTimeout(this.runtimeState.delegationMouse.mouseReenableTimer);
102
+ this.runtimeState.delegationMouse.mouseReenableTimer = undefined;
103
+ }
104
+
105
+ handleInput(data: string): void {
106
+ if (handleDelegationMouseInput({ hasUI: true, cwd: this.repoRoot, ui: { onTerminalInput: () => () => undefined } } as unknown as ExtensionContext, this.runtimeState, data)?.consume) return;
107
+
108
+ if (matchesKey(data, "ctrl+c")) {
109
+ this.close();
110
+ return;
111
+ }
112
+ if (matchesKey(data, "escape")) {
113
+ if (this.filterEditing || this.filter) {
114
+ this.filter = "";
115
+ this.filterEditing = false;
116
+ this.listScroll = 0;
117
+ this.ensureSelectionOnNextRender = true;
118
+ this.invalidate();
119
+ return;
120
+ }
121
+ this.close();
122
+ return;
123
+ }
124
+
125
+ if (this.filterEditing) {
126
+ if (matchesKey(data, "enter")) {
127
+ this.filterEditing = false;
128
+ return;
129
+ }
130
+ if (matchesKey(data, "backspace") || data === "\x7f") {
131
+ this.filter = this.filter.slice(0, -1);
132
+ this.listScroll = 0;
133
+ this.ensureSelectionOnNextRender = true;
134
+ this.invalidate();
135
+ return;
136
+ }
137
+ if (this.isPrintableInput(data)) {
138
+ this.filter += data;
139
+ this.listScroll = 0;
140
+ this.ensureSelectionOnNextRender = true;
141
+ this.invalidate();
142
+ }
143
+ return;
144
+ }
145
+
146
+ if (data === "/") {
147
+ this.filterEditing = true;
148
+ return;
149
+ }
150
+ if (data === "?") {
151
+ this.helpVisible = !this.helpVisible;
152
+ return;
153
+ }
154
+
155
+ const rows = this.rows();
156
+ const selectable = rows.filter((row) => row.kind === "run" && row.run);
157
+ const currentIndex = Math.max(0, selectable.findIndex((row) => row.id === this.selectedRunId));
158
+
159
+ if (matchesKey(data, "up")) {
160
+ if (selectable.length === 0) return;
161
+ const next = selectable[Math.max(0, currentIndex - 1)];
162
+ this.selectedRunId = next?.id;
163
+ this.logScroll = 0;
164
+ this.followTail = true;
165
+ this.ensureSelectionOnNextRender = true;
166
+ this.ensureSelectedVisible(rows);
167
+ } else if (matchesKey(data, "down")) {
168
+ if (selectable.length === 0) return;
169
+ const next = selectable[Math.min(selectable.length - 1, currentIndex + 1)];
170
+ this.selectedRunId = next?.id;
171
+ this.logScroll = 0;
172
+ this.followTail = true;
173
+ this.ensureSelectionOnNextRender = true;
174
+ this.ensureSelectedVisible(rows);
175
+ } else if (data === "\x1b[5~") {
176
+ this.followTail = false;
177
+ this.logScroll = Math.max(0, this.logScroll - 10);
178
+ } else if (data === "\x1b[6~") {
179
+ this.logScroll += 10;
180
+ if (this.logScroll >= this.lastMaxLogScroll) this.followTail = true;
181
+ } else if (matchesKey(data, "home")) {
182
+ this.followTail = false;
183
+ this.logScroll = 0;
184
+ } else if (matchesKey(data, "end")) {
185
+ this.followTail = true;
186
+ this.logScroll = Number.MAX_SAFE_INTEGER;
187
+ } else if (data === "[" || data === "{") {
188
+ this.scrollList("up");
189
+ } else if (data === "]" || data === "}") {
190
+ this.scrollList("down");
191
+ } else if (data === "s" || data === "S") {
192
+ this.sortIndex = (this.sortIndex + 1) % SORT_MODES.length;
193
+ this.listScroll = 0;
194
+ this.logScroll = 0;
195
+ this.ensureSelectionOnNextRender = true;
196
+ } else if (data === "r" || data === "R") {
197
+ this.invalidate();
198
+ } else if (selectable.length === 0) {
199
+ return;
200
+ }
201
+ }
202
+
203
+ render(width: number): string[] {
204
+ const th = this.theme;
205
+ const w = Math.max(50, width);
206
+ const inner = Math.max(1, w - 2);
207
+ const listWidth = Math.min(38, Math.max(22, Math.floor(inner * 0.36)));
208
+ this.lastListWidth = listWidth;
209
+ const gap = 1;
210
+ const logWidth = Math.max(20, inner - listWidth - gap);
211
+ const bodyHeight = this.bodyHeight();
212
+ const rows = this.rows();
213
+ const selected = this.selectedRun(rows);
214
+ const transcript = this.transcriptLines(selected, logWidth);
215
+ const maxLogScroll = Math.max(0, transcript.length - bodyHeight);
216
+ this.listScroll = Math.max(0, Math.min(this.listScroll, Math.max(0, rows.length - bodyHeight)));
217
+ this.lastMaxLogScroll = maxLogScroll;
218
+ this.logScroll = this.followTail ? maxLogScroll : Math.min(Math.max(0, this.logScroll), maxLogScroll);
219
+ if (this.ensureSelectionOnNextRender) {
220
+ this.ensureSelectedVisible(rows, bodyHeight);
221
+ this.ensureSelectionOnNextRender = false;
222
+ }
223
+
224
+ const title = ` ZOB Delegations · sort=${SORT_MODES[this.sortIndex]} `;
225
+ const titleWidth = visibleWidth(title);
226
+ const leftRule = "─".repeat(Math.max(0, Math.floor((inner - titleWidth) / 2)));
227
+ const rightRule = "─".repeat(Math.max(0, inner - titleWidth - leftRule.length));
228
+ const lines: string[] = [th.fg("border", `╭${leftRule}`) + th.fg("accent", title) + th.fg("border", `${rightRule}╮`)];
229
+
230
+ const headerLeft = `${th.fg("accent", "Agents")} ${th.fg("muted", delegateCloseButton())}`;
231
+ const selectedBadge = delegationSignalBadge(selected);
232
+ const selectedBadgeText = formatDelegationSignalBadge(selectedBadge);
233
+ const headerRight = selected
234
+ ? `${th.fg(statusColor(selected.status), `${statusIcon(selected.status)} ${selected.agent}`)}${selectedBadgeText ? ` ${th.fg(delegationSignalColor(selectedBadge), selectedBadgeText)}` : ""}${formatDelegationModelLabel(selected) ? ` ${th.fg("muted", `(${formatDelegationModelLabel(selected)})`)}` : ""} ${th.fg("dim", formatDuration(delegationDurationMs(selected)))} ${th.fg("accent", formatDelegationCostLabel(selected))} ${th.fg("muted", formatDelegationContextLabel(selected))}`
235
+ : th.fg("warning", "No delegation selected");
236
+ lines.push(this.row(padToWidth(headerLeft, listWidth) + th.fg("dim", "│") + padToWidth(headerRight, logWidth), inner));
237
+ lines.push(th.fg("border", `├${"─".repeat(listWidth)}┼${"─".repeat(logWidth)}┤`));
238
+
239
+ const visibleRows = rows.slice(this.listScroll, this.listScroll + bodyHeight);
240
+ const visibleTranscript = transcript.slice(this.logScroll, this.logScroll + bodyHeight);
241
+ const noMatch = this.noMatchMessage(rows);
242
+ for (let index = 0; index < bodyHeight; index++) {
243
+ const listRow = visibleRows[index];
244
+ const logLine = visibleTranscript[index] ?? "";
245
+ const left = listRow ? this.renderListRow(listRow, listWidth) : index === 0 && noMatch ? th.fg("warning", noMatch) : "";
246
+ const right = truncateToWidth(logLine, logWidth, "…");
247
+ lines.push(this.row(padToWidth(left, listWidth) + th.fg("dim", "│") + padToWidth(right, logWidth), inner));
248
+ }
249
+
250
+ const filterInfo = this.filter || this.filterEditing ? ` · filter=${this.filterEditing ? ">" : ""}${this.filter || "<type>"}` : "";
251
+ const helpInfo = this.helpVisible
252
+ ? " · help: / filter · ? hide help · Esc clears filter/closes · ↑↓ select · [] list · PgUp/PgDn feed · s sort · r refresh"
253
+ : " · / filter · ? help";
254
+ const noMatchInfo = noMatch ? ` · ${noMatch}` : "";
255
+ const scrollInfo = `${rows.length} rows${filterInfo}${noMatchInfo} · list ${Math.min(this.listScroll + 1, rows.length || 1)}/${Math.max(1, rows.length)} · feed ${Math.min(this.logScroll + 1, transcript.length || 1)}/${Math.max(1, transcript.length)} · wheel over list/feed · click agent · [close]/Esc · ↑↓ select · [] list · PgUp/PgDn feed · End live-tail · s sort · r refresh${helpInfo}`;
256
+ lines.push(th.fg("border", `├${"─".repeat(inner)}┤`));
257
+ lines.push(this.row(th.fg("dim", truncateToWidth(scrollInfo, inner, "…")), inner));
258
+ lines.push(th.fg("border", `╰${"─".repeat(inner)}╯`));
259
+ return lines.map((line) => truncateToWidth(line, w, ""));
260
+ }
261
+
262
+ invalidate(): void {
263
+ this.cachedTranscriptKey = undefined;
264
+ this.cachedTranscriptLines = [];
265
+ }
266
+
267
+ dispose(): void {
268
+ disableDelegationMouseMode(this.tui);
269
+ this.runtimeState.delegationMouse.mouseReleaseEpoch++;
270
+ if (this.runtimeState.delegationMouse.tui === this.tui) this.runtimeState.delegationMouse.enabled = false;
271
+ this.runtimeState.delegationMouse.releasedUntilMs = undefined;
272
+ if (this.runtimeState.delegationMouse.mouseReenableTimer) clearTimeout(this.runtimeState.delegationMouse.mouseReenableTimer);
273
+ this.runtimeState.delegationMouse.mouseReenableTimer = undefined;
274
+ this.runtimeState.delegationMouse.opening = false;
275
+ if (this.runtimeState.delegationMouse.overlaySelect === this.overlaySelectHandler) this.runtimeState.delegationMouse.overlaySelect = undefined;
276
+ if (this.runtimeState.delegationMouse.overlayClose === this.overlayCloseHandler) this.runtimeState.delegationMouse.overlayClose = undefined;
277
+ if (this.runtimeState.delegationMouse.overlayScroll === this.overlayScrollHandler) this.runtimeState.delegationMouse.overlayScroll = undefined;
278
+ }
279
+
280
+ private close(): void {
281
+ this.runtimeState.delegationMouse.suppressOpenUntilMs = Date.now() + 350;
282
+ this.dispose();
283
+ this.done();
284
+ }
285
+
286
+ private selectRun(runId: string): boolean {
287
+ const rows = this.rows();
288
+ if (!rows.some((row) => row.kind === "run" && row.id === runId)) return false;
289
+ this.selectedRunId = runId;
290
+ this.logScroll = 0;
291
+ this.followTail = true;
292
+ this.ensureSelectionOnNextRender = true;
293
+ this.ensureSelectedVisible(rows);
294
+ this.invalidate();
295
+ return true;
296
+ }
297
+
298
+ private scrollTranscript(direction: "up" | "down"): boolean {
299
+ if (direction === "up") {
300
+ this.followTail = false;
301
+ this.logScroll = Math.max(0, this.logScroll - 4);
302
+ } else {
303
+ this.logScroll += 4;
304
+ if (this.logScroll >= this.lastMaxLogScroll) this.followTail = true;
305
+ }
306
+ return true;
307
+ }
308
+
309
+ private scrollList(direction: "up" | "down"): boolean {
310
+ const maxListScroll = Math.max(0, this.rows().length - this.bodyHeight());
311
+ this.listScroll = direction === "up" ? Math.max(0, this.listScroll - 4) : Math.min(maxListScroll, this.listScroll + 4);
312
+ this.ensureSelectionOnNextRender = false;
313
+ return true;
314
+ }
315
+
316
+ private isLeftPaneColumn(x: number | undefined): boolean {
317
+ return typeof x === "number" && x > 1 && x <= this.lastListWidth + 1;
318
+ }
319
+
320
+ private rows(): OverlayRow[] {
321
+ const nowMs = Date.now();
322
+ const allRows = flattenRows(this.runtimeState.delegations, SORT_MODES[this.sortIndex] ?? "active", nowMs);
323
+ const allRunRows = allRows.filter((row) => row.kind === "run" && row.run);
324
+ const hinted = this.initialSelection ? this.findRunByHint(allRunRows, this.initialSelection) : undefined;
325
+ this.initialSelectionNoMatch = Boolean(this.initialSelection?.trim() && !hinted);
326
+ const rows = this.filterRows(allRows);
327
+ const runRows = rows.filter((row) => row.kind === "run" && row.run);
328
+ const filteredHint = hinted && rows.some((row) => row.id === hinted.id) ? hinted : undefined;
329
+ if (!this.selectedRunId) this.selectedRunId = filteredHint?.id ?? runRows[0]?.id;
330
+ if (this.selectedRunId && !rows.some((row) => row.id === this.selectedRunId && row.kind === "run")) this.selectedRunId = filteredHint?.id ?? runRows[0]?.id;
331
+ return rows;
332
+ }
333
+
334
+ private findRunByHint(rows: OverlayRow[], hint: string): OverlayRow | undefined {
335
+ const normalized = hint.trim().toLowerCase();
336
+ if (!normalized) return undefined;
337
+ return rows.find((row) => {
338
+ const run = row.run;
339
+ return Boolean(run && (run.id.toLowerCase().startsWith(normalized) || run.id.slice(0, 8).toLowerCase() === normalized || run.agent.toLowerCase() === normalized));
340
+ });
341
+ }
342
+
343
+ private filterRows(rows: OverlayRow[]): OverlayRow[] {
344
+ const needle = this.filter.trim().toLowerCase();
345
+ if (!needle) return rows;
346
+ const filtered: OverlayRow[] = [];
347
+ let currentGroup: OverlayRow | undefined;
348
+ let groupMatches = false;
349
+ for (const row of rows) {
350
+ if (row.kind === "group") {
351
+ currentGroup = row;
352
+ groupMatches = row.label.toLowerCase().includes(needle);
353
+ continue;
354
+ }
355
+ if (!row.run) continue;
356
+ const searchableRun = row.run as DelegationRunView & { failureKind?: string; taskPreview?: string };
357
+ const haystack = [currentGroup?.label, row.id, searchableRun.agent, searchableRun.status, searchableRun.failureKind, searchableRun.taskPreview, formatDelegationSignalBadge(delegationSignalBadge(row.run))]
358
+ .filter((part): part is string => typeof part === "string")
359
+ .join(" ")
360
+ .toLowerCase();
361
+ if (!groupMatches && !haystack.includes(needle)) continue;
362
+ if (currentGroup && filtered[filtered.length - 1]?.id !== currentGroup.id) filtered.push(currentGroup);
363
+ filtered.push(row);
364
+ }
365
+ return filtered;
366
+ }
367
+
368
+ private selectedRun(rows: OverlayRow[]): DelegationRunView | undefined {
369
+ return rows.find((row) => row.kind === "run" && row.id === this.selectedRunId)?.run;
370
+ }
371
+
372
+ private transcriptLines(run: DelegationRunView | undefined, width: number): string[] {
373
+ const key = run ? `${delegationFeedFingerprint(run, this.repoRoot)}|${width}` : `none|${width}`;
374
+ if (this.cachedTranscriptKey === key) return this.cachedTranscriptLines;
375
+ this.cachedTranscriptKey = key;
376
+ this.cachedTranscriptLines = renderDelegationFeedLines(run, this.repoRoot, width, this.theme);
377
+ return this.cachedTranscriptLines;
378
+ }
379
+
380
+ private bodyHeight(): number {
381
+ const terminalRows = (this.tui as { terminal?: { rows?: number } }).terminal?.rows;
382
+ const availableRows = typeof terminalRows === "number" && Number.isFinite(terminalRows) ? terminalRows - 8 : 22;
383
+ return Math.max(8, Math.min(22, availableRows));
384
+ }
385
+
386
+ private isPrintableInput(data: string): boolean {
387
+ return data.length === 1 && data >= " " && data !== "\x7f";
388
+ }
389
+
390
+ private noMatchMessage(rows: OverlayRow[]): string | undefined {
391
+ const hasRun = rows.some((row) => row.kind === "run" && row.run);
392
+ if (this.filter.trim() && !hasRun) return `No matches for /${this.filter}`;
393
+ if (this.initialSelectionNoMatch) return `No run matches initial selection ${this.initialSelection}`;
394
+ return undefined;
395
+ }
396
+
397
+ private ensureSelectedVisible(rows: OverlayRow[], bodyHeight = this.bodyHeight()): void {
398
+ const selectedIndex = rows.findIndex((row) => row.id === this.selectedRunId);
399
+ if (selectedIndex < 0) return;
400
+ if (selectedIndex < this.listScroll) this.listScroll = selectedIndex;
401
+ if (selectedIndex >= this.listScroll + bodyHeight) this.listScroll = selectedIndex - bodyHeight + 1;
402
+ this.listScroll = Math.max(0, Math.min(this.listScroll, Math.max(0, rows.length - bodyHeight)));
403
+ }
404
+
405
+ private renderListRow(row: OverlayRow, width: number): string {
406
+ const th = this.theme;
407
+ if (row.kind === "group") return th.fg("muted", truncateToWidth(row.label, width, "…"));
408
+ const selected = row.id === this.selectedRunId;
409
+ const run = row.run;
410
+ if (!run) return "";
411
+ const duration = formatDuration(delegationDurationMs(run));
412
+ const cost = formatDelegationCostLabel(run);
413
+ const context = formatDelegationContextLabel(run);
414
+ const badge = formatDelegationSignalBadge(delegationSignalBadge(run));
415
+ const modelLabel = formatDelegationModelLabel(run);
416
+ const modelSuffix = modelLabel ? ` (${modelLabel})` : "";
417
+ const base = `${row.label}${badge ? ` ${badge}` : ""}${modelSuffix} ${duration} ${cost} ${context} [view]`;
418
+ const labeled = `${truncateToWidth(base, width - (selected ? 2 : 0), "…")}${delegateSelectMarker(run.id)}`;
419
+ const colored = th.fg(statusColor(run.status), labeled);
420
+ return selected ? th.bg("selectedBg", padToWidth(colored, width)) : colored;
421
+ }
422
+
423
+ private row(content: string, innerWidth: number): string {
424
+ return this.theme.fg("border", "│") + padToWidth(content, innerWidth) + this.theme.fg("border", "│");
425
+ }
426
+ }
427
+
428
+ export async function showDelegationOverlay(ctx: ExtensionContext, state: HarnessRuntimeState, initialSelection?: string): Promise<void> {
429
+ if (!ctx.hasUI) return;
430
+ await ctx.ui.custom<void>((tui, theme, _keybindings, done) => new DelegationOverlayComponent(state, ctx.cwd, theme, done, initialSelection, tui), {
431
+ overlay: true,
432
+ overlayOptions: { anchor: "center", width: "90%", maxHeight: "80%", margin: 2 },
433
+ });
434
+ }