@zaip-ai/cli 1.3.8 → 1.4.1

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 (315) hide show
  1. package/README.md +58 -3
  2. package/dist/commands/init.d.ts +1 -0
  3. package/dist/commands/init.d.ts.map +1 -1
  4. package/dist/commands/init.js +17 -6
  5. package/dist/commands/init.js.map +1 -1
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +2 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/services/adapters.js +4 -4
  11. package/dist/services/adapters.js.map +1 -1
  12. package/dist/services/codex-config-template.d.ts +2 -2
  13. package/dist/services/codex-config-template.d.ts.map +1 -1
  14. package/dist/services/codex-config-template.js +3 -3
  15. package/dist/services/codex-config-template.js.map +1 -1
  16. package/dist/services/codex-rules.d.ts +1 -1
  17. package/dist/services/codex-rules.d.ts.map +1 -1
  18. package/dist/services/codex-rules.js +9 -24
  19. package/dist/services/codex-rules.js.map +1 -1
  20. package/dist/services/delivery-git-preflight.d.ts +23 -0
  21. package/dist/services/delivery-git-preflight.d.ts.map +1 -0
  22. package/dist/services/delivery-git-preflight.js +69 -0
  23. package/dist/services/delivery-git-preflight.js.map +1 -0
  24. package/dist/services/doctor.d.ts.map +1 -1
  25. package/dist/services/doctor.js +13 -1
  26. package/dist/services/doctor.js.map +1 -1
  27. package/dist/services/install-agents-template.d.ts.map +1 -1
  28. package/dist/services/install-agents-template.js +22 -28
  29. package/dist/services/install-agents-template.js.map +1 -1
  30. package/dist/services/install-profile.d.ts +8 -0
  31. package/dist/services/install-profile.d.ts.map +1 -0
  32. package/dist/services/install-profile.js +56 -0
  33. package/dist/services/install-profile.js.map +1 -0
  34. package/dist/services/logger.d.ts.map +1 -1
  35. package/dist/services/logger.js +6 -5
  36. package/dist/services/logger.js.map +1 -1
  37. package/dist/services/stack-git.d.ts +9 -0
  38. package/dist/services/stack-git.d.ts.map +1 -0
  39. package/dist/services/stack-git.js +188 -0
  40. package/dist/services/stack-git.js.map +1 -0
  41. package/dist/services/stack-plan.d.ts +3 -1
  42. package/dist/services/stack-plan.d.ts.map +1 -1
  43. package/dist/services/stack-plan.js +15 -1
  44. package/dist/services/stack-plan.js.map +1 -1
  45. package/dist/services/stack-terraform.d.ts +13 -0
  46. package/dist/services/stack-terraform.d.ts.map +1 -0
  47. package/dist/services/stack-terraform.js +274 -0
  48. package/dist/services/stack-terraform.js.map +1 -0
  49. package/dist/services/template-manifest.d.ts.map +1 -1
  50. package/dist/services/template-manifest.js +14 -1
  51. package/dist/services/template-manifest.js.map +1 -1
  52. package/dist/types.d.ts +1 -0
  53. package/dist/types.d.ts.map +1 -1
  54. package/package.json +1 -1
  55. package/templates/.agents/.env.example +34 -0
  56. package/templates/{README.md → .agents/README.md} +124 -60
  57. package/templates/.agents/config/agents/catalog.yaml +23 -23
  58. package/templates/.agents/config/clients/codex/agents/zaip-agent-analyst.toml +1 -0
  59. package/templates/.agents/config/clients/codex/agents/zaip-agent-auditor.toml +1 -0
  60. package/templates/.agents/config/clients/codex/agents/zaip-agent-backend.toml +5 -4
  61. package/templates/.agents/config/clients/codex/agents/zaip-agent-brand-strategist.toml +1 -0
  62. package/templates/.agents/config/clients/codex/agents/zaip-agent-builder.toml +1 -0
  63. package/templates/.agents/config/clients/codex/agents/zaip-agent-cloud-engineer.toml +10 -7
  64. package/templates/.agents/config/clients/codex/agents/zaip-agent-data-analyst.toml +1 -0
  65. package/templates/.agents/config/clients/codex/agents/zaip-agent-designer.toml +1 -0
  66. package/templates/.agents/config/clients/codex/agents/zaip-agent-finalizer.toml +1 -0
  67. package/templates/.agents/config/clients/codex/agents/zaip-agent-frontend.toml +5 -4
  68. package/templates/.agents/config/clients/codex/agents/zaip-agent-general-operations.toml +1 -0
  69. package/templates/.agents/config/clients/codex/agents/zaip-agent-governance-compliance.toml +1 -0
  70. package/templates/.agents/config/clients/codex/agents/zaip-agent-growth-strategist.toml +1 -0
  71. package/templates/.agents/config/clients/codex/agents/zaip-agent-integrator.toml +1 -0
  72. package/templates/.agents/config/clients/codex/agents/zaip-agent-marketing-analyst.toml +5 -4
  73. package/templates/.agents/config/clients/codex/agents/zaip-agent-orchestrator.toml +1 -0
  74. package/templates/.agents/config/clients/codex/agents/zaip-agent-refactoring-specialist.toml +1 -0
  75. package/templates/.agents/config/clients/codex/agents/zaip-agent-reviewer.toml +1 -0
  76. package/templates/.agents/config/clients/codex/agents/zaip-agent-sales-specialist.toml +1 -0
  77. package/templates/.agents/config/clients/codex/agents/zaip-agent-security-auditor.toml +1 -0
  78. package/templates/.agents/config/clients/codex/agents/zaip-agent-task-executor.toml +1 -0
  79. package/templates/.agents/config/clients/codex/agents/zaip-agent-website-developer.toml +5 -4
  80. package/templates/.agents/config/clients/codex/agents/zaip-agent-writer.toml +1 -0
  81. package/templates/.agents/config/pricing/models.json +25 -1
  82. package/templates/.agents/config/project.yaml +2 -0
  83. package/templates/.agents/dashboard/.zaip-managed.json +200 -88
  84. package/templates/.agents/dashboard/DATA-DICTIONARY.md +1 -1
  85. package/templates/.agents/dashboard/README.md +58 -19
  86. package/templates/.agents/dashboard/apps/frontend/dist/assets/{CostCalculationGuidePage-DwVZOmMV.js → CostCalculationGuidePage-snUCQYTC.js} +1 -1
  87. package/templates/.agents/dashboard/apps/frontend/dist/assets/{DashboardHelpDialog-VcLx9iOO.js → DashboardHelpDialog-oZVlf-l5.js} +72 -8
  88. package/templates/.agents/dashboard/apps/frontend/dist/assets/{PricingSettingsDialog-CyjMXkm8.js → PricingSettingsDialog-BPtVUGgs.js} +1 -1
  89. package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-3Awyaovx.js +3 -0
  90. package/templates/.agents/dashboard/apps/frontend/dist/assets/{TraceabilityWorkspace-DFZwIXSC.js → TraceabilityWorkspace-BYjVOHI_.js} +1 -1
  91. package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-DbaLbU2q.js +68 -0
  92. package/templates/.agents/dashboard/apps/frontend/dist/assets/{icons-vendor-DXBOtWNI.js → icons-vendor-TPUT2IUt.js} +1 -1
  93. package/templates/.agents/dashboard/apps/frontend/dist/assets/index-Cmlx8OYH.css +1 -0
  94. package/templates/.agents/dashboard/apps/frontend/dist/assets/index-ZJFXmK7m.js +2 -0
  95. package/templates/.agents/dashboard/apps/frontend/dist/assets/{react-vendor-DaNXQPyk.js → react-vendor-Ct48XHGL.js} +1 -1
  96. package/templates/.agents/dashboard/apps/frontend/dist/assets/{traceability-I4AKqVDX.js → traceability-BDe4_Ubl.js} +1 -1
  97. package/templates/.agents/dashboard/apps/frontend/dist/index.html +6 -6
  98. package/templates/.agents/dashboard/apps/frontend/src/App.tsx +73 -67
  99. package/templates/.agents/dashboard/apps/frontend/src/AppLoadingBoundary.tsx +35 -7
  100. package/templates/.agents/dashboard/apps/frontend/src/AppWorkBoard.ts +55 -0
  101. package/templates/.agents/dashboard/apps/frontend/src/ProjectStackEditor.tsx +11 -0
  102. package/templates/.agents/dashboard/apps/frontend/src/app-loading-boundary.css +98 -0
  103. package/templates/.agents/dashboard/apps/frontend/src/cost-period-refresh.test.ts +5 -5
  104. package/templates/.agents/dashboard/apps/frontend/src/dashboard-api-reconciliation.ts +33 -0
  105. package/templates/.agents/dashboard/apps/frontend/src/dashboard-api.test.ts +75 -0
  106. package/templates/.agents/dashboard/apps/frontend/src/dashboard-api.ts +7 -8
  107. package/templates/.agents/dashboard/apps/frontend/src/project-settings-model.ts +14 -2
  108. package/templates/.agents/dashboard/apps/frontend/src/project-settings.test.ts +35 -0
  109. package/templates/.agents/dashboard/apps/frontend/src/snapshot-coherence.test.ts +78 -2
  110. package/templates/.agents/dashboard/apps/frontend/src/use-app-cost-loaders.test.ts +28 -0
  111. package/templates/.agents/dashboard/apps/frontend/src/use-app-cost-loaders.ts +8 -5
  112. package/templates/.agents/dashboard/apps/frontend/src/use-app-effects.ts +180 -1
  113. package/templates/.agents/dashboard/modules/cost-monitor/src/contracts.ts +7 -4
  114. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorContent.tsx +13 -7
  115. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.tsx +14 -0
  116. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTableDisplay.ts +211 -0
  117. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables.test.ts +152 -157
  118. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables.tsx +155 -142
  119. package/templates/.agents/dashboard/modules/cost-monitor/src/react/InvocationManifestQuery.test.ts +145 -0
  120. package/templates/.agents/dashboard/modules/cost-monitor/src/react/period-cost-groups.ts +7 -5
  121. package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-compact-cost-page.ts +4 -1
  122. package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-cost-group-page.ts +4 -1
  123. package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-cost-run-page.ts +4 -1
  124. package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-projection.ts +4 -4
  125. package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportAction.test.ts +79 -1
  126. package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportAction.tsx +105 -11
  127. package/templates/.agents/dashboard/packages/local-runtime/dist/server.cjs +482 -332
  128. package/templates/.agents/dashboard/packages/local-runtime/dist/sqlite-read-model.cjs +430 -285
  129. package/templates/.agents/dashboard/packages/local-runtime/scripts/build-sqlite-runtime.mjs +14 -2
  130. package/templates/.agents/dashboard/packages/local-runtime/scripts/rebuild-sqlite-read-model.mjs +6 -26
  131. package/templates/.agents/dashboard/packages/local-runtime/scripts/validate-sqlite-read-model.mjs +1 -1
  132. package/templates/.agents/dashboard/packages/local-runtime/scripts/verify-persistent-launch.mjs +268 -0
  133. package/templates/.agents/dashboard/packages/local-runtime/server.mjs +482 -332
  134. package/templates/.agents/dashboard/packages/local-runtime/src/project-settings.test.ts +90 -1
  135. package/templates/.agents/dashboard/packages/local-runtime/src/project-settings.ts +112 -22
  136. package/templates/.agents/dashboard/packages/local-runtime/src/server-agent-assets.ts +39 -0
  137. package/templates/.agents/dashboard/packages/local-runtime/src/server-browser-lease.ts +33 -0
  138. package/templates/.agents/dashboard/packages/local-runtime/src/server-reconciliation-refresh.test.ts +148 -11
  139. package/templates/.agents/dashboard/packages/local-runtime/src/server-reconciliation-result.test.ts +68 -0
  140. package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-refresh.test.ts +19 -0
  141. package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-refresh.ts +39 -43
  142. package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-revision.test.ts +42 -0
  143. package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-revision.ts +26 -0
  144. package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-synchronization.ts +34 -0
  145. package/templates/.agents/dashboard/packages/local-runtime/src/server-startup.ts +30 -0
  146. package/templates/.agents/dashboard/packages/local-runtime/src/server-work-reconciliation.test.ts +89 -0
  147. package/templates/.agents/dashboard/packages/local-runtime/src/server-work-reconciliation.ts +88 -0
  148. package/templates/.agents/dashboard/packages/local-runtime/src/server-workspace.ts +68 -7
  149. package/templates/.agents/dashboard/packages/local-runtime/src/server.test.ts +11 -5
  150. package/templates/.agents/dashboard/packages/local-runtime/src/server.ts +129 -99
  151. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-agent-productivity.test.ts +111 -0
  152. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-agent-productivity.ts +140 -0
  153. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-agent-page.test.ts +127 -4
  154. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-agent-page.ts +145 -5
  155. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-aggregates.ts +156 -23
  156. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-group-projection.ts +18 -9
  157. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-invocation-projection.ts +52 -0
  158. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-first-fold-persistence.ts +35 -13
  159. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-force-canonical.test.ts +56 -0
  160. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-incremental-cache.test.ts +29 -0
  161. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-incremental-cache.ts +136 -0
  162. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-incremental-refresh.test.ts +251 -0
  163. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-operations-projection.ts +22 -7
  164. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-cache.test-support.ts +1 -1
  165. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-canonical-parsing.ts +42 -0
  166. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-canonical.ts +793 -0
  167. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-multi-provider-duration.test.ts +270 -0
  168. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-multi-provider-fixture.ts +3 -2
  169. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-multi-provider.test.ts +18 -4
  170. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-source-fingerprint.test.ts +87 -0
  171. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-source-fingerprint.ts +105 -16
  172. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model.test.ts +131 -59
  173. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model.ts +1000 -1115
  174. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-snapshot-cache.ts +13 -92
  175. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-launch-claims.test.mjs +79 -0
  176. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-launch-page.mjs +27 -0
  177. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-lifecycle.mjs +6 -6
  178. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-prerequisites.mjs +1 -1
  179. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-refresh.mjs +2 -10
  180. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-server.mjs +142 -0
  181. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard.mjs +231 -239
  182. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard.test.mjs +18 -29
  183. package/templates/.agents/dashboard/packages/windows-launcher/Program.cs +6 -0
  184. package/templates/.agents/dashboard/zaip-dashboard-windows.exe +0 -0
  185. package/templates/.agents/requirements/autonomous-assurance.md +1 -1
  186. package/templates/.agents/requirements/cloud-hostinger-autonomy.md +47 -0
  187. package/templates/.agents/requirements/comparative-audit.md +1 -1
  188. package/templates/.agents/requirements/context-engine.md +1 -1
  189. package/templates/.agents/requirements/cost-observability.md +1 -1
  190. package/templates/.agents/requirements/dashboard-launch.md +2 -2
  191. package/templates/.agents/requirements/data-export.md +1 -1
  192. package/templates/.agents/requirements/design-system.md +1 -1
  193. package/templates/.agents/requirements/execution-engine.md +1 -1
  194. package/templates/.agents/requirements/kanban-dashboard.md +1 -1
  195. package/templates/.agents/requirements/model-orchestration.md +1 -1
  196. package/templates/.agents/requirements/public-distribution.md +1 -1
  197. package/templates/.agents/requirements/software-architecture.md +1 -1
  198. package/templates/.agents/requirements/strategic-improvements.md +1 -1
  199. package/templates/.agents/requirements/work-lifecycle.md +1 -1
  200. package/templates/.agents/requirements/zaip-strategic-95.md +1 -1
  201. package/templates/.agents/rules/autonomy-decision.md +1 -1
  202. package/templates/.agents/rules/cloud-hostinger-autonomy.md +21 -0
  203. package/templates/.agents/rules/core.md +5 -4
  204. package/templates/.agents/rules/local-sqlite-storage.md +18 -0
  205. package/templates/.agents/rules/meta-mcp.md +21 -0
  206. package/templates/.agents/rules/workflow.md +1 -0
  207. package/templates/.agents/runtime/bin/zaip.mjs +305 -137
  208. package/templates/.agents/runtime/checksums.sha256 +2 -2
  209. package/templates/.agents/runtime/provenance.json +2 -2
  210. package/templates/.agents/skills/zaip-skill-api-to-mcp/SKILL.md +4 -0
  211. package/templates/.agents/skills/zaip-skill-brand-governance/SKILL.md +25 -9
  212. package/templates/.agents/skills/zaip-skill-brand-governance/references/brandbook-framework.md +2 -2
  213. package/templates/.agents/skills/zaip-skill-brand-governance/references/brandbook-standards.md +2 -2
  214. package/templates/.agents/skills/zaip-skill-change/references/observable-evidence.md +15 -0
  215. package/templates/.agents/skills/zaip-skill-dashboard-sqlite/SKILL.md +13 -5
  216. package/templates/.agents/skills/zaip-skill-data-analyst/SKILL.md +10 -5
  217. package/templates/.agents/skills/zaip-skill-execution/SKILL.md +5 -4
  218. package/templates/.agents/skills/zaip-skill-frontend-launcher/SKILL.md +4 -3
  219. package/templates/.agents/skills/zaip-skill-frontend-launcher/references/launcher-contract.md +5 -3
  220. package/templates/.agents/skills/zaip-skill-github-deploy/SKILL.md +5 -5
  221. package/templates/.agents/skills/zaip-skill-github-deploy/scripts/preflight.mjs +78 -13
  222. package/templates/.agents/skills/zaip-skill-github-deploy/scripts/preflight.test.mjs +59 -0
  223. package/templates/.agents/skills/zaip-skill-github-deploy/scripts/yaml-parser.mjs +157 -0
  224. package/templates/.agents/skills/zaip-skill-growth-strategy-revops/SKILL.md +11 -6
  225. package/templates/.agents/skills/zaip-skill-hostinger-cloudflare-terraform/SKILL.md +17 -0
  226. package/templates/.agents/skills/zaip-skill-hostinger-cloudflare-terraform/agents/openai.yaml +7 -0
  227. package/templates/.agents/skills/zaip-skill-hostinger-cloudflare-terraform/references/autonomous-cloud-inputs.example.json +41 -0
  228. package/templates/.agents/skills/zaip-skill-hostinger-cloudflare-terraform/references/autonomous-runner.md +84 -0
  229. package/templates/.agents/skills/zaip-skill-hostinger-cloudflare-terraform/references/operational-contract.md +19 -0
  230. package/templates/.agents/skills/zaip-skill-local-credentials/SKILL.md +43 -0
  231. package/templates/.agents/skills/zaip-skill-local-credentials/agents/openai.yaml +6 -0
  232. package/templates/.agents/skills/zaip-skill-local-credentials/references/dotenv-resolution.md +47 -0
  233. package/templates/.agents/skills/zaip-skill-marketing/SKILL.md +8 -3
  234. package/templates/.agents/skills/zaip-skill-meta-ads/SKILL.md +16 -0
  235. package/templates/.agents/skills/zaip-skill-meta-ads/agents/openai.yaml +4 -0
  236. package/templates/.agents/skills/zaip-skill-meta-ads/references/setup.md +3 -0
  237. package/templates/.agents/skills/zaip-skill-meta-ads-setup/SKILL.md +24 -0
  238. package/templates/.agents/skills/zaip-skill-meta-ads-setup/agents/openai.yaml +4 -0
  239. package/templates/.agents/skills/zaip-skill-meta-ads-setup/references/diagnostics.md +13 -0
  240. package/templates/.agents/skills/zaip-skill-meta-ads-setup/references/official-sources.md +10 -0
  241. package/templates/.agents/skills/zaip-skill-meta-devtools-api-health/SKILL.md +12 -0
  242. package/templates/.agents/skills/zaip-skill-meta-devtools-api-health/agents/openai.yaml +4 -0
  243. package/templates/.agents/skills/zaip-skill-meta-devtools-api-health/references/LICENSE +21 -0
  244. package/templates/.agents/skills/zaip-skill-meta-devtools-api-health/references/upstream.md +77 -0
  245. package/templates/.agents/skills/zaip-skill-meta-devtools-api-integration/SKILL.md +12 -0
  246. package/templates/.agents/skills/zaip-skill-meta-devtools-api-integration/agents/openai.yaml +4 -0
  247. package/templates/.agents/skills/zaip-skill-meta-devtools-api-integration/references/LICENSE +21 -0
  248. package/templates/.agents/skills/zaip-skill-meta-devtools-api-integration/references/upstream.md +126 -0
  249. package/templates/.agents/skills/zaip-skill-meta-devtools-app-health-check/SKILL.md +12 -0
  250. package/templates/.agents/skills/zaip-skill-meta-devtools-app-health-check/agents/openai.yaml +4 -0
  251. package/templates/.agents/skills/zaip-skill-meta-devtools-app-health-check/references/LICENSE +21 -0
  252. package/templates/.agents/skills/zaip-skill-meta-devtools-app-health-check/references/upstream.md +67 -0
  253. package/templates/.agents/skills/zaip-skill-meta-devtools-app-review-prep/SKILL.md +12 -0
  254. package/templates/.agents/skills/zaip-skill-meta-devtools-app-review-prep/agents/openai.yaml +4 -0
  255. package/templates/.agents/skills/zaip-skill-meta-devtools-app-review-prep/references/LICENSE +21 -0
  256. package/templates/.agents/skills/zaip-skill-meta-devtools-app-review-prep/references/upstream.md +69 -0
  257. package/templates/.agents/skills/zaip-skill-meta-devtools-compliance-check/SKILL.md +12 -0
  258. package/templates/.agents/skills/zaip-skill-meta-devtools-compliance-check/agents/openai.yaml +4 -0
  259. package/templates/.agents/skills/zaip-skill-meta-devtools-compliance-check/references/LICENSE +21 -0
  260. package/templates/.agents/skills/zaip-skill-meta-devtools-compliance-check/references/upstream.md +79 -0
  261. package/templates/.agents/skills/zaip-skill-meta-devtools-debug-access-token/SKILL.md +14 -0
  262. package/templates/.agents/skills/zaip-skill-meta-devtools-debug-access-token/agents/openai.yaml +4 -0
  263. package/templates/.agents/skills/zaip-skill-meta-devtools-debug-access-token/references/LICENSE +21 -0
  264. package/templates/.agents/skills/zaip-skill-meta-devtools-debug-access-token/references/upstream.md +144 -0
  265. package/templates/.agents/skills/zaip-skill-meta-devtools-debug-webhooks/SKILL.md +12 -0
  266. package/templates/.agents/skills/zaip-skill-meta-devtools-debug-webhooks/agents/openai.yaml +4 -0
  267. package/templates/.agents/skills/zaip-skill-meta-devtools-debug-webhooks/references/LICENSE +21 -0
  268. package/templates/.agents/skills/zaip-skill-meta-devtools-debug-webhooks/references/upstream.md +83 -0
  269. package/templates/.agents/skills/zaip-skill-meta-devtools-search-docs/SKILL.md +10 -0
  270. package/templates/.agents/skills/zaip-skill-meta-devtools-search-docs/agents/openai.yaml +4 -0
  271. package/templates/.agents/skills/zaip-skill-meta-devtools-search-docs/references/LICENSE +21 -0
  272. package/templates/.agents/skills/zaip-skill-meta-devtools-search-docs/references/setup.md +11 -0
  273. package/templates/.agents/skills/zaip-skill-meta-devtools-search-docs/references/upstream.md +55 -0
  274. package/templates/.agents/skills/zaip-skill-meta-devtools-webhook-setup/SKILL.md +12 -0
  275. package/templates/.agents/skills/zaip-skill-meta-devtools-webhook-setup/agents/openai.yaml +4 -0
  276. package/templates/.agents/skills/zaip-skill-meta-devtools-webhook-setup/references/LICENSE +21 -0
  277. package/templates/.agents/skills/zaip-skill-meta-devtools-webhook-setup/references/upstream.md +56 -0
  278. package/templates/.agents/skills/zaip-skill-sales-methodology/SKILL.md +12 -7
  279. package/templates/.agents/skills/zaip-skill-sqlite-read-model/SKILL.md +11 -4
  280. package/templates/.agents/skills/zaip-skill-tool-setup/SKILL.md +6 -4
  281. package/templates/.agents/skills/zaip-skill-tool-setup/references/codex-config.md +4 -2
  282. package/templates/.agents/skills/zaip-skill-tool-setup/references/secrets.md +1 -0
  283. package/templates/.agents/tools/catalog.yaml +6 -0
  284. package/templates/.agents/tools/cloud-runner-dns.mjs +28 -0
  285. package/templates/.agents/tools/cloud-runner-terraform.mjs +212 -0
  286. package/templates/.agents/tools/cloud-runner.integration.test.mjs +239 -0
  287. package/templates/.agents/tools/cloud-runner.mjs +786 -0
  288. package/templates/.agents/tools/cloud-runner.test.mjs +534 -0
  289. package/templates/.agents/tools/cloud-terraform-plan-policy.mjs +262 -0
  290. package/templates/.agents/tools/mcp/development/meta-devtools/README.md +14 -0
  291. package/templates/.agents/tools/mcp/development/meta-devtools/manifest.yaml +28 -0
  292. package/templates/.agents/tools/mcp/infra/cloudflare/manifest.yaml +2 -3
  293. package/templates/.agents/tools/mcp/infra/hostinger/manifest.yaml +1 -3
  294. package/templates/.agents/tools/mcp/marketing/meta-ads/README.md +15 -13
  295. package/templates/.agents/tools/mcp/marketing/meta-ads/manifest.yaml +15 -10
  296. package/templates/.agents/tools/profiles/development.yaml +3 -0
  297. package/templates/infra/terraform/.terraform.lock.hcl +42 -0
  298. package/templates/infra/terraform/README.md +31 -0
  299. package/templates/infra/terraform/backend.tf.json +13 -0
  300. package/templates/infra/terraform/deployment-inputs.example.yaml +22 -0
  301. package/templates/infra/terraform/fixtures/approved-targets.json +32 -0
  302. package/templates/infra/terraform/fixtures/plan-approved.json +67 -0
  303. package/templates/infra/terraform/main.tf +77 -0
  304. package/templates/infra/terraform/outputs.tf +20 -0
  305. package/templates/infra/terraform/terraform.tfvars.example +26 -0
  306. package/templates/infra/terraform/variables.tf +91 -0
  307. package/templates/infra/terraform/versions.tf +18 -0
  308. package/templates/scripts/validate-cloud-hostinger-contract.mjs +89 -0
  309. package/templates/scripts/validate-cloud-terraform-plan.mjs +1 -0
  310. package/templates/template-manifest.json +599 -167
  311. package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-BwnJpl02.js +0 -3
  312. package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-C09KmlSw.js +0 -68
  313. package/templates/.agents/dashboard/apps/frontend/dist/assets/index-Dyo_wpL4.js +0 -2
  314. package/templates/.agents/dashboard/apps/frontend/dist/assets/index-hPPfVGQv.css +0 -1
  315. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-stale-seed.ts +0 -50
@@ -0,0 +1,211 @@
1
+ import { formatCompactNumber, formatCurrency, formatDurationMs } from "@zaip-ai/dashboard-ui";
2
+ import type { CostRunRow, DurationCoverage } from "../contracts.js";
3
+ import type { CostCurrency, CostLocale } from "./cost-monitor-copy.js";
4
+ import {
5
+ formatBrlRate,
6
+ formatMultiplierPair,
7
+ formatRate,
8
+ formatUsd,
9
+ } from "./cost-table-presentation.js";
10
+
11
+ export function displayCostGroupLabel(label: string, locale: CostLocale): string {
12
+ const normalized = label.trim().toLowerCase();
13
+ return normalized.length === 0 || normalized === "unknown"
14
+ ? locale === "pt-BR"
15
+ ? "Sem modelo/provedor atribuído"
16
+ : "No model/provider assigned"
17
+ : label;
18
+ }
19
+
20
+ export function formatAuditableNumber(value: number | null, locale: CostLocale): string {
21
+ return new Intl.NumberFormat(locale, { maximumFractionDigits: 0 }).format(value ?? 0);
22
+ }
23
+
24
+ export function formatFactualCount(value: number | null, locale: CostLocale): string {
25
+ return value === null
26
+ ? locale === "pt-BR"
27
+ ? "Indisponível"
28
+ : "Unavailable"
29
+ : formatAuditableNumber(value, locale);
30
+ }
31
+
32
+ export function formatAuditableCompactNumber(value: number | null, locale: CostLocale): string {
33
+ return formatCompactNumber(value ?? 0, locale);
34
+ }
35
+
36
+ export function formatAuditableCurrency(
37
+ value: number | null,
38
+ currency: CostCurrency,
39
+ locale: CostLocale,
40
+ ): string {
41
+ if (value === null) return locale === "pt-BR" ? "Indisponível" : "Unavailable";
42
+ return formatCurrency(value, currency, locale);
43
+ }
44
+
45
+ export function formatAuditableDuration(value: number | null, locale: CostLocale): string {
46
+ if (value === null) return locale === "pt-BR" ? "Indisponível" : "Unavailable";
47
+ return value === 0 ? "0" : formatDurationMs(value, locale);
48
+ }
49
+
50
+ export const formatInvocationNumber = (value: number | null, locale: CostLocale) =>
51
+ formatAuditableNumber(value, locale);
52
+ export const formatInvocationCurrency = (
53
+ value: number | null,
54
+ currency: CostCurrency,
55
+ locale: CostLocale,
56
+ ) => formatAuditableCurrency(value, currency, locale);
57
+ export const formatInvocationDuration = (value: number | null, locale: CostLocale) =>
58
+ formatAuditableDuration(value, locale);
59
+ export const formatInvocationRate = (value: number | null, locale: CostLocale) =>
60
+ formatRate(value, locale);
61
+ export const formatInvocationUsd = (value: number | null, locale: CostLocale) =>
62
+ formatUsd(value, locale);
63
+ export const formatInvocationBrlRate = (value: number | null, locale: CostLocale) =>
64
+ formatBrlRate(value, locale);
65
+ export const formatInvocationMultiplierPair = (
66
+ input: number | null,
67
+ output: number | null,
68
+ locale: CostLocale,
69
+ ) => formatMultiplierPair(input, output, locale);
70
+
71
+ export function invocationMetricDescription(locale: CostLocale, metric: string): string {
72
+ const source =
73
+ locale === "pt-BR"
74
+ ? "Valor da projeção SQLite/API desta Invocação de Agente. Fato canônico nulo permanece indisponível e não é convertido em zero."
75
+ : "Value from this Agent Invocation's SQLite/API projection. A null canonical fact remains unavailable and is not converted to zero.";
76
+ const details: Record<string, readonly [string, string]> = {
77
+ duration: [
78
+ "Tempo factual da invocação, quando capturado ou reconciliado.",
79
+ "Factual invocation duration, when captured or reconciled.",
80
+ ],
81
+ inputTokens: [
82
+ "Input total informado pela fonte; inclui a parcela de cache.",
83
+ "Source-reported total input; includes the cached portion.",
84
+ ],
85
+ cachedInputTokens: [
86
+ "Parcela de cache já incluída no input total.",
87
+ "Cached portion already included in total input.",
88
+ ],
89
+ outputTokens: [
90
+ "Output total informado pela fonte; inclui a parcela de raciocínio.",
91
+ "Source-reported total output; includes the reasoning portion.",
92
+ ],
93
+ reasoningTokens: [
94
+ "Parcela de raciocínio já incluída no output total.",
95
+ "Reasoning portion already included in total output.",
96
+ ],
97
+ totalTokens: [
98
+ "Soma de entrada e saída quando ambas são conhecidas; caso contrário, total informado pela fonte.",
99
+ "Input plus output when both are known; otherwise the source-reported total.",
100
+ ],
101
+ inputRate: [
102
+ "Tarifa efetiva de entrada em USD por milhão de tokens.",
103
+ "Effective input rate in USD per million tokens.",
104
+ ],
105
+ cacheRate: [
106
+ "Tarifa efetiva de entrada em cache em USD por milhão de tokens.",
107
+ "Effective cached-input rate in USD per million tokens.",
108
+ ],
109
+ outputRate: [
110
+ "Tarifa efetiva de saída em USD por milhão de tokens.",
111
+ "Effective output rate in USD per million tokens.",
112
+ ],
113
+ reasoningRate: [
114
+ "Tarifa efetiva de raciocínio em USD por milhão de tokens.",
115
+ "Effective reasoning rate in USD per million tokens.",
116
+ ],
117
+ contextMultiplier: [
118
+ "Multiplicadores de contexto de entrada/saída aplicados aos segmentos internos.",
119
+ "Input/output context multipliers applied to internal segments.",
120
+ ],
121
+ inputCost: [
122
+ "Custo USD de entrada calculado com tokens e tarifa efetiva.",
123
+ "Input USD cost calculated from tokens and the effective rate.",
124
+ ],
125
+ cacheCost: [
126
+ "Custo USD da entrada em cache calculado com tokens e tarifa efetiva.",
127
+ "Cached-input USD cost calculated with tokens and the effective rate.",
128
+ ],
129
+ outputCost: [
130
+ "Custo USD de saída calculado com tokens e tarifa efetiva.",
131
+ "Output USD cost calculated with tokens and the effective rate.",
132
+ ],
133
+ reasoningCost: [
134
+ "Custo USD de raciocínio calculado com tokens e tarifa efetiva.",
135
+ "Reasoning USD cost calculated with tokens and the effective rate.",
136
+ ],
137
+ standardCost: [
138
+ "Custo USD no cenário Standard, antes do acréscimo de velocidade.",
139
+ "USD cost in the Standard scenario, before the speed uplift.",
140
+ ],
141
+ speedUplift: [
142
+ "Acréscimo USD do cenário Priority/Fast, já incluído no custo efetivo.",
143
+ "USD uplift from the Priority/Fast scenario, already included in the effective cost.",
144
+ ],
145
+ finalUsd: [
146
+ "Custo final estimado da API em USD, somando os componentes de custo desta invocação.",
147
+ "Estimated final API cost in USD, summing this invocation's cost components.",
148
+ ],
149
+ fxRate: [
150
+ "Câmbio BRL/USD atual aplicado para converter o custo final atual.",
151
+ "Current BRL/USD exchange rate used to convert the current final cost.",
152
+ ],
153
+ recordedFxRate: [
154
+ "Câmbio BRL/USD registrado no período da atividade.",
155
+ "BRL/USD exchange rate recorded for the activity period.",
156
+ ],
157
+ recordedBrl: [
158
+ "Custo final BRL registrado no período, preservado para auditoria histórica.",
159
+ "Final BRL cost recorded in the period, retained for historical audit.",
160
+ ],
161
+ cost: [
162
+ "Custo final atual: USD estimado ou sua conversão BRL pelo câmbio atual selecionado.",
163
+ "Current final cost: estimated USD or its BRL conversion at the selected current exchange rate.",
164
+ ],
165
+ };
166
+ const detail = details[metric] ?? [
167
+ "Métrica numérica desta invocação.",
168
+ "Numeric metric for this invocation.",
169
+ ];
170
+ return `${detail[locale === "pt-BR" ? 0 : 1]} ${source}`;
171
+ }
172
+
173
+ export function formatDurationCoverage(value: DurationCoverage, locale: CostLocale): string {
174
+ if (value.known_sum <= 0 && !value.complete)
175
+ return locale === "pt-BR" ? "Indisponível" : "Unavailable";
176
+ return value.known_sum <= 0 ? "0" : formatDurationMs(value.known_sum, locale);
177
+ }
178
+
179
+ export function hasKnownDuration(value: DurationCoverage): boolean {
180
+ return value.known_sum > 0 || value.coverage_ratio > 0;
181
+ }
182
+
183
+ export function formatTokenBackedDuration(
184
+ value: DurationCoverage,
185
+ _totalTokens: number | null,
186
+ locale: CostLocale,
187
+ ): string {
188
+ return formatDurationCoverage(value, locale);
189
+ }
190
+
191
+ export function costRunsFooterLabel(locale: CostLocale, pageOnly: boolean): string {
192
+ if (!pageOnly) return "Total";
193
+ return locale === "pt-BR" ? "Subtotal da página" : "Page subtotal";
194
+ }
195
+
196
+ export function sortCostValue(
197
+ currency: CostCurrency,
198
+ brl: number | null,
199
+ usd: number | null,
200
+ ): number | null {
201
+ return currency === "BRL" ? brl : usd;
202
+ }
203
+
204
+ export function runOriginBadge(row: Pick<CostRunRow, "prd_id" | "spec_id" | "task_id">): {
205
+ label: "PRD" | "SPEC" | "Tarefa avulsa";
206
+ tone: "prd" | "spec" | "task";
207
+ } {
208
+ if (row.prd_id !== null) return { label: "PRD", tone: "prd" };
209
+ if (row.spec_id !== null) return { label: "SPEC", tone: "spec" };
210
+ return { label: "Tarefa avulsa", tone: "task" };
211
+ }
@@ -1,6 +1,5 @@
1
- import { createHash } from "node:crypto";
2
- import { queryInvocationManifestPeriod } from "@zaip-ai/costs";
3
1
  import { describe, expect, it } from "vitest";
2
+ import type { CostGroupRow } from "../contracts.js";
4
3
  import { displayModelName, isModelAuditRow, sumModelDurationMs } from "./CostModelsAuditTable.js";
5
4
  import {
6
5
  agentRunModelPresentation,
@@ -140,10 +139,10 @@ describe("monetary formatting", () => {
140
139
  expect(ratio(106.73, 19.583444)).toBeCloseTo(5.45, 2);
141
140
  expect(ratio(100, 0)).toBeNull();
142
141
  });
143
- it("renders unavailable numeric metrics as zero", () => {
142
+ it("keeps unavailable cost metrics distinct from zero", () => {
144
143
  expect(formatRate(null, "pt-BR")).toBe("0,00");
145
144
  expect(formatUsd(null, "en-US")).toContain("0.00");
146
- expect(formatAuditableCurrency(null, "BRL", "pt-BR")).toContain("0,00");
145
+ expect(formatAuditableCurrency(null, "BRL", "pt-BR")).toBe("Indisponível");
147
146
  expect(formatAuditableDuration(null, "pt-BR")).toBe("Indisponível");
148
147
  expect(formatAuditableCompactNumber(null, "pt-BR")).toBe("0");
149
148
  });
@@ -384,11 +383,11 @@ describe("grouped cost availability", () => {
384
383
  expect(table.props.scrollLabel).toBe(costGroupsScrollLabel("pt-BR"));
385
384
  expect(column("duration")?.render(unavailableGroup)).toBe("Indisponível");
386
385
  expect(column("tokens")?.render(unavailableGroup)).toBe("0");
387
- expect(column("cost")?.render(unavailableGroup)).toContain("0,00");
386
+ expect(column("cost")?.render(unavailableGroup)).toBe("Indisponível");
388
387
  expect(column("duration")?.sortValue?.(unavailableGroup)).toBeNull();
389
388
  expect(column("tokens")?.sortValue?.(unavailableGroup)).toBeNull();
390
389
  expect(column("cost")?.sortValue?.(unavailableGroup)).toBeNull();
391
- const totalSummary = "Total geral — Tempo: Indisponível; Tokens: 0; BRL: R$ 0,00";
390
+ const totalSummary = "Total geral — Tempo: Indisponível; Tokens: 0; BRL: Indisponível";
392
391
  const footerLabel = (key: string) => {
393
392
  const footer = column(key)?.footer as { props?: { "aria-label"?: string } } | undefined;
394
393
  return footer?.props?.["aria-label"];
@@ -462,9 +461,36 @@ describe("grouped cost availability", () => {
462
461
  expect(columns.find((column) => column.key === "job")?.render?.({ job: "Builder" })).toBe(
463
462
  "Builder",
464
463
  );
465
- expect(columns.find((column) => column.key === "tasks")).toBeUndefined();
464
+ expect(columns.find((column) => column.key === "tasks")?.label).toBe("Tarefas");
466
465
  expect(table.props.defaultSort).toEqual({ key: "cost", direction: "desc" });
467
466
  });
467
+
468
+ it("renders missing Agent numeric metrics as zero, keeping model rendering independent", () => {
469
+ const missing: CostGroupRow = {
470
+ ...unavailableGroup,
471
+ task_count: null,
472
+ prd_count: null,
473
+ spec_count: null,
474
+ test_count: null,
475
+ evidence_count: null,
476
+ };
477
+ const table = CostGroupsTable({
478
+ rows: [missing],
479
+ currency: "BRL",
480
+ locale: "pt-BR",
481
+ showAgentIdentity: true,
482
+ });
483
+ const columns = table.props.columns as Array<{
484
+ key: string;
485
+ render?: (row: CostGroupRow) => unknown;
486
+ footer?: unknown;
487
+ }>;
488
+ for (const key of ["tasks", "prds", "specs", "tests", "evidences", "duration", "tokens"]) {
489
+ expect(columns.find((c) => c.key === key)?.render?.(missing)).toBe("0");
490
+ }
491
+ expect(columns.find((c) => c.key === "cost")?.render?.(missing)).not.toContain("Indisponível");
492
+ });
493
+
468
494
  it("keeps legacy codex identity fields blank and uses the complete paged aggregate in its footer", () => {
469
495
  const table = CostGroupsTable({
470
496
  rows: [
@@ -518,6 +544,123 @@ describe("grouped cost availability", () => {
518
544
  expect(columns.find((column) => column.key === "latestStartedAt")?.hidden).toBe(true);
519
545
  expect(columns.find((column) => column.key === "tasks")?.label).toBe("Tarefas com invocação");
520
546
  });
547
+ it("renders the requested model-analysis columns with explicit numeric zeroes", () => {
548
+ const model: CostGroupRow = {
549
+ ...unavailableGroup,
550
+ key: "gpt-6-astra",
551
+ label: "gpt-6-astra",
552
+ prd_count: 2,
553
+ spec_count: 3,
554
+ task_count: null,
555
+ run_count: 8,
556
+ test_count: null,
557
+ evidence_count: 1,
558
+ conversation_count: 0,
559
+ };
560
+ const table = CostGroupsTable({
561
+ rows: [model],
562
+ currency: "BRL",
563
+ locale: "pt-BR",
564
+ showDateTime: false,
565
+ showModelLifecycleDetails: true,
566
+ totals: {
567
+ ...model,
568
+ prd_count: 2,
569
+ spec_count: 3,
570
+ task_count: null,
571
+ test_count: null,
572
+ evidence_count: 1,
573
+ },
574
+ });
575
+ const columns = table.props.columns as Array<{
576
+ key: string;
577
+ label: string;
578
+ render?: (row: typeof model) => unknown;
579
+ sortValue?: (row: typeof model) => unknown;
580
+ description?: string;
581
+ }>;
582
+ expect(columns.map((column) => column.key).filter((key) => key !== "latestStartedAt")).toEqual([
583
+ "label",
584
+ "prds",
585
+ "specs",
586
+ "tasks",
587
+ "conversations",
588
+ "runs",
589
+ "tests",
590
+ "evidences",
591
+ "duration",
592
+ "tokens",
593
+ "cost",
594
+ ]);
595
+ expect(columns.find((column) => column.key === "tasks")?.label).toBe("Tasks");
596
+ expect(columns.find((column) => column.key === "tasks")?.render?.(model)).toBe("0");
597
+ expect(columns.find((column) => column.key === "conversations")?.render?.(model)).toBe("0");
598
+ expect(columns.find((column) => column.key === "conversations")?.description).toContain(
599
+ "unassisted",
600
+ );
601
+ expect(columns.find((column) => column.key === "tasks")?.description).toContain(
602
+ "creation_run_id",
603
+ );
604
+ expect(columns.find((column) => column.key === "runs")?.description).toContain(
605
+ "sem distribuir",
606
+ );
607
+ for (const key of ["prds", "specs", "tasks", "conversations", "runs", "tests", "evidences"])
608
+ expect(columns.find((column) => column.key === key)?.sortValue).toBeDefined();
609
+ expect(columns.find((column) => column.key === "cost")?.label).toBe("Custos");
610
+ expect(
611
+ columns.find((column) => column.key === "tokens")?.render?.({ ...model, total_tokens: null }),
612
+ ).toBe("0");
613
+ expect(
614
+ columns.find((column) => column.key === "prds")?.render?.({ ...model, prd_count: null }),
615
+ ).toBe("0");
616
+ expect(
617
+ columns.find((column) => column.key === "specs")?.render?.({ ...model, spec_count: null }),
618
+ ).toBe("0");
619
+ expect(
620
+ columns.find((column) => column.key === "tests")?.render?.({ ...model, test_count: null }),
621
+ ).toBe("0");
622
+ expect(
623
+ columns
624
+ .find((column) => column.key === "evidences")
625
+ ?.render?.({ ...model, evidence_count: null }),
626
+ ).toBe("0");
627
+ expect(columns.find((column) => column.key === "conversations")?.sortValue?.(model)).toBe(0);
628
+ expect(columns.find((column) => column.key === "tests")?.description).toContain(
629
+ "Run registradora",
630
+ );
631
+ expect(columns.find((column) => column.key === "evidences")?.description).toContain(
632
+ "Run registradora",
633
+ );
634
+ expect(
635
+ columns
636
+ .find((column) => column.key === "duration")
637
+ ?.render?.({
638
+ ...model,
639
+ duration: { known_sum: 0, unknown: 1, complete: false, coverage_ratio: 0 },
640
+ }),
641
+ ).toBe("0");
642
+ expect(
643
+ columns.find((column) => column.key === "cost")?.render?.({ ...model, estimated_brl: null }),
644
+ ).toContain("0,00");
645
+ expect(
646
+ columns
647
+ .find((column) => column.key === "tokens")
648
+ ?.sortValue?.({ ...model, total_tokens: null }),
649
+ ).toBe(0);
650
+ expect(
651
+ columns
652
+ .find((column) => column.key === "duration")
653
+ ?.sortValue?.({
654
+ ...model,
655
+ duration: { known_sum: 0, unknown: 1, complete: false, coverage_ratio: 0 },
656
+ }),
657
+ ).toBe(0);
658
+ expect(
659
+ columns
660
+ .find((column) => column.key === "cost")
661
+ ?.sortValue?.({ ...model, estimated_brl: null }),
662
+ ).toBe(0);
663
+ });
521
664
  it("keeps a complete observed zero visible without a partial coverage label", () => {
522
665
  const observedZeroGroup = {
523
666
  ...unavailableGroup,
@@ -649,8 +792,8 @@ describe("grouped cost availability", () => {
649
792
  expect(column("contextMultiplier")?.render?.(unavailableRun)).toBe("Indisponível");
650
793
  expect(column("inputCost")?.render?.(unavailableRun)).toContain("0,00");
651
794
  expect(column("fxRate")?.render?.(unavailableRun)).toBe("R$ 0,00");
652
- expect(column("recordedBrl")?.render?.(unavailableRun)).toContain("0,00");
653
- expect(column("cost")?.render?.(unavailableRun)).toContain("0,00");
795
+ expect(column("recordedBrl")?.render?.(unavailableRun)).toBe("Indisponível");
796
+ expect(column("cost")?.render?.(unavailableRun)).toBe("Indisponível");
654
797
  });
655
798
  it("provides a clear scroll label for the detailed Runs table", () => {
656
799
  expect(costRunsScrollLabel("pt-BR")).toBe(
@@ -727,154 +870,6 @@ describe("grouped cost availability", () => {
727
870
  expect(pager.props.pagination.onRetry).toEqual(expect.any(Function));
728
871
  });
729
872
  });
730
- describe("manifest-first invocation query", () => {
731
- it("opens only intersecting monthly manifests and candidate chunks", async () => {
732
- const inRange = signedSummary({
733
- agent_invocation_id: "RUN-JULY-OPENAI",
734
- occurred_at: "2026-07-10T12:00:00.000Z",
735
- provider: "openai",
736
- });
737
- const outOfRange = signedSummary({
738
- agent_invocation_id: "RUN-JULY-ANTHROPIC",
739
- occurred_at: "2026-07-20T12:00:00.000Z",
740
- provider: "anthropic",
741
- });
742
- const firstChunk = `${JSON.stringify(inRange)}\n`;
743
- const secondChunk = `${JSON.stringify(outOfRange)}\n`;
744
- const manifest = signedManifest({
745
- period: { year: 2026, month: 7 },
746
- from: "2026-07-10T12:00:00.000Z",
747
- to: "2026-07-20T12:00:00.000Z",
748
- chunks: [
749
- {
750
- path: ".agents/records/telemetry/2026/07/chunk-openai.jsonl",
751
- content_sha256: digest(firstChunk),
752
- summary_count: 1,
753
- from: inRange.occurred_at,
754
- to: inRange.occurred_at,
755
- summary_hashes: [inRange.summary_hash],
756
- dimensions: dimensions({ providers: ["openai"] }),
757
- },
758
- {
759
- path: ".agents/records/telemetry/2026/07/chunk-anthropic.jsonl",
760
- content_sha256: digest(secondChunk),
761
- summary_count: 1,
762
- from: outOfRange.occurred_at,
763
- to: outOfRange.occurred_at,
764
- summary_hashes: [outOfRange.summary_hash],
765
- dimensions: dimensions({ providers: ["anthropic"] }),
766
- },
767
- ],
768
- });
769
- const reads: string[] = [];
770
- const openaiChunkPath = manifest.chunks[0]?.path;
771
- const anthropicChunkPath = manifest.chunks[1]?.path;
772
- if (openaiChunkPath === undefined || anthropicChunkPath === undefined) {
773
- throw new Error("Expected two manifest chunks");
774
- }
775
- const files = new Map<string, string>([
776
- [".agents/records/telemetry/2026/07/manifest.json", JSON.stringify(manifest)],
777
- [openaiChunkPath, firstChunk],
778
- [anthropicChunkPath, secondChunk],
779
- ]);
780
- const result = await queryInvocationManifestPeriod(
781
- {
782
- exists: async (path) => files.has(path),
783
- readText: async (path) => {
784
- reads.push(path);
785
- const value = files.get(path);
786
- if (value === undefined) throw new Error(`Missing fixture: ${path}`);
787
- return value;
788
- },
789
- },
790
- {
791
- from: "2026-07-09",
792
- to: "2026-07-11",
793
- filters: { providers: ["openai"] },
794
- },
795
- );
796
- expect(result.summaries.map((summary) => summary.agent_invocation_id)).toEqual([
797
- "RUN-JULY-OPENAI",
798
- ]);
799
- expect(result.manifest_count).toBe(1);
800
- expect(result.chunk_count).toBe(1);
801
- expect(result.source_latest_at).toBe("2026-07-20T12:00:00.000Z");
802
- expect(result.lag_ms).toBe(10);
803
- expect(reads).toEqual([
804
- ".agents/records/telemetry/2026/07/manifest.json",
805
- ".agents/records/telemetry/2026/07/chunk-openai.jsonl",
806
- ]);
807
- });
808
- });
809
- function digest(value: string): string {
810
- return createHash("sha256").update(value).digest("hex");
811
- }
812
- function dimensions(overrides: Partial<Record<string, readonly string[]>> = {}) {
813
- return {
814
- providers: [],
815
- models: [],
816
- zaip_agents: [],
817
- phases: [],
818
- purposes: [],
819
- statuses: [],
820
- executions: [],
821
- tasks: [],
822
- specs: [],
823
- prds: [],
824
- changes: [],
825
- ...overrides,
826
- };
827
- }
828
- function signedSummary(input: {
829
- agent_invocation_id: string;
830
- occurred_at: string;
831
- provider: string;
832
- }) {
833
- const unsigned = {
834
- schema_version: 1,
835
- agent_invocation_id: input.agent_invocation_id,
836
- occurred_at: input.occurred_at,
837
- coverage: "complete",
838
- usage_segments: [{ provider: input.provider, model: "gpt-5.6-terra" }],
839
- };
840
- return { ...unsigned, summary_hash: digest(JSON.stringify(unsigned)) };
841
- }
842
- function signedManifest(input: {
843
- period: { year: number; month: number };
844
- from: string;
845
- to: string;
846
- chunks: Array<{
847
- path: string;
848
- content_sha256: string;
849
- summary_count: number;
850
- from: string;
851
- to: string;
852
- summary_hashes: string[];
853
- dimensions: ReturnType<typeof dimensions>;
854
- }>;
855
- }) {
856
- const unsigned = {
857
- schema_version: 1,
858
- period: input.period,
859
- summary_count: input.chunks.reduce((sum, chunk) => sum + chunk.summary_count, 0),
860
- chunk_count: input.chunks.length,
861
- from: input.from,
862
- to: input.to,
863
- source_latest_at: input.to,
864
- lag_ms: 10,
865
- coverage: { complete: 2, partial: 0, unavailable: 0 },
866
- chunks: input.chunks,
867
- dimensions: dimensions(),
868
- aggregates: { daily: {}, monthly: {}, annual: {} },
869
- integrity: {
870
- status: "verified",
871
- algorithm: "sha256",
872
- chunk_count: input.chunks.length,
873
- summary_count: input.chunks.reduce((sum, chunk) => sum + chunk.summary_count, 0),
874
- },
875
- };
876
- return { ...unsigned, manifest_hash: digest(JSON.stringify(unsigned)) };
877
- }
878
873
  describe("cost sorting", () => {
879
874
  it("orders the raw BRL values rather than their localized currency labels", () => {
880
875
  const rows = [143.72, 127.78, 21457.76, 1370.63];