@letta-ai/letta-agent-sdk 0.7.6 → 0.7.7

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.
@@ -13,6 +13,7 @@ export declare class LettaAgentClient extends LettaAgentClientBase {
13
13
  export { CloudManagedSandboxExpiredError } from "./cloud-session.js";
14
14
  export { ConversationForkHydrationError } from "./management-errors.js";
15
15
  export { RepositoriesClient } from "./repositories.js";
16
+ export type * from "./sandbox-files.js";
16
17
  export type { Computer, ComputerMetadata, ComputerSelector, ComputersClient, ListComputersOptions, ListComputersResult, ResolvedComputer, } from "./computers.js";
17
18
  export type * from "./management-types.js";
18
19
  export { extractStreamTextDelta } from "./stream-events.js";
@@ -1 +1 @@
1
- {"version":3,"file":"client-entry.d.ts","sourceRoot":"","sources":["../src/client-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EACV,2BAA2B,EAC3B,4BAA4B,EAC7B,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,+BAA+B,GACvC,4BAA4B,GAC5B,2BAA2B,CAAC;AAEhC;;;;;GAKG;AACH,qBAAa,gBAAiB,SAAQ,oBAAoB;gBAC5C,OAAO,EAAE,+BAA+B;CAMrD;AAED,OAAO,EAAE,+BAA+B,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,YAAY,EACV,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,mBAAmB,uBAAuB,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B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B,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,qCAAqC,EAAE,MAAM,gBAAgB,CAAC;AACvE,mBAAmB,YAAY,CAAC"}
@@ -10963,6 +10963,51 @@ function validateCloudSandboxOptions(options, name) {
10963
10963
  }
10964
10964
  }
10965
10965
 
10966
+ // src/sandbox-files.ts
10967
+ function isUploadedFile(value) {
10968
+ if (!value || typeof value !== "object" || Array.isArray(value))
10969
+ return false;
10970
+ const file = value;
10971
+ return typeof file.path === "string" && typeof file.name === "string" && typeof file.mimeType === "string" && typeof file.size === "number" && Number.isSafeInteger(file.size) && file.size >= 0;
10972
+ }
10973
+ function parseUploadResult(value) {
10974
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
10975
+ throw new Error("Cloud sandbox file upload returned an invalid response.");
10976
+ }
10977
+ const files = value.files;
10978
+ if (!Array.isArray(files) || !files.every(isUploadedFile)) {
10979
+ throw new Error("Cloud sandbox file upload returned invalid file metadata.");
10980
+ }
10981
+ return { files };
10982
+ }
10983
+ function uploadForm(files) {
10984
+ if (files.length === 0) {
10985
+ throw new Error("Cloud sandbox file upload requires at least one file.");
10986
+ }
10987
+ const form = new FormData;
10988
+ for (const [index, file] of files.entries()) {
10989
+ if (!file || typeof file.name !== "string" || file.name.trim() === "") {
10990
+ throw new Error(`Invalid Cloud sandbox upload file at index ${index}.`);
10991
+ }
10992
+ form.append("file", file.data, file.name);
10993
+ }
10994
+ return form;
10995
+ }
10996
+ async function uploadSandboxFiles(apiClient, sandboxId, files) {
10997
+ const response = await apiClient.post(`/v1/sandboxes/${encodeURIComponent(sandboxId)}/files`, { body: uploadForm(files) });
10998
+ return parseUploadResult(response);
10999
+ }
11000
+ async function downloadSandboxFile(apiClient, sandboxId, path2) {
11001
+ if (typeof path2 !== "string" || path2.trim() === "") {
11002
+ throw new Error("Cloud sandbox file download requires a non-empty path.");
11003
+ }
11004
+ const response = await apiClient.get(`/v1/sandboxes/${encodeURIComponent(sandboxId)}/files`, {
11005
+ query: { path: path2 },
11006
+ __binaryResponse: true
11007
+ });
11008
+ return new Uint8Array(await response.arrayBuffer());
11009
+ }
11010
+
10966
11011
  // src/cloud-session.ts
10967
11012
  var DEFAULT_TURN_TIMEOUT_MS = 120000;
10968
11013
  var DEFAULT_PING_INTERVAL_MS = 30000;
@@ -11102,6 +11147,7 @@ function assertCloudSessionOptionsSupported(action, options) {
11102
11147
  class CloudEnvironmentSession extends RemoteClientSessionCore {
11103
11148
  cloudOptions;
11104
11149
  apiClient;
11150
+ sandbox;
11105
11151
  connectionId = null;
11106
11152
  removeExternalToolHandler = null;
11107
11153
  removeControlRequestHandler = null;
@@ -11125,6 +11171,10 @@ class CloudEnvironmentSession extends RemoteClientSessionCore {
11125
11171
  this.apiClient = apiClient;
11126
11172
  this.cloudMode = mode;
11127
11173
  this.repositoryManagement = new CloudManagementTransport(apiClient);
11174
+ this.sandbox = this.effectiveEnvironment() === undefined ? {
11175
+ uploadFiles: (files) => this.uploadFilesToManagedSandbox(files),
11176
+ downloadFile: (path2) => this.downloadFileFromManagedSandbox(path2)
11177
+ } : undefined;
11128
11178
  const tools = mode.options.tools;
11129
11179
  this.externalTools = externalToolsByName(tools);
11130
11180
  }
@@ -11290,6 +11340,26 @@ class CloudEnvironmentSession extends RemoteClientSessionCore {
11290
11340
  return;
11291
11341
  await this.refreshManagedSandbox(sandbox);
11292
11342
  }
11343
+ async uploadFilesToManagedSandbox(files) {
11344
+ const sandbox = await this.requireManagedSandboxForFileTransfer();
11345
+ return uploadSandboxFiles(this.apiClient, sandbox.sandboxId, files);
11346
+ }
11347
+ async downloadFileFromManagedSandbox(path2) {
11348
+ const sandbox = await this.requireManagedSandboxForFileTransfer();
11349
+ return downloadSandboxFile(this.apiClient, sandbox.sandboxId, path2);
11350
+ }
11351
+ async requireManagedSandboxForFileTransfer() {
11352
+ if (this.effectiveEnvironment() !== undefined) {
11353
+ throw new Error("Sandbox file transfer requires an SDK-managed Cloud sandbox.");
11354
+ }
11355
+ await this.ready();
11356
+ const sandbox = this.managedSandbox;
11357
+ if (!sandbox) {
11358
+ throw new Error("SDK-managed Cloud sandbox is unavailable.");
11359
+ }
11360
+ await this.refreshManagedSandbox(sandbox);
11361
+ return sandbox;
11362
+ }
11293
11363
  onCoreClose() {
11294
11364
  this.cleanupTransportHandlers();
11295
11365
  this.mcpCleanup = this.closeMcpBridge();
@@ -12788,4 +12858,4 @@ export {
12788
12858
  CloudManagedSandboxExpiredError
12789
12859
  };
12790
12860
 
12791
- //# debugId=7375838F6D261D8064756E2164756E21
12861
+ //# debugId=4D2DEBF58B35A6BA64756E2164756E21