@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
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import type { OperationsProjection } from "@zaip-ai/dashboard-operations/contracts";
|
|
2
|
+
import { type Dispatch, type MutableRefObject, type SetStateAction, useCallback } from "react";
|
|
3
|
+
import {
|
|
4
|
+
isAbortError,
|
|
5
|
+
isCurrentOperationsPageRequest,
|
|
6
|
+
isCurrentOperationsPeriodRequest,
|
|
7
|
+
} from "./AppRequestGuards.js";
|
|
8
|
+
import type {
|
|
9
|
+
DashboardApiClient,
|
|
10
|
+
OperationsEntityPage,
|
|
11
|
+
OperationsEntityPageKind,
|
|
12
|
+
OperationsLifecyclePageKind,
|
|
13
|
+
OperationsPageFilters,
|
|
14
|
+
} from "./dashboard-api.js";
|
|
15
|
+
import { projectEntityPage } from "./operations-entity-page-projection.js";
|
|
16
|
+
import { type OperationsPeriodState, requestPeriodForOperations } from "./operations-period.js";
|
|
17
|
+
|
|
18
|
+
function jsonStringArray(value: unknown): string[] {
|
|
19
|
+
if (typeof value !== "string") return [];
|
|
20
|
+
try {
|
|
21
|
+
const parsed = JSON.parse(value);
|
|
22
|
+
return Array.isArray(parsed)
|
|
23
|
+
? parsed.filter((item): item is string => typeof item === "string")
|
|
24
|
+
: [];
|
|
25
|
+
} catch {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface OperationsEntityPageState {
|
|
31
|
+
offset: number;
|
|
32
|
+
total: number | null;
|
|
33
|
+
loading: boolean;
|
|
34
|
+
error: string | null;
|
|
35
|
+
aggregation?: "canonical_entity" | "page_partial" | undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function useAppOperationsPages({
|
|
39
|
+
api,
|
|
40
|
+
entityFiltersRef,
|
|
41
|
+
operationsPageAbortRef,
|
|
42
|
+
operationsPageRequestVersionRef,
|
|
43
|
+
operationsPeriod,
|
|
44
|
+
operationsPeriodRef,
|
|
45
|
+
refreshVersion,
|
|
46
|
+
setEntityPage,
|
|
47
|
+
setEntityPageKind,
|
|
48
|
+
setOperations,
|
|
49
|
+
}: {
|
|
50
|
+
api: DashboardApiClient;
|
|
51
|
+
entityFiltersRef: MutableRefObject<OperationsPageFilters>;
|
|
52
|
+
operationsPageAbortRef: MutableRefObject<AbortController | null>;
|
|
53
|
+
operationsPageRequestVersionRef: MutableRefObject<number>;
|
|
54
|
+
operationsPeriod: OperationsPeriodState;
|
|
55
|
+
operationsPeriodRef: MutableRefObject<OperationsPeriodState>;
|
|
56
|
+
refreshVersion: MutableRefObject<number>;
|
|
57
|
+
setEntityPage: Dispatch<SetStateAction<OperationsEntityPageState>>;
|
|
58
|
+
setEntityPageKind: Dispatch<
|
|
59
|
+
SetStateAction<OperationsEntityPageKind | OperationsLifecyclePageKind>
|
|
60
|
+
>;
|
|
61
|
+
setOperations: Dispatch<SetStateAction<OperationsProjection | null>>;
|
|
62
|
+
}) {
|
|
63
|
+
const loadOperationsEntityPage = useCallback(
|
|
64
|
+
async (kind: OperationsEntityPageKind, offset = 0, filters = entityFiltersRef.current) => {
|
|
65
|
+
operationsPageAbortRef.current?.abort();
|
|
66
|
+
const controller = new AbortController();
|
|
67
|
+
operationsPageAbortRef.current = controller;
|
|
68
|
+
const requestVersion = ++operationsPageRequestVersionRef.current;
|
|
69
|
+
const dashboardRequestVersion = refreshVersion.current;
|
|
70
|
+
const period = requestPeriodForOperations(operationsPeriod);
|
|
71
|
+
const isCurrentRequest = () =>
|
|
72
|
+
isCurrentOperationsPageRequest(
|
|
73
|
+
requestVersion,
|
|
74
|
+
operationsPageRequestVersionRef.current,
|
|
75
|
+
controller.signal,
|
|
76
|
+
) &&
|
|
77
|
+
isCurrentOperationsPeriodRequest(
|
|
78
|
+
dashboardRequestVersion,
|
|
79
|
+
refreshVersion.current,
|
|
80
|
+
period,
|
|
81
|
+
requestPeriodForOperations(operationsPeriodRef.current),
|
|
82
|
+
);
|
|
83
|
+
setEntityPageKind(kind);
|
|
84
|
+
setEntityPage({ offset, total: null, loading: true, error: null });
|
|
85
|
+
try {
|
|
86
|
+
const view = (
|
|
87
|
+
{
|
|
88
|
+
runs: "operations_agent_invocations",
|
|
89
|
+
executions: "operations_executions",
|
|
90
|
+
conversations: "operations_conversations",
|
|
91
|
+
} as const
|
|
92
|
+
)[kind];
|
|
93
|
+
const sql = await api.sqliteViewPage(
|
|
94
|
+
view,
|
|
95
|
+
period,
|
|
96
|
+
{
|
|
97
|
+
offset,
|
|
98
|
+
limit: 100,
|
|
99
|
+
...(filters.query ? { query: filters.query } : {}),
|
|
100
|
+
...(filters.status ? { status: filters.status } : {}),
|
|
101
|
+
...(filters.risk ? { risk: filters.risk } : {}),
|
|
102
|
+
},
|
|
103
|
+
controller.signal,
|
|
104
|
+
);
|
|
105
|
+
const page: OperationsEntityPage = {
|
|
106
|
+
kind,
|
|
107
|
+
offset: sql.offset,
|
|
108
|
+
limit: sql.limit,
|
|
109
|
+
total: sql.total_count,
|
|
110
|
+
// The result is paginated, but every row is a complete canonical
|
|
111
|
+
// entity. `page_partial` means an aggregate assembled from raw page
|
|
112
|
+
// fragments and intentionally triggers the loading placeholder.
|
|
113
|
+
aggregation: "canonical_entity" as const,
|
|
114
|
+
rows: sql.rows.map((row) => ({
|
|
115
|
+
id: String(
|
|
116
|
+
row.agent_invocation_id ?? row.execution_id ?? row.conversation_id ?? row.id,
|
|
117
|
+
),
|
|
118
|
+
started_at: String(row.occurred_at ?? row.started_at ?? "1970-01-01T00:00:00.000Z"),
|
|
119
|
+
finished_at: typeof row.finished_at === "string" ? row.finished_at : null,
|
|
120
|
+
task_id: typeof row.task_id === "string" ? row.task_id : null,
|
|
121
|
+
execution_id: typeof row.execution_id === "string" ? row.execution_id : null,
|
|
122
|
+
conversation_id: typeof row.conversation_id === "string" ? row.conversation_id : null,
|
|
123
|
+
parent_run_id:
|
|
124
|
+
typeof row.parent_agent_invocation_id === "string"
|
|
125
|
+
? row.parent_agent_invocation_id
|
|
126
|
+
: null,
|
|
127
|
+
run_kind:
|
|
128
|
+
row.invocation_kind === "delegated" || row.invocation_kind === "subagent"
|
|
129
|
+
? "subrun"
|
|
130
|
+
: row.invocation_kind === "orchestrator"
|
|
131
|
+
? "run"
|
|
132
|
+
: null,
|
|
133
|
+
run_purpose: typeof row.purpose === "string" ? row.purpose : null,
|
|
134
|
+
phase: typeof row.phase === "string" ? row.phase : null,
|
|
135
|
+
status: typeof row.status === "string" ? row.status : null,
|
|
136
|
+
agent: typeof row.zaip_agent === "string" ? row.zaip_agent : null,
|
|
137
|
+
agent_persona:
|
|
138
|
+
typeof row.zaip_agent_persona === "string" ? row.zaip_agent_persona : null,
|
|
139
|
+
agent_job: typeof row.zaip_agent_job === "string" ? row.zaip_agent_job : null,
|
|
140
|
+
client: typeof row.client === "string" ? row.client : null,
|
|
141
|
+
provider: typeof row.provider === "string" ? row.provider : null,
|
|
142
|
+
model: typeof row.model === "string" ? row.model : null,
|
|
143
|
+
reasoning_effort:
|
|
144
|
+
typeof row.reasoning_effort === "string" ? row.reasoning_effort : null,
|
|
145
|
+
service_tier: typeof row.service_tier === "string" ? row.service_tier : null,
|
|
146
|
+
duration_ms:
|
|
147
|
+
typeof row.duration_ms === "number"
|
|
148
|
+
? row.duration_ms
|
|
149
|
+
: typeof row.total_duration === "number"
|
|
150
|
+
? row.total_duration
|
|
151
|
+
: null,
|
|
152
|
+
source_duration_ms:
|
|
153
|
+
typeof row.source_duration_ms === "number" ? row.source_duration_ms : null,
|
|
154
|
+
duration_provenance:
|
|
155
|
+
typeof row.duration_provenance === "string" ? row.duration_provenance : null,
|
|
156
|
+
llm_call_count:
|
|
157
|
+
typeof row.llm_call_count === "number" ? row.llm_call_count : null,
|
|
158
|
+
input_tokens: typeof row.input_tokens === "number" ? row.input_tokens : null,
|
|
159
|
+
cached_input_tokens:
|
|
160
|
+
typeof row.cached_input_tokens === "number" ? row.cached_input_tokens : null,
|
|
161
|
+
uncached_input_tokens:
|
|
162
|
+
typeof row.uncached_input_tokens === "number" ? row.uncached_input_tokens : null,
|
|
163
|
+
output_tokens: typeof row.output_tokens === "number" ? row.output_tokens : null,
|
|
164
|
+
reasoning_tokens:
|
|
165
|
+
typeof row.reasoning_tokens === "number" ? row.reasoning_tokens : null,
|
|
166
|
+
visible_output_tokens:
|
|
167
|
+
typeof row.visible_output_tokens === "number" ? row.visible_output_tokens : null,
|
|
168
|
+
total_tokens: typeof row.total_tokens === "number" ? row.total_tokens : null,
|
|
169
|
+
input_rate_usd_per_million:
|
|
170
|
+
typeof row.input_rate_usd_per_million === "number"
|
|
171
|
+
? row.input_rate_usd_per_million
|
|
172
|
+
: null,
|
|
173
|
+
cached_input_rate_usd_per_million:
|
|
174
|
+
typeof row.cached_input_rate_usd_per_million === "number"
|
|
175
|
+
? row.cached_input_rate_usd_per_million
|
|
176
|
+
: null,
|
|
177
|
+
output_rate_usd_per_million:
|
|
178
|
+
typeof row.output_rate_usd_per_million === "number"
|
|
179
|
+
? row.output_rate_usd_per_million
|
|
180
|
+
: null,
|
|
181
|
+
reasoning_rate_usd_per_million:
|
|
182
|
+
typeof row.reasoning_rate_usd_per_million === "number"
|
|
183
|
+
? row.reasoning_rate_usd_per_million
|
|
184
|
+
: null,
|
|
185
|
+
context_input_multiplier:
|
|
186
|
+
typeof row.context_input_multiplier === "number"
|
|
187
|
+
? row.context_input_multiplier
|
|
188
|
+
: null,
|
|
189
|
+
context_output_multiplier:
|
|
190
|
+
typeof row.context_output_multiplier === "number"
|
|
191
|
+
? row.context_output_multiplier
|
|
192
|
+
: null,
|
|
193
|
+
speed_cost_multiplier:
|
|
194
|
+
typeof row.speed_cost_multiplier === "number" ? row.speed_cost_multiplier : null,
|
|
195
|
+
pricing_scenario:
|
|
196
|
+
typeof row.pricing_scenario === "string" ? row.pricing_scenario : null,
|
|
197
|
+
standard_cost_usd:
|
|
198
|
+
typeof row.standard_cost_usd === "number" ? row.standard_cost_usd : null,
|
|
199
|
+
speed_uplift_usd:
|
|
200
|
+
typeof row.speed_uplift_usd === "number" ? row.speed_uplift_usd : null,
|
|
201
|
+
input_cost_usd:
|
|
202
|
+
typeof row.input_cost_usd === "number" ? row.input_cost_usd : null,
|
|
203
|
+
cached_input_cost_usd:
|
|
204
|
+
typeof row.cached_input_cost_usd === "number" ? row.cached_input_cost_usd : null,
|
|
205
|
+
output_cost_usd:
|
|
206
|
+
typeof row.output_cost_usd === "number" ? row.output_cost_usd : null,
|
|
207
|
+
reasoning_cost_usd:
|
|
208
|
+
typeof row.reasoning_cost_usd === "number" ? row.reasoning_cost_usd : null,
|
|
209
|
+
calculated_cost_usd:
|
|
210
|
+
typeof row.calculated_cost_usd === "number" ? row.calculated_cost_usd : null,
|
|
211
|
+
recorded_cost_usd:
|
|
212
|
+
typeof row.recorded_cost_usd === "number" ? row.recorded_cost_usd : null,
|
|
213
|
+
cost_variance_usd:
|
|
214
|
+
typeof row.cost_variance_usd === "number" ? row.cost_variance_usd : null,
|
|
215
|
+
cost_usd: typeof row.cost_usd === "number" ? row.cost_usd : null,
|
|
216
|
+
fx_rate: typeof row.fx_rate === "number" ? row.fx_rate : null,
|
|
217
|
+
pricing_segment_count:
|
|
218
|
+
typeof row.pricing_segment_count === "number" ? row.pricing_segment_count : null,
|
|
219
|
+
pricing_mixed: row.pricing_mixed === 1 || row.pricing_mixed === true,
|
|
220
|
+
pricing_model:
|
|
221
|
+
typeof row.audit_pricing_model === "string"
|
|
222
|
+
? row.audit_pricing_model
|
|
223
|
+
: typeof row.pricing_model === "string"
|
|
224
|
+
? row.pricing_model
|
|
225
|
+
: null,
|
|
226
|
+
pricing_source:
|
|
227
|
+
typeof row.audit_pricing_source === "string"
|
|
228
|
+
? row.audit_pricing_source
|
|
229
|
+
: typeof row.pricing_source === "string"
|
|
230
|
+
? row.pricing_source
|
|
231
|
+
: null,
|
|
232
|
+
cost:
|
|
233
|
+
typeof row.total_cost_brl === "number"
|
|
234
|
+
? row.total_cost_brl
|
|
235
|
+
: typeof row.cost_brl === "number"
|
|
236
|
+
? row.cost_brl
|
|
237
|
+
: null,
|
|
238
|
+
currency: "BRL",
|
|
239
|
+
})),
|
|
240
|
+
};
|
|
241
|
+
if (!isCurrentRequest()) return;
|
|
242
|
+
setOperations((current) =>
|
|
243
|
+
current === null ? current : projectEntityPage(current, kind, page),
|
|
244
|
+
);
|
|
245
|
+
setEntityPage({
|
|
246
|
+
offset: page.offset,
|
|
247
|
+
total: page.total,
|
|
248
|
+
loading: false,
|
|
249
|
+
error: null,
|
|
250
|
+
aggregation: page.aggregation,
|
|
251
|
+
});
|
|
252
|
+
} catch (cause) {
|
|
253
|
+
if (!isCurrentRequest() || isAbortError(cause)) return;
|
|
254
|
+
setEntityPage({
|
|
255
|
+
offset,
|
|
256
|
+
total: null,
|
|
257
|
+
loading: false,
|
|
258
|
+
error: cause instanceof Error ? cause.message : String(cause),
|
|
259
|
+
});
|
|
260
|
+
} finally {
|
|
261
|
+
if (operationsPageAbortRef.current === controller) operationsPageAbortRef.current = null;
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
[
|
|
265
|
+
api,
|
|
266
|
+
entityFiltersRef,
|
|
267
|
+
operationsPageAbortRef,
|
|
268
|
+
operationsPageRequestVersionRef,
|
|
269
|
+
operationsPeriod,
|
|
270
|
+
operationsPeriodRef,
|
|
271
|
+
refreshVersion,
|
|
272
|
+
setEntityPage,
|
|
273
|
+
setEntityPageKind,
|
|
274
|
+
setOperations,
|
|
275
|
+
],
|
|
276
|
+
);
|
|
277
|
+
|
|
278
|
+
const loadOperationsLifecyclePage = useCallback(
|
|
279
|
+
async (kind: OperationsLifecyclePageKind, offset = 0, filters = entityFiltersRef.current) => {
|
|
280
|
+
operationsPageAbortRef.current?.abort();
|
|
281
|
+
const controller = new AbortController();
|
|
282
|
+
operationsPageAbortRef.current = controller;
|
|
283
|
+
const requestVersion = ++operationsPageRequestVersionRef.current;
|
|
284
|
+
const dashboardRequestVersion = refreshVersion.current;
|
|
285
|
+
const period = requestPeriodForOperations(operationsPeriod);
|
|
286
|
+
const isCurrentRequest = () =>
|
|
287
|
+
isCurrentOperationsPageRequest(
|
|
288
|
+
requestVersion,
|
|
289
|
+
operationsPageRequestVersionRef.current,
|
|
290
|
+
controller.signal,
|
|
291
|
+
) &&
|
|
292
|
+
isCurrentOperationsPeriodRequest(
|
|
293
|
+
dashboardRequestVersion,
|
|
294
|
+
refreshVersion.current,
|
|
295
|
+
period,
|
|
296
|
+
requestPeriodForOperations(operationsPeriodRef.current),
|
|
297
|
+
);
|
|
298
|
+
setEntityPageKind(kind);
|
|
299
|
+
setEntityPage({ offset, total: null, loading: true, error: null });
|
|
300
|
+
try {
|
|
301
|
+
const sql = await api.sqliteViewPage(
|
|
302
|
+
kind === "changes" ? "operations_changes" : "operations_decisions",
|
|
303
|
+
period,
|
|
304
|
+
{
|
|
305
|
+
offset,
|
|
306
|
+
limit: 100,
|
|
307
|
+
...(filters.query ? { query: filters.query } : {}),
|
|
308
|
+
...(filters.status ? { status: filters.status } : {}),
|
|
309
|
+
...(filters.risk ? { risk: filters.risk } : {}),
|
|
310
|
+
},
|
|
311
|
+
controller.signal,
|
|
312
|
+
);
|
|
313
|
+
const rows =
|
|
314
|
+
kind === "changes"
|
|
315
|
+
? sql.rows.map((row) => {
|
|
316
|
+
const sourceType = String(row.source_type);
|
|
317
|
+
const sourceId = String(row.source_id);
|
|
318
|
+
return {
|
|
319
|
+
id: String(row.id),
|
|
320
|
+
title: typeof row.title === "string" ? row.title : String(row.id),
|
|
321
|
+
created_at: typeof row.occurred_at === "string" ? row.occurred_at : null,
|
|
322
|
+
status: typeof row.status === "string" ? row.status : "unclassified",
|
|
323
|
+
risk: typeof row.risk === "string" ? row.risk : "unclassified",
|
|
324
|
+
source:
|
|
325
|
+
sourceType === "spec"
|
|
326
|
+
? ({ type: "spec", spec_id: sourceId } as const)
|
|
327
|
+
: sourceType === "prd"
|
|
328
|
+
? ({ type: "prd", prd_id: sourceId, spec_id: null } as const)
|
|
329
|
+
: ({ type: "task", task_id: sourceId } as const),
|
|
330
|
+
requirement_ids: jsonStringArray(row.requirement_ids_json),
|
|
331
|
+
acceptance_ids: jsonStringArray(row.acceptance_ids_json),
|
|
332
|
+
task_ids: jsonStringArray(row.task_ids_json),
|
|
333
|
+
result: typeof row.result === "string" ? row.result : null,
|
|
334
|
+
artifact_path:
|
|
335
|
+
typeof row.source_path === "string" ? row.source_path : String(row.id),
|
|
336
|
+
};
|
|
337
|
+
})
|
|
338
|
+
: sql.rows.map((row) => ({
|
|
339
|
+
id: String(row.id),
|
|
340
|
+
title: typeof row.title === "string" ? row.title : String(row.id),
|
|
341
|
+
origin: row.origin === "human" ? ("human" as const) : ("agent" as const),
|
|
342
|
+
scope_type:
|
|
343
|
+
row.scope_type === "execution" ? ("execution" as const) : ("change" as const),
|
|
344
|
+
scope_id: String(row.scope_id),
|
|
345
|
+
artifact_path:
|
|
346
|
+
typeof row.source_path === "string" ? row.source_path : String(row.id),
|
|
347
|
+
created_at:
|
|
348
|
+
typeof row.occurred_at === "string"
|
|
349
|
+
? row.occurred_at
|
|
350
|
+
: "1970-01-01T00:00:00.000Z",
|
|
351
|
+
}));
|
|
352
|
+
const page = {
|
|
353
|
+
kind,
|
|
354
|
+
offset: sql.offset,
|
|
355
|
+
limit: sql.limit,
|
|
356
|
+
total: sql.total_count,
|
|
357
|
+
rows,
|
|
358
|
+
};
|
|
359
|
+
if (!isCurrentRequest()) return;
|
|
360
|
+
setOperations((current) =>
|
|
361
|
+
current === null
|
|
362
|
+
? current
|
|
363
|
+
: {
|
|
364
|
+
...current,
|
|
365
|
+
...(kind === "changes"
|
|
366
|
+
? { changes: page.rows as OperationsProjection["changes"] }
|
|
367
|
+
: { decisions: page.rows as OperationsProjection["decisions"] }),
|
|
368
|
+
},
|
|
369
|
+
);
|
|
370
|
+
setEntityPage({ offset: page.offset, total: page.total, loading: false, error: null });
|
|
371
|
+
} catch (cause) {
|
|
372
|
+
if (!isCurrentRequest() || isAbortError(cause)) return;
|
|
373
|
+
setEntityPage({
|
|
374
|
+
offset,
|
|
375
|
+
total: null,
|
|
376
|
+
loading: false,
|
|
377
|
+
error: cause instanceof Error ? cause.message : String(cause),
|
|
378
|
+
});
|
|
379
|
+
} finally {
|
|
380
|
+
if (operationsPageAbortRef.current === controller) operationsPageAbortRef.current = null;
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
[
|
|
384
|
+
api,
|
|
385
|
+
entityFiltersRef,
|
|
386
|
+
operationsPageAbortRef,
|
|
387
|
+
operationsPageRequestVersionRef,
|
|
388
|
+
operationsPeriod,
|
|
389
|
+
operationsPeriodRef,
|
|
390
|
+
refreshVersion,
|
|
391
|
+
setEntityPage,
|
|
392
|
+
setEntityPageKind,
|
|
393
|
+
setOperations,
|
|
394
|
+
],
|
|
395
|
+
);
|
|
396
|
+
|
|
397
|
+
return { loadOperationsEntityPage, loadOperationsLifecyclePage };
|
|
398
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ChangeProjection,
|
|
3
|
+
MacroProjection,
|
|
4
|
+
OperationsProjection,
|
|
5
|
+
PrdDetailProjection,
|
|
6
|
+
SpecDetailProjection,
|
|
7
|
+
} from "@zaip-ai/dashboard-operations/contracts";
|
|
8
|
+
import type { TaskTrace } from "@zaip-ai/dashboard-traceability/contracts";
|
|
9
|
+
import { type Dispatch, type SetStateAction, useRef, useState } from "react";
|
|
10
|
+
import type { LoadingArea } from "./AppLoadingPanels.js";
|
|
11
|
+
import type { DashboardApiClient } from "./dashboard-api.js";
|
|
12
|
+
|
|
13
|
+
export function useAppTraceDocuments({
|
|
14
|
+
api,
|
|
15
|
+
operations,
|
|
16
|
+
setError,
|
|
17
|
+
setFailedArea,
|
|
18
|
+
setLoadingArea,
|
|
19
|
+
}: {
|
|
20
|
+
api: DashboardApiClient;
|
|
21
|
+
operations: OperationsProjection | null;
|
|
22
|
+
setError: Dispatch<SetStateAction<string | null>>;
|
|
23
|
+
setFailedArea: Dispatch<SetStateAction<LoadingArea | null>>;
|
|
24
|
+
setLoadingArea: Dispatch<SetStateAction<LoadingArea | null>>;
|
|
25
|
+
}) {
|
|
26
|
+
const [trace, setTrace] = useState<TaskTrace | null>(null);
|
|
27
|
+
const [traceTasks, setTraceTasks] = useState<OperationsProjection["tasks"]>([]);
|
|
28
|
+
const [documentDetail, setDocumentDetail] = useState<{
|
|
29
|
+
kind: "prd" | "spec";
|
|
30
|
+
label: "PRD" | "SPEC";
|
|
31
|
+
preview: Pick<MacroProjection, "id" | "title" | "artifact_path">;
|
|
32
|
+
detail?: PrdDetailProjection | SpecDetailProjection;
|
|
33
|
+
error?: string;
|
|
34
|
+
} | null>(null);
|
|
35
|
+
const [traceLink, setTraceLink] = useState<
|
|
36
|
+
| { kind: "change"; row: ChangeProjection }
|
|
37
|
+
| { kind: "macro"; label: "PRD" | "SPEC"; row: MacroProjection }
|
|
38
|
+
| null
|
|
39
|
+
>(null);
|
|
40
|
+
const documentRequestId = useRef(0);
|
|
41
|
+
const traceRequestId = useRef(0);
|
|
42
|
+
const [traceLoadingTaskId, setTraceLoadingTaskId] = useState<string | null>(null);
|
|
43
|
+
const [selectedTraceTaskId, setSelectedTraceTaskId] = useState("");
|
|
44
|
+
|
|
45
|
+
async function openTrace(taskId: string) {
|
|
46
|
+
const requestId = ++traceRequestId.current;
|
|
47
|
+
setError(null);
|
|
48
|
+
setFailedArea(null);
|
|
49
|
+
setTrace(null);
|
|
50
|
+
setTraceLoadingTaskId(taskId);
|
|
51
|
+
setLoadingArea("traceability");
|
|
52
|
+
await new Promise<void>((resolveFrame) => window.requestAnimationFrame(() => resolveFrame()));
|
|
53
|
+
try {
|
|
54
|
+
const loadedTrace = await api.taskTrace(taskId);
|
|
55
|
+
if (traceRequestId.current !== requestId) return false;
|
|
56
|
+
const cardTask =
|
|
57
|
+
traceTasks.find((task) => task.id === taskId) ??
|
|
58
|
+
operations?.tasks.find((task) => task.id === taskId);
|
|
59
|
+
setTrace({
|
|
60
|
+
...loadedTrace,
|
|
61
|
+
task_title: cardTask?.title || loadedTrace.task_title || taskId,
|
|
62
|
+
task_risk: cardTask?.risk || loadedTrace.task_risk || null,
|
|
63
|
+
task_created_at: cardTask?.created_at || loadedTrace.task_created_at || null,
|
|
64
|
+
task_progress: cardTask?.progress ?? loadedTrace.task_progress ?? 0,
|
|
65
|
+
});
|
|
66
|
+
return true;
|
|
67
|
+
} catch (cause) {
|
|
68
|
+
if (traceRequestId.current !== requestId) return false;
|
|
69
|
+
setError(cause instanceof Error ? cause.message : String(cause));
|
|
70
|
+
setFailedArea("traceability");
|
|
71
|
+
return false;
|
|
72
|
+
} finally {
|
|
73
|
+
if (traceRequestId.current === requestId) {
|
|
74
|
+
setTraceLoadingTaskId(null);
|
|
75
|
+
setLoadingArea((current) => (current === "traceability" ? null : current));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function openTraceChange(changeId: string) {
|
|
81
|
+
const row = operations?.changes.find((change) => change.id === changeId);
|
|
82
|
+
if (row === undefined) return;
|
|
83
|
+
setTrace(null);
|
|
84
|
+
setTraceLink({ kind: "change", row });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function openTraceMacro(label: "PRD" | "SPEC", id: string) {
|
|
88
|
+
const rows = label === "PRD" ? operations?.prds : operations?.specs;
|
|
89
|
+
const row = rows?.find((macro) => macro.id === id);
|
|
90
|
+
if (row === undefined) return;
|
|
91
|
+
setTrace(null);
|
|
92
|
+
setTraceLink({ kind: "macro", label, row });
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async function openDocument(kind: "prd" | "spec", id: string) {
|
|
96
|
+
const preview = (kind === "prd" ? operations?.prds : operations?.specs)?.find(
|
|
97
|
+
(macro) => macro.id === id,
|
|
98
|
+
);
|
|
99
|
+
if (!preview) return;
|
|
100
|
+
const requestId = ++documentRequestId.current;
|
|
101
|
+
const label = kind === "prd" ? "PRD" : "SPEC";
|
|
102
|
+
setDocumentDetail({ kind, label, preview });
|
|
103
|
+
try {
|
|
104
|
+
const detail = kind === "prd" ? await api.prd(id) : await api.spec(id);
|
|
105
|
+
if (documentRequestId.current !== requestId) return;
|
|
106
|
+
setDocumentDetail({ kind, label, preview, detail });
|
|
107
|
+
} catch (cause) {
|
|
108
|
+
if (documentRequestId.current !== requestId) return;
|
|
109
|
+
setDocumentDetail({
|
|
110
|
+
kind,
|
|
111
|
+
label,
|
|
112
|
+
preview,
|
|
113
|
+
error: cause instanceof Error ? cause.message : String(cause),
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function closeDocument() {
|
|
119
|
+
documentRequestId.current += 1;
|
|
120
|
+
setDocumentDetail(null);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
closeDocument,
|
|
125
|
+
documentDetail,
|
|
126
|
+
openDocument,
|
|
127
|
+
openTrace,
|
|
128
|
+
openTraceChange,
|
|
129
|
+
openTraceMacro,
|
|
130
|
+
selectedTraceTaskId,
|
|
131
|
+
setSelectedTraceTaskId,
|
|
132
|
+
setTrace,
|
|
133
|
+
setTraceLink,
|
|
134
|
+
setTraceLoadingTaskId,
|
|
135
|
+
setTraceTasks,
|
|
136
|
+
trace,
|
|
137
|
+
traceLink,
|
|
138
|
+
traceLoadingTaskId,
|
|
139
|
+
traceTasks,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { CostCurrency } from "@zaip-ai/dashboard-cost-monitor/react";
|
|
2
|
+
import type { OperationsProjection } from "@zaip-ai/dashboard-operations/contracts";
|
|
3
|
+
import { type MutableRefObject, useEffect } from "react";
|
|
4
|
+
import type { DashboardApiClient } from "./dashboard-api.js";
|
|
5
|
+
|
|
6
|
+
type Prefetch = { key: string; promise: ReturnType<DashboardApiClient["snapshot"]> } | null;
|
|
7
|
+
|
|
8
|
+
export function useIdleCostPrefetch({
|
|
9
|
+
api,
|
|
10
|
+
currency,
|
|
11
|
+
key,
|
|
12
|
+
operations,
|
|
13
|
+
period,
|
|
14
|
+
prefetch,
|
|
15
|
+
}: {
|
|
16
|
+
api: DashboardApiClient;
|
|
17
|
+
currency: CostCurrency;
|
|
18
|
+
key: string;
|
|
19
|
+
operations: OperationsProjection | null;
|
|
20
|
+
period: { from: string | null; to: string | null };
|
|
21
|
+
prefetch: MutableRefObject<Prefetch>;
|
|
22
|
+
}) {
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (operations === null || operations.runs.length === 0 || prefetch.current?.key === key)
|
|
25
|
+
return;
|
|
26
|
+
let cancelled = false;
|
|
27
|
+
const load = () => {
|
|
28
|
+
if (cancelled) return;
|
|
29
|
+
const promise = api.snapshot(currency, period);
|
|
30
|
+
prefetch.current = { key, promise };
|
|
31
|
+
void promise.catch(() => {
|
|
32
|
+
if (prefetch.current?.promise === promise) prefetch.current = null;
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
const handle =
|
|
36
|
+
typeof window.requestIdleCallback === "function"
|
|
37
|
+
? { kind: "idle" as const, id: window.requestIdleCallback(load) }
|
|
38
|
+
: { kind: "timeout" as const, id: window.setTimeout(load, 0) };
|
|
39
|
+
return () => {
|
|
40
|
+
cancelled = true;
|
|
41
|
+
if (handle.kind === "idle") window.cancelIdleCallback(handle.id);
|
|
42
|
+
else window.clearTimeout(handle.id);
|
|
43
|
+
};
|
|
44
|
+
}, [api, currency, key, operations, period, prefetch]);
|
|
45
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
collectWorkListPages,
|
|
4
|
+
normalizeWorkListFilters,
|
|
5
|
+
selectedWorkListKinds,
|
|
6
|
+
} from "./work-list-pagination.js";
|
|
7
|
+
|
|
8
|
+
describe("Trabalho (Lista) canonical pagination", () => {
|
|
9
|
+
it("keeps a server-selected PRD/SPEC kind instead of refetching every kind", () => {
|
|
10
|
+
expect(selectedWorkListKinds("spec")).toEqual(["spec"]);
|
|
11
|
+
expect(selectedWorkListKinds("prd")).toEqual(["prd"]);
|
|
12
|
+
expect(selectedWorkListKinds("")).toEqual(["prd", "spec", "task"]);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("retains the List type through search/status changes without mutating the Kanban snapshot", () => {
|
|
16
|
+
const kanban = { query: "kanban", status: "ready", risk: "", kind: "" };
|
|
17
|
+
const listSpec = normalizeWorkListFilters(
|
|
18
|
+
{ query: "", status: "", risk: "", kind: "spec" },
|
|
19
|
+
{ query: "", status: "", risk: "" },
|
|
20
|
+
);
|
|
21
|
+
const searched = normalizeWorkListFilters(
|
|
22
|
+
{ query: "telemetria", status: "executing", risk: "standard" },
|
|
23
|
+
listSpec,
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
expect(searched).toMatchObject({
|
|
27
|
+
query: "telemetria",
|
|
28
|
+
status: "executing",
|
|
29
|
+
risk: "standard",
|
|
30
|
+
kind: "spec",
|
|
31
|
+
});
|
|
32
|
+
expect(kanban).toEqual({ query: "kanban", status: "ready", risk: "", kind: "" });
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
it("continues from the returned offset until the canonical total is complete", async () => {
|
|
37
|
+
const loadPage = vi
|
|
38
|
+
.fn()
|
|
39
|
+
.mockResolvedValueOnce({ total: 59, received: 50, value: "first" })
|
|
40
|
+
.mockResolvedValueOnce({ total: 59, received: 9, value: "second" });
|
|
41
|
+
|
|
42
|
+
await expect(collectWorkListPages(loadPage)).resolves.toEqual(["first", "second"]);
|
|
43
|
+
expect(loadPage).toHaveBeenNthCalledWith(1, 0);
|
|
44
|
+
expect(loadPage).toHaveBeenNthCalledWith(2, 50);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type WorkListKind = "prd" | "spec" | "task";
|
|
2
|
+
|
|
3
|
+
export type WorkListFilters = {
|
|
4
|
+
query: string;
|
|
5
|
+
status: string;
|
|
6
|
+
risk: string;
|
|
7
|
+
origin?: string;
|
|
8
|
+
kind?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/** Keep the List snapshot independent of Kanban while retaining its selected type. */
|
|
12
|
+
export function normalizeWorkListFilters(
|
|
13
|
+
filters: WorkListFilters,
|
|
14
|
+
previous: WorkListFilters,
|
|
15
|
+
): WorkListFilters {
|
|
16
|
+
return { ...filters, kind: filters.kind ?? previous.kind ?? "" };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
export function selectedWorkListKinds(kind: string | undefined): readonly WorkListKind[] {
|
|
21
|
+
return kind === "prd" || kind === "spec" || kind === "task"
|
|
22
|
+
? [kind]
|
|
23
|
+
: ["prd", "spec", "task"];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export async function collectWorkListPages<T>(
|
|
27
|
+
loadPage: (offset: number) => Promise<{ total: number; received: number; value: T }>,
|
|
28
|
+
): Promise<T[]> {
|
|
29
|
+
const pages: T[] = [];
|
|
30
|
+
let offset = 0;
|
|
31
|
+
for (;;) {
|
|
32
|
+
const page = await loadPage(offset);
|
|
33
|
+
pages.push(page.value);
|
|
34
|
+
offset += page.received;
|
|
35
|
+
if (page.received === 0 || offset >= page.total) return pages;
|
|
36
|
+
}
|
|
37
|
+
}
|