@limo-labs/deity 0.2.0-alpha.0 → 0.2.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.
package/README.md CHANGED
@@ -1,18 +1,23 @@
1
1
  # @limo-labs/deity
2
2
 
3
- > **Declarative AI Agent Framework** — Build type-safe AI agents with JSX/TSX syntax
3
+ > **Declarative AI Agent Framework** — Build type-safe AI agents with JSX/TSX syntax for agents and declarative API for workflows
4
4
 
5
- Deity is a declarative framework for building AI agents using familiar JSX/TSX syntax. Write agents like React components, with full TypeScript support and zero runtime overhead.
5
+ Deity is a declarative framework for building AI agents. **Agents** use familiar JSX/TSX syntax like React components. **Workflows** use declarative function composition. Full TypeScript support and zero runtime overhead.
6
+
7
+ **Important Distinction:**
8
+ - **Agent Definition:** Uses true JSX/TSX tags (`<Agent>`, `<Prompt>`) in `.tsx` files
9
+ - **Workflow Definition:** Uses function calls (`Workflow()`, `Sequence()`) in `.ts` files
6
10
 
7
11
  [![npm version](https://img.shields.io/npm/v/@limo-labs/deity.svg)](https://www.npmjs.com/package/@limo-labs/deity)
8
- [![License](https://img.shields.io/npm/l/@limo-labs/deity.svg)](https://github.com/limo-labs/deity/blob/main/LICENSE)
12
+ [![License](https://img.shields.io/npm/l/@limo-labs/deity.svg)](https://github.com/Limo-Labs/Limo-Deity/blob/main/LICENSE)
9
13
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue.svg)](https://www.typescriptlang.org/)
10
14
 
11
15
  ## ✨ Features
12
16
 
13
- - 🎨 **JSX/TSX Syntax** - Write agents with familiar React-like syntax
17
+ - 🎨 **JSX/TSX Syntax for Agents** - Write agents with familiar React-like JSX tags (`.tsx` files)
18
+ - 📦 **Declarative Workflow API** - Compose workflows with function calls (`.ts` files)
14
19
  - 🔒 **Type Safe** - Full TypeScript support with Zod schema validation
15
- - 🔧 **Declarative** - Compose agents from reusable components
20
+ - 🔧 **Declarative** - Compose agents and workflows from reusable components
16
21
  - 🚀 **Zero Runtime Overhead** - Compiles to lightweight AST nodes
17
22
  - 🎯 **LLM Agnostic** - Works with any LLM adapter
18
23
  - 🔁 **Auto Retry** - Built-in retry logic with LLM feedback
@@ -36,9 +41,9 @@ pnpm add @limo-labs/deity zod
36
41
 
37
42
  ## 🚀 Quick Start
38
43
 
39
- ### 1. Configure TypeScript
44
+ ### 1. Configure TypeScript (Optional - For JSX/TSX Agent Syntax)
40
45
 
41
- Add JSX support to your `tsconfig.json`:
46
+ If you want to use **JSX/TSX tags** for Agent definitions (`.tsx` files), add JSX support to your `tsconfig.json`:
42
47
 
43
48
  ```json
44
49
  {
@@ -49,7 +54,11 @@ Add JSX support to your `tsconfig.json`:
49
54
  }
50
55
  ```
51
56
 
52
- ### 2. Create Your First Agent
57
+ **Note:** Workflow definitions use function calls and work in regular `.ts` files without JSX configuration.
58
+
59
+ ### 2. Create Your First Agent (Using JSX/TSX Tags)
60
+
61
+ **File:** `agent.tsx` (note the `.tsx` extension for JSX support)
53
62
 
54
63
  ```tsx
55
64
  import { Agent, Prompt, System, User, Result } from '@limo-labs/deity';
@@ -65,7 +74,7 @@ const OutputSchema = z.object({
65
74
  keyPoints: z.array(z.string())
66
75
  });
67
76
 
68
- // Create agent using JSX
77
+ // Create agent using JSX tags (requires .tsx file)
69
78
  const SummarizerAgent = (
70
79
  <Agent id="summarizer" input={InputSchema} output={OutputSchema}>
71
80
  <Prompt>
@@ -291,6 +300,48 @@ const CodeAnalyzer = (
291
300
  );
292
301
  ```
293
302
 
303
+ ### Dynamic Tool Factory (NEW in 4.0)
304
+
305
+ **Tool Factory Pattern** - Create tools dynamically based on execution context:
306
+
307
+ ```tsx
308
+ import { createMemoryTools } from '@limo-labs/deity';
309
+
310
+ const DynamicAgent = (
311
+ <Agent
312
+ id="dynamic"
313
+ input={z.object({ enableMemory: z.boolean() })}
314
+ output={z.object({ result: z.string() })}
315
+ tools={(ctx) => {
316
+ // Static tools always available
317
+ const staticTools = [
318
+ {
319
+ name: 'read_file',
320
+ description: 'Read file',
321
+ inputSchema: z.object({ path: z.string() }),
322
+ async execute(input) {
323
+ return await fs.readFile(input.path, 'utf-8');
324
+ }
325
+ }
326
+ ];
327
+
328
+ // Add memory tools conditionally
329
+ const memoryTools = ctx.memory ? createMemoryTools(ctx) : [];
330
+
331
+ return [...staticTools, ...memoryTools];
332
+ }}
333
+ >
334
+ {/* ... */}
335
+ </Agent>
336
+ );
337
+ ```
338
+
339
+ **Key Benefits:**
340
+ - ✅ Tools can access ExecutionContext at creation time
341
+ - ✅ Conditional tool inclusion based on context state
342
+ - ✅ Enables Deity's memory tools in TSX workflows
343
+ - ✅ Backward compatible with static tool arrays
344
+
294
345
  ### Multi-Step Workflow
295
346
 
296
347
  ```tsx
@@ -520,10 +571,66 @@ expect(result.output).toEqual({ result: 'success' });
520
571
  ## 📖 Documentation
521
572
 
522
573
  - [API Reference](./docs/API.md) - Full API documentation
574
+ - [**Declarative Workflow Guide**](./docs/TSX_WORKFLOW.md) - **NEW: Build workflows with declarative API**
575
+ - [Workflow Quick Reference](./docs/TSX_WORKFLOW_QUICK_REF.md) - Quick syntax reference
523
576
  - [Migration Guide](./docs/MIGRATION.md) - Migrating from imperative API
524
577
  - [Best Practices](./docs/BEST_PRACTICES.md) - Design patterns and tips
525
578
  - [Examples](./docs/EXAMPLES.md) - Real-world examples
526
579
 
580
+ ## 🔀 Declarative Workflows (NEW in 4.0)
581
+
582
+ Deity 4.0 introduces **Declarative Workflow API** - build complex multi-agent workflows with function composition:
583
+
584
+ **Note:** Despite the name "TSX Workflow", these use **function calls** (`.ts` files), not JSX tags. Only Agent definitions support true JSX/TSX syntax.
585
+
586
+ ```typescript
587
+ import { Workflow, Sequence, Parallel, Conditional, runTSXWorkflow } from '@limo-labs/deity';
588
+
589
+ const workflow = Workflow({
590
+ name: 'code-analysis',
591
+ defaultModel: { adapter: llmAdapter },
592
+ children: Sequence({
593
+ children: [
594
+ // Step 1: Classify code
595
+ ClassifierAgent,
596
+
597
+ // Step 2: Branch based on complexity
598
+ Conditional({
599
+ condition: (ctx) => ctx.getOutput('classifier').isComplex,
600
+ children: [
601
+ // Complex: parallel deep analysis
602
+ Parallel({
603
+ children: [
604
+ SecurityAnalyzer,
605
+ PerformanceAnalyzer,
606
+ QualityAnalyzer,
607
+ ],
608
+ }),
609
+ // Simple: quick summary
610
+ QuickSummary,
611
+ ],
612
+ }),
613
+
614
+ // Step 3: Generate report
615
+ ReportGenerator,
616
+ ],
617
+ }),
618
+ });
619
+
620
+ // Execute
621
+ const result = await runTSXWorkflow(workflow, { code: '...' });
622
+ ```
623
+
624
+ ### Workflow Components
625
+
626
+ - **`Sequence`** - Execute children in order (function call)
627
+ - **`Parallel`** - Execute children concurrently (function call)
628
+ - **`Conditional`** - Branch based on condition (function call)
629
+ - **`Loop`** - Execute child N times (function call)
630
+ - **`ForEach`** - Execute child for each item in array (function call)
631
+
632
+ **[➡️ Full TSX Workflow Guide](./docs/TSX_WORKFLOW.md)**
633
+
527
634
  ## 🔗 Integration
528
635
 
529
636
  ### LLM Adapters
@@ -563,10 +670,10 @@ MIT © [Limo Labs](https://github.com/limo-labs)
563
670
 
564
671
  ## 🔗 Links
565
672
 
566
- - [GitHub](https://github.com/limo-labs/deity)
673
+ - [GitHub](https://github.com/Limo-Labs/Limo-Deity)
567
674
  - [npm](https://www.npmjs.com/package/@limo-labs/deity)
568
675
  - [Documentation](https://deity.limo.run)
569
- - [Issues](https://github.com/limo-labs/deity/issues)
676
+ - [Issues](https://github.com/Limo-Labs/Limo-Deity/issues)
570
677
  - [Changelog](./CHANGELOG.md)
571
678
 
572
679
  ---