create-windy 0.2.33 → 0.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/dist/cli.js +173 -17
- package/package.json +1 -1
- package/template/.agents/skills/windy-business-module/SKILL.md +10 -1
- package/template/.windy-template.json +2 -2
- package/template/AGENTS.md +9 -0
- package/template/README.md +3 -1
- package/template/apps/agent-server/Dockerfile +1 -0
- package/template/apps/agent-server/README.md +28 -5
- package/template/apps/agent-server/adk_web_agents/__init__.py +1 -0
- package/template/apps/agent-server/adk_web_agents/safe_debug/__init__.py +3 -0
- package/template/apps/agent-server/adk_web_agents/safe_debug/agent.py +40 -0
- package/template/apps/agent-server/pyproject.toml +1 -1
- package/template/apps/agent-server/src/southwind_agent_server/adk_adapter.py +191 -16
- package/template/apps/agent-server/src/southwind_agent_server/adk_failure.py +13 -0
- package/template/apps/agent-server/src/southwind_agent_server/adk_model.py +225 -0
- package/template/apps/agent-server/src/southwind_agent_server/adk_tools.py +76 -0
- package/template/apps/agent-server/src/southwind_agent_server/app.py +63 -3
- package/template/apps/agent-server/src/southwind_agent_server/contracts.py +35 -0
- package/template/apps/agent-server/src/southwind_agent_server/engine.py +2 -0
- package/template/apps/agent-server/src/southwind_agent_server/openai_engine.py +31 -3
- package/template/apps/agent-server/src/southwind_agent_server/openai_provider.py +22 -9
- package/template/apps/agent-server/src/southwind_agent_server/provider_audit.py +144 -0
- package/template/apps/agent-server/src/southwind_agent_server/provider_governance.py +227 -0
- package/template/apps/agent-server/src/southwind_agent_server/service.py +1 -0
- package/template/apps/agent-server/tests/test_adk_adapter.py +305 -0
- package/template/apps/agent-server/tests/test_adk_web_agent.py +12 -0
- package/template/apps/agent-server/tests/test_api.py +16 -1
- package/template/apps/agent-server/tests/test_openai_provider.py +79 -0
- package/template/apps/agent-server/tests/test_provider_governance.py +215 -0
- package/template/apps/server/package.json +4 -1
- package/template/apps/server/src/agent/provider-input-governance.test.ts +82 -0
- package/template/apps/server/src/agent/provider-input-governance.ts +140 -0
- package/template/apps/server/src/agent/remote-runtime.test.ts +22 -0
- package/template/apps/server/src/agent/remote-runtime.ts +1 -0
- package/template/apps/server/src/agent/run-contracts.ts +2 -0
- package/template/apps/server/src/agent/run-facade.test.ts +52 -2
- package/template/apps/server/src/agent/run-facade.ts +38 -9
- package/template/apps/server/src/agent/tool-registry.ts +2 -6
- package/template/apps/server/src/application-services.ts +50 -0
- package/template/apps/server/src/audit/drizzle-log-store.ts +25 -0
- package/template/apps/server/src/audit/search-summary.ts +2 -6
- package/template/apps/server/src/auth/credential-restriction.ts +1 -0
- package/template/apps/server/src/auth/password.ts +30 -21
- package/template/apps/server/src/auth/routes.test.ts +44 -3
- package/template/apps/server/src/auth/routes.ts +6 -1
- package/template/apps/server/src/auth/runtime.ts +4 -1
- package/template/apps/server/src/auth/service.ts +25 -7
- package/template/apps/server/src/configuration/bootstrap.ts +20 -1
- package/template/apps/server/src/configuration/definition.test.ts +71 -0
- package/template/apps/server/src/configuration/definition.ts +242 -12
- package/template/apps/server/src/configuration/drizzle-repository.ts +36 -2
- package/template/apps/server/src/configuration/repository.ts +27 -2
- package/template/apps/server/src/configuration/routes.ts +4 -1
- package/template/apps/server/src/configuration/service.test.ts +100 -0
- package/template/apps/server/src/configuration/service.ts +50 -10
- package/template/apps/server/src/data-access/scoped-repository.integration.test.ts +3 -2
- package/template/apps/server/src/data-governance/export/service.ts +2 -6
- package/template/apps/server/src/example-modules.ts +4 -1
- package/template/apps/server/src/guards.ts +18 -5
- package/template/apps/server/src/http/request-source.test.ts +85 -0
- package/template/apps/server/src/http/request-source.ts +90 -0
- package/template/apps/server/src/index.ts +45 -45
- package/template/apps/server/src/license/routes.ts +2 -0
- package/template/apps/server/src/license/runtime-service.ts +10 -11
- package/template/apps/server/src/module-bootstrap.ts +2 -2
- package/template/apps/server/src/module-host/initialize-contracts.ts +6 -0
- package/template/apps/server/src/module-host/initialize.ts +30 -44
- package/template/apps/server/src/module-host/request-context.ts +29 -23
- package/template/apps/server/src/module-host/resource-file-policies.test.ts +197 -0
- package/template/apps/server/src/module-host/resource-file-policies.ts +108 -0
- package/template/apps/server/src/module-host/route-declaration.ts +45 -0
- package/template/apps/server/src/module-host/route-installer.ts +27 -3
- package/template/apps/server/src/module-host/storage-port.test.ts +170 -1
- package/template/apps/server/src/module-host/storage-port.ts +134 -1
- package/template/apps/server/src/module-host/storage-scope.ts +89 -0
- package/template/apps/server/src/module-host/tool-handlers.test.ts +305 -0
- package/template/apps/server/src/module-host/tool-handlers.ts +38 -4
- package/template/apps/server/src/module-host/user-directory-composition.test.ts +126 -0
- package/template/apps/server/src/module-host/user-directory-port.test.ts +238 -0
- package/template/apps/server/src/module-host/user-directory-port.ts +139 -0
- package/template/apps/server/src/module-host.ts +4 -0
- package/template/apps/server/src/notification/channel-adapter.ts +46 -0
- package/template/apps/server/src/notification/delivery-policy.test.ts +59 -0
- package/template/apps/server/src/notification/delivery-policy.ts +37 -0
- package/template/apps/server/src/notification/delivery-repository.ts +198 -0
- package/template/apps/server/src/notification/delivery-worker.test.ts +87 -0
- package/template/apps/server/src/notification/delivery-worker.ts +88 -0
- package/template/apps/server/src/notification/drizzle-management.ts +180 -0
- package/template/apps/server/src/notification/drizzle-query.ts +160 -0
- package/template/apps/server/src/notification/drizzle-repository.integration.test.ts +301 -0
- package/template/apps/server/src/notification/drizzle-repository.ts +156 -90
- package/template/apps/server/src/notification/extension-routes.test.ts +119 -0
- package/template/apps/server/src/notification/extension-routes.ts +111 -0
- package/template/apps/server/src/notification/memory-delivery-repository.ts +137 -0
- package/template/apps/server/src/notification/memory-support.ts +72 -0
- package/template/apps/server/src/notification/preference-repository.ts +95 -0
- package/template/apps/server/src/notification/recipient-directory.ts +104 -0
- package/template/apps/server/src/notification/repository.test.ts +171 -0
- package/template/apps/server/src/notification/repository.ts +179 -32
- package/template/apps/server/src/notification/revision-routes.test.ts +186 -0
- package/template/apps/server/src/notification/route-support.ts +225 -0
- package/template/apps/server/src/notification/routes.test.ts +182 -0
- package/template/apps/server/src/notification/routes.ts +225 -132
- package/template/apps/server/src/notification/service.test.ts +104 -0
- package/template/apps/server/src/notification/service.ts +140 -0
- package/template/apps/server/src/notification/smtp-adapter.test.ts +65 -0
- package/template/apps/server/src/notification/smtp-adapter.ts +68 -0
- package/template/apps/server/src/persistence.integration.test.ts +41 -2
- package/template/apps/server/src/route-guards.ts +1 -0
- package/template/apps/server/src/runtime-audit-list.test.ts +39 -0
- package/template/apps/server/src/runtime-development.ts +2 -0
- package/template/apps/server/src/runtime.test.ts +23 -9
- package/template/apps/server/src/runtime.ts +39 -2
- package/template/apps/server/src/scheduler/audit.ts +2 -11
- package/template/apps/server/src/scheduler/definitions.test.ts +6 -0
- package/template/apps/server/src/scheduler/definitions.ts +7 -0
- package/template/apps/server/src/scheduler/recovery-service.ts +2 -11
- package/template/apps/server/src/scheduler/routes.ts +2 -7
- package/template/apps/server/src/search/opensearch-client.test.ts +45 -0
- package/template/apps/server/src/search/opensearch-client.ts +145 -0
- package/template/apps/server/src/search/service.ts +2 -6
- package/template/apps/server/src/settings/routes.ts +15 -3
- package/template/apps/server/src/settings/runtime.ts +10 -1
- package/template/apps/server/src/storage/runtime.ts +13 -0
- package/template/apps/server/src/system/audit-query.ts +33 -4
- package/template/apps/server/src/system/audit-routes.test.ts +58 -4
- package/template/apps/server/src/system/audit-routes.ts +6 -5
- package/template/apps/server/src/system/built-in-roles.ts +1 -0
- package/template/apps/server/src/system/department-organization.ts +320 -0
- package/template/apps/server/src/system/department-routes.test.ts +207 -48
- package/template/apps/server/src/system/department-routes.ts +114 -33
- package/template/apps/server/src/system/drizzle-repository.ts +15 -7
- package/template/apps/server/src/system/drizzle-scoped-repository.ts +5 -3
- package/template/apps/server/src/system/drizzle-system.ts +37 -9
- package/template/apps/server/src/system/drizzle-transaction-context.ts +14 -0
- package/template/apps/server/src/system/identity-route-config.ts +7 -2
- package/template/apps/server/src/system/mutation-runner.ts +23 -0
- package/template/apps/server/src/system/organization-postgres.integration.test.ts +176 -0
- package/template/apps/server/src/system/resource-access-response.ts +12 -6
- package/template/apps/server/src/system/role-department-scope-policy.ts +55 -0
- package/template/apps/server/src/system/route-helpers.ts +2 -5
- package/template/apps/server/src/system/route-types.ts +12 -3
- package/template/apps/server/src/system/routes-validation.test.ts +26 -0
- package/template/apps/server/src/system/routes.test.ts +10 -2
- package/template/apps/server/src/system/routes.ts +70 -36
- package/template/apps/server/src/system/seed.ts +7 -0
- package/template/apps/server/src/work-order/data-scope.integration.test.ts +9 -2
- package/template/apps/server/src/work-order/opensearch-index.test.ts +97 -0
- package/template/apps/server/src/work-order/opensearch-index.ts +313 -0
- package/template/apps/server/src/work-order/search-provider.ts +60 -1
- package/template/apps/server/src/work-order/service.ts +42 -10
- package/template/apps/web/src/app/error-pages.ts +9 -0
- package/template/apps/web/src/components/auth/PasswordChangeForm.vue +16 -11
- package/template/apps/web/src/components/auth/PasswordChangeForm.webtest.ts +14 -0
- package/template/apps/web/src/components/common/FormDialog.vue +16 -2
- package/template/apps/web/src/components/common/ModalLayout.webtest.ts +20 -1
- package/template/apps/web/src/composables/useGlobalSearch.ts +68 -0
- package/template/apps/web/src/composables/usePlatformSettings.ts +8 -7
- package/template/apps/web/src/layout/GlobalSearchResults.vue +58 -0
- package/template/apps/web/src/layout/NavigationSearchDialog.vue +42 -6
- package/template/apps/web/src/layout/NavigationSearchDialog.webtest.ts +71 -0
- package/template/apps/web/src/layout/NotificationMenu.vue +73 -31
- package/template/apps/web/src/layout/NotificationMenu.webtest.ts +44 -1
- package/template/apps/web/src/layout/NotificationMenuItem.vue +61 -0
- package/template/apps/web/src/layout/NotificationPreferencesDialog.vue +181 -0
- package/template/apps/web/src/layout/NotificationPreferencesDialog.webtest.ts +80 -0
- package/template/apps/web/src/lib/date-time.ts +22 -10
- package/template/apps/web/src/lib/date-time.webtest.ts +9 -1
- package/template/apps/web/src/main.ts +14 -1
- package/template/apps/web/src/pages/auth/ChangePasswordPage.vue +16 -1
- package/template/apps/web/src/pages/configuration/components/ModuleConfigVersionList.vue +1 -0
- package/template/apps/web/src/pages/configuration/components/ModuleConfigurationEditor.vue +10 -0
- package/template/apps/web/src/pages/configuration/components/ModuleConfigurationWorkbench.vue +37 -6
- package/template/apps/web/src/pages/errors/PlatformErrorPage.vue +115 -0
- package/template/apps/web/src/pages/errors/PlatformErrorPage.webtest.ts +44 -0
- package/template/apps/web/src/pages/errors/error-page-extension.ts +26 -0
- package/template/apps/web/src/pages/system/SystemNotificationsPage.vue +136 -68
- package/template/apps/web/src/pages/system/SystemNotificationsPage.webtest.ts +224 -12
- package/template/apps/web/src/pages/system/audit-log-presenter.ts +86 -0
- package/template/apps/web/src/pages/system/audit-time-range.ts +28 -0
- package/template/apps/web/src/pages/system/components/AuditActionCell.vue +10 -69
- package/template/apps/web/src/pages/system/components/AuditActionCell.webtest.ts +20 -27
- package/template/apps/web/src/pages/system/components/AuditLogDetailDialog.vue +134 -0
- package/template/apps/web/src/pages/system/components/AuditLogDetailDialog.webtest.ts +76 -0
- package/template/apps/web/src/pages/system/components/AuditLogFilters.vue +116 -52
- package/template/apps/web/src/pages/system/components/AuditLogFilters.webtest.ts +52 -15
- package/template/apps/web/src/pages/system/components/NotificationHistoryDialog.vue +129 -0
- package/template/apps/web/src/pages/system/components/NotificationManagementCard.vue +91 -0
- package/template/apps/web/src/pages/system/components/NotificationPublishDialog.vue +121 -0
- package/template/apps/web/src/pages/system/components/NotificationPublishForm.vue +162 -1
- package/template/apps/web/src/pages/system/components/SystemResourceActions.vue +68 -0
- package/template/apps/web/src/pages/system/components/SystemResourceEditor.vue +74 -0
- package/template/apps/web/src/pages/system/components/SystemResourceFilters.vue +3 -4
- package/template/apps/web/src/pages/system/components/SystemResourcePage.vue +91 -98
- package/template/apps/web/src/pages/system/components/SystemResourcePage.webtest.ts +68 -0
- package/template/apps/web/src/pages/system/components/SystemResourceTable.vue +20 -1
- package/template/apps/web/src/pages/system/components/SystemResourceTable.webtest.ts +28 -7
- package/template/apps/web/src/pages/system/components/department/DepartmentOrganizationForm.vue +210 -0
- package/template/apps/web/src/pages/system/components/department/DepartmentTransitionDialog.vue +112 -0
- package/template/apps/web/src/pages/system/components/user-account/UserAccountForm.vue +17 -4
- package/template/apps/web/src/pages/system/composables/useDepartmentTransitions.ts +79 -0
- package/template/apps/web/src/pages/system/composables/useNotificationPermissions.ts +14 -0
- package/template/apps/web/src/pages/system/composables/useSystemResource.ts +2 -0
- package/template/apps/web/src/pages/system/composables/useSystemResource.webtest.ts +15 -2
- package/template/apps/web/src/pages/system/resource-config.ts +12 -4
- package/template/apps/web/src/router/error-navigation.ts +50 -0
- package/template/apps/web/src/router/error-navigation.webtest.ts +106 -0
- package/template/apps/web/src/router/index.ts +71 -0
- package/template/apps/web/src/router/index.webtest.ts +29 -0
- package/template/apps/web/src/router/manifest-routes.webtest.ts +4 -0
- package/template/apps/web/src/router/shared-scaffold-neutrality.webtest.ts +12 -0
- package/template/apps/web/src/services/auth-api.ts +5 -0
- package/template/apps/web/src/services/http.ts +43 -6
- package/template/apps/web/src/services/http.webtest.ts +70 -0
- package/template/apps/web/src/services/notification-api.ts +85 -2
- package/template/apps/web/src/services/notification-api.webtest.ts +110 -0
- package/template/apps/web/src/services/search-api.ts +39 -0
- package/template/apps/web/src/services/system-api.ts +18 -0
- package/template/apps/web/vitest.config.ts +1 -0
- package/template/docker-compose.yml +68 -0
- package/template/docs/architecture/ai-egress.md +49 -7
- package/template/docs/architecture/ai-runtime.md +34 -6
- package/template/docs/architecture/data-scope-query-enforcement.md +4 -0
- package/template/docs/architecture/object-storage.md +22 -2
- package/template/docs/architecture/search-provider-protocol.md +38 -2
- package/template/docs/development/custom-error-pages.md +78 -0
- package/template/docs/development/custom-login-page.md +3 -3
- package/template/docs/platform/agent-runtime.md +76 -7
- package/template/docs/platform/audit-reliability.md +46 -2
- package/template/docs/platform/business-user-directory.md +82 -0
- package/template/docs/platform/module-configuration.md +13 -4
- package/template/docs/platform/notifications.md +67 -11
- package/template/docs/platform/organization-membership.md +17 -3
- package/template/docs/platform/system-crud-api.md +16 -0
- package/template/docs/platform/web-system-crud.md +6 -2
- package/template/package.json +4 -0
- package/template/packages/config/index.test.ts +45 -0
- package/template/packages/config/package.json +1 -1
- package/template/packages/config/src/platform.ts +169 -48
- package/template/packages/database/drizzle/0035_material_nightshade.sql +10 -0
- package/template/packages/database/drizzle/0036_hesitant_speed.sql +35 -0
- package/template/packages/database/drizzle/0037_absent_nick_fury.sql +2 -0
- package/template/packages/database/drizzle/0038_uneven_wasp.sql +38 -0
- package/template/packages/database/drizzle/meta/0035_snapshot.json +7331 -0
- package/template/packages/database/drizzle/meta/0036_snapshot.json +7436 -0
- package/template/packages/database/drizzle/meta/0037_snapshot.json +7457 -0
- package/template/packages/database/drizzle/meta/0038_snapshot.json +7749 -0
- package/template/packages/database/drizzle/meta/_journal.json +28 -0
- package/template/packages/database/package.json +1 -1
- package/template/packages/database/src/schema/identity.ts +7 -0
- package/template/packages/database/src/schema/notifications.ts +135 -0
- package/template/packages/database/src/schema-notification-delivery.test.ts +54 -0
- package/template/packages/database/src/schema-workflow-notification.test.ts +40 -1
- package/template/packages/modules/package.json +1 -1
- package/template/packages/modules/src/ai-operation-composition.test.ts +68 -0
- package/template/packages/modules/src/ai-operation-composition.ts +115 -0
- package/template/packages/modules/src/manifest.ts +26 -0
- package/template/packages/modules/src/provider-data-policy-composition.test.ts +74 -0
- package/template/packages/modules/src/system-api-permissions.ts +54 -0
- package/template/packages/modules/src/system-audit-actions.ts +15 -0
- package/template/packages/modules/src/system-features.ts +6 -1
- package/template/packages/modules/src/system-module-catalog.test.ts +16 -0
- package/template/packages/modules/src/system-module-catalog.ts +28 -4
- package/template/packages/modules/src/system-modules.test.ts +13 -1
- package/template/packages/modules/src/system-modules.ts +12 -0
- package/template/packages/modules/src/system-permissions.ts +11 -5
- package/template/packages/server-sdk/index.ts +11 -0
- package/template/packages/server-sdk/package.json +3 -2
- package/template/packages/server-sdk/src/ai-operation-registration.ts +2 -1
- package/template/packages/server-sdk/src/module-host.ts +8 -0
- package/template/packages/server-sdk/src/request-context.ts +2 -0
- package/template/packages/server-sdk/src/storage-port.ts +66 -0
- package/template/packages/server-sdk/src/tool-registration.ts +6 -0
- package/template/packages/server-sdk/src/user-directory-port.ts +42 -0
- package/template/packages/shared/package.json +1 -1
- package/template/packages/shared/src/audit.ts +25 -0
- package/template/packages/shared/src/module-configuration.ts +5 -0
- package/template/packages/shared/src/notification.ts +92 -1
- package/template/packages/shared/src/password.ts +7 -2
- package/template/packages/shared/src/platform-settings.ts +2 -0
- package/template/packages/storage/package.json +1 -1
- package/template/packages/storage/src/upload-service.test.ts +16 -0
- package/template/packages/storage/src/upload-service.ts +5 -1
- package/template/scripts/notification-postgres-regression.ts +27 -0
|
@@ -246,6 +246,34 @@
|
|
|
246
246
|
"when": 1784976420447,
|
|
247
247
|
"tag": "0034_funny_mesmero",
|
|
248
248
|
"breakpoints": true
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
"idx": 35,
|
|
252
|
+
"version": "7",
|
|
253
|
+
"when": 1785008351360,
|
|
254
|
+
"tag": "0035_material_nightshade",
|
|
255
|
+
"breakpoints": true
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
"idx": 36,
|
|
259
|
+
"version": "7",
|
|
260
|
+
"when": 1785009127636,
|
|
261
|
+
"tag": "0036_hesitant_speed",
|
|
262
|
+
"breakpoints": true
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
"idx": 37,
|
|
266
|
+
"version": "7",
|
|
267
|
+
"when": 1785012884328,
|
|
268
|
+
"tag": "0037_absent_nick_fury",
|
|
269
|
+
"breakpoints": true
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"idx": 38,
|
|
273
|
+
"version": "7",
|
|
274
|
+
"when": 1785013875842,
|
|
275
|
+
"tag": "0038_uneven_wasp",
|
|
276
|
+
"breakpoints": true
|
|
249
277
|
}
|
|
250
278
|
]
|
|
251
279
|
}
|
|
@@ -27,7 +27,14 @@ export const departments = pgTable(
|
|
|
27
27
|
},
|
|
28
28
|
(table) => [
|
|
29
29
|
uniqueIndex("uk_departments_code").on(table.code),
|
|
30
|
+
uniqueIndex("uk_departments_single_root")
|
|
31
|
+
.on(sql`((1))`)
|
|
32
|
+
.where(sql`${table.parentId} is null and ${table.deletedAt} is null`),
|
|
30
33
|
index("idx_departments_parent").on(table.parentId),
|
|
34
|
+
check(
|
|
35
|
+
"departments_parent_not_self",
|
|
36
|
+
sql`${table.parentId} is null or ${table.parentId} <> ${table.id}`,
|
|
37
|
+
),
|
|
31
38
|
],
|
|
32
39
|
);
|
|
33
40
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
boolean,
|
|
2
3
|
index,
|
|
4
|
+
integer,
|
|
3
5
|
pgTable,
|
|
4
6
|
primaryKey,
|
|
5
7
|
text,
|
|
@@ -9,6 +11,10 @@ import {
|
|
|
9
11
|
varchar,
|
|
10
12
|
} from "drizzle-orm/pg-core";
|
|
11
13
|
import type { TargetRef } from "@southwind-ai/shared";
|
|
14
|
+
import type {
|
|
15
|
+
ExternalNotificationChannel,
|
|
16
|
+
NotificationDeliveryStatus,
|
|
17
|
+
} from "@southwind-ai/shared";
|
|
12
18
|
import { auditColumns, idColumn, statusColumn } from "./common.js";
|
|
13
19
|
import { users } from "./identity.js";
|
|
14
20
|
|
|
@@ -22,15 +28,32 @@ export const platformNotifications = pgTable(
|
|
|
22
28
|
category: varchar("category", { length: 40 }).notNull(),
|
|
23
29
|
status: statusColumn().notNull(),
|
|
24
30
|
publishedAt: timestamp("published_at", { withTimezone: true }).notNull(),
|
|
31
|
+
scheduledFor: timestamp("scheduled_for", { withTimezone: true }),
|
|
25
32
|
archivedAt: timestamp("archived_at", { withTimezone: true }),
|
|
26
33
|
archivedBy: varchar("archived_by", { length: 64 }),
|
|
27
34
|
target: jsonb("target").$type<TargetRef>(),
|
|
28
35
|
recipientUserId: varchar("recipient_user_id", { length: 64 }),
|
|
36
|
+
recipientUserIds: jsonb("recipient_user_ids")
|
|
37
|
+
.$type<string[]>()
|
|
38
|
+
.notNull()
|
|
39
|
+
.default([]),
|
|
29
40
|
recipientRoleCodes: jsonb("recipient_role_codes")
|
|
30
41
|
.$type<string[]>()
|
|
31
42
|
.notNull()
|
|
32
43
|
.default([]),
|
|
44
|
+
recipientDepartmentIds: jsonb("recipient_department_ids")
|
|
45
|
+
.$type<string[]>()
|
|
46
|
+
.notNull()
|
|
47
|
+
.default([]),
|
|
48
|
+
includeChildDepartments: boolean("include_child_departments")
|
|
49
|
+
.notNull()
|
|
50
|
+
.default(false),
|
|
51
|
+
deliveryChannels: jsonb("delivery_channels")
|
|
52
|
+
.$type<ExternalNotificationChannel[]>()
|
|
53
|
+
.notNull()
|
|
54
|
+
.default([]),
|
|
33
55
|
sourceKey: varchar("source_key", { length: 180 }),
|
|
56
|
+
revision: integer("revision").notNull().default(1),
|
|
34
57
|
...auditColumns,
|
|
35
58
|
},
|
|
36
59
|
(table) => [
|
|
@@ -42,6 +65,96 @@ export const platformNotifications = pgTable(
|
|
|
42
65
|
],
|
|
43
66
|
);
|
|
44
67
|
|
|
68
|
+
export const notificationPreferences = pgTable("notification_preferences", {
|
|
69
|
+
userId: varchar("user_id", { length: 64 })
|
|
70
|
+
.primaryKey()
|
|
71
|
+
.references(() => users.id, { onDelete: "restrict" }),
|
|
72
|
+
enabledChannels: jsonb("enabled_channels")
|
|
73
|
+
.$type<ExternalNotificationChannel[]>()
|
|
74
|
+
.notNull()
|
|
75
|
+
.default([]),
|
|
76
|
+
disabledCategories: jsonb("disabled_categories")
|
|
77
|
+
.$type<string[]>()
|
|
78
|
+
.notNull()
|
|
79
|
+
.default([]),
|
|
80
|
+
updatedAt: timestamp("updated_at", { withTimezone: true })
|
|
81
|
+
.notNull()
|
|
82
|
+
.defaultNow(),
|
|
83
|
+
updatedBy: varchar("updated_by", { length: 64 }).notNull(),
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
export const notificationDeliveryOutbox = pgTable(
|
|
87
|
+
"notification_delivery_outbox",
|
|
88
|
+
{
|
|
89
|
+
id: idColumn().primaryKey(),
|
|
90
|
+
notificationId: varchar("notification_id", { length: 64 })
|
|
91
|
+
.notNull()
|
|
92
|
+
.references(() => platformNotifications.id, { onDelete: "restrict" }),
|
|
93
|
+
userId: varchar("user_id", { length: 64 })
|
|
94
|
+
.notNull()
|
|
95
|
+
.references(() => users.id, { onDelete: "restrict" }),
|
|
96
|
+
channel: varchar("channel", { length: 16 })
|
|
97
|
+
.$type<ExternalNotificationChannel>()
|
|
98
|
+
.notNull(),
|
|
99
|
+
status: varchar("status", { length: 16 })
|
|
100
|
+
.$type<NotificationDeliveryStatus>()
|
|
101
|
+
.notNull(),
|
|
102
|
+
subject: varchar("subject", { length: 120 }).notNull(),
|
|
103
|
+
content: text("content").notNull(),
|
|
104
|
+
attemptCount: integer("attempt_count").notNull().default(0),
|
|
105
|
+
nextAttemptAt: timestamp("next_attempt_at", { withTimezone: true })
|
|
106
|
+
.notNull()
|
|
107
|
+
.defaultNow(),
|
|
108
|
+
leaseToken: varchar("lease_token", { length: 64 }),
|
|
109
|
+
leaseExpiresAt: timestamp("lease_expires_at", { withTimezone: true }),
|
|
110
|
+
deliveredAt: timestamp("delivered_at", { withTimezone: true }),
|
|
111
|
+
providerMessageId: varchar("provider_message_id", { length: 180 }),
|
|
112
|
+
lastErrorCode: varchar("last_error_code", { length: 64 }),
|
|
113
|
+
createdAt: timestamp("created_at", { withTimezone: true })
|
|
114
|
+
.notNull()
|
|
115
|
+
.defaultNow(),
|
|
116
|
+
updatedAt: timestamp("updated_at", { withTimezone: true })
|
|
117
|
+
.notNull()
|
|
118
|
+
.defaultNow(),
|
|
119
|
+
},
|
|
120
|
+
(table) => [
|
|
121
|
+
uniqueIndex("uk_notification_delivery_target").on(
|
|
122
|
+
table.notificationId,
|
|
123
|
+
table.userId,
|
|
124
|
+
table.channel,
|
|
125
|
+
),
|
|
126
|
+
index("idx_notification_delivery_claim").on(
|
|
127
|
+
table.status,
|
|
128
|
+
table.nextAttemptAt,
|
|
129
|
+
table.leaseExpiresAt,
|
|
130
|
+
),
|
|
131
|
+
index("idx_notification_delivery_notification").on(table.notificationId),
|
|
132
|
+
],
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
export const notificationRevisions = pgTable(
|
|
136
|
+
"notification_revisions",
|
|
137
|
+
{
|
|
138
|
+
notificationId: varchar("notification_id", { length: 64 })
|
|
139
|
+
.notNull()
|
|
140
|
+
.references(() => platformNotifications.id, { onDelete: "restrict" }),
|
|
141
|
+
revision: integer("revision").notNull(),
|
|
142
|
+
title: varchar("title", { length: 120 }).notNull(),
|
|
143
|
+
summary: varchar("summary", { length: 240 }).notNull(),
|
|
144
|
+
content: text("content").notNull(),
|
|
145
|
+
category: varchar("category", { length: 40 }).notNull(),
|
|
146
|
+
editedAt: timestamp("edited_at", { withTimezone: true }).notNull(),
|
|
147
|
+
editedBy: varchar("edited_by", { length: 64 }).notNull(),
|
|
148
|
+
},
|
|
149
|
+
(table) => [
|
|
150
|
+
primaryKey({ columns: [table.notificationId, table.revision] }),
|
|
151
|
+
index("idx_notification_revisions_time").on(
|
|
152
|
+
table.notificationId,
|
|
153
|
+
table.editedAt,
|
|
154
|
+
),
|
|
155
|
+
],
|
|
156
|
+
);
|
|
157
|
+
|
|
45
158
|
export const notificationReads = pgTable(
|
|
46
159
|
"notification_reads",
|
|
47
160
|
{
|
|
@@ -58,3 +171,25 @@ export const notificationReads = pgTable(
|
|
|
58
171
|
index("idx_notification_reads_user").on(table.userId, table.readAt),
|
|
59
172
|
],
|
|
60
173
|
);
|
|
174
|
+
|
|
175
|
+
export const notificationFavorites = pgTable(
|
|
176
|
+
"notification_favorites",
|
|
177
|
+
{
|
|
178
|
+
notificationId: varchar("notification_id", { length: 64 })
|
|
179
|
+
.notNull()
|
|
180
|
+
.references(() => platformNotifications.id, { onDelete: "restrict" }),
|
|
181
|
+
userId: varchar("user_id", { length: 64 })
|
|
182
|
+
.notNull()
|
|
183
|
+
.references(() => users.id, { onDelete: "restrict" }),
|
|
184
|
+
favoritedAt: timestamp("favorited_at", { withTimezone: true })
|
|
185
|
+
.notNull()
|
|
186
|
+
.defaultNow(),
|
|
187
|
+
},
|
|
188
|
+
(table) => [
|
|
189
|
+
primaryKey({ columns: [table.notificationId, table.userId] }),
|
|
190
|
+
index("idx_notification_favorites_user").on(
|
|
191
|
+
table.userId,
|
|
192
|
+
table.favoritedAt,
|
|
193
|
+
),
|
|
194
|
+
],
|
|
195
|
+
);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { getTableConfig } from "drizzle-orm/pg-core";
|
|
3
|
+
import {
|
|
4
|
+
notificationDeliveryOutbox,
|
|
5
|
+
notificationPreferences,
|
|
6
|
+
platformNotifications,
|
|
7
|
+
} from "./schema/index.js";
|
|
8
|
+
|
|
9
|
+
describe("通知策略与投递 schema", () => {
|
|
10
|
+
test("定时、多受众、偏好与 outbox 使用可迁移的 PostgreSQL 结构", async () => {
|
|
11
|
+
expect(platformNotifications.scheduledFor).toBeDefined();
|
|
12
|
+
expect(platformNotifications.recipientUserIds.notNull).toBe(true);
|
|
13
|
+
expect(platformNotifications.recipientDepartmentIds.notNull).toBe(true);
|
|
14
|
+
expect(platformNotifications.includeChildDepartments.notNull).toBe(true);
|
|
15
|
+
expect(platformNotifications.deliveryChannels.notNull).toBe(true);
|
|
16
|
+
|
|
17
|
+
expect(getTableConfig(notificationPreferences).name).toBe(
|
|
18
|
+
"notification_preferences",
|
|
19
|
+
);
|
|
20
|
+
expect(notificationPreferences.userId.primary).toBe(true);
|
|
21
|
+
expect(notificationPreferences.enabledChannels.notNull).toBe(true);
|
|
22
|
+
expect(notificationPreferences.disabledCategories.notNull).toBe(true);
|
|
23
|
+
|
|
24
|
+
const outbox = getTableConfig(notificationDeliveryOutbox);
|
|
25
|
+
expect(outbox.name).toBe("notification_delivery_outbox");
|
|
26
|
+
expect(
|
|
27
|
+
outbox.indexes.some(
|
|
28
|
+
({ config }) => config.name === "uk_notification_delivery_target",
|
|
29
|
+
),
|
|
30
|
+
).toBe(true);
|
|
31
|
+
expect(
|
|
32
|
+
outbox.indexes.some(
|
|
33
|
+
({ config }) => config.name === "idx_notification_delivery_claim",
|
|
34
|
+
),
|
|
35
|
+
).toBe(true);
|
|
36
|
+
expect(
|
|
37
|
+
outbox.foreignKeys.every(
|
|
38
|
+
(foreignKey) => foreignKey.onDelete === "restrict",
|
|
39
|
+
),
|
|
40
|
+
).toBe(true);
|
|
41
|
+
|
|
42
|
+
const migration = await Bun.file(
|
|
43
|
+
new URL("../drizzle/0038_uneven_wasp.sql", import.meta.url),
|
|
44
|
+
).text();
|
|
45
|
+
expect(migration).toContain('CREATE TABLE "notification_preferences"');
|
|
46
|
+
expect(migration).toContain('CREATE TABLE "notification_delivery_outbox"');
|
|
47
|
+
expect(migration).toContain(
|
|
48
|
+
'ALTER TABLE "platform_notifications" ADD COLUMN "scheduled_for"',
|
|
49
|
+
);
|
|
50
|
+
expect(migration).toContain(
|
|
51
|
+
'CREATE INDEX "idx_notification_delivery_claim"',
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import { getTableConfig } from "drizzle-orm/pg-core";
|
|
3
3
|
import {
|
|
4
|
+
notificationFavorites,
|
|
4
5
|
notificationReads,
|
|
6
|
+
notificationRevisions,
|
|
5
7
|
platformNotifications,
|
|
6
8
|
workflowTransitions,
|
|
7
9
|
workflowWorkItems,
|
|
@@ -30,7 +32,7 @@ describe("审批与通知 schema", () => {
|
|
|
30
32
|
);
|
|
31
33
|
});
|
|
32
34
|
|
|
33
|
-
test("
|
|
35
|
+
test("站内通知持久化发布状态、受众、已读与独立收藏回执", async () => {
|
|
34
36
|
expect(getTableConfig(platformNotifications).name).toBe(
|
|
35
37
|
"platform_notifications",
|
|
36
38
|
);
|
|
@@ -52,6 +54,21 @@ describe("审批与通知 schema", () => {
|
|
|
52
54
|
(foreignKey) => foreignKey.onDelete === "restrict",
|
|
53
55
|
),
|
|
54
56
|
).toBe(true);
|
|
57
|
+
expect(getTableConfig(notificationFavorites).name).toBe(
|
|
58
|
+
"notification_favorites",
|
|
59
|
+
);
|
|
60
|
+
expect(getTableConfig(notificationFavorites).primaryKeys).toHaveLength(1);
|
|
61
|
+
expect(notificationFavorites.favoritedAt.notNull).toBe(true);
|
|
62
|
+
expect(
|
|
63
|
+
getTableConfig(notificationFavorites).foreignKeys.every(
|
|
64
|
+
(foreignKey) => foreignKey.onDelete === "restrict",
|
|
65
|
+
),
|
|
66
|
+
).toBe(true);
|
|
67
|
+
expect(getTableConfig(notificationRevisions).name).toBe(
|
|
68
|
+
"notification_revisions",
|
|
69
|
+
);
|
|
70
|
+
expect(getTableConfig(notificationRevisions).primaryKeys).toHaveLength(1);
|
|
71
|
+
expect(platformNotifications.revision.notNull).toBe(true);
|
|
55
72
|
const migration = await Bun.file(
|
|
56
73
|
new URL("../drizzle/0027_tiny_diamondback.sql", import.meta.url),
|
|
57
74
|
).text();
|
|
@@ -59,5 +76,27 @@ describe("审批与通知 schema", () => {
|
|
|
59
76
|
expect(migration).toContain(
|
|
60
77
|
'CREATE UNIQUE INDEX "uk_platform_notifications_source_key"',
|
|
61
78
|
);
|
|
79
|
+
const favoritesMigration = await Bun.file(
|
|
80
|
+
new URL("../drizzle/0035_material_nightshade.sql", import.meta.url),
|
|
81
|
+
).text();
|
|
82
|
+
expect(favoritesMigration).toContain(
|
|
83
|
+
'CREATE TABLE "notification_favorites"',
|
|
84
|
+
);
|
|
85
|
+
expect(favoritesMigration).toContain(
|
|
86
|
+
'PRIMARY KEY("notification_id","user_id")',
|
|
87
|
+
);
|
|
88
|
+
expect(favoritesMigration).toContain("ON DELETE restrict");
|
|
89
|
+
const revisionsMigration = await Bun.file(
|
|
90
|
+
new URL("../drizzle/0036_hesitant_speed.sql", import.meta.url),
|
|
91
|
+
).text();
|
|
92
|
+
expect(revisionsMigration).toContain(
|
|
93
|
+
'CREATE TABLE "notification_revisions"',
|
|
94
|
+
);
|
|
95
|
+
expect(revisionsMigration).toContain(
|
|
96
|
+
'ALTER TABLE "platform_notifications" ADD COLUMN "revision"',
|
|
97
|
+
);
|
|
98
|
+
expect(revisionsMigration).toContain(
|
|
99
|
+
'INSERT INTO "notification_revisions"',
|
|
100
|
+
);
|
|
62
101
|
});
|
|
63
102
|
});
|
|
@@ -112,6 +112,7 @@ describe("AI Operation Composition", () => {
|
|
|
112
112
|
mode: "configured-endpoint",
|
|
113
113
|
deploymentKey: "ai.openai-compatible",
|
|
114
114
|
},
|
|
115
|
+
providerDataPolicy: providerDataPolicy(),
|
|
115
116
|
toolNetworkPolicy: { mode: "forbidden" },
|
|
116
117
|
},
|
|
117
118
|
];
|
|
@@ -133,6 +134,7 @@ describe("AI Operation Composition", () => {
|
|
|
133
134
|
mode: "configured-endpoint",
|
|
134
135
|
deploymentKey: " ",
|
|
135
136
|
},
|
|
137
|
+
providerDataPolicy: providerDataPolicy(),
|
|
136
138
|
},
|
|
137
139
|
];
|
|
138
140
|
expect(() => validateModuleComposition([module])).toThrow(
|
|
@@ -148,6 +150,48 @@ describe("AI Operation Composition", () => {
|
|
|
148
150
|
);
|
|
149
151
|
});
|
|
150
152
|
|
|
153
|
+
test("Provider 字段策略必须完整、唯一且与出网授权绑定", () => {
|
|
154
|
+
const module = fixture("business");
|
|
155
|
+
module.aiOperations = [
|
|
156
|
+
{
|
|
157
|
+
...operation("business.generate"),
|
|
158
|
+
providerEgress: {
|
|
159
|
+
mode: "configured-endpoint",
|
|
160
|
+
deploymentKey: "ai.openai-compatible",
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
];
|
|
164
|
+
expect(() => validateModuleComposition([module])).toThrow(
|
|
165
|
+
"字段发送 allowlist 缺失",
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
module.aiOperations[0] = {
|
|
169
|
+
...module.aiOperations[0],
|
|
170
|
+
providerDataPolicy: {
|
|
171
|
+
...providerDataPolicy(),
|
|
172
|
+
envelopeFields: [
|
|
173
|
+
...providerDataPolicy().envelopeFields,
|
|
174
|
+
{
|
|
175
|
+
field: "instructions",
|
|
176
|
+
classification: "internal",
|
|
177
|
+
dlpAction: "reject",
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
expect(() => validateModuleComposition([module])).toThrow(
|
|
183
|
+
"字段发送规则重复",
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
module.aiOperations[0] = {
|
|
187
|
+
...operation("business.generate"),
|
|
188
|
+
providerDataPolicy: providerDataPolicy(),
|
|
189
|
+
};
|
|
190
|
+
expect(() => validateModuleComposition([module])).toThrow(
|
|
191
|
+
"禁止 Provider 出网时不能声明字段发送策略",
|
|
192
|
+
);
|
|
193
|
+
});
|
|
194
|
+
|
|
151
195
|
test("Operation Handler 必须与 Manifest 声明一一对应", () => {
|
|
152
196
|
const module = fixture("business");
|
|
153
197
|
module.aiOperations = [operation("business.generate")];
|
|
@@ -190,6 +234,30 @@ function operation(
|
|
|
190
234
|
};
|
|
191
235
|
}
|
|
192
236
|
|
|
237
|
+
function providerDataPolicy() {
|
|
238
|
+
return {
|
|
239
|
+
inputFields: [
|
|
240
|
+
{
|
|
241
|
+
jsonPointer: "/question",
|
|
242
|
+
classification: "internal" as const,
|
|
243
|
+
dlpAction: "redact" as const,
|
|
244
|
+
},
|
|
245
|
+
],
|
|
246
|
+
envelopeFields: [
|
|
247
|
+
{
|
|
248
|
+
field: "instructions" as const,
|
|
249
|
+
classification: "internal" as const,
|
|
250
|
+
dlpAction: "reject" as const,
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
field: "user-prompt" as const,
|
|
254
|
+
classification: "internal" as const,
|
|
255
|
+
dlpAction: "redact" as const,
|
|
256
|
+
},
|
|
257
|
+
],
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
193
261
|
function fixture(name: string): ModuleManifest {
|
|
194
262
|
const permissionKey = `${name}.ai.execute`;
|
|
195
263
|
const featureKey = `${name}.ai`;
|
|
@@ -102,9 +102,124 @@ function validateOperation(
|
|
|
102
102
|
validateCapabilities(operation);
|
|
103
103
|
validateTools(operation, catalogs.tools);
|
|
104
104
|
validateAiNetworkPolicy(operation);
|
|
105
|
+
validateProviderDataPolicy(operation);
|
|
105
106
|
validateLimits(operation);
|
|
106
107
|
}
|
|
107
108
|
|
|
109
|
+
const providerDataFields = new Set([
|
|
110
|
+
"instructions",
|
|
111
|
+
"user-prompt",
|
|
112
|
+
"tool-definitions",
|
|
113
|
+
"provider-output",
|
|
114
|
+
"tool-results",
|
|
115
|
+
]);
|
|
116
|
+
|
|
117
|
+
export function validateProviderDataPolicy(
|
|
118
|
+
operation: ModuleAiOperationDefinition,
|
|
119
|
+
): void {
|
|
120
|
+
const policy = operation.providerDataPolicy;
|
|
121
|
+
if (operation.providerEgress?.mode !== "configured-endpoint") {
|
|
122
|
+
if (policy) {
|
|
123
|
+
throw new Error(
|
|
124
|
+
`${operation.key} 禁止 Provider 出网时不能声明字段发送策略`,
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (!policy?.inputFields.length || !policy.envelopeFields.length) {
|
|
130
|
+
throw new Error(`${operation.key} Provider 字段发送 allowlist 缺失`);
|
|
131
|
+
}
|
|
132
|
+
validateInputFields(operation.key, policy.inputFields);
|
|
133
|
+
const fields = new Set<string>();
|
|
134
|
+
for (const rule of policy.envelopeFields) {
|
|
135
|
+
if (!providerDataFields.has(rule.field)) {
|
|
136
|
+
throw new Error(
|
|
137
|
+
`${operation.key} Provider 字段发送 allowlist 含未知字段`,
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
if (fields.has(rule.field)) {
|
|
141
|
+
throw new Error(
|
|
142
|
+
`${operation.key} Provider 字段发送规则重复:${rule.field}`,
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
fields.add(rule.field);
|
|
146
|
+
if (!["public", "internal", "sensitive"].includes(rule.classification)) {
|
|
147
|
+
throw new Error(`${operation.key} Provider 字段分类无效:${rule.field}`);
|
|
148
|
+
}
|
|
149
|
+
if (!["reject", "redact"].includes(rule.dlpAction)) {
|
|
150
|
+
throw new Error(`${operation.key} Provider DLP 动作无效:${rule.field}`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
for (const field of ["instructions", "user-prompt"]) {
|
|
154
|
+
if (!fields.has(field)) {
|
|
155
|
+
throw new Error(
|
|
156
|
+
`${operation.key} Provider 字段发送 allowlist 缺少 ${field}`,
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (operation.allowedToolKeys.length) {
|
|
161
|
+
for (const field of [
|
|
162
|
+
"tool-definitions",
|
|
163
|
+
"provider-output",
|
|
164
|
+
"tool-results",
|
|
165
|
+
]) {
|
|
166
|
+
if (!fields.has(field)) {
|
|
167
|
+
throw new Error(
|
|
168
|
+
`${operation.key} 使用 Tool 时 Provider 字段发送 allowlist 缺少 ${field}`,
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function validateInputFields(
|
|
176
|
+
operationKey: string,
|
|
177
|
+
fields: NonNullable<
|
|
178
|
+
ModuleAiOperationDefinition["providerDataPolicy"]
|
|
179
|
+
>["inputFields"],
|
|
180
|
+
): void {
|
|
181
|
+
const pointers = new Set<string>();
|
|
182
|
+
for (const rule of fields) {
|
|
183
|
+
const segments = rule.jsonPointer
|
|
184
|
+
.slice(1)
|
|
185
|
+
.split("/")
|
|
186
|
+
.map((segment) => segment.replaceAll("~1", "/").replaceAll("~0", "~"));
|
|
187
|
+
if (
|
|
188
|
+
!rule.jsonPointer.startsWith("/") ||
|
|
189
|
+
rule.jsonPointer === "/" ||
|
|
190
|
+
rule.jsonPointer.endsWith("/") ||
|
|
191
|
+
rule.jsonPointer.includes("//") ||
|
|
192
|
+
/~(?:[^01]|$)/u.test(rule.jsonPointer) ||
|
|
193
|
+
segments.some((segment) =>
|
|
194
|
+
["__proto__", "prototype", "constructor"].includes(segment),
|
|
195
|
+
)
|
|
196
|
+
) {
|
|
197
|
+
throw new Error(`${operationKey} Provider 输入字段 JSON Pointer 无效`);
|
|
198
|
+
}
|
|
199
|
+
if (
|
|
200
|
+
[...pointers].some(
|
|
201
|
+
(pointer) =>
|
|
202
|
+
pointer.startsWith(`${rule.jsonPointer}/`) ||
|
|
203
|
+
rule.jsonPointer.startsWith(`${pointer}/`),
|
|
204
|
+
)
|
|
205
|
+
) {
|
|
206
|
+
throw new Error(`${operationKey} Provider 输入字段规则不能父子重叠`);
|
|
207
|
+
}
|
|
208
|
+
if (pointers.has(rule.jsonPointer)) {
|
|
209
|
+
throw new Error(
|
|
210
|
+
`${operationKey} Provider 输入字段规则重复:${rule.jsonPointer}`,
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
pointers.add(rule.jsonPointer);
|
|
214
|
+
if (!["public", "internal", "sensitive"].includes(rule.classification)) {
|
|
215
|
+
throw new Error(`${operationKey} Provider 输入字段分类无效`);
|
|
216
|
+
}
|
|
217
|
+
if (!["reject", "redact"].includes(rule.dlpAction)) {
|
|
218
|
+
throw new Error(`${operationKey} Provider 输入字段 DLP 动作无效`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
108
223
|
function validateCapabilities(operation: ModuleAiOperationDefinition): void {
|
|
109
224
|
if (!operation.requiredCapabilities.length) {
|
|
110
225
|
throw new Error(`${operation.key} 至少需要一个 capability`);
|
|
@@ -98,6 +98,31 @@ export interface AiToolNetworkPolicy {
|
|
|
98
98
|
mode: "forbidden";
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
export type AiProviderDataField =
|
|
102
|
+
| "instructions"
|
|
103
|
+
| "user-prompt"
|
|
104
|
+
| "tool-definitions"
|
|
105
|
+
| "provider-output"
|
|
106
|
+
| "tool-results";
|
|
107
|
+
export type AiProviderDlpAction = "reject" | "redact";
|
|
108
|
+
|
|
109
|
+
export interface AiProviderFieldPolicy {
|
|
110
|
+
field: AiProviderDataField;
|
|
111
|
+
classification: AiOperationDataClassification;
|
|
112
|
+
dlpAction: AiProviderDlpAction;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface AiProviderInputFieldPolicy {
|
|
116
|
+
jsonPointer: string;
|
|
117
|
+
classification: AiOperationDataClassification;
|
|
118
|
+
dlpAction: AiProviderDlpAction;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface AiProviderDataPolicy {
|
|
122
|
+
inputFields: readonly AiProviderInputFieldPolicy[];
|
|
123
|
+
envelopeFields: readonly AiProviderFieldPolicy[];
|
|
124
|
+
}
|
|
125
|
+
|
|
101
126
|
export interface AiOperationLimits {
|
|
102
127
|
maxDurationSeconds: number;
|
|
103
128
|
maxInputBytes: number;
|
|
@@ -119,6 +144,7 @@ export interface ModuleAiOperationDefinition {
|
|
|
119
144
|
/** @deprecated 使用 providerEgress 与 toolNetworkPolicy 拆分两类网络边界。 */
|
|
120
145
|
publicNetworkAccess?: AiOperationPublicNetworkAccess;
|
|
121
146
|
providerEgress?: AiProviderEgressPolicy;
|
|
147
|
+
providerDataPolicy?: AiProviderDataPolicy;
|
|
122
148
|
toolNetworkPolicy?: AiToolNetworkPolicy;
|
|
123
149
|
limits: AiOperationLimits;
|
|
124
150
|
}
|