@letta-ai/letta-code-sdk 0.0.3 → 0.0.5
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 +108 -155
- package/dist/index.d.ts +100 -53
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +168 -94
- package/dist/index.js.map +7 -7
- package/dist/session.d.ts +16 -5
- package/dist/session.d.ts.map +1 -1
- package/dist/transport.d.ts +2 -4
- package/dist/transport.d.ts.map +1 -1
- package/dist/types.d.ts +77 -43
- package/dist/types.d.ts.map +1 -1
- package/dist/validation.d.ts +8 -5
- package/dist/validation.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,16 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@letta-ai/letta-code-sdk) [](https://discord.gg/letta)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
> [!TIP]
|
|
6
|
+
> Check out [**LettaBot**](https://github.com/letta-ai/lettabot) and [**Letta Cowork**](https://github.com/letta-ai/letta-cowork), two open-source apps built on the **Letta Code SDK**.
|
|
7
|
+
|
|
8
|
+
The SDK interface to [**Letta Code**](https://github.com/letta-ai/letta-code). Build agents with persistent memory that learn over time.
|
|
6
9
|
|
|
7
10
|
```typescript
|
|
8
|
-
import {
|
|
11
|
+
import { createSession } from '@letta-ai/letta-code-sdk';
|
|
9
12
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const session = createSession();
|
|
14
|
+
await session.send('Find and fix the bug in auth.py');
|
|
15
|
+
for await (const msg of session.stream()) {
|
|
16
|
+
if (msg.type === 'assistant') console.log(msg.content);
|
|
17
|
+
}
|
|
15
18
|
```
|
|
16
19
|
|
|
17
20
|
## Installation
|
|
@@ -27,19 +30,27 @@ npm install @letta-ai/letta-code-sdk
|
|
|
27
30
|
```typescript
|
|
28
31
|
import { prompt } from '@letta-ai/letta-code-sdk';
|
|
29
32
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
// One-shot (uses default agent - like `letta -p`)
|
|
34
|
+
const result = await prompt('What is 2 + 2?');
|
|
35
|
+
console.log(result.result);
|
|
36
|
+
|
|
37
|
+
// One-shot with specific agent
|
|
38
|
+
const result2 = await prompt('Run: echo hello', agentId);
|
|
35
39
|
```
|
|
36
40
|
|
|
37
41
|
### Multi-turn session
|
|
38
42
|
|
|
39
43
|
```typescript
|
|
40
|
-
import {
|
|
44
|
+
import { createAgent, resumeSession } from '@letta-ai/letta-code-sdk';
|
|
45
|
+
|
|
46
|
+
// Create an agent with custom memory (has default conversation)
|
|
47
|
+
const agentId = await createAgent({
|
|
48
|
+
memory: ['persona'],
|
|
49
|
+
persona: 'You are a helpful coding assistant for TypeScript projects'
|
|
50
|
+
});
|
|
41
51
|
|
|
42
|
-
|
|
52
|
+
// Resume the default conversation
|
|
53
|
+
await using session = resumeSession(agentId);
|
|
43
54
|
|
|
44
55
|
await session.send('What is 5 + 3?');
|
|
45
56
|
for await (const msg of session.stream()) {
|
|
@@ -57,16 +68,16 @@ for await (const msg of session.stream()) {
|
|
|
57
68
|
Agents persist across sessions and remember context:
|
|
58
69
|
|
|
59
70
|
```typescript
|
|
60
|
-
import {
|
|
71
|
+
import { createAgent, resumeSession } from '@letta-ai/letta-code-sdk';
|
|
61
72
|
|
|
62
|
-
//
|
|
63
|
-
const
|
|
73
|
+
// Create agent and teach it something
|
|
74
|
+
const agentId = await createAgent();
|
|
75
|
+
const session1 = resumeSession(agentId);
|
|
64
76
|
await session1.send('Remember: the secret word is "banana"');
|
|
65
77
|
for await (const msg of session1.stream()) { /* ... */ }
|
|
66
|
-
const agentId = session1.agentId;
|
|
67
78
|
session1.close();
|
|
68
79
|
|
|
69
|
-
// Later...
|
|
80
|
+
// Later... resume the default conversation
|
|
70
81
|
await using session2 = resumeSession(agentId);
|
|
71
82
|
await session2.send('What is the secret word?');
|
|
72
83
|
for await (const msg of session2.stream()) {
|
|
@@ -74,49 +85,46 @@ for await (const msg of session2.stream()) {
|
|
|
74
85
|
}
|
|
75
86
|
```
|
|
76
87
|
|
|
77
|
-
|
|
88
|
+
## Multi-threaded Conversations
|
|
78
89
|
|
|
79
90
|
Run multiple concurrent conversations with the same agent. Each conversation has its own message history while sharing the agent's persistent memory.
|
|
80
91
|
|
|
81
92
|
```typescript
|
|
82
|
-
import { createSession, resumeSession
|
|
93
|
+
import { createAgent, createSession, resumeSession } from '@letta-ai/letta-code-sdk';
|
|
83
94
|
|
|
84
|
-
// Create an agent
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
95
|
+
// Create an agent (has default conversation)
|
|
96
|
+
const agentId = await createAgent();
|
|
97
|
+
|
|
98
|
+
// Resume the default conversation
|
|
99
|
+
const session1 = resumeSession(agentId);
|
|
100
|
+
await session1.send('Hello!');
|
|
101
|
+
for await (const msg of session1.stream()) { /* ... */ }
|
|
102
|
+
const conversationId = session1.conversationId; // Save this!
|
|
103
|
+
session1.close();
|
|
104
|
+
|
|
105
|
+
// Resume a specific conversation by ID
|
|
106
|
+
await using session2 = resumeSession(conversationId); // auto-detects conv-xxx
|
|
94
107
|
await session2.send('Continue our discussion...');
|
|
95
108
|
for await (const msg of session2.stream()) { /* ... */ }
|
|
96
109
|
|
|
97
110
|
// Create a NEW conversation on the same agent
|
|
98
|
-
await using session3 =
|
|
111
|
+
await using session3 = createSession(agentId);
|
|
99
112
|
await session3.send('Start a fresh thread...');
|
|
100
113
|
// session3.conversationId is different from conversationId
|
|
101
114
|
|
|
102
|
-
//
|
|
103
|
-
await using session4 =
|
|
104
|
-
|
|
105
|
-
// Resume last used session (agent + conversation)
|
|
106
|
-
await using session5 = createSession({ continue: true });
|
|
107
|
-
|
|
108
|
-
// Create new agent with a new (non-default) conversation
|
|
109
|
-
await using session6 = createSession({ newConversation: true });
|
|
115
|
+
// Start fresh conversation with default agent
|
|
116
|
+
await using session4 = createSession();
|
|
110
117
|
```
|
|
111
118
|
|
|
112
119
|
**Key concepts:**
|
|
113
120
|
- **Agent** (`agentId`): Persistent entity with memory that survives across sessions
|
|
114
121
|
- **Conversation** (`conversationId`): A message thread within an agent
|
|
115
|
-
- **Session
|
|
122
|
+
- **Session**: A single execution/connection
|
|
123
|
+
- **Default conversation**: Always exists after `createAgent()` - use `resumeSession(agentId)` to access it
|
|
116
124
|
|
|
117
125
|
Agents remember across conversations (via memory blocks), but each conversation has its own message history.
|
|
118
126
|
|
|
119
|
-
##
|
|
127
|
+
## Session Configuration
|
|
120
128
|
|
|
121
129
|
### System Prompt
|
|
122
130
|
|
|
@@ -124,12 +132,12 @@ Choose from built-in presets or provide a custom prompt:
|
|
|
124
132
|
|
|
125
133
|
```typescript
|
|
126
134
|
// Use a preset
|
|
127
|
-
createSession({
|
|
135
|
+
createSession(agentId, {
|
|
128
136
|
systemPrompt: { type: 'preset', preset: 'letta-claude' }
|
|
129
137
|
});
|
|
130
138
|
|
|
131
139
|
// Use a preset with additional instructions
|
|
132
|
-
createSession({
|
|
140
|
+
createSession(agentId, {
|
|
133
141
|
systemPrompt: {
|
|
134
142
|
type: 'preset',
|
|
135
143
|
preset: 'letta-claude',
|
|
@@ -138,7 +146,7 @@ createSession({
|
|
|
138
146
|
});
|
|
139
147
|
|
|
140
148
|
// Use a completely custom prompt
|
|
141
|
-
createSession({
|
|
149
|
+
createSession(agentId, {
|
|
142
150
|
systemPrompt: 'You are a helpful Python expert.'
|
|
143
151
|
});
|
|
144
152
|
```
|
|
@@ -151,80 +159,7 @@ createSession({
|
|
|
151
159
|
- `codex` - Basic Codex
|
|
152
160
|
- `gemini` - Basic Gemini
|
|
153
161
|
|
|
154
|
-
### Memory Blocks
|
|
155
|
-
|
|
156
|
-
Configure which memory blocks the agent uses:
|
|
157
|
-
|
|
158
|
-
```typescript
|
|
159
|
-
// Use default blocks (persona, human, project)
|
|
160
|
-
createSession({});
|
|
161
|
-
|
|
162
|
-
// Use specific preset blocks
|
|
163
|
-
createSession({
|
|
164
|
-
memory: ['project', 'persona'] // Only these blocks
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
// Use custom blocks
|
|
168
|
-
createSession({
|
|
169
|
-
memory: [
|
|
170
|
-
{ label: 'context', value: 'API documentation for Acme Corp...' },
|
|
171
|
-
{ label: 'rules', value: 'Always use TypeScript. Prefer functional patterns.' }
|
|
172
|
-
]
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
// Mix presets and custom blocks
|
|
176
|
-
createSession({
|
|
177
|
-
memory: [
|
|
178
|
-
'project', // Use default project block
|
|
179
|
-
{ label: 'custom', value: 'Additional context...' }
|
|
180
|
-
]
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
// No optional blocks (only core skills blocks)
|
|
184
|
-
createSession({
|
|
185
|
-
memory: []
|
|
186
|
-
});
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
### Convenience Props
|
|
190
162
|
|
|
191
|
-
Quickly customize common memory blocks:
|
|
192
|
-
|
|
193
|
-
```typescript
|
|
194
|
-
createSession({
|
|
195
|
-
persona: 'You are a senior Python developer who writes clean, tested code.',
|
|
196
|
-
human: 'Name: Alice. Prefers concise responses.',
|
|
197
|
-
project: 'FastAPI backend for a todo app using PostgreSQL.'
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
// Combine with memory config
|
|
201
|
-
createSession({
|
|
202
|
-
memory: ['persona', 'project'], // Only include these blocks
|
|
203
|
-
persona: 'You are a Go expert.',
|
|
204
|
-
project: 'CLI tool for managing Docker containers.'
|
|
205
|
-
});
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
### Tool Execution
|
|
209
|
-
|
|
210
|
-
Execute tools with automatic permission handling:
|
|
211
|
-
|
|
212
|
-
```typescript
|
|
213
|
-
import { prompt } from '@letta-ai/letta-code-sdk';
|
|
214
|
-
|
|
215
|
-
// Run shell commands
|
|
216
|
-
const result = await prompt('List all TypeScript files', {
|
|
217
|
-
allowedTools: ['Glob', 'Bash'],
|
|
218
|
-
permissionMode: 'bypassPermissions',
|
|
219
|
-
cwd: '/path/to/project'
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
// Read and analyze code
|
|
223
|
-
const analysis = await prompt('Explain what auth.ts does', {
|
|
224
|
-
allowedTools: ['Read', 'Grep'],
|
|
225
|
-
permissionMode: 'bypassPermissions'
|
|
226
|
-
});
|
|
227
|
-
```
|
|
228
163
|
|
|
229
164
|
## API Reference
|
|
230
165
|
|
|
@@ -232,10 +167,10 @@ const analysis = await prompt('Explain what auth.ts does', {
|
|
|
232
167
|
|
|
233
168
|
| Function | Description |
|
|
234
169
|
|----------|-------------|
|
|
235
|
-
| `
|
|
236
|
-
| `createSession(options?)` |
|
|
237
|
-
| `resumeSession(
|
|
238
|
-
| `
|
|
170
|
+
| `createAgent(options?)` | Create new agent with custom memory/prompt. No options = blank agent with default memory blocks. Returns `agentId` |
|
|
171
|
+
| `createSession(agentId?, options?)` | New conversation on specified agent. No agentId = uses LRU agent (or creates "Memo" if none exists) |
|
|
172
|
+
| `resumeSession(id, options?)` | Resume session - pass `agent-xxx` for default conv, `conv-xxx` for specific conv |
|
|
173
|
+
| `prompt(message, agentId?)` | One-shot query with default/specified agent (like `letta -p`) |
|
|
239
174
|
|
|
240
175
|
### Session
|
|
241
176
|
|
|
@@ -250,41 +185,38 @@ const analysis = await prompt('Explain what auth.ts does', {
|
|
|
250
185
|
|
|
251
186
|
### Options
|
|
252
187
|
|
|
188
|
+
**CreateAgentOptions** (for `createAgent()` - full control):
|
|
189
|
+
|
|
253
190
|
```typescript
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
type: 'preset';
|
|
267
|
-
preset: 'default' | 'letta-claude' | 'letta-codex' | 'letta-gemini' | 'claude' | 'codex' | 'gemini';
|
|
268
|
-
append?: string;
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
// Memory blocks: preset names, custom blocks, or mixed
|
|
272
|
-
memory?: Array<string | CreateBlock | { blockId: string }>;
|
|
273
|
-
|
|
274
|
-
// Convenience: set block values directly
|
|
275
|
-
persona?: string;
|
|
276
|
-
human?: string;
|
|
277
|
-
project?: string;
|
|
278
|
-
|
|
279
|
-
// Tool configuration
|
|
280
|
-
allowedTools?: string[];
|
|
281
|
-
permissionMode?: 'default' | 'acceptEdits' | 'bypassPermissions';
|
|
282
|
-
|
|
283
|
-
// Working directory
|
|
284
|
-
cwd?: string;
|
|
285
|
-
}
|
|
191
|
+
// Create blank agent
|
|
192
|
+
await createAgent();
|
|
193
|
+
|
|
194
|
+
// Create agent with custom memory and system prompt
|
|
195
|
+
await createAgent({
|
|
196
|
+
model: 'claude-sonnet-4',
|
|
197
|
+
systemPrompt: 'You are a helpful Python expert.',
|
|
198
|
+
memory: [
|
|
199
|
+
{ label: 'persona', value: 'You are a senior Python developer' },
|
|
200
|
+
{ label: 'project', value: 'FastAPI backend for a todo app' }
|
|
201
|
+
]
|
|
202
|
+
});
|
|
286
203
|
```
|
|
287
204
|
|
|
205
|
+
**CreateSessionOptions** (for `createSession()` / `resumeSession()` - runtime options):
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
// Start session with permissions
|
|
209
|
+
createSession(agentId, {
|
|
210
|
+
permissionMode: 'bypassPermissions',
|
|
211
|
+
allowedTools: ['Bash', 'Glob'],
|
|
212
|
+
cwd: '/path/to/project'
|
|
213
|
+
});
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**Available system prompt presets:**
|
|
217
|
+
- `default` / `letta-claude`, `letta-codex`, `letta-gemini` - Full Letta Code prompts
|
|
218
|
+
- `claude`, `codex`, `gemini` - Basic (no skills/memory instructions)
|
|
219
|
+
|
|
288
220
|
### Message Types
|
|
289
221
|
|
|
290
222
|
```typescript
|
|
@@ -313,7 +245,7 @@ See [`examples/`](./examples/) for comprehensive examples including:
|
|
|
313
245
|
- Basic session usage
|
|
314
246
|
- Multi-turn conversations
|
|
315
247
|
- Session resume with persistent memory
|
|
316
|
-
- **Multi-threaded conversations** (
|
|
248
|
+
- **Multi-threaded conversations** (createSession, resumeSession)
|
|
317
249
|
- System prompt configuration
|
|
318
250
|
- Memory block customization
|
|
319
251
|
- Tool execution (Bash, Glob, Read, etc.)
|
|
@@ -326,6 +258,27 @@ bun examples/v2-examples.ts all
|
|
|
326
258
|
bun examples/v2-examples.ts conversations
|
|
327
259
|
```
|
|
328
260
|
|
|
261
|
+
## Internals
|
|
262
|
+
|
|
263
|
+
### CLI Mapping
|
|
264
|
+
|
|
265
|
+
The SDK spawns the Letta Code CLI as a subprocess. Here's how API calls map to CLI flags:
|
|
266
|
+
|
|
267
|
+
| Function | CLI Flags | Behavior |
|
|
268
|
+
|----------|-----------|----------|
|
|
269
|
+
| `createSession()` | `--new` | LRU agent + new conversation |
|
|
270
|
+
| `createSession(agentId)` | `--agent X --new` | Specified agent + new conversation |
|
|
271
|
+
| `createAgent()` | `--new-agent` | New agent + default conversation |
|
|
272
|
+
| `resumeSession(agentId)` | `--agent X --default` | Specified agent + default conversation |
|
|
273
|
+
| `resumeSession(convId)` | `--conversation X` | Derived agent + specified conversation |
|
|
274
|
+
| `prompt(msg)` | *(none)* | LRU agent + default conversation |
|
|
275
|
+
| `prompt(msg, agentId)` | `--agent X --new` | Specified agent + new conversation |
|
|
276
|
+
|
|
277
|
+
**Key concepts:**
|
|
278
|
+
- **LRU agent**: Most recently used agent from `.letta/settings.local.json`, or creates "Memo" if none exists
|
|
279
|
+
- **Default conversation**: The agent's primary message history (always exists)
|
|
280
|
+
- **New conversation**: Fresh message thread, isolated from other conversations
|
|
281
|
+
|
|
329
282
|
## License
|
|
330
283
|
|
|
331
284
|
Apache-2.0
|
package/dist/index.d.ts
CHANGED
|
@@ -5,92 +5,139 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* ```typescript
|
|
8
|
-
* import { createSession, prompt } from '@letta-ai/letta-code-sdk';
|
|
8
|
+
* import { createAgent, createSession, resumeSession, prompt } from '@letta-ai/letta-code-sdk';
|
|
9
9
|
*
|
|
10
|
-
* //
|
|
11
|
-
* const
|
|
10
|
+
* // Start session with default agent + new conversation (like `letta`)
|
|
11
|
+
* const session = createSession();
|
|
12
12
|
*
|
|
13
|
-
* //
|
|
14
|
-
*
|
|
15
|
-
* await session.send('Hello!');
|
|
16
|
-
* for await (const msg of session.stream()) {
|
|
17
|
-
* if (msg.type === 'assistant') console.log(msg.content);
|
|
18
|
-
* }
|
|
13
|
+
* // Create a new agent explicitly
|
|
14
|
+
* const agentId = await createAgent();
|
|
19
15
|
*
|
|
20
|
-
* // Resume
|
|
21
|
-
*
|
|
16
|
+
* // Resume default conversation on an agent
|
|
17
|
+
* const session = resumeSession(agentId);
|
|
18
|
+
*
|
|
19
|
+
* // Resume specific conversation
|
|
20
|
+
* const session = resumeSession('conv-xxx');
|
|
21
|
+
*
|
|
22
|
+
* // Create new conversation on specific agent
|
|
23
|
+
* const session = createSession(agentId);
|
|
24
|
+
*
|
|
25
|
+
* // One-shot prompt (uses default agent)
|
|
26
|
+
* const result = await prompt('Hello');
|
|
27
|
+
* const result = await prompt('Hello', agentId); // specific agent
|
|
22
28
|
* ```
|
|
23
29
|
*/
|
|
24
30
|
import { Session } from "./session.js";
|
|
25
|
-
import type {
|
|
26
|
-
export type {
|
|
31
|
+
import type { CreateSessionOptions, CreateAgentOptions, SDKResultMessage } from "./types.js";
|
|
32
|
+
export type { CreateSessionOptions, CreateAgentOptions, SDKMessage, SDKInitMessage, SDKAssistantMessage, SDKToolCallMessage, SDKToolResultMessage, SDKReasoningMessage, SDKResultMessage, SDKStreamEventMessage, PermissionMode, CanUseToolCallback, CanUseToolResponse, CanUseToolResponseAllow, CanUseToolResponseDeny, TextContent, ImageContent, MessageContentItem, SendMessage, } from "./types.js";
|
|
27
33
|
export { Session } from "./session.js";
|
|
28
34
|
/**
|
|
29
|
-
* Create a new
|
|
30
|
-
*
|
|
31
|
-
* The agent will have persistent memory that survives across sessions.
|
|
32
|
-
* Use `resumeSession` to continue a conversation with an existing agent.
|
|
35
|
+
* Create a new agent with a default conversation.
|
|
36
|
+
* Returns the agentId which can be used with resumeSession or createSession.
|
|
33
37
|
*
|
|
34
38
|
* @example
|
|
35
39
|
* ```typescript
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
40
|
+
* // Create agent with default settings
|
|
41
|
+
* const agentId = await createAgent();
|
|
42
|
+
*
|
|
43
|
+
* // Create agent with custom memory
|
|
44
|
+
* const agentId = await createAgent({
|
|
45
|
+
* memory: ['persona', 'project'],
|
|
46
|
+
* persona: 'You are a helpful coding assistant',
|
|
47
|
+
* model: 'claude-sonnet-4'
|
|
48
|
+
* });
|
|
49
|
+
*
|
|
50
|
+
* // Then resume the default conversation:
|
|
51
|
+
* const session = resumeSession(agentId);
|
|
42
52
|
* ```
|
|
43
53
|
*/
|
|
44
|
-
export declare function
|
|
54
|
+
export declare function createAgent(options?: CreateAgentOptions): Promise<string>;
|
|
45
55
|
/**
|
|
46
|
-
*
|
|
56
|
+
* Create a new conversation (session).
|
|
47
57
|
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
58
|
+
* - Without agentId: uses default/LRU agent with new conversation (like `letta`)
|
|
59
|
+
* - With agentId: creates new conversation on specified agent
|
|
50
60
|
*
|
|
51
61
|
* @example
|
|
52
62
|
* ```typescript
|
|
53
|
-
* //
|
|
54
|
-
* await using session =
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* }
|
|
63
|
+
* // New conversation on default agent (like `letta`)
|
|
64
|
+
* await using session = createSession();
|
|
65
|
+
*
|
|
66
|
+
* // New conversation on specific agent
|
|
67
|
+
* await using session = createSession(agentId);
|
|
59
68
|
* ```
|
|
60
69
|
*/
|
|
61
|
-
export declare function
|
|
70
|
+
export declare function createSession(agentId?: string, options?: CreateSessionOptions): Session;
|
|
62
71
|
/**
|
|
63
|
-
* Resume an existing
|
|
72
|
+
* Resume an existing session.
|
|
64
73
|
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
74
|
+
* - Pass an agent ID (agent-xxx) to resume the default conversation
|
|
75
|
+
* - Pass a conversation ID (conv-xxx) to resume a specific conversation
|
|
76
|
+
*
|
|
77
|
+
* The default conversation always exists after createAgent, so you can:
|
|
78
|
+
* `createAgent()` → `resumeSession(agentId)` without needing createSession first.
|
|
67
79
|
*
|
|
68
80
|
* @example
|
|
69
81
|
* ```typescript
|
|
70
|
-
* // Resume
|
|
71
|
-
* await using session =
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* }
|
|
82
|
+
* // Resume default conversation
|
|
83
|
+
* await using session = resumeSession(agentId);
|
|
84
|
+
*
|
|
85
|
+
* // Resume specific conversation
|
|
86
|
+
* await using session = resumeSession('conv-xxx');
|
|
76
87
|
* ```
|
|
77
88
|
*/
|
|
78
|
-
export declare function
|
|
89
|
+
export declare function resumeSession(id: string, options?: CreateSessionOptions): Session;
|
|
79
90
|
/**
|
|
80
91
|
* One-shot prompt convenience function.
|
|
81
92
|
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
93
|
+
* - Without agentId: uses default agent (like `letta -p`), new conversation
|
|
94
|
+
* - With agentId: uses specific agent, new conversation
|
|
84
95
|
*
|
|
85
96
|
* @example
|
|
86
97
|
* ```typescript
|
|
87
|
-
* const result = await prompt('What is
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
98
|
+
* const result = await prompt('What is 2+2?'); // default agent
|
|
99
|
+
* const result = await prompt('What is the capital of France?', agentId); // specific agent
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export declare function prompt(message: string, agentId?: string): Promise<SDKResultMessage>;
|
|
103
|
+
import type { ImageContent } from "./types.js";
|
|
104
|
+
/**
|
|
105
|
+
* Create image content from a file path.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```typescript
|
|
109
|
+
* await session.send([
|
|
110
|
+
* { type: "text", text: "What's in this image?" },
|
|
111
|
+
* imageFromFile("./screenshot.png")
|
|
112
|
+
* ]);
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
export declare function imageFromFile(filePath: string): ImageContent;
|
|
116
|
+
/**
|
|
117
|
+
* Create image content from base64 data.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* const base64 = fs.readFileSync("image.png").toString("base64");
|
|
122
|
+
* await session.send([
|
|
123
|
+
* { type: "text", text: "Describe this" },
|
|
124
|
+
* imageFromBase64(base64, "image/png")
|
|
125
|
+
* ]);
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
export declare function imageFromBase64(data: string, media_type?: ImageContent["source"]["media_type"]): ImageContent;
|
|
129
|
+
/**
|
|
130
|
+
* Create image content from a URL.
|
|
131
|
+
* Fetches the image and converts to base64.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* const img = await imageFromURL("https://example.com/image.png");
|
|
136
|
+
* await session.send([
|
|
137
|
+
* { type: "text", text: "What's this?" },
|
|
138
|
+
* img
|
|
139
|
+
* ]);
|
|
93
140
|
* ```
|
|
94
141
|
*/
|
|
95
|
-
export declare function
|
|
142
|
+
export declare function imageFromURL(url: string): Promise<ImageContent>;
|
|
96
143
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAI7F,YAAY,EACV,oBAAoB,EACpB,kBAAkB,EAClB,UAAU,EACV,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,EAEtB,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,WAAW,GACZ,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CAMnF;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAO3F;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAC3B,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAOT;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,MAAM,CAC1B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,gBAAgB,CAAC,CA+B3B;AAOD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,CAa5D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,UAAU,GAAE,YAAY,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAe,GAC7D,YAAY,CAKd;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAqBrE"}
|