@plures/praxis 1.0.3 → 1.1.1

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 (530) hide show
  1. package/FRAMEWORK.md +55 -5
  2. package/README.md +162 -375
  3. package/core/codegen/docs-generator.ts +5 -2
  4. package/core/codegen/index.ts +1 -1
  5. package/core/db-adapter/index.ts +2 -2
  6. package/core/db-adapter/sync-engine.ts +17 -6
  7. package/core/logic-engine/engine.ts +1 -1
  8. package/core/logic-engine/index.ts +2 -2
  9. package/core/logic-engine/protocol.ts +1 -1
  10. package/core/logic-engine/psf-adapter.ts +8 -4
  11. package/core/logic-engine/rules.ts +1 -1
  12. package/core/schema-engine/compiler.ts +53 -11
  13. package/core/schema-engine/generator.ts +17 -7
  14. package/core/schema-engine/index.ts +2 -2
  15. package/core/schema-engine/psf.ts +12 -3
  16. package/core/schema-engine/types.ts +3 -11
  17. package/core/schema-engine/validator.ts +112 -22
  18. package/dist/browser/engine-BjdqxeXG.d.ts +333 -0
  19. package/dist/browser/index.d.ts +3004 -0
  20. package/dist/browser/index.js +2892 -0
  21. package/dist/{src → browser}/integrations/svelte.d.ts +19 -17
  22. package/dist/browser/integrations/svelte.js +298 -0
  23. package/dist/node/auth-STARLY7I.js +207 -0
  24. package/dist/node/build-Y7OT5VBF.js +144 -0
  25. package/dist/node/canvas-UERZHJYW.js +362 -0
  26. package/dist/node/chunk-DSDC2JWZ.js +256 -0
  27. package/dist/node/chunk-FXQZXAWF.js +175 -0
  28. package/dist/node/chunk-N5Y37EUV.js +202 -0
  29. package/dist/node/chunk-QGM4M3NI.js +37 -0
  30. package/dist/node/chunk-RJMWCNHR.js +175 -0
  31. package/dist/node/chunk-SRM3OPPM.js +404 -0
  32. package/dist/node/chunk-UATVJBNV.js +175 -0
  33. package/dist/node/chunk-UY7YEBE2.js +159 -0
  34. package/dist/node/chunk-XCY2VIFX.js +143 -0
  35. package/dist/node/chunk-YXH4Y7ZZ.js +349 -0
  36. package/dist/node/cli/index.cjs +215139 -0
  37. package/dist/node/cli/index.d.cts +1 -0
  38. package/dist/node/cli/index.d.ts +1 -0
  39. package/dist/node/cli/index.js +690 -0
  40. package/dist/node/cloud/index.cjs +1043 -0
  41. package/dist/node/cloud/index.d.cts +864 -0
  42. package/dist/node/cloud/index.d.ts +864 -0
  43. package/dist/node/cloud/index.js +456 -0
  44. package/dist/node/cloud-AXOK4PSN.js +212 -0
  45. package/dist/node/component.cjs +374 -0
  46. package/dist/node/component.d.cts +125 -0
  47. package/dist/{src/core/component/generator.d.ts → node/component.d.ts} +11 -8
  48. package/dist/node/component.js +9 -0
  49. package/dist/node/components/index.cjs +216 -0
  50. package/dist/node/components/index.d.cts +43 -0
  51. package/dist/{src → node}/components/index.d.ts +8 -8
  52. package/dist/node/components/index.js +7 -0
  53. package/dist/node/create-TRLSVCNQ.js +584 -0
  54. package/dist/node/dev-PMJZUYGE.js +65 -0
  55. package/dist/node/engine-1iqLe6_P.d.ts +214 -0
  56. package/dist/node/engine-CVJobhHm.d.cts +214 -0
  57. package/dist/node/index.cjs +3247 -0
  58. package/dist/node/index.d.cts +2579 -0
  59. package/dist/node/index.d.ts +2579 -0
  60. package/dist/node/index.js +2098 -0
  61. package/dist/node/integrations/svelte.cjs +330 -0
  62. package/dist/node/integrations/svelte.d.cts +309 -0
  63. package/dist/node/integrations/svelte.d.ts +309 -0
  64. package/dist/node/integrations/svelte.js +300 -0
  65. package/dist/node/orchestrate-737TCL5H.js +127 -0
  66. package/dist/{src/core/protocol.d.ts → node/protocol-Qek7ebBl.d.cts} +11 -10
  67. package/dist/node/protocol-Qek7ebBl.d.ts +122 -0
  68. package/dist/node/schema.cjs +200 -0
  69. package/dist/{src/core/schema/types.d.ts → node/schema.d.cts} +30 -29
  70. package/dist/node/schema.d.ts +371 -0
  71. package/dist/node/schema.js +9 -0
  72. package/dist/{src/runtime/terminal-adapter.d.ts → node/terminal-adapter-07HGftGQ.d.ts} +86 -11
  73. package/dist/node/terminal-adapter-XLtCjjb_.d.cts +231 -0
  74. package/dist/node/verify-QRYKRIDU.js +210960 -0
  75. package/docs/MONETIZATION.md +21 -16
  76. package/docs/REACTIVE_REDESIGN.md +132 -0
  77. package/docs/README.md +47 -36
  78. package/docs/SVELTE_INTEGRATION_STRATEGY.md +68 -0
  79. package/docs/TERMINAL_NODE.md +27 -24
  80. package/docs/core/building-extensions.md +58 -61
  81. package/docs/core/cli-usage.md +59 -59
  82. package/docs/core/code-canvas-sync.md +28 -16
  83. package/docs/core/logic-engine.md +77 -82
  84. package/docs/core/pluresdb-integration.md +29 -39
  85. package/docs/core/schema-model.md +66 -52
  86. package/docs/core/ui-generation.md +57 -49
  87. package/docs/core/what-is-praxis.md +32 -15
  88. package/docs/guides/canvas.md +21 -5
  89. package/docs/guides/getting-started.md +13 -7
  90. package/docs/guides/history-state-pattern.md +65 -51
  91. package/docs/guides/orchestration.md +46 -32
  92. package/docs/guides/parallel-state-pattern.md +56 -72
  93. package/docs/guides/svelte-integration.md +45 -53
  94. package/docs/tutorials/README.md +16 -0
  95. package/docs/tutorials/ecommerce-cart.md +177 -95
  96. package/docs/tutorials/first-app.md +26 -41
  97. package/docs/tutorials/form-builder.md +191 -138
  98. package/docs/tutorials/todo-pluresdb.md +71 -69
  99. package/package.json +58 -23
  100. package/src/__tests__/actors.test.ts +68 -68
  101. package/src/__tests__/billing.test.ts +32 -32
  102. package/src/__tests__/canvas-components.test.ts +94 -73
  103. package/src/__tests__/cli-create.test.ts +28 -28
  104. package/src/__tests__/cloud.test.ts +36 -36
  105. package/src/__tests__/code-canvas-integration.test.ts +132 -141
  106. package/src/__tests__/docs-generator.test.ts +3 -9
  107. package/src/__tests__/dsl.test.ts +58 -64
  108. package/src/__tests__/edge-cases.test.ts +106 -108
  109. package/src/__tests__/engine.test.ts +51 -25
  110. package/src/__tests__/generators.test.ts +42 -44
  111. package/src/__tests__/introspection.test.ts +104 -114
  112. package/src/__tests__/pluresdb.test.ts +189 -187
  113. package/src/__tests__/protocol.test.ts +15 -15
  114. package/src/__tests__/provisioning.test.ts +61 -61
  115. package/src/__tests__/schema.test.ts +7 -11
  116. package/src/__tests__/state-docs-integration.test.ts +162 -145
  117. package/src/__tests__/svelte-integration.test.ts +16 -19
  118. package/src/__tests__/tauri-integration.test.ts +149 -147
  119. package/src/__tests__/terminal-node.test.ts +12 -7
  120. package/src/__tests__/unum-integration.test.ts +68 -68
  121. package/src/adapters/cli.ts +21 -15
  122. package/src/cli/commands/auth.ts +82 -78
  123. package/src/cli/commands/build.ts +29 -27
  124. package/src/cli/commands/canvas.ts +338 -127
  125. package/src/cli/commands/cloud.ts +47 -47
  126. package/src/cli/commands/create.ts +59 -47
  127. package/src/cli/commands/dev.ts +12 -12
  128. package/src/cli/commands/generate.ts +29 -40
  129. package/src/cli/commands/orchestrate.ts +24 -24
  130. package/src/cli/commands/verify.ts +7 -8
  131. package/src/cli/index.ts +14 -10
  132. package/src/cloud/README.md +28 -15
  133. package/src/cloud/auth.ts +55 -70
  134. package/src/cloud/billing.ts +59 -58
  135. package/src/cloud/client.ts +29 -35
  136. package/src/cloud/index.ts +19 -40
  137. package/src/cloud/marketplace.ts +69 -78
  138. package/src/cloud/provisioning.ts +42 -51
  139. package/src/cloud/relay/endpoints.ts +30 -34
  140. package/src/cloud/relay/health/index.ts +1 -1
  141. package/src/cloud/relay/stats/index.ts +1 -1
  142. package/src/cloud/relay/sync/index.ts +1 -1
  143. package/src/cloud/relay/usage/index.ts +1 -1
  144. package/src/cloud/sponsors.ts +31 -34
  145. package/src/cloud/types.ts +4 -4
  146. package/src/components/README.md +1 -0
  147. package/src/components/index.ts +3 -4
  148. package/src/core/actors.ts +7 -7
  149. package/src/core/component/generator.ts +10 -28
  150. package/src/core/engine.ts +51 -24
  151. package/src/core/introspection.ts +37 -35
  152. package/src/core/logic/generator.ts +62 -62
  153. package/src/core/pluresdb/adapter.ts +8 -8
  154. package/src/core/pluresdb/generator.ts +39 -35
  155. package/src/core/pluresdb/index.ts +9 -12
  156. package/src/core/pluresdb/schema-registry.ts +22 -25
  157. package/src/core/pluresdb/store.ts +57 -57
  158. package/src/core/protocol.ts +14 -14
  159. package/src/core/reactive-engine.svelte.ts +65 -0
  160. package/src/core/reactive-engine.ts +67 -0
  161. package/src/core/rules.ts +4 -4
  162. package/src/core/schema/loader.common.ts +150 -0
  163. package/src/core/schema/loader.ts +19 -149
  164. package/src/core/schema/normalize.ts +34 -51
  165. package/src/core/schema/types.ts +47 -11
  166. package/src/dsl/index.ts +8 -8
  167. package/src/dsl.ts +11 -17
  168. package/src/examples/advanced-todo/README.md +58 -40
  169. package/src/examples/advanced-todo/index.ts +3 -3
  170. package/src/examples/auth-basic/index.ts +30 -30
  171. package/src/examples/cart/index.ts +50 -50
  172. package/src/examples/hero-ecommerce/index.ts +130 -157
  173. package/src/examples/svelte-counter/index.ts +22 -26
  174. package/src/flows.ts +6 -17
  175. package/src/index.browser.ts +204 -0
  176. package/src/index.ts +37 -42
  177. package/src/integrations/code-canvas.ts +237 -193
  178. package/src/integrations/pluresdb.ts +55 -35
  179. package/src/integrations/state-docs.ts +104 -104
  180. package/src/integrations/svelte.ts +35 -35
  181. package/src/integrations/tauri.ts +75 -73
  182. package/src/integrations/unum.ts +68 -61
  183. package/src/registry.ts +7 -14
  184. package/src/runtime/terminal-adapter.ts +31 -26
  185. package/src/step.ts +10 -16
  186. package/src/types.ts +1 -1
  187. package/templates/basic-app/README.md +6 -9
  188. package/templates/fullstack-app/README.md +10 -0
  189. package/dist/core/codegen/docs-generator.d.ts +0 -123
  190. package/dist/core/codegen/docs-generator.d.ts.map +0 -1
  191. package/dist/core/codegen/docs-generator.js +0 -674
  192. package/dist/core/codegen/docs-generator.js.map +0 -1
  193. package/dist/core/codegen/index.d.ts +0 -11
  194. package/dist/core/codegen/index.d.ts.map +0 -1
  195. package/dist/core/codegen/index.js +0 -13
  196. package/dist/core/codegen/index.js.map +0 -1
  197. package/dist/core/codegen/ts-generator.d.ts +0 -8
  198. package/dist/core/codegen/ts-generator.d.ts.map +0 -1
  199. package/dist/core/codegen/ts-generator.js +0 -8
  200. package/dist/core/codegen/ts-generator.js.map +0 -1
  201. package/dist/core/db-adapter/index.d.ts +0 -18
  202. package/dist/core/db-adapter/index.d.ts.map +0 -1
  203. package/dist/core/db-adapter/index.js +0 -23
  204. package/dist/core/db-adapter/index.js.map +0 -1
  205. package/dist/core/db-adapter/sync-engine.d.ts +0 -180
  206. package/dist/core/db-adapter/sync-engine.d.ts.map +0 -1
  207. package/dist/core/db-adapter/sync-engine.js +0 -342
  208. package/dist/core/db-adapter/sync-engine.js.map +0 -1
  209. package/dist/core/logic-engine/engine.d.ts +0 -8
  210. package/dist/core/logic-engine/engine.d.ts.map +0 -1
  211. package/dist/core/logic-engine/engine.js +0 -8
  212. package/dist/core/logic-engine/engine.js.map +0 -1
  213. package/dist/core/logic-engine/index.d.ts +0 -16
  214. package/dist/core/logic-engine/index.d.ts.map +0 -1
  215. package/dist/core/logic-engine/index.js +0 -16
  216. package/dist/core/logic-engine/index.js.map +0 -1
  217. package/dist/core/logic-engine/protocol.d.ts +0 -7
  218. package/dist/core/logic-engine/protocol.d.ts.map +0 -1
  219. package/dist/core/logic-engine/protocol.js +0 -7
  220. package/dist/core/logic-engine/protocol.js.map +0 -1
  221. package/dist/core/logic-engine/psf-adapter.d.ts +0 -88
  222. package/dist/core/logic-engine/psf-adapter.d.ts.map +0 -1
  223. package/dist/core/logic-engine/psf-adapter.js +0 -207
  224. package/dist/core/logic-engine/psf-adapter.js.map +0 -1
  225. package/dist/core/logic-engine/rules.d.ts +0 -7
  226. package/dist/core/logic-engine/rules.d.ts.map +0 -1
  227. package/dist/core/logic-engine/rules.js +0 -7
  228. package/dist/core/logic-engine/rules.js.map +0 -1
  229. package/dist/core/schema-engine/compiler.d.ts +0 -198
  230. package/dist/core/schema-engine/compiler.d.ts.map +0 -1
  231. package/dist/core/schema-engine/compiler.js +0 -262
  232. package/dist/core/schema-engine/compiler.js.map +0 -1
  233. package/dist/core/schema-engine/generator.d.ts +0 -115
  234. package/dist/core/schema-engine/generator.d.ts.map +0 -1
  235. package/dist/core/schema-engine/generator.js +0 -506
  236. package/dist/core/schema-engine/generator.js.map +0 -1
  237. package/dist/core/schema-engine/index.d.ts +0 -18
  238. package/dist/core/schema-engine/index.d.ts.map +0 -1
  239. package/dist/core/schema-engine/index.js +0 -18
  240. package/dist/core/schema-engine/index.js.map +0 -1
  241. package/dist/core/schema-engine/psf.d.ts +0 -612
  242. package/dist/core/schema-engine/psf.d.ts.map +0 -1
  243. package/dist/core/schema-engine/psf.js +0 -45
  244. package/dist/core/schema-engine/psf.js.map +0 -1
  245. package/dist/core/schema-engine/types.d.ts +0 -10
  246. package/dist/core/schema-engine/types.d.ts.map +0 -1
  247. package/dist/core/schema-engine/types.js +0 -7
  248. package/dist/core/schema-engine/types.js.map +0 -1
  249. package/dist/core/schema-engine/validator.d.ts +0 -140
  250. package/dist/core/schema-engine/validator.d.ts.map +0 -1
  251. package/dist/core/schema-engine/validator.js +0 -407
  252. package/dist/core/schema-engine/validator.js.map +0 -1
  253. package/dist/src/adapters/cli.d.ts +0 -43
  254. package/dist/src/adapters/cli.d.ts.map +0 -1
  255. package/dist/src/adapters/cli.js +0 -126
  256. package/dist/src/adapters/cli.js.map +0 -1
  257. package/dist/src/cli/commands/auth.d.ts +0 -26
  258. package/dist/src/cli/commands/auth.d.ts.map +0 -1
  259. package/dist/src/cli/commands/auth.js +0 -233
  260. package/dist/src/cli/commands/auth.js.map +0 -1
  261. package/dist/src/cli/commands/build.d.ts +0 -23
  262. package/dist/src/cli/commands/build.d.ts.map +0 -1
  263. package/dist/src/cli/commands/build.js +0 -162
  264. package/dist/src/cli/commands/build.js.map +0 -1
  265. package/dist/src/cli/commands/canvas.d.ts +0 -23
  266. package/dist/src/cli/commands/canvas.d.ts.map +0 -1
  267. package/dist/src/cli/commands/canvas.js +0 -215
  268. package/dist/src/cli/commands/canvas.js.map +0 -1
  269. package/dist/src/cli/commands/cloud.d.ts +0 -27
  270. package/dist/src/cli/commands/cloud.d.ts.map +0 -1
  271. package/dist/src/cli/commands/cloud.js +0 -232
  272. package/dist/src/cli/commands/cloud.js.map +0 -1
  273. package/dist/src/cli/commands/create.d.ts +0 -21
  274. package/dist/src/cli/commands/create.d.ts.map +0 -1
  275. package/dist/src/cli/commands/create.js +0 -621
  276. package/dist/src/cli/commands/create.js.map +0 -1
  277. package/dist/src/cli/commands/dev.d.ts +0 -21
  278. package/dist/src/cli/commands/dev.d.ts.map +0 -1
  279. package/dist/src/cli/commands/dev.js +0 -71
  280. package/dist/src/cli/commands/dev.js.map +0 -1
  281. package/dist/src/cli/commands/generate.d.ts +0 -25
  282. package/dist/src/cli/commands/generate.d.ts.map +0 -1
  283. package/dist/src/cli/commands/generate.js +0 -168
  284. package/dist/src/cli/commands/generate.js.map +0 -1
  285. package/dist/src/cli/commands/orchestrate.d.ts +0 -44
  286. package/dist/src/cli/commands/orchestrate.d.ts.map +0 -1
  287. package/dist/src/cli/commands/orchestrate.js +0 -150
  288. package/dist/src/cli/commands/orchestrate.js.map +0 -1
  289. package/dist/src/cli/commands/verify.d.ts +0 -10
  290. package/dist/src/cli/commands/verify.d.ts.map +0 -1
  291. package/dist/src/cli/commands/verify.js +0 -39
  292. package/dist/src/cli/commands/verify.js.map +0 -1
  293. package/dist/src/cli/index.d.ts +0 -8
  294. package/dist/src/cli/index.d.ts.map +0 -1
  295. package/dist/src/cli/index.js +0 -226
  296. package/dist/src/cli/index.js.map +0 -1
  297. package/dist/src/cloud/auth.d.ts +0 -51
  298. package/dist/src/cloud/auth.d.ts.map +0 -1
  299. package/dist/src/cloud/auth.js +0 -194
  300. package/dist/src/cloud/auth.js.map +0 -1
  301. package/dist/src/cloud/billing.d.ts +0 -184
  302. package/dist/src/cloud/billing.d.ts.map +0 -1
  303. package/dist/src/cloud/billing.js +0 -179
  304. package/dist/src/cloud/billing.js.map +0 -1
  305. package/dist/src/cloud/client.d.ts +0 -39
  306. package/dist/src/cloud/client.d.ts.map +0 -1
  307. package/dist/src/cloud/client.js +0 -176
  308. package/dist/src/cloud/client.js.map +0 -1
  309. package/dist/src/cloud/index.d.ts +0 -44
  310. package/dist/src/cloud/index.d.ts.map +0 -1
  311. package/dist/src/cloud/index.js +0 -44
  312. package/dist/src/cloud/index.js.map +0 -1
  313. package/dist/src/cloud/marketplace.d.ts +0 -166
  314. package/dist/src/cloud/marketplace.d.ts.map +0 -1
  315. package/dist/src/cloud/marketplace.js +0 -159
  316. package/dist/src/cloud/marketplace.js.map +0 -1
  317. package/dist/src/cloud/provisioning.d.ts +0 -110
  318. package/dist/src/cloud/provisioning.d.ts.map +0 -1
  319. package/dist/src/cloud/provisioning.js +0 -148
  320. package/dist/src/cloud/provisioning.js.map +0 -1
  321. package/dist/src/cloud/relay/endpoints.d.ts +0 -62
  322. package/dist/src/cloud/relay/endpoints.d.ts.map +0 -1
  323. package/dist/src/cloud/relay/endpoints.js +0 -217
  324. package/dist/src/cloud/relay/endpoints.js.map +0 -1
  325. package/dist/src/cloud/relay/health/index.d.ts +0 -5
  326. package/dist/src/cloud/relay/health/index.d.ts.map +0 -1
  327. package/dist/src/cloud/relay/health/index.js +0 -9
  328. package/dist/src/cloud/relay/health/index.js.map +0 -1
  329. package/dist/src/cloud/relay/stats/index.d.ts +0 -5
  330. package/dist/src/cloud/relay/stats/index.d.ts.map +0 -1
  331. package/dist/src/cloud/relay/stats/index.js +0 -9
  332. package/dist/src/cloud/relay/stats/index.js.map +0 -1
  333. package/dist/src/cloud/relay/sync/index.d.ts +0 -5
  334. package/dist/src/cloud/relay/sync/index.d.ts.map +0 -1
  335. package/dist/src/cloud/relay/sync/index.js +0 -9
  336. package/dist/src/cloud/relay/sync/index.js.map +0 -1
  337. package/dist/src/cloud/relay/usage/index.d.ts +0 -5
  338. package/dist/src/cloud/relay/usage/index.d.ts.map +0 -1
  339. package/dist/src/cloud/relay/usage/index.js +0 -9
  340. package/dist/src/cloud/relay/usage/index.js.map +0 -1
  341. package/dist/src/cloud/sponsors.d.ts +0 -81
  342. package/dist/src/cloud/sponsors.d.ts.map +0 -1
  343. package/dist/src/cloud/sponsors.js +0 -130
  344. package/dist/src/cloud/sponsors.js.map +0 -1
  345. package/dist/src/cloud/types.d.ts +0 -169
  346. package/dist/src/cloud/types.d.ts.map +0 -1
  347. package/dist/src/cloud/types.js +0 -7
  348. package/dist/src/cloud/types.js.map +0 -1
  349. package/dist/src/components/index.d.ts.map +0 -1
  350. package/dist/src/components/index.js +0 -17
  351. package/dist/src/components/index.js.map +0 -1
  352. package/dist/src/core/actors.d.ts +0 -95
  353. package/dist/src/core/actors.d.ts.map +0 -1
  354. package/dist/src/core/actors.js +0 -158
  355. package/dist/src/core/actors.js.map +0 -1
  356. package/dist/src/core/component/generator.d.ts.map +0 -1
  357. package/dist/src/core/component/generator.js +0 -349
  358. package/dist/src/core/component/generator.js.map +0 -1
  359. package/dist/src/core/engine.d.ts +0 -92
  360. package/dist/src/core/engine.d.ts.map +0 -1
  361. package/dist/src/core/engine.js +0 -199
  362. package/dist/src/core/engine.js.map +0 -1
  363. package/dist/src/core/introspection.d.ts +0 -141
  364. package/dist/src/core/introspection.d.ts.map +0 -1
  365. package/dist/src/core/introspection.js +0 -208
  366. package/dist/src/core/introspection.js.map +0 -1
  367. package/dist/src/core/logic/generator.d.ts +0 -76
  368. package/dist/src/core/logic/generator.d.ts.map +0 -1
  369. package/dist/src/core/logic/generator.js +0 -370
  370. package/dist/src/core/logic/generator.js.map +0 -1
  371. package/dist/src/core/pluresdb/adapter.d.ts +0 -72
  372. package/dist/src/core/pluresdb/adapter.d.ts.map +0 -1
  373. package/dist/src/core/pluresdb/adapter.js +0 -73
  374. package/dist/src/core/pluresdb/adapter.js.map +0 -1
  375. package/dist/src/core/pluresdb/generator.d.ts +0 -58
  376. package/dist/src/core/pluresdb/generator.d.ts.map +0 -1
  377. package/dist/src/core/pluresdb/generator.js +0 -191
  378. package/dist/src/core/pluresdb/generator.js.map +0 -1
  379. package/dist/src/core/pluresdb/index.d.ts +0 -15
  380. package/dist/src/core/pluresdb/index.d.ts.map +0 -1
  381. package/dist/src/core/pluresdb/index.js +0 -11
  382. package/dist/src/core/pluresdb/index.js.map +0 -1
  383. package/dist/src/core/pluresdb/schema-registry.d.ts +0 -104
  384. package/dist/src/core/pluresdb/schema-registry.d.ts.map +0 -1
  385. package/dist/src/core/pluresdb/schema-registry.js +0 -130
  386. package/dist/src/core/pluresdb/schema-registry.js.map +0 -1
  387. package/dist/src/core/pluresdb/store.d.ts +0 -199
  388. package/dist/src/core/pluresdb/store.d.ts.map +0 -1
  389. package/dist/src/core/pluresdb/store.js +0 -344
  390. package/dist/src/core/pluresdb/store.js.map +0 -1
  391. package/dist/src/core/protocol.d.ts.map +0 -1
  392. package/dist/src/core/protocol.js +0 -46
  393. package/dist/src/core/protocol.js.map +0 -1
  394. package/dist/src/core/rules.d.ts +0 -120
  395. package/dist/src/core/rules.d.ts.map +0 -1
  396. package/dist/src/core/rules.js +0 -81
  397. package/dist/src/core/rules.js.map +0 -1
  398. package/dist/src/core/schema/loader.d.ts +0 -47
  399. package/dist/src/core/schema/loader.d.ts.map +0 -1
  400. package/dist/src/core/schema/loader.js +0 -189
  401. package/dist/src/core/schema/loader.js.map +0 -1
  402. package/dist/src/core/schema/normalize.d.ts +0 -72
  403. package/dist/src/core/schema/normalize.d.ts.map +0 -1
  404. package/dist/src/core/schema/normalize.js +0 -190
  405. package/dist/src/core/schema/normalize.js.map +0 -1
  406. package/dist/src/core/schema/types.d.ts.map +0 -1
  407. package/dist/src/core/schema/types.js +0 -161
  408. package/dist/src/core/schema/types.js.map +0 -1
  409. package/dist/src/dsl/index.d.ts +0 -152
  410. package/dist/src/dsl/index.d.ts.map +0 -1
  411. package/dist/src/dsl/index.js +0 -132
  412. package/dist/src/dsl/index.js.map +0 -1
  413. package/dist/src/dsl.d.ts +0 -124
  414. package/dist/src/dsl.d.ts.map +0 -1
  415. package/dist/src/dsl.js +0 -130
  416. package/dist/src/dsl.js.map +0 -1
  417. package/dist/src/examples/advanced-todo/index.d.ts +0 -55
  418. package/dist/src/examples/advanced-todo/index.d.ts.map +0 -1
  419. package/dist/src/examples/advanced-todo/index.js +0 -222
  420. package/dist/src/examples/advanced-todo/index.js.map +0 -1
  421. package/dist/src/examples/auth-basic/index.d.ts +0 -17
  422. package/dist/src/examples/auth-basic/index.d.ts.map +0 -1
  423. package/dist/src/examples/auth-basic/index.js +0 -122
  424. package/dist/src/examples/auth-basic/index.js.map +0 -1
  425. package/dist/src/examples/cart/index.d.ts +0 -19
  426. package/dist/src/examples/cart/index.d.ts.map +0 -1
  427. package/dist/src/examples/cart/index.js +0 -202
  428. package/dist/src/examples/cart/index.js.map +0 -1
  429. package/dist/src/examples/hero-ecommerce/index.d.ts +0 -39
  430. package/dist/src/examples/hero-ecommerce/index.d.ts.map +0 -1
  431. package/dist/src/examples/hero-ecommerce/index.js +0 -506
  432. package/dist/src/examples/hero-ecommerce/index.js.map +0 -1
  433. package/dist/src/examples/svelte-counter/index.d.ts +0 -31
  434. package/dist/src/examples/svelte-counter/index.d.ts.map +0 -1
  435. package/dist/src/examples/svelte-counter/index.js +0 -123
  436. package/dist/src/examples/svelte-counter/index.js.map +0 -1
  437. package/dist/src/flows.d.ts +0 -125
  438. package/dist/src/flows.d.ts.map +0 -1
  439. package/dist/src/flows.js +0 -160
  440. package/dist/src/flows.js.map +0 -1
  441. package/dist/src/index.d.ts +0 -77
  442. package/dist/src/index.d.ts.map +0 -1
  443. package/dist/src/index.js +0 -64
  444. package/dist/src/index.js.map +0 -1
  445. package/dist/src/integrations/code-canvas.d.ts +0 -265
  446. package/dist/src/integrations/code-canvas.d.ts.map +0 -1
  447. package/dist/src/integrations/code-canvas.js +0 -451
  448. package/dist/src/integrations/code-canvas.js.map +0 -1
  449. package/dist/src/integrations/pluresdb.d.ts +0 -117
  450. package/dist/src/integrations/pluresdb.d.ts.map +0 -1
  451. package/dist/src/integrations/pluresdb.js +0 -117
  452. package/dist/src/integrations/pluresdb.js.map +0 -1
  453. package/dist/src/integrations/state-docs.d.ts +0 -191
  454. package/dist/src/integrations/state-docs.d.ts.map +0 -1
  455. package/dist/src/integrations/state-docs.js +0 -515
  456. package/dist/src/integrations/state-docs.js.map +0 -1
  457. package/dist/src/integrations/svelte.d.ts.map +0 -1
  458. package/dist/src/integrations/svelte.js +0 -447
  459. package/dist/src/integrations/svelte.js.map +0 -1
  460. package/dist/src/integrations/tauri.d.ts +0 -360
  461. package/dist/src/integrations/tauri.d.ts.map +0 -1
  462. package/dist/src/integrations/tauri.js +0 -278
  463. package/dist/src/integrations/tauri.js.map +0 -1
  464. package/dist/src/integrations/unum.d.ts +0 -159
  465. package/dist/src/integrations/unum.d.ts.map +0 -1
  466. package/dist/src/integrations/unum.js +0 -240
  467. package/dist/src/integrations/unum.js.map +0 -1
  468. package/dist/src/registry.d.ts +0 -94
  469. package/dist/src/registry.d.ts.map +0 -1
  470. package/dist/src/registry.js +0 -181
  471. package/dist/src/registry.js.map +0 -1
  472. package/dist/src/runtime/terminal-adapter.d.ts.map +0 -1
  473. package/dist/src/runtime/terminal-adapter.js +0 -239
  474. package/dist/src/runtime/terminal-adapter.js.map +0 -1
  475. package/dist/src/step.d.ts +0 -34
  476. package/dist/src/step.d.ts.map +0 -1
  477. package/dist/src/step.js +0 -111
  478. package/dist/src/step.js.map +0 -1
  479. package/dist/src/types.d.ts +0 -63
  480. package/dist/src/types.d.ts.map +0 -1
  481. package/dist/src/types.js +0 -6
  482. package/dist/src/types.js.map +0 -1
  483. package/dist/tools/ast-analyzer/src/ast-analyzer.d.ts +0 -8
  484. package/dist/tools/ast-analyzer/src/ast-analyzer.d.ts.map +0 -1
  485. package/dist/tools/ast-analyzer/src/ast-analyzer.js +0 -119
  486. package/dist/tools/ast-analyzer/src/ast-analyzer.js.map +0 -1
  487. package/dist/tools/cli/commands/index.d.ts +0 -7
  488. package/dist/tools/cli/commands/index.d.ts.map +0 -1
  489. package/dist/tools/cli/commands/index.js +0 -7
  490. package/dist/tools/cli/commands/index.js.map +0 -1
  491. package/dist/tools/cli/index.d.ts +0 -8
  492. package/dist/tools/cli/index.d.ts.map +0 -1
  493. package/dist/tools/cli/index.js +0 -9
  494. package/dist/tools/cli/index.js.map +0 -1
  495. package/dist/tools/watcher/index.d.ts +0 -105
  496. package/dist/tools/watcher/index.d.ts.map +0 -1
  497. package/dist/tools/watcher/index.js +0 -213
  498. package/dist/tools/watcher/index.js.map +0 -1
  499. package/dist/ui/canvas/canvas-projection.d.ts +0 -78
  500. package/dist/ui/canvas/canvas-projection.d.ts.map +0 -1
  501. package/dist/ui/canvas/canvas-projection.js +0 -416
  502. package/dist/ui/canvas/canvas-projection.js.map +0 -1
  503. package/dist/ui/canvas/canvas-state.d.ts +0 -200
  504. package/dist/ui/canvas/canvas-state.d.ts.map +0 -1
  505. package/dist/ui/canvas/canvas-state.js +0 -464
  506. package/dist/ui/canvas/canvas-state.js.map +0 -1
  507. package/dist/ui/canvas/components/index.d.ts +0 -95
  508. package/dist/ui/canvas/components/index.d.ts.map +0 -1
  509. package/dist/ui/canvas/components/index.js +0 -19
  510. package/dist/ui/canvas/components/index.js.map +0 -1
  511. package/dist/ui/canvas/index.d.ts +0 -32
  512. package/dist/ui/canvas/index.d.ts.map +0 -1
  513. package/dist/ui/canvas/index.js +0 -32
  514. package/dist/ui/canvas/index.js.map +0 -1
  515. package/dist/ui/canvas-inspector/src/server.d.ts +0 -2
  516. package/dist/ui/canvas-inspector/src/server.d.ts.map +0 -1
  517. package/dist/ui/canvas-inspector/src/server.js +0 -248
  518. package/dist/ui/canvas-inspector/src/server.js.map +0 -1
  519. package/dist/ui/canvas-inspector/src/verify-fsm-implementation.d.ts +0 -5
  520. package/dist/ui/canvas-inspector/src/verify-fsm-implementation.d.ts.map +0 -1
  521. package/dist/ui/canvas-inspector/src/verify-fsm-implementation.js +0 -58
  522. package/dist/ui/canvas-inspector/src/verify-fsm-implementation.js.map +0 -1
  523. package/dist/ui/svelte-generator/index.d.ts +0 -9
  524. package/dist/ui/svelte-generator/index.d.ts.map +0 -1
  525. package/dist/ui/svelte-generator/index.js +0 -11
  526. package/dist/ui/svelte-generator/index.js.map +0 -1
  527. package/dist/ui/svelte-generator/psf-generator.d.ts +0 -128
  528. package/dist/ui/svelte-generator/psf-generator.d.ts.map +0 -1
  529. package/dist/ui/svelte-generator/psf-generator.js +0 -506
  530. package/dist/ui/svelte-generator/psf-generator.js.map +0 -1
@@ -0,0 +1,3004 @@
1
+ import { L as LogicEngine, P as PraxisState, a as PraxisEvent, b as PraxisRegistry, R as RuleDescriptor, C as ConstraintDescriptor, c as PraxisFact, d as RuleFn, e as ConstraintFn, f as PraxisModule } from './engine-BjdqxeXG.js';
2
+ export { m as ConstraintId, k as PRAXIS_PROTOCOL_VERSION, g as PraxisDiagnostics, n as PraxisEngineOptions, h as PraxisStepConfig, j as PraxisStepFn, i as PraxisStepResult, l as RuleId, o as createPraxisEngine } from './engine-BjdqxeXG.js';
3
+
4
+ /**
5
+ * Praxis Reactive Logic Engine
6
+ *
7
+ * A Svelte 5 native implementation of the Praxis Logic Engine.
8
+ * Uses Runes ($state, $derived, $effect) for fine-grained reactivity.
9
+ */
10
+ interface ReactiveEngineOptions<TContext> {
11
+ initialContext: TContext;
12
+ initialFacts?: any[];
13
+ initialMeta?: Record<string, unknown>;
14
+ }
15
+ declare class ReactiveLogicEngine<TContext extends object> {
16
+ state: {
17
+ context: TContext;
18
+ facts: any[];
19
+ meta: Record<string, unknown>;
20
+ };
21
+ constructor(options: ReactiveEngineOptions<TContext>);
22
+ /**
23
+ * Access the reactive context directly.
24
+ * Consumers can use this in $derived() or $effect().
25
+ */
26
+ get context(): TContext;
27
+ /**
28
+ * Access the reactive facts list.
29
+ */
30
+ get facts(): any[];
31
+ /**
32
+ * Apply a mutation to the state.
33
+ * This is the "Action" or "Rule" equivalent.
34
+ *
35
+ * @param mutator A function that receives the state and modifies it.
36
+ */
37
+ apply(mutator: (state: {
38
+ context: TContext;
39
+ facts: any[];
40
+ meta: Record<string, unknown>;
41
+ }) => void): void;
42
+ /**
43
+ * Access the reactive meta.
44
+ */
45
+ get meta(): Record<string, unknown>;
46
+ }
47
+
48
+ /**
49
+ * Actors System
50
+ *
51
+ * Actors are effectful units that:
52
+ * - Observe Praxis logic state
53
+ * - Perform side effects (network I/O, database operations, timers, etc.)
54
+ * - Feed new events/facts back into the engine
55
+ *
56
+ * Actors provide the bridge between pure logic and the effectful world.
57
+ */
58
+
59
+ /**
60
+ * Actor interface
61
+ *
62
+ * An actor observes state changes and can:
63
+ * - React to state changes (onStateChange)
64
+ * - Perform initialization (onStart)
65
+ * - Perform cleanup (onStop)
66
+ */
67
+ interface Actor<TContext = unknown> {
68
+ /** Unique identifier for the actor */
69
+ id: string;
70
+ /** Human-readable description */
71
+ description: string;
72
+ /** Called when the actor is started */
73
+ onStart?: (engine: LogicEngine<TContext>) => void | Promise<void>;
74
+ /** Called when state changes */
75
+ onStateChange?: (state: Readonly<PraxisState & {
76
+ context: TContext;
77
+ }>, engine: LogicEngine<TContext>) => void | Promise<void>;
78
+ /** Called when the actor is stopped */
79
+ onStop?: () => void | Promise<void>;
80
+ }
81
+ /**
82
+ * Actor manager
83
+ *
84
+ * Manages the lifecycle of actors and coordinates their interaction with the engine.
85
+ */
86
+ declare class ActorManager<TContext = unknown> {
87
+ private actors;
88
+ private activeActors;
89
+ private engine;
90
+ /**
91
+ * Register an actor
92
+ */
93
+ register(actor: Actor<TContext>): void;
94
+ /**
95
+ * Unregister an actor
96
+ */
97
+ unregister(actorId: string): void;
98
+ /**
99
+ * Attach the actor manager to an engine
100
+ */
101
+ attachEngine(engine: LogicEngine<TContext>): void;
102
+ /**
103
+ * Start an actor
104
+ */
105
+ start(actorId: string): Promise<void>;
106
+ /**
107
+ * Stop an actor
108
+ */
109
+ stop(actorId: string): Promise<void>;
110
+ /**
111
+ * Start all registered actors
112
+ */
113
+ startAll(): Promise<void>;
114
+ /**
115
+ * Stop all active actors
116
+ */
117
+ stopAll(): Promise<void>;
118
+ /**
119
+ * Notify active actors of a state change
120
+ */
121
+ notifyStateChange(state: Readonly<PraxisState & {
122
+ context: TContext;
123
+ }>): Promise<void>;
124
+ /**
125
+ * Get all registered actor IDs
126
+ */
127
+ getActorIds(): string[];
128
+ /**
129
+ * Get all active actor IDs
130
+ */
131
+ getActiveActorIds(): string[];
132
+ /**
133
+ * Check if an actor is active
134
+ */
135
+ isActive(actorId: string): boolean;
136
+ }
137
+ /**
138
+ * Helper to create a simple actor that dispatches events on a timer
139
+ */
140
+ declare function createTimerActor<TContext = unknown>(id: string, intervalMs: number, createEvent: () => PraxisEvent): Actor<TContext>;
141
+
142
+ /**
143
+ * Introspection and Visualization Utilities
144
+ *
145
+ * Provides APIs to introspect the registry, generate schemas,
146
+ * and export graph representations for external tools.
147
+ */
148
+
149
+ /**
150
+ * Graph node representing a rule in the system
151
+ */
152
+ interface RuleNode {
153
+ id: string;
154
+ type: 'rule';
155
+ description: string;
156
+ meta?: Record<string, unknown>;
157
+ }
158
+ /**
159
+ * Graph node representing a constraint in the system
160
+ */
161
+ interface ConstraintNode {
162
+ id: string;
163
+ type: 'constraint';
164
+ description: string;
165
+ meta?: Record<string, unknown>;
166
+ }
167
+ /**
168
+ * Graph edge representing a dependency or relationship
169
+ */
170
+ interface GraphEdge {
171
+ from: string;
172
+ to: string;
173
+ type: 'triggers' | 'constrains' | 'depends-on';
174
+ }
175
+ /**
176
+ * Complete graph representation of the registry
177
+ */
178
+ interface RegistryGraph {
179
+ nodes: (RuleNode | ConstraintNode)[];
180
+ edges: GraphEdge[];
181
+ meta: {
182
+ nodeCount: number;
183
+ ruleCount: number;
184
+ constraintCount: number;
185
+ };
186
+ }
187
+ /**
188
+ * JSON Schema-like representation of a rule
189
+ */
190
+ interface RuleSchema {
191
+ id: string;
192
+ description: string;
193
+ type: 'rule';
194
+ meta?: Record<string, unknown>;
195
+ }
196
+ /**
197
+ * JSON Schema-like representation of a constraint
198
+ */
199
+ interface ConstraintSchema {
200
+ id: string;
201
+ description: string;
202
+ type: 'constraint';
203
+ meta?: Record<string, unknown>;
204
+ }
205
+ /**
206
+ * Complete registry schema
207
+ */
208
+ interface RegistrySchema {
209
+ protocolVersion: string;
210
+ rules: RuleSchema[];
211
+ constraints: ConstraintSchema[];
212
+ meta: {
213
+ ruleCount: number;
214
+ constraintCount: number;
215
+ };
216
+ }
217
+ /**
218
+ * Statistics about the registry
219
+ */
220
+ interface RegistryStats {
221
+ ruleCount: number;
222
+ constraintCount: number;
223
+ moduleCount: number;
224
+ rulesById: string[];
225
+ constraintsById: string[];
226
+ }
227
+ /**
228
+ * Introspection utilities for a Praxis registry
229
+ */
230
+ declare class RegistryIntrospector<TContext = unknown> {
231
+ private registry;
232
+ constructor(registry: PraxisRegistry<TContext>);
233
+ /**
234
+ * Get basic statistics about the registry
235
+ */
236
+ getStats(): RegistryStats;
237
+ /**
238
+ * Generate a JSON schema representation of the registry
239
+ */
240
+ generateSchema(protocolVersion: string): RegistrySchema;
241
+ /**
242
+ * Generate a graph representation of the registry
243
+ *
244
+ * This creates nodes for rules and constraints.
245
+ * Edges can be inferred from metadata if rules/constraints
246
+ * document their dependencies.
247
+ */
248
+ generateGraph(): RegistryGraph;
249
+ /**
250
+ * Export graph in DOT format (Graphviz)
251
+ *
252
+ * This can be rendered with Graphviz tools or online services.
253
+ */
254
+ exportDOT(): string;
255
+ /**
256
+ * Export graph in Mermaid format
257
+ *
258
+ * Mermaid is a markdown-friendly diagramming language.
259
+ */
260
+ exportMermaid(): string;
261
+ /**
262
+ * Get detailed information about a specific rule
263
+ */
264
+ getRuleInfo(ruleId: string): RuleDescriptor<TContext> | undefined;
265
+ /**
266
+ * Get detailed information about a specific constraint
267
+ */
268
+ getConstraintInfo(constraintId: string): ConstraintDescriptor<TContext> | undefined;
269
+ /**
270
+ * Search for rules by description text
271
+ */
272
+ searchRules(query: string): RuleDescriptor<TContext>[];
273
+ /**
274
+ * Search for constraints by description text
275
+ */
276
+ searchConstraints(query: string): ConstraintDescriptor<TContext>[];
277
+ }
278
+ /**
279
+ * Create a registry introspector
280
+ */
281
+ declare function createIntrospector<TContext = unknown>(registry: PraxisRegistry<TContext>): RegistryIntrospector<TContext>;
282
+
283
+ /**
284
+ * DSL Helpers
285
+ *
286
+ * Ergonomic TypeScript helpers for defining facts, events, rules, constraints, and flows.
287
+ * These produce both strongly-typed APIs and serializable descriptors.
288
+ */
289
+
290
+ /**
291
+ * Strongly typed fact definition
292
+ */
293
+ interface FactDefinition$1<TTag extends string, TPayload> {
294
+ tag: TTag;
295
+ create(payload: TPayload): PraxisFact & {
296
+ tag: TTag;
297
+ payload: TPayload;
298
+ };
299
+ is(fact: PraxisFact): fact is PraxisFact & {
300
+ tag: TTag;
301
+ payload: TPayload;
302
+ };
303
+ }
304
+ /**
305
+ * Define a typed fact
306
+ *
307
+ * @example
308
+ * const UserLoggedIn = defineFact<"UserLoggedIn", { userId: string }>("UserLoggedIn");
309
+ * const fact = UserLoggedIn.create({ userId: "123" });
310
+ * if (UserLoggedIn.is(fact)) {
311
+ * console.log(fact.payload.userId); // Type-safe!
312
+ * }
313
+ */
314
+ declare function defineFact<TTag extends string, TPayload>(tag: TTag): FactDefinition$1<TTag, TPayload>;
315
+ /**
316
+ * Strongly typed event definition
317
+ */
318
+ interface EventDefinition$1<TTag extends string, TPayload> {
319
+ tag: TTag;
320
+ create(payload: TPayload): PraxisEvent & {
321
+ tag: TTag;
322
+ payload: TPayload;
323
+ };
324
+ is(event: PraxisEvent): event is PraxisEvent & {
325
+ tag: TTag;
326
+ payload: TPayload;
327
+ };
328
+ }
329
+ /**
330
+ * Define a typed event
331
+ *
332
+ * @example
333
+ * const Login = defineEvent<"LOGIN", { username: string; password: string }>("LOGIN");
334
+ * const event = Login.create({ username: "alice", password: "secret" });
335
+ */
336
+ declare function defineEvent<TTag extends string, TPayload>(tag: TTag): EventDefinition$1<TTag, TPayload>;
337
+ /**
338
+ * Options for defining a rule
339
+ */
340
+ interface DefineRuleOptions<TContext = unknown> {
341
+ id: string;
342
+ description: string;
343
+ impl: RuleFn<TContext>;
344
+ meta?: Record<string, unknown>;
345
+ }
346
+ /**
347
+ * Define a rule
348
+ *
349
+ * @example
350
+ * const loginRule = defineRule({
351
+ * id: "auth.login",
352
+ * description: "Process login event",
353
+ * impl: (state, events) => {
354
+ * const loginEvent = events.find(Login.is);
355
+ * if (loginEvent) {
356
+ * return [UserLoggedIn.create({ userId: loginEvent.payload.username })];
357
+ * }
358
+ * return [];
359
+ * }
360
+ * });
361
+ */
362
+ declare function defineRule<TContext = unknown>(options: DefineRuleOptions<TContext>): RuleDescriptor<TContext>;
363
+ /**
364
+ * Options for defining a constraint
365
+ */
366
+ interface DefineConstraintOptions<TContext = unknown> {
367
+ id: string;
368
+ description: string;
369
+ impl: ConstraintFn<TContext>;
370
+ meta?: Record<string, unknown>;
371
+ }
372
+ /**
373
+ * Define a constraint
374
+ *
375
+ * @example
376
+ * const maxCartItems = defineConstraint({
377
+ * id: "cart.maxItems",
378
+ * description: "Cart cannot exceed 100 items",
379
+ * impl: (state) => {
380
+ * const itemCount = state.context.items?.length ?? 0;
381
+ * return itemCount <= 100 || `Cart has ${itemCount} items, maximum is 100`;
382
+ * }
383
+ * });
384
+ */
385
+ declare function defineConstraint<TContext = unknown>(options: DefineConstraintOptions<TContext>): ConstraintDescriptor<TContext>;
386
+ /**
387
+ * Options for defining a module
388
+ */
389
+ interface DefineModuleOptions<TContext = unknown> {
390
+ rules?: RuleDescriptor<TContext>[];
391
+ constraints?: ConstraintDescriptor<TContext>[];
392
+ meta?: Record<string, unknown>;
393
+ }
394
+ /**
395
+ * Define a module (bundle of rules and constraints)
396
+ *
397
+ * @example
398
+ * const authModule = defineModule({
399
+ * rules: [loginRule, logoutRule],
400
+ * constraints: [maxSessionsConstraint],
401
+ * meta: { version: "1.0.0" }
402
+ * });
403
+ */
404
+ declare function defineModule<TContext = unknown>(options: DefineModuleOptions<TContext>): PraxisModule<TContext>;
405
+ /**
406
+ * Helper to filter events by definition
407
+ */
408
+ declare function filterEvents<TTag extends string, TPayload>(events: PraxisEvent[], definition: EventDefinition$1<TTag, TPayload>): Array<PraxisEvent & {
409
+ tag: TTag;
410
+ payload: TPayload;
411
+ }>;
412
+ /**
413
+ * Helper to filter facts by definition
414
+ */
415
+ declare function filterFacts<TTag extends string, TPayload>(facts: PraxisFact[], definition: FactDefinition$1<TTag, TPayload>): Array<PraxisFact & {
416
+ tag: TTag;
417
+ payload: TPayload;
418
+ }>;
419
+ /**
420
+ * Helper to find first event matching definition
421
+ */
422
+ declare function findEvent<TTag extends string, TPayload>(events: PraxisEvent[], definition: EventDefinition$1<TTag, TPayload>): (PraxisEvent & {
423
+ tag: TTag;
424
+ payload: TPayload;
425
+ }) | undefined;
426
+ /**
427
+ * Helper to find first fact matching definition
428
+ */
429
+ declare function findFact<TTag extends string, TPayload>(facts: PraxisFact[], definition: FactDefinition$1<TTag, TPayload>): (PraxisFact & {
430
+ tag: TTag;
431
+ payload: TPayload;
432
+ }) | undefined;
433
+
434
+ /**
435
+ * Praxis Schema System
436
+ *
437
+ * Declarative schema definitions for generating models, components, logic, and documentation.
438
+ */
439
+ /**
440
+ * Base schema definition
441
+ */
442
+ interface PraxisSchema {
443
+ /** Schema version (semver) */
444
+ version: string;
445
+ /** Schema name/identifier */
446
+ name: string;
447
+ /** Human-readable description */
448
+ description?: string;
449
+ /** Data models */
450
+ models?: ModelDefinition[];
451
+ /** UI components */
452
+ components?: ComponentDefinition[];
453
+ /** Logic definitions */
454
+ logic?: LogicDefinition[];
455
+ /** Orchestration configuration */
456
+ orchestration?: OrchestrationDefinition;
457
+ /** Additional metadata */
458
+ metadata?: Record<string, unknown>;
459
+ }
460
+ /**
461
+ * Model definition for data structures
462
+ */
463
+ interface ModelDefinition {
464
+ /** Model name */
465
+ name: string;
466
+ /** Model description */
467
+ description?: string;
468
+ /** Model fields */
469
+ fields: FieldDefinition[];
470
+ /** Validation constraints */
471
+ constraints?: ConstraintDefinition[];
472
+ /** Indexes for queries */
473
+ indexes?: IndexDefinition[];
474
+ /** Relationships to other models */
475
+ relationships?: RelationshipDefinition[];
476
+ }
477
+ /**
478
+ * Field definition within a model
479
+ */
480
+ interface FieldDefinition {
481
+ /** Field name */
482
+ name: string;
483
+ /** Field type */
484
+ type: FieldType;
485
+ /** Optional field */
486
+ optional?: boolean;
487
+ /** Default value */
488
+ default?: unknown;
489
+ /** Field description */
490
+ description?: string;
491
+ /** Validation rules */
492
+ validation?: ValidationRule[];
493
+ }
494
+ /**
495
+ * Supported field types
496
+ */
497
+ type FieldType = 'string' | 'number' | 'boolean' | 'date' | 'array' | 'object' | 'reference' | {
498
+ array: FieldType;
499
+ } | {
500
+ object: Record<string, FieldDefinition>;
501
+ } | {
502
+ reference: string;
503
+ };
504
+ /**
505
+ * Validation rule for a field
506
+ */
507
+ interface ValidationRule {
508
+ /** Validation type */
509
+ type: 'required' | 'min' | 'max' | 'pattern' | 'custom';
510
+ /** Validation value */
511
+ value?: unknown;
512
+ /** Error message */
513
+ message?: string;
514
+ }
515
+ /**
516
+ * Constraint definition for models
517
+ */
518
+ interface ConstraintDefinition {
519
+ /** Constraint identifier */
520
+ id: string;
521
+ /** Constraint description */
522
+ description: string;
523
+ /** Constraint type */
524
+ type: 'unique' | 'check' | 'foreign_key';
525
+ /** Constraint fields */
526
+ fields: string[];
527
+ /** Additional constraint options */
528
+ options?: Record<string, unknown>;
529
+ }
530
+ /**
531
+ * Index definition for queries
532
+ */
533
+ interface IndexDefinition {
534
+ /** Index name */
535
+ name: string;
536
+ /** Indexed fields */
537
+ fields: string[];
538
+ /** Unique index */
539
+ unique?: boolean;
540
+ /** Index type */
541
+ type?: 'btree' | 'hash' | 'fulltext';
542
+ }
543
+ /**
544
+ * Relationship definition between models
545
+ */
546
+ interface RelationshipDefinition {
547
+ /** Relationship name */
548
+ name: string;
549
+ /** Relationship type */
550
+ type: 'one-to-one' | 'one-to-many' | 'many-to-many';
551
+ /** Target model */
552
+ target: string;
553
+ /** Foreign key field */
554
+ foreignKey?: string;
555
+ /** Cascade delete */
556
+ cascadeDelete?: boolean;
557
+ }
558
+ /**
559
+ * Component definition for UI
560
+ */
561
+ interface ComponentDefinition {
562
+ /** Component name */
563
+ name: string;
564
+ /** Component type */
565
+ type: 'form' | 'display' | 'list' | 'navigation' | 'custom';
566
+ /** Component description */
567
+ description?: string;
568
+ /** Model binding */
569
+ model?: string;
570
+ /** Component properties */
571
+ props?: ComponentProp[];
572
+ /** Component events */
573
+ events?: ComponentEvent[];
574
+ /** Component layout */
575
+ layout?: LayoutDefinition;
576
+ /** Component styling */
577
+ styling?: StylingDefinition;
578
+ }
579
+ /**
580
+ * Component property definition
581
+ */
582
+ interface ComponentProp {
583
+ /** Property name */
584
+ name: string;
585
+ /** Property type */
586
+ type: string;
587
+ /** Required property */
588
+ required?: boolean;
589
+ /** Default value */
590
+ default?: unknown;
591
+ /** Property description */
592
+ description?: string;
593
+ }
594
+ /**
595
+ * Component event definition
596
+ */
597
+ interface ComponentEvent {
598
+ /** Event name */
599
+ name: string;
600
+ /** Event payload type */
601
+ payload?: string;
602
+ /** Event description */
603
+ description?: string;
604
+ }
605
+ /**
606
+ * Layout definition for components
607
+ */
608
+ interface LayoutDefinition {
609
+ /** Layout type */
610
+ type: 'stack' | 'grid' | 'flex' | 'absolute';
611
+ /** Layout direction */
612
+ direction?: 'horizontal' | 'vertical';
613
+ /** Layout gap */
614
+ gap?: number;
615
+ /** Layout padding */
616
+ padding?: number;
617
+ /** Layout alignment */
618
+ alignment?: string;
619
+ }
620
+ /**
621
+ * Styling definition for components
622
+ */
623
+ interface StylingDefinition {
624
+ /** CSS classes */
625
+ classes?: string[];
626
+ /** Inline styles */
627
+ styles?: Record<string, string>;
628
+ /** Theme tokens */
629
+ theme?: Record<string, string>;
630
+ }
631
+ /**
632
+ * Logic definition for business rules
633
+ */
634
+ interface LogicDefinition {
635
+ /** Logic identifier */
636
+ id: string;
637
+ /** Logic description */
638
+ description: string;
639
+ /** Facts definitions */
640
+ facts?: FactDefinition[];
641
+ /** Events definitions */
642
+ events?: EventDefinition[];
643
+ /** Rules definitions */
644
+ rules?: RuleDefinition[];
645
+ /** Constraints definitions */
646
+ constraints?: LogicConstraint[];
647
+ }
648
+ /**
649
+ * Fact definition
650
+ */
651
+ interface FactDefinition {
652
+ /** Fact tag */
653
+ tag: string;
654
+ /** Fact payload type */
655
+ payload: Record<string, string>;
656
+ /** Fact description */
657
+ description?: string;
658
+ }
659
+ /**
660
+ * Event definition
661
+ */
662
+ interface EventDefinition {
663
+ /** Event tag */
664
+ tag: string;
665
+ /** Event payload type */
666
+ payload: Record<string, string>;
667
+ /** Event description */
668
+ description?: string;
669
+ }
670
+ /**
671
+ * Rule definition
672
+ */
673
+ interface RuleDefinition {
674
+ /** Rule identifier */
675
+ id: string;
676
+ /** Rule description */
677
+ description: string;
678
+ /** Input events */
679
+ on?: string[];
680
+ /** Rule condition */
681
+ when?: string;
682
+ /** Rule action */
683
+ then: string;
684
+ /** Rule priority */
685
+ priority?: number;
686
+ }
687
+ /**
688
+ * Logic constraint definition
689
+ */
690
+ interface LogicConstraint {
691
+ /** Constraint identifier */
692
+ id: string;
693
+ /** Constraint description */
694
+ description: string;
695
+ /** Constraint check */
696
+ check: string;
697
+ /** Error message */
698
+ message: string;
699
+ }
700
+ /**
701
+ * Orchestration definition
702
+ */
703
+ interface OrchestrationDefinition {
704
+ /** Orchestration type */
705
+ type: 'dsc' | 'mcp' | 'custom';
706
+ /** Node configurations */
707
+ nodes?: NodeDefinition[];
708
+ /** State synchronization */
709
+ sync?: SyncDefinition;
710
+ /** Health checks */
711
+ health?: HealthDefinition;
712
+ }
713
+ /**
714
+ * Node definition for orchestration
715
+ */
716
+ interface NodeDefinition {
717
+ /** Node identifier */
718
+ id: string;
719
+ /** Node type */
720
+ type: string;
721
+ /** Node configuration */
722
+ config: Record<string, unknown>;
723
+ /** Node position (x, y coordinates for canvas) */
724
+ x?: number;
725
+ y?: number;
726
+ /** Node props (type-specific properties) */
727
+ props?: Record<string, unknown>;
728
+ /** Node bindings (connections to pluresdb paths) */
729
+ bindings?: NodeBindings;
730
+ }
731
+ /**
732
+ * Node bindings for pluresdb path connections
733
+ */
734
+ interface NodeBindings {
735
+ /** Output binding to pluresdb path */
736
+ output?: string;
737
+ /** Input binding to pluresdb path */
738
+ input?: string;
739
+ /** Additional custom bindings */
740
+ [key: string]: string | undefined;
741
+ }
742
+ /**
743
+ * Terminal node specific configuration
744
+ */
745
+ interface TerminalNodeProps {
746
+ /** Input mode: text input or widget-based */
747
+ inputMode: 'text' | 'widget';
748
+ /** Command history */
749
+ history: string[];
750
+ /** Last command output */
751
+ lastOutput: string | null;
752
+ }
753
+ /**
754
+ * Sync definition for state synchronization
755
+ */
756
+ interface SyncDefinition {
757
+ /** Sync interval in ms */
758
+ interval: number;
759
+ /** Conflict resolution strategy */
760
+ conflictResolution: 'last-write-wins' | 'merge' | 'custom';
761
+ /** Sync targets */
762
+ targets: string[];
763
+ }
764
+ /**
765
+ * Health check definition
766
+ */
767
+ interface HealthDefinition {
768
+ /** Check interval in ms */
769
+ interval: number;
770
+ /** Health check endpoints */
771
+ endpoints: string[];
772
+ /** Timeout in ms */
773
+ timeout: number;
774
+ }
775
+ /**
776
+ * Schema validation result
777
+ */
778
+ interface ValidationResult {
779
+ /** Validation success */
780
+ valid: boolean;
781
+ /** Validation errors */
782
+ errors: ValidationError[];
783
+ }
784
+ /**
785
+ * Validation error
786
+ */
787
+ interface ValidationError {
788
+ /** Error path in schema */
789
+ path: string;
790
+ /** Error message */
791
+ message: string;
792
+ /** Error code */
793
+ code?: string;
794
+ }
795
+ /**
796
+ * Validate a Praxis schema
797
+ */
798
+ declare function validateSchema(schema: PraxisSchema): ValidationResult;
799
+ /**
800
+ * Create a basic schema template
801
+ */
802
+ declare function createSchemaTemplate(name: string): PraxisSchema;
803
+
804
+ /**
805
+ * Praxis Schema Loader (Common/Browser Compatible)
806
+ *
807
+ * Core schema loading and validation functions that don't depend on Node.js APIs.
808
+ */
809
+
810
+ /**
811
+ * Loader options
812
+ */
813
+ interface LoaderOptions {
814
+ /** Validate schema after loading */
815
+ validate?: boolean;
816
+ /** Base directory for resolving relative paths */
817
+ baseDir?: string;
818
+ }
819
+ /**
820
+ * Loader result
821
+ */
822
+ interface LoaderResult {
823
+ /** Loaded schema */
824
+ schema?: PraxisSchema;
825
+ /** Validation result */
826
+ validation?: ValidationResult;
827
+ /** Load errors */
828
+ errors: string[];
829
+ }
830
+ /**
831
+ * Create a new empty schema
832
+ */
833
+ declare function createSchema(name: string): PraxisSchema;
834
+ /**
835
+ * Load schema from JSON string
836
+ */
837
+ declare function loadSchemaFromJson(json: string, options?: LoaderOptions): LoaderResult;
838
+ /**
839
+ * Load schema from YAML string
840
+ */
841
+ declare function loadSchemaFromYaml(yaml: string, options?: LoaderOptions): LoaderResult;
842
+ /**
843
+ * Validate that a loaded schema has required fields for generation
844
+ */
845
+ declare function validateForGeneration(schema: PraxisSchema): ValidationResult;
846
+
847
+ /**
848
+ * PraxisDB Adapter
849
+ *
850
+ * Provides a minimal adapter layer for PluresDB integration.
851
+ * This module defines the core interface and an in-memory implementation.
852
+ */
853
+ /**
854
+ * Function to unsubscribe from a watch
855
+ */
856
+ type UnsubscribeFn = () => void;
857
+ /**
858
+ * Core database interface for Praxis
859
+ *
860
+ * Provides a minimal API for get/set/watch operations.
861
+ * Can be backed by in-memory storage or PluresDB.
862
+ */
863
+ interface PraxisDB {
864
+ /**
865
+ * Get a value by key
866
+ * @param key The key to retrieve
867
+ * @returns The value or undefined if not found
868
+ */
869
+ get<T>(key: string): Promise<T | undefined>;
870
+ /**
871
+ * Set a value by key
872
+ * @param key The key to set
873
+ * @param value The value to store
874
+ */
875
+ set<T>(key: string, value: T): Promise<void>;
876
+ /**
877
+ * Watch a key for changes
878
+ * @param key The key to watch
879
+ * @param callback Called when the value changes
880
+ * @returns Function to unsubscribe from updates
881
+ */
882
+ watch<T>(key: string, callback: (val: T) => void): UnsubscribeFn;
883
+ }
884
+ /**
885
+ * In-memory implementation of PraxisDB
886
+ *
887
+ * Provides a simple in-memory store for development and testing.
888
+ * Suitable for proxying to PluresDB later.
889
+ */
890
+ declare class InMemoryPraxisDB implements PraxisDB {
891
+ private store;
892
+ private watchers;
893
+ get<T>(key: string): Promise<T | undefined>;
894
+ set<T>(key: string, value: T): Promise<void>;
895
+ watch<T>(key: string, callback: (val: T) => void): UnsubscribeFn;
896
+ /**
897
+ * Get all keys (for testing/debugging)
898
+ */
899
+ keys(): string[];
900
+ /**
901
+ * Clear all data (for testing)
902
+ */
903
+ clear(): void;
904
+ }
905
+ /**
906
+ * Create a new in-memory PraxisDB instance
907
+ *
908
+ * @returns InMemoryPraxisDB instance
909
+ *
910
+ * @example
911
+ * ```typescript
912
+ * const db = createInMemoryDB();
913
+ * await db.set('user:1', { name: 'Alice' });
914
+ * const user = await db.get('user:1');
915
+ * ```
916
+ */
917
+ declare function createInMemoryDB(): InMemoryPraxisDB;
918
+
919
+ /**
920
+ * PraxisDB Store
921
+ *
922
+ * Connects Praxis Facts, Events, Rules, and Constraints to PluresDB.
923
+ * Provides CRDT-backed storage for facts and append-only event streams.
924
+ */
925
+
926
+ /**
927
+ * Key paths for Praxis data in PluresDB
928
+ */
929
+ declare const PRAXIS_PATHS: {
930
+ /** Base path for all Praxis data */
931
+ readonly BASE: "/_praxis";
932
+ /** Path for facts storage */
933
+ readonly FACTS: "/_praxis/facts";
934
+ /** Path for events storage */
935
+ readonly EVENTS: "/_praxis/events";
936
+ /** Path for schema registry */
937
+ readonly SCHEMAS: "/_praxis/schemas";
938
+ };
939
+ /**
940
+ * Generate a fact key path
941
+ * @param factTag The fact type tag
942
+ * @param id Optional unique identifier for the fact instance
943
+ */
944
+ declare function getFactPath(factTag: string, id?: string): string;
945
+ /**
946
+ * Generate an event stream key path
947
+ * @param eventTag The event type tag
948
+ */
949
+ declare function getEventPath(eventTag: string): string;
950
+ /**
951
+ * Generate a unique ID for facts or events
952
+ * Uses timestamp and random string for uniqueness
953
+ */
954
+ declare function generateId(): string;
955
+ /**
956
+ * Event stream entry with timestamp
957
+ */
958
+ interface EventStreamEntry {
959
+ /** The event data */
960
+ event: PraxisEvent;
961
+ /** Timestamp when the event was appended */
962
+ timestamp: number;
963
+ /** Optional sequence number */
964
+ sequence?: number;
965
+ }
966
+ /**
967
+ * Options for creating a PraxisDBStore
968
+ */
969
+ interface PraxisDBStoreOptions<TContext = unknown> {
970
+ /** The PraxisDB instance to use */
971
+ db: PraxisDB;
972
+ /** The PraxisRegistry for rules and constraints */
973
+ registry: PraxisRegistry<TContext>;
974
+ /** Initial context for rule evaluation */
975
+ initialContext?: TContext;
976
+ }
977
+ /**
978
+ * PraxisDBStore
979
+ *
980
+ * Manages persistence and reactive updates for Praxis state in PluresDB.
981
+ *
982
+ * - Facts are stored as CRDT-backed documents under `/_praxis/facts/<factTag>/<id>`
983
+ * - Events are stored as append-only streams under `/_praxis/events/<eventTag>`
984
+ * - Rules are triggered automatically when watched keys change
985
+ * - Constraints are run before writing mutated state
986
+ */
987
+ /**
988
+ * Error handler callback for rule execution errors
989
+ */
990
+ type RuleErrorHandler = (ruleId: string, error: unknown) => void;
991
+ declare class PraxisDBStore<TContext = unknown> {
992
+ private db;
993
+ private registry;
994
+ private context;
995
+ private subscriptions;
996
+ private factWatchers;
997
+ private onRuleError;
998
+ constructor(options: PraxisDBStoreOptions<TContext> & {
999
+ onRuleError?: RuleErrorHandler;
1000
+ });
1001
+ /**
1002
+ * Store a fact in PluresDB
1003
+ *
1004
+ * Facts are stored under `/_praxis/facts/<factTag>/<id>`
1005
+ * If no id is provided in the payload, a timestamp-based id is used.
1006
+ *
1007
+ * @param fact The fact to store
1008
+ * @returns Promise that resolves when the fact is stored
1009
+ */
1010
+ storeFact(fact: PraxisFact): Promise<void>;
1011
+ /**
1012
+ * Store multiple facts in PluresDB
1013
+ *
1014
+ * @param facts The facts to store
1015
+ */
1016
+ storeFacts(facts: PraxisFact[]): Promise<void>;
1017
+ /**
1018
+ * Internal method to persist a fact without constraint checking
1019
+ * Used by both storeFact and derived fact storage
1020
+ */
1021
+ private persistFact;
1022
+ /**
1023
+ * Get a fact by tag and id
1024
+ *
1025
+ * @param factTag The fact type tag
1026
+ * @param id The fact id
1027
+ * @returns The fact or undefined if not found
1028
+ */
1029
+ getFact(factTag: string, id: string): Promise<PraxisFact | undefined>;
1030
+ /**
1031
+ * Append an event to the event stream
1032
+ *
1033
+ * Events are stored as append-only streams under `/_praxis/events/<eventTag>`
1034
+ *
1035
+ * @param event The event to append
1036
+ */
1037
+ appendEvent(event: PraxisEvent): Promise<void>;
1038
+ /**
1039
+ * Append multiple events to their respective streams
1040
+ *
1041
+ * @param events The events to append
1042
+ */
1043
+ appendEvents(events: PraxisEvent[]): Promise<void>;
1044
+ /**
1045
+ * Get events from a stream
1046
+ *
1047
+ * @param eventTag The event type tag
1048
+ * @param options Query options
1049
+ * @returns Array of event stream entries
1050
+ */
1051
+ getEvents(eventTag: string, options?: {
1052
+ since?: number;
1053
+ limit?: number;
1054
+ }): Promise<EventStreamEntry[]>;
1055
+ /**
1056
+ * Watch a fact path for changes
1057
+ *
1058
+ * @param factTag The fact type tag to watch
1059
+ * @param callback Called when facts of this type change
1060
+ * @returns Unsubscribe function
1061
+ */
1062
+ watchFacts(factTag: string, callback: (facts: PraxisFact[]) => void): UnsubscribeFn;
1063
+ /**
1064
+ * Check constraints against the current state with new facts
1065
+ */
1066
+ private checkConstraints;
1067
+ /**
1068
+ * Trigger rules when new facts are added
1069
+ *
1070
+ * This method is called after facts are stored. It can be extended
1071
+ * for derived fact computation where rules generate new facts based
1072
+ * on existing facts. Currently implemented as a hook point for future
1073
+ * enhancements.
1074
+ *
1075
+ * @param _newFacts The newly stored facts (unused in current implementation)
1076
+ */
1077
+ private triggerRules;
1078
+ /**
1079
+ * Trigger rules when events are appended
1080
+ */
1081
+ private triggerRulesForEvents;
1082
+ /**
1083
+ * Update the context
1084
+ */
1085
+ updateContext(context: TContext): void;
1086
+ /**
1087
+ * Get the current context
1088
+ */
1089
+ getContext(): TContext;
1090
+ /**
1091
+ * Dispose of all subscriptions
1092
+ */
1093
+ dispose(): void;
1094
+ }
1095
+ /**
1096
+ * Create a new PraxisDBStore
1097
+ *
1098
+ * @param db The PraxisDB instance to use
1099
+ * @param registry The PraxisRegistry for rules and constraints
1100
+ * @param initialContext Optional initial context
1101
+ * @param onRuleError Optional error handler for rule execution errors
1102
+ * @returns PraxisDBStore instance
1103
+ *
1104
+ * @example
1105
+ * ```typescript
1106
+ * const db = createInMemoryDB();
1107
+ * const registry = new PraxisRegistry();
1108
+ * const store = createPraxisDBStore(db, registry);
1109
+ *
1110
+ * await store.storeFact({ tag: "UserLoggedIn", payload: { userId: "alice" } });
1111
+ * await store.appendEvent({ tag: "LOGIN", payload: { username: "alice" } });
1112
+ * ```
1113
+ */
1114
+ declare function createPraxisDBStore<TContext = unknown>(db: PraxisDB, registry: PraxisRegistry<TContext>, initialContext?: TContext, onRuleError?: RuleErrorHandler): PraxisDBStore<TContext>;
1115
+
1116
+ /**
1117
+ * Praxis Schema Registry for PluresDB
1118
+ *
1119
+ * Registers Praxis schema definitions in PluresDB for type-safe storage
1120
+ * and cross-agent schema discovery.
1121
+ */
1122
+
1123
+ /**
1124
+ * Get the path for a schema in PluresDB
1125
+ * @param schemaName The schema name
1126
+ */
1127
+ declare function getSchemaPath(schemaName: string): string;
1128
+ /**
1129
+ * Stored schema entry with metadata
1130
+ */
1131
+ interface StoredSchema {
1132
+ /** The schema definition */
1133
+ schema: PraxisSchema;
1134
+ /** When the schema was registered */
1135
+ registeredAt: number;
1136
+ /** Schema version */
1137
+ version: string;
1138
+ }
1139
+ /**
1140
+ * PraxisSchemaRegistry
1141
+ *
1142
+ * Manages schema definitions in PluresDB.
1143
+ * Schemas are stored under `/_praxis/schemas/<schemaName>`
1144
+ */
1145
+ declare class PraxisSchemaRegistry {
1146
+ private db;
1147
+ constructor(db: PraxisDB);
1148
+ /**
1149
+ * Register a schema in PluresDB
1150
+ *
1151
+ * @param schema The schema to register
1152
+ */
1153
+ register(schema: PraxisSchema): Promise<void>;
1154
+ /**
1155
+ * Get a schema by name
1156
+ *
1157
+ * @param schemaName The schema name
1158
+ * @returns The stored schema or undefined if not found
1159
+ */
1160
+ get(schemaName: string): Promise<StoredSchema | undefined>;
1161
+ /**
1162
+ * Check if a schema is registered
1163
+ *
1164
+ * @param schemaName The schema name
1165
+ * @returns True if the schema exists
1166
+ */
1167
+ exists(schemaName: string): Promise<boolean>;
1168
+ /**
1169
+ * Update a schema (replaces existing)
1170
+ *
1171
+ * @param schema The updated schema
1172
+ */
1173
+ update(schema: PraxisSchema): Promise<void>;
1174
+ /**
1175
+ * List all registered schema names
1176
+ *
1177
+ * Implementation note: This method uses an index stored at `/_praxis/schemas/_index`.
1178
+ * When using InMemoryPraxisDB, schemas must be registered using `registerWithIndex()`
1179
+ * for them to appear in this listing. When using a full PluresDB implementation,
1180
+ * native listing capabilities should be used instead.
1181
+ *
1182
+ * @returns Array of registered schema names
1183
+ */
1184
+ list(): Promise<string[]>;
1185
+ /**
1186
+ * Register a schema and update the index
1187
+ *
1188
+ * @param schema The schema to register
1189
+ */
1190
+ registerWithIndex(schema: PraxisSchema): Promise<void>;
1191
+ }
1192
+ /**
1193
+ * Register a schema in PluresDB
1194
+ *
1195
+ * Convenience function for one-off schema registration.
1196
+ *
1197
+ * @param db The PraxisDB instance
1198
+ * @param schema The schema to register
1199
+ *
1200
+ * @example
1201
+ * ```typescript
1202
+ * const db = createInMemoryDB();
1203
+ * await registerSchema(db, {
1204
+ * version: "1.0.0",
1205
+ * name: "MyApp",
1206
+ * description: "My application schema"
1207
+ * });
1208
+ * ```
1209
+ */
1210
+ declare function registerSchema(db: PraxisDB, schema: PraxisSchema): Promise<void>;
1211
+ /**
1212
+ * Create a PraxisSchemaRegistry instance
1213
+ *
1214
+ * @param db The PraxisDB instance
1215
+ * @returns PraxisSchemaRegistry instance
1216
+ */
1217
+ declare function createSchemaRegistry(db: PraxisDB): PraxisSchemaRegistry;
1218
+
1219
+ /**
1220
+ * Praxis Schema Normalizer
1221
+ *
1222
+ * Expands and normalizes schema definitions for code generation.
1223
+ */
1224
+
1225
+ /**
1226
+ * Normalized schema with expanded and validated definitions
1227
+ */
1228
+ interface NormalizedSchema extends PraxisSchema {
1229
+ /** Normalized models with expanded references */
1230
+ models: NormalizedModel[];
1231
+ /** Normalized components */
1232
+ components: NormalizedComponent[];
1233
+ /** Normalized logic */
1234
+ logic: NormalizedLogic[];
1235
+ }
1236
+ /**
1237
+ * Normalized model definition
1238
+ */
1239
+ interface NormalizedModel extends ModelDefinition {
1240
+ /** Fully qualified name */
1241
+ fullName: string;
1242
+ /** All fields including inherited ones */
1243
+ allFields: FieldDefinition[];
1244
+ /** Model dependencies */
1245
+ dependencies: string[];
1246
+ }
1247
+ /**
1248
+ * Normalized component definition
1249
+ */
1250
+ interface NormalizedComponent extends ComponentDefinition {
1251
+ /** Fully qualified name */
1252
+ fullName: string;
1253
+ /** Resolved model reference */
1254
+ resolvedModel?: NormalizedModel;
1255
+ }
1256
+ /**
1257
+ * Normalized logic definition
1258
+ */
1259
+ interface NormalizedLogic extends LogicDefinition {
1260
+ /** Fully qualified identifier */
1261
+ fullId: string;
1262
+ }
1263
+
1264
+ /**
1265
+ * PluresDB Config Generator
1266
+ *
1267
+ * Generates PluresDB configuration from schema definitions.
1268
+ */
1269
+
1270
+ /**
1271
+ * PluresDB config generation options
1272
+ */
1273
+ interface PluresDBGeneratorOptions {
1274
+ /** Output directory */
1275
+ outputDir: string;
1276
+ /** Database name */
1277
+ dbName?: string;
1278
+ /** Database version */
1279
+ dbVersion?: number;
1280
+ /** Enable sync */
1281
+ enableSync?: boolean;
1282
+ /** Sync endpoint */
1283
+ syncEndpoint?: string;
1284
+ /** Auto-index strategy: 'all' indexes all string/number/date fields, 'explicit' only indexes fields defined in schema, 'none' disables auto-indexing */
1285
+ autoIndex?: 'all' | 'explicit' | 'none';
1286
+ }
1287
+ /**
1288
+ * Generated PluresDB config file
1289
+ */
1290
+ interface GeneratedPluresDBFile {
1291
+ /** File path */
1292
+ path: string;
1293
+ /** File content */
1294
+ content: string;
1295
+ /** File type */
1296
+ type: 'config' | 'types';
1297
+ }
1298
+ /**
1299
+ * PluresDB generator class
1300
+ */
1301
+ declare class PluresDBGenerator {
1302
+ private options;
1303
+ constructor(options: PluresDBGeneratorOptions);
1304
+ /**
1305
+ * Generate PluresDB configuration from schema
1306
+ */
1307
+ generateConfig(schema: NormalizedSchema): GeneratedPluresDBFile[];
1308
+ /**
1309
+ * Generate pluresdb-config.ts file
1310
+ */
1311
+ private generateConfigFile;
1312
+ /**
1313
+ * Generate store configuration for a model
1314
+ */
1315
+ private generateStoreConfig;
1316
+ }
1317
+ /**
1318
+ * Create a PluresDB generator
1319
+ */
1320
+ declare function createPluresDBGenerator(outputDir: string, options?: Partial<PluresDBGeneratorOptions>): PluresDBGenerator;
1321
+
1322
+ /**
1323
+ * PluresDB Integration
1324
+ *
1325
+ * Integration with pluresdb - reactive graph datastore and event source/sink.
1326
+ * This module provides adapters for:
1327
+ * - Storing Praxis state in pluresdb
1328
+ * - Sourcing events from pluresdb
1329
+ * - Sinking events to pluresdb
1330
+ * - Reactive queries and subscriptions
1331
+ */
1332
+
1333
+ /**
1334
+ * PluresDB adapter interface for engine integration
1335
+ *
1336
+ * Provides:
1337
+ * - Event sourcing (persist events to pluresdb)
1338
+ * - State snapshots (persist state to pluresdb)
1339
+ * - Event replay (rebuild state from events)
1340
+ * - Reactive queries (subscribe to state changes)
1341
+ */
1342
+ interface PluresDBAdapter<TContext = unknown> {
1343
+ /**
1344
+ * Persist events to pluresdb
1345
+ */
1346
+ persistEvents(events: PraxisEvent[]): Promise<void>;
1347
+ /**
1348
+ * Persist facts to pluresdb
1349
+ */
1350
+ persistFacts(facts: PraxisFact[]): Promise<void>;
1351
+ /**
1352
+ * Load events from pluresdb
1353
+ */
1354
+ loadEvents(query?: unknown): Promise<PraxisEvent[]>;
1355
+ /**
1356
+ * Subscribe to changes for a given tag
1357
+ *
1358
+ * Note: This watches for derived facts that are created when events are processed.
1359
+ * The callback receives the new facts as event-like objects for convenience.
1360
+ */
1361
+ subscribeToEvents(callback: (events: PraxisEvent[]) => void, query?: unknown): () => void;
1362
+ /**
1363
+ * Attach the adapter to an engine
1364
+ */
1365
+ attachEngine(engine: LogicEngine<TContext>): void;
1366
+ /**
1367
+ * Dispose of resources
1368
+ */
1369
+ dispose(): void;
1370
+ }
1371
+ /**
1372
+ * Options for creating a PluresDB adapter
1373
+ */
1374
+ interface PluresDBAdapterOptions<TContext = unknown> {
1375
+ /** The PraxisDB instance to use */
1376
+ db: PraxisDB;
1377
+ /** The PraxisRegistry for rules and constraints */
1378
+ registry: PraxisRegistry<TContext>;
1379
+ /** Initial context */
1380
+ initialContext?: TContext;
1381
+ }
1382
+ /**
1383
+ * Create a PluresDB adapter with full implementation
1384
+ *
1385
+ * @example
1386
+ * ```typescript
1387
+ * const db = createInMemoryDB();
1388
+ * const registry = new PraxisRegistry();
1389
+ * const adapter = createPluresDBAdapter({ db, registry });
1390
+ *
1391
+ * const engine = createPraxisEngine({ initialContext: {}, registry });
1392
+ * adapter.attachEngine(engine);
1393
+ *
1394
+ * await adapter.persistFacts([{ tag: "UserLoggedIn", payload: { userId: "alice" } }]);
1395
+ * ```
1396
+ */
1397
+ declare function createPluresDBAdapter<TContext = unknown>(options: PluresDBAdapterOptions<TContext>): PluresDBAdapter<TContext>;
1398
+ /**
1399
+ * Attach a PraxisDBStore to a LogicEngine
1400
+ *
1401
+ * This function creates a bidirectional connection between the store and engine:
1402
+ * - Events processed by the engine are persisted to the store
1403
+ * - Facts from the store are synchronized to the engine
1404
+ *
1405
+ * @param store The PraxisDBStore instance
1406
+ * @param engine The LogicEngine instance
1407
+ * @returns Cleanup function to detach the store
1408
+ *
1409
+ * @example
1410
+ * ```typescript
1411
+ * const db = createInMemoryDB();
1412
+ * const registry = new PraxisRegistry();
1413
+ * const store = createPraxisDBStore(db, registry);
1414
+ * const engine = createPraxisEngine({ initialContext: {}, registry });
1415
+ *
1416
+ * const detach = attachToEngine(store, engine);
1417
+ *
1418
+ * // Events are now automatically persisted
1419
+ * engine.step([{ tag: "LOGIN", payload: { username: "alice" } }]);
1420
+ *
1421
+ * // Cleanup
1422
+ * detach();
1423
+ * ```
1424
+ */
1425
+ declare function attachToEngine<TContext = unknown>(store: PraxisDBStore<TContext>, engine: LogicEngine<TContext>): UnsubscribeFn;
1426
+
1427
+ /**
1428
+ * Unum Integration
1429
+ *
1430
+ * Integration with plures/unum - A modern Svelte binding library for PluresDB
1431
+ * with full Svelte 5 compatibility. Provides identity and channels support.
1432
+ *
1433
+ * Features:
1434
+ * - Svelte 4 & 5 Compatible: Works with both store-based and runes-based reactivity
1435
+ * - Type-Safe: Full TypeScript support with proper types
1436
+ * - Action-Based: Modern Svelte actions for DOM binding
1437
+ * - Store-Based: Writable store implementation for reactive data
1438
+ * - Collection Support: Easy handling of PluresDB collections
1439
+ *
1440
+ * @see https://github.com/plures/unum
1441
+ */
1442
+
1443
+ /**
1444
+ * Unum store interface for reactive PluresDB data
1445
+ */
1446
+ interface UnumStore<T> {
1447
+ subscribe(run: (value: T) => void): () => void;
1448
+ set(value: T): void;
1449
+ update(updater: (value: T) => T): void;
1450
+ }
1451
+ /**
1452
+ * Unum channel for real-time communication
1453
+ */
1454
+ interface UnumChannel {
1455
+ /** Channel identifier */
1456
+ id: string;
1457
+ /** Channel name */
1458
+ name: string;
1459
+ /** Subscribe to channel messages */
1460
+ subscribe(handler: (message: UnumMessage) => void): () => void;
1461
+ /** Publish a message to the channel */
1462
+ publish(message: Omit<UnumMessage, 'timestamp' | 'channelId'>): Promise<void>;
1463
+ /** Get channel members */
1464
+ getMembers(): Promise<UnumIdentity[]>;
1465
+ /** Leave the channel */
1466
+ leave(): Promise<void>;
1467
+ }
1468
+ /**
1469
+ * Message sent through a Unum channel
1470
+ */
1471
+ interface UnumMessage {
1472
+ /** Message ID */
1473
+ id: string;
1474
+ /** Channel ID */
1475
+ channelId: string;
1476
+ /** Sender identity */
1477
+ sender: UnumIdentity;
1478
+ /** Message content */
1479
+ content: unknown;
1480
+ /** Message type */
1481
+ type: 'text' | 'event' | 'fact' | 'system';
1482
+ /** Timestamp */
1483
+ timestamp: number;
1484
+ }
1485
+ /**
1486
+ * Unum identity representing a user or system
1487
+ */
1488
+ interface UnumIdentity {
1489
+ /** Unique identifier */
1490
+ id: string;
1491
+ /** Display name */
1492
+ name?: string;
1493
+ /** Public key for encryption */
1494
+ publicKey?: string;
1495
+ /** Identity metadata */
1496
+ metadata?: Record<string, unknown>;
1497
+ /** Creation timestamp */
1498
+ createdAt: number;
1499
+ /** Last seen timestamp */
1500
+ lastSeen?: number;
1501
+ }
1502
+ /**
1503
+ * Unum adapter configuration
1504
+ */
1505
+ interface UnumAdapterConfig {
1506
+ /** PluresDB instance to use */
1507
+ db: PraxisDB;
1508
+ /** Current user identity */
1509
+ identity?: UnumIdentity;
1510
+ /** Whether to enable real-time sync */
1511
+ realtime?: boolean;
1512
+ /** Sync interval in milliseconds */
1513
+ syncInterval?: number;
1514
+ }
1515
+ /**
1516
+ * Unum adapter for Praxis engine integration
1517
+ *
1518
+ * Provides identity management and channel-based communication
1519
+ * for distributed Praxis applications.
1520
+ */
1521
+ interface UnumAdapter {
1522
+ /** Current identity */
1523
+ identity: UnumIdentity | null;
1524
+ /** Create or update identity */
1525
+ setIdentity(identity: Omit<UnumIdentity, 'id' | 'createdAt'>): Promise<UnumIdentity>;
1526
+ /** Get identity by ID */
1527
+ getIdentity(id: string): Promise<UnumIdentity | null>;
1528
+ /** Create a new channel */
1529
+ createChannel(name: string, members?: string[]): Promise<UnumChannel>;
1530
+ /** Join an existing channel */
1531
+ joinChannel(channelId: string): Promise<UnumChannel>;
1532
+ /** List available channels */
1533
+ listChannels(): Promise<UnumChannel[]>;
1534
+ /** Broadcast a Praxis event to a channel */
1535
+ broadcastEvent(channelId: string, event: PraxisEvent): Promise<void>;
1536
+ /** Broadcast a Praxis fact to a channel */
1537
+ broadcastFact(channelId: string, fact: PraxisFact): Promise<void>;
1538
+ /** Subscribe to events from a channel */
1539
+ subscribeToEvents(channelId: string, handler: (event: PraxisEvent) => void): () => void;
1540
+ /** Subscribe to facts from a channel */
1541
+ subscribeToFacts(channelId: string, handler: (fact: PraxisFact) => void): () => void;
1542
+ /** Disconnect and cleanup */
1543
+ disconnect(): Promise<void>;
1544
+ }
1545
+ /**
1546
+ * Create a Unum adapter for Praxis engine integration
1547
+ *
1548
+ * @example
1549
+ * ```typescript
1550
+ * import { createUnumAdapter } from '@plures/praxis/integrations/unum';
1551
+ * import { createInMemoryDB } from '@plures/praxis/integrations/pluresdb';
1552
+ *
1553
+ * const db = createInMemoryDB();
1554
+ * const unum = await createUnumAdapter({
1555
+ * db,
1556
+ * identity: {
1557
+ * name: 'Alice',
1558
+ * },
1559
+ * realtime: true,
1560
+ * });
1561
+ *
1562
+ * // Create a channel
1563
+ * const channel = await unum.createChannel('my-channel');
1564
+ *
1565
+ * // Broadcast events to the channel
1566
+ * await unum.broadcastEvent(channel.id, myEvent);
1567
+ * ```
1568
+ */
1569
+ declare function createUnumAdapter(config: UnumAdapterConfig): Promise<UnumAdapter>;
1570
+ /**
1571
+ * Attach Unum adapter to a Praxis engine
1572
+ *
1573
+ * Enables automatic event/fact broadcasting to connected channels.
1574
+ * This is a placeholder for future integration where the engine
1575
+ * would emit events that get broadcast to channels.
1576
+ *
1577
+ * @param _engine - The Praxis logic engine
1578
+ * @param _adapter - The Unum adapter
1579
+ * @param _channelId - The channel to broadcast to
1580
+ * @returns Cleanup function
1581
+ */
1582
+ declare function attachUnumToEngine<TContext>(_engine: LogicEngine<TContext>, _adapter: UnumAdapter, _channelId: string): () => void;
1583
+
1584
+ /**
1585
+ * Praxis Schema Format (PSF) Types
1586
+ *
1587
+ * PSF is the canonical AST format that serves as the single source of truth.
1588
+ * All code, canvas, and documentation are derived from or synchronized with PSF.
1589
+ *
1590
+ * Design principles:
1591
+ * - JSON-serializable for persistence and transmission
1592
+ * - Supports bidirectional code ↔ canvas sync
1593
+ * - Complete representation of all Praxis concepts
1594
+ * - Extensible with metadata and custom properties
1595
+ */
1596
+ /**
1597
+ * PSF Schema version
1598
+ */
1599
+ declare const PSF_VERSION: "1.0.0";
1600
+ /**
1601
+ * Root PSF Schema Document
1602
+ */
1603
+ interface PSFSchema {
1604
+ /** PSF format version */
1605
+ $version: typeof PSF_VERSION;
1606
+ /** Schema identifier */
1607
+ id: string;
1608
+ /** Human-readable name */
1609
+ name: string;
1610
+ /** Description */
1611
+ description?: string;
1612
+ /** Creation timestamp */
1613
+ createdAt?: string;
1614
+ /** Last modified timestamp */
1615
+ modifiedAt?: string;
1616
+ /** Facts defined in this schema */
1617
+ facts: PSFFact[];
1618
+ /** Events defined in this schema */
1619
+ events: PSFEvent[];
1620
+ /** Rules defined in this schema */
1621
+ rules: PSFRule[];
1622
+ /** Constraints defined in this schema */
1623
+ constraints: PSFConstraint[];
1624
+ /** Data models */
1625
+ models: PSFModel[];
1626
+ /** UI Components */
1627
+ components: PSFComponent[];
1628
+ /** Flows/Orchestrations */
1629
+ flows: PSFFlow[];
1630
+ /** Documentation metadata */
1631
+ docs?: PSFDocs;
1632
+ /** Additional metadata */
1633
+ metadata?: Record<string, unknown>;
1634
+ /** Canvas layout information for visual editing */
1635
+ canvas?: PSFCanvasLayout;
1636
+ }
1637
+ /**
1638
+ * PSF Fact Definition
1639
+ */
1640
+ interface PSFFact {
1641
+ /** Unique identifier */
1642
+ id: string;
1643
+ /** Fact tag (for type discrimination) */
1644
+ tag: string;
1645
+ /** Description */
1646
+ description?: string;
1647
+ /** Payload schema */
1648
+ payload: PSFPayloadSchema;
1649
+ /** Documentation hints */
1650
+ docs?: PSFDocsHint;
1651
+ /** Canvas position */
1652
+ position?: PSFPosition;
1653
+ /** Metadata */
1654
+ meta?: Record<string, unknown>;
1655
+ }
1656
+ /**
1657
+ * PSF Event Definition
1658
+ */
1659
+ interface PSFEvent {
1660
+ /** Unique identifier */
1661
+ id: string;
1662
+ /** Event tag (for type discrimination) */
1663
+ tag: string;
1664
+ /** Description */
1665
+ description?: string;
1666
+ /** Payload schema */
1667
+ payload: PSFPayloadSchema;
1668
+ /** Documentation hints */
1669
+ docs?: PSFDocsHint;
1670
+ /** Canvas position */
1671
+ position?: PSFPosition;
1672
+ /** Metadata */
1673
+ meta?: Record<string, unknown>;
1674
+ }
1675
+ /**
1676
+ * PSF Rule Definition
1677
+ */
1678
+ interface PSFRule {
1679
+ /** Unique identifier */
1680
+ id: string;
1681
+ /** Human-readable name */
1682
+ name?: string;
1683
+ /** Description */
1684
+ description: string;
1685
+ /** Events that trigger this rule */
1686
+ triggers?: string[];
1687
+ /** Condition expression (DSL or reference) */
1688
+ when?: PSFExpression;
1689
+ /** Action expression (DSL or reference) */
1690
+ then: PSFExpression;
1691
+ /** Priority (higher executes first) */
1692
+ priority?: number;
1693
+ /** Documentation hints */
1694
+ docs?: PSFDocsHint;
1695
+ /** Canvas position */
1696
+ position?: PSFPosition;
1697
+ /** Metadata */
1698
+ meta?: Record<string, unknown>;
1699
+ }
1700
+ /**
1701
+ * PSF Constraint Definition
1702
+ */
1703
+ interface PSFConstraint {
1704
+ /** Unique identifier */
1705
+ id: string;
1706
+ /** Human-readable name */
1707
+ name?: string;
1708
+ /** Description */
1709
+ description: string;
1710
+ /** Check expression */
1711
+ check: PSFExpression;
1712
+ /** Error message when violated */
1713
+ errorMessage: string;
1714
+ /** Severity level */
1715
+ severity?: 'error' | 'warning' | 'info';
1716
+ /** Documentation hints */
1717
+ docs?: PSFDocsHint;
1718
+ /** Canvas position */
1719
+ position?: PSFPosition;
1720
+ /** Metadata */
1721
+ meta?: Record<string, unknown>;
1722
+ }
1723
+ /**
1724
+ * PSF Data Model
1725
+ */
1726
+ interface PSFModel {
1727
+ /** Unique identifier */
1728
+ id: string;
1729
+ /** Model name */
1730
+ name: string;
1731
+ /** Description */
1732
+ description?: string;
1733
+ /** Fields */
1734
+ fields: PSFField[];
1735
+ /** Relationships to other models */
1736
+ relationships?: PSFRelationship[];
1737
+ /** Indexes */
1738
+ indexes?: PSFIndex[];
1739
+ /** Model-level constraints */
1740
+ constraints?: PSFModelConstraint[];
1741
+ /** Documentation hints */
1742
+ docs?: PSFDocsHint;
1743
+ /** Canvas position */
1744
+ position?: PSFPosition;
1745
+ /** Metadata */
1746
+ meta?: Record<string, unknown>;
1747
+ }
1748
+ /**
1749
+ * PSF Model Field
1750
+ */
1751
+ interface PSFField {
1752
+ /** Field name */
1753
+ name: string;
1754
+ /** Field type */
1755
+ type: PSFFieldType;
1756
+ /** Is optional */
1757
+ optional?: boolean;
1758
+ /** Default value */
1759
+ default?: unknown;
1760
+ /** Description */
1761
+ description?: string;
1762
+ /** Validation rules */
1763
+ validation?: PSFValidation[];
1764
+ /** UI hints for form generation */
1765
+ ui?: PSFUIHint;
1766
+ }
1767
+ /**
1768
+ * PSF Field Type
1769
+ */
1770
+ type PSFFieldType = 'string' | 'number' | 'boolean' | 'date' | 'datetime' | 'uuid' | {
1771
+ array: PSFFieldType;
1772
+ } | {
1773
+ object: Record<string, PSFField>;
1774
+ } | {
1775
+ reference: string;
1776
+ } | {
1777
+ enum: string[];
1778
+ } | {
1779
+ union: PSFFieldType[];
1780
+ };
1781
+ /**
1782
+ * PSF Validation Rule
1783
+ */
1784
+ interface PSFValidation {
1785
+ /** Validation type */
1786
+ type: 'required' | 'min' | 'max' | 'minLength' | 'maxLength' | 'pattern' | 'email' | 'url' | 'custom';
1787
+ /** Validation value */
1788
+ value?: unknown;
1789
+ /** Error message */
1790
+ message?: string;
1791
+ }
1792
+ /**
1793
+ * PSF Model Constraint
1794
+ */
1795
+ interface PSFModelConstraint {
1796
+ /** Constraint identifier */
1797
+ id: string;
1798
+ /** Constraint type */
1799
+ type: 'unique' | 'check' | 'foreign_key';
1800
+ /** Fields involved */
1801
+ fields: string[];
1802
+ /** Description */
1803
+ description?: string;
1804
+ /** Additional options */
1805
+ options?: Record<string, unknown>;
1806
+ }
1807
+ /**
1808
+ * PSF Relationship
1809
+ */
1810
+ interface PSFRelationship {
1811
+ /** Relationship name */
1812
+ name: string;
1813
+ /** Relationship type */
1814
+ type: 'one-to-one' | 'one-to-many' | 'many-to-many';
1815
+ /** Target model */
1816
+ target: string;
1817
+ /** Foreign key field */
1818
+ foreignKey?: string;
1819
+ /** Cascade behavior */
1820
+ cascade?: boolean;
1821
+ }
1822
+ /**
1823
+ * PSF Index
1824
+ */
1825
+ interface PSFIndex {
1826
+ /** Index name */
1827
+ name: string;
1828
+ /** Fields to index */
1829
+ fields: string[];
1830
+ /** Is unique index */
1831
+ unique?: boolean;
1832
+ /** Index type */
1833
+ type?: 'btree' | 'hash' | 'fulltext';
1834
+ }
1835
+ /**
1836
+ * PSF Component Definition
1837
+ */
1838
+ interface PSFComponent {
1839
+ /** Unique identifier */
1840
+ id: string;
1841
+ /** Component name */
1842
+ name: string;
1843
+ /** Component type */
1844
+ type: 'form' | 'display' | 'list' | 'navigation' | 'editor' | 'custom';
1845
+ /** Description */
1846
+ description?: string;
1847
+ /** Bound model */
1848
+ model?: string;
1849
+ /** Component properties */
1850
+ props: PSFComponentProp[];
1851
+ /** Component events */
1852
+ events: PSFComponentEvent[];
1853
+ /** Layout configuration */
1854
+ layout?: PSFLayout;
1855
+ /** Styling configuration */
1856
+ styling?: PSFStyling;
1857
+ /** Documentation hints */
1858
+ docs?: PSFDocsHint;
1859
+ /** Canvas position */
1860
+ position?: PSFPosition;
1861
+ /** Metadata */
1862
+ meta?: Record<string, unknown>;
1863
+ }
1864
+ /**
1865
+ * PSF Component Property
1866
+ */
1867
+ interface PSFComponentProp {
1868
+ /** Property name */
1869
+ name: string;
1870
+ /** Property type */
1871
+ type: string;
1872
+ /** Is required */
1873
+ required?: boolean;
1874
+ /** Default value */
1875
+ default?: unknown;
1876
+ /** Description */
1877
+ description?: string;
1878
+ /** Binding expression */
1879
+ binding?: PSFExpression;
1880
+ }
1881
+ /**
1882
+ * PSF Component Event
1883
+ */
1884
+ interface PSFComponentEvent {
1885
+ /** Event name */
1886
+ name: string;
1887
+ /** Payload type */
1888
+ payload?: string;
1889
+ /** Description */
1890
+ description?: string;
1891
+ /** Handler expression */
1892
+ handler?: PSFExpression;
1893
+ }
1894
+ /**
1895
+ * PSF Layout Configuration
1896
+ */
1897
+ interface PSFLayout {
1898
+ /** Layout type */
1899
+ type: 'stack' | 'grid' | 'flex' | 'absolute';
1900
+ /** Direction */
1901
+ direction?: 'horizontal' | 'vertical';
1902
+ /** Gap between items */
1903
+ gap?: number | string;
1904
+ /** Padding */
1905
+ padding?: number | string;
1906
+ /** Alignment */
1907
+ align?: 'start' | 'center' | 'end' | 'stretch';
1908
+ /** Justify */
1909
+ justify?: 'start' | 'center' | 'end' | 'between' | 'around';
1910
+ }
1911
+ /**
1912
+ * PSF Styling Configuration
1913
+ */
1914
+ interface PSFStyling {
1915
+ /** CSS classes */
1916
+ classes?: string[];
1917
+ /** Inline styles */
1918
+ styles?: Record<string, string>;
1919
+ /** Theme tokens */
1920
+ theme?: Record<string, string>;
1921
+ /** Variant */
1922
+ variant?: string;
1923
+ }
1924
+ /**
1925
+ * PSF Flow/Orchestration
1926
+ */
1927
+ interface PSFFlow {
1928
+ /** Unique identifier */
1929
+ id: string;
1930
+ /** Flow name */
1931
+ name: string;
1932
+ /** Description */
1933
+ description?: string;
1934
+ /** Flow type */
1935
+ type: 'sequence' | 'parallel' | 'state-machine' | 'saga';
1936
+ /** Flow steps */
1937
+ steps: PSFFlowStep[];
1938
+ /** Initial state/step */
1939
+ initial?: string;
1940
+ /** Error handling */
1941
+ errorHandling?: PSFErrorHandling;
1942
+ /** Documentation hints */
1943
+ docs?: PSFDocsHint;
1944
+ /** Canvas position */
1945
+ position?: PSFPosition;
1946
+ /** Metadata */
1947
+ meta?: Record<string, unknown>;
1948
+ }
1949
+ /**
1950
+ * PSF Flow Step
1951
+ */
1952
+ interface PSFFlowStep {
1953
+ /** Step identifier */
1954
+ id: string;
1955
+ /** Step name */
1956
+ name?: string;
1957
+ /** Step type */
1958
+ type: 'action' | 'condition' | 'wait' | 'parallel' | 'terminal';
1959
+ /** Action expression */
1960
+ action?: PSFExpression;
1961
+ /** Condition expression */
1962
+ condition?: PSFExpression;
1963
+ /** Next step(s) */
1964
+ next?: string | {
1965
+ [key: string]: string;
1966
+ };
1967
+ /** Timeout in milliseconds */
1968
+ timeout?: number;
1969
+ /** Retry configuration */
1970
+ retry?: PSFRetry;
1971
+ }
1972
+ /**
1973
+ * PSF Retry Configuration
1974
+ */
1975
+ interface PSFRetry {
1976
+ /** Maximum retry attempts */
1977
+ maxAttempts: number;
1978
+ /** Delay between retries (ms) */
1979
+ delay: number;
1980
+ /** Exponential backoff factor */
1981
+ backoff?: number;
1982
+ }
1983
+ /**
1984
+ * PSF Error Handling
1985
+ */
1986
+ interface PSFErrorHandling {
1987
+ /** Global error handler */
1988
+ handler?: PSFExpression;
1989
+ /** Compensation flow */
1990
+ compensation?: string;
1991
+ /** Error policy */
1992
+ policy: 'fail-fast' | 'continue' | 'compensate';
1993
+ }
1994
+ /**
1995
+ * PSF Documentation
1996
+ */
1997
+ interface PSFDocs {
1998
+ /** Overview */
1999
+ overview?: string;
2000
+ /** Getting started guide */
2001
+ gettingStarted?: string;
2002
+ /** Examples */
2003
+ examples?: PSFExample[];
2004
+ /** Additional sections */
2005
+ sections?: PSFDocSection[];
2006
+ /** API documentation configuration */
2007
+ api?: PSFAPIDoc;
2008
+ }
2009
+ /**
2010
+ * PSF Documentation Hint (for individual elements)
2011
+ */
2012
+ interface PSFDocsHint {
2013
+ /** Brief summary */
2014
+ summary?: string;
2015
+ /** Detailed description */
2016
+ details?: string;
2017
+ /** Examples */
2018
+ examples?: string[];
2019
+ /** See also references */
2020
+ seeAlso?: string[];
2021
+ /** Tags for categorization */
2022
+ tags?: string[];
2023
+ /** Deprecation notice */
2024
+ deprecated?: string | boolean;
2025
+ }
2026
+ /**
2027
+ * PSF Example
2028
+ */
2029
+ interface PSFExample {
2030
+ /** Example name */
2031
+ name: string;
2032
+ /** Description */
2033
+ description?: string;
2034
+ /** Code snippet */
2035
+ code: string;
2036
+ /** Language */
2037
+ language?: string;
2038
+ }
2039
+ /**
2040
+ * PSF Documentation Section
2041
+ */
2042
+ interface PSFDocSection {
2043
+ /** Section title */
2044
+ title: string;
2045
+ /** Section content (markdown) */
2046
+ content: string;
2047
+ /** Subsections */
2048
+ children?: PSFDocSection[];
2049
+ }
2050
+ /**
2051
+ * PSF API Documentation Configuration
2052
+ */
2053
+ interface PSFAPIDoc {
2054
+ /** Generate API docs */
2055
+ generate?: boolean;
2056
+ /** Output format */
2057
+ format?: 'markdown' | 'html' | 'json';
2058
+ /** Include private members */
2059
+ includePrivate?: boolean;
2060
+ }
2061
+ /**
2062
+ * PSF Expression (can be inline or reference)
2063
+ */
2064
+ type PSFExpression = {
2065
+ inline: string;
2066
+ language?: 'typescript' | 'javascript';
2067
+ } | {
2068
+ ref: string;
2069
+ };
2070
+ /**
2071
+ * PSF Position (for canvas layout)
2072
+ */
2073
+ interface PSFPosition {
2074
+ /** X coordinate */
2075
+ x: number;
2076
+ /** Y coordinate */
2077
+ y: number;
2078
+ /** Width (optional) */
2079
+ width?: number;
2080
+ /** Height (optional) */
2081
+ height?: number;
2082
+ }
2083
+ /**
2084
+ * PSF UI Hint (for form generation)
2085
+ */
2086
+ interface PSFUIHint {
2087
+ /** Display label */
2088
+ label?: string;
2089
+ /** Placeholder text */
2090
+ placeholder?: string;
2091
+ /** Help text */
2092
+ help?: string;
2093
+ /** Input type override */
2094
+ inputType?: string;
2095
+ /** Component to use */
2096
+ component?: string;
2097
+ /** Hidden from UI */
2098
+ hidden?: boolean;
2099
+ /** Read-only */
2100
+ readonly?: boolean;
2101
+ /** Display order */
2102
+ order?: number;
2103
+ }
2104
+ /**
2105
+ * PSF Payload Schema
2106
+ */
2107
+ interface PSFPayloadSchema {
2108
+ /** Schema type (usually 'object') */
2109
+ type: 'object';
2110
+ /** Properties */
2111
+ properties: Record<string, PSFPropertySchema>;
2112
+ /** Required properties */
2113
+ required?: string[];
2114
+ }
2115
+ /**
2116
+ * PSF Property Schema
2117
+ */
2118
+ interface PSFPropertySchema {
2119
+ /** Property type */
2120
+ type: PSFFieldType | 'string' | 'number' | 'boolean' | 'array' | 'object';
2121
+ /** Description */
2122
+ description?: string;
2123
+ /** Default value */
2124
+ default?: unknown;
2125
+ /** Array items schema */
2126
+ items?: PSFPropertySchema;
2127
+ /** Nested properties (for object type) */
2128
+ properties?: Record<string, PSFPropertySchema>;
2129
+ }
2130
+ /**
2131
+ * PSF Canvas Layout (for visual editor)
2132
+ */
2133
+ interface PSFCanvasLayout {
2134
+ /** Viewport settings */
2135
+ viewport?: {
2136
+ x: number;
2137
+ y: number;
2138
+ zoom: number;
2139
+ };
2140
+ /** Grid settings */
2141
+ grid?: {
2142
+ enabled: boolean;
2143
+ size: number;
2144
+ snap: boolean;
2145
+ };
2146
+ /** Node groups */
2147
+ groups?: PSFCanvasGroup[];
2148
+ /** Connections between nodes */
2149
+ connections?: PSFCanvasConnection[];
2150
+ }
2151
+ /**
2152
+ * PSF Canvas Group
2153
+ */
2154
+ interface PSFCanvasGroup {
2155
+ /** Group identifier */
2156
+ id: string;
2157
+ /** Group name */
2158
+ name: string;
2159
+ /** Color */
2160
+ color?: string;
2161
+ /** Collapsed state */
2162
+ collapsed?: boolean;
2163
+ /** Position */
2164
+ position: PSFPosition;
2165
+ /** Member node IDs */
2166
+ members: string[];
2167
+ }
2168
+ /**
2169
+ * PSF Canvas Connection
2170
+ */
2171
+ interface PSFCanvasConnection {
2172
+ /** Connection identifier */
2173
+ id: string;
2174
+ /** Source node ID */
2175
+ source: string;
2176
+ /** Source port */
2177
+ sourcePort?: string;
2178
+ /** Target node ID */
2179
+ target: string;
2180
+ /** Target port */
2181
+ targetPort?: string;
2182
+ /** Connection type */
2183
+ type?: 'data' | 'control' | 'event';
2184
+ /** Label */
2185
+ label?: string;
2186
+ }
2187
+
2188
+ /**
2189
+ * CodeCanvas Integration
2190
+ *
2191
+ * Integration with plures/code-canvas - A visual schema editor and FSM enforcement tool.
2192
+ * Provides visual editing capabilities for Praxis schemas and logic flows.
2193
+ *
2194
+ * Features:
2195
+ * - Visual Schema Editor: Drag-and-drop interface for schema design
2196
+ * - FSM Visualization: Mermaid and DOT graph generation
2197
+ * - State Lifecycle Management: Activity tracking and validation
2198
+ * - Canvas Export/Import: YAML and JSON Canvas formats
2199
+ * - Guardian Integration: Pre-commit validation and rules enforcement
2200
+ *
2201
+ * @see https://github.com/plures/code-canvas
2202
+ */
2203
+
2204
+ /**
2205
+ * Canvas node representing a visual element
2206
+ */
2207
+ interface CanvasNode {
2208
+ /** Unique node identifier */
2209
+ id: string;
2210
+ /** Node type */
2211
+ type: 'model' | 'component' | 'event' | 'fact' | 'rule' | 'constraint' | 'state' | 'transition';
2212
+ /** Node label/name */
2213
+ label: string;
2214
+ /** X position */
2215
+ x: number;
2216
+ /** Y position */
2217
+ y: number;
2218
+ /** Width */
2219
+ width: number;
2220
+ /** Height */
2221
+ height: number;
2222
+ /** Node data (model, component, etc.) */
2223
+ data?: unknown;
2224
+ /** Node style */
2225
+ style?: CanvasNodeStyle;
2226
+ /** FSM state reference */
2227
+ fsmState?: string;
2228
+ }
2229
+ /**
2230
+ * Canvas edge representing a connection between nodes
2231
+ */
2232
+ interface CanvasEdge {
2233
+ /** Unique edge identifier */
2234
+ id: string;
2235
+ /** Source node ID */
2236
+ source: string;
2237
+ /** Target node ID */
2238
+ target: string;
2239
+ /** Edge label */
2240
+ label?: string;
2241
+ /** Edge type */
2242
+ type?: 'dependency' | 'transition' | 'trigger' | 'reference' | 'event';
2243
+ /** Edge style */
2244
+ style?: CanvasEdgeStyle;
2245
+ }
2246
+ /**
2247
+ * Node style configuration
2248
+ */
2249
+ interface CanvasNodeStyle {
2250
+ /** Background color */
2251
+ backgroundColor?: string;
2252
+ /** Border color */
2253
+ borderColor?: string;
2254
+ /** Border width */
2255
+ borderWidth?: number;
2256
+ /** Text color */
2257
+ textColor?: string;
2258
+ /** Font size */
2259
+ fontSize?: number;
2260
+ /** Border radius */
2261
+ borderRadius?: number;
2262
+ }
2263
+ /**
2264
+ * Edge style configuration
2265
+ */
2266
+ interface CanvasEdgeStyle {
2267
+ /** Stroke color */
2268
+ strokeColor?: string;
2269
+ /** Stroke width */
2270
+ strokeWidth?: number;
2271
+ /** Stroke style */
2272
+ strokeDasharray?: string;
2273
+ /** Arrow type */
2274
+ arrowType?: 'arrow' | 'none' | 'circle';
2275
+ }
2276
+ /**
2277
+ * Canvas document containing nodes and edges
2278
+ */
2279
+ interface CanvasDocument {
2280
+ /** Document identifier */
2281
+ id: string;
2282
+ /** Document name */
2283
+ name: string;
2284
+ /** Document version */
2285
+ version: string;
2286
+ /** All nodes in the canvas */
2287
+ nodes: CanvasNode[];
2288
+ /** All edges in the canvas */
2289
+ edges: CanvasEdge[];
2290
+ /** Logic flows */
2291
+ flows?: PSFFlow[];
2292
+ /** Document metadata */
2293
+ metadata?: {
2294
+ created: number;
2295
+ modified: number;
2296
+ author?: string;
2297
+ description?: string;
2298
+ };
2299
+ /** Viewport settings */
2300
+ viewport?: {
2301
+ x: number;
2302
+ y: number;
2303
+ zoom: number;
2304
+ };
2305
+ }
2306
+ /**
2307
+ * FSM lifecycle state
2308
+ */
2309
+ interface LifecycleState {
2310
+ /** State identifier */
2311
+ id: string;
2312
+ /** State name */
2313
+ name: string;
2314
+ /** State description */
2315
+ description?: string;
2316
+ /** Allowed transitions from this state */
2317
+ transitions: string[];
2318
+ /** Entry actions */
2319
+ onEntry?: string[];
2320
+ /** Exit actions */
2321
+ onExit?: string[];
2322
+ /** Is this an initial state */
2323
+ initial?: boolean;
2324
+ /** Is this a final state */
2325
+ final?: boolean;
2326
+ }
2327
+ /**
2328
+ * Activity tracking for current work context
2329
+ */
2330
+ interface ActivityState {
2331
+ /** Current activity type */
2332
+ activity: 'designing' | 'implementing' | 'testing' | 'documenting' | 'reviewing';
2333
+ /** Actor performing the activity */
2334
+ actor: string;
2335
+ /** Current intent/goal */
2336
+ intent?: string;
2337
+ /** Started timestamp */
2338
+ startedAt: number;
2339
+ /** Allowed file patterns for this activity */
2340
+ allowedPaths?: string[];
2341
+ }
2342
+ /**
2343
+ * Canvas editor configuration
2344
+ */
2345
+ interface CanvasEditorConfig {
2346
+ /** Canvas document to edit */
2347
+ document?: CanvasDocument;
2348
+ /** Schema to visualize */
2349
+ schema?: PSFSchema;
2350
+ /** Enable FSM validation */
2351
+ enableFSM?: boolean;
2352
+ /** Custom node styles by type */
2353
+ nodeStyles?: Record<string, CanvasNodeStyle>;
2354
+ /** Custom edge styles by type */
2355
+ edgeStyles?: Record<string, CanvasEdgeStyle>;
2356
+ /** Auto-layout algorithm */
2357
+ layout?: 'hierarchical' | 'force' | 'grid' | 'circular';
2358
+ }
2359
+ /**
2360
+ * Guardian validation result
2361
+ */
2362
+ interface GuardianResult {
2363
+ /** Whether validation passed */
2364
+ valid: boolean;
2365
+ /** Validation errors */
2366
+ errors: GuardianError[];
2367
+ /** Validation warnings */
2368
+ warnings: GuardianWarning[];
2369
+ /** Files validated */
2370
+ filesChecked: string[];
2371
+ /** Current activity state */
2372
+ activity?: ActivityState;
2373
+ }
2374
+ /**
2375
+ * Guardian validation error
2376
+ */
2377
+ interface GuardianError {
2378
+ /** Error code */
2379
+ code: string;
2380
+ /** Error message */
2381
+ message: string;
2382
+ /** File path (if applicable) */
2383
+ file?: string;
2384
+ /** Line number (if applicable) */
2385
+ line?: number;
2386
+ /** Rule that was violated */
2387
+ rule?: string;
2388
+ }
2389
+ /**
2390
+ * Guardian validation warning
2391
+ */
2392
+ interface GuardianWarning {
2393
+ /** Warning code */
2394
+ code: string;
2395
+ /** Warning message */
2396
+ message: string;
2397
+ /** File path (if applicable) */
2398
+ file?: string;
2399
+ /** Suggestion for resolution */
2400
+ suggestion?: string;
2401
+ }
2402
+ /**
2403
+ * Create a canvas document from a Praxis schema
2404
+ *
2405
+ * @example
2406
+ * ```typescript
2407
+ * import { schemaToCanvas } from '@plures/praxis/integrations/code-canvas';
2408
+ *
2409
+ * const canvas = schemaToCanvas(mySchema, {
2410
+ * layout: 'hierarchical',
2411
+ * });
2412
+ *
2413
+ * // Export to YAML
2414
+ * const yaml = canvasToYaml(canvas);
2415
+ * ```
2416
+ */
2417
+ declare function schemaToCanvas(schema: PSFSchema, _options?: {
2418
+ layout?: 'hierarchical' | 'force' | 'grid' | 'circular';
2419
+ }): CanvasDocument;
2420
+ /**
2421
+ * Convert a canvas document back to a Praxis schema
2422
+ */
2423
+ declare function canvasToSchema(canvas: CanvasDocument): PSFSchema;
2424
+ /**
2425
+ * Export canvas to YAML format (compatible with Obsidian Canvas)
2426
+ */
2427
+ declare function canvasToYaml(canvas: CanvasDocument): string;
2428
+ /**
2429
+ * Export canvas to Mermaid diagram format
2430
+ */
2431
+ declare function canvasToMermaid(canvas: CanvasDocument): string;
2432
+ /**
2433
+ * Validate files against FSM lifecycle rules
2434
+ *
2435
+ * This provides integration with the CodeCanvas Guardian for pre-commit validation.
2436
+ */
2437
+ declare function validateWithGuardian(files: string[], activity: ActivityState, lifecycle: LifecycleState[]): GuardianResult;
2438
+ /**
2439
+ * Create a CodeCanvas editor instance
2440
+ *
2441
+ * Note: This is a placeholder for the visual editor integration.
2442
+ * The actual visual editor requires a browser environment.
2443
+ */
2444
+ declare function createCanvasEditor(config: CanvasEditorConfig): {
2445
+ document: CanvasDocument;
2446
+ addNode: (node: Omit<CanvasNode, 'id'>) => CanvasNode;
2447
+ removeNode: (id: string) => void;
2448
+ addEdge: (edge: Omit<CanvasEdge, 'id'>) => CanvasEdge;
2449
+ removeEdge: (id: string) => void;
2450
+ toSchema: () => PSFSchema;
2451
+ toYaml: () => string;
2452
+ toMermaid: () => string;
2453
+ };
2454
+
2455
+ /**
2456
+ * State-Docs Integration
2457
+ *
2458
+ * Integration with plures/state-docs - FSM documentation generator for XState projects.
2459
+ * Generates Markdown and Mermaid documentation from Praxis state machines and logic.
2460
+ *
2461
+ * Features:
2462
+ * - Auto-generate documentation from Praxis schemas
2463
+ * - Markdown output with Mermaid diagrams
2464
+ * - State machine visualization
2465
+ * - Transition documentation
2466
+ * - Integration with Praxis logic engine
2467
+ *
2468
+ * @see https://github.com/plures/state-docs
2469
+ */
2470
+
2471
+ /**
2472
+ * State-Docs configuration
2473
+ */
2474
+ interface StateDocsConfig {
2475
+ /** Project title */
2476
+ projectTitle: string;
2477
+ /** Source directory containing schemas */
2478
+ source?: string;
2479
+ /** Target directory for generated docs */
2480
+ target?: string;
2481
+ /** File patterns to include */
2482
+ globs?: string[];
2483
+ /** Visualization settings */
2484
+ visualization?: {
2485
+ /** Output format */
2486
+ format?: 'mermaid' | 'dot';
2487
+ /** Export as PNG */
2488
+ exportPng?: boolean;
2489
+ /** Diagram theme */
2490
+ theme?: 'default' | 'dark' | 'forest' | 'neutral';
2491
+ };
2492
+ /** Template settings */
2493
+ template?: {
2494
+ /** Include table of contents */
2495
+ toc?: boolean;
2496
+ /** Include timestamp */
2497
+ timestamp?: boolean;
2498
+ /** Custom header content */
2499
+ header?: string;
2500
+ /** Custom footer content */
2501
+ footer?: string;
2502
+ };
2503
+ }
2504
+ /**
2505
+ * Generated documentation file
2506
+ */
2507
+ interface GeneratedDoc {
2508
+ /** File path */
2509
+ path: string;
2510
+ /** File content */
2511
+ content: string;
2512
+ /** File type */
2513
+ type: 'markdown' | 'mermaid' | 'dot' | 'json';
2514
+ }
2515
+ /**
2516
+ * State machine representation for documentation
2517
+ */
2518
+ interface StateMachineDoc {
2519
+ /** Machine identifier */
2520
+ id: string;
2521
+ /** Machine name */
2522
+ name: string;
2523
+ /** Machine description */
2524
+ description?: string;
2525
+ /** Initial state */
2526
+ initial?: string;
2527
+ /** All states */
2528
+ states: StateDoc[];
2529
+ /** All transitions */
2530
+ transitions: TransitionDoc[];
2531
+ /** Context type description */
2532
+ context?: string;
2533
+ /** Events that this machine handles */
2534
+ events?: string[];
2535
+ }
2536
+ /**
2537
+ * State documentation
2538
+ */
2539
+ interface StateDoc {
2540
+ /** State identifier */
2541
+ id: string;
2542
+ /** State name */
2543
+ name: string;
2544
+ /** State description */
2545
+ description?: string;
2546
+ /** Is this an initial state */
2547
+ initial?: boolean;
2548
+ /** Is this a final state */
2549
+ final?: boolean;
2550
+ /** Entry actions */
2551
+ onEntry?: string[];
2552
+ /** Exit actions */
2553
+ onExit?: string[];
2554
+ /** State tags */
2555
+ tags?: string[];
2556
+ }
2557
+ /**
2558
+ * Transition documentation
2559
+ */
2560
+ interface TransitionDoc {
2561
+ /** Source state */
2562
+ from: string;
2563
+ /** Target state */
2564
+ to: string;
2565
+ /** Event that triggers the transition */
2566
+ event: string;
2567
+ /** Transition guard condition */
2568
+ guard?: string;
2569
+ /** Actions executed during transition */
2570
+ actions?: string[];
2571
+ /** Transition description */
2572
+ description?: string;
2573
+ }
2574
+ /**
2575
+ * Documentation generator for Praxis schemas
2576
+ */
2577
+ declare class StateDocsGenerator {
2578
+ private config;
2579
+ constructor(config: StateDocsConfig);
2580
+ /**
2581
+ * Generate documentation from a Praxis schema
2582
+ */
2583
+ generateFromSchema(schema: PraxisSchema): GeneratedDoc[];
2584
+ /**
2585
+ * Generate documentation from a Praxis registry
2586
+ */
2587
+ generateFromModule<TContext>(module: PraxisModule<TContext>): GeneratedDoc[];
2588
+ /**
2589
+ * Generate the main schema README
2590
+ */
2591
+ private generateSchemaReadme;
2592
+ /**
2593
+ * Generate models documentation
2594
+ */
2595
+ private generateModelsDoc;
2596
+ /**
2597
+ * Generate components documentation
2598
+ */
2599
+ private generateComponentsDoc;
2600
+ /**
2601
+ * Generate logic documentation
2602
+ */
2603
+ private generateLogicDoc;
2604
+ /**
2605
+ * Generate Mermaid diagram for logic
2606
+ */
2607
+ private generateLogicDiagram;
2608
+ /**
2609
+ * Generate rules documentation
2610
+ */
2611
+ private generateRulesDoc;
2612
+ /**
2613
+ * Generate constraints documentation
2614
+ */
2615
+ private generateConstraintsDoc;
2616
+ /**
2617
+ * Generate state diagram from registry
2618
+ */
2619
+ private generateRegistryDiagram;
2620
+ }
2621
+ /**
2622
+ * Create a State-Docs generator instance
2623
+ *
2624
+ * @example
2625
+ * ```typescript
2626
+ * import { createStateDocsGenerator } from '@plures/praxis/integrations/state-docs';
2627
+ *
2628
+ * const generator = createStateDocsGenerator({
2629
+ * projectTitle: 'My Project',
2630
+ * target: './docs/api',
2631
+ * });
2632
+ *
2633
+ * const docs = generator.generateFromSchema(mySchema);
2634
+ * for (const doc of docs) {
2635
+ * await writeFile(doc.path, doc.content);
2636
+ * }
2637
+ * ```
2638
+ */
2639
+ declare function createStateDocsGenerator(config: StateDocsConfig): StateDocsGenerator;
2640
+ /**
2641
+ * Generate documentation from a schema (convenience function)
2642
+ */
2643
+ declare function generateDocs(schema: PraxisSchema, config: StateDocsConfig): GeneratedDoc[];
2644
+
2645
+ /**
2646
+ * Tauri Integration
2647
+ *
2648
+ * Integration with plures/svelte-tauri-template for cross-platform desktop applications.
2649
+ * Provides Praxis engine integration with Tauri 2 for native desktop capabilities.
2650
+ *
2651
+ * Features:
2652
+ * - Cross-Platform: Windows, macOS, Linux, Android, iOS
2653
+ * - Native Integration: File system, system tray, notifications
2654
+ * - IPC Bridge: Type-safe communication between Rust and TypeScript
2655
+ * - Auto-Updates: Built-in update system
2656
+ * - Code Signing: Support for signed releases
2657
+ *
2658
+ * @see https://github.com/plures/svelte-tauri-template
2659
+ */
2660
+
2661
+ /**
2662
+ * Tauri app configuration
2663
+ */
2664
+ interface TauriAppConfig {
2665
+ /** Application name */
2666
+ name: string;
2667
+ /** Application version */
2668
+ version: string;
2669
+ /** Application identifier (e.g., com.example.myapp) */
2670
+ identifier: string;
2671
+ /** Window configuration */
2672
+ window?: TauriWindowConfig;
2673
+ /** Security configuration */
2674
+ security?: TauriSecurityConfig;
2675
+ /** Update configuration */
2676
+ updates?: TauriUpdateConfig;
2677
+ /** Plugins to enable */
2678
+ plugins?: TauriPlugin[];
2679
+ }
2680
+ /**
2681
+ * Window configuration
2682
+ */
2683
+ interface TauriWindowConfig {
2684
+ /** Window title */
2685
+ title?: string;
2686
+ /** Window width */
2687
+ width?: number;
2688
+ /** Window height */
2689
+ height?: number;
2690
+ /** Minimum width */
2691
+ minWidth?: number;
2692
+ /** Minimum height */
2693
+ minHeight?: number;
2694
+ /** Whether window is resizable */
2695
+ resizable?: boolean;
2696
+ /** Whether window is fullscreen */
2697
+ fullscreen?: boolean;
2698
+ /** Whether to show title bar */
2699
+ decorations?: boolean;
2700
+ /** Whether window is transparent */
2701
+ transparent?: boolean;
2702
+ /** Whether to always be on top */
2703
+ alwaysOnTop?: boolean;
2704
+ /** Center window on screen */
2705
+ center?: boolean;
2706
+ }
2707
+ /**
2708
+ * Security configuration
2709
+ */
2710
+ interface TauriSecurityConfig {
2711
+ /** Content Security Policy */
2712
+ csp?: string;
2713
+ /** Allowed domains for fetch */
2714
+ allowedDomains?: string[];
2715
+ /** Enable dev tools in production */
2716
+ devTools?: boolean;
2717
+ /** Dangerous features to allow */
2718
+ dangerousAllowList?: string[];
2719
+ }
2720
+ /**
2721
+ * Auto-update configuration
2722
+ */
2723
+ interface TauriUpdateConfig {
2724
+ /** Enable auto-updates */
2725
+ enabled: boolean;
2726
+ /** Update endpoint URL */
2727
+ endpoint?: string;
2728
+ /** Update check interval (ms) */
2729
+ checkInterval?: number;
2730
+ /** Whether to install silently */
2731
+ silent?: boolean;
2732
+ /** Public key for update verification */
2733
+ publicKey?: string;
2734
+ }
2735
+ /**
2736
+ * Tauri plugin definition
2737
+ */
2738
+ interface TauriPlugin {
2739
+ /** Plugin name */
2740
+ name: string;
2741
+ /** Plugin version */
2742
+ version?: string;
2743
+ /** Plugin configuration */
2744
+ config?: Record<string, unknown>;
2745
+ }
2746
+ /**
2747
+ * IPC message from frontend to backend
2748
+ */
2749
+ interface TauriCommand<T = unknown> {
2750
+ /** Command name */
2751
+ cmd: string;
2752
+ /** Command payload */
2753
+ payload?: T;
2754
+ }
2755
+ /**
2756
+ * IPC event from backend to frontend
2757
+ */
2758
+ interface TauriEvent<T = unknown> {
2759
+ /** Event name */
2760
+ event: string;
2761
+ /** Event payload */
2762
+ payload?: T;
2763
+ /** Window label that emitted the event */
2764
+ windowLabel?: string;
2765
+ }
2766
+ /**
2767
+ * File system operations
2768
+ */
2769
+ interface TauriFS {
2770
+ /** Read a file */
2771
+ readFile(path: string): Promise<Uint8Array>;
2772
+ /** Read a file as text */
2773
+ readTextFile(path: string): Promise<string>;
2774
+ /** Write to a file */
2775
+ writeFile(path: string, data: Uint8Array): Promise<void>;
2776
+ /** Write text to a file */
2777
+ writeTextFile(path: string, data: string): Promise<void>;
2778
+ /** Check if path exists */
2779
+ exists(path: string): Promise<boolean>;
2780
+ /** Create directory */
2781
+ mkdir(path: string, options?: {
2782
+ recursive?: boolean;
2783
+ }): Promise<void>;
2784
+ /** Remove file or directory */
2785
+ remove(path: string, options?: {
2786
+ recursive?: boolean;
2787
+ }): Promise<void>;
2788
+ /** Rename/move file */
2789
+ rename(oldPath: string, newPath: string): Promise<void>;
2790
+ /** List directory contents */
2791
+ readDir(path: string): Promise<TauriFileEntry[]>;
2792
+ }
2793
+ /**
2794
+ * File entry from directory listing
2795
+ */
2796
+ interface TauriFileEntry {
2797
+ /** File name */
2798
+ name: string;
2799
+ /** Full path */
2800
+ path: string;
2801
+ /** Is directory */
2802
+ isDirectory: boolean;
2803
+ /** Is file */
2804
+ isFile: boolean;
2805
+ /** File size in bytes */
2806
+ size?: number;
2807
+ /** Last modified timestamp */
2808
+ modifiedAt?: number;
2809
+ }
2810
+ /**
2811
+ * System tray operations
2812
+ */
2813
+ interface TauriTray {
2814
+ /** Set tray icon */
2815
+ setIcon(icon: string | Uint8Array): Promise<void>;
2816
+ /** Set tray tooltip */
2817
+ setTooltip(tooltip: string): Promise<void>;
2818
+ /** Set tray menu */
2819
+ setMenu(menu: TauriMenuItem[]): Promise<void>;
2820
+ /** Show tray */
2821
+ show(): Promise<void>;
2822
+ /** Hide tray */
2823
+ hide(): Promise<void>;
2824
+ }
2825
+ /**
2826
+ * Tray menu item
2827
+ */
2828
+ interface TauriMenuItem {
2829
+ /** Item ID */
2830
+ id: string;
2831
+ /** Item label */
2832
+ label: string;
2833
+ /** Is item enabled */
2834
+ enabled?: boolean;
2835
+ /** Is item checked (for checkboxes) */
2836
+ checked?: boolean;
2837
+ /** Submenu items */
2838
+ submenu?: TauriMenuItem[];
2839
+ /** Click handler */
2840
+ onClick?: () => void;
2841
+ }
2842
+ /**
2843
+ * Notification API
2844
+ */
2845
+ interface TauriNotification {
2846
+ /** Send a notification */
2847
+ send(options: TauriNotificationOptions): Promise<void>;
2848
+ /** Request notification permission */
2849
+ requestPermission(): Promise<'granted' | 'denied' | 'default'>;
2850
+ /** Check notification permission */
2851
+ checkPermission(): Promise<'granted' | 'denied' | 'default'>;
2852
+ }
2853
+ /**
2854
+ * Notification options
2855
+ */
2856
+ interface TauriNotificationOptions {
2857
+ /** Notification title */
2858
+ title: string;
2859
+ /** Notification body */
2860
+ body?: string;
2861
+ /** Notification icon */
2862
+ icon?: string;
2863
+ /** Sound to play */
2864
+ sound?: string;
2865
+ }
2866
+ /**
2867
+ * Tauri bridge for Praxis integration
2868
+ *
2869
+ * Provides type-safe access to Tauri APIs from Praxis applications.
2870
+ */
2871
+ interface TauriBridge {
2872
+ /** Application info */
2873
+ app: {
2874
+ name: string;
2875
+ version: string;
2876
+ tauriVersion: string;
2877
+ };
2878
+ /** File system operations */
2879
+ fs: TauriFS;
2880
+ /** System tray operations */
2881
+ tray: TauriTray;
2882
+ /** Notification operations */
2883
+ notification: TauriNotification;
2884
+ /** Invoke a Tauri command */
2885
+ invoke<T = unknown>(cmd: string, payload?: unknown): Promise<T>;
2886
+ /** Listen to a Tauri event */
2887
+ listen<T = unknown>(event: string, handler: (event: TauriEvent<T>) => void): Promise<() => void>;
2888
+ /** Emit a Tauri event */
2889
+ emit(event: string, payload?: unknown): Promise<void>;
2890
+ /** Get window operations */
2891
+ window: {
2892
+ /** Minimize window */
2893
+ minimize(): Promise<void>;
2894
+ /** Maximize window */
2895
+ maximize(): Promise<void>;
2896
+ /** Unmaximize window */
2897
+ unmaximize(): Promise<void>;
2898
+ /** Close window */
2899
+ close(): Promise<void>;
2900
+ /** Toggle fullscreen */
2901
+ toggleFullscreen(): Promise<void>;
2902
+ /** Set window title */
2903
+ setTitle(title: string): Promise<void>;
2904
+ /** Show window */
2905
+ show(): Promise<void>;
2906
+ /** Hide window */
2907
+ hide(): Promise<void>;
2908
+ /** Focus window */
2909
+ focus(): Promise<void>;
2910
+ };
2911
+ /** Check for updates */
2912
+ checkForUpdates(): Promise<TauriUpdateInfo | null>;
2913
+ /** Install update */
2914
+ installUpdate(): Promise<void>;
2915
+ }
2916
+ /**
2917
+ * Update information
2918
+ */
2919
+ interface TauriUpdateInfo {
2920
+ /** New version available */
2921
+ version: string;
2922
+ /** Release date */
2923
+ date: string;
2924
+ /** Release notes */
2925
+ notes?: string;
2926
+ /** Download URL */
2927
+ url: string;
2928
+ }
2929
+ /**
2930
+ * Praxis-Tauri adapter for engine persistence
2931
+ */
2932
+ interface TauriPraxisAdapter<TContext = unknown> {
2933
+ /** Save engine state to file */
2934
+ saveState(state: TContext): Promise<void>;
2935
+ /** Load engine state from file */
2936
+ loadState(): Promise<TContext | null>;
2937
+ /** Save events to file */
2938
+ saveEvents(events: PraxisEvent[]): Promise<void>;
2939
+ /** Load events from file */
2940
+ loadEvents(): Promise<PraxisEvent[]>;
2941
+ /** Watch for file changes */
2942
+ watchStateFile(handler: (state: TContext) => void): Promise<() => void>;
2943
+ /** Get state file path */
2944
+ getStatePath(): string;
2945
+ /** Get events file path */
2946
+ getEventsPath(): string;
2947
+ }
2948
+ /**
2949
+ * Create a mock Tauri bridge for development/testing
2950
+ *
2951
+ * This provides a mock implementation that works without Tauri runtime.
2952
+ */
2953
+ declare function createMockTauriBridge(): TauriBridge;
2954
+ /**
2955
+ * Create a Tauri-Praxis adapter for engine persistence
2956
+ *
2957
+ * @example
2958
+ * ```typescript
2959
+ * import { createTauriPraxisAdapter } from '@plures/praxis/integrations/tauri';
2960
+ *
2961
+ * const adapter = createTauriPraxisAdapter({
2962
+ * bridge: tauriBridge,
2963
+ * statePath: 'app-state.json',
2964
+ * eventsPath: 'app-events.json',
2965
+ * });
2966
+ *
2967
+ * // Save state
2968
+ * await adapter.saveState(engine.getContext());
2969
+ *
2970
+ * // Load state
2971
+ * const savedState = await adapter.loadState();
2972
+ * ```
2973
+ */
2974
+ declare function createTauriPraxisAdapter<TContext = unknown>(options: {
2975
+ bridge: TauriBridge;
2976
+ statePath?: string;
2977
+ eventsPath?: string;
2978
+ }): TauriPraxisAdapter<TContext>;
2979
+ /**
2980
+ * Attach Tauri bridge to a Praxis engine for auto-save
2981
+ *
2982
+ * @example
2983
+ * ```typescript
2984
+ * import { attachTauriToEngine } from '@plures/praxis/integrations/tauri';
2985
+ *
2986
+ * const cleanup = attachTauriToEngine(engine, adapter, {
2987
+ * autoSave: true,
2988
+ * saveInterval: 5000,
2989
+ * });
2990
+ *
2991
+ * // Later, cleanup subscriptions
2992
+ * cleanup();
2993
+ * ```
2994
+ */
2995
+ declare function attachTauriToEngine<TContext>(engine: LogicEngine<TContext>, adapter: TauriPraxisAdapter<TContext>, options?: {
2996
+ autoSave?: boolean;
2997
+ saveInterval?: number;
2998
+ }): () => void;
2999
+ /**
3000
+ * Generate Tauri configuration from Praxis app config
3001
+ */
3002
+ declare function generateTauriConfig(config: TauriAppConfig): Record<string, unknown>;
3003
+
3004
+ export { type ActivityState, type Actor, ActorManager, type CanvasDocument, type CanvasEdge, type CanvasEdgeStyle, type CanvasEditorConfig, type CanvasNode, type CanvasNodeStyle, type ComponentDefinition, ConstraintDescriptor, ConstraintFn, type ConstraintNode, type ConstraintSchema, type DefineConstraintOptions, type DefineModuleOptions, type DefineRuleOptions, type EventDefinition$1 as EventDefinition, type EventStreamEntry, type FactDefinition$1 as FactDefinition, type GeneratedDoc, type GeneratedPluresDBFile, type GraphEdge, type GuardianError, type GuardianResult, type GuardianWarning, InMemoryPraxisDB, type LifecycleState, type LoaderOptions, type LoaderResult, type LogicDefinition, LogicEngine, type ModelDefinition, type NodeBindings, type NodeDefinition, type OrchestrationDefinition, PRAXIS_PATHS, type PluresDBAdapter, type PluresDBAdapterOptions, PluresDBGenerator, type PluresDBGeneratorOptions, type PraxisDB, PraxisDBStore, type PraxisDBStoreOptions, PraxisEvent, PraxisFact, PraxisModule, PraxisRegistry, type PraxisSchema, PraxisSchemaRegistry, PraxisState, type ReactiveEngineOptions, ReactiveLogicEngine, type RegistryGraph, RegistryIntrospector, type RegistrySchema, type RegistryStats, RuleDescriptor, RuleFn, type RuleNode, type RuleSchema, type StateDoc, type StateDocsConfig, StateDocsGenerator, type StateMachineDoc, type StoredSchema, type TauriAppConfig, type TauriBridge, type TauriCommand, type TauriEvent, type TauriFS, type TauriFileEntry, type TauriMenuItem, type TauriNotification, type TauriNotificationOptions, type TauriPlugin, type TauriPraxisAdapter, type TauriSecurityConfig, type TauriTray, type TauriUpdateConfig, type TauriUpdateInfo, type TauriWindowConfig, type TerminalNodeProps, type TransitionDoc, type UnsubscribeFn, type UnumAdapter, type UnumAdapterConfig, type UnumChannel, type UnumIdentity, type UnumMessage, type UnumStore, type ValidationError, type ValidationResult, attachTauriToEngine, attachToEngine, attachUnumToEngine, canvasToMermaid, canvasToSchema, canvasToYaml, createCanvasEditor, createInMemoryDB, createIntrospector, createMockTauriBridge, createPluresDBAdapter, createPluresDBGenerator, createPraxisDBStore, createSchema, createSchemaRegistry, createSchemaTemplate, createStateDocsGenerator, createTauriPraxisAdapter, createTimerActor, createUnumAdapter, defineConstraint, defineEvent, defineFact, defineModule, defineRule, filterEvents, filterFacts, findEvent, findFact, generateDocs, generateId, generateTauriConfig, getEventPath, getFactPath, getSchemaPath, loadSchemaFromJson, loadSchemaFromYaml, registerSchema, schemaToCanvas, validateForGeneration, validateSchema, validateWithGuardian };