@letta-ai/letta-code 0.11.0 → 0.11.2-next.1

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.
@@ -0,0 +1,214 @@
1
+ /**
2
+ * Protocol Types for Letta Code
3
+ *
4
+ * These types define:
5
+ * 1. The JSON structure emitted by headless.ts in stream-json mode (wire protocol)
6
+ * 2. Configuration types for session options (used internally and by SDK)
7
+ *
8
+ * Design principle: Compose from @letta-ai/letta-client types where possible.
9
+ */
10
+ import type { MessageCreate } from "@letta-ai/letta-client/resources/agents/agents";
11
+ import type { AssistantMessage as LettaAssistantMessage, ReasoningMessage as LettaReasoningMessage, LettaStreamingResponse, ToolCallMessage as LettaToolCallMessage, ToolCall } from "@letta-ai/letta-client/resources/agents/messages";
12
+ import type { CreateBlock } from "@letta-ai/letta-client/resources/blocks/blocks";
13
+ import type { StopReasonType } from "@letta-ai/letta-client/resources/runs/runs";
14
+ import type { ToolReturnMessage as LettaToolReturnMessage } from "@letta-ai/letta-client/resources/tools";
15
+ export type { LettaStreamingResponse, ToolCall, StopReasonType, MessageCreate, LettaToolReturnMessage, CreateBlock, };
16
+ /**
17
+ * System prompt preset configuration.
18
+ * Use this to select a built-in system prompt with optional appended text.
19
+ *
20
+ * Available presets (validated at runtime by CLI):
21
+ * - 'default' - Alias for letta-claude
22
+ * - 'letta-claude' - Full Letta Code prompt (Claude-optimized)
23
+ * - 'letta-codex' - Full Letta Code prompt (Codex-optimized)
24
+ * - 'letta-gemini' - Full Letta Code prompt (Gemini-optimized)
25
+ * - 'claude' - Basic Claude (no skills/memory instructions)
26
+ * - 'codex' - Basic Codex (no skills/memory instructions)
27
+ * - 'gemini' - Basic Gemini (no skills/memory instructions)
28
+ */
29
+ export interface SystemPromptPresetConfig {
30
+ type: "preset";
31
+ /** Preset ID (e.g., 'default', 'letta-codex'). Validated at runtime. */
32
+ preset: string;
33
+ /** Additional instructions to append to the preset */
34
+ append?: string;
35
+ }
36
+ /**
37
+ * System prompt configuration - either a raw string or preset config.
38
+ * - string: Use as the complete system prompt
39
+ * - SystemPromptPresetConfig: Use a preset, optionally with appended text
40
+ */
41
+ export type SystemPromptConfig = string | SystemPromptPresetConfig;
42
+ export interface MessageEnvelope {
43
+ session_id: string;
44
+ uuid: string;
45
+ }
46
+ export interface SystemInitMessage extends MessageEnvelope {
47
+ type: "system";
48
+ subtype: "init";
49
+ agent_id: string;
50
+ model: string;
51
+ tools: string[];
52
+ cwd: string;
53
+ mcp_servers: Array<{
54
+ name: string;
55
+ status: string;
56
+ }>;
57
+ permission_mode: string;
58
+ slash_commands: string[];
59
+ }
60
+ export type SystemMessage = SystemInitMessage;
61
+ /**
62
+ * Wire format for assistant messages.
63
+ * Extends LettaAssistantMessage with wire envelope fields.
64
+ */
65
+ export interface AssistantMessageWire extends LettaAssistantMessage, MessageEnvelope {
66
+ type: "message";
67
+ }
68
+ /**
69
+ * Wire format for tool call messages.
70
+ * Extends LettaToolCallMessage with wire envelope fields.
71
+ */
72
+ export interface ToolCallMessageWire extends LettaToolCallMessage, MessageEnvelope {
73
+ type: "message";
74
+ }
75
+ /**
76
+ * Wire format for reasoning messages.
77
+ * Extends LettaReasoningMessage with wire envelope fields.
78
+ */
79
+ export interface ReasoningMessageWire extends LettaReasoningMessage, MessageEnvelope {
80
+ type: "message";
81
+ }
82
+ /**
83
+ * Wire format for tool return messages.
84
+ * Extends LettaToolReturnMessage with wire envelope fields.
85
+ */
86
+ export interface ToolReturnMessageWire extends LettaToolReturnMessage, MessageEnvelope {
87
+ type: "message";
88
+ }
89
+ export type ContentMessage = AssistantMessageWire | ToolCallMessageWire | ReasoningMessageWire | ToolReturnMessageWire;
90
+ /**
91
+ * Generic message wrapper for spreading LettaStreamingResponse chunks.
92
+ * Used when the exact message type is determined at runtime.
93
+ */
94
+ export type MessageWire = {
95
+ type: "message";
96
+ session_id: string;
97
+ uuid: string;
98
+ } & LettaStreamingResponse;
99
+ export interface StreamEvent extends MessageEnvelope {
100
+ type: "stream_event";
101
+ event: LettaStreamingResponse;
102
+ }
103
+ export interface AutoApprovalMessage extends MessageEnvelope {
104
+ type: "auto_approval";
105
+ tool_call: ToolCall;
106
+ reason: string;
107
+ matched_rule: string;
108
+ }
109
+ export interface ErrorMessage extends MessageEnvelope {
110
+ type: "error";
111
+ /** High-level error message from the CLI */
112
+ message: string;
113
+ stop_reason: StopReasonType;
114
+ run_id?: string;
115
+ /** Nested API error when the error originated from Letta API */
116
+ api_error?: LettaStreamingResponse.LettaErrorMessage;
117
+ }
118
+ export interface RetryMessage extends MessageEnvelope {
119
+ type: "retry";
120
+ /** The stop reason that triggered the retry. Uses StopReasonType from letta-client. */
121
+ reason: StopReasonType;
122
+ attempt: number;
123
+ max_attempts: number;
124
+ delay_ms: number;
125
+ run_id?: string;
126
+ }
127
+ /**
128
+ * Result subtypes.
129
+ * For errors, use stop_reason field with StopReasonType from letta-client.
130
+ */
131
+ export type ResultSubtype = "success" | "interrupted" | "error";
132
+ /**
133
+ * Usage statistics from letta-client.
134
+ * Re-exported for convenience.
135
+ */
136
+ export type UsageStatistics = LettaStreamingResponse.LettaUsageStatistics;
137
+ export interface ResultMessage extends MessageEnvelope {
138
+ type: "result";
139
+ subtype: ResultSubtype;
140
+ agent_id: string;
141
+ duration_ms: number;
142
+ duration_api_ms: number;
143
+ num_turns: number;
144
+ result: string | null;
145
+ run_ids: string[];
146
+ usage: UsageStatistics | null;
147
+ /**
148
+ * Present when subtype is "error".
149
+ * Uses StopReasonType from letta-client (e.g., 'error', 'max_steps', 'llm_api_error').
150
+ */
151
+ stop_reason?: StopReasonType;
152
+ }
153
+ export interface ControlRequest {
154
+ type: "control_request";
155
+ request_id: string;
156
+ request: ControlRequestBody;
157
+ }
158
+ export type SdkToCliControlRequest = {
159
+ subtype: "initialize";
160
+ } | {
161
+ subtype: "interrupt";
162
+ };
163
+ export interface CanUseToolControlRequest {
164
+ subtype: "can_use_tool";
165
+ tool_name: string;
166
+ input: Record<string, unknown>;
167
+ tool_call_id: string;
168
+ /** TODO: Not implemented - suggestions for permission updates */
169
+ permission_suggestions: unknown[];
170
+ /** TODO: Not implemented - path that triggered the permission check */
171
+ blocked_path: string | null;
172
+ }
173
+ export type CliToSdkControlRequest = CanUseToolControlRequest;
174
+ export type ControlRequestBody = SdkToCliControlRequest | CliToSdkControlRequest;
175
+ export interface ControlResponse extends MessageEnvelope {
176
+ type: "control_response";
177
+ response: ControlResponseBody;
178
+ }
179
+ export type ControlResponseBody = {
180
+ subtype: "success";
181
+ request_id: string;
182
+ response?: CanUseToolResponse | Record<string, unknown>;
183
+ } | {
184
+ subtype: "error";
185
+ request_id: string;
186
+ error: string;
187
+ };
188
+ export interface CanUseToolResponseAllow {
189
+ behavior: "allow";
190
+ /** TODO: Not supported - Letta stores tool calls server-side */
191
+ updatedInput?: Record<string, unknown> | null;
192
+ /** TODO: Not implemented - dynamic permission rule updates */
193
+ updatedPermissions?: unknown[];
194
+ }
195
+ export interface CanUseToolResponseDeny {
196
+ behavior: "deny";
197
+ message: string;
198
+ /** TODO: Not wired up yet - infrastructure exists in TUI */
199
+ interrupt?: boolean;
200
+ }
201
+ export type CanUseToolResponse = CanUseToolResponseAllow | CanUseToolResponseDeny;
202
+ /**
203
+ * User input message for bidirectional communication.
204
+ * Uses MessageCreate from letta-client for multimodal content support.
205
+ */
206
+ export interface UserInput {
207
+ type: "user";
208
+ message: MessageCreate;
209
+ }
210
+ /**
211
+ * Union of all wire message types that can be emitted by headless.ts
212
+ */
213
+ export type WireMessage = SystemMessage | ContentMessage | StreamEvent | AutoApprovalMessage | ErrorMessage | RetryMessage | ResultMessage | ControlResponse | ControlRequest;
214
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/types/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AACpF,OAAO,KA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