@zaip-ai/cli 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/README.md +3 -2
  2. package/dist/services/agent-adapters.js +1 -1
  3. package/dist/services/agent-adapters.js.map +1 -1
  4. package/dist/services/agent-adapters.test.js +2 -1
  5. package/dist/services/agent-adapters.test.js.map +1 -1
  6. package/dist/services/codex-pre-tool-hook-template.d.ts.map +1 -1
  7. package/dist/services/codex-pre-tool-hook-template.js +89 -7
  8. package/dist/services/codex-pre-tool-hook-template.js.map +1 -1
  9. package/dist/services/codex-rules.d.ts +1 -1
  10. package/dist/services/codex-rules.d.ts.map +1 -1
  11. package/dist/services/codex-rules.js +7 -0
  12. package/dist/services/codex-rules.js.map +1 -1
  13. package/dist/services/install-agents-template.d.ts.map +1 -1
  14. package/dist/services/install-agents-template.js +1 -0
  15. package/dist/services/install-agents-template.js.map +1 -1
  16. package/dist/services/runtime-template.test.js +31 -7
  17. package/dist/services/runtime-template.test.js.map +1 -1
  18. package/dist/services/template-manifest.d.ts.map +1 -1
  19. package/dist/services/template-manifest.js +7 -3
  20. package/dist/services/template-manifest.js.map +1 -1
  21. package/package.json +1 -1
  22. package/templates/.agents/config/agents/catalog.yaml +7 -7
  23. package/templates/.agents/config/clients/codex/agents/zaip-agent-backend.toml +2 -2
  24. package/templates/.agents/config/clients/codex/agents/zaip-agent-designer.toml +2 -2
  25. package/templates/.agents/config/clients/codex/agents/zaip-agent-frontend.toml +8 -8
  26. package/templates/.agents/dashboard/.zaip-managed.json +373 -205
  27. package/templates/.agents/dashboard/apps/frontend/dist/assets/{CostCalculationGuidePage-DxR_pgSV.js → CostCalculationGuidePage-ovxurkIk.js} +1 -1
  28. package/templates/.agents/dashboard/apps/frontend/dist/assets/{DashboardHelpDialog-4jZLTWE_.js → DashboardHelpDialog-BXy6nti1.js} +268 -86
  29. package/templates/.agents/dashboard/apps/frontend/dist/assets/{PricingSettingsDialog-CKcsqb-r.js → PricingSettingsDialog-vSvvOHQp.js} +1 -1
  30. package/templates/.agents/dashboard/apps/frontend/dist/assets/{ProjectSettingsPage-DmmJD2Th.js → ProjectSettingsPage-zH758vfs.js} +1 -1
  31. package/templates/.agents/dashboard/apps/frontend/dist/assets/TraceabilityWorkspace-CTH2wDs5.js +1 -0
  32. package/templates/.agents/dashboard/apps/frontend/dist/assets/{TraceabilityWorkspace-CaKwQP43.css → TraceabilityWorkspace-DvvavDLY.css} +1 -1
  33. package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-DKwP1stV.js +68 -0
  34. package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-PoJA2PI1.css +1 -0
  35. package/templates/.agents/dashboard/apps/frontend/dist/assets/{icons-vendor-C0fj2uU9.js → icons-vendor-B_lDDHn1.js} +1 -1
  36. package/templates/.agents/dashboard/apps/frontend/dist/assets/index-B31GMG5O.css +1 -0
  37. package/templates/.agents/dashboard/apps/frontend/dist/assets/index-CuMcoUni.js +2 -0
  38. package/templates/.agents/dashboard/apps/frontend/dist/assets/{react-vendor-BEsJ-FYH.js → react-vendor-B3TJrD4O.js} +1 -1
  39. package/templates/.agents/dashboard/apps/frontend/dist/assets/{traceability-B6y6Gw12.js → traceability-7f1j5wx3.js} +1 -1
  40. package/templates/.agents/dashboard/apps/frontend/dist/index.html +7 -7
  41. package/templates/.agents/dashboard/apps/frontend/playwright.dom.config.ts +32 -0
  42. package/templates/.agents/dashboard/apps/frontend/src/App.tsx +132 -245
  43. package/templates/.agents/dashboard/apps/frontend/src/AppOverlays.tsx +0 -21
  44. package/templates/.agents/dashboard/apps/frontend/src/DashboardAlternateContent.tsx +9 -0
  45. package/templates/.agents/dashboard/apps/frontend/src/TraceabilityWorkspace.dom.e2e.ts +56 -0
  46. package/templates/.agents/dashboard/apps/frontend/src/TraceabilityWorkspace.test.ts +18 -1
  47. package/templates/.agents/dashboard/apps/frontend/src/TraceabilityWorkspace.tsx +75 -8
  48. package/templates/.agents/dashboard/apps/frontend/src/dashboard-api.test.ts +25 -1
  49. package/templates/.agents/dashboard/apps/frontend/src/dashboard-api.ts +7 -9
  50. package/templates/.agents/dashboard/apps/frontend/src/operations-period-render.test.ts +4 -4
  51. package/templates/.agents/dashboard/apps/frontend/src/overview-status-page.test.ts +1 -1
  52. package/templates/.agents/dashboard/apps/frontend/src/snapshot-banner-semantics.test.ts +7 -0
  53. package/templates/.agents/dashboard/apps/frontend/src/snapshot-coherence.test.ts +20 -8
  54. package/templates/.agents/dashboard/apps/frontend/src/sqlite-page-export.test.ts +32 -0
  55. package/templates/.agents/dashboard/apps/frontend/src/sqlite-page-export.ts +21 -0
  56. package/templates/.agents/dashboard/apps/frontend/src/styles.css +19 -0
  57. package/templates/.agents/dashboard/apps/frontend/src/traceability-task-pagination.test.ts +32 -0
  58. package/templates/.agents/dashboard/apps/frontend/src/traceability-task-pagination.ts +36 -0
  59. package/templates/.agents/dashboard/apps/frontend/src/traceability-workspace.css +6 -2
  60. package/templates/.agents/dashboard/apps/frontend/src/use-app-cost-loaders.test.ts +48 -0
  61. package/templates/.agents/dashboard/apps/frontend/src/use-app-cost-loaders.ts +31 -27
  62. package/templates/.agents/dashboard/apps/frontend/src/use-app-trace-documents.ts +7 -1
  63. package/templates/.agents/dashboard/apps/frontend/src/use-app-work-list-page.test.ts +163 -0
  64. package/templates/.agents/dashboard/apps/frontend/src/use-app-work-list-page.ts +136 -0
  65. package/templates/.agents/dashboard/apps/frontend/src/use-operations-detail-export.ts +76 -0
  66. package/templates/.agents/dashboard/apps/frontend/src/work-list-load-dedup.test.ts +23 -0
  67. package/templates/.agents/dashboard/apps/frontend/src/work-list-load-dedup.ts +27 -0
  68. package/templates/.agents/dashboard/apps/frontend/src/work-list-pagination.test.ts +38 -14
  69. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostDeveloperAttributionPanel.tsx +60 -0
  70. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostDeveloperAttributionTable.tsx +191 -0
  71. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostFilters.loading.test.ts +14 -0
  72. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostFilters.run-page.test.ts +18 -0
  73. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostFilters.tsx +18 -3
  74. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorContent.tsx +8 -2
  75. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorLoadErrors.tsx +35 -0
  76. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.test.ts +47 -1
  77. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.tsx +50 -58
  78. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTableLoading.test.ts +132 -0
  79. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTableLoading.tsx +70 -0
  80. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables.test.ts +128 -138
  81. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables.tsx +17 -67
  82. package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-copy.ts +2 -0
  83. package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-views.ts +3 -1
  84. package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-page-range.ts +35 -0
  85. package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-compact-cost-page.ts +16 -4
  86. package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-cost-group-page.test.ts +37 -2
  87. package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-cost-group-page.ts +44 -8
  88. package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-cost-run-page.ts +6 -1
  89. package/templates/.agents/dashboard/modules/operations/src/contracts.ts +20 -3
  90. package/templates/.agents/dashboard/modules/operations/src/react/DeveloperAttributionPanel.test.ts +54 -0
  91. package/templates/.agents/dashboard/modules/operations/src/react/DeveloperAttributionPanel.tsx +247 -0
  92. package/templates/.agents/dashboard/modules/operations/src/react/OperationsMainContent.tsx +39 -13
  93. package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.helpers.tsx +107 -2
  94. package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.macro-metrics.test.ts +55 -0
  95. package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.test.ts +20 -28
  96. package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.tsx +162 -165
  97. package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverviewTopPanel.tsx +127 -0
  98. package/templates/.agents/dashboard/modules/operations/src/react/OperationsPage.tsx +13 -46
  99. package/templates/.agents/dashboard/modules/operations/src/react/OperationsPageOverview.tsx +3 -0
  100. package/templates/.agents/dashboard/modules/operations/src/react/PagedWorkList.test.tsx +43 -0
  101. package/templates/.agents/dashboard/modules/operations/src/react/PagedWorkList.tsx +181 -0
  102. package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkList.test.ts +4 -2
  103. package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkList.tsx +13 -0
  104. package/templates/.agents/dashboard/modules/operations/src/react/developer-identities.test.ts +18 -0
  105. package/templates/.agents/dashboard/modules/operations/src/react/developer-identities.ts +30 -0
  106. package/templates/.agents/dashboard/modules/operations/src/react/execution-metrics.ts +1 -0
  107. package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportAction.test.ts +8 -0
  108. package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportAction.tsx +3 -0
  109. package/templates/.agents/dashboard/modules/operations/src/react/export/export-layout.test.ts +14 -5
  110. package/templates/.agents/dashboard/modules/operations/src/react/index.ts +1 -0
  111. package/templates/.agents/dashboard/modules/operations/src/react/operations-coverage-toast.test.ts +4 -3
  112. package/templates/.agents/dashboard/modules/operations/src/react/operations-date-filters.css +1 -1
  113. package/templates/.agents/dashboard/modules/operations/src/react/operations-overview-period-filter.test.ts +21 -11
  114. package/templates/.agents/dashboard/modules/operations/src/react/operations-overview.css +4 -0
  115. package/templates/.agents/dashboard/modules/operations/src/react/operations-page-contract.ts +8 -1
  116. package/templates/.agents/dashboard/modules/operations/src/react/operations-view-order.test.ts +1 -0
  117. package/templates/.agents/dashboard/modules/operations/src/react/period-summary.ts +1 -0
  118. package/templates/.agents/dashboard/modules/operations/src/server/metric-coverage.ts +1 -0
  119. package/templates/.agents/dashboard/packages/local-runtime/dist/server.cjs +527 -335
  120. package/templates/.agents/dashboard/packages/local-runtime/dist/sqlite-read-model.cjs +501 -309
  121. package/templates/.agents/dashboard/packages/local-runtime/gitignore.template +2 -0
  122. package/templates/.agents/dashboard/packages/local-runtime/scripts/rebuild-sqlite-read-model.mjs +3 -1
  123. package/templates/.agents/dashboard/packages/local-runtime/scripts/test-sqlite-read-model.mjs +3 -3
  124. package/templates/.agents/dashboard/packages/local-runtime/scripts/validate-sqlite-read-model.mjs +25 -15
  125. package/templates/.agents/dashboard/packages/local-runtime/server.mjs +527 -335
  126. package/templates/.agents/dashboard/packages/local-runtime/src/server-board.test.ts +34 -0
  127. package/templates/.agents/dashboard/packages/local-runtime/src/server-board.ts +15 -8
  128. package/templates/.agents/dashboard/packages/local-runtime/src/server-classification-page.test.ts +87 -0
  129. package/templates/.agents/dashboard/packages/local-runtime/src/server-period-macro-metric.test.ts +44 -0
  130. package/templates/.agents/dashboard/packages/local-runtime/src/server-period-macro-metric.ts +125 -0
  131. package/templates/.agents/dashboard/packages/local-runtime/src/server-reconciliation-refresh.test.ts +66 -0
  132. package/templates/.agents/dashboard/packages/local-runtime/src/server-request-authority.test.ts +61 -0
  133. package/templates/.agents/dashboard/packages/local-runtime/src/server-request-authority.ts +18 -0
  134. package/templates/.agents/dashboard/packages/local-runtime/src/server-run-projections.test.ts +42 -0
  135. package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-refresh.ts +97 -0
  136. package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot.test.ts +3 -1
  137. package/templates/.agents/dashboard/packages/local-runtime/src/server-sqlite-task-trace.ts +91 -0
  138. package/templates/.agents/dashboard/packages/local-runtime/src/server.test-fixtures.ts +36 -0
  139. package/templates/.agents/dashboard/packages/local-runtime/src/server.test.ts +98 -123
  140. package/templates/.agents/dashboard/packages/local-runtime/src/server.ts +111 -135
  141. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-artifact-counts.ts +28 -0
  142. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-agent-page.test.ts +63 -0
  143. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-agent-page.ts +109 -0
  144. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-aggregates.ts +497 -0
  145. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-fast-page-parity.test-support.ts +65 -0
  146. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-group-page.test.ts +176 -0
  147. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-group-page.ts +119 -0
  148. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-group-projection.ts +41 -0
  149. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-invocation-page.test.ts +16 -0
  150. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-invocation-page.ts +29 -0
  151. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-first-fold-cache.ts +355 -0
  152. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-first-fold-persistence.ts +121 -0
  153. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-first-fold-timing.ts +27 -0
  154. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-operations-projection.ts +15 -0
  155. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-operations-work-list.test.ts +293 -0
  156. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-operations-work-list.ts +371 -0
  157. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-cache.test-support.ts +23 -0
  158. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-first-fold-types.ts +89 -0
  159. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-multi-provider-fixture.ts +227 -0
  160. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-multi-provider.test.ts +691 -0
  161. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-source-fingerprint.ts +81 -0
  162. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model.test.ts +440 -863
  163. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model.ts +1120 -1086
  164. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-snapshot-cache.ts +129 -0
  165. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-snapshot-install.test.ts +26 -0
  166. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-snapshot-install.ts +28 -0
  167. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-snapshot-seed.test.ts +116 -0
  168. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-launch-page.mjs +146 -0
  169. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-launch-page.test.mjs +165 -0
  170. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-refresh.mjs +140 -0
  171. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard.mjs +188 -299
  172. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard.test.mjs +51 -70
  173. package/templates/.agents/dashboard/packages/windows-launcher/Program.cs +5 -2
  174. package/templates/.agents/dashboard/tests/e2e/playwright.config.ts +4 -1
  175. package/templates/.agents/dashboard/tests/e2e/specs/cost-monitor-loading.spec.ts +142 -0
  176. package/templates/.agents/dashboard/tests/e2e/specs/cost-monitor-pagination.spec.ts +232 -0
  177. package/templates/.agents/dashboard/tests/e2e/specs/dashboard-performance-matrix.spec.ts +743 -0
  178. package/templates/.agents/dashboard/tests/e2e/specs/dashboard.spec.ts +183 -210
  179. package/templates/.agents/dashboard/zaip-dashboard-windows.exe +0 -0
  180. package/templates/.agents/requirements/autonomous-assurance.md +6 -6
  181. package/templates/.agents/requirements/comparative-audit.md +1 -1
  182. package/templates/.agents/requirements/context-engine.md +1 -1
  183. package/templates/.agents/requirements/cost-observability.md +1 -1
  184. package/templates/.agents/requirements/dashboard-launch.md +1 -1
  185. package/templates/.agents/requirements/data-export.md +1 -1
  186. package/templates/.agents/requirements/design-system.md +1 -1
  187. package/templates/.agents/requirements/execution-engine.md +3 -3
  188. package/templates/.agents/requirements/kanban-dashboard.md +10 -2
  189. package/templates/.agents/requirements/model-orchestration.md +1 -1
  190. package/templates/.agents/requirements/public-distribution.md +1 -1
  191. package/templates/.agents/requirements/software-architecture.md +1 -1
  192. package/templates/.agents/requirements/strategic-improvements.md +1 -1
  193. package/templates/.agents/requirements/work-lifecycle.md +4 -4
  194. package/templates/.agents/requirements/zaip-strategic-95.md +1 -1
  195. package/templates/.agents/rules/dashboard-ui-consistency.md +14 -0
  196. package/templates/.agents/rules/frontend-lite.md +4 -4
  197. package/templates/.agents/rules/run-lifecycle-closure.md +4 -4
  198. package/templates/.agents/runtime/bin/zaip.mjs +1137 -1037
  199. package/templates/.agents/runtime/checksums.sha256 +2 -2
  200. package/templates/.agents/runtime/provenance.json +2 -2
  201. package/templates/.agents/skills/criar-pasta-obsidian/scripts/generate-obsidian-vault.test.mjs +20 -16
  202. package/templates/.agents/skills/zaip-skill-agent-catalog/SKILL.md +22 -0
  203. package/templates/.agents/skills/zaip-skill-agent-catalog/agents/openai.yaml +4 -0
  204. package/templates/.agents/skills/zaip-skill-author-skills/SKILL.md +3 -2
  205. package/templates/.agents/skills/zaip-skill-author-skills/scripts/audit-skill-catalog.mjs +49 -0
  206. package/templates/.agents/skills/zaip-skill-author-skills/scripts/author-skill-scripts.test.mjs +27 -0
  207. package/templates/.agents/skills/zaip-skill-author-skills/scripts/run-skill-tests.mjs +37 -0
  208. package/templates/.agents/skills/zaip-skill-backend/SKILL.md +1 -0
  209. package/templates/.agents/skills/zaip-skill-change/SKILL.md +1 -1
  210. package/templates/.agents/skills/zaip-skill-change/references/observable-evidence.md +83 -0
  211. package/templates/.agents/skills/zaip-skill-dashboard-diagnostics/SKILL.md +22 -0
  212. package/templates/.agents/skills/zaip-skill-dashboard-diagnostics/agents/openai.yaml +4 -0
  213. package/templates/.agents/skills/zaip-skill-execution/SKILL.md +1 -1
  214. package/templates/.agents/skills/zaip-skill-frontend/SKILL.md +4 -3
  215. package/templates/.agents/skills/zaip-skill-frontend/agents/openai.yaml +2 -2
  216. package/templates/.agents/skills/zaip-skill-github-deploy/SKILL.md +10 -10
  217. package/templates/.agents/skills/zaip-skill-lifecycle-closure/SKILL.md +27 -0
  218. package/templates/.agents/skills/zaip-skill-lifecycle-closure/agents/openai.yaml +4 -0
  219. package/templates/.agents/skills/zaip-skill-prd/SKILL.md +4 -0
  220. package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-local-telemetry.mjs +72 -22
  221. package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-explicit-recovery.mjs +223 -0
  222. package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-lib.mjs +42 -1
  223. package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-lib.test.mjs +101 -0
  224. package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-remeasurement.test.mjs +53 -0
  225. package/templates/.agents/skills/zaip-skill-release-qualification/SKILL.md +20 -0
  226. package/templates/.agents/skills/zaip-skill-release-qualification/agents/openai.yaml +4 -0
  227. package/templates/.agents/skills/zaip-skill-review/SKILL.md +5 -0
  228. package/templates/.agents/skills/zaip-skill-rules/SKILL.md +1 -1
  229. package/templates/.agents/skills/zaip-skill-spec/SKILL.md +4 -0
  230. package/templates/.agents/skills/zaip-skill-sqlite-read-model/SKILL.md +22 -90
  231. package/templates/.agents/zaip-aios/INDEX.md +57 -32
  232. package/templates/.agents/zaip-aios/README.md +22 -12
  233. package/templates/.agents/zaip-aios/guides/02-requirements.md +5 -0
  234. package/templates/.agents/zaip-aios/guides/06-execucao.md +13 -4
  235. package/templates/.agents/zaip-aios/guides/07-revisao-e-validacao.md +7 -0
  236. package/templates/.agents/zaip-aios/guides/10-seguranca.md +23 -0
  237. package/templates/.agents/zaip-aios/guides/11-observabilidade-e-custos.md +6 -6
  238. package/templates/.agents/zaip-aios/guides/13-boas-praticas.md +3 -0
  239. package/templates/.agents/zaip-aios/guides/16-lifecycle-e-reconciliacao.md +12 -3
  240. package/templates/.agents/zaip-aios/guides/17-como-o-custo-e-calculado.md +5 -5
  241. package/templates/.agents/zaip-aios/guides/19-assurance-e-autonomia.md +23 -0
  242. package/templates/.agents/zaip-aios/guides/20-instalacao-detalhada.md +44 -8
  243. package/templates/.agents/zaip-aios/guides/21-telemetria-monitor-custos.md +8 -14
  244. package/templates/.agents/zaip-aios/guides/22-fluxos-e-roteamento.md +5 -0
  245. package/templates/.agents/zaip-aios/guides/23-orquestracao-de-modelos.md +6 -6
  246. package/templates/.agents/zaip-aios/guides/24-calculo-de-custos-openai.md +8 -8
  247. package/templates/.agents/zaip-aios/guides/25-fontes-de-precos-openai.md +3 -2
  248. package/templates/.agents/zaip-aios/guides/26-qualidade-e-release.md +92 -10
  249. package/templates/.agents/zaip-aios/guides/27-telemetria-git-native.md +8 -3
  250. package/templates/.agents/zaip-aios/guides/28-lifecycle-completo.md +5 -0
  251. package/templates/template-manifest.json +555 -170
  252. package/templates/.agents/dashboard/apps/frontend/dist/assets/TraceabilityWorkspace-BwtitWa_.js +0 -1
  253. package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-BZ5WdaMN.css +0 -1
  254. package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-N5Csr0RP.js +0 -68
  255. package/templates/.agents/dashboard/apps/frontend/dist/assets/index-C4aIB1PV.js +0 -2
  256. package/templates/.agents/dashboard/apps/frontend/dist/assets/index-DK_enB5Z.css +0 -1
  257. package/templates/.agents/dashboard/apps/frontend/src/use-idle-cost-prefetch.ts +0 -45
  258. package/templates/.agents/dashboard/packages/local-runtime/dist/server.cjs.metafile.json +0 -7333
@@ -0,0 +1,32 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import {
3
+ appendTraceabilityTaskPage,
4
+ nextTraceabilityVisibleCount,
5
+ traceabilityTaskPageSize,
6
+ } from "./traceability-task-pagination.js";
7
+
8
+ describe("traceability task pagination", () => {
9
+ it("advances offsets through the API total while preserving unique tasks", () => {
10
+ const task = (id: string) => ({ id, title: id }) as never;
11
+ const first = appendTraceabilityTaskPage({
12
+ cursor: { offset: 0, stageIndex: 0 },
13
+ page: { tasks: [task("TASK-1"), task("TASK-2")], total: 3 } as never,
14
+ tasks: [],
15
+ });
16
+ const second = appendTraceabilityTaskPage({
17
+ cursor: first.cursor,
18
+ page: { tasks: [task("TASK-2"), task("TASK-3")], total: 3 } as never,
19
+ tasks: first.tasks,
20
+ });
21
+
22
+ expect(first.cursor).toEqual({ offset: 2, stageIndex: 0 });
23
+ expect(second.cursor).toEqual({ offset: 0, stageIndex: 1 });
24
+ expect(second.tasks.map((item) => item.id)).toEqual(["TASK-1", "TASK-2", "TASK-3"]);
25
+ });
26
+
27
+ it("advances the rendered list by a deterministic concise batch", () => {
28
+ expect(traceabilityTaskPageSize).toBe(10);
29
+ expect(nextTraceabilityVisibleCount(12, 30, 12)).toBe(24);
30
+ expect(nextTraceabilityVisibleCount(24, 30, 12)).toBe(30);
31
+ });
32
+ });
@@ -0,0 +1,36 @@
1
+ import type { OperationsProjection } from "@zaip-ai/dashboard-operations/contracts";
2
+ import type { OperationsBoardPage } from "./dashboard-api.js";
3
+
4
+ /** The selector is a navigation aid, not a full task export. */
5
+ export const traceabilityTaskPageSize = 10;
6
+
7
+ export type TraceabilityTaskCursor = { offset: number; stageIndex: number };
8
+
9
+ export function appendTraceabilityTaskPage({
10
+ cursor,
11
+ page,
12
+ tasks,
13
+ }: {
14
+ cursor: TraceabilityTaskCursor;
15
+ page: OperationsBoardPage;
16
+ tasks: OperationsProjection["tasks"];
17
+ }): { cursor: TraceabilityTaskCursor; tasks: OperationsProjection["tasks"] } {
18
+ const tasksById = new Map(tasks.map((task) => [task.id, task]));
19
+ for (const task of page.tasks) tasksById.set(task.id, task);
20
+ const nextOffset = cursor.offset + page.tasks.length;
21
+ return {
22
+ tasks: [...tasksById.values()],
23
+ cursor:
24
+ page.tasks.length === 0 || nextOffset >= page.total
25
+ ? { offset: 0, stageIndex: cursor.stageIndex + 1 }
26
+ : { ...cursor, offset: nextOffset },
27
+ };
28
+ }
29
+
30
+ export function nextTraceabilityVisibleCount(
31
+ visibleCount: number,
32
+ totalCount: number,
33
+ batchSize: number,
34
+ ): number {
35
+ return Math.min(totalCount, visibleCount + batchSize);
36
+ }
@@ -63,13 +63,17 @@
63
63
  outline: none;
64
64
  background: rgba(56, 189, 248, 0.15);
65
65
  }
66
- .traceability-task-results button small,
67
- .traceability-task-no-results {
66
+ .traceability-task-no-results,
67
+ .traceability-task-pagination-status {
68
68
  color: #a8b6c9;
69
69
  }
70
70
  .traceability-task-no-results {
71
71
  padding: 12px;
72
72
  }
73
+ .traceability-task-pagination-status {
74
+ margin: 0;
75
+ font-size: 0.78rem;
76
+ }
73
77
  .traceability-workspace > header small {
74
78
  max-width: 360px;
75
79
  color: #71829a;
@@ -4,6 +4,7 @@ import {
4
4
  adaptSqliteCompactLifecyclePage,
5
5
  adaptSqliteCostRun,
6
6
  loadSqliteCostGroupPage,
7
+ loadSqliteCostRunPage,
7
8
  } from "./use-app-cost-loaders.js";
8
9
 
9
10
  describe("daily Cost Monitor continuous pagination", () => {
@@ -205,6 +206,53 @@ describe("adaptSqliteCostRun", () => {
205
206
  });
206
207
  });
207
208
 
209
+ describe("agent invocation remote pagination", () => {
210
+ it("forwards the requested ten-row page instead of expanding it to one hundred", async () => {
211
+ const calls: Array<{ view: string; range: unknown; page: Record<string, unknown> }> = [];
212
+ const api = {
213
+ sqliteViewPage: async (view: string, range: unknown, page: Record<string, unknown>) => {
214
+ calls.push({ view, range, page });
215
+ return {
216
+ offset: 10,
217
+ limit: 10,
218
+ total_count: 24,
219
+ has_more: true,
220
+ rows: [],
221
+ };
222
+ },
223
+ };
224
+
225
+ const loaded = await loadSqliteCostRunPage(api as never, {
226
+ currency: "BRL",
227
+ from: "2026-08-01",
228
+ to: "2026-08-25",
229
+ offset: 10,
230
+ limit: 10,
231
+ filters: {
232
+ query: "agent-builder",
233
+ provider: "openai",
234
+ model: "",
235
+ agent: "",
236
+ phase: "",
237
+ status: "",
238
+ origin: "",
239
+ workType: "",
240
+ priority: "",
241
+ risk: "",
242
+ },
243
+ });
244
+
245
+ expect(calls).toEqual([
246
+ {
247
+ view: "cost_monitor_agent_invocations",
248
+ range: { from: "2026-08-01", to: "2026-08-25" },
249
+ page: { offset: 10, limit: 10, query: "agent-builder", provider: "openai" },
250
+ },
251
+ ]);
252
+ expect(loaded.run_page).toEqual({ offset: 10, limit: 10, total: 24, has_more: true });
253
+ });
254
+ });
255
+
208
256
  describe("adaptSqliteCompactLifecyclePage", () => {
209
257
  it("keeps identical server subtotals on page two for all compact lifecycle views", () => {
210
258
  const sqlitePage = {
@@ -17,6 +17,7 @@ import {
17
17
  } from "./sqlite-cost-adapters.js";
18
18
 
19
19
  type CostGroupLoadRequest = Parameters<LoadCostGroupPage>[0];
20
+ type CostRunLoadRequest = Parameters<LoadCostRunPage>[0];
20
21
 
21
22
  function costGroupQueryOptions(request: CostGroupLoadRequest, offset: number, limit: number) {
22
23
  const { filters, query } = request;
@@ -114,6 +115,35 @@ export async function loadSqliteCostGroupPage(
114
115
  };
115
116
  }
116
117
 
118
+ export async function loadSqliteCostRunPage(api: DashboardApiClient, request: CostRunLoadRequest) {
119
+ const { filters, from, limit = 10, offset, signal, to } = request;
120
+ const page = await api.sqliteViewPage(
121
+ "cost_monitor_agent_invocations",
122
+ from === undefined || to === undefined ? undefined : { from, to },
123
+ {
124
+ offset,
125
+ limit,
126
+ ...(filters?.query ? { query: filters.query } : {}),
127
+ ...(filters?.provider ? { provider: filters.provider } : {}),
128
+ ...(filters?.model ? { model: filters.model } : {}),
129
+ ...(filters?.agent ? { agent: filters.agent } : {}),
130
+ ...(filters?.phase ? { phase: filters.phase } : {}),
131
+ ...(filters?.status ? { status: filters.status } : {}),
132
+ },
133
+ signal,
134
+ );
135
+ return {
136
+ page_only: true as const,
137
+ runs: page.rows.map(adaptSqliteCostRun),
138
+ run_page: {
139
+ offset: page.offset,
140
+ limit: page.limit,
141
+ total: page.total_count,
142
+ has_more: page.has_more,
143
+ },
144
+ };
145
+ }
146
+
117
147
  /** Adapts a sparse SQLite invocation row to the complete CostRunRow contract. */
118
148
  export function adaptSqliteCostRun(
119
149
  row: Record<string, unknown>,
@@ -343,33 +373,7 @@ export function useAppCostLoaders(api: DashboardApiClient) {
343
373
  [api],
344
374
  );
345
375
  const loadCostRunPage = useCallback<LoadCostRunPage>(
346
- async ({ filters, from, offset, signal, to }) => {
347
- const page = await api.sqliteViewPage(
348
- "cost_monitor_agent_invocations",
349
- from === undefined || to === undefined ? undefined : { from, to },
350
- {
351
- offset,
352
- limit: 100,
353
- ...(filters?.query ? { query: filters.query } : {}),
354
- ...(filters?.provider ? { provider: filters.provider } : {}),
355
- ...(filters?.model ? { model: filters.model } : {}),
356
- ...(filters?.agent ? { agent: filters.agent } : {}),
357
- ...(filters?.phase ? { phase: filters.phase } : {}),
358
- ...(filters?.status ? { status: filters.status } : {}),
359
- },
360
- signal,
361
- );
362
- return {
363
- page_only: true,
364
- runs: page.rows.map(adaptSqliteCostRun),
365
- run_page: {
366
- offset: page.offset,
367
- limit: page.limit,
368
- total: page.total_count,
369
- has_more: page.has_more,
370
- },
371
- };
372
- },
376
+ (request) => loadSqliteCostRunPage(api, request),
373
377
  [api],
374
378
  );
375
379
  const loadCostGroupPage = useCallback<LoadCostGroupPage>(
@@ -39,11 +39,15 @@ export function useAppTraceDocuments({
39
39
  >(null);
40
40
  const documentRequestId = useRef(0);
41
41
  const traceRequestId = useRef(0);
42
+ const traceAbortController = useRef<AbortController | null>(null);
42
43
  const [traceLoadingTaskId, setTraceLoadingTaskId] = useState<string | null>(null);
43
44
  const [selectedTraceTaskId, setSelectedTraceTaskId] = useState("");
44
45
 
45
46
  async function openTrace(taskId: string) {
46
47
  const requestId = ++traceRequestId.current;
48
+ traceAbortController.current?.abort();
49
+ const controller = new AbortController();
50
+ traceAbortController.current = controller;
47
51
  setError(null);
48
52
  setFailedArea(null);
49
53
  setTrace(null);
@@ -51,7 +55,7 @@ export function useAppTraceDocuments({
51
55
  setLoadingArea("traceability");
52
56
  await new Promise<void>((resolveFrame) => window.requestAnimationFrame(() => resolveFrame()));
53
57
  try {
54
- const loadedTrace = await api.taskTrace(taskId);
58
+ const loadedTrace = await api.taskTrace(taskId, controller.signal);
55
59
  if (traceRequestId.current !== requestId) return false;
56
60
  const cardTask =
57
61
  traceTasks.find((task) => task.id === taskId) ??
@@ -65,12 +69,14 @@ export function useAppTraceDocuments({
65
69
  });
66
70
  return true;
67
71
  } catch (cause) {
72
+ if (controller.signal.aborted) return false;
68
73
  if (traceRequestId.current !== requestId) return false;
69
74
  setError(cause instanceof Error ? cause.message : String(cause));
70
75
  setFailedArea("traceability");
71
76
  return false;
72
77
  } finally {
73
78
  if (traceRequestId.current === requestId) {
79
+ if (traceAbortController.current === controller) traceAbortController.current = null;
74
80
  setTraceLoadingTaskId(null);
75
81
  setLoadingArea((current) => (current === "traceability" ? null : current));
76
82
  }
@@ -0,0 +1,163 @@
1
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
2
+ import type { DashboardApiClient } from "./dashboard-api.js";
3
+ import type { OperationsPeriodState } from "./operations-period.js";
4
+ import { useAppWorkListPage, type WorkListPageState } from "./use-app-work-list-page.js";
5
+
6
+ // Keep the hook's actual async/request logic; only replace React's render storage.
7
+ const storage = vi.hoisted(() => ({
8
+ refs: [] as { current: unknown }[],
9
+ cursor: 0,
10
+ page: undefined as WorkListPageState | undefined,
11
+ }));
12
+
13
+ vi.mock("react", async (importOriginal) => ({
14
+ ...(await importOriginal<typeof import("react")>()),
15
+ useCallback: (callback: unknown) => callback,
16
+ useRef: (initial: unknown) => {
17
+ const index = storage.cursor++;
18
+ storage.refs[index] ??= { current: initial };
19
+ return storage.refs[index];
20
+ },
21
+ useState: (initial: WorkListPageState) => {
22
+ storage.page ??= initial;
23
+ return [
24
+ storage.page,
25
+ (update: WorkListPageState | ((previous: WorkListPageState) => WorkListPageState)) => {
26
+ storage.page = typeof update === "function" ? update(storage.page ?? initial) : update;
27
+ },
28
+ ];
29
+ },
30
+ }));
31
+
32
+ const filters = { query: "", status: "", risk: "" };
33
+ const period: OperationsPeriodState = {
34
+ preset: "this-month",
35
+ range: { start: "2026-08-01", end: "2026-08-30" },
36
+ };
37
+ const result = (offset: number) => ({
38
+ data_source: "sqlite_read_model" as const,
39
+ view: "operations_work_list" as const,
40
+ offset,
41
+ limit: 10,
42
+ total_count: 30,
43
+ has_more: true,
44
+ rows: [{ id: `row-${offset}` }],
45
+ });
46
+
47
+ function deferred() {
48
+ let resolve!: (value: ReturnType<typeof result>) => void;
49
+ let reject!: (cause: Error) => void;
50
+ const promise = new Promise<ReturnType<typeof result>>((yes, no) => {
51
+ resolve = yes;
52
+ reject = no;
53
+ });
54
+ return { promise, resolve, reject };
55
+ }
56
+
57
+ function setup() {
58
+ const sqliteViewPage = vi.fn<DashboardApiClient["sqliteViewPage"]>();
59
+ sqliteViewPage.mockImplementation(async (_view, _period, options) =>
60
+ result(options?.offset ?? 0),
61
+ );
62
+ const api = { sqliteViewPage } as unknown as DashboardApiClient;
63
+ const operationsPeriodRef = { current: period };
64
+ const render = (nextPeriod = operationsPeriodRef.current) => {
65
+ storage.cursor = 0;
66
+ operationsPeriodRef.current = nextPeriod;
67
+ return useAppWorkListPage({ api, operationsPeriod: nextPeriod, operationsPeriodRef });
68
+ };
69
+ return { sqliteViewPage, render, page: render() };
70
+ }
71
+
72
+ beforeEach(() => {
73
+ storage.refs = [];
74
+ storage.cursor = 0;
75
+ storage.page = undefined;
76
+ vi.useFakeTimers();
77
+ });
78
+ afterEach(() => vi.useRealTimers());
79
+
80
+ describe("work-list request ordering", () => {
81
+ it("keeps offset 10 when the pending filter timer fires after explicit navigation", async () => {
82
+ const { page, sqliteViewPage } = setup();
83
+ await page.loadWorkListPage(filters);
84
+ setTimeout(() => void page.loadWorkListFilters(filters), 180);
85
+ await vi.advanceTimersByTimeAsync(50);
86
+ await page.loadWorkListPage(filters, 10);
87
+ await vi.advanceTimersByTimeAsync(200);
88
+
89
+ expect(sqliteViewPage.mock.calls.map((call) => call[2]?.offset)).toEqual([0, 10]);
90
+ expect(storage.page).toMatchObject({ offset: 10, loading: false, error: null });
91
+ });
92
+
93
+ it("does not abort an in-flight page request when identical hydration arrives", async () => {
94
+ const { page, sqliteViewPage } = setup();
95
+ await page.loadWorkListPage(filters);
96
+ const secondPage = deferred();
97
+ sqliteViewPage.mockReturnValueOnce(secondPage.promise);
98
+ const pending = page.loadWorkListPage(filters, 10);
99
+ await page.loadWorkListFilters(filters);
100
+ expect(sqliteViewPage).toHaveBeenCalledTimes(2);
101
+ expect(sqliteViewPage.mock.calls[1]?.[3]?.aborted).toBe(false);
102
+ secondPage.resolve(result(10));
103
+ await pending;
104
+ expect(storage.page?.offset).toBe(10);
105
+ });
106
+
107
+ it("applies changed filters at offset 0 and retains the selected work kind", async () => {
108
+ const { page, sqliteViewPage } = setup();
109
+ await page.loadWorkListPage({ ...filters, kind: "task" }, 10);
110
+ await page.loadWorkListFilters({ ...filters, query: "telemetria", origin: "standalone" });
111
+ expect(sqliteViewPage.mock.calls[1]?.[2]).toMatchObject({
112
+ offset: 0,
113
+ kind: "task",
114
+ query: "telemetria",
115
+ origin: "standalone",
116
+ });
117
+ await page.loadWorkListFilters({ ...filters, query: "telemetria", origin: "standalone" });
118
+ expect(sqliteViewPage).toHaveBeenCalledTimes(2);
119
+ });
120
+
121
+ it("retains explicit same-filter reloads for type selection and List re-entry", async () => {
122
+ const { page, sqliteViewPage } = setup();
123
+ await page.loadWorkListPage(filters, 10);
124
+ await page.loadWorkListPage(filters, 0);
125
+ expect(sqliteViewPage.mock.calls.map((call) => call[2]?.offset)).toEqual([10, 0]);
126
+ });
127
+
128
+ it("allows hydration after a canceled timer, reset or period change", async () => {
129
+ const { page, render, sqliteViewPage } = setup();
130
+ const timer = setTimeout(() => void page.loadWorkListFilters(filters), 180);
131
+ clearTimeout(timer);
132
+ await vi.advanceTimersByTimeAsync(200);
133
+ await page.loadWorkListFilters(filters);
134
+ page.resetWorkListPage();
135
+ await page.loadWorkListFilters(filters);
136
+ await render({ ...period, preset: "all" }).loadWorkListFilters(filters);
137
+ expect(sqliteViewPage).toHaveBeenCalledTimes(3);
138
+ expect(sqliteViewPage.mock.calls[2]?.[1]).toEqual({ from: null, to: null });
139
+ });
140
+
141
+ it("retries the same filters after a current request failed", async () => {
142
+ const { page, sqliteViewPage } = setup();
143
+ sqliteViewPage.mockRejectedValueOnce(new Error("read failed"));
144
+ await page.loadWorkListFilters(filters);
145
+ expect(storage.page?.error).toBe("read failed");
146
+ await page.loadWorkListFilters(filters);
147
+ expect(sqliteViewPage).toHaveBeenCalledTimes(2);
148
+ expect(storage.page?.error).toBeNull();
149
+ });
150
+
151
+ it("does not clear the current identity when an older aborted request fails", async () => {
152
+ const { page, sqliteViewPage } = setup();
153
+ const old = deferred();
154
+ sqliteViewPage.mockReturnValueOnce(old.promise);
155
+ const pending = page.loadWorkListPage(filters);
156
+ await page.loadWorkListPage(filters, 10);
157
+ old.reject(new Error("late failure"));
158
+ await pending;
159
+ await page.loadWorkListFilters(filters);
160
+ expect(sqliteViewPage).toHaveBeenCalledTimes(2);
161
+ expect(storage.page).toMatchObject({ offset: 10, error: null });
162
+ });
163
+ });
@@ -0,0 +1,136 @@
1
+ import { type MutableRefObject, useCallback, useRef, useState } from "react";
2
+ import type { DashboardApiClient, OperationsPageFilters } from "./dashboard-api.js";
3
+ import { type OperationsPeriodState, requestPeriodForOperations } from "./operations-period.js";
4
+ import {
5
+ shouldStartWorkListLoad,
6
+ type WorkListLoadIntent,
7
+ workListLoadKey,
8
+ } from "./work-list-load-dedup.js";
9
+ import { normalizeWorkListFilters } from "./work-list-pagination.js";
10
+
11
+ export type WorkListTypeFilter = "all" | "task" | "standalone-task" | "prd" | "spec";
12
+ export type WorkListPageState = {
13
+ offset: number;
14
+ limit: number;
15
+ total: number | null;
16
+ hasMore: boolean;
17
+ typeFilter: WorkListTypeFilter;
18
+ rows: readonly Record<string, unknown>[];
19
+ loading: boolean;
20
+ error: string | null;
21
+ };
22
+
23
+ const initialPage: WorkListPageState = {
24
+ offset: 0,
25
+ limit: 10,
26
+ total: null,
27
+ hasMore: false,
28
+ typeFilter: "all",
29
+ rows: [],
30
+ loading: false,
31
+ error: null,
32
+ };
33
+
34
+ /** Visual List is one bounded SQLite page; exports use their own full iterator. */
35
+ export function useAppWorkListPage({
36
+ api,
37
+ operationsPeriod,
38
+ operationsPeriodRef,
39
+ }: {
40
+ api: DashboardApiClient;
41
+ operationsPeriod: OperationsPeriodState;
42
+ operationsPeriodRef: MutableRefObject<OperationsPeriodState>;
43
+ }) {
44
+ const [workListPage, setWorkListPage] = useState<WorkListPageState>(initialPage);
45
+ const filtersRef = useRef<OperationsPageFilters>({ query: "", status: "", risk: "" });
46
+ const abortRef = useRef<AbortController | null>(null);
47
+ const requestVersionRef = useRef(0);
48
+ const knownLoadKeyRef = useRef<string | null>(null);
49
+ const load = useCallback(
50
+ async (filters: OperationsPageFilters, offset = 0, intent: WorkListLoadIntent = "explicit") => {
51
+ const period = requestPeriodForOperations(operationsPeriod);
52
+ const normalizedFilters = normalizeWorkListFilters(filters, filtersRef.current);
53
+ const loadKey = workListLoadKey(normalizedFilters, period);
54
+ if (!shouldStartWorkListLoad(intent, loadKey, knownLoadKeyRef.current)) return;
55
+ abortRef.current?.abort();
56
+ const controller = new AbortController();
57
+ abortRef.current = controller;
58
+ const requestVersion = ++requestVersionRef.current;
59
+ filtersRef.current = normalizedFilters;
60
+ knownLoadKeyRef.current = loadKey;
61
+ const typeFilter = (normalizedFilters.kind || "all") as WorkListTypeFilter;
62
+ setWorkListPage((current) => ({
63
+ ...current,
64
+ offset,
65
+ typeFilter,
66
+ loading: true,
67
+ error: null,
68
+ }));
69
+ try {
70
+ const sql = await api.sqliteViewPage(
71
+ "operations_work_list",
72
+ period,
73
+ {
74
+ offset,
75
+ limit: 10,
76
+ ...(normalizedFilters.query ? { query: normalizedFilters.query } : {}),
77
+ ...(normalizedFilters.status ? { status: normalizedFilters.status } : {}),
78
+ ...(normalizedFilters.risk ? { risk: normalizedFilters.risk } : {}),
79
+ ...(normalizedFilters.origin ? { origin: normalizedFilters.origin } : {}),
80
+ ...(typeFilter === "all" ? {} : { kind: typeFilter }),
81
+ },
82
+ controller.signal,
83
+ );
84
+ if (
85
+ controller.signal.aborted ||
86
+ requestVersion !== requestVersionRef.current ||
87
+ period.from !== requestPeriodForOperations(operationsPeriodRef.current).from ||
88
+ period.to !== requestPeriodForOperations(operationsPeriodRef.current).to
89
+ )
90
+ return;
91
+ setWorkListPage({
92
+ offset: sql.offset,
93
+ limit: sql.limit,
94
+ total: sql.total_count,
95
+ hasMore: sql.has_more,
96
+ typeFilter,
97
+ rows: sql.rows,
98
+ loading: false,
99
+ error: null,
100
+ });
101
+ } catch (cause) {
102
+ if (controller.signal.aborted || requestVersion !== requestVersionRef.current) return;
103
+ if (knownLoadKeyRef.current === loadKey) knownLoadKeyRef.current = null;
104
+ setWorkListPage((current) => ({
105
+ ...current,
106
+ offset,
107
+ typeFilter,
108
+ loading: false,
109
+ error: cause instanceof Error ? cause.message : String(cause),
110
+ }));
111
+ } finally {
112
+ if (abortRef.current === controller) abortRef.current = null;
113
+ }
114
+ },
115
+ [api, operationsPeriod, operationsPeriodRef],
116
+ );
117
+ const reset = useCallback(() => {
118
+ abortRef.current?.abort();
119
+ abortRef.current = null;
120
+ ++requestVersionRef.current;
121
+ knownLoadKeyRef.current = null;
122
+ setWorkListPage(initialPage);
123
+ }, []);
124
+ const loadFilters = useCallback(
125
+ (filters: OperationsPageFilters) => load(filters, 0, "filter-hydration"),
126
+ [load],
127
+ );
128
+
129
+ return {
130
+ workListPage,
131
+ workListFiltersRef: filtersRef,
132
+ loadWorkListFilters: loadFilters,
133
+ loadWorkListPage: load,
134
+ resetWorkListPage: reset,
135
+ };
136
+ }
@@ -0,0 +1,76 @@
1
+ import { useCallback } from "react";
2
+ import type { DashboardApiClient, SqliteViewName } from "./dashboard-api.js";
3
+ import type { OperationsPeriodState } from "./operations-period.js";
4
+ import { requestPeriodForOperations } from "./operations-period.js";
5
+ import { allSqliteExportPages } from "./sqlite-page-export.js";
6
+
7
+ export type OperationsExportView =
8
+ | "work-kanban"
9
+ | "work-list"
10
+ | "changes"
11
+ | "decisions"
12
+ | "executions"
13
+ | "runs"
14
+ | "conversations"
15
+ | "daily"
16
+ | "monthly"
17
+ | "yearly";
18
+
19
+ type DetailExportFilters = {
20
+ query: string;
21
+ status: string;
22
+ risk: string;
23
+ origin: string;
24
+ kind?: string;
25
+ };
26
+
27
+ /** Exports are intentionally independent from the bounded visual page. */
28
+ export function useOperationsDetailExport({
29
+ api,
30
+ operationsPeriod,
31
+ }: {
32
+ api: DashboardApiClient;
33
+ operationsPeriod: OperationsPeriodState;
34
+ }) {
35
+ return useCallback(
36
+ (view: OperationsExportView, filters: DetailExportFilters) => {
37
+ const period = requestPeriodForOperations(operationsPeriod);
38
+ if (view === "work-kanban") return undefined;
39
+ const sqliteView = {
40
+ "work-list": "operations_work_list",
41
+ changes: "operations_changes",
42
+ decisions: "operations_decisions",
43
+ executions: "operations_executions",
44
+ runs: "operations_agent_invocations",
45
+ conversations: "operations_conversations",
46
+ daily: "operations_daily",
47
+ monthly: "operations_monthly",
48
+ yearly: "operations_annual",
49
+ } as const satisfies Partial<Record<OperationsExportView, SqliteViewName>>;
50
+ const source = sqliteView[view];
51
+ if (source === undefined) return undefined;
52
+ const options = (offset: number) => ({
53
+ offset,
54
+ limit: 100,
55
+ ...(filters.query ? { query: filters.query } : {}),
56
+ ...(filters.status ? { status: filters.status } : {}),
57
+ ...(filters.risk ? { risk: filters.risk } : {}),
58
+ ...(filters.origin ? { origin: filters.origin } : {}),
59
+ ...(source === "operations_work_list" && filters.kind ? { kind: filters.kind } : {}),
60
+ });
61
+ return {
62
+ prepare: async () => {
63
+ const firstPage = await api.sqliteViewPage(source, period, options(0));
64
+ return {
65
+ totalRows: firstPage.total_count,
66
+ pages: () =>
67
+ allSqliteExportPages(firstPage, (offset) =>
68
+ api.sqliteViewPage(source, period, options(offset)),
69
+ ),
70
+ };
71
+ },
72
+ };
73
+ },
74
+ [api, operationsPeriod],
75
+ );
76
+ }
@@ -0,0 +1,23 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { shouldStartWorkListLoad, workListLoadKey } from "./work-list-load-dedup.js";
3
+
4
+ describe("work-list delayed filter hydration", () => {
5
+ const defaultFilters = { query: "", status: "", risk: "", origin: "", kind: "" };
6
+ const period = { from: "2026-08-01", to: "2026-08-31" };
7
+
8
+ it("keeps page two explicit while suppressing the same delayed hydration", () => {
9
+ const key = workListLoadKey(defaultFilters, period);
10
+
11
+ expect(shouldStartWorkListLoad("explicit", key, null)).toBe(true);
12
+ expect(shouldStartWorkListLoad("explicit", key, key)).toBe(true);
13
+ expect(shouldStartWorkListLoad("filter-hydration", key, key)).toBe(false);
14
+ });
15
+
16
+ it("rearms after cleanup when no matching request was started, and reloads real filter changes", () => {
17
+ const key = workListLoadKey(defaultFilters, period);
18
+ const changedKey = workListLoadKey({ ...defaultFilters, query: "telemetria" }, period);
19
+
20
+ expect(shouldStartWorkListLoad("filter-hydration", key, null)).toBe(true);
21
+ expect(shouldStartWorkListLoad("filter-hydration", changedKey, key)).toBe(true);
22
+ });
23
+ });