@zaip-ai/cli 4.9.0 → 5.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.
Files changed (213) hide show
  1. package/dist/services/adapter-hook-sources.d.ts +3 -0
  2. package/dist/services/adapter-hook-sources.d.ts.map +1 -1
  3. package/dist/services/adapter-hook-sources.js +3 -0
  4. package/dist/services/adapter-hook-sources.js.map +1 -1
  5. package/dist/services/adapters.d.ts +1 -1
  6. package/dist/services/adapters.d.ts.map +1 -1
  7. package/dist/services/adapters.js +5 -2
  8. package/dist/services/adapters.js.map +1 -1
  9. package/dist/services/adapters.test.js +1 -1
  10. package/dist/services/adapters.test.js.map +1 -1
  11. package/dist/services/codex-conversation-lifecycle-hook.d.ts.map +1 -1
  12. package/dist/services/codex-conversation-lifecycle-hook.js +16 -6
  13. package/dist/services/codex-conversation-lifecycle-hook.js.map +1 -1
  14. package/dist/services/codex-hook-activation.d.ts +1 -1
  15. package/dist/services/codex-hook-activation.d.ts.map +1 -1
  16. package/dist/services/codex-hook-activation.js +116 -10
  17. package/dist/services/codex-hook-activation.js.map +1 -1
  18. package/dist/services/codex-pre-tool-cli-capture-template.d.ts +2 -0
  19. package/dist/services/codex-pre-tool-cli-capture-template.d.ts.map +1 -0
  20. package/dist/services/codex-pre-tool-cli-capture-template.js +104 -0
  21. package/dist/services/codex-pre-tool-cli-capture-template.js.map +1 -0
  22. package/dist/services/codex-pre-tool-cloud-template.d.ts +2 -0
  23. package/dist/services/codex-pre-tool-cloud-template.d.ts.map +1 -0
  24. package/dist/services/codex-pre-tool-cloud-template.js +190 -0
  25. package/dist/services/codex-pre-tool-cloud-template.js.map +1 -0
  26. package/dist/services/codex-pre-tool-dependencies.test-support.d.ts +2 -0
  27. package/dist/services/codex-pre-tool-dependencies.test-support.d.ts.map +1 -0
  28. package/dist/services/codex-pre-tool-dependencies.test-support.js +9 -0
  29. package/dist/services/codex-pre-tool-dependencies.test-support.js.map +1 -0
  30. package/dist/services/codex-pre-tool-hook-fixture.test-support.d.ts +5 -0
  31. package/dist/services/codex-pre-tool-hook-fixture.test-support.d.ts.map +1 -0
  32. package/dist/services/codex-pre-tool-hook-fixture.test-support.js +19 -0
  33. package/dist/services/codex-pre-tool-hook-fixture.test-support.js.map +1 -0
  34. package/dist/services/codex-pre-tool-hook-template-bootstrap.test.d.ts +2 -0
  35. package/dist/services/codex-pre-tool-hook-template-bootstrap.test.d.ts.map +1 -0
  36. package/dist/services/codex-pre-tool-hook-template-bootstrap.test.js +107 -0
  37. package/dist/services/codex-pre-tool-hook-template-bootstrap.test.js.map +1 -0
  38. package/dist/services/codex-pre-tool-hook-template.d.ts.map +1 -1
  39. package/dist/services/codex-pre-tool-hook-template.js +96 -210
  40. package/dist/services/codex-pre-tool-hook-template.js.map +1 -1
  41. package/dist/services/codex-pre-tool-hook-template.test.js +32 -80
  42. package/dist/services/codex-pre-tool-hook-template.test.js.map +1 -1
  43. package/dist/services/codex-pre-tool-host-context-template.d.ts +2 -0
  44. package/dist/services/codex-pre-tool-host-context-template.d.ts.map +1 -0
  45. package/dist/services/codex-pre-tool-host-context-template.js +139 -0
  46. package/dist/services/codex-pre-tool-host-context-template.js.map +1 -0
  47. package/dist/services/codex-pre-tool-support-template.d.ts.map +1 -1
  48. package/dist/services/codex-pre-tool-support-template.js +61 -101
  49. package/dist/services/codex-pre-tool-support-template.js.map +1 -1
  50. package/dist/services/codex-subagent-hook-template.d.ts +1 -1
  51. package/dist/services/codex-subagent-hook-template.d.ts.map +1 -1
  52. package/dist/services/codex-subagent-hook-template.js +13 -2
  53. package/dist/services/codex-subagent-hook-template.js.map +1 -1
  54. package/dist/services/codex-validation-runtime-template.d.ts.map +1 -1
  55. package/dist/services/codex-validation-runtime-template.js +10 -4
  56. package/dist/services/codex-validation-runtime-template.js.map +1 -1
  57. package/dist/services/runtime-template-test-support.d.ts +1 -0
  58. package/dist/services/runtime-template-test-support.d.ts.map +1 -1
  59. package/dist/services/runtime-template-test-support.js +23 -2
  60. package/dist/services/runtime-template-test-support.js.map +1 -1
  61. package/dist/services/runtime-template.test.js +4 -23
  62. package/dist/services/runtime-template.test.js.map +1 -1
  63. package/package.json +1 -1
  64. package/templates/.agents/README-ENG.md +58 -7
  65. package/templates/.agents/README.md +46 -10
  66. package/templates/.agents/config/agents/discovery.json +1 -1
  67. package/templates/.agents/dashboard/.zaip-managed.json +174 -86
  68. package/templates/.agents/dashboard/apps/frontend/dist/assets/{CostCalculationGuidePage-BW7Vy1cp.js → CostCalculationGuidePage-uR-asJv_.js} +1 -1
  69. package/templates/.agents/dashboard/apps/frontend/dist/assets/{DashboardHelpDialog-Cp_hEVd8.js → DashboardHelpDialog-CngnpoLL.js} +87 -13
  70. package/templates/.agents/dashboard/apps/frontend/dist/assets/{PricingSettingsDialog-Prcs-ydy.js → PricingSettingsDialog-Bszw3ekd.js} +1 -1
  71. package/templates/.agents/dashboard/apps/frontend/dist/assets/{ProjectSettingsPage-Cu40wAFF.js → ProjectSettingsPage-IJ1znG4w.js} +1 -1
  72. package/templates/.agents/dashboard/apps/frontend/dist/assets/{TraceabilityWorkspace-Bh3YBd3C.js → TraceabilityWorkspace-CsBpHqq_.js} +1 -1
  73. package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-B0Jwz_rk.js +68 -0
  74. package/templates/.agents/dashboard/apps/frontend/dist/assets/{dashboard-localization-CF7B1Hjn.js → dashboard-localization-D41g5rdo.js} +58 -7
  75. package/templates/.agents/dashboard/apps/frontend/dist/assets/{icons-vendor-DOhy6D2-.js → icons-vendor-CjGGux6h.js} +1 -1
  76. package/templates/.agents/dashboard/apps/frontend/dist/assets/index-Bedlm0f7.js +2 -0
  77. package/templates/.agents/dashboard/apps/frontend/dist/assets/{react-vendor-CkPC-yMz.js → react-vendor-B9jZSAKf.js} +1 -1
  78. package/templates/.agents/dashboard/apps/frontend/dist/assets/{traceability-BEdGoIDm.js → traceability-DFpwb0TN.js} +1 -1
  79. package/templates/.agents/dashboard/apps/frontend/dist/index.html +5 -5
  80. package/templates/.agents/dashboard/apps/frontend/package.json +2 -2
  81. package/templates/.agents/dashboard/apps/frontend/src/AppDashboardContent.tsx +3 -0
  82. package/templates/.agents/dashboard/apps/frontend/src/AppOverlays.tsx +16 -7
  83. package/templates/.agents/dashboard/apps/frontend/src/__tests__/app-composition-support.ts +1 -0
  84. package/templates/.agents/dashboard/apps/frontend/src/cost-period-refresh.test.ts +1 -1
  85. package/templates/.agents/dashboard/apps/frontend/src/operations-period-render.test.ts +2 -0
  86. package/templates/.agents/dashboard/apps/frontend/src/use-app-trace-documents.navigation.test.tsx +125 -0
  87. package/templates/.agents/dashboard/apps/frontend/src/use-app-trace-documents.ts +67 -9
  88. package/templates/.agents/dashboard/apps/frontend/src/use-dashboard-app-model.tsx +15 -15
  89. package/templates/.agents/dashboard/apps/frontend/src/use-dashboard-locale.ts +18 -0
  90. package/templates/.agents/dashboard/modules/cost-monitor/package.json +1 -1
  91. package/templates/.agents/dashboard/modules/cost-monitor/src/contracts.ts +10 -3
  92. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostFilters.run-page.test.ts +5 -1
  93. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostGroupsTable.period-values.test.tsx +2 -2
  94. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables-keeps-legacy-codex-identity-fields-blank.test.ts +5 -5
  95. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables.test.ts +36 -43
  96. package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-loaders.ts +1 -0
  97. package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-table-formatters.ts +6 -4
  98. package/templates/.agents/dashboard/modules/cost-monitor/src/server/aggregate.ts +2 -2
  99. package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-projection.ts +1 -1
  100. package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-projection.ts +11 -25
  101. package/templates/.agents/dashboard/modules/cost-monitor/src/server/cost-summary-defaults.ts +26 -0
  102. package/templates/.agents/dashboard/modules/operations/package.json +1 -1
  103. package/templates/.agents/dashboard/modules/operations/src/contracts.ts +11 -16
  104. package/templates/.agents/dashboard/modules/operations/src/planning-contracts.ts +14 -0
  105. package/templates/.agents/dashboard/modules/operations/src/react/DecisionTable.tsx +65 -0
  106. package/templates/.agents/dashboard/modules/operations/src/react/EntityTables.tsx +5 -71
  107. package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.tsx +4 -39
  108. package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverviewTopPanel.navigation.test.tsx +150 -0
  109. package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverviewTopPanel.tsx +7 -3
  110. package/templates/.agents/dashboard/modules/operations/src/react/OperationsPage.tsx +14 -43
  111. package/templates/.agents/dashboard/modules/operations/src/react/OperationsPageOverview.tsx +3 -0
  112. package/templates/.agents/dashboard/modules/operations/src/react/operations-overview-contract.ts +51 -0
  113. package/templates/.agents/dashboard/modules/operations/src/react/operations-overview-period-filter.test.ts +12 -3
  114. package/templates/.agents/dashboard/modules/operations/src/react/operations-page-contract.ts +1 -0
  115. package/templates/.agents/dashboard/modules/operations/src/react/use-operations-default-range.ts +16 -0
  116. package/templates/.agents/dashboard/modules/operations/src/react/use-operations-filter-sync.ts +66 -0
  117. package/templates/.agents/dashboard/modules/traceability/package.json +1 -1
  118. package/templates/.agents/dashboard/packages/branding/package.json +1 -1
  119. package/templates/.agents/dashboard/packages/contracts/package.json +1 -1
  120. package/templates/.agents/dashboard/packages/data-export/package.json +1 -1
  121. package/templates/.agents/dashboard/packages/local-runtime/dashboard-build-fingerprint.mjs +87 -0
  122. package/templates/.agents/dashboard/packages/local-runtime/dashboard-build-fingerprint.test.mjs +48 -0
  123. package/templates/.agents/dashboard/packages/local-runtime/dist/server.cjs +193 -191
  124. package/templates/.agents/dashboard/packages/local-runtime/dist/sqlite-read-model.cjs +169 -169
  125. package/templates/.agents/dashboard/packages/local-runtime/package.json +1 -1
  126. package/templates/.agents/dashboard/packages/local-runtime/scripts/build-frontend.mjs +29 -0
  127. package/templates/.agents/dashboard/packages/local-runtime/scripts/build-sqlite-runtime.mjs +5 -0
  128. package/templates/.agents/dashboard/packages/local-runtime/server.mjs +193 -191
  129. package/templates/.agents/dashboard/packages/local-runtime/src/active-capture-failure.test.ts +38 -0
  130. package/templates/.agents/dashboard/packages/local-runtime/src/active-capture-failure.ts +35 -0
  131. package/templates/.agents/dashboard/packages/local-runtime/src/active-codex-telemetry.test.ts +53 -2
  132. package/templates/.agents/dashboard/packages/local-runtime/src/active-codex-telemetry.ts +18 -1
  133. package/templates/.agents/dashboard/packages/local-runtime/src/manifest-runs.ts +8 -2
  134. package/templates/.agents/dashboard/packages/local-runtime/src/server-capture-projection-order.test.ts +118 -0
  135. package/templates/.agents/dashboard/packages/local-runtime/src/server-cost-run-search.test.ts +90 -0
  136. package/templates/.agents/dashboard/packages/local-runtime/src/server-cost-run-search.ts +86 -0
  137. package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-routes.ts +8 -1
  138. package/templates/.agents/dashboard/packages/local-runtime/src/server-projection-loaders.ts +13 -0
  139. package/templates/.agents/dashboard/packages/local-runtime/src/server-projections.ts +30 -74
  140. package/templates/.agents/dashboard/packages/local-runtime/src/server-route-handlers.ts +42 -0
  141. package/templates/.agents/dashboard/packages/local-runtime/src/server-routes.test.ts +60 -0
  142. package/templates/.agents/dashboard/packages/local-runtime/src/server-run-projections.test.ts +12 -2
  143. package/templates/.agents/dashboard/packages/local-runtime/src/server-telemetry-command.test.ts +29 -4
  144. package/templates/.agents/dashboard/packages/local-runtime/src/server-telemetry-refresh.ts +7 -0
  145. package/templates/.agents/dashboard/packages/local-runtime/src/server.test.ts +51 -54
  146. package/templates/.agents/dashboard/packages/local-runtime/src/server.ts +28 -45
  147. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-filter-matrix.test.ts +5 -0
  148. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-invocation-page.test.ts +49 -0
  149. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-invocation-page.ts +44 -1
  150. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-cached-cost-page.ts +11 -10
  151. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-summary.ts +1 -1
  152. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-work-item-index.test.ts +18 -1
  153. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-build.mjs +12 -5
  154. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-paths.mjs +8 -0
  155. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard.test.mjs +1 -0
  156. package/templates/.agents/dashboard/packages/ui/package.json +1 -1
  157. package/templates/.agents/dashboard/tests/e2e/package.json +1 -1
  158. package/templates/.agents/dashboard/tests/e2e/qualify-top-five-trace.mjs +53 -0
  159. package/templates/.agents/dashboard/tests/e2e/verify-top-five-served.mjs +78 -0
  160. package/templates/.agents/design/.zaip-managed.json +14 -6
  161. package/templates/.agents/design/apps/catalog/dist/assets/index-BGxXxXTo.js +72 -0
  162. package/templates/.agents/design/apps/catalog/dist/index.html +1 -1
  163. package/templates/.agents/design/apps/catalog/package.json +1 -1
  164. package/templates/.agents/design/apps/catalog/src/components/TopEntitiesSpecimen.tsx +45 -0
  165. package/templates/.agents/design/apps/catalog/src/pages/ComponentsPage.tsx +3 -1
  166. package/templates/.agents/design/apps/catalog/src/stories/Components.stories.tsx +2 -0
  167. package/templates/.agents/design/packages/local-runtime/package.json +1 -1
  168. package/templates/.agents/requirements/autonomous-assurance.md +11 -2
  169. package/templates/.agents/requirements/cloud-hostinger-autonomy.md +1 -1
  170. package/templates/.agents/requirements/comparative-audit.md +1 -1
  171. package/templates/.agents/requirements/context-engine.md +1 -1
  172. package/templates/.agents/requirements/cost-observability.md +1 -1
  173. package/templates/.agents/requirements/dashboard-launch.md +1 -1
  174. package/templates/.agents/requirements/data-export.md +1 -1
  175. package/templates/.agents/requirements/design-system.md +1 -1
  176. package/templates/.agents/requirements/execution-engine.md +1 -1
  177. package/templates/.agents/requirements/kanban-dashboard.md +1 -1
  178. package/templates/.agents/requirements/model-orchestration.md +1 -1
  179. package/templates/.agents/requirements/public-distribution.md +1 -1
  180. package/templates/.agents/requirements/software-architecture.md +1 -1
  181. package/templates/.agents/requirements/strategic-improvements.md +1 -1
  182. package/templates/.agents/requirements/work-lifecycle.md +2 -1
  183. package/templates/.agents/requirements/zaip-strategic-95.md +1 -1
  184. package/templates/.agents/rules/run-lifecycle-closure.md +2 -1
  185. package/templates/.agents/rules/workflow.md +1 -0
  186. package/templates/.agents/runtime/VERSION +1 -1
  187. package/templates/.agents/runtime/bin/zaip.mjs +1178 -764
  188. package/templates/.agents/runtime/checksums.sha256 +6 -6
  189. package/templates/.agents/runtime/manifest.json +1 -1
  190. package/templates/.agents/runtime/pnpm-lock.sha256 +1 -1
  191. package/templates/.agents/runtime/provenance.json +5 -5
  192. package/templates/.agents/runtime/sbom.cdx.json +59 -59
  193. package/templates/.agents/skills/zaip-skill-execution/SKILL.md +1 -1
  194. package/templates/.agents/skills/zaip-skill-execution/references/controlled-release-recovery.md +14 -0
  195. package/templates/.agents/skills/zaip-skill-execution/references/runtime-governance.md +1 -1
  196. package/templates/.agents/skills/zaip-skill-github-deploy/SKILL.md +5 -1
  197. package/templates/.agents/skills/zaip-skill-github-deploy/scripts/deploy-contract-cli.test.mjs +53 -0
  198. package/templates/.agents/skills/zaip-skill-github-deploy/scripts/deploy-contract.mjs +12 -0
  199. package/templates/.agents/skills/zaip-skill-github-deploy/scripts/deploy-contract.test.mjs +26 -32
  200. package/templates/.agents/skills/zaip-skill-maintenance-enter/SKILL.md +23 -0
  201. package/templates/.agents/skills/zaip-skill-maintenance-enter/agents/openai.yaml +4 -0
  202. package/templates/.agents/skills/zaip-skill-maintenance-enter/scripts/maintenance.mjs +213 -0
  203. package/templates/.agents/skills/zaip-skill-maintenance-enter/scripts/maintenance.test.mjs +207 -0
  204. package/templates/.agents/skills/zaip-skill-maintenance-exit/SKILL.md +21 -0
  205. package/templates/.agents/skills/zaip-skill-maintenance-exit/agents/openai.yaml +4 -0
  206. package/templates/.agents/skills/zaip-skill-release-qualification/SKILL.md +2 -0
  207. package/templates/.agents/skills/zaip-skill-release-qualification/references/local-preparation.md +37 -8
  208. package/templates/.agents/zaip-aios/VERSION +1 -1
  209. package/templates/.agents/zaip-aios/guides/10-seguranca.md +2 -2
  210. package/templates/.agents/zaip-aios/guides/26-qualidade-e-release.md +38 -0
  211. package/templates/template-manifest.json +259 -135
  212. package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-Co2Jiuzh.js +0 -68
  213. package/templates/.agents/dashboard/apps/frontend/dist/assets/index-qVSJnJ0_.js +0 -2
@@ -1,7 +1,56 @@
1
1
  import { describe, expect, it } from "vitest";
2
2
  import { filterCostInvocationProjection } from "./sqlite-cost-invocation-page.js";
3
+ import { readCachedCostViewPage } from "./sqlite-query-cached-cost-page.js";
4
+ import type { SqliteQueryContext } from "./sqlite-query-context.js";
3
5
 
4
6
  describe("cost invocation projection page", () => {
7
+ it("searches the immutable projection before pagination, preserving nulls and empty results", () => {
8
+ const context = {
9
+ technicalPayloadRows: () => [
10
+ {
11
+ agent_invocation_id: "AINV-OTHER",
12
+ task_id: null,
13
+ occurred_at: "2026-08-01T12:00:00Z",
14
+ total_tokens: 20,
15
+ },
16
+ {
17
+ agent_invocation_id: "AINV-TARGET-1",
18
+ task_id: null,
19
+ occurred_at: "2026-08-01T11:00:00Z",
20
+ total_tokens: 12,
21
+ },
22
+ {
23
+ agent_invocation_id: "AINV-TARGET-2",
24
+ task_id: null,
25
+ occurred_at: "2026-08-01T10:00:00Z",
26
+ total_tokens: null,
27
+ },
28
+ ],
29
+ } as unknown as SqliteQueryContext;
30
+ expect(
31
+ readCachedCostViewPage(context, "cost_monitor_agent_invocations", {
32
+ query: "target",
33
+ offset: 1,
34
+ limit: 1,
35
+ }),
36
+ ).toMatchObject({
37
+ total_count: 2,
38
+ has_more: false,
39
+ rows: [{ agent_invocation_id: "AINV-TARGET-2", total_tokens: null }],
40
+ });
41
+ expect(
42
+ readCachedCostViewPage(context, "cost_monitor_agent_invocations", { query: "absent" }),
43
+ ).toMatchObject({ total_count: 0, rows: [] });
44
+ expect(
45
+ readCachedCostViewPage(context, "cost_monitor_agent_invocations", { query: "TARGET%" }),
46
+ ).toBeNull();
47
+ expect(
48
+ readCachedCostViewPage(context, "cost_monitor_agent_invocations", {
49
+ query: "target",
50
+ provider: "openai",
51
+ }),
52
+ ).toBeNull();
53
+ });
5
54
  it("uses the Sao Paulo source day for the fast date-only page", () => {
6
55
  const rows = [
7
56
  { agent_invocation_id: "before", source_started_at: "2026-08-01T02:30:00.000Z" },
@@ -1,4 +1,6 @@
1
- type CostInvocationDateFilter = { from?: string | null; to?: string | null };
1
+ import type { DatabaseSync } from "node:sqlite";
2
+
3
+ type CostInvocationDateFilter = { from?: string | null; to?: string | null; query?: string };
2
4
 
3
5
  function costDay(value: string | null | undefined): string | null {
4
6
  if (!value) return null;
@@ -21,9 +23,50 @@ export function filterCostInvocationProjection(
21
23
  ) {
22
24
  const from = costDay(input.from);
23
25
  const to = costDay(input.to);
26
+ // SQLite LIKE folds ASCII only. Wildcard queries remain on the SQL reader.
27
+ const fold = (value: string) => value.replace(/[A-Z]/g, (letter) => letter.toLowerCase());
28
+ const query = input.query ? fold(input.query) : null;
24
29
  return rows.filter((row) => {
30
+ if (
31
+ query !== null &&
32
+ ![row.agent_invocation_id, row.task_id, row.execution_id].some(
33
+ (value) => typeof value === "string" && fold(value).includes(query),
34
+ )
35
+ )
36
+ return false;
25
37
  const timestamp = row.source_started_at ?? row.source_occurred_at ?? row.occurred_at;
26
38
  const day = typeof timestamp === "string" ? costDay(timestamp) : null;
27
39
  return day !== null && (from === null || day >= from) && (to === null || day <= to);
28
40
  });
29
41
  }
42
+
43
+ /** Enrich only the selected page, matching the original SQL left join. */
44
+ export function enrichCostInvocationPage(
45
+ database: DatabaseSync,
46
+ rows: Array<Record<string, unknown>>,
47
+ ) {
48
+ const ids = [
49
+ ...new Set(rows.flatMap((row) => (typeof row.task_id === "string" ? [row.task_id] : []))),
50
+ ];
51
+ const tasks =
52
+ ids.length === 0
53
+ ? []
54
+ : (database
55
+ .prepare(
56
+ "SELECT id, priority, risk, status AS task_status, title AS task_title FROM tasks WHERE id IN (" +
57
+ ids.map(() => "?").join(",") +
58
+ ")",
59
+ )
60
+ .all(...ids) as Array<Record<string, unknown>>);
61
+ const byId = new Map(tasks.map((task) => [task.id, task]));
62
+ return rows.map((row) => {
63
+ const task = byId.get(row.task_id);
64
+ return {
65
+ ...row,
66
+ priority: task?.priority ?? null,
67
+ risk: task?.risk ?? null,
68
+ task_status: task?.task_status ?? null,
69
+ task_title: task?.task_title ?? null,
70
+ };
71
+ });
72
+ }
@@ -1,4 +1,7 @@
1
- import { filterCostInvocationProjection } from "./sqlite-cost-invocation-page.js";
1
+ import {
2
+ enrichCostInvocationPage,
3
+ filterCostInvocationProjection,
4
+ } from "./sqlite-cost-invocation-page.js";
2
5
  import type { SqliteQueryContext, SqliteViewPage } from "./sqlite-query-context.js";
3
6
  import type { SqliteViewName } from "./sqlite-read-model-types.js";
4
7
 
@@ -38,9 +41,9 @@ export function readCachedCostViewPage(
38
41
  !input.origin &&
39
42
  !input.workType &&
40
43
  !input.priority;
41
- const isDateOnlyCostInvocationPage =
44
+ const isCompactCostInvocationPage =
42
45
  view === "cost_monitor_agent_invocations" &&
43
- !input.query &&
46
+ !/[\0%_]/.test(input.query ?? "") &&
44
47
  !input.status &&
45
48
  !input.risk &&
46
49
  !input.provider &&
@@ -50,12 +53,10 @@ export function readCachedCostViewPage(
50
53
  !input.origin &&
51
54
  !input.workType &&
52
55
  !input.priority;
53
- if (isDateOnlyCostInvocationPage) {
54
- const projection = filterCostInvocationProjection(
55
- context.technicalPayloadRows("cost_agent_invocation_projection_v1"),
56
- input,
57
- );
58
- if (projection.length > 0) {
56
+ if (isCompactCostInvocationPage) {
57
+ const cachedRows = context.technicalPayloadRows("cost_agent_invocation_projection_v1");
58
+ const projection = filterCostInvocationProjection(cachedRows, input);
59
+ if (cachedRows.length > 0) {
59
60
  const limit = Math.min(200, Math.max(1, input.limit ?? 100));
60
61
  const offset = Math.max(0, input.offset ?? 0);
61
62
  const rows = projection.slice(offset, offset + limit);
@@ -66,7 +67,7 @@ export function readCachedCostViewPage(
66
67
  limit,
67
68
  total_count: projection.length,
68
69
  has_more: offset + rows.length < projection.length,
69
- rows,
70
+ rows: input.query ? enrichCostInvocationPage(context.database, rows) : rows,
70
71
  };
71
72
  }
72
73
  }
@@ -110,7 +110,7 @@ export function queryCostMonitorSummaryAggregate(
110
110
  add("work_type", filter.workTypes);
111
111
  if (filter.query) {
112
112
  clauses.push(
113
- "(a.task_id LIKE ? OR a.spec_id LIKE ? OR a.prd_id LIKE ? OR a.execution_id LIKE ? OR a.conversation_id LIKE ? OR a.zaip_agent LIKE ? OR a.model LIKE ? OR a.run_id LIKE ? OR a.agent_run_id LIKE ? OR EXISTS (SELECT 1 FROM canonical_work_items task WHERE task.id=a.task_id AND task.title LIKE ?))",
113
+ "(a.task_id LIKE ? OR a.spec_id LIKE ? OR a.prd_id LIKE ? OR a.execution_id LIKE ? OR a.conversation_id LIKE ? OR a.zaip_agent LIKE ? OR a.model LIKE ? OR a.run_id LIKE ? OR a.agent_run_id LIKE ? OR EXISTS (SELECT 1 FROM canonical_work_items task WHERE task.entity_kind='task' AND task.id=a.task_id AND task.title LIKE ?))",
114
114
  );
115
115
  values.push(...Array(10).fill(`%${filter.query}%`));
116
116
  }
@@ -2,7 +2,7 @@ import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
2
2
  import { tmpdir } from "node:os";
3
3
  import { join } from "node:path";
4
4
  import { DatabaseSync } from "node:sqlite";
5
- import { afterEach, describe, expect, it } from "vitest";
5
+ import { afterEach, describe, expect, it, vi } from "vitest";
6
6
  import { rebuildSqliteReadModel, SqliteReadModelFileSystem } from "./sqlite-read-model.js";
7
7
 
8
8
  const roots: string[] = [];
@@ -35,6 +35,23 @@ describe("SQLite work-item identity index", () => {
35
35
  ).toContain("TASK-INDEXED");
36
36
  const database = new DatabaseSync(process.env.ZAIP_SQLITE_DB_PATH, { readOnly: true });
37
37
  try {
38
+ const reader = new SqliteReadModelFileSystem(root, database);
39
+ const prepared = vi.spyOn(database, "prepare");
40
+ reader.costMonitorSummaryAggregate({ from: null, to: null, query: "Indexed" });
41
+ const searchSql = prepared.mock.calls
42
+ .map(([sql]) => sql)
43
+ .find(
44
+ (sql) =>
45
+ sql.startsWith("WITH selected AS MATERIALIZED") && sql.includes("task.title LIKE"),
46
+ );
47
+ prepared.mockRestore();
48
+ expect(searchSql).toBeDefined();
49
+ const searchPlan = database
50
+ .prepare(`EXPLAIN QUERY PLAN ${searchSql}`)
51
+ .all(null, null, null, null, ...Array(10).fill("%Indexed%")) as Array<{ detail: string }>;
52
+ expect(searchPlan.map((row) => row.detail).join("\n")).toContain(
53
+ "zaip_activities_work_item_identity",
54
+ );
38
55
  const plan = database
39
56
  .prepare(`EXPLAIN QUERY PLAN
40
57
  SELECT a.task_id FROM zaip_vw_activities a WHERE a.task_id IS NOT NULL
@@ -3,6 +3,7 @@ import { createHash } from "node:crypto";
3
3
  import { readdir, stat } from "node:fs/promises";
4
4
  import { join, resolve } from "node:path";
5
5
  import process from "node:process";
6
+ import { dashboardReleaseFrozen, inspectBuildFingerprint } from "./dashboard-build-fingerprint.mjs";
6
7
  import { formatLauncherError } from "./start-dashboard-logging.mjs";
7
8
  import {
8
9
  dashboardBuildTargets,
@@ -55,7 +56,7 @@ export async function runSqliteBuild(target) {
55
56
  const frontend = target === "frontend";
56
57
  const command = process.execPath;
57
58
  const args = frontend
58
- ? [resolve(workspaceRoot, "node_modules/vite/bin/vite.js"), "build"]
59
+ ? [resolve(packageRoot, "scripts/build-frontend.mjs")]
59
60
  : [
60
61
  resolve(
61
62
  workspaceRoot,
@@ -110,6 +111,7 @@ export async function refreshDashboardBuildTargets({
110
111
  forceRebuild = process.env.ZAIP_DASHBOARD_FORCE_REBUILD === "1",
111
112
  inspectTarget = inspectDashboardBuildTarget,
112
113
  runBuild = runSqliteBuild,
114
+ frozen = undefined,
113
115
  onProgress = () => {},
114
116
  } = {}) {
115
117
  const builtTargets = [];
@@ -121,10 +123,11 @@ export async function refreshDashboardBuildTargets({
121
123
  "Conferindo somente as dependências que geram este artefato.",
122
124
  );
123
125
  const state = await inspectTarget(target);
124
- const needsBuild =
125
- forceRebuild ||
126
- state.missingArtifacts.length > 0 ||
127
- state.artifactsModifiedAt < state.sourcesModifiedAt;
126
+ const contentFresh =
127
+ inspectTarget === inspectDashboardBuildTarget
128
+ ? await inspectBuildFingerprint(name, target)
129
+ : state.artifactsModifiedAt >= state.sourcesModifiedAt;
130
+ const needsBuild = forceRebuild || state.missingArtifacts.length > 0 || !contentFresh;
128
131
  if (!needsBuild) {
129
132
  buildProgress(
130
133
  onProgress,
@@ -134,6 +137,10 @@ export async function refreshDashboardBuildTargets({
134
137
  );
135
138
  continue;
136
139
  }
140
+ if (frozen ?? (await dashboardReleaseFrozen()))
141
+ throw new Error(
142
+ `Dashboard ${name} needs an explicit build, but the release is frozen. Reopen the release before changing candidate artifacts.`,
143
+ );
137
144
  const reason = forceRebuild
138
145
  ? "A atualização foi solicitada explicitamente."
139
146
  : state.missingArtifacts.length > 0
@@ -36,6 +36,7 @@ export const maxPortHistory = 50;
36
36
  export const dashboardBuildTargets = {
37
37
  frontend: {
38
38
  artifacts: [resolve(frontendRoot, "index.html")],
39
+ outputRoots: [frontendRoot],
39
40
  sourceRoots: [
40
41
  resolve(workspaceRoot, ".agents/dashboard/apps/frontend/src"),
41
42
  resolve(workspaceRoot, ".agents/dashboard/apps/frontend/public"),
@@ -54,6 +55,11 @@ export const dashboardBuildTargets = {
54
55
  resolve(workspaceRoot, "tsconfig.base.json"),
55
56
  resolve(workspaceRoot, "pnpm-lock.yaml"),
56
57
  resolve(workspaceRoot, "README.md"),
58
+ resolve(workspaceRoot, "README-ENG.md"),
59
+ resolve(workspaceRoot, ".agents/zaip-aios/guides"),
60
+ resolve(packageRoot, "scripts/build-frontend.mjs"),
61
+ resolve(packageRoot, "dashboard-build-fingerprint.mjs"),
62
+ resolve(packageRoot, "start-dashboard-paths.mjs"),
57
63
  ],
58
64
  excludedSourcePaths: ["/server/"],
59
65
  },
@@ -67,6 +73,8 @@ export const dashboardBuildTargets = {
67
73
  sourceRoots: [
68
74
  resolve(packageRoot, "src"),
69
75
  resolve(packageRoot, "scripts"),
76
+ resolve(packageRoot, "dashboard-build-fingerprint.mjs"),
77
+ resolve(packageRoot, "start-dashboard-paths.mjs"),
70
78
  resolve(packageRoot, "package.json"),
71
79
  resolve(packageRoot, "tsconfig.json"),
72
80
  resolve(workspaceRoot, ".agents/dashboard/modules/operations/src"),
@@ -198,6 +198,7 @@ describe("dashboard executable session", () => {
198
198
  const progress = [];
199
199
  const result = await refreshDashboardBuildTargets({
200
200
  targets,
201
+ frozen: false,
201
202
  forceRebuild,
202
203
  inspectTarget: async (target) => states[target.artifacts[0]],
203
204
  runBuild: async (target) => calls.push(target),
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zaip-ai/dashboard-ui",
3
- "version": "4.9.0",
3
+ "version": "5.1.0",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zaip-ai/dashboard-e2e",
3
- "version": "4.9.0",
3
+ "version": "5.1.0",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -0,0 +1,53 @@
1
+ import assert from "node:assert/strict";
2
+ import { spawnSync } from "node:child_process";
3
+ import { existsSync } from "node:fs";
4
+ import { dirname, join, resolve } from "node:path";
5
+
6
+ const root = resolve(import.meta.dirname, "../../../..");
7
+ assert.equal(resolve(process.cwd()), root);
8
+ const mode = process.argv[2];
9
+ assert.ok(["test", "check"].includes(mode));
10
+ function run(args) {
11
+ const result = spawnSync(process.execPath, args, {
12
+ cwd: root,
13
+ windowsHide: true,
14
+ encoding: "utf8",
15
+ timeout: 240_000,
16
+ maxBuffer: 8 * 1024 * 1024,
17
+ env: { ...process.env, CI: "true" },
18
+ });
19
+ process.stdout.write(result.stdout ?? "");
20
+ process.stderr.write(result.stderr ?? "");
21
+ assert.equal(result.status, 0, result.error?.message);
22
+ }
23
+ if (!existsSync(join(root, "node_modules/.modules.yaml"))) {
24
+ const branch = spawnSync("git", ["symbolic-ref", "-q", "HEAD"], {
25
+ cwd: root,
26
+ windowsHide: true,
27
+ encoding: "utf8",
28
+ timeout: 10000,
29
+ });
30
+ assert.equal(branch.status, 1, "Only prepare dependencies in detached candidate");
31
+ const manager = join(dirname(process.execPath), "node_modules/corepack/dist/pnpm.js");
32
+ assert.ok(existsSync(manager));
33
+ run([manager, "install", "--offline", "--frozen-lockfile", "--ignore-scripts"]);
34
+ }
35
+ if (mode === "test") {
36
+ run([
37
+ "node_modules/vitest/vitest.mjs",
38
+ "run",
39
+ "--maxWorkers=1",
40
+ ".agents/dashboard/modules/operations/src/react/OperationsOverviewTopPanel.navigation.test.tsx",
41
+ ".agents/dashboard/modules/operations/src/react/OperationsOverview.test.ts",
42
+ ".agents/dashboard/modules/operations/src/react/OperationsOverview.macro-metrics.test.ts",
43
+ ".agents/dashboard/apps/frontend/src/use-app-trace-documents.navigation.test.tsx",
44
+ ".agents/dashboard/apps/frontend/src/operations-period-render.test.ts",
45
+ ]);
46
+ } else {
47
+ for (const project of [
48
+ ".agents/dashboard/modules/operations/tsconfig.json",
49
+ ".agents/dashboard/apps/frontend/tsconfig.json",
50
+ ".agents/design/apps/catalog/tsconfig.json",
51
+ ])
52
+ run(["node_modules/typescript/bin/tsc", "--noEmit", "--project", project]);
53
+ }
@@ -0,0 +1,78 @@
1
+ import assert from "node:assert/strict";
2
+ import { mkdir, writeFile } from "node:fs/promises";
3
+ import { chromium, expect } from "@playwright/test";
4
+
5
+ const baseUrl = process.env.ZAIP_TOP_FIVE_URL ?? "http://127.0.0.1:4417";
6
+ assert.equal(new URL(baseUrl).hostname, "127.0.0.1", "Local dashboard only");
7
+ const output = ".local/top-five-served";
8
+ await mkdir(output, { recursive: true });
9
+ const browser = await chromium.launch({ headless: true });
10
+ try {
11
+ const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
12
+ page.setDefaultTimeout(60_000);
13
+ const errors = [];
14
+ const responses = [];
15
+ page.on("pageerror", (error) => errors.push(error.message));
16
+ page.on("response", (response) => {
17
+ if (response.url().includes("/api/v2/operations") || response.url().includes("/trace"))
18
+ responses.push({ path: new URL(response.url()).pathname, status: response.status() });
19
+ });
20
+ await page.goto(baseUrl, { waitUntil: "domcontentloaded" });
21
+ await page.getByRole("heading", { name: "Top 5 tarefas", exact: true }).waitFor();
22
+ const bundles = await page
23
+ .locator('script[src],link[rel="modulepreload"]')
24
+ .evaluateAll((nodes) =>
25
+ nodes.map((node) => node.getAttribute("src") ?? node.getAttribute("href")),
26
+ );
27
+ const cases = [];
28
+ for (const [kind, buttonName, heading, index] of [
29
+ ["spec", /^SPECs/, "Top 5 SPECs", 0],
30
+ ["prd", /^PRDs/, "Top 5 PRDs", 0],
31
+ ["task", /^Tarefas/, "Top 5 tarefas", 0],
32
+ ["spec", /^SPECs/, "Top 5 SPECs", 1],
33
+ ]) {
34
+ await page.getByRole("button", { name: buttonName }).first().click();
35
+ const panel = page
36
+ .locator("article")
37
+ .filter({ has: page.getByRole("heading", { name: heading, exact: true }) });
38
+ await panel.waitFor();
39
+ const bar = panel.locator(".operations-run-bar").nth(index);
40
+ await expect(bar).toBeEnabled();
41
+ const accessibleName = await bar.getAttribute("aria-label");
42
+ const title = (await bar.getAttribute("title")).replace(/: [^:]+$/, "");
43
+ if (index === 1) {
44
+ await bar.focus();
45
+ await bar.press("Enter");
46
+ } else await bar.click();
47
+ const dialog = page.getByRole("dialog").last();
48
+ await dialog.waitFor();
49
+ await expect(dialog).toContainText(title);
50
+ const text = await dialog.innerText();
51
+ const id = text.match(new RegExp(`\\b${kind.toUpperCase()}-[A-Z0-9-]+`))?.[0];
52
+ assert.ok(id, `Selected ${kind} identity is visible`);
53
+ await page.screenshot({ path: `${output}/${kind}-${index}.png` });
54
+ cases.push({ kind, index, title, id, accessibleName, observedAt: new Date().toISOString() });
55
+ await dialog.getByRole("button", { name: "Fechar", exact: true }).click();
56
+ await expect(dialog).not.toBeVisible();
57
+ }
58
+ assert.deepEqual(errors, []);
59
+ assert.equal(
60
+ responses.some((response) => response.status >= 400),
61
+ false,
62
+ );
63
+ const report = {
64
+ result: "passed",
65
+ baseUrl,
66
+ viewport: "1440x1000",
67
+ browser: browser.version(),
68
+ candidate: process.argv[2] ?? null,
69
+ bundles,
70
+ cases,
71
+ responses,
72
+ errors,
73
+ };
74
+ await writeFile(`${output}/report.json`, JSON.stringify(report, null, 2));
75
+ console.log(JSON.stringify(report, null, 2));
76
+ } finally {
77
+ await browser.close();
78
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "version": "4.9.0",
3
+ "version": "5.1.0",
4
4
  "files": [
5
5
  {
6
6
  "path": "DESIGN.md",
@@ -26,6 +26,10 @@
26
26
  "path": "apps/catalog/dist/assets/index-32GZO95T.js",
27
27
  "sha256": "12695d7255f03bf97d35c63efcff5b1ed52319ab36cbeacbf32de815a85cb03a"
28
28
  },
29
+ {
30
+ "path": "apps/catalog/dist/assets/index-BGxXxXTo.js",
31
+ "sha256": "e6b716d44fd773a3735d97d3bf3fd1959b2241696ff699e684ffd9889f941663"
32
+ },
29
33
  {
30
34
  "path": "apps/catalog/dist/assets/index-BP8IxOxt.js",
31
35
  "sha256": "972731afbaa1a1de2666477d46df0f7af55bfe698cb74bae919bac2718e1fbc8"
@@ -60,7 +64,7 @@
60
64
  },
61
65
  {
62
66
  "path": "apps/catalog/dist/index.html",
63
- "sha256": "9692409f65f5eff07c696c8cbf636266846c25d5173e3730f0a5aa152be76666"
67
+ "sha256": "4b3d44098eabcf0c06da564cefab001010523b9f5152d7d647caa6112224f432"
64
68
  },
65
69
  {
66
70
  "path": "apps/catalog/dist/logo_novo_azul.png",
@@ -276,7 +280,7 @@
276
280
  },
277
281
  {
278
282
  "path": "apps/catalog/package.json",
279
- "sha256": "51e5b590cefb6e579380f6bd25aefacecdaae63e0334452d802cfed620ff8626"
283
+ "sha256": "90285448c2f5d279607059952aa7233329049613882cc623f68da9305fded44f"
280
284
  },
281
285
  {
282
286
  "path": "apps/catalog/public/logo_novo_azul.png",
@@ -322,6 +326,10 @@
322
326
  "path": "apps/catalog/src/components/StackVersionFieldSpecimen.tsx",
323
327
  "sha256": "b33c5f2d78c34f8b2484be09d50244b8d67f1ce38d958c06306ecd742895284b"
324
328
  },
329
+ {
330
+ "path": "apps/catalog/src/components/TopEntitiesSpecimen.tsx",
331
+ "sha256": "2c3855f3d7d7f2c8570d7dc4ebf457b1d83dbeacc991dc4d8a4fc010155dc6c5"
332
+ },
325
333
  {
326
334
  "path": "apps/catalog/src/components/WorkspaceStatusSpecimen.tsx",
327
335
  "sha256": "6275e010e85452df87079176f79f30e6778ab72d1c463541bf19ac5ec72efb76"
@@ -344,7 +352,7 @@
344
352
  },
345
353
  {
346
354
  "path": "apps/catalog/src/pages/ComponentsPage.tsx",
347
- "sha256": "7ac73f7f9f02035b90e9d179706c9beab0f836afb9002d1516d05d09d4f8b8c0"
355
+ "sha256": "73a60ec9c86e94ed1b8ebe9064d65e4bb6c20551a2f652ce639b35642f81b0dc"
348
356
  },
349
357
  {
350
358
  "path": "apps/catalog/src/pages/DesignSystemPage.tsx",
@@ -360,7 +368,7 @@
360
368
  },
361
369
  {
362
370
  "path": "apps/catalog/src/stories/Components.stories.tsx",
363
- "sha256": "bc3044d7c0826656dd49d81f4128a8c2a5c271192f31ec7428445923676af832"
371
+ "sha256": "2a854431eb13a393de6d9475bf3308db20f7ccbdcb84d3983694cfe09b962ab7"
364
372
  },
365
373
  {
366
374
  "path": "apps/catalog/src/stories/DashboardFilters.stories.tsx",
@@ -408,7 +416,7 @@
408
416
  },
409
417
  {
410
418
  "path": "packages/local-runtime/package.json",
411
- "sha256": "36000642ad5ec75354a48998989c41030e3fc1990998d521ac417bed51595d85"
419
+ "sha256": "0e6f81da73ac2ce53dce5ea41197cab4939e784976420a2bf0c3aeccd45573e1"
412
420
  },
413
421
  {
414
422
  "path": "packages/local-runtime/runtime.mjs",