@letta-ai/letta-agent-sdk 0.7.7 → 0.7.8
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-entry.js +59 -23
- package/dist/client-entry.js.map +3 -3
- package/dist/cloud-session.d.ts +2 -0
- package/dist/cloud-session.d.ts.map +1 -1
- package/dist/index.js +59 -23
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
- package/src/cloud-session.ts +80 -25
package/dist/cloud-session.d.ts
CHANGED
|
@@ -41,6 +41,8 @@ export declare class CloudEnvironmentSession extends RemoteClientSessionCore {
|
|
|
41
41
|
constructor(cloudOptions: LettaCodeCloudClientOptions, mode: CloudSessionMode, apiClient?: Letta);
|
|
42
42
|
protected initializeRuntimeController(): Promise<RuntimeSessionInit>;
|
|
43
43
|
private openCloudTransport;
|
|
44
|
+
private createCloudTransportClient;
|
|
45
|
+
private connectCloudTransport;
|
|
44
46
|
private installTransportHandlers;
|
|
45
47
|
private cleanupTransportHandlers;
|
|
46
48
|
protected recoverIdleTransport(runtime: RuntimeScope): Promise<RuntimeSessionInit>;
|
|
@@ -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;AAgChD,OAAO,EACL,uBAAuB,EAGvB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACxB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAEV,kBAAkB,EAClB,6BAA6B,EAC7B,2BAA2B,EAI5B,MAAM,YAAY,CAAC;AAKpB,OAAO,EAIL,KAAK,kBAAkB,EAExB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"cloud-session.d.ts","sourceRoot":"","sources":["../src/cloud-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,wBAAwB,CAAC;A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AAO,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
|
@@ -11037,6 +11037,7 @@ var DEFAULT_SANDBOX_READY_TIMEOUT_MS = 120000;
|
|
|
11037
11037
|
var DEFAULT_SANDBOX_READY_POLL_INTERVAL_MS = 1000;
|
|
11038
11038
|
var DEFAULT_REPOSITORY_ATTACH_TIMEOUT_MS = 1e4;
|
|
11039
11039
|
var DEFAULT_REPOSITORY_ATTACH_POLL_INTERVAL_MS = 250;
|
|
11040
|
+
var INITIAL_CLOUD_TRANSPORT_ATTEMPTS = 2;
|
|
11040
11041
|
var SDK_AGENT_ORIGIN = "@letta-ai/letta-agent-sdk";
|
|
11041
11042
|
|
|
11042
11043
|
class CloudManagedSandboxOwnershipError extends Error {
|
|
@@ -11227,30 +11228,9 @@ class CloudEnvironmentSession extends RemoteClientSessionCore {
|
|
|
11227
11228
|
}
|
|
11228
11229
|
}
|
|
11229
11230
|
async openCloudTransport(runtime, connectionId) {
|
|
11230
|
-
const
|
|
11231
|
-
const url = buildCloudStatusWebSocketUrl({
|
|
11232
|
-
apiBaseUrl: this.cloudOptions.apiBaseUrl,
|
|
11233
|
-
connectionId,
|
|
11234
|
-
agentId: runtime.agent_id,
|
|
11235
|
-
conversationId: runtime.conversation_id,
|
|
11236
|
-
apiKey,
|
|
11237
|
-
authMode: this.cloudOptions.webSocketAuth ?? "header"
|
|
11238
|
-
});
|
|
11239
|
-
const client = applyUniqueRequestIds(createAppServerClient({
|
|
11240
|
-
url,
|
|
11241
|
-
WebSocket: createCloudStatusTransportConstructor({
|
|
11242
|
-
url,
|
|
11243
|
-
WebSocket: getWebSocketConstructor(this.cloudOptions.WebSocket),
|
|
11244
|
-
...(this.cloudOptions.webSocketAuth ?? "header") === "header" ? { headers: cloudWebSocketHeaders(this.cloudOptions) } : {},
|
|
11245
|
-
pingIntervalMs: this.cloudOptions.pingIntervalMs ?? DEFAULT_PING_INTERVAL_MS,
|
|
11246
|
-
runtime
|
|
11247
|
-
}),
|
|
11248
|
-
requestTimeoutMs: this.cloudOptions.requestTimeoutMs ?? DEFAULT_TURN_TIMEOUT_MS
|
|
11249
|
-
}));
|
|
11231
|
+
const client = await this.connectCloudTransport(runtime, connectionId);
|
|
11250
11232
|
const options = this.currentOptions();
|
|
11251
|
-
this.installTransportHandlers(client);
|
|
11252
11233
|
try {
|
|
11253
|
-
await client.connect();
|
|
11254
11234
|
const response = await this.startCloudRuntime(client, runtime);
|
|
11255
11235
|
if (!response.success || !response.runtime) {
|
|
11256
11236
|
throw new Error(response.error ?? "Failed to start Cloud status runtime");
|
|
@@ -11278,6 +11258,62 @@ class CloudEnvironmentSession extends RemoteClientSessionCore {
|
|
|
11278
11258
|
throw error;
|
|
11279
11259
|
}
|
|
11280
11260
|
}
|
|
11261
|
+
createCloudTransportClient(runtime, connectionId) {
|
|
11262
|
+
const apiKey = getCloudApiKey(this.cloudOptions);
|
|
11263
|
+
const url = buildCloudStatusWebSocketUrl({
|
|
11264
|
+
apiBaseUrl: this.cloudOptions.apiBaseUrl,
|
|
11265
|
+
connectionId,
|
|
11266
|
+
agentId: runtime.agent_id,
|
|
11267
|
+
conversationId: runtime.conversation_id,
|
|
11268
|
+
apiKey,
|
|
11269
|
+
authMode: this.cloudOptions.webSocketAuth ?? "header"
|
|
11270
|
+
});
|
|
11271
|
+
return applyUniqueRequestIds(createAppServerClient({
|
|
11272
|
+
url,
|
|
11273
|
+
WebSocket: createCloudStatusTransportConstructor({
|
|
11274
|
+
url,
|
|
11275
|
+
WebSocket: getWebSocketConstructor(this.cloudOptions.WebSocket),
|
|
11276
|
+
...(this.cloudOptions.webSocketAuth ?? "header") === "header" ? { headers: cloudWebSocketHeaders(this.cloudOptions) } : {},
|
|
11277
|
+
pingIntervalMs: this.cloudOptions.pingIntervalMs ?? DEFAULT_PING_INTERVAL_MS,
|
|
11278
|
+
runtime
|
|
11279
|
+
}),
|
|
11280
|
+
requestTimeoutMs: this.cloudOptions.requestTimeoutMs ?? DEFAULT_TURN_TIMEOUT_MS
|
|
11281
|
+
}));
|
|
11282
|
+
}
|
|
11283
|
+
async connectCloudTransport(runtime, initialConnectionId) {
|
|
11284
|
+
let connectionId = initialConnectionId;
|
|
11285
|
+
let lastError;
|
|
11286
|
+
for (let attempt = 0;attempt < INITIAL_CLOUD_TRANSPORT_ATTEMPTS; attempt++) {
|
|
11287
|
+
const client = this.createCloudTransportClient(runtime, connectionId);
|
|
11288
|
+
this.installTransportHandlers(client);
|
|
11289
|
+
try {
|
|
11290
|
+
await client.connect();
|
|
11291
|
+
this.connectionId = connectionId;
|
|
11292
|
+
return client;
|
|
11293
|
+
} catch (error) {
|
|
11294
|
+
lastError = error;
|
|
11295
|
+
console.warn(JSON.stringify({
|
|
11296
|
+
event: "cloud_status_transport_connection_failed",
|
|
11297
|
+
attempt: attempt + 1,
|
|
11298
|
+
max_attempts: INITIAL_CLOUD_TRANSPORT_ATTEMPTS,
|
|
11299
|
+
will_retry: attempt + 1 < INITIAL_CLOUD_TRANSPORT_ATTEMPTS,
|
|
11300
|
+
connection_id: connectionId,
|
|
11301
|
+
agent_id: runtime.agent_id,
|
|
11302
|
+
conversation_id: runtime.conversation_id,
|
|
11303
|
+
error_name: error instanceof Error ? error.name : null,
|
|
11304
|
+
error_message: error instanceof Error ? error.message : String(error)
|
|
11305
|
+
}));
|
|
11306
|
+
this.cleanupTransportHandlers();
|
|
11307
|
+
client.close();
|
|
11308
|
+
}
|
|
11309
|
+
if (attempt + 1 < INITIAL_CLOUD_TRANSPORT_ATTEMPTS) {
|
|
11310
|
+
const resolved = await this.resolveRecoveryConnection(runtime);
|
|
11311
|
+
connectionId = resolved.connectionId;
|
|
11312
|
+
}
|
|
11313
|
+
}
|
|
11314
|
+
const detail = lastError instanceof Error ? lastError.message : String(lastError);
|
|
11315
|
+
throw new Error(`Cloud status WebSocket failed to open for connection ${connectionId}: ${detail}`, { cause: lastError });
|
|
11316
|
+
}
|
|
11281
11317
|
installTransportHandlers(client) {
|
|
11282
11318
|
this.cleanupTransportHandlers();
|
|
11283
11319
|
this.removeControlRequestHandler = registerAppServerControlRequestHandler({
|
|
@@ -30518,4 +30554,4 @@ export {
|
|
|
30518
30554
|
CloudManagedSandboxExpiredError
|
|
30519
30555
|
};
|
|
30520
30556
|
|
|
30521
|
-
//# debugId=
|
|
30557
|
+
//# debugId=1DB15671E78E416164756E2164756E21
|