@limo-labs/deity 0.2.0-alpha.0 → 0.2.0

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.
@@ -208,6 +208,8 @@ interface SessionData {
208
208
  stats: ExecutionStats;
209
209
  /** Stage outputs (checkpoint data) */
210
210
  stageOutputs: Record<string, unknown>;
211
+ /** Application state (isolated from AI memory) */
212
+ appState?: Record<string, unknown>;
211
213
  /** Session metadata */
212
214
  metadata: SessionMetadata;
213
215
  }
@@ -517,6 +519,52 @@ declare class LimoMemoryManager {
517
519
  * Get detailed memories
518
520
  */
519
521
  getDetailedMemories(): Memory[];
522
+ /**
523
+ * Get all memory keys (core + detailed)
524
+ *
525
+ * @returns Array of all memory keys
526
+ */
527
+ getAllKeys(): string[];
528
+ /**
529
+ * Get all Memory objects (core + detailed)
530
+ *
531
+ * @returns Array of all Memory entries
532
+ */
533
+ getAllMemories(): Memory[];
534
+ /**
535
+ * Get raw Memory object by key (without triggering access metadata update)
536
+ *
537
+ * @param key - Memory key
538
+ * @returns Memory object or undefined
539
+ */
540
+ getMemory(key: string): Memory | undefined;
541
+ /**
542
+ * Update an existing memory entry
543
+ *
544
+ * @param key - Memory key to update
545
+ * @param updates - Partial updates (content, importance, category, tags)
546
+ * @returns true if updated, false if key not found
547
+ */
548
+ update(key: string, updates: Partial<{
549
+ content: string;
550
+ importance: number;
551
+ category: string;
552
+ tags: string[];
553
+ }>): Promise<boolean>;
554
+ /**
555
+ * Promote a memory to core by key
556
+ *
557
+ * @param key - Memory key to promote
558
+ * @returns true if promoted, false if key not found or already in core
559
+ */
560
+ promoteToCoreByKey(key: string): boolean;
561
+ /**
562
+ * Demote a memory from core to detailed by key
563
+ *
564
+ * @param key - Memory key to demote
565
+ * @returns true if demoted, false if key not found in core
566
+ */
567
+ demoteFromCore(key: string): boolean;
520
568
  /**
521
569
  * Get memory statistics
522
570
  */
@@ -705,7 +753,7 @@ interface ToolResult<T = unknown> {
705
753
  /**
706
754
  * Tool definition
707
755
  */
708
- interface Tool<TInput = unknown, TOutput = unknown> {
756
+ interface ToolSpec<TInput = unknown, TOutput = unknown> {
709
757
  name: string;
710
758
  description: string;
711
759
  inputSchema: ZodSchema<TInput>;
@@ -805,7 +853,7 @@ type TraceEntry = {
805
853
  } | {
806
854
  type: 'llm_call';
807
855
  messages: Message[];
808
- tools?: Tool[];
856
+ tools?: ToolSpec[];
809
857
  timestamp: Date;
810
858
  } | {
811
859
  type: 'llm_response';
@@ -882,6 +930,8 @@ interface ExecutionContext<I = unknown> {
882
930
  ui?: UIUpdateBridge;
883
931
  /** Session store (optional) */
884
932
  session?: SessionStore;
933
+ /** Application state store (optional, isolated from AI memory) */
934
+ appState?: StateStore;
885
935
  /** Execution statistics (consensus requirement) */
886
936
  stats: ExecutionStats;
887
937
  /** Current stage ID (for UI updates) */
@@ -980,8 +1030,16 @@ interface AgentComponent<I = unknown, O = unknown> {
980
1030
  /**
981
1031
  * Tool definitions (declarative)
982
1032
  * Component declares available tools, runtime executes them
1033
+ *
1034
+ * Tools that need ExecutionContext (e.g., memory tools) receive it
1035
+ * automatically as the second argument to their execute() function.
1036
+ *
1037
+ * @example
1038
+ * ```typescript
1039
+ * tools: [readFileTool, writeFileTool]
1040
+ * ```
983
1041
  */
984
- tools?: Tool[];
1042
+ tools?: ToolSpec[];
985
1043
  /**
986
1044
  * Retry configuration (declarative with dynamic conditions)
987
1045
  * Component declares retry rules, runtime controls loop
@@ -1097,7 +1155,7 @@ interface ToolCall {
1097
1155
  * LLM adapter interface
1098
1156
  */
1099
1157
  interface LLMAdapter {
1100
- generate(messages: Message[], tools?: Tool[], config?: GenerationConfig, ctx?: ExecutionContext): Promise<LLMResponse>;
1158
+ generate(messages: Message[], tools?: ToolSpec[], config?: GenerationConfig, ctx?: ExecutionContext): Promise<LLMResponse>;
1101
1159
  }
1102
1160
  /**
1103
1161
  * Result from LLM execution loop
@@ -1139,16 +1197,23 @@ interface WorkflowEnhancements {
1139
1197
  ui?: UIUpdateBridge;
1140
1198
  /** Session store */
1141
1199
  session?: SessionStore;
1200
+ /** Application state store (isolated from AI memory) */
1201
+ appState?: StateStore;
1142
1202
  }
1143
1203
  /**
1144
1204
  * Execution node (for workflow graph)
1145
1205
  */
1146
1206
  interface ExecutionNode {
1147
- type: 'step' | 'sequence' | 'parallel' | 'conditional' | 'loop';
1207
+ type: 'step' | 'sequence' | 'parallel' | 'conditional' | 'loop' | 'foreach';
1148
1208
  component?: AgentComponent;
1149
1209
  children?: ExecutionNode[];
1150
1210
  condition?: (ctx: ExecutionContext) => boolean | Promise<boolean>;
1151
1211
  maxIterations?: number;
1212
+ itemsAccessor?: unknown[] | ((ctx: ExecutionContext) => unknown[] | Promise<unknown[]>);
1213
+ itemMode?: 'merge' | 'replace' | 'property';
1214
+ itemKey?: string;
1215
+ errorMode?: 'stop' | 'continue' | 'skip';
1216
+ collectResults?: boolean;
1152
1217
  }
1153
1218
  /**
1154
1219
  * Workflow configuration (consensus requirement)
@@ -1221,11 +1286,11 @@ interface AgentNode<I = unknown, O = unknown> extends ASTNode {
1221
1286
  /** Timeout in milliseconds */
1222
1287
  timeout?: number;
1223
1288
  };
1224
- /** Optional tool definitions */
1225
- tools?: Tool[];
1289
+ /** Optional tool definitions (static array) */
1290
+ tools?: ToolSpec[];
1226
1291
  };
1227
1292
  /** Child nodes (Prompt is required, others are optional) */
1228
- children: (PromptNode | ObserveNode | ResultNode | ValidateNode | RetryNode)[];
1293
+ children: (PromptNode | ObserveNode | ResultNode | ValidateNode | RetryNode | ToolsNode)[];
1229
1294
  }
1230
1295
  /**
1231
1296
  * Prompt Node - Container for system and user prompts
@@ -1241,6 +1306,7 @@ interface PromptNode extends ASTNode {
1241
1306
  * - File (source: 'file:path/to/prompt.md')
1242
1307
  * - Inline (content: 'text')
1243
1308
  * - Computed (compute: (ctx) => string)
1309
+ * - Mixed template (templateParts: TemplatePart[]) - for ToolRef support
1244
1310
  */
1245
1311
  interface SystemNode extends ASTNode {
1246
1312
  type: 'System';
@@ -1253,6 +1319,8 @@ interface SystemNode extends ASTNode {
1253
1319
  content?: string;
1254
1320
  /** Computed content (function) */
1255
1321
  compute?: (ctx: ExecutionContext) => string | Promise<string>;
1322
+ /** Template parts (for mixed text/computed/toolref content) */
1323
+ templateParts?: TemplatePart[];
1256
1324
  };
1257
1325
  }
1258
1326
  /**
@@ -1261,6 +1329,7 @@ interface SystemNode extends ASTNode {
1261
1329
  * Can be:
1262
1330
  * - Inline (content: 'text')
1263
1331
  * - Computed (compute: (ctx) => string)
1332
+ * - Mixed template (templateParts: TemplatePart[]) - for ToolRef support
1264
1333
  */
1265
1334
  interface UserNode extends ASTNode {
1266
1335
  type: 'User';
@@ -1269,6 +1338,42 @@ interface UserNode extends ASTNode {
1269
1338
  content?: string;
1270
1339
  /** Computed content (function) */
1271
1340
  compute?: (ctx: ExecutionContext) => string | Promise<string>;
1341
+ /** Template parts (for mixed text/computed/toolref content) */
1342
+ templateParts?: TemplatePart[];
1343
+ };
1344
+ }
1345
+ /**
1346
+ * Template Part - Single part of a mixed-content template
1347
+ *
1348
+ * Used by System and User nodes to support inline ToolRef nodes.
1349
+ */
1350
+ type TemplatePart = {
1351
+ kind: 'text';
1352
+ value: string;
1353
+ } | {
1354
+ kind: 'computed';
1355
+ compute: (ctx: ExecutionContext) => string | Promise<string>;
1356
+ } | {
1357
+ kind: 'toolref';
1358
+ toolName: string;
1359
+ };
1360
+ /**
1361
+ * ToolRef Node - Reference to a tool name in prompt text
1362
+ *
1363
+ * This node acts as a placeholder that gets replaced with the tool's
1364
+ * runtime ID during prompt compilation.
1365
+ *
1366
+ * @example
1367
+ * ```tsx
1368
+ * <User>Use <ToolRef tool={MemoryStore} /> to save data.</User>
1369
+ * // Compiles to: "Use memory_store to save data."
1370
+ * ```
1371
+ */
1372
+ interface ToolRefNode extends ASTNode {
1373
+ type: 'ToolRef';
1374
+ props: {
1375
+ /** The tool's runtime ID (e.g., 'memory_store') */
1376
+ toolName: string;
1272
1377
  };
1273
1378
  }
1274
1379
  /**
@@ -1375,6 +1480,43 @@ interface RetryNode extends ASTNode {
1375
1480
  feedbackErrorToLLM?: boolean;
1376
1481
  };
1377
1482
  }
1483
+ /**
1484
+ * Tools Container Node - Groups tool definitions for an agent
1485
+ *
1486
+ * Contains static tool definitions via <ToolDef> or <Tool> children.
1487
+ *
1488
+ * @example
1489
+ * ```tsx
1490
+ * <Tools>
1491
+ * <MemoryStore />
1492
+ * <MemoryRecall />
1493
+ * <Tool name="my_tool" description="..." input={Schema}>
1494
+ * {async (params) => ({ ... })}
1495
+ * </Tool>
1496
+ * </Tools>
1497
+ * ```
1498
+ */
1499
+ interface ToolsNode extends ASTNode {
1500
+ type: 'Tools';
1501
+ props: Record<string, never>;
1502
+ /** Child ToolDef nodes */
1503
+ children: ToolDefNode[];
1504
+ }
1505
+ /**
1506
+ * Tool Definition Node - Wraps a single Tool object
1507
+ *
1508
+ * @example
1509
+ * ```tsx
1510
+ * <ToolDef tool={createFileListTool(context)} />
1511
+ * ```
1512
+ */
1513
+ interface ToolDefNode extends ASTNode {
1514
+ type: 'Tools:Def';
1515
+ props: {
1516
+ /** The tool object */
1517
+ tool: ToolSpec;
1518
+ };
1519
+ }
1378
1520
  /**
1379
1521
  * Check if a node is an AgentNode
1380
1522
  */
@@ -1407,6 +1549,160 @@ declare function isValidateNode(node: ASTNode): node is ValidateNode;
1407
1549
  * Check if a node is a RetryNode
1408
1550
  */
1409
1551
  declare function isRetryNode(node: ASTNode): node is RetryNode;
1552
+ /**
1553
+ * Check if a node is a ToolsNode
1554
+ */
1555
+ declare function isToolsNode(node: ASTNode): node is ToolsNode;
1556
+ /**
1557
+ * Check if a node is a ToolDefNode
1558
+ */
1559
+ declare function isToolDefNode(node: ASTNode): node is ToolDefNode;
1560
+ /**
1561
+ * Check if a node is a ToolRefNode
1562
+ */
1563
+ declare function isToolRefNode(node: ASTNode): node is ToolRefNode;
1564
+ /**
1565
+ * Workflow Sequence Node - Execute children in order
1566
+ */
1567
+ interface WorkflowSequenceNode extends ASTNode {
1568
+ type: 'WorkflowSequence';
1569
+ children: WorkflowChildNode[];
1570
+ }
1571
+ /**
1572
+ * Workflow Parallel Node - Execute children concurrently
1573
+ */
1574
+ interface WorkflowParallelNode extends ASTNode {
1575
+ type: 'WorkflowParallel';
1576
+ children: WorkflowChildNode[];
1577
+ }
1578
+ /**
1579
+ * Workflow Conditional Node - Execute children based on condition
1580
+ */
1581
+ interface WorkflowConditionalNode extends ASTNode {
1582
+ type: 'WorkflowConditional';
1583
+ props: {
1584
+ /** Condition function (true = first child, false = second child) */
1585
+ condition: (ctx: ExecutionContext) => boolean | Promise<boolean>;
1586
+ };
1587
+ children: [WorkflowChildNode] | [WorkflowChildNode, WorkflowChildNode];
1588
+ }
1589
+ /**
1590
+ * Workflow Loop Node - Execute child N times
1591
+ */
1592
+ interface WorkflowLoopNode extends ASTNode {
1593
+ type: 'WorkflowLoop';
1594
+ props: {
1595
+ /** Number of iterations */
1596
+ iterations: number;
1597
+ };
1598
+ children: [WorkflowChildNode];
1599
+ }
1600
+ /**
1601
+ * Workflow ForEach Node - Execute child for each item in array
1602
+ */
1603
+ interface WorkflowForEachNode extends ASTNode {
1604
+ type: 'WorkflowForEach';
1605
+ props: {
1606
+ /** Array of items or function to resolve items */
1607
+ items: unknown[] | ((ctx: ExecutionContext) => unknown[] | Promise<unknown[]>);
1608
+ /** How to inject item into context ('property' | 'merge' | 'replace') */
1609
+ itemMode: string;
1610
+ /** Property key for 'property' mode */
1611
+ itemKey: string;
1612
+ /** Error handling mode ('stop' | 'continue' | 'skip') */
1613
+ errorMode: string;
1614
+ /** Whether to collect results */
1615
+ collectResults: boolean;
1616
+ };
1617
+ children: [WorkflowChildNode];
1618
+ }
1619
+ /**
1620
+ * Union type for workflow child nodes
1621
+ * Can be either an Agent or a workflow structure node
1622
+ */
1623
+ type WorkflowChildNode = AgentNode | WorkflowSequenceNode | WorkflowParallelNode | WorkflowConditionalNode | WorkflowLoopNode | WorkflowForEachNode;
1624
+ /**
1625
+ * Check if a node is a WorkflowSequenceNode
1626
+ */
1627
+ declare function isWorkflowSequenceNode(node: ASTNode): node is WorkflowSequenceNode;
1628
+ /**
1629
+ * Check if a node is a WorkflowParallelNode
1630
+ */
1631
+ declare function isWorkflowParallelNode(node: ASTNode): node is WorkflowParallelNode;
1632
+ /**
1633
+ * Check if a node is a WorkflowConditionalNode
1634
+ */
1635
+ declare function isWorkflowConditionalNode(node: ASTNode): node is WorkflowConditionalNode;
1636
+ /**
1637
+ * Check if a node is a WorkflowLoopNode
1638
+ */
1639
+ declare function isWorkflowLoopNode(node: ASTNode): node is WorkflowLoopNode;
1640
+ /**
1641
+ * Check if a node is a WorkflowForEachNode
1642
+ */
1643
+ declare function isWorkflowForEachNode(node: ASTNode): node is WorkflowForEachNode;
1644
+ /**
1645
+ * Workflow Node - Top-level workflow container
1646
+ *
1647
+ * Contains the complete workflow configuration including:
1648
+ * - Name and description
1649
+ * - Default model configuration
1650
+ * - Workflow graph (Sequence, Parallel, Conditional, Loop, or Agent)
1651
+ * - Optional enhancements (conversation, memory, session, UI)
1652
+ */
1653
+ interface WorkflowNode extends ASTNode {
1654
+ type: 'Workflow';
1655
+ props: {
1656
+ /** Workflow name */
1657
+ name: string;
1658
+ /** Optional description */
1659
+ description?: string;
1660
+ /** Default LLM model configuration */
1661
+ defaultModel?: {
1662
+ adapter: any;
1663
+ config?: any;
1664
+ };
1665
+ /** Optional state storage */
1666
+ state?: {
1667
+ store: any;
1668
+ };
1669
+ /** Optional enhancements */
1670
+ enhancements?: {
1671
+ /** Conversation management */
1672
+ conversation?: {
1673
+ maxTokens: number;
1674
+ pruneThreshold: number;
1675
+ messageRetentionPolicy?: unknown;
1676
+ };
1677
+ /** Memory management */
1678
+ memory?: {
1679
+ coreBudget: {
1680
+ maxItems: number;
1681
+ maxTotalSize: number;
1682
+ };
1683
+ detailedBudget?: {
1684
+ maxItems: number;
1685
+ maxTotalSize: number;
1686
+ };
1687
+ };
1688
+ /** Session persistence */
1689
+ session?: {
1690
+ directory: string;
1691
+ autoSave?: boolean;
1692
+ };
1693
+ /** UI updates */
1694
+ ui?: any;
1695
+ /** Application state store (isolated from AI memory) */
1696
+ appState?: any;
1697
+ };
1698
+ };
1699
+ /** Single child representing the workflow graph */
1700
+ children: [WorkflowChildNode];
1701
+ }
1702
+ /**
1703
+ * Check if a node is a WorkflowNode
1704
+ */
1705
+ declare function isWorkflowNode(node: ASTNode): node is WorkflowNode;
1410
1706
 
1411
1707
  /**
1412
1708
  * Deity TSX - JSX Runtime
@@ -1481,10 +1777,10 @@ declare global {
1481
1777
  /**
1482
1778
  * Element type (return type of JSX expressions)
1483
1779
  *
1484
- * We use ASTNode as the base type, but TypeScript will infer
1485
- * the specific node type based on the component function's return type.
1780
+ * Instead of fixing this to ASTNode, we leave it generic so TypeScript
1781
+ * can infer the specific return type from the component function.
1486
1782
  */
1487
- type Element = ASTNode;
1783
+ type Element = any;
1488
1784
  /**
1489
1785
  * Intrinsic elements (built-in HTML-like elements)
1490
1786
  *
@@ -1500,7 +1796,7 @@ declare global {
1500
1796
  * Deity TSX only uses function components.
1501
1797
  */
1502
1798
  interface ElementClass {
1503
- render(): ASTNode;
1799
+ render(): any;
1504
1800
  }
1505
1801
  /**
1506
1802
  * Element attributes property
@@ -1517,4 +1813,4 @@ declare global {
1517
1813
  }
1518
1814
  }
1519
1815
 
1520
- export { type AgentNode as A, isAgentNode as B, ConversationManager as C, isObserveNode as D, type ExecutionContext as E, isPromptNode as F, type GenerationConfig as G, isResultNode as H, isRetryNode as I, type JSXComponent as J, isSystemNode as K, type LLMLoopResult as L, type Message as M, isUserNode as N, type ObserveNode as O, type PromptNode as P, isValidateNode as Q, type ResultNode as R, type SystemNode as S, type Tool as T, type UserNode as U, type Validator as V, type WorkflowConfig as W, Fragment as X, jsx as Y, jsxs as Z, type ValidationRules as a, type ValidateNode as b, type RetryNode as c, type AgentComponent as d, type ValidationResult as e, type LLMAdapter as f, type ExecutionNode as g, type StateStore as h, type TraceLogger as i, type TraceEntry as j, type ExecutionStats as k, LimoMemoryManager as l, type UIUpdateBridge as m, type SessionStore as n, type ConversationConfig as o, type MemoryConfig as p, type SessionConfig as q, type ASTNode as r, type JSXElementType as s, type JSXProps as t, type LLMLoopState as u, type LLMResponse as v, type MessageRole as w, type ToolCall as x, type ToolResult as y, type ValidationRule as z };
1816
+ export { isObserveNode as $, type AgentNode as A, type MemoryConfig as B, ConversationManager as C, type SessionConfig as D, type ExecutionContext as E, type JSXElementType as F, type GenerationConfig as G, type JSXProps as H, type LLMLoopState as I, type JSXComponent as J, type LLMResponse as K, type LLMLoopResult as L, type Message as M, type MessageRole as N, type ObserveNode as O, type PromptNode as P, type TemplatePart as Q, type ResultNode as R, type SystemNode as S, type ToolSpec as T, type UserNode as U, type Validator as V, type WorkflowChildNode as W, type ToolCall as X, type ToolResult as Y, type ValidationRule as Z, isAgentNode as _, type ValidationRules as a, isPromptNode as a0, isResultNode as a1, isRetryNode as a2, isSystemNode as a3, isToolDefNode as a4, isToolRefNode as a5, isToolsNode as a6, isUserNode as a7, isValidateNode as a8, isWorkflowConditionalNode as a9, isWorkflowForEachNode as aa, isWorkflowLoopNode as ab, isWorkflowNode as ac, isWorkflowParallelNode as ad, isWorkflowSequenceNode as ae, Fragment as af, jsx as ag, jsxs as ah, type ValidateNode as b, type RetryNode as c, type ToolDefNode as d, type ToolsNode as e, type ToolRefNode as f, type WorkflowSequenceNode as g, type WorkflowParallelNode as h, type WorkflowConditionalNode as i, type WorkflowLoopNode as j, type WorkflowForEachNode as k, type WorkflowNode as l, type AgentComponent as m, type WorkflowConfig as n, type ExecutionNode as o, type ASTNode as p, type ValidationResult as q, type LLMAdapter as r, type StateStore as s, type TraceLogger as t, type TraceEntry as u, type ExecutionStats as v, LimoMemoryManager as w, type UIUpdateBridge as x, type SessionStore as y, type ConversationConfig as z };