@zaip-ai/cli 1.0.8 → 1.3.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 +1 -1
- package/dist/services/adapters.d.ts +1 -1
- package/dist/services/adapters.js +1 -1
- package/dist/services/agent-adapters.js +2 -2
- package/dist/services/agent-adapters.js.map +1 -1
- package/dist/services/agent-adapters.test.js +5 -0
- package/dist/services/agent-adapters.test.js.map +1 -1
- package/dist/services/logger.test.js +2 -2
- package/dist/services/runtime-template.test.js +6 -6
- package/dist/services/template-manifest.d.ts.map +1 -1
- package/dist/services/template-manifest.js +5 -0
- package/dist/services/template-manifest.js.map +1 -1
- package/package.json +1 -1
- package/templates/.agents/architecture/software-architecture.md +131 -0
- package/templates/.agents/branding/brandbook.docx +0 -0
- package/templates/.agents/branding/brandbook.md +60 -0
- package/templates/.agents/config/clients/codex/agents/zaip-agent-finalizer.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-orchestrator.toml +1 -1
- package/templates/.agents/dashboard/.tmp-run-list.json +254 -0
- package/templates/.agents/dashboard/.zaip-managed.json +252 -136
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{CostCalculationGuidePage-Z60df2r-.js → CostCalculationGuidePage-DxR_pgSV.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/DashboardHelpDialog-4jZLTWE_.js +2156 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{PricingSettingsDialog-Coc6pA-1.js → PricingSettingsDialog-CKcsqb-r.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-BomxqCBU.css +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-DmmJD2Th.js +3 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/TraceabilityWorkspace-BwtitWa_.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-N5Csr0RP.js +68 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{icons-vendor-DFBuc_qp.js → icons-vendor-C0fj2uU9.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-C4aIB1PV.js +2 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{react-vendor-CCQOHdVI.js → react-vendor-BEsJ-FYH.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{traceability-pC2_0J8x.js → traceability-B6y6Gw12.js} +1 -1
- 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/App.tsx +204 -32
- package/templates/.agents/dashboard/apps/frontend/src/DashboardAlternateContent.tsx +11 -11
- package/templates/.agents/dashboard/apps/frontend/src/ProjectSettingsPage.tsx +14 -7
- package/templates/.agents/dashboard/apps/frontend/src/ProjectStackEditor.tsx +4 -2
- package/templates/.agents/dashboard/apps/frontend/src/TraceabilityWorkspace.test.ts +3 -1
- package/templates/.agents/dashboard/apps/frontend/src/TraceabilityWorkspace.tsx +14 -11
- package/templates/.agents/dashboard/apps/frontend/src/cost-period-refresh.test.ts +19 -4
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-api.test.ts +24 -2
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-api.ts +22 -1
- package/templates/.agents/dashboard/apps/frontend/src/overview-status-page.test.ts +3 -1
- package/templates/.agents/dashboard/apps/frontend/src/project-settings-page.css +36 -26
- package/templates/.agents/dashboard/apps/frontend/src/project-settings.test.ts +2 -2
- package/templates/.agents/dashboard/apps/frontend/src/snapshot-banner-semantics.test.ts +40 -6
- package/templates/.agents/dashboard/apps/frontend/src/snapshot-coherence.test.ts +39 -1
- package/templates/.agents/dashboard/apps/frontend/src/use-app-cost-loaders.test.ts +89 -23
- package/templates/.agents/dashboard/apps/frontend/src/use-app-cost-loaders.ts +219 -29
- package/templates/.agents/dashboard/apps/frontend/src/use-app-effects.ts +61 -7
- package/templates/.agents/dashboard/apps/frontend/src/use-app-operations-pages.ts +3 -6
- package/templates/.agents/dashboard/apps/frontend/src/work-list-pagination.test.ts +2 -2
- package/templates/.agents/dashboard/apps/frontend/src/work-list-pagination.ts +3 -4
- package/templates/.agents/dashboard/apps/frontend/vite.config.ts +4 -1
- package/templates/.agents/dashboard/modules/cost-monitor/package.json +1 -1
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CompactLifecycleCostTable.test.ts +89 -19
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CompactLifecycleCostTable.tsx +31 -16
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostCharts.test.ts +43 -14
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostCharts.tsx +5 -5
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostModelsAuditTable.tsx +1 -1
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorContent.tsx +67 -42
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.test.ts +115 -39
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.tsx +188 -38
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables.test.ts +75 -17
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables.tsx +147 -58
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor.css +5 -2
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/index.ts +2 -2
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/period-cost-groups.ts +2 -1
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-compact-cost-page.ts +18 -7
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-cost-group-page.ts +95 -9
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-cost-run-page.ts +29 -17
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-projection.test.ts +0 -24
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-projection.test.ts +225 -424
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-projection.ts +24 -15
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-terminal-day.test.ts +6 -1
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/source-size-cost-server/build-cost-monitor-projection-agents.test.ts +31 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/source-size-cost-server/build-cost-summary-projection-duration.test.ts +414 -0
- package/templates/.agents/dashboard/modules/operations/package.json +1 -1
- package/templates/.agents/dashboard/modules/operations/src/contracts.ts +26 -23
- package/templates/.agents/dashboard/modules/operations/src/react/EntityTables.tsx +31 -11
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.test.ts +3 -1
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.tsx +51 -21
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsPage.tsx +47 -5
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsPageNavigation.tsx +1 -4
- package/templates/.agents/dashboard/modules/operations/src/react/PeriodSummaryTable.tsx +32 -10
- package/templates/.agents/dashboard/modules/operations/src/react/TaskDetailsDialog.tsx +9 -3
- package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkBoard.tsx +13 -5
- package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkList.test.ts +12 -4
- package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkList.tsx +1 -4
- package/templates/.agents/dashboard/modules/operations/src/react/conversation-rows.ts +1 -2
- package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportAction.test.ts +385 -4
- package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportAction.tsx +481 -61
- package/templates/.agents/dashboard/modules/operations/src/react/export/export-layout.test.ts +14 -1
- package/templates/.agents/dashboard/modules/operations/src/react/export/xlsx-runtime-e2e.test.ts +248 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operation-duration.test.ts +4 -4
- package/templates/.agents/dashboard/modules/operations/src/react/operation-duration.ts +6 -4
- package/templates/.agents/dashboard/modules/operations/src/react/operations-global-filters.test.ts +4 -1
- package/templates/.agents/dashboard/modules/operations/src/react/operations-overview-period-filter.test.ts +1 -1
- package/templates/.agents/dashboard/modules/operations/src/react/operations-overview.status-cards.test.ts +1 -1
- package/templates/.agents/dashboard/modules/operations/src/react/operations-page-contract.ts +46 -6
- package/templates/.agents/dashboard/modules/operations/src/react/operations-view-order.test.ts +1 -4
- package/templates/.agents/dashboard/modules/operations/src/react/period-summary.test.ts +82 -6
- package/templates/.agents/dashboard/modules/operations/src/react/work-board-model.test.ts +2 -1
- package/templates/.agents/dashboard/modules/operations/src/react/work-board-model.ts +1 -1
- package/templates/.agents/dashboard/modules/operations/src/server/execution-relationship-counts.test.ts +19 -7
- package/templates/.agents/dashboard/modules/operations/src/server/execution-relationship-counts.ts +4 -1
- package/templates/.agents/dashboard/modules/operations/src/server/quick-daily-operations-projection.ts +11 -5
- 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/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 +152 -149
- package/templates/.agents/dashboard/packages/local-runtime/dist/server.cjs.metafile.json +7333 -0
- package/templates/.agents/dashboard/packages/local-runtime/dist/sqlite-read-model.cjs +149 -146
- package/templates/.agents/dashboard/packages/local-runtime/package.json +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/scripts/build-sqlite-dashboard.mjs +15 -7
- package/templates/.agents/dashboard/packages/local-runtime/scripts/build-sqlite-runtime.mjs +44 -13
- package/templates/.agents/dashboard/packages/local-runtime/scripts/rebuild-sqlite-read-model.mjs +5 -2
- package/templates/.agents/dashboard/packages/local-runtime/scripts/source-size-runtime-scripts/sqlite-read-model-fixture.mjs +397 -0
- package/templates/.agents/dashboard/packages/local-runtime/scripts/test-sqlite-read-model.mjs +472 -145
- package/templates/.agents/dashboard/packages/local-runtime/scripts/test-unix-launchers.mjs +15 -3
- package/templates/.agents/dashboard/packages/local-runtime/scripts/validate-sqlite-read-model.mjs +129 -31
- package/templates/.agents/dashboard/packages/local-runtime/server.mjs +153 -150
- package/templates/.agents/dashboard/packages/local-runtime/src/project-settings.test.ts +6 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/project-settings.ts +3 -3
- package/templates/.agents/dashboard/packages/local-runtime/src/server-board.test.ts +55 -16
- package/templates/.agents/dashboard/packages/local-runtime/src/server-board.ts +23 -13
- package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot.test.ts +19 -4
- package/templates/.agents/dashboard/packages/local-runtime/src/server-workspace.ts +7 -3
- package/templates/.agents/dashboard/packages/local-runtime/src/server.test.ts +132 -9
- package/templates/.agents/dashboard/packages/local-runtime/src/server.ts +126 -60
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-metric-contract.ts +16 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model.test.ts +1861 -350
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model.ts +1218 -352
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard.mjs +119 -42
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard.test.mjs +45 -20
- package/templates/.agents/dashboard/packages/ui/package.json +1 -1
- package/templates/.agents/dashboard/tests/e2e/package.json +1 -1
- package/templates/.agents/dashboard/tests/e2e/specs/dashboard.spec.ts +7 -5
- 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/growth/estrategia-bootstrap-90-dias.md +169 -0
- package/templates/.agents/growth/strategy.md +27 -0
- package/templates/.agents/marketing/estrategia-marketing-zaip-90-dias.md +197 -0
- package/templates/.agents/marketing/strategy.md +29 -0
- 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 +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 +1 -1
- package/templates/.agents/requirements/zaip-strategic-95.md +1 -1
- package/templates/.agents/runtime/VERSION +1 -1
- package/templates/.agents/runtime/bin/zaip.mjs +30 -29
- 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/sales/playbook.md +32 -0
- package/templates/.agents/sales/roteiro-comercial-zaip.md +252 -0
- package/templates/.agents/skills/zaip-aios/SKILL.md +1 -1
- package/templates/.agents/skills/zaip-skill-brand-governance/SKILL.md +9 -2
- package/templates/.agents/skills/zaip-skill-brand-governance/references/brandbook-framework.md +39 -0
- package/templates/.agents/skills/zaip-skill-brand-governance/references/brandbook-standards.md +1 -1
- package/templates/.agents/skills/zaip-skill-enforce-architecture/SKILL.md +2 -0
- package/templates/.agents/skills/zaip-skill-growth-strategy-revops/SKILL.md +6 -0
- package/templates/.agents/skills/zaip-skill-marketing/SKILL.md +6 -0
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-local-telemetry.mjs +39 -82
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-lib.mjs +13 -8
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-lib.test.mjs +44 -14
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-remeasurement.mjs +19 -9
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-remeasurement.test.mjs +29 -5
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/source-size-telemetry/model-identity-reconciliation.mjs +77 -0
- package/templates/.agents/skills/zaip-skill-sales-methodology/SKILL.md +6 -0
- package/templates/.agents/skills/zaip-skill-sqlite-read-model/scripts/ensure-node.mjs +28 -5
- package/templates/.agents/zaip-aios/INDEX.md +10 -0
- package/templates/.agents/zaip-aios/README.md +2 -1
- package/templates/.agents/zaip-aios/VERSION +1 -1
- package/templates/.agents/zaip-aios/guides/18-catalogo-de-agentes.md +76 -0
- package/templates/.agents/zaip-aios/guides/19-assurance-e-autonomia.md +72 -0
- package/templates/.agents/zaip-aios/guides/20-instalacao-detalhada.md +330 -0
- package/templates/.agents/zaip-aios/guides/21-telemetria-monitor-custos.md +52 -0
- package/templates/.agents/zaip-aios/guides/22-fluxos-e-roteamento.md +69 -0
- package/templates/.agents/zaip-aios/guides/23-orquestracao-de-modelos.md +483 -0
- package/templates/.agents/zaip-aios/guides/24-calculo-de-custos-openai.md +85 -0
- package/templates/.agents/zaip-aios/guides/25-fontes-de-precos-openai.md +18 -0
- package/templates/.agents/zaip-aios/guides/26-qualidade-e-release.md +44 -0
- package/templates/.agents/zaip-aios/guides/27-telemetria-git-native.md +167 -0
- package/templates/.agents/zaip-aios/guides/28-lifecycle-completo.md +144 -0
- package/templates/.agents/zaip-aios/guides/assets/diagrams/lifecycles-task-spec-prd.png +0 -0
- package/templates/.agents/zaip-aios/guides/assets/diagrams/prd-lifecycle.png +0 -0
- package/templates/.agents/zaip-aios/guides/assets/diagrams/spec-lifecycle.png +0 -0
- package/templates/.agents/zaip-aios/guides/assets/diagrams/task-lifecycle.png +0 -0
- package/templates/template-manifest.json +313 -177
- package/templates/.agents/dashboard/apps/frontend/dist/assets/DashboardHelpDialog-Cs6dzDmW.js +0 -1505
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-QE1k9yZB.css +0 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-_Pf5DA_A.js +0 -3
- package/templates/.agents/dashboard/apps/frontend/dist/assets/TraceabilityWorkspace-BVlz3DLZ.js +0 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-Cf9ctPVt.js +0 -68
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-8A4DcNXM.js +0 -2
package/templates/.agents/dashboard/modules/cost-monitor/src/react/CompactLifecycleCostTable.test.ts
CHANGED
|
@@ -8,21 +8,47 @@ describe("CompactLifecycleCostTable filtered subtotal", () => {
|
|
|
8
8
|
it("renders the server subtotal as the final DataTable row with all metrics", () => {
|
|
9
9
|
const view = CompactLifecycleCostTable({
|
|
10
10
|
locale: "pt-BR",
|
|
11
|
-
rows: [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
rows: [
|
|
12
|
+
{
|
|
13
|
+
id: "TASK-PAGE-50",
|
|
14
|
+
title: "Página 2",
|
|
15
|
+
kind: "task",
|
|
16
|
+
status: "active",
|
|
17
|
+
risk: null,
|
|
18
|
+
occurred_at: "2026-08-04T12:00:00.000Z",
|
|
19
|
+
parent_id: null,
|
|
20
|
+
run_count: 1,
|
|
21
|
+
cost_currency: "BRL",
|
|
22
|
+
metrics: { duration: known(1_000), total_tokens: known(2), cost: known(5) },
|
|
23
|
+
},
|
|
24
|
+
],
|
|
16
25
|
subtotal: {
|
|
17
26
|
entity_count: 270,
|
|
18
27
|
run_count: known(270),
|
|
19
|
-
metrics: {
|
|
28
|
+
metrics: {
|
|
29
|
+
duration: known(270_000),
|
|
30
|
+
total_tokens: known(540),
|
|
31
|
+
cost_brl: known(1_350),
|
|
32
|
+
cost_usd: known(270),
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
pagination: {
|
|
36
|
+
offset: 50,
|
|
37
|
+
limit: 50,
|
|
38
|
+
total: 270,
|
|
39
|
+
has_more: true,
|
|
40
|
+
loading: false,
|
|
41
|
+
error: null,
|
|
42
|
+
onChange: () => undefined,
|
|
43
|
+
onRetry: () => undefined,
|
|
20
44
|
},
|
|
21
|
-
pagination: { offset: 50, limit: 50, total: 270, has_more: true, loading: false, error: null, onChange: () => undefined, onRetry: () => undefined },
|
|
22
45
|
});
|
|
23
|
-
const [table] = view.props.children as readonly {
|
|
46
|
+
const [table] = view.props.children as readonly {
|
|
47
|
+
props: { columns: Array<{ key: string; footer?: unknown }> };
|
|
48
|
+
}[];
|
|
24
49
|
expect(table).toBeDefined();
|
|
25
|
-
const footer = (key: string) =>
|
|
50
|
+
const footer = (key: string) =>
|
|
51
|
+
table!.props.columns.find((column) => column.key === key)?.footer;
|
|
26
52
|
expect(footer("occurredAt")).toContain("Subtotal filtrado");
|
|
27
53
|
expect(footer("entity")).toBe("270");
|
|
28
54
|
expect(footer("runs")).toBe("270");
|
|
@@ -34,13 +60,35 @@ describe("CompactLifecycleCostTable filtered subtotal", () => {
|
|
|
34
60
|
|
|
35
61
|
it("renders unknown numeric subtotals as zero", () => {
|
|
36
62
|
const view = CompactLifecycleCostTable({
|
|
37
|
-
locale: "pt-BR",
|
|
38
|
-
|
|
39
|
-
|
|
63
|
+
locale: "pt-BR",
|
|
64
|
+
rows: [],
|
|
65
|
+
subtotal: {
|
|
66
|
+
entity_count: 0,
|
|
67
|
+
run_count: known(0),
|
|
68
|
+
metrics: {
|
|
69
|
+
duration: unavailable,
|
|
70
|
+
total_tokens: known(0),
|
|
71
|
+
cost_brl: known(0),
|
|
72
|
+
cost_usd: unavailable,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
pagination: {
|
|
76
|
+
offset: 0,
|
|
77
|
+
limit: 50,
|
|
78
|
+
total: 0,
|
|
79
|
+
has_more: false,
|
|
80
|
+
loading: false,
|
|
81
|
+
error: null,
|
|
82
|
+
onChange: () => undefined,
|
|
83
|
+
onRetry: () => undefined,
|
|
84
|
+
},
|
|
40
85
|
});
|
|
41
|
-
const [table] = view.props.children as readonly {
|
|
86
|
+
const [table] = view.props.children as readonly {
|
|
87
|
+
props: { columns: Array<{ key: string; footer?: unknown }> };
|
|
88
|
+
}[];
|
|
42
89
|
expect(table).toBeDefined();
|
|
43
|
-
const footer = (key: string) =>
|
|
90
|
+
const footer = (key: string) =>
|
|
91
|
+
table!.props.columns.find((column) => column.key === key)?.footer;
|
|
44
92
|
expect(footer("runs")).toBe("0");
|
|
45
93
|
expect(footer("tokens")).toBe("0");
|
|
46
94
|
expect(footer("duration")).toBe("0");
|
|
@@ -48,12 +96,34 @@ describe("CompactLifecycleCostTable filtered subtotal", () => {
|
|
|
48
96
|
|
|
49
97
|
it("does not render a subtotal row when all lifecycle metrics are unavailable", () => {
|
|
50
98
|
const view = CompactLifecycleCostTable({
|
|
51
|
-
locale: "pt-BR",
|
|
52
|
-
|
|
53
|
-
|
|
99
|
+
locale: "pt-BR",
|
|
100
|
+
rows: [],
|
|
101
|
+
subtotal: {
|
|
102
|
+
entity_count: 1,
|
|
103
|
+
run_count: unavailable,
|
|
104
|
+
metrics: {
|
|
105
|
+
duration: unavailable,
|
|
106
|
+
total_tokens: unavailable,
|
|
107
|
+
cost_brl: unavailable,
|
|
108
|
+
cost_usd: unavailable,
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
pagination: {
|
|
112
|
+
offset: 0,
|
|
113
|
+
limit: 50,
|
|
114
|
+
total: 0,
|
|
115
|
+
has_more: false,
|
|
116
|
+
loading: false,
|
|
117
|
+
error: null,
|
|
118
|
+
onChange: () => undefined,
|
|
119
|
+
onRetry: () => undefined,
|
|
120
|
+
},
|
|
54
121
|
});
|
|
55
|
-
const [table] = view.props.children as readonly {
|
|
56
|
-
|
|
122
|
+
const [table] = view.props.children as readonly {
|
|
123
|
+
props: { columns: Array<{ key: string; footer?: unknown }> };
|
|
124
|
+
}[];
|
|
125
|
+
const footer = (key: string) =>
|
|
126
|
+
table!.props.columns.find((column) => column.key === key)?.footer;
|
|
57
127
|
expect(footer("occurredAt")).toBeUndefined();
|
|
58
128
|
expect(footer("entity")).toBeUndefined();
|
|
59
129
|
expect(footer("runs")).toBeUndefined();
|
package/templates/.agents/dashboard/modules/cost-monitor/src/react/CompactLifecycleCostTable.tsx
CHANGED
|
@@ -88,8 +88,7 @@ export function CompactLifecycleCostTable({
|
|
|
88
88
|
const durationMetric = (row: CompactLifecycleCostRow) => {
|
|
89
89
|
const value = row.metrics.duration;
|
|
90
90
|
const effective = compactLifecycleDurationMs(row);
|
|
91
|
-
if (effective === null || (value.unknown > 0 && effective === 0))
|
|
92
|
-
return "0";
|
|
91
|
+
if (effective === null || (value.unknown > 0 && effective === 0)) return "0";
|
|
93
92
|
return formatDurationMs(effective, locale);
|
|
94
93
|
};
|
|
95
94
|
const subtotalMetric = (value: KnownMetric, format: (known: number) => string) => {
|
|
@@ -98,21 +97,24 @@ export function CompactLifecycleCostTable({
|
|
|
98
97
|
};
|
|
99
98
|
const subtotalMetricUnavailable = (value: KnownMetric) =>
|
|
100
99
|
value.unknown > 0 && value.known_sum === 0;
|
|
101
|
-
const showSubtotal =
|
|
102
|
-
subtotal
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
100
|
+
const showSubtotal =
|
|
101
|
+
subtotal !== null &&
|
|
102
|
+
![
|
|
103
|
+
subtotal.run_count,
|
|
104
|
+
subtotal.metrics.duration,
|
|
105
|
+
subtotal.metrics.total_tokens,
|
|
106
|
+
subtotal.metrics.cost_brl,
|
|
107
|
+
].every(subtotalMetricUnavailable);
|
|
107
108
|
const number = (value: number) => new Intl.NumberFormat(locale).format(value);
|
|
108
109
|
const subtotalLabel = !showSubtotal
|
|
109
110
|
? undefined
|
|
110
111
|
: subtotal === null
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const subtotalCost =
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
? "Total"
|
|
113
|
+
: `${locale === "pt-BR" ? "Subtotal filtrado" : "Filtered subtotal"} · ${number(subtotal.entity_count)} ${locale === "pt-BR" ? "registros" : "records"}`;
|
|
114
|
+
const subtotalCost =
|
|
115
|
+
!showSubtotal || subtotal === null
|
|
116
|
+
? undefined
|
|
117
|
+
: subtotalMetric(subtotal.metrics.cost_brl, (brl) => formatCurrency(brl, "BRL", locale));
|
|
116
118
|
return (
|
|
117
119
|
<>
|
|
118
120
|
<DataTable
|
|
@@ -140,14 +142,22 @@ export function CompactLifecycleCostTable({
|
|
|
140
142
|
label: locale === "pt-BR" ? "Invocações" : "Invocations",
|
|
141
143
|
render: (row) => new Intl.NumberFormat(locale).format(row.run_count),
|
|
142
144
|
align: "right",
|
|
143
|
-
footer:
|
|
145
|
+
footer:
|
|
146
|
+
!showSubtotal || subtotal === null
|
|
147
|
+
? undefined
|
|
148
|
+
: subtotalMetric(subtotal.run_count, number),
|
|
144
149
|
},
|
|
145
150
|
{
|
|
146
151
|
key: "duration",
|
|
147
152
|
label: locale === "pt-BR" ? "Tempo observado" : "Observed time",
|
|
148
153
|
render: durationMetric,
|
|
149
154
|
align: "right",
|
|
150
|
-
footer:
|
|
155
|
+
footer:
|
|
156
|
+
!showSubtotal || subtotal === null
|
|
157
|
+
? undefined
|
|
158
|
+
: subtotalMetric(subtotal.metrics.duration, (value) =>
|
|
159
|
+
value === 0 ? "0" : formatDurationMs(value, locale),
|
|
160
|
+
),
|
|
151
161
|
},
|
|
152
162
|
{
|
|
153
163
|
key: "tokens",
|
|
@@ -155,7 +165,12 @@ export function CompactLifecycleCostTable({
|
|
|
155
165
|
render: (row) =>
|
|
156
166
|
metric(row.metrics.total_tokens, (value) => formatCompactNumber(value, locale)),
|
|
157
167
|
align: "right",
|
|
158
|
-
footer:
|
|
168
|
+
footer:
|
|
169
|
+
!showSubtotal || subtotal === null
|
|
170
|
+
? undefined
|
|
171
|
+
: subtotalMetric(subtotal.metrics.total_tokens, (value) =>
|
|
172
|
+
formatCompactNumber(value, locale),
|
|
173
|
+
),
|
|
159
174
|
},
|
|
160
175
|
{
|
|
161
176
|
key: "cost",
|
|
@@ -56,11 +56,7 @@ describe("lastSevenDays", () => {
|
|
|
56
56
|
|
|
57
57
|
const result = lastSevenDays(rows, "BRL");
|
|
58
58
|
|
|
59
|
-
expect(result.map((day) => day.key)).toEqual([
|
|
60
|
-
"2026-07-08",
|
|
61
|
-
"2026-07-10",
|
|
62
|
-
"2026-07-15",
|
|
63
|
-
]);
|
|
59
|
+
expect(result.map((day) => day.key)).toEqual(["2026-07-08", "2026-07-10", "2026-07-15"]);
|
|
64
60
|
expect(result.map((day) => day.value)).toEqual([99, 12.5, 8]);
|
|
65
61
|
});
|
|
66
62
|
|
|
@@ -93,7 +89,11 @@ describe("aggregate-only overview metrics", () => {
|
|
|
93
89
|
const usage = {
|
|
94
90
|
conversation: metric({ input: 10, cached_input: 1, output: 5, reasoning: 3, total: 15 }, 2),
|
|
95
91
|
planning: metric({ input: 20, cached_input: 2, output: 10, reasoning: 6, total: 30 }, 3),
|
|
96
|
-
execution: metric(
|
|
92
|
+
execution: metric(
|
|
93
|
+
{ input: 30, cached_input: 3, output: 15, reasoning: 9, total: 45 },
|
|
94
|
+
4,
|
|
95
|
+
12_000,
|
|
96
|
+
),
|
|
97
97
|
total: metric({ input: 60, cached_input: 6, output: 30, reasoning: 18, total: 90 }, 9),
|
|
98
98
|
};
|
|
99
99
|
|
|
@@ -113,8 +113,32 @@ describe("aggregate-only overview metrics", () => {
|
|
|
113
113
|
planning: metric({ input: 0, cached_input: 0, output: 0, reasoning: 0, total: 0 }, 0),
|
|
114
114
|
total: metric({ input: 0, cached_input: 0, output: 0, reasoning: 0, total: 0 }, 0),
|
|
115
115
|
};
|
|
116
|
-
expect(
|
|
117
|
-
|
|
116
|
+
expect(
|
|
117
|
+
chartPhaseMetrics(
|
|
118
|
+
"execution",
|
|
119
|
+
[],
|
|
120
|
+
{
|
|
121
|
+
...base,
|
|
122
|
+
execution: metric({ input: 0, cached_input: 0, output: 0, reasoning: 0, total: 0 }, 0, 0),
|
|
123
|
+
},
|
|
124
|
+
"BRL",
|
|
125
|
+
).duration,
|
|
126
|
+
).toBe(0);
|
|
127
|
+
expect(
|
|
128
|
+
chartPhaseMetrics(
|
|
129
|
+
"execution",
|
|
130
|
+
[],
|
|
131
|
+
{
|
|
132
|
+
...base,
|
|
133
|
+
execution: metric(
|
|
134
|
+
{ input: 0, cached_input: 0, output: 0, reasoning: 0, total: 0 },
|
|
135
|
+
0,
|
|
136
|
+
null,
|
|
137
|
+
),
|
|
138
|
+
},
|
|
139
|
+
"BRL",
|
|
140
|
+
).duration,
|
|
141
|
+
).toBeNull();
|
|
118
142
|
});
|
|
119
143
|
|
|
120
144
|
it("marks an invalid cached or reasoning subset unavailable without changing inclusive totals", () => {
|
|
@@ -132,15 +156,20 @@ describe("aggregate-only overview metrics", () => {
|
|
|
132
156
|
|
|
133
157
|
it("preserves canonical output when a partial source total diverges", () => {
|
|
134
158
|
const usage = {
|
|
135
|
-
total: metric(
|
|
159
|
+
total: metric(
|
|
160
|
+
{
|
|
161
|
+
input: 400_000,
|
|
162
|
+
cached_input: 390_000,
|
|
163
|
+
output: 30_000,
|
|
164
|
+
reasoning: 10_000,
|
|
165
|
+
total: 445_099,
|
|
166
|
+
},
|
|
167
|
+
1,
|
|
168
|
+
),
|
|
136
169
|
};
|
|
137
170
|
|
|
138
171
|
expect(chartTokenMix([], usage, costChartsCopy("pt-BR")).map(([, value]) => value)).toEqual([
|
|
139
|
-
10_000,
|
|
140
|
-
390_000,
|
|
141
|
-
20_000,
|
|
142
|
-
10_000,
|
|
143
|
-
430_000,
|
|
172
|
+
10_000, 390_000, 20_000, 10_000, 430_000,
|
|
144
173
|
]);
|
|
145
174
|
});
|
|
146
175
|
});
|
|
@@ -169,7 +169,10 @@ export function CostCharts({
|
|
|
169
169
|
export function chartTokenMix(
|
|
170
170
|
rows: readonly CostRunRow[],
|
|
171
171
|
summaryUsage: Pick<UsageProjection, "total"> | undefined,
|
|
172
|
-
copy: Pick<
|
|
172
|
+
copy: Pick<
|
|
173
|
+
ReturnType<typeof costChartsCopy>,
|
|
174
|
+
"inputWithoutCache" | "cachedInput" | "visibleOutput" | "reasoning" | "total"
|
|
175
|
+
>,
|
|
173
176
|
) {
|
|
174
177
|
const tokens = summaryUsage?.total.tokens;
|
|
175
178
|
const input = tokens?.input ?? observed(rows.map((row) => row.input_tokens));
|
|
@@ -321,10 +324,7 @@ function inclusiveTokenTotal(
|
|
|
321
324
|
return input !== null && output !== null ? input + output : reportedTotal;
|
|
322
325
|
}
|
|
323
326
|
|
|
324
|
-
export function lastSevenDays(
|
|
325
|
-
daily: readonly CostGroupRow[],
|
|
326
|
-
currency: CostCurrency,
|
|
327
|
-
) {
|
|
327
|
+
export function lastSevenDays(daily: readonly CostGroupRow[], currency: CostCurrency) {
|
|
328
328
|
const values = new Map(daily.map((row) => [row.key, cost(row, currency)]));
|
|
329
329
|
const buckets = [...values.keys()].sort().slice(-7);
|
|
330
330
|
return buckets.map((key) => {
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { ExecutionTable } from "@zaip-ai/dashboard-operations/react";
|
|
2
2
|
import type { ComponentProps } from "react";
|
|
3
3
|
import {
|
|
4
|
-
CompactLifecycleCostTable,
|
|
5
4
|
type CompactLifecycleCostSubtotal,
|
|
5
|
+
CompactLifecycleCostTable,
|
|
6
6
|
} from "./CompactLifecycleCostTable.js";
|
|
7
7
|
import { CostCharts } from "./CostCharts.js";
|
|
8
8
|
import { CostPeriodAverageCards } from "./CostPeriodAverageCards.js";
|
|
9
9
|
import { CostGroupsTable, CostRunsTable } from "./CostTables.js";
|
|
10
|
+
import type { CostCurrency, CostLocale } from "./cost-monitor-copy.js";
|
|
11
|
+
import type { CostView } from "./cost-monitor-views.js";
|
|
12
|
+
import { MacroCostTable } from "./MacroCostTable.js";
|
|
10
13
|
import {
|
|
14
|
+
type CostGroupTotals,
|
|
11
15
|
costGroupPageLabel,
|
|
12
16
|
reconcileCostGroupTotalsWithCards,
|
|
13
|
-
type CostGroupTotals,
|
|
14
17
|
} from "./use-cost-group-page.js";
|
|
15
|
-
import type { CostCurrency, CostLocale } from "./cost-monitor-copy.js";
|
|
16
|
-
import type { CostView } from "./cost-monitor-views.js";
|
|
17
|
-
import { MacroCostTable } from "./MacroCostTable.js";
|
|
18
18
|
|
|
19
19
|
type CostRunRows = ComponentProps<typeof CostRunsTable>["rows"];
|
|
20
20
|
type CostGroupRows = ComponentProps<typeof CostGroupsTable>["rows"];
|
|
@@ -88,7 +88,13 @@ export function CostMonitorContent({
|
|
|
88
88
|
providers: CostGroupRows;
|
|
89
89
|
tasks: CostGroupRows;
|
|
90
90
|
};
|
|
91
|
-
groupPage: {
|
|
91
|
+
groupPage: {
|
|
92
|
+
offset: number;
|
|
93
|
+
limit: number;
|
|
94
|
+
total_count: number;
|
|
95
|
+
has_more: boolean;
|
|
96
|
+
totals?: CostGroupTotals;
|
|
97
|
+
} | null;
|
|
92
98
|
groupPageLoading: boolean;
|
|
93
99
|
groupPageOffset: number;
|
|
94
100
|
locale: CostLocale;
|
|
@@ -120,13 +126,30 @@ export function CostMonitorContent({
|
|
|
120
126
|
visiblePrds: ComponentProps<typeof MacroCostTable>["rows"];
|
|
121
127
|
visibleSpecs: ComponentProps<typeof MacroCostTable>["rows"];
|
|
122
128
|
}) {
|
|
123
|
-
const groupPager =
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
<
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
129
|
+
const groupPager =
|
|
130
|
+
["daily", "monthly", "annual", "agents", "models", "providers"].includes(view) &&
|
|
131
|
+
groupPage !== null ? (
|
|
132
|
+
<nav
|
|
133
|
+
aria-label={locale === "pt-BR" ? "Paginação de grupos" : "Group pagination"}
|
|
134
|
+
className="cost-page-controls"
|
|
135
|
+
>
|
|
136
|
+
<button
|
|
137
|
+
disabled={groupPageLoading || groupPageOffset === 0}
|
|
138
|
+
onClick={() => setGroupPageOffset(Math.max(0, groupPageOffset - groupPage.limit))}
|
|
139
|
+
type="button"
|
|
140
|
+
>
|
|
141
|
+
{locale === "pt-BR" ? "Anterior" : "Previous"}
|
|
142
|
+
</button>
|
|
143
|
+
<output aria-live="polite">{costGroupPageLabel({ locale, page: groupPage })}</output>
|
|
144
|
+
<button
|
|
145
|
+
disabled={groupPageLoading || !groupPage.has_more}
|
|
146
|
+
onClick={() => setGroupPageOffset(groupPageOffset + groupPage.limit)}
|
|
147
|
+
type="button"
|
|
148
|
+
>
|
|
149
|
+
{locale === "pt-BR" ? "Próxima" : "Next"}
|
|
150
|
+
</button>
|
|
151
|
+
</nav>
|
|
152
|
+
) : null;
|
|
130
153
|
return (
|
|
131
154
|
<section
|
|
132
155
|
className={`cost-content cost-content-${view} ${view === "overview" ? "cost-content-overview" : ""}`}
|
|
@@ -161,9 +184,7 @@ export function CostMonitorContent({
|
|
|
161
184
|
currency={currency}
|
|
162
185
|
locale={locale}
|
|
163
186
|
onOpenRun={onOpenRun}
|
|
164
|
-
rows={
|
|
165
|
-
serverPagingEligible && runPageData !== null ? pagedRunRows : rows
|
|
166
|
-
}
|
|
187
|
+
rows={serverPagingEligible && runPageData !== null ? pagedRunRows : rows}
|
|
167
188
|
{...(serverPagingEligible &&
|
|
168
189
|
(runPageData?.run_page !== undefined || runPageLoading || runPageError !== null)
|
|
169
190
|
? {
|
|
@@ -246,32 +267,36 @@ export function CostMonitorContent({
|
|
|
246
267
|
{(["providers", "agents", "models"] as const).map((key) =>
|
|
247
268
|
view === key && !dimensionalDetailPending && !detailLoading && detailError === null ? (
|
|
248
269
|
<>
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
270
|
+
<CostGroupsTable
|
|
271
|
+
currency={currency}
|
|
272
|
+
key={key}
|
|
273
|
+
labelHeading={
|
|
274
|
+
key === "models"
|
|
275
|
+
? locale === "pt-BR"
|
|
276
|
+
? "Modelo LLM"
|
|
277
|
+
: "LLM model"
|
|
278
|
+
: key === "agents"
|
|
279
|
+
? locale === "pt-BR"
|
|
280
|
+
? "Zaip Agentes"
|
|
281
|
+
: "ZAIP agents"
|
|
282
|
+
: locale === "pt-BR"
|
|
283
|
+
? "Provedor"
|
|
284
|
+
: "Providers"
|
|
285
|
+
}
|
|
286
|
+
locale={locale}
|
|
287
|
+
rows={groups[key]}
|
|
288
|
+
{...(key === "models" || key === "providers"
|
|
289
|
+
? { totals: summaryTotals }
|
|
290
|
+
: groupPage?.totals === undefined
|
|
291
|
+
? {}
|
|
292
|
+
: { totals: groupPage.totals })}
|
|
293
|
+
{...(key === "agents"
|
|
294
|
+
? { showDateTime: false, showAgentIdentity: true }
|
|
295
|
+
: key === "models" || key === "providers"
|
|
296
|
+
? { showDateTime: false, showInvocationTasks: true }
|
|
297
|
+
: {})}
|
|
298
|
+
/>
|
|
299
|
+
{groupPager}
|
|
275
300
|
</>
|
|
276
301
|
) : null,
|
|
277
302
|
)}
|