@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.
- package/LICENSE +190 -0
- package/README.md +240 -0
- package/dist/app-server-session.d.ts +86 -0
- package/dist/app-server-session.d.ts.map +1 -0
- package/dist/cli-resolver.d.ts +9 -0
- package/dist/cli-resolver.d.ts.map +1 -0
- package/dist/client.d.ts +47 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/cloud-session.d.ts +45 -0
- package/dist/cloud-session.d.ts.map +1 -0
- package/dist/index.d.ts +167 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4994 -0
- package/dist/index.js.map +24 -0
- package/dist/interactiveToolPolicy.d.ts +4 -0
- package/dist/interactiveToolPolicy.d.ts.map +1 -0
- package/dist/local-app-server.d.ts +17 -0
- package/dist/local-app-server.d.ts.map +1 -0
- package/dist/protocol.d.ts +205 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/remote-client-session-core.d.ts +140 -0
- package/dist/remote-client-session-core.d.ts.map +1 -0
- package/dist/remote.d.ts +57 -0
- package/dist/remote.d.ts.map +1 -0
- package/dist/session.d.ts +142 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/stream-events.d.ts +15 -0
- package/dist/stream-events.d.ts.map +1 -0
- package/dist/tests/advanced-session.d.ts +10 -0
- package/dist/tests/advanced-session.d.ts.map +1 -0
- package/dist/tool-helpers.d.ts +47 -0
- package/dist/tool-helpers.d.ts.map +1 -0
- package/dist/transport.d.ts +53 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/types.d.ts +759 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/validation.d.ts +15 -0
- package/dist/validation.d.ts.map +1 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2025, Letta authors
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# Letta Agent SDK
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@letta-ai/letta-agent-sdk) [](https://discord.gg/letta)
|
|
4
|
+
|
|
5
|
+
The SDK interface to [**Letta Code**](https://github.com/letta-ai/letta-code). Build agents with persistent memory that learn over time.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @letta-ai/letta-agent-sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
### Client creation
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { LettaCodeClient } from "@letta-ai/letta-agent-sdk";
|
|
19
|
+
|
|
20
|
+
// Local: SDK-owned Letta Code app-server over loopback websockets. The SDK
|
|
21
|
+
// spawns/manages the app-server process for you.
|
|
22
|
+
const localClient = new LettaCodeClient({ backend: "local" });
|
|
23
|
+
|
|
24
|
+
// Remote: connect to a user-managed Letta Code app-server over websockets.
|
|
25
|
+
const remoteClient = new LettaCodeClient({
|
|
26
|
+
backend: "remote",
|
|
27
|
+
url: "http://127.0.0.1:4500",
|
|
28
|
+
// Required when the app-server is bound to a non-loopback interface with
|
|
29
|
+
// --ws-auth capability-token.
|
|
30
|
+
authToken: process.env.LETTA_APP_SERVER_TOKEN,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Constellation: create or resume agents whose state lives in Letta's
|
|
34
|
+
// agent cloud, with an SDK-managed sandbox by default.
|
|
35
|
+
const client = new LettaCodeClient({
|
|
36
|
+
backend: "cloud",
|
|
37
|
+
apiKey: process.env.LETTA_API_KEY,
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Persistent agent with multi-turn conversations
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { LettaCodeClient } from "@letta-ai/letta-agent-sdk";
|
|
45
|
+
|
|
46
|
+
const client = new LettaCodeClient({ backend: "local" });
|
|
47
|
+
|
|
48
|
+
const agentId = await client.createAgent({
|
|
49
|
+
persona: "You are a helpful coding assistant for TypeScript projects.",
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
await using session = client.resumeSession(agentId);
|
|
53
|
+
|
|
54
|
+
await session.send("Find and fix the bug in auth.ts");
|
|
55
|
+
for await (const msg of session.stream()) {
|
|
56
|
+
if (msg.type === "assistant") console.log(msg.content);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
await session.send("Add a unit test for the fix");
|
|
60
|
+
for await (const msg of session.stream()) {
|
|
61
|
+
if (msg.type === "assistant") console.log(msg.content);
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Cloud, remote, and local agent sessions can accept another `send()` while a
|
|
66
|
+
turn is streaming. The SDK sends the same `input` frame used by Letta Desktop
|
|
67
|
+
and the listener owns queueing; `stream()` may surface `queue_update` events
|
|
68
|
+
before the current turn's `result`.
|
|
69
|
+
|
|
70
|
+
By default, `resumeSession(agentId)` continues the agent’s default conversation.
|
|
71
|
+
Use `createSession(agentId)` when you want to start a fresh thread.
|
|
72
|
+
|
|
73
|
+
For Constellation agents, omitting `environment` lets the SDK create and manage
|
|
74
|
+
a sandbox for the session. `environment` is still session-scoped and can
|
|
75
|
+
override the client default when you want to use a specific remote runtime:
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
await using session = client.resumeSession(agentId, {
|
|
79
|
+
environment: { name: "LettaDevelopers" },
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The top-level helpers (`createAgent`, `createSession`, `resumeSession`, and
|
|
84
|
+
`prompt`) remain available. Local helper calls use Letta Code's default agent
|
|
85
|
+
selection when you do not pass an agent ID.
|
|
86
|
+
|
|
87
|
+
### User-managed app-server backend
|
|
88
|
+
|
|
89
|
+
Use `backend: "remote"` when you already have a Letta Code app-server running.
|
|
90
|
+
The app-server URL selects the execution environment; the SDK uses the same
|
|
91
|
+
Letta Code websocket protocol for `runtime_start`, `input`, streaming deltas,
|
|
92
|
+
and SDK-defined external tools.
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
const client = new LettaCodeClient({
|
|
96
|
+
backend: "remote",
|
|
97
|
+
url: "http://127.0.0.1:4500",
|
|
98
|
+
authToken: process.env.LETTA_APP_SERVER_TOKEN,
|
|
99
|
+
requestTimeoutMs: 120_000,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const agentId = await client.createAgent({
|
|
103
|
+
model: "anthropic/claude-sonnet-4",
|
|
104
|
+
persona: "You are a helpful coding assistant.",
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
await using session = client.createSession(agentId);
|
|
108
|
+
|
|
109
|
+
await session.send("Summarize this repository.");
|
|
110
|
+
for await (const msg of session.stream()) {
|
|
111
|
+
if (msg.type === "assistant") console.log(msg.content);
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
### Constellation
|
|
117
|
+
|
|
118
|
+
Use `backend: "cloud"` to create or resume agents hosted on Constellation. If
|
|
119
|
+
no `environment` is provided, the SDK creates an agent-scoped sandbox, waits for
|
|
120
|
+
it to come online, refreshes it while the session is active, and cleans it up on
|
|
121
|
+
close.
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
const client = new LettaCodeClient({
|
|
125
|
+
backend: "cloud",
|
|
126
|
+
apiKey: process.env.LETTA_API_KEY,
|
|
127
|
+
sandbox: {
|
|
128
|
+
// Optional: defaults to a 5-minute refresh TTL.
|
|
129
|
+
ttlMinutes: 5,
|
|
130
|
+
// Optional: defaults true. Set false for concurrent same-agent sessions.
|
|
131
|
+
terminateOnClose: true,
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const agentId = await client.createAgent({
|
|
136
|
+
model: "anthropic/claude-sonnet-4",
|
|
137
|
+
persona: "You are a helpful coding assistant.",
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
await using session = client.resumeSession(agentId, {
|
|
141
|
+
permissionMode: "bypassPermissions",
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
await session.send("Summarize this repository.");
|
|
145
|
+
for await (const msg of session.stream()) {
|
|
146
|
+
if (msg.type === "assistant") console.log(msg.content);
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
If you pass `cwd` for a Constellation session, use a path that exists inside the
|
|
151
|
+
selected remote environment or managed sandbox. Local paths such as
|
|
152
|
+
`process.cwd()` are not mapped into managed sandboxes automatically.
|
|
153
|
+
|
|
154
|
+
You can still set a default `environment` on the client or override it per
|
|
155
|
+
session to use an existing remote runtime instead of an SDK-managed sandbox:
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
const client = new LettaCodeClient({
|
|
159
|
+
backend: "cloud",
|
|
160
|
+
apiKey: process.env.LETTA_API_KEY,
|
|
161
|
+
environment: { connectionId: "conn-default" },
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
await using session = client.resumeSession(agentId, {
|
|
165
|
+
environment: { connectionId: "conn-123" },
|
|
166
|
+
});
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
`environment` and `sandbox` are mutually exclusive. Managed sandbox refresh and
|
|
170
|
+
termination operate on the latest active sandbox for an agent; set
|
|
171
|
+
`sandbox.terminateOnClose: false` when multiple SDK sessions may run
|
|
172
|
+
concurrently against the same agent and rely on TTL cleanup instead.
|
|
173
|
+
|
|
174
|
+
By default, websocket authentication uses `Authorization` headers. Set
|
|
175
|
+
`webSocketAuth: "query"` for browser-style websocket clients that cannot send
|
|
176
|
+
custom upgrade headers.
|
|
177
|
+
|
|
178
|
+
## Session configuration
|
|
179
|
+
|
|
180
|
+
Session options let you set runtime defaults before a session starts, including
|
|
181
|
+
`model`, `reasoningEffort`, `cwd`, `permissionMode`, and dreaming triggers. For
|
|
182
|
+
remote and Constellation sessions, `cwd` must be a path inside the selected
|
|
183
|
+
runtime environment.
|
|
184
|
+
|
|
185
|
+
```ts
|
|
186
|
+
import { LettaCodeClient } from "@letta-ai/letta-agent-sdk";
|
|
187
|
+
|
|
188
|
+
const client = new LettaCodeClient({ backend: "local" });
|
|
189
|
+
|
|
190
|
+
const session = client.resumeSession("agent-123", {
|
|
191
|
+
model: "anthropic/claude-sonnet-4",
|
|
192
|
+
reasoningEffort: "high",
|
|
193
|
+
// For local sessions this may be a local path; for remote/Constellation
|
|
194
|
+
// sessions, use a path inside the selected runtime environment.
|
|
195
|
+
cwd: "/workspace/project",
|
|
196
|
+
permissionMode: "bypassPermissions",
|
|
197
|
+
dreaming: {
|
|
198
|
+
trigger: "step-count", // off | step-count | compaction-event
|
|
199
|
+
stepCount: 8,
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
You can also inspect and change models after startup:
|
|
205
|
+
|
|
206
|
+
```ts
|
|
207
|
+
const catalog = await session.listModels();
|
|
208
|
+
await session.updateModel({ model: "sonnet", reasoningEffort: "medium" });
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Call `await session.abort()` to interrupt the current turn without closing the
|
|
212
|
+
session.
|
|
213
|
+
|
|
214
|
+
For advanced protocol access, use `sendCommand()` with raw Letta Code websocket
|
|
215
|
+
protocol commands:
|
|
216
|
+
|
|
217
|
+
```ts
|
|
218
|
+
await session.sendCommand({
|
|
219
|
+
type: "change_device_state",
|
|
220
|
+
runtime: { agent_id: session.agentId!, conversation_id: session.conversationId! },
|
|
221
|
+
payload: { cwd: "/workspace/project" },
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
const sync = await session.sendCommand(
|
|
225
|
+
{
|
|
226
|
+
type: "sync",
|
|
227
|
+
runtime: { agent_id: session.agentId!, conversation_id: session.conversationId! },
|
|
228
|
+
},
|
|
229
|
+
{ responseType: "sync_response" },
|
|
230
|
+
);
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## Links
|
|
234
|
+
|
|
235
|
+
- Docs: https://docs.letta.com/letta-agent-sdk
|
|
236
|
+
- Examples: [`./examples`](./examples)
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
Made with 💜 in San Francisco
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { type AppServerClient, type AppServerExternalToolCallHandler } from "@letta-ai/letta-code/app-server-client";
|
|
2
|
+
import { RemoteClientSessionCore, type ProtocolMessage, type RemoteClientRuntimeController, type RuntimeSendTurnOptions, type RuntimeScope, type RuntimeSessionInit, type RuntimeSessionMode } from "./remote-client-session-core.js";
|
|
3
|
+
import type { AnyAgentTool, CanUseToolResponse, CreateAgentOptions, LettaCodeRemoteClientOptions, LettaCodeClientSessionOptions, ListModelsResult, ListMessagesOptions, ListMessagesResult, RecoverPendingApprovalsOptions, RecoverPendingApprovalsResult, SendMessage, UpdateModelResult } from "./types.js";
|
|
4
|
+
type UpdateModelPayload = {
|
|
5
|
+
model_id?: string;
|
|
6
|
+
model_handle?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function agentToolNames(agent: Record<string, unknown> | null | undefined): string[] | undefined;
|
|
9
|
+
export type AppServerSessionOptions = Partial<LettaCodeRemoteClientOptions> & {
|
|
10
|
+
/** Base websocket URL. Remote sessions require this; local sessions may omit
|
|
11
|
+
* it to spawn an SDK-owned app-server lazily at initialize(). */
|
|
12
|
+
url?: string;
|
|
13
|
+
/** Spawn a local app-server when url is omitted. */
|
|
14
|
+
local?: boolean;
|
|
15
|
+
/** Optional backend for SDK-owned local app-server processes. */
|
|
16
|
+
localBackend?: string;
|
|
17
|
+
/** Optional local app-server listen URL. Defaults to ws://127.0.0.1:0. */
|
|
18
|
+
localListen?: string;
|
|
19
|
+
/** Timeout for local app-server startup. */
|
|
20
|
+
localStartupTimeoutMs?: number;
|
|
21
|
+
/** Extra environment variables for SDK-owned local app-server processes. */
|
|
22
|
+
localEnv?: Record<string, string | undefined>;
|
|
23
|
+
/** Whether create-agent runtime_start should pin the created agent globally. */
|
|
24
|
+
pinGlobalAgent?: boolean;
|
|
25
|
+
/** Whether SDK create-agent payloads should add the origin tag automatically. */
|
|
26
|
+
includeSdkOriginTag?: boolean;
|
|
27
|
+
};
|
|
28
|
+
export type AppServerSessionMode = RuntimeSessionMode;
|
|
29
|
+
export declare function assertRemoteSessionOptionsSupported(action: string, options: LettaCodeClientSessionOptions): void;
|
|
30
|
+
export declare function createAgentBody(options: CreateAgentOptions, settings?: {
|
|
31
|
+
includeSdkOriginTag?: boolean;
|
|
32
|
+
}): Record<string, unknown>;
|
|
33
|
+
export declare function externalToolGroups(tools: AnyAgentTool[] | undefined): Array<Record<string, unknown>> | undefined;
|
|
34
|
+
export declare function createExternalToolCallHandler(externalTools: Map<string, AnyAgentTool>): AppServerExternalToolCallHandler;
|
|
35
|
+
type AppServerApprovalOptions = LettaCodeClientSessionOptions | CreateAgentOptions;
|
|
36
|
+
type AppServerApprovalResponseDecision = {
|
|
37
|
+
behavior: "allow";
|
|
38
|
+
message?: string;
|
|
39
|
+
updated_input?: Record<string, unknown> | null;
|
|
40
|
+
selected_permission_suggestion_ids?: string[];
|
|
41
|
+
} | {
|
|
42
|
+
behavior: "deny";
|
|
43
|
+
message: string;
|
|
44
|
+
};
|
|
45
|
+
export declare function resolveAppServerToolApproval(options: AppServerApprovalOptions, toolName: string, toolInput: Record<string, unknown>): Promise<CanUseToolResponse>;
|
|
46
|
+
export declare function toAppServerApprovalDecision(decision: CanUseToolResponse): AppServerApprovalResponseDecision;
|
|
47
|
+
export declare function registerAppServerControlRequestHandler(config: {
|
|
48
|
+
client: AppServerClient;
|
|
49
|
+
getRuntime: () => RuntimeScope | null;
|
|
50
|
+
getOptions: () => AppServerApprovalOptions;
|
|
51
|
+
}): () => void;
|
|
52
|
+
export declare class AppServerRuntimeController implements RemoteClientRuntimeController {
|
|
53
|
+
private readonly client;
|
|
54
|
+
private readonly options;
|
|
55
|
+
constructor(client: AppServerClient, options: AppServerSessionOptions);
|
|
56
|
+
onMessage(handler: (message: ProtocolMessage, channel?: string) => void): () => void;
|
|
57
|
+
send(command: Record<string, unknown>): void;
|
|
58
|
+
sendTurnMessage(runtime: RuntimeScope, message: SendMessage, options: RuntimeSendTurnOptions): void;
|
|
59
|
+
abort(runtime: RuntimeScope): Promise<void>;
|
|
60
|
+
request(type: string, body: Record<string, unknown>, options?: {
|
|
61
|
+
timeoutMs?: number;
|
|
62
|
+
predicate?: (message: ProtocolMessage) => boolean;
|
|
63
|
+
}): Promise<ProtocolMessage>;
|
|
64
|
+
listModels(): Promise<ListModelsResult>;
|
|
65
|
+
updateModel(runtime: RuntimeScope, payload: UpdateModelPayload): Promise<UpdateModelResult>;
|
|
66
|
+
recoverPendingApprovals(runtime: RuntimeScope, options?: RecoverPendingApprovalsOptions): Promise<RecoverPendingApprovalsResult>;
|
|
67
|
+
listMessages(conversationId: string, options?: ListMessagesOptions): Promise<ListMessagesResult>;
|
|
68
|
+
close(): void;
|
|
69
|
+
}
|
|
70
|
+
export declare class AppServerSession extends RemoteClientSessionCore {
|
|
71
|
+
private readonly remoteOptions;
|
|
72
|
+
private ownedAppServer;
|
|
73
|
+
private externalTools;
|
|
74
|
+
private removeExternalToolHandler;
|
|
75
|
+
private removeControlRequestHandler;
|
|
76
|
+
constructor(remoteOptions: AppServerSessionOptions, mode: AppServerSessionMode);
|
|
77
|
+
protected shouldEnableMemfs(options: LettaCodeClientSessionOptions | CreateAgentOptions): boolean;
|
|
78
|
+
protected initializeRuntimeController(): Promise<RuntimeSessionInit>;
|
|
79
|
+
protected onCoreClose(): void;
|
|
80
|
+
private resolveAppServerUrl;
|
|
81
|
+
private startRuntime;
|
|
82
|
+
private buildRuntimeStartCommand;
|
|
83
|
+
private resolveConversationAgentId;
|
|
84
|
+
}
|
|
85
|
+
export {};
|
|
86
|
+
//# sourceMappingURL=app-server-session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-server-session.d.ts","sourceRoot":"","sources":["../src/app-server-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,gCAAgC,EAEtC,MAAM,wCAAwC,CAAC;AAMhD,OAAO,EACL,uBAAuB,EAIvB,KAAK,eAAe,EACp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AC,cAAc,CAAqC;IAC3D,OAAO,CAAC,aAAa,CAAmC;IACxD,OAAO,CAAC,yBAAyB,CAA6B;IAC9D,OAAO,CAAC,2BAA2B,CAA6B;gBAG7C,aAAa,EAAE,uBAAuB,EACvD,IAAI,EAAE,oBAAoB;cAYT,iBAAiB,CAAC,OAAO,EAAE,6BAA6B,GAAG,kBAAkB,GAAG,OAAO;cAKjF,2BAA2B,IAAI,OAAO,CAAC,kBAAkB,CAAC;cAoDhE,WAAW,IAAI,IAAI;YASxB,mBAAmB;YAgBnB,YAAY;YAMZ,wBAAwB;YAiDxB,0BAA0B;CAoBzC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the Letta Code CLI entrypoint used by SDK-owned transports.
|
|
3
|
+
*
|
|
4
|
+
* Resolution order intentionally matches the historical subprocess transport:
|
|
5
|
+
* explicit LETTA_CLI_PATH first, then the installed @letta-ai/letta-code package,
|
|
6
|
+
* then local development fallbacks.
|
|
7
|
+
*/
|
|
8
|
+
export declare function findLettaCli(): string;
|
|
9
|
+
//# sourceMappingURL=cli-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-resolver.d.ts","sourceRoot":"","sources":["../src/cli-resolver.ts"],"names":[],"mappings":"AASA;;;;;;GAMG;AACH,wBAAgB,YAAY,IAAI,MAAM,CA6BrC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { CreateAgentOptions, LettaCodeBackend, LettaCodeClientOptions, LettaCodeClientSessionOptions, LettaCodeEnvironment, LettaCodeSession, SDKResultMessage, SendMessage } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Top-level Letta Agent SDK client.
|
|
4
|
+
*
|
|
5
|
+
* `backend` selects how the SDK reaches or runs the Letta Code harness.
|
|
6
|
+
* `local` spawns an SDK-owned Letta Code app-server and speaks the websocket
|
|
7
|
+
* protocol by default, with an explicit stdio fallback for legacy flows.
|
|
8
|
+
* `remote` connects to a user-managed Letta Code app-server websocket endpoint.
|
|
9
|
+
* `cloud` uses agents hosted on Constellation, with an explicit remote
|
|
10
|
+
* environment or SDK-managed sandbox.
|
|
11
|
+
*/
|
|
12
|
+
export declare class LettaCodeClient {
|
|
13
|
+
readonly backend: LettaCodeBackend;
|
|
14
|
+
readonly environment: LettaCodeEnvironment | undefined;
|
|
15
|
+
private readonly options;
|
|
16
|
+
constructor(options?: LettaCodeClientOptions);
|
|
17
|
+
/**
|
|
18
|
+
* Create a new Letta Code agent with a default conversation.
|
|
19
|
+
*
|
|
20
|
+
* Environment/device selection is intentionally not part of the agent payload;
|
|
21
|
+
* it belongs to the client/session execution context.
|
|
22
|
+
*/
|
|
23
|
+
createAgent(options?: CreateAgentOptions): Promise<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Create a new conversation/session.
|
|
26
|
+
*
|
|
27
|
+
* Without an agent id, this uses the default/LRU agent, matching the legacy
|
|
28
|
+
* top-level createSession() helper.
|
|
29
|
+
*/
|
|
30
|
+
createSession(agentIdOrOptions?: string | LettaCodeClientSessionOptions, options?: LettaCodeClientSessionOptions): LettaCodeSession;
|
|
31
|
+
/**
|
|
32
|
+
* Resume an existing agent default conversation or a specific conversation.
|
|
33
|
+
*
|
|
34
|
+
* `options.environment` overrides the client's default execution target for
|
|
35
|
+
* Constellation sessions. Remote app-server URLs already select the runtime.
|
|
36
|
+
*/
|
|
37
|
+
resumeSession(id: string, options?: LettaCodeClientSessionOptions): LettaCodeSession;
|
|
38
|
+
/** One-shot prompt convenience helper using a new conversation. */
|
|
39
|
+
prompt(message: SendMessage, agentId?: string, options?: LettaCodeClientSessionOptions): Promise<SDKResultMessage>;
|
|
40
|
+
private assertLocalBackend;
|
|
41
|
+
private assertSessionBackend;
|
|
42
|
+
private useLegacyLocalStdio;
|
|
43
|
+
private localAppServerOptions;
|
|
44
|
+
private remoteOptions;
|
|
45
|
+
private cloudOptions;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,kBAAkB,EAElB,gBAAgB,EAChB,sBAAsB,EACtB,6BAA6B,EAC7B,oBAAoB,EAIpB,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACZ,MAAM,YAAY,CAAC;AA8CpB;;;;;;;;;GASG;AACH,qBAAa,eAAe;IAC1B,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,oBAAoB,GAAG,SAAS,CAAC;IACvD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;gBAErC,OAAO,GAAE,sBAA2B;IAoEhD;;;;;OAKG;IACG,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC;IAqCpE;;;;;OAKG;IACH,aAAa,CACX,gBAAgB,CAAC,EAAE,MAAM,GAAG,6BAA6B,EACzD,OAAO,GAAE,6BAAkC,GAC1C,gBAAgB;IAkDnB;;;;;OAKG;IACH,aAAa,CACX,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,6BAAkC,GAC1C,gBAAgB;IA4DnB,mEAAmE;IAC7D,MAAM,CACV,OAAO,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,GAAE,6BAAkC,GAC1C,OAAO,CAAC,gBAAgB,CAAC;IAY5B,OAAO,CAAC,kBAAkB;IAU1B,OAAO,CAAC,oBAAoB;IAgD5B,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,qBAAqB;IAiB7B,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,YAAY;CAMrB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { RemoteClientSessionCore, type RuntimeSessionInit, type RuntimeSessionMode } from "./remote-client-session-core.js";
|
|
2
|
+
import type { CreateAgentOptions, LettaCodeClientSessionOptions, LettaCodeCloudClientOptions } from "./types.js";
|
|
3
|
+
type CloudSessionMode = Extract<RuntimeSessionMode, {
|
|
4
|
+
kind: "session";
|
|
5
|
+
}>;
|
|
6
|
+
export declare function validateCloudClientOptions(options: LettaCodeCloudClientOptions): void;
|
|
7
|
+
export declare function createCloudAgent(clientOptions: LettaCodeCloudClientOptions, agentOptions: CreateAgentOptions): Promise<string>;
|
|
8
|
+
export declare function assertCloudSessionOptionsSupported(action: string, options: LettaCodeClientSessionOptions): void;
|
|
9
|
+
export declare class CloudEnvironmentSession extends RemoteClientSessionCore {
|
|
10
|
+
private readonly cloudOptions;
|
|
11
|
+
private connectionId;
|
|
12
|
+
private removeExternalToolHandler;
|
|
13
|
+
private removeControlRequestHandler;
|
|
14
|
+
private externalTools;
|
|
15
|
+
private managedSandbox;
|
|
16
|
+
private sandboxRefreshTimer;
|
|
17
|
+
private sandboxRefreshInFlight;
|
|
18
|
+
private readonly cloudMode;
|
|
19
|
+
constructor(cloudOptions: LettaCodeCloudClientOptions, mode: CloudSessionMode);
|
|
20
|
+
protected initializeRuntimeController(): Promise<RuntimeSessionInit>;
|
|
21
|
+
private startCloudRuntime;
|
|
22
|
+
protected afterRuntimeInitialized(): Promise<void>;
|
|
23
|
+
protected beforeTurn(): Promise<void>;
|
|
24
|
+
protected onCoreClose(): void;
|
|
25
|
+
private resolveRuntime;
|
|
26
|
+
private createConversation;
|
|
27
|
+
private retrieveConversation;
|
|
28
|
+
private resolveConnectionForRuntime;
|
|
29
|
+
private resolveExplicitConnection;
|
|
30
|
+
private createManagedSandboxConnection;
|
|
31
|
+
private createManagedSandbox;
|
|
32
|
+
private refreshManagedSandbox;
|
|
33
|
+
private refreshManagedSandboxOnce;
|
|
34
|
+
private terminateManagedSandbox;
|
|
35
|
+
private waitForManagedSandboxConnection;
|
|
36
|
+
private startManagedSandboxRefresh;
|
|
37
|
+
private stopManagedSandboxRefresh;
|
|
38
|
+
private cleanupManagedSandbox;
|
|
39
|
+
private remoteEnvironmentClient;
|
|
40
|
+
private effectiveEnvironment;
|
|
41
|
+
private effectiveSandboxOptions;
|
|
42
|
+
private resolvedSandboxOptions;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=cloud-session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud-session.d.ts","sourceRoot":"","sources":["../src/cloud-session.ts"],"names":[],"mappings":"AAoBA,OAAO,EACL,uBAAuB,EAIvB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACxB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAEV,kBAAkB,EAClB,6BAA6B,EAC7B,2BAA2B,EAK5B,MAAM,YAAY,CAAC;AAgFpB,KAAK,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,EAAE;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC,CAAC;AA6IzE,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,2BAA2B,GAAG,IAAI,CAerF;AA8VD,wBAAsB,gBAAgB,CACpC,aAAa,EAAE,2BAA2B,EAC1C,YAAY,EAAE,kBAAkB,GAC/B,OAAO,CAAC,MAAM,CAAC,CAQjB;AAED,wBAAgB,kCAAkC,CAChD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,6BAA6B,GACrC,IAAI,CA0BN;AAED,qBAAa,uBAAwB,SAAQ,uBAAuB;IAWhE,OAAO,CAAC,QAAQ,CAAC,YAAY;IAV/B,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,yBAAyB,CAA6B;IAC9D,OAAO,CAAC,2BAA2B,CAA6B;IAChE,OAAO,CAAC,aAAa,CAAmC;IACxD,OAAO,CAAC,cAAc,CAAoC;IAC1D,OAAO,CAAC,mBAAmB,CAA+C;IAC1E,OAAO,CAAC,sBAAsB,CAA8B;IAC5D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAmB;gBAG1B,YAA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