@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.
- package/dist/client-base.d.ts +14 -2
- package/dist/client-base.d.ts.map +1 -1
- package/dist/client-entry.d.ts.map +1 -1
- package/dist/client-entry.js +77 -29
- package/dist/client-entry.js.map +6 -6
- package/dist/client.d.ts +1 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/cloud-session.d.ts +8 -1
- package/dist/cloud-session.d.ts.map +1 -1
- package/dist/index.js +103 -33
- package/dist/index.js.map +8 -8
- package/dist/local-app-server.d.ts +3 -1
- package/dist/local-app-server.d.ts.map +1 -1
- package/dist/remote-turn-coordinator.d.ts +2 -0
- package/dist/remote-turn-coordinator.d.ts.map +1 -1
- package/dist/types.d.ts +12 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/client-base.ts +90 -45
- package/src/client-entry.ts +5 -0
- package/src/client.ts +45 -4
- package/src/cloud-session.ts +20 -0
- package/src/local-app-server.ts +9 -1
- package/src/remote-turn-coordinator.ts +14 -6
- package/src/types.ts +10 -3
package/dist/client.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare class LettaAgentClient extends LettaAgentClientBase {
|
|
|
8
8
|
private localClosePromise;
|
|
9
9
|
private sharedLocalServer;
|
|
10
10
|
close(): Promise<void>;
|
|
11
|
+
protected startRegisteredComputer(): Promise<void>;
|
|
11
12
|
protected skillNodeSupport(): SkillNodeSupport;
|
|
12
13
|
protected createLocalManagementTransport(): ManagementTransport;
|
|
13
14
|
protected localAppServerConnection(): {
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAG3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,KAAK,EACV,kBAAkB,EAElB,6BAA6B,EAE7B,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,qBAAa,gBAAiB,SAAQ,oBAAoB;IACxD,OAAO,CAAC,WAAW,CAAqC;IACxD,OAAO,CAAC,iBAAiB,CAA8B;IAEvD,OAAO,CAAC,iBAAiB;IAehB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;cAUN,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;cAI9C,gBAAgB,IAAI,gBAAgB;cAIpC,8BAA8B,IAAI,mBAAmB;cAIrD,wBAAwB;;;;;;;;;cAyBlB,gBAAgB,CACvC,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,MAAM,CAAC;cAqBC,kBAAkB,CACnC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,6BAA6B,GACrC,gBAAgB;cAcA,uBAAuB,CACxC,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,6BAA6B,GAC5C,gBAAgB;cAgCA,kBAAkB,CACnC,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,6BAA6B,GACrC,gBAAgB;CAwBpB"}
|
package/dist/cloud-session.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ import { type SkillFilesPusher } from "./skill-loading.js";
|
|
|
3
3
|
import { RemoteClientSessionCore, type RuntimeScope, type RuntimeSessionInit, type RuntimeSessionMode } from "./remote-client-session-core.js";
|
|
4
4
|
import type { CreateAgentOptions, LettaCodeClientSessionOptions, LettaCodeCloudClientOptions } from "./types.js";
|
|
5
5
|
import { type SandboxFilesClient } from "./sandbox-files.js";
|
|
6
|
+
type ResolvedCloudConnection = {
|
|
7
|
+
connectionId: string;
|
|
8
|
+
};
|
|
6
9
|
/**
|
|
7
10
|
* The Cloud API reaped a conversation-scoped managed sandbox before the SDK
|
|
8
11
|
* could refresh it. The failed refresh happens before the next turn is sent,
|
|
@@ -26,6 +29,8 @@ export declare function assertCloudSessionOptionsSupported(action: string, optio
|
|
|
26
29
|
export declare class CloudEnvironmentSession extends RemoteClientSessionCore {
|
|
27
30
|
private readonly cloudOptions;
|
|
28
31
|
private readonly apiClient;
|
|
32
|
+
/** Starts and resolves the computer this client registers, when the session runs there. */
|
|
33
|
+
private readonly connectRegisteredComputer?;
|
|
29
34
|
readonly sandbox: SandboxFilesClient | undefined;
|
|
30
35
|
private connectionId;
|
|
31
36
|
private removeExternalToolHandler;
|
|
@@ -41,7 +46,9 @@ export declare class CloudEnvironmentSession extends RemoteClientSessionCore {
|
|
|
41
46
|
private repositoryIdsRequiringCleanupRecompile;
|
|
42
47
|
private readonly repositoryManagement;
|
|
43
48
|
private readonly cloudMode;
|
|
44
|
-
constructor(cloudOptions: LettaCodeCloudClientOptions, mode: CloudSessionMode, apiClient?: Letta
|
|
49
|
+
constructor(cloudOptions: LettaCodeCloudClientOptions, mode: CloudSessionMode, apiClient?: Letta,
|
|
50
|
+
/** Starts and resolves the computer this client registers, when the session runs there. */
|
|
51
|
+
connectRegisteredComputer?: (() => Promise<ResolvedCloudConnection>) | undefined);
|
|
45
52
|
protected initializeRuntimeController(): Promise<RuntimeSessionInit>;
|
|
46
53
|
private openCloudTransport;
|
|
47
54
|
private createCloudTransportClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloud-session.d.ts","sourceRoot":"","sources":["../src/cloud-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,wBAAwB,CAAC;AAQhD,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAyB5B,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,OAAO,CAAC,wBAAwB;IAchC,OAAO,CAAC,wBAAwB;cAOP,oBAAoB,CAC3C,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,kBAAkB,CAAC;YAMhB,yBAAyB;cAepB,yBAAyB,IAAI,IAAI;cAIjC,6BAA6B,IAAI,IAAI;YAI1C,iBAAiB;cAwCN,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;cAUxC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;YAMtC,2BAA2B;YAO3B,8BAA8B;YAK9B,oCAAoC;cAa/B,WAAW,IAAI,IAAI;cAYb,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxD,OAAO,CAAC,cAAc;YAOR,cAAc;YA0Dd,yBAAyB;YA6CzB,0BAA0B;YAgC1B,qBAAqB;IAenC,OAAO,CAAC,mBAAmB;YAkBb,sBAAsB;YActB,kBAAkB;YAUlB,oBAAoB;YAUpB,2BAA2B;YAc3B,yBAAyB;YASzB,8BAA8B;YAsC9B,oBAAoB;YA2DpB,qBAAqB;YAcrB,yBAAyB;YA4CzB,uBAAuB;YA4BvB,+BAA+B;IA4B7C,OAAO,CAAC,0BAA0B;IAelC,OAAO,CAAC,yBAAyB;YAMnB,qBAAqB;IAuBnC,OAAO,CAAC,uBAAuB;IAI/B,OAAO,CAAC,oBAAoB;IAS5B,OAAO,CAAC,uBAAuB;IAO/B,OAAO,CAAC,sBAAsB;CAG/B"}
|
package/dist/index.js
CHANGED
|
@@ -13576,6 +13576,7 @@ class RemoteTurnCoordinator {
|
|
|
13576
13576
|
active.observedTurnEvidence = true;
|
|
13577
13577
|
if (runId)
|
|
13578
13578
|
active.runIds.add(runId);
|
|
13579
|
+
this.armTurnTimeout(active);
|
|
13579
13580
|
}
|
|
13580
13581
|
const sdkMessage = this.transformStreamDelta(delta);
|
|
13581
13582
|
if (sdkMessage)
|
|
@@ -13641,12 +13642,17 @@ class RemoteTurnCoordinator {
|
|
|
13641
13642
|
this.activeTurn = turn;
|
|
13642
13643
|
turn.startedAt = Date.now();
|
|
13643
13644
|
this._activeTurnStartedAt = turn.startedAt;
|
|
13644
|
-
|
|
13645
|
-
|
|
13646
|
-
|
|
13647
|
-
|
|
13648
|
-
|
|
13649
|
-
|
|
13645
|
+
this.armTurnTimeout(turn);
|
|
13646
|
+
}
|
|
13647
|
+
armTurnTimeout(turn) {
|
|
13648
|
+
if (this.requestTimeoutMs === undefined)
|
|
13649
|
+
return;
|
|
13650
|
+
if (turn.timeout)
|
|
13651
|
+
clearTimeout(turn.timeout);
|
|
13652
|
+
turn.timeout = setTimeout(() => {
|
|
13653
|
+
this.failTurn(turn, `Timed out waiting for ${this.label} turn`);
|
|
13654
|
+
}, this.requestTimeoutMs);
|
|
13655
|
+
turn.timeout.unref?.();
|
|
13650
13656
|
}
|
|
13651
13657
|
activateNextTurnFromProtocol() {
|
|
13652
13658
|
if (this.activeTurn)
|
|
@@ -16001,6 +16007,19 @@ function validateCloudClientOptions(options) {
|
|
|
16001
16007
|
const field = options.computer !== undefined ? "computer" : "environment";
|
|
16002
16008
|
throw new Error(`Letta Cloud sessions cannot specify both ${field} and sandbox options.`);
|
|
16003
16009
|
}
|
|
16010
|
+
if (options.registerComputer !== undefined) {
|
|
16011
|
+
const name = options.registerComputer?.name;
|
|
16012
|
+
if (typeof name !== "string" || !name.trim()) {
|
|
16013
|
+
throw new Error("Invalid registerComputer.name. Expected a non-empty string.");
|
|
16014
|
+
}
|
|
16015
|
+
if (options.computer !== undefined || options.environment !== undefined) {
|
|
16016
|
+
const field = options.computer !== undefined ? "computer" : "environment";
|
|
16017
|
+
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.`);
|
|
16018
|
+
}
|
|
16019
|
+
if (options.sandbox !== undefined) {
|
|
16020
|
+
throw new Error("Letta Cloud clients cannot specify both registerComputer and sandbox options.");
|
|
16021
|
+
}
|
|
16022
|
+
}
|
|
16004
16023
|
if (options.webSocketAuth !== undefined && options.webSocketAuth !== "header" && options.webSocketAuth !== "query") {
|
|
16005
16024
|
throw new Error("Invalid webSocketAuth. Valid values: header, query.");
|
|
16006
16025
|
}
|
|
@@ -16094,6 +16113,7 @@ function assertCloudSessionOptionsSupported(action, options) {
|
|
|
16094
16113
|
class CloudEnvironmentSession extends RemoteClientSessionCore {
|
|
16095
16114
|
cloudOptions;
|
|
16096
16115
|
apiClient;
|
|
16116
|
+
connectRegisteredComputer;
|
|
16097
16117
|
sandbox;
|
|
16098
16118
|
connectionId = null;
|
|
16099
16119
|
removeExternalToolHandler = null;
|
|
@@ -16109,13 +16129,14 @@ class CloudEnvironmentSession extends RemoteClientSessionCore {
|
|
|
16109
16129
|
repositoryIdsRequiringCleanupRecompile = new Set;
|
|
16110
16130
|
repositoryManagement;
|
|
16111
16131
|
cloudMode;
|
|
16112
|
-
constructor(cloudOptions, mode, apiClient = createCloudClient(cloudOptions)) {
|
|
16132
|
+
constructor(cloudOptions, mode, apiClient = createCloudClient(cloudOptions), connectRegisteredComputer) {
|
|
16113
16133
|
super(mode, {
|
|
16114
16134
|
label: "cloud",
|
|
16115
16135
|
requestTimeoutMs: cloudOptions.requestTimeoutMs ?? DEFAULT_TURN_TIMEOUT_MS
|
|
16116
16136
|
});
|
|
16117
16137
|
this.cloudOptions = cloudOptions;
|
|
16118
16138
|
this.apiClient = apiClient;
|
|
16139
|
+
this.connectRegisteredComputer = connectRegisteredComputer;
|
|
16119
16140
|
this.cloudMode = mode;
|
|
16120
16141
|
this.repositoryManagement = new CloudManagementTransport(apiClient);
|
|
16121
16142
|
this.sandbox = this.effectiveEnvironment() === undefined ? {
|
|
@@ -16518,6 +16539,8 @@ class CloudEnvironmentSession extends RemoteClientSessionCore {
|
|
|
16518
16539
|
return this.createManagedSandboxConnection(runtime);
|
|
16519
16540
|
}
|
|
16520
16541
|
async resolveExplicitConnection(environment) {
|
|
16542
|
+
if (this.connectRegisteredComputer)
|
|
16543
|
+
return this.connectRegisteredComputer();
|
|
16521
16544
|
const target = environmentToRemoteTarget(environment);
|
|
16522
16545
|
const resolved = await this.remoteEnvironmentClient().resolveEnvironment(target);
|
|
16523
16546
|
return { connectionId: resolved.connectionId };
|
|
@@ -17317,6 +17340,15 @@ function stripCloudExecutionOptions(options) {
|
|
|
17317
17340
|
delete sessionOptions.filesystemConfinement;
|
|
17318
17341
|
return sessionOptions;
|
|
17319
17342
|
}
|
|
17343
|
+
var REGISTERED_COMPUTER_READY_TIMEOUT_MS = 30000;
|
|
17344
|
+
var REGISTERED_COMPUTER_POLL_INTERVAL_MS = 500;
|
|
17345
|
+
function registeredComputerName(options) {
|
|
17346
|
+
return options.backend === "cloud" ? options.registerComputer?.name : undefined;
|
|
17347
|
+
}
|
|
17348
|
+
function isRegisteredComputerPending(error) {
|
|
17349
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
17350
|
+
return message.startsWith("Computer not found") || message.startsWith("Computer is offline");
|
|
17351
|
+
}
|
|
17320
17352
|
function hasRepositoryResources(options) {
|
|
17321
17353
|
return options.resources !== undefined && options.resources.length > 0;
|
|
17322
17354
|
}
|
|
@@ -17375,7 +17407,8 @@ class LettaAgentClientBase {
|
|
|
17375
17407
|
throw new Error(`Invalid Letta Code backend '${String(backend)}'. Valid values: local, remote, cloud.`);
|
|
17376
17408
|
}
|
|
17377
17409
|
this.backend = backend;
|
|
17378
|
-
|
|
17410
|
+
const registeredName = registeredComputerName(options);
|
|
17411
|
+
this.computer = getOptionsComputer(options) ?? (registeredName !== undefined ? { name: registeredName } : undefined);
|
|
17379
17412
|
this.environment = this.computer;
|
|
17380
17413
|
this.options = options;
|
|
17381
17414
|
this.agents = createAgentsClient(() => this.getManagementTransport(), () => this.getAgentRepositoriesClient());
|
|
@@ -17471,12 +17504,12 @@ class LettaAgentClientBase {
|
|
|
17471
17504
|
});
|
|
17472
17505
|
}
|
|
17473
17506
|
if (this.backend === "cloud") {
|
|
17474
|
-
return
|
|
17507
|
+
return this.createCloudSession({
|
|
17475
17508
|
kind: "session",
|
|
17476
17509
|
agentId,
|
|
17477
17510
|
newConversation: true,
|
|
17478
17511
|
options
|
|
17479
|
-
}
|
|
17512
|
+
});
|
|
17480
17513
|
}
|
|
17481
17514
|
return this.createLocalSession(agentId, options);
|
|
17482
17515
|
}
|
|
@@ -17502,19 +17535,7 @@ class LettaAgentClientBase {
|
|
|
17502
17535
|
return session2;
|
|
17503
17536
|
}
|
|
17504
17537
|
if (this.backend === "cloud") {
|
|
17505
|
-
|
|
17506
|
-
return new CloudEnvironmentSession(this.cloudOptions(), {
|
|
17507
|
-
kind: "session",
|
|
17508
|
-
conversationId: id,
|
|
17509
|
-
options
|
|
17510
|
-
}, this.getCloudClient());
|
|
17511
|
-
}
|
|
17512
|
-
return new CloudEnvironmentSession(this.cloudOptions(), {
|
|
17513
|
-
kind: "session",
|
|
17514
|
-
agentId: id,
|
|
17515
|
-
defaultConversation: true,
|
|
17516
|
-
options
|
|
17517
|
-
}, this.getCloudClient());
|
|
17538
|
+
return this.createCloudSession(looksLikeConversationId(id) ? { kind: "session", conversationId: id, options } : { kind: "session", agentId: id, defaultConversation: true, options });
|
|
17518
17539
|
}
|
|
17519
17540
|
const session = this.resumeLocalSession(id, options);
|
|
17520
17541
|
if (inherited && session instanceof AppServerSession)
|
|
@@ -17580,11 +17601,11 @@ class LettaAgentClientBase {
|
|
|
17580
17601
|
if (!conversation || typeof conversation !== "object" || typeof conversation.id !== "string") {
|
|
17581
17602
|
throw new Error("Cloud query conversation response did not include a conversation id.");
|
|
17582
17603
|
}
|
|
17583
|
-
return
|
|
17604
|
+
return this.createCloudSession({
|
|
17584
17605
|
kind: "conversation",
|
|
17585
17606
|
conversationId: conversation.id,
|
|
17586
17607
|
options: sessionOptions
|
|
17587
|
-
}
|
|
17608
|
+
});
|
|
17588
17609
|
}
|
|
17589
17610
|
return this.createLocalQuerySession(options, sessionOptions);
|
|
17590
17611
|
}
|
|
@@ -17649,6 +17670,29 @@ class LettaAgentClientBase {
|
|
|
17649
17670
|
}
|
|
17650
17671
|
throw new Error(`LettaAgentClient backend '${this.backend}' is not implemented yet. ${action} currently supports backend 'local' only.`);
|
|
17651
17672
|
}
|
|
17673
|
+
createCloudSession(mode) {
|
|
17674
|
+
const name = registeredComputerName(this.options);
|
|
17675
|
+
const sessionComputer = mode.options.computer ?? mode.options.environment;
|
|
17676
|
+
return new CloudEnvironmentSession(this.cloudOptions(), mode, this.getCloudClient(), name !== undefined && sessionComputer === undefined ? () => this.connectRegisteredComputer(name) : undefined);
|
|
17677
|
+
}
|
|
17678
|
+
async connectRegisteredComputer(name) {
|
|
17679
|
+
await this.startRegisteredComputer();
|
|
17680
|
+
const deadline = Date.now() + REGISTERED_COMPUTER_READY_TIMEOUT_MS;
|
|
17681
|
+
while (true) {
|
|
17682
|
+
try {
|
|
17683
|
+
const resolved = await this.getComputersClient().resolve({ name });
|
|
17684
|
+
return { connectionId: resolved.connectionId };
|
|
17685
|
+
} catch (error) {
|
|
17686
|
+
if (!isRegisteredComputerPending(error) || Date.now() >= deadline) {
|
|
17687
|
+
throw error;
|
|
17688
|
+
}
|
|
17689
|
+
await new Promise((resolve) => setTimeout(resolve, REGISTERED_COMPUTER_POLL_INTERVAL_MS));
|
|
17690
|
+
}
|
|
17691
|
+
}
|
|
17692
|
+
}
|
|
17693
|
+
startRegisteredComputer() {
|
|
17694
|
+
return Promise.reject(this.localBackendUnavailableError());
|
|
17695
|
+
}
|
|
17652
17696
|
createLocalAgent(_options) {
|
|
17653
17697
|
throw this.localBackendUnavailableError();
|
|
17654
17698
|
}
|
|
@@ -17729,8 +17773,8 @@ class LettaAgentClientBase {
|
|
|
17729
17773
|
}
|
|
17730
17774
|
registerTools(options) {
|
|
17731
17775
|
this.assertOpen();
|
|
17732
|
-
if (this.backend === "cloud") {
|
|
17733
|
-
return Promise.reject(new Error('registerTools() requires backend: "local" or "remote". Cloud sessions register tools through the tools session option.'));
|
|
17776
|
+
if (this.backend === "cloud" && registeredComputerName(this.options) === undefined) {
|
|
17777
|
+
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.'));
|
|
17734
17778
|
}
|
|
17735
17779
|
this.toolRegistry ??= new ToolRegistry(this.backend === "remote" ? this.remoteOptions() : this.localAppServerConnection());
|
|
17736
17780
|
return this.toolRegistry.register(options);
|
|
@@ -17761,7 +17805,8 @@ class LettaAgentClientBase {
|
|
|
17761
17805
|
if (this.backend !== "cloud") {
|
|
17762
17806
|
throw new Error('Letta Cloud options requested for non-"cloud" backend.');
|
|
17763
17807
|
}
|
|
17764
|
-
|
|
17808
|
+
const options = this.options;
|
|
17809
|
+
return options.registerComputer !== undefined ? { ...options, computer: { name: options.registerComputer.name } } : options;
|
|
17765
17810
|
}
|
|
17766
17811
|
}
|
|
17767
17812
|
|
|
@@ -18243,7 +18288,8 @@ function buildLocalAppServerArgs(cliPath, options = {}) {
|
|
|
18243
18288
|
...options.backend !== undefined ? ["--backend", options.backend] : [],
|
|
18244
18289
|
"server",
|
|
18245
18290
|
"--listen",
|
|
18246
|
-
options.listen ?? DEFAULT_LISTEN_URL
|
|
18291
|
+
options.listen ?? DEFAULT_LISTEN_URL,
|
|
18292
|
+
...options.computerName !== undefined ? ["--computer-name", options.computerName] : []
|
|
18247
18293
|
];
|
|
18248
18294
|
}
|
|
18249
18295
|
function buildLocalAppServerProcess(cliPath, options = {}, confineMemory = createMemoryConfinementLauncher) {
|
|
@@ -18510,6 +18556,9 @@ class LettaAgentClient extends LettaAgentClientBase {
|
|
|
18510
18556
|
sharedLocalServer() {
|
|
18511
18557
|
if (this.localClosePromise)
|
|
18512
18558
|
throw new Error("LettaAgentClient is closed");
|
|
18559
|
+
if (this.backend === "cloud") {
|
|
18560
|
+
return this.localServer ??= registeredComputerServer(this.options);
|
|
18561
|
+
}
|
|
18513
18562
|
const options = this.options.appServer;
|
|
18514
18563
|
return this.localServer ??= new SharedLocalAppServer({
|
|
18515
18564
|
listen: options?.listen,
|
|
@@ -18526,6 +18575,9 @@ class LettaAgentClient extends LettaAgentClientBase {
|
|
|
18526
18575
|
}
|
|
18527
18576
|
return this.localClosePromise;
|
|
18528
18577
|
}
|
|
18578
|
+
async startRegisteredComputer() {
|
|
18579
|
+
await this.sharedLocalServer().connect();
|
|
18580
|
+
}
|
|
18529
18581
|
skillNodeSupport() {
|
|
18530
18582
|
return { loadSkillDirectory, pushSkillSupportFiles };
|
|
18531
18583
|
}
|
|
@@ -18533,10 +18585,13 @@ class LettaAgentClient extends LettaAgentClientBase {
|
|
|
18533
18585
|
return new AppServerManagementTransport(this.localAppServerConnection());
|
|
18534
18586
|
}
|
|
18535
18587
|
localAppServerConnection() {
|
|
18536
|
-
const localOptions = this.
|
|
18588
|
+
const localOptions = this.backend === "cloud" ? {
|
|
18589
|
+
WebSocket: this.options.WebSocket,
|
|
18590
|
+
requestTimeoutMs: this.options.requestTimeoutMs
|
|
18591
|
+
} : this.options.appServer;
|
|
18537
18592
|
const sharedServer = this.sharedLocalServer();
|
|
18538
18593
|
return {
|
|
18539
|
-
...localOptions
|
|
18594
|
+
...localOptions !== undefined && "url" in localOptions && localOptions.url !== undefined ? { url: localOptions.url } : {
|
|
18540
18595
|
connect: () => sharedServer.connect()
|
|
18541
18596
|
},
|
|
18542
18597
|
...localOptions?.WebSocket !== undefined ? { WebSocket: localOptions.WebSocket } : {},
|
|
@@ -18604,6 +18659,21 @@ class LettaAgentClient extends LettaAgentClientBase {
|
|
|
18604
18659
|
}, this.sharedLocalServer());
|
|
18605
18660
|
}
|
|
18606
18661
|
}
|
|
18662
|
+
function registeredComputerServer(options) {
|
|
18663
|
+
const name = options.registerComputer?.name;
|
|
18664
|
+
if (name === undefined) {
|
|
18665
|
+
throw new Error('A local app-server is only available with backend: "local" or registerComputer.');
|
|
18666
|
+
}
|
|
18667
|
+
const apiKey = getCloudApiKey(options);
|
|
18668
|
+
return new SharedLocalAppServer({
|
|
18669
|
+
backend: "api",
|
|
18670
|
+
computerName: name,
|
|
18671
|
+
env: {
|
|
18672
|
+
...apiKey !== undefined ? { LETTA_API_KEY: apiKey } : {},
|
|
18673
|
+
...options.apiBaseUrl !== undefined ? { LETTA_BASE_URL: options.apiBaseUrl } : {}
|
|
18674
|
+
}
|
|
18675
|
+
});
|
|
18676
|
+
}
|
|
18607
18677
|
function looksLikeConversationId2(id) {
|
|
18608
18678
|
return id.startsWith("conv-") || id.startsWith("local-conv-");
|
|
18609
18679
|
}
|
|
@@ -35393,7 +35463,7 @@ class StreamableHTTPClientTransport {
|
|
|
35393
35463
|
}
|
|
35394
35464
|
var DEFAULT_CLIENT_INFO = {
|
|
35395
35465
|
name: "letta-code",
|
|
35396
|
-
version: "0.34.
|
|
35466
|
+
version: "0.34.49"
|
|
35397
35467
|
};
|
|
35398
35468
|
async function connectMcpServer(config2, options = {}) {
|
|
35399
35469
|
let client = new Client(options.clientInfo ?? DEFAULT_CLIENT_INFO);
|
|
@@ -36421,4 +36491,4 @@ export {
|
|
|
36421
36491
|
CloudManagedSandboxExpiredError
|
|
36422
36492
|
};
|
|
36423
36493
|
|
|
36424
|
-
//# debugId=
|
|
36494
|
+
//# debugId=AFB0BEDEFE911CAD64756E2164756E21
|