deepagentsdk 0.9.2
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/LICENSE +21 -0
- package/README.md +159 -0
- package/package.json +95 -0
- package/src/agent.ts +1230 -0
- package/src/backends/composite.ts +273 -0
- package/src/backends/filesystem.ts +692 -0
- package/src/backends/index.ts +22 -0
- package/src/backends/local-sandbox.ts +175 -0
- package/src/backends/persistent.ts +593 -0
- package/src/backends/sandbox.ts +510 -0
- package/src/backends/state.ts +244 -0
- package/src/backends/utils.ts +287 -0
- package/src/checkpointer/file-saver.ts +98 -0
- package/src/checkpointer/index.ts +5 -0
- package/src/checkpointer/kv-saver.ts +82 -0
- package/src/checkpointer/memory-saver.ts +82 -0
- package/src/checkpointer/types.ts +125 -0
- package/src/cli/components/ApiKeyInput.tsx +300 -0
- package/src/cli/components/FilePreview.tsx +237 -0
- package/src/cli/components/Input.tsx +277 -0
- package/src/cli/components/Message.tsx +93 -0
- package/src/cli/components/ModelSelection.tsx +338 -0
- package/src/cli/components/SlashMenu.tsx +101 -0
- package/src/cli/components/StatusBar.tsx +89 -0
- package/src/cli/components/Subagent.tsx +91 -0
- package/src/cli/components/TodoList.tsx +133 -0
- package/src/cli/components/ToolApproval.tsx +70 -0
- package/src/cli/components/ToolCall.tsx +144 -0
- package/src/cli/components/ToolCallSummary.tsx +175 -0
- package/src/cli/components/Welcome.tsx +75 -0
- package/src/cli/components/index.ts +24 -0
- package/src/cli/hooks/index.ts +12 -0
- package/src/cli/hooks/useAgent.ts +933 -0
- package/src/cli/index.tsx +1066 -0
- package/src/cli/theme.ts +205 -0
- package/src/cli/utils/model-list.ts +365 -0
- package/src/constants/errors.ts +29 -0
- package/src/constants/limits.ts +195 -0
- package/src/index.ts +176 -0
- package/src/middleware/agent-memory.ts +330 -0
- package/src/prompts.ts +196 -0
- package/src/skills/index.ts +2 -0
- package/src/skills/load.ts +191 -0
- package/src/skills/types.ts +53 -0
- package/src/tools/execute.ts +167 -0
- package/src/tools/filesystem.ts +418 -0
- package/src/tools/index.ts +39 -0
- package/src/tools/subagent.ts +443 -0
- package/src/tools/todos.ts +101 -0
- package/src/tools/web.ts +567 -0
- package/src/types/backend.ts +177 -0
- package/src/types/core.ts +220 -0
- package/src/types/events.ts +429 -0
- package/src/types/index.ts +94 -0
- package/src/types/structured-output.ts +43 -0
- package/src/types/subagent.ts +96 -0
- package/src/types.ts +22 -0
- package/src/utils/approval.ts +213 -0
- package/src/utils/events.ts +416 -0
- package/src/utils/eviction.ts +181 -0
- package/src/utils/index.ts +34 -0
- package/src/utils/model-parser.ts +38 -0
- package/src/utils/patch-tool-calls.ts +233 -0
- package/src/utils/project-detection.ts +32 -0
- package/src/utils/summarization.ts +254 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 deepagentsdk contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# AI SDK Deep Agent
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="assets/www-hero.png" alt="AI SDK Deep Agent" width="100%" />
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/deepagentsdk)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
[](https://deepwiki.com/chrispangg/ai-sdk-deepagent)
|
|
10
|
+
[](https://deepagentsdk.vercel.app/docs)
|
|
11
|
+
|
|
12
|
+
> **Note:** This package requires [Bun](https://bun.sh) runtime. It uses Bun-specific features and TypeScript imports.
|
|
13
|
+
|
|
14
|
+
A TypeScript library for building controllable AI agents using [Vercel AI SDK](https://ai-sdk.dev/). This is a reimplementation of [deepagentsjs](https://github.com/langchain-ai/deepagentsjs) without any LangChain/LangGraph dependencies.
|
|
15
|
+
|
|
16
|
+
## What is Deep Agent?
|
|
17
|
+
|
|
18
|
+
Using an LLM to call tools in a loop is the simplest form of an agent. This architecture, however, can yield agents that are "shallow" and fail to plan and act over longer, more complex tasks.
|
|
19
|
+
|
|
20
|
+
Deep Agent addresses these limitations through four core architectural components:
|
|
21
|
+
|
|
22
|
+
| Component | Purpose | Implementation |
|
|
23
|
+
|-----------|---------|----------------|
|
|
24
|
+
| **Planning Tool** | Long-term task breakdown and tracking | `write_todos` for maintaining task lists |
|
|
25
|
+
| **Sub Agents** | Task delegation and specialization | `task` tool for spawning specialized agents |
|
|
26
|
+
| **File System Access** | Persistent state and information storage | Virtual filesystem with `read_file`, `write_file`, `edit_file` |
|
|
27
|
+
| **Detailed Prompts** | Context-aware instructions | Sophisticated prompting strategies |
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
This package requires Bun runtime:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# Install Bun if you haven't already
|
|
35
|
+
curl -fsSL https://bun.sh/install | bash
|
|
36
|
+
|
|
37
|
+
# Install the package
|
|
38
|
+
bun add deepagentsdk
|
|
39
|
+
|
|
40
|
+
# Or install globally for CLI usage
|
|
41
|
+
bun add -g deepagentsdk
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Why Bun?** This package publishes TypeScript source directly and uses Bun-specific optimizations for better performance.
|
|
45
|
+
|
|
46
|
+
## Quick Start
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { createDeepAgent } from 'deepagentsdk';
|
|
50
|
+
import { anthropic } from '@ai-sdk/anthropic';
|
|
51
|
+
|
|
52
|
+
const agent = createDeepAgent({
|
|
53
|
+
model: anthropic('claude-sonnet-4-5-20250929'),
|
|
54
|
+
systemPrompt: 'You are an expert researcher.',
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const result = await agent.generate({
|
|
58
|
+
prompt: 'Research the topic of quantum computing and write a report',
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
console.log(result.text);
|
|
62
|
+
console.log('Todos:', result.state.todos);
|
|
63
|
+
console.log('Files:', Object.keys(result.state.files));
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Features
|
|
67
|
+
|
|
68
|
+
### Structured Output
|
|
69
|
+
|
|
70
|
+
Deep agents can return typed, validated objects using Zod schemas alongside text responses:
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
import { z } from 'zod';
|
|
74
|
+
|
|
75
|
+
const agent = createDeepAgent({
|
|
76
|
+
model: anthropic('claude-sonnet-4-5-20250929'),
|
|
77
|
+
output: {
|
|
78
|
+
schema: z.object({
|
|
79
|
+
summary: z.string(),
|
|
80
|
+
keyPoints: z.array(z.string()),
|
|
81
|
+
}),
|
|
82
|
+
description: 'Research findings',
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const result = await agent.generate({
|
|
87
|
+
prompt: "Research latest AI developments",
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
console.log(result.output?.summary); // string
|
|
91
|
+
console.log(result.output?.keyPoints); // string[]
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Streaming with Events
|
|
95
|
+
|
|
96
|
+
Stream responses with real-time events for tool calls, file operations, and more:
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
for await (const event of agent.streamWithEvents({
|
|
100
|
+
prompt: 'Build a todo app',
|
|
101
|
+
})) {
|
|
102
|
+
switch (event.type) {
|
|
103
|
+
case 'text':
|
|
104
|
+
process.stdout.write(event.text);
|
|
105
|
+
break;
|
|
106
|
+
case 'tool-call':
|
|
107
|
+
console.log(`Calling: ${event.toolName}`);
|
|
108
|
+
break;
|
|
109
|
+
case 'file-written':
|
|
110
|
+
console.log(`Written: ${event.path}`);
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Built-in Tools
|
|
117
|
+
|
|
118
|
+
- **Planning**: `write_todos` for task management
|
|
119
|
+
- **Filesystem**: `read_file`, `write_file`, `edit_file`, `ls`, `glob`, `grep`
|
|
120
|
+
- **Web**: `web_search`, `http_request`, `fetch_url` (requires Tavily API key)
|
|
121
|
+
- **Execute**: Shell command execution with `LocalSandbox` backend
|
|
122
|
+
- **Subagents**: Spawn specialized agents for complex subtasks
|
|
123
|
+
|
|
124
|
+
## Documentation
|
|
125
|
+
|
|
126
|
+
For comprehensive guides, API reference, and examples, visit **[deepagentsdk.vercel.app/docs](https://deepagentsdk.vercel.app/docs)**
|
|
127
|
+
|
|
128
|
+
### Key Documentation Sections
|
|
129
|
+
|
|
130
|
+
- **[Get Started](https://deepagentsdk.vercel.app/docs/get-started)** - Installation and basic setup
|
|
131
|
+
- **[Guides](https://deepagentsdk.vercel.app/docs/guides)** - In-depth tutorials on:
|
|
132
|
+
- Configuration options (models, backends, middleware)
|
|
133
|
+
- Custom tools and subagents
|
|
134
|
+
- Agent memory and persistence
|
|
135
|
+
- Prompt caching and conversation summarization
|
|
136
|
+
- Web tools and API integration
|
|
137
|
+
- **[Reference](https://deepagentsdk.vercel.app/docs/reference)** - Complete API documentation
|
|
138
|
+
|
|
139
|
+
## CLI
|
|
140
|
+
|
|
141
|
+
The interactive CLI is built with [Ink](https://github.com/vadimdemedes/ink):
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# Run without installing (recommended)
|
|
145
|
+
bunx deepagentsdk
|
|
146
|
+
|
|
147
|
+
# Or install globally
|
|
148
|
+
bun add -g deepagentsdk
|
|
149
|
+
deep-agent
|
|
150
|
+
|
|
151
|
+
# With options
|
|
152
|
+
bunx deepagentsdk --model anthropic/claude-haiku-4-5-20251001
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**API Keys**: Load from environment variables (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `TAVILY_API_KEY`) or `.env` file.
|
|
156
|
+
|
|
157
|
+
## License
|
|
158
|
+
|
|
159
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "deepagentsdk",
|
|
3
|
+
"version": "0.9.2",
|
|
4
|
+
"description": "Deep Agent implementation using Vercel AI SDK - build controllable AI agents with planning, filesystem, and subagent capabilities",
|
|
5
|
+
"main": "./src/index.ts",
|
|
6
|
+
"module": "./src/index.ts",
|
|
7
|
+
"types": "./src/index.ts",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"bin": {
|
|
10
|
+
"deep-agent": "./src/cli/index.tsx"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./src/index.ts",
|
|
15
|
+
"types": "./src/index.ts"
|
|
16
|
+
},
|
|
17
|
+
"./cli": {
|
|
18
|
+
"import": "./src/cli/index.ts"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"src",
|
|
23
|
+
"README.md",
|
|
24
|
+
"LICENSE"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"test": "bun test test/",
|
|
28
|
+
"test:integration": "bun test test-integration/",
|
|
29
|
+
"test:all": "bun run test && bun run test:integration",
|
|
30
|
+
"typecheck": "tsc --noEmit",
|
|
31
|
+
"prepublishOnly": "bun run typecheck",
|
|
32
|
+
"cli": "bun src/cli/index.tsx"
|
|
33
|
+
},
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/chrispangg/ai-sdk-deepagent.git"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/chrispangg/ai-sdk-deepagent#readme",
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/chrispangg/ai-sdk-deepagent/issues"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@ai-sdk/anthropic": "^3.0.0-beta.83",
|
|
44
|
+
"@ai-sdk/openai": "^3.0.0-beta.96",
|
|
45
|
+
"@ai-sdk/react": "^3.0.0-beta.153",
|
|
46
|
+
"@inkjs/ui": "^1.0.0",
|
|
47
|
+
"@mozilla/readability": "^0.6.0",
|
|
48
|
+
"@tavily/core": "^0.6.1",
|
|
49
|
+
"ai": "^6.0.0-beta.150",
|
|
50
|
+
"fast-glob": "^3.3.3",
|
|
51
|
+
"ink": "^5.1.0",
|
|
52
|
+
"jsdom": "^25.0.1",
|
|
53
|
+
"micromatch": "^4.0.8",
|
|
54
|
+
"react": "^18.2.0",
|
|
55
|
+
"react-devtools-core": "^5.3.2",
|
|
56
|
+
"turndown": "^7.2.0",
|
|
57
|
+
"zod": "^3.25.0"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@langfuse/otel": "^4.5.1",
|
|
61
|
+
"@langfuse/tracing": "^4.5.1",
|
|
62
|
+
"@opentelemetry/api-logs": "^0.208.0",
|
|
63
|
+
"@opentelemetry/instrumentation": "^0.208.0",
|
|
64
|
+
"@opentelemetry/sdk-logs": "^0.208.0",
|
|
65
|
+
"@opentelemetry/sdk-node": "^0.208.0",
|
|
66
|
+
"@types/bun": "latest",
|
|
67
|
+
"@types/jsdom": "^21.1.7",
|
|
68
|
+
"@types/micromatch": "^4.0.9",
|
|
69
|
+
"@types/react": "^18.3.18",
|
|
70
|
+
"@types/turndown": "^5.0.5",
|
|
71
|
+
"@vercel/otel": "^2.1.0",
|
|
72
|
+
"install": "^0.13.0",
|
|
73
|
+
"langfuse-vercel": "^3.38.6",
|
|
74
|
+
"typescript": "^5.7.3"
|
|
75
|
+
},
|
|
76
|
+
"peerDependencies": {
|
|
77
|
+
"typescript": "^5"
|
|
78
|
+
},
|
|
79
|
+
"keywords": [
|
|
80
|
+
"ai",
|
|
81
|
+
"agents",
|
|
82
|
+
"deep-agents",
|
|
83
|
+
"vercel-ai-sdk",
|
|
84
|
+
"llm",
|
|
85
|
+
"typescript",
|
|
86
|
+
"bun",
|
|
87
|
+
"anthropic",
|
|
88
|
+
"openai",
|
|
89
|
+
"ai-sdk"
|
|
90
|
+
],
|
|
91
|
+
"engines": {
|
|
92
|
+
"bun": ">=1.0.0"
|
|
93
|
+
},
|
|
94
|
+
"license": "MIT"
|
|
95
|
+
}
|