@letta-ai/letta-agent-sdk 0.3.1 → 0.3.3
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/AGENTS.md +47 -0
- package/README.md +17 -0
- package/dist/app-server-management.d.ts +58 -0
- package/dist/app-server-management.d.ts.map +1 -1
- package/dist/app-server-session.d.ts +5 -0
- package/dist/app-server-session.d.ts.map +1 -1
- package/dist/client-base.d.ts +7 -0
- package/dist/client-base.d.ts.map +1 -1
- package/dist/client-entry.js +1123 -776
- package/dist/client-entry.js.map +13 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/cloud-sandbox.d.ts +33 -0
- package/dist/cloud-sandbox.d.ts.map +1 -0
- package/dist/cloud-session.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1176 -791
- package/dist/index.js.map +17 -13
- package/dist/local-app-server-session.d.ts +1 -1
- package/dist/local-app-server-session.d.ts.map +1 -1
- package/dist/management.d.ts +7 -0
- package/dist/management.d.ts.map +1 -1
- package/dist/remote-client-session-core.d.ts +24 -93
- package/dist/remote-client-session-core.d.ts.map +1 -1
- package/dist/remote-session-protocol.d.ts +130 -0
- package/dist/remote-session-protocol.d.ts.map +1 -0
- package/dist/remote-turn-coordinator.d.ts +49 -0
- package/dist/remote-turn-coordinator.d.ts.map +1 -0
- package/dist/request-ids.d.ts +24 -0
- package/dist/request-ids.d.ts.map +1 -0
- package/dist/session.d.ts +10 -1
- package/dist/session.d.ts.map +1 -1
- package/dist/types.d.ts +6 -20
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -2
- package/src/app-server-management.ts +641 -0
- package/src/app-server-session.ts +948 -0
- package/src/cli-resolver.ts +46 -0
- package/src/client-base.ts +482 -0
- package/src/client-entry.ts +31 -0
- package/src/client.ts +138 -0
- package/src/cloud-management.ts +360 -0
- package/src/cloud-sandbox.ts +117 -0
- package/src/cloud-session.ts +1313 -0
- package/src/index.ts +440 -0
- package/src/interactiveToolPolicy.ts +62 -0
- package/src/local-app-server-session.ts +39 -0
- package/src/local-app-server.ts +137 -0
- package/src/management-types.ts +133 -0
- package/src/management.ts +206 -0
- package/src/protocol.ts +249 -0
- package/src/remote-client-session-core.ts +786 -0
- package/src/remote-session-protocol.ts +660 -0
- package/src/remote-turn-coordinator.ts +505 -0
- package/src/remote.ts +177 -0
- package/src/repositories.ts +340 -0
- package/src/request-ids.ts +33 -0
- package/src/session.ts +1638 -0
- package/src/stream-events.ts +88 -0
- package/src/tool-helpers.ts +147 -0
- package/src/transport.ts +484 -0
- package/src/types.ts +1328 -0
- package/src/validation.ts +223 -0
- package/src/websocket.ts +22 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { AppServerSession, type AppServerSessionMode } from "./app-server-session.js";
|
|
2
2
|
import type { LettaCodeLocalAppServerOptions } from "./types.js";
|
|
3
|
-
export declare function createLocalAppServerSession(options: LettaCodeLocalAppServerOptions | undefined, mode: AppServerSessionMode): AppServerSession;
|
|
3
|
+
export declare function createLocalAppServerSession(options: LettaCodeLocalAppServerOptions | undefined, mode: AppServerSessionMode, beforeConnect?: () => Promise<void>): AppServerSession;
|
|
4
4
|
//# sourceMappingURL=local-app-server-session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-app-server-session.d.ts","sourceRoot":"","sources":["../src/local-app-server-session.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,KAAK,oBAAoB,EAE1B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAC;AAEjE,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,8BAA8B,GAAG,SAAS,EACnD,IAAI,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"local-app-server-session.d.ts","sourceRoot":"","sources":["../src/local-app-server-session.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,KAAK,oBAAoB,EAE1B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAC;AAEjE,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,8BAA8B,GAAG,SAAS,EACnD,IAAI,EAAE,oBAAoB,EAC1B,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAClC,gBAAgB,CA0BlB"}
|
package/dist/management.d.ts
CHANGED
|
@@ -12,6 +12,13 @@ export interface ManagementTransport {
|
|
|
12
12
|
createConversation(body: Record<string, unknown>): Promise<LettaConversation>;
|
|
13
13
|
updateConversation(conversationId: string, body: Record<string, unknown>): Promise<LettaConversation>;
|
|
14
14
|
listConversationMessages(conversationId: string, query: ManagementQuery): Promise<ConversationMessagesResult>;
|
|
15
|
+
/**
|
|
16
|
+
* Release the pooled connection, waiting for in-flight work when necessary,
|
|
17
|
+
* so other clients of the same backend (for example sessions, which compete
|
|
18
|
+
* for the app-server's single control-client slot) can connect. Optional;
|
|
19
|
+
* transports whose backend has no such contention (Cloud REST) omit it.
|
|
20
|
+
*/
|
|
21
|
+
releaseIdleConnection?(): Promise<void> | void;
|
|
15
22
|
}
|
|
16
23
|
type TransportProvider = () => ManagementTransport;
|
|
17
24
|
export declare function createAgentsClient(transport: TransportProvider): AgentsClient;
|
package/dist/management.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"management.d.ts","sourceRoot":"","sources":["../src/management.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,0BAA0B,EAE1B,UAAU,EACV,iBAAiB,EAGjB,YAAY,EAIb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,MAAM,MAAM,eAAe,GAAG,MAAM,CAClC,MAAM,EACN,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,GAA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AE,iBAAiB,GAC3B,YAAY,CAYd;AAED,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,iBAAiB,GAC3B,YAAY,CAId;AAED,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,iBAAiB,GAC3B,mBAAmB,CAmBrB"}
|
|
@@ -1,80 +1,13 @@
|
|
|
1
|
-
import type { BootstrapStateOptions, BootstrapStateResult, ChangeDeviceStateOptions, CreateAgentOptions, GetDeviceStatusOptions, LettaCodeClientSessionOptions, LettaCodeSession, ListModelsResult, ListMessagesOptions, ListMessagesResult,
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
export type ProtocolMessage = Record<string, unknown> & {
|
|
7
|
-
type: string;
|
|
8
|
-
request_id?: string;
|
|
9
|
-
runtime?: RuntimeScope;
|
|
10
|
-
};
|
|
11
|
-
export type RuntimeSessionMode = {
|
|
12
|
-
kind: "create-agent";
|
|
13
|
-
options: CreateAgentOptions;
|
|
14
|
-
} | {
|
|
15
|
-
kind: "session";
|
|
16
|
-
agentId?: string;
|
|
17
|
-
conversationId?: string;
|
|
18
|
-
newConversation?: boolean;
|
|
19
|
-
defaultConversation?: boolean;
|
|
20
|
-
options: LettaCodeClientSessionOptions;
|
|
21
|
-
};
|
|
22
|
-
export type RuntimeTurnResult = {
|
|
23
|
-
runtime: RuntimeScope;
|
|
24
|
-
stopReason: string | null;
|
|
25
|
-
runIds: string[];
|
|
26
|
-
success?: boolean;
|
|
27
|
-
detail?: string;
|
|
28
|
-
errorCode?: SDKErrorCode;
|
|
29
|
-
};
|
|
30
|
-
export type RuntimeSendTurnOptions = {
|
|
31
|
-
clientMessageId: string;
|
|
32
|
-
};
|
|
33
|
-
export type RuntimeRequestOptions = {
|
|
34
|
-
timeoutMs?: number;
|
|
35
|
-
predicate?: (message: ProtocolMessage) => boolean;
|
|
36
|
-
};
|
|
37
|
-
export interface RemoteClientRuntimeController {
|
|
38
|
-
onMessage(handler: (message: ProtocolMessage, channel?: string) => void): () => void;
|
|
39
|
-
send(command: Record<string, unknown>): void;
|
|
40
|
-
sendTurnMessage(runtime: RuntimeScope, message: SendMessage, options: RuntimeSendTurnOptions): void;
|
|
41
|
-
abort(runtime: RuntimeScope): Promise<void>;
|
|
42
|
-
request(type: string, body: Record<string, unknown>, options?: RuntimeRequestOptions): Promise<ProtocolMessage>;
|
|
43
|
-
recoverPendingApprovals(runtime: RuntimeScope, options?: RecoverPendingApprovalsOptions): Promise<RecoverPendingApprovalsResult>;
|
|
44
|
-
listMessages(conversationId: string, options?: ListMessagesOptions): Promise<ListMessagesResult>;
|
|
45
|
-
listModels(): Promise<ListModelsResult>;
|
|
46
|
-
updateModel(runtime: RuntimeScope, payload: {
|
|
47
|
-
model_id?: string;
|
|
48
|
-
model_handle?: string;
|
|
49
|
-
}): Promise<UpdateModelResult>;
|
|
50
|
-
close(): void;
|
|
51
|
-
}
|
|
52
|
-
export type RuntimeSessionInit = {
|
|
53
|
-
controller: RemoteClientRuntimeController;
|
|
54
|
-
runtime: RuntimeScope;
|
|
55
|
-
model?: string | null;
|
|
56
|
-
modelSettings?: Record<string, unknown> | null;
|
|
57
|
-
tools?: string[];
|
|
58
|
-
/** Effective runtime skill source override, when explicitly requested. */
|
|
59
|
-
skillSources?: SkillSource[];
|
|
60
|
-
};
|
|
61
|
-
type RemoteClientSessionCoreConfig = {
|
|
62
|
-
label: string;
|
|
63
|
-
requestTimeoutMs?: number;
|
|
64
|
-
};
|
|
65
|
-
type LegacyPermissionMode = "default" | "bypassPermissions" | "fullAccess";
|
|
66
|
-
export declare function normalizePermissionMode(mode: LettaCodeClientSessionOptions["permissionMode"] | LegacyPermissionMode | undefined): LettaCodeClientSessionOptions["permissionMode"] | undefined;
|
|
67
|
-
export declare function mapPermissionMode(mode: LettaCodeClientSessionOptions["permissionMode"] | LegacyPermissionMode | undefined): string | undefined;
|
|
68
|
-
export declare function isUnrestrictedPermissionMode(mode: LettaCodeClientSessionOptions["permissionMode"] | LegacyPermissionMode | undefined): boolean;
|
|
69
|
-
export declare function ensureSuccess(message: Record<string, unknown>, fallback: string): void;
|
|
70
|
-
export declare function normalizeSendMessage(message: SendMessage): string | MessageContentItem[];
|
|
1
|
+
import type { BootstrapStateOptions, BootstrapStateResult, ChangeDeviceStateOptions, CreateAgentOptions, GetDeviceStatusOptions, LettaCodeClientSessionOptions, LettaCodeSession, ListModelsResult, ListMessagesOptions, ListMessagesResult, RecoverPendingApprovalsOptions, RecoverPendingApprovalsResult, RemoveQueuedMessageResult, RunTurnOptions, SDKInitMessage, SDKMessage, SDKProtocolCommand, SDKProtocolMessage, SDKResultMessage, SendCommandOptions, SendMessage, SessionDeviceStatus, UpdateModelOptions, UpdateModelResult } from "./types.js";
|
|
2
|
+
export { ensureSuccess, isUnrestrictedPermissionMode, mapPermissionMode, normalizePermissionMode, normalizeSendMessage, } from "./remote-session-protocol.js";
|
|
3
|
+
import { type RemoteClientSessionCoreConfig, type RemoteClientRuntimeController, type RuntimeScope, type RuntimeSessionInit, type RuntimeSessionMode } from "./remote-session-protocol.js";
|
|
4
|
+
export type { ProtocolMessage, RemoteClientRuntimeController, RuntimeRequestOptions, RuntimeScope, RuntimeSendTurnOptions, RuntimeSessionInit, RuntimeSessionMode, RuntimeTurnResult, } from "./remote-session-protocol.js";
|
|
71
5
|
export declare abstract class RemoteClientSessionCore implements LettaCodeSession {
|
|
72
6
|
protected readonly mode: RuntimeSessionMode;
|
|
73
7
|
protected controller: RemoteClientRuntimeController | null;
|
|
74
8
|
protected runtime: RuntimeScope | null;
|
|
75
9
|
protected initialized: boolean;
|
|
76
10
|
protected closed: boolean;
|
|
77
|
-
protected activeTurnStartedAt: number;
|
|
78
11
|
protected _agentId: string | null;
|
|
79
12
|
protected _sessionId: string | null;
|
|
80
13
|
protected _conversationId: string | null;
|
|
@@ -82,19 +15,30 @@ export declare abstract class RemoteClientSessionCore implements LettaCodeSessio
|
|
|
82
15
|
protected _modelSettings: Record<string, unknown> | null;
|
|
83
16
|
private readonly label;
|
|
84
17
|
private readonly requestTimeoutMs;
|
|
85
|
-
private
|
|
86
|
-
private streamResolvers;
|
|
18
|
+
private initializePromise;
|
|
87
19
|
private removeMessageHandler;
|
|
88
|
-
private
|
|
89
|
-
private pendingTurns;
|
|
90
|
-
private nextTurnId;
|
|
91
|
-
private messageCounter;
|
|
92
|
-
private clientMessageCounter;
|
|
20
|
+
private readonly turns;
|
|
93
21
|
private toolNames;
|
|
94
22
|
private deviceStatusListeners;
|
|
95
23
|
private deviceStatusRefreshCancels;
|
|
96
24
|
protected constructor(mode: RuntimeSessionMode, config: RemoteClientSessionCoreConfig);
|
|
25
|
+
/**
|
|
26
|
+
* Initialize the session.
|
|
27
|
+
*
|
|
28
|
+
* Single-flight: the first caller starts initialization and every
|
|
29
|
+
* concurrent caller (including the lazily-initializing entry points such
|
|
30
|
+
* as send()/stream()/listMessages()) awaits the same promise, so a fresh
|
|
31
|
+
* session never opens more than one runtime connection. A failed attempt
|
|
32
|
+
* clears the memo so a later call can retry; it only releases the
|
|
33
|
+
* resources that failed attempt created.
|
|
34
|
+
*/
|
|
97
35
|
initialize(): Promise<SDKInitMessage>;
|
|
36
|
+
private performInitialize;
|
|
37
|
+
/**
|
|
38
|
+
* Release the partial state a failed initialize attempt created without
|
|
39
|
+
* closing the session, so a later initialize() can retry.
|
|
40
|
+
*/
|
|
41
|
+
private cleanupFailedInitialize;
|
|
98
42
|
send(message: SendMessage): Promise<void>;
|
|
99
43
|
runTurn(message: SendMessage, _options?: RunTurnOptions): Promise<SDKResultMessage>;
|
|
100
44
|
stream(): AsyncGenerator<SDKMessage>;
|
|
@@ -103,6 +47,7 @@ export declare abstract class RemoteClientSessionCore implements LettaCodeSessio
|
|
|
103
47
|
sendCommand<TResponse extends SDKProtocolMessage = SDKProtocolMessage>(command: SDKProtocolCommand, options: SendCommandOptions): Promise<TResponse>;
|
|
104
48
|
listModels(): Promise<ListModelsResult>;
|
|
105
49
|
updateModel(update: string | UpdateModelOptions): Promise<UpdateModelResult>;
|
|
50
|
+
private applyModelUpdate;
|
|
106
51
|
recoverPendingApprovals(options?: RecoverPendingApprovalsOptions): Promise<RecoverPendingApprovalsResult>;
|
|
107
52
|
removeQueuedMessage(itemId: string): Promise<RemoveQueuedMessageResult>;
|
|
108
53
|
getDeviceStatus(options?: GetDeviceStatusOptions): Promise<SessionDeviceStatus>;
|
|
@@ -125,22 +70,8 @@ export declare abstract class RemoteClientSessionCore implements LettaCodeSessio
|
|
|
125
70
|
protected shouldEnableMemfs(options: LettaCodeClientSessionOptions | CreateAgentOptions): boolean;
|
|
126
71
|
protected enableMemfsBody(): Record<string, unknown>;
|
|
127
72
|
protected setModel(model: string): void;
|
|
128
|
-
private trackSentTurn;
|
|
129
|
-
private activateTurn;
|
|
130
|
-
private activateNextTurnFromProtocol;
|
|
131
|
-
private removeTrackedTurn;
|
|
132
|
-
private failTurn;
|
|
133
|
-
private completeActiveTurn;
|
|
134
73
|
private resolveUpdateModelPayload;
|
|
135
74
|
protected applyPostInitializeOptions(): Promise<void>;
|
|
136
|
-
private
|
|
137
|
-
private handleLoopStatusMessage;
|
|
138
|
-
private handleTurnTerminalDelta;
|
|
139
|
-
private transformStreamDelta;
|
|
140
|
-
private resultFromTurn;
|
|
141
|
-
private enqueue;
|
|
142
|
-
private nextMessage;
|
|
143
|
-
private resolveAll;
|
|
75
|
+
private emitDeviceStatus;
|
|
144
76
|
}
|
|
145
|
-
export {};
|
|
146
77
|
//# sourceMappingURL=remote-client-session-core.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-client-session-core.d.ts","sourceRoot":"","sources":["../src/remote-client-session-core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,kBAAkB,EAClB,sBAAsB,EACtB,6BAA6B,EAC7B,gBAAgB,EAEhB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"remote-client-session-core.d.ts","sourceRoot":"","sources":["../src/remote-client-session-core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,kBAAkB,EAClB,sBAAsB,EACtB,6BAA6B,EAC7B,gBAAgB,EAEhB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,8BAA8B,EAC9B,6BAA6B,EAC7B,yBAAyB,EACzB,cAAc,EACd,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,aAAa,EACb,4BAA4B,EAC5B,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAWL,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,EAClC,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EAExB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,eAAe,EACf,6BAA6B,EAC7B,qBAAqB,EACrB,YAAY,EACZ,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,8BAA8B,CAAC;AAEtC,8BAAsB,uBAAwB,YAAW,gBAAgB;IAqBrE,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,kBAAkB;IApB7C,SAAS,CAAC,UAAU,EAAE,6BAA6B,GAAG,IAAI,CAAQ;IAClE,SAAS,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAAQ;IAC9C,SAAS,CAAC,WAAW,UAAS;IAC9B,SAAS,CAAC,MAAM,UAAS;IACzB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IACzC,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC3C,SA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AKjG,SAAS,CAAC,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAKpD,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;YAIzB,yBAAyB;cAuEvB,0BAA0B,IAAI,OAAO,CAAC,IAAI,CAAC;IAqD3D,OAAO,CAAC,gBAAgB;CASzB"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { CreateAgentOptions, LettaCodeClientSessionOptions, LettaCodeModelEntry, ListMessagesOptions, ListMessagesResult, ListModelsResult, MessageContentItem, RecoverPendingApprovalsOptions, RecoverPendingApprovalsResult, ReasoningEffort, SDKErrorCode, SDKQueueItem, SendMessage, SessionDeviceStatus, SkillSource, UpdateModelOptions, UpdateModelResult } from "./types.js";
|
|
2
|
+
export type RuntimeScope = {
|
|
3
|
+
agent_id: string;
|
|
4
|
+
conversation_id: string;
|
|
5
|
+
};
|
|
6
|
+
export type ProtocolMessage = Record<string, unknown> & {
|
|
7
|
+
type: string;
|
|
8
|
+
request_id?: string;
|
|
9
|
+
runtime?: RuntimeScope;
|
|
10
|
+
};
|
|
11
|
+
export type RuntimeSessionMode = {
|
|
12
|
+
kind: "create-agent";
|
|
13
|
+
options: CreateAgentOptions;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "session";
|
|
16
|
+
agentId?: string;
|
|
17
|
+
conversationId?: string;
|
|
18
|
+
newConversation?: boolean;
|
|
19
|
+
defaultConversation?: boolean;
|
|
20
|
+
options: LettaCodeClientSessionOptions;
|
|
21
|
+
};
|
|
22
|
+
export type RuntimeTurnResult = {
|
|
23
|
+
runtime: RuntimeScope;
|
|
24
|
+
stopReason: string | null;
|
|
25
|
+
runIds: string[];
|
|
26
|
+
success?: boolean;
|
|
27
|
+
detail?: string;
|
|
28
|
+
errorCode?: SDKErrorCode;
|
|
29
|
+
};
|
|
30
|
+
export type RuntimeSendTurnOptions = {
|
|
31
|
+
clientMessageId: string;
|
|
32
|
+
};
|
|
33
|
+
export type RuntimeRequestOptions = {
|
|
34
|
+
timeoutMs?: number;
|
|
35
|
+
predicate?: (message: ProtocolMessage) => boolean;
|
|
36
|
+
};
|
|
37
|
+
export interface RemoteClientRuntimeController {
|
|
38
|
+
onMessage(handler: (message: ProtocolMessage, channel?: string) => void): () => void;
|
|
39
|
+
send(command: Record<string, unknown>): void;
|
|
40
|
+
sendTurnMessage(runtime: RuntimeScope, message: SendMessage, options: RuntimeSendTurnOptions): void;
|
|
41
|
+
abort(runtime: RuntimeScope): Promise<void>;
|
|
42
|
+
request(type: string, body: Record<string, unknown>, options?: RuntimeRequestOptions): Promise<ProtocolMessage>;
|
|
43
|
+
recoverPendingApprovals(runtime: RuntimeScope, options?: RecoverPendingApprovalsOptions): Promise<RecoverPendingApprovalsResult>;
|
|
44
|
+
listMessages(conversationId: string, options?: ListMessagesOptions): Promise<ListMessagesResult>;
|
|
45
|
+
listModels(): Promise<ListModelsResult>;
|
|
46
|
+
updateModel(runtime: RuntimeScope, payload: {
|
|
47
|
+
model_id?: string;
|
|
48
|
+
model_handle?: string;
|
|
49
|
+
}): Promise<UpdateModelResult>;
|
|
50
|
+
close(): void;
|
|
51
|
+
}
|
|
52
|
+
export type RuntimeSessionInit = {
|
|
53
|
+
controller: RemoteClientRuntimeController;
|
|
54
|
+
runtime: RuntimeScope;
|
|
55
|
+
model?: string | null;
|
|
56
|
+
modelSettings?: Record<string, unknown> | null;
|
|
57
|
+
tools?: string[];
|
|
58
|
+
/** Effective runtime skill source override, when explicitly requested. */
|
|
59
|
+
skillSources?: SkillSource[];
|
|
60
|
+
};
|
|
61
|
+
export type RemoteClientSessionCoreConfig = {
|
|
62
|
+
label: string;
|
|
63
|
+
requestTimeoutMs?: number;
|
|
64
|
+
};
|
|
65
|
+
type ReflectionSettings = {
|
|
66
|
+
trigger: "off" | "step-count" | "compaction-event";
|
|
67
|
+
step_count: number;
|
|
68
|
+
};
|
|
69
|
+
export type UpdateModelPayload = {
|
|
70
|
+
model_id?: string;
|
|
71
|
+
model_handle?: string;
|
|
72
|
+
};
|
|
73
|
+
export type NormalizedUpdateModelInput = {
|
|
74
|
+
model?: string;
|
|
75
|
+
modelId?: string;
|
|
76
|
+
modelHandle?: string;
|
|
77
|
+
reasoningEffort?: ReasoningEffort;
|
|
78
|
+
};
|
|
79
|
+
export type TurnTracker = {
|
|
80
|
+
id: number;
|
|
81
|
+
runtime: RuntimeScope;
|
|
82
|
+
clientMessageId: string;
|
|
83
|
+
queuedAt: number;
|
|
84
|
+
startedAt: number;
|
|
85
|
+
assistantText: string;
|
|
86
|
+
runIds: Set<string>;
|
|
87
|
+
observedTurnEvidence: boolean;
|
|
88
|
+
observedRequiresApprovalStop: boolean;
|
|
89
|
+
abortRequested: boolean;
|
|
90
|
+
timeout: ReturnType<typeof setTimeout> | null;
|
|
91
|
+
};
|
|
92
|
+
export declare const FAILURE_STOP_REASONS: Set<string>;
|
|
93
|
+
type LegacyPermissionMode = "default" | "bypassPermissions" | "fullAccess";
|
|
94
|
+
export declare function normalizePermissionMode(mode: LettaCodeClientSessionOptions["permissionMode"] | LegacyPermissionMode | undefined): LettaCodeClientSessionOptions["permissionMode"] | undefined;
|
|
95
|
+
export declare function mapPermissionMode(mode: LettaCodeClientSessionOptions["permissionMode"] | LegacyPermissionMode | undefined): string | undefined;
|
|
96
|
+
export declare function isUnrestrictedPermissionMode(mode: LettaCodeClientSessionOptions["permissionMode"] | LegacyPermissionMode | undefined): boolean;
|
|
97
|
+
export declare function ensureSuccess(message: Record<string, unknown>, fallback: string): void;
|
|
98
|
+
export declare function toSdkErrorCode(value: string | null | undefined): SDKErrorCode | undefined;
|
|
99
|
+
export declare function normalizeUpdateModelInput(update: string | UpdateModelOptions): NormalizedUpdateModelInput;
|
|
100
|
+
export declare function modelPayloadWithoutReasoning(input: NormalizedUpdateModelInput): UpdateModelPayload;
|
|
101
|
+
export declare function toBaseModelHandle(handle: string | undefined, byokProviderAliases: Record<string, string> | undefined): string | undefined;
|
|
102
|
+
export declare function getContextWindow(value: Record<string, unknown> | null | undefined): number | undefined;
|
|
103
|
+
export declare function getReasoningEffort(entry: LettaCodeModelEntry): string | undefined;
|
|
104
|
+
export declare function sameContextCandidates(candidates: LettaCodeModelEntry[], contextWindow: number | undefined): LettaCodeModelEntry[];
|
|
105
|
+
export declare function isApprovalConflictSignal(params: {
|
|
106
|
+
detail?: string;
|
|
107
|
+
message?: string;
|
|
108
|
+
stopReason?: string | null;
|
|
109
|
+
}): boolean;
|
|
110
|
+
export declare function resolveDreamingSettings(dreaming: LettaCodeClientSessionOptions["dreaming"]): ReflectionSettings | null;
|
|
111
|
+
export declare function extractTextFromContent(content: unknown): string | null;
|
|
112
|
+
export declare function toolInputFromArguments(args: unknown): {
|
|
113
|
+
input: Record<string, unknown>;
|
|
114
|
+
raw?: string;
|
|
115
|
+
};
|
|
116
|
+
export declare function firstToolCall(delta: Record<string, unknown>): Record<string, unknown> | undefined;
|
|
117
|
+
export declare function firstToolReturn(delta: Record<string, unknown>): Record<string, unknown> | undefined;
|
|
118
|
+
export declare function sameRuntime(message: ProtocolMessage, runtime: RuntimeScope): boolean;
|
|
119
|
+
export declare function streamDeltaRecord(message: ProtocolMessage): Record<string, unknown> | null;
|
|
120
|
+
export declare function streamDeltaMessageType(delta: Record<string, unknown>): string | undefined;
|
|
121
|
+
export declare function streamDeltaRunId(delta: Record<string, unknown>): string | undefined;
|
|
122
|
+
export declare function streamDeltaStopReason(delta: Record<string, unknown>): string | null | undefined;
|
|
123
|
+
export declare function loopStatusValue(message: ProtocolMessage): string | undefined;
|
|
124
|
+
export declare function loopStatusRunIds(message: ProtocolMessage): string[];
|
|
125
|
+
export declare function queueItems(message: ProtocolMessage): SDKQueueItem[];
|
|
126
|
+
export declare function deviceStatusRecord(message: ProtocolMessage): Record<string, unknown> | null;
|
|
127
|
+
export declare function toSessionDeviceStatus(status: Record<string, unknown>): SessionDeviceStatus | null;
|
|
128
|
+
export declare function normalizeSendMessage(message: SendMessage): string | MessageContentItem[];
|
|
129
|
+
export {};
|
|
130
|
+
//# sourceMappingURL=remote-session-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-session-protocol.d.ts","sourceRoot":"","sources":["../src/remote-session-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,6BAA6B,EAC7B,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,8BAA8B,EAC9B,6BAA6B,EAC7B,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,mBAAmB,EAKnB,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,OAAO,EAAE,kBAAkB,CAAA;CAAE,GACrD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,OAAO,EAAE,6BAA6B,CAAC;CACxC,CAAC;AAEN,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,CAAC,E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AED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAM1F;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,SAAS,CAEzF;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,SAAS,CAEnF;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAE/F;AAUD,wBAAgB,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,GAAG,SAAS,CAG5E;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,EAAE,CAKnE;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,eAAe,GAAG,YAAY,EAAE,CAmBnE;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAM3F;AA6HD,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,mBAAmB,GAAG,IAAI,CAyB5B;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,GAAG,kBAAkB,EAAE,CAExF"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { SDKMessage, SessionDeviceStatus } from "./types.js";
|
|
2
|
+
import { type ProtocolMessage, type RuntimeScope, type TurnTracker } from "./remote-session-protocol.js";
|
|
3
|
+
type RemoteTurnCoordinatorConfig = {
|
|
4
|
+
label: string;
|
|
5
|
+
requestTimeoutMs?: number;
|
|
6
|
+
onDeviceStatus(status: SessionDeviceStatus): void;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Owns the portable session's turn correlation and stream queue.
|
|
10
|
+
*
|
|
11
|
+
* Transport setup and public SDK methods stay in RemoteClientSessionCore.
|
|
12
|
+
* This class only translates protocol events into SDK messages and correlates
|
|
13
|
+
* those events with active or queued turns.
|
|
14
|
+
*/
|
|
15
|
+
export declare class RemoteTurnCoordinator {
|
|
16
|
+
private readonly label;
|
|
17
|
+
private readonly requestTimeoutMs;
|
|
18
|
+
private readonly onDeviceStatus;
|
|
19
|
+
private streamQueue;
|
|
20
|
+
private streamResolvers;
|
|
21
|
+
private activeTurn;
|
|
22
|
+
private pendingTurns;
|
|
23
|
+
private nextTurnId;
|
|
24
|
+
private messageCounter;
|
|
25
|
+
private clientMessageCounter;
|
|
26
|
+
private closed;
|
|
27
|
+
private _activeTurnStartedAt;
|
|
28
|
+
constructor(config: RemoteTurnCoordinatorConfig);
|
|
29
|
+
get activeTurnStartedAt(): number;
|
|
30
|
+
hasInFlightTurn(): boolean;
|
|
31
|
+
trackSentTurn(runtime: RuntimeScope): TurnTracker;
|
|
32
|
+
removeTrackedTurn(turn: TurnTracker): void;
|
|
33
|
+
markAbortRequested(): void;
|
|
34
|
+
handleProtocolMessage(message: ProtocolMessage, runtime: RuntimeScope): void;
|
|
35
|
+
nextMessage(): Promise<SDKMessage | null>;
|
|
36
|
+
close(): void;
|
|
37
|
+
private activateTurn;
|
|
38
|
+
private activateNextTurnFromProtocol;
|
|
39
|
+
private failTurn;
|
|
40
|
+
private completeActiveTurn;
|
|
41
|
+
private handleLoopStatusMessage;
|
|
42
|
+
private handleTurnTerminalDelta;
|
|
43
|
+
private transformStreamDelta;
|
|
44
|
+
private resultFromTurn;
|
|
45
|
+
private enqueue;
|
|
46
|
+
private resolveAll;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=remote-turn-coordinator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-turn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b,OAAO,CAAC,YAAY;IAYpB,OAAO,CAAC,4BAA4B;IAQpC,OAAO,CAAC,QAAQ;IAoBhB,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,uBAAuB;IA8C/B,OAAO,CAAC,uBAAuB;IAiC/B,OAAO,CAAC,oBAAoB;IA0J5B,OAAO,CAAC,cAAc;IAqCtB,OAAO,CAAC,OAAO;IASf,OAAO,CAAC,UAAU;CAKnB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collision-free request-id generation for request/response correlation.
|
|
3
|
+
*
|
|
4
|
+
* AppServerClient's built-in nextRequestId() is a bare per-instance counter
|
|
5
|
+
* that restarts at 1, so two client instances (for example two session
|
|
6
|
+
* objects, or a session plus a management request) each emit ids like
|
|
7
|
+
* `conversation_retrieve-1`. When more than one connection is involved the
|
|
8
|
+
* app-server can deliver request-correlated responses where both ids look
|
|
9
|
+
* identical, and the wrong caller's pending request resolves (or times out).
|
|
10
|
+
*
|
|
11
|
+
* Ids generated here embed a per-client random nonce plus a process-wide
|
|
12
|
+
* monotonic counter, so no two clients in the same process can ever emit the
|
|
13
|
+
* same id, and cross-process collisions are vanishingly unlikely.
|
|
14
|
+
*/
|
|
15
|
+
/** Create a request-id generator scoped to one client/connection instance. */
|
|
16
|
+
export declare function createRequestIdGenerator(): (prefix?: string) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Replace a client's request-id generator with a collision-free one.
|
|
19
|
+
* Returns the same client for call-site convenience.
|
|
20
|
+
*/
|
|
21
|
+
export declare function applyUniqueRequestIds<TClient extends {
|
|
22
|
+
nextRequestId(prefix?: string): string;
|
|
23
|
+
}>(client: TClient): TClient;
|
|
24
|
+
//# sourceMappingURL=request-ids.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-ids.d.ts","sourceRoot":"","sources":["../src/request-ids.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,8EAA8E;AAC9E,wBAAgB,wBAAwB,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,MAAM,CAGtE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,SAAS;IAAE,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EAC1D,MAAM,EAAE,OAAO,GAAG,OAAO,CAG1B"}
|
package/dist/session.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export declare class Session implements AsyncDisposable {
|
|
|
12
12
|
private _sessionId;
|
|
13
13
|
private _conversationId;
|
|
14
14
|
private initialized;
|
|
15
|
+
private closed;
|
|
16
|
+
private initializePromise;
|
|
15
17
|
private externalTools;
|
|
16
18
|
private streamQueue;
|
|
17
19
|
private streamResolvers;
|
|
@@ -23,9 +25,16 @@ export declare class Session implements AsyncDisposable {
|
|
|
23
25
|
private controlResponseWaiters;
|
|
24
26
|
constructor(options?: InternalSessionOptions);
|
|
25
27
|
/**
|
|
26
|
-
* Initialize the session (called automatically on first send)
|
|
28
|
+
* Initialize the session (called automatically on first send).
|
|
29
|
+
*
|
|
30
|
+
* Single-flight: concurrent callers (including lazily-initializing entry
|
|
31
|
+
* points such as send()) share one in-flight initialization instead of
|
|
32
|
+
* each connecting the transport. A failed stdio attempt closes the session
|
|
33
|
+
* because its subprocess transport is no longer safe to reuse.
|
|
27
34
|
*/
|
|
28
35
|
initialize(): Promise<SDKInitMessage>;
|
|
36
|
+
private performInitialize;
|
|
37
|
+
private cleanupFailedInitialize;
|
|
29
38
|
/**
|
|
30
39
|
* Send a message to the agent
|
|
31
40
|
*
|
package/dist/session.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,sBAAsB,EACtB,UAAU,EACV,cAAc,EACd,gBAAgB,EAShB,WAAW,EAGX,mBAAmB,EACnB,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AC,IAAI,CAAC;IACvD,WAAW,CAAC,SAAS,SAAS,kBAAkB,GAAG,kBAAkB,EACzE,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,SAAS,CAAC;IAUf,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAM7E,iBAAiB,CAAC,QAAQ,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAMpE,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAMxE,eAAe,CAAC,QAAQ,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAMtF,cAAc,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,GAAG,MAAM,IAAI;IAM5E;;;;;;;;OAQG;IACG,cAAc,CAClB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,oBAAoB,CAAC;IAwD1B,aAAa,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9D;;OAEG;IACH,KAAK,IAAI,IAAI;IASb;;OAEG;IACH,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAE3B;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,MAAM,GAAG,IAAI,CAE7B;IAED;;OAEG;IACH,IAAI,cAAc,IAAI,MAAM,GAAG,IAAI,CAElC;IAED;;OAEG;IACG,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5C;;OAEG;IACH,OAAO,CAAC,gBAAgB;CAoQzB"}
|
package/dist/types.d.ts
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
export type { WireMessage, SystemInitMessage, MessageWire, ResultMessage, ErrorMessage, StreamEvent, ControlRequest, ControlResponse, CanUseToolControlRequest, CanUseToolResponse, CanUseToolResponseAllow, CanUseToolResponseDeny, SystemPromptPresetConfig, CreateBlock, } from "./protocol.js";
|
|
8
8
|
import type { CreateBlock, CanUseToolResponse } from "./protocol.js";
|
|
9
9
|
import type { PersonalityId } from "@letta-ai/letta-code/agent-presets";
|
|
10
|
+
import type { LettaCodeCloudSandboxOptions } from "./cloud-sandbox.js";
|
|
11
|
+
export type { GitHubRepositoryRef, LettaCodeCloudSandboxOptions, } from "./cloud-sandbox.js";
|
|
10
12
|
/** Letta Code personality preset used to seed a new agent. */
|
|
11
13
|
export type LettaCodePersonalityId = PersonalityId;
|
|
12
14
|
export interface LettaCodeSocketLike {
|
|
@@ -214,6 +216,8 @@ export interface LettaCodeLocalAppServerOptions {
|
|
|
214
216
|
WebSocket?: LettaCodeSocketConstructor;
|
|
215
217
|
/** Timeout for websocket protocol request/turn correlation. */
|
|
216
218
|
requestTimeoutMs?: number;
|
|
219
|
+
/** Milliseconds an idle management connection may be reused before release. Defaults to 250. */
|
|
220
|
+
idleLingerMs?: number;
|
|
217
221
|
/** Whether agents created through this app-server are added to Letta Code's global pinned-agent list. */
|
|
218
222
|
pinGlobalAgent?: boolean;
|
|
219
223
|
/** Local app-server listen URL when the SDK spawns it. Defaults to ws://127.0.0.1:0. */
|
|
@@ -238,29 +242,11 @@ export interface LettaCodeRemoteClientOptions {
|
|
|
238
242
|
WebSocket?: LettaCodeSocketConstructor;
|
|
239
243
|
/** Timeout for websocket protocol request/turn correlation. */
|
|
240
244
|
requestTimeoutMs?: number;
|
|
245
|
+
/** Milliseconds an idle management connection may be reused before release. Defaults to 250. */
|
|
246
|
+
idleLingerMs?: number;
|
|
241
247
|
/** Whether agents created through this app-server are added to Letta Code's global pinned-agent list. */
|
|
242
248
|
pinGlobalAgent?: boolean;
|
|
243
249
|
}
|
|
244
|
-
export interface LettaCodeCloudSandboxOptions {
|
|
245
|
-
/**
|
|
246
|
-
* TTL to request when refreshing an SDK-managed sandbox. Defaults to 5
|
|
247
|
-
* minutes, matching the Cloud API default. Valid range: 1-60.
|
|
248
|
-
*/
|
|
249
|
-
ttlMinutes?: number;
|
|
250
|
-
/** Timeout waiting for a newly created sandbox environment to come online. */
|
|
251
|
-
readyTimeoutMs?: number;
|
|
252
|
-
/** Poll interval while waiting for a newly created sandbox environment. */
|
|
253
|
-
readyPollIntervalMs?: number;
|
|
254
|
-
/** Interval for proactive TTL refreshes while the session is open. */
|
|
255
|
-
refreshIntervalMs?: number;
|
|
256
|
-
/**
|
|
257
|
-
* Best-effort terminate the SDK-managed sandbox on session close. Defaults to
|
|
258
|
-
* false so other sessions for the same conversation and reconnecting clients
|
|
259
|
-
* can continue using it. Set true to restore eager cleanup when this session
|
|
260
|
-
* exclusively owns the sandbox.
|
|
261
|
-
*/
|
|
262
|
-
terminateOnClose?: boolean;
|
|
263
|
-
}
|
|
264
250
|
export interface LettaCodeCloudClientOptions {
|
|
265
251
|
backend: "cloud";
|
|
266
252
|
/** Optional API key override. Defaults to LETTA_API_KEY / existing auth. */
|