@mdxui/do 2.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 (42) hide show
  1. package/README.md +412 -0
  2. package/dist/__test-utils__/index.d.ts +399 -0
  3. package/dist/__test-utils__/index.js +34641 -0
  4. package/dist/__test-utils__/index.js.map +1 -0
  5. package/dist/agents-xcIn2dUB.d.ts +832 -0
  6. package/dist/chunk-EEDMN7UF.js +1351 -0
  7. package/dist/chunk-EEDMN7UF.js.map +1 -0
  8. package/dist/chunk-G3PMV62Z.js +33 -0
  9. package/dist/chunk-G3PMV62Z.js.map +1 -0
  10. package/dist/chunk-GGO5GW72.js +695 -0
  11. package/dist/chunk-GGO5GW72.js.map +1 -0
  12. package/dist/chunk-GKSP5RIA.js +3 -0
  13. package/dist/chunk-GKSP5RIA.js.map +1 -0
  14. package/dist/chunk-NXPXL5NA.js +3789 -0
  15. package/dist/chunk-NXPXL5NA.js.map +1 -0
  16. package/dist/chunk-PC5FJY6M.js +20 -0
  17. package/dist/chunk-PC5FJY6M.js.map +1 -0
  18. package/dist/chunk-XF6LKY2M.js +445 -0
  19. package/dist/chunk-XF6LKY2M.js.map +1 -0
  20. package/dist/components/index.d.ts +813 -0
  21. package/dist/components/index.js +8 -0
  22. package/dist/components/index.js.map +1 -0
  23. package/dist/do-CaQVueZw.d.ts +195 -0
  24. package/dist/hooks/index.d.ts +801 -0
  25. package/dist/hooks/index.js +7 -0
  26. package/dist/hooks/index.js.map +1 -0
  27. package/dist/index.d.ts +1012 -0
  28. package/dist/index.js +843 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/magic-string.es-J7BYFTTJ.js +1307 -0
  31. package/dist/magic-string.es-J7BYFTTJ.js.map +1 -0
  32. package/dist/providers/index.d.ts +90 -0
  33. package/dist/providers/index.js +5 -0
  34. package/dist/providers/index.js.map +1 -0
  35. package/dist/schemas/index.d.ts +206 -0
  36. package/dist/schemas/index.js +262 -0
  37. package/dist/schemas/index.js.map +1 -0
  38. package/dist/thing-DtI25yZh.d.ts +902 -0
  39. package/dist/types/index.d.ts +7681 -0
  40. package/dist/types/index.js +5 -0
  41. package/dist/types/index.js.map +1 -0
  42. package/package.json +94 -0
@@ -0,0 +1,832 @@
1
+ import { ExecutionError, TokenUsage } from './schemas/index.js';
2
+
3
+ /**
4
+ * Workflow Types - Business Process Orchestration
5
+ *
6
+ * Workflows orchestrate multi-step business processes using:
7
+ * - Event, schedule, manual, or webhook triggers
8
+ * - Function steps (Code, Generative, Agentic, Human)
9
+ * - Conditional branching and parallel execution
10
+ * - Saga pattern for compensation/rollback
11
+ *
12
+ * @remarks
13
+ * Workflows are implemented via the StateMachine DO using XState v5.
14
+ * Each execution maintains its own state with full audit trail.
15
+ */
16
+
17
+ /**
18
+ * Workflow status
19
+ */
20
+ type WorkflowStatus = 'draft' | 'active' | 'deprecated' | 'archived';
21
+ /**
22
+ * Core workflow definition
23
+ */
24
+ interface Workflow {
25
+ /** Unique workflow identifier */
26
+ id: string;
27
+ /** URL-friendly slug */
28
+ slug: string;
29
+ /** Workflow name */
30
+ name: string;
31
+ /** Description */
32
+ description: string;
33
+ /** Namespace */
34
+ ns: string;
35
+ /** Version */
36
+ version: string;
37
+ /** Workflow status */
38
+ status: WorkflowStatus;
39
+ /** Trigger configuration */
40
+ trigger: WorkflowTrigger;
41
+ /** Workflow steps */
42
+ steps: WorkflowStep[];
43
+ /** Error handling configuration */
44
+ errorHandling: ErrorHandlingConfig;
45
+ /** Compensation steps (saga pattern) */
46
+ compensation?: CompensationConfig;
47
+ /** Workflow configuration */
48
+ config: WorkflowConfig;
49
+ /** Tags */
50
+ tags: string[];
51
+ /** Owner user ID */
52
+ owner: string;
53
+ /** Creation timestamp */
54
+ createdAt: Date;
55
+ /** Last update timestamp */
56
+ updatedAt: Date;
57
+ }
58
+ /**
59
+ * Trigger types
60
+ */
61
+ type TriggerType = 'event' | 'schedule' | 'manual' | 'webhook';
62
+ /**
63
+ * Base trigger configuration
64
+ */
65
+ interface TriggerBase {
66
+ /** Trigger type */
67
+ type: TriggerType;
68
+ /** Trigger name */
69
+ name: string;
70
+ /** Is this trigger enabled? */
71
+ enabled: boolean;
72
+ }
73
+ /**
74
+ * Event trigger - $.Subject.predicate pattern
75
+ */
76
+ interface EventTrigger extends TriggerBase {
77
+ type: 'event';
78
+ /** Event pattern to match ($.Subject.predicate) */
79
+ pattern: string;
80
+ /** Additional filter conditions */
81
+ filter?: Record<string, unknown>;
82
+ /** Batch events */
83
+ batch?: {
84
+ maxSize: number;
85
+ maxWaitMs: number;
86
+ };
87
+ }
88
+ /**
89
+ * Schedule trigger - Cron or interval
90
+ */
91
+ interface ScheduleTrigger extends TriggerBase {
92
+ type: 'schedule';
93
+ /** Cron expression */
94
+ cron?: string;
95
+ /** Interval in seconds */
96
+ intervalSeconds?: number;
97
+ /** Timezone */
98
+ timezone?: string;
99
+ }
100
+ /**
101
+ * Manual trigger - User-initiated
102
+ */
103
+ interface ManualTrigger extends TriggerBase {
104
+ type: 'manual';
105
+ /** Input schema for manual trigger */
106
+ inputSchema?: Record<string, unknown>;
107
+ /** Require approval before execution */
108
+ requireApproval?: boolean;
109
+ /** Allowed users/roles */
110
+ allowedBy?: string[];
111
+ }
112
+ /**
113
+ * Webhook trigger - HTTP endpoint
114
+ */
115
+ interface WebhookTrigger extends TriggerBase {
116
+ type: 'webhook';
117
+ /** Webhook path */
118
+ path: string;
119
+ /** HTTP methods allowed */
120
+ methods: ('GET' | 'POST' | 'PUT' | 'DELETE')[];
121
+ /** Authentication required */
122
+ authentication?: 'none' | 'api-key' | 'jwt' | 'hmac';
123
+ /** Secret for HMAC validation */
124
+ hmacSecret?: string;
125
+ }
126
+ /**
127
+ * Union of all trigger types
128
+ */
129
+ type WorkflowTrigger = EventTrigger | ScheduleTrigger | ManualTrigger | WebhookTrigger;
130
+ /**
131
+ * Step types
132
+ */
133
+ type StepType = 'function' | 'workflow' | 'task' | 'wait' | 'parallel' | 'choice' | 'foreach' | 'http' | 'database' | 'ai' | 'event';
134
+ /**
135
+ * Workflow step definition
136
+ */
137
+ interface WorkflowStep {
138
+ /** Step ID (unique within workflow) */
139
+ id: string;
140
+ /** Step name */
141
+ name: string;
142
+ /** Step type */
143
+ type: StepType;
144
+ /** Step configuration */
145
+ config: StepConfig;
146
+ /** Dependencies (step IDs that must complete first) */
147
+ dependsOn?: string[];
148
+ /** Chain after (for RPC optimization) */
149
+ chainAfter?: string;
150
+ /** Condition (JSONLogic) for conditional execution */
151
+ condition?: Record<string, unknown>;
152
+ /** Retry configuration */
153
+ retry?: RetryConfig;
154
+ /** Timeout in ms */
155
+ timeout?: number;
156
+ /** Output mapping */
157
+ outputMapping?: Record<string, string>;
158
+ }
159
+ /**
160
+ * Step configuration by type
161
+ */
162
+ interface StepConfig {
163
+ /** Function ID (for function steps) */
164
+ functionId?: string;
165
+ /** Workflow ID (for workflow steps) */
166
+ workflowId?: string;
167
+ /** Wait duration in ms (for wait steps) */
168
+ waitMs?: number;
169
+ /** Wait until date/time (for wait steps) */
170
+ waitUntil?: string;
171
+ /** Parallel branches (for parallel steps) */
172
+ branches?: WorkflowStep[][];
173
+ /** Choice conditions (for choice steps) */
174
+ choices?: ChoiceCondition[];
175
+ /** Default branch (for choice steps) */
176
+ default?: WorkflowStep[];
177
+ /** Iterator expression (for foreach steps) */
178
+ iterator?: string;
179
+ /** Loop body (for foreach steps) */
180
+ body?: WorkflowStep[];
181
+ /** HTTP request config (for http steps) */
182
+ http?: HttpStepConfig;
183
+ /** Database query config (for database steps) */
184
+ database?: DatabaseStepConfig;
185
+ /** AI config (for ai steps) */
186
+ ai?: AIStepConfig;
187
+ /** Event config (for event steps) */
188
+ event?: EventStepConfig;
189
+ /** Input mapping (template expressions) */
190
+ input?: Record<string, string>;
191
+ }
192
+ /**
193
+ * Choice condition for branching
194
+ */
195
+ interface ChoiceCondition {
196
+ /** Condition (JSONLogic) */
197
+ condition: Record<string, unknown>;
198
+ /** Steps to execute if condition is true */
199
+ steps: WorkflowStep[];
200
+ }
201
+ /**
202
+ * HTTP step configuration
203
+ */
204
+ interface HttpStepConfig {
205
+ /** URL (supports template expressions) */
206
+ url: string;
207
+ /** HTTP method */
208
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
209
+ /** Headers */
210
+ headers?: Record<string, string>;
211
+ /** Request body */
212
+ body?: unknown;
213
+ /** Response handling */
214
+ responseType?: 'json' | 'text' | 'binary';
215
+ }
216
+ /**
217
+ * Database step configuration
218
+ */
219
+ interface DatabaseStepConfig {
220
+ /** Operation type */
221
+ operation: 'query' | 'insert' | 'update' | 'delete';
222
+ /** Collection/table name */
223
+ collection: string;
224
+ /** Query filter */
225
+ filter?: Record<string, unknown>;
226
+ /** Data for insert/update */
227
+ data?: Record<string, unknown>;
228
+ }
229
+ /**
230
+ * AI step configuration
231
+ */
232
+ interface AIStepConfig {
233
+ /** Prompt (supports template expressions) */
234
+ prompt: string;
235
+ /** Model */
236
+ model: string;
237
+ /** Output schema for structured output */
238
+ outputSchema?: Record<string, unknown>;
239
+ /** Temperature */
240
+ temperature?: number;
241
+ /** Max tokens */
242
+ maxTokens?: number;
243
+ }
244
+ /**
245
+ * Event step configuration (emit event)
246
+ */
247
+ interface EventStepConfig {
248
+ /** Event type/pattern */
249
+ eventType: string;
250
+ /** Event payload (supports template expressions) */
251
+ payload: Record<string, unknown>;
252
+ }
253
+ /**
254
+ * Retry configuration
255
+ */
256
+ interface RetryConfig {
257
+ /** Maximum retry attempts */
258
+ maxAttempts: number;
259
+ /** Backoff strategy */
260
+ backoff: 'exponential' | 'linear' | 'fixed';
261
+ /** Initial delay in ms */
262
+ initialDelayMs: number;
263
+ /** Maximum delay in ms */
264
+ maxDelayMs: number;
265
+ /** Retry on specific errors */
266
+ retryOn?: string[];
267
+ }
268
+ /**
269
+ * Error handling configuration
270
+ */
271
+ interface ErrorHandlingConfig {
272
+ /** Global error strategy */
273
+ strategy: 'retry' | 'compensate' | 'ignore' | 'fail';
274
+ /** Retry config (if strategy is retry) */
275
+ retry?: RetryConfig;
276
+ /** Notification on error */
277
+ notify?: NotificationConfig;
278
+ /** Custom error handler function */
279
+ errorHandler?: string;
280
+ }
281
+ /**
282
+ * Compensation configuration (saga pattern)
283
+ */
284
+ interface CompensationConfig {
285
+ /** Compensation steps (run in reverse order) */
286
+ steps: WorkflowStep[];
287
+ /** Strategy */
288
+ strategy: 'sequential' | 'parallel';
289
+ /** Continue on compensation failure? */
290
+ continueOnFailure: boolean;
291
+ }
292
+ /**
293
+ * Workflow configuration
294
+ */
295
+ interface WorkflowConfig {
296
+ /** Global timeout in ms */
297
+ timeout: number;
298
+ /** Maximum concurrent executions */
299
+ maxConcurrency?: number;
300
+ /** Rate limiting */
301
+ rateLimit?: {
302
+ maxPerMinute: number;
303
+ strategy: 'sliding' | 'fixed';
304
+ };
305
+ /** Execution mode */
306
+ executionMode: 'async' | 'sync';
307
+ /** Store execution history */
308
+ storeHistory: boolean;
309
+ /** Retention period for history in days */
310
+ historyRetentionDays: number;
311
+ }
312
+ /**
313
+ * Notification configuration
314
+ */
315
+ interface NotificationConfig {
316
+ /** Notification channels */
317
+ channels: ('email' | 'slack' | 'webhook')[];
318
+ /** Recipients */
319
+ recipients: string[];
320
+ /** Custom message template */
321
+ messageTemplate?: string;
322
+ }
323
+ /**
324
+ * Execution status
325
+ */
326
+ type ExecutionStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'compensating' | 'compensated';
327
+ /**
328
+ * Workflow execution record
329
+ */
330
+ interface WorkflowExecution {
331
+ /** Execution ID */
332
+ id: string;
333
+ /** Workflow ID */
334
+ workflowId: string;
335
+ /** Workflow version at execution time */
336
+ workflowVersion: string;
337
+ /** Execution status */
338
+ status: ExecutionStatus;
339
+ /** Trigger data */
340
+ trigger: TriggerData;
341
+ /** Execution context */
342
+ context: ExecutionContext;
343
+ /** Step executions */
344
+ steps: StepExecution[];
345
+ /** Start time */
346
+ startedAt: Date;
347
+ /** End time */
348
+ completedAt?: Date;
349
+ /** Duration in ms */
350
+ durationMs?: number;
351
+ /** Error if failed */
352
+ error?: ExecutionError;
353
+ /** Namespace */
354
+ ns: string;
355
+ }
356
+ /**
357
+ * Trigger data (what triggered the execution)
358
+ */
359
+ interface TriggerData {
360
+ /** Trigger type */
361
+ type: TriggerType;
362
+ /** Trigger payload */
363
+ data: Record<string, unknown>;
364
+ /** Trigger timestamp */
365
+ triggeredAt: Date;
366
+ /** Trigger source (user, event, schedule) */
367
+ source: string;
368
+ }
369
+ /**
370
+ * Execution context
371
+ */
372
+ interface ExecutionContext {
373
+ /** Variables (workflow-scoped state) */
374
+ variables: Record<string, unknown>;
375
+ /** Step outputs (step_id -> output) */
376
+ stepOutputs: Record<string, unknown>;
377
+ /** Metadata */
378
+ metadata: Record<string, unknown>;
379
+ }
380
+ /**
381
+ * Step execution record
382
+ */
383
+ interface StepExecution {
384
+ /** Step ID */
385
+ stepId: string;
386
+ /** Step name */
387
+ stepName: string;
388
+ /** Execution status */
389
+ status: ExecutionStatus;
390
+ /** Input provided */
391
+ input: Record<string, unknown>;
392
+ /** Output produced */
393
+ output?: Record<string, unknown>;
394
+ /** Error if failed */
395
+ error?: ExecutionError;
396
+ /** Start time */
397
+ startedAt: Date;
398
+ /** End time */
399
+ completedAt?: Date;
400
+ /** Duration in ms */
401
+ durationMs?: number;
402
+ /** Retry count */
403
+ retryCount: number;
404
+ }
405
+ /**
406
+ * Workflow filter for queries
407
+ */
408
+ interface WorkflowFilter {
409
+ /** Filter by status */
410
+ status?: WorkflowStatus[];
411
+ /** Filter by namespace */
412
+ ns?: string;
413
+ /** Filter by tags */
414
+ tags?: string[];
415
+ /** Filter by trigger type */
416
+ triggerType?: TriggerType[];
417
+ /** Search by name */
418
+ nameSearch?: string;
419
+ /** Filter by owner */
420
+ owner?: string;
421
+ }
422
+ /**
423
+ * Execution filter for queries
424
+ */
425
+ interface ExecutionFilter {
426
+ /** Filter by workflow ID */
427
+ workflowId?: string;
428
+ /** Filter by status */
429
+ status?: ExecutionStatus[];
430
+ /** Filter by trigger type */
431
+ triggerType?: TriggerType[];
432
+ /** Filter by date range */
433
+ startedAfter?: Date;
434
+ startedBefore?: Date;
435
+ /** Filter by namespace */
436
+ ns?: string;
437
+ }
438
+
439
+ /**
440
+ * Agent Types - Autonomous AI Workers
441
+ *
442
+ * Agents are autonomous AI workers derived from:
443
+ * - O*NET occupations (1,459 occupations)
444
+ * - NAICS industries (68 industries)
445
+ * - Task × Tool × Operation combinations
446
+ *
447
+ * This creates 40,000+ potential agent types that can perform
448
+ * specialized work autonomously or semi-autonomously.
449
+ *
450
+ * @remarks
451
+ * Agent classifications:
452
+ * - Digital-first (22%): Remote-only operations
453
+ * - Hybrid (60%): Mix of digital and physical
454
+ * - Embodiment-required (18%): Physical work
455
+ */
456
+
457
+ /**
458
+ * Agent definition
459
+ */
460
+ interface Agent {
461
+ /** Unique agent identifier */
462
+ id: string;
463
+ /** Agent name */
464
+ name: string;
465
+ /** Agent slug (URL-friendly) */
466
+ slug: string;
467
+ /** Agent description */
468
+ description: string;
469
+ /** Namespace */
470
+ ns: string;
471
+ /** Agent type/role */
472
+ type: AgentType;
473
+ /** Classification */
474
+ classification: AgentClassification;
475
+ /** System prompt */
476
+ systemPrompt: string;
477
+ /** Character description (for persona) */
478
+ characterBible?: CharacterBible;
479
+ /** Available tools */
480
+ tools: string[];
481
+ /** AI model to use */
482
+ model: string;
483
+ /** Maximum iterations per execution */
484
+ maxIterations: number;
485
+ /** Thinking budget (for reasoning) */
486
+ thinkingBudget?: number;
487
+ /** Guardrails */
488
+ guardrails: AgentGuardrail[];
489
+ /** Handoff rules */
490
+ handoffRules: HandoffRule[];
491
+ /** Status */
492
+ status: AgentStatus;
493
+ /** Performance metrics */
494
+ metrics?: AgentMetrics;
495
+ /** Creation timestamp */
496
+ createdAt: Date;
497
+ /** Last update timestamp */
498
+ updatedAt: Date;
499
+ /** Creator */
500
+ createdBy: string;
501
+ }
502
+ /**
503
+ * Agent type derived from O*NET + NAICS
504
+ */
505
+ interface AgentType {
506
+ /** O*NET occupation code (e.g., "15-1252.00") */
507
+ onetCode?: string;
508
+ /** O*NET occupation title */
509
+ onetTitle?: string;
510
+ /** NAICS industry code */
511
+ naicsCode?: string;
512
+ /** NAICS industry title */
513
+ naicsTitle?: string;
514
+ /** Custom type name */
515
+ customType?: string;
516
+ /** Role category */
517
+ roleCategory: RoleCategory;
518
+ }
519
+ /**
520
+ * Role categories
521
+ */
522
+ type RoleCategory = 'sdr' | 'csm' | 'engineer' | 'devops' | 'content' | 'design' | 'security' | 'compliance' | 'finance' | 'hr' | 'legal' | 'support' | 'analyst' | 'researcher' | 'manager' | 'executive' | 'specialist' | 'custom';
523
+ /**
524
+ * Agent classification
525
+ */
526
+ interface AgentClassification {
527
+ /** Work mode */
528
+ workMode: 'digital-first' | 'hybrid' | 'embodiment-required';
529
+ /** Role type */
530
+ roleType: 'leadership' | 'analytical' | 'creative' | 'customer-facing' | 'operational';
531
+ /** Autonomy level (0-1) */
532
+ autonomyLevel: number;
533
+ /** Automation score (from O*NET) */
534
+ automationScore?: number;
535
+ /** Job zone (1-5, complexity) */
536
+ jobZone?: number;
537
+ /** Required skills */
538
+ requiredSkills: string[];
539
+ /** Required knowledge */
540
+ requiredKnowledge: string[];
541
+ }
542
+ /**
543
+ * Character bible for agent persona
544
+ */
545
+ interface CharacterBible {
546
+ /** Full name */
547
+ fullName: string;
548
+ /** Pronouns */
549
+ pronouns: string;
550
+ /** Age */
551
+ age?: number;
552
+ /** Background story */
553
+ background: string;
554
+ /** Personality traits */
555
+ traits: string[];
556
+ /** Communication style */
557
+ communicationStyle: string;
558
+ /** Expertise areas */
559
+ expertise: string[];
560
+ /** Limitations/boundaries */
561
+ limitations: string[];
562
+ /** Avatar/headshot URL */
563
+ avatarUrl?: string;
564
+ /** Voice characteristics (for audio) */
565
+ voiceCharacteristics?: string;
566
+ }
567
+ /**
568
+ * Agent guardrail
569
+ */
570
+ interface AgentGuardrail {
571
+ /** Guardrail ID */
572
+ id: string;
573
+ /** Guardrail type */
574
+ type: 'input' | 'output' | 'action' | 'content' | 'safety';
575
+ /** Check to perform */
576
+ check: string;
577
+ /** Action on violation */
578
+ onViolation: 'block' | 'warn' | 'log' | 'escalate';
579
+ /** Custom validator function */
580
+ validator?: string;
581
+ /** Severity */
582
+ severity: 'low' | 'medium' | 'high' | 'critical';
583
+ }
584
+ /**
585
+ * Handoff rule for agent coordination
586
+ */
587
+ interface HandoffRule {
588
+ /** Rule ID */
589
+ id: string;
590
+ /** Condition for handoff (natural language or JSONLogic) */
591
+ condition: string;
592
+ /** Target agent or workflow */
593
+ target: string;
594
+ /** Target type */
595
+ targetType: 'agent' | 'workflow' | 'human';
596
+ /** Context to pass */
597
+ context: string[];
598
+ /** Is this handoff required? */
599
+ required: boolean;
600
+ /** Priority */
601
+ priority: number;
602
+ }
603
+ /**
604
+ * Agent status
605
+ */
606
+ type AgentStatus = 'draft' | 'active' | 'paused' | 'deprecated' | 'archived';
607
+ /**
608
+ * Agent performance metrics
609
+ */
610
+ interface AgentMetrics {
611
+ /** Total executions */
612
+ totalExecutions: number;
613
+ /** Successful executions */
614
+ successfulExecutions: number;
615
+ /** Failed executions */
616
+ failedExecutions: number;
617
+ /** Success rate (0-1) */
618
+ successRate: number;
619
+ /** Average duration in ms */
620
+ avgDurationMs: number;
621
+ /** Average iterations */
622
+ avgIterations: number;
623
+ /** Average token usage */
624
+ avgTokenUsage: number;
625
+ /** Average cost in USD */
626
+ avgCostUsd: number;
627
+ /** User satisfaction (0-5) */
628
+ userSatisfaction?: number;
629
+ /** Last execution time */
630
+ lastExecutedAt?: Date;
631
+ /** Period start */
632
+ periodStart: Date;
633
+ /** Period end */
634
+ periodEnd: Date;
635
+ }
636
+ /**
637
+ * Agent execution record
638
+ */
639
+ interface AgentExecution {
640
+ /** Execution ID */
641
+ id: string;
642
+ /** Agent ID */
643
+ agentId: string;
644
+ /** Execution status */
645
+ status: AgentExecutionStatus;
646
+ /** Input/task provided */
647
+ input: AgentInput;
648
+ /** Output produced */
649
+ output?: AgentOutput;
650
+ /** Execution trace */
651
+ trace: AgentTrace[];
652
+ /** Handoffs that occurred */
653
+ handoffs: AgentHandoff[];
654
+ /** Guardrail violations */
655
+ violations: GuardrailViolation[];
656
+ /** Start time */
657
+ startedAt: Date;
658
+ /** End time */
659
+ completedAt?: Date;
660
+ /** Duration in ms */
661
+ durationMs?: number;
662
+ /** Total iterations */
663
+ iterations: number;
664
+ /** Token usage */
665
+ tokenUsage: TokenUsage;
666
+ /** Cost in USD */
667
+ costUsd: number;
668
+ /** User feedback */
669
+ feedback?: AgentFeedback;
670
+ /** Namespace */
671
+ ns: string;
672
+ /** Triggered by */
673
+ triggeredBy: string;
674
+ }
675
+ /**
676
+ * Execution status
677
+ */
678
+ type AgentExecutionStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'handed-off' | 'awaiting-human';
679
+ /**
680
+ * Agent input
681
+ */
682
+ interface AgentInput {
683
+ /** Task description */
684
+ task: string;
685
+ /** Context information */
686
+ context?: Record<string, unknown>;
687
+ /** Constraints */
688
+ constraints?: string[];
689
+ /** Expected output format */
690
+ outputFormat?: string;
691
+ }
692
+ /**
693
+ * Agent output
694
+ */
695
+ interface AgentOutput {
696
+ /** Result/response */
697
+ result: unknown;
698
+ /** Summary */
699
+ summary: string;
700
+ /** Confidence score (0-1) */
701
+ confidence?: number;
702
+ /** Artifacts produced */
703
+ artifacts?: AgentArtifact[];
704
+ /** Recommendations */
705
+ recommendations?: string[];
706
+ }
707
+ /**
708
+ * Agent artifact (file, code, etc.)
709
+ */
710
+ interface AgentArtifact {
711
+ /** Artifact type */
712
+ type: 'file' | 'code' | 'image' | 'document' | 'data';
713
+ /** Artifact name */
714
+ name: string;
715
+ /** Content or URL */
716
+ content: string;
717
+ /** MIME type */
718
+ mimeType?: string;
719
+ }
720
+ /**
721
+ * Agent execution trace (step-by-step)
722
+ */
723
+ interface AgentTrace {
724
+ /** Iteration number */
725
+ iteration: number;
726
+ /** Timestamp */
727
+ timestamp: Date;
728
+ /** Action type */
729
+ type: 'thought' | 'action' | 'observation' | 'decision';
730
+ /** Content */
731
+ content: string;
732
+ /** Tool used (if action) */
733
+ tool?: string;
734
+ /** Tool input (if action) */
735
+ toolInput?: Record<string, unknown>;
736
+ /** Tool output (if observation) */
737
+ toolOutput?: unknown;
738
+ /** Token usage for this step */
739
+ tokenUsage?: TokenUsage;
740
+ }
741
+ /**
742
+ * Agent handoff record
743
+ */
744
+ interface AgentHandoff {
745
+ /** Handoff timestamp */
746
+ timestamp: Date;
747
+ /** Rule that triggered handoff */
748
+ ruleId: string;
749
+ /** Source agent */
750
+ fromAgent: string;
751
+ /** Target agent/workflow/human */
752
+ toTarget: string;
753
+ /** Target type */
754
+ targetType: 'agent' | 'workflow' | 'human';
755
+ /** Context passed */
756
+ context: Record<string, unknown>;
757
+ /** Handoff successful? */
758
+ successful: boolean;
759
+ }
760
+ /**
761
+ * Guardrail violation record
762
+ */
763
+ interface GuardrailViolation {
764
+ /** Timestamp */
765
+ timestamp: Date;
766
+ /** Guardrail ID */
767
+ guardrailId: string;
768
+ /** Violation type */
769
+ type: string;
770
+ /** Details */
771
+ details: string;
772
+ /** Action taken */
773
+ actionTaken: 'blocked' | 'warned' | 'logged' | 'escalated';
774
+ /** Severity */
775
+ severity: 'low' | 'medium' | 'high' | 'critical';
776
+ }
777
+ /**
778
+ * User feedback on agent execution
779
+ */
780
+ interface AgentFeedback {
781
+ /** Rating (1-5) */
782
+ rating: number;
783
+ /** Comment */
784
+ comment?: string;
785
+ /** Feedback categories */
786
+ categories?: ('accurate' | 'helpful' | 'fast' | 'clear' | 'wrong' | 'slow' | 'confusing')[];
787
+ /** Timestamp */
788
+ submittedAt: Date;
789
+ /** User who submitted */
790
+ submittedBy: string;
791
+ }
792
+ /**
793
+ * Agent filter for queries
794
+ */
795
+ interface AgentFilter {
796
+ /** Filter by status */
797
+ status?: AgentStatus[];
798
+ /** Filter by role category */
799
+ roleCategory?: RoleCategory[];
800
+ /** Filter by work mode */
801
+ workMode?: ('digital-first' | 'hybrid' | 'embodiment-required')[];
802
+ /** Filter by namespace */
803
+ ns?: string;
804
+ /** Search by name */
805
+ nameSearch?: string;
806
+ /** Filter by tools */
807
+ tools?: string[];
808
+ /** Minimum autonomy level */
809
+ minAutonomyLevel?: number;
810
+ }
811
+ /**
812
+ * Execution filter for queries
813
+ */
814
+ interface AgentExecutionFilter {
815
+ /** Filter by agent ID */
816
+ agentId?: string;
817
+ /** Filter by status */
818
+ status?: AgentExecutionStatus[];
819
+ /** Filter by date range */
820
+ startedAfter?: Date;
821
+ startedBefore?: Date;
822
+ /** Filter by namespace */
823
+ ns?: string;
824
+ /** Filter by triggered by */
825
+ triggeredBy?: string;
826
+ /** Has feedback */
827
+ hasFeedback?: boolean;
828
+ /** Minimum rating */
829
+ minRating?: number;
830
+ }
831
+
832
+ export type { AIStepConfig as A, AgentMetrics as B, ChoiceCondition as C, DatabaseStepConfig as D, EventTrigger as E, AgentExecution as F, AgentExecutionStatus as G, HttpStepConfig as H, AgentInput as I, AgentOutput as J, AgentArtifact as K, AgentTrace as L, ManualTrigger as M, NotificationConfig as N, AgentHandoff as O, GuardrailViolation as P, AgentFeedback as Q, RetryConfig as R, ScheduleTrigger as S, TriggerType as T, AgentFilter as U, AgentExecutionFilter as V, WorkflowStatus as W, Workflow as a, TriggerBase as b, WebhookTrigger as c, WorkflowTrigger as d, StepType as e, WorkflowStep as f, StepConfig as g, EventStepConfig as h, ErrorHandlingConfig as i, CompensationConfig as j, WorkflowConfig as k, ExecutionStatus as l, WorkflowExecution as m, TriggerData as n, ExecutionContext as o, StepExecution as p, WorkflowFilter as q, ExecutionFilter as r, Agent as s, AgentType as t, RoleCategory as u, AgentClassification as v, CharacterBible as w, AgentGuardrail as x, HandoffRule as y, AgentStatus as z };