@zaip-ai/cli 2.6.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -13
- package/dist/services/adapters.d.ts +1 -1
- package/dist/services/adapters.d.ts.map +1 -1
- package/dist/services/adapters.js +5 -2
- package/dist/services/adapters.js.map +1 -1
- package/dist/services/agent-adapters.js +12 -9
- package/dist/services/agent-adapters.js.map +1 -1
- package/dist/services/codex-conversation-lifecycle-hook.d.ts.map +1 -1
- package/dist/services/codex-conversation-lifecycle-hook.js +32 -21
- package/dist/services/codex-conversation-lifecycle-hook.js.map +1 -1
- package/dist/services/install-agents-template.js +9 -1
- package/dist/services/install-agents-template.js.map +1 -1
- package/dist/services/runtime-template.test.js +25 -2
- package/dist/services/runtime-template.test.js.map +1 -1
- package/dist/services/transactional-files.d.ts.map +1 -1
- package/dist/services/transactional-files.js +59 -14
- package/dist/services/transactional-files.js.map +1 -1
- package/package.json +1 -1
- package/templates/.agents/README-ENG.md +75 -10
- package/templates/.agents/README.md +76 -10
- package/templates/.agents/config/agents/catalog.yaml +3 -0
- package/templates/.agents/config/agents/discovery.json +2 -2
- package/templates/.agents/config/clients/codex/agents/zaip-agent-analyst.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-auditor.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-backend.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-brand-strategist.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-builder.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-cloud-engineer.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-data-analyst.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-designer.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-finalizer.toml +2 -2
- package/templates/.agents/config/clients/codex/agents/zaip-agent-frontend.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-general-operations.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-governance-compliance.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-growth-strategist.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-integrator.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-marketing-analyst.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-orchestrator.toml +13 -10
- package/templates/.agents/config/clients/codex/agents/zaip-agent-refactoring-specialist.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-reviewer.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-sales-specialist.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-security-auditor.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-task-executor.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-website-developer.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-writer.toml +1 -1
- package/templates/.agents/config/project.yaml +10 -1
- package/templates/.agents/dashboard/.zaip-managed.json +274 -138
- package/templates/.agents/dashboard/README.md +16 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{CostCalculationGuidePage-CGxeQak4.js → CostCalculationGuidePage-CEDZjl4V.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{DashboardHelpDialog-tzS7YxYB.js → DashboardHelpDialog-DIWDmvAS.js} +930 -550
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{PricingSettingsDialog-DEbCi1gP.js → PricingSettingsDialog-BBRBKaHa.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-B9GWkEyN.css +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-BAvLPAee.js +3 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{TraceabilityWorkspace-t1Om0Abw.js → TraceabilityWorkspace-C9dDhj34.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-06__WZco.js +68 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/dashboard-localization-CoAVMZN6.js +828 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{icons-vendor-DiGC-dsJ.js → icons-vendor-DEmo6Tn2.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-BVzw_Wux.js +2 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{react-vendor-kPO6yNed.js → react-vendor-CadYsm83.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/traceability-BzKK8kK3.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/index.html +5 -5
- package/templates/.agents/dashboard/apps/frontend/package.json +1 -1
- package/templates/.agents/dashboard/apps/frontend/src/AppDashboardContent.tsx +10 -5
- package/templates/.agents/dashboard/apps/frontend/src/AutonomySettings.tsx +82 -0
- package/templates/.agents/dashboard/apps/frontend/src/ProjectSettingsPage.dom.test.ts +38 -7
- package/templates/.agents/dashboard/apps/frontend/src/ProjectSettingsPage.tsx +164 -171
- package/templates/.agents/dashboard/apps/frontend/src/__tests__/app-composition-support.ts +6 -1
- package/templates/.agents/dashboard/apps/frontend/src/cost-monitor-population.test.tsx +149 -0
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-api-settings.ts +2 -1
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-api.test.ts +19 -0
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-api.ts +22 -1
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-cost-facts.test.ts +54 -0
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-cost-facts.ts +20 -2
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-localization.test.ts +37 -43
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-localization.ts +9 -251
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-project-overview.ts +34 -7
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-view-actions.test.ts +51 -0
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-view-actions.ts +3 -1
- package/templates/.agents/dashboard/apps/frontend/src/operations-period-render.test.ts +35 -0
- package/templates/.agents/dashboard/apps/frontend/src/operations-period.test.ts +19 -4
- package/templates/.agents/dashboard/apps/frontend/src/operations-period.ts +5 -3
- package/templates/.agents/dashboard/apps/frontend/src/project-installation-status.test.ts +112 -23
- package/templates/.agents/dashboard/apps/frontend/src/project-installation-status.ts +49 -12
- package/templates/.agents/dashboard/apps/frontend/src/project-settings-copy.ts +181 -0
- package/templates/.agents/dashboard/apps/frontend/src/project-settings-model.ts +11 -1
- package/templates/.agents/dashboard/apps/frontend/src/project-settings-page.css +34 -51
- package/templates/.agents/dashboard/apps/frontend/src/project-settings-state.css +55 -0
- package/templates/.agents/dashboard/apps/frontend/src/project-settings.test.ts +12 -0
- package/templates/.agents/dashboard/apps/frontend/src/snapshot-coherence.test.ts +1 -1
- package/templates/.agents/dashboard/apps/frontend/src/traceability-task-pagination.ts +1 -2
- package/templates/.agents/dashboard/apps/frontend/src/use-app-cost-loaders.test.ts +6 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-app-cost-loaders.ts +2 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-app-trace-documents.ts +3 -1
- package/templates/.agents/dashboard/apps/frontend/src/use-app-trace-task-pagination.ts +4 -15
- package/templates/.agents/dashboard/apps/frontend/src/use-dashboard-app-model.tsx +2 -2
- package/templates/.agents/dashboard/modules/cost-monitor/package.json +1 -1
- package/templates/.agents/dashboard/modules/cost-monitor/src/complete-cost-average.test.ts +73 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/contracts.ts +9 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/period-averages.ts +60 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorContent.tsx +8 -22
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.tsx +2 -3
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostPeriodAverageCards.tsx +32 -8
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-summary.ts +3 -2
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/period-cost-groups.ts +1 -42
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-cost-group-page.ts +2 -1
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-projection.ts +3 -2
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-projection.ts +8 -2
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/index.ts +1 -0
- package/templates/.agents/dashboard/modules/operations/package.json +1 -1
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview-keeps-structure-classes-mutually-exclusive.test.ts +4 -3
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.helpers.tsx +66 -3
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.test.ts +71 -1
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.tsx +36 -30
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsPage.tsx +5 -14
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsPageOverview.tsx +3 -0
- package/templates/.agents/dashboard/modules/operations/src/react/OverviewCostKpi.tsx +46 -0
- package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkList.test.ts +28 -1
- package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkList.tsx +11 -4
- package/templates/.agents/dashboard/modules/operations/src/react/index.ts +1 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-coverage-toast.test.ts +2 -2
- package/templates/.agents/dashboard/modules/operations/src/react/operations-overview-period-filter.test.ts +28 -8
- package/templates/.agents/dashboard/modules/operations/src/react/operations-page-contract.ts +19 -2
- package/templates/.agents/dashboard/modules/operations/src/react/overview-cost-card.test.tsx +89 -0
- package/templates/.agents/dashboard/modules/operations/src/react/work-board-model.test.ts +3 -3
- package/templates/.agents/dashboard/modules/operations/src/work-board-model.ts +2 -1
- package/templates/.agents/dashboard/modules/traceability/package.json +1 -1
- package/templates/.agents/dashboard/packages/branding/package.json +1 -1
- package/templates/.agents/dashboard/packages/contracts/package.json +1 -1
- package/templates/.agents/dashboard/packages/data-export/package.json +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/dist/server.cjs +279 -245
- package/templates/.agents/dashboard/packages/local-runtime/dist/sqlite-read-model.cjs +247 -215
- package/templates/.agents/dashboard/packages/local-runtime/package.json +2 -2
- package/templates/.agents/dashboard/packages/local-runtime/scripts/build-sqlite-runtime.mjs +15 -25
- package/templates/.agents/dashboard/packages/local-runtime/server.mjs +279 -245
- package/templates/.agents/dashboard/packages/local-runtime/src/active-codex-telemetry.ts +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/project-installation-summary.test.ts +142 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/project-installation-summary.ts +190 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/project-settings.test.ts +65 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/project-settings.ts +67 -66
- package/templates/.agents/dashboard/packages/local-runtime/src/server-browser-lease.test.ts +91 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-browser-lease.ts +24 -4
- package/templates/.agents/dashboard/packages/local-runtime/src/server-hono-security.test.ts +17 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-routes.ts +21 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-refresh.test.ts +94 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-refresh.ts +62 -12
- package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-synchronization.test.ts +26 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-synchronization.ts +4 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/server-sqlite-task-trace.test.ts +97 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-sqlite-task-trace.ts +10 -13
- package/templates/.agents/dashboard/packages/local-runtime/src/server-trace-routes.ts +2 -10
- package/templates/.agents/dashboard/packages/local-runtime/src/server-traceability-index.test.ts +84 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server.ts +15 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-calendar.ts +17 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cold-parse.test.ts +78 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-dimension-facts.test.ts +12 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-group-projection.test.ts +94 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-group-projection.ts +5 -5
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-duration-lookup.test.ts +59 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-entity-label-views.test.ts +72 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-file-index.test.ts +69 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-first-fold-cache.ts +3 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-force-canonical.test.ts +3 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-incremental-refresh.test.ts +2 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-materialize-projections.ts +9 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-materialize-runs.ts +4 -5
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-period-averages.ts +46 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-provider-alias-parity.test.ts +50 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-entity-group.test.ts +171 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-entity-group.ts +36 -16
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-filtered-dimension.ts +13 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-summary.ts +25 -7
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-temporal-dimension.ts +2 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-canonical-parsing.ts +7 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-canonical.ts +5 -15
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-counts-every-root-execution-day-returns.test.ts +34 -10
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-filesystem.ts +17 -3
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-keeps-orphan-telemetry-out-kanban-without.test.ts +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-rebuild.ts +11 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-schema.ts +5 -4
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-source-fingerprint.test.ts +54 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-source-fingerprint.ts +7 -3
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model.test.ts +4 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-risk-population.test.ts +98 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-schema-base-views.ts +29 -16
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-schema-dashboard-views.ts +2 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-snapshot-seed.test.ts +2 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/verify-project-settings.mjs +57 -0
- package/templates/.agents/dashboard/packages/ui/package.json +1 -1
- package/templates/.agents/dashboard/scripts/qualify-observability.mjs +130 -0
- package/templates/.agents/dashboard/scripts/verify-autonomy-settings.mjs +175 -0
- package/templates/.agents/dashboard/scripts/verify-observability.mjs +254 -0
- package/templates/.agents/dashboard/scripts/verify-project-setup.mjs +64 -0
- package/templates/.agents/dashboard/tests/e2e/lease-global-setup.ts +37 -0
- package/templates/.agents/dashboard/tests/e2e/package.json +1 -1
- package/templates/.agents/dashboard/tests/e2e/playwright.config.ts +5 -3
- package/templates/.agents/dashboard/tests/e2e/specs/cost-monitor-period-transition.spec.ts +22 -1
- package/templates/.agents/dashboard/tests/e2e/specs/dashboard-performance-matrix.spec.ts +17 -8
- package/templates/.agents/dashboard/tests/e2e/specs/dashboard.spec.ts +47 -6
- package/templates/.agents/dashboard/tests/e2e/specs/lease-lifetime.spec.ts +14 -0
- package/templates/.agents/dashboard/tests/observability-fixture.mjs +200 -0
- package/templates/.agents/design/.zaip-managed.json +84 -40
- package/templates/.agents/design/apps/catalog/dist/assets/index-BJV597iq.js +72 -0
- package/templates/.agents/design/apps/catalog/dist/assets/index-BOjCcUaU.js +72 -0
- package/templates/.agents/design/apps/catalog/dist/assets/index-B_WhrCZe.js +72 -0
- package/templates/.agents/design/apps/catalog/dist/assets/index-CqtYXZfV.js +72 -0
- package/templates/.agents/design/apps/catalog/dist/assets/index-D_lfqoyx.js +72 -0
- package/templates/.agents/design/apps/catalog/dist/assets/index-i_PO2k9R.js +9 -0
- package/templates/.agents/design/apps/catalog/dist/index.html +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/CatalogShell-Cstn1UwA.js +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{Color-6AOWCN3U-B-kAgAjB.js → Color-6AOWCN3U-Cm-yJJz_.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/Components.stories-D1WopB2L.js +137 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/DesignSystem.stories-DQ9PJ3N3.js +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{DocsRenderer-JROSPFPF-BVN7xHtv.js → DocsRenderer-JROSPFPF-Belk4jRr.js} +4 -4
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{WithTooltip-7X4HQR7L-CDHtKYkz.js → WithTooltip-7X4HQR7L-DoPvjkS1.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{chunk-DRQKCCAG-D6AsDkMK.js → chunk-DRQKCCAG-B1itKXEN.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{chunk-W22LQPXL-B4m5uloN.js → chunk-W22LQPXL-C-Eb5SPY.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{components-CN8YyTUg.js → components-DnyKLwhj.js} +5 -5
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/formatter-L2YTDE3Q-D0OSgxWz.js +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{iframe-9yZfIsdT.js → iframe-DcXBsFPz.js} +3 -3
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{react-18-BoCSnq6H.js → react-18-CRM89QRf.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/react-C3tkVMIp.js +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{syntaxhighlighter-YFXUGROL-Bnn_nMwJ.js → syntaxhighlighter-YFXUGROL-B03jQGTF.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{theming-DS_ue2sb.js → theming-4ZyufAga.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/iframe.html +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/index.json +1 -1
- package/templates/.agents/design/apps/catalog/package.json +2 -2
- package/templates/.agents/design/apps/catalog/src/components/AutonomySpecimen.tsx +15 -0
- package/templates/.agents/design/apps/catalog/src/components/CostPopulationSpecimen.test.tsx +19 -0
- package/templates/.agents/design/apps/catalog/src/components/CostPopulationSpecimen.tsx +45 -0
- package/templates/.agents/design/apps/catalog/src/components/EstimatedCostSpecimen.tsx +48 -0
- package/templates/.agents/design/apps/catalog/src/components/ProjectStatusSpecimen.tsx +169 -0
- package/templates/.agents/design/apps/catalog/src/pages/ComponentsPage.tsx +55 -0
- package/templates/.agents/design/apps/catalog/src/stories/Components.stories.tsx +60 -0
- package/templates/.agents/design/packages/local-runtime/package.json +1 -1
- package/templates/.agents/requirements/autonomous-assurance.md +1 -1
- package/templates/.agents/requirements/cloud-hostinger-autonomy.md +1 -1
- package/templates/.agents/requirements/comparative-audit.md +1 -1
- package/templates/.agents/requirements/context-engine.md +1 -1
- package/templates/.agents/requirements/cost-observability.md +1 -1
- package/templates/.agents/requirements/dashboard-launch.md +1 -1
- package/templates/.agents/requirements/data-export.md +1 -1
- package/templates/.agents/requirements/design-system.md +1 -1
- package/templates/.agents/requirements/execution-engine.md +1 -1
- package/templates/.agents/requirements/kanban-dashboard.md +1 -1
- package/templates/.agents/requirements/model-orchestration.md +1 -1
- package/templates/.agents/requirements/public-distribution.md +1 -1
- 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 +5 -5
- package/templates/.agents/requirements/zaip-strategic-95.md +1 -1
- package/templates/.agents/rules/astra-diagnostic.md +3 -1
- package/templates/.agents/rules/autonomy-decision.md +10 -2
- package/templates/.agents/rules/core.md +12 -1
- package/templates/.agents/rules/run-lifecycle-closure.md +8 -6
- package/templates/.agents/rules/workflow.md +2 -2
- package/templates/.agents/runtime/VERSION +1 -1
- package/templates/.agents/runtime/bin/zaip.mjs +383 -350
- package/templates/.agents/runtime/checksums.sha256 +6 -6
- package/templates/.agents/runtime/manifest.json +1 -1
- package/templates/.agents/runtime/pnpm-lock.sha256 +1 -1
- package/templates/.agents/runtime/provenance.json +5 -5
- package/templates/.agents/runtime/sbom.cdx.json +3 -3
- package/templates/.agents/skills/zaip-skill-dev-environment/SKILL.md +2 -0
- package/templates/.agents/skills/zaip-skill-execution/SKILL.md +28 -5
- package/templates/.agents/skills/zaip-skill-execution/references/runtime-governance.md +17 -3
- package/templates/.agents/skills/zaip-skill-github-deploy/SKILL.md +8 -9
- package/templates/.agents/skills/zaip-skill-github-deploy/references/deployment-workflow.md +10 -6
- package/templates/.agents/skills/zaip-skill-github-deploy/references/release-identity.md +17 -12
- package/templates/.agents/skills/zaip-skill-move-prd/SKILL.md +2 -0
- package/templates/.agents/skills/zaip-skill-prd/SKILL.md +2 -0
- package/templates/.agents/skills/zaip-skill-release-qualification/SKILL.md +21 -23
- package/templates/.agents/skills/zaip-skill-release-qualification/references/local-preparation.md +37 -13
- package/templates/.agents/skills/zaip-skill-setup/SKILL.md +2 -0
- package/templates/.agents/skills/zaip-skill-tool-setup/SKILL.md +2 -0
- package/templates/.agents/zaip-aios/INDEX.md +9 -1
- package/templates/.agents/zaip-aios/README.md +24 -2
- package/templates/.agents/zaip-aios/VERSION +1 -1
- package/templates/.agents/zaip-aios/guides/01-primeiros-passos.md +5 -1
- package/templates/.agents/zaip-aios/guides/03-tasks.md +15 -2
- package/templates/.agents/zaip-aios/guides/04-specs.md +13 -0
- package/templates/.agents/zaip-aios/guides/05-prds.md +13 -0
- package/templates/.agents/zaip-aios/guides/06-execucao.md +19 -4
- package/templates/.agents/zaip-aios/guides/07-revisao-e-validacao.md +14 -0
- package/templates/.agents/zaip-aios/guides/08-contexto-e-tokens.md +4 -3
- package/templates/.agents/zaip-aios/guides/09-agentes-e-squads.md +17 -9
- package/templates/.agents/zaip-aios/guides/10-seguranca.md +9 -0
- package/templates/.agents/zaip-aios/guides/11-observabilidade-e-custos.md +69 -0
- package/templates/.agents/zaip-aios/guides/12-instalacao-e-upgrade.md +9 -4
- package/templates/.agents/zaip-aios/guides/13-boas-praticas.md +7 -1
- package/templates/.agents/zaip-aios/guides/14-troubleshooting.md +18 -0
- package/templates/.agents/zaip-aios/guides/16-lifecycle-e-reconciliacao.md +54 -3
- package/templates/.agents/zaip-aios/guides/18-catalogo-de-agentes.md +10 -2
- package/templates/.agents/zaip-aios/guides/19-assurance-e-autonomia.md +186 -5
- package/templates/.agents/zaip-aios/guides/20-instalacao-detalhada.md +21 -15
- package/templates/.agents/zaip-aios/guides/21-telemetria-monitor-custos.md +18 -2
- package/templates/.agents/zaip-aios/guides/22-fluxos-e-roteamento.md +14 -2
- package/templates/.agents/zaip-aios/guides/23-orquestracao-de-modelos.md +190 -489
- package/templates/.agents/zaip-aios/guides/26-qualidade-e-release.md +72 -13
- package/templates/.agents/zaip-aios/guides/27-telemetria-git-native.md +18 -0
- package/templates/.agents/zaip-aios/guides/28-lifecycle-completo.md +18 -1
- package/templates/template-manifest.json +454 -274
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-1L7Qw-Gq.js +0 -3
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-EInWr641.css +0 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-B6aZfo5f.js +0 -68
- package/templates/.agents/dashboard/apps/frontend/dist/assets/dashboard-localization-CLJ0lT9v.js +0 -231
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-DgTmNHN5.js +0 -2
- package/templates/.agents/dashboard/apps/frontend/dist/assets/traceability-DQpKX9c1.js +0 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/CatalogShell-BWY-80s4.js +0 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/Components.stories-Be2mDUQj.js +0 -27
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/DesignSystem.stories-DRx9blDs.js +0 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/formatter-L2YTDE3Q-EwuTh8Zk.js +0 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/react-DyL61NPT.js +0 -1
|
@@ -34,6 +34,18 @@ const config: ProjectConfigSettings = {
|
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
describe("project settings form mapping", () => {
|
|
37
|
+
it.each([
|
|
38
|
+
"essential",
|
|
39
|
+
"balanced",
|
|
40
|
+
"persistent",
|
|
41
|
+
] as const)("preserves autonomy %s without rewriting execution or assurance", (preset) => {
|
|
42
|
+
const source = { ...config, autonomy: { version: 1 as const, preset } };
|
|
43
|
+
const draft = projectSettingsDraft(source);
|
|
44
|
+
const payload = buildProjectSettingsPayload(source, draft.components, draft.otherOverrides);
|
|
45
|
+
expect(payload.autonomy).toEqual(source.autonomy);
|
|
46
|
+
expect(payload.execution).toEqual(source.execution);
|
|
47
|
+
expect(payload.assurance).toEqual(source.assurance);
|
|
48
|
+
});
|
|
37
49
|
it("renders a canonical framework SemVer as a short major.minor label", () => {
|
|
38
50
|
expect(shortFrameworkVersion("2.5.0")).toBe("v2.5");
|
|
39
51
|
expect(shortFrameworkVersion("v2.5.0")).toBe("v2.5");
|
|
@@ -277,7 +277,7 @@ describe("atomic Cost snapshot loading", () => {
|
|
|
277
277
|
periodChange.lastIndexOf("setOperationsPeriod(nextPeriod);"),
|
|
278
278
|
);
|
|
279
279
|
expect(periodChange).toContain(
|
|
280
|
-
"
|
|
280
|
+
"isSameOperationsRequestPeriod(operationsPeriodRef.current, nextPeriod)",
|
|
281
281
|
);
|
|
282
282
|
expect(periodChange).toContain("setOperationsLoading(true);");
|
|
283
283
|
expect(periodChange).toContain('setLoadingArea("operations");');
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { OperationsProjection } from "@zaip-ai/dashboard-operations/contracts";
|
|
2
|
-
import type { OperationsBoardPage } from "./dashboard-api.js";
|
|
3
2
|
|
|
4
3
|
/** The selector is a navigation aid, not a full task export. */
|
|
5
4
|
export const traceabilityTaskPageSize = 10;
|
|
@@ -12,7 +11,7 @@ export function appendTraceabilityTaskPage({
|
|
|
12
11
|
tasks,
|
|
13
12
|
}: {
|
|
14
13
|
cursor: TraceabilityTaskCursor;
|
|
15
|
-
page:
|
|
14
|
+
page: { tasks: OperationsProjection["tasks"]; total: number };
|
|
16
15
|
tasks: OperationsProjection["tasks"];
|
|
17
16
|
}): { cursor: TraceabilityTaskCursor; tasks: OperationsProjection["tasks"] } {
|
|
18
17
|
const tasksById = new Map(tasks.map((task) => [task.id, task]));
|
|
@@ -10,12 +10,15 @@ import {
|
|
|
10
10
|
describe("daily Cost Monitor continuous pagination", () => {
|
|
11
11
|
it("uses cost_monitor_daily as a 30-day direct pager across months and keeps full-filter totals", async () => {
|
|
12
12
|
const calls: Array<{ view: string; range: unknown; page: Record<string, unknown> }> = [];
|
|
13
|
+
const average = { tasks: 5, specs: 2, prds: 1, durationMs: 1000, tokens: 50, cost: 10 };
|
|
14
|
+
const periodAverages = { BRL: average, USD: { ...average, cost: 2 } };
|
|
13
15
|
const api = {
|
|
14
16
|
sqliteViewPage: async (view: string, range: unknown, page: Record<string, unknown>) => {
|
|
15
17
|
calls.push({ view, range, page });
|
|
16
18
|
if (page.offset === 0) {
|
|
17
19
|
return {
|
|
18
20
|
offset: 0,
|
|
21
|
+
period_averages: periodAverages,
|
|
19
22
|
limit: 30,
|
|
20
23
|
total_count: 35,
|
|
21
24
|
has_more: true,
|
|
@@ -34,6 +37,7 @@ describe("daily Cost Monitor continuous pagination", () => {
|
|
|
34
37
|
}
|
|
35
38
|
return {
|
|
36
39
|
offset: 30,
|
|
40
|
+
period_averages: periodAverages,
|
|
37
41
|
limit: 30,
|
|
38
42
|
total_count: 35,
|
|
39
43
|
has_more: false,
|
|
@@ -83,6 +87,8 @@ describe("daily Cost Monitor continuous pagination", () => {
|
|
|
83
87
|
filters,
|
|
84
88
|
});
|
|
85
89
|
|
|
90
|
+
expect(firstPage.period_averages).toEqual(periodAverages);
|
|
91
|
+
expect(secondPage.period_averages).toEqual(periodAverages);
|
|
86
92
|
expect(calls).toEqual([
|
|
87
93
|
{
|
|
88
94
|
view: "cost_monitor_daily",
|
|
@@ -90,6 +90,7 @@ export async function loadSqliteCostGroupPage(
|
|
|
90
90
|
total_count: page.total_count,
|
|
91
91
|
has_more: page.has_more,
|
|
92
92
|
rows: page.rows.map(adaptSqliteCostGroup),
|
|
93
|
+
...(page.period_averages === undefined ? {} : { period_averages: page.period_averages }),
|
|
93
94
|
...(page.totals === undefined ? {} : { totals: adaptSqliteCostGroup(page.totals) }),
|
|
94
95
|
};
|
|
95
96
|
}
|
|
@@ -114,6 +115,7 @@ export async function loadSqliteCostGroupPage(
|
|
|
114
115
|
total_count: page.total_count,
|
|
115
116
|
has_more: page.has_more,
|
|
116
117
|
rows: page.rows.map(adaptSqliteCostGroup),
|
|
118
|
+
...(page.period_averages === undefined ? {} : { period_averages: page.period_averages }),
|
|
117
119
|
...(page.totals === undefined ? {} : { totals: adaptSqliteCostGroup(page.totals) }),
|
|
118
120
|
};
|
|
119
121
|
}
|
|
@@ -65,7 +65,9 @@ export function useAppTraceDocuments({
|
|
|
65
65
|
task_title: cardTask?.title || loadedTrace.task_title || taskId,
|
|
66
66
|
task_risk: cardTask?.risk || loadedTrace.task_risk || null,
|
|
67
67
|
task_created_at: cardTask?.created_at || loadedTrace.task_created_at || null,
|
|
68
|
-
|
|
68
|
+
// The detail response is authoritative; an earlier quick card may still
|
|
69
|
+
// carry a partial/default progress value during hydration.
|
|
70
|
+
task_progress: loadedTrace.task_progress ?? cardTask?.progress ?? 0,
|
|
69
71
|
});
|
|
70
72
|
return true;
|
|
71
73
|
} catch (cause) {
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
useRef,
|
|
8
8
|
useState,
|
|
9
9
|
} from "react";
|
|
10
|
-
import { traceTaskSearchStages } from "./AppWorkBoard.js";
|
|
11
10
|
import type { DashboardApiClient } from "./dashboard-api.js";
|
|
12
11
|
import {
|
|
13
12
|
appendTraceabilityTaskPage,
|
|
@@ -35,24 +34,14 @@ export function useAppTraceTaskPagination(
|
|
|
35
34
|
setTraceTasks([]);
|
|
36
35
|
setTraceTasksHasMore(true);
|
|
37
36
|
}
|
|
38
|
-
if (traceTaskCursorRef.current.stageIndex >=
|
|
39
|
-
return traceTasksRef.current;
|
|
37
|
+
if (traceTaskCursorRef.current.stageIndex >= 1) return traceTasksRef.current;
|
|
40
38
|
|
|
41
39
|
traceTasksLoadingRef.current = true;
|
|
42
40
|
setTraceTasksLoading(true);
|
|
43
41
|
try {
|
|
44
42
|
do {
|
|
45
43
|
const cursor = traceTaskCursorRef.current;
|
|
46
|
-
const
|
|
47
|
-
if (stage === undefined) break;
|
|
48
|
-
const page = await api.operationsBoard(
|
|
49
|
-
{ from: null, to: null },
|
|
50
|
-
stage,
|
|
51
|
-
cursor.offset,
|
|
52
|
-
{ kind: "all-tasks" },
|
|
53
|
-
undefined,
|
|
54
|
-
traceabilityTaskPageSize,
|
|
55
|
-
);
|
|
44
|
+
const page = await api.traceabilityTasks(cursor.offset, traceabilityTaskPageSize);
|
|
56
45
|
const updated = appendTraceabilityTaskPage({
|
|
57
46
|
cursor,
|
|
58
47
|
page,
|
|
@@ -62,8 +51,8 @@ export function useAppTraceTaskPagination(
|
|
|
62
51
|
setTraceTasks(traceTasksRef.current);
|
|
63
52
|
traceTaskCursorRef.current = updated.cursor;
|
|
64
53
|
if (page.tasks.length > 0 && !loadAll) break;
|
|
65
|
-
} while (traceTaskCursorRef.current.stageIndex <
|
|
66
|
-
setTraceTasksHasMore(traceTaskCursorRef.current.stageIndex <
|
|
54
|
+
} while (traceTaskCursorRef.current.stageIndex < 1);
|
|
55
|
+
setTraceTasksHasMore(traceTaskCursorRef.current.stageIndex < 1);
|
|
67
56
|
return traceTasksRef.current;
|
|
68
57
|
} finally {
|
|
69
58
|
traceTasksLoadingRef.current = false;
|
|
@@ -620,7 +620,7 @@ export function useDashboardAppModel() {
|
|
|
620
620
|
setTraceLoadingTaskId,
|
|
621
621
|
});
|
|
622
622
|
const currentCostByRun = buildCurrentCostByRun(costs, displayedCosts, currency);
|
|
623
|
-
const {
|
|
623
|
+
const { fact: factualCostFact, periods: factualCostPeriods } = factualCostFacts(
|
|
624
624
|
costs,
|
|
625
625
|
displayedCosts,
|
|
626
626
|
currency,
|
|
@@ -724,7 +724,7 @@ export function useDashboardAppModel() {
|
|
|
724
724
|
entityPage,
|
|
725
725
|
dashboardIdentity,
|
|
726
726
|
operationsLoading,
|
|
727
|
-
|
|
727
|
+
factualCostFact,
|
|
728
728
|
factualCostPeriods,
|
|
729
729
|
setOperationsSurfaceLoading,
|
|
730
730
|
currentCostByRun,
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { OperationsProjection } from "@zaip-ai/dashboard-operations/contracts";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { averageCompleteCost } from "./contracts.js";
|
|
4
|
+
import { buildCostSummaryProjection } from "./server/build-cost-summary-projection.js";
|
|
5
|
+
|
|
6
|
+
describe("population cost averages", () => {
|
|
7
|
+
it.each([
|
|
8
|
+
{ unknown: 1, total: 10, expected: null },
|
|
9
|
+
{ unknown: 1, total: 0, expected: null },
|
|
10
|
+
{ unknown: 0, total: 0, expected: 0 },
|
|
11
|
+
{ unknown: 0, total: 10, expected: 5 },
|
|
12
|
+
])("summary retains subtotal but not diluted mean: $unknown/$total", ({
|
|
13
|
+
unknown,
|
|
14
|
+
total,
|
|
15
|
+
expected,
|
|
16
|
+
}) => {
|
|
17
|
+
const operations = {
|
|
18
|
+
schema_version: 2,
|
|
19
|
+
layout_version: 3,
|
|
20
|
+
readonly: true,
|
|
21
|
+
source: ".agents/records",
|
|
22
|
+
filters: { from: null, to: null },
|
|
23
|
+
summary: { task_count: 1, overview_metrics: {}, usage: {} },
|
|
24
|
+
prds: [],
|
|
25
|
+
specs: [],
|
|
26
|
+
runs: [],
|
|
27
|
+
} as unknown as OperationsProjection;
|
|
28
|
+
const cost = {
|
|
29
|
+
known_sum: total,
|
|
30
|
+
unknown,
|
|
31
|
+
complete: unknown === 0,
|
|
32
|
+
coverage_ratio: (2 - unknown) / 2,
|
|
33
|
+
currency: "BRL",
|
|
34
|
+
};
|
|
35
|
+
const projection = buildCostSummaryProjection(
|
|
36
|
+
{
|
|
37
|
+
periods: {
|
|
38
|
+
daily: {
|
|
39
|
+
"2026-08-19": {
|
|
40
|
+
prds: 0,
|
|
41
|
+
specs: 0,
|
|
42
|
+
tasks: 1,
|
|
43
|
+
validations: 0,
|
|
44
|
+
evidences: 0,
|
|
45
|
+
runs: 2,
|
|
46
|
+
usage: {
|
|
47
|
+
total_tokens: { known_sum: 100, unknown: 0, complete: true, coverage_ratio: 1 },
|
|
48
|
+
cost,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
cost_monitor_daily_duration: {},
|
|
54
|
+
daily_rows: [{ key: "2026-08-19", total_cost_usd: total, total_cost_brl: total }],
|
|
55
|
+
},
|
|
56
|
+
operations,
|
|
57
|
+
"BRL",
|
|
58
|
+
null,
|
|
59
|
+
);
|
|
60
|
+
expect(projection.overview.estimated_brl).toBe(total);
|
|
61
|
+
expect(projection.overview.average_run_cost_brl).toBe(expected);
|
|
62
|
+
});
|
|
63
|
+
it.each([
|
|
64
|
+
{ values: [], expected: null },
|
|
65
|
+
{ values: [null], expected: null },
|
|
66
|
+
{ values: [10, null], expected: null },
|
|
67
|
+
{ values: [0, null], expected: null },
|
|
68
|
+
{ values: [0, 0], expected: 0 },
|
|
69
|
+
{ values: [10, 20], expected: 15 },
|
|
70
|
+
])("preserves completeness: $values", ({ values, expected }) => {
|
|
71
|
+
expect(averageCompleteCost(values)).toBe(expected);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { ReadonlyV2Projection } from "@zaip-ai/dashboard-contracts";
|
|
2
|
+
|
|
3
|
+
export type { CostPeriodAverages } from "./period-averages.js";
|
|
4
|
+
|
|
2
5
|
import type {
|
|
3
6
|
MacroProjection,
|
|
4
7
|
ProjectionTimeFilter,
|
|
@@ -22,6 +25,12 @@ export interface DurationCoverage {
|
|
|
22
25
|
export type DurationAggregationScope = "root_execution" | "all_execution" | "all_invocations";
|
|
23
26
|
|
|
24
27
|
/** Returns the sum of reported values; missing telemetry does not erase known usage. */
|
|
28
|
+
/** A population average must not treat missing Run costs as observed zero. */
|
|
29
|
+
export function averageCompleteCost(values: readonly (number | null)[]): number | null {
|
|
30
|
+
if (values.length === 0 || values.some((value) => value === null)) return null;
|
|
31
|
+
return values.reduce<number>((total, value) => total + (value ?? 0), 0) / values.length;
|
|
32
|
+
}
|
|
33
|
+
|
|
25
34
|
export function sumKnown(values: readonly (number | null)[]): number | null {
|
|
26
35
|
const known = values.filter((value): value is number => value !== null);
|
|
27
36
|
return known.length === 0 ? null : known.reduce((sum, value) => sum + value, 0);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { CostGroupRow } from "./contracts.js";
|
|
2
|
+
|
|
3
|
+
export interface CostPeriodAverages {
|
|
4
|
+
tasks: number | null;
|
|
5
|
+
specs: number | null;
|
|
6
|
+
prds: number | null;
|
|
7
|
+
durationMs: number | null;
|
|
8
|
+
tokens: number | null;
|
|
9
|
+
cost: number | null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function summarizeCostPeriodAverages(
|
|
13
|
+
rows: readonly Pick<
|
|
14
|
+
CostGroupRow,
|
|
15
|
+
| "task_count"
|
|
16
|
+
| "spec_count"
|
|
17
|
+
| "prd_count"
|
|
18
|
+
| "duration_ms"
|
|
19
|
+
| "total_tokens"
|
|
20
|
+
| "estimated_usd"
|
|
21
|
+
| "estimated_brl"
|
|
22
|
+
>[],
|
|
23
|
+
currency: "BRL" | "USD",
|
|
24
|
+
): CostPeriodAverages {
|
|
25
|
+
const divisor = rows.length;
|
|
26
|
+
return {
|
|
27
|
+
tasks: averagePerPeriod(
|
|
28
|
+
rows.map((row) => row.task_count),
|
|
29
|
+
divisor,
|
|
30
|
+
),
|
|
31
|
+
specs: averagePerPeriod(
|
|
32
|
+
rows.map((row) => row.spec_count),
|
|
33
|
+
divisor,
|
|
34
|
+
),
|
|
35
|
+
prds: averagePerPeriod(
|
|
36
|
+
rows.map((row) => row.prd_count),
|
|
37
|
+
divisor,
|
|
38
|
+
),
|
|
39
|
+
durationMs: averagePerPeriod(
|
|
40
|
+
rows.map((row) => row.duration_ms),
|
|
41
|
+
divisor,
|
|
42
|
+
),
|
|
43
|
+
tokens: averageObserved(rows.map((row) => row.total_tokens)),
|
|
44
|
+
cost: averageObserved(
|
|
45
|
+
rows.map((row) => (currency === "BRL" ? row.estimated_brl : row.estimated_usd)),
|
|
46
|
+
),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function averageObserved(values: readonly (number | null)[]): number | null {
|
|
51
|
+
const present = values.filter((value): value is number => value !== null);
|
|
52
|
+
return present.length === 0
|
|
53
|
+
? null
|
|
54
|
+
: present.reduce((sum, value) => sum + value, 0) / present.length;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function averagePerPeriod(values: readonly (number | null)[], periodCount: number): number | null {
|
|
58
|
+
if (periodCount === 0 || values.every((value) => value === null)) return null;
|
|
59
|
+
return values.reduce<number>((sum, value) => sum + (value ?? 0), 0) / periodCount;
|
|
60
|
+
}
|
|
@@ -11,9 +11,9 @@ import type { CostCurrency, CostLocale } from "./cost-monitor-copy.js";
|
|
|
11
11
|
import type { CostView } from "./cost-monitor-views.js";
|
|
12
12
|
import { MacroCostTable } from "./MacroCostTable.js";
|
|
13
13
|
import {
|
|
14
|
+
type CostGroupPage,
|
|
14
15
|
type CostGroupTotals,
|
|
15
16
|
costGroupPageLabel,
|
|
16
|
-
reconcileCostGroupTotalsWithCards,
|
|
17
17
|
} from "./use-cost-group-page.js";
|
|
18
18
|
|
|
19
19
|
type CostRunRows = ComponentProps<typeof CostRunsTable>["rows"];
|
|
@@ -90,13 +90,7 @@ export function CostMonitorContent({
|
|
|
90
90
|
providers: CostGroupRows;
|
|
91
91
|
tasks: CostGroupRows;
|
|
92
92
|
};
|
|
93
|
-
groupPage:
|
|
94
|
-
offset: number;
|
|
95
|
-
limit: number;
|
|
96
|
-
total_count: number;
|
|
97
|
-
has_more: boolean;
|
|
98
|
-
totals?: CostGroupTotals;
|
|
99
|
-
} | null;
|
|
93
|
+
groupPage: Omit<CostGroupPage, "rows"> | null;
|
|
100
94
|
groupPageLoading: boolean;
|
|
101
95
|
groupPageOffset: number;
|
|
102
96
|
locale: CostLocale;
|
|
@@ -290,15 +284,7 @@ export function CostMonitorContent({
|
|
|
290
284
|
locale={locale}
|
|
291
285
|
loading={groupPageLoading}
|
|
292
286
|
rows={groups[key]}
|
|
293
|
-
{...(
|
|
294
|
-
? groupPage?.totals === undefined
|
|
295
|
-
? {}
|
|
296
|
-
: { totals: groupPage.totals }
|
|
297
|
-
: key === "providers"
|
|
298
|
-
? { totals: summaryTotals }
|
|
299
|
-
: groupPage?.totals === undefined
|
|
300
|
-
? {}
|
|
301
|
-
: { totals: groupPage.totals })}
|
|
287
|
+
{...(groupPage?.totals === undefined ? {} : { totals: groupPage.totals })}
|
|
302
288
|
{...(key === "agents"
|
|
303
289
|
? { showDateTime: false, showAgentIdentity: true }
|
|
304
290
|
: key === "models"
|
|
@@ -316,6 +302,10 @@ export function CostMonitorContent({
|
|
|
316
302
|
<CostPeriodAverageCards
|
|
317
303
|
currency={currency}
|
|
318
304
|
locale={locale}
|
|
305
|
+
loading={groupPageLoading}
|
|
306
|
+
{...(groupPage === null
|
|
307
|
+
? {}
|
|
308
|
+
: { average: groupPage.period_averages?.[currency] ?? null })}
|
|
319
309
|
period={view}
|
|
320
310
|
rows={groups[view]}
|
|
321
311
|
/>
|
|
@@ -326,11 +316,7 @@ export function CostMonitorContent({
|
|
|
326
316
|
period={view}
|
|
327
317
|
rows={groups[view]}
|
|
328
318
|
showDateTime={false}
|
|
329
|
-
totals={
|
|
330
|
-
groupPage?.totals === undefined
|
|
331
|
-
? summaryTotals
|
|
332
|
-
: reconcileCostGroupTotalsWithCards(groupPage.totals, summaryTotals)
|
|
333
|
-
}
|
|
319
|
+
totals={groupPage?.totals ?? summaryTotals}
|
|
334
320
|
/>
|
|
335
321
|
{groupPager}
|
|
336
322
|
</>
|
|
@@ -491,9 +491,8 @@ export function CostMonitorPage({
|
|
|
491
491
|
(total, row) => total + row.duration.known_sum,
|
|
492
492
|
0,
|
|
493
493
|
);
|
|
494
|
-
//
|
|
495
|
-
//
|
|
496
|
-
// visible subset or its paginated SQLite total.
|
|
494
|
+
// Card totals are a fallback for local, non-paged data only. Remote tables
|
|
495
|
+
// retain the full filtered totals returned alongside their paginated rows.
|
|
497
496
|
const cardMetrics = operations?.summary.overview_metrics;
|
|
498
497
|
const cardDurationTotal = cardMetrics ? cardMetrics.duration_ms : canonicalDurationTotal;
|
|
499
498
|
const summaryTotals = {
|
package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostPeriodAverageCards.tsx
CHANGED
|
@@ -5,49 +5,73 @@ import {
|
|
|
5
5
|
formatNumber,
|
|
6
6
|
PeriodAverageCards,
|
|
7
7
|
} from "@zaip-ai/dashboard-ui";
|
|
8
|
-
import type { CostGroupRow } from "../contracts.js";
|
|
8
|
+
import type { CostGroupRow, CostPeriodAverages } from "../contracts.js";
|
|
9
9
|
import type { CostCurrency, CostLocale } from "./cost-monitor-copy.js";
|
|
10
10
|
import { type CostPeriodGranularity, summarizeCostPeriodAverages } from "./period-cost-groups.js";
|
|
11
11
|
|
|
12
12
|
export function CostPeriodAverageCards({
|
|
13
13
|
currency,
|
|
14
14
|
locale,
|
|
15
|
+
loading = false,
|
|
16
|
+
average: suppliedAverage,
|
|
15
17
|
period,
|
|
16
18
|
rows,
|
|
17
19
|
}: {
|
|
18
20
|
currency: CostCurrency;
|
|
19
21
|
locale: CostLocale;
|
|
22
|
+
loading?: boolean;
|
|
23
|
+
average?: CostPeriodAverages | null;
|
|
20
24
|
period: CostPeriodGranularity;
|
|
21
25
|
rows: readonly CostGroupRow[];
|
|
22
26
|
}) {
|
|
23
|
-
|
|
27
|
+
if (loading) {
|
|
28
|
+
return <p role="status">{locale === "pt-BR" ? "Carregando médias…" : "Loading averages…"}</p>;
|
|
29
|
+
}
|
|
30
|
+
// A server page without full-population averages is unavailable, never a page-only average.
|
|
31
|
+
const average =
|
|
32
|
+
suppliedAverage === undefined
|
|
33
|
+
? summarizeCostPeriodAverages(rows, currency)
|
|
34
|
+
: (suppliedAverage ?? {
|
|
35
|
+
tasks: null,
|
|
36
|
+
specs: null,
|
|
37
|
+
prds: null,
|
|
38
|
+
durationMs: null,
|
|
39
|
+
tokens: null,
|
|
40
|
+
cost: null,
|
|
41
|
+
});
|
|
42
|
+
const unavailable = locale === "pt-BR" ? "Indisponível" : "Unavailable";
|
|
24
43
|
return (
|
|
25
44
|
<PeriodAverageCards
|
|
26
45
|
ariaLabel={periodAverageAriaLabel(period, locale)}
|
|
27
46
|
metrics={[
|
|
28
47
|
{
|
|
29
48
|
label: periodAverageMetricLabel(locale === "pt-BR" ? "Tarefas" : "Tasks", period, locale),
|
|
30
|
-
value: formatNumber(average.tasks, locale, 1),
|
|
49
|
+
value: average.tasks === null ? unavailable : formatNumber(average.tasks, locale, 1),
|
|
31
50
|
},
|
|
32
51
|
{
|
|
33
52
|
label: periodAverageMetricLabel("SPECs", period, locale),
|
|
34
|
-
value: formatNumber(average.specs, locale, 1),
|
|
53
|
+
value: average.specs === null ? unavailable : formatNumber(average.specs, locale, 1),
|
|
35
54
|
},
|
|
36
55
|
{
|
|
37
56
|
label: periodAverageMetricLabel("PRDs", period, locale),
|
|
38
|
-
value: formatNumber(average.prds, locale, 1),
|
|
57
|
+
value: average.prds === null ? unavailable : formatNumber(average.prds, locale, 1),
|
|
39
58
|
},
|
|
40
59
|
{
|
|
41
60
|
label: periodAverageMetricLabel(locale === "pt-BR" ? "Tempo" : "Time", period, locale),
|
|
42
|
-
value:
|
|
61
|
+
value:
|
|
62
|
+
average.durationMs === null
|
|
63
|
+
? unavailable
|
|
64
|
+
: formatAverageDurationMs(average.durationMs, locale),
|
|
43
65
|
},
|
|
44
66
|
{
|
|
45
67
|
label: periodAverageMetricLabel("Tokens", period, locale),
|
|
46
|
-
value:
|
|
68
|
+
value:
|
|
69
|
+
average.tokens === null ? unavailable : formatCompactNumber(average.tokens, locale),
|
|
47
70
|
},
|
|
48
71
|
{
|
|
49
72
|
label: periodAverageMetricLabel(locale === "pt-BR" ? "Custo" : "Cost", period, locale),
|
|
50
|
-
value:
|
|
73
|
+
value:
|
|
74
|
+
average.cost === null ? unavailable : formatCurrency(average.cost, currency, locale),
|
|
51
75
|
},
|
|
52
76
|
]}
|
|
53
77
|
/>
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
} from "@zaip-ai/dashboard-operations/contracts";
|
|
6
6
|
import {
|
|
7
7
|
aggregateDurationCoverage,
|
|
8
|
+
averageCompleteCost,
|
|
8
9
|
type CostGroupRow,
|
|
9
10
|
type CostMonitorProjection,
|
|
10
11
|
type CostRunRow,
|
|
@@ -120,8 +121,8 @@ export function summarizeCostRows(
|
|
|
120
121
|
estimated_brl: sumKnown(rows.map((row) => row.estimated_brl)),
|
|
121
122
|
recorded_usd: sumKnown(rows.map((row) => row.recorded_usd)),
|
|
122
123
|
recorded_brl: sumKnown(rows.map((row) => row.recorded_brl)),
|
|
123
|
-
average_run_cost_usd:
|
|
124
|
-
average_run_cost_brl:
|
|
124
|
+
average_run_cost_usd: averageCompleteCost(rows.map((row) => row.estimated_usd)),
|
|
125
|
+
average_run_cost_brl: averageCompleteCost(rows.map((row) => row.estimated_brl)),
|
|
125
126
|
average_run_duration_ms: average(durationContributors(rows).map((row) => row.duration_ms)),
|
|
126
127
|
known_tokens_per_cycle: knownCycles === 0 ? null : knownTokens / knownCycles,
|
|
127
128
|
top_10_token_share: knownTokens === 0 ? null : top10Tokens / knownTokens,
|
|
@@ -3,14 +3,7 @@ import type { CostGroupRow } from "../contracts.js";
|
|
|
3
3
|
|
|
4
4
|
export type CostPeriodGranularity = "daily" | "monthly" | "annual";
|
|
5
5
|
|
|
6
|
-
export
|
|
7
|
-
tasks: number | null;
|
|
8
|
-
specs: number | null;
|
|
9
|
-
prds: number | null;
|
|
10
|
-
durationMs: number | null;
|
|
11
|
-
tokens: number | null;
|
|
12
|
-
cost: number | null;
|
|
13
|
-
}
|
|
6
|
+
export { type CostPeriodAverages, summarizeCostPeriodAverages } from "../period-averages.js";
|
|
14
7
|
|
|
15
8
|
interface PeriodEntities {
|
|
16
9
|
prds: readonly { created_at: string | null }[];
|
|
@@ -122,40 +115,6 @@ export function enrichPeriodCostGroups(
|
|
|
122
115
|
return [...rows.values()].sort((left, right) => right.key.localeCompare(left.key));
|
|
123
116
|
}
|
|
124
117
|
|
|
125
|
-
export function summarizeCostPeriodAverages(
|
|
126
|
-
rows: readonly CostGroupRow[],
|
|
127
|
-
currency: "BRL" | "USD",
|
|
128
|
-
): CostPeriodAverages {
|
|
129
|
-
const divisor = rows.length;
|
|
130
|
-
return {
|
|
131
|
-
tasks:
|
|
132
|
-
divisor === 0 ? null : rows.reduce((sum, row) => sum + (row.task_count ?? 0), 0) / divisor,
|
|
133
|
-
specs:
|
|
134
|
-
divisor === 0 ? null : rows.reduce((sum, row) => sum + (row.spec_count ?? 0), 0) / divisor,
|
|
135
|
-
prds: divisor === 0 ? null : rows.reduce((sum, row) => sum + (row.prd_count ?? 0), 0) / divisor,
|
|
136
|
-
durationMs: averagePerPeriod(
|
|
137
|
-
rows.map((row) => row.duration_ms),
|
|
138
|
-
divisor,
|
|
139
|
-
),
|
|
140
|
-
tokens: averageObserved(rows.map((row) => row.total_tokens)),
|
|
141
|
-
cost: averageObserved(
|
|
142
|
-
rows.map((row) => (currency === "BRL" ? row.estimated_brl : row.estimated_usd)),
|
|
143
|
-
),
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function averageObserved(values: readonly (number | null)[]): number | null {
|
|
148
|
-
const present = values.filter((value): value is number => value !== null);
|
|
149
|
-
return present.length === 0
|
|
150
|
-
? null
|
|
151
|
-
: present.reduce((sum, value) => sum + value, 0) / present.length;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function averagePerPeriod(values: readonly (number | null)[], periodCount: number): number | null {
|
|
155
|
-
if (periodCount === 0) return null;
|
|
156
|
-
return values.reduce<number>((sum, value) => sum + (value ?? 0), 0) / periodCount;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
118
|
function periodKey(value: string | null, granularity: CostPeriodGranularity): string | null {
|
|
160
119
|
return saoPauloPeriodKey(
|
|
161
120
|
value,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from "react";
|
|
2
|
-
import type { CostGroupRow } from "../contracts.js";
|
|
2
|
+
import type { CostGroupRow, CostPeriodAverages } from "../contracts.js";
|
|
3
3
|
import type { CostFilterState } from "./CostFilters.js";
|
|
4
4
|
import type { CostLocale } from "./cost-monitor-copy.js";
|
|
5
5
|
|
|
@@ -26,6 +26,7 @@ export type CostGroupPage = {
|
|
|
26
26
|
has_more: boolean;
|
|
27
27
|
rows: readonly CostGroupRow[];
|
|
28
28
|
totals?: CostGroupTotals;
|
|
29
|
+
period_averages?: Record<"BRL" | "USD", CostPeriodAverages>;
|
|
29
30
|
};
|
|
30
31
|
export type CostGroupFilters = CostFilterState;
|
|
31
32
|
export type LoadCostGroupPage = (request: {
|
package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-projection.ts
CHANGED
|
@@ -15,6 +15,7 @@ import type {
|
|
|
15
15
|
import { LEGACY_EFFORT_SNAPSHOT, saoPauloPeriodKey } from "@zaip-ai/dashboard-operations/contracts";
|
|
16
16
|
import { includeConfiguredAgentGroups } from "../agent-groups.js";
|
|
17
17
|
import {
|
|
18
|
+
averageCompleteCost,
|
|
18
19
|
type CostMonitorProjection,
|
|
19
20
|
type CostRunRow,
|
|
20
21
|
durationAggregationRows,
|
|
@@ -215,8 +216,8 @@ export function buildCostMonitorProjection(
|
|
|
215
216
|
recorded_brl: availableCurrencySum(
|
|
216
217
|
tableRuns.map((run) => recordedRunsById.get(run.id)?.usage.total.cost.brl ?? null),
|
|
217
218
|
),
|
|
218
|
-
average_run_cost_usd:
|
|
219
|
-
average_run_cost_brl:
|
|
219
|
+
average_run_cost_usd: averageCompleteCost(rows.map((row) => row.estimated_usd)),
|
|
220
|
+
average_run_cost_brl: averageCompleteCost(rows.map((row) => row.estimated_brl)),
|
|
220
221
|
average_run_duration_ms: averageAvailable(
|
|
221
222
|
durationAggregationRows(rows).map((row) => row.duration_ms),
|
|
222
223
|
),
|
package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-projection.ts
CHANGED
|
@@ -183,8 +183,14 @@ export function buildCostSummaryProjection(
|
|
|
183
183
|
estimated_brl: brlTotal,
|
|
184
184
|
recorded_usd: null,
|
|
185
185
|
recorded_brl: null,
|
|
186
|
-
average_run_cost_usd:
|
|
187
|
-
|
|
186
|
+
average_run_cost_usd:
|
|
187
|
+
runCount === 0 || usdTotal === null || coverage.usd !== runCount
|
|
188
|
+
? null
|
|
189
|
+
: usdTotal / runCount,
|
|
190
|
+
average_run_cost_brl:
|
|
191
|
+
runCount === 0 || brlTotal === null || coverage.brl !== runCount
|
|
192
|
+
? null
|
|
193
|
+
: brlTotal / runCount,
|
|
188
194
|
// Legacy effort has no individual Run cardinality, so it is not a
|
|
189
195
|
// legitimate contributor to an average per Run.
|
|
190
196
|
average_run_duration_ms: observedDurationAverage,
|