@letta-ai/letta-agent-sdk 0.3.2 → 0.5.0
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 +44 -0
- package/README.md +29 -0
- package/dist/app-server-management.d.ts +3 -48
- package/dist/app-server-management.d.ts.map +1 -1
- package/dist/app-server-session.d.ts +0 -6
- package/dist/app-server-session.d.ts.map +1 -1
- package/dist/client-base.d.ts +7 -15
- package/dist/client-base.d.ts.map +1 -1
- package/dist/client-entry.js +979 -1010
- package/dist/client-entry.js.map +15 -11
- package/dist/client.d.ts +3 -3
- 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/cloud-status-transport.d.ts +53 -0
- package/dist/cloud-status-transport.d.ts.map +1 -0
- package/dist/index.d.ts +7 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3242 -4298
- package/dist/index.js.map +20 -17
- package/dist/local-app-server-session.d.ts +1 -1
- package/dist/local-app-server-session.d.ts.map +1 -1
- package/dist/local-app-server.d.ts +11 -0
- package/dist/local-app-server.d.ts.map +1 -1
- package/dist/management.d.ts +0 -7
- package/dist/management.d.ts.map +1 -1
- package/dist/remote-client-session-core.d.ts +6 -93
- package/dist/remote-client-session-core.d.ts.map +1 -1
- package/dist/remote-session-protocol.d.ts +132 -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/types.d.ts +59 -86
- package/dist/types.d.ts.map +1 -1
- package/dist/validation.d.ts.map +1 -1
- package/package.json +6 -3
- package/src/app-server-management.ts +405 -0
- package/src/app-server-session.ts +916 -0
- package/src/cli-resolver.ts +46 -0
- package/src/client-base.ts +456 -0
- package/src/client-entry.ts +31 -0
- package/src/client.ts +99 -0
- package/src/cloud-management.ts +360 -0
- package/src/cloud-sandbox.ts +117 -0
- package/src/cloud-session.ts +1055 -0
- package/src/cloud-status-transport.ts +305 -0
- package/src/index.ts +422 -0
- package/src/interactiveToolPolicy.ts +62 -0
- package/src/local-app-server-session.ts +49 -0
- package/src/local-app-server.ts +231 -0
- package/src/management-types.ts +133 -0
- package/src/management.ts +199 -0
- package/src/remote-client-session-core.ts +786 -0
- package/src/remote-session-protocol.ts +674 -0
- package/src/remote-turn-coordinator.ts +523 -0
- package/src/remote.ts +177 -0
- package/src/repositories.ts +340 -0
- package/src/request-ids.ts +33 -0
- package/src/stream-events.ts +88 -0
- package/src/tool-helpers.ts +147 -0
- package/src/types.ts +1281 -0
- package/src/validation.ts +238 -0
- package/src/websocket.ts +22 -0
- package/dist/protocol.d.ts +0 -205
- package/dist/protocol.d.ts.map +0 -1
- package/dist/session.d.ts +0 -155
- package/dist/session.d.ts.map +0 -1
- package/dist/transport.d.ts +0 -53
- package/dist/transport.d.ts.map +0 -1
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK Validation
|
|
3
|
+
*
|
|
4
|
+
* Validates user-provided options before spawning the CLI.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
CreateSessionOptions,
|
|
9
|
+
CreateAgentOptions,
|
|
10
|
+
MemoryItem,
|
|
11
|
+
CreateBlock,
|
|
12
|
+
SystemPromptPreset,
|
|
13
|
+
SkillSource,
|
|
14
|
+
DreamingOptions,
|
|
15
|
+
} from "./types.js";
|
|
16
|
+
|
|
17
|
+
const VALID_SKILL_SOURCES: SkillSource[] = [
|
|
18
|
+
"bundled",
|
|
19
|
+
"global",
|
|
20
|
+
"agent",
|
|
21
|
+
"project",
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
const VALID_REASONING_EFFORTS = [
|
|
25
|
+
"none",
|
|
26
|
+
"minimal",
|
|
27
|
+
"low",
|
|
28
|
+
"medium",
|
|
29
|
+
"high",
|
|
30
|
+
"xhigh",
|
|
31
|
+
] as const;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Extract block labels from memory items.
|
|
35
|
+
*/
|
|
36
|
+
function getBlockLabels(memory: MemoryItem[]): string[] {
|
|
37
|
+
return memory
|
|
38
|
+
.map((item) => {
|
|
39
|
+
if (typeof item === "string") return item; // preset name
|
|
40
|
+
if ("label" in item) return (item as CreateBlock).label; // CreateBlock
|
|
41
|
+
return null; // blockId - no label to check
|
|
42
|
+
})
|
|
43
|
+
.filter((label): label is string => label !== null);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function validateApprovalRecoveryOptions(options: CreateSessionOptions): void {
|
|
47
|
+
if (
|
|
48
|
+
options.maxApprovalRecoveryAttempts !== undefined &&
|
|
49
|
+
(!Number.isInteger(options.maxApprovalRecoveryAttempts) ||
|
|
50
|
+
options.maxApprovalRecoveryAttempts < 0)
|
|
51
|
+
) {
|
|
52
|
+
throw new Error(
|
|
53
|
+
"Invalid maxApprovalRecoveryAttempts. Expected a non-negative integer."
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (
|
|
58
|
+
options.approvalRecoveryTimeoutMs !== undefined &&
|
|
59
|
+
(!Number.isInteger(options.approvalRecoveryTimeoutMs) ||
|
|
60
|
+
options.approvalRecoveryTimeoutMs <= 0)
|
|
61
|
+
) {
|
|
62
|
+
throw new Error(
|
|
63
|
+
"Invalid approvalRecoveryTimeoutMs. Expected a positive integer."
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function validateRemovedSessionOptions(options: CreateSessionOptions): void {
|
|
69
|
+
const removedOptions = options as CreateSessionOptions & Record<string, unknown>;
|
|
70
|
+
if (removedOptions.systemPrompt !== undefined) {
|
|
71
|
+
throw new Error("systemPrompt is not supported when opening an existing agent session.");
|
|
72
|
+
}
|
|
73
|
+
if (removedOptions.disallowedTools !== undefined) {
|
|
74
|
+
throw new Error("disallowedTools is not supported when opening an existing agent session.");
|
|
75
|
+
}
|
|
76
|
+
if (removedOptions.systemInfoReminder !== undefined) {
|
|
77
|
+
throw new Error("systemInfoReminder is not supported when opening an existing agent session.");
|
|
78
|
+
}
|
|
79
|
+
if (removedOptions.includePartialMessages !== undefined) {
|
|
80
|
+
throw new Error("includePartialMessages is not supported by app-server sessions.");
|
|
81
|
+
}
|
|
82
|
+
if (
|
|
83
|
+
options.dreaming &&
|
|
84
|
+
"behavior" in options.dreaming &&
|
|
85
|
+
options.dreaming.behavior !== undefined
|
|
86
|
+
) {
|
|
87
|
+
throw new Error("dreaming.behavior is not supported when opening an existing agent session.");
|
|
88
|
+
}
|
|
89
|
+
if (removedOptions.memfsStartup !== undefined) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
"memfsStartup is not supported by the SDK.",
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Validate systemPrompt preset value.
|
|
98
|
+
*/
|
|
99
|
+
function validateSystemPromptPreset(preset: string): void {
|
|
100
|
+
const validPresets = [
|
|
101
|
+
"default",
|
|
102
|
+
"letta-claude",
|
|
103
|
+
"letta-codex",
|
|
104
|
+
"letta-gemini",
|
|
105
|
+
"claude",
|
|
106
|
+
"codex",
|
|
107
|
+
"gemini",
|
|
108
|
+
];
|
|
109
|
+
if (!validPresets.includes(preset)) {
|
|
110
|
+
throw new Error(
|
|
111
|
+
`Invalid system prompt preset '${preset}'. ` +
|
|
112
|
+
`Valid presets: ${validPresets.join(", ")}`
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function validateSkillSources(sources: SkillSource[] | undefined): void {
|
|
118
|
+
if (sources === undefined) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
for (const source of sources) {
|
|
123
|
+
if (!VALID_SKILL_SOURCES.includes(source)) {
|
|
124
|
+
throw new Error(
|
|
125
|
+
`Invalid skill source '${source}'. Valid values: ${VALID_SKILL_SOURCES.join(", ")}`
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function validateDreamingOptions(dreaming: DreamingOptions | undefined): void {
|
|
132
|
+
if (dreaming === undefined) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (
|
|
137
|
+
dreaming.trigger !== undefined &&
|
|
138
|
+
!["off", "step-count", "compaction-event"].includes(dreaming.trigger)
|
|
139
|
+
) {
|
|
140
|
+
throw new Error(
|
|
141
|
+
`Invalid dreaming.trigger '${String(dreaming.trigger)}'. Valid values: off, step-count, compaction-event`
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (
|
|
146
|
+
dreaming.behavior !== undefined &&
|
|
147
|
+
!["reminder", "auto-launch"].includes(dreaming.behavior)
|
|
148
|
+
) {
|
|
149
|
+
throw new Error(
|
|
150
|
+
`Invalid dreaming.behavior '${String(dreaming.behavior)}'. Valid values: reminder, auto-launch`
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (
|
|
155
|
+
dreaming.stepCount !== undefined &&
|
|
156
|
+
(!Number.isInteger(dreaming.stepCount) || dreaming.stepCount <= 0)
|
|
157
|
+
) {
|
|
158
|
+
throw new Error(
|
|
159
|
+
"Invalid dreaming.stepCount. Expected a positive integer."
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function validateReasoningEffort(value: unknown): void {
|
|
165
|
+
if (value === undefined) return;
|
|
166
|
+
if (
|
|
167
|
+
typeof value !== "string" ||
|
|
168
|
+
!VALID_REASONING_EFFORTS.includes(value as (typeof VALID_REASONING_EFFORTS)[number])
|
|
169
|
+
) {
|
|
170
|
+
throw new Error(
|
|
171
|
+
`Invalid reasoningEffort '${String(value)}'. Valid values: ${VALID_REASONING_EFFORTS.join(", ")}`
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Validate CreateSessionOptions (used by createSession and resumeSession).
|
|
178
|
+
*/
|
|
179
|
+
export function validateCreateSessionOptions(options: CreateSessionOptions): void {
|
|
180
|
+
validateSkillSources(options.skillSources);
|
|
181
|
+
validateReasoningEffort(options.reasoningEffort);
|
|
182
|
+
validateDreamingOptions(options.dreaming);
|
|
183
|
+
validateApprovalRecoveryOptions(options);
|
|
184
|
+
validateRemovedSessionOptions(options);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Validate CreateAgentOptions (used by createAgent).
|
|
189
|
+
*/
|
|
190
|
+
export function validateCreateAgentOptions(options: CreateAgentOptions): void {
|
|
191
|
+
// Validate memory/persona consistency
|
|
192
|
+
if (options.memory !== undefined) {
|
|
193
|
+
const blockLabels = getBlockLabels(options.memory);
|
|
194
|
+
|
|
195
|
+
if (options.persona !== undefined && !blockLabels.includes("persona")) {
|
|
196
|
+
throw new Error(
|
|
197
|
+
"Cannot set 'persona' value - block not included in 'memory'. " +
|
|
198
|
+
"Either add 'persona' to memory array or remove the persona option."
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (options.human !== undefined && !blockLabels.includes("human")) {
|
|
203
|
+
throw new Error(
|
|
204
|
+
"Cannot set 'human' value - block not included in 'memory'. " +
|
|
205
|
+
"Either add 'human' to memory array or remove the human option."
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Validate systemPrompt preset if provided as preset object
|
|
211
|
+
if (
|
|
212
|
+
options.systemPrompt !== undefined &&
|
|
213
|
+
typeof options.systemPrompt === "object"
|
|
214
|
+
) {
|
|
215
|
+
validateSystemPromptPreset(options.systemPrompt.preset);
|
|
216
|
+
} else if (
|
|
217
|
+
options.systemPrompt !== undefined &&
|
|
218
|
+
typeof options.systemPrompt === "string"
|
|
219
|
+
) {
|
|
220
|
+
// Check if it's a preset name (if so, validate it)
|
|
221
|
+
const validPresets = [
|
|
222
|
+
"default",
|
|
223
|
+
"letta-claude",
|
|
224
|
+
"letta-codex",
|
|
225
|
+
"letta-gemini",
|
|
226
|
+
"claude",
|
|
227
|
+
"codex",
|
|
228
|
+
"gemini",
|
|
229
|
+
] as const;
|
|
230
|
+
if (validPresets.includes(options.systemPrompt as SystemPromptPreset)) {
|
|
231
|
+
validateSystemPromptPreset(options.systemPrompt);
|
|
232
|
+
}
|
|
233
|
+
// If not a preset, it's a custom string - no validation needed
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
validateSkillSources(options.skillSources);
|
|
237
|
+
validateDreamingOptions(options.dreaming);
|
|
238
|
+
}
|
package/src/websocket.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
LettaCodeReactNativeSocketConstructor,
|
|
3
|
+
LettaCodeSocketConstructor,
|
|
4
|
+
LettaCodeSocketOptions,
|
|
5
|
+
} from "./types.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Adapt React Native's three-argument WebSocket constructor to the SDK's
|
|
9
|
+
* Node-compatible constructor shape. This is only needed when a remote
|
|
10
|
+
* app-server authenticates its websocket upgrade with headers. Cloud clients
|
|
11
|
+
* should prefer `webSocketAuth: "query"`.
|
|
12
|
+
*/
|
|
13
|
+
export function createReactNativeWebSocketConstructor(
|
|
14
|
+
WebSocket: LettaCodeReactNativeSocketConstructor,
|
|
15
|
+
): LettaCodeSocketConstructor {
|
|
16
|
+
class ReactNativeWebSocketAdapter {
|
|
17
|
+
constructor(url: string, options?: LettaCodeSocketOptions) {
|
|
18
|
+
return new WebSocket(url, undefined, options);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return ReactNativeWebSocketAdapter as unknown as LettaCodeSocketConstructor;
|
|
22
|
+
}
|
package/dist/protocol.d.ts
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Local protocol type surface consumed by the SDK.
|
|
3
|
-
*
|
|
4
|
-
* @letta-ai/letta-code@0.27.11 publishes these declarations under an internal
|
|
5
|
-
* dist path while its package.json points the public `./protocol` export at a
|
|
6
|
-
* missing file. Keep the SDK's public types self-contained so CI and consumers
|
|
7
|
-
* do not depend on that broken subpath export.
|
|
8
|
-
*/
|
|
9
|
-
export interface MessageEnvelope {
|
|
10
|
-
type: string;
|
|
11
|
-
session_id?: string;
|
|
12
|
-
uuid?: string;
|
|
13
|
-
timestamp?: string;
|
|
14
|
-
event_seq?: number;
|
|
15
|
-
agent_id?: string;
|
|
16
|
-
conversation_id?: string;
|
|
17
|
-
[key: string]: unknown;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* System prompt preset configuration used by the CLI protocol.
|
|
21
|
-
*/
|
|
22
|
-
export interface SystemPromptPresetConfig {
|
|
23
|
-
type: "preset";
|
|
24
|
-
preset: string;
|
|
25
|
-
append?: string;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Custom memory block definition accepted when creating agents.
|
|
29
|
-
*/
|
|
30
|
-
export interface CreateBlock {
|
|
31
|
-
label: string;
|
|
32
|
-
value: string;
|
|
33
|
-
base_template_id?: string | null;
|
|
34
|
-
deployment_id?: string | null;
|
|
35
|
-
description?: string | null;
|
|
36
|
-
entity_id?: string | null;
|
|
37
|
-
hidden?: boolean | null;
|
|
38
|
-
is_template?: boolean;
|
|
39
|
-
limit?: number;
|
|
40
|
-
metadata?: Record<string, unknown> | null;
|
|
41
|
-
preserve_on_migration?: boolean | null;
|
|
42
|
-
project_id?: string | null;
|
|
43
|
-
read_only?: boolean;
|
|
44
|
-
tags?: string[] | null;
|
|
45
|
-
template_id?: string | null;
|
|
46
|
-
template_name?: string | null;
|
|
47
|
-
}
|
|
48
|
-
export interface SystemInitMessage extends MessageEnvelope {
|
|
49
|
-
type: "system";
|
|
50
|
-
subtype: "init";
|
|
51
|
-
agent_id: string;
|
|
52
|
-
conversation_id: string;
|
|
53
|
-
model: string;
|
|
54
|
-
tools: string[];
|
|
55
|
-
cwd: string;
|
|
56
|
-
mcp_servers: Array<{
|
|
57
|
-
name: string;
|
|
58
|
-
status: string;
|
|
59
|
-
}>;
|
|
60
|
-
permission_mode: string;
|
|
61
|
-
slash_commands: string[];
|
|
62
|
-
memfs_enabled?: boolean;
|
|
63
|
-
skill_sources?: Array<"bundled" | "global" | "agent" | "project">;
|
|
64
|
-
system_info_reminder_enabled?: boolean;
|
|
65
|
-
reflection_trigger?: "off" | "step-count" | "compaction-event";
|
|
66
|
-
reflection_behavior?: "reminder" | "auto-launch";
|
|
67
|
-
reflection_step_count?: number;
|
|
68
|
-
}
|
|
69
|
-
export interface MessageWire extends MessageEnvelope {
|
|
70
|
-
type: "message";
|
|
71
|
-
message_type?: string;
|
|
72
|
-
run_id?: string;
|
|
73
|
-
}
|
|
74
|
-
export interface StreamEvent extends MessageEnvelope {
|
|
75
|
-
type: "stream_event";
|
|
76
|
-
event: unknown;
|
|
77
|
-
}
|
|
78
|
-
export type ResultSubtype = "success" | "interrupted" | "error" | string;
|
|
79
|
-
export interface ResultMessage extends MessageEnvelope {
|
|
80
|
-
type: "result";
|
|
81
|
-
subtype: ResultSubtype;
|
|
82
|
-
agent_id?: string;
|
|
83
|
-
conversation_id: string;
|
|
84
|
-
duration_ms: number;
|
|
85
|
-
duration_api_ms?: number;
|
|
86
|
-
num_turns?: number;
|
|
87
|
-
result?: string | null;
|
|
88
|
-
run_ids?: string[];
|
|
89
|
-
usage?: unknown;
|
|
90
|
-
stop_reason?: string;
|
|
91
|
-
}
|
|
92
|
-
export interface ErrorMessage extends MessageEnvelope {
|
|
93
|
-
type: "error";
|
|
94
|
-
message: string;
|
|
95
|
-
stop_reason: string;
|
|
96
|
-
run_id?: string;
|
|
97
|
-
api_error?: Record<string, unknown>;
|
|
98
|
-
}
|
|
99
|
-
export interface CanUseToolControlRequest {
|
|
100
|
-
subtype: "can_use_tool";
|
|
101
|
-
tool_name: string;
|
|
102
|
-
input: Record<string, unknown>;
|
|
103
|
-
tool_call_id: string;
|
|
104
|
-
permission_suggestions?: unknown[];
|
|
105
|
-
blocked_path?: string | null;
|
|
106
|
-
diffs?: unknown[];
|
|
107
|
-
}
|
|
108
|
-
export interface RegisterExternalToolsRequest {
|
|
109
|
-
subtype: "register_external_tools";
|
|
110
|
-
tools: Array<{
|
|
111
|
-
name: string;
|
|
112
|
-
label?: string;
|
|
113
|
-
description: string;
|
|
114
|
-
parameters: Record<string, unknown>;
|
|
115
|
-
}>;
|
|
116
|
-
}
|
|
117
|
-
export interface BootstrapSessionStateRequest {
|
|
118
|
-
subtype: "bootstrap_session_state";
|
|
119
|
-
limit?: number;
|
|
120
|
-
order?: "asc" | "desc";
|
|
121
|
-
}
|
|
122
|
-
export interface RecoverPendingApprovalsControlRequest {
|
|
123
|
-
subtype: "recover_pending_approvals";
|
|
124
|
-
agent_id?: string;
|
|
125
|
-
conversation_id?: string;
|
|
126
|
-
}
|
|
127
|
-
export interface ListMessagesControlRequest {
|
|
128
|
-
subtype: "list_messages";
|
|
129
|
-
conversation_id?: string;
|
|
130
|
-
agent_id?: string;
|
|
131
|
-
before?: string;
|
|
132
|
-
after?: string;
|
|
133
|
-
order?: "asc" | "desc";
|
|
134
|
-
limit?: number;
|
|
135
|
-
}
|
|
136
|
-
export interface InterruptControlRequest {
|
|
137
|
-
subtype: "interrupt";
|
|
138
|
-
}
|
|
139
|
-
export interface InitializeControlRequest {
|
|
140
|
-
subtype: "initialize";
|
|
141
|
-
}
|
|
142
|
-
export interface ExecuteExternalToolControlRequest {
|
|
143
|
-
subtype: "execute_external_tool";
|
|
144
|
-
tool_call_id: string;
|
|
145
|
-
tool_name: string;
|
|
146
|
-
input: Record<string, unknown>;
|
|
147
|
-
}
|
|
148
|
-
export type ControlRequestBody = InitializeControlRequest | InterruptControlRequest | RegisterExternalToolsRequest | BootstrapSessionStateRequest | RecoverPendingApprovalsControlRequest | ListMessagesControlRequest | CanUseToolControlRequest | ExecuteExternalToolControlRequest | (Record<string, unknown> & {
|
|
149
|
-
subtype: string;
|
|
150
|
-
});
|
|
151
|
-
export interface ControlRequest extends MessageEnvelope {
|
|
152
|
-
type: "control_request";
|
|
153
|
-
request_id: string;
|
|
154
|
-
request: ControlRequestBody;
|
|
155
|
-
}
|
|
156
|
-
export interface CanUseToolResponseAllow {
|
|
157
|
-
behavior: "allow";
|
|
158
|
-
message?: string;
|
|
159
|
-
updatedInput?: Record<string, unknown> | null;
|
|
160
|
-
updatedPermissions?: unknown[];
|
|
161
|
-
}
|
|
162
|
-
export interface CanUseToolResponseDeny {
|
|
163
|
-
behavior: "deny";
|
|
164
|
-
message: string;
|
|
165
|
-
interrupt?: boolean;
|
|
166
|
-
}
|
|
167
|
-
export type CanUseToolResponse = CanUseToolResponseAllow | CanUseToolResponseDeny;
|
|
168
|
-
export interface ExternalToolResultContent {
|
|
169
|
-
type: "text" | "image";
|
|
170
|
-
text?: string;
|
|
171
|
-
data?: string;
|
|
172
|
-
mimeType?: string;
|
|
173
|
-
}
|
|
174
|
-
export interface ExternalToolResultResponse {
|
|
175
|
-
subtype: "external_tool_result";
|
|
176
|
-
request_id: string;
|
|
177
|
-
tool_call_id: string;
|
|
178
|
-
content: ExternalToolResultContent[];
|
|
179
|
-
is_error: boolean;
|
|
180
|
-
}
|
|
181
|
-
export type ControlResponseBody = {
|
|
182
|
-
subtype: "success";
|
|
183
|
-
request_id: string;
|
|
184
|
-
response?: CanUseToolResponse | Record<string, unknown>;
|
|
185
|
-
} | {
|
|
186
|
-
subtype: "error";
|
|
187
|
-
request_id: string;
|
|
188
|
-
error: string;
|
|
189
|
-
} | ExternalToolResultResponse;
|
|
190
|
-
export interface ControlResponse extends MessageEnvelope {
|
|
191
|
-
type: "control_response";
|
|
192
|
-
response: ControlResponseBody;
|
|
193
|
-
}
|
|
194
|
-
export interface RetryMessage extends MessageEnvelope {
|
|
195
|
-
type: "retry";
|
|
196
|
-
reason: string;
|
|
197
|
-
attempt: number;
|
|
198
|
-
max_attempts: number;
|
|
199
|
-
delay_ms: number;
|
|
200
|
-
run_id?: string;
|
|
201
|
-
}
|
|
202
|
-
export type WireMessage = SystemInitMessage | MessageWire | StreamEvent | ResultMessage | ErrorMessage | RetryMessage | ControlRequest | ControlResponse | (MessageEnvelope & {
|
|
203
|
-
type: string;
|
|
204
|
-
});
|
|
205
|
-
//# sourceMappingURL=protocol.d.ts.map
|
package/dist/protocol.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,CAAC,EAAE,OAAO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U,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzD,GACD;IACE,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf,GACD,0BAA0B,CAAC;AAE/B,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,IAAI,EAAE,kBAAkB,CAAC;IACzB,QAAQ,EAAE,mBAAmB,CAAC;CAC/B;AAED,MAAM,WAAW,YAAa,SAAQ,eAAe;IACnD,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,WAAW,GACnB,iBAAiB,GACjB,WAAW,GACX,WAAW,GACX,aAAa,GACb,YAAY,GACZ,YAAY,GACZ,cAAc,GACd,eAAe,GACf,CAAC,eAAe,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC"}
|
package/dist/session.d.ts
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Session
|
|
3
|
-
*
|
|
4
|
-
* Represents a conversation session with a Letta agent.
|
|
5
|
-
* Implements the V2 API pattern: send() / receive()
|
|
6
|
-
*/
|
|
7
|
-
import type { InternalSessionOptions, SDKMessage, SDKInitMessage, SDKResultMessage, SendMessage, ListMessagesOptions, ListMessagesResult, ListModelsResult, BootstrapStateOptions, BootstrapStateResult, ChangeDeviceStateOptions, GetDeviceStatusOptions, SessionDeviceStatus, RunTurnOptions, RecoverPendingApprovalsOptions, RecoverPendingApprovalsResult, RemoveQueuedMessageResult, SDKProtocolCommand, SDKProtocolMessage, SendCommandOptions, UpdateModelOptions, UpdateModelResult } from "./types.js";
|
|
8
|
-
export declare class Session implements AsyncDisposable {
|
|
9
|
-
private options;
|
|
10
|
-
private transport;
|
|
11
|
-
private _agentId;
|
|
12
|
-
private _sessionId;
|
|
13
|
-
private _conversationId;
|
|
14
|
-
private initialized;
|
|
15
|
-
private closed;
|
|
16
|
-
private initializePromise;
|
|
17
|
-
private externalTools;
|
|
18
|
-
private streamQueue;
|
|
19
|
-
private streamResolvers;
|
|
20
|
-
private pumpPromise;
|
|
21
|
-
private pumpClosed;
|
|
22
|
-
private droppedStreamMessages;
|
|
23
|
-
private sendGeneration;
|
|
24
|
-
private lastCompletedRunIds;
|
|
25
|
-
private controlResponseWaiters;
|
|
26
|
-
constructor(options?: InternalSessionOptions);
|
|
27
|
-
/**
|
|
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.
|
|
34
|
-
*/
|
|
35
|
-
initialize(): Promise<SDKInitMessage>;
|
|
36
|
-
private performInitialize;
|
|
37
|
-
private cleanupFailedInitialize;
|
|
38
|
-
/**
|
|
39
|
-
* Send a message to the agent
|
|
40
|
-
*
|
|
41
|
-
* @param message - Text string or multimodal content array
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* // Simple text
|
|
45
|
-
* await session.send("Hello!");
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* // With image
|
|
49
|
-
* await session.send([
|
|
50
|
-
* { type: "text", text: "What's in this image?" },
|
|
51
|
-
* { type: "image", source: { type: "base64", mediaType: "image/png", data: "..." } }
|
|
52
|
-
* ]);
|
|
53
|
-
*/
|
|
54
|
-
send(message: SendMessage): Promise<void>;
|
|
55
|
-
/**
|
|
56
|
-
* Run a full turn (send + stream terminal result), with optional bounded
|
|
57
|
-
* SDK-owned approval-conflict recovery.
|
|
58
|
-
*/
|
|
59
|
-
runTurn(message: SendMessage, options?: RunTurnOptions): Promise<SDKResultMessage>;
|
|
60
|
-
/**
|
|
61
|
-
* Ask the CLI to recover pending approvals for the current
|
|
62
|
-
* agent/conversation context.
|
|
63
|
-
*/
|
|
64
|
-
recoverPendingApprovals(options?: RecoverPendingApprovalsOptions): Promise<RecoverPendingApprovalsResult>;
|
|
65
|
-
private resolveMaxApprovalRecoveryAttempts;
|
|
66
|
-
private resolveApprovalRecoveryTimeoutMs;
|
|
67
|
-
private toTerminalApprovalConflictResult;
|
|
68
|
-
private runSingleTurn;
|
|
69
|
-
/**
|
|
70
|
-
* Stream messages from the agent
|
|
71
|
-
*/
|
|
72
|
-
stream(): AsyncGenerator<SDKMessage>;
|
|
73
|
-
private startBackgroundPump;
|
|
74
|
-
private runBackgroundPump;
|
|
75
|
-
private handleControlRequest;
|
|
76
|
-
private enqueueStreamMessage;
|
|
77
|
-
private nextBufferedMessage;
|
|
78
|
-
private resolveAllStreamWaiters;
|
|
79
|
-
private getMessageRunId;
|
|
80
|
-
private updateCompletedRunIds;
|
|
81
|
-
/**
|
|
82
|
-
* Register external tools with the CLI
|
|
83
|
-
*/
|
|
84
|
-
private registerExternalTools;
|
|
85
|
-
/**
|
|
86
|
-
* Convert TypeBox schema to JSON Schema
|
|
87
|
-
*/
|
|
88
|
-
private schemaToJsonSchema;
|
|
89
|
-
/**
|
|
90
|
-
* Handle execute_external_tool control request from CLI
|
|
91
|
-
*/
|
|
92
|
-
private handleExecuteExternalTool;
|
|
93
|
-
/**
|
|
94
|
-
* Handle can_use_tool control request from CLI (Claude SDK compatible format)
|
|
95
|
-
*/
|
|
96
|
-
private handleCanUseTool;
|
|
97
|
-
/**
|
|
98
|
-
* Abort the current operation (interrupt without closing the session)
|
|
99
|
-
*/
|
|
100
|
-
abort(): Promise<void>;
|
|
101
|
-
private requestControlResponse;
|
|
102
|
-
/**
|
|
103
|
-
* Fetch a page of conversation messages via the CLI control protocol.
|
|
104
|
-
*
|
|
105
|
-
* The session must be initialized before calling this method.
|
|
106
|
-
* Safe to call concurrently with an active stream() — the pump routes
|
|
107
|
-
* matching control_response messages to this waiter without touching the
|
|
108
|
-
* stream queue.
|
|
109
|
-
*/
|
|
110
|
-
listMessages(options?: ListMessagesOptions): Promise<ListMessagesResult>;
|
|
111
|
-
listModels(): Promise<ListModelsResult>;
|
|
112
|
-
sendCommand(command: SDKProtocolCommand): Promise<void>;
|
|
113
|
-
sendCommand<TResponse extends SDKProtocolMessage = SDKProtocolMessage>(command: SDKProtocolCommand, options: SendCommandOptions): Promise<TResponse>;
|
|
114
|
-
updateModel(_update: string | UpdateModelOptions): Promise<UpdateModelResult>;
|
|
115
|
-
changeDeviceState(_updates: ChangeDeviceStateOptions): Promise<void>;
|
|
116
|
-
removeQueuedMessage(_itemId: string): Promise<RemoveQueuedMessageResult>;
|
|
117
|
-
getDeviceStatus(_options?: GetDeviceStatusOptions): Promise<SessionDeviceStatus>;
|
|
118
|
-
onDeviceStatus(_listener: (status: SessionDeviceStatus) => void): () => void;
|
|
119
|
-
/**
|
|
120
|
-
* Fetch all data needed to render the initial conversation view in one round-trip.
|
|
121
|
-
*
|
|
122
|
-
* Returns resolved session metadata + initial history page + pending approval flag
|
|
123
|
-
* + optional timing breakdown. This is faster than separate initialize() + listMessages()
|
|
124
|
-
* calls because the CLI collects and returns everything in a single control response.
|
|
125
|
-
*
|
|
126
|
-
* The session must be initialized before calling this method.
|
|
127
|
-
*/
|
|
128
|
-
bootstrapState(options?: BootstrapStateOptions): Promise<BootstrapStateResult>;
|
|
129
|
-
updateToolset(_toolsetPreference: string): Promise<void>;
|
|
130
|
-
/**
|
|
131
|
-
* Close the session
|
|
132
|
-
*/
|
|
133
|
-
close(): void;
|
|
134
|
-
/**
|
|
135
|
-
* Get the agent ID (available after initialization)
|
|
136
|
-
*/
|
|
137
|
-
get agentId(): string | null;
|
|
138
|
-
/**
|
|
139
|
-
* Get the session ID (available after initialization)
|
|
140
|
-
*/
|
|
141
|
-
get sessionId(): string | null;
|
|
142
|
-
/**
|
|
143
|
-
* Get the conversation ID (available after initialization)
|
|
144
|
-
*/
|
|
145
|
-
get conversationId(): string | null;
|
|
146
|
-
/**
|
|
147
|
-
* AsyncDisposable implementation for `await using`
|
|
148
|
-
*/
|
|
149
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
150
|
-
/**
|
|
151
|
-
* Transform wire message to SDK message
|
|
152
|
-
*/
|
|
153
|
-
private transformMessage;
|
|
154
|
-
}
|
|
155
|
-
//# sourceMappingURL=session.d.ts.map
|
package/dist/session.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,sBAAsB,EACtB,mBAAmB,EAEnB,cAAc,EACd,8BAA8B,EAC9B,6BAA6B,EAC7B,yBAAyB,EACzB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAiFpB,qBAAa,OAAQ,YAAW,eAAe;IA+B3C,OAAO,CAAC,OAAO;IA9BjB,OAAO,CAAC,SAAS,CAAsB;IACvC,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,eAAe,CAAuB;IAC9C,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,iBAAiB,CAAwC;IACjE,OAAO,CAAC,aAAa,CAAwC;IAC7D,OAAO,CAAC,WAAW,CAA+B;IAClD,OAAO,CAAC,eAAe,CAA0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|
|
|
1
|
-
/**
|
|
2
|
-
* SubprocessTransport
|
|
3
|
-
*
|
|
4
|
-
* Spawns the Letta Code CLI and communicates via stdin/stdout JSON streams.
|
|
5
|
-
*/
|
|
6
|
-
import type { InternalSessionOptions, WireMessage } from "./types.js";
|
|
7
|
-
/**
|
|
8
|
-
* Build the CLI argument array for a given set of session options.
|
|
9
|
-
*
|
|
10
|
-
* Exported as a pure function for testing — this IS the real production code
|
|
11
|
-
* path. SubprocessTransport.buildArgs() delegates here.
|
|
12
|
-
*/
|
|
13
|
-
export declare function buildCliArgs(options: InternalSessionOptions): string[];
|
|
14
|
-
export declare class SubprocessTransport {
|
|
15
|
-
private options;
|
|
16
|
-
private process;
|
|
17
|
-
private stdout;
|
|
18
|
-
private messageQueue;
|
|
19
|
-
private messageResolvers;
|
|
20
|
-
private closed;
|
|
21
|
-
private agentId?;
|
|
22
|
-
private wireMessageCount;
|
|
23
|
-
private lastMessageAt;
|
|
24
|
-
private stderrLines;
|
|
25
|
-
constructor(options?: InternalSessionOptions);
|
|
26
|
-
/**
|
|
27
|
-
* Start the CLI subprocess
|
|
28
|
-
*/
|
|
29
|
-
connect(): Promise<void>;
|
|
30
|
-
/**
|
|
31
|
-
* Send a message to the CLI via stdin
|
|
32
|
-
*/
|
|
33
|
-
write(data: object): Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* Read the next message from the CLI
|
|
36
|
-
*/
|
|
37
|
-
read(): Promise<WireMessage | null>;
|
|
38
|
-
/**
|
|
39
|
-
* Async iterator for messages
|
|
40
|
-
*/
|
|
41
|
-
messages(): AsyncGenerator<WireMessage>;
|
|
42
|
-
/**
|
|
43
|
-
* Close the transport
|
|
44
|
-
*/
|
|
45
|
-
close(): void;
|
|
46
|
-
get isClosed(): boolean;
|
|
47
|
-
/** Return buffered stderr output from the CLI subprocess. */
|
|
48
|
-
getStderr(): string;
|
|
49
|
-
private handleMessage;
|
|
50
|
-
private buildArgs;
|
|
51
|
-
private findCli;
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=transport.d.ts.map
|