@letta-ai/letta-agent-sdk 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.
Files changed (39) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +240 -0
  3. package/dist/app-server-session.d.ts +86 -0
  4. package/dist/app-server-session.d.ts.map +1 -0
  5. package/dist/cli-resolver.d.ts +9 -0
  6. package/dist/cli-resolver.d.ts.map +1 -0
  7. package/dist/client.d.ts +47 -0
  8. package/dist/client.d.ts.map +1 -0
  9. package/dist/cloud-session.d.ts +45 -0
  10. package/dist/cloud-session.d.ts.map +1 -0
  11. package/dist/index.d.ts +167 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +4994 -0
  14. package/dist/index.js.map +24 -0
  15. package/dist/interactiveToolPolicy.d.ts +4 -0
  16. package/dist/interactiveToolPolicy.d.ts.map +1 -0
  17. package/dist/local-app-server.d.ts +17 -0
  18. package/dist/local-app-server.d.ts.map +1 -0
  19. package/dist/protocol.d.ts +205 -0
  20. package/dist/protocol.d.ts.map +1 -0
  21. package/dist/remote-client-session-core.d.ts +140 -0
  22. package/dist/remote-client-session-core.d.ts.map +1 -0
  23. package/dist/remote.d.ts +57 -0
  24. package/dist/remote.d.ts.map +1 -0
  25. package/dist/session.d.ts +142 -0
  26. package/dist/session.d.ts.map +1 -0
  27. package/dist/stream-events.d.ts +15 -0
  28. package/dist/stream-events.d.ts.map +1 -0
  29. package/dist/tests/advanced-session.d.ts +10 -0
  30. package/dist/tests/advanced-session.d.ts.map +1 -0
  31. package/dist/tool-helpers.d.ts +47 -0
  32. package/dist/tool-helpers.d.ts.map +1 -0
  33. package/dist/transport.d.ts +53 -0
  34. package/dist/transport.d.ts.map +1 -0
  35. package/dist/types.d.ts +759 -0
  36. package/dist/types.d.ts.map +1 -0
  37. package/dist/validation.d.ts +15 -0
  38. package/dist/validation.d.ts.map +1 -0
  39. package/package.json +45 -0
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Letta Agent SDK
3
+ *
4
+ * Programmatic control of Letta Code CLI with persistent agent memory.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { LettaCodeClient, createAgent, createSession, resumeSession, prompt } from '@letta-ai/letta-agent-sdk';
9
+ *
10
+ * const client = new LettaCodeClient({ backend: 'local' });
11
+ * const agentId = await client.createAgent();
12
+ * const clientSession = client.resumeSession(agentId);
13
+ *
14
+ * // Start session with default agent + new conversation (like `letta`)
15
+ * const session = createSession();
16
+ *
17
+ * // Create a new agent explicitly
18
+ * const agentId = await createAgent();
19
+ *
20
+ * // Resume default conversation on an agent
21
+ * const session = resumeSession(agentId);
22
+ *
23
+ * // Resume specific conversation
24
+ * const session = resumeSession('conv-xxx');
25
+ *
26
+ * // Create new conversation on specific agent
27
+ * const session = createSession(agentId);
28
+ *
29
+ * // One-shot prompt (uses default agent)
30
+ * const result = await prompt('Hello');
31
+ * const result = await prompt('Hello', agentId); // specific agent
32
+ * ```
33
+ */
34
+ import type { CreateSessionOptions, CreateAgentOptions, LettaCodeSession, SDKResultMessage } from "./types.js";
35
+ export type { CreateSessionOptions, CreateAgentOptions, LettaCodeBackend, LettaCodeEnvironment, LettaCodeLocalClientOptions, LettaCodeLocalAppServerOptions, LettaCodeRemoteClientOptions, LettaCodeCloudClientOptions, LettaCodeClientOptions, LettaCodeClientSessionOptions, LettaCodeSession, LettaCodeSocketLike, LettaCodeSocketConstructor, SDKMessage, SDKInitMessage, SDKAssistantMessage, SDKToolCallMessage, SDKToolResultMessage, SDKReasoningMessage, SDKResultMessage, SDKErrorCode, SDKStreamEventMessage, SDKStreamEventPayload, SDKStreamEventDeltaPayload, SDKStreamEventMessagePayload, SDKUnknownStreamEventPayload, SDKErrorMessage, SDKRetryMessage, SDKQueueItem, SDKQueueUpdateMessage, SDKLoopStatusMessage, SDKProtocolMessage, SDKProtocolCommand, SendCommandOptions, RunTurnOptions, RecoverPendingApprovalsOptions, RecoverPendingApprovalsResult, SkillSource, DreamingOptions, DreamingTrigger, DreamingBehavior, EffectiveDreamingSettings, PermissionMode, ReasoningEffort, CanUseToolCallback, CanUseToolResponse, CanUseToolResponseAllow, CanUseToolResponseDeny, TextContent, ImageContent, MessageContentItem, SendMessage, ListMessagesOptions, ListMessagesResult, ListModelsResult, LettaCodeModelEntry, UpdateModelOptions, UpdateModelResult, BootstrapStateOptions, BootstrapStateResult, AgentTool, AgentToolResult, AgentToolResultContent, AgentToolUpdateCallback, AnyAgentTool, } from "./types.js";
36
+ export { Session } from "./session.js";
37
+ export { LettaCodeClient } from "./client.js";
38
+ export { extractStreamTextDelta } from "./stream-events.js";
39
+ export { jsonResult, readStringParam, readNumberParam, readBooleanParam, readStringArrayParam, } from "./tool-helpers.js";
40
+ /**
41
+ * Create a new agent with a default conversation.
42
+ * Returns the agentId which can be used with resumeSession or createSession.
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * // Create agent with default settings.
47
+ * const agentId = await createAgent();
48
+ *
49
+ * // Create agent with custom memory
50
+ * const agentId = await createAgent({
51
+ * memory: ['persona', 'project'],
52
+ * persona: 'You are a helpful coding assistant',
53
+ * model: 'claude-sonnet-4',
54
+ * tags: ['project:docs']
55
+ * });
56
+ *
57
+ * // Then resume the default conversation:
58
+ * const session = resumeSession(agentId);
59
+ * ```
60
+ */
61
+ export declare function createAgent(options?: CreateAgentOptions): Promise<string>;
62
+ /**
63
+ * Create a new conversation (session).
64
+ *
65
+ * - Without agentId: uses default/LRU agent with new conversation (like `letta`)
66
+ * - With agentId: creates new conversation on specified agent
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * // New conversation on default agent (like `letta`)
71
+ * await using session = createSession();
72
+ *
73
+ * // New conversation on specific agent
74
+ * await using session = createSession(agentId);
75
+ * ```
76
+ */
77
+ export declare function createSession(agentId?: string, options?: CreateSessionOptions): LettaCodeSession;
78
+ /**
79
+ * Resume an existing session.
80
+ *
81
+ * - Pass an agent ID (agent-xxx) to resume the default conversation
82
+ * - Pass a conversation ID (conv-xxx) to resume a specific conversation
83
+ *
84
+ * The default conversation always exists after createAgent, so you can:
85
+ * `createAgent()` → `resumeSession(agentId)` without needing createSession first.
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * // Resume default conversation
90
+ * await using session = resumeSession(agentId);
91
+ *
92
+ * // Resume specific conversation
93
+ * await using session = resumeSession('conv-xxx');
94
+ * ```
95
+ */
96
+ export declare function resumeSession(id: string, options?: CreateSessionOptions): LettaCodeSession;
97
+ export declare function prompt(message: string, agentId?: string): Promise<SDKResultMessage>;
98
+ import type { ListMessagesOptions, ListMessagesResult } from "./types.js";
99
+ /**
100
+ * Fetch conversation messages without requiring a pre-existing session.
101
+ *
102
+ * Creates a transient CLI subprocess, fetches the requested message page, and
103
+ * closes the subprocess. Useful for prefetching conversation histories before
104
+ * opening a full session (e.g. desktop sidebar warm-up).
105
+ *
106
+ * Routing follows the same agent/conversation semantics as session history:
107
+ * - Pass a conv-xxx conversationId to read a specific conversation.
108
+ * - Omit conversationId to read the agent's default conversation.
109
+ *
110
+ * @param agentId - Agent ID to fetch messages for.
111
+ * @param options - Pagination / filtering options (same as ListMessagesOptions).
112
+ *
113
+ * @example
114
+ * ```typescript
115
+ * // Prefetch default conversation
116
+ * const { messages } = await listMessagesDirect(agentId);
117
+ *
118
+ * // Prefetch a specific conversation
119
+ * const { messages, hasMore, nextBefore } = await listMessagesDirect(agentId, {
120
+ * conversationId: 'conv-abc',
121
+ * limit: 20,
122
+ * order: 'desc',
123
+ * });
124
+ * ```
125
+ */
126
+ export declare function listMessagesDirect(agentId: string, options?: ListMessagesOptions): Promise<ListMessagesResult>;
127
+ import type { ImageContent } from "./types.js";
128
+ /**
129
+ * Create image content from a file path.
130
+ *
131
+ * @example
132
+ * ```typescript
133
+ * await session.send([
134
+ * { type: "text", text: "What's in this image?" },
135
+ * imageFromFile("./screenshot.png")
136
+ * ]);
137
+ * ```
138
+ */
139
+ export declare function imageFromFile(filePath: string): ImageContent;
140
+ /**
141
+ * Create image content from base64 data.
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * const base64 = fs.readFileSync("image.png").toString("base64");
146
+ * await session.send([
147
+ * { type: "text", text: "Describe this" },
148
+ * imageFromBase64(base64, "image/png")
149
+ * ]);
150
+ * ```
151
+ */
152
+ export declare function imageFromBase64(data: string, media_type?: ImageContent["source"]["media_type"]): ImageContent;
153
+ /**
154
+ * Create image content from a URL.
155
+ * Fetches the image and converts to base64.
156
+ *
157
+ * @example
158
+ * ```typescript
159
+ * const img = await imageFromURL("https://example.com/image.png");
160
+ * await session.send([
161
+ * { type: "text", text: "What's this?" },
162
+ * img
163
+ * ]);
164
+ * ```
165
+ */
166
+ export declare function imageFromURL(url: string): Promise<ImageContent>;
167
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAIH,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAEhB,gBAAgB,EAEjB,MAAM,YAAY,CAAC;AAIpB,YAAY,EACV,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,2BAA2B,EAC3B,8BAA8B,EAC9B,4BAA4B,EAC5B,2BAA2B,EAC3B,sBAAsB,EACtB,6BAA6B,EAC7B,gBAAgB,EAChB,mBAAmB,EACnB,0BAA0B,EAC1B,UAAU,EACV,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,4BAA4B,EAC5B,4BAA4B,EAC5B,eAAe,EACf,eAAe,EACf,YAAY,EACZ,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,8BAA8B,EAC9B,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