@letta-ai/letta-agent-sdk 0.7.8 → 0.8.0

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.
@@ -35,6 +35,7 @@ export declare class AppServerManagementTransport implements ManagementTransport
35
35
  updateConversation(conversationId: string, body: ConversationUpdateParams): Promise<LettaConversation>;
36
36
  forkConversation(conversationId: string, body: ConversationForkParams): Promise<LettaConversation>;
37
37
  listConversationMessages(conversationId: string, query: MessageListParams): Promise<ConversationMessagesResult>;
38
+ enqueueConversationMessage(): Promise<never>;
38
39
  private request;
39
40
  private acquireConnection;
40
41
  private openConnection;
@@ -1 +1 @@
1
- {"version":3,"file":"app-server-management.d.ts","sourceRoot":"","sources":["../src/app-server-management.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EAClB,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EACV,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACzB,MAAM,8DAA8D,CAAC;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAC;AAGjG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,OAAO,KAAK,EACV,0BAA0B,EAC1B,UAAU,EACV,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEjF,KAAK,eAAe,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,IAAI,IAAI,CAAA;CAAE,CAAC;AAEtD,MAAM,MAAM,0BAA0B,GACpC,OAAO,CAAC,4BAA4B,CAAC,GAAG;IACtC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;CAC1C,CAAC;AAmBJ;;;;;;GAMG;AACH,q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C,gBAAgB,CAAC;IAWvC,iBAAiB,CACrB,KAAK,EAAE,sBAAsB,GAC5B,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAYzB,oBAAoB,CACxB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,iBAAiB,CAAC;IAavB,kBAAkB,CACtB,IAAI,EAAE,wBAAwB,GAC7B,OAAO,CAAC,iBAAiB,CAAC;IAavB,kBAAkB,CACtB,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,wBAAwB,GAC7B,OAAO,CAAC,iBAAiB,CAAC;IAavB,gBAAgB,CACpB,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,iBAAiB,CAAC;IAkBvB,wBAAwB,CAC5B,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,0BAA0B,CAAC;IAgBtC,0BAA0B,IAAI,OAAO,CAAC,KAAK,CAAC;YAQ9B,OAAO;IA4BrB,OAAO,CAAC,iBAAiB;YAsBX,cAAc;IA+C5B,OAAO,CAAC,iBAAiB;IAUzB,OAAO,CAAC,sBAAsB;CAW/B"}
@@ -20,13 +20,13 @@ function __classPrivateFieldGet(receiver, state, kind, f) {
20
20
 
21
21
  // node_modules/@letta-ai/letta-client/internal/utils/uuid.mjs
22
22
  var uuid4 = function() {
23
- const { crypto } = globalThis;
24
- if (crypto?.randomUUID) {
25
- uuid4 = crypto.randomUUID.bind(crypto);
26
- return crypto.randomUUID();
23
+ const { crypto: crypto2 } = globalThis;
24
+ if (crypto2?.randomUUID) {
25
+ uuid4 = crypto2.randomUUID.bind(crypto2);
26
+ return crypto2.randomUUID();
27
27
  }
28
28
  const u8 = new Uint8Array(1);
29
- const randomByte = crypto ? () => crypto.getRandomValues(u8)[0] : () => Math.random() * 255 & 255;
29
+ const randomByte = crypto2 ? () => crypto2.getRandomValues(u8)[0] : () => Math.random() * 255 & 255;
30
30
  return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (c) => (+c ^ randomByte() & 15 >> +c / 4).toString(16));
31
31
  };
32
32
 
@@ -3535,6 +3535,9 @@ class AppServerManagementTransport {
3535
3535
  }
3536
3536
  return { messages: response.messages };
3537
3537
  }
3538
+ enqueueConversationMessage() {
3539
+ return Promise.reject(new Error(`conversations.enqueue() is only available with backend: "cloud". App-server backends deliver messages through a session's send().`));
3540
+ }
3538
3541
  async request(type, body, responseType) {
3539
3542
  if (this.closingConnections.size > 0) {
3540
3543
  await Promise.all([...this.closingConnections]);
@@ -10481,6 +10484,20 @@ function cloudModelEntry(raw) {
10481
10484
  function isNotFound(error) {
10482
10485
  return error instanceof APIError && error.status === 404;
10483
10486
  }
10487
+ function asEnqueueMessageResult(body) {
10488
+ if (!body || typeof body !== "object" || Array.isArray(body)) {
10489
+ throw new Error("Cloud enqueue message response was not an object.");
10490
+ }
10491
+ const response = body;
10492
+ if (typeof response.client_message_id !== "string" || typeof response.workflow_id !== "string" || typeof response.super_run_id !== "string") {
10493
+ throw new Error("Cloud enqueue message response did not include client_message_id, workflow_id, and super_run_id.");
10494
+ }
10495
+ return {
10496
+ clientMessageId: response.client_message_id,
10497
+ workflowId: response.workflow_id,
10498
+ superRunId: response.super_run_id
10499
+ };
10500
+ }
10484
10501
  function toOrderRelativeCursors(query) {
10485
10502
  if ((query.order ?? "desc") !== "desc")
10486
10503
  return query;
@@ -10572,6 +10589,28 @@ class CloudManagementTransport {
10572
10589
  const page = await this.client.conversations.messages.list(conversationId, toOrderRelativeCursors(query));
10573
10590
  return { messages: page.items };
10574
10591
  }
10592
+ async enqueueConversationMessage(conversationId, message, options) {
10593
+ const clientMessageId = options.clientMessageId ?? crypto.randomUUID();
10594
+ const settings = {
10595
+ ...options.workingDirectory !== undefined ? { working_directory: options.workingDirectory } : {},
10596
+ ...options.permissionMode !== undefined ? { permission_mode: options.permissionMode } : {}
10597
+ };
10598
+ const body = await this.client.post(`/v1/conversations/${encodeURIComponent(conversationId)}/messages/enqueue`, {
10599
+ body: {
10600
+ ...options.agentId !== undefined ? { agent_id: options.agentId } : {},
10601
+ messages: [
10602
+ {
10603
+ role: "user",
10604
+ content: message,
10605
+ client_message_id: clientMessageId
10606
+ }
10607
+ ],
10608
+ client_message_id: clientMessageId,
10609
+ ...Object.keys(settings).length > 0 ? { settings } : {}
10610
+ }
10611
+ });
10612
+ return asEnqueueMessageResult(body);
10613
+ }
10575
10614
  }
10576
10615
 
10577
10616
  // src/remote.ts
@@ -11845,7 +11884,20 @@ function createConversationsClient(transport) {
11845
11884
  }
11846
11885
  return await transport().forkConversation(sourceConversationId, conversationForkQuery(options));
11847
11886
  },
11848
- listMessages: (conversationId, options = {}) => transport().listConversationMessages(conversationId, conversationMessagesQuery(options))
11887
+ listMessages: (conversationId, options = {}) => transport().listConversationMessages(conversationId, conversationMessagesQuery(options)),
11888
+ enqueue: async (conversationId, message, options = {}) => {
11889
+ assertNonEmptyId2(conversationId, "conversation id");
11890
+ if (conversationId.trim() === "default" && !options.agentId) {
11891
+ throw new Error('enqueue("default", ...) requires options.agentId to identify the agent.');
11892
+ }
11893
+ if (options.agentId !== undefined) {
11894
+ assertNonEmptyId2(options.agentId, "agent id");
11895
+ }
11896
+ if (options.clientMessageId !== undefined) {
11897
+ assertNonEmptyId2(options.clientMessageId, "client message id");
11898
+ }
11899
+ return await transport().enqueueConversationMessage(conversationId, message, options);
11900
+ }
11849
11901
  };
11850
11902
  }
11851
11903
 
@@ -12894,4 +12946,4 @@ export {
12894
12946
  CloudManagedSandboxExpiredError
12895
12947
  };
12896
12948
 
12897
- //# debugId=02750F72F2B016D564756E2164756E21
12949
+ //# debugId=6DEC5A9A513E517464756E2164756E21