formagent-sdk 0.2.0 → 0.3.3
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 +2 -0
- package/dist/cli/index.js +1546 -134
- package/dist/index.js +1195 -34
- package/docs/README.md +126 -0
- package/docs/api-reference.md +677 -0
- package/docs/getting-started.md +273 -0
- package/docs/mcp-servers.md +465 -0
- package/docs/session-storage.md +320 -0
- package/docs/tools.md +501 -0
- package/package.json +3 -1
package/docs/README.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# formagent-sdk Documentation
|
|
2
|
+
|
|
3
|
+
Welcome to the documentation for `formagent-sdk`, a Claude Agent SDK compatible framework for building AI agents with streaming support, tool execution, and skill management.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Getting Started](./getting-started.md) - Quick start guide
|
|
8
|
+
- [API Reference](./api-reference.md) - Complete API documentation
|
|
9
|
+
- [Session Storage](./session-storage.md) - Persistent session management
|
|
10
|
+
- [Built-in Tools](./tools.md) - File operations, bash, and more
|
|
11
|
+
- [MCP Servers](./mcp-servers.md) - Model Context Protocol integration
|
|
12
|
+
|
|
13
|
+
## Quick Links
|
|
14
|
+
|
|
15
|
+
### Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install formagent-sdk
|
|
19
|
+
# or
|
|
20
|
+
bun add formagent-sdk
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Environment Setup
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
export ANTHROPIC_API_KEY=your-api-key
|
|
27
|
+
# Optional: Custom endpoint
|
|
28
|
+
export ANTHROPIC_BASE_URL=https://your-proxy.com
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Minimal Example
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { createSession, builtinTools } from "formagent-sdk"
|
|
35
|
+
|
|
36
|
+
const session = await createSession({
|
|
37
|
+
model: "claude-sonnet-4-20250514",
|
|
38
|
+
tools: builtinTools,
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
await session.send("List files in the current directory")
|
|
42
|
+
|
|
43
|
+
for await (const event of session.receive()) {
|
|
44
|
+
if (event.type === "text") {
|
|
45
|
+
process.stdout.write(event.text)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
await session.close()
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Core Concepts
|
|
53
|
+
|
|
54
|
+
### Sessions
|
|
55
|
+
|
|
56
|
+
Sessions manage conversations with Claude. They handle message history, tool execution, and streaming responses.
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
const session = await createSession({ model: "claude-sonnet-4-20250514" })
|
|
60
|
+
await session.send("Hello!")
|
|
61
|
+
for await (const event of session.receive()) { /* ... */ }
|
|
62
|
+
await session.close()
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Tools
|
|
66
|
+
|
|
67
|
+
Tools extend Claude's capabilities. The SDK provides built-in tools and supports custom tool definitions.
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { builtinTools, tool } from "formagent-sdk"
|
|
71
|
+
import { z } from "zod"
|
|
72
|
+
|
|
73
|
+
// Use built-in tools
|
|
74
|
+
const session = await createSession({ tools: builtinTools })
|
|
75
|
+
|
|
76
|
+
// Or create custom tools
|
|
77
|
+
const myTool = tool({
|
|
78
|
+
name: "my_tool",
|
|
79
|
+
description: "Does something useful",
|
|
80
|
+
schema: z.object({ input: z.string() }),
|
|
81
|
+
execute: async ({ input }) => `Result: ${input}`,
|
|
82
|
+
})
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### MCP Servers
|
|
86
|
+
|
|
87
|
+
MCP (Model Context Protocol) servers provide a standardized way to expose tools.
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
import { createSdkMcpServer, tool } from "formagent-sdk"
|
|
91
|
+
|
|
92
|
+
const server = createSdkMcpServer({
|
|
93
|
+
name: "my-server",
|
|
94
|
+
version: "1.0.0",
|
|
95
|
+
tools: [myTool],
|
|
96
|
+
})
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Architecture
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
formagent-sdk
|
|
103
|
+
├── Session API # Conversation management
|
|
104
|
+
│ ├── createSession() # Create new sessions
|
|
105
|
+
│ ├── send() # Send messages
|
|
106
|
+
│ └── receive() # Stream responses
|
|
107
|
+
├── Session Storage # Persistence layer
|
|
108
|
+
│ ├── MemorySessionStorage # In-memory (default, non-persistent)
|
|
109
|
+
│ └── FileSessionStorage # File-based persistence
|
|
110
|
+
├── Tool System # Tool execution
|
|
111
|
+
│ ├── builtinTools # Built-in tools (Bash, Read, Write, etc.)
|
|
112
|
+
│ ├── tool() # Tool definition helper
|
|
113
|
+
│ └── ToolManager # Tool registration and execution
|
|
114
|
+
├── MCP Integration # Model Context Protocol
|
|
115
|
+
│ ├── createSdkMcpServer()
|
|
116
|
+
│ └── MCPServerManager
|
|
117
|
+
└── Providers # LLM providers
|
|
118
|
+
├── AnthropicProvider
|
|
119
|
+
├── OpenAIProvider
|
|
120
|
+
└── GeminiProvider
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Support
|
|
124
|
+
|
|
125
|
+
- [GitHub Issues](https://github.com/anthropics/claude-code/issues)
|
|
126
|
+
- [Examples](../examples/)
|