@letta-ai/letta-agent-sdk 0.2.1 → 0.2.4
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 +34 -13
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -16
- package/dist/index.js.map +5 -5
- package/dist/types.d.ts +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -15,14 +15,14 @@ npm install @letta-ai/letta-agent-sdk
|
|
|
15
15
|
### Client creation
|
|
16
16
|
|
|
17
17
|
```ts
|
|
18
|
-
import {
|
|
18
|
+
import { LettaAgentClient } from "@letta-ai/letta-agent-sdk";
|
|
19
19
|
|
|
20
20
|
// Local: SDK-owned Letta Code app-server over loopback websockets. The SDK
|
|
21
21
|
// spawns/manages the app-server process for you.
|
|
22
|
-
const localClient = new
|
|
22
|
+
const localClient = new LettaAgentClient({ backend: "local" });
|
|
23
23
|
|
|
24
24
|
// Remote: connect to a user-managed Letta Code app-server over websockets.
|
|
25
|
-
const remoteClient = new
|
|
25
|
+
const remoteClient = new LettaAgentClient({
|
|
26
26
|
backend: "remote",
|
|
27
27
|
url: "http://127.0.0.1:4500",
|
|
28
28
|
// Required when the app-server is bound to a non-loopback interface with
|
|
@@ -32,7 +32,7 @@ const remoteClient = new LettaCodeClient({
|
|
|
32
32
|
|
|
33
33
|
// Constellation: create or resume agents whose state lives in Letta's
|
|
34
34
|
// agent cloud, with an SDK-managed sandbox by default.
|
|
35
|
-
const client = new
|
|
35
|
+
const client = new LettaAgentClient({
|
|
36
36
|
backend: "cloud",
|
|
37
37
|
apiKey: process.env.LETTA_API_KEY,
|
|
38
38
|
});
|
|
@@ -41,9 +41,9 @@ const client = new LettaCodeClient({
|
|
|
41
41
|
### Persistent agent with multi-turn conversations
|
|
42
42
|
|
|
43
43
|
```ts
|
|
44
|
-
import {
|
|
44
|
+
import { LettaAgentClient } from "@letta-ai/letta-agent-sdk";
|
|
45
45
|
|
|
46
|
-
const client = new
|
|
46
|
+
const client = new LettaAgentClient({ backend: "local" });
|
|
47
47
|
|
|
48
48
|
const agentId = await client.createAgent({
|
|
49
49
|
persona: "You are a helpful coding assistant for TypeScript projects.",
|
|
@@ -92,7 +92,7 @@ Letta Code websocket protocol for `runtime_start`, `input`, streaming deltas,
|
|
|
92
92
|
and SDK-defined external tools.
|
|
93
93
|
|
|
94
94
|
```ts
|
|
95
|
-
const client = new
|
|
95
|
+
const client = new LettaAgentClient({
|
|
96
96
|
backend: "remote",
|
|
97
97
|
url: "http://127.0.0.1:4500",
|
|
98
98
|
authToken: process.env.LETTA_APP_SERVER_TOKEN,
|
|
@@ -121,7 +121,7 @@ it to come online, refreshes it while the session is active, and cleans it up on
|
|
|
121
121
|
close.
|
|
122
122
|
|
|
123
123
|
```ts
|
|
124
|
-
const client = new
|
|
124
|
+
const client = new LettaAgentClient({
|
|
125
125
|
backend: "cloud",
|
|
126
126
|
apiKey: process.env.LETTA_API_KEY,
|
|
127
127
|
sandbox: {
|
|
@@ -152,20 +152,34 @@ selected remote environment or managed sandbox. Local paths such as
|
|
|
152
152
|
`process.cwd()` are not mapped into managed sandboxes automatically.
|
|
153
153
|
|
|
154
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
|
|
155
|
+
session to use an existing remote runtime instead of an SDK-managed sandbox. Use
|
|
156
|
+
the environment name from `letta remote --env-name <name>`:
|
|
156
157
|
|
|
157
158
|
```ts
|
|
158
|
-
const client = new
|
|
159
|
+
const client = new LettaAgentClient({
|
|
159
160
|
backend: "cloud",
|
|
160
161
|
apiKey: process.env.LETTA_API_KEY,
|
|
161
|
-
environment: {
|
|
162
|
+
environment: { name: "devbox" },
|
|
162
163
|
});
|
|
163
164
|
|
|
165
|
+
await using session = client.resumeSession(agentId, {
|
|
166
|
+
environment: { name: "devbox" },
|
|
167
|
+
});
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
For advanced cases where you want to target a specific remote connection, pass
|
|
171
|
+
its `connectionId` instead. Connection IDs are assigned when the remote listener
|
|
172
|
+
registers and may change after reconnects:
|
|
173
|
+
|
|
174
|
+
```ts
|
|
164
175
|
await using session = client.resumeSession(agentId, {
|
|
165
176
|
environment: { connectionId: "conn-123" },
|
|
166
177
|
});
|
|
167
178
|
```
|
|
168
179
|
|
|
180
|
+
`environment` also accepts `{ id: "env-..." }` for an environment record or
|
|
181
|
+
`{ deviceId: "device-..." }` for a stable device selector.
|
|
182
|
+
|
|
169
183
|
`environment` and `sandbox` are mutually exclusive. Managed sandbox refresh and
|
|
170
184
|
termination operate on the latest active sandbox for an agent; set
|
|
171
185
|
`sandbox.terminateOnClose: false` when multiple SDK sessions may run
|
|
@@ -183,9 +197,9 @@ remote and Constellation sessions, `cwd` must be a path inside the selected
|
|
|
183
197
|
runtime environment.
|
|
184
198
|
|
|
185
199
|
```ts
|
|
186
|
-
import {
|
|
200
|
+
import { LettaAgentClient } from "@letta-ai/letta-agent-sdk";
|
|
187
201
|
|
|
188
|
-
const client = new
|
|
202
|
+
const client = new LettaAgentClient({ backend: "local" });
|
|
189
203
|
|
|
190
204
|
const session = client.resumeSession("agent-123", {
|
|
191
205
|
model: "anthropic/claude-sonnet-4",
|
|
@@ -238,3 +252,10 @@ const sync = await session.sendCommand(
|
|
|
238
252
|
---
|
|
239
253
|
|
|
240
254
|
Made with 💜 in San Francisco
|
|
255
|
+
|
|
256
|
+
<img
|
|
257
|
+
referrerpolicy="no-referrer-when-downgrade"
|
|
258
|
+
src="https://static.scarf.sh/a.png?x-pxid=29de91a5-e18c-4366-b192-33a909e184bc&page=README.md"
|
|
259
|
+
alt=""
|
|
260
|
+
aria-hidden="true"
|
|
261
|
+
/>
|
package/dist/client.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type { CreateAgentOptions, LettaCodeBackend, LettaCodeClientOptions, Lett
|
|
|
9
9
|
* `cloud` uses agents hosted on Constellation, with an explicit remote
|
|
10
10
|
* environment or SDK-managed sandbox.
|
|
11
11
|
*/
|
|
12
|
-
export declare class
|
|
12
|
+
export declare class LettaAgentClient {
|
|
13
13
|
readonly backend: LettaCodeBackend;
|
|
14
14
|
readonly environment: LettaCodeEnvironment | undefined;
|
|
15
15
|
private readonly options;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +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;
|
|
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;AAkDpB;;;;;;;;;GASG;AACH,qBAAa,gBAAgB;IAC3B,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;IA0CpE;;;;;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;IAkB7B,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,YAAY;CAMrB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* ```typescript
|
|
8
|
-
* import {
|
|
8
|
+
* import { LettaAgentClient, createAgent, createSession, resumeSession, prompt } from '@letta-ai/letta-agent-sdk';
|
|
9
9
|
*
|
|
10
|
-
* const client = new
|
|
10
|
+
* const client = new LettaAgentClient({ backend: 'local' });
|
|
11
11
|
* const agentId = await client.createAgent();
|
|
12
12
|
* const clientSession = client.resumeSession(agentId);
|
|
13
13
|
*
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
import type { CreateSessionOptions, CreateAgentOptions, LettaCodeSession, SDKResultMessage } from "./types.js";
|
|
35
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
36
|
export { Session } from "./session.js";
|
|
37
|
-
export {
|
|
37
|
+
export { LettaAgentClient } from "./client.js";
|
|
38
38
|
export { extractStreamTextDelta } from "./stream-events.js";
|
|
39
39
|
export { jsonResult, readStringParam, readNumberParam, readBooleanParam, readStringArrayParam, } from "./tool-helpers.js";
|
|
40
40
|
/**
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +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,6BAA6B,EAC7B,WAAW,EACX,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,yBAAyB,EACzB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,EAEtB,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,WAAW,EAEX,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EAEjB,qBAAqB,EACrB,oBAAoB,EAEpB,SAAS,EACT,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,YAAY,GACb,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
package/dist/index.js
CHANGED
|
@@ -2991,11 +2991,11 @@ function createAgentBody(options, settings = {}) {
|
|
|
2991
2991
|
if (options.systemPrompt !== undefined) {
|
|
2992
2992
|
if (typeof options.systemPrompt === "string") {
|
|
2993
2993
|
if (isPresetSystemPrompt(options.systemPrompt)) {
|
|
2994
|
-
throw new Error("
|
|
2994
|
+
throw new Error("createAgent() does not yet support system prompt presets for this backend.");
|
|
2995
2995
|
}
|
|
2996
2996
|
body.system = options.systemPrompt;
|
|
2997
2997
|
} else {
|
|
2998
|
-
throw new Error("
|
|
2998
|
+
throw new Error("createAgent() does not yet support system prompt preset objects for this backend.");
|
|
2999
2999
|
}
|
|
3000
3000
|
}
|
|
3001
3001
|
const memoryBlocks = [];
|
|
@@ -4489,11 +4489,14 @@ function stripCloudExecutionOptions(options) {
|
|
|
4489
4489
|
function hasCreateAgentEnvironment(options) {
|
|
4490
4490
|
return "environment" in options;
|
|
4491
4491
|
}
|
|
4492
|
+
function hasExplicitCreateAgentModel(options) {
|
|
4493
|
+
return typeof options.model === "string" && options.model.trim().length > 0;
|
|
4494
|
+
}
|
|
4492
4495
|
function looksLikeConversationId(id) {
|
|
4493
4496
|
return id.startsWith("conv-") || id.startsWith("local-conv-");
|
|
4494
4497
|
}
|
|
4495
4498
|
|
|
4496
|
-
class
|
|
4499
|
+
class LettaAgentClient {
|
|
4497
4500
|
backend;
|
|
4498
4501
|
environment;
|
|
4499
4502
|
options;
|
|
@@ -4506,13 +4509,13 @@ class LettaCodeClient {
|
|
|
4506
4509
|
this.environment = getOptionsEnvironment(options);
|
|
4507
4510
|
this.options = options;
|
|
4508
4511
|
if (this.backend === "local" && this.environment !== undefined) {
|
|
4509
|
-
throw new Error('
|
|
4512
|
+
throw new Error('LettaAgentClient environment is only valid with backend: "cloud".');
|
|
4510
4513
|
}
|
|
4511
4514
|
if (this.backend === "remote" && this.environment !== undefined) {
|
|
4512
|
-
throw new Error('
|
|
4515
|
+
throw new Error('LettaAgentClient environment is only valid with backend: "cloud"; remote url selects the app-server runtime.');
|
|
4513
4516
|
}
|
|
4514
4517
|
if (this.backend !== "cloud" && options.sandbox !== undefined) {
|
|
4515
|
-
throw new Error('
|
|
4518
|
+
throw new Error('LettaAgentClient sandbox options are only valid with backend: "cloud".');
|
|
4516
4519
|
}
|
|
4517
4520
|
if (this.backend === "local") {
|
|
4518
4521
|
const localOptions = options;
|
|
@@ -4530,7 +4533,7 @@ class LettaCodeClient {
|
|
|
4530
4533
|
}
|
|
4531
4534
|
if (this.backend === "remote") {
|
|
4532
4535
|
if (!("url" in options) || typeof options.url !== "string" || options.url.length === 0) {
|
|
4533
|
-
throw new Error("
|
|
4536
|
+
throw new Error("LettaAgentClient remote backend requires a non-empty url.");
|
|
4534
4537
|
}
|
|
4535
4538
|
if (options.requestTimeoutMs !== undefined && (!Number.isInteger(options.requestTimeoutMs) || options.requestTimeoutMs <= 0)) {
|
|
4536
4539
|
throw new Error("Invalid requestTimeoutMs. Expected a positive integer.");
|
|
@@ -4555,6 +4558,9 @@ class LettaCodeClient {
|
|
|
4555
4558
|
return initMsg2.agentId;
|
|
4556
4559
|
}
|
|
4557
4560
|
if (this.backend === "cloud") {
|
|
4561
|
+
if (!hasExplicitCreateAgentModel(options)) {
|
|
4562
|
+
throw new Error('Constellation createAgent() requires an explicit model. Pass model in createAgent({ model: "provider/model" }).');
|
|
4563
|
+
}
|
|
4558
4564
|
return createCloudAgent(this.cloudOptions(), options);
|
|
4559
4565
|
}
|
|
4560
4566
|
this.assertLocalBackend("createAgent");
|
|
@@ -4683,7 +4689,7 @@ class LettaCodeClient {
|
|
|
4683
4689
|
if (this.backend === "local") {
|
|
4684
4690
|
return;
|
|
4685
4691
|
}
|
|
4686
|
-
throw new Error(`
|
|
4692
|
+
throw new Error(`LettaAgentClient backend '${this.backend}' is not implemented yet. ${action} currently supports backend 'local' only.`);
|
|
4687
4693
|
}
|
|
4688
4694
|
assertSessionBackend(action, options) {
|
|
4689
4695
|
const effectiveEnvironment = options.environment ?? this.environment;
|
|
@@ -4720,7 +4726,7 @@ class LettaCodeClient {
|
|
|
4720
4726
|
assertCloudSessionOptionsSupported(action, options);
|
|
4721
4727
|
return;
|
|
4722
4728
|
}
|
|
4723
|
-
throw new Error(`
|
|
4729
|
+
throw new Error(`LettaAgentClient backend '${this.backend}' is not implemented yet. ${action} currently supports backend 'local' only.`);
|
|
4724
4730
|
}
|
|
4725
4731
|
useLegacyLocalStdio() {
|
|
4726
4732
|
return this.options.transport === "stdio";
|
|
@@ -4730,6 +4736,7 @@ class LettaCodeClient {
|
|
|
4730
4736
|
const appServer = localOptions.appServer;
|
|
4731
4737
|
return {
|
|
4732
4738
|
local: appServer?.url === undefined,
|
|
4739
|
+
localBackend: "local",
|
|
4733
4740
|
...appServer?.url !== undefined ? { url: appServer.url } : {},
|
|
4734
4741
|
...appServer?.WebSocket !== undefined ? { WebSocket: appServer.WebSocket } : {},
|
|
4735
4742
|
...appServer?.requestTimeoutMs !== undefined ? { requestTimeoutMs: appServer.requestTimeoutMs } : {},
|
|
@@ -4907,18 +4914,18 @@ function readStringArrayParam(params, key, options = {}) {
|
|
|
4907
4914
|
import { readFileSync } from "node:fs";
|
|
4908
4915
|
async function createAgent(options = {}) {
|
|
4909
4916
|
validateCreateAgentOptions(options);
|
|
4910
|
-
return new
|
|
4917
|
+
return new LettaAgentClient().createAgent(options);
|
|
4911
4918
|
}
|
|
4912
4919
|
function createSession(agentId, options = {}) {
|
|
4913
4920
|
validateCreateSessionOptions(options);
|
|
4914
4921
|
if (agentId) {
|
|
4915
|
-
return new
|
|
4922
|
+
return new LettaAgentClient().createSession(agentId, options);
|
|
4916
4923
|
}
|
|
4917
|
-
return new
|
|
4924
|
+
return new LettaAgentClient({ backend: "local", transport: "stdio" }).createSession(options);
|
|
4918
4925
|
}
|
|
4919
4926
|
function resumeSession(id, options = {}) {
|
|
4920
4927
|
validateCreateSessionOptions(options);
|
|
4921
|
-
return new
|
|
4928
|
+
return new LettaAgentClient().resumeSession(id, options);
|
|
4922
4929
|
}
|
|
4923
4930
|
async function prompt(message, agentId) {
|
|
4924
4931
|
const session = agentId ? createSession(agentId) : createSession();
|
|
@@ -4929,7 +4936,7 @@ async function prompt(message, agentId) {
|
|
|
4929
4936
|
}
|
|
4930
4937
|
}
|
|
4931
4938
|
async function listMessagesDirect(agentId, options = {}) {
|
|
4932
|
-
const session = new
|
|
4939
|
+
const session = new LettaAgentClient().resumeSession(agentId, {
|
|
4933
4940
|
permissionMode: "bypassPermissions"
|
|
4934
4941
|
});
|
|
4935
4942
|
await session.initialize();
|
|
@@ -4988,7 +4995,7 @@ export {
|
|
|
4988
4995
|
createSession,
|
|
4989
4996
|
createAgent,
|
|
4990
4997
|
Session,
|
|
4991
|
-
|
|
4998
|
+
LettaAgentClient
|
|
4992
4999
|
};
|
|
4993
5000
|
|
|
4994
|
-
//# debugId=
|
|
5001
|
+
//# debugId=380F2F63E2AF857764756E2164756E21
|