create-windy 0.4.0 → 0.5.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/dist/cli.js +263 -121
- package/package.json +1 -1
- package/template/.windy-template.json +2 -2
- package/template/apps/agent-server/adk_web_agents/canonical_debug/agent.py +29 -9
- package/template/apps/agent-server/adk_web_agents/services.py +25 -0
- package/template/apps/agent-server/src/southwind_agent_server/adk_adapter.py +40 -11
- package/template/apps/agent-server/src/southwind_agent_server/adk_debug_sessions.py +325 -0
- package/template/apps/agent-server/src/southwind_agent_server/adk_model.py +70 -6
- package/template/apps/agent-server/src/southwind_agent_server/adk_tools.py +1 -1
- package/template/apps/agent-server/src/southwind_agent_server/app.py +16 -4
- package/template/apps/agent-server/src/southwind_agent_server/approval_resolution.py +30 -0
- package/template/apps/agent-server/src/southwind_agent_server/contracts.py +9 -0
- package/template/apps/agent-server/src/southwind_agent_server/deterministic.py +2 -1
- package/template/apps/agent-server/src/southwind_agent_server/engine.py +3 -1
- package/template/apps/agent-server/src/southwind_agent_server/openai_engine.py +95 -130
- package/template/apps/agent-server/src/southwind_agent_server/openai_engine_validation.py +133 -0
- package/template/apps/agent-server/src/southwind_agent_server/openai_provider.py +89 -20
- package/template/apps/agent-server/src/southwind_agent_server/postgres_report_insert.py +34 -0
- package/template/apps/agent-server/src/southwind_agent_server/postgres_report_queries.py +234 -0
- package/template/apps/agent-server/src/southwind_agent_server/postgres_report_replay.py +44 -0
- package/template/apps/agent-server/src/southwind_agent_server/postgres_report_status.py +83 -0
- package/template/apps/agent-server/src/southwind_agent_server/postgres_report_store.py +331 -0
- package/template/apps/agent-server/src/southwind_agent_server/postgres_report_summary.py +304 -0
- package/template/apps/agent-server/src/southwind_agent_server/report_lifecycle.py +217 -0
- package/template/apps/agent-server/src/southwind_agent_server/report_metrics.py +149 -0
- package/template/apps/agent-server/src/southwind_agent_server/report_presenter.py +280 -0
- package/template/apps/agent-server/src/southwind_agent_server/report_routes.py +126 -0
- package/template/apps/agent-server/src/southwind_agent_server/report_store.py +344 -0
- package/template/apps/agent-server/src/southwind_agent_server/report_types.py +111 -0
- package/template/apps/agent-server/src/southwind_agent_server/runtime_factory.py +31 -2
- package/template/apps/agent-server/src/southwind_agent_server/service.py +56 -51
- package/template/apps/agent-server/src/southwind_agent_server/signal_events.py +18 -1
- package/template/apps/agent-server/tests/test_adk_adapter.py +7 -9
- package/template/apps/agent-server/tests/test_adk_debug_sessions.py +215 -0
- package/template/apps/agent-server/tests/test_adk_web_canonical_debug.py +48 -1
- package/template/apps/agent-server/tests/test_openai_provider.py +58 -6
- package/template/apps/agent-server/tests/test_postgres_report_status.py +59 -0
- package/template/apps/agent-server/tests/test_postgres_report_summary.py +298 -0
- package/template/apps/agent-server/tests/test_provider_attempt_reporting.py +152 -0
- package/template/apps/agent-server/tests/test_report_attempt_lifecycle.py +126 -0
- package/template/apps/agent-server/tests/test_report_resilience.py +181 -0
- package/template/apps/agent-server/tests/test_report_store.py +286 -0
- package/template/apps/agent-server/tests/test_report_summary_parity.py +115 -0
- package/template/apps/agent-server/tests/test_report_terminal_sync.py +177 -0
- package/template/apps/server/src/agent/debug-session-facade-provider-failure.test.ts +269 -0
- package/template/apps/server/src/agent/debug-session-facade.test.ts +335 -0
- package/template/apps/server/src/agent/debug-session-facade.ts +302 -0
- package/template/apps/server/src/agent/debug-session-id.test.ts +37 -0
- package/template/apps/server/src/agent/debug-session-id.ts +37 -0
- package/template/apps/server/src/agent/debug-session-provider-reader.ts +54 -0
- package/template/apps/server/src/agent/debug-session-routes.test.ts +64 -0
- package/template/apps/server/src/agent/debug-session-routes.ts +73 -0
- package/template/apps/server/src/agent/debug-session-validation.ts +106 -0
- package/template/apps/server/src/agent/drizzle-run-binding-repository.ts +2 -0
- package/template/apps/server/src/agent/provider-input-governance.test.ts +18 -0
- package/template/apps/server/src/agent/provider-input-governance.ts +37 -1
- package/template/apps/server/src/agent/remote-runtime.test.ts +7 -0
- package/template/apps/server/src/agent/remote-runtime.ts +1 -0
- package/template/apps/server/src/agent/run-authorization.test.ts +98 -0
- package/template/apps/server/src/agent/run-authorization.ts +32 -1
- package/template/apps/server/src/agent/run-binding-repository.ts +1 -0
- package/template/apps/server/src/agent/run-contracts.ts +5 -0
- package/template/apps/server/src/agent/run-facade-adk-debug.test.ts +39 -0
- package/template/apps/server/src/agent/run-facade.test.ts +78 -0
- package/template/apps/server/src/agent/run-facade.ts +33 -3
- package/template/apps/server/src/agent/run-input-commitment.ts +50 -0
- package/template/apps/server/src/agent/run-input-verification.ts +41 -0
- package/template/apps/server/src/agent/runtime-bootstrap-report.test.ts +136 -0
- package/template/apps/server/src/agent/runtime-bootstrap.ts +66 -1
- package/template/apps/server/src/agent/tool-host.test.ts +1 -0
- package/template/apps/server/src/agent/unavailable-routes.ts +4 -0
- package/template/apps/server/src/ai-runtime-report/actor-directory.ts +94 -0
- package/template/apps/server/src/ai-runtime-report/actor-handle.test.ts +27 -0
- package/template/apps/server/src/ai-runtime-report/actor-handle.ts +81 -0
- package/template/apps/server/src/ai-runtime-report/contracts.ts +91 -0
- package/template/apps/server/src/ai-runtime-report/remote-parser.ts +212 -0
- package/template/apps/server/src/ai-runtime-report/remote-port.ts +138 -0
- package/template/apps/server/src/ai-runtime-report/routes.ts +172 -0
- package/template/apps/server/src/ai-runtime-report/scope.ts +63 -0
- package/template/apps/server/src/ai-runtime-report/service.test.ts +271 -0
- package/template/apps/server/src/ai-runtime-report/service.ts +206 -0
- package/template/apps/server/src/license/runtime-audit-reliability.test.ts +2 -0
- package/template/apps/server/src/license/runtime-service.test.ts +6 -0
- package/template/apps/server/src/module-host/ai-operation-port.test.ts +63 -0
- package/template/apps/server/src/module-host/ai-operation-port.ts +30 -5
- package/template/apps/server/src/module-host/debug-session-provider-registration.test.ts +162 -0
- package/template/apps/server/src/module-host/debug-session-provider-registration.ts +84 -0
- package/template/apps/server/src/module-host/initialize-contracts.ts +7 -0
- package/template/apps/server/src/module-host/initialize.ts +6 -197
- package/template/apps/server/src/module-host/request-context.ts +1 -0
- package/template/apps/server/src/module-host/scoped-host.ts +214 -0
- package/template/apps/server/src/module-host.ts +1 -0
- package/template/apps/server/src/runtime-adk-debug.test.ts +25 -1
- package/template/apps/server/src/runtime-adk-debug.ts +8 -2
- package/template/apps/server/src/settings/drizzle-watermark-repository.integration.test.ts +4 -0
- package/template/apps/server/src/settings/drizzle-watermark-repository.ts +11 -3
- package/template/apps/server/src/settings/watermark-routes.test.ts +54 -1
- package/template/apps/server/src/settings/watermark-routes.ts +29 -1
- package/template/apps/server/src/system/operations.test.ts +54 -0
- package/template/apps/server/src/system/operations.ts +23 -1
- package/template/apps/server/src/system/seed.test.ts +4 -0
- package/template/apps/server/src/system/system-resource-monitoring.test.ts +82 -0
- package/template/apps/server/src/system/system-resource-monitoring.ts +300 -0
- package/template/apps/web/src/composables/useWatermarkSettings.webtest.ts +14 -0
- package/template/apps/web/src/composables/watermark-settings.ts +40 -11
- package/template/apps/web/src/composables/watermark-settings.webtest.ts +19 -6
- package/template/apps/web/src/layout/AppSidebar.vue +6 -1
- package/template/apps/web/src/layout/AppSidebar.webtest.ts +2 -0
- package/template/apps/web/src/layout/GlobalWatermark.layering.webtest.ts +2 -0
- package/template/apps/web/src/layout/GlobalWatermark.vue +4 -8
- package/template/apps/web/src/layout/GlobalWatermark.webtest.ts +12 -5
- package/template/apps/web/src/pages/auth/LoginPage.vue +6 -1
- package/template/apps/web/src/pages/settings/BrandingSettingsSection.vue +20 -3
- package/template/apps/web/src/pages/settings/BrandingSettingsSection.webtest.ts +80 -0
- package/template/apps/web/src/pages/settings/WatermarkPreview.vue +72 -0
- package/template/apps/web/src/pages/settings/WatermarkPreview.webtest.ts +55 -0
- package/template/apps/web/src/pages/settings/WatermarkSettingsSection.vue +80 -24
- package/template/apps/web/src/pages/settings/WatermarkSettingsSection.webtest.ts +115 -0
- package/template/apps/web/src/pages/system/AiRuntimePage.vue +129 -0
- package/template/apps/web/src/pages/system/SystemOperationsPage.vue +2 -1
- package/template/apps/web/src/pages/system/ai-runtime-presenter.ts +60 -0
- package/template/apps/web/src/pages/system/ai-runtime-presenter.webtest.ts +48 -0
- package/template/apps/web/src/pages/system/audit-time-range.ts +34 -2
- package/template/apps/web/src/pages/system/components/AuditLogFilters.vue +4 -3
- package/template/apps/web/src/pages/system/components/AuditLogFilters.webtest.ts +26 -1
- package/template/apps/web/src/pages/system/components/OperationGpuMonitor.vue +98 -0
- package/template/apps/web/src/pages/system/components/OperationGpuMonitor.webtest.ts +61 -0
- package/template/apps/web/src/pages/system/components/OperationServiceMonitor.vue +53 -0
- package/template/apps/web/src/pages/system/components/OperationServiceMonitor.webtest.ts +20 -1
- package/template/apps/web/src/pages/system/components/SystemResourcePage.webtest.ts +14 -1
- package/template/apps/web/src/pages/system/components/ai-runtime/AiRuntimeActivityChart.vue +85 -0
- package/template/apps/web/src/pages/system/components/ai-runtime/AiRuntimeCharts.webtest.ts +82 -0
- package/template/apps/web/src/pages/system/components/ai-runtime/AiRuntimeFilters.vue +98 -0
- package/template/apps/web/src/pages/system/components/ai-runtime/AiRuntimeFilters.webtest.ts +27 -0
- package/template/apps/web/src/pages/system/components/ai-runtime/AiRuntimeRunDetailDialog.vue +168 -0
- package/template/apps/web/src/pages/system/components/ai-runtime/AiRuntimeRunTable.vue +130 -0
- package/template/apps/web/src/pages/system/components/ai-runtime/AiRuntimeSummaryCards.vue +82 -0
- package/template/apps/web/src/pages/system/components/ai-runtime/AiRuntimeSummaryCards.webtest.ts +102 -0
- package/template/apps/web/src/pages/system/components/ai-runtime/AiRuntimeTokenByModelChart.vue +101 -0
- package/template/apps/web/src/pages/system/composables/useAiRuntimeReport.ts +185 -0
- package/template/apps/web/src/pages/system/composables/useAiRuntimeReport.webtest.ts +158 -0
- package/template/apps/web/src/pages/system/composables/useSystemResource.ts +21 -7
- package/template/apps/web/src/router/error-navigation.ts +22 -0
- package/template/apps/web/src/router/index.ts +12 -23
- package/template/apps/web/src/router/platform-admin-route-bindings.ts +4 -0
- package/template/apps/web/src/services/ai-runtime-api.ts +164 -0
- package/template/apps/web/src/services/ai-runtime-api.webtest.ts +111 -0
- package/template/apps/web/src/services/operations-api.ts +28 -0
- package/template/docker-compose.agent-debug.yml +1 -1
- package/template/docs/architecture/ai-runtime.md +2 -1
- package/template/docs/architecture/module-host.md +3 -0
- package/template/docs/platform/agent-run-attestation.md +65 -0
- package/template/docs/platform/agent-runtime-observability.md +135 -0
- package/template/docs/platform/agent-runtime.md +47 -3
- package/template/docs/platform/operations-overview.md +13 -0
- package/template/docs/platform/platform-authentication.md +4 -3
- package/template/docs/platform/platform-shell-settings.md +15 -10
- package/template/docs/platform/web-system-crud.md +1 -1
- package/template/packages/config/package.json +1 -1
- package/template/packages/database/drizzle/0044_sweet_tarantula.sql +6 -0
- package/template/packages/database/drizzle/0045_tiny_cassandra_nova.sql +65 -0
- package/template/packages/database/drizzle/0046_tranquil_living_mummy.sql +6 -0
- package/template/packages/database/drizzle/0047_oval_luke_cage.sql +18 -0
- package/template/packages/database/drizzle/meta/0044_snapshot.json +8349 -0
- package/template/packages/database/drizzle/meta/0045_snapshot.json +8814 -0
- package/template/packages/database/drizzle/meta/0046_snapshot.json +8820 -0
- package/template/packages/database/drizzle/meta/0047_snapshot.json +8835 -0
- package/template/packages/database/drizzle/meta/_journal.json +28 -0
- package/template/packages/database/package.json +1 -1
- package/template/packages/database/src/agent-runtime-schema.test.ts +54 -0
- package/template/packages/database/src/schema/agent-runtime.ts +114 -0
- package/template/packages/database/src/schema/platform-settings.ts +3 -0
- package/template/packages/jobs/package.json +1 -1
- package/template/packages/modules/package.json +1 -1
- package/template/packages/modules/src/system-admin-routes.ts +10 -0
- package/template/packages/modules/src/system-admin-ui-catalog.ts +1 -1
- package/template/packages/modules/src/system-api-control-plane.ts +17 -1
- package/template/packages/modules/src/system-audit-actions.ts +10 -0
- package/template/packages/modules/src/system-features.ts +8 -0
- package/template/packages/modules/src/system-module-catalog.test.ts +35 -0
- package/template/packages/modules/src/system-module-catalog.ts +15 -4
- package/template/packages/modules/src/system-modules-access.test.ts +69 -0
- package/template/packages/modules/src/system-modules.ts +13 -0
- package/template/packages/modules/src/system-permissions.ts +2 -0
- package/template/packages/server-sdk/index.ts +11 -0
- package/template/packages/server-sdk/package.json +2 -1
- package/template/packages/server-sdk/src/ai-operation-port.ts +5 -0
- package/template/packages/server-sdk/src/debug-session-provider.ts +63 -0
- package/template/packages/server-sdk/src/module-host.ts +5 -0
- package/template/packages/shared/index.ts +3 -0
- package/template/packages/shared/package.json +1 -1
- package/template/packages/shared/src/ai-runtime-report.ts +134 -0
- package/template/packages/shared/src/platform-settings.ts +17 -0
- package/template/scripts/lib/postgres-regression.ts +201 -0
|
@@ -53,11 +53,13 @@
|
|
|
53
53
|
- 权限:`system.watermark.read`、`system.watermark.manage`
|
|
54
54
|
- 页面入口:全局设置 / 页面水印,不注册独立 Sidebar 菜单
|
|
55
55
|
|
|
56
|
-
水印是平台级强制策略,不是用户偏好。`PlatformWatermarkPolicy`
|
|
57
|
-
`enabled
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
水印是平台级强制策略,不是用户偏好。`PlatformWatermarkPolicy` 包含统一控制管理页与
|
|
57
|
+
业务页的 `enabled`、`low / medium / high` 密度、3% 至 30% 的 `opacityPercent`、
|
|
58
|
+
12px 至 32px 的 `fontSize`、内容字段勾选与最长 80 字符的 `customContent`。可选内容为
|
|
59
|
+
用户名、姓名、手机号、邮箱和自定义内容,可任意组合但至少保留一项;缺少已勾选的用户资料
|
|
60
|
+
时不会渲染空片段,所有选项均无值时兜底使用用户名。设置页使用与实际页面相同的 SVG
|
|
61
|
+
平铺算法即时预览表单草稿,未保存草稿不会提前改变其他页面。策略由 Admin 的全局设置页面
|
|
62
|
+
维护,写入
|
|
61
63
|
`platform_watermark_policies`;每次保存都记录 `config.update` 审计,目标为
|
|
62
64
|
`platform-watermark/platform`。用户应用端没有水印开关,也不使用 localStorage
|
|
63
65
|
保存或覆盖策略。
|
|
@@ -65,9 +67,10 @@
|
|
|
65
67
|
管理接口 `GET/PUT /api/system/settings/watermark` 分别经过
|
|
66
68
|
`system.watermark.read/manage`、Feature 与 License Guard。业务应用通过公开只读接口
|
|
67
69
|
`GET /api/platform/watermark-policy` 获取相同策略;公开响应只包含上述非敏感策略字段。
|
|
68
|
-
Feature 最终有效且 `enabled=true` 时 Admin
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
Feature 最终有效且 `enabled=true` 时 Admin 与业务页面统一显示水印。Admin 设置区本身
|
|
71
|
+
仍要求读取权限,但普通业务用户不需要水印读取权限,也不能覆盖全局策略。历史
|
|
72
|
+
`businessPagesEnabled` 仅保留为升级兼容字段,读写时始终与 `enabled` 保持一致,不再形成
|
|
73
|
+
第二个产品开关。
|
|
71
74
|
|
|
72
75
|
客户端按管理员勾选顺序从当前 Actor 派生身份水印,自定义内容只有被勾选时才加入。
|
|
73
76
|
渲染算法先按字符视觉宽度自动换行,再根据旋转后文本包围盒与密度预设计算 SVG 平铺
|
|
@@ -80,8 +83,10 @@ Feature 最终有效且 `enabled=true` 时 Admin 页面显示水印;业务页
|
|
|
80
83
|
|
|
81
84
|
数据库迁移 `0031_panoramic_typhoid_mary.sql` 新增策略表,
|
|
82
85
|
`0034_funny_mesmero.sql` 新增密度与内容字段。升级时,已有自定义文字的策略自动迁移为
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
勾选“自定义内容”,避免改变既有展示;`0044_sweet_tarantula.sql` 新增不透明度和字号,
|
|
87
|
+
并按旧 `enabled && businessPagesEnabled` 折叠历史有效状态,避免升级时意外扩大水印范围。
|
|
88
|
+
其它已有策略采用中密度、“用户名 + 姓名”、8% 不透明度和 14px 字号。未持久化策略采用
|
|
89
|
+
相同默认值,统一开关默认开启。
|
|
85
90
|
|
|
86
91
|
## 个人设置
|
|
87
92
|
|
|
@@ -87,7 +87,7 @@ VITE_DEV_ADMIN_TOKEN=<显式开发 Token>
|
|
|
87
87
|
- Feature 管理页在列表最右侧操作栏直接显示启停开关,不再打开通用编辑弹窗;修改仍调用受 Guard 和关键审计保护的 Server API。
|
|
88
88
|
- Feature 开关成功修改会写入 `feature.update`,可在审计日志页通过“功能开关变更”直接查看。
|
|
89
89
|
- 系统资源表和字典后台任务表加载时保留表头与列宽,并显示带 `animate-pulse` 的骨架行;加载失败和空数据仍使用各自独立状态。
|
|
90
|
-
-
|
|
90
|
+
- 页面水印默认开启,一个开关统一控制管理页和业务页。管理员在“全局设置”中维护低/中/高密度、3% 至 30% 不透明度、12px 至 32px 字号,并任意组合用户名、姓名、手机号、邮箱或最多 80 个字符的自定义内容;表单草稿使用实际平铺算法即时预览,保存后写入审计并成为所有用户的只读策略。客户端按旋转文本包围盒自动计算平铺尺寸与安全间距,长内容和高密度模式也不会相互重叠。用户应用端不提供开关,也不使用 localStorage。`system.watermark` Feature 控制最终生效态,管理区另需 `system.watermark.read/manage` 权限。水印使用专用审计顶层覆盖 Sidebar、Drawer、Overlay 和 Modal,同时保持 `pointer-events-none`。服务端只向当前用户自己的会话响应补充这些身份字段。
|
|
91
91
|
- 站内通知由 PostgreSQL `platform_notifications`、`notification_revisions`、`notification_reads` 和 `notification_favorites` 持久化;管理人员可在 `/system/notifications` 广播发布、修改、查看版本历史和归档,用户从 Header 收件箱阅读正文并幂等写入相互独立的已读、收藏回执。修改会生成带服务端时间和 Actor 的完整不可变快照,无内容变化不增加版本。普通用户 API 支持关键词、分类、已读和收藏的服务端组合筛选,列表与 `total` 使用同一可见性范围。归档是生命周期操作,不物理删除通知、版本或回执。
|
|
92
92
|
|
|
93
93
|
<!-- @windy-module system.bulk-data begin -->
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
ALTER TABLE "platform_watermark_policies" ADD COLUMN "opacity_percent" integer DEFAULT 8 NOT NULL;--> statement-breakpoint
|
|
2
|
+
ALTER TABLE "platform_watermark_policies" ADD COLUMN "font_size" integer DEFAULT 14 NOT NULL;--> statement-breakpoint
|
|
3
|
+
UPDATE "platform_watermark_policies"
|
|
4
|
+
SET
|
|
5
|
+
"enabled" = "enabled" AND "business_pages_enabled",
|
|
6
|
+
"business_pages_enabled" = "enabled" AND "business_pages_enabled";
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
CREATE TABLE "agent_runtime_report_attempts" (
|
|
2
|
+
"attempt_id" varchar(80) PRIMARY KEY NOT NULL,
|
|
3
|
+
"run_id" varchar(80) NOT NULL,
|
|
4
|
+
"sequence" integer NOT NULL,
|
|
5
|
+
"tool_round" integer NOT NULL,
|
|
6
|
+
"deployment_key" varchar(200) NOT NULL,
|
|
7
|
+
"requested_model" varchar(200) NOT NULL,
|
|
8
|
+
"reported_model" varchar(200),
|
|
9
|
+
"outcome" varchar(32) NOT NULL,
|
|
10
|
+
"cache_status" varchar(16) NOT NULL,
|
|
11
|
+
"usage_source" varchar(32) NOT NULL,
|
|
12
|
+
"input_tokens" integer,
|
|
13
|
+
"output_tokens" integer,
|
|
14
|
+
"cached_input_tokens" integer,
|
|
15
|
+
"reasoning_tokens" integer,
|
|
16
|
+
"total_tokens" integer,
|
|
17
|
+
"first_token_latency_ms" integer,
|
|
18
|
+
"duration_ms" integer,
|
|
19
|
+
"safe_error_code" varchar(80),
|
|
20
|
+
"started_at" double precision NOT NULL,
|
|
21
|
+
"finished_at" double precision,
|
|
22
|
+
CONSTRAINT "ck_agent_report_attempts_sequence" CHECK ("agent_runtime_report_attempts"."sequence" > 0),
|
|
23
|
+
CONSTRAINT "ck_agent_report_attempts_tool_round" CHECK ("agent_runtime_report_attempts"."tool_round" > 0),
|
|
24
|
+
CONSTRAINT "ck_agent_report_attempts_outcome" CHECK ("agent_runtime_report_attempts"."outcome" in ('completed', 'failed', 'cancelled', 'blocked', 'abandoned')),
|
|
25
|
+
CONSTRAINT "ck_agent_report_attempts_cache" CHECK ("agent_runtime_report_attempts"."cache_status" in ('hit', 'miss', 'unknown')),
|
|
26
|
+
CONSTRAINT "ck_agent_report_attempts_usage_source" CHECK ("agent_runtime_report_attempts"."usage_source" in ('provider-reported', 'estimated', 'unknown')),
|
|
27
|
+
CONSTRAINT "ck_agent_report_attempts_non_negative" CHECK (coalesce("agent_runtime_report_attempts"."input_tokens", 0) >= 0
|
|
28
|
+
and coalesce("agent_runtime_report_attempts"."output_tokens", 0) >= 0
|
|
29
|
+
and coalesce("agent_runtime_report_attempts"."cached_input_tokens", 0) >= 0
|
|
30
|
+
and coalesce("agent_runtime_report_attempts"."reasoning_tokens", 0) >= 0
|
|
31
|
+
and coalesce("agent_runtime_report_attempts"."total_tokens", 0) >= 0
|
|
32
|
+
and coalesce("agent_runtime_report_attempts"."first_token_latency_ms", 0) >= 0
|
|
33
|
+
and coalesce("agent_runtime_report_attempts"."duration_ms", 0) >= 0)
|
|
34
|
+
);
|
|
35
|
+
--> statement-breakpoint
|
|
36
|
+
CREATE TABLE "agent_runtime_report_runs" (
|
|
37
|
+
"run_id" varchar(80) PRIMARY KEY NOT NULL,
|
|
38
|
+
"operation_key" varchar(200) NOT NULL,
|
|
39
|
+
"release_id" varchar(80) NOT NULL,
|
|
40
|
+
"trace_id" varchar(160) NOT NULL,
|
|
41
|
+
"actor_id" varchar(64),
|
|
42
|
+
"actor_type" varchar(32),
|
|
43
|
+
"department_id" varchar(64),
|
|
44
|
+
"status" varchar(32) NOT NULL,
|
|
45
|
+
"safe_error_code" varchar(80),
|
|
46
|
+
"started_at" double precision,
|
|
47
|
+
"finished_at" double precision,
|
|
48
|
+
"duration_ms" integer,
|
|
49
|
+
"created_at" double precision NOT NULL,
|
|
50
|
+
"updated_at" double precision NOT NULL,
|
|
51
|
+
"expires_at" double precision NOT NULL,
|
|
52
|
+
CONSTRAINT "ck_agent_report_runs_status" CHECK ("agent_runtime_report_runs"."status" in ('accepted', 'running', 'awaiting-approval', 'completed', 'failed', 'cancelled')),
|
|
53
|
+
CONSTRAINT "ck_agent_report_runs_duration" CHECK ("agent_runtime_report_runs"."duration_ms" is null or "agent_runtime_report_runs"."duration_ms" >= 0)
|
|
54
|
+
);
|
|
55
|
+
--> statement-breakpoint
|
|
56
|
+
ALTER TABLE "agent_runtime_report_attempts" ADD CONSTRAINT "agent_runtime_report_attempts_run_id_agent_runtime_report_runs_run_id_fk" FOREIGN KEY ("run_id") REFERENCES "public"."agent_runtime_report_runs"("run_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
57
|
+
CREATE UNIQUE INDEX "uk_agent_report_attempts_sequence" ON "agent_runtime_report_attempts" USING btree ("run_id","sequence");--> statement-breakpoint
|
|
58
|
+
CREATE INDEX "idx_agent_report_attempts_model" ON "agent_runtime_report_attempts" USING btree ("deployment_key","requested_model","started_at");--> statement-breakpoint
|
|
59
|
+
CREATE INDEX "idx_agent_report_attempts_outcome" ON "agent_runtime_report_attempts" USING btree ("outcome","started_at");--> statement-breakpoint
|
|
60
|
+
CREATE INDEX "idx_agent_report_runs_created" ON "agent_runtime_report_runs" USING btree ("created_at");--> statement-breakpoint
|
|
61
|
+
CREATE INDEX "idx_agent_report_runs_status" ON "agent_runtime_report_runs" USING btree ("status","created_at");--> statement-breakpoint
|
|
62
|
+
CREATE INDEX "idx_agent_report_runs_operation" ON "agent_runtime_report_runs" USING btree ("operation_key","created_at");--> statement-breakpoint
|
|
63
|
+
CREATE INDEX "idx_agent_report_runs_actor" ON "agent_runtime_report_runs" USING btree ("actor_id","created_at");--> statement-breakpoint
|
|
64
|
+
CREATE INDEX "idx_agent_report_runs_department" ON "agent_runtime_report_runs" USING btree ("department_id","created_at");--> statement-breakpoint
|
|
65
|
+
CREATE INDEX "idx_agent_report_runs_expiry" ON "agent_runtime_report_runs" USING btree ("expires_at");
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
ALTER TABLE "agent_runtime_report_attempts" DROP CONSTRAINT "ck_agent_report_attempts_outcome";--> statement-breakpoint
|
|
2
|
+
UPDATE "agent_runtime_report_attempts"
|
|
3
|
+
SET "finished_at" = greatest(
|
|
4
|
+
"started_at",
|
|
5
|
+
extract(epoch from clock_timestamp())
|
|
6
|
+
),
|
|
7
|
+
"duration_ms" = greatest(
|
|
8
|
+
0,
|
|
9
|
+
round(
|
|
10
|
+
(
|
|
11
|
+
greatest("started_at", extract(epoch from clock_timestamp()))
|
|
12
|
+
- "started_at"
|
|
13
|
+
) * 1000
|
|
14
|
+
)
|
|
15
|
+
)::integer
|
|
16
|
+
WHERE "outcome" = 'abandoned' AND "finished_at" IS NULL;--> statement-breakpoint
|
|
17
|
+
CREATE INDEX "idx_agent_report_attempts_started" ON "agent_runtime_report_attempts" USING btree ("started_at");--> statement-breakpoint
|
|
18
|
+
ALTER TABLE "agent_runtime_report_attempts" ADD CONSTRAINT "ck_agent_report_attempts_outcome" CHECK ("agent_runtime_report_attempts"."outcome" in ('running', 'completed', 'failed', 'cancelled', 'blocked', 'abandoned'));
|