@plures/praxis 1.1.3 → 1.2.10

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 (74) hide show
  1. package/FRAMEWORK.md +106 -15
  2. package/README.md +194 -119
  3. package/dist/browser/adapter-CIMBGDC7.js +14 -0
  4. package/dist/browser/chunk-K377RW4V.js +230 -0
  5. package/dist/browser/chunk-MBVHLOU2.js +152 -0
  6. package/dist/browser/{chunk-R45WXWKH.js → chunk-VOMLVI6V.js} +1 -149
  7. package/dist/browser/engine-YJZV4SLD.js +8 -0
  8. package/dist/browser/index.d.ts +161 -5
  9. package/dist/browser/index.js +156 -141
  10. package/dist/browser/integrations/svelte.d.ts +2 -2
  11. package/dist/browser/integrations/svelte.js +2 -1
  12. package/dist/browser/{reactive-engine.svelte-C9OpcTHf.d.ts → reactive-engine.svelte-9aS0kTa8.d.ts} +136 -1
  13. package/dist/node/adapter-75ISSMWD.js +15 -0
  14. package/dist/node/chunk-5RH7UAQC.js +486 -0
  15. package/dist/node/chunk-MBVHLOU2.js +152 -0
  16. package/dist/node/chunk-PRPQO6R5.js +85 -0
  17. package/dist/node/chunk-R2PSBPKQ.js +150 -0
  18. package/dist/node/chunk-S54337I5.js +446 -0
  19. package/dist/node/{chunk-R45WXWKH.js → chunk-VOMLVI6V.js} +1 -149
  20. package/dist/node/chunk-WZ6B3LZ6.js +638 -0
  21. package/dist/node/cli/index.cjs +2936 -897
  22. package/dist/node/cli/index.js +27 -0
  23. package/dist/node/components/index.d.cts +3 -2
  24. package/dist/node/components/index.d.ts +3 -2
  25. package/dist/node/docs-JFNYTOJA.js +102 -0
  26. package/dist/node/engine-2DQBKBJC.js +9 -0
  27. package/dist/node/index.cjs +1114 -354
  28. package/dist/node/index.d.cts +388 -5
  29. package/dist/node/index.d.ts +388 -5
  30. package/dist/node/index.js +201 -640
  31. package/dist/node/integrations/svelte.cjs +76 -0
  32. package/dist/node/integrations/svelte.d.cts +2 -2
  33. package/dist/node/integrations/svelte.d.ts +2 -2
  34. package/dist/node/integrations/svelte.js +3 -1
  35. package/dist/node/{reactive-engine.svelte-1M4m_C_v.d.cts → reactive-engine.svelte-BFIZfawz.d.cts} +199 -1
  36. package/dist/node/{reactive-engine.svelte-ChNFn4Hj.d.ts → reactive-engine.svelte-CRNqHlbv.d.ts} +199 -1
  37. package/dist/node/reverse-W7THPV45.js +193 -0
  38. package/dist/node/{terminal-adapter-CWka-yL8.d.ts → terminal-adapter-B-UK_Vdz.d.ts} +28 -3
  39. package/dist/node/{terminal-adapter-CDzxoLKR.d.cts → terminal-adapter-BQSIF5bf.d.cts} +28 -3
  40. package/dist/node/validate-CNHUULQE.js +180 -0
  41. package/docs/core/pluresdb-integration.md +15 -15
  42. package/docs/decision-ledger/BEHAVIOR_LEDGER.md +225 -0
  43. package/docs/decision-ledger/DecisionLedger.tla +180 -0
  44. package/docs/decision-ledger/IMPLEMENTATION_SUMMARY.md +217 -0
  45. package/docs/decision-ledger/LATEST.md +166 -0
  46. package/docs/guides/cicd-pipeline.md +142 -0
  47. package/package.json +2 -2
  48. package/src/__tests__/cli-validate.test.ts +197 -0
  49. package/src/__tests__/decision-ledger.test.ts +485 -0
  50. package/src/__tests__/reverse-generator.test.ts +189 -0
  51. package/src/__tests__/scanner.test.ts +215 -0
  52. package/src/cli/commands/docs.ts +147 -0
  53. package/src/cli/commands/reverse.ts +289 -0
  54. package/src/cli/commands/validate.ts +264 -0
  55. package/src/cli/index.ts +68 -0
  56. package/src/core/pluresdb/adapter.ts +46 -3
  57. package/src/core/reactive-engine.svelte.ts +6 -1
  58. package/src/core/reactive-engine.ts +1 -1
  59. package/src/core/rules.ts +133 -0
  60. package/src/decision-ledger/README.md +400 -0
  61. package/src/decision-ledger/REVERSE_ENGINEERING.md +484 -0
  62. package/src/decision-ledger/facts-events.ts +121 -0
  63. package/src/decision-ledger/index.ts +70 -0
  64. package/src/decision-ledger/ledger.ts +246 -0
  65. package/src/decision-ledger/logic-ledger.ts +158 -0
  66. package/src/decision-ledger/reverse-generator.ts +426 -0
  67. package/src/decision-ledger/scanner.ts +506 -0
  68. package/src/decision-ledger/types.ts +247 -0
  69. package/src/decision-ledger/validation.ts +336 -0
  70. package/src/dsl/index.ts +13 -2
  71. package/src/index.browser.ts +6 -0
  72. package/src/index.ts +40 -0
  73. package/src/integrations/pluresdb.ts +14 -2
  74. package/src/integrations/unified.ts +350 -0
@@ -1,5 +1,6 @@
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 './reactive-engine.svelte-C9OpcTHf.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, p as ReactiveEngineOptions, q as ReactiveLogicEngine, l as RuleId, o as createPraxisEngine, r as createReactiveEngine } from './reactive-engine.svelte-C9OpcTHf.js';
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 Contract, f as ConstraintFn, g as PraxisModule } from './reactive-engine.svelte-9aS0kTa8.js';
2
+ export { n as ConstraintId, l as PRAXIS_PROTOCOL_VERSION, h as PraxisDiagnostics, o as PraxisEngineOptions, i as PraxisStepConfig, k as PraxisStepFn, j as PraxisStepResult, q as ReactiveEngineOptions, r as ReactiveLogicEngine, m as RuleId, p as createPraxisEngine, s as createReactiveEngine } from './reactive-engine.svelte-9aS0kTa8.js';
3
+ import { LocalFirstOptions } from '@plures/pluresdb/local-first';
3
4
 
4
5
  /**
5
6
  * Praxis Reactive Logic Engine
@@ -434,6 +435,7 @@ interface DefineRuleOptions<TContext = unknown> {
434
435
  id: string;
435
436
  description: string;
436
437
  impl: RuleFn<TContext>;
438
+ contract?: Contract;
437
439
  meta?: Record<string, unknown>;
438
440
  }
439
441
  /**
@@ -460,6 +462,7 @@ interface DefineConstraintOptions<TContext = unknown> {
460
462
  id: string;
461
463
  description: string;
462
464
  impl: ConstraintFn<TContext>;
465
+ contract?: Contract;
463
466
  meta?: Record<string, unknown>;
464
467
  }
465
468
  /**
@@ -943,6 +946,7 @@ declare function validateForGeneration(schema: PraxisSchema): ValidationResult;
943
946
  * Provides a minimal adapter layer for PluresDB integration.
944
947
  * This module defines the core interface and an in-memory implementation.
945
948
  */
949
+
946
950
  /**
947
951
  * Function to unsubscribe from a watch
948
952
  */
@@ -1013,7 +1017,10 @@ declare function createInMemoryDB(): InMemoryPraxisDB;
1013
1017
  */
1014
1018
  type PluresDBInstance = {
1015
1019
  get(key: string): Promise<any>;
1016
- put(key: string, value: any): Promise<void>;
1020
+ put(key: string, value: any): Promise<any>;
1021
+ delete?(key: string): Promise<void>;
1022
+ list?(): Promise<any[]>;
1023
+ close?(): Promise<void>;
1017
1024
  };
1018
1025
  /**
1019
1026
  * Configuration options for PluresDBPraxisAdapter
@@ -1055,7 +1062,7 @@ declare class PluresDBPraxisAdapter implements PraxisDB {
1055
1062
  *
1056
1063
  * @example
1057
1064
  * ```typescript
1058
- * import { PluresNode } from 'pluresdb';
1065
+ * import { PluresNode } from '@plures/pluresdb';
1059
1066
  * import { createPluresDB } from '@plures/praxis';
1060
1067
  *
1061
1068
  * const pluresdb = new PluresNode({ autoStart: true });
@@ -1075,6 +1082,26 @@ declare class PluresDBPraxisAdapter implements PraxisDB {
1075
1082
  * ```
1076
1083
  */
1077
1084
  declare function createPluresDB(config: PluresDBAdapterConfig | PluresDBInstance): PluresDBPraxisAdapter;
1085
+ /**
1086
+ * Options for creating a local-first PluresDB adapter using the unified API
1087
+ */
1088
+ interface PraxisLocalFirstOptions extends LocalFirstOptions {
1089
+ /** Optional polling interval override for watch semantics (ms). Defaults to 1000ms. */
1090
+ pollInterval?: number;
1091
+ }
1092
+ /**
1093
+ * Create a PraxisDB adapter backed by PluresDB's unified local-first API.
1094
+ *
1095
+ * This will auto-detect the best backend (WASM/Tauri/IPC/network) unless a mode is provided.
1096
+ * Uses dynamic import to avoid bundling the local-first module in environments that don't need it.
1097
+ *
1098
+ * @example
1099
+ * ```typescript
1100
+ * const db = await createPraxisLocalFirst({ mode: 'auto' });
1101
+ * await db.set('/_praxis/facts/user/1', { id: '1', name: 'Alice' });
1102
+ * ```
1103
+ */
1104
+ declare function createPraxisLocalFirst(options?: PraxisLocalFirstOptions): Promise<PluresDBPraxisAdapter>;
1078
1105
 
1079
1106
  /**
1080
1107
  * PraxisDB Store
@@ -3161,4 +3188,133 @@ declare function attachTauriToEngine<TContext>(engine: LogicEngine<TContext>, ad
3161
3188
  */
3162
3189
  declare function generateTauriConfig(config: TauriAppConfig): Record<string, unknown>;
3163
3190
 
3164
- 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, ReactiveLogicEngine as FrameworkAgnosticReactiveEngine, type ReactiveEngineOptions as FrameworkAgnosticReactiveEngineOptions, 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 PluresDBAdapterConfig, type PluresDBAdapterOptions, PluresDBGenerator, type PluresDBGeneratorOptions, type PluresDBInstance, PluresDBPraxisAdapter, type PraxisDB, PraxisDBStore, type PraxisDBStoreOptions, PraxisEvent, PraxisFact, PraxisModule, PraxisRegistry, type PraxisSchema, PraxisSchemaRegistry, PraxisState, type RegistryGraph, RegistryIntrospector, type RegistrySchema, type RegistryStats, RuleDescriptor, RuleFn, type RuleNode, type RuleSchema, type StateChangeCallback, 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, createReactiveEngine as createFrameworkAgnosticReactiveEngine, createInMemoryDB, createIntrospector, createMockTauriBridge, createPluresDB, 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 };
3191
+ /**
3192
+ * Unified Integration Helpers
3193
+ *
3194
+ * Convenience functions for setting up Praxis with all ecosystem integrations
3195
+ * (PluresDB, Unum, State-Docs, CodeCanvas) in a single call.
3196
+ */
3197
+
3198
+ /**
3199
+ * Configuration for unified Praxis application
3200
+ */
3201
+ interface UnifiedAppConfig<TContext = unknown> {
3202
+ /** Praxis registry with rules and constraints */
3203
+ registry: PraxisRegistry<TContext>;
3204
+ /** Initial context for the engine */
3205
+ initialContext: TContext;
3206
+ /** PluresDB instance (if not provided, creates in-memory DB) */
3207
+ db?: PraxisDB;
3208
+ /** Enable Unum for distributed communication */
3209
+ enableUnum?: boolean;
3210
+ /** Unum identity configuration (without id and createdAt which are auto-generated) */
3211
+ unumIdentity?: Omit<UnumIdentity, 'id' | 'createdAt'>;
3212
+ /** Enable State-Docs documentation generation */
3213
+ enableDocs?: boolean;
3214
+ /** State-Docs configuration */
3215
+ docsConfig?: {
3216
+ projectTitle: string;
3217
+ target?: string;
3218
+ };
3219
+ /** Praxis schema for CodeCanvas integration */
3220
+ schema?: PraxisSchema;
3221
+ }
3222
+ /**
3223
+ * Unified application instance with all integrations
3224
+ */
3225
+ interface UnifiedApp<TContext = unknown> {
3226
+ /** Praxis logic engine */
3227
+ engine: LogicEngine<TContext>;
3228
+ /** PluresDB adapter for persistence */
3229
+ pluresdb: PluresDBAdapter<TContext>;
3230
+ /** Unum adapter for distributed communication (if enabled) */
3231
+ unum?: UnumAdapter;
3232
+ /** Default Unum channel (if Unum enabled) */
3233
+ channel?: UnumChannel;
3234
+ /** State-Docs generator (if enabled) */
3235
+ docs?: StateDocsGenerator;
3236
+ /** CodeCanvas document (if schema provided) */
3237
+ canvas?: CanvasDocument;
3238
+ /** Generate documentation from current state */
3239
+ generateDocs?: () => GeneratedDoc[];
3240
+ /** Cleanup function to dispose all integrations */
3241
+ dispose: () => void;
3242
+ }
3243
+ /**
3244
+ * Create a unified Praxis application with all integrations
3245
+ *
3246
+ * This is a convenience function that sets up:
3247
+ * - Praxis logic engine
3248
+ * - PluresDB for persistence (auto-attaches to engine)
3249
+ * - Unum for distributed communication (optional)
3250
+ * - State-Docs for documentation generation (optional)
3251
+ * - CodeCanvas for visual schema editing (optional)
3252
+ *
3253
+ * @example
3254
+ * ```typescript
3255
+ * import { createUnifiedApp } from '@plures/praxis';
3256
+ *
3257
+ * const app = await createUnifiedApp({
3258
+ * registry: myRegistry,
3259
+ * initialContext: { count: 0 },
3260
+ * enableUnum: true,
3261
+ * unumIdentity: { name: 'node-1' },
3262
+ * enableDocs: true,
3263
+ * docsConfig: { projectTitle: 'My App' },
3264
+ * schema: mySchema,
3265
+ * });
3266
+ *
3267
+ * // Use the engine
3268
+ * app.engine.step([myEvent]);
3269
+ *
3270
+ * // Broadcast to other nodes
3271
+ * if (app.channel) {
3272
+ * await app.unum?.broadcastEvent(app.channel.id, myEvent);
3273
+ * }
3274
+ *
3275
+ * // Generate documentation
3276
+ * const docs = app.generateDocs?.();
3277
+ *
3278
+ * // Cleanup
3279
+ * app.dispose();
3280
+ * ```
3281
+ */
3282
+ declare function createUnifiedApp<TContext = unknown>(config: UnifiedAppConfig<TContext>): Promise<UnifiedApp<TContext>>;
3283
+ /**
3284
+ * Attach all available integrations to an existing Praxis engine
3285
+ *
3286
+ * This is useful when you already have an engine and want to add integrations.
3287
+ *
3288
+ * @example
3289
+ * ```typescript
3290
+ * import { createPraxisEngine, attachAllIntegrations } from '@plures/praxis';
3291
+ *
3292
+ * const engine = createPraxisEngine({ initialContext: {}, registry });
3293
+ *
3294
+ * const integrations = await attachAllIntegrations(engine, registry, {
3295
+ * enableUnum: true,
3296
+ * enableDocs: true,
3297
+ * });
3298
+ *
3299
+ * // Later cleanup
3300
+ * integrations.dispose();
3301
+ * ```
3302
+ */
3303
+ declare function attachAllIntegrations<TContext = unknown>(engine: LogicEngine<TContext>, registry: PraxisRegistry<TContext>, options?: {
3304
+ db?: PraxisDB;
3305
+ enableUnum?: boolean;
3306
+ unumIdentity?: Omit<UnumIdentity, 'id' | 'createdAt'>;
3307
+ enableDocs?: boolean;
3308
+ docsConfig?: {
3309
+ projectTitle: string;
3310
+ target?: string;
3311
+ };
3312
+ }): Promise<{
3313
+ pluresdb: PluresDBAdapter<TContext>;
3314
+ unum?: UnumAdapter;
3315
+ channel?: UnumChannel;
3316
+ docs?: StateDocsGenerator;
3317
+ dispose: () => void;
3318
+ }>;
3319
+
3320
+ 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, ReactiveLogicEngine as FrameworkAgnosticReactiveEngine, type ReactiveEngineOptions as FrameworkAgnosticReactiveEngineOptions, 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 PluresDBAdapterConfig, type PluresDBAdapterOptions, PluresDBGenerator, type PluresDBGeneratorOptions, type PluresDBInstance, PluresDBPraxisAdapter, type PraxisDB, PraxisDBStore, type PraxisDBStoreOptions, PraxisEvent, PraxisFact, type PraxisLocalFirstOptions, PraxisModule, PraxisRegistry, type PraxisSchema, PraxisSchemaRegistry, PraxisState, type RegistryGraph, RegistryIntrospector, type RegistrySchema, type RegistryStats, RuleDescriptor, RuleFn, type RuleNode, type RuleSchema, type StateChangeCallback, 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 UnifiedApp, type UnifiedAppConfig, type UnsubscribeFn, type UnumAdapter, type UnumAdapterConfig, type UnumChannel, type UnumIdentity, type UnumMessage, type UnumStore, type ValidationError, type ValidationResult, attachAllIntegrations, attachTauriToEngine, attachToEngine, attachUnumToEngine, canvasToMermaid, canvasToSchema, canvasToYaml, createCanvasEditor, createReactiveEngine as createFrameworkAgnosticReactiveEngine, createInMemoryDB, createIntrospector, createMockTauriBridge, createPluresDB, createPluresDBAdapter, createPluresDBGenerator, createPraxisDBStore, createPraxisLocalFirst, createSchema, createSchemaRegistry, createSchemaTemplate, createStateDocsGenerator, createTauriPraxisAdapter, createTimerActor, createUnifiedApp, createUnumAdapter, defineConstraint, defineEvent, defineFact, defineModule, defineRule, filterEvents, filterFacts, findEvent, findFact, generateDocs, generateId, generateTauriConfig, getEventPath, getFactPath, getSchemaPath, loadSchemaFromJson, loadSchemaFromYaml, registerSchema, schemaToCanvas, validateForGeneration, validateSchema, validateWithGuardian };
@@ -1,11 +1,20 @@
1
1
  import {
2
- LogicEngine,
3
- PRAXIS_PROTOCOL_VERSION,
4
2
  PraxisRegistry,
5
3
  ReactiveLogicEngine,
6
- createPraxisEngine,
7
4
  createReactiveEngine
8
- } from "./chunk-R45WXWKH.js";
5
+ } from "./chunk-K377RW4V.js";
6
+ import {
7
+ LogicEngine,
8
+ PRAXIS_PROTOCOL_VERSION,
9
+ createPraxisEngine
10
+ } from "./chunk-VOMLVI6V.js";
11
+ import {
12
+ InMemoryPraxisDB,
13
+ PluresDBPraxisAdapter,
14
+ createInMemoryDB,
15
+ createPluresDB,
16
+ createPraxisLocalFirst
17
+ } from "./chunk-MBVHLOU2.js";
9
18
 
10
19
  // src/core/reactive-engine.ts
11
20
  var ReactiveLogicEngine2 = class _ReactiveLogicEngine {
@@ -571,19 +580,25 @@ function defineEvent(tag) {
571
580
  };
572
581
  }
573
582
  function defineRule(options) {
583
+ const contract = options.contract ?? options.meta?.contract;
584
+ const meta = contract ? { ...options.meta ?? {}, contract } : options.meta;
574
585
  return {
575
586
  id: options.id,
576
587
  description: options.description,
577
588
  impl: options.impl,
578
- meta: options.meta
589
+ contract,
590
+ meta
579
591
  };
580
592
  }
581
593
  function defineConstraint(options) {
594
+ const contract = options.contract ?? options.meta?.contract;
595
+ const meta = contract ? { ...options.meta ?? {}, contract } : options.meta;
582
596
  return {
583
597
  id: options.id,
584
598
  description: options.description,
585
599
  impl: options.impl,
586
- meta: options.meta
600
+ contract,
601
+ meta
587
602
  };
588
603
  }
589
604
  function defineModule(options) {
@@ -1148,141 +1163,6 @@ function createPraxisDBStore(db, registry, initialContext, onRuleError) {
1148
1163
  return new PraxisDBStore({ db, registry, initialContext, onRuleError });
1149
1164
  }
1150
1165
 
1151
- // src/core/pluresdb/adapter.ts
1152
- var InMemoryPraxisDB = class {
1153
- store = /* @__PURE__ */ new Map();
1154
- watchers = /* @__PURE__ */ new Map();
1155
- async get(key) {
1156
- return this.store.get(key);
1157
- }
1158
- async set(key, value) {
1159
- this.store.set(key, value);
1160
- const keyWatchers = this.watchers.get(key);
1161
- if (keyWatchers) {
1162
- for (const callback of keyWatchers) {
1163
- callback(value);
1164
- }
1165
- }
1166
- }
1167
- watch(key, callback) {
1168
- if (!this.watchers.has(key)) {
1169
- this.watchers.set(key, /* @__PURE__ */ new Set());
1170
- }
1171
- const watchers = this.watchers.get(key);
1172
- const wrappedCallback = (val) => callback(val);
1173
- watchers.add(wrappedCallback);
1174
- return () => {
1175
- watchers.delete(wrappedCallback);
1176
- if (watchers.size === 0) {
1177
- this.watchers.delete(key);
1178
- }
1179
- };
1180
- }
1181
- /**
1182
- * Get all keys (for testing/debugging)
1183
- */
1184
- keys() {
1185
- return Array.from(this.store.keys());
1186
- }
1187
- /**
1188
- * Clear all data (for testing)
1189
- */
1190
- clear() {
1191
- this.store.clear();
1192
- this.watchers.clear();
1193
- }
1194
- };
1195
- function createInMemoryDB() {
1196
- return new InMemoryPraxisDB();
1197
- }
1198
- var PluresDBPraxisAdapter = class {
1199
- db;
1200
- watchers = /* @__PURE__ */ new Map();
1201
- pollIntervals = /* @__PURE__ */ new Map();
1202
- lastValues = /* @__PURE__ */ new Map();
1203
- pollInterval;
1204
- constructor(config) {
1205
- if ("get" in config && "put" in config) {
1206
- this.db = config;
1207
- this.pollInterval = 1e3;
1208
- } else {
1209
- this.db = config.db;
1210
- this.pollInterval = config.pollInterval ?? 1e3;
1211
- }
1212
- }
1213
- async get(key) {
1214
- try {
1215
- const value = await this.db.get(key);
1216
- return value;
1217
- } catch (error) {
1218
- return void 0;
1219
- }
1220
- }
1221
- async set(key, value) {
1222
- await this.db.put(key, value);
1223
- this.lastValues.set(key, value);
1224
- const keyWatchers = this.watchers.get(key);
1225
- if (keyWatchers) {
1226
- for (const callback of keyWatchers) {
1227
- callback(value);
1228
- }
1229
- }
1230
- }
1231
- watch(key, callback) {
1232
- if (!this.watchers.has(key)) {
1233
- this.watchers.set(key, /* @__PURE__ */ new Set());
1234
- }
1235
- const watchers = this.watchers.get(key);
1236
- const wrappedCallback = (val) => callback(val);
1237
- watchers.add(wrappedCallback);
1238
- if (!this.pollIntervals.has(key)) {
1239
- const interval = setInterval(async () => {
1240
- try {
1241
- const value = await this.db.get(key);
1242
- const lastValue = this.lastValues.get(key);
1243
- if (JSON.stringify(value) !== JSON.stringify(lastValue)) {
1244
- this.lastValues.set(key, value);
1245
- const currentWatchers = this.watchers.get(key);
1246
- if (currentWatchers) {
1247
- for (const cb of currentWatchers) {
1248
- cb(value);
1249
- }
1250
- }
1251
- }
1252
- } catch (error) {
1253
- }
1254
- }, this.pollInterval);
1255
- this.pollIntervals.set(key, interval);
1256
- }
1257
- return () => {
1258
- watchers.delete(wrappedCallback);
1259
- if (watchers.size === 0) {
1260
- this.watchers.delete(key);
1261
- const interval = this.pollIntervals.get(key);
1262
- if (interval) {
1263
- clearInterval(interval);
1264
- this.pollIntervals.delete(key);
1265
- }
1266
- this.lastValues.delete(key);
1267
- }
1268
- };
1269
- }
1270
- /**
1271
- * Clean up all resources
1272
- */
1273
- dispose() {
1274
- for (const interval of this.pollIntervals.values()) {
1275
- clearInterval(interval);
1276
- }
1277
- this.pollIntervals.clear();
1278
- this.watchers.clear();
1279
- this.lastValues.clear();
1280
- }
1281
- };
1282
- function createPluresDB(config) {
1283
- return new PluresDBPraxisAdapter(config);
1284
- }
1285
-
1286
1166
  // src/core/pluresdb/schema-registry.ts
1287
1167
  function getSchemaPath(schemaName) {
1288
1168
  return `${PRAXIS_PATHS.SCHEMAS}/${schemaName}`;
@@ -2830,6 +2710,138 @@ function generateTauriConfig(config) {
2830
2710
  plugins: Object.fromEntries((config.plugins || []).map((p) => [p.name, p.config || {}]))
2831
2711
  };
2832
2712
  }
2713
+
2714
+ // src/integrations/unified.ts
2715
+ async function createUnifiedApp(config) {
2716
+ const { createPraxisEngine: createPraxisEngine2 } = await import("./engine-YJZV4SLD.js");
2717
+ const { createInMemoryDB: createInMemoryDB2 } = await import("./adapter-CIMBGDC7.js");
2718
+ const db = config.db || createInMemoryDB2();
2719
+ const pluresdb = createPluresDBAdapter({
2720
+ db,
2721
+ registry: config.registry,
2722
+ initialContext: config.initialContext
2723
+ });
2724
+ const engine = createPraxisEngine2({
2725
+ initialContext: config.initialContext,
2726
+ registry: config.registry
2727
+ });
2728
+ pluresdb.attachEngine(engine);
2729
+ const disposers = [];
2730
+ let unum;
2731
+ let channel;
2732
+ if (config.enableUnum) {
2733
+ const fullIdentity = config.unumIdentity ? {
2734
+ ...config.unumIdentity,
2735
+ id: generateId(),
2736
+ createdAt: Date.now()
2737
+ } : void 0;
2738
+ unum = await createUnumAdapter({
2739
+ db,
2740
+ identity: fullIdentity,
2741
+ realtime: true
2742
+ });
2743
+ channel = await unum.createChannel(
2744
+ config.unumIdentity?.name || "praxis-app",
2745
+ []
2746
+ );
2747
+ const unumDisposer = attachUnumToEngine(engine, unum, channel.id);
2748
+ disposers.push(unumDisposer);
2749
+ }
2750
+ let docs;
2751
+ let generateDocs2;
2752
+ if (config.enableDocs && config.docsConfig) {
2753
+ docs = createStateDocsGenerator({
2754
+ projectTitle: config.docsConfig.projectTitle,
2755
+ target: config.docsConfig.target || "./docs"
2756
+ });
2757
+ generateDocs2 = () => {
2758
+ const module = {
2759
+ rules: config.registry.getAllRules(),
2760
+ constraints: config.registry.getAllConstraints()
2761
+ };
2762
+ return docs.generateFromModule(module);
2763
+ };
2764
+ }
2765
+ let canvas;
2766
+ if (config.schema) {
2767
+ canvas = schemaToCanvas(config.schema, { layout: "hierarchical" });
2768
+ }
2769
+ return {
2770
+ engine,
2771
+ pluresdb,
2772
+ unum,
2773
+ channel,
2774
+ docs,
2775
+ canvas,
2776
+ generateDocs: generateDocs2,
2777
+ dispose: () => {
2778
+ pluresdb.dispose();
2779
+ if (unum) {
2780
+ unum.disconnect().catch((err) => {
2781
+ console.warn("Warning: Error during Unum disconnect:", err);
2782
+ });
2783
+ }
2784
+ for (const disposer of disposers) {
2785
+ disposer();
2786
+ }
2787
+ }
2788
+ };
2789
+ }
2790
+ async function attachAllIntegrations(engine, registry, options = {}) {
2791
+ const { createInMemoryDB: createInMemoryDB2 } = await import("./adapter-CIMBGDC7.js");
2792
+ const db = options.db || createInMemoryDB2();
2793
+ const pluresdb = createPluresDBAdapter({
2794
+ db,
2795
+ registry,
2796
+ initialContext: engine.getContext()
2797
+ });
2798
+ pluresdb.attachEngine(engine);
2799
+ const disposers = [];
2800
+ let unum;
2801
+ let channel;
2802
+ if (options.enableUnum) {
2803
+ const fullIdentity = options.unumIdentity ? {
2804
+ ...options.unumIdentity,
2805
+ id: generateId(),
2806
+ createdAt: Date.now()
2807
+ } : void 0;
2808
+ unum = await createUnumAdapter({
2809
+ db,
2810
+ identity: fullIdentity,
2811
+ realtime: true
2812
+ });
2813
+ channel = await unum.createChannel(
2814
+ options.unumIdentity?.name || "praxis-app",
2815
+ []
2816
+ );
2817
+ const unumDisposer = attachUnumToEngine(engine, unum, channel.id);
2818
+ disposers.push(unumDisposer);
2819
+ }
2820
+ let docs;
2821
+ if (options.enableDocs && options.docsConfig) {
2822
+ docs = createStateDocsGenerator({
2823
+ projectTitle: options.docsConfig.projectTitle,
2824
+ target: options.docsConfig.target || "./docs"
2825
+ });
2826
+ }
2827
+ return {
2828
+ pluresdb,
2829
+ unum,
2830
+ channel,
2831
+ docs,
2832
+ dispose: () => {
2833
+ pluresdb.dispose();
2834
+ if (unum) {
2835
+ unum.disconnect().catch((err) => {
2836
+ console.warn("Warning: Error during Unum disconnect:", err);
2837
+ });
2838
+ }
2839
+ for (const disposer of disposers) {
2840
+ disposer();
2841
+ }
2842
+ }
2843
+ };
2844
+ }
2833
2845
  export {
2834
2846
  ActorManager,
2835
2847
  ReactiveLogicEngine2 as FrameworkAgnosticReactiveEngine,
@@ -2845,6 +2857,7 @@ export {
2845
2857
  ReactiveLogicEngine,
2846
2858
  RegistryIntrospector,
2847
2859
  StateDocsGenerator,
2860
+ attachAllIntegrations,
2848
2861
  attachTauriToEngine,
2849
2862
  attachToEngine,
2850
2863
  attachUnumToEngine,
@@ -2861,6 +2874,7 @@ export {
2861
2874
  createPluresDBGenerator,
2862
2875
  createPraxisDBStore,
2863
2876
  createPraxisEngine,
2877
+ createPraxisLocalFirst,
2864
2878
  createReactiveEngine,
2865
2879
  createSchema,
2866
2880
  createSchemaRegistry,
@@ -2868,6 +2882,7 @@ export {
2868
2882
  createStateDocsGenerator,
2869
2883
  createTauriPraxisAdapter,
2870
2884
  createTimerActor,
2885
+ createUnifiedApp,
2871
2886
  createUnumAdapter,
2872
2887
  defineConstraint,
2873
2888
  defineEvent,
@@ -1,5 +1,5 @@
1
- import { L as LogicEngine, P as PraxisState, a as PraxisEvent } from '../reactive-engine.svelte-C9OpcTHf.js';
2
- export { p as ReactiveEngineOptions, q as ReactiveLogicEngine, r as createReactiveEngine } from '../reactive-engine.svelte-C9OpcTHf.js';
1
+ import { L as LogicEngine, P as PraxisState, a as PraxisEvent } from '../reactive-engine.svelte-9aS0kTa8.js';
2
+ export { q as ReactiveEngineOptions, r as ReactiveLogicEngine, s as createReactiveEngine } from '../reactive-engine.svelte-9aS0kTa8.js';
3
3
 
4
4
  /**
5
5
  * Svelte v5 Integration
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  ReactiveLogicEngine,
3
3
  createReactiveEngine
4
- } from "../chunk-R45WXWKH.js";
4
+ } from "../chunk-K377RW4V.js";
5
+ import "../chunk-VOMLVI6V.js";
5
6
 
6
7
  // src/integrations/svelte.ts
7
8
  function createPraxisStore(engine) {