@letta-ai/letta-agent-sdk 0.8.77 → 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"}
@@ -13518,6 +13518,7 @@ class RemoteTurnCoordinator {
13518
13518
  active.observedTurnEvidence = true;
13519
13519
  if (runId)
13520
13520
  active.runIds.add(runId);
13521
+ this.armTurnTimeout(active);
13521
13522
  }
13522
13523
  const sdkMessage = this.transformStreamDelta(delta);
13523
13524
  if (sdkMessage)
@@ -13583,12 +13584,17 @@ class RemoteTurnCoordinator {
13583
13584
  this.activeTurn = turn;
13584
13585
  turn.startedAt = Date.now();
13585
13586
  this._activeTurnStartedAt = turn.startedAt;
13586
- if (this.requestTimeoutMs !== undefined) {
13587
- turn.timeout = setTimeout(() => {
13588
- this.failTurn(turn, `Timed out waiting for ${this.label} turn`);
13589
- }, this.requestTimeoutMs);
13590
- turn.timeout.unref?.();
13591
- }
13587
+ this.armTurnTimeout(turn);
13588
+ }
13589
+ armTurnTimeout(turn) {
13590
+ if (this.requestTimeoutMs === undefined)
13591
+ return;
13592
+ if (turn.timeout)
13593
+ clearTimeout(turn.timeout);
13594
+ turn.timeout = setTimeout(() => {
13595
+ this.failTurn(turn, `Timed out waiting for ${this.label} turn`);
13596
+ }, this.requestTimeoutMs);
13597
+ turn.timeout.unref?.();
13592
13598
  }
13593
13599
  activateNextTurnFromProtocol() {
13594
13600
  if (this.activeTurn)
@@ -15943,6 +15949,19 @@ function validateCloudClientOptions(options) {
15943
15949
  const field = options.computer !== undefined ? "computer" : "environment";
15944
15950
  throw new Error(`Letta Cloud sessions cannot specify both ${field} and sandbox options.`);
15945
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
+ }
15946
15965
  if (options.webSocketAuth !== undefined && options.webSocketAuth !== "header" && options.webSocketAuth !== "query") {
15947
15966
  throw new Error("Invalid webSocketAuth. Valid values: header, query.");
15948
15967
  }
@@ -16036,6 +16055,7 @@ function assertCloudSessionOptionsSupported(action, options) {
16036
16055
  class CloudEnvironmentSession extends RemoteClientSessionCore {
16037
16056
  cloudOptions;
16038
16057
  apiClient;
16058
+ connectRegisteredComputer;
16039
16059
  sandbox;
16040
16060
  connectionId = null;
16041
16061
  removeExternalToolHandler = null;
@@ -16051,13 +16071,14 @@ class CloudEnvironmentSession extends RemoteClientSessionCore {
16051
16071
  repositoryIdsRequiringCleanupRecompile = new Set;
16052
16072
  repositoryManagement;
16053
16073
  cloudMode;
16054
- constructor(cloudOptions, mode, apiClient = createCloudClient(cloudOptions)) {
16074
+ constructor(cloudOptions, mode, apiClient = createCloudClient(cloudOptions), connectRegisteredComputer) {
16055
16075
  super(mode, {
16056
16076
  label: "cloud",
16057
16077
  requestTimeoutMs: cloudOptions.requestTimeoutMs ?? DEFAULT_TURN_TIMEOUT_MS
16058
16078
  });
16059
16079
  this.cloudOptions = cloudOptions;
16060
16080
  this.apiClient = apiClient;
16081
+ this.connectRegisteredComputer = connectRegisteredComputer;
16061
16082
  this.cloudMode = mode;
16062
16083
  this.repositoryManagement = new CloudManagementTransport(apiClient);
16063
16084
  this.sandbox = this.effectiveEnvironment() === undefined ? {
@@ -16460,6 +16481,8 @@ class CloudEnvironmentSession extends RemoteClientSessionCore {
16460
16481
  return this.createManagedSandboxConnection(runtime);
16461
16482
  }
16462
16483
  async resolveExplicitConnection(environment) {
16484
+ if (this.connectRegisteredComputer)
16485
+ return this.connectRegisteredComputer();
16463
16486
  const target = environmentToRemoteTarget(environment);
16464
16487
  const resolved = await this.remoteEnvironmentClient().resolveEnvironment(target);
16465
16488
  return { connectionId: resolved.connectionId };
@@ -17259,6 +17282,15 @@ function stripCloudExecutionOptions(options) {
17259
17282
  delete sessionOptions.filesystemConfinement;
17260
17283
  return sessionOptions;
17261
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
+ }
17262
17294
  function hasRepositoryResources(options) {
17263
17295
  return options.resources !== undefined && options.resources.length > 0;
17264
17296
  }
@@ -17317,7 +17349,8 @@ class LettaAgentClientBase {
17317
17349
  throw new Error(`Invalid Letta Code backend '${String(backend)}'. Valid values: local, remote, cloud.`);
17318
17350
  }
17319
17351
  this.backend = backend;
17320
- this.computer = getOptionsComputer(options);
17352
+ const registeredName = registeredComputerName(options);
17353
+ this.computer = getOptionsComputer(options) ?? (registeredName !== undefined ? { name: registeredName } : undefined);
17321
17354
  this.environment = this.computer;
17322
17355
  this.options = options;
17323
17356
  this.agents = createAgentsClient(() => this.getManagementTransport(), () => this.getAgentRepositoriesClient());
@@ -17413,12 +17446,12 @@ class LettaAgentClientBase {
17413
17446
  });
17414
17447
  }
17415
17448
  if (this.backend === "cloud") {
17416
- return new CloudEnvironmentSession(this.cloudOptions(), {
17449
+ return this.createCloudSession({
17417
17450
  kind: "session",
17418
17451
  agentId,
17419
17452
  newConversation: true,
17420
17453
  options
17421
- }, this.getCloudClient());
17454
+ });
17422
17455
  }
17423
17456
  return this.createLocalSession(agentId, options);
17424
17457
  }
@@ -17444,19 +17477,7 @@ class LettaAgentClientBase {
17444
17477
  return session2;
17445
17478
  }
17446
17479
  if (this.backend === "cloud") {
17447
- if (looksLikeConversationId(id)) {
17448
- return new CloudEnvironmentSession(this.cloudOptions(), {
17449
- kind: "session",
17450
- conversationId: id,
17451
- options
17452
- }, this.getCloudClient());
17453
- }
17454
- return new CloudEnvironmentSession(this.cloudOptions(), {
17455
- kind: "session",
17456
- agentId: id,
17457
- defaultConversation: true,
17458
- options
17459
- }, this.getCloudClient());
17480
+ return this.createCloudSession(looksLikeConversationId(id) ? { kind: "session", conversationId: id, options } : { kind: "session", agentId: id, defaultConversation: true, options });
17460
17481
  }
17461
17482
  const session = this.resumeLocalSession(id, options);
17462
17483
  if (inherited && session instanceof AppServerSession)
@@ -17522,11 +17543,11 @@ class LettaAgentClientBase {
17522
17543
  if (!conversation || typeof conversation !== "object" || typeof conversation.id !== "string") {
17523
17544
  throw new Error("Cloud query conversation response did not include a conversation id.");
17524
17545
  }
17525
- return new CloudEnvironmentSession(this.cloudOptions(), {
17546
+ return this.createCloudSession({
17526
17547
  kind: "conversation",
17527
17548
  conversationId: conversation.id,
17528
17549
  options: sessionOptions
17529
- }, this.getCloudClient());
17550
+ });
17530
17551
  }
17531
17552
  return this.createLocalQuerySession(options, sessionOptions);
17532
17553
  }
@@ -17591,6 +17612,29 @@ class LettaAgentClientBase {
17591
17612
  }
17592
17613
  throw new Error(`LettaAgentClient backend '${this.backend}' is not implemented yet. ${action} currently supports backend 'local' only.`);
17593
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
+ }
17594
17638
  createLocalAgent(_options) {
17595
17639
  throw this.localBackendUnavailableError();
17596
17640
  }
@@ -17671,8 +17715,8 @@ class LettaAgentClientBase {
17671
17715
  }
17672
17716
  registerTools(options) {
17673
17717
  this.assertOpen();
17674
- if (this.backend === "cloud") {
17675
- 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.'));
17676
17720
  }
17677
17721
  this.toolRegistry ??= new ToolRegistry(this.backend === "remote" ? this.remoteOptions() : this.localAppServerConnection());
17678
17722
  return this.toolRegistry.register(options);
@@ -17703,7 +17747,8 @@ class LettaAgentClientBase {
17703
17747
  if (this.backend !== "cloud") {
17704
17748
  throw new Error('Letta Cloud options requested for non-"cloud" backend.');
17705
17749
  }
17706
- return this.options;
17750
+ const options = this.options;
17751
+ return options.registerComputer !== undefined ? { ...options, computer: { name: options.registerComputer.name } } : options;
17707
17752
  }
17708
17753
  }
17709
17754
  // src/stream-events.ts
@@ -18218,6 +18263,9 @@ class LettaAgentClient extends LettaAgentClientBase {
18218
18263
  if (this.backend === "local") {
18219
18264
  throw this.localBackendUnavailableError();
18220
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
+ }
18221
18269
  }
18222
18270
  }
18223
18271
  export {
@@ -18230,4 +18278,4 @@ export {
18230
18278
  CloudManagedSandboxExpiredError
18231
18279
  };
18232
18280
 
18233
- //# debugId=214DC938EA1FA61564756E2164756E21
18281
+ //# debugId=6F04BC66F4049A5B64756E2164756E21