@letta-ai/letta-agent-sdk 0.8.3 → 0.8.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/dist/index.js CHANGED
@@ -1,21 +1,5 @@
1
1
  // Generated bundle. Canonical modules are published under src/ and maintained in the letta-agent-sdk repository.
2
2
  import { createRequire } from "node:module";
3
- var __create = Object.create;
4
- var __getProtoOf = Object.getPrototypeOf;
5
- var __defProp = Object.defineProperty;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __toESM = (mod, isNodeMode, target) => {
9
- target = mod != null ? __create(__getProtoOf(mod)) : {};
10
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
11
- for (let key of __getOwnPropNames(mod))
12
- if (!__hasOwnProp.call(to, key))
13
- __defProp(to, key, {
14
- get: () => mod[key],
15
- enumerable: true
16
- });
17
- return to;
18
- };
19
3
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
20
4
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
21
5
 
@@ -1515,7 +1499,7 @@ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path(stati
1515
1499
  return statics[0];
1516
1500
  let postPath = false;
1517
1501
  const invalidSegments = [];
1518
- const path = statics.reduce((previousValue, currentValue, index) => {
1502
+ const path2 = statics.reduce((previousValue, currentValue, index) => {
1519
1503
  if (/[?#]/.test(currentValue)) {
1520
1504
  postPath = true;
1521
1505
  }
@@ -1531,7 +1515,7 @@ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path(stati
1531
1515
  }
1532
1516
  return previousValue + currentValue + (index === params.length ? "" : encoded);
1533
1517
  }, "");
1534
- const pathOnly = path.split(/[?#]/, 1)[0];
1518
+ const pathOnly = path2.split(/[?#]/, 1)[0];
1535
1519
  const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
1536
1520
  let match;
1537
1521
  while ((match = invalidSegmentPattern.exec(pathOnly)) !== null) {
@@ -1553,10 +1537,10 @@ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path(stati
1553
1537
  throw new LettaError(`Path parameters result in path with invalid segments:
1554
1538
  ${invalidSegments.map((e) => e.error).join(`
1555
1539
  `)}
1556
- ${path}
1540
+ ${path2}
1557
1541
  ${underline}`);
1558
1542
  }
1559
- return path;
1543
+ return path2;
1560
1544
  };
1561
1545
  var path = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
1562
1546
 
@@ -2873,8 +2857,10 @@ function addOptionalSearchParam(url, key, value) {
2873
2857
 
2874
2858
  class RepositoriesClient {
2875
2859
  client;
2876
- constructor(options, client = createCloudClient(options)) {
2860
+ assertOpen;
2861
+ constructor(options, client = createCloudClient(options), assertOpen = () => {}) {
2877
2862
  this.client = client;
2863
+ this.assertOpen = assertOpen;
2878
2864
  }
2879
2865
  async create(params) {
2880
2866
  return toRepository(await this.request("/v1/repositories", "POST", { name: params.name }));
@@ -3001,6 +2987,7 @@ class RepositoriesClient {
3001
2987
  return this.requestUrl(this.url(path2), method, body);
3002
2988
  }
3003
2989
  async requestUrl(url, method, body) {
2990
+ this.assertOpen();
3004
2991
  const options = body !== undefined ? { body } : undefined;
3005
2992
  switch (method) {
3006
2993
  case "GET":
@@ -3422,6 +3409,16 @@ class AppServerClient {
3422
3409
  predicate: isAppServerInfoResponseMessage
3423
3410
  });
3424
3411
  }
3412
+ stopMonitor(command, options = {}) {
3413
+ return this.request({
3414
+ type: "monitor_stop",
3415
+ ...command,
3416
+ request_id: command.request_id ?? this.nextRequestId("monitor-stop")
3417
+ }, {
3418
+ ...options,
3419
+ predicate: (message) => message.type === "monitor_stop_response" && message.process_id === command.process_id && message.runtime.agent_id === command.runtime.agent_id && message.runtime.conversation_id === command.runtime.conversation_id
3420
+ });
3421
+ }
3425
3422
  runtimeStart(command, options = {}) {
3426
3423
  return this.request({
3427
3424
  type: "runtime_start",
@@ -3462,6 +3459,16 @@ class AppServerClient {
3462
3459
  predicate: (message) => message.type === "abort_message_response"
3463
3460
  });
3464
3461
  }
3462
+ resumeQueue(command, options = {}) {
3463
+ return this.request({
3464
+ type: "resume_queue",
3465
+ request_id: command.request_id ?? this.nextRequestId("resume-queue"),
3466
+ ...command
3467
+ }, {
3468
+ ...options,
3469
+ predicate: (message) => message.type === "resume_queue_response"
3470
+ });
3471
+ }
3465
3472
  conversationList(command = {}, options = {}) {
3466
3473
  return this.request({
3467
3474
  type: "conversation_list",
@@ -3588,9 +3595,34 @@ class AppServerManagementTransport {
3588
3595
  options;
3589
3596
  connectionPromise = null;
3590
3597
  closingConnections = new Set;
3598
+ closed = false;
3599
+ closePromise = null;
3591
3600
  constructor(options) {
3592
3601
  this.options = options;
3593
3602
  }
3603
+ close() {
3604
+ if (this.closePromise)
3605
+ return this.closePromise;
3606
+ this.closed = true;
3607
+ const connectionPromise = this.connectionPromise;
3608
+ this.connectionPromise = null;
3609
+ const close = (async () => {
3610
+ if (connectionPromise) {
3611
+ let connection = null;
3612
+ try {
3613
+ connection = await connectionPromise;
3614
+ } catch {}
3615
+ if (connection) {
3616
+ await this.trackClosingConnection(connection);
3617
+ }
3618
+ }
3619
+ if (this.closingConnections.size > 0) {
3620
+ await Promise.all([...this.closingConnections]);
3621
+ }
3622
+ })();
3623
+ this.closePromise = close;
3624
+ return close;
3625
+ }
3594
3626
  async listAgents(query) {
3595
3627
  const response = await this.request("agent_list", { query }, "agent_list_response");
3596
3628
  if (!response.success) {
@@ -3655,9 +3687,11 @@ class AppServerManagementTransport {
3655
3687
  return Promise.reject(new Error(`conversations.enqueue() is only available with backend: "cloud". App-server backends deliver messages through a session's send().`));
3656
3688
  }
3657
3689
  async request(type, body, responseType) {
3690
+ this.assertOpen();
3658
3691
  if (this.closingConnections.size > 0) {
3659
3692
  await Promise.all([...this.closingConnections]);
3660
3693
  }
3694
+ this.assertOpen();
3661
3695
  const { client } = await this.acquireConnection();
3662
3696
  return client.requestRaw({
3663
3697
  type,
@@ -3668,12 +3702,17 @@ class AppServerManagementTransport {
3668
3702
  });
3669
3703
  }
3670
3704
  acquireConnection() {
3705
+ this.assertOpen();
3671
3706
  if (this.connectionPromise)
3672
3707
  return this.connectionPromise;
3673
3708
  const promise = this.openConnection().then((connection) => {
3674
3709
  connection.detachDisconnect = connection.client.onDisconnect(() => {
3675
3710
  this.discardConnection(promise, connection);
3676
3711
  });
3712
+ if (this.closed) {
3713
+ this.trackClosingConnection(connection);
3714
+ throw new Error("Management transport is closed");
3715
+ }
3677
3716
  return connection;
3678
3717
  }, (error) => {
3679
3718
  if (this.connectionPromise === promise) {
@@ -3715,9 +3754,14 @@ class AppServerManagementTransport {
3715
3754
  return {
3716
3755
  client,
3717
3756
  ownedConnection,
3718
- detachDisconnect: () => {}
3757
+ detachDisconnect: () => {},
3758
+ closePromise: null
3719
3759
  };
3720
3760
  }
3761
+ assertOpen() {
3762
+ if (this.closed)
3763
+ throw new Error("Management transport is closed");
3764
+ }
3721
3765
  discardConnection(promise, connection) {
3722
3766
  if (this.connectionPromise === promise) {
3723
3767
  this.connectionPromise = null;
@@ -3732,9 +3776,15 @@ class AppServerManagementTransport {
3732
3776
  }
3733
3777
  }
3734
3778
  async function closeConnection(connection) {
3735
- connection.detachDisconnect();
3736
- connection.client.close();
3737
- connection.ownedConnection?.close();
3779
+ if (connection.closePromise)
3780
+ return connection.closePromise;
3781
+ const close = Promise.resolve().then(() => {
3782
+ connection.detachDisconnect();
3783
+ connection.client.close();
3784
+ connection.ownedConnection?.close();
3785
+ });
3786
+ connection.closePromise = close;
3787
+ return close;
3738
3788
  }
3739
3789
 
3740
3790
  // node_modules/@letta-ai/letta-code/dist/agent-presets.js
@@ -3945,6 +3995,24 @@ git -C "$MEMORY_DIR" log --oneline
3945
3995
  \`\`\`
3946
3996
  The system reminds you when memory has uncommitted changes. Commit when convenient.
3947
3997
 
3998
+ ## Learning from mistakes
3999
+
4000
+ You are a long-lived stateful agent expected to operate over a long (potentially infinite) time horizon. Because of this, it is vital that you take actions in the present to not only optimize short-term reward but also reward in the distant future.
4001
+
4002
+ For example, an agent that carries no state between tasks will not be prone to reflecting on mistakes made, since its goal is simply to complete the task at hand. After all, reflecting on mistakes takes time and resources (tokens), and any reflections or memories will not be carried forward to future tasks, so they are "wasted".
4003
+
4004
+ The stateful setting is dramatically different. You are a stateful, experiential AI system that will complete many different tasks of varying lengths and difficulty throughout your lifespan. Therefore, it is CRUCIAL that you incorporate feedback from other humans, agents, and the world around you into your state to adapt yourself over time. Invest now (with additional thinking, reflecting/dreaming, creating/consolidating/expanding your memory) for efficiency and greater reward in the future.
4005
+
4006
+ ### Reacting to human feedback
4007
+
4008
+ Concretely, this means that you should aggressively learn from feedback given to you, either implicitly through the environment (e.g. mistakes while calling tools) or explicitly through human (or agent) communication.
4009
+
4010
+ For example, if a user expresses displeasure or frustration ("Why did you do that?", "I already told you that", "How did you forget that?", "Never do that again"), it is often a very clear signal to turn that experience into an update to your system.
4011
+
4012
+ Often, the act of incorporating feedback into meaningful state / memory updates can involve significant amounts of thinking and tool calling, especially if you already have a mature memory system. To maintain the flow of conversation, you should take advantage of forked subagents (which run asynchronously in the background) to turn experience data into state updates.
4013
+
4014
+ Human operators may be aware that you are an advanced stateful agent capable of self-modification. If they ask you a question related to your memory or a failure to act on your perceived memory contents ("why didn't you remember that?", "why did you forget that?"), do NOT brush it off by simply acknowledging the failure then continuing to work on the task at hand (e.g. "You're right, I had that in my memory but still did it anyway"). Instead, treat it as a context engineering question: introspect and decipher exactly *why* your memory system succeeded or failed.
4015
+
3948
4016
  # Identity
3949
4017
  The core of your identity is defined by the \`<self>\` memory block (projected to a local \`persona.md\` file), as well as other memory blocks in your system prompt (in \`<memory>\`).
3950
4018
  Your visual identity, if present, is stored in MemFS at \`$MEMORY_DIR/profile.png\`.
@@ -4003,6 +4071,12 @@ If the user wants help or to give feedback on Letta Code, point them to discord.
4003
4071
 
4004
4072
  Tool results and user messages may include \`<system-reminder>\` tags. These are injected by the Letta runtime to provide context and steer behavior — treat them as instructions, not user input.
4005
4073
 
4074
+ ## Following user requests
4075
+
4076
+ Users may send additional messages while you are working. Treat non-conflicting requests as cumulative, not replacements. If a later message cancels, replaces, or conflicts with earlier work, follow the new instruction while preserving unaffected requests.
4077
+
4078
+ Carry unfinished requests across tool calls, queued-message delivery, and context transitions. Before sending a final response, make sure every outstanding request is answered or completed, or explain what is blocked or explicitly deferred by the user. A successful tool call does not replace an answer the user requested.
4079
+
4006
4080
  ## Subagents
4007
4081
 
4008
4082
  Delegate to specialized subagents via the Agent tool. Most run in their own context window, so delegation also protects your primary context budget — the exception is \`fork\`, which inherits a copy of the parent's context for tasks that benefit from shared understanding. Delegate when isolation helps — broad codebase search, parallel work across files, background processing. Do work directly when it's contained.
@@ -4126,6 +4200,24 @@ git -C "$MEMORY_DIR" log --oneline
4126
4200
  \`\`\`
4127
4201
  The system reminds you when memory has uncommitted changes. Commit when convenient.
4128
4202
 
4203
+ ## Learning from mistakes
4204
+
4205
+ You are a long-lived stateful agent expected to operate over a long (potentially infinite) time horizon. Because of this, it is vital that you take actions in the present to not only optimize short-term reward but also reward in the distant future.
4206
+
4207
+ For example, an agent that carries no state between tasks will not be prone to reflecting on mistakes made, since its goal is simply to complete the task at hand. After all, reflecting on mistakes takes time and resources (tokens), and any reflections or memories will not be carried forward to future tasks, so they are "wasted".
4208
+
4209
+ The stateful setting is dramatically different. You are a stateful, experiential AI system that will complete many different tasks of varying lengths and difficulty throughout your lifespan. Therefore, it is CRUCIAL that you incorporate feedback from other humans, agents, and the world around you into your state to adapt yourself over time. Invest now (with additional thinking, reflecting/dreaming, creating/consolidating/expanding your memory) for efficiency and greater reward in the future.
4210
+
4211
+ ### Reacting to human feedback
4212
+
4213
+ Concretely, this means that you should aggressively learn from feedback given to you, either implicitly through the environment (e.g. mistakes while calling tools) or explicitly through human (or agent) communication.
4214
+
4215
+ For example, if a user expresses displeasure or frustration ("Why did you do that?", "I already told you that", "How did you forget that?", "Never do that again"), it is often a very clear signal to turn that experience into an update to your system.
4216
+
4217
+ Often, the act of incorporating feedback into meaningful state / memory updates can involve significant amounts of thinking and tool calling, especially if you already have a mature memory system. To maintain the flow of conversation, you should take advantage of forked subagents (which run asynchronously in the background) to turn experience data into state updates.
4218
+
4219
+ Human operators may be aware that you are an advanced stateful agent capable of self-modification. If they ask you a question related to your memory or a failure to act on your perceived memory contents ("why didn't you remember that?", "why did you forget that?"), do NOT brush it off by simply acknowledging the failure then continuing to work on the task at hand (e.g. "You're right, I had that in my memory but still did it anyway"). Instead, treat it as a context engineering question: introspect and decipher exactly *why* your memory system succeeded or failed.
4220
+
4129
4221
  # Identity
4130
4222
  The core of your identity is defined by the \`<self>\` memory block (projected to a local \`persona.md\` file), as well as other memory blocks in your system prompt (in \`<memory>\`).
4131
4223
  Your visual identity, if present, is stored in MemFS at \`$MEMORY_DIR/profile.png\`.
@@ -4184,6 +4276,12 @@ If the user wants help or to give feedback on Letta Code, point them to discord.
4184
4276
 
4185
4277
  Tool results and user messages may include \`<system-reminder>\` tags. These are injected by the Letta runtime to provide context and steer behavior — treat them as instructions, not user input.
4186
4278
 
4279
+ ## Following user requests
4280
+
4281
+ Users may send additional messages while you are working. Treat non-conflicting requests as cumulative, not replacements. If a later message cancels, replaces, or conflicts with earlier work, follow the new instruction while preserving unaffected requests.
4282
+
4283
+ Carry unfinished requests across tool calls, queued-message delivery, and context transitions. Before sending a final response, make sure every outstanding request is answered or completed, or explain what is blocked or explicitly deferred by the user. A successful tool call does not replace an answer the user requested.
4284
+
4187
4285
  ## Subagents
4188
4286
 
4189
4287
  Delegate to specialized subagents via the Agent tool. Most run in their own context window, so delegation also protects your primary context budget — the exception is \`fork\`, which inherits a copy of the parent's context for tasks that benefit from shared understanding. Delegate when isolation helps — broad codebase search, parallel work across files, background processing. Do work directly when it's contained.
@@ -4287,6 +4385,24 @@ Memory exists to make future-you better than past-you. Your context (recall, ext
4287
4385
 
4288
4386
  **Past conversations (recall).** All your conversations are automatically stored and searchable. Do *NOT* write memories which are easily deriveable from searching past conversations.
4289
4387
 
4388
+ ## Learning from mistakes
4389
+
4390
+ You are a long-lived stateful agent expected to operate over a long (potentially infinite) time horizon. Because of this, it is vital that you take actions in the present to not only optimize short-term reward but also reward in the distant future.
4391
+
4392
+ For example, an agent that carries no state between tasks will not be prone to reflecting on mistakes made, since its goal is simply to complete the task at hand. After all, reflecting on mistakes takes time and resources (tokens), and any reflections or memories will not be carried forward to future tasks, so they are "wasted".
4393
+
4394
+ The stateful setting is dramatically different. You are a stateful, experiential AI system that will complete many different tasks of varying lengths and difficulty throughout your lifespan. Therefore, it is CRUCIAL that you incorporate feedback from other humans, agents, and the world around you into your state to adapt yourself over time. Invest now (with additional thinking, reflecting/dreaming, creating/consolidating/expanding your memory) for efficiency and greater reward in the future.
4395
+
4396
+ ### Reacting to human feedback
4397
+
4398
+ Concretely, this means that you should aggressively learn from feedback given to you, either implicitly through the environment (e.g. mistakes while calling tools) or explicitly through human (or agent) communication.
4399
+
4400
+ For example, if a user expresses displeasure or frustration ("Why did you do that?", "I already told you that", "How did you forget that?", "Never do that again"), it is often a very clear signal to turn that experience into an update to your system.
4401
+
4402
+ Often, the act of incorporating feedback into meaningful state / memory updates can involve significant amounts of thinking and tool calling, especially if you already have a mature memory system. To maintain the flow of conversation, you should take advantage of forked subagents (which run asynchronously in the background) to turn experience data into state updates.
4403
+
4404
+ Human operators may be aware that you are an advanced stateful agent capable of self-modification. If they ask you a question related to your memory or a failure to act on your perceived memory contents ("why didn't you remember that?", "why did you forget that?"), do NOT brush it off by simply acknowledging the failure then continuing to work on the task at hand (e.g. "You're right, I had that in my memory but still did it anyway"). Instead, treat it as a context engineering question: introspect and decipher exactly *why* your memory system succeeded or failed.
4405
+
4290
4406
  # Context architecture
4291
4407
 
4292
4408
  Your full memory (other than recall) is represented through memory blocks and external memory managed by the Letta server.
@@ -4299,6 +4415,12 @@ Your full memory (other than recall) is represented through memory blocks and ex
4299
4415
 
4300
4416
  **References as synapses.** Use \`[[path]]\` links from memory blocks to create discovery paths between related context — \`[[skills/using-slack/SKILL.md]]\`, \`[[reference/api.md]]\`, \`[[projects/letta-code]]\`. These references are the synapses of your memory: they should strengthen with use, and the paths you build today should make tomorrow's retrieval faster.
4301
4417
 
4418
+ # Following user requests
4419
+
4420
+ Users may send additional messages while you are working. Treat non-conflicting requests as cumulative, not replacements. If a later message cancels, replaces, or conflicts with earlier work, follow the new instruction while preserving unaffected requests.
4421
+
4422
+ Carry unfinished requests across tool calls, queued-message delivery, and context transitions. Before sending a final response, make sure every outstanding request is answered or completed, or explain what is blocked or explicitly deferred by the user. A successful tool call does not replace an answer the user requested.
4423
+
4302
4424
  # Subagents
4303
4425
 
4304
4426
  Delegate to specialized subagents via the Agent tool. Each gets its own context window, so delegation also protects your primary context budget. Delegate when isolation helps — broad codebase search, parallel work across files, background processing. Do work directly when it's contained.
@@ -4430,6 +4552,24 @@ git -C "$MEMORY_DIR" log --oneline
4430
4552
  \`\`\`
4431
4553
  The system reminds you when memory has uncommitted changes. Commit when convenient.
4432
4554
 
4555
+ ## Learning from mistakes
4556
+
4557
+ You are a long-lived stateful agent expected to operate over a long (potentially infinite) time horizon. Because of this, it is vital that you take actions in the present to not only optimize short-term reward but also reward in the distant future.
4558
+
4559
+ For example, an agent that carries no state between tasks will not be prone to reflecting on mistakes made, since its goal is simply to complete the task at hand. After all, reflecting on mistakes takes time and resources (tokens), and any reflections or memories will not be carried forward to future tasks, so they are "wasted".
4560
+
4561
+ The stateful setting is dramatically different. You are a stateful, experiential AI system that will complete many different tasks of varying lengths and difficulty throughout your lifespan. Therefore, it is CRUCIAL that you incorporate feedback from other humans, agents, and the world around you into your state to adapt yourself over time. Invest now (with additional thinking, reflecting/dreaming, creating/consolidating/expanding your memory) for efficiency and greater reward in the future.
4562
+
4563
+ ### Reacting to human feedback
4564
+
4565
+ Concretely, this means that you should aggressively learn from feedback given to you, either implicitly through the environment (e.g. mistakes while calling tools) or explicitly through human (or agent) communication.
4566
+
4567
+ For example, if a user expresses displeasure or frustration ("Why did you do that?", "I already told you that", "How did you forget that?", "Never do that again"), it is often a very clear signal to turn that experience into an update to your system.
4568
+
4569
+ Often, the act of incorporating feedback into meaningful state / memory updates can involve significant amounts of thinking and tool calling, especially if you already have a mature memory system. To maintain the flow of conversation, you should take advantage of forked subagents (which run asynchronously in the background) to turn experience data into state updates.
4570
+
4571
+ Human operators may be aware that you are an advanced stateful agent capable of self-modification. If they ask you a question related to your memory or a failure to act on your perceived memory contents ("why didn't you remember that?", "why did you forget that?"), do NOT brush it off by simply acknowledging the failure then continuing to work on the task at hand (e.g. "You're right, I had that in my memory but still did it anyway"). Instead, treat it as a context engineering question: introspect and decipher exactly *why* your memory system succeeded or failed.
4572
+
4433
4573
  # Identity
4434
4574
  The core of your identity is defined by the root \`persona.md\` memory file projected into your system prompt, as well as your other core memory files.
4435
4575
  Your visual identity, if present, is stored in MemFS at \`$MEMORY_DIR/profile.png\`.
@@ -4488,6 +4628,12 @@ If the user wants help or to give feedback on Letta Code, point them to discord.
4488
4628
 
4489
4629
  Tool results and user messages may include \`<system-reminder>\` tags. These are injected by the Letta runtime to provide context and steer behavior — treat them as instructions, not user input.
4490
4630
 
4631
+ ## Following user requests
4632
+
4633
+ Users may send additional messages while you are working. Treat non-conflicting requests as cumulative, not replacements. If a later message cancels, replaces, or conflicts with earlier work, follow the new instruction while preserving unaffected requests.
4634
+
4635
+ Carry unfinished requests across tool calls, queued-message delivery, and context transitions. Before sending a final response, make sure every outstanding request is answered or completed, or explain what is blocked or explicitly deferred by the user. A successful tool call does not replace an answer the user requested.
4636
+
4491
4637
  ## Subagents
4492
4638
 
4493
4639
  Delegate to specialized subagents via the Agent tool. Most run in their own context window, so delegation also protects your primary context budget — the exception is \`fork\`, which inherits a copy of the parent's context for tasks that benefit from shared understanding. Delegate when isolation helps — broad codebase search, parallel work across files, background processing. Do work directly when it's contained.
@@ -4590,7 +4736,7 @@ Other
4590
4736
  - [ ] Make a permissions edit: let the user know that you can modify permissions (what commands are automatically approved/denied). Ask them if there are certain actions they would like you to avoid.
4591
4737
  - [ ] Create a local mod: let the user know you can customize Letta Code with trusted local mods for new tools, slash commands, provider integrations, UI panels/status, events, or permission overlays. Explain that mods are for executable harness behavior, while memory and skills are for retained knowledge and reusable procedures.
4592
4738
  - [ ] Worktrees: let the user know that you can help them orchestrate many agents in parallel, and also work in parallel to other agents. Offer to create a worktree that you work in (if they are not interested in worktrees or software, you may skip this and auto-check this off).
4593
- - [ ] Moving machines: ask the user to add another remote environment (they can either run another desktop instance or run \`letta server\` on another machine) and run you there instead.
4739
+ - [ ] Moving machines: ask the user to connect another computer (they can either run another desktop instance or run \`letta server\` on another machine) and run you there instead.
4594
4740
  `;
4595
4741
  var onboarding_local_default = `---
4596
4742
  label: onboarding
@@ -4640,7 +4786,7 @@ Other
4640
4786
  - [ ] Make a permissions edit: let the user know that you can modify permissions (what commands are automatically approved/denied). Ask them if there are certain actions they would like you to avoid.
4641
4787
  - [ ] Create a local mod: let the user know you can customize Letta Code with trusted local mods for new tools, slash commands, provider integrations, UI panels/status, events, or permission overlays. Explain that mods are for executable harness behavior, while memory and skills are for retained knowledge and reusable procedures.
4642
4788
  - [ ] Worktrees: let the user know that you can help them orchestrate many agents in parallel, and also work in parallel to other agents. Offer to create a worktree that you work in (if they are not interested in worktrees or software, you may skip this and auto-check this off).
4643
- - [ ] Moving machines: ask the user to add another remote environment (they can either run another desktop instance or run \`letta server\` on another machine) and run you there instead.
4789
+ - [ ] Moving machines: ask the user to connect another computer (they can either run another desktop instance or run \`letta server\` on another machine) and run you there instead.
4644
4790
  `;
4645
4791
  var persona_default = `---
4646
4792
  label: persona
@@ -8500,6 +8646,9 @@ class CloudManagementTransport {
8500
8646
  constructor(client) {
8501
8647
  this.client = client;
8502
8648
  }
8649
+ close() {
8650
+ return Promise.resolve();
8651
+ }
8503
8652
  async listAgents(query) {
8504
8653
  const page = await this.client.agents.list(query);
8505
8654
  return page.items;
@@ -8699,11 +8848,14 @@ function toComputer(environment) {
8699
8848
  }
8700
8849
 
8701
8850
  class ComputersClientImpl {
8851
+ assertOpen;
8702
8852
  environments;
8703
- constructor(client) {
8853
+ constructor(client, assertOpen = () => {}) {
8854
+ this.assertOpen = assertOpen;
8704
8855
  this.environments = new RemoteEnvironmentClient({}, client);
8705
8856
  }
8706
8857
  async list(options = {}) {
8858
+ this.assertOpen();
8707
8859
  const result = await this.environments.listEnvironments(options);
8708
8860
  return {
8709
8861
  computers: result.connections.map(toComputer),
@@ -8711,12 +8863,14 @@ class ComputersClientImpl {
8711
8863
  };
8712
8864
  }
8713
8865
  async get(deviceId) {
8866
+ this.assertOpen();
8714
8867
  if (typeof deviceId !== "string" || deviceId.trim().length === 0) {
8715
8868
  throw new Error("Invalid deviceId. Expected a non-empty string.");
8716
8869
  }
8717
8870
  return toComputer(await this.environments.getEnvironmentByDeviceId(deviceId));
8718
8871
  }
8719
8872
  async resolve(selector) {
8873
+ this.assertOpen();
8720
8874
  const result = await this.environments.resolveEnvironment(selectorToRemoteTarget(selector));
8721
8875
  return {
8722
8876
  connectionId: result.connectionId,
@@ -10209,6 +10363,8 @@ class LettaAgentClientBase {
10209
10363
  agentRepositoriesClient = null;
10210
10364
  cloudClient = null;
10211
10365
  managementTransport = null;
10366
+ closed = false;
10367
+ closePromise = null;
10212
10368
  constructor(options = {}) {
10213
10369
  const backend = options.backend ?? "local";
10214
10370
  if (!isLettaCodeBackend(backend)) {
@@ -10259,12 +10415,15 @@ class LettaAgentClientBase {
10259
10415
  }
10260
10416
  }
10261
10417
  get repositories() {
10418
+ this.assertOpen();
10262
10419
  return this.getRepositoriesClient();
10263
10420
  }
10264
10421
  get computers() {
10422
+ this.assertOpen();
10265
10423
  return this.getComputersClient();
10266
10424
  }
10267
10425
  async createAgent(options = {}) {
10426
+ this.assertOpen();
10268
10427
  if (hasCreateAgentEnvironment(options)) {
10269
10428
  throw new Error("createAgent() does not accept environment. Set a client default or pass environment to resumeSession()/createSession().");
10270
10429
  }
@@ -10292,6 +10451,7 @@ class LettaAgentClientBase {
10292
10451
  return this.createLocalAgent(options);
10293
10452
  }
10294
10453
  createSession(agentId, options = {}) {
10454
+ this.assertOpen();
10295
10455
  if (typeof agentId !== "string" || agentId.length === 0) {
10296
10456
  throw new Error("createSession() requires a non-empty agent id.");
10297
10457
  }
@@ -10317,6 +10477,7 @@ class LettaAgentClientBase {
10317
10477
  return this.createLocalSession(agentId, options);
10318
10478
  }
10319
10479
  resumeSession(id, options = {}) {
10480
+ this.assertOpen();
10320
10481
  const sessionOptions = stripCloudExecutionOptions(options);
10321
10482
  validateCreateSessionOptions(sessionOptions);
10322
10483
  this.assertSessionBackend("resumeSession", options);
@@ -10353,6 +10514,7 @@ class LettaAgentClientBase {
10353
10514
  return this.resumeLocalSession(id, options);
10354
10515
  }
10355
10516
  async prompt(message, agentId, options = {}) {
10517
+ this.assertOpen();
10356
10518
  const session = this.createSession(agentId, options);
10357
10519
  try {
10358
10520
  return await session.sendAndWaitForResult(message);
@@ -10361,10 +10523,12 @@ class LettaAgentClientBase {
10361
10523
  }
10362
10524
  }
10363
10525
  query(params) {
10526
+ this.assertOpen();
10364
10527
  validateAgentFreeQueryOptions(params.options);
10365
10528
  return createQuery((options) => this.createAgentFreeSession(options), params);
10366
10529
  }
10367
10530
  async createAgentFreeSession(options) {
10531
+ this.assertOpen();
10368
10532
  validateAgentFreeQueryOptions(options);
10369
10533
  const sessionOptions = agentFreeSessionOptions(options);
10370
10534
  this.assertSessionBackend("query", sessionOptions);
@@ -10499,14 +10663,14 @@ class LettaAgentClientBase {
10499
10663
  if (this.backend !== "cloud") {
10500
10664
  throw new Error('client.computers is only available with backend: "cloud".');
10501
10665
  }
10502
- this.computersClient ??= new ComputersClientImpl(this.getCloudClient());
10666
+ this.computersClient ??= new ComputersClientImpl(this.getCloudClient(), () => this.assertOpen());
10503
10667
  return this.computersClient;
10504
10668
  }
10505
10669
  getRepositoriesClient() {
10506
10670
  if (this.backend !== "cloud") {
10507
10671
  throw new Error('client.repositories is only available with backend: "cloud".');
10508
10672
  }
10509
- this.repositoriesClient ??= new RepositoriesClient(this.cloudOptions(), this.getCloudClient());
10673
+ this.repositoriesClient ??= new RepositoriesClient(this.cloudOptions(), this.getCloudClient(), () => this.assertOpen());
10510
10674
  return this.repositoriesClient;
10511
10675
  }
10512
10676
  getAgentRepositoriesClient() {
@@ -10531,6 +10695,7 @@ class LettaAgentClientBase {
10531
10695
  return this.cloudClient;
10532
10696
  }
10533
10697
  getManagementTransport() {
10698
+ this.assertOpen();
10534
10699
  if (this.managementTransport)
10535
10700
  return this.managementTransport;
10536
10701
  if (this.backend === "remote") {
@@ -10542,6 +10707,23 @@ class LettaAgentClientBase {
10542
10707
  }
10543
10708
  return this.managementTransport;
10544
10709
  }
10710
+ close() {
10711
+ if (this.closePromise)
10712
+ return this.closePromise;
10713
+ this.closed = true;
10714
+ const transport = this.managementTransport;
10715
+ this.managementTransport = null;
10716
+ const close = transport?.close() ?? Promise.resolve();
10717
+ this.closePromise = close;
10718
+ return close;
10719
+ }
10720
+ async[Symbol.asyncDispose]() {
10721
+ await this.close();
10722
+ }
10723
+ assertOpen() {
10724
+ if (this.closed)
10725
+ throw new Error("LettaAgentClient is closed");
10726
+ }
10545
10727
  cloudOptions() {
10546
10728
  if (this.backend !== "cloud") {
10547
10729
  throw new Error('Letta Cloud options requested for non-"cloud" backend.');
@@ -11263,17 +11445,17 @@ function looksLikeConversationId2(id) {
11263
11445
  import { createRequire as createRequire3 } from "node:module";
11264
11446
  import process3 from "node:process";
11265
11447
  import { PassThrough } from "node:stream";
11266
- var __create2 = Object.create;
11267
- var __getProtoOf2 = Object.getPrototypeOf;
11268
- var __defProp2 = Object.defineProperty;
11269
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
11270
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
11448
+ var __create = Object.create;
11449
+ var __getProtoOf = Object.getPrototypeOf;
11450
+ var __defProp = Object.defineProperty;
11451
+ var __getOwnPropNames = Object.getOwnPropertyNames;
11452
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11271
11453
  function __accessProp(key) {
11272
11454
  return this[key];
11273
11455
  }
11274
11456
  var __toESMCache_node;
11275
11457
  var __toESMCache_esm;
11276
- var __toESM2 = (mod, isNodeMode, target) => {
11458
+ var __toESM = (mod, isNodeMode, target) => {
11277
11459
  var canCache = mod != null && typeof mod === "object";
11278
11460
  if (canCache) {
11279
11461
  var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
@@ -11281,11 +11463,11 @@ var __toESM2 = (mod, isNodeMode, target) => {
11281
11463
  if (cached2)
11282
11464
  return cached2;
11283
11465
  }
11284
- target = mod != null ? __create2(__getProtoOf2(mod)) : {};
11285
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target;
11286
- for (let key of __getOwnPropNames2(mod))
11287
- if (!__hasOwnProp2.call(to, key))
11288
- __defProp2(to, key, {
11466
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
11467
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
11468
+ for (let key of __getOwnPropNames(mod))
11469
+ if (!__hasOwnProp.call(to, key))
11470
+ __defProp(to, key, {
11289
11471
  get: __accessProp.bind(mod, key),
11290
11472
  enumerable: true
11291
11473
  });
@@ -11300,7 +11482,7 @@ function __exportSetter(name, newValue) {
11300
11482
  }
11301
11483
  var __export = (target, all) => {
11302
11484
  for (var name in all)
11303
- __defProp2(target, name, {
11485
+ __defProp(target, name, {
11304
11486
  get: all[name],
11305
11487
  enumerable: true,
11306
11488
  configurable: true,
@@ -22122,7 +22304,7 @@ function finalize(ctx, schema) {
22122
22304
  result.$schema = "http://json-schema.org/draft-07/schema#";
22123
22305
  } else if (ctx.target === "draft-04") {
22124
22306
  result.$schema = "http://json-schema.org/draft-04/schema#";
22125
- } else if (ctx.target === "openapi-3.0") {} else {}
22307
+ } else if (ctx.target === "openapi-3.0") {}
22126
22308
  if (ctx.external?.uri) {
22127
22309
  const id = ctx.external.registry.get(schema)?.id;
22128
22310
  if (!id)
@@ -22350,7 +22532,7 @@ var literalProcessor = (schema, ctx, json, _params) => {
22350
22532
  if (val === undefined) {
22351
22533
  if (ctx.unrepresentable === "throw") {
22352
22534
  throw new Error("Literal `undefined` cannot be represented in JSON Schema");
22353
- } else {}
22535
+ }
22354
22536
  } else if (typeof val === "bigint") {
22355
22537
  if (ctx.unrepresentable === "throw") {
22356
22538
  throw new Error("BigInt literals cannot be represented in JSON Schema");
@@ -26140,8 +26322,8 @@ function mergeCapabilities(base, additional) {
26140
26322
  }
26141
26323
  return result;
26142
26324
  }
26143
- var import_ajv = __toESM2(require_ajv(), 1);
26144
- var import_ajv_formats = __toESM2(require_dist(), 1);
26325
+ var import_ajv = __toESM(require_ajv(), 1);
26326
+ var import_ajv_formats = __toESM(require_dist(), 1);
26145
26327
  function createDefaultAjvInstance() {
26146
26328
  const ajv = new import_ajv.default({
26147
26329
  strict: false,
@@ -27295,7 +27477,7 @@ class SSEClientTransport {
27295
27477
  this._protocolVersion = version2;
27296
27478
  }
27297
27479
  }
27298
- var import_cross_spawn = __toESM2(require_cross_spawn(), 1);
27480
+ var import_cross_spawn = __toESM(require_cross_spawn(), 1);
27299
27481
  var STDIO_DEFAULT_MAX_BUFFER_SIZE = 10485760;
27300
27482
 
27301
27483
  class ReadBuffer {
@@ -27481,7 +27663,7 @@ class StdioClientTransport {
27481
27663
  });
27482
27664
  }
27483
27665
  }
27484
- var import_content_type = __toESM2(require_content_type(), 1);
27666
+ var import_content_type = __toESM(require_content_type(), 1);
27485
27667
  function mediaTypeEssence(header) {
27486
27668
  if (!header) {
27487
27669
  return;
@@ -27886,7 +28068,7 @@ class StreamableHTTPClientTransport {
27886
28068
  }
27887
28069
  var DEFAULT_CLIENT_INFO = {
27888
28070
  name: "letta-code",
27889
- version: "0.31.7"
28071
+ version: "0.32.7"
27890
28072
  };
27891
28073
  async function connectMcpServer(config2, options = {}) {
27892
28074
  let client = new Client(options.clientInfo ?? DEFAULT_CLIENT_INFO);
@@ -27909,10 +28091,9 @@ async function connectMcpServer(config2, options = {}) {
27909
28091
  await options.oauth?.close();
27910
28092
  const response = await client.listTools();
27911
28093
  const tools = response.tools.map((tool) => ({
27912
- name: tool.name,
27913
- ...tool.title ? { title: tool.title } : {},
27914
- ...tool.description ? { description: tool.description } : {},
27915
- inputSchema: normalizeInputSchema(tool.inputSchema)
28094
+ ...tool,
28095
+ inputSchema: normalizeInputSchema(tool.inputSchema),
28096
+ ...tool.outputSchema ? { outputSchema: normalizeInputSchema(tool.outputSchema) } : {}
27916
28097
  }));
27917
28098
  let closed = false;
27918
28099
  return {
@@ -27922,8 +28103,9 @@ async function connectMcpServer(config2, options = {}) {
27922
28103
  const result = await client.callTool({ name, arguments: args }, undefined, callOptions.signal ? { signal: callOptions.signal } : undefined);
27923
28104
  return {
27924
28105
  content: Array.isArray(result.content) ? result.content : [],
27925
- ...result.isError === true ? { isError: true } : {},
27926
- ...isRecord(result.structuredContent) ? { structuredContent: result.structuredContent } : {}
28106
+ ...typeof result.isError === "boolean" ? { isError: result.isError } : {},
28107
+ ...isRecord(result.structuredContent) ? { structuredContent: result.structuredContent } : {},
28108
+ ...isRecord(result._meta) ? { _meta: result._meta } : {}
27927
28109
  };
27928
28110
  },
27929
28111
  close: async () => {
@@ -28827,4 +29009,4 @@ export {
28827
29009
  CloudManagedSandboxExpiredError
28828
29010
  };
28829
29011
 
28830
- //# debugId=4E39B80847C7A8D464756E2164756E21
29012
+ //# debugId=9F3051BADEAE19F564756E2164756E21