@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/build-operations-projection.ts
CHANGED
|
@@ -12,20 +12,25 @@ import {
|
|
|
12
12
|
PrdV2Repository,
|
|
13
13
|
} from "@zaip-ai/specs";
|
|
14
14
|
import { type TaskV2, TaskV2Repository } from "@zaip-ai/tasks";
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
type OperationsProjection,
|
|
18
|
-
type ProjectionTimeFilter,
|
|
19
|
-
type RunProjection,
|
|
20
|
-
saoPauloPeriodKey,
|
|
21
|
-
} from "../contracts.js";
|
|
22
|
-
import { rootExecutionDurationRuns } from "../duration-population.js";
|
|
15
|
+
import type { OperationsProjection, ProjectionTimeFilter, RunProjection } from "../contracts.js";
|
|
16
|
+
import { observedExecutionElapsedMs, rootExecutionDurationRuns } from "../duration-population.js";
|
|
23
17
|
import { taskIdsWithStartedExecution } from "../work-readiness.js";
|
|
24
18
|
import { manifestQualityProjection, taskTelemetry } from "./build-operations-projection-helpers.js";
|
|
25
|
-
import {
|
|
19
|
+
import { projectCanonicalRun } from "./canonical-run-projection.js";
|
|
20
|
+
import { projectExecutionDurations } from "./execution-duration-projection.js";
|
|
26
21
|
import { executionRelationshipCounts } from "./execution-relationship-counts.js";
|
|
27
22
|
import { normalizeFilter } from "./filter.js";
|
|
23
|
+
import {
|
|
24
|
+
createManifestDescendantQueries,
|
|
25
|
+
type ManifestDecision,
|
|
26
|
+
manifestMacroProjection,
|
|
27
|
+
manifestUsageProjection,
|
|
28
|
+
} from "./operations-projection-aggregates.js";
|
|
28
29
|
import { plannedTaskPreviews, taskExecutionIds } from "./planned-task-previews.js";
|
|
30
|
+
import {
|
|
31
|
+
aggregateOverviewRunMetrics,
|
|
32
|
+
buildQuickOperationsProjection,
|
|
33
|
+
} from "./quick-operations-projection.js";
|
|
29
34
|
import { recentRunsFirst } from "./run-order.js";
|
|
30
35
|
import { readScopedRuns } from "./runs.js";
|
|
31
36
|
import { countTaskTestArtifacts } from "./task-test-counts.js";
|
|
@@ -33,7 +38,6 @@ import {
|
|
|
33
38
|
decisionCounts,
|
|
34
39
|
executionWorkStatus,
|
|
35
40
|
latestTimestamp,
|
|
36
|
-
macroWorkStatus,
|
|
37
41
|
reconciliation,
|
|
38
42
|
taskProgress,
|
|
39
43
|
} from "./usage.js";
|
|
@@ -43,49 +47,52 @@ export {
|
|
|
43
47
|
latestObservedSourceTiming,
|
|
44
48
|
observedSourceTiming,
|
|
45
49
|
} from "./canonical-compat.js";
|
|
50
|
+
export { effectiveOperationsDurationMs } from "./canonical-run-projection.js";
|
|
51
|
+
export { projectExecutionDurations } from "./execution-duration-projection.js";
|
|
52
|
+
export {
|
|
53
|
+
observedMacroRunTelemetry,
|
|
54
|
+
recalculateOperationsRunSummary,
|
|
55
|
+
} from "./operations-projection-aggregates.js";
|
|
46
56
|
|
|
47
57
|
export function overviewMetricTotals(
|
|
48
58
|
runs: readonly {
|
|
49
59
|
id: string;
|
|
50
60
|
started_at: string;
|
|
61
|
+
finished_at?: string | null;
|
|
62
|
+
source_started_at?: string | null;
|
|
63
|
+
duration_started_at?: string | null;
|
|
64
|
+
phase?: string;
|
|
65
|
+
parent_run_id?: string | null;
|
|
51
66
|
source_duration_ms?: number | null;
|
|
52
67
|
duration_ms: number | null;
|
|
53
68
|
duration_provenance?: RunProjection["duration_provenance"];
|
|
54
69
|
usage: { total: { tokens: { total: number | null }; cost: { brl: number | null } } };
|
|
55
70
|
}[],
|
|
56
|
-
|
|
71
|
+
range: { from: string | null; to: string | null },
|
|
57
72
|
) {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
const metrics = aggregateOverviewRunMetrics(
|
|
74
|
+
runs.map((run) => ({
|
|
75
|
+
id: run.id,
|
|
76
|
+
started_at: run.started_at,
|
|
77
|
+
finished_at: run.finished_at ?? null,
|
|
78
|
+
phase: run.phase ?? null,
|
|
79
|
+
parent_run_id: run.parent_run_id ?? null,
|
|
80
|
+
duration_started_at: run.source_started_at ?? run.duration_started_at ?? null,
|
|
81
|
+
duration_ms:
|
|
82
|
+
run.source_duration_ms !== null && run.source_duration_ms !== undefined
|
|
83
|
+
? run.source_duration_ms
|
|
84
|
+
: run.duration_ms,
|
|
85
|
+
total_tokens: run.usage.total.tokens.total,
|
|
86
|
+
cost: run.usage.total.cost.brl,
|
|
87
|
+
})),
|
|
88
|
+
range,
|
|
89
|
+
false,
|
|
90
|
+
);
|
|
76
91
|
return {
|
|
77
|
-
duration_ms:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
: observedDurations.reduce((sum, value) => sum + value, 0),
|
|
82
|
-
execution_day_count: new Set(
|
|
83
|
-
executionRoots
|
|
84
|
-
.map((run) => saoPauloPeriodKey(run.started_at, "day"))
|
|
85
|
-
.filter((value): value is string => value !== null),
|
|
86
|
-
).size,
|
|
87
|
-
tokens: numeric(unique.map((run) => run.usage.total.tokens.total)),
|
|
88
|
-
cost_brl: numeric(unique.map((run) => run.usage.total.cost.brl)),
|
|
92
|
+
duration_ms: metrics.duration_ms,
|
|
93
|
+
execution_day_count: metrics.execution_day_count,
|
|
94
|
+
tokens: metrics.tokens,
|
|
95
|
+
cost_brl: metrics.cost_brl,
|
|
89
96
|
};
|
|
90
97
|
}
|
|
91
98
|
|
|
@@ -93,7 +100,11 @@ export async function buildOperationsProjection(
|
|
|
93
100
|
filesystem: WorkspaceFileSystem,
|
|
94
101
|
layout: WorkspaceLayout,
|
|
95
102
|
filter: Partial<ProjectionTimeFilter> = {},
|
|
96
|
-
options: {
|
|
103
|
+
options: {
|
|
104
|
+
overviewOnly?: boolean;
|
|
105
|
+
skipTestArtifacts?: boolean;
|
|
106
|
+
includeOverviewChanges?: boolean;
|
|
107
|
+
} = {},
|
|
97
108
|
): Promise<OperationsProjection> {
|
|
98
109
|
if (layout.version === 1)
|
|
99
110
|
throw new Error("Operations projection requires a modern WorkspaceLayout");
|
|
@@ -107,7 +118,11 @@ export async function buildOperationsProjection(
|
|
|
107
118
|
const decisionsRepository = new DecisionV2Repository(filesystem, layout);
|
|
108
119
|
const [entities, scopedRuns] = await Promise.all([
|
|
109
120
|
manifest.readEntities(),
|
|
110
|
-
|
|
121
|
+
// The overview is backed by durable aggregates. Details and Run pages
|
|
122
|
+
// load separately; reading every Run here defeats first-paint sharding.
|
|
123
|
+
options.overviewOnly
|
|
124
|
+
? Promise.resolve([])
|
|
125
|
+
: readScopedRuns(filesystem, layout, normalizedFilter),
|
|
111
126
|
]);
|
|
112
127
|
if (
|
|
113
128
|
entities.length === 0 &&
|
|
@@ -124,18 +139,28 @@ export async function buildOperationsProjection(
|
|
|
124
139
|
const allExecutions = manifestData<ExecutionV2>(entities, "execution");
|
|
125
140
|
const allTasks = manifestData<TaskV2>(entities, "task");
|
|
126
141
|
const allDecisions = manifestDecisions(entities);
|
|
142
|
+
const allEvidences = manifestEvidences(entities);
|
|
143
|
+
const allValidations = manifestValidations(entities);
|
|
127
144
|
// Run manifests remain the canonical source for lifecycle entities. Run
|
|
128
145
|
// records retain independently observed source intervals (including
|
|
129
146
|
// Sub-Runs), which Operations uses for duration totals.
|
|
130
147
|
const allRuns = scopedRuns.map(projectCanonicalRun);
|
|
131
|
-
const prds = allPrds.filter((row) =>
|
|
132
|
-
const specs = allSpecs.filter((row) =>
|
|
148
|
+
const prds = allPrds.filter((row) => macroInWindow(row.status, row.updated_at, normalizedFilter));
|
|
149
|
+
const specs = allSpecs.filter((row) =>
|
|
150
|
+
macroInWindow(row.status, row.updated_at, normalizedFilter),
|
|
151
|
+
);
|
|
133
152
|
const changes = allChanges.filter((row) => lifecycleRowInWindow(row, normalizedFilter));
|
|
134
153
|
const executions = allExecutions.filter((row) => lifecycleRowInWindow(row, normalizedFilter));
|
|
135
154
|
const tasks = allTasks.filter((row) => lifecycleRowInWindow(row, normalizedFilter));
|
|
136
155
|
const decisions = allDecisions.filter((row) =>
|
|
137
156
|
timestampInWindow(row.created_at, normalizedFilter),
|
|
138
157
|
);
|
|
158
|
+
const evidences = allEvidences.filter((row) =>
|
|
159
|
+
timestampInWindow(row.observed_at, normalizedFilter),
|
|
160
|
+
);
|
|
161
|
+
const validations = allValidations.filter((row) =>
|
|
162
|
+
timestampInWindow(row.executed_at, normalizedFilter),
|
|
163
|
+
);
|
|
139
164
|
const filteredRuns = allRuns.filter((row) =>
|
|
140
165
|
timestampInWindow(row.finished_at ?? row.started_at, normalizedFilter),
|
|
141
166
|
);
|
|
@@ -225,10 +250,25 @@ export async function buildOperationsProjection(
|
|
|
225
250
|
});
|
|
226
251
|
const allUsage = manifestUsageProjection(runs);
|
|
227
252
|
const executionRuns = rootExecutionDurationRuns(runs);
|
|
228
|
-
const overviewMetrics = overviewMetricTotals(
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
253
|
+
const overviewMetrics = overviewMetricTotals(runs, normalizedFilter);
|
|
254
|
+
const aggregateOverview = options.overviewOnly
|
|
255
|
+
? await buildQuickOperationsProjection(filesystem, layout, normalizedFilter)
|
|
256
|
+
: null;
|
|
257
|
+
const taskStatusCounts = countBy(tasks, (task) => task.status);
|
|
258
|
+
const taskRiskCounts = countBy(tasks, (task) => task.risk);
|
|
259
|
+
const deliveredMacros = deliveredMacroCounts(prds, specs);
|
|
260
|
+
const entityOverview = {
|
|
261
|
+
prd_count: prdRows.length,
|
|
262
|
+
spec_count: specRows.length,
|
|
263
|
+
selected_counts: { prds: prdRows.length, specs: specRows.length },
|
|
264
|
+
task_count: tasks.length,
|
|
265
|
+
completed_prd_count: deliveredMacros.prds,
|
|
266
|
+
completed_spec_count: deliveredMacros.specs,
|
|
267
|
+
completed_task_count: taskStatusCounts.completed ?? 0,
|
|
268
|
+
task_status_counts: taskStatusCounts,
|
|
269
|
+
task_risk_counts: taskRiskCounts,
|
|
270
|
+
latest_task_created_at: latestTimestamp(tasks.map((task) => task.created_at)),
|
|
271
|
+
};
|
|
232
272
|
const origins = {
|
|
233
273
|
conversation: manifestUsageProjection(runs.filter((run) => run.entrypoint === "conversation")),
|
|
234
274
|
task: manifestUsageProjection(runs.filter((run) => run.entrypoint === "task")),
|
|
@@ -248,39 +288,39 @@ export async function buildOperationsProjection(
|
|
|
248
288
|
execution_count: executions.length,
|
|
249
289
|
task_count: tasks.length,
|
|
250
290
|
run_count: runs.length,
|
|
251
|
-
execution_duration_ms: executionRuns
|
|
291
|
+
execution_duration_ms: observedExecutionElapsedMs(executionRuns) ?? 0,
|
|
252
292
|
execution_day_count: new Set(executionRuns.map((run) => run.started_at.slice(0, 10))).size,
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
},
|
|
258
|
-
}
|
|
259
|
-
: {}),
|
|
293
|
+
overview_metrics:
|
|
294
|
+
aggregateOverview?.summary.overview_metrics === undefined
|
|
295
|
+
? { ...overviewMetrics, ...entityOverview, data_source: "run_records", partial: false }
|
|
296
|
+
: { ...aggregateOverview.summary.overview_metrics, ...entityOverview, partial: false },
|
|
260
297
|
decisions: decisionCounts(decisions),
|
|
261
|
-
source_latest_at:
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
298
|
+
source_latest_at:
|
|
299
|
+
aggregateOverview?.summary.source_latest_at ??
|
|
300
|
+
latestTimestamp([
|
|
301
|
+
...prds.map((prd) => prd.updated_at),
|
|
302
|
+
...specs.map((spec) => spec.updated_at),
|
|
303
|
+
...changes.map((change) => change.updated_at),
|
|
304
|
+
...executions.map((execution) => execution.updated_at),
|
|
305
|
+
...tasks.map((task) => task.updated_at),
|
|
306
|
+
...decisions.map((decision) => decision.created_at),
|
|
307
|
+
...runs.map((run) => run.finished_at ?? run.started_at),
|
|
308
|
+
]),
|
|
270
309
|
quality: manifestQualityProjection(tasks, runs),
|
|
271
310
|
reconciliation: reconciliation(allUsage, origins),
|
|
272
|
-
usage: allUsage,
|
|
311
|
+
usage: aggregateOverview?.summary.usage ?? allUsage,
|
|
273
312
|
},
|
|
274
313
|
origins,
|
|
275
314
|
prds: prdRows,
|
|
276
315
|
specs: specRows,
|
|
277
316
|
tasks: taskRows,
|
|
278
|
-
changes:
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
317
|
+
changes:
|
|
318
|
+
options.overviewOnly && !options.includeOverviewChanges
|
|
319
|
+
? []
|
|
320
|
+
: changes.map((change) => ({
|
|
321
|
+
...change,
|
|
322
|
+
artifact_path: changesRepository.path(change.id),
|
|
323
|
+
})),
|
|
284
324
|
executions: options.overviewOnly
|
|
285
325
|
? []
|
|
286
326
|
: executions.map((execution) => ({
|
|
@@ -292,6 +332,9 @@ export async function buildOperationsProjection(
|
|
|
292
332
|
agent: run.agent,
|
|
293
333
|
call_count: run.call_count,
|
|
294
334
|
duration_ms: run.duration_ms,
|
|
335
|
+
...(run.duration_provenance === undefined
|
|
336
|
+
? {}
|
|
337
|
+
: { duration_provenance: run.duration_provenance }),
|
|
295
338
|
execution_id: run.execution_id,
|
|
296
339
|
finished_at: run.finished_at,
|
|
297
340
|
parent_run_id: run.parent_run_id,
|
|
@@ -300,6 +343,7 @@ export async function buildOperationsProjection(
|
|
|
300
343
|
started_at: run.started_at,
|
|
301
344
|
status: run.status,
|
|
302
345
|
task_id: run.task_id,
|
|
346
|
+
usage: run.usage.total,
|
|
303
347
|
})),
|
|
304
348
|
tasks,
|
|
305
349
|
changes,
|
|
@@ -309,6 +353,8 @@ export async function buildOperationsProjection(
|
|
|
309
353
|
work_status: executionWorkStatus(execution.status),
|
|
310
354
|
})),
|
|
311
355
|
runs: options.overviewOnly ? [] : recentRunsFirst(runs),
|
|
356
|
+
evidences,
|
|
357
|
+
validations,
|
|
312
358
|
decisions: options.overviewOnly
|
|
313
359
|
? []
|
|
314
360
|
: decisions.map((decision) => ({
|
|
@@ -327,14 +373,59 @@ export async function buildOperationsProjection(
|
|
|
327
373
|
};
|
|
328
374
|
}
|
|
329
375
|
|
|
330
|
-
|
|
331
|
-
"
|
|
332
|
-
"
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
376
|
+
export function deliveredMacroCounts(
|
|
377
|
+
prds: readonly Pick<PrdV2, "status">[],
|
|
378
|
+
specs: readonly Pick<DeliverySpecV2, "status">[],
|
|
379
|
+
): { prds: number; specs: number } {
|
|
380
|
+
return {
|
|
381
|
+
prds: prds.filter((prd) => prd.status === "delivered").length,
|
|
382
|
+
specs: specs.filter((spec) => spec.status === "delivered").length,
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function countBy<T>(values: readonly T[], key: (value: T) => string): Record<string, number> {
|
|
387
|
+
return values.reduce<Record<string, number>>((counts, value) => {
|
|
388
|
+
const name = key(value);
|
|
389
|
+
counts[name] = (counts[name] ?? 0) + 1;
|
|
390
|
+
return counts;
|
|
391
|
+
}, {});
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
function manifestValidations(
|
|
395
|
+
entities: readonly LifecycleManifestEntity[],
|
|
396
|
+
): NonNullable<OperationsProjection["validations"]> {
|
|
397
|
+
return entities.flatMap((entity) => {
|
|
398
|
+
const data = entity.data;
|
|
399
|
+
if (entity.kind !== "validation" || data === null || typeof data.executed_at !== "string") {
|
|
400
|
+
return [];
|
|
401
|
+
}
|
|
402
|
+
return [
|
|
403
|
+
{
|
|
404
|
+
id: entity.id,
|
|
405
|
+
task_id: typeof data.task_id === "string" ? data.task_id : null,
|
|
406
|
+
executed_at: data.executed_at,
|
|
407
|
+
},
|
|
408
|
+
];
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
function manifestEvidences(
|
|
413
|
+
entities: readonly LifecycleManifestEntity[],
|
|
414
|
+
): NonNullable<OperationsProjection["evidences"]> {
|
|
415
|
+
return entities.flatMap((entity) => {
|
|
416
|
+
const data = entity.data;
|
|
417
|
+
if (entity.kind !== "evidence" || data === null || typeof data.observed_at !== "string") {
|
|
418
|
+
return [];
|
|
419
|
+
}
|
|
420
|
+
return [
|
|
421
|
+
{
|
|
422
|
+
id: entity.id,
|
|
423
|
+
task_id: typeof data.task_id === "string" ? data.task_id : null,
|
|
424
|
+
observed_at: data.observed_at,
|
|
425
|
+
},
|
|
426
|
+
];
|
|
427
|
+
});
|
|
428
|
+
}
|
|
338
429
|
|
|
339
430
|
function manifestData<T>(
|
|
340
431
|
entities: readonly LifecycleManifestEntity[],
|
|
@@ -357,15 +448,6 @@ function manifestData<T>(
|
|
|
357
448
|
);
|
|
358
449
|
}
|
|
359
450
|
|
|
360
|
-
interface ManifestDecision {
|
|
361
|
-
id: string;
|
|
362
|
-
title: string;
|
|
363
|
-
origin: "human" | "agent";
|
|
364
|
-
scope_type: "change" | "execution";
|
|
365
|
-
scope_id: string;
|
|
366
|
-
created_at: string;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
451
|
function manifestDecisions(entities: readonly LifecycleManifestEntity[]): ManifestDecision[] {
|
|
370
452
|
return entities.flatMap((entity) => {
|
|
371
453
|
if (entity.kind !== "decision" || entity.data === null) return [];
|
|
@@ -375,9 +457,8 @@ function manifestDecisions(entities: readonly LifecycleManifestEntity[]): Manife
|
|
|
375
457
|
(data.scope_type !== "change" && data.scope_type !== "execution") ||
|
|
376
458
|
typeof data.scope_id !== "string" ||
|
|
377
459
|
typeof data.created_at !== "string"
|
|
378
|
-
)
|
|
460
|
+
)
|
|
379
461
|
return [];
|
|
380
|
-
}
|
|
381
462
|
return [
|
|
382
463
|
{
|
|
383
464
|
id: entity.id,
|
|
@@ -395,10 +476,18 @@ function lifecycleRowInWindow(
|
|
|
395
476
|
row: { status: string; updated_at: string; finished_at?: string | null },
|
|
396
477
|
filter: ProjectionTimeFilter,
|
|
397
478
|
): boolean {
|
|
398
|
-
if (!TERMINAL_LIFECYCLE_STATUSES.has(row.status)) return true;
|
|
399
479
|
return timestampInWindow(row.finished_at ?? row.updated_at, filter);
|
|
400
480
|
}
|
|
401
481
|
|
|
482
|
+
function macroInWindow(
|
|
483
|
+
lifecycleStatus: string | null | undefined,
|
|
484
|
+
updatedAt: string,
|
|
485
|
+
filter: ProjectionTimeFilter,
|
|
486
|
+
): boolean {
|
|
487
|
+
void lifecycleStatus;
|
|
488
|
+
return timestampInWindow(updatedAt, filter);
|
|
489
|
+
}
|
|
490
|
+
|
|
402
491
|
function timestampInWindow(timestamp: string, filter: ProjectionTimeFilter): boolean {
|
|
403
492
|
const normalized = new Date(timestamp).toISOString();
|
|
404
493
|
return (
|
|
@@ -406,382 +495,3 @@ function timestampInWindow(timestamp: string, filter: ProjectionTimeFilter): boo
|
|
|
406
495
|
(filter.to === null || normalized <= filter.to)
|
|
407
496
|
);
|
|
408
497
|
}
|
|
409
|
-
|
|
410
|
-
function _projectManifestRun(
|
|
411
|
-
entity: LifecycleManifestEntity,
|
|
412
|
-
layout: WorkspaceLayout,
|
|
413
|
-
): OperationsProjection["runs"][number] {
|
|
414
|
-
const data = entity.data ?? {};
|
|
415
|
-
const startedAt = stringValue(data.started_at) ?? entity.updated_at;
|
|
416
|
-
const finishedAt = stringValue(data.finished_at);
|
|
417
|
-
const sourceDurationMs = numberValue(data.source_duration_ms);
|
|
418
|
-
const lifecycleDurationMs =
|
|
419
|
-
finishedAt === null ? null : Math.max(0, Date.parse(finishedAt) - Date.parse(startedAt));
|
|
420
|
-
const runUsage = usageFromManifestData(data.entrypoint_usage, stringValue(data.work_type));
|
|
421
|
-
return {
|
|
422
|
-
id: entity.id,
|
|
423
|
-
artifact_path: layout.activePath("run", entity.id),
|
|
424
|
-
status: runStatus(entity.status),
|
|
425
|
-
phase: stringValue(data.phase) ?? "execution",
|
|
426
|
-
entrypoint: entrypointValue(data.entrypoint),
|
|
427
|
-
work_type: data.work_type === "rework" ? "rework" : "new",
|
|
428
|
-
run_role: runRoleValue(data.run_role),
|
|
429
|
-
run_kind: data.run_kind === "subrun" ? "subrun" : "run",
|
|
430
|
-
run_purpose: runPurposeValue(data.run_purpose),
|
|
431
|
-
requires_finalizer: data.requires_finalizer === true,
|
|
432
|
-
parent_run_id: stringValue(data.parent_run_id),
|
|
433
|
-
client: stringValue(data.client) ?? "unknown",
|
|
434
|
-
agent: stringValue(data.agent) ?? "unknown",
|
|
435
|
-
agent_name: stringValue(data.agent_name) ?? stringValue(data.agent) ?? "unknown",
|
|
436
|
-
provider: stringValue(data.provider),
|
|
437
|
-
model: stringValue(data.model) ?? "unknown",
|
|
438
|
-
reasoning_effort: stringValue(data.reasoning_effort),
|
|
439
|
-
effective_model: stringValue(data.effective_model),
|
|
440
|
-
effective_reasoning_effort: stringValue(data.effective_reasoning_effort),
|
|
441
|
-
effective_config_mixed: data.effective_config_mixed === true,
|
|
442
|
-
service_tier: stringValue(data.service_tier),
|
|
443
|
-
call_count: numberValue(data.call_count),
|
|
444
|
-
terminal_call_count: numberValue(data.terminal_call_count),
|
|
445
|
-
failed_call_count: numberValue(data.failed_call_count),
|
|
446
|
-
cancelled_call_count: numberValue(data.cancelled_call_count),
|
|
447
|
-
conversation_id: stringValue(data.conversation_id) ?? "unknown",
|
|
448
|
-
client_thread_id: stringValue(data.client_thread_id),
|
|
449
|
-
client_turn_id: stringValue(data.client_turn_id),
|
|
450
|
-
execution_id: stringValue(data.execution_id),
|
|
451
|
-
task_id: stringValue(data.task_id),
|
|
452
|
-
spec_id: stringValue(data.spec_id),
|
|
453
|
-
prd_id: stringValue(data.prd_id),
|
|
454
|
-
change_id: stringValue(data.change_id),
|
|
455
|
-
started_at: startedAt,
|
|
456
|
-
finished_at: finishedAt,
|
|
457
|
-
duration_ms: effectiveOperationsDurationMs(sourceDurationMs, lifecycleDurationMs),
|
|
458
|
-
source_started_at: stringValue(data.source_started_at),
|
|
459
|
-
source_finished_at: stringValue(data.source_finished_at),
|
|
460
|
-
source_duration_ms: sourceDurationMs,
|
|
461
|
-
capture_lag_ms: numberValue(data.capture_lag_ms),
|
|
462
|
-
pricing_segments: Array.isArray(data.pricing_segments)
|
|
463
|
-
? (data.pricing_segments as NonNullable<
|
|
464
|
-
OperationsProjection["runs"][number]["pricing_segments"]
|
|
465
|
-
>)
|
|
466
|
-
: [],
|
|
467
|
-
usage: runUsage,
|
|
468
|
-
};
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
export { effectiveOperationsDurationMs } from "./canonical-run-projection.js";
|
|
472
|
-
|
|
473
|
-
export function projectExecutionDurations<T extends RunProjection>(runs: readonly T[]): T[] {
|
|
474
|
-
return runs.map((run) => {
|
|
475
|
-
if (typeof run.source_duration_ms === "number" && run.source_duration_ms > 0) {
|
|
476
|
-
return {
|
|
477
|
-
...run,
|
|
478
|
-
duration_ms: run.source_duration_ms,
|
|
479
|
-
duration_provenance: "observed",
|
|
480
|
-
estimation_basis: null,
|
|
481
|
-
};
|
|
482
|
-
}
|
|
483
|
-
if (
|
|
484
|
-
typeof run.duration_ms === "number" &&
|
|
485
|
-
run.duration_ms > 0 &&
|
|
486
|
-
(run.duration_provenance === "reconciled" || run.duration_provenance === "legacy_inferred")
|
|
487
|
-
) {
|
|
488
|
-
return { ...run, estimation_basis: null };
|
|
489
|
-
}
|
|
490
|
-
return {
|
|
491
|
-
...run,
|
|
492
|
-
duration_ms: null,
|
|
493
|
-
duration_provenance: "unavailable",
|
|
494
|
-
estimation_basis: null,
|
|
495
|
-
};
|
|
496
|
-
});
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
function usageFromManifestData(value: unknown, workType: string | null) {
|
|
500
|
-
const source = recordValue(value);
|
|
501
|
-
const conversation = metricFromManifestBucket(source?.conversation);
|
|
502
|
-
const planning = metricFromManifestBucket(source?.planning);
|
|
503
|
-
const execution = metricFromManifestBucket(source?.execution);
|
|
504
|
-
const total = metricFromManifestBucket(source?.total);
|
|
505
|
-
return {
|
|
506
|
-
conversation,
|
|
507
|
-
planning,
|
|
508
|
-
execution,
|
|
509
|
-
total,
|
|
510
|
-
new_work: workType === "rework" ? emptyUsageMetric() : total,
|
|
511
|
-
rework: workType === "rework" ? total : emptyUsageMetric(),
|
|
512
|
-
};
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
function metricFromManifestBucket(value: unknown) {
|
|
516
|
-
const bucket = recordValue(value);
|
|
517
|
-
const tokens = recordValue(bucket?.tokens);
|
|
518
|
-
const cost = recordValue(bucket?.cost);
|
|
519
|
-
const coverage = recordValue(bucket?.coverage);
|
|
520
|
-
return {
|
|
521
|
-
events: numberValue(bucket?.usage_event_count) ?? 0,
|
|
522
|
-
tokens: {
|
|
523
|
-
input: numberValue(tokens?.input),
|
|
524
|
-
cached_input: numberValue(tokens?.cached_input),
|
|
525
|
-
output: numberValue(tokens?.output),
|
|
526
|
-
reasoning: numberValue(tokens?.reasoning),
|
|
527
|
-
total: numberValue(tokens?.total),
|
|
528
|
-
},
|
|
529
|
-
cost: {
|
|
530
|
-
usd: numberValue(cost?.usd),
|
|
531
|
-
brl: numberValue(cost?.brl),
|
|
532
|
-
},
|
|
533
|
-
coverage: {
|
|
534
|
-
events: numberValue(coverage?.events) ?? 0,
|
|
535
|
-
tokens: numberValue(coverage?.tokens) ?? 0,
|
|
536
|
-
usd: numberValue(coverage?.usd) ?? 0,
|
|
537
|
-
brl: numberValue(coverage?.brl) ?? 0,
|
|
538
|
-
},
|
|
539
|
-
};
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
function emptyUsageMetric(): OperationsProjection["summary"]["usage"]["total"] {
|
|
543
|
-
return {
|
|
544
|
-
events: 0,
|
|
545
|
-
tokens: { input: null, cached_input: null, output: null, reasoning: null, total: null },
|
|
546
|
-
cost: { usd: null, brl: null },
|
|
547
|
-
coverage: { events: 0, tokens: 0, usd: 0, brl: 0 },
|
|
548
|
-
};
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
function manifestUsageProjection(
|
|
552
|
-
runs: readonly OperationsProjection["runs"][number][],
|
|
553
|
-
): OperationsProjection["summary"]["usage"] {
|
|
554
|
-
const sumMetric = (
|
|
555
|
-
selector: (
|
|
556
|
-
run: OperationsProjection["runs"][number],
|
|
557
|
-
) => OperationsProjection["summary"]["usage"]["total"],
|
|
558
|
-
) => {
|
|
559
|
-
const metrics = runs.map(selector);
|
|
560
|
-
const sumNullable = (values: readonly (number | null)[]) => {
|
|
561
|
-
const known = values.filter((value): value is number => value !== null);
|
|
562
|
-
return known.length === 0 ? null : known.reduce((sum, value) => sum + value, 0);
|
|
563
|
-
};
|
|
564
|
-
return {
|
|
565
|
-
events: metrics.reduce((sum, metric) => sum + metric.events, 0),
|
|
566
|
-
tokens: {
|
|
567
|
-
input: sumNullable(metrics.map((metric) => metric.tokens.input)),
|
|
568
|
-
cached_input: sumNullable(metrics.map((metric) => metric.tokens.cached_input)),
|
|
569
|
-
output: sumNullable(metrics.map((metric) => metric.tokens.output)),
|
|
570
|
-
reasoning: sumNullable(metrics.map((metric) => metric.tokens.reasoning)),
|
|
571
|
-
total: sumNullable(metrics.map((metric) => metric.tokens.total)),
|
|
572
|
-
},
|
|
573
|
-
cost: {
|
|
574
|
-
usd: sumNullable(metrics.map((metric) => metric.cost.usd)),
|
|
575
|
-
brl: sumNullable(metrics.map((metric) => metric.cost.brl)),
|
|
576
|
-
},
|
|
577
|
-
coverage: {
|
|
578
|
-
events: metrics.reduce((sum, metric) => sum + metric.coverage.events, 0),
|
|
579
|
-
tokens: metrics.reduce((sum, metric) => sum + metric.coverage.tokens, 0),
|
|
580
|
-
usd: metrics.reduce((sum, metric) => sum + metric.coverage.usd, 0),
|
|
581
|
-
brl: metrics.reduce((sum, metric) => sum + metric.coverage.brl, 0),
|
|
582
|
-
},
|
|
583
|
-
};
|
|
584
|
-
};
|
|
585
|
-
return {
|
|
586
|
-
conversation: sumMetric((run) => run.usage.conversation),
|
|
587
|
-
planning: sumMetric((run) => run.usage.planning),
|
|
588
|
-
execution: sumMetric((run) => run.usage.execution),
|
|
589
|
-
total: sumMetric((run) => run.usage.total),
|
|
590
|
-
new_work: sumMetric((run) => run.usage.new_work),
|
|
591
|
-
rework: sumMetric((run) => run.usage.rework),
|
|
592
|
-
};
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
export function recalculateOperationsRunSummary(
|
|
596
|
-
operations: OperationsProjection,
|
|
597
|
-
): OperationsProjection {
|
|
598
|
-
const runs = projectExecutionDurations(operations.runs);
|
|
599
|
-
const executionRuns = rootExecutionDurationRuns(runs);
|
|
600
|
-
const allUsage = manifestUsageProjection(runs);
|
|
601
|
-
const origins = {
|
|
602
|
-
conversation: manifestUsageProjection(runs.filter((run) => run.entrypoint === "conversation")),
|
|
603
|
-
task: manifestUsageProjection(runs.filter((run) => run.entrypoint === "task")),
|
|
604
|
-
spec: manifestUsageProjection(runs.filter((run) => run.entrypoint === "spec")),
|
|
605
|
-
prd: manifestUsageProjection(runs.filter((run) => run.entrypoint === "prd")),
|
|
606
|
-
};
|
|
607
|
-
return {
|
|
608
|
-
...operations,
|
|
609
|
-
runs,
|
|
610
|
-
origins,
|
|
611
|
-
summary: {
|
|
612
|
-
...operations.summary,
|
|
613
|
-
run_count: runs.length,
|
|
614
|
-
execution_duration_ms: executionRuns.reduce((sum, run) => sum + (run.duration_ms ?? 0), 0),
|
|
615
|
-
execution_day_count: new Set(executionRuns.map((run) => run.started_at.slice(0, 10))).size,
|
|
616
|
-
source_latest_at: latestTimestamp([
|
|
617
|
-
operations.summary.source_latest_at,
|
|
618
|
-
...runs.map((run) => run.finished_at ?? run.started_at),
|
|
619
|
-
]),
|
|
620
|
-
quality: manifestQualityProjection(operations.tasks, runs),
|
|
621
|
-
reconciliation: reconciliation(allUsage, origins),
|
|
622
|
-
usage: allUsage,
|
|
623
|
-
},
|
|
624
|
-
};
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
function manifestMacroProjection(input: {
|
|
628
|
-
id: string;
|
|
629
|
-
title: string;
|
|
630
|
-
createdAt: string;
|
|
631
|
-
updatedAt: string;
|
|
632
|
-
kind: "prd" | "spec";
|
|
633
|
-
parentId: string | null;
|
|
634
|
-
artifactPath: string;
|
|
635
|
-
lifecycleStatus: string;
|
|
636
|
-
changeIds: ReadonlySet<string>;
|
|
637
|
-
executionIds: ReadonlySet<string>;
|
|
638
|
-
taskIds: ReadonlySet<string>;
|
|
639
|
-
runs: readonly OperationsProjection["runs"][number][];
|
|
640
|
-
decisions: readonly ManifestDecision[];
|
|
641
|
-
executions: ReadonlyMap<string, ExecutionV2>;
|
|
642
|
-
tasks: ReadonlyMap<string, TaskV2>;
|
|
643
|
-
plannedTasks: OperationsProjection["prds"][number]["planned_tasks"];
|
|
644
|
-
}): OperationsProjection["prds"][number] {
|
|
645
|
-
const scopedTasks = [...input.taskIds].flatMap((id) => {
|
|
646
|
-
const task = input.tasks.get(id);
|
|
647
|
-
return task === undefined ? [] : [task];
|
|
648
|
-
});
|
|
649
|
-
const relevantDecisions = input.decisions.filter(
|
|
650
|
-
(decision) =>
|
|
651
|
-
(decision.scope_type === "change" && input.changeIds.has(decision.scope_id)) ||
|
|
652
|
-
(decision.scope_type === "execution" && input.executionIds.has(decision.scope_id)),
|
|
653
|
-
);
|
|
654
|
-
const rootDurations = input.runs.flatMap((run) =>
|
|
655
|
-
run.parent_run_id === null && run.duration_ms !== null ? [run.duration_ms] : [],
|
|
656
|
-
);
|
|
657
|
-
return {
|
|
658
|
-
id: input.id,
|
|
659
|
-
title: input.title,
|
|
660
|
-
created_at: input.createdAt,
|
|
661
|
-
updated_at: input.updatedAt,
|
|
662
|
-
kind: input.kind,
|
|
663
|
-
parent_id: input.parentId,
|
|
664
|
-
artifact_path: input.artifactPath,
|
|
665
|
-
lifecycle_status: input.lifecycleStatus,
|
|
666
|
-
work_status: macroWorkStatus(
|
|
667
|
-
input.lifecycleStatus,
|
|
668
|
-
[...input.executionIds].map((id) => input.executions.get(id)),
|
|
669
|
-
),
|
|
670
|
-
execution_ids: [...input.executionIds].sort(),
|
|
671
|
-
task_ids: [...input.taskIds].sort(),
|
|
672
|
-
planned_tasks: [...input.plannedTasks],
|
|
673
|
-
run_ids: input.runs.map((run) => run.id).sort(),
|
|
674
|
-
execution_count: input.executionIds.size,
|
|
675
|
-
task_count: Math.max(input.taskIds.size, input.plannedTasks.length),
|
|
676
|
-
run_count: input.runs.length,
|
|
677
|
-
duration_ms:
|
|
678
|
-
rootDurations.length === 0
|
|
679
|
-
? null
|
|
680
|
-
: rootDurations.reduce((sum, duration) => sum + duration, 0),
|
|
681
|
-
decisions: decisionCounts(relevantDecisions),
|
|
682
|
-
rework_run_count: input.runs.filter((run) => run.work_type === "rework").length,
|
|
683
|
-
quality: manifestQualityProjection(scopedTasks, input.runs),
|
|
684
|
-
usage: manifestUsageProjection(input.runs),
|
|
685
|
-
};
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
function createManifestDescendantQueries(input: {
|
|
689
|
-
changes: readonly ChangeV2[];
|
|
690
|
-
tasks: readonly TaskV2[];
|
|
691
|
-
executions: readonly ExecutionV2[];
|
|
692
|
-
prds: readonly PrdV2[];
|
|
693
|
-
specs: readonly DeliverySpecV2[];
|
|
694
|
-
runs: readonly OperationsProjection["runs"][number][];
|
|
695
|
-
}) {
|
|
696
|
-
function collect(specIds: ReadonlySet<string>, prdId: string | null) {
|
|
697
|
-
const creationRunIds = new Set(
|
|
698
|
-
[
|
|
699
|
-
...(prdId === null
|
|
700
|
-
? []
|
|
701
|
-
: input.prds.filter((prd) => prd.id === prdId).map((prd) => prd.creation_run_id)),
|
|
702
|
-
...input.specs.filter((spec) => specIds.has(spec.id)).map((spec) => spec.creation_run_id),
|
|
703
|
-
].filter((id): id is string => id !== null && id !== undefined),
|
|
704
|
-
);
|
|
705
|
-
const changeIds = new Set(
|
|
706
|
-
input.changes
|
|
707
|
-
.filter(
|
|
708
|
-
(change) =>
|
|
709
|
-
(prdId !== null && change.source.type === "prd" && change.source.prd_id === prdId) ||
|
|
710
|
-
((change.source.type === "spec" || change.source.type === "prd") &&
|
|
711
|
-
change.source.spec_id !== null &&
|
|
712
|
-
change.source.spec_id !== undefined &&
|
|
713
|
-
specIds.has(change.source.spec_id)),
|
|
714
|
-
)
|
|
715
|
-
.map((change) => change.id),
|
|
716
|
-
);
|
|
717
|
-
const taskIds = new Set(
|
|
718
|
-
input.tasks.filter((task) => changeIds.has(task.change_id)).map((task) => task.id),
|
|
719
|
-
);
|
|
720
|
-
const executionIds = new Set(
|
|
721
|
-
input.executions
|
|
722
|
-
.filter(
|
|
723
|
-
(execution) =>
|
|
724
|
-
(prdId !== null &&
|
|
725
|
-
execution.origin.type === "prd" &&
|
|
726
|
-
execution.origin.prd_id === prdId) ||
|
|
727
|
-
(execution.origin.type === "spec" && specIds.has(execution.origin.spec_id)) ||
|
|
728
|
-
execution.dag.nodes.some((node) => taskIds.has(node.task_id)),
|
|
729
|
-
)
|
|
730
|
-
.map((execution) => execution.id),
|
|
731
|
-
);
|
|
732
|
-
const runs = input.runs.filter(
|
|
733
|
-
(run) =>
|
|
734
|
-
(run.spec_id !== null && specIds.has(run.spec_id)) ||
|
|
735
|
-
(run.task_id !== null && taskIds.has(run.task_id)) ||
|
|
736
|
-
creationRunIds.has(run.id) ||
|
|
737
|
-
(prdId !== null &&
|
|
738
|
-
(run.prd_id === prdId ||
|
|
739
|
-
(run.execution_id !== null && executionIds.has(run.execution_id)))),
|
|
740
|
-
);
|
|
741
|
-
return { changeIds, taskIds, executionIds, runs };
|
|
742
|
-
}
|
|
743
|
-
return {
|
|
744
|
-
forSpec: (specId: string) => collect(new Set([specId]), null),
|
|
745
|
-
forPrd: (prdId: string) =>
|
|
746
|
-
collect(
|
|
747
|
-
new Set(input.specs.filter((spec) => spec.prd_id === prdId).map((spec) => spec.id)),
|
|
748
|
-
prdId,
|
|
749
|
-
),
|
|
750
|
-
};
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
function recordValue(value: unknown): Record<string, unknown> | null {
|
|
754
|
-
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
755
|
-
? (value as Record<string, unknown>)
|
|
756
|
-
: null;
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
function stringValue(value: unknown): string | null {
|
|
760
|
-
return typeof value === "string" && value.length > 0 ? value : null;
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
function numberValue(value: unknown): number | null {
|
|
764
|
-
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
function runStatus(value: string | null): OperationsProjection["runs"][number]["status"] {
|
|
768
|
-
return value === "completed" || value === "failed" || value === "cancelled" ? value : "running";
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
function entrypointValue(value: unknown): OperationsProjection["runs"][number]["entrypoint"] {
|
|
772
|
-
return value === "conversation" || value === "spec" || value === "prd" ? value : "task";
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
function runRoleValue(value: unknown): OperationsProjection["runs"][number]["run_role"] {
|
|
776
|
-
return value === "intake" || value === "subagent" ? value : "orchestrator";
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
function runPurposeValue(value: unknown): OperationsProjection["runs"][number]["run_purpose"] {
|
|
780
|
-
return value === "intake" ||
|
|
781
|
-
value === "execution" ||
|
|
782
|
-
value === "review" ||
|
|
783
|
-
value === "audit" ||
|
|
784
|
-
value === "finalization"
|
|
785
|
-
? value
|
|
786
|
-
: "orchestration";
|
|
787
|
-
}
|