create-windy 0.3.2 → 0.3.5

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 (343) hide show
  1. package/README.md +27 -9
  2. package/dist/cli.js +825 -117
  3. package/package.json +1 -1
  4. package/template/.agents/skills/windy-business-module/SKILL.md +16 -3
  5. package/template/.windy-template.json +2 -2
  6. package/template/AGENTS.md +4 -0
  7. package/template/README.md +18 -11
  8. package/template/_gitignore +1 -0
  9. package/template/apps/agent-server/README.md +2 -0
  10. package/template/apps/agent-server/pyproject.toml +8 -0
  11. package/template/apps/agent-server/src/southwind_agent_server/adk_adapter.py +87 -10
  12. package/template/apps/agent-server/src/southwind_agent_server/adk_model.py +18 -3
  13. package/template/apps/agent-server/src/southwind_agent_server/adk_tools.py +78 -11
  14. package/template/apps/agent-server/src/southwind_agent_server/app.py +120 -115
  15. package/template/apps/agent-server/src/southwind_agent_server/artifact_input.py +153 -0
  16. package/template/apps/agent-server/src/southwind_agent_server/config.py +29 -0
  17. package/template/apps/agent-server/src/southwind_agent_server/contracts.py +81 -1
  18. package/template/apps/agent-server/src/southwind_agent_server/deterministic.py +8 -0
  19. package/template/apps/agent-server/src/southwind_agent_server/engine.py +28 -0
  20. package/template/apps/agent-server/src/southwind_agent_server/fingerprint.py +41 -0
  21. package/template/apps/agent-server/src/southwind_agent_server/http_helpers.py +62 -0
  22. package/template/apps/agent-server/src/southwind_agent_server/lease.py +15 -0
  23. package/template/apps/agent-server/src/southwind_agent_server/multimodal.py +76 -0
  24. package/template/apps/agent-server/src/southwind_agent_server/openai_engine.py +112 -20
  25. package/template/apps/agent-server/src/southwind_agent_server/openai_provider.py +14 -1
  26. package/template/apps/agent-server/src/southwind_agent_server/postgres_store.py +329 -0
  27. package/template/apps/agent-server/src/southwind_agent_server/postgres_store_backend.py +332 -0
  28. package/template/apps/agent-server/src/southwind_agent_server/provider_governance.py +64 -3
  29. package/template/apps/agent-server/src/southwind_agent_server/runtime_factory.py +68 -0
  30. package/template/apps/agent-server/src/southwind_agent_server/service.py +218 -56
  31. package/template/apps/agent-server/src/southwind_agent_server/signal_events.py +36 -0
  32. package/template/apps/agent-server/src/southwind_agent_server/sqlite_catalog.py +107 -0
  33. package/template/apps/agent-server/src/southwind_agent_server/sqlite_schema.py +65 -0
  34. package/template/apps/agent-server/src/southwind_agent_server/sqlite_serialization.py +16 -0
  35. package/template/apps/agent-server/src/southwind_agent_server/sqlite_store.py +89 -57
  36. package/template/apps/agent-server/src/southwind_agent_server/store.py +105 -2
  37. package/template/apps/agent-server/src/southwind_agent_server/store_cipher.py +40 -0
  38. package/template/apps/agent-server/src/southwind_agent_server/telemetry.py +89 -0
  39. package/template/apps/agent-server/src/southwind_agent_server/tool_host.py +72 -0
  40. package/template/apps/agent-server/tests/test_adk_adapter.py +6 -2
  41. package/template/apps/agent-server/tests/test_api.py +24 -1
  42. package/template/apps/agent-server/tests/test_artifact_input.py +110 -0
  43. package/template/apps/agent-server/tests/test_config.py +4 -0
  44. package/template/apps/agent-server/tests/test_fingerprint.py +10 -0
  45. package/template/apps/agent-server/tests/test_multimodal.py +51 -0
  46. package/template/apps/agent-server/tests/test_openai_provider.py +6 -2
  47. package/template/apps/agent-server/tests/test_postgres_store.py +131 -0
  48. package/template/apps/agent-server/tests/test_provider_governance.py +61 -0
  49. package/template/apps/agent-server/tests/test_sqlite_store.py +95 -10
  50. package/template/apps/agent-server/tests/test_telemetry.py +25 -0
  51. package/template/apps/agent-server/tests/test_tool_approval.py +28 -0
  52. package/template/apps/agent-server/uv.lock +165 -0
  53. package/template/apps/document-server/Dockerfile +19 -0
  54. package/template/apps/document-server/pyproject.toml +43 -0
  55. package/template/apps/document-server/src/southwind_document_server/__init__.py +1 -0
  56. package/template/apps/document-server/src/southwind_document_server/adapter.py +337 -0
  57. package/template/apps/document-server/src/southwind_document_server/app.py +151 -0
  58. package/template/apps/document-server/src/southwind_document_server/config.py +94 -0
  59. package/template/apps/document-server/src/southwind_document_server/contracts.py +103 -0
  60. package/template/apps/document-server/src/southwind_document_server/service.py +149 -0
  61. package/template/apps/document-server/src/southwind_document_server/store.py +185 -0
  62. package/template/apps/document-server/tests/__init__.py +1 -0
  63. package/template/apps/document-server/tests/test_config.py +42 -0
  64. package/template/apps/document-server/tests/test_service.py +140 -0
  65. package/template/apps/document-server/uv.lock +430 -0
  66. package/template/apps/embedding-server/Dockerfile +17 -0
  67. package/template/apps/embedding-server/pyproject.toml +44 -0
  68. package/template/apps/embedding-server/src/southwind_embedding_server/__init__.py +1 -0
  69. package/template/apps/embedding-server/src/southwind_embedding_server/adapter.py +254 -0
  70. package/template/apps/embedding-server/src/southwind_embedding_server/app.py +119 -0
  71. package/template/apps/embedding-server/src/southwind_embedding_server/config.py +120 -0
  72. package/template/apps/embedding-server/src/southwind_embedding_server/contracts.py +106 -0
  73. package/template/apps/embedding-server/src/southwind_embedding_server/error.py +6 -0
  74. package/template/apps/embedding-server/src/southwind_embedding_server/image_input.py +87 -0
  75. package/template/apps/embedding-server/tests/__init__.py +1 -0
  76. package/template/apps/embedding-server/tests/test_adapter.py +92 -0
  77. package/template/apps/embedding-server/tests/test_config.py +38 -0
  78. package/template/apps/embedding-server/uv.lock +449 -0
  79. package/template/apps/server/src/agent/background-operation-port.ts +37 -0
  80. package/template/apps/server/src/agent/background-operation.test.ts +231 -0
  81. package/template/apps/server/src/agent/background-operation.ts +252 -0
  82. package/template/apps/server/src/agent/drizzle-run-binding-repository.ts +114 -0
  83. package/template/apps/server/src/agent/execution-grants.ts +7 -1
  84. package/template/apps/server/src/agent/fake-runtime.test-support.ts +43 -0
  85. package/template/apps/server/src/agent/idempotency-key.test.ts +28 -0
  86. package/template/apps/server/src/agent/idempotency-key.ts +11 -0
  87. package/template/apps/server/src/agent/remote-runtime.test.ts +115 -1
  88. package/template/apps/server/src/agent/remote-runtime.ts +173 -5
  89. package/template/apps/server/src/agent/run-authorization.test-support.ts +9 -0
  90. package/template/apps/server/src/agent/run-authorization.test.ts +126 -0
  91. package/template/apps/server/src/agent/run-authorization.ts +180 -0
  92. package/template/apps/server/src/agent/run-binding-repository.ts +93 -0
  93. package/template/apps/server/src/agent/run-contracts.ts +88 -1
  94. package/template/apps/server/src/agent/run-definition-support.ts +58 -0
  95. package/template/apps/server/src/agent/run-errors.ts +25 -0
  96. package/template/apps/server/src/agent/run-facade.test.ts +57 -46
  97. package/template/apps/server/src/agent/run-facade.ts +185 -65
  98. package/template/apps/server/src/agent/run-release.ts +78 -0
  99. package/template/apps/server/src/agent/run-route-input.ts +169 -0
  100. package/template/apps/server/src/agent/run-routes.ts +63 -76
  101. package/template/apps/server/src/agent/runtime-bootstrap.ts +169 -13
  102. package/template/apps/server/src/agent/sandbox-client.ts +200 -0
  103. package/template/apps/server/src/agent/sandbox-protocol.ts +76 -0
  104. package/template/apps/server/src/agent/sandbox-registry.ts +205 -0
  105. package/template/apps/server/src/agent/sandbox-runtime.test.ts +137 -0
  106. package/template/apps/server/src/agent/sandbox-worker-server.ts +195 -0
  107. package/template/apps/server/src/agent/sandbox-worker.ts +12 -0
  108. package/template/apps/server/src/agent/tool-approval.test.ts +75 -0
  109. package/template/apps/server/src/agent/tool-approval.ts +115 -0
  110. package/template/apps/server/src/agent/tool-audit.ts +62 -0
  111. package/template/apps/server/src/agent/tool-host.test.ts +39 -11
  112. package/template/apps/server/src/agent/tool-host.ts +184 -17
  113. package/template/apps/server/src/agent/tool-registry.ts +52 -47
  114. package/template/apps/server/src/agent/vision-facade.test.ts +256 -0
  115. package/template/apps/server/src/agent/vision-input.ts +120 -0
  116. package/template/apps/server/src/ai-artifact/codec.test.ts +44 -0
  117. package/template/apps/server/src/ai-artifact/codec.ts +137 -0
  118. package/template/apps/server/src/ai-artifact/routes.ts +37 -0
  119. package/template/apps/server/src/ai-artifact/runtime.ts +205 -0
  120. package/template/apps/server/src/application-services.ts +62 -2
  121. package/template/apps/server/src/auth/reauthentication.test.ts +40 -0
  122. package/template/apps/server/src/auth/reauthentication.ts +19 -0
  123. package/template/apps/server/src/auth/runtime.ts +9 -1
  124. package/template/apps/server/src/data-access/context.ts +6 -4
  125. package/template/apps/server/src/data-access/scope-snapshot.ts +27 -0
  126. package/template/apps/server/src/data-governance/export/approval-port.ts +6 -3
  127. package/template/apps/server/src/data-governance/export/authorization-port.test.ts +23 -4
  128. package/template/apps/server/src/data-governance/export/authorization-port.ts +89 -25
  129. package/template/apps/server/src/data-governance/export/drizzle-repository.integration.test.ts +2 -0
  130. package/template/apps/server/src/data-governance/export/drizzle-repository.ts +1 -0
  131. package/template/apps/server/src/data-governance/export/job-runtime.test.ts +15 -4
  132. package/template/apps/server/src/data-governance/export/job-runtime.ts +68 -15
  133. package/template/apps/server/src/data-governance/export/ndjson-stream.ts +25 -6
  134. package/template/apps/server/src/data-governance/export/postgres-recovery.integration.test.ts +4 -2
  135. package/template/apps/server/src/data-governance/export/renderer-job-runtime.test.ts +235 -0
  136. package/template/apps/server/src/data-governance/export/renderer-runtime.ts +293 -0
  137. package/template/apps/server/src/data-governance/export/renderer-selection.test.ts +67 -0
  138. package/template/apps/server/src/data-governance/export/repository.test.ts +2 -0
  139. package/template/apps/server/src/data-governance/export/request-fingerprint.test.ts +13 -0
  140. package/template/apps/server/src/data-governance/export/request-fingerprint.ts +2 -0
  141. package/template/apps/server/src/data-governance/export/routes.ts +11 -1
  142. package/template/apps/server/src/data-governance/export/scope-snapshot.ts +6 -18
  143. package/template/apps/server/src/data-governance/export/service-support.ts +188 -0
  144. package/template/apps/server/src/data-governance/export/service.ts +90 -113
  145. package/template/apps/server/src/data-governance/export/source.ts +101 -0
  146. package/template/apps/server/src/data-governance/export/types.ts +27 -0
  147. package/template/apps/server/src/document/contracts.ts +76 -0
  148. package/template/apps/server/src/document/facade.ts +339 -0
  149. package/template/apps/server/src/document/remote-runtime.test.ts +96 -0
  150. package/template/apps/server/src/document/remote-runtime.ts +223 -0
  151. package/template/apps/server/src/document/routes.ts +193 -0
  152. package/template/apps/server/src/embedding/contracts.ts +83 -0
  153. package/template/apps/server/src/embedding/error.ts +10 -0
  154. package/template/apps/server/src/embedding/facade.ts +217 -0
  155. package/template/apps/server/src/embedding/input.ts +172 -0
  156. package/template/apps/server/src/embedding/remote-runtime.test.ts +66 -0
  157. package/template/apps/server/src/embedding/remote-runtime.ts +218 -0
  158. package/template/apps/server/src/embedding/routes.ts +152 -0
  159. package/template/apps/server/src/index.ts +40 -43
  160. package/template/apps/server/src/jobs/artifact-service.test.ts +14 -2
  161. package/template/apps/server/src/jobs/artifact-service.ts +10 -0
  162. package/template/apps/server/src/jobs/drizzle-execution-repository.ts +17 -18
  163. package/template/apps/server/src/jobs/drizzle-execution.integration.test.ts +19 -1
  164. package/template/apps/server/src/jobs/drizzle-mappers.ts +4 -1
  165. package/template/apps/server/src/jobs/drizzle-recovery-repository.ts +49 -2
  166. package/template/apps/server/src/jobs/drizzle-repository.ts +1 -0
  167. package/template/apps/server/src/jobs/execution-repository.ts +17 -0
  168. package/template/apps/server/src/jobs/execution.test.ts +34 -0
  169. package/template/apps/server/src/jobs/in-memory-control.ts +135 -0
  170. package/template/apps/server/src/jobs/in-memory-execution.ts +34 -65
  171. package/template/apps/server/src/jobs/legacy-service-runtime.ts +5 -2
  172. package/template/apps/server/src/jobs/repository.ts +3 -0
  173. package/template/apps/server/src/jobs/worker.ts +80 -41
  174. package/template/apps/server/src/module-host/ai-operation-port.ts +170 -0
  175. package/template/apps/server/src/module-host/durable-context.test.ts +312 -0
  176. package/template/apps/server/src/module-host/durable-context.ts +124 -0
  177. package/template/apps/server/src/module-host/durable-handler-registration.ts +72 -0
  178. package/template/apps/server/src/module-host/governed-export-route-support.ts +171 -0
  179. package/template/apps/server/src/module-host/governed-export-routes.test.ts +327 -0
  180. package/template/apps/server/src/module-host/governed-export-routes.ts +238 -0
  181. package/template/apps/server/src/module-host/governed-renderer-registration.test.ts +247 -0
  182. package/template/apps/server/src/module-host/governed-resource-routes.ts +331 -0
  183. package/template/apps/server/src/module-host/governed-resources.test.ts +344 -0
  184. package/template/apps/server/src/module-host/governed-resources.ts +203 -0
  185. package/template/apps/server/src/module-host/http-runtime.ts +95 -0
  186. package/template/apps/server/src/module-host/initialize-contracts.ts +14 -0
  187. package/template/apps/server/src/module-host/initialize.test.ts +49 -1
  188. package/template/apps/server/src/module-host/initialize.ts +39 -16
  189. package/template/apps/server/src/module-host/job-port.test.ts +262 -0
  190. package/template/apps/server/src/module-host/job-port.ts +334 -0
  191. package/template/apps/server/src/module-host/request-context.test.ts +88 -2
  192. package/template/apps/server/src/module-host/request-context.ts +56 -22
  193. package/template/apps/server/src/module-host/route-installer.test.ts +10 -0
  194. package/template/apps/server/src/module-host/route-installer.ts +36 -1
  195. package/template/apps/server/src/module-host/sandbox-tool-registration.ts +42 -0
  196. package/template/apps/server/src/module-host/tool-handlers.ts +67 -31
  197. package/template/apps/server/src/module-host.ts +1 -0
  198. package/template/apps/server/src/module-runtime-validation.ts +7 -3
  199. package/template/apps/server/src/speech/contracts.ts +76 -0
  200. package/template/apps/server/src/speech/facade.ts +316 -0
  201. package/template/apps/server/src/speech/remote-runtime.test.ts +88 -0
  202. package/template/apps/server/src/speech/remote-runtime.ts +227 -0
  203. package/template/apps/server/src/speech/routes.ts +180 -0
  204. package/template/apps/server/src/system/actor.ts +39 -0
  205. package/template/apps/server/src/system/route-helpers.ts +1 -0
  206. package/template/apps/server/src/workflow/service.ts +2 -1
  207. package/template/apps/speech-server/Dockerfile +22 -0
  208. package/template/apps/speech-server/pyproject.toml +43 -0
  209. package/template/apps/speech-server/src/southwind_speech_server/__init__.py +1 -0
  210. package/template/apps/speech-server/src/southwind_speech_server/adapter.py +249 -0
  211. package/template/apps/speech-server/src/southwind_speech_server/app.py +183 -0
  212. package/template/apps/speech-server/src/southwind_speech_server/config.py +100 -0
  213. package/template/apps/speech-server/src/southwind_speech_server/contracts.py +103 -0
  214. package/template/apps/speech-server/src/southwind_speech_server/errors.py +6 -0
  215. package/template/apps/speech-server/src/southwind_speech_server/normalizer.py +108 -0
  216. package/template/apps/speech-server/src/southwind_speech_server/output_validation.py +128 -0
  217. package/template/apps/speech-server/src/southwind_speech_server/service.py +162 -0
  218. package/template/apps/speech-server/src/southwind_speech_server/store.py +209 -0
  219. package/template/apps/speech-server/tests/__init__.py +1 -0
  220. package/template/apps/speech-server/tests/test_config.py +33 -0
  221. package/template/apps/speech-server/tests/test_service.py +154 -0
  222. package/template/apps/speech-server/uv.lock +430 -0
  223. package/template/apps/web/src/app/business-routes.ts +22 -0
  224. package/template/apps/web/src/components/common/AccessSnapshotBoundary.vue +112 -0
  225. package/template/apps/web/src/components/common/AccessSnapshotBoundary.webtest.ts +130 -0
  226. package/template/apps/web/src/components/common/AccessSnapshotNotice.vue +117 -0
  227. package/template/apps/web/src/components/common/FormDialog.vue +6 -0
  228. package/template/apps/web/src/components/common/ModalLayout.webtest.ts +13 -0
  229. package/template/apps/web/src/composables/access-snapshot-change.ts +131 -0
  230. package/template/apps/web/src/composables/access-snapshot-change.webtest.ts +103 -0
  231. package/template/apps/web/src/composables/useAccessSnapshot.ts +48 -2
  232. package/template/apps/web/src/composables/useAccessSnapshot.webtest.ts +54 -0
  233. package/template/apps/web/src/composables/useAccessSnapshotMonitor.ts +42 -0
  234. package/template/apps/web/src/layout/AppShell.vue +28 -25
  235. package/template/apps/web/src/layout/AppShell.webtest.ts +1 -0
  236. package/template/apps/web/src/router/business-routes.ts +68 -0
  237. package/template/apps/web/src/router/business-routes.webtest.ts +85 -0
  238. package/template/apps/web/src/router/index.ts +7 -0
  239. package/template/apps/web/src/router/shared-scaffold-neutrality.webtest.ts +12 -0
  240. package/template/apps/web/src/services/access-api.ts +5 -1
  241. package/template/apps/web/src/services/access-api.webtest.ts +35 -0
  242. package/template/docker-compose.yml +127 -0
  243. package/template/docs/architecture/ai-egress.md +12 -9
  244. package/template/docs/architecture/ai-runtime.md +23 -11
  245. package/template/docs/architecture/durable-jobs.md +25 -3
  246. package/template/docs/architecture/foundation-infrastructure.md +163 -0
  247. package/template/docs/architecture/module-host.md +115 -0
  248. package/template/docs/architecture/server-module-interface.md +39 -0
  249. package/template/docs/architecture/web-access-snapshot-resilience.md +60 -0
  250. package/template/docs/development/business-web-routes.md +66 -0
  251. package/template/docs/development/custom-login-page.md +3 -3
  252. package/template/docs/development/module-lifecycle.md +71 -0
  253. package/template/docs/operations/observability.md +5 -1
  254. package/template/docs/platform/agent-runtime.md +21 -11
  255. package/template/docs/platform/agent-tool-sandbox.md +58 -0
  256. package/template/docs/platform/agent-tools.md +5 -0
  257. package/template/docs/platform/document-ai-runtime.md +204 -0
  258. package/template/docs/platform/governed-export-renderers.md +132 -0
  259. package/template/docs/platform/navigation-registry.md +5 -0
  260. package/template/docs/platform/organization-membership.md +2 -1
  261. package/template/docs/platform/speech-ai-runtime.md +156 -0
  262. package/template/docs/platform/system-crud-api.md +7 -1
  263. package/template/docs/platform/vision-ai-runtime.md +97 -0
  264. package/template/docs/platform/web-system-crud.md +6 -0
  265. package/template/package.json +16 -2
  266. package/template/packages/ai-client/index.ts +4 -0
  267. package/template/packages/ai-client/package.json +5 -2
  268. package/template/packages/ai-client/src/agent/client/artifact.ts +26 -0
  269. package/template/packages/ai-client/src/agent/client/attach.test.ts +124 -0
  270. package/template/packages/ai-client/src/agent/client/client.ts +119 -7
  271. package/template/packages/ai-client/src/agent/client/run.ts +14 -0
  272. package/template/packages/ai-client/src/agent/client/types.ts +18 -0
  273. package/template/packages/ai-client/src/agent/client/vision.test.ts +53 -0
  274. package/template/packages/ai-client/src/agent/contracts/contracts.test.ts +1 -0
  275. package/template/packages/ai-client/src/agent/contracts/events.ts +33 -0
  276. package/template/packages/ai-client/src/agent/contracts/runs.ts +71 -0
  277. package/template/packages/ai-client/src/agent/index.ts +1 -0
  278. package/template/packages/ai-client/src/artifact-ref.ts +8 -0
  279. package/template/packages/ai-client/src/document/client.test.ts +114 -0
  280. package/template/packages/ai-client/src/document/client.ts +134 -0
  281. package/template/packages/ai-client/src/document/contracts.ts +152 -0
  282. package/template/packages/ai-client/src/document/error.ts +43 -0
  283. package/template/packages/ai-client/src/document/index.ts +3 -0
  284. package/template/packages/ai-client/src/document/run.ts +104 -0
  285. package/template/packages/ai-client/src/document/validation.ts +115 -0
  286. package/template/packages/ai-client/src/embedding/client.test.ts +77 -0
  287. package/template/packages/ai-client/src/embedding/client.ts +96 -0
  288. package/template/packages/ai-client/src/embedding/contracts.ts +46 -0
  289. package/template/packages/ai-client/src/embedding/error.ts +61 -0
  290. package/template/packages/ai-client/src/embedding/index.ts +3 -0
  291. package/template/packages/ai-client/src/embedding/validation.ts +117 -0
  292. package/template/packages/ai-client/src/speech/client.test.ts +135 -0
  293. package/template/packages/ai-client/src/speech/client.ts +104 -0
  294. package/template/packages/ai-client/src/speech/contracts.ts +129 -0
  295. package/template/packages/ai-client/src/speech/error.ts +43 -0
  296. package/template/packages/ai-client/src/speech/index.ts +3 -0
  297. package/template/packages/ai-client/src/speech/run.ts +133 -0
  298. package/template/packages/ai-client/src/speech/validation.ts +132 -0
  299. package/template/packages/config/package.json +2 -2
  300. package/template/packages/database/drizzle/0039_early_ezekiel_stane.sql +1 -0
  301. package/template/packages/database/drizzle/0040_colossal_baron_strucker.sql +63 -0
  302. package/template/packages/database/drizzle/0041_yummy_prowler.sql +21 -0
  303. package/template/packages/database/drizzle/0042_puzzling_rumiko_fujikawa.sql +27 -0
  304. package/template/packages/database/drizzle/meta/0039_snapshot.json +7755 -0
  305. package/template/packages/database/drizzle/meta/0040_snapshot.json +8150 -0
  306. package/template/packages/database/drizzle/meta/0041_snapshot.json +8323 -0
  307. package/template/packages/database/drizzle/meta/0042_snapshot.json +8541 -0
  308. package/template/packages/database/drizzle/meta/_journal.json +28 -0
  309. package/template/packages/database/package.json +2 -2
  310. package/template/packages/database/src/agent-runtime-schema.test.ts +54 -0
  311. package/template/packages/database/src/schema/agent-runtime.ts +149 -0
  312. package/template/packages/database/src/schema/common.ts +2 -14
  313. package/template/packages/database/src/schema/durable-jobs.ts +5 -0
  314. package/template/packages/database/src/schema/governed-exports.ts +17 -5
  315. package/template/packages/database/src/schema/index.ts +3 -0
  316. package/template/packages/database/src/schema-durable-recovery.test.ts +31 -0
  317. package/template/packages/database/src/schema-governed-exports.test.ts +21 -1
  318. package/template/packages/database/src/schema.test.ts +6 -23
  319. package/template/packages/jobs/package.json +3 -2
  320. package/template/packages/jobs/src/handlers.test.ts +13 -0
  321. package/template/packages/jobs/src/handlers.ts +7 -1
  322. package/template/packages/jobs/src/types.ts +4 -0
  323. package/template/packages/modules/package.json +2 -2
  324. package/template/packages/modules/src/ai-operation-composition.test-support.ts +165 -0
  325. package/template/packages/modules/src/ai-operation-composition.test.ts +91 -127
  326. package/template/packages/modules/src/ai-operation-composition.ts +59 -1
  327. package/template/packages/modules/src/manifest.ts +25 -1
  328. package/template/packages/modules/src/tool-composition.ts +18 -0
  329. package/template/packages/server-sdk/index.ts +50 -0
  330. package/template/packages/server-sdk/package.json +10 -4
  331. package/template/packages/server-sdk/src/ai-artifact-port.ts +34 -0
  332. package/template/packages/server-sdk/src/ai-operation-port.ts +65 -0
  333. package/template/packages/server-sdk/src/ai-operation-registration.ts +42 -1
  334. package/template/packages/server-sdk/src/background-ai-port.ts +43 -0
  335. package/template/packages/server-sdk/src/data-governance-registration.ts +116 -0
  336. package/template/packages/server-sdk/src/durable-handler.ts +29 -0
  337. package/template/packages/server-sdk/src/jobs-port.ts +69 -0
  338. package/template/packages/server-sdk/src/module-host.ts +16 -2
  339. package/template/packages/server-sdk/src/request-context.ts +6 -2
  340. package/template/packages/server-sdk/src/sandbox-tool.ts +21 -0
  341. package/template/packages/server-sdk/src/tool-registration.ts +2 -0
  342. package/template/packages/shared/package.json +1 -1
  343. package/template/packages/shared/src/rbac.ts +30 -0
@@ -1,22 +1,35 @@
1
1
  import { readonly, shallowReadonly, shallowRef } from "vue";
2
2
  import type { WebAccessSnapshot } from "@/layout/navigation";
3
3
  import { loadAccessSnapshot } from "@/services/access-api";
4
+ import { isApiErrorStatus } from "@/services/http";
5
+ import {
6
+ accessSnapshotIdentity,
7
+ describeAccessSnapshotChange,
8
+ type AccessSnapshotChange,
9
+ } from "./access-snapshot-change";
4
10
 
5
11
  const snapshot = shallowRef<WebAccessSnapshot>();
6
12
  const loading = shallowRef(false);
7
13
  const error = shallowRef("");
14
+ const failureReason = shallowRef<
15
+ "admin-access-revoked" | "snapshot-unavailable" | undefined
16
+ >();
17
+ const fingerprint = shallowRef("");
18
+ const version = shallowRef(0);
19
+ const change = shallowRef<AccessSnapshotChange>();
8
20
  let pending: Promise<WebAccessSnapshot> | undefined;
9
21
  let generation = 0;
22
+ let identity: ReturnType<typeof accessSnapshotIdentity> | undefined;
10
23
 
11
24
  async function load(force = false): Promise<WebAccessSnapshot> {
12
25
  if (pending) return pending;
13
26
  if (snapshot.value && !force) return snapshot.value;
14
27
  loading.value = true;
15
- error.value = "";
28
+ if (!snapshot.value) error.value = "";
16
29
  const requestGeneration = generation;
17
30
  const operation = loadAccessSnapshot()
18
31
  .then((result) => {
19
- if (requestGeneration === generation) snapshot.value = result;
32
+ if (requestGeneration === generation) acceptSnapshot(result);
20
33
  return result;
21
34
  })
22
35
  .catch((currentError: unknown) => {
@@ -25,6 +38,9 @@ async function load(force = false): Promise<WebAccessSnapshot> {
25
38
  currentError instanceof Error
26
39
  ? currentError.message
27
40
  : String(currentError);
41
+ failureReason.value = isApiErrorStatus(currentError, 403)
42
+ ? "admin-access-revoked"
43
+ : "snapshot-unavailable";
28
44
  }
29
45
  throw currentError;
30
46
  })
@@ -36,11 +52,34 @@ async function load(force = false): Promise<WebAccessSnapshot> {
36
52
  return operation;
37
53
  }
38
54
 
55
+ function acceptSnapshot(result: WebAccessSnapshot): void {
56
+ const nextIdentity = accessSnapshotIdentity(result);
57
+ const nextChange = identity
58
+ ? describeAccessSnapshotChange(identity, nextIdentity)
59
+ : undefined;
60
+ snapshot.value = result;
61
+ error.value = "";
62
+ failureReason.value = undefined;
63
+ fingerprint.value = nextIdentity.fingerprint;
64
+ if (nextChange) {
65
+ version.value += 1;
66
+ change.value = nextChange;
67
+ } else if (!identity) {
68
+ version.value = 1;
69
+ }
70
+ identity = nextIdentity;
71
+ }
72
+
39
73
  export function resetAccessSnapshot(): void {
40
74
  generation += 1;
41
75
  snapshot.value = undefined;
42
76
  loading.value = false;
43
77
  error.value = "";
78
+ failureReason.value = undefined;
79
+ fingerprint.value = "";
80
+ version.value = 0;
81
+ change.value = undefined;
82
+ identity = undefined;
44
83
  pending = undefined;
45
84
  }
46
85
 
@@ -49,7 +88,14 @@ export function useAccessSnapshot() {
49
88
  snapshot: shallowReadonly(snapshot),
50
89
  loading: readonly(loading),
51
90
  error: readonly(error),
91
+ failureReason: readonly(failureReason),
92
+ fingerprint: readonly(fingerprint),
93
+ version: readonly(version),
94
+ change: shallowReadonly(change),
52
95
  ensureLoaded: () => load(false),
53
96
  refresh: () => load(true),
97
+ acknowledgeChange: () => {
98
+ change.value = undefined;
99
+ },
54
100
  };
55
101
  }
@@ -36,4 +36,58 @@ describe("权限快照 single-flight", () => {
36
36
  expect(first).toEqual(snapshot);
37
37
  expect(second).toEqual(snapshot);
38
38
  });
39
+
40
+ test("运行中快照变化保留版本、指纹和能力收紧事实", async () => {
41
+ const initial = accessSnapshot(["system.user.read"]);
42
+ const reduced = accessSnapshot([]);
43
+ mocks.loadAccessSnapshot
44
+ .mockResolvedValueOnce(initial)
45
+ .mockResolvedValueOnce(reduced);
46
+ const access = useAccessSnapshot();
47
+
48
+ await access.ensureLoaded();
49
+ const initialFingerprint = access.fingerprint.value;
50
+ await access.refresh();
51
+
52
+ expect(access.version.value).toBe(2);
53
+ expect(access.fingerprint.value).not.toBe(initialFingerprint);
54
+ expect(access.change.value).toMatchObject({
55
+ kind: "reduced",
56
+ previousFingerprint: initialFingerprint,
57
+ currentFingerprint: access.fingerprint.value,
58
+ removedCapabilities: ["permission:system.user.read"],
59
+ });
60
+
61
+ access.acknowledgeChange();
62
+ expect(access.change.value).toBeUndefined();
63
+ });
64
+
65
+ test("刷新失败时保留旧快照并进入显式安全降级状态", async () => {
66
+ const initial = accessSnapshot(["system.user.read"]);
67
+ mocks.loadAccessSnapshot
68
+ .mockResolvedValueOnce(initial)
69
+ .mockRejectedValueOnce(new Error("network unavailable"));
70
+ const access = useAccessSnapshot();
71
+ await access.ensureLoaded();
72
+
73
+ await expect(access.refresh()).rejects.toThrow("network unavailable");
74
+
75
+ expect(access.snapshot.value).toEqual(initial);
76
+ expect(access.error.value).toBe("network unavailable");
77
+ });
39
78
  });
79
+
80
+ function accessSnapshot(permissionKeys: string[]) {
81
+ return {
82
+ actor: {
83
+ id: "user_1",
84
+ type: "user" as const,
85
+ name: "测试员",
86
+ roleCodes: ["member"],
87
+ permissionKeys,
88
+ },
89
+ menus: [],
90
+ permissions: [],
91
+ features: [],
92
+ };
93
+ }
@@ -0,0 +1,42 @@
1
+ import { onBeforeUnmount, onMounted } from "vue";
2
+ import { useAccessSnapshot } from "./useAccessSnapshot";
3
+
4
+ const refreshIntervalMilliseconds = 60_000;
5
+ const eventRefreshCooldownMilliseconds = 5_000;
6
+
7
+ export function useAccessSnapshotMonitor(): void {
8
+ const access = useAccessSnapshot();
9
+ let interval: ReturnType<typeof setInterval> | undefined;
10
+ let lastEventRefresh = 0;
11
+
12
+ function refresh(): void {
13
+ void access.refresh().catch(() => {
14
+ // 失败状态由权限快照统一边界展示,事件处理器不产生未处理拒绝。
15
+ });
16
+ }
17
+
18
+ function refreshAfterBrowserEvent(): void {
19
+ const now = Date.now();
20
+ if (now - lastEventRefresh < eventRefreshCooldownMilliseconds) return;
21
+ lastEventRefresh = now;
22
+ refresh();
23
+ }
24
+
25
+ function refreshWhenVisible(): void {
26
+ if (document.visibilityState === "visible") refreshAfterBrowserEvent();
27
+ }
28
+
29
+ onMounted(() => {
30
+ interval = setInterval(refresh, refreshIntervalMilliseconds);
31
+ window.addEventListener("focus", refreshAfterBrowserEvent);
32
+ window.addEventListener("online", refreshAfterBrowserEvent);
33
+ document.addEventListener("visibilitychange", refreshWhenVisible);
34
+ });
35
+
36
+ onBeforeUnmount(() => {
37
+ if (interval) clearInterval(interval);
38
+ window.removeEventListener("focus", refreshAfterBrowserEvent);
39
+ window.removeEventListener("online", refreshAfterBrowserEvent);
40
+ document.removeEventListener("visibilitychange", refreshWhenVisible);
41
+ });
42
+ }
@@ -3,6 +3,7 @@ import { Toaster } from "@/components/ui/sonner";
3
3
  import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar";
4
4
  import { TooltipProvider } from "@/components/ui/tooltip";
5
5
  import DevelopmentAuthWarning from "@/components/auth/DevelopmentAuthWarning.vue";
6
+ import AccessSnapshotBoundary from "@/components/common/AccessSnapshotBoundary.vue";
6
7
  // @windy-module system.license begin
7
8
  import LicenseExpiryBanner from "@/components/license/LicenseExpiryBanner.vue";
8
9
  import { useLicenseReminderRefresh } from "@/composables/useLicenseReminderRefresh";
@@ -24,32 +25,34 @@ useLicenseReminderRefresh(licenseRuntime.refresh);
24
25
 
25
26
  <template>
26
27
  <TooltipProvider :delay-duration="0">
27
- <SidebarProvider class="h-svh min-h-0 overflow-hidden">
28
- <AppSidebar />
29
- <SidebarInset class="h-svh min-w-0 overflow-hidden">
30
- <AppHeader />
31
- <div
32
- data-testid="app-content-scroll"
33
- class="min-h-0 flex-1 overflow-y-auto overscroll-contain"
34
- >
35
- <div v-if="developmentAuth.configured" class="px-6 pt-4">
36
- <DevelopmentAuthWarning />
28
+ <AccessSnapshotBoundary>
29
+ <SidebarProvider class="h-svh min-h-0 overflow-hidden">
30
+ <AppSidebar />
31
+ <SidebarInset class="h-svh min-w-0 overflow-hidden">
32
+ <AppHeader />
33
+ <div
34
+ data-testid="app-content-scroll"
35
+ class="min-h-0 flex-1 overflow-y-auto overscroll-contain"
36
+ >
37
+ <div v-if="developmentAuth.configured" class="px-6 pt-4">
38
+ <DevelopmentAuthWarning />
39
+ </div>
40
+ <!-- @windy-module system.license begin -->
41
+ <LicenseExpiryBanner
42
+ v-if="licenseRuntime.snapshot.value"
43
+ :snapshot="licenseRuntime.snapshot.value"
44
+ />
45
+ <!-- @windy-module system.license end -->
46
+ <main class="p-6">
47
+ <slot />
48
+ </main>
37
49
  </div>
38
- <!-- @windy-module system.license begin -->
39
- <LicenseExpiryBanner
40
- v-if="licenseRuntime.snapshot.value"
41
- :snapshot="licenseRuntime.snapshot.value"
42
- />
43
- <!-- @windy-module system.license end -->
44
- <main class="p-6">
45
- <slot />
46
- </main>
47
- </div>
48
- </SidebarInset>
49
- </SidebarProvider>
50
- <!-- @windy-module system.settings begin -->
51
- <GlobalWatermark />
52
- <!-- @windy-module system.settings end -->
50
+ </SidebarInset>
51
+ </SidebarProvider>
52
+ <!-- @windy-module system.settings begin -->
53
+ <GlobalWatermark />
54
+ <!-- @windy-module system.settings end -->
55
+ </AccessSnapshotBoundary>
53
56
  <Toaster />
54
57
  </TooltipProvider>
55
58
  </template>
@@ -35,6 +35,7 @@ describe("AppShell", () => {
35
35
  stubs: {
36
36
  AppHeader: { template: '<header data-testid="app-header" />' },
37
37
  AppSidebar: { template: '<aside data-testid="app-sidebar" />' },
38
+ AccessSnapshotBoundary: passthroughStub("access-snapshot-boundary"),
38
39
  DevelopmentAuthWarning: true,
39
40
  GlobalWatermark: true,
40
41
  // @windy-module system.license begin
@@ -0,0 +1,68 @@
1
+ import type { RouteRecordRaw } from "vue-router";
2
+ import type { BusinessAdminRouteRegistration } from "@/app/business-routes";
3
+
4
+ export function materializeBusinessAdminRoutes(
5
+ registrations: readonly BusinessAdminRouteRegistration[],
6
+ ): RouteRecordRaw[] {
7
+ assertBusinessAdminRouteRegistrations(registrations);
8
+ return registrations.map((registration) => ({
9
+ path: registration.path,
10
+ name: registration.name,
11
+ component: registration.component,
12
+ props: registration.props,
13
+ meta: {
14
+ title: registration.title,
15
+ layout: "admin",
16
+ businessRouteKey: registration.key,
17
+ featureKey: registration.featureKey,
18
+ permissionKey: registration.permissionKey,
19
+ },
20
+ }));
21
+ }
22
+
23
+ export function assertNoRouteCollisions(
24
+ routes: readonly RouteRecordRaw[],
25
+ ): void {
26
+ const paths = new Set<string>();
27
+ const names = new Set<string>();
28
+ for (const route of routes) {
29
+ if (paths.has(route.path)) {
30
+ throw new Error(`Web Route 路径重复:${route.path}`);
31
+ }
32
+ paths.add(route.path);
33
+ if (typeof route.name !== "string") continue;
34
+ if (names.has(route.name)) {
35
+ throw new Error(`Web Route 名称重复:${route.name}`);
36
+ }
37
+ names.add(route.name);
38
+ }
39
+ }
40
+
41
+ function assertBusinessAdminRouteRegistrations(
42
+ registrations: readonly BusinessAdminRouteRegistration[],
43
+ ): void {
44
+ const keys = new Set<string>();
45
+ for (const registration of registrations) {
46
+ for (const [field, value] of [
47
+ ["key", registration.key],
48
+ ["path", registration.path],
49
+ ["title", registration.title],
50
+ ["featureKey", registration.featureKey],
51
+ ["permissionKey", registration.permissionKey],
52
+ ] as const) {
53
+ if (!value.trim()) {
54
+ throw new Error(`业务 Web Route 的 ${field} 不能为空`);
55
+ }
56
+ }
57
+ if (!registration.path.startsWith("/")) {
58
+ throw new Error(`业务 Web Route 必须使用绝对路径:${registration.path}`);
59
+ }
60
+ if (registration.path.includes(":pathMatch")) {
61
+ throw new Error(`业务 Web Route 不能注册兜底路径:${registration.path}`);
62
+ }
63
+ if (keys.has(registration.key)) {
64
+ throw new Error(`业务 Web Route Key 重复:${registration.key}`);
65
+ }
66
+ keys.add(registration.key);
67
+ }
68
+ }
@@ -0,0 +1,85 @@
1
+ import { describe, expect, test } from "vitest";
2
+ import {
3
+ assertNoRouteCollisions,
4
+ materializeBusinessAdminRoutes,
5
+ } from "./business-routes";
6
+
7
+ describe("project-owned 业务路由接缝", () => {
8
+ test("统一生成带 Feature 与 RBAC Guard 的管理路由", () => {
9
+ const [route] = materializeBusinessAdminRoutes([
10
+ {
11
+ key: "case.record",
12
+ path: "/cases",
13
+ name: "case-records",
14
+ title: "案件",
15
+ component: {},
16
+ featureKey: "case.record",
17
+ permissionKey: "case.record.read",
18
+ },
19
+ ]);
20
+
21
+ expect(route).toMatchObject({
22
+ path: "/cases",
23
+ name: "case-records",
24
+ meta: {
25
+ title: "案件",
26
+ layout: "admin",
27
+ businessRouteKey: "case.record",
28
+ featureKey: "case.record",
29
+ permissionKey: "case.record.read",
30
+ },
31
+ });
32
+ });
33
+
34
+ test("拒绝空 Guard、重复 Key 与兜底路径", () => {
35
+ expect(() =>
36
+ materializeBusinessAdminRoutes([
37
+ {
38
+ key: "case.record",
39
+ path: "/cases",
40
+ title: "案件",
41
+ component: {},
42
+ featureKey: "",
43
+ permissionKey: "case.record.read",
44
+ },
45
+ ]),
46
+ ).toThrow("featureKey 不能为空");
47
+ expect(() =>
48
+ materializeBusinessAdminRoutes([
49
+ registration("/cases"),
50
+ registration("/other"),
51
+ ]),
52
+ ).toThrow("业务 Web Route Key 重复");
53
+ expect(() =>
54
+ materializeBusinessAdminRoutes([
55
+ registration("/:pathMatch(.*)*"),
56
+ ]),
57
+ ).toThrow("不能注册兜底路径");
58
+ });
59
+
60
+ test("组合时拒绝与平台路由重复的路径或名称", () => {
61
+ expect(() =>
62
+ assertNoRouteCollisions([
63
+ { path: "/admin", name: "admin-home", component: {} },
64
+ { path: "/admin", name: "business-home", component: {} },
65
+ ]),
66
+ ).toThrow("Web Route 路径重复:/admin");
67
+ expect(() =>
68
+ assertNoRouteCollisions([
69
+ { path: "/admin", name: "admin-home", component: {} },
70
+ { path: "/cases", name: "admin-home", component: {} },
71
+ ]),
72
+ ).toThrow("Web Route 名称重复:admin-home");
73
+ });
74
+ });
75
+
76
+ function registration(path: string) {
77
+ return {
78
+ key: "case.record",
79
+ path,
80
+ title: "案件",
81
+ component: {},
82
+ featureKey: "case.record",
83
+ permissionKey: "case.record.read",
84
+ };
85
+ }
@@ -6,6 +6,7 @@ import {
6
6
  } from "vue-router";
7
7
  import DashboardPage from "@/pages/dashboard/DashboardPage.vue";
8
8
  import HomePage from "@/app/home/HomePage.vue";
9
+ import { installedBusinessAdminRoutes } from "@/app/business-routes";
9
10
  import { loginPageComponent } from "@/app/auth/login-page";
10
11
  import { errorPageComponents } from "@/app/error-pages";
11
12
  import AccessDeniedPage from "@/pages/AccessDeniedPage.vue";
@@ -41,6 +42,10 @@ import { evaluateWebAccess, type WebAccessSnapshot } from "@/layout/navigation";
41
42
  import { isApiErrorStatus } from "@/services/http";
42
43
  import { loginRoute, safeReturnTo } from "./auth-navigation";
43
44
  import { safeErrorReturnTo } from "./error-navigation";
45
+ import {
46
+ assertNoRouteCollisions,
47
+ materializeBusinessAdminRoutes,
48
+ } from "./business-routes";
44
49
  import {
45
50
  manifestAdminRoute,
46
51
  validateWebModuleComposition,
@@ -195,6 +200,7 @@ export const routes: RouteRecordRaw[] = [
195
200
  component: ModuleConfigurationPage,
196
201
  }),
197
202
  // @windy-module system.configuration end
203
+ ...materializeBusinessAdminRoutes(installedBusinessAdminRoutes),
198
204
  {
199
205
  path: "/:pathMatch(.*)*",
200
206
  name: "not-found",
@@ -212,6 +218,7 @@ export const routes: RouteRecordRaw[] = [
212
218
  },
213
219
  ];
214
220
 
221
+ assertNoRouteCollisions(routes);
215
222
  validateWebModuleComposition(routes);
216
223
 
217
224
  export function createAppRouter(
@@ -25,6 +25,18 @@ describe("Router shared-scaffold 中性契约", () => {
25
25
  expect(routerSource).toContain("component: errorPageComponents.network");
26
26
  });
27
27
 
28
+ test("平台路由组合 project-owned 业务注册表且保持在兜底页之前", () => {
29
+ expect(routerSource).toContain(
30
+ 'import { installedBusinessAdminRoutes } from "@/app/business-routes";',
31
+ );
32
+ const businessIndex = routerSource.indexOf(
33
+ "...materializeBusinessAdminRoutes(installedBusinessAdminRoutes)",
34
+ );
35
+ const fallbackIndex = routerSource.indexOf('path: "/:pathMatch(.*)*"');
36
+ expect(businessIndex).toBeGreaterThan(0);
37
+ expect(businessIndex).toBeLessThan(fallbackIndex);
38
+ });
39
+
28
40
  test("测试快照只从项目注入路由递归派生访问键", () => {
29
41
  expect(collectRouteAccess([])).toEqual({
30
42
  permissionKeys: [],
@@ -23,7 +23,11 @@ interface FoundationResponse {
23
23
  }
24
24
 
25
25
  export async function loadAccessSnapshot(): Promise<WebAccessSnapshot> {
26
- const foundation = await apiRequest<FoundationResponse>("/admin/bootstrap");
26
+ const foundation = await apiRequest<FoundationResponse>(
27
+ "/admin/bootstrap",
28
+ {},
29
+ { suppressFailureHandler: true },
30
+ );
27
31
  return {
28
32
  actor: foundation.access.actor,
29
33
  menus: foundation.menus,
@@ -0,0 +1,35 @@
1
+ import { describe, expect, test, vi } from "vitest";
2
+
3
+ const mocks = vi.hoisted(() => ({ apiRequest: vi.fn() }));
4
+ vi.mock("./http", () => mocks);
5
+
6
+ import { loadAccessSnapshot } from "./access-api";
7
+
8
+ describe("权限快照 API", () => {
9
+ test("由调用方处理刷新失败,避免全局错误页卸载编辑实例", async () => {
10
+ mocks.apiRequest.mockResolvedValue({
11
+ menus: [],
12
+ permissions: [],
13
+ auditActionCatalog: [],
14
+ licenseCatalog: [],
15
+ access: {
16
+ actor: {
17
+ id: "user_1",
18
+ type: "user",
19
+ name: "测试员",
20
+ roleCodes: [],
21
+ permissionKeys: [],
22
+ },
23
+ features: [],
24
+ },
25
+ });
26
+
27
+ await loadAccessSnapshot();
28
+
29
+ expect(mocks.apiRequest).toHaveBeenCalledWith(
30
+ "/admin/bootstrap",
31
+ {},
32
+ { suppressFailureHandler: true },
33
+ );
34
+ });
35
+ });