@zaip-ai/cli 3.2.0 → 3.4.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 (288) hide show
  1. package/dist/services/adapters.d.ts +1 -1
  2. package/dist/services/adapters.d.ts.map +1 -1
  3. package/dist/services/adapters.js +5 -3
  4. package/dist/services/adapters.js.map +1 -1
  5. package/dist/services/agent-catalog-upgrade.d.ts +3 -0
  6. package/dist/services/agent-catalog-upgrade.d.ts.map +1 -0
  7. package/dist/services/agent-catalog-upgrade.js +35 -0
  8. package/dist/services/agent-catalog-upgrade.js.map +1 -0
  9. package/dist/services/install-agents-template.d.ts.map +1 -1
  10. package/dist/services/install-agents-template.js +22 -22
  11. package/dist/services/install-agents-template.js.map +1 -1
  12. package/dist/services/install-template-policy.d.ts +3 -0
  13. package/dist/services/install-template-policy.d.ts.map +1 -0
  14. package/dist/services/install-template-policy.js +21 -0
  15. package/dist/services/install-template-policy.js.map +1 -0
  16. package/dist/services/logger.js +24 -8
  17. package/dist/services/logger.js.map +1 -1
  18. package/dist/services/logger.test.js +33 -6
  19. package/dist/services/logger.test.js.map +1 -1
  20. package/dist/services/sqlite-bootstrap.d.ts +1 -0
  21. package/dist/services/sqlite-bootstrap.d.ts.map +1 -1
  22. package/dist/services/sqlite-bootstrap.js +10 -1
  23. package/dist/services/sqlite-bootstrap.js.map +1 -1
  24. package/package.json +2 -2
  25. package/templates/.agents/README-ENG.md +2 -1
  26. package/templates/.agents/README.md +2 -1
  27. package/templates/.agents/config/agents/catalog.yaml +1 -0
  28. package/templates/.agents/config/agents/discovery.json +2 -2
  29. package/templates/.agents/config/clients/codex/agents/zaip-agent-builder.toml +2 -2
  30. package/templates/.agents/dashboard/.zaip-managed.json +278 -126
  31. package/templates/.agents/dashboard/apps/frontend/dist/assets/{CostCalculationGuidePage-CEDZjl4V.js → CostCalculationGuidePage-C5NgEcVh.js} +1 -1
  32. package/templates/.agents/dashboard/apps/frontend/dist/assets/{DashboardHelpDialog-BzaUTZDx.js → DashboardHelpDialog-CCMVnkkI.js} +4 -3
  33. package/templates/.agents/dashboard/apps/frontend/dist/assets/{PricingSettingsDialog-21cCJik-.js → PricingSettingsDialog-CGYcJ5EB.js} +1 -1
  34. package/templates/.agents/dashboard/apps/frontend/dist/assets/{ProjectSettingsPage-BAvLPAee.js → ProjectSettingsPage-DVCPPV75.js} +1 -1
  35. package/templates/.agents/dashboard/apps/frontend/dist/assets/{TraceabilityWorkspace-wqW52uCx.js → TraceabilityWorkspace-CqK3Psfy.js} +1 -1
  36. package/templates/.agents/dashboard/apps/frontend/dist/assets/{cost-monitor-PoJA2PI1.css → cost-monitor-BsMfGfQi.css} +1 -1
  37. package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-j3aUYH5G.js +68 -0
  38. package/templates/.agents/dashboard/apps/frontend/dist/assets/{dashboard-localization-BkAm8-h4.js → dashboard-localization-jvdDfNKs.js} +2 -1
  39. package/templates/.agents/dashboard/apps/frontend/dist/assets/{icons-vendor-DEmo6Tn2.js → icons-vendor-x8xxL9yW.js} +1 -1
  40. package/templates/.agents/dashboard/apps/frontend/dist/assets/index-Cl5EWx8R.js +2 -0
  41. package/templates/.agents/dashboard/apps/frontend/dist/assets/index-Cwylbh_N.css +1 -0
  42. package/templates/.agents/dashboard/apps/frontend/dist/assets/{react-vendor-CadYsm83.js → react-vendor-CNOXIJHN.js} +1 -1
  43. package/templates/.agents/dashboard/apps/frontend/dist/assets/{traceability-BzKK8kK3.js → traceability-CcpbpT1s.js} +1 -1
  44. package/templates/.agents/dashboard/apps/frontend/dist/index.html +7 -7
  45. package/templates/.agents/dashboard/apps/frontend/package.json +1 -1
  46. package/templates/.agents/dashboard/apps/frontend/src/App.tsx +12 -1
  47. package/templates/.agents/dashboard/apps/frontend/src/WorkspaceStatus.test.tsx +33 -0
  48. package/templates/.agents/dashboard/apps/frontend/src/WorkspaceStatus.tsx +58 -0
  49. package/templates/.agents/dashboard/apps/frontend/src/app-work-board-options.ts +41 -0
  50. package/templates/.agents/dashboard/apps/frontend/src/dashboard-runtime-status.ts +25 -0
  51. package/templates/.agents/dashboard/apps/frontend/src/snapshot-coherence.test.ts +1 -1
  52. package/templates/.agents/dashboard/apps/frontend/src/use-app-cost-loaders.ts +5 -1
  53. package/templates/.agents/dashboard/apps/frontend/src/use-app-work-board.test.ts +140 -0
  54. package/templates/.agents/dashboard/apps/frontend/src/use-app-work-board.ts +28 -41
  55. package/templates/.agents/dashboard/apps/frontend/src/use-runtime-status.ts +38 -0
  56. package/templates/.agents/dashboard/apps/frontend/src/workspace-status.css +33 -0
  57. package/templates/.agents/dashboard/modules/cost-monitor/package.json +1 -1
  58. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CompactLifecycleCostTable.test.ts +25 -3
  59. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CompactLifecycleCostTable.tsx +17 -19
  60. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostFilters.tsx +13 -167
  61. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostGroupsTable.tsx +2 -9
  62. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.test.ts +8 -8
  63. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.tsx +29 -52
  64. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTableLoading.test.ts +1 -1
  65. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables-keeps-legacy-codex-identity-fields-blank.test.ts +2 -2
  66. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables.test.ts +4 -27
  67. package/templates/.agents/dashboard/modules/cost-monitor/src/react/MacroCostTable.test.ts +2 -2
  68. package/templates/.agents/dashboard/modules/cost-monitor/src/react/MacroCostTable.tsx +4 -3
  69. package/templates/.agents/dashboard/modules/cost-monitor/src/react/agent-model-presentation.test.ts +26 -0
  70. package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-embedded.css +7 -0
  71. package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-loaders.ts +173 -0
  72. package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-page-props.ts +47 -0
  73. package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-page-selectors.ts +1 -7
  74. package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-page-range.ts +3 -9
  75. package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-projection.test.ts +44 -83
  76. package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-projection.ts +11 -111
  77. package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-projection.test.ts +47 -181
  78. package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-projection.ts +63 -91
  79. package/templates/.agents/dashboard/modules/cost-monitor/src/server/cost-monitor-unavailable.test.ts +55 -0
  80. package/templates/.agents/dashboard/modules/cost-monitor/src/server/cost-summary-duration.test.ts +189 -0
  81. package/templates/.agents/dashboard/modules/operations/package.json +1 -1
  82. package/templates/.agents/dashboard/modules/operations/src/react/OperationsEntityFilters.tsx +82 -0
  83. package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.helpers.tsx +4 -1
  84. package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.test.ts +5 -0
  85. package/templates/.agents/dashboard/modules/operations/src/react/OperationsPage.tsx +22 -31
  86. package/templates/.agents/dashboard/modules/operations/src/react/PagedWorkList.test.tsx +13 -1
  87. package/templates/.agents/dashboard/modules/operations/src/react/PagedWorkList.tsx +16 -3
  88. package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportAction.test.ts +11 -27
  89. package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportAction.tsx +44 -193
  90. package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportColumns.ts +186 -0
  91. package/templates/.agents/dashboard/modules/operations/src/react/export/excel-agent-participations.test.ts +28 -0
  92. package/templates/.agents/dashboard/modules/operations/src/react/export/export-layout.test.ts +2 -1
  93. package/templates/.agents/dashboard/modules/operations/src/react/export/xlsx-runtime-e2e.test.ts +55 -31
  94. package/templates/.agents/dashboard/modules/operations/src/react/operations-export-duration.ts +13 -0
  95. package/templates/.agents/dashboard/modules/operations/src/react/operations-filter-panel.css +4 -0
  96. package/templates/.agents/dashboard/modules/operations/src/react/use-operation-filter-feedback.ts +18 -0
  97. package/templates/.agents/dashboard/modules/operations/src/react/work-board-model.test.ts +11 -0
  98. package/templates/.agents/dashboard/modules/operations/src/react/work-board-model.ts +10 -2
  99. package/templates/.agents/dashboard/modules/operations/src/work-board-model.ts +1 -1
  100. package/templates/.agents/dashboard/modules/traceability/package.json +1 -1
  101. package/templates/.agents/dashboard/packages/branding/package.json +1 -1
  102. package/templates/.agents/dashboard/packages/contracts/package.json +1 -1
  103. package/templates/.agents/dashboard/packages/data-export/package.json +1 -1
  104. package/templates/.agents/dashboard/packages/local-runtime/dist/server.cjs +406 -332
  105. package/templates/.agents/dashboard/packages/local-runtime/dist/sqlite-read-model.cjs +352 -280
  106. package/templates/.agents/dashboard/packages/local-runtime/package.json +1 -1
  107. package/templates/.agents/dashboard/packages/local-runtime/scripts/rebuild-sqlite-read-model.mjs +2 -1
  108. package/templates/.agents/dashboard/packages/local-runtime/scripts/validate-sqlite-read-model.mjs +4 -2
  109. package/templates/.agents/dashboard/packages/local-runtime/server.mjs +406 -332
  110. package/templates/.agents/dashboard/packages/local-runtime/src/active-codex-telemetry.test.ts +95 -0
  111. package/templates/.agents/dashboard/packages/local-runtime/src/active-codex-telemetry.ts +102 -12
  112. package/templates/.agents/dashboard/packages/local-runtime/src/server-board.test.ts +75 -1
  113. package/templates/.agents/dashboard/packages/local-runtime/src/server-costs-routes.ts +10 -0
  114. package/templates/.agents/dashboard/packages/local-runtime/src/server-lifecycle-diagnostics.ts +50 -0
  115. package/templates/.agents/dashboard/packages/local-runtime/src/server-macro-population.test.ts +165 -0
  116. package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-page-filters.ts +65 -0
  117. package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-pages.test.ts +111 -0
  118. package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-pages.ts +53 -63
  119. package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-runs-route.ts +19 -5
  120. package/templates/.agents/dashboard/packages/local-runtime/src/server-period-macro-metric.test.ts +19 -0
  121. package/templates/.agents/dashboard/packages/local-runtime/src/server-period-macro-metric.ts +11 -2
  122. package/templates/.agents/dashboard/packages/local-runtime/src/server-read-projections.ts +19 -12
  123. package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-refresh.test.ts +46 -2
  124. package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-synchronization.test.ts +10 -2
  125. package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-synchronization.ts +4 -3
  126. package/templates/.agents/dashboard/packages/local-runtime/src/server.test.ts +43 -1
  127. package/templates/.agents/dashboard/packages/local-runtime/src/server.ts +46 -11
  128. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-filter-matrix.test.ts +188 -0
  129. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-summary-details.test.ts +85 -0
  130. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-summary-details.ts +147 -0
  131. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-first-fold-cache.test.ts +94 -0
  132. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-first-fold-cache.ts +96 -55
  133. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-force-canonical.test.ts +58 -3
  134. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-macro-classification.test.ts +172 -0
  135. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-materialize-projections.ts +1 -1
  136. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-operations-projection.ts +4 -1
  137. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-operations-work-list.test.ts +7 -7
  138. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-operations-work-list.ts +2 -1
  139. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-period-averages.ts +10 -1
  140. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-agent-dimension.ts +18 -82
  141. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-cached-cost-page.ts +169 -0
  142. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-developer.ts +205 -0
  143. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-entity-group.ts +13 -4
  144. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-filtered-dimension.ts +22 -23
  145. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-financial.ts +42 -209
  146. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-model-dimension.ts +18 -4
  147. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-provider-dimension.ts +9 -2
  148. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-summary.ts +76 -83
  149. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-view-page.ts +25 -161
  150. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-canonical.ts +18 -45
  151. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-counts-every-root-execution-day-returns.test.ts +15 -2
  152. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-filesystem.ts +16 -16
  153. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-keeps-orphan-telemetry-out-kanban-without.test.ts +2 -1
  154. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-multi-provider.test.ts +1 -1
  155. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-rebuild.ts +47 -22
  156. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-schema.ts +16 -2
  157. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model.test.ts +13 -1
  158. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-rebuild-result.ts +15 -0
  159. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-schema-base-views.ts +4 -4
  160. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-schema-dashboard-views.ts +19 -42
  161. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-schema-macro-classification.ts +48 -0
  162. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-summary-cursor.ts +15 -0
  163. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-token-active-allocation.ts +46 -0
  164. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-work-stages.ts +60 -0
  165. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-history.mjs +5 -1
  166. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-launch-claims.test.mjs +7 -1
  167. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-launch-page.mjs +17 -2
  168. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-ownership.mjs +65 -0
  169. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-ownership.test.mjs +72 -0
  170. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-processes.mjs +32 -9
  171. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard.mjs +39 -45
  172. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard.test.mjs +5 -2
  173. package/templates/.agents/dashboard/packages/ui/package.json +1 -1
  174. package/templates/.agents/dashboard/scripts/qualify-macro-overview.mjs +50 -0
  175. package/templates/.agents/dashboard/tests/e2e/package.json +1 -1
  176. package/templates/.agents/dashboard/tests/e2e/specs/dashboard-performance-matrix.spec.ts +1 -18
  177. package/templates/.agents/dashboard/tests/e2e/specs/export-row-identity.spec.ts +20 -0
  178. package/templates/.agents/dashboard/tests/e2e/specs/export-row-identity.ts +20 -0
  179. package/templates/.agents/design/.zaip-managed.json +82 -74
  180. package/templates/.agents/design/apps/catalog/dist/assets/index-0W0Gj_Gs.css +1 -0
  181. package/templates/.agents/design/apps/catalog/dist/assets/index-32GZO95T.js +72 -0
  182. package/templates/.agents/design/apps/catalog/dist/assets/{index-D_lfqoyx.js → index-BP8IxOxt.js} +3 -3
  183. package/templates/.agents/design/apps/catalog/dist/assets/{index-BOjCcUaU.js → index-QJsgr9Ht.js} +3 -3
  184. package/templates/.agents/design/apps/catalog/dist/index.html +2 -2
  185. package/templates/.agents/design/apps/catalog/dist/storybook/assets/CatalogShell-CvaciY0C.js +1 -0
  186. package/templates/.agents/design/apps/catalog/dist/storybook/assets/{Color-6AOWCN3U-Cm-yJJz_.js → Color-6AOWCN3U-DwBV1A1Y.js} +1 -1
  187. package/templates/.agents/design/apps/catalog/dist/storybook/assets/Components.stories-3dqK5g3e.js +142 -0
  188. package/templates/.agents/design/apps/catalog/dist/storybook/assets/DesignSystem.stories-2OCgtT0I.js +1 -0
  189. package/templates/.agents/design/apps/catalog/dist/storybook/assets/{DocsRenderer-JROSPFPF-Belk4jRr.js → DocsRenderer-JROSPFPF-CODg0rSl.js} +4 -4
  190. package/templates/.agents/design/apps/catalog/dist/storybook/assets/Primitives-BmeKjJW4.js +1 -0
  191. package/templates/.agents/design/apps/catalog/dist/storybook/assets/{WithTooltip-7X4HQR7L-DoPvjkS1.js → WithTooltip-7X4HQR7L-C5MI-3uZ.js} +1 -1
  192. package/templates/.agents/design/apps/catalog/dist/storybook/assets/WorkspaceStatus.stories-Tb_iQqVK.js +17 -0
  193. package/templates/.agents/design/apps/catalog/dist/storybook/assets/WorkspaceStatusSpecimen-CD54pw0-.js +1 -0
  194. package/templates/.agents/design/apps/catalog/dist/storybook/assets/{chunk-DRQKCCAG-B1itKXEN.js → chunk-DRQKCCAG-KSn75jcy.js} +1 -1
  195. package/templates/.agents/design/apps/catalog/dist/storybook/assets/{chunk-W22LQPXL-C-Eb5SPY.js → chunk-W22LQPXL-C4LS1Thf.js} +1 -1
  196. package/templates/.agents/design/apps/catalog/dist/storybook/assets/{components-DnyKLwhj.js → components-DV1BRgMY.js} +5 -5
  197. package/templates/.agents/design/apps/catalog/dist/storybook/assets/formatter-L2YTDE3Q-BU_68im1.js +1 -0
  198. package/templates/.agents/design/apps/catalog/dist/storybook/assets/iframe-0W0Gj_Gs.css +1 -0
  199. package/templates/.agents/design/apps/catalog/dist/storybook/assets/{iframe-DcXBsFPz.js → iframe-CBbPFx5G.js} +4 -4
  200. package/templates/.agents/design/apps/catalog/dist/storybook/assets/{react-18-CRM89QRf.js → react-18-C9IPGXtb.js} +1 -1
  201. package/templates/.agents/design/apps/catalog/dist/storybook/assets/react-CEv2qkJT.js +1 -0
  202. package/templates/.agents/design/apps/catalog/dist/storybook/assets/{syntaxhighlighter-YFXUGROL-B03jQGTF.js → syntaxhighlighter-YFXUGROL-ZgDQjyWI.js} +1 -1
  203. package/templates/.agents/design/apps/catalog/dist/storybook/assets/{theming-4ZyufAga.js → theming-Cx9-gH6l.js} +1 -1
  204. package/templates/.agents/design/apps/catalog/dist/storybook/iframe.html +2 -2
  205. package/templates/.agents/design/apps/catalog/dist/storybook/index.json +1 -1
  206. package/templates/.agents/design/apps/catalog/dist/storybook/sb-addons/a11y-2/manager-bundle.js +3 -3
  207. package/templates/.agents/design/apps/catalog/dist/storybook/sb-addons/docs-1/manager-bundle.js +4 -4
  208. package/templates/.agents/design/apps/catalog/dist/storybook/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js +60 -60
  209. package/templates/.agents/design/apps/catalog/package.json +1 -1
  210. package/templates/.agents/design/apps/catalog/src/components/DashboardFiltersSpecimen.tsx +61 -0
  211. package/templates/.agents/design/apps/catalog/src/components/Primitives.tsx +24 -0
  212. package/templates/.agents/design/apps/catalog/src/components/WorkspaceStatusSpecimen.tsx +26 -0
  213. package/templates/.agents/design/apps/catalog/src/design-contract.test.ts +27 -13
  214. package/templates/.agents/design/apps/catalog/src/pages/ComponentsPage.tsx +38 -0
  215. package/templates/.agents/design/apps/catalog/src/pages/DesignSystemPage.tsx +15 -1
  216. package/templates/.agents/design/apps/catalog/src/stories/Components.stories.tsx +18 -0
  217. package/templates/.agents/design/apps/catalog/src/stories/DashboardFilters.stories.tsx +7 -0
  218. package/templates/.agents/design/apps/catalog/src/stories/WorkspaceStatus.stories.tsx +9 -0
  219. package/templates/.agents/design/apps/catalog/src/styles/components.css +83 -2
  220. package/templates/.agents/design/apps/catalog/src/styles.css +2 -0
  221. package/templates/.agents/design/packages/local-runtime/package.json +1 -1
  222. package/templates/.agents/design/tokens.json +32 -0
  223. package/templates/.agents/requirements/autonomous-assurance.md +1 -1
  224. package/templates/.agents/requirements/cloud-hostinger-autonomy.md +1 -1
  225. package/templates/.agents/requirements/comparative-audit.md +1 -1
  226. package/templates/.agents/requirements/context-engine.md +1 -1
  227. package/templates/.agents/requirements/cost-observability.md +1 -1
  228. package/templates/.agents/requirements/dashboard-launch.md +1 -1
  229. package/templates/.agents/requirements/data-export.md +1 -1
  230. package/templates/.agents/requirements/design-system.md +1 -1
  231. package/templates/.agents/requirements/execution-engine.md +1 -1
  232. package/templates/.agents/requirements/kanban-dashboard.md +1 -1
  233. package/templates/.agents/requirements/model-orchestration.md +1 -1
  234. package/templates/.agents/requirements/public-distribution.md +18 -4
  235. package/templates/.agents/requirements/software-architecture.md +1 -1
  236. package/templates/.agents/requirements/strategic-improvements.md +1 -1
  237. package/templates/.agents/requirements/work-lifecycle.md +1 -1
  238. package/templates/.agents/requirements/zaip-strategic-95.md +1 -1
  239. package/templates/.agents/rules/autonomy-decision.md +1 -0
  240. package/templates/.agents/rules/workflow.md +1 -1
  241. package/templates/.agents/runtime/VERSION +1 -1
  242. package/templates/.agents/runtime/bin/zaip.mjs +28 -26
  243. package/templates/.agents/runtime/checksums.sha256 +5 -5
  244. package/templates/.agents/runtime/manifest.json +1 -1
  245. package/templates/.agents/runtime/provenance.json +4 -4
  246. package/templates/.agents/runtime/sbom.cdx.json +1 -1
  247. package/templates/.agents/skills/zaip-aios/SKILL.md +0 -1
  248. package/templates/.agents/skills/zaip-skill-author-skills/scripts/audit-skill-catalog.mjs +1 -0
  249. package/templates/.agents/skills/zaip-skill-config/SKILL.md +1 -1
  250. package/templates/.agents/skills/zaip-skill-execution/SKILL.md +13 -0
  251. package/templates/.agents/skills/zaip-skill-execution/references/autonomous-continuation.md +17 -0
  252. package/templates/.agents/skills/zaip-skill-execution/references/correction-cycle.md +2 -2
  253. package/templates/.agents/skills/zaip-skill-github-deploy/SKILL.md +4 -2
  254. package/templates/.agents/skills/zaip-skill-github-deploy/references/deployment-workflow.md +4 -2
  255. package/templates/.agents/skills/zaip-skill-github-deploy/references/release-identity.md +2 -2
  256. package/templates/.agents/skills/zaip-skill-github-setup/SKILL.md +2 -2
  257. package/templates/.agents/skills/zaip-skill-move-prd/SKILL.md +4 -0
  258. package/templates/.agents/skills/zaip-skill-move-spec/SKILL.md +4 -0
  259. package/templates/.agents/skills/zaip-skill-prd/SKILL.md +3 -3
  260. package/templates/.agents/skills/zaip-skill-release-qualification/SKILL.md +15 -8
  261. package/templates/.agents/skills/zaip-skill-release-qualification/references/local-preparation.md +13 -12
  262. package/templates/.agents/skills/zaip-skill-setup/SKILL.md +50 -13
  263. package/templates/.agents/skills/zaip-skill-setup/agents/openai.yaml +2 -2
  264. package/templates/.agents/skills/zaip-skill-spec/SKILL.md +2 -2
  265. package/templates/.agents/skills/zaip-skill-update-version-doc/SKILL.md +39 -0
  266. package/templates/.agents/skills/zaip-skill-update-version-doc/agents/openai.yaml +4 -0
  267. package/templates/.agents/skills/zaip-skill-update-version-doc/scripts/update-version-doc.mjs +21 -0
  268. package/templates/.agents/skills/zaip-skill-update-version-doc/scripts/update-version-doc.test.mjs +32 -0
  269. package/templates/.agents/zaip-aios/README.md +2 -1
  270. package/templates/.agents/zaip-aios/VERSION +1 -1
  271. package/templates/.agents/zaip-aios/guides/20-instalacao-detalhada.md +7 -3
  272. package/templates/template-manifest.json +436 -256
  273. package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-06__WZco.js +0 -68
  274. package/templates/.agents/dashboard/apps/frontend/dist/assets/index-Cmlx8OYH.css +0 -1
  275. package/templates/.agents/dashboard/apps/frontend/dist/assets/index-DqZKJS8y.js +0 -2
  276. package/templates/.agents/design/apps/catalog/dist/assets/index-BEmIE7WE.css +0 -1
  277. package/templates/.agents/design/apps/catalog/dist/assets/index-BJV597iq.js +0 -72
  278. package/templates/.agents/design/apps/catalog/dist/assets/index-B_WhrCZe.js +0 -72
  279. package/templates/.agents/design/apps/catalog/dist/assets/index-CqqYWY2f.js +0 -9
  280. package/templates/.agents/design/apps/catalog/dist/assets/index-CqtYXZfV.js +0 -72
  281. package/templates/.agents/design/apps/catalog/dist/assets/index-D9pj7Jlf.js +0 -9
  282. package/templates/.agents/design/apps/catalog/dist/assets/index-i_PO2k9R.js +0 -9
  283. package/templates/.agents/design/apps/catalog/dist/storybook/assets/CatalogShell-Cstn1UwA.js +0 -1
  284. package/templates/.agents/design/apps/catalog/dist/storybook/assets/Components.stories-D1WopB2L.js +0 -137
  285. package/templates/.agents/design/apps/catalog/dist/storybook/assets/DesignSystem.stories-DQ9PJ3N3.js +0 -1
  286. package/templates/.agents/design/apps/catalog/dist/storybook/assets/formatter-L2YTDE3Q-D0OSgxWz.js +0 -1
  287. package/templates/.agents/design/apps/catalog/dist/storybook/assets/iframe-BEmIE7WE.css +0 -1
  288. package/templates/.agents/design/apps/catalog/dist/storybook/assets/react-C3tkVMIp.js +0 -1
@@ -0,0 +1,173 @@
1
+ import type { CostMonitorProjection } from "../contracts.js";
2
+ import type { CostFilterState } from "./CostFilters.js";
3
+ import type { CostCurrency } from "./cost-monitor-copy.js";
4
+
5
+ export async function loadCostMonitorPeriod({
6
+ currency,
7
+ filters,
8
+ from,
9
+ refresh,
10
+ to,
11
+ signal,
12
+ fetcher = fetch,
13
+ }: {
14
+ currency: CostCurrency;
15
+ filters?: CostFilterState;
16
+ from?: string;
17
+ refresh?: string | null;
18
+ to?: string;
19
+ signal?: AbortSignal;
20
+ fetcher?: typeof fetch;
21
+ }): Promise<CostMonitorProjection> {
22
+ const query = new URLSearchParams({ currency });
23
+ // Period and filter changes hydrate aggregate read models only. Entity
24
+ // detail is loaded through its dedicated bounded page route.
25
+ query.set("scope", "summary");
26
+ if (from !== undefined) query.set("from", from);
27
+ if (to !== undefined) query.set("to", to);
28
+ if (filters) {
29
+ const manifestFilters = [
30
+ ["provider", filters.provider],
31
+ ["phase", filters.phase],
32
+ ["agent", filters.agent],
33
+ ["model", filters.model],
34
+ ["status", filters.status],
35
+ ["query", filters.query],
36
+ ["priority", filters.priority],
37
+ ["risk", filters.risk],
38
+ ["origin", filters.origin],
39
+ ["workType", filters.workType],
40
+ ] as const;
41
+ for (const [key, value] of manifestFilters) {
42
+ if (value) query.set(key, value);
43
+ }
44
+ }
45
+ if (refresh) query.set("refresh", refresh);
46
+ const response = await fetcher(`/api/v2/cost-monitor?${query.toString()}`, {
47
+ ...(signal === undefined ? {} : { signal }),
48
+ });
49
+ if (!response.ok) {
50
+ const detail = (await response.text()).trim();
51
+ throw new Error(detail || `Cost Monitor period request failed (${response.status})`);
52
+ }
53
+ return (await response.json()) as CostMonitorProjection;
54
+ }
55
+
56
+ /** Exact dimensional projection, requested only after a dimensional tab opens. */
57
+ export async function loadCostMonitorDetail({
58
+ currency,
59
+ filters,
60
+ from,
61
+ refresh,
62
+ to,
63
+ signal,
64
+ fetcher = fetch,
65
+ }: {
66
+ currency: CostCurrency;
67
+ filters?: CostFilterState;
68
+ from?: string;
69
+ refresh?: string | null;
70
+ to?: string;
71
+ signal?: AbortSignal;
72
+ fetcher?: typeof fetch;
73
+ }): Promise<CostMonitorProjection> {
74
+ const query = costMonitorQuery({
75
+ currency,
76
+ ...(filters === undefined ? {} : { filters }),
77
+ ...(from === undefined ? {} : { from }),
78
+ ...(refresh === undefined ? {} : { refresh }),
79
+ ...(to === undefined ? {} : { to }),
80
+ });
81
+ query.set("scope", "detail");
82
+ const response = await fetcher(`/api/v2/cost-monitor?${query.toString()}`, {
83
+ ...(signal === undefined ? {} : { signal }),
84
+ });
85
+ if (!response.ok)
86
+ throw new Error(
87
+ (await response.text()).trim() || `Cost Monitor detail request failed (${response.status})`,
88
+ );
89
+ return (await response.json()) as CostMonitorProjection;
90
+ }
91
+
92
+ export async function loadCostMonitorRunPage({
93
+ currency,
94
+ filters,
95
+ from,
96
+ limit = 10,
97
+ offset,
98
+ refresh,
99
+ to,
100
+ signal,
101
+ fetcher = fetch,
102
+ }: {
103
+ currency: CostCurrency;
104
+ filters?: CostFilterState;
105
+ from?: string;
106
+ limit?: number;
107
+ offset: number;
108
+ refresh?: string | null;
109
+ to?: string;
110
+ signal?: AbortSignal;
111
+ fetcher?: typeof fetch;
112
+ }): Promise<CostRunPage> {
113
+ const query = costMonitorQuery({
114
+ currency,
115
+ ...(filters === undefined ? {} : { filters }),
116
+ ...(from === undefined ? {} : { from }),
117
+ ...(refresh === undefined ? {} : { refresh }),
118
+ ...(to === undefined ? {} : { to }),
119
+ });
120
+ query.set("scope", "runs");
121
+ query.set("offset", String(Math.max(0, offset)));
122
+ query.set("limit", String(Math.max(1, limit)));
123
+ const response = await fetcher(`/api/v2/cost-monitor?${query.toString()}`, {
124
+ ...(signal === undefined ? {} : { signal }),
125
+ });
126
+ if (!response.ok) {
127
+ const detail = (await response.text()).trim();
128
+ throw new Error(detail || `Cost Monitor run page request failed (${response.status})`);
129
+ }
130
+ const payload = (await response.json()) as Pick<CostMonitorProjection, "runs" | "run_page">;
131
+ return {
132
+ page_only: true,
133
+ runs: payload.runs,
134
+ run_page: payload.run_page ?? { offset, limit, total: null, has_more: false },
135
+ };
136
+ }
137
+
138
+ /** Complete contract for the incremental Run endpoint; it is not a summary projection. */
139
+ export interface CostRunPage {
140
+ page_only: true;
141
+ runs: CostMonitorProjection["runs"];
142
+ run_page: { offset: number; limit: number; total: number | null; has_more: boolean };
143
+ }
144
+
145
+ function costMonitorQuery({
146
+ currency,
147
+ filters,
148
+ from,
149
+ refresh,
150
+ to,
151
+ }: {
152
+ currency: CostCurrency;
153
+ filters?: CostFilterState;
154
+ from?: string;
155
+ refresh?: string | null;
156
+ to?: string;
157
+ }): URLSearchParams {
158
+ const query = new URLSearchParams({ currency });
159
+ if (from !== undefined) query.set("from", from);
160
+ if (to !== undefined) query.set("to", to);
161
+ if (filters) {
162
+ const manifestFilters = [
163
+ ["provider", filters.provider],
164
+ ["phase", filters.phase],
165
+ ["agent", filters.agent],
166
+ ["model", filters.model],
167
+ ["status", filters.status],
168
+ ] as const;
169
+ for (const [key, value] of manifestFilters) if (value) query.set(key, value);
170
+ }
171
+ if (refresh) query.set("refresh", refresh);
172
+ return query;
173
+ }
@@ -0,0 +1,47 @@
1
+ import type { OperationsProjection } from "@zaip-ai/dashboard-operations/contracts";
2
+ import type { ReactNode } from "react";
3
+ import type { CostMonitorProjection } from "../contracts.js";
4
+ import type {
5
+ loadCostMonitorDetail,
6
+ loadCostMonitorPeriod,
7
+ loadCostMonitorRunPage,
8
+ } from "./CostFilters.js";
9
+ import type { CostCurrency, CostLocale } from "./cost-monitor-copy.js";
10
+ import type { LoadCompactCostPage } from "./use-compact-cost-page.js";
11
+ import type { LoadCostGroupPage } from "./use-cost-group-page.js";
12
+
13
+ type LoadCostMonitorDetail = typeof loadCostMonitorDetail;
14
+ type LoadCostRunPage = typeof loadCostMonitorRunPage;
15
+
16
+ export interface CostMonitorPageProps {
17
+ capabilityNavigation?: ReactNode;
18
+ data: CostMonitorProjection;
19
+ dashboardTitle?: string;
20
+ embedded?: boolean;
21
+ globalFilters?: { query: string; datePreset: string; dateRange?: { start: string; end: string } };
22
+ lastUpdatedAt: string | null;
23
+ locale: CostLocale;
24
+ loading: boolean;
25
+ onLoadingChange?: (loading: boolean) => void;
26
+ onLocaleChange: (locale: CostLocale) => void;
27
+ onOpenTrace: (taskId: string) => void;
28
+ onActiveDataChange?: (data: CostMonitorProjection) => void;
29
+ /**
30
+ * Retained for host compatibility. Cost views must use bounded summary or
31
+ * page routes; activating a tab never requests the historical detail blob.
32
+ */
33
+ onDetailDataRequest?: () => void;
34
+ onRefresh: () => void;
35
+ loadDetail?: LoadCostMonitorDetail;
36
+ loadRunPage?: LoadCostRunPage;
37
+ loadReadModelPage?: LoadCompactCostPage;
38
+ loadGroupPage?: LoadCostGroupPage;
39
+ loadPeriod?: typeof loadCostMonitorPeriod;
40
+ operations?: Pick<
41
+ OperationsProjection,
42
+ "runs" | "specs" | "tasks" | "executions" | "evidences" | "validations" | "summary"
43
+ >;
44
+ repositoryName?: string;
45
+ currency?: CostCurrency;
46
+ onCurrencyChange?: (currency: CostCurrency) => void;
47
+ }
@@ -39,11 +39,5 @@ export function visibleExecutionRows<T extends { id: string }>(
39
39
 
40
40
  /** Only filters represented by the partial Runs endpoint may use page-only data. */
41
41
  export function isServerCostRunPagingEligible(filters: CostFilterState, globalQuery = ""): boolean {
42
- return (
43
- (globalQuery === "" || filters.query === "") &&
44
- filters.priority === "" &&
45
- filters.risk === "" &&
46
- filters.origin === "" &&
47
- filters.workType === ""
48
- );
42
+ return globalQuery === "" || filters.query === "";
49
43
  }
@@ -4,12 +4,11 @@ export type CostPageDateRange = { from: string; to: string };
4
4
 
5
5
  /**
6
6
  * Embedded pages use the host's all-time atomic snapshot until an explicit
7
- * period, date range, or local Cost filter narrows the population.
7
+ * period or date range narrows the population. Metadata never changes dates.
8
8
  */
9
9
  export function resolveCostGroupPageRange({
10
10
  embedded,
11
11
  globalDateRange,
12
- hasLocalCostFilters,
13
12
  period,
14
13
  runPageRange,
15
14
  }: {
@@ -19,13 +18,8 @@ export function resolveCostGroupPageRange({
19
18
  period: CostPeriod;
20
19
  runPageRange: CostPageDateRange | undefined;
21
20
  }): CostPageDateRange | undefined {
22
- if (
23
- embedded &&
24
- globalDateRange === undefined &&
25
- period === defaultCostPeriod &&
26
- !hasLocalCostFilters
27
- )
28
- return undefined;
21
+ // The visible host period owns the range. Metadata filters never change it.
22
+ if (embedded && globalDateRange === undefined && period === defaultCostPeriod) return undefined;
29
23
  return runPageRange;
30
24
  }
31
25
 
@@ -124,7 +124,7 @@ describe("Cost Monitor V2", () => {
124
124
  }),
125
125
  );
126
126
  });
127
- it("keeps priced Runs whose duration was not observed", () => {
127
+ it("keeps legacy persisted duration when raw source timing is absent", () => {
128
128
  const operations = operationsWithPricedRun();
129
129
  const source = operations.runs[0];
130
130
  if (source === undefined) throw new Error("priced Run fixture is missing");
@@ -139,13 +139,13 @@ describe("Cost Monitor V2", () => {
139
139
  expect(projection.runs).toContainEqual(
140
140
  expect.objectContaining({
141
141
  run_id: "RUN-WITHOUT-OBSERVED-DURATION",
142
- duration_ms: 900_000,
143
- duration_provenance: "estimated",
144
- estimation_basis: "token_budget_v1:4_000_000_tokens_per_hour",
142
+ duration_ms: 60_000,
143
+ duration_provenance: "legacy_inferred",
144
+ estimation_basis: null,
145
145
  }),
146
146
  );
147
147
  });
148
- it("keeps every tokenized Run positive when factual timing would exhaust the canonical budget", () => {
148
+ it("does not allocate a duration budget to a tokenized Run without timing", () => {
149
149
  const operations = operationsWithPricedRun();
150
150
  operations.summary.overview_metrics = {
151
151
  ...(operations.summary.overview_metrics ?? {}),
@@ -162,17 +162,16 @@ describe("Cost Monitor V2", () => {
162
162
  duration_ms: null,
163
163
  });
164
164
  const rows = buildCostMonitorProjection(operations).runs;
165
- const rootDuration = rows.find((row) => row.run_id === root.id)?.duration_ms ?? 0;
166
- const tokenOnlyDuration = rows.find((row) => row.run_id === "TOKEN-ONLY")?.duration_ms ?? 0;
167
- expect(rootDuration).toBeGreaterThan(0);
168
- expect(tokenOnlyDuration).toBeGreaterThan(0);
169
- expect(rootDuration + tokenOnlyDuration).toBe(3_600_000);
165
+ const rootDuration = rows.find((row) => row.run_id === root.id)?.duration_ms;
166
+ const tokenOnlyDuration = rows.find((row) => row.run_id === "TOKEN-ONLY")?.duration_ms;
167
+ expect(rootDuration).toBe(4_000_000);
168
+ expect(tokenOnlyDuration).toBeNull();
170
169
  expect(rows.find((row) => row.run_id === "TOKEN-ONLY")).toMatchObject({
171
- duration_provenance: "estimated",
172
- estimation_basis: "operations_canonical_budget_v1:proportional_tokens",
170
+ duration_provenance: "unavailable",
171
+ estimation_basis: null,
173
172
  });
174
173
  });
175
- it("reconciles the all-period dimensional total to the displayed whole-hour budget", () => {
174
+ it("keeps dimensional durations sourced from factual Runs instead of overview budgets", () => {
176
175
  const operations = operationsWithPricedRun();
177
176
  operations.filters = { from: null, to: null };
178
177
  operations.summary.overview_metrics = {
@@ -181,13 +180,13 @@ describe("Cost Monitor V2", () => {
181
180
  } as never;
182
181
  const projection = buildCostMonitorProjection(operations);
183
182
  expect(projection.groups.models.reduce((sum, row) => sum + row.duration.known_sum, 0)).toBe(
184
- 76 * 3_600_000,
183
+ 40_000,
185
184
  );
186
185
  expect(projection.groups.daily.reduce((sum, row) => sum + row.duration.known_sum, 0)).toBe(
187
- 76 * 3_600_000,
186
+ 40_000,
188
187
  );
189
188
  });
190
- it("enforces tokens imply positive time for every Run and aggregate", () => {
189
+ it("preserves an observed zero duration for a tokenized Run", () => {
191
190
  const operations = operationsWithPricedRun();
192
191
  const source = operations.runs[0]!;
193
192
  operations.runs.push({
@@ -197,19 +196,21 @@ describe("Cost Monitor V2", () => {
197
196
  duration_ms: 0,
198
197
  });
199
198
  const projection = buildCostMonitorProjection(operations);
200
- expect(
201
- projection.runs
202
- .filter((row) => (row.total_tokens ?? 0) > 0)
203
- .every((row) => (row.duration_ms ?? 0) > 0),
204
- ).toBe(true);
205
- for (const groups of Object.values(projection.groups))
206
- expect(
207
- groups
208
- .filter((row) => (row.total_tokens ?? 0) > 0)
209
- .every((row) => row.duration.known_sum > 0),
210
- ).toBe(true);
199
+ expect(projection.runs).toContainEqual(
200
+ expect.objectContaining({
201
+ run_id: "TOKENIZED-ZERO",
202
+ duration_ms: 0,
203
+ duration_provenance: "observed",
204
+ estimation_basis: null,
205
+ }),
206
+ );
207
+ expect(projection.groups.daily[0]?.duration).toMatchObject({
208
+ known_sum: 40_000,
209
+ unknown: 0,
210
+ complete: true,
211
+ });
211
212
  });
212
- it("repairs a tokenized observed zero so the invariant remains positive", () => {
213
+ it("keeps unavailable and observed-zero duration distinct", () => {
213
214
  const operations = operationsWithPricedRun();
214
215
  const source = operations.runs[0];
215
216
  if (source === undefined) throw new Error("priced Run fixture is missing");
@@ -224,15 +225,15 @@ describe("Cost Monitor V2", () => {
224
225
  expect(projection.runs).toContainEqual(
225
226
  expect.objectContaining({
226
227
  run_id: source.id,
227
- duration_ms: 900_000,
228
- duration_provenance: "estimated",
228
+ duration_ms: 60_000,
229
+ duration_provenance: "legacy_inferred",
229
230
  }),
230
231
  );
231
232
  expect(projection.runs).toContainEqual(
232
233
  expect.objectContaining({
233
234
  run_id: "RUN-OBSERVED-ZERO",
234
- duration_ms: 900_000,
235
- duration_provenance: "estimated",
235
+ duration_ms: 0,
236
+ duration_provenance: "observed",
236
237
  }),
237
238
  );
238
239
  });
@@ -293,13 +294,16 @@ describe("Cost Monitor V2", () => {
293
294
  const bounded = withTimestamp("2026-08-01T00:01:00.000Z");
294
295
  expect(outlier).not.toEqual(bounded);
295
296
  expect(outlier).toContainEqual(
296
- expect.objectContaining({ key: "2026-08-10", duration_ms: 900_000 }),
297
+ expect.objectContaining({
298
+ key: "2026-08-10",
299
+ duration_ms: 0,
300
+ duration: expect.objectContaining({ known_sum: 0, unknown: 1, complete: false }),
301
+ }),
297
302
  );
298
303
  expect(outlier).toContainEqual(
299
304
  expect.objectContaining({
300
- // Daily wall-clock matches Operations: root factual durations are
301
- // retained regardless of whether they were observed or reconciled.
302
- // The estimate is token-backed, not lifecycle elapsed time.
305
+ // Daily root durations retain their observed, reconciled, and legacy
306
+ // facts. The unavailable outlier contributes no inferred duration.
303
307
  duration_ms: 13_500_000,
304
308
  duration: { known_sum: 13_500_000, unknown: 0, complete: true, coverage_ratio: 1 },
305
309
  }),
@@ -347,7 +351,7 @@ describe("Cost Monitor V2", () => {
347
351
  expect(projection.specs).toContainEqual(
348
352
  expect.objectContaining({
349
353
  id: "SPEC-DURATION",
350
- duration_ms: projection.groups.annual[0]?.duration.known_sum,
354
+ duration_ms: 0,
351
355
  }),
352
356
  );
353
357
  });
@@ -397,7 +401,7 @@ describe("Cost Monitor V2", () => {
397
401
  expect(projection.specs).toContainEqual(
398
402
  expect.objectContaining({
399
403
  id: "SPEC-VISIBLE-ROOT",
400
- duration_ms: projection.groups.annual[0]?.duration.known_sum,
404
+ duration_ms: null,
401
405
  }),
402
406
  );
403
407
  });
@@ -445,8 +449,8 @@ describe("Cost Monitor V2", () => {
445
449
  expect(projection.runs).toContainEqual(
446
450
  expect.objectContaining({
447
451
  run_id: source.id,
448
- duration_ms: 900_000,
449
- duration_provenance: "estimated",
452
+ duration_ms: 60_000,
453
+ duration_provenance: "legacy_inferred",
450
454
  estimated_brl: null,
451
455
  }),
452
456
  );
@@ -754,47 +758,4 @@ describe("Cost Monitor V2", () => {
754
758
  });
755
759
  expect(projection.overview).toMatchObject({ estimated_usd: 1.25, estimated_brl: 6.25 });
756
760
  });
757
- it("retains token-bearing Runs when a cost cannot be established", () => {
758
- const operations = operationsWithPricedRun();
759
- const source = operations.runs[0];
760
- if (!source) throw new Error("priced Run fixture is missing");
761
- operations.runs = [
762
- {
763
- ...source,
764
- id: "RUN-UNKNOWN-MODEL",
765
- model: "unknown-model",
766
- effective_model: "unknown-model",
767
- service_tier: null,
768
- usage: usage(metric({ tokens: 1_000, input: 900, cached: 800, output: 100, events: 1 })),
769
- },
770
- {
771
- ...source,
772
- id: "RUN-UNKNOWN-TOKENS",
773
- model: "gpt-5.4",
774
- effective_model: "gpt-5.4",
775
- service_tier: null,
776
- usage: usage(metric({ tokens: 1_000, input: 900, output: 100, events: 1 })),
777
- },
778
- ];
779
- const projection = buildCostMonitorProjection(operations, {
780
- catalog: gpt54Catalog(),
781
- fxRate: fxRate(5.5),
782
- currency: "BRL",
783
- });
784
- expect(projection.runs).toHaveLength(2);
785
- expect(projection.runs).toEqual(
786
- expect.arrayContaining([
787
- expect.objectContaining({
788
- run_id: "RUN-UNKNOWN-MODEL",
789
- total_tokens: 1_000,
790
- estimated_brl: null,
791
- }),
792
- expect.objectContaining({
793
- run_id: "RUN-UNKNOWN-TOKENS",
794
- total_tokens: 1_000,
795
- estimated_brl: null,
796
- }),
797
- ]),
798
- );
799
- });
800
761
  });
@@ -20,7 +20,6 @@ import {
20
20
  type CostRunRow,
21
21
  durationAggregationRows,
22
22
  } from "../contracts.js";
23
- import { estimatedDurationMs, TOKEN_DURATION_ESTIMATE_BASIS } from "../duration-estimate.js";
24
23
  import { normalizeCostProvider } from "../provider.js";
25
24
  import { aggregateTaskCostRows } from "../task-cost-groups.js";
26
25
  import { aggregateRows, averageAvailable } from "./aggregate.js";
@@ -76,7 +75,7 @@ export function buildCostMonitorProjection(
76
75
  const totalTokens = tokenTelemetryKnown
77
76
  ? inclusiveTokenTotal(recordedRun?.usage.total.tokens ?? usage.tokens)
78
77
  : null;
79
- const duration = costDuration(run, totalTokens);
78
+ const duration = costDuration(run);
80
79
  return {
81
80
  run_id: run.id,
82
81
  execution_id: run.execution_id,
@@ -111,10 +110,7 @@ export function buildCostMonitorProjection(
111
110
  started_at: run.started_at,
112
111
  finished_at: run.finished_at,
113
112
  ...duration,
114
- estimation_basis:
115
- duration.duration_provenance === "estimated"
116
- ? TOKEN_DURATION_ESTIMATE_BASIS
117
- : (run.estimation_basis ?? null),
113
+ estimation_basis: null,
118
114
  source_started_at: run.source_started_at ?? null,
119
115
  source_finished_at: run.source_finished_at ?? null,
120
116
  capture_lag_ms: run.capture_lag_ms ?? null,
@@ -157,14 +153,9 @@ export function buildCostMonitorProjection(
157
153
  artifact_path: run.artifact_path,
158
154
  };
159
155
  });
160
- // The Operations overview is the canonical, non-overlapping duration
161
- // budget. Keep factual post-cutoff root execution timing; distribute only
162
- // its remaining budget across tokenized non-canonical Runs. This makes every
163
- // Cost dimension consume one effective value per Run without reusing
164
- // lifecycle elapsed time or modifying token/cost telemetry.
165
- const rows = assertTokenDurationInvariant(
166
- allocateCanonicalDurationBudget(enforceTokenDurationInvariant(sourceRows), operations),
167
- );
156
+ // Cost dimensions carry only factual source timing. Tokens and lifecycle
157
+ // budgets are not duration evidence, so unavailable timing remains null.
158
+ const rows = sourceRows;
168
159
  const group = (
169
160
  select: (row: CostRunRow) => string,
170
161
  label?: (key: string) => string,
@@ -239,8 +230,8 @@ export function buildCostMonitorProjection(
239
230
  configured_agents: configuredAgents,
240
231
  usage,
241
232
  origins,
242
- prds: repriceMacros(operations.prds, tableRuns, rows),
243
- specs: repriceMacros(operations.specs, tableRuns, rows),
233
+ prds: repriceMacros(operations.prds, tableRuns),
234
+ specs: repriceMacros(operations.specs, tableRuns),
244
235
  runs: [...rows].sort((left, right) => right.started_at.localeCompare(left.started_at)),
245
236
  groups: {
246
237
  conversations: aggregateRows(
@@ -301,77 +292,6 @@ export function buildCostMonitorProjection(
301
292
  };
302
293
  }
303
294
 
304
- function allocateCanonicalDurationBudget(
305
- rows: readonly CostRunRow[],
306
- operations: OperationsProjection,
307
- ): CostRunRow[] {
308
- const rawBudget = operations.summary.overview_metrics?.duration_ms;
309
- if (typeof rawBudget !== "number" || rawBudget < 0) return [...rows];
310
- // The all-period Operations card is the human-facing reconciliation target
311
- // and is expressed in whole hours. Use that same precision for the Cost
312
- // allocation so its dimensional footers reconcile to the displayed 76 h,
313
- // while explicit date ranges retain their exact millisecond budget.
314
- const budget =
315
- operations.filters.from === null && operations.filters.to === null
316
- ? Math.round(rawBudget / 3_600_000) * 3_600_000
317
- : rawBudget;
318
- const tokenized = rows.filter((row) => (row.total_tokens ?? 0) > 0);
319
- if (tokenized.length === 0) return [...rows];
320
- // A non-positive/sub-millisecond-per-Run budget contradicts the invariant.
321
- // Prefer the deterministic token estimate instead of emitting 0 ms.
322
- if (budget < tokenized.length) return [...rows];
323
- const tokenTotal = tokenized.reduce((total, row) => total + (row.total_tokens ?? 0), 0);
324
- // Reserve one millisecond for every tokenized Run before distributing the
325
- // remainder. A previous factual-first allocation could exhaust the budget
326
- // and leave a recent day displaying 0 s despite millions of tokens.
327
- const minimumPerRun = budget >= tokenized.length ? 1 : 0;
328
- const distributable = Math.max(0, budget - minimumPerRun * tokenized.length);
329
- let assigned = 0;
330
- return rows.map((row) => {
331
- if (!tokenized.includes(row))
332
- return {
333
- ...row,
334
- duration_ms: null,
335
- duration_provenance: "unavailable",
336
- estimation_basis: null,
337
- };
338
- const isLast = tokenized.at(-1) === row;
339
- const duration_ms = isLast
340
- ? budget - assigned
341
- : minimumPerRun + Math.floor((distributable * (row.total_tokens ?? 0)) / tokenTotal);
342
- assigned += duration_ms;
343
- return {
344
- ...row,
345
- duration_ms,
346
- duration_provenance: "estimated",
347
- estimation_basis: "operations_canonical_budget_v1:proportional_tokens",
348
- };
349
- });
350
- }
351
-
352
- export function enforceTokenDurationInvariant(rows: readonly CostRunRow[]): CostRunRow[] {
353
- return rows.map((row) => {
354
- if ((row.total_tokens ?? 0) <= 0 || (row.duration_ms ?? 0) > 0) return row;
355
- const duration_ms = estimatedDurationMs(row.total_tokens);
356
- if (duration_ms === null || duration_ms <= 0) return row;
357
- return {
358
- ...row,
359
- duration_ms,
360
- duration_provenance: "estimated",
361
- estimation_basis: TOKEN_DURATION_ESTIMATE_BASIS,
362
- };
363
- });
364
- }
365
-
366
- function assertTokenDurationInvariant(rows: readonly CostRunRow[]): CostRunRow[] {
367
- const invalid = rows.find((row) => (row.total_tokens ?? 0) > 0 && (row.duration_ms ?? 0) <= 0);
368
- if (invalid !== undefined)
369
- throw new TypeError(
370
- `Cost Monitor invariant violated: ${invalid.run_id} has tokens without positive duration`,
371
- );
372
- return [...rows];
373
- }
374
-
375
295
  function withCreatedTaskCounts(
376
296
  groups: CostMonitorProjection["groups"]["daily"],
377
297
  tasks: readonly { created_at: string }[],
@@ -668,7 +588,6 @@ function singleFxRate(rates: readonly number[]): number | null {
668
588
 
669
589
  function costDuration(
670
590
  run: Pick<RunProjection, "source_duration_ms" | "duration_ms" | "duration_provenance">,
671
- totalTokens: number | null,
672
591
  ) {
673
592
  if (typeof run.source_duration_ms === "number" && run.source_duration_ms >= 0)
674
593
  return { duration_ms: run.source_duration_ms, duration_provenance: "observed" as const };
@@ -678,18 +597,16 @@ function costDuration(
678
597
  if (
679
598
  typeof run.duration_ms === "number" &&
680
599
  run.duration_ms >= 0 &&
681
- (run.duration_provenance === "observed" ||
600
+ (run.duration_provenance === undefined ||
601
+ run.duration_provenance === "observed" ||
682
602
  run.duration_provenance === "reconciled" ||
683
603
  run.duration_provenance === "legacy_inferred")
684
604
  ) {
685
605
  return {
686
606
  duration_ms: run.duration_ms,
687
- duration_provenance: run.duration_provenance,
607
+ duration_provenance: run.duration_provenance ?? "legacy_inferred",
688
608
  };
689
609
  }
690
- const estimated = estimatedDurationMs(totalTokens);
691
- if (estimated !== null)
692
- return { duration_ms: estimated, duration_provenance: "estimated" as const };
693
610
  return { duration_ms: null, duration_provenance: "unavailable" as const };
694
611
  }
695
612
 
@@ -744,9 +661,8 @@ function inclusiveTokenTotal(
744
661
  function repriceMacros(
745
662
  macros: readonly MacroProjection[],
746
663
  runs: readonly RunProjection[],
747
- costRows: readonly CostRunRow[],
748
664
  ): MacroProjection[] {
749
- const repriced = macros.map((macro) => {
665
+ return macros.map((macro) => {
750
666
  const declaredRunIds = new Set(macro.run_ids);
751
667
  const relatedRuns = runs.filter(
752
668
  (run) =>
@@ -759,22 +675,6 @@ function repriceMacros(
759
675
  usage: usageForRuns(relatedRuns),
760
676
  };
761
677
  });
762
- const durationBudget = costRows.reduce((sum, row) => sum + (row.duration_ms ?? 0), 0);
763
- const tokenized = repriced.filter((macro) => (macro.usage.total.tokens.total ?? 0) > 0);
764
- const tokenBudget = tokenized.reduce(
765
- (sum, macro) => sum + (macro.usage.total.tokens.total ?? 0),
766
- 0,
767
- );
768
- let assigned = 0;
769
- return repriced.map((macro) => {
770
- if (!tokenized.includes(macro)) return { ...macro, duration_ms: null };
771
- const isLast = tokenized.at(-1) === macro;
772
- const duration_ms = isLast
773
- ? durationBudget - assigned
774
- : Math.round((durationBudget * (macro.usage.total.tokens.total ?? 0)) / tokenBudget);
775
- assigned += duration_ms;
776
- return { ...macro, duration_ms };
777
- });
778
678
  }
779
679
 
780
680
  function unique(values: readonly string[]): string[] {