@zaip-ai/cli 3.3.0 → 3.5.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.
- package/dist/services/adapters.d.ts +1 -1
- package/dist/services/adapters.d.ts.map +1 -1
- package/dist/services/adapters.js +4 -3
- package/dist/services/adapters.js.map +1 -1
- package/dist/services/agent-catalog-upgrade.d.ts +3 -0
- package/dist/services/agent-catalog-upgrade.d.ts.map +1 -0
- package/dist/services/agent-catalog-upgrade.js +35 -0
- package/dist/services/agent-catalog-upgrade.js.map +1 -0
- package/dist/services/install-agents-template.d.ts.map +1 -1
- package/dist/services/install-agents-template.js +22 -22
- package/dist/services/install-agents-template.js.map +1 -1
- package/dist/services/install-template-policy.d.ts +3 -0
- package/dist/services/install-template-policy.d.ts.map +1 -0
- package/dist/services/install-template-policy.js +21 -0
- package/dist/services/install-template-policy.js.map +1 -0
- package/dist/services/logger.test.js +12 -2
- package/dist/services/logger.test.js.map +1 -1
- package/dist/services/sqlite-bootstrap.d.ts +1 -0
- package/dist/services/sqlite-bootstrap.d.ts.map +1 -1
- package/dist/services/sqlite-bootstrap.js +10 -1
- package/dist/services/sqlite-bootstrap.js.map +1 -1
- package/package.json +2 -2
- package/templates/.agents/config/agents/discovery.json +1 -1
- package/templates/.agents/dashboard/.zaip-managed.json +286 -126
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{CostCalculationGuidePage-BBFDrn64.js → CostCalculationGuidePage-C5NgEcVh.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{DashboardHelpDialog-Cd-qo9w7.js → DashboardHelpDialog-CCMVnkkI.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{PricingSettingsDialog-J7L5m8lk.js → PricingSettingsDialog-CGYcJ5EB.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{ProjectSettingsPage-B9GWkEyN.css → ProjectSettingsPage-CQMhvzvJ.css} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-D46WWIKr.js +3 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{TraceabilityWorkspace-BzVtGLWS.js → TraceabilityWorkspace-BKBpJyLh.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{cost-monitor-PoJA2PI1.css → cost-monitor-BsMfGfQi.css} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-j3aUYH5G.js +68 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{icons-vendor-CWzf_RiP.js → icons-vendor-x8xxL9yW.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-Bas2TVju.js +2 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-CxrG_wRI.css +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{react-vendor-CtHdbZk3.js → react-vendor-CNOXIJHN.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{traceability-BKrDH2TR.js → traceability-CcpbpT1s.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/index.html +7 -7
- package/templates/.agents/dashboard/apps/frontend/package.json +1 -1
- package/templates/.agents/dashboard/apps/frontend/src/App.tsx +12 -1
- package/templates/.agents/dashboard/apps/frontend/src/ProjectSettingsCard.tsx +5 -0
- package/templates/.agents/dashboard/apps/frontend/src/ProjectSettingsField.tsx +21 -0
- package/templates/.agents/dashboard/apps/frontend/src/ProjectSettingsPage.dom.test.ts +12 -1
- package/templates/.agents/dashboard/apps/frontend/src/ProjectSettingsPage.tsx +16 -28
- package/templates/.agents/dashboard/apps/frontend/src/ProjectStackEditor.tsx +25 -4
- package/templates/.agents/dashboard/apps/frontend/src/WorkspaceStatus.test.tsx +51 -0
- package/templates/.agents/dashboard/apps/frontend/src/WorkspaceStatus.tsx +39 -0
- package/templates/.agents/dashboard/apps/frontend/src/app-work-board-options.ts +41 -0
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-runtime-status.ts +25 -0
- package/templates/.agents/dashboard/apps/frontend/src/project-settings-copy.ts +13 -4
- package/templates/.agents/dashboard/apps/frontend/src/project-settings-model.ts +25 -1
- package/templates/.agents/dashboard/apps/frontend/src/project-settings-workspace.css +28 -0
- package/templates/.agents/dashboard/apps/frontend/src/project-settings.test.ts +39 -0
- package/templates/.agents/dashboard/apps/frontend/src/snapshot-coherence.test.ts +1 -1
- package/templates/.agents/dashboard/apps/frontend/src/use-app-cost-loaders.ts +5 -1
- package/templates/.agents/dashboard/apps/frontend/src/use-app-work-board.test.ts +140 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-app-work-board.ts +28 -41
- package/templates/.agents/dashboard/apps/frontend/src/use-runtime-status.ts +38 -0
- package/templates/.agents/dashboard/apps/frontend/src/workspace-status.css +20 -0
- package/templates/.agents/dashboard/modules/cost-monitor/package.json +1 -1
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CompactLifecycleCostTable.test.ts +25 -3
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CompactLifecycleCostTable.tsx +17 -19
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostFilters.tsx +13 -167
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostGroupsTable.tsx +2 -9
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.test.ts +8 -8
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.tsx +29 -52
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTableLoading.test.ts +1 -1
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables-keeps-legacy-codex-identity-fields-blank.test.ts +2 -2
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables.test.ts +4 -27
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/MacroCostTable.test.ts +2 -2
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/MacroCostTable.tsx +4 -3
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/agent-model-presentation.test.ts +26 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-embedded.css +7 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-loaders.ts +173 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-page-props.ts +47 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-page-selectors.ts +1 -7
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-page-range.ts +3 -9
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-projection.test.ts +44 -83
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-projection.ts +11 -111
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-projection.test.ts +47 -181
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-projection.ts +63 -91
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/cost-monitor-unavailable.test.ts +55 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/cost-summary-duration.test.ts +189 -0
- package/templates/.agents/dashboard/modules/operations/package.json +1 -1
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsEntityFilters.tsx +82 -0
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsPage.tsx +22 -31
- package/templates/.agents/dashboard/modules/operations/src/react/PagedWorkList.test.tsx +13 -1
- package/templates/.agents/dashboard/modules/operations/src/react/PagedWorkList.tsx +16 -3
- package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportAction.test.ts +11 -27
- package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportAction.tsx +44 -193
- package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportColumns.ts +186 -0
- package/templates/.agents/dashboard/modules/operations/src/react/export/excel-agent-participations.test.ts +28 -0
- package/templates/.agents/dashboard/modules/operations/src/react/export/export-layout.test.ts +2 -1
- package/templates/.agents/dashboard/modules/operations/src/react/operations-export-duration.ts +13 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-filter-panel.css +4 -0
- package/templates/.agents/dashboard/modules/operations/src/react/use-operation-filter-feedback.ts +18 -0
- package/templates/.agents/dashboard/modules/operations/src/react/work-board-model.test.ts +11 -0
- package/templates/.agents/dashboard/modules/operations/src/react/work-board-model.ts +10 -2
- package/templates/.agents/dashboard/modules/operations/src/work-board-model.ts +1 -1
- package/templates/.agents/dashboard/modules/traceability/package.json +1 -1
- package/templates/.agents/dashboard/packages/branding/package.json +1 -1
- package/templates/.agents/dashboard/packages/contracts/package.json +1 -1
- package/templates/.agents/dashboard/packages/data-export/package.json +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/dist/server.cjs +395 -341
- package/templates/.agents/dashboard/packages/local-runtime/dist/sqlite-read-model.cjs +346 -294
- package/templates/.agents/dashboard/packages/local-runtime/package.json +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/scripts/rebuild-sqlite-read-model.mjs +2 -1
- package/templates/.agents/dashboard/packages/local-runtime/scripts/validate-sqlite-read-model.mjs +42 -8
- package/templates/.agents/dashboard/packages/local-runtime/server.mjs +395 -341
- package/templates/.agents/dashboard/packages/local-runtime/src/active-codex-telemetry.test.ts +95 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/active-codex-telemetry.ts +102 -12
- package/templates/.agents/dashboard/packages/local-runtime/src/project-settings.test.ts +2 -3
- package/templates/.agents/dashboard/packages/local-runtime/src/project-settings.ts +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/server-board.test.ts +75 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/server-costs-routes.ts +10 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-lifecycle-diagnostics.ts +50 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-macro-population.test.ts +165 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-page-filters.ts +65 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-pages.test.ts +111 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-pages.ts +53 -63
- package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-runs-route.ts +19 -5
- package/templates/.agents/dashboard/packages/local-runtime/src/server-period-macro-metric.ts +11 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/server-read-projections.ts +16 -9
- package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-refresh.test.ts +46 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-synchronization.test.ts +10 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-synchronization.ts +4 -3
- package/templates/.agents/dashboard/packages/local-runtime/src/server.test.ts +43 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/server.ts +46 -11
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-filter-matrix.test.ts +188 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-summary-details.test.ts +85 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-summary-details.ts +147 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-first-fold-cache.ts +64 -54
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-macro-classification.test.ts +172 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-materialize-projections.ts +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-operations-projection.ts +2 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-operations-work-list.test.ts +7 -7
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-operations-work-list.ts +2 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-period-averages.ts +10 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-pricing-provenance.test.ts +39 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-agent-dimension.ts +18 -82
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-cached-cost-page.ts +169 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-developer.ts +205 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-entity-group.ts +13 -4
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-filtered-dimension.ts +22 -23
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-financial.ts +42 -209
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-model-dimension.ts +18 -4
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-provider-dimension.ts +9 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-summary.ts +76 -83
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-view-page.ts +25 -161
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-canonical.ts +20 -47
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-counts-every-root-execution-day-returns.test.ts +2 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-filesystem.ts +16 -16
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-multi-provider.test.ts +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-rebuild.ts +47 -22
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-schema.ts +3 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model.test.ts +11 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-rebuild-result.ts +15 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-schema-base-views.ts +4 -4
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-schema-dashboard-views.ts +15 -56
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-schema-macro-classification.ts +48 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-summary-cursor.ts +15 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-token-active-allocation.ts +46 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-work-stages.ts +60 -0
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-history.mjs +5 -1
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-launch-claims.test.mjs +7 -1
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-launch-page.mjs +17 -2
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-ownership.mjs +65 -0
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-ownership.test.mjs +72 -0
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-processes.mjs +32 -9
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard.mjs +39 -45
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard.test.mjs +5 -2
- package/templates/.agents/dashboard/packages/ui/package.json +1 -1
- package/templates/.agents/dashboard/tests/e2e/package.json +1 -1
- package/templates/.agents/dashboard/tests/e2e/specs/dashboard-performance-matrix.spec.ts +1 -18
- package/templates/.agents/dashboard/tests/e2e/specs/export-row-identity.spec.ts +20 -0
- package/templates/.agents/dashboard/tests/e2e/specs/export-row-identity.ts +20 -0
- package/templates/.agents/design/.zaip-managed.json +105 -69
- package/templates/.agents/design/apps/catalog/dist/assets/index-0W0Gj_Gs.css +1 -0
- package/templates/.agents/design/apps/catalog/dist/assets/index-32GZO95T.js +72 -0
- package/templates/.agents/design/apps/catalog/dist/assets/{index-D_lfqoyx.js → index-BP8IxOxt.js} +3 -3
- package/templates/.agents/design/apps/catalog/dist/assets/index-D1JaPXfV.css +1 -0
- package/templates/.agents/design/apps/catalog/dist/assets/index-D2miO4-O.js +72 -0
- package/templates/.agents/design/apps/catalog/dist/assets/{index-BOjCcUaU.js → index-QJsgr9Ht.js} +3 -3
- package/templates/.agents/design/apps/catalog/dist/assets/{index-CqtYXZfV.js → index-mvD5mwcC.js} +3 -3
- package/templates/.agents/design/apps/catalog/dist/index.html +2 -2
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/CatalogShell-BJ8b4xZr.js +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{Color-6AOWCN3U-Cm-yJJz_.js → Color-6AOWCN3U-CQLHzznn.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/Components.stories-kxWwSKin.js +146 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/DashboardFilters.stories-Chm_dXV7.js +9 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/DashboardFiltersSpecimen-9CaCbGIZ.js +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/DesignSystem.stories-ED52wFjY.js +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{DocsRenderer-JROSPFPF-Belk4jRr.js → DocsRenderer-JROSPFPF-BcLgM80v.js} +4 -4
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/Primitives-DV6Bpudf.js +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{WithTooltip-7X4HQR7L-DoPvjkS1.js → WithTooltip-7X4HQR7L-BKNiAz_E.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/WorkspaceStatus.stories-BL19HGOo.js +17 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/WorkspaceStatusSpecimen-DQnSS6s9.js +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{chunk-DRQKCCAG-B1itKXEN.js → chunk-DRQKCCAG-DZBcXL-p.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{chunk-W22LQPXL-C-Eb5SPY.js → chunk-W22LQPXL-CF3y2mfo.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{components-DnyKLwhj.js → components-BVjxMRGq.js} +5 -5
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/formatter-L2YTDE3Q-Do9sjqiW.js +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/iframe-0W0Gj_Gs.css +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{iframe-DcXBsFPz.js → iframe-CTWGZcEe.js} +4 -4
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{react-18-CRM89QRf.js → react-18-B9_a4mHb.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/react-NrUxok8K.js +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{syntaxhighlighter-YFXUGROL-B03jQGTF.js → syntaxhighlighter-YFXUGROL-F_p8E2xc.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{theming-4ZyufAga.js → theming-fbSD9ZLF.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/iframe.html +2 -2
- package/templates/.agents/design/apps/catalog/dist/storybook/index.json +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/sb-addons/a11y-2/manager-bundle.js +3 -3
- package/templates/.agents/design/apps/catalog/dist/storybook/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js +3 -3
- package/templates/.agents/design/apps/catalog/package.json +1 -1
- package/templates/.agents/design/apps/catalog/src/components/DashboardFiltersSpecimen.tsx +61 -0
- package/templates/.agents/design/apps/catalog/src/components/Primitives.tsx +24 -0
- package/templates/.agents/design/apps/catalog/src/components/StackVersionFieldSpecimen.tsx +70 -0
- package/templates/.agents/design/apps/catalog/src/components/WorkspaceStatusSpecimen.tsx +42 -0
- package/templates/.agents/design/apps/catalog/src/design-contract.test.ts +27 -13
- package/templates/.agents/design/apps/catalog/src/pages/ComponentsPage.tsx +52 -0
- package/templates/.agents/design/apps/catalog/src/pages/DesignSystemPage.tsx +15 -1
- package/templates/.agents/design/apps/catalog/src/stories/Components.stories.tsx +32 -0
- package/templates/.agents/design/apps/catalog/src/stories/DashboardFilters.stories.tsx +7 -0
- package/templates/.agents/design/apps/catalog/src/stories/WorkspaceStatus.stories.tsx +12 -0
- package/templates/.agents/design/apps/catalog/src/styles/components.css +84 -3
- package/templates/.agents/design/apps/catalog/src/styles/stack-version-field.css +17 -0
- package/templates/.agents/design/apps/catalog/src/styles.css +2 -0
- package/templates/.agents/design/packages/local-runtime/package.json +1 -1
- package/templates/.agents/design/tokens.json +32 -0
- package/templates/.agents/requirements/autonomous-assurance.md +1 -1
- package/templates/.agents/requirements/cloud-hostinger-autonomy.md +1 -1
- package/templates/.agents/requirements/comparative-audit.md +1 -1
- package/templates/.agents/requirements/context-engine.md +1 -1
- package/templates/.agents/requirements/cost-observability.md +1 -1
- package/templates/.agents/requirements/dashboard-launch.md +1 -1
- package/templates/.agents/requirements/data-export.md +1 -1
- package/templates/.agents/requirements/design-system.md +1 -1
- package/templates/.agents/requirements/execution-engine.md +1 -1
- package/templates/.agents/requirements/kanban-dashboard.md +1 -1
- package/templates/.agents/requirements/model-orchestration.md +1 -1
- package/templates/.agents/requirements/public-distribution.md +9 -3
- package/templates/.agents/requirements/software-architecture.md +1 -1
- package/templates/.agents/requirements/strategic-improvements.md +1 -1
- package/templates/.agents/requirements/work-lifecycle.md +1 -1
- package/templates/.agents/requirements/zaip-strategic-95.md +1 -1
- package/templates/.agents/rules/autonomy-decision.md +1 -0
- package/templates/.agents/rules/workflow.md +2 -2
- package/templates/.agents/runtime/VERSION +1 -1
- package/templates/.agents/runtime/bin/zaip.mjs +27 -26
- package/templates/.agents/runtime/checksums.sha256 +5 -5
- package/templates/.agents/runtime/manifest.json +1 -1
- package/templates/.agents/runtime/provenance.json +4 -4
- package/templates/.agents/runtime/sbom.cdx.json +1 -1
- package/templates/.agents/skills/zaip-skill-execution/SKILL.md +13 -0
- package/templates/.agents/skills/zaip-skill-execution/references/autonomous-continuation.md +17 -0
- package/templates/.agents/skills/zaip-skill-execution/references/correction-cycle.md +2 -2
- package/templates/.agents/skills/zaip-skill-github-deploy/SKILL.md +9 -6
- package/templates/.agents/skills/zaip-skill-github-deploy/agents/openai.yaml +1 -1
- package/templates/.agents/skills/zaip-skill-github-deploy/references/deployment-workflow.md +11 -9
- package/templates/.agents/skills/zaip-skill-github-deploy/references/release-identity.md +2 -2
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/consumer-release-preparation.mjs +1 -2
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/consumer-release-preparation.test.mjs +9 -1
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/github-deploy-contract.test.mjs +23 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/preflight.mjs +2 -6
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/preflight.test.mjs +15 -1
- package/templates/.agents/skills/zaip-skill-move-prd/SKILL.md +4 -0
- package/templates/.agents/skills/zaip-skill-move-spec/SKILL.md +4 -0
- package/templates/.agents/skills/zaip-skill-prd/SKILL.md +3 -3
- package/templates/.agents/skills/zaip-skill-release-qualification/SKILL.md +11 -8
- package/templates/.agents/skills/zaip-skill-release-qualification/references/local-preparation.md +13 -12
- package/templates/.agents/skills/zaip-skill-setup/SKILL.md +17 -2
- package/templates/.agents/skills/zaip-skill-setup/agents/openai.yaml +1 -1
- package/templates/.agents/skills/zaip-skill-spec/SKILL.md +2 -2
- package/templates/.agents/zaip-aios/VERSION +1 -1
- package/templates/template-manifest.json +445 -245
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-BpsAFy0g.js +0 -3
- package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor--iPcnZdx.js +0 -68
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-Cmlx8OYH.css +0 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-DfdlGa7c.js +0 -2
- package/templates/.agents/design/apps/catalog/dist/assets/index-BEmIE7WE.css +0 -1
- package/templates/.agents/design/apps/catalog/dist/assets/index-BJV597iq.js +0 -72
- package/templates/.agents/design/apps/catalog/dist/assets/index-B_WhrCZe.js +0 -72
- package/templates/.agents/design/apps/catalog/dist/assets/index-CqqYWY2f.js +0 -9
- package/templates/.agents/design/apps/catalog/dist/assets/index-D9pj7Jlf.js +0 -9
- package/templates/.agents/design/apps/catalog/dist/assets/index-i_PO2k9R.js +0 -9
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/CatalogShell-Cstn1UwA.js +0 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/Components.stories-D1WopB2L.js +0 -137
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/DesignSystem.stories-DQ9PJ3N3.js +0 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/formatter-L2YTDE3Q-D0OSgxWz.js +0 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/iframe-BEmIE7WE.css +0 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/react-C3tkVMIp.js +0 -1
|
@@ -124,7 +124,7 @@ describe("Cost Monitor V2", () => {
|
|
|
124
124
|
}),
|
|
125
125
|
);
|
|
126
126
|
});
|
|
127
|
-
it("keeps
|
|
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:
|
|
143
|
-
duration_provenance: "
|
|
144
|
-
estimation_basis:
|
|
142
|
+
duration_ms: 60_000,
|
|
143
|
+
duration_provenance: "legacy_inferred",
|
|
144
|
+
estimation_basis: null,
|
|
145
145
|
}),
|
|
146
146
|
);
|
|
147
147
|
});
|
|
148
|
-
it("
|
|
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
|
|
166
|
-
const tokenOnlyDuration = rows.find((row) => row.run_id === "TOKEN-ONLY")?.duration_ms
|
|
167
|
-
expect(rootDuration).
|
|
168
|
-
expect(tokenOnlyDuration).
|
|
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: "
|
|
172
|
-
estimation_basis:
|
|
170
|
+
duration_provenance: "unavailable",
|
|
171
|
+
estimation_basis: null,
|
|
173
172
|
});
|
|
174
173
|
});
|
|
175
|
-
it("
|
|
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
|
-
|
|
183
|
+
40_000,
|
|
185
184
|
);
|
|
186
185
|
expect(projection.groups.daily.reduce((sum, row) => sum + row.duration.known_sum, 0)).toBe(
|
|
187
|
-
|
|
186
|
+
40_000,
|
|
188
187
|
);
|
|
189
188
|
});
|
|
190
|
-
it("
|
|
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
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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("
|
|
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:
|
|
228
|
-
duration_provenance: "
|
|
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:
|
|
235
|
-
duration_provenance: "
|
|
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({
|
|
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
|
|
301
|
-
//
|
|
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:
|
|
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:
|
|
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:
|
|
449
|
-
duration_provenance: "
|
|
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
|
});
|
package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-projection.ts
CHANGED
|
@@ -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
|
|
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
|
-
//
|
|
161
|
-
//
|
|
162
|
-
|
|
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
|
|
243
|
-
specs: repriceMacros(operations.specs, tableRuns
|
|
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 ===
|
|
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
|
-
|
|
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[] {
|
|
@@ -6,6 +6,52 @@ import {
|
|
|
6
6
|
} from "./build-cost-summary-projection.js";
|
|
7
7
|
|
|
8
8
|
describe("buildCostSummaryProjection", () => {
|
|
9
|
+
it("keeps compact SQLite filter dimensions without hydrating Run rows", () => {
|
|
10
|
+
const operations = {
|
|
11
|
+
schema_version: 1,
|
|
12
|
+
layout_version: 2,
|
|
13
|
+
readonly: true,
|
|
14
|
+
source: ".agents/records",
|
|
15
|
+
filters: { from: null, to: null },
|
|
16
|
+
summary: { task_count: 2, overview_metrics: {}, usage: {} },
|
|
17
|
+
prds: [],
|
|
18
|
+
specs: [],
|
|
19
|
+
runs: [],
|
|
20
|
+
} as unknown as OperationsProjection;
|
|
21
|
+
const projection = buildCostSummaryProjection(
|
|
22
|
+
{
|
|
23
|
+
periods: { daily: {} },
|
|
24
|
+
filters_available: {
|
|
25
|
+
providers: ["anthropic", "openai"],
|
|
26
|
+
agents: ["zaip-agent-builder"],
|
|
27
|
+
models: ["claude-sonnet", "gpt-5"],
|
|
28
|
+
statuses: ["active", "completed"],
|
|
29
|
+
priorities: ["high", "low"],
|
|
30
|
+
risks: ["standard", "high"],
|
|
31
|
+
phases: ["planning", "execution"],
|
|
32
|
+
origins: ["conversation", "task"],
|
|
33
|
+
work_types: ["new", "rework"],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
operations,
|
|
37
|
+
"BRL",
|
|
38
|
+
null,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
expect(projection.runs).toEqual([]);
|
|
42
|
+
expect(projection.filters_available).toEqual({
|
|
43
|
+
providers: ["anthropic", "openai"],
|
|
44
|
+
agents: ["zaip-agent-builder"],
|
|
45
|
+
models: ["claude-sonnet", "gpt-5"],
|
|
46
|
+
statuses: ["active", "completed"],
|
|
47
|
+
priorities: ["high", "low"],
|
|
48
|
+
risks: ["standard", "high"],
|
|
49
|
+
phases: ["planning", "execution"],
|
|
50
|
+
origins: ["conversation", "task"],
|
|
51
|
+
work_types: ["new", "rework"],
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
9
55
|
it("retains factual USD from a compact SQLite summary with no Run rows", () => {
|
|
10
56
|
const operations = {
|
|
11
57
|
schema_version: 2,
|
|
@@ -496,7 +542,7 @@ describe("buildCostSummaryProjection", () => {
|
|
|
496
542
|
usd: null,
|
|
497
543
|
brl: null,
|
|
498
544
|
metrics: {
|
|
499
|
-
duration: { eligible_runs: 3, known_runs:
|
|
545
|
+
duration: { eligible_runs: 3, known_runs: 0, unknown_runs: 3 },
|
|
500
546
|
tokens: { eligible_runs: 3, known_runs: 2, unknown_runs: 1 },
|
|
501
547
|
usd: { eligible_runs: 3, known_runs: 2, unknown_runs: 1 },
|
|
502
548
|
brl: { eligible_runs: 3, known_runs: 2, unknown_runs: 1 },
|
|
@@ -574,184 +620,4 @@ describe("buildCostSummaryProjection", () => {
|
|
|
574
620
|
expect.arrayContaining([expect.objectContaining({ key: "unknown" })]),
|
|
575
621
|
);
|
|
576
622
|
});
|
|
577
|
-
|
|
578
|
-
it("uses the same token-backed effective duration in the fast daily projection", () => {
|
|
579
|
-
const summary: CostSummarySource = {
|
|
580
|
-
periods: {
|
|
581
|
-
daily: {
|
|
582
|
-
"2026-08-07": {
|
|
583
|
-
prds: 0,
|
|
584
|
-
specs: 0,
|
|
585
|
-
tasks: 0,
|
|
586
|
-
validations: 0,
|
|
587
|
-
evidences: 0,
|
|
588
|
-
runs: 1,
|
|
589
|
-
usage: {
|
|
590
|
-
total_tokens: { known_sum: 4_000_000, unknown: 0, complete: true, coverage_ratio: 1 },
|
|
591
|
-
cost: {
|
|
592
|
-
known_sum: 1,
|
|
593
|
-
unknown: 0,
|
|
594
|
-
complete: true,
|
|
595
|
-
coverage_ratio: 1,
|
|
596
|
-
currency: "BRL",
|
|
597
|
-
},
|
|
598
|
-
},
|
|
599
|
-
},
|
|
600
|
-
},
|
|
601
|
-
},
|
|
602
|
-
run_metrics: [
|
|
603
|
-
{
|
|
604
|
-
id: "TOKEN-ONLY",
|
|
605
|
-
started_at: "2026-08-07T12:00:00.000Z",
|
|
606
|
-
finished_at: null,
|
|
607
|
-
task_id: null,
|
|
608
|
-
phase: "execution",
|
|
609
|
-
parent_run_id: null,
|
|
610
|
-
status: null,
|
|
611
|
-
duration_ms: null,
|
|
612
|
-
total_tokens: 4_000_000,
|
|
613
|
-
cost: 1,
|
|
614
|
-
currency: "BRL",
|
|
615
|
-
events: 1,
|
|
616
|
-
},
|
|
617
|
-
],
|
|
618
|
-
};
|
|
619
|
-
const operations = {
|
|
620
|
-
filters: { from: "2026-08-07", to: "2026-08-07" },
|
|
621
|
-
summary: { task_count: 0 },
|
|
622
|
-
prds: [],
|
|
623
|
-
specs: [],
|
|
624
|
-
} as unknown as OperationsProjection;
|
|
625
|
-
const projection = buildCostSummaryProjection(summary, operations, "BRL", null);
|
|
626
|
-
expect(projection.groups.daily[0]?.duration).toMatchObject({
|
|
627
|
-
known_sum: 3_600_000,
|
|
628
|
-
unknown: 0,
|
|
629
|
-
complete: true,
|
|
630
|
-
});
|
|
631
|
-
});
|
|
632
|
-
|
|
633
|
-
it("enforces positive daily time from period tokens even without compact Run metrics", () => {
|
|
634
|
-
const summary: CostSummarySource = {
|
|
635
|
-
periods: {
|
|
636
|
-
daily: {
|
|
637
|
-
"2026-08-07": {
|
|
638
|
-
prds: 0,
|
|
639
|
-
specs: 0,
|
|
640
|
-
tasks: 0,
|
|
641
|
-
validations: 0,
|
|
642
|
-
evidences: 0,
|
|
643
|
-
runs: 1,
|
|
644
|
-
usage: {
|
|
645
|
-
total_tokens: { known_sum: 4_000_000, unknown: 0, complete: true, coverage_ratio: 1 },
|
|
646
|
-
cost: {
|
|
647
|
-
known_sum: 1,
|
|
648
|
-
unknown: 0,
|
|
649
|
-
complete: true,
|
|
650
|
-
coverage_ratio: 1,
|
|
651
|
-
currency: "BRL",
|
|
652
|
-
},
|
|
653
|
-
},
|
|
654
|
-
},
|
|
655
|
-
},
|
|
656
|
-
},
|
|
657
|
-
};
|
|
658
|
-
const operations = {
|
|
659
|
-
filters: { from: "2026-08-07", to: "2026-08-07" },
|
|
660
|
-
summary: { task_count: 0 },
|
|
661
|
-
prds: [],
|
|
662
|
-
specs: [],
|
|
663
|
-
} as unknown as OperationsProjection;
|
|
664
|
-
const projection = buildCostSummaryProjection(summary, operations, "BRL", null);
|
|
665
|
-
expect(projection.groups.daily[0]).toMatchObject({
|
|
666
|
-
total_tokens: 4_000_000,
|
|
667
|
-
duration_ms: 3_600_000,
|
|
668
|
-
duration: { known_sum: 3_600_000, unknown: 0, complete: true },
|
|
669
|
-
});
|
|
670
|
-
});
|
|
671
|
-
|
|
672
|
-
it("uses the canonical root duration and excludes child and conversation duration", () => {
|
|
673
|
-
const summary: CostSummarySource = {
|
|
674
|
-
periods: {
|
|
675
|
-
daily: {
|
|
676
|
-
"2026-07-24": {
|
|
677
|
-
prds: 0,
|
|
678
|
-
specs: 0,
|
|
679
|
-
tasks: 0,
|
|
680
|
-
validations: 0,
|
|
681
|
-
evidences: 0,
|
|
682
|
-
runs: 3,
|
|
683
|
-
usage: {
|
|
684
|
-
total_tokens: { known_sum: 3, unknown: 0, complete: true, coverage_ratio: 1 },
|
|
685
|
-
cost: {
|
|
686
|
-
known_sum: 3,
|
|
687
|
-
unknown: 0,
|
|
688
|
-
complete: true,
|
|
689
|
-
coverage_ratio: 1,
|
|
690
|
-
currency: "BRL",
|
|
691
|
-
},
|
|
692
|
-
},
|
|
693
|
-
duration: { known_sum: 60_109_200, unknown: 0, complete: true, coverage_ratio: 1 },
|
|
694
|
-
},
|
|
695
|
-
},
|
|
696
|
-
},
|
|
697
|
-
run_metrics: [
|
|
698
|
-
{
|
|
699
|
-
id: "ROOT",
|
|
700
|
-
started_at: "2026-07-24T20:00:00.000Z",
|
|
701
|
-
finished_at: null,
|
|
702
|
-
task_id: null,
|
|
703
|
-
phase: "execution",
|
|
704
|
-
parent_run_id: null,
|
|
705
|
-
status: null,
|
|
706
|
-
duration_ms: 23_241_600,
|
|
707
|
-
total_tokens: 1,
|
|
708
|
-
cost: 1,
|
|
709
|
-
currency: "BRL",
|
|
710
|
-
events: 1,
|
|
711
|
-
},
|
|
712
|
-
{
|
|
713
|
-
id: "CHILD",
|
|
714
|
-
started_at: "2026-07-24T20:01:00.000Z",
|
|
715
|
-
finished_at: null,
|
|
716
|
-
task_id: null,
|
|
717
|
-
phase: "execution",
|
|
718
|
-
parent_run_id: "ROOT",
|
|
719
|
-
status: null,
|
|
720
|
-
duration_ms: 36_867_600,
|
|
721
|
-
total_tokens: 1,
|
|
722
|
-
cost: 1,
|
|
723
|
-
currency: "BRL",
|
|
724
|
-
events: 1,
|
|
725
|
-
},
|
|
726
|
-
{
|
|
727
|
-
id: "CONVERSATION",
|
|
728
|
-
started_at: "2026-07-24T20:02:00.000Z",
|
|
729
|
-
finished_at: null,
|
|
730
|
-
task_id: null,
|
|
731
|
-
phase: "conversation",
|
|
732
|
-
parent_run_id: null,
|
|
733
|
-
status: null,
|
|
734
|
-
duration_ms: 1_000,
|
|
735
|
-
total_tokens: 1,
|
|
736
|
-
cost: 1,
|
|
737
|
-
currency: "BRL",
|
|
738
|
-
events: 1,
|
|
739
|
-
},
|
|
740
|
-
],
|
|
741
|
-
canonical_daily_duration_ms: { "2026-07-24": 23_241_600 },
|
|
742
|
-
};
|
|
743
|
-
const operations = {
|
|
744
|
-
filters: { from: null, to: null },
|
|
745
|
-
summary: { task_count: 0 },
|
|
746
|
-
prds: [],
|
|
747
|
-
specs: [],
|
|
748
|
-
} as unknown as OperationsProjection;
|
|
749
|
-
const row = buildCostSummaryProjection(summary, operations, "BRL", null).groups.daily.find(
|
|
750
|
-
(value) => value.key === "2026-07-24",
|
|
751
|
-
)!;
|
|
752
|
-
|
|
753
|
-
expect(row.duration.known_sum).toBe(23_241_600);
|
|
754
|
-
expect(row.duration.coverage_ratio).toBe(1);
|
|
755
|
-
expect(row.run_count).toBe(3);
|
|
756
|
-
});
|
|
757
623
|
});
|