@zaip-ai/cli 3.2.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/services/adapters.d.ts +1 -1
- package/dist/services/adapters.d.ts.map +1 -1
- package/dist/services/adapters.js +5 -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.js +24 -8
- package/dist/services/logger.js.map +1 -1
- package/dist/services/logger.test.js +33 -6
- 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/README-ENG.md +2 -1
- package/templates/.agents/README.md +2 -1
- package/templates/.agents/config/agents/catalog.yaml +1 -0
- package/templates/.agents/config/agents/discovery.json +2 -2
- package/templates/.agents/config/clients/codex/agents/zaip-agent-builder.toml +2 -2
- package/templates/.agents/dashboard/.zaip-managed.json +278 -126
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{CostCalculationGuidePage-CEDZjl4V.js → CostCalculationGuidePage-C5NgEcVh.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{DashboardHelpDialog-BzaUTZDx.js → DashboardHelpDialog-CCMVnkkI.js} +4 -3
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{PricingSettingsDialog-21cCJik-.js → PricingSettingsDialog-CGYcJ5EB.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{ProjectSettingsPage-BAvLPAee.js → ProjectSettingsPage-DVCPPV75.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{TraceabilityWorkspace-wqW52uCx.js → TraceabilityWorkspace-CqK3Psfy.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/{dashboard-localization-BkAm8-h4.js → dashboard-localization-jvdDfNKs.js} +2 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{icons-vendor-DEmo6Tn2.js → icons-vendor-x8xxL9yW.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-Cl5EWx8R.js +2 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-Cwylbh_N.css +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{react-vendor-CadYsm83.js → react-vendor-CNOXIJHN.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{traceability-BzKK8kK3.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/WorkspaceStatus.test.tsx +33 -0
- package/templates/.agents/dashboard/apps/frontend/src/WorkspaceStatus.tsx +58 -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/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 +33 -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/OperationsOverview.helpers.tsx +4 -1
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.test.ts +5 -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/export/xlsx-runtime-e2e.test.ts +55 -31
- 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 +406 -332
- package/templates/.agents/dashboard/packages/local-runtime/dist/sqlite-read-model.cjs +352 -280
- 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 +4 -2
- package/templates/.agents/dashboard/packages/local-runtime/server.mjs +406 -332
- 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/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.test.ts +19 -0
- 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 +19 -12
- 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.test.ts +94 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-first-fold-cache.ts +96 -55
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-force-canonical.test.ts +58 -3
- 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 +4 -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-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 +18 -45
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-counts-every-root-execution-day-returns.test.ts +15 -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-keeps-orphan-telemetry-out-kanban-without.test.ts +2 -1
- 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 +16 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model.test.ts +13 -1
- 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 +19 -42
- 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/scripts/qualify-macro-overview.mjs +50 -0
- 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 +82 -74
- 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-BOjCcUaU.js → index-QJsgr9Ht.js} +3 -3
- package/templates/.agents/design/apps/catalog/dist/index.html +2 -2
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/CatalogShell-CvaciY0C.js +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{Color-6AOWCN3U-Cm-yJJz_.js → Color-6AOWCN3U-DwBV1A1Y.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/Components.stories-3dqK5g3e.js +142 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/DesignSystem.stories-2OCgtT0I.js +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{DocsRenderer-JROSPFPF-Belk4jRr.js → DocsRenderer-JROSPFPF-CODg0rSl.js} +4 -4
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/Primitives-BmeKjJW4.js +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{WithTooltip-7X4HQR7L-DoPvjkS1.js → WithTooltip-7X4HQR7L-C5MI-3uZ.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/WorkspaceStatus.stories-Tb_iQqVK.js +17 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/WorkspaceStatusSpecimen-CD54pw0-.js +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{chunk-DRQKCCAG-B1itKXEN.js → chunk-DRQKCCAG-KSn75jcy.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{chunk-W22LQPXL-C-Eb5SPY.js → chunk-W22LQPXL-C4LS1Thf.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{components-DnyKLwhj.js → components-DV1BRgMY.js} +5 -5
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/formatter-L2YTDE3Q-BU_68im1.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-CBbPFx5G.js} +4 -4
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{react-18-CRM89QRf.js → react-18-C9IPGXtb.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/react-CEv2qkJT.js +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{syntaxhighlighter-YFXUGROL-B03jQGTF.js → syntaxhighlighter-YFXUGROL-ZgDQjyWI.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{theming-4ZyufAga.js → theming-Cx9-gH6l.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/docs-1/manager-bundle.js +4 -4
- package/templates/.agents/design/apps/catalog/dist/storybook/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js +60 -60
- 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/WorkspaceStatusSpecimen.tsx +26 -0
- package/templates/.agents/design/apps/catalog/src/design-contract.test.ts +27 -13
- package/templates/.agents/design/apps/catalog/src/pages/ComponentsPage.tsx +38 -0
- package/templates/.agents/design/apps/catalog/src/pages/DesignSystemPage.tsx +15 -1
- package/templates/.agents/design/apps/catalog/src/stories/Components.stories.tsx +18 -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 +9 -0
- package/templates/.agents/design/apps/catalog/src/styles/components.css +83 -2
- 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 +18 -4
- 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 +1 -1
- package/templates/.agents/runtime/VERSION +1 -1
- package/templates/.agents/runtime/bin/zaip.mjs +28 -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-aios/SKILL.md +0 -1
- package/templates/.agents/skills/zaip-skill-author-skills/scripts/audit-skill-catalog.mjs +1 -0
- package/templates/.agents/skills/zaip-skill-config/SKILL.md +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 +4 -2
- package/templates/.agents/skills/zaip-skill-github-deploy/references/deployment-workflow.md +4 -2
- package/templates/.agents/skills/zaip-skill-github-deploy/references/release-identity.md +2 -2
- package/templates/.agents/skills/zaip-skill-github-setup/SKILL.md +2 -2
- 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 +15 -8
- package/templates/.agents/skills/zaip-skill-release-qualification/references/local-preparation.md +13 -12
- package/templates/.agents/skills/zaip-skill-setup/SKILL.md +50 -13
- package/templates/.agents/skills/zaip-skill-setup/agents/openai.yaml +2 -2
- package/templates/.agents/skills/zaip-skill-spec/SKILL.md +2 -2
- package/templates/.agents/skills/zaip-skill-update-version-doc/SKILL.md +39 -0
- package/templates/.agents/skills/zaip-skill-update-version-doc/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-update-version-doc/scripts/update-version-doc.mjs +21 -0
- package/templates/.agents/skills/zaip-skill-update-version-doc/scripts/update-version-doc.test.mjs +32 -0
- package/templates/.agents/zaip-aios/README.md +2 -1
- package/templates/.agents/zaip-aios/VERSION +1 -1
- package/templates/.agents/zaip-aios/guides/20-instalacao-detalhada.md +7 -3
- package/templates/template-manifest.json +436 -256
- package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-06__WZco.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-DqZKJS8y.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-CqtYXZfV.js +0 -72
- 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
|
@@ -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
|
});
|
package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-projection.ts
CHANGED
|
@@ -5,19 +5,16 @@ import type {
|
|
|
5
5
|
UsageProjection,
|
|
6
6
|
} from "@zaip-ai/dashboard-operations/contracts";
|
|
7
7
|
import {
|
|
8
|
-
canonicalAllTimeDurationMs,
|
|
9
8
|
isAfterLegacyEffortCutoff,
|
|
10
9
|
LEGACY_EFFORT_DAILY_MS,
|
|
11
10
|
LEGACY_EFFORT_SNAPSHOT,
|
|
12
11
|
saoPauloPeriodKey,
|
|
13
12
|
} from "@zaip-ai/dashboard-operations/contracts";
|
|
14
13
|
import {
|
|
15
|
-
normalizeTokenBackedDailyDuration,
|
|
16
14
|
hybridDailyDuration as sharedHybridDailyDuration,
|
|
17
15
|
rootExecutionDurationByDay as sharedRootExecutionDurationByDay,
|
|
18
16
|
} from "@zaip-ai/dashboard-operations/server";
|
|
19
17
|
import type { CostGroupRow, CostMonitorProjection } from "../contracts.js";
|
|
20
|
-
import { estimatedDurationMs, TOKEN_DURATION_ESTIMATE_BASIS } from "../duration-estimate.js";
|
|
21
18
|
import { buildCostMonitorProjection, usageForRuns } from "./build-cost-monitor-projection.js";
|
|
22
19
|
|
|
23
20
|
/** Fast Cost Monitor first fold backed only by the durable lifecycle summary. */
|
|
@@ -69,9 +66,8 @@ export function buildCostSummaryProjection(
|
|
|
69
66
|
for (const day of Object.keys(LEGACY_EFFORT_DAILY_MS))
|
|
70
67
|
if (!dailyPeriods.has(day)) dailyPeriods.set(day, emptyPeriodSummary());
|
|
71
68
|
}
|
|
72
|
-
// Prefer
|
|
73
|
-
//
|
|
74
|
-
// back to root-only summary timing would turn a tokenized day into 0 s.
|
|
69
|
+
// Prefer persisted SQLite duration facts; legacy inputs retain their
|
|
70
|
+
// observed coverage without deriving elapsed time from token volume.
|
|
75
71
|
const periodEntries = [...dailyPeriods].filter(([key]) =>
|
|
76
72
|
inRange(key, operations.filters.from, operations.filters.to),
|
|
77
73
|
);
|
|
@@ -105,32 +101,13 @@ export function buildCostSummaryProjection(
|
|
|
105
101
|
if (hasRunMetrics) return factualDurationByDay.get(key) ?? emptyDuration();
|
|
106
102
|
return dailyDurationSource(key, period);
|
|
107
103
|
};
|
|
108
|
-
const durationBudget = periodEntries.reduce(
|
|
109
|
-
(total, [key, period]) => total + durationForDay(key, period).value.known_sum,
|
|
110
|
-
0,
|
|
111
|
-
);
|
|
112
|
-
const normalizedDurationBudget =
|
|
113
|
-
!hasRunMetrics &&
|
|
114
|
-
!hasCanonicalSqliteFacts &&
|
|
115
|
-
operations.filters.from === null &&
|
|
116
|
-
operations.filters.to === null
|
|
117
|
-
? canonicalAllTimeDurationMs(durationBudget)
|
|
118
|
-
: durationBudget;
|
|
119
104
|
const factualDailyRows = new Map(
|
|
120
105
|
(summary.daily_rows ?? []).map((row) => [row.key, row] as const),
|
|
121
106
|
);
|
|
122
107
|
const projectedDaily = periodEntries.map(([key, period]) =>
|
|
123
108
|
periodRow(key, period, fxRate, durationForDay(key, period), factualDailyRows.get(key)),
|
|
124
109
|
);
|
|
125
|
-
|
|
126
|
-
// correct São Paulo calendar day. Rebalancing it by token population would
|
|
127
|
-
// preserve only the all-time total while corrupting each daily row.
|
|
128
|
-
const daily = hasCanonicalSqliteFacts
|
|
129
|
-
? projectedDaily
|
|
130
|
-
: normalizeTokenBackedGroupBudget(
|
|
131
|
-
projectedDaily.map(ensureTokenBackedGroupDuration),
|
|
132
|
-
normalizedDurationBudget,
|
|
133
|
-
);
|
|
110
|
+
const daily = projectedDaily;
|
|
134
111
|
const runCount = daily.reduce((total, row) => total + row.run_count, 0);
|
|
135
112
|
const eventCount = daily.reduce((total, row) => total + row.event_count, 0);
|
|
136
113
|
// A completely unavailable population must not become a factual zero merely
|
|
@@ -199,15 +176,18 @@ export function buildCostSummaryProjection(
|
|
|
199
176
|
coverage,
|
|
200
177
|
},
|
|
201
178
|
filters_available: {
|
|
202
|
-
providers:
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
179
|
+
providers:
|
|
180
|
+
summary.filters_available?.providers ?? available?.filters_available.providers ?? [],
|
|
181
|
+
agents: summary.filters_available?.agents ?? available?.filters_available.agents ?? [],
|
|
182
|
+
models: summary.filters_available?.models ?? available?.filters_available.models ?? [],
|
|
183
|
+
statuses: summary.filters_available?.statuses ?? available?.filters_available.statuses ?? [],
|
|
184
|
+
priorities:
|
|
185
|
+
summary.filters_available?.priorities ?? available?.filters_available.priorities ?? [],
|
|
186
|
+
risks: summary.filters_available?.risks ?? available?.filters_available.risks ?? [],
|
|
187
|
+
phases: summary.filters_available?.phases ?? available?.filters_available.phases ?? [],
|
|
188
|
+
origins: summary.filters_available?.origins ?? available?.filters_available.origins ?? [],
|
|
189
|
+
work_types:
|
|
190
|
+
summary.filters_available?.work_types ?? available?.filters_available.work_types ?? [],
|
|
211
191
|
},
|
|
212
192
|
configured_agents: available?.configured_agents ?? [],
|
|
213
193
|
// Compact Run facts preserve total tokens and cost even though component
|
|
@@ -240,7 +220,32 @@ export function buildCostSummaryProjection(
|
|
|
240
220
|
}
|
|
241
221
|
|
|
242
222
|
function dailyDurationSource(key: string, period: PeriodSummary): DurationSource {
|
|
243
|
-
|
|
223
|
+
// Preserve the immutable historical aggregate shared with Operations.
|
|
224
|
+
// This fallback is used only without canonical SQLite or compact Run facts,
|
|
225
|
+
// and never allocates that historical aggregate to individual tokenized Runs.
|
|
226
|
+
if ((LEGACY_EFFORT_DAILY_MS[key as keyof typeof LEGACY_EFFORT_DAILY_MS] ?? 0) > 0)
|
|
227
|
+
return sharedHybridDailyDuration(key, period) as DurationSource;
|
|
228
|
+
// The legacy period bucket can carry a persisted factual duration. It is
|
|
229
|
+
// meaningful independently of Run transport and must survive this compact
|
|
230
|
+
// projection. Tokens and financial usage, however, are never timing data.
|
|
231
|
+
if (period.duration !== undefined) {
|
|
232
|
+
const knownRunCount = knownRuns(period.runs, period.duration.unknown);
|
|
233
|
+
return {
|
|
234
|
+
value: period.duration,
|
|
235
|
+
population: runPopulation(period.runs, knownRunCount),
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
// A bucket with Runs but no factual duration remains unavailable. In
|
|
239
|
+
// particular, do not convert a tokenized bucket into an hour or a zero.
|
|
240
|
+
return {
|
|
241
|
+
value: {
|
|
242
|
+
known_sum: 0,
|
|
243
|
+
unknown: period.runs,
|
|
244
|
+
complete: period.runs === 0,
|
|
245
|
+
coverage_ratio: period.runs === 0 ? 1 : 0,
|
|
246
|
+
},
|
|
247
|
+
population: runPopulation(period.runs, 0),
|
|
248
|
+
};
|
|
244
249
|
}
|
|
245
250
|
|
|
246
251
|
function emptyPeriodSummary(): PeriodSummary {
|
|
@@ -258,6 +263,8 @@ function emptyPeriodSummary(): PeriodSummary {
|
|
|
258
263
|
|
|
259
264
|
export interface CostSummarySource {
|
|
260
265
|
periods: { daily: Record<string, PeriodSummary> };
|
|
266
|
+
/** Distinct compact dimensions for first-fold filter controls. */
|
|
267
|
+
filters_available?: Partial<CostMonitorProjection["filters_available"]>;
|
|
261
268
|
/**
|
|
262
269
|
* SQLite's selected financial facts, retained for compact summaries where
|
|
263
270
|
* no Run transport is present. Values are factual and currency-specific.
|
|
@@ -300,7 +307,12 @@ export interface CostSummarySource {
|
|
|
300
307
|
duration_ms: number | null;
|
|
301
308
|
/** Raw factual invocation duration, never a token estimate. */
|
|
302
309
|
source_duration_ms?: number | null;
|
|
303
|
-
duration_provenance?:
|
|
310
|
+
duration_provenance?:
|
|
311
|
+
| "observed"
|
|
312
|
+
| "reconciled"
|
|
313
|
+
| "legacy_inferred"
|
|
314
|
+
| "estimated"
|
|
315
|
+
| "unavailable";
|
|
304
316
|
estimation_basis?: string | null;
|
|
305
317
|
duration_started_at?: string | null;
|
|
306
318
|
total_tokens: number | null;
|
|
@@ -402,63 +414,23 @@ function summaryRunProjection(
|
|
|
402
414
|
function effectiveSummaryRun(
|
|
403
415
|
run: NonNullable<CostSummarySource["run_metrics"]>[number],
|
|
404
416
|
): NonNullable<CostSummarySource["run_metrics"]>[number] {
|
|
405
|
-
|
|
417
|
+
const duration_ms = run.source_duration_ms ?? run.duration_ms;
|
|
418
|
+
const provenance =
|
|
419
|
+
run.source_duration_ms !== null && run.source_duration_ms !== undefined
|
|
420
|
+
? "observed"
|
|
421
|
+
: (run.duration_provenance ?? "legacy_inferred");
|
|
422
|
+
if (
|
|
423
|
+
typeof duration_ms === "number" &&
|
|
424
|
+
duration_ms >= 0 &&
|
|
425
|
+
(provenance === "observed" || provenance === "reconciled" || provenance === "legacy_inferred")
|
|
426
|
+
)
|
|
406
427
|
return {
|
|
407
428
|
...run,
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
429
|
+
duration_ms,
|
|
430
|
+
duration_provenance: provenance,
|
|
431
|
+
estimation_basis: null,
|
|
411
432
|
};
|
|
412
|
-
|
|
413
|
-
return duration_ms === null
|
|
414
|
-
? { ...run, duration_provenance: "unavailable", estimation_basis: null }
|
|
415
|
-
: {
|
|
416
|
-
...run,
|
|
417
|
-
duration_ms,
|
|
418
|
-
duration_provenance: "estimated",
|
|
419
|
-
estimation_basis: TOKEN_DURATION_ESTIMATE_BASIS,
|
|
420
|
-
};
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
function ensureTokenBackedGroupDuration(row: CostGroupRow): CostGroupRow {
|
|
424
|
-
if ((row.total_tokens ?? 0) <= 0 || (row.duration_ms ?? 0) > 0) return row;
|
|
425
|
-
const duration_ms = estimatedDurationMs(row.total_tokens);
|
|
426
|
-
if (duration_ms === null || duration_ms <= 0) return row;
|
|
427
|
-
const coverageCounts = row.coverage_counts;
|
|
428
|
-
return {
|
|
429
|
-
...row,
|
|
430
|
-
duration_ms,
|
|
431
|
-
duration: { known_sum: duration_ms, unknown: 0, complete: true, coverage_ratio: 1 },
|
|
432
|
-
...(coverageCounts === undefined
|
|
433
|
-
? {}
|
|
434
|
-
: {
|
|
435
|
-
coverage_counts: {
|
|
436
|
-
...coverageCounts,
|
|
437
|
-
...(coverageCounts.metrics === undefined
|
|
438
|
-
? {}
|
|
439
|
-
: {
|
|
440
|
-
metrics: {
|
|
441
|
-
...coverageCounts.metrics,
|
|
442
|
-
duration: {
|
|
443
|
-
eligible_runs: row.run_count,
|
|
444
|
-
known_runs: row.run_count,
|
|
445
|
-
unknown_runs: 0,
|
|
446
|
-
},
|
|
447
|
-
},
|
|
448
|
-
}),
|
|
449
|
-
},
|
|
450
|
-
}),
|
|
451
|
-
};
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
function normalizeTokenBackedGroupBudget(
|
|
455
|
-
rows: readonly CostGroupRow[],
|
|
456
|
-
budget: number,
|
|
457
|
-
): CostGroupRow[] {
|
|
458
|
-
return normalizeTokenBackedDailyDuration(rows, budget).map((row) => ({
|
|
459
|
-
...row,
|
|
460
|
-
duration_ms: row.duration.complete ? row.duration.known_sum : null,
|
|
461
|
-
}));
|
|
433
|
+
return { ...run, duration_ms: null, duration_provenance: "unavailable", estimation_basis: null };
|
|
462
434
|
}
|
|
463
435
|
|
|
464
436
|
interface KnownValue {
|
package/templates/.agents/dashboard/modules/cost-monitor/src/server/cost-monitor-unavailable.test.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { buildCostMonitorProjection } from "./build-cost-monitor-projection.js";
|
|
3
|
+
import {
|
|
4
|
+
fxRate,
|
|
5
|
+
gpt54Catalog,
|
|
6
|
+
metric,
|
|
7
|
+
operationsWithPricedRun,
|
|
8
|
+
usage,
|
|
9
|
+
} from "./build-cost-monitor-projection.test-fixtures.js";
|
|
10
|
+
|
|
11
|
+
describe("Factual duration and cost", () => {
|
|
12
|
+
it("retains token-bearing Runs when a cost cannot be established", () => {
|
|
13
|
+
const operations = operationsWithPricedRun();
|
|
14
|
+
const source = operations.runs[0];
|
|
15
|
+
if (!source) throw new Error("priced Run fixture is missing");
|
|
16
|
+
operations.runs = [
|
|
17
|
+
{
|
|
18
|
+
...source,
|
|
19
|
+
id: "RUN-UNKNOWN-MODEL",
|
|
20
|
+
model: "unknown-model",
|
|
21
|
+
effective_model: "unknown-model",
|
|
22
|
+
service_tier: null,
|
|
23
|
+
usage: usage(metric({ tokens: 1_000, input: 900, cached: 800, output: 100, events: 1 })),
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
...source,
|
|
27
|
+
id: "RUN-UNKNOWN-TOKENS",
|
|
28
|
+
model: "gpt-5.4",
|
|
29
|
+
effective_model: "gpt-5.4",
|
|
30
|
+
service_tier: null,
|
|
31
|
+
usage: usage(metric({ tokens: 1_000, input: 900, output: 100, events: 1 })),
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
const projection = buildCostMonitorProjection(operations, {
|
|
35
|
+
catalog: gpt54Catalog(),
|
|
36
|
+
fxRate: fxRate(5.5),
|
|
37
|
+
currency: "BRL",
|
|
38
|
+
});
|
|
39
|
+
expect(projection.runs).toHaveLength(2);
|
|
40
|
+
expect(projection.runs).toEqual(
|
|
41
|
+
expect.arrayContaining([
|
|
42
|
+
expect.objectContaining({
|
|
43
|
+
run_id: "RUN-UNKNOWN-MODEL",
|
|
44
|
+
total_tokens: 1_000,
|
|
45
|
+
estimated_brl: null,
|
|
46
|
+
}),
|
|
47
|
+
expect.objectContaining({
|
|
48
|
+
run_id: "RUN-UNKNOWN-TOKENS",
|
|
49
|
+
total_tokens: 1_000,
|
|
50
|
+
estimated_brl: null,
|
|
51
|
+
}),
|
|
52
|
+
]),
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
});
|