@letta-ai/letta-agent-sdk 0.6.3 → 0.7.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/src/types.ts CHANGED
@@ -109,6 +109,25 @@ export type MessageContentItem = TextContent | ImageContent;
109
109
  */
110
110
  export type SendMessage = string | MessageContentItem[];
111
111
 
112
+ /**
113
+ * Per-turn options accepted by `send()`.
114
+ */
115
+ export interface SendOptions {
116
+ /**
117
+ * Caller-supplied offline threading id (OTID) for this user message.
118
+ *
119
+ * The OTID is the canonical optimistic-input-matching key: stamp the row you
120
+ * render optimistically with the same value and you can correlate it with the
121
+ * persisted user message that comes back from the stream or from
122
+ * `listMessages()`. It is also used as the turn's `clientMessageId`, so it
123
+ * shows up on `SDKQueueItem.clientMessageId` while the message is queued.
124
+ *
125
+ * When omitted the SDK generates one. Must be a non-empty string; reuse the
126
+ * same value when retrying a send so the runtime can deduplicate it.
127
+ */
128
+ otid?: string;
129
+ }
130
+
112
131
  // ═══════════════════════════════════════════════════════════════
113
132
  // SKILLS / REMINDER / DREAMING TYPES
114
133
  // ═══════════════════════════════════════════════════════════════
@@ -663,6 +682,13 @@ export interface CreateSessionOptions {
663
682
  /** Working directory for the CLI process */
664
683
  cwd?: string;
665
684
 
685
+ /**
686
+ * Run without loading or changing the agent's MemFS. The agent and
687
+ * conversation remain persistent; this only changes the session's local
688
+ * memory, agent-skill, agent-mod, transcript, and reflection behavior.
689
+ */
690
+ stateless?: boolean;
691
+
666
692
  /**
667
693
  * Restrict available skills by source.
668
694
  * Empty array disables all skills (`--no-skills`).
@@ -730,7 +756,11 @@ export interface LettaCodeClientSessionOptions extends CreateSessionOptions {
730
756
  }
731
757
 
732
758
  export interface LettaCodeSession extends AsyncDisposable {
733
- send(message: SendMessage): Promise<void>;
759
+ /**
760
+ * Send a user message. Pass `{ otid }` to supply your own correlation id for
761
+ * optimistic reconciliation; the SDK generates one when omitted.
762
+ */
763
+ send(message: SendMessage, options?: SendOptions): Promise<void>;
734
764
  stream(): AsyncGenerator<SDKMessage>;
735
765
  abort(): Promise<void>;
736
766
  sendCommand(command: SDKProtocolCommand): Promise<void>;
package/src/validation.ts CHANGED
@@ -223,6 +223,22 @@ function validateMcpServers(servers: McpServers | undefined): void {
223
223
  * Validate CreateSessionOptions (used by createSession and resumeSession).
224
224
  */
225
225
  export function validateCreateSessionOptions(options: CreateSessionOptions): void {
226
+ if (options.stateless !== undefined && typeof options.stateless !== "boolean") {
227
+ throw new Error("Invalid stateless. Expected a boolean.");
228
+ }
229
+ if (options.stateless) {
230
+ const persistedOption = [
231
+ ["model", options.model],
232
+ ["reasoningEffort", options.reasoningEffort],
233
+ ["dreaming", options.dreaming],
234
+ ["resources", options.resources],
235
+ ].find(([, value]) => value !== undefined);
236
+ if (persistedOption) {
237
+ throw new Error(
238
+ `stateless sessions cannot set ${persistedOption[0]} because it changes persisted agent configuration.`,
239
+ );
240
+ }
241
+ }
226
242
  validateClientToolset(options.toolset);
227
243
  validateSkillSources(options.skillSources);
228
244
  validateMcpServers(options.mcpServers);