@zaip-ai/cli 1.0.7 → 1.0.8
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/README.md +6 -4
- package/dist/services/adapters.d.ts +1 -1
- package/dist/services/adapters.d.ts.map +1 -1
- package/dist/services/adapters.js +15 -5
- package/dist/services/adapters.js.map +1 -1
- package/dist/services/adapters.test.js +1 -1
- package/dist/services/agent-adapters.d.ts +9 -0
- package/dist/services/agent-adapters.d.ts.map +1 -1
- package/dist/services/agent-adapters.js +38 -3
- package/dist/services/agent-adapters.js.map +1 -1
- package/dist/services/agent-adapters.test.js +8 -1
- package/dist/services/agent-adapters.test.js.map +1 -1
- package/dist/services/codex-config-template.d.ts +2 -1
- package/dist/services/codex-config-template.d.ts.map +1 -1
- package/dist/services/codex-config-template.js +13 -2
- package/dist/services/codex-config-template.js.map +1 -1
- package/dist/services/codex-rules.d.ts +1 -1
- package/dist/services/codex-rules.d.ts.map +1 -1
- package/dist/services/codex-rules.js +31 -7
- package/dist/services/codex-rules.js.map +1 -1
- package/dist/services/codex-subagent-hook-template.d.ts +1 -1
- package/dist/services/codex-subagent-hook-template.d.ts.map +1 -1
- package/dist/services/codex-subagent-hook-template.js +4 -1
- package/dist/services/codex-subagent-hook-template.js.map +1 -1
- package/dist/services/doctor.d.ts.map +1 -1
- package/dist/services/doctor.js +3 -1
- package/dist/services/doctor.js.map +1 -1
- package/dist/services/global-codex-config.d.ts +6 -3
- package/dist/services/global-codex-config.d.ts.map +1 -1
- package/dist/services/global-codex-config.js +82 -13
- package/dist/services/global-codex-config.js.map +1 -1
- package/dist/services/global-codex-config.test.js +57 -10
- package/dist/services/global-codex-config.test.js.map +1 -1
- package/dist/services/install-agents-template.d.ts.map +1 -1
- package/dist/services/install-agents-template.js +15 -2
- package/dist/services/install-agents-template.js.map +1 -1
- package/dist/services/logger.js +1 -1
- package/dist/services/logger.js.map +1 -1
- package/dist/services/logger.test.js +3 -3
- package/dist/services/logger.test.js.map +1 -1
- package/dist/services/runtime-template.test.js +21 -5
- package/dist/services/runtime-template.test.js.map +1 -1
- package/dist/services/template-manifest.d.ts.map +1 -1
- package/dist/services/template-manifest.js +2 -0
- package/dist/services/template-manifest.js.map +1 -1
- package/package.json +1 -1
- package/templates/.agents/config/agents/catalog.yaml +310 -10
- package/templates/.agents/config/clients/codex/agents/zaip-agent-brand-strategist.toml +30 -0
- package/templates/.agents/config/clients/codex/agents/zaip-agent-designer.toml +5 -5
- package/templates/.agents/config/clients/codex/agents/zaip-agent-finalizer.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-general-operations.toml +30 -0
- package/templates/.agents/config/clients/codex/agents/zaip-agent-governance-compliance.toml +30 -0
- package/templates/.agents/config/clients/codex/agents/zaip-agent-growth-strategist.toml +30 -0
- package/templates/.agents/config/clients/codex/agents/zaip-agent-marketing-analyst.toml +8 -8
- package/templates/.agents/config/clients/codex/agents/zaip-agent-orchestrator.toml +5 -3
- package/templates/.agents/config/clients/codex/agents/zaip-agent-sales-specialist.toml +30 -0
- package/templates/.agents/config/project.yaml +1 -1
- package/templates/.agents/dashboard/.zaip-managed.json +659 -163
- package/templates/.agents/dashboard/DATA-DICTIONARY.md +2227 -0
- package/templates/.agents/dashboard/README.md +48 -97
- package/templates/.agents/dashboard/apps/frontend/dist/assets/CostCalculationGuidePage-Z60df2r-.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{DashboardHelpDialog-Cv-JcoxP.js → DashboardHelpDialog-Cs6dzDmW.js} +294 -109
- package/templates/.agents/dashboard/apps/frontend/dist/assets/PricingSettingsDialog-Coc6pA-1.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-QE1k9yZB.css +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-_Pf5DA_A.js +3 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/TraceabilityWorkspace-BVlz3DLZ.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/TraceabilityWorkspace-CaKwQP43.css +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-BZ5WdaMN.css +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-Cf9ctPVt.js +68 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{dashboard-localization-C98LGC-Q.js → dashboard-localization-CLJ0lT9v.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/icons-vendor-DFBuc_qp.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-8A4DcNXM.js +2 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-DK_enB5Z.css +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/react-vendor-CCQOHdVI.js +9 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/rolldown-runtime-D9-fqq9M.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/traceability-DFY7ZDlu.css +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/traceability-pC2_0J8x.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/index.html +9 -2
- package/templates/.agents/dashboard/apps/frontend/package.json +1 -1
- package/templates/.agents/dashboard/apps/frontend/src/App.tsx +952 -595
- package/templates/.agents/dashboard/apps/frontend/src/AppLoadingBoundary.tsx +48 -0
- package/templates/.agents/dashboard/apps/frontend/src/AppLoadingPanels.tsx +2 -0
- package/templates/.agents/dashboard/apps/frontend/src/AppOverlays.tsx +247 -0
- package/templates/.agents/dashboard/apps/frontend/src/AppRequestGuards.tsx +95 -0
- package/templates/.agents/dashboard/apps/frontend/src/AppSetupRoutes.tsx +87 -0
- package/templates/.agents/dashboard/apps/frontend/src/CostCalculationGuidePage.tsx +641 -0
- package/templates/.agents/dashboard/apps/frontend/src/DashboardAlternateContent.tsx +159 -0
- package/templates/.agents/dashboard/apps/frontend/src/DashboardCapabilityNav.tsx +13 -13
- package/templates/.agents/dashboard/apps/frontend/src/DashboardGlobalSettings.tsx +56 -0
- package/templates/.agents/dashboard/apps/frontend/src/ProjectSettingsPage.tsx +257 -313
- package/templates/.agents/dashboard/apps/frontend/src/ProjectStackEditor.tsx +149 -0
- package/templates/.agents/dashboard/apps/frontend/src/TraceabilityWorkspace.test.ts +35 -0
- package/templates/.agents/dashboard/apps/frontend/src/TraceabilityWorkspace.tsx +111 -12
- package/templates/.agents/dashboard/apps/frontend/src/app-preferences.ts +15 -0
- package/templates/.agents/dashboard/apps/frontend/src/app-session-token.ts +20 -0
- package/templates/.agents/dashboard/apps/frontend/src/cost-calculation-guide.css +267 -0
- package/templates/.agents/dashboard/apps/frontend/src/cost-calculation-guide.test.ts +69 -0
- package/templates/.agents/dashboard/apps/frontend/src/cost-period-refresh.test.ts +70 -0
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-api.test.ts +111 -0
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-api.ts +432 -13
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-localization.ts +1 -1
- package/templates/.agents/dashboard/apps/frontend/src/main.tsx +1 -0
- package/templates/.agents/dashboard/apps/frontend/src/operations-detail-hydration.test.ts +55 -0
- package/templates/.agents/dashboard/apps/frontend/src/operations-detail-hydration.ts +36 -0
- package/templates/.agents/dashboard/apps/frontend/src/operations-entity-page-projection.test.ts +126 -0
- package/templates/.agents/dashboard/apps/frontend/src/operations-entity-page-projection.ts +181 -0
- package/templates/.agents/dashboard/apps/frontend/src/operations-period-contract.test.ts +138 -0
- package/templates/.agents/dashboard/apps/frontend/src/operations-period-render.test.ts +105 -0
- package/templates/.agents/dashboard/apps/frontend/src/operations-period.test.ts +6 -3
- package/templates/.agents/dashboard/apps/frontend/src/operations-period.ts +9 -5
- package/templates/.agents/dashboard/apps/frontend/src/overview-status-page.test.ts +24 -0
- package/templates/.agents/dashboard/apps/frontend/src/period-transition-overlay.css +44 -0
- package/templates/.agents/dashboard/apps/frontend/src/project-settings-model.ts +121 -62
- package/templates/.agents/dashboard/apps/frontend/src/project-settings-page.css +471 -2
- package/templates/.agents/dashboard/apps/frontend/src/project-settings.test.ts +84 -17
- package/templates/.agents/dashboard/apps/frontend/src/snapshot-banner-semantics.test.ts +44 -0
- package/templates/.agents/dashboard/apps/frontend/src/snapshot-coherence.test.ts +196 -39
- package/templates/.agents/dashboard/apps/frontend/src/snapshot-notice.ts +15 -0
- package/templates/.agents/dashboard/apps/frontend/src/sqlite-cost-adapters.ts +26 -0
- package/templates/.agents/dashboard/apps/frontend/src/styles.css +14 -2
- package/templates/.agents/dashboard/apps/frontend/src/traceability-workspace.css +38 -2
- package/templates/.agents/dashboard/apps/frontend/src/use-app-cost-loaders.test.ts +187 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-app-cost-loaders.ts +190 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-app-effects.ts +121 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-app-operations-pages.ts +398 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-app-trace-documents.ts +141 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-idle-cost-prefetch.ts +45 -0
- package/templates/.agents/dashboard/apps/frontend/src/work-list-pagination.test.ts +46 -0
- package/templates/.agents/dashboard/apps/frontend/src/work-list-pagination.ts +37 -0
- package/templates/.agents/dashboard/apps/frontend/vite.config.ts +55 -5
- package/templates/.agents/dashboard/modules/cost-monitor/package.json +1 -1
- package/templates/.agents/dashboard/modules/cost-monitor/src/contracts.ts +47 -6
- package/templates/.agents/dashboard/modules/cost-monitor/src/duration-estimate.ts +13 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CompactLifecycleCostTable.test.ts +64 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CompactLifecycleCostTable.tsx +275 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostCharts.test.ts +100 -15
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostCharts.tsx +131 -40
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostFilters.tsx +137 -19
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostModelsAuditTable.test.ts +2 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostModelsAuditTable.tsx +13 -10
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorContent.tsx +303 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.test.ts +226 -6
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.tsx +479 -402
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostSummary.tsx +5 -13
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables.test.ts +312 -72
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables.tsx +373 -321
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/MacroCostTable.test.ts +17 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/MacroCostTable.tsx +25 -6
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-copy.ts +0 -2
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-page-helpers.ts +17 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-responsive.css +6 -3
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-row-filters.ts +123 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-summary.ts +8 -3
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-views.ts +32 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor.css +52 -14
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-table-presentation.ts +121 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/index.ts +3 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/period-cost-groups.test.ts +68 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/period-cost-groups.ts +32 -5
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-compact-cost-page.ts +108 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-cost-group-page.test.ts +12 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-cost-group-page.ts +60 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-cost-run-page.ts +106 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/aggregate.test.ts +2 -2
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/aggregate.ts +5 -3
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-pricing-fallback.test.ts +53 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-projection.basics.test.ts +34 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-projection.test.ts +168 -137
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-projection.ts +188 -29
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-projection.test.ts +956 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-projection.ts +775 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-terminal-day.test.ts +95 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/index.ts +1 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/refactor-map-xr9l.json +61 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/task-cost-groups.test.ts +41 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/task-cost-groups.ts +55 -11
- package/templates/.agents/dashboard/modules/operations/package.json +2 -1
- package/templates/.agents/dashboard/modules/operations/src/contracts.ts +182 -0
- package/templates/.agents/dashboard/modules/operations/src/duration-population.test.ts +63 -1
- package/templates/.agents/dashboard/modules/operations/src/duration-population.ts +60 -5
- package/templates/.agents/dashboard/modules/operations/src/react/EntityDetailsDialog.tsx +14 -3
- package/templates/.agents/dashboard/modules/operations/src/react/EntityTables.test.ts +44 -1
- package/templates/.agents/dashboard/modules/operations/src/react/EntityTables.tsx +325 -18
- package/templates/.agents/dashboard/modules/operations/src/react/MacroPlanningDialog.tsx +1 -0
- package/templates/.agents/dashboard/modules/operations/src/react/OperationDateFilters.test.ts +9 -5
- package/templates/.agents/dashboard/modules/operations/src/react/OperationDateFilters.tsx +2 -2
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsMainContent.tsx +168 -0
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.helpers.tsx +95 -6
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.test.ts +365 -14
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.tsx +532 -131
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsPage.tsx +314 -358
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsPageNavigation.tsx +68 -0
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsPageOverview.tsx +169 -0
- package/templates/.agents/dashboard/modules/operations/src/react/PeriodSummaryTable.tsx +51 -8
- package/templates/.agents/dashboard/modules/operations/src/react/PrdDocumentDialog.test.tsx +32 -0
- package/templates/.agents/dashboard/modules/operations/src/react/PrdDocumentDialog.tsx +62 -6
- package/templates/.agents/dashboard/modules/operations/src/react/TaskBoard.test.ts +55 -0
- package/templates/.agents/dashboard/modules/operations/src/react/TaskBoard.tsx +27 -19
- package/templates/.agents/dashboard/modules/operations/src/react/TaskDetailsDialog.tsx +99 -42
- package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkBoard.priority.test.ts +19 -0
- package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkBoard.tsx +255 -34
- package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkList.test.ts +163 -8
- package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkList.tsx +101 -68
- package/templates/.agents/dashboard/modules/operations/src/react/conversation-rows.test.ts +72 -1
- package/templates/.agents/dashboard/modules/operations/src/react/conversation-rows.ts +78 -16
- package/templates/.agents/dashboard/modules/operations/src/react/execution-metrics.ts +6 -4
- package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportAction.test.ts +50 -1
- package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportAction.tsx +143 -9
- package/templates/.agents/dashboard/modules/operations/src/react/export/export-layout.test.ts +29 -4
- package/templates/.agents/dashboard/modules/operations/src/react/macro-planning-dialog-content.css +49 -0
- package/templates/.agents/dashboard/modules/operations/src/react/macro-planning-dialog.css +93 -50
- package/templates/.agents/dashboard/modules/operations/src/react/manual-work-priority.test.ts +82 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operation-date-range.test.ts +29 -2
- package/templates/.agents/dashboard/modules/operations/src/react/operation-date-range.ts +22 -1
- package/templates/.agents/dashboard/modules/operations/src/react/operation-duration.test.ts +77 -4
- package/templates/.agents/dashboard/modules/operations/src/react/operation-duration.ts +65 -5
- package/templates/.agents/dashboard/modules/operations/src/react/operations-coverage-toast.test.ts +54 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-global-filters.test.ts +19 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-overview-period-filter.test.ts +149 -12
- package/templates/.agents/dashboard/modules/operations/src/react/operations-overview.status-cards.test.ts +27 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-page-contract.ts +136 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-period-scope.test.ts +160 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-period-scope.ts +47 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-query.ts +10 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-responsive.css +3 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-view-labels.ts +28 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-view-order.test.ts +24 -7
- package/templates/.agents/dashboard/modules/operations/src/react/operations.css +42 -0
- package/templates/.agents/dashboard/modules/operations/src/react/period-summary-population.test.ts +54 -0
- package/templates/.agents/dashboard/modules/operations/src/react/period-summary-population.ts +32 -0
- package/templates/.agents/dashboard/modules/operations/src/react/period-summary.test.ts +165 -6
- package/templates/.agents/dashboard/modules/operations/src/react/period-summary.ts +148 -6
- package/templates/.agents/dashboard/modules/operations/src/react/popup-localization.test.ts +1 -1
- package/templates/.agents/dashboard/modules/operations/src/react/unified-work-board.css +132 -0
- package/templates/.agents/dashboard/modules/operations/src/react/unified-work-board.css.test.ts +13 -0
- package/templates/.agents/dashboard/modules/operations/src/react/unified-work-board.header.test.ts +16 -0
- package/templates/.agents/dashboard/modules/operations/src/react/use-infinite-column.ts +11 -5
- package/templates/.agents/dashboard/modules/operations/src/react/work-board-model.test.ts +5 -3
- package/templates/.agents/dashboard/modules/operations/src/react/work-board-model.ts +4 -83
- package/templates/.agents/dashboard/modules/operations/src/server/build-operations-projection.test.ts +291 -15
- package/templates/.agents/dashboard/modules/operations/src/server/build-operations-projection.ts +182 -472
- package/templates/.agents/dashboard/modules/operations/src/server/canonical-compat.test.ts +40 -0
- package/templates/.agents/dashboard/modules/operations/src/server/canonical-compat.ts +19 -6
- package/templates/.agents/dashboard/modules/operations/src/server/canonical-run-projection.ts +31 -6
- package/templates/.agents/dashboard/modules/operations/src/server/daily-duration-projection.ts +220 -0
- package/templates/.agents/dashboard/modules/operations/src/server/execution-duration-projection.ts +28 -0
- package/templates/.agents/dashboard/modules/operations/src/server/execution-relationship-counts.test.ts +27 -2
- package/templates/.agents/dashboard/modules/operations/src/server/execution-relationship-counts.ts +22 -13
- package/templates/.agents/dashboard/modules/operations/src/server/filter.test.ts +3 -3
- package/templates/.agents/dashboard/modules/operations/src/server/filter.ts +7 -2
- package/templates/.agents/dashboard/modules/operations/src/server/index.ts +3 -0
- package/templates/.agents/dashboard/modules/operations/src/server/macro.ts +3 -12
- package/templates/.agents/dashboard/modules/operations/src/server/manifest-usage.ts +65 -0
- package/templates/.agents/dashboard/modules/operations/src/server/operations-projection-aggregates.ts +297 -0
- package/templates/.agents/dashboard/modules/operations/src/server/quick-daily-operations-projection.ts +324 -0
- package/templates/.agents/dashboard/modules/operations/src/server/quick-operations-projection.test.ts +505 -0
- package/templates/.agents/dashboard/modules/operations/src/server/quick-operations-projection.ts +609 -0
- package/templates/.agents/dashboard/modules/operations/src/server/runs.ts +18 -19
- package/templates/.agents/dashboard/modules/operations/src/work-board-model.ts +76 -0
- package/templates/.agents/dashboard/modules/traceability/package.json +1 -1
- package/templates/.agents/dashboard/modules/traceability/src/server/build-task-trace.ts +3 -1
- package/templates/.agents/dashboard/packages/branding/package.json +1 -1
- package/templates/.agents/dashboard/packages/branding/src/index.ts +1 -1
- package/templates/.agents/dashboard/packages/contracts/package.json +1 -1
- package/templates/.agents/dashboard/packages/contracts/src/index.ts +1 -0
- package/templates/.agents/dashboard/packages/data-export/package.json +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/dist/server.cjs +1756 -0
- package/templates/.agents/dashboard/packages/local-runtime/dist/sqlite-read-model.cjs +1608 -0
- package/templates/.agents/dashboard/packages/local-runtime/package.json +8 -3
- package/templates/.agents/dashboard/packages/local-runtime/scripts/build-sqlite-dashboard.mjs +12 -0
- package/templates/.agents/dashboard/packages/local-runtime/scripts/build-sqlite-runtime.mjs +83 -0
- package/templates/.agents/dashboard/packages/local-runtime/scripts/rebuild-sqlite-read-model.mjs +28 -0
- package/templates/.agents/dashboard/packages/local-runtime/scripts/test-sqlite-read-model.mjs +262 -0
- package/templates/.agents/dashboard/packages/local-runtime/scripts/test-unix-launchers.mjs +41 -0
- package/templates/.agents/dashboard/packages/local-runtime/scripts/validate-sqlite-read-model.mjs +105 -0
- package/templates/.agents/dashboard/packages/local-runtime/server.mjs +1643 -107
- package/templates/.agents/dashboard/packages/local-runtime/src/agent-adapter-sync.ts +30 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/agent-catalog-settings.test.ts +3 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/agent-catalog-settings.ts +5 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/manifest-runs.ts +72 -33
- package/templates/.agents/dashboard/packages/local-runtime/src/project-settings.test.ts +335 -4
- package/templates/.agents/dashboard/packages/local-runtime/src/project-settings.ts +392 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/runtime.mjs +5 -5
- package/templates/.agents/dashboard/packages/local-runtime/src/server-board.test.ts +71 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-board.ts +179 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-cross-layer-parity.test.ts +245 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-daily-read-models-route.ts +64 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-daily-read-models.test.ts +204 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-daily-read-models.ts +194 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-pages.test.ts +163 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-pages.ts +354 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-runs-route.test.ts +74 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-runs-route.ts +113 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-overview.test.ts +68 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-period.ts +47 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-projections.ts +483 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-settings.test.ts +5 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot.test.ts +163 -84
- package/templates/.agents/dashboard/packages/local-runtime/src/server-workspace.ts +145 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server.test.ts +551 -266
- package/templates/.agents/dashboard/packages/local-runtime/src/server.ts +1145 -308
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-metric-contract.test.ts +53 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-metric-contract.ts +708 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model.test.ts +2232 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model.ts +6151 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/work-priority-contract.test.ts +33 -0
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-history.mjs +41 -0
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-processes.mjs +210 -0
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard.mjs +437 -190
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard.test.mjs +299 -24
- package/templates/.agents/dashboard/packages/ui/package.json +1 -1
- package/templates/.agents/dashboard/packages/windows-launcher/LauncherVerificationBehaviorTests.cs +206 -0
- package/templates/.agents/dashboard/packages/windows-launcher/Program.cs +95 -8
- package/templates/.agents/dashboard/packages/windows-launcher/build-dashboard-launcher.ps1 +2 -2
- package/templates/.agents/dashboard/packages/windows-launcher/run-launcher-verification-tests.ps1 +22 -0
- package/templates/.agents/dashboard/read-model.dbml +2201 -0
- package/templates/.agents/dashboard/tests/e2e/package.json +1 -1
- package/templates/.agents/dashboard/tests/e2e/playwright.config.ts +1 -1
- package/templates/.agents/dashboard/tests/e2e/specs/dashboard.spec.ts +214 -41
- package/templates/.agents/dashboard/work-priority.json +34 -0
- package/templates/.agents/dashboard/zaip-dashboard-linux.sh +45 -0
- package/templates/.agents/dashboard/zaip-dashboard-mac.command +3 -0
- package/templates/.agents/dashboard/zaip-dashboard-windows.exe +0 -0
- package/templates/.agents/design/.zaip-managed.json +3 -3
- package/templates/.agents/design/apps/catalog/package.json +1 -1
- package/templates/.agents/design/packages/local-runtime/package.json +1 -1
- package/templates/.agents/requirements/autonomous-assurance.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 +24 -0
- 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 +4 -3
- package/templates/.agents/requirements/model-orchestration.md +1 -1
- package/templates/.agents/requirements/public-distribution.md +9 -6
- 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 +9 -3
- package/templates/.agents/requirements/zaip-strategic-95.md +4 -4
- package/templates/.agents/rules/autonomy-decision.md +15 -0
- package/templates/.agents/rules/core.md +1 -1
- package/templates/.agents/rules/run-lifecycle-closure.md +1 -1
- package/templates/.agents/rules/specialist-routing.md +19 -0
- package/templates/.agents/rules/workflow.md +1 -1
- package/templates/.agents/runtime/VERSION +1 -1
- package/templates/.agents/runtime/bin/zaip.mjs +114 -64
- package/templates/.agents/runtime/checksums.sha256 +6 -4
- package/templates/.agents/runtime/manifest.json +3 -1
- package/templates/.agents/runtime/pnpm-lock.sha256 +1 -0
- package/templates/.agents/runtime/provenance.json +11 -0
- package/templates/.agents/runtime/sbom.cdx.json +1929 -39
- package/templates/.agents/skills/zaip-aios/SKILL.md +1 -1
- package/templates/.agents/skills/zaip-skill-brand-governance/SKILL.md +15 -0
- package/templates/.agents/skills/zaip-skill-brand-governance/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-brand-governance/references/brandbook-standards.md +30 -0
- package/templates/.agents/skills/zaip-skill-dashboard-sqlite/SKILL.md +25 -0
- package/templates/.agents/skills/zaip-skill-dashboard-sqlite/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-executar-fila-pronta/SKILL.md +18 -0
- package/templates/.agents/skills/zaip-skill-executar-fila-pronta/agents/openai.yaml +6 -0
- package/templates/.agents/skills/zaip-skill-executar-fila-pronta/scripts/ready-queue-fence.mjs +71 -0
- package/templates/.agents/skills/zaip-skill-executar-fila-pronta/scripts/ready-queue-fence.test.mjs +60 -0
- package/templates/.agents/skills/zaip-skill-executar-fila-pronta/scripts/scheduled-ready-queue-contract.test.mjs +111 -0
- package/templates/.agents/skills/zaip-skill-execution/SKILL.md +2 -2
- package/templates/.agents/skills/zaip-skill-frontend-launcher/references/launcher-contract.md +3 -1
- package/templates/.agents/skills/zaip-skill-general-operations/SKILL.md +12 -0
- package/templates/.agents/skills/zaip-skill-general-operations/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/SKILL.md +9 -7
- package/templates/.agents/skills/zaip-skill-github-deploy/agents/openai.yaml +2 -2
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/github-deploy-contract.test.mjs +11 -38
- package/templates/.agents/skills/zaip-skill-governance-compliance/SKILL.md +12 -0
- package/templates/.agents/skills/zaip-skill-governance-compliance/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-growth-strategy-revops/SKILL.md +15 -0
- package/templates/.agents/skills/zaip-skill-growth-strategy-revops/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-growth-strategy-revops/references/growth-revops-framework.md +25 -0
- package/templates/.agents/skills/zaip-skill-instalar-agendamento/SKILL.md +17 -0
- package/templates/.agents/skills/zaip-skill-instalar-agendamento/agents/openai.yaml +6 -0
- package/templates/.agents/skills/zaip-skill-marketing/SKILL.md +3 -3
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-local-telemetry.mjs +76 -27
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-lib.mjs +128 -24
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-lib.test.mjs +122 -4
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-remeasurement.mjs +66 -19
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-remeasurement.test.mjs +193 -7
- package/templates/.agents/skills/zaip-skill-sales-methodology/SKILL.md +14 -0
- package/templates/.agents/skills/zaip-skill-sales-methodology/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-sales-methodology/references/sales-process-framework.md +77 -0
- package/templates/.agents/skills/zaip-skill-setup/SKILL.md +5 -0
- package/templates/.agents/skills/zaip-skill-sqlite-read-model/SKILL.md +96 -0
- package/templates/.agents/skills/zaip-skill-sqlite-read-model/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-sqlite-read-model/scripts/ensure-node.mjs +18 -0
- package/templates/.agents/zaip-aios/INDEX.md +1 -0
- package/templates/.agents/zaip-aios/README.md +37 -8
- package/templates/.agents/zaip-aios/VERSION +1 -1
- package/templates/.agents/zaip-aios/guides/09-agentes-e-squads.md +43 -6
- package/templates/.agents/zaip-aios/guides/10-seguranca.md +21 -7
- package/templates/.agents/zaip-aios/guides/17-como-o-custo-e-calculado.md +32 -0
- package/templates/template-manifest.json +945 -214
- package/templates/.agents/dashboard/apps/frontend/dist/assets/AgentCatalogSettingsPage-CLYIi7Vo.js +0 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/AgentCatalogSettingsPage-DTDNVQGX.css +0 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/PricingSettingsDialog-CzEggcRb.js +0 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-05YKn6Z4.js +0 -3
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-YO3yqtgV.css +0 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-8AzCnl3a.js +0 -77
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-DdBYQ_8D.css +0 -1
- package/templates/.agents/dashboard/apps/frontend/src/AgentCatalogSettingsPage.tsx +0 -617
- package/templates/.agents/dashboard/apps/frontend/src/agent-catalog-settings-page.css +0 -660
- package/templates/.agents/dashboard/apps/frontend/src/agent-catalog-settings.test.ts +0 -249
- package/templates/.agents/dashboard/dashboard.config.json +0 -4
- package/templates/.agents/dashboard/zaip-dashboard.exe +0 -0
package/templates/.agents/dashboard/modules/operations/src/server/quick-operations-projection.ts
ADDED
|
@@ -0,0 +1,609 @@
|
|
|
1
|
+
import type { WorkspaceFileSystem, WorkspaceLayout } from "@zaip-ai/core";
|
|
2
|
+
import {
|
|
3
|
+
type CompactMacroMetric,
|
|
4
|
+
LifecycleManifestStore,
|
|
5
|
+
type LifecycleManifestSummary,
|
|
6
|
+
} from "@zaip-ai/lifecycle-manifests";
|
|
7
|
+
import type {
|
|
8
|
+
OperationsProjection,
|
|
9
|
+
ProjectionTimeFilter,
|
|
10
|
+
UsageMetricProjection,
|
|
11
|
+
UsageProjection,
|
|
12
|
+
} from "../contracts.js";
|
|
13
|
+
import { LEGACY_EFFORT_DAILY_MS, saoPauloPeriodKey } from "../contracts.js";
|
|
14
|
+
import { observedExecutionElapsedMs } from "../duration-population.js";
|
|
15
|
+
import {
|
|
16
|
+
hybridDailyDuration,
|
|
17
|
+
normalizeDailyPeriods,
|
|
18
|
+
rootExecutionDurationByDay,
|
|
19
|
+
} from "./daily-duration-projection.js";
|
|
20
|
+
import { normalizeFilter } from "./filter.js";
|
|
21
|
+
import {
|
|
22
|
+
aggregateDailyDetails,
|
|
23
|
+
aggregateOverviewPeriodMetrics,
|
|
24
|
+
dailyMacroProjection,
|
|
25
|
+
dailyTaskProjection,
|
|
26
|
+
dailyTopTasksFromRows,
|
|
27
|
+
taskCountsFromDailyRows,
|
|
28
|
+
} from "./quick-daily-operations-projection.js";
|
|
29
|
+
|
|
30
|
+
export type OverviewMetricRun = {
|
|
31
|
+
id: string;
|
|
32
|
+
started_at: string;
|
|
33
|
+
finished_at?: string | null;
|
|
34
|
+
phase?: string | null;
|
|
35
|
+
parent_run_id?: string | null;
|
|
36
|
+
duration_started_at?: string | null;
|
|
37
|
+
duration_ms: number | null;
|
|
38
|
+
total_tokens: number | null;
|
|
39
|
+
cost: number | null;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/** The shared quick/detail Run population: terminal time, then start time. */
|
|
43
|
+
export function aggregateOverviewRunMetrics<T extends OverviewMetricRun>(
|
|
44
|
+
runs: readonly T[],
|
|
45
|
+
filter: ProjectionTimeFilter,
|
|
46
|
+
filterRuns = true,
|
|
47
|
+
) {
|
|
48
|
+
const deduplicated = [...new Map(runs.map((run) => [run.id, run] as const)).values()];
|
|
49
|
+
const selected = filterRuns
|
|
50
|
+
? deduplicated.filter((run) => inTimeWindow(run.finished_at ?? run.started_at, filter))
|
|
51
|
+
: deduplicated;
|
|
52
|
+
const roots = selected.filter((run) => run.phase === "execution" && run.parent_run_id == null);
|
|
53
|
+
const duration = hybridLegacyDurationMetric(roots, filter);
|
|
54
|
+
const knownSum = (values: readonly (number | null)[]) => {
|
|
55
|
+
const known = values.filter((value): value is number => value !== null);
|
|
56
|
+
// Compact manifests and folded Run records can arrive in different stable
|
|
57
|
+
// orders. Normalize binary floating-point noise at the metric boundary so
|
|
58
|
+
// the canonical numeric contract is byte-for-byte identical.
|
|
59
|
+
return known.length === 0
|
|
60
|
+
? null
|
|
61
|
+
: Math.round(known.reduce((total, value) => total + value, 0) * 1_000_000_000) /
|
|
62
|
+
1_000_000_000;
|
|
63
|
+
};
|
|
64
|
+
const coverage = (values: readonly (number | null)[]) =>
|
|
65
|
+
values.length === 0 ? 1 : values.filter((value) => value !== null).length / values.length;
|
|
66
|
+
return {
|
|
67
|
+
duration_ms:
|
|
68
|
+
duration === undefined || duration.coverage_ratio === 0 ? null : duration.known_sum,
|
|
69
|
+
tokens: knownSum(selected.map((run) => run.total_tokens)),
|
|
70
|
+
cost_brl: knownSum(selected.map((run) => run.cost)),
|
|
71
|
+
coverage: {
|
|
72
|
+
duration: duration?.coverage_ratio ?? 1,
|
|
73
|
+
tokens: coverage(selected.map((run) => run.total_tokens)),
|
|
74
|
+
cost: coverage(selected.map((run) => run.cost)),
|
|
75
|
+
},
|
|
76
|
+
execution_day_count: new Set(
|
|
77
|
+
roots
|
|
78
|
+
.map((run) => saoPauloPeriodKey(run.duration_started_at ?? run.started_at, "day"))
|
|
79
|
+
.filter((day): day is string => day !== null),
|
|
80
|
+
).size,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The legacy snapshot is a complete aggregate, never a synthesized Run.
|
|
86
|
+
* Coverage therefore describes only the observed root-execution population
|
|
87
|
+
* after the snapshot cutoff, including roots whose duration is unavailable.
|
|
88
|
+
*/
|
|
89
|
+
export function hybridLegacyDurationMetric<
|
|
90
|
+
T extends {
|
|
91
|
+
id: string;
|
|
92
|
+
started_at: string | null;
|
|
93
|
+
duration_started_at?: string | null;
|
|
94
|
+
duration_ms: number | null;
|
|
95
|
+
phase?: string | null;
|
|
96
|
+
parent_run_id?: string | null;
|
|
97
|
+
},
|
|
98
|
+
>(
|
|
99
|
+
roots: readonly T[],
|
|
100
|
+
range: ProjectionTimeFilter,
|
|
101
|
+
): { known_sum: number; unknown: number; complete: boolean; coverage_ratio: number } | undefined {
|
|
102
|
+
const rootsByDay = rootExecutionDurationByDay(roots);
|
|
103
|
+
const days = new Set([...Object.keys(LEGACY_EFFORT_DAILY_MS), ...rootsByDay.keys()]);
|
|
104
|
+
const values = [...days]
|
|
105
|
+
.filter((day) => inDurationDayRange(day, range))
|
|
106
|
+
.map((day) => hybridDailyDuration(day, { runs: 0 }, rootsByDay.get(day), true).value);
|
|
107
|
+
if (values.length === 0) return undefined;
|
|
108
|
+
const unknown = values.reduce((total, value) => total + value.unknown, 0);
|
|
109
|
+
const known = values.reduce((total, value) => total + value.known_sum, 0);
|
|
110
|
+
const eligible = [...rootsByDay]
|
|
111
|
+
.filter(([day]) => inDurationDayRange(day, range))
|
|
112
|
+
.reduce((total, [, value]) => total + value.population.eligible_runs, 0);
|
|
113
|
+
const covered = [...rootsByDay]
|
|
114
|
+
.filter(([day]) => inDurationDayRange(day, range))
|
|
115
|
+
.reduce((total, [, value]) => total + value.population.known_runs, 0);
|
|
116
|
+
return {
|
|
117
|
+
known_sum: known,
|
|
118
|
+
unknown,
|
|
119
|
+
complete: unknown === 0,
|
|
120
|
+
coverage_ratio: eligible === 0 ? 1 : covered / eligible,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function inDurationDayRange(day: string, range: ProjectionTimeFilter): boolean {
|
|
125
|
+
return (
|
|
126
|
+
(range.from === null || day >= range.from.slice(0, 10)) &&
|
|
127
|
+
(range.to === null || day <= range.to.slice(0, 10))
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export async function buildQuickOperationsProjection(
|
|
132
|
+
filesystem: WorkspaceFileSystem,
|
|
133
|
+
layout: WorkspaceLayout,
|
|
134
|
+
filter: Partial<ProjectionTimeFilter> = {},
|
|
135
|
+
options: { includeBoardTasks?: boolean } = {},
|
|
136
|
+
): Promise<OperationsProjection> {
|
|
137
|
+
if (layout.version === 1)
|
|
138
|
+
throw new Error("Operations projection requires a modern WorkspaceLayout");
|
|
139
|
+
const manifest = new LifecycleManifestStore(filesystem);
|
|
140
|
+
const normalizedFilter = normalizeFilter(filter);
|
|
141
|
+
const [overview, taskModels, specModels, prdModels] = await Promise.all([
|
|
142
|
+
manifest.readDailyReadModels("overview"),
|
|
143
|
+
manifest.readDailyReadModels("tasks"),
|
|
144
|
+
manifest.readDailyReadModels("specs"),
|
|
145
|
+
manifest.readDailyReadModels("prds"),
|
|
146
|
+
]);
|
|
147
|
+
if (overview === null) throw new Error("Lifecycle daily overview is not initialized");
|
|
148
|
+
const selectedPeriods = Object.entries(overview.days)
|
|
149
|
+
.filter(([day]) => inDurationDayRange(day, normalizedFilter))
|
|
150
|
+
.map(([day, model]) => [day, model.overview] as const);
|
|
151
|
+
const metrics = aggregateOverviewPeriodMetrics(selectedPeriods, normalizedFilter);
|
|
152
|
+
const periodCounts = {
|
|
153
|
+
runs: selectedPeriods.reduce((total, [, period]) => total + period.runs, 0),
|
|
154
|
+
};
|
|
155
|
+
const unavailable = emptyUsageMetric();
|
|
156
|
+
const total = {
|
|
157
|
+
...unavailable,
|
|
158
|
+
tokens: { ...unavailable.tokens, total: metrics.tokens },
|
|
159
|
+
cost: { ...unavailable.cost, brl: metrics.cost_brl },
|
|
160
|
+
};
|
|
161
|
+
const coverage = metrics.coverage;
|
|
162
|
+
const quickDailyPeriods = normalizeDailyPeriods(selectedPeriods, metrics.duration_ms ?? 0);
|
|
163
|
+
const tasks = aggregateDailyDetails(taskModels, normalizedFilter);
|
|
164
|
+
const prdRows = aggregateDailyDetails(prdModels, normalizedFilter);
|
|
165
|
+
const specRows = aggregateDailyDetails(specModels, normalizedFilter);
|
|
166
|
+
const taskWindowCounts = taskCountsFromDailyRows(tasks);
|
|
167
|
+
const statusCounts = taskWindowCounts.statuses;
|
|
168
|
+
const riskCounts = taskWindowCounts.risks;
|
|
169
|
+
const tasksBySpec = new Map<string, number>();
|
|
170
|
+
for (const task of tasks)
|
|
171
|
+
if (task.parent_id !== null)
|
|
172
|
+
tasksBySpec.set(task.parent_id, (tasksBySpec.get(task.parent_id) ?? 0) + 1);
|
|
173
|
+
const specsByPrd = new Map(specRows.map((spec) => [spec.id, spec.parent_id] as const));
|
|
174
|
+
const prds = prdRows.map((row) =>
|
|
175
|
+
dailyMacroProjection(
|
|
176
|
+
row,
|
|
177
|
+
"prd",
|
|
178
|
+
tasks.filter((task) => task.parent_id === row.id).length +
|
|
179
|
+
[...tasksBySpec]
|
|
180
|
+
.filter(([specId]) => specsByPrd.get(specId) === row.id)
|
|
181
|
+
.reduce((total, [, count]) => total + count, 0),
|
|
182
|
+
),
|
|
183
|
+
);
|
|
184
|
+
const specs = specRows.map((row) =>
|
|
185
|
+
dailyMacroProjection(row, "spec", tasksBySpec.get(row.id) ?? 0),
|
|
186
|
+
);
|
|
187
|
+
const topTasks = dailyTopTasksFromRows(tasks);
|
|
188
|
+
return {
|
|
189
|
+
schema_version: 2,
|
|
190
|
+
layout_version: layout.version,
|
|
191
|
+
readonly: true,
|
|
192
|
+
source: ".agents/records",
|
|
193
|
+
filters: normalizedFilter,
|
|
194
|
+
summary: {
|
|
195
|
+
prd_count: prds.length,
|
|
196
|
+
spec_count: specs.length,
|
|
197
|
+
execution_count: 0,
|
|
198
|
+
task_count: taskWindowCounts.total,
|
|
199
|
+
run_count: periodCounts.runs,
|
|
200
|
+
overview_metrics: {
|
|
201
|
+
duration_ms: metrics.duration_ms,
|
|
202
|
+
execution_day_count: metrics.execution_day_count,
|
|
203
|
+
tokens: metrics.tokens,
|
|
204
|
+
cost_brl: metrics.cost_brl,
|
|
205
|
+
prd_count: prds.length,
|
|
206
|
+
spec_count: specs.length,
|
|
207
|
+
selected_counts: { prds: prds.length, specs: specs.length },
|
|
208
|
+
// Count, status, and risk deliberately share taskCountsInWindow.
|
|
209
|
+
// `period.tasks` remains available in daily rows as tasksCreated,
|
|
210
|
+
// which has a different time semantic.
|
|
211
|
+
task_count: taskWindowCounts.total,
|
|
212
|
+
completed_prd_count: prds.filter((macro) => macro.work_status === "completed").length,
|
|
213
|
+
completed_spec_count: specs.filter((macro) => macro.work_status === "completed").length,
|
|
214
|
+
completed_task_count: statusCounts.completed ?? 0,
|
|
215
|
+
task_status_counts: statusCounts,
|
|
216
|
+
task_risk_counts: riskCounts,
|
|
217
|
+
top_tasks: topTasks,
|
|
218
|
+
latest_task_created_at:
|
|
219
|
+
tasks
|
|
220
|
+
.map((task) => task.occurred_at)
|
|
221
|
+
.sort()
|
|
222
|
+
.at(-1) ?? null,
|
|
223
|
+
coverage: {
|
|
224
|
+
duration: coverage.duration,
|
|
225
|
+
tokens: coverage.tokens,
|
|
226
|
+
cost: coverage.cost,
|
|
227
|
+
},
|
|
228
|
+
data_source: "lifecycle_manifest_summary",
|
|
229
|
+
partial: true,
|
|
230
|
+
},
|
|
231
|
+
decisions: { human: 0, agent: 0 },
|
|
232
|
+
source_latest_at: overview.source_latest_at,
|
|
233
|
+
quality: {
|
|
234
|
+
completed_tasks: 0,
|
|
235
|
+
task_completion_rate: 0,
|
|
236
|
+
terminal_runs: 0,
|
|
237
|
+
successful_runs: 0,
|
|
238
|
+
terminal_success_rate: 0,
|
|
239
|
+
rework_rate: 0,
|
|
240
|
+
},
|
|
241
|
+
reconciliation: {
|
|
242
|
+
phase_tokens_match_total: false,
|
|
243
|
+
phase_usd_match_total: false,
|
|
244
|
+
phase_brl_match_total: false,
|
|
245
|
+
origin_tokens_match_total: false,
|
|
246
|
+
},
|
|
247
|
+
usage: usageProjection(unavailable, total),
|
|
248
|
+
periods: { daily: quickDailyPeriods },
|
|
249
|
+
},
|
|
250
|
+
origins: {
|
|
251
|
+
conversation: usageProjection(unavailable, unavailable),
|
|
252
|
+
task: usageProjection(unavailable, unavailable),
|
|
253
|
+
spec: usageProjection(unavailable, unavailable),
|
|
254
|
+
prd: usageProjection(unavailable, unavailable),
|
|
255
|
+
},
|
|
256
|
+
prds,
|
|
257
|
+
specs,
|
|
258
|
+
// The quick overview keeps cards out of its first-fold payload. The
|
|
259
|
+
// paginated board route opts into compact Task cards from the same daily
|
|
260
|
+
// read model, without reading execution or telemetry records.
|
|
261
|
+
tasks: options.includeBoardTasks ? tasks.map(dailyTaskProjection) : [],
|
|
262
|
+
changes: [],
|
|
263
|
+
executions: [],
|
|
264
|
+
runs: [],
|
|
265
|
+
decisions: [],
|
|
266
|
+
evidences: [],
|
|
267
|
+
validations: [],
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export function withExecutionDurations(
|
|
272
|
+
periods: ReturnType<typeof manifestDailyPeriods>,
|
|
273
|
+
runs: NonNullable<LifecycleManifestSummary["run_metrics"]>,
|
|
274
|
+
) {
|
|
275
|
+
return Object.fromEntries(
|
|
276
|
+
periods.map(([day, period]) => {
|
|
277
|
+
// `hybridLegacyDurationMetric` splits observed intervals at the Sao
|
|
278
|
+
// Paulo day boundary and unions overlaps. It also keeps the immutable
|
|
279
|
+
// pre-cutoff baseline separate from Run attribution.
|
|
280
|
+
const duration = hybridLegacyDurationMetric(runs.filter(isRootExecutionRun), {
|
|
281
|
+
from: day,
|
|
282
|
+
to: day,
|
|
283
|
+
});
|
|
284
|
+
return [
|
|
285
|
+
day,
|
|
286
|
+
{
|
|
287
|
+
...period,
|
|
288
|
+
...(duration === undefined ? {} : { duration }),
|
|
289
|
+
},
|
|
290
|
+
];
|
|
291
|
+
}),
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export function taskCountsInWindow(
|
|
296
|
+
tasks: readonly {
|
|
297
|
+
status: string | null;
|
|
298
|
+
risk: string | null;
|
|
299
|
+
updated_at: string;
|
|
300
|
+
finished_at?: string | null;
|
|
301
|
+
data?: Record<string, unknown> | null;
|
|
302
|
+
}[],
|
|
303
|
+
filter: ProjectionTimeFilter,
|
|
304
|
+
): { total: number; statuses: Record<string, number>; risks: Record<string, number> } {
|
|
305
|
+
const statuses: Record<string, number> = {};
|
|
306
|
+
const risks: Record<string, number> = {};
|
|
307
|
+
let total = 0;
|
|
308
|
+
for (const task of tasks) {
|
|
309
|
+
const finished =
|
|
310
|
+
task.finished_at ??
|
|
311
|
+
(typeof task.data?.finished_at === "string" ? task.data.finished_at : null);
|
|
312
|
+
const timestamp = finished ?? task.updated_at;
|
|
313
|
+
if (!inTimeWindow(timestamp, filter)) continue;
|
|
314
|
+
total += 1;
|
|
315
|
+
const status = task.status ?? "unclassified";
|
|
316
|
+
const risk = task.risk ?? "unclassified";
|
|
317
|
+
statuses[status] = (statuses[status] ?? 0) + 1;
|
|
318
|
+
risks[risk] = (risks[risk] ?? 0) + 1;
|
|
319
|
+
}
|
|
320
|
+
return { total, statuses, risks };
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function inTimeWindow(timestamp: string, filter: ProjectionTimeFilter): boolean {
|
|
324
|
+
const normalized = new Date(timestamp).toISOString();
|
|
325
|
+
return (
|
|
326
|
+
(filter.from === null || normalized >= filter.from) &&
|
|
327
|
+
(filter.to === null || normalized <= filter.to)
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export function aggregateTopTasks(
|
|
332
|
+
runs: NonNullable<LifecycleManifestSummary["run_metrics"]>,
|
|
333
|
+
canonicalTaskIds: ReadonlySet<string>,
|
|
334
|
+
): NonNullable<NonNullable<OperationsProjection["summary"]["overview_metrics"]>["top_tasks"]> {
|
|
335
|
+
const tasks = new Map<
|
|
336
|
+
string,
|
|
337
|
+
NonNullable<
|
|
338
|
+
NonNullable<OperationsProjection["summary"]["overview_metrics"]>["top_tasks"]
|
|
339
|
+
>[number] & {
|
|
340
|
+
total_tokens: number;
|
|
341
|
+
cost_brl: number;
|
|
342
|
+
runs: NonNullable<LifecycleManifestSummary["run_metrics"]>;
|
|
343
|
+
}
|
|
344
|
+
>();
|
|
345
|
+
for (const run of runs) {
|
|
346
|
+
if (run.task_id === null || !canonicalTaskIds.has(run.task_id)) continue;
|
|
347
|
+
const current = tasks.get(run.task_id) ?? {
|
|
348
|
+
task_id: run.task_id,
|
|
349
|
+
duration_ms: 0,
|
|
350
|
+
total_tokens: 0,
|
|
351
|
+
cost_brl: 0,
|
|
352
|
+
run_count: 0,
|
|
353
|
+
runs: [],
|
|
354
|
+
};
|
|
355
|
+
// Rankings use observed processing time only. Lifecycle wall-clock time
|
|
356
|
+
// can overlap across Runs and must remain a distinct diagnostic metric.
|
|
357
|
+
current.runs.push(run);
|
|
358
|
+
current.total_tokens += run.total_tokens ?? 0;
|
|
359
|
+
current.cost_brl += run.cost ?? 0;
|
|
360
|
+
current.run_count += 1;
|
|
361
|
+
tasks.set(run.task_id, current);
|
|
362
|
+
}
|
|
363
|
+
return [...tasks.values()]
|
|
364
|
+
.map(({ runs: taskRuns, ...task }) => ({
|
|
365
|
+
...task,
|
|
366
|
+
duration_ms: observedExecutionElapsedMs(taskRuns) ?? 0,
|
|
367
|
+
}))
|
|
368
|
+
.sort(
|
|
369
|
+
(left, right) =>
|
|
370
|
+
right.duration_ms - left.duration_ms || left.task_id.localeCompare(right.task_id),
|
|
371
|
+
)
|
|
372
|
+
.slice(0, 5);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function isRootExecutionRun(
|
|
376
|
+
run: NonNullable<LifecycleManifestSummary["run_metrics"]>[number],
|
|
377
|
+
): boolean {
|
|
378
|
+
return run.phase === "execution" && run.parent_run_id == null;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export function manifestDailyPeriods(
|
|
382
|
+
summary: LifecycleManifestSummary,
|
|
383
|
+
from: string | null,
|
|
384
|
+
to: string | null,
|
|
385
|
+
) {
|
|
386
|
+
const fromDay = from === null ? null : saoPauloPeriodKey(from, "day");
|
|
387
|
+
const toDay = to === null ? null : saoPauloPeriodKey(to, "day");
|
|
388
|
+
return Object.entries(finishDayPeriods(summary)).filter(
|
|
389
|
+
([day]) => (fromDay === null || day >= fromDay) && (toDay === null || day <= toDay),
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Lifecycle period counters predate the completed-Run calendar contract. When
|
|
395
|
+
* the compact Run index is complete, re-bucket Run accounting by terminal day
|
|
396
|
+
* while retaining entity-created counters from the durable period summary.
|
|
397
|
+
*/
|
|
398
|
+
function finishDayPeriods(
|
|
399
|
+
summary: LifecycleManifestSummary,
|
|
400
|
+
): LifecycleManifestSummary["periods"]["daily"] {
|
|
401
|
+
const runs = [
|
|
402
|
+
...new Map((summary.run_metrics ?? []).map((run) => [run.id, run] as const)).values(),
|
|
403
|
+
];
|
|
404
|
+
const summarizedRuns = Object.values(summary.periods.daily).reduce(
|
|
405
|
+
(total, period) => total + period.runs,
|
|
406
|
+
0,
|
|
407
|
+
);
|
|
408
|
+
if (runs.length === 0 || runs.length !== summarizedRuns) return summary.periods.daily;
|
|
409
|
+
|
|
410
|
+
const byDay = new Map<string, typeof runs>();
|
|
411
|
+
for (const run of runs) {
|
|
412
|
+
const day = saoPauloPeriodKey(run.finished_at ?? run.started_at, "day");
|
|
413
|
+
if (day !== null) byDay.set(day, [...(byDay.get(day) ?? []), run]);
|
|
414
|
+
}
|
|
415
|
+
const days = new Set([...Object.keys(summary.periods.daily), ...byDay.keys()]);
|
|
416
|
+
return Object.fromEntries(
|
|
417
|
+
[...days].map((day) => {
|
|
418
|
+
const period = summary.periods.daily[day] ?? emptyManifestPeriod(summary.usage.cost.currency);
|
|
419
|
+
const dayRuns = byDay.get(day) ?? [];
|
|
420
|
+
return [
|
|
421
|
+
day,
|
|
422
|
+
{
|
|
423
|
+
...period,
|
|
424
|
+
runs: dayRuns.length,
|
|
425
|
+
usage: {
|
|
426
|
+
...period.usage,
|
|
427
|
+
total_tokens: knownRunMetric(dayRuns.map((run) => run.total_tokens)),
|
|
428
|
+
cost: {
|
|
429
|
+
...knownRunMetric(dayRuns.map((run) => run.cost)),
|
|
430
|
+
currency: period.usage.cost.currency ?? summary.usage.cost.currency,
|
|
431
|
+
},
|
|
432
|
+
},
|
|
433
|
+
events: knownRunMetric(dayRuns.map((run) => run.events)),
|
|
434
|
+
},
|
|
435
|
+
];
|
|
436
|
+
}),
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function knownRunMetric(values: readonly (number | null)[]) {
|
|
441
|
+
const known = values.filter((value): value is number => value !== null);
|
|
442
|
+
const unknown = values.length - known.length;
|
|
443
|
+
return {
|
|
444
|
+
known_sum: known.reduce((total, value) => total + value, 0),
|
|
445
|
+
unknown,
|
|
446
|
+
complete: unknown === 0,
|
|
447
|
+
coverage_ratio: values.length === 0 ? 1 : known.length / values.length,
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
function emptyManifestPeriod(
|
|
452
|
+
currency: string | null,
|
|
453
|
+
): LifecycleManifestSummary["periods"]["daily"][string] {
|
|
454
|
+
const empty = knownRunMetric([]);
|
|
455
|
+
return {
|
|
456
|
+
prds: 0,
|
|
457
|
+
specs: 0,
|
|
458
|
+
tasks: 0,
|
|
459
|
+
validations: 0,
|
|
460
|
+
evidences: 0,
|
|
461
|
+
runs: 0,
|
|
462
|
+
usage: {
|
|
463
|
+
input_tokens: empty,
|
|
464
|
+
output_tokens: empty,
|
|
465
|
+
total_tokens: empty,
|
|
466
|
+
cost: { ...empty, currency },
|
|
467
|
+
},
|
|
468
|
+
events: empty,
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
export function summaryTopTasks(
|
|
473
|
+
summary: LifecycleManifestSummary,
|
|
474
|
+
filter: ProjectionTimeFilter,
|
|
475
|
+
canonicalTaskIds: ReadonlySet<string>,
|
|
476
|
+
): NonNullable<NonNullable<OperationsProjection["summary"]["overview_metrics"]>["top_tasks"]> {
|
|
477
|
+
// A per-day Top 5 is not compositional: a Task that finishes sixth every
|
|
478
|
+
// day can be first over a selected week. Re-rank the compact Run metrics
|
|
479
|
+
// after applying the same finished-or-started window as detail projection.
|
|
480
|
+
return aggregateTopTasks(
|
|
481
|
+
(summary.run_metrics ?? []).filter((run) =>
|
|
482
|
+
inTimeWindow(run.finished_at ?? run.started_at, filter),
|
|
483
|
+
),
|
|
484
|
+
canonicalTaskIds,
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
export function macroInWindow(macro: CompactMacroMetric, filter: ProjectionTimeFilter): boolean {
|
|
489
|
+
return inTimeWindow(macro.updated_at, filter);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
function availableKnownSum(value: { known_sum: number; unknown: number }): number | null {
|
|
493
|
+
return value.known_sum === 0 && value.unknown > 0 ? null : value.known_sum;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
function compactMacroProjection(metric: CompactMacroMetric): OperationsProjection["prds"][number] {
|
|
497
|
+
const unavailable = emptyUsageMetric();
|
|
498
|
+
const total: UsageMetricProjection = {
|
|
499
|
+
...unavailable,
|
|
500
|
+
tokens: { ...unavailable.tokens, total: metric.total_tokens },
|
|
501
|
+
cost: { ...unavailable.cost, brl: metric.cost },
|
|
502
|
+
};
|
|
503
|
+
return {
|
|
504
|
+
id: metric.id,
|
|
505
|
+
title: metric.title,
|
|
506
|
+
created_at: metric.created_at,
|
|
507
|
+
updated_at: metric.updated_at,
|
|
508
|
+
kind: metric.kind,
|
|
509
|
+
parent_id: metric.parent_id,
|
|
510
|
+
artifact_path: "",
|
|
511
|
+
lifecycle_status: metric.lifecycle_status,
|
|
512
|
+
work_status: metric.work_status,
|
|
513
|
+
execution_ids: [],
|
|
514
|
+
task_ids: [],
|
|
515
|
+
planned_tasks: [],
|
|
516
|
+
canonical_run_ids: metric.canonical_run_ids,
|
|
517
|
+
run_ids: metric.canonical_run_ids,
|
|
518
|
+
root_execution_run_ids: metric.root_execution_run_ids,
|
|
519
|
+
execution_count: 0,
|
|
520
|
+
task_count: metric.task_count,
|
|
521
|
+
run_count: metric.run_count,
|
|
522
|
+
duration_ms: metric.observed_root_duration_ms,
|
|
523
|
+
observed_root_duration_ms: metric.observed_root_duration_ms,
|
|
524
|
+
observed_lifecycle_duration_ms: metric.observed_lifecycle_duration_ms,
|
|
525
|
+
duration_coverage: metric.duration_coverage,
|
|
526
|
+
duration_provenance: metric.duration_provenance,
|
|
527
|
+
lifecycle_duration_coverage: metric.lifecycle_duration_coverage,
|
|
528
|
+
lifecycle_duration_provenance: metric.lifecycle_duration_provenance,
|
|
529
|
+
decisions: { human: 0, agent: 0 },
|
|
530
|
+
rework_run_count: metric.rework_run_count,
|
|
531
|
+
quality: {
|
|
532
|
+
completed_tasks: 0,
|
|
533
|
+
task_completion_rate: 0,
|
|
534
|
+
terminal_runs: 0,
|
|
535
|
+
successful_runs: 0,
|
|
536
|
+
terminal_success_rate: 0,
|
|
537
|
+
rework_rate: metric.run_count === 0 ? 0 : metric.rework_run_count / metric.run_count,
|
|
538
|
+
},
|
|
539
|
+
usage: usageProjection(unavailable, total),
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
function emptyUsageMetric(): UsageMetricProjection {
|
|
544
|
+
return {
|
|
545
|
+
events: 0,
|
|
546
|
+
tokens: { input: null, cached_input: null, output: null, reasoning: null, total: null },
|
|
547
|
+
cost: { usd: null, brl: null },
|
|
548
|
+
coverage: { events: 0, tokens: 0, usd: 0, brl: 0 },
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
function usageProjection(
|
|
553
|
+
unavailable: UsageMetricProjection,
|
|
554
|
+
total: UsageMetricProjection,
|
|
555
|
+
): UsageProjection {
|
|
556
|
+
return {
|
|
557
|
+
conversation: unavailable,
|
|
558
|
+
planning: unavailable,
|
|
559
|
+
execution: unavailable,
|
|
560
|
+
total,
|
|
561
|
+
new_work: unavailable,
|
|
562
|
+
rework: unavailable,
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/** Derive bounded-period coverage from the same dated Runs used by the overview. */
|
|
567
|
+
export function coverageFromRuns(
|
|
568
|
+
runs: readonly Pick<
|
|
569
|
+
NonNullable<LifecycleManifestSummary["run_metrics"]>[number],
|
|
570
|
+
"duration_ms" | "total_tokens" | "cost"
|
|
571
|
+
>[],
|
|
572
|
+
): { duration: number; tokens: number; cost: number } {
|
|
573
|
+
const ratio = (known: number) => (runs.length === 0 ? 1 : known / runs.length);
|
|
574
|
+
return {
|
|
575
|
+
duration: ratio(runs.filter((run) => run.duration_ms !== null).length),
|
|
576
|
+
tokens: ratio(runs.filter((run) => run.total_tokens !== null).length),
|
|
577
|
+
cost: ratio(runs.filter((run) => run.cost !== null).length),
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
function aggregateManifestPeriodUsage(
|
|
582
|
+
summary: LifecycleManifestSummary,
|
|
583
|
+
from: string | null,
|
|
584
|
+
to: string | null,
|
|
585
|
+
): LifecycleManifestSummary["usage"] {
|
|
586
|
+
const periods = manifestDailyPeriods(summary, from, to);
|
|
587
|
+
const aggregate = (key: keyof LifecycleManifestSummary["usage"]) => {
|
|
588
|
+
const values = periods.map(([, period]) => period.usage[key]);
|
|
589
|
+
const runs = periods.reduce((total, [, period]) => total + period.runs, 0);
|
|
590
|
+
return {
|
|
591
|
+
known_sum: values.reduce((total, value) => total + value.known_sum, 0),
|
|
592
|
+
unknown: values.reduce((total, value) => total + value.unknown, 0),
|
|
593
|
+
complete: values.every((value) => value.complete),
|
|
594
|
+
coverage_ratio:
|
|
595
|
+
runs === 0
|
|
596
|
+
? 1
|
|
597
|
+
: periods.reduce(
|
|
598
|
+
(total, [, period]) => total + period.runs * period.usage[key].coverage_ratio,
|
|
599
|
+
0,
|
|
600
|
+
) / runs,
|
|
601
|
+
};
|
|
602
|
+
};
|
|
603
|
+
return {
|
|
604
|
+
input_tokens: aggregate("input_tokens"),
|
|
605
|
+
output_tokens: aggregate("output_tokens"),
|
|
606
|
+
total_tokens: aggregate("total_tokens"),
|
|
607
|
+
cost: { ...aggregate("cost"), currency: summary.usage.cost.currency },
|
|
608
|
+
} as LifecycleManifestSummary["usage"];
|
|
609
|
+
}
|
|
@@ -19,17 +19,20 @@ export async function readScopedRuns(
|
|
|
19
19
|
const runs = (
|
|
20
20
|
await mapLimited<string, ScopedRun | null>(paths, 32, async (path) => {
|
|
21
21
|
const fold = foldRunV2Records(parseRunV2JsonLines(await filesystem.readText(path)));
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
// Operations assigns a completed Run to its terminal instant, matching
|
|
23
|
+
// the compact manifest and the client-side period contract. Once the
|
|
24
|
+
// Run is selected, retain all of its settled usage rather than slicing
|
|
25
|
+
// individual capture records into a different population.
|
|
26
|
+
const periodTimestamp = fold.finished?.occurred_at ?? fold.run.occurred_at;
|
|
27
|
+
if ((filter.from !== null || filter.to !== null) && !inWindow(periodTimestamp, filter))
|
|
28
|
+
return null;
|
|
24
29
|
const scoped: ScopedRun = {
|
|
25
30
|
fold,
|
|
26
31
|
artifactPath: path,
|
|
27
32
|
cost: {
|
|
28
33
|
run: fold.run,
|
|
29
|
-
records,
|
|
30
|
-
effective_usage_records: fold.effective_usage_records
|
|
31
|
-
inWindow(record.occurred_at, filter),
|
|
32
|
-
),
|
|
34
|
+
records: fold.records,
|
|
35
|
+
effective_usage_records: fold.effective_usage_records,
|
|
33
36
|
},
|
|
34
37
|
};
|
|
35
38
|
return scoped;
|
|
@@ -52,20 +55,16 @@ export async function mapLimited<T, R>(
|
|
|
52
55
|
return results;
|
|
53
56
|
}
|
|
54
57
|
|
|
55
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* A Run is filed under its start month but belongs to Operations by terminal
|
|
60
|
+
* capture when complete. A bounded start-month scan drops start-before,
|
|
61
|
+
* finish-inside Runs, so detail must inspect the complete Run index before
|
|
62
|
+
* applying the shared terminal-time predicate. Quick cards remain snapshot
|
|
63
|
+
* backed and do not pay this cost.
|
|
64
|
+
*/
|
|
56
65
|
export function runSearchRoots(root: string, filter: ProjectionTimeFilter): string[] {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const cursor = new Date(filter.from);
|
|
60
|
-
const end = new Date(filter.to);
|
|
61
|
-
cursor.setUTCDate(1);
|
|
62
|
-
while (cursor <= end) {
|
|
63
|
-
months.add(
|
|
64
|
-
`${root}/${cursor.getUTCFullYear()}/${String(cursor.getUTCMonth() + 1).padStart(2, "0")}`,
|
|
65
|
-
);
|
|
66
|
-
cursor.setUTCMonth(cursor.getUTCMonth() + 1);
|
|
67
|
-
}
|
|
68
|
-
return [...months];
|
|
66
|
+
void filter;
|
|
67
|
+
return [root];
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
function inWindow(timestamp: string, filter: ProjectionTimeFilter): boolean {
|