@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.
- 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 +65 -23
- package/dist/client-entry.js.map +5 -5
- 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 +90 -26
- package/dist/index.js.map +6 -6
- package/dist/local-app-server.d.ts +3 -1
- package/dist/local-app-server.d.ts.map +1 -1
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- 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/types.ts +7 -0
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,OAAO,EACL,uBAAuB,EAGvB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACxB,MAAM,iCAA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AO,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
|
@@ -16007,6 +16007,19 @@ function validateCloudClientOptions(options) {
|
|
|
16007
16007
|
const field = options.computer !== undefined ? "computer" : "environment";
|
|
16008
16008
|
throw new Error(`Letta Cloud sessions cannot specify both ${field} and sandbox options.`);
|
|
16009
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
|
+
}
|
|
16010
16023
|
if (options.webSocketAuth !== undefined && options.webSocketAuth !== "header" && options.webSocketAuth !== "query") {
|
|
16011
16024
|
throw new Error("Invalid webSocketAuth. Valid values: header, query.");
|
|
16012
16025
|
}
|
|
@@ -16100,6 +16113,7 @@ function assertCloudSessionOptionsSupported(action, options) {
|
|
|
16100
16113
|
class CloudEnvironmentSession extends RemoteClientSessionCore {
|
|
16101
16114
|
cloudOptions;
|
|
16102
16115
|
apiClient;
|
|
16116
|
+
connectRegisteredComputer;
|
|
16103
16117
|
sandbox;
|
|
16104
16118
|
connectionId = null;
|
|
16105
16119
|
removeExternalToolHandler = null;
|
|
@@ -16115,13 +16129,14 @@ class CloudEnvironmentSession extends RemoteClientSessionCore {
|
|
|
16115
16129
|
repositoryIdsRequiringCleanupRecompile = new Set;
|
|
16116
16130
|
repositoryManagement;
|
|
16117
16131
|
cloudMode;
|
|
16118
|
-
constructor(cloudOptions, mode, apiClient = createCloudClient(cloudOptions)) {
|
|
16132
|
+
constructor(cloudOptions, mode, apiClient = createCloudClient(cloudOptions), connectRegisteredComputer) {
|
|
16119
16133
|
super(mode, {
|
|
16120
16134
|
label: "cloud",
|
|
16121
16135
|
requestTimeoutMs: cloudOptions.requestTimeoutMs ?? DEFAULT_TURN_TIMEOUT_MS
|
|
16122
16136
|
});
|
|
16123
16137
|
this.cloudOptions = cloudOptions;
|
|
16124
16138
|
this.apiClient = apiClient;
|
|
16139
|
+
this.connectRegisteredComputer = connectRegisteredComputer;
|
|
16125
16140
|
this.cloudMode = mode;
|
|
16126
16141
|
this.repositoryManagement = new CloudManagementTransport(apiClient);
|
|
16127
16142
|
this.sandbox = this.effectiveEnvironment() === undefined ? {
|
|
@@ -16524,6 +16539,8 @@ class CloudEnvironmentSession extends RemoteClientSessionCore {
|
|
|
16524
16539
|
return this.createManagedSandboxConnection(runtime);
|
|
16525
16540
|
}
|
|
16526
16541
|
async resolveExplicitConnection(environment) {
|
|
16542
|
+
if (this.connectRegisteredComputer)
|
|
16543
|
+
return this.connectRegisteredComputer();
|
|
16527
16544
|
const target = environmentToRemoteTarget(environment);
|
|
16528
16545
|
const resolved = await this.remoteEnvironmentClient().resolveEnvironment(target);
|
|
16529
16546
|
return { connectionId: resolved.connectionId };
|
|
@@ -17323,6 +17340,15 @@ function stripCloudExecutionOptions(options) {
|
|
|
17323
17340
|
delete sessionOptions.filesystemConfinement;
|
|
17324
17341
|
return sessionOptions;
|
|
17325
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
|
+
}
|
|
17326
17352
|
function hasRepositoryResources(options) {
|
|
17327
17353
|
return options.resources !== undefined && options.resources.length > 0;
|
|
17328
17354
|
}
|
|
@@ -17381,7 +17407,8 @@ class LettaAgentClientBase {
|
|
|
17381
17407
|
throw new Error(`Invalid Letta Code backend '${String(backend)}'. Valid values: local, remote, cloud.`);
|
|
17382
17408
|
}
|
|
17383
17409
|
this.backend = backend;
|
|
17384
|
-
|
|
17410
|
+
const registeredName = registeredComputerName(options);
|
|
17411
|
+
this.computer = getOptionsComputer(options) ?? (registeredName !== undefined ? { name: registeredName } : undefined);
|
|
17385
17412
|
this.environment = this.computer;
|
|
17386
17413
|
this.options = options;
|
|
17387
17414
|
this.agents = createAgentsClient(() => this.getManagementTransport(), () => this.getAgentRepositoriesClient());
|
|
@@ -17477,12 +17504,12 @@ class LettaAgentClientBase {
|
|
|
17477
17504
|
});
|
|
17478
17505
|
}
|
|
17479
17506
|
if (this.backend === "cloud") {
|
|
17480
|
-
return
|
|
17507
|
+
return this.createCloudSession({
|
|
17481
17508
|
kind: "session",
|
|
17482
17509
|
agentId,
|
|
17483
17510
|
newConversation: true,
|
|
17484
17511
|
options
|
|
17485
|
-
}
|
|
17512
|
+
});
|
|
17486
17513
|
}
|
|
17487
17514
|
return this.createLocalSession(agentId, options);
|
|
17488
17515
|
}
|
|
@@ -17508,19 +17535,7 @@ class LettaAgentClientBase {
|
|
|
17508
17535
|
return session2;
|
|
17509
17536
|
}
|
|
17510
17537
|
if (this.backend === "cloud") {
|
|
17511
|
-
|
|
17512
|
-
return new CloudEnvironmentSession(this.cloudOptions(), {
|
|
17513
|
-
kind: "session",
|
|
17514
|
-
conversationId: id,
|
|
17515
|
-
options
|
|
17516
|
-
}, this.getCloudClient());
|
|
17517
|
-
}
|
|
17518
|
-
return new CloudEnvironmentSession(this.cloudOptions(), {
|
|
17519
|
-
kind: "session",
|
|
17520
|
-
agentId: id,
|
|
17521
|
-
defaultConversation: true,
|
|
17522
|
-
options
|
|
17523
|
-
}, this.getCloudClient());
|
|
17538
|
+
return this.createCloudSession(looksLikeConversationId(id) ? { kind: "session", conversationId: id, options } : { kind: "session", agentId: id, defaultConversation: true, options });
|
|
17524
17539
|
}
|
|
17525
17540
|
const session = this.resumeLocalSession(id, options);
|
|
17526
17541
|
if (inherited && session instanceof AppServerSession)
|
|
@@ -17586,11 +17601,11 @@ class LettaAgentClientBase {
|
|
|
17586
17601
|
if (!conversation || typeof conversation !== "object" || typeof conversation.id !== "string") {
|
|
17587
17602
|
throw new Error("Cloud query conversation response did not include a conversation id.");
|
|
17588
17603
|
}
|
|
17589
|
-
return
|
|
17604
|
+
return this.createCloudSession({
|
|
17590
17605
|
kind: "conversation",
|
|
17591
17606
|
conversationId: conversation.id,
|
|
17592
17607
|
options: sessionOptions
|
|
17593
|
-
}
|
|
17608
|
+
});
|
|
17594
17609
|
}
|
|
17595
17610
|
return this.createLocalQuerySession(options, sessionOptions);
|
|
17596
17611
|
}
|
|
@@ -17655,6 +17670,29 @@ class LettaAgentClientBase {
|
|
|
17655
17670
|
}
|
|
17656
17671
|
throw new Error(`LettaAgentClient backend '${this.backend}' is not implemented yet. ${action} currently supports backend 'local' only.`);
|
|
17657
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
|
+
}
|
|
17658
17696
|
createLocalAgent(_options) {
|
|
17659
17697
|
throw this.localBackendUnavailableError();
|
|
17660
17698
|
}
|
|
@@ -17735,8 +17773,8 @@ class LettaAgentClientBase {
|
|
|
17735
17773
|
}
|
|
17736
17774
|
registerTools(options) {
|
|
17737
17775
|
this.assertOpen();
|
|
17738
|
-
if (this.backend === "cloud") {
|
|
17739
|
-
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.'));
|
|
17740
17778
|
}
|
|
17741
17779
|
this.toolRegistry ??= new ToolRegistry(this.backend === "remote" ? this.remoteOptions() : this.localAppServerConnection());
|
|
17742
17780
|
return this.toolRegistry.register(options);
|
|
@@ -17767,7 +17805,8 @@ class LettaAgentClientBase {
|
|
|
17767
17805
|
if (this.backend !== "cloud") {
|
|
17768
17806
|
throw new Error('Letta Cloud options requested for non-"cloud" backend.');
|
|
17769
17807
|
}
|
|
17770
|
-
|
|
17808
|
+
const options = this.options;
|
|
17809
|
+
return options.registerComputer !== undefined ? { ...options, computer: { name: options.registerComputer.name } } : options;
|
|
17771
17810
|
}
|
|
17772
17811
|
}
|
|
17773
17812
|
|
|
@@ -18249,7 +18288,8 @@ function buildLocalAppServerArgs(cliPath, options = {}) {
|
|
|
18249
18288
|
...options.backend !== undefined ? ["--backend", options.backend] : [],
|
|
18250
18289
|
"server",
|
|
18251
18290
|
"--listen",
|
|
18252
|
-
options.listen ?? DEFAULT_LISTEN_URL
|
|
18291
|
+
options.listen ?? DEFAULT_LISTEN_URL,
|
|
18292
|
+
...options.computerName !== undefined ? ["--computer-name", options.computerName] : []
|
|
18253
18293
|
];
|
|
18254
18294
|
}
|
|
18255
18295
|
function buildLocalAppServerProcess(cliPath, options = {}, confineMemory = createMemoryConfinementLauncher) {
|
|
@@ -18516,6 +18556,9 @@ class LettaAgentClient extends LettaAgentClientBase {
|
|
|
18516
18556
|
sharedLocalServer() {
|
|
18517
18557
|
if (this.localClosePromise)
|
|
18518
18558
|
throw new Error("LettaAgentClient is closed");
|
|
18559
|
+
if (this.backend === "cloud") {
|
|
18560
|
+
return this.localServer ??= registeredComputerServer(this.options);
|
|
18561
|
+
}
|
|
18519
18562
|
const options = this.options.appServer;
|
|
18520
18563
|
return this.localServer ??= new SharedLocalAppServer({
|
|
18521
18564
|
listen: options?.listen,
|
|
@@ -18532,6 +18575,9 @@ class LettaAgentClient extends LettaAgentClientBase {
|
|
|
18532
18575
|
}
|
|
18533
18576
|
return this.localClosePromise;
|
|
18534
18577
|
}
|
|
18578
|
+
async startRegisteredComputer() {
|
|
18579
|
+
await this.sharedLocalServer().connect();
|
|
18580
|
+
}
|
|
18535
18581
|
skillNodeSupport() {
|
|
18536
18582
|
return { loadSkillDirectory, pushSkillSupportFiles };
|
|
18537
18583
|
}
|
|
@@ -18539,10 +18585,13 @@ class LettaAgentClient extends LettaAgentClientBase {
|
|
|
18539
18585
|
return new AppServerManagementTransport(this.localAppServerConnection());
|
|
18540
18586
|
}
|
|
18541
18587
|
localAppServerConnection() {
|
|
18542
|
-
const localOptions = this.
|
|
18588
|
+
const localOptions = this.backend === "cloud" ? {
|
|
18589
|
+
WebSocket: this.options.WebSocket,
|
|
18590
|
+
requestTimeoutMs: this.options.requestTimeoutMs
|
|
18591
|
+
} : this.options.appServer;
|
|
18543
18592
|
const sharedServer = this.sharedLocalServer();
|
|
18544
18593
|
return {
|
|
18545
|
-
...localOptions
|
|
18594
|
+
...localOptions !== undefined && "url" in localOptions && localOptions.url !== undefined ? { url: localOptions.url } : {
|
|
18546
18595
|
connect: () => sharedServer.connect()
|
|
18547
18596
|
},
|
|
18548
18597
|
...localOptions?.WebSocket !== undefined ? { WebSocket: localOptions.WebSocket } : {},
|
|
@@ -18610,6 +18659,21 @@ class LettaAgentClient extends LettaAgentClientBase {
|
|
|
18610
18659
|
}, this.sharedLocalServer());
|
|
18611
18660
|
}
|
|
18612
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
|
+
}
|
|
18613
18677
|
function looksLikeConversationId2(id) {
|
|
18614
18678
|
return id.startsWith("conv-") || id.startsWith("local-conv-");
|
|
18615
18679
|
}
|
|
@@ -36427,4 +36491,4 @@ export {
|
|
|
36427
36491
|
CloudManagedSandboxExpiredError
|
|
36428
36492
|
};
|
|
36429
36493
|
|
|
36430
|
-
//# debugId=
|
|
36494
|
+
//# debugId=AFB0BEDEFE911CAD64756E2164756E21
|