xcomponent-ai 0.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 (49) hide show
  1. package/CONTRIBUTING.md +195 -0
  2. package/LICENSE +45 -0
  3. package/PERSISTENCE.md +774 -0
  4. package/README.md +594 -0
  5. package/dist/agents.d.ts +81 -0
  6. package/dist/agents.d.ts.map +1 -0
  7. package/dist/agents.js +405 -0
  8. package/dist/agents.js.map +1 -0
  9. package/dist/api.d.ts +36 -0
  10. package/dist/api.d.ts.map +1 -0
  11. package/dist/api.js +404 -0
  12. package/dist/api.js.map +1 -0
  13. package/dist/cli.d.ts +7 -0
  14. package/dist/cli.d.ts.map +1 -0
  15. package/dist/cli.js +437 -0
  16. package/dist/cli.js.map +1 -0
  17. package/dist/component-registry.d.ts +190 -0
  18. package/dist/component-registry.d.ts.map +1 -0
  19. package/dist/component-registry.js +382 -0
  20. package/dist/component-registry.js.map +1 -0
  21. package/dist/fsm-runtime.d.ts +263 -0
  22. package/dist/fsm-runtime.d.ts.map +1 -0
  23. package/dist/fsm-runtime.js +1122 -0
  24. package/dist/fsm-runtime.js.map +1 -0
  25. package/dist/index.d.ts +23 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +56 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/monitoring.d.ts +68 -0
  30. package/dist/monitoring.d.ts.map +1 -0
  31. package/dist/monitoring.js +176 -0
  32. package/dist/monitoring.js.map +1 -0
  33. package/dist/persistence.d.ts +100 -0
  34. package/dist/persistence.d.ts.map +1 -0
  35. package/dist/persistence.js +270 -0
  36. package/dist/persistence.js.map +1 -0
  37. package/dist/timer-wheel.d.ts +85 -0
  38. package/dist/timer-wheel.d.ts.map +1 -0
  39. package/dist/timer-wheel.js +181 -0
  40. package/dist/timer-wheel.js.map +1 -0
  41. package/dist/types.d.ts +404 -0
  42. package/dist/types.d.ts.map +1 -0
  43. package/dist/types.js +40 -0
  44. package/dist/types.js.map +1 -0
  45. package/dist/websockets.d.ts +32 -0
  46. package/dist/websockets.d.ts.map +1 -0
  47. package/dist/websockets.js +117 -0
  48. package/dist/websockets.js.map +1 -0
  49. package/package.json +103 -0
package/README.md ADDED
@@ -0,0 +1,594 @@
1
+ # 🤖 xcomponent-ai
2
+
3
+ [![npm version](https://img.shields.io/npm/v/xcomponent-ai.svg)](https://www.npmjs.com/package/xcomponent-ai)
4
+ [![npm downloads](https://img.shields.io/npm/dm/xcomponent-ai.svg)](https://www.npmjs.com/package/xcomponent-ai)
5
+ [![CI](https://github.com/fredericcarre/mayele-ai/workflows/CI/badge.svg)](https://github.com/fredericcarre/mayele-ai/actions)
6
+ [![Coverage](https://img.shields.io/badge/coverage-79.91%25-brightgreen.svg)](https://github.com/fredericcarre/mayele-ai/actions)
7
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
8
+ [![Node](https://img.shields.io/badge/node-%3E%3D20.0.0-brightgreen.svg)](https://nodejs.org)
9
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-blue.svg)](https://www.typescriptlang.org/)
10
+
11
+ > **LLM-First Framework**: Event-driven FSM runtime designed for AI agents (Claude, GPT) to build applications with sanctuarized business logic. Multi-instance state machines, cross-component communication, event sourcing, and production-ready persistence.
12
+
13
+ **🎯 Built for LLMs**: xcomponent-ai is specifically designed for AI agents to structure applications with immutable business logic in YAML, while code remains a thin integration layer.
14
+
15
+ ## 📦 Installation
16
+
17
+ ```bash
18
+ npm install xcomponent-ai
19
+ ```
20
+
21
+ **Requirements**: Node.js 20.0.0+
22
+
23
+ ## 🤖 For LLMs (Claude, GPT, etc.)
24
+
25
+ **xcomponent-ai is designed to be used by you (LLM) as a structuring framework** for building applications with sanctuarized business logic.
26
+
27
+ ### Quick Pattern
28
+
29
+ When a developer asks you to build an application:
30
+
31
+ ```
32
+ User: "Build a lending platform with credit checks and approval workflow"
33
+
34
+ LLM (You): I'll use xcomponent-ai to structure this with sanctuarized business logic.
35
+
36
+ 1️⃣ Define FSM (immutable business logic):
37
+ fsm/loan-application.yaml → States, guards, compliance rules
38
+
39
+ 2️⃣ Initialize runtime:
40
+ src/runtime/index.ts → FSM runtime setup
41
+
42
+ 3️⃣ Create API layer:
43
+ src/api/loan-routes.ts → HTTP → FSM events (thin wrapper)
44
+
45
+ 4️⃣ Build UI:
46
+ src/ui/LoanForm.tsx → React components reading FSM state
47
+
48
+ Key principle: Business logic lives in YAML, code just connects to it.
49
+ ```
50
+
51
+ **See [LLM Framework Guide](LLM_FRAMEWORK_GUIDE.md) for complete usage patterns.**
52
+
53
+ ```
54
+ my-fintech-app/
55
+ ├── fsm/ # 🔒 SANCTUARIZED (business logic)
56
+ │ ├── *.yaml # Immutable state machines
57
+ ├── src/
58
+ │ ├── runtime/ # xcomponent-ai runtime
59
+ │ ├── api/ # HTTP → FSM events
60
+ │ └── ui/ # UI reading FSM state
61
+ └── tests/fsm/ # FSM simulation tests
62
+ ```
63
+
64
+ **For detailed guidance**, see:
65
+ - **[LLM Framework Guide](LLM_FRAMEWORK_GUIDE.md)** - Complete usage instructions for LLMs
66
+ - **[Full Project Example](examples/full-project-structure.md)** - E-commerce platform example
67
+
68
+ ### Why This Matters
69
+
70
+ ✅ **Separation of concerns**: Business logic (FSM) vs technical code (API/UI)
71
+ ✅ **Auditability**: Compliance officer reviews YAML, not code
72
+ ✅ **Maintainability**: FSM changes are explicit Git commits
73
+ ✅ **LLM-friendly**: Clear structure for code generation
74
+
75
+ ## 🚀 Quick Start
76
+
77
+ > **📖 Full guide: [QUICKSTART.md](QUICKSTART.md)**
78
+
79
+ ### Two Ways to Use xcomponent-ai
80
+
81
+ #### 1️⃣ Standalone CLI (Exploration)
82
+
83
+ ```bash
84
+ npm install -g xcomponent-ai
85
+ xcomponent-ai load examples/trading.yaml
86
+ ```
87
+
88
+ #### 2️⃣ Framework (Production Projects) **← Recommended**
89
+
90
+ ```bash
91
+ npx xcomponent-ai init my-fintech-app
92
+ cd my-fintech-app
93
+ npm install
94
+ # Edit fsm/*.yaml → build API/UI
95
+ ```
96
+
97
+ ### Prerequisites
98
+
99
+ - Node.js ≥ 20.0.0
100
+ - OpenAI API key (for AI agents): `export OPENAI_API_KEY=your_key`
101
+
102
+ ### CLI Usage Examples
103
+
104
+ ```bash
105
+ # Create FSM from natural language (AI-powered)
106
+ xcomponent-ai ai-create "Trading order with compliance guards for amounts over 100k" -o trading.yaml
107
+
108
+ # Load and validate FSM
109
+ xcomponent-ai load examples/trading.yaml
110
+
111
+ # Run instance with events
112
+ xcomponent-ai run examples/payment.yaml Payment \
113
+ --context '{"accountBalance": 5000}' \
114
+ --events '[{"type":"AUTHORIZE_PAYMENT","payload":{"amount":100,"currency":"EUR","paymentMethod":"card"},"timestamp":1234567890}]'
115
+
116
+ # Simulate path
117
+ xcomponent-ai simulate examples/kyc.yaml Onboarding \
118
+ --events '[{"type":"DOCUMENTS_RECEIVED","payload":{"documentType":"passport"},"timestamp":123}]'
119
+
120
+ # Analyze logs with AI insights
121
+ xcomponent-ai ai-analyze TradingComponent
122
+
123
+ # Generate UI code
124
+ xcomponent-ai generate-ui examples/trading.yaml --type api -o generated-api.ts
125
+ ```
126
+
127
+ ### Programmatic Usage
128
+
129
+ ```typescript
130
+ import { FSMRuntime, loadComponent, SupervisorAgent } from 'xcomponent-ai';
131
+ import * as yaml from 'yaml';
132
+ import * as fs from 'fs';
133
+
134
+ // Load component
135
+ const content = fs.readFileSync('examples/trading.yaml', 'utf-8');
136
+ const component = yaml.parse(content);
137
+
138
+ // Create runtime
139
+ const runtime = new FSMRuntime(component);
140
+
141
+ // Create instance
142
+ const instanceId = runtime.createInstance('OrderEntry', {
143
+ amount: 50000,
144
+ instrument: 'AAPL'
145
+ });
146
+
147
+ // Send event
148
+ await runtime.sendEvent(instanceId, {
149
+ type: 'VALIDATE',
150
+ payload: { amount: 50000, instrument: 'AAPL', clientId: 'C123' },
151
+ timestamp: Date.now(),
152
+ });
153
+
154
+ // AI Agent: Create FSM from description
155
+ const supervisor = new SupervisorAgent();
156
+ const result = await supervisor.getFSMAgent().createFSM(
157
+ 'Payment workflow with SCA compliance and refund capability'
158
+ );
159
+ console.log(result.data.yaml);
160
+ ```
161
+
162
+ ### API Server
163
+
164
+ ```bash
165
+ # Start API server
166
+ npm run api
167
+
168
+ # Visit dashboard: http://localhost:3000/dashboard
169
+ # WebSocket: ws://localhost:3000
170
+ ```
171
+
172
+ API endpoints:
173
+ - `POST /api/component/load` - Load component from YAML file
174
+ - `POST /api/:component/:machine/instance` - Create instance
175
+ - `POST /api/:component/instance/:instanceId/event` - Send event
176
+ - `GET /api/:component/instance/:instanceId` - Get instance state
177
+ - `GET /api/monitor/:component` - Get monitoring data
178
+ - `POST /api/ai/create-fsm` - AI-powered FSM creation
179
+ - `POST /api/ai/analyze` - AI log analysis
180
+
181
+ ## 📊 Examples
182
+
183
+ ### Trading Workflow (examples/trading.yaml)
184
+
185
+ ```yaml
186
+ name: TradingComponent
187
+ stateMachines:
188
+ - name: OrderEntry
189
+ initialState: Pending
190
+ states:
191
+ - name: Pending
192
+ type: entry
193
+ - name: Validated
194
+ type: regular
195
+ - name: Executed
196
+ type: regular
197
+ - name: Settled
198
+ type: final
199
+ - name: Rejected
200
+ type: error
201
+ transitions:
202
+ - from: Pending
203
+ to: Validated
204
+ event: VALIDATE
205
+ guards:
206
+ - customFunction: "event.payload.amount <= 100000" # Compliance limit
207
+ triggeredMethod: validateOrderLimits
208
+ - from: Validated
209
+ to: Executed
210
+ event: EXECUTE
211
+ type: triggerable
212
+ - from: Executed
213
+ to: Settled
214
+ event: SETTLEMENT_COMPLETE
215
+ type: inter_machine # Instantiates Settlement machine
216
+ targetMachine: Settlement
217
+ - from: Pending
218
+ to: Rejected
219
+ event: TIMEOUT
220
+ type: timeout
221
+ timeoutMs: 30000
222
+ ```
223
+
224
+ **Features demonstrated**:
225
+ - Compliance guards (amount limits)
226
+ - Inter-machine transitions (Settlement)
227
+ - Timeout handling
228
+ - Error states
229
+
230
+ ### Order Processing with Property Matching (examples/order-processing-xcomponent.yaml)
231
+
232
+ Complete example demonstrating multi-instance routing:
233
+
234
+ ```typescript
235
+ // Create 100 concurrent orders
236
+ for (let i = 1; i <= 100; i++) {
237
+ runtime.createInstance('Order', {
238
+ Id: i,
239
+ AssetName: i % 2 === 0 ? 'AAPL' : 'GOOGL',
240
+ Quantity: 1000,
241
+ RemainingQuantity: 1000,
242
+ ExecutedQuantity: 0
243
+ });
244
+ }
245
+
246
+ // Execute specific order #42 (partial execution)
247
+ await runtime.broadcastEvent('Order', 'Pending', {
248
+ type: 'ExecutionInput',
249
+ payload: { OrderId: 42, Quantity: 500 },
250
+ timestamp: Date.now()
251
+ });
252
+
253
+ // Only Order #42 transitions to PartiallyExecuted
254
+ // Others remain in Pending state
255
+ ```
256
+
257
+ **Features demonstrated**:
258
+ - Property-based instance routing (OrderId matching)
259
+ - Specific triggering rules (full vs partial execution)
260
+ - Public member pattern (business object separation)
261
+ - Scalable multi-instance management (100+ orders)
262
+
263
+ ### KYC Workflow (examples/kyc.yaml)
264
+
265
+ Complete customer onboarding with:
266
+ - RGPD/GDPR consent checks
267
+ - AI document validation
268
+ - AML screening
269
+ - Manual review escalation
270
+
271
+ ### Payment Workflow (examples/payment.yaml)
272
+
273
+ PSD2-compliant payment processing with:
274
+ - Strong Customer Authentication (SCA)
275
+ - Refund capability (inter-machine)
276
+ - Timeout guards
277
+
278
+ ## 🧠 Agentic AI Features
279
+
280
+ ### Supervisor Agent
281
+
282
+ Orchestrates specialized agents based on user intent:
283
+
284
+ ```typescript
285
+ const supervisor = new SupervisorAgent();
286
+ const result = await supervisor.processRequest(
287
+ 'Create a KYC workflow with AML checks and GDPR compliance'
288
+ );
289
+ ```
290
+
291
+ ### FSM Agent
292
+
293
+ - **Create FSM**: Natural language → YAML
294
+ - **Detect Missing Compliance**: Suggests AML, KYC, RGPD guards
295
+ - **Update FSM**: Apply changes via prompts
296
+ - **Simulate Paths**: Test workflows before deployment
297
+
298
+ ```typescript
299
+ const fsmAgent = supervisor.getFSMAgent();
300
+
301
+ // Create
302
+ const result = await fsmAgent.createFSM('Payment with refund');
303
+
304
+ // Get compliance suggestions
305
+ console.log(result.suggestions);
306
+ // ["Consider adding AML/KYC compliance checks", ...]
307
+ ```
308
+
309
+ ### UI Agent
310
+
311
+ Generates Express routes and React components:
312
+
313
+ ```typescript
314
+ const uiAgent = supervisor.getUIAgent();
315
+ const apiCode = await uiAgent.generateAPIRoutes(component);
316
+ const reactCode = await uiAgent.generateReactUI(component);
317
+ ```
318
+
319
+ ### Monitoring Agent
320
+
321
+ Analyzes logs with natural language insights:
322
+
323
+ ```typescript
324
+ const monitoringAgent = supervisor.getMonitoringAgent();
325
+ const analysis = await monitoringAgent.analyzeLogs('TradingComponent');
326
+
327
+ // Insights:
328
+ // "Bottleneck detected: Validated->Executed takes 8.2s on average"
329
+ // "High error rate: 15.3%. Review error states and guards."
330
+ ```
331
+
332
+ ## 📡 Real-time Monitoring
333
+
334
+ ### WebSocket API
335
+
336
+ Subscribe to FSM events:
337
+
338
+ ```javascript
339
+ import io from 'socket.io-client';
340
+
341
+ const socket = io('http://localhost:3000');
342
+
343
+ // Subscribe to component
344
+ socket.emit('subscribe_component', 'TradingComponent');
345
+
346
+ // Listen to state changes
347
+ socket.on('state_change', (data) => {
348
+ console.log(`Instance ${data.instanceId}: ${data.previousState} → ${data.newState}`);
349
+ });
350
+
351
+ // Instance lifecycle
352
+ socket.on('instance_created', (instance) => { ... });
353
+ socket.on('instance_disposed', (instance) => { ... });
354
+ socket.on('instance_error', (error) => { ... });
355
+ ```
356
+
357
+ ### Dashboard
358
+
359
+ Visit `http://localhost:3000/dashboard` for:
360
+ - Active instances table
361
+ - Real-time event stream
362
+ - State visualizations
363
+
364
+ ## 🏗️ Architecture
365
+
366
+ ### FSM Runtime
367
+
368
+ Built on `@xstate/core` with XComponent-inspired enhancements:
369
+ - **Multi-instance management**: Track unlimited concurrent instances
370
+ - **Property matching**: Automatic event routing to instances based on business properties
371
+ - **Event-driven execution**: Pub/Sub + WebSocket broadcasting
372
+ - **Timeout transitions**: Automatic timeouts with configurable delays
373
+ - **Inter-machine workflows**: Create new instances on transition
374
+ - **Guard evaluation**: Conditional transitions (keys, contains, custom functions)
375
+
376
+ See [archi-runtime.mmd](archi-runtime.mmd) for sequence diagram.
377
+
378
+ ### Agentic Layer
379
+
380
+ ```mermaid
381
+ graph TD
382
+ User[User Prompt] --> Supervisor[Supervisor Agent]
383
+ Supervisor --> FSM[FSM Agent]
384
+ Supervisor --> UI[UI Agent]
385
+ Supervisor --> Monitor[Monitoring Agent]
386
+ FSM --> |Create/Update| YAML[FSM YAML]
387
+ FSM --> |Detect| Compliance[Compliance Gaps]
388
+ UI --> |Generate| Code[Express/React Code]
389
+ Monitor --> |Analyze| Insights[Natural Language Insights]
390
+ ```
391
+
392
+ See [archi-agents.mmd](archi-agents.mmd) for detailed flow.
393
+
394
+ ## 🎯 Property Matching & Multi-Instance Routing
395
+
396
+ **XComponent-inspired property matching** enables automatic event routing to instances based on business properties, eliminating manual instance ID tracking.
397
+
398
+ ### The Problem
399
+
400
+ In real-world applications, you often have **many instances of the same state machine** running simultaneously:
401
+ - 100+ active orders
402
+ - 1000+ customer KYC applications
403
+ - Dozens of concurrent trades
404
+
405
+ When an external event arrives, the system needs to **find the correct instance** to update.
406
+
407
+ ### The Solution
408
+
409
+ Property matching automatically routes events to instances where specified properties match:
410
+
411
+ ```yaml
412
+ transitions:
413
+ - from: Pending
414
+ to: Executed
415
+ event: ExecutionInput
416
+ matchingRules:
417
+ - eventProperty: OrderId # Property in event payload
418
+ instanceProperty: Id # Property in instance public member
419
+ ```
420
+
421
+ **How it works**:
422
+ 1. Event arrives: `{ OrderId: 42, Quantity: 500 }`
423
+ 2. System examines ALL `Order` instances in `Pending` state
424
+ 3. For each instance, checks: `event.payload.OrderId === instance.publicMember.Id`
425
+ 4. Routes event ONLY to matching instances
426
+ 5. Other instances remain unaffected
427
+
428
+ ### Usage Example
429
+
430
+ ```typescript
431
+ import { FSMRuntime } from 'xcomponent-ai';
432
+
433
+ const runtime = new FSMRuntime(component);
434
+
435
+ // Create 100 orders
436
+ for (let i = 1; i <= 100; i++) {
437
+ runtime.createInstance('Order', {
438
+ Id: i,
439
+ AssetName: 'AAPL',
440
+ Quantity: 1000,
441
+ RemainingQuantity: 1000
442
+ });
443
+ }
444
+
445
+ // Execute specific order #42
446
+ const processedCount = await runtime.broadcastEvent('Order', 'Pending', {
447
+ type: 'ExecutionInput',
448
+ payload: { OrderId: 42, Quantity: 500 },
449
+ timestamp: Date.now()
450
+ });
451
+
452
+ console.log(`Processed ${processedCount} instances`); // 1
453
+ // Only Order #42 transitioned, others remain in Pending
454
+ ```
455
+
456
+ ### Advanced Features
457
+
458
+ **Nested Property Matching**:
459
+ ```yaml
460
+ matchingRules:
461
+ - eventProperty: customer.id
462
+ instanceProperty: customerId
463
+ ```
464
+
465
+ **Comparison Operators**:
466
+ ```yaml
467
+ matchingRules:
468
+ - eventProperty: threshold
469
+ instanceProperty: balance
470
+ operator: '>' # Also: ===, !==, <, >=, <=
471
+ ```
472
+
473
+ **Specific Triggering Rules** (differentiate multiple transitions):
474
+ ```yaml
475
+ transitions:
476
+ # Full execution
477
+ - from: Pending
478
+ to: FullyExecuted
479
+ event: ExecutionInput
480
+ matchingRules:
481
+ - eventProperty: OrderId
482
+ instanceProperty: Id
483
+ specificTriggeringRule: "event.payload.Quantity === context.RemainingQuantity"
484
+
485
+ # Partial execution
486
+ - from: Pending
487
+ to: PartiallyExecuted
488
+ event: ExecutionInput
489
+ matchingRules:
490
+ - eventProperty: OrderId
491
+ instanceProperty: Id
492
+ specificTriggeringRule: "event.payload.Quantity < context.RemainingQuantity"
493
+ ```
494
+
495
+ **Public Member Pattern** (XComponent convention):
496
+ ```yaml
497
+ stateMachines:
498
+ - name: Order
499
+ publicMemberType: Order # Separates business object from internal state
500
+ ```
501
+
502
+ ### Benefits
503
+
504
+ ✅ **No manual bookkeeping**: No need to maintain external OrderId → InstanceId maps
505
+ ✅ **Survives restarts**: When persistence is added, routing works automatically
506
+ ✅ **Decoupled**: External systems don't need runtime internals
507
+ ✅ **Scalable**: Handles 100-10,000 instances per state efficiently
508
+
509
+ ## 🔐 Open-Core Model
510
+
511
+ ### Free (Apache 2.0)
512
+ - Core FSM runtime
513
+ - CLI and API server
514
+ - Agentic AI layer (FSM, UI, Monitoring agents)
515
+ - WebSocket monitoring
516
+ - All examples and documentation
517
+
518
+ ### Enterprise (Coming Soon)
519
+ - **Cloud Hosting**: Managed runtime with auto-scaling
520
+ - **Advanced AI**: Deep compliance analysis (AML risk scoring, GDPR audit trails)
521
+ - **Enterprise Monitoring**: Grafana/Prometheus integration, alerting, SLA tracking
522
+ - **Premium Support**: Dedicated compliance consulting, custom FSM templates
523
+
524
+ Contact: [dev@xcomponent.com](mailto:dev@xcomponent.com)
525
+
526
+ ## 🧪 Testing
527
+
528
+ ```bash
529
+ # Run all tests
530
+ npm test
531
+
532
+ # With coverage
533
+ npm test -- --coverage
534
+
535
+ # Watch mode
536
+ npm run test:watch
537
+ ```
538
+
539
+ Coverage target: **>80%** (branches, functions, lines, statements)
540
+
541
+ ## 📚 Documentation
542
+
543
+ ```bash
544
+ # Generate API docs
545
+ npm run doc
546
+
547
+ # Open docs/index.html
548
+ ```
549
+
550
+ **Guides**:
551
+ - **[LLM Framework Guide](LLM_FRAMEWORK_GUIDE.md)** - Complete usage for LLMs (Claude/GPT)
552
+ - **[Persistence Guide](PERSISTENCE.md)** - Database configuration and event sourcing
553
+ - **[Quick Start](QUICKSTART.md)** - Getting started guide
554
+ - **[Full Project Example](examples/full-project-structure.md)** - E-commerce application
555
+
556
+ **JSDoc coverage**: All public APIs documented
557
+
558
+ ## 🤝 Contributing
559
+
560
+ We welcome contributions! Please:
561
+ 1. Fork the repository
562
+ 2. Create a feature branch: `git checkout -b feature/my-feature`
563
+ 3. Commit changes: `git commit -m 'Add my feature'`
564
+ 4. Push: `git push origin feature/my-feature`
565
+ 5. Open a Pull Request
566
+
567
+ **Guidelines**:
568
+ - Write tests (maintain >80% coverage)
569
+ - Follow TypeScript strict mode
570
+ - Add JSDoc comments
571
+ - Update README for new features
572
+
573
+ ## 📄 License
574
+
575
+ Apache License 2.0 - see [LICENSE](LICENSE)
576
+
577
+ ## 🙏 Acknowledgments
578
+
579
+ - Inspired by [XComponent](https://github.com/xcomponent/xcomponent) state machine architecture
580
+ - Built with [LangChain.js](https://github.com/langchain-ai/langchainjs)
581
+ - Powered by [XState](https://xstate.js.org/)
582
+
583
+ ## 🔗 Links
584
+
585
+ - **Documentation**: [API Docs](docs/index.html)
586
+ - **Examples**: [examples/](examples/)
587
+ - **Issues**: [GitHub Issues](https://github.com/fredericcarre/mayele-ai/issues)
588
+ - **Discussions**: [GitHub Discussions](https://github.com/fredericcarre/mayele-ai/discussions)
589
+
590
+ ---
591
+
592
+ **Built with ❤️ for secure fintech workflows**
593
+
594
+ *Reduce compliance risks. Accelerate development. Days → Minutes.*
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Agentic AI Layer with LangChain
3
+ * Supervisor LLM orchestrating specialized agents
4
+ */
5
+ import { Component, AgentToolResult } from './types';
6
+ /**
7
+ * FSM Agent - handles FSM creation, updates, and simulation
8
+ */
9
+ export declare class FSMAgent {
10
+ private llm;
11
+ constructor(apiKey?: string);
12
+ /**
13
+ * Create FSM from natural language description
14
+ */
15
+ createFSM(description: string): Promise<AgentToolResult>;
16
+ /**
17
+ * Update existing FSM
18
+ */
19
+ updateFSM(currentYaml: string, changes: string): Promise<AgentToolResult>;
20
+ /**
21
+ * Simulate FSM path
22
+ */
23
+ simulatePath(component: Component, machineName: string, eventDescriptions: string[]): Promise<AgentToolResult>;
24
+ /**
25
+ * Detect missing compliance elements
26
+ */
27
+ private detectMissingCompliance;
28
+ }
29
+ /**
30
+ * UI Agent - generates code wrappers
31
+ */
32
+ export declare class UIAgent {
33
+ private llm;
34
+ constructor(apiKey?: string);
35
+ /**
36
+ * Generate Express API routes for FSM
37
+ */
38
+ generateAPIRoutes(component: Component): Promise<AgentToolResult>;
39
+ /**
40
+ * Generate React UI stub
41
+ */
42
+ generateReactUI(component: Component): Promise<AgentToolResult>;
43
+ }
44
+ /**
45
+ * Monitoring Agent - analyzes logs and provides insights
46
+ */
47
+ export declare class MonitoringAgent {
48
+ private llm;
49
+ constructor(apiKey?: string);
50
+ /**
51
+ * Analyze logs with natural language insights
52
+ */
53
+ analyzeLogs(componentName: string): Promise<AgentToolResult>;
54
+ }
55
+ /**
56
+ * Supervisor Agent - orchestrates other agents
57
+ */
58
+ export declare class SupervisorAgent {
59
+ private fsmAgent;
60
+ private uiAgent;
61
+ private monitoringAgent;
62
+ private llm;
63
+ constructor(apiKey?: string);
64
+ /**
65
+ * Process user request
66
+ */
67
+ processRequest(request: string): Promise<AgentToolResult>;
68
+ /**
69
+ * Get FSM agent
70
+ */
71
+ getFSMAgent(): FSMAgent;
72
+ /**
73
+ * Get UI agent
74
+ */
75
+ getUIAgent(): UIAgent;
76
+ /**
77
+ * Get monitoring agent
78
+ */
79
+ getMonitoringAgent(): MonitoringAgent;
80
+ }
81
+ //# sourceMappingURL=agents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,SAAS,EAAY,eAAe,EAAE,MAAM,SAAS,CAAC;AAK/D;;GAEG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,GAAG,CAAa;gBAEZ,MAAM,CAAC,EAAE,MAAM;IAQ3B;;OAEG;IACG,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAuC9D;;OAEG;IACG,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAiC/E;;OAEG;IACG,YAAY,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC;IAgCpH;;OAEG;IACH,OAAO,CAAC,uBAAuB;CAuChC;AAED;;GAEG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,GAAG,CAAa;gBAEZ,MAAM,CAAC,EAAE,MAAM;IAQ3B;;OAEG;IACG,iBAAiB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,eAAe,CAAC;IA4BvE;;OAEG;IACG,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,eAAe,CAAC;CA2BtE;AAED;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,GAAG,CAAa;gBAEZ,MAAM,CAAC,EAAE,MAAM;IAQ3B;;OAEG;IACG,WAAW,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;CAmCnE;AAED;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,GAAG,CAAa;gBAEZ,MAAM,CAAC,EAAE,MAAM;IAW3B;;OAEG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IA6C/D;;OAEG;IACH,WAAW,IAAI,QAAQ;IAIvB;;OAEG;IACH,UAAU,IAAI,OAAO;IAIrB;;OAEG;IACH,kBAAkB,IAAI,eAAe;CAGtC"}