@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.
- package/README.md +118 -11
- package/dist/index.cjs +932 -306
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +720 -169
- package/dist/index.d.ts +720 -169
- package/dist/index.js +909 -303
- package/dist/index.js.map +1 -1
- package/dist/{jsx-dev-runtime-CKrGWO-8.d.cts → jsx-dev-runtime-Dg782FK5.d.cts} +309 -13
- package/dist/{jsx-dev-runtime-CKrGWO-8.d.ts → jsx-dev-runtime-Dg782FK5.d.ts} +309 -13
- package/dist/jsx-dev-runtime.cjs.map +1 -1
- package/dist/jsx-dev-runtime.d.cts +1 -1
- package/dist/jsx-dev-runtime.d.ts +1 -1
- package/dist/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx-runtime.cjs.map +1 -1
- package/dist/jsx-runtime.d.cts +1 -1
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js.map +1 -1
- package/package.json +10 -1
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
|
|
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
|
[](https://www.npmjs.com/package/@limo-labs/deity)
|
|
8
|
-
[](https://github.com/
|
|
12
|
+
[](https://github.com/Limo-Labs/Limo-Deity/blob/main/LICENSE)
|
|
9
13
|
[](https://www.typescriptlang.org/)
|
|
10
14
|
|
|
11
15
|
## ✨ Features
|
|
12
16
|
|
|
13
|
-
- 🎨 **JSX/TSX Syntax** - Write agents with familiar React-like
|
|
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
|
-
|
|
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
|
-
|
|
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/
|
|
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/
|
|
676
|
+
- [Issues](https://github.com/Limo-Labs/Limo-Deity/issues)
|
|
570
677
|
- [Changelog](./CHANGELOG.md)
|
|
571
678
|
|
|
572
679
|
---
|