@letta-ai/letta-agent-sdk 0.8.78 → 0.8.79

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.
@@ -15,7 +15,8 @@ import type { CreateAgentOptions, LettaCodeBackend, LettaCodeClientOptions, Lett
15
15
  * protocol.
16
16
  * `remote` connects to a user-managed Letta Code app-server websocket endpoint.
17
17
  * `cloud` uses agents hosted on Letta Cloud, with an explicit remote
18
- * environment or SDK-managed sandbox.
18
+ * environment or SDK-managed sandbox. With `registerComputer`, the SDK also
19
+ * starts a local app-server that registers this machine as that computer.
19
20
  */
20
21
  export declare class LettaAgentClientBase implements AsyncDisposable {
21
22
  readonly backend: LettaCodeBackend;
@@ -72,6 +73,14 @@ export declare class LettaAgentClientBase implements AsyncDisposable {
72
73
  query(params: QueryParams): Query;
73
74
  private createQuerySession;
74
75
  private assertSessionBackend;
76
+ /**
77
+ * Build a Cloud session. Sessions that run on the computer this client
78
+ * registers start the local app-server first and wait for it to come online.
79
+ */
80
+ private createCloudSession;
81
+ private connectRegisteredComputer;
82
+ /** Start the app-server that registers this machine; overridden by the Node client. */
83
+ protected startRegisteredComputer(): Promise<void>;
75
84
  protected createLocalAgent(_options: CreateAgentOptions): Promise<string>;
76
85
  /**
77
86
  * Node-only skill seeding support (directory loading, memory-repo git
@@ -99,7 +108,10 @@ export declare class LettaAgentClientBase implements AsyncDisposable {
99
108
  * prompts, with or without an open session.
100
109
  */
101
110
  registerTools(options: RegisterToolsOptions): Promise<ToolRegistration>;
102
- /** How the local backend reaches its App Server; overridden by the Node client. */
111
+ /**
112
+ * How the local backend, or a Cloud client's registered computer, reaches
113
+ * its App Server; overridden by the Node client.
114
+ */
103
115
  protected localAppServerConnection(): AppServerSessionOptions;
104
116
  /**
105
117
  * Release resources owned directly by this client, including its pooled
@@ -1 +1 @@
1
- {"version":3,"file":"client-base.d.ts","sourceRoot":"","sources":["../src/client-base.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,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B,EACrB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,qCAAqC,EAAE,MAAM,gBAAgB,CAAC;AACvE,mBAAmB,YAAY,CAAC;AAChC,mBAAmB,kBAAkB,CAAC"}
@@ -15949,6 +15949,19 @@ function validateCloudClientOptions(options) {
15949
15949
  const field = options.computer !== undefined ? "computer" : "environment";
15950
15950
  throw new Error(`Letta Cloud sessions cannot specify both ${field} and sandbox options.`);
15951
15951
  }
15952
+ if (options.registerComputer !== undefined) {
15953
+ const name = options.registerComputer?.name;
15954
+ if (typeof name !== "string" || !name.trim()) {
15955
+ throw new Error("Invalid registerComputer.name. Expected a non-empty string.");
15956
+ }
15957
+ if (options.computer !== undefined || options.environment !== undefined) {
15958
+ const field = options.computer !== undefined ? "computer" : "environment";
15959
+ throw new Error(`Letta Cloud clients cannot specify both ${field} and registerComputer. Use computer for a machine that is already connected, or registerComputer to connect this one.`);
15960
+ }
15961
+ if (options.sandbox !== undefined) {
15962
+ throw new Error("Letta Cloud clients cannot specify both registerComputer and sandbox options.");
15963
+ }
15964
+ }
15952
15965
  if (options.webSocketAuth !== undefined && options.webSocketAuth !== "header" && options.webSocketAuth !== "query") {
15953
15966
  throw new Error("Invalid webSocketAuth. Valid values: header, query.");
15954
15967
  }
@@ -16042,6 +16055,7 @@ function assertCloudSessionOptionsSupported(action, options) {
16042
16055
  class CloudEnvironmentSession extends RemoteClientSessionCore {
16043
16056
  cloudOptions;
16044
16057
  apiClient;
16058
+ connectRegisteredComputer;
16045
16059
  sandbox;
16046
16060
  connectionId = null;
16047
16061
  removeExternalToolHandler = null;
@@ -16057,13 +16071,14 @@ class CloudEnvironmentSession extends RemoteClientSessionCore {
16057
16071
  repositoryIdsRequiringCleanupRecompile = new Set;
16058
16072
  repositoryManagement;
16059
16073
  cloudMode;
16060
- constructor(cloudOptions, mode, apiClient = createCloudClient(cloudOptions)) {
16074
+ constructor(cloudOptions, mode, apiClient = createCloudClient(cloudOptions), connectRegisteredComputer) {
16061
16075
  super(mode, {
16062
16076
  label: "cloud",
16063
16077
  requestTimeoutMs: cloudOptions.requestTimeoutMs ?? DEFAULT_TURN_TIMEOUT_MS
16064
16078
  });
16065
16079
  this.cloudOptions = cloudOptions;
16066
16080
  this.apiClient = apiClient;
16081
+ this.connectRegisteredComputer = connectRegisteredComputer;
16067
16082
  this.cloudMode = mode;
16068
16083
  this.repositoryManagement = new CloudManagementTransport(apiClient);
16069
16084
  this.sandbox = this.effectiveEnvironment() === undefined ? {
@@ -16466,6 +16481,8 @@ class CloudEnvironmentSession extends RemoteClientSessionCore {
16466
16481
  return this.createManagedSandboxConnection(runtime);
16467
16482
  }
16468
16483
  async resolveExplicitConnection(environment) {
16484
+ if (this.connectRegisteredComputer)
16485
+ return this.connectRegisteredComputer();
16469
16486
  const target = environmentToRemoteTarget(environment);
16470
16487
  const resolved = await this.remoteEnvironmentClient().resolveEnvironment(target);
16471
16488
  return { connectionId: resolved.connectionId };
@@ -17265,6 +17282,15 @@ function stripCloudExecutionOptions(options) {
17265
17282
  delete sessionOptions.filesystemConfinement;
17266
17283
  return sessionOptions;
17267
17284
  }
17285
+ var REGISTERED_COMPUTER_READY_TIMEOUT_MS = 30000;
17286
+ var REGISTERED_COMPUTER_POLL_INTERVAL_MS = 500;
17287
+ function registeredComputerName(options) {
17288
+ return options.backend === "cloud" ? options.registerComputer?.name : undefined;
17289
+ }
17290
+ function isRegisteredComputerPending(error) {
17291
+ const message = error instanceof Error ? error.message : String(error);
17292
+ return message.startsWith("Computer not found") || message.startsWith("Computer is offline");
17293
+ }
17268
17294
  function hasRepositoryResources(options) {
17269
17295
  return options.resources !== undefined && options.resources.length > 0;
17270
17296
  }
@@ -17323,7 +17349,8 @@ class LettaAgentClientBase {
17323
17349
  throw new Error(`Invalid Letta Code backend '${String(backend)}'. Valid values: local, remote, cloud.`);
17324
17350
  }
17325
17351
  this.backend = backend;
17326
- this.computer = getOptionsComputer(options);
17352
+ const registeredName = registeredComputerName(options);
17353
+ this.computer = getOptionsComputer(options) ?? (registeredName !== undefined ? { name: registeredName } : undefined);
17327
17354
  this.environment = this.computer;
17328
17355
  this.options = options;
17329
17356
  this.agents = createAgentsClient(() => this.getManagementTransport(), () => this.getAgentRepositoriesClient());
@@ -17419,12 +17446,12 @@ class LettaAgentClientBase {
17419
17446
  });
17420
17447
  }
17421
17448
  if (this.backend === "cloud") {
17422
- return new CloudEnvironmentSession(this.cloudOptions(), {
17449
+ return this.createCloudSession({
17423
17450
  kind: "session",
17424
17451
  agentId,
17425
17452
  newConversation: true,
17426
17453
  options
17427
- }, this.getCloudClient());
17454
+ });
17428
17455
  }
17429
17456
  return this.createLocalSession(agentId, options);
17430
17457
  }
@@ -17450,19 +17477,7 @@ class LettaAgentClientBase {
17450
17477
  return session2;
17451
17478
  }
17452
17479
  if (this.backend === "cloud") {
17453
- if (looksLikeConversationId(id)) {
17454
- return new CloudEnvironmentSession(this.cloudOptions(), {
17455
- kind: "session",
17456
- conversationId: id,
17457
- options
17458
- }, this.getCloudClient());
17459
- }
17460
- return new CloudEnvironmentSession(this.cloudOptions(), {
17461
- kind: "session",
17462
- agentId: id,
17463
- defaultConversation: true,
17464
- options
17465
- }, this.getCloudClient());
17480
+ return this.createCloudSession(looksLikeConversationId(id) ? { kind: "session", conversationId: id, options } : { kind: "session", agentId: id, defaultConversation: true, options });
17466
17481
  }
17467
17482
  const session = this.resumeLocalSession(id, options);
17468
17483
  if (inherited && session instanceof AppServerSession)
@@ -17528,11 +17543,11 @@ class LettaAgentClientBase {
17528
17543
  if (!conversation || typeof conversation !== "object" || typeof conversation.id !== "string") {
17529
17544
  throw new Error("Cloud query conversation response did not include a conversation id.");
17530
17545
  }
17531
- return new CloudEnvironmentSession(this.cloudOptions(), {
17546
+ return this.createCloudSession({
17532
17547
  kind: "conversation",
17533
17548
  conversationId: conversation.id,
17534
17549
  options: sessionOptions
17535
- }, this.getCloudClient());
17550
+ });
17536
17551
  }
17537
17552
  return this.createLocalQuerySession(options, sessionOptions);
17538
17553
  }
@@ -17597,6 +17612,29 @@ class LettaAgentClientBase {
17597
17612
  }
17598
17613
  throw new Error(`LettaAgentClient backend '${this.backend}' is not implemented yet. ${action} currently supports backend 'local' only.`);
17599
17614
  }
17615
+ createCloudSession(mode) {
17616
+ const name = registeredComputerName(this.options);
17617
+ const sessionComputer = mode.options.computer ?? mode.options.environment;
17618
+ return new CloudEnvironmentSession(this.cloudOptions(), mode, this.getCloudClient(), name !== undefined && sessionComputer === undefined ? () => this.connectRegisteredComputer(name) : undefined);
17619
+ }
17620
+ async connectRegisteredComputer(name) {
17621
+ await this.startRegisteredComputer();
17622
+ const deadline = Date.now() + REGISTERED_COMPUTER_READY_TIMEOUT_MS;
17623
+ while (true) {
17624
+ try {
17625
+ const resolved = await this.getComputersClient().resolve({ name });
17626
+ return { connectionId: resolved.connectionId };
17627
+ } catch (error) {
17628
+ if (!isRegisteredComputerPending(error) || Date.now() >= deadline) {
17629
+ throw error;
17630
+ }
17631
+ await new Promise((resolve) => setTimeout(resolve, REGISTERED_COMPUTER_POLL_INTERVAL_MS));
17632
+ }
17633
+ }
17634
+ }
17635
+ startRegisteredComputer() {
17636
+ return Promise.reject(this.localBackendUnavailableError());
17637
+ }
17600
17638
  createLocalAgent(_options) {
17601
17639
  throw this.localBackendUnavailableError();
17602
17640
  }
@@ -17677,8 +17715,8 @@ class LettaAgentClientBase {
17677
17715
  }
17678
17716
  registerTools(options) {
17679
17717
  this.assertOpen();
17680
- if (this.backend === "cloud") {
17681
- return Promise.reject(new Error('registerTools() requires backend: "local" or "remote". Cloud sessions register tools through the tools session option.'));
17718
+ if (this.backend === "cloud" && registeredComputerName(this.options) === undefined) {
17719
+ return Promise.reject(new Error('registerTools() requires backend: "local" or "remote", or backend: "cloud" with registerComputer. Other Cloud sessions register tools through the tools session option.'));
17682
17720
  }
17683
17721
  this.toolRegistry ??= new ToolRegistry(this.backend === "remote" ? this.remoteOptions() : this.localAppServerConnection());
17684
17722
  return this.toolRegistry.register(options);
@@ -17709,7 +17747,8 @@ class LettaAgentClientBase {
17709
17747
  if (this.backend !== "cloud") {
17710
17748
  throw new Error('Letta Cloud options requested for non-"cloud" backend.');
17711
17749
  }
17712
- return this.options;
17750
+ const options = this.options;
17751
+ return options.registerComputer !== undefined ? { ...options, computer: { name: options.registerComputer.name } } : options;
17713
17752
  }
17714
17753
  }
17715
17754
  // src/stream-events.ts
@@ -18224,6 +18263,9 @@ class LettaAgentClient extends LettaAgentClientBase {
18224
18263
  if (this.backend === "local") {
18225
18264
  throw this.localBackendUnavailableError();
18226
18265
  }
18266
+ if (options.backend === "cloud" && options.registerComputer !== undefined) {
18267
+ throw new Error('registerComputer starts a local Letta Code app-server. Import from "@letta-ai/letta-agent-sdk" in Node.js to use it.');
18268
+ }
18227
18269
  }
18228
18270
  }
18229
18271
  export {
@@ -18236,4 +18278,4 @@ export {
18236
18278
  CloudManagedSandboxExpiredError
18237
18279
  };
18238
18280
 
18239
- //# debugId=E1CFC3CF63B8416B64756E2164756E21
18281
+ //# debugId=6F04BC66F4049A5B64756E2164756E21