@letta-ai/letta-agent-sdk 0.2.5 → 0.2.6

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.
Files changed (65) hide show
  1. package/README.md +135 -11
  2. package/dist/app-server-session.d.ts.map +1 -1
  3. package/dist/cloud-session.d.ts +13 -0
  4. package/dist/cloud-session.d.ts.map +1 -1
  5. package/dist/dream/agent.d.ts +55 -0
  6. package/dist/dream/agent.d.ts.map +1 -0
  7. package/dist/dream/aggregate.d.ts +38 -0
  8. package/dist/dream/aggregate.d.ts.map +1 -0
  9. package/dist/dream/batching.d.ts +12 -0
  10. package/dist/dream/batching.d.ts.map +1 -0
  11. package/dist/dream/clone.d.ts +14 -0
  12. package/dist/dream/clone.d.ts.map +1 -0
  13. package/dist/dream/cursors.d.ts +7 -0
  14. package/dist/dream/cursors.d.ts.map +1 -0
  15. package/dist/dream/index.d.ts +67 -0
  16. package/dist/dream/index.d.ts.map +1 -0
  17. package/dist/dream/memfs.d.ts +75 -0
  18. package/dist/dream/memfs.d.ts.map +1 -0
  19. package/dist/dream/normalize-core.d.ts +67 -0
  20. package/dist/dream/normalize-core.d.ts.map +1 -0
  21. package/dist/dream/prompts.d.ts +26 -0
  22. package/dist/dream/prompts.d.ts.map +1 -0
  23. package/dist/dream/redact.d.ts +3 -0
  24. package/dist/dream/redact.d.ts.map +1 -0
  25. package/dist/dream/reflect.d.ts +49 -0
  26. package/dist/dream/reflect.d.ts.map +1 -0
  27. package/dist/dream/registry.d.ts +4 -0
  28. package/dist/dream/registry.d.ts.map +1 -0
  29. package/dist/dream/runner.d.ts +30 -0
  30. package/dist/dream/runner.d.ts.map +1 -0
  31. package/dist/dream/sdk-messages.d.ts +4 -0
  32. package/dist/dream/sdk-messages.d.ts.map +1 -0
  33. package/dist/dream/select.d.ts +6 -0
  34. package/dist/dream/select.d.ts.map +1 -0
  35. package/dist/dream/sources/claude-code.d.ts +18 -0
  36. package/dist/dream/sources/claude-code.d.ts.map +1 -0
  37. package/dist/dream/sources/codex.d.ts +20 -0
  38. package/dist/dream/sources/codex.d.ts.map +1 -0
  39. package/dist/dream/sources/letta.d.ts +3 -0
  40. package/dist/dream/sources/letta.d.ts.map +1 -0
  41. package/dist/dream/sources/openhands.d.ts +43 -0
  42. package/dist/dream/sources/openhands.d.ts.map +1 -0
  43. package/dist/dream/sources/transcript-file.d.ts +8 -0
  44. package/dist/dream/sources/transcript-file.d.ts.map +1 -0
  45. package/dist/dream/store-utils.d.ts +21 -0
  46. package/dist/dream/store-utils.d.ts.map +1 -0
  47. package/dist/dream/transcripts.d.ts +27 -0
  48. package/dist/dream/transcripts.d.ts.map +1 -0
  49. package/dist/dream/types.d.ts +48 -0
  50. package/dist/dream/types.d.ts.map +1 -0
  51. package/dist/dream/workers.d.ts +12 -0
  52. package/dist/dream/workers.d.ts.map +1 -0
  53. package/dist/index.d.ts +3 -0
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +7537 -4163
  56. package/dist/index.js.map +35 -11
  57. package/dist/remote-client-session-core.d.ts +7 -2
  58. package/dist/remote-client-session-core.d.ts.map +1 -1
  59. package/dist/session.d.ts.map +1 -1
  60. package/dist/tests/advanced-session.d.ts +6 -0
  61. package/dist/tests/advanced-session.d.ts.map +1 -1
  62. package/dist/transport.d.ts.map +1 -1
  63. package/dist/types.d.ts +40 -2
  64. package/dist/types.d.ts.map +1 -1
  65. package/package.json +2 -2
package/README.md CHANGED
@@ -116,9 +116,12 @@ for await (const msg of session.stream()) {
116
116
  ### Constellation
117
117
 
118
118
  Use `backend: "cloud"` to create or resume agents hosted on Constellation. If
119
- no `environment` is provided, the SDK creates an agent-scoped sandbox, waits for
120
- it to come online, refreshes it while the session is active, and cleans it up on
121
- close.
119
+ no `environment` is provided, the SDK creates a managed sandbox, waits for it to
120
+ come online, and refreshes it while the session is active. Non-default
121
+ conversations request a conversation-scoped sandbox from supporting servers;
122
+ the default conversation and legacy servers retain the agent-scoped lifecycle.
123
+ Managed sandboxes are left for TTL cleanup by default so another session for the
124
+ same conversation can reconnect to them.
122
125
 
123
126
  ```ts
124
127
  const client = new LettaAgentClient({
@@ -127,8 +130,8 @@ const client = new LettaAgentClient({
127
130
  sandbox: {
128
131
  // Optional: defaults to a 5-minute refresh TTL.
129
132
  ttlMinutes: 5,
130
- // Optional: defaults true. Set false for concurrent same-agent sessions.
131
- terminateOnClose: true,
133
+ // Optional: defaults false. Set true only with exclusive ownership.
134
+ terminateOnClose: false,
132
135
  },
133
136
  });
134
137
 
@@ -138,7 +141,7 @@ const agentId = await client.createAgent({
138
141
  });
139
142
 
140
143
  await using session = client.resumeSession(agentId, {
141
- permissionMode: "bypassPermissions",
144
+ permissionMode: "unrestricted",
142
145
  });
143
146
 
144
147
  await session.send("Summarize this repository.");
@@ -180,10 +183,52 @@ await using session = client.resumeSession(agentId, {
180
183
  `environment` also accepts `{ id: "env-..." }` for an environment record or
181
184
  `{ deviceId: "device-..." }` for a stable device selector.
182
185
 
183
- `environment` and `sandbox` are mutually exclusive. Managed sandbox refresh and
184
- termination operate on the latest active sandbox for an agent; set
185
- `sandbox.terminateOnClose: false` when multiple SDK sessions may run
186
- concurrently against the same agent and rely on TTL cleanup instead.
186
+ `environment` and `sandbox` are mutually exclusive. Conversation-scoped
187
+ sandboxes refresh and terminate by sandbox ID. Legacy agent-scoped sandboxes
188
+ retain the latest-active ownership check. Pass `sandbox.terminateOnClose: true`
189
+ to request best-effort eager cleanup, but only when no other session or
190
+ reconnecting client needs the sandbox.
191
+
192
+ If Cloud reaps a conversation-scoped sandbox before the next refresh,
193
+ `send()` throws `CloudManagedSandboxExpiredError` before transmitting the turn.
194
+ Close the old SDK session and resume the same conversation to create a fresh
195
+ connection, then retry safely:
196
+
197
+ ```ts
198
+ import {
199
+ CloudManagedSandboxExpiredError,
200
+ LettaAgentClient,
201
+ } from "@letta-ai/letta-agent-sdk";
202
+
203
+ const client = new LettaAgentClient({
204
+ backend: "cloud",
205
+ apiKey: process.env.LETTA_API_KEY,
206
+ });
207
+ const conversationId = "conv-123";
208
+ let session = client.resumeSession(conversationId);
209
+
210
+ async function sendWithSandboxRecovery(message: string): Promise<void> {
211
+ for (let attempt = 0; attempt < 2; attempt += 1) {
212
+ try {
213
+ await session.send(message);
214
+ for await (const event of session.stream()) {
215
+ if (event.type === "assistant") console.log(event.content);
216
+ }
217
+ return;
218
+ } catch (error) {
219
+ if (!(error instanceof CloudManagedSandboxExpiredError) || attempt > 0) {
220
+ throw error;
221
+ }
222
+ session.close();
223
+ session = client.resumeSession(conversationId);
224
+ }
225
+ }
226
+ }
227
+ ```
228
+
229
+ Only retry automatically for this pre-send expiration error. If a connection
230
+ fails after `send()` succeeds, inspect conversation history before retrying
231
+ because the original message may already have reached the runtime.
187
232
 
188
233
  By default, websocket authentication uses `Authorization` headers. Set
189
234
  `webSocketAuth: "query"` for browser-style websocket clients that cannot send
@@ -238,7 +283,7 @@ const session = client.resumeSession("agent-123", {
238
283
  // For local sessions this may be a local path; for remote/Constellation
239
284
  // sessions, use a path inside the selected runtime environment.
240
285
  cwd: "/workspace/project",
241
- permissionMode: "bypassPermissions",
286
+ permissionMode: "unrestricted",
242
287
  dreaming: {
243
288
  trigger: "step-count", // off | step-count | compaction-event
244
289
  stepCount: 8,
@@ -275,6 +320,85 @@ const sync = await session.sendCommand(
275
320
  );
276
321
  ```
277
322
 
323
+ ## Dreaming
324
+
325
+ The dreaming API has three explicit components: collect normalized transcript
326
+ snapshots, initialize a guarded memory filesystem, then run a dream over the
327
+ exact transcript list. Reflection batches edit isolated clones and a final
328
+ aggregation pass synthesizes their diffs into the dream agent's MemFS.
329
+
330
+ ```typescript
331
+ import {
332
+ LettaAgentClient,
333
+ collectTranscripts,
334
+ dream,
335
+ initDreamAgent,
336
+ } from "@letta-ai/letta-agent-sdk";
337
+
338
+ const client = new LettaAgentClient({
339
+ backend: "local",
340
+ appServer: { harnessBackend: "api" },
341
+ });
342
+
343
+ // 1. Collect immutable snapshots after an exclusive cutoff. Limits apply per
344
+ // source, so this selects the five newest eligible sessions from each store.
345
+ const transcripts = await collectTranscripts({
346
+ after: "2026-07-01T00:00:00Z",
347
+ sources: [
348
+ { type: "claude", limit: 5 },
349
+ { type: "codex", limit: 5 },
350
+ ],
351
+ });
352
+
353
+ // 2. Initialize the complete starting MemFS. Seeded files may be modified but
354
+ // not deleted. New files and directories are allowed only below skills/.
355
+ const agent = await initDreamAgent(client, {
356
+ model: "anthropic/claude-opus-4-8",
357
+ memfs: {
358
+ directories: ["skills"],
359
+ files: {
360
+ "system/project/AGENTS.md":
361
+ "---\ndescription: Project guidance\n---\n\n# Project guidance\n",
362
+ },
363
+ },
364
+ guard: {
365
+ allowedNewFilePrefixes: ["skills"],
366
+ },
367
+ });
368
+
369
+ // 3. Run against the exact snapshots. The optional prompt is appended to each
370
+ // reflection batch, not to the aggregation pass.
371
+ const result = await dream({
372
+ client,
373
+ agentId: agent.agentId,
374
+ transcripts,
375
+ reflectionPrompt: "Only retain learnings relevant to this project.",
376
+ });
377
+
378
+ if (result.kind === "completed") {
379
+ console.log(result.success, result.runRoot, result.aggregation.report);
380
+ }
381
+ ```
382
+
383
+ Available transcript sources include `claude`, `codex`, `openhands`, `letta`,
384
+ and already-normalized `transcript` files. `after` compares against each
385
+ session's end time and is exclusive; `limit` keeps the latest eligible sessions
386
+ for that source spec. Use `planOnly: true` to inspect transcript selection and
387
+ batch packing without running agents.
388
+
389
+ The pre-commit guard is installed on the canonical MemFS and every reflection
390
+ clone. The SDK also validates every commit and the final working tree after
391
+ each run, so `--no-verify` cannot bypass the policy. For finer control, pass
392
+ `guard.allowedOperations` rules for exact or recursive paths. Every run records
393
+ batch inputs, output clones, diffs, normalized worker trajectories, reports,
394
+ and an immutable final aggregate snapshot under `runRoot`. See
395
+ [`examples/dream.ts`](./examples/dream.ts).
396
+
397
+ OpenHands conversations retain incremental cursors in the dream agent's SDK
398
+ state; later dreams skip records at or before the last successfully reflected
399
+ timestamp. Claude and Codex sessions are finite snapshots and remain
400
+ cursor-free.
401
+
278
402
  ## Links
279
403
 
280
404
  - Docs: https://docs.letta.com/letta-agent-sdk
@@ -1 +1 @@
1
- {"version":3,"file":"app-server-session.d.ts","sourceRoot":"","sources":["../src/app-server-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,gCAAgC,EAEtC,MAAM,wCAAwC,CAAC;AAMhD,OAAO,EACL,uBAAuB,EAIvB,KAAK,eAAe,EACpB,KAAK,6BAA6B,EAClC,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACxB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,4BAA4B,EAC5B,6BAA6B,EAC7B,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAElB,8BAA8B,EAC9B,6BAA6B,EAC7B,WAAW,EACX,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAoDpB,KAAK,kBAAkB,GAAG;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAIF,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,GAChD,MAAM,EAAE,GAAG,SAAS,CAStB;AAED,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC,4BAA4B,CAAC,GAAG;IAC5E;qEACiE;IACjE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,iEAAiE;IACjE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0EAA0E;IAC1E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4CAA4C;IAC5C,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,4EAA4E;IAC5E,QAAQ,CAAC,E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AwB;YAiExB,0BAA0B;CAoBzC"}
@@ -1,5 +1,17 @@
1
1
  import { RemoteClientSessionCore, type RuntimeSessionInit, type RuntimeSessionMode } from "./remote-client-session-core.js";
2
2
  import type { CreateAgentOptions, LettaCodeClientSessionOptions, LettaCodeCloudClientOptions } from "./types.js";
3
+ /**
4
+ * The Cloud API reaped a conversation-scoped managed sandbox before the SDK
5
+ * could refresh it. The failed refresh happens before the next turn is sent,
6
+ * so callers can safely create a new SDK session for {@link conversationId}
7
+ * and retry that turn.
8
+ */
9
+ export declare class CloudManagedSandboxExpiredError extends Error {
10
+ readonly sandboxId: string;
11
+ readonly conversationId: string;
12
+ readonly code: "managed_sandbox_expired";
13
+ constructor(sandboxId: string, conversationId: string);
14
+ }
3
15
  type CloudSessionMode = Extract<RuntimeSessionMode, {
4
16
  kind: "session";
5
17
  }>;
@@ -15,6 +27,7 @@ export declare class CloudEnvironmentSession extends RemoteClientSessionCore {
15
27
  private managedSandbox;
16
28
  private sandboxRefreshTimer;
17
29
  private sandboxRefreshInFlight;
30
+ private sandboxLifecycleClosing;
18
31
  private attachedRepositoryIds;
19
32
  private readonly cloudMode;
20
33
  constructor(cloudOptions: LettaCodeCloudClientOptions, mode: CloudSessionMode);
@@ -1 +1 @@
1
- {"version":3,"file":"cloud-session.d.ts","sourceRoot":"","sources":["../src/cloud-session.ts"],"names":[],"mappings":"AAoBA,OAAO,EACL,uBAAuB,EAIvB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACxB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAEV,kBAAkB,EAClB,6BAA6B,EAC7B,2BAA2B,EAM5B,MAAM,YAAY,CAAC;AAkFpB,KAAK,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,EAAE;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC,CAAC;AAmJzE,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,2BAA2B,GAAG,IAAI,CAerF;AA8VD,wBAAsB,gBAAgB,C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AA8B;IAC5D,OAAO,CAAC,uBAAuB,CAAS;IACxC,OAAO,CAAC,qBAAqB,CAAqB;IAClD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAmB;gBAG1B,YAAY,EAAE,2BAA2B,EAC1D,IAAI,EAAE,gBAAgB;cAWC,2BAA2B,IAAI,OAAO,CAAC,kBAAkB,CAAC;YAgErE,iBAAiB;cA8BN,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;cAUxC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;cAMjC,WAAW,IAAI,IAAI;YASxB,cAAc;YAoCd,yBAAyB;YAsBzB,0BAA0B;IAYxC,OAAO,CAAC,mBAAmB;YAkBb,qBAAqB;YAoBrB,sBAAsB;YAYtB,mBAAmB;YAenB,qBAAqB;YAYrB,kBAAkB;YAkBlB,oBAAoB;YAepB,2BAA2B;YAc3B,yBAAyB;YAQzB,8BAA8B;YAiC9B,oBAAoB;YA2DpB,qBAAqB;YAcrB,yBAAyB;YAuDzB,uBAAuB;YAqCvB,+BAA+B;IA4B7C,OAAO,CAAC,0BAA0B;IAelC,OAAO,CAAC,yBAAyB;YAMnB,qBAAqB;IAuBnC,OAAO,CAAC,uBAAuB;IAS/B,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,uBAAuB;IAO/B,OAAO,CAAC,sBAAsB;CAG/B"}
@@ -0,0 +1,55 @@
1
+ import type { LettaAgentClient } from "../client.js";
2
+ import { type MemfsGuardInstallation, type MemfsOperationRule, type MemfsStructure, type MemfsWritePolicy } from "./memfs.js";
3
+ export interface DreamAgentConfig {
4
+ schema_version: "v1";
5
+ name?: string;
6
+ createdAt: string;
7
+ /** Model for the dream agent and its lazily-created reflection worker. */
8
+ model?: string;
9
+ reflectorAgentId?: string;
10
+ memfs: {
11
+ /** Empty directories that initialization must preserve across clones. */
12
+ directories: readonly string[];
13
+ /** Persistent write policy enforced for reflection and aggregation. */
14
+ policy: MemfsWritePolicy;
15
+ };
16
+ }
17
+ export interface DreamAgentGuardOptions {
18
+ /** Directory prefixes under which agents may create new files/folders. */
19
+ allowedNewFilePrefixes?: readonly string[];
20
+ /** Optional exact/recursive overrides for create, modify, and delete. */
21
+ allowedOperations?: readonly MemfsOperationRule[];
22
+ }
23
+ export interface InitDreamAgentOptions {
24
+ name?: string;
25
+ /** Model for the dream agent and its reflection worker. */
26
+ model?: string;
27
+ /** Complete initial contents and declared empty directories for MemFS. */
28
+ memfs?: MemfsStructure;
29
+ /** Restrict what later reflection/aggregation sessions may write. */
30
+ guard?: DreamAgentGuardOptions;
31
+ /** Override the harness agents directory (primarily for tests). */
32
+ agentsDir?: string;
33
+ /** Reuse an existing memfs-enabled Letta agent instead of creating one. */
34
+ agentId?: string;
35
+ }
36
+ export interface LoadedDreamAgent {
37
+ agentId: string;
38
+ memoryDir: string;
39
+ stateDir: string;
40
+ runsDir: string;
41
+ configPath: string;
42
+ config: DreamAgentConfig;
43
+ }
44
+ export declare function saveDreamAgentConfig(agent: LoadedDreamAgent): Promise<void>;
45
+ export declare function loadDreamAgent(agentId: string, options?: {
46
+ agentsDir?: string;
47
+ }): Promise<LoadedDreamAgent>;
48
+ /** Reinstall the guard and recreate declared empty directories before a run. */
49
+ export declare function prepareDreamAgentMemfs(agent: LoadedDreamAgent): Promise<MemfsGuardInstallation>;
50
+ /**
51
+ * Create or bind a memfs-enabled Letta agent, seed its initial MemFS, commit
52
+ * that seed, and install the requested write guard.
53
+ */
54
+ export declare function initDreamAgent(client: LettaAgentClient, options?: InitDreamAgentOptions): Promise<LoadedDreamAgent>;
55
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/dream/agent.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAML,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EAC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AAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACnC,OAAO,CAAC,gBAAgB,CAAC,CAwB3B;AAED,gFAAgF;AAChF,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,gBAAgB,GACtB,OAAO,CAAC,sBAAsB,CAAC,CAOjC;AAkCD;;;GAGG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,gBAAgB,EACxB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,gBAAgB,CAAC,CAgE3B"}
@@ -0,0 +1,38 @@
1
+ import type { LettaAgentClient } from "../client.js";
2
+ import { type MemfsWritePolicy } from "./memfs.js";
3
+ import type { BatchReflectionResult } from "./reflect.js";
4
+ export interface DreamAggregationOutcome {
5
+ success: boolean;
6
+ /** The aggregator's final report (or the skip reason). */
7
+ report: string;
8
+ error?: string;
9
+ conversationId?: string;
10
+ /** Commits the aggregator landed on the target, relative to the base. */
11
+ commitCount: number;
12
+ }
13
+ export declare function runDreamAggregation(params: {
14
+ client: LettaAgentClient;
15
+ aggregatorAgentId: string;
16
+ /** The target memory filesystem the synthesis lands on. */
17
+ memoryDir: string;
18
+ runRoot: string;
19
+ reflections: BatchReflectionResult[];
20
+ /** Write policy enforced on the canonical MemFS and checked afterward. */
21
+ memfsPolicy: MemfsWritePolicy;
22
+ /**
23
+ * Persona text prepended to the prompt when the aggregating agent doesn't
24
+ * carry a dedicated aggregator persona block (a dream agent synthesizing
25
+ * its own memory).
26
+ */
27
+ personaPreamble?: string;
28
+ /**
29
+ * Additional caller instruction. The aggregator is the only stage that
30
+ * edits the target memory, so instructions about maintaining specific
31
+ * files (e.g. a projected AGENTS.md) must reach it here.
32
+ */
33
+ instruction?: string;
34
+ /** Abort: close the aggregator session and stop nudging. */
35
+ signal?: AbortSignal;
36
+ log?: (line: string) => void;
37
+ }): Promise<DreamAggregationOutcome>;
38
+ //# sourceMappingURL=aggregate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aggregate.d.ts","sourceRoot":"","sources":["../../src/dream/aggregate.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,YAAY,CAAC;AAKpB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAI1D,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,0DAA0D;IAC1D,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,yEAAyE;IACzE,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAsB,mBAAmB,CAAC,MAAM,EAAE;IAChD,MAAM,EAAE,gBAAgB,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,2DAA2D;IAC3D,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,qBAAqB,EAAE,CAAC;IACrC,0EAA0E;IAC1E,WAAW,EAAE,gBAAgB,CAAC;IAC9B;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4DAA4D;IAC5D,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9B,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA+PnC"}
@@ -0,0 +1,12 @@
1
+ import type { DiscoveredSession } from "./types.js";
2
+ export declare const DEFAULT_BATCH_TOKEN_BUDGET = 60000;
3
+ export declare const DEFAULT_MAX_SESSIONS_PER_BATCH = 10;
4
+ export interface DreamBatch {
5
+ index: number;
6
+ sessions: DiscoveredSession[];
7
+ estTokens: number;
8
+ startTime: string;
9
+ endTime: string;
10
+ }
11
+ export declare function packDreamBatches(sessions: DiscoveredSession[], tokenBudget: number, maxSessions: number): DreamBatch[];
12
+ //# sourceMappingURL=batching.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batching.d.ts","sourceRoot":"","sources":["../../src/dream/batching.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,eAAO,MAAM,0BAA0B,QAAS,CAAC;AACjD,eAAO,MAAM,8BAA8B,KAAK,CAAC;AAEjD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,iBAAiB,EAAE,EAC7B,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAClB,UAAU,EAAE,CAmCd"}
@@ -0,0 +1,14 @@
1
+ export declare function gitOutput(cwd: string, args: string[]): Promise<string>;
2
+ /**
3
+ * Clone the memory filesystem into outputDir and return the base revision the
4
+ * clone starts from (the revision batch diffs are taken against).
5
+ */
6
+ export declare function cloneMemoryTree(memoryDir: string, outputDir: string): Promise<string>;
7
+ /** Commits past the base revision, and whether the tree has uncommitted edits. */
8
+ export declare function inspectMemoryTree(memoryDir: string, baseRevision: string): Promise<{
9
+ commitCount: number;
10
+ dirty: boolean;
11
+ }>;
12
+ /** Record an immutable checkout of the final memory tree with a run. */
13
+ export declare function snapshotMemoryTree(memoryDir: string, outputDir: string): Promise<void>;
14
+ //# sourceMappingURL=clone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clone.d.ts","sourceRoot":"","sources":["../../src/dream/clone.ts"],"names":[],"mappings":"AAaA,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAG5E;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,CAOjB;AAED,kFAAkF;AAClF,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,CAelD;AAED,wEAAwE;AACxE,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAMf"}
@@ -0,0 +1,7 @@
1
+ /** sessionKey ("openhands:<conversation-id>") → last reflected timestamp. */
2
+ export type DreamCursors = Record<string, {
3
+ reflectedThrough: string;
4
+ }>;
5
+ export declare function loadDreamCursors(stateDir: string): Promise<DreamCursors>;
6
+ export declare function saveDreamCursors(stateDir: string, cursors: DreamCursors): Promise<void>;
7
+ //# sourceMappingURL=cursors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursors.d.ts","sourceRoot":"","sources":["../../src/dream/cursors.ts"],"names":[],"mappings":"AAiBA,6EAA6E;AAC7E,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,gBAAgB,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAExE,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,YAAY,CAAC,CAUvB;AAED,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,IAAI,CAAC,CAIf"}
@@ -0,0 +1,67 @@
1
+ import type { LettaAgentClient } from "../client.js";
2
+ import { type DreamBatch } from "./batching.js";
3
+ import { type DreamAggregationOutcome } from "./aggregate.js";
4
+ import { type BatchReflectionResult } from "./reflect.js";
5
+ import type { DiscoveredSession, NormalizedSession } from "./types.js";
6
+ export type { DreamBatch } from "./batching.js";
7
+ export type { DreamAggregationOutcome } from "./aggregate.js";
8
+ export type { BatchReflectionResult } from "./reflect.js";
9
+ export { packDreamBatches } from "./batching.js";
10
+ export { AGGREGATOR_PERSONA, REFLECTION_SYSTEM_PROMPT, } from "./prompts.js";
11
+ export { getTrajectorySource, listTrajectorySourceTypes } from "./registry.js";
12
+ export { type DreamAgentConfig, type DreamAgentGuardOptions, type InitDreamAgentOptions, type LoadedDreamAgent, initDreamAgent, loadDreamAgent, } from "./agent.js";
13
+ export { type MemfsOperation, type MemfsOperationRule, type MemfsStructure, type MemfsWritePolicy, } from "./memfs.js";
14
+ export { collectTranscripts, type CollectTranscriptsOptions, type Transcript, type TranscriptSourceSpec, } from "./transcripts.js";
15
+ export type { DiscoveredSession, NormalizedRecord, NormalizedSession, TrajectorySource, } from "./types.js";
16
+ export interface DreamOptions {
17
+ client: LettaAgentClient;
18
+ /** Initialized dream-agent id returned by initDreamAgent(). */
19
+ agentId: string;
20
+ /** Immutable normalized transcript snapshots to reflect on. */
21
+ transcripts: readonly NormalizedSession[];
22
+ /**
23
+ * Additional caller instruction for the run, provided to every reflection
24
+ * batch AND to the aggregation pass. The aggregator is the stage that
25
+ * lands the final commit on the memory filesystem, so instructions about
26
+ * maintaining specific files (e.g. a projected AGENTS.md) reach it too —
27
+ * an instruction that steered only the batches would be unreliable.
28
+ */
29
+ instruction?: string;
30
+ /** Override the harness agents directory (tests). */
31
+ agentsDir?: string;
32
+ /** Per-batch token budget (default 60k, measured on normalized content). */
33
+ batchTokenBudget?: number;
34
+ /** Maximum transcripts in one batch (default 10). */
35
+ maxTranscriptsPerBatch?: number;
36
+ /** Concurrent reflection sessions; default: every batch at once. */
37
+ concurrency?: number;
38
+ /** Preview cursor filtering and batch packing without running agents. */
39
+ planOnly?: boolean;
40
+ /**
41
+ * Abort the run: in-flight reflector/aggregator sessions are closed, no
42
+ * new batches start, the run's artifacts (clones, runRoot) are removed,
43
+ * cursors are NOT advanced, and dream() rejects with the abort reason.
44
+ * Shutting down a spawned app-server remains the caller's job via
45
+ * client.close().
46
+ */
47
+ signal?: AbortSignal;
48
+ log?: (line: string) => void;
49
+ }
50
+ export type DreamResult = {
51
+ kind: "nothing_to_dream";
52
+ } | {
53
+ kind: "plan";
54
+ transcripts: DiscoveredSession[];
55
+ batches: DreamBatch[];
56
+ } | {
57
+ kind: "completed";
58
+ runRoot: string;
59
+ success: boolean;
60
+ transcripts: DiscoveredSession[];
61
+ batches: BatchReflectionResult[];
62
+ aggregation: DreamAggregationOutcome;
63
+ reflectorAgentId: string;
64
+ aggregatorAgentId: string;
65
+ };
66
+ export declare function dream(options: DreamOptions): Promise<DreamResult>;
67
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dream/index.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAGL,KAAK,UAAU,EAEhB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,KAAK,uBAAuB,EAE7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,KAAK,qBAAqB,EAE3B,MAAM,cAAc,CAAC;AAUtB,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAOpB,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,YAAY,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAC9D,YAAY,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EACL,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AA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AE,CAAC;CACvB,GACD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,iBAAiB,EAAE,CAAC;IACjC,OAAO,EAAE,qBAAqB,EAAE,CAAC;IACjC,WAAW,EAAE,uBAAuB,CAAC;IACrC,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAuCN,wBAAsB,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CAyKvE"}
@@ -0,0 +1,75 @@
1
+ export interface MemfsStructure {
2
+ /** UTF-8 file contents keyed by path relative to the MemFS root. */
3
+ files?: Readonly<Record<string, string>>;
4
+ /** Directories to materialize even when they contain no tracked files. */
5
+ directories?: readonly string[];
6
+ }
7
+ export interface ValidatedMemfsStructure {
8
+ files: readonly {
9
+ path: string;
10
+ content: string;
11
+ }[];
12
+ directories: readonly string[];
13
+ }
14
+ export type MemfsOperation = "create" | "modify" | "delete";
15
+ export interface MemfsOperationRule {
16
+ /** Exact relative path, or directory path when recursive is true. */
17
+ path: string;
18
+ recursive?: boolean;
19
+ operations: readonly MemfsOperation[];
20
+ }
21
+ /**
22
+ * Default policy semantics:
23
+ * - paths in existingPaths may be modified (but not created or deleted);
24
+ * - paths below allowedNewFilePrefixes may be created, modified, or deleted;
25
+ * - everything else is denied.
26
+ *
27
+ * A matching allowedOperations rule overrides those defaults. This permits,
28
+ * for example, an existing AGENTS.md to be modifiable but not deletable.
29
+ */
30
+ export interface MemfsWritePolicy {
31
+ existingPaths: readonly string[];
32
+ allowedNewFilePrefixes?: readonly string[];
33
+ allowedOperations?: readonly MemfsOperationRule[];
34
+ /** Empty directories that must be recreated after a Git clone. */
35
+ declaredDirectories?: readonly string[];
36
+ }
37
+ export interface MemfsGuardInstallation {
38
+ hooksDir: string;
39
+ preCommitPath: string;
40
+ postCommitPath: string;
41
+ /** Directories present when the guard was installed, excluding .git. */
42
+ baselineDirectories: readonly string[];
43
+ }
44
+ export interface MemfsPolicyViolation {
45
+ path: string;
46
+ operation?: MemfsOperation;
47
+ source: "commit" | "working-tree" | "untracked" | "directory";
48
+ commit?: string;
49
+ reason: string;
50
+ }
51
+ export interface MemfsValidationResult {
52
+ valid: boolean;
53
+ violations: readonly MemfsPolicyViolation[];
54
+ }
55
+ export declare function validateMemfsStructure(structure: MemfsStructure): ValidatedMemfsStructure;
56
+ export declare function createMemfsWritePolicy(structure: MemfsStructure | ValidatedMemfsStructure, options?: {
57
+ allowedNewFilePrefixes?: readonly string[];
58
+ allowedOperations?: readonly MemfsOperationRule[];
59
+ }): MemfsWritePolicy;
60
+ export declare function validateMemfsWritePolicy(policy: MemfsWritePolicy): MemfsWritePolicy;
61
+ export declare function recreateMemfsDirectories(memoryDir: string, directories: readonly string[]): Promise<readonly string[]>;
62
+ export declare function materializeMemfsStructure(memoryDir: string, structure: MemfsStructure): Promise<ValidatedMemfsStructure>;
63
+ export declare function installMemfsGuard(memoryDir: string, policy: MemfsWritePolicy): Promise<MemfsGuardInstallation>;
64
+ /** Configure a freshly cloned MemFS repo, whose hooks and local config Git did not copy. */
65
+ export declare function configureMemfsCloneGuard(sourceMemoryDir: string, cloneMemoryDir: string, policy: MemfsWritePolicy): Promise<MemfsGuardInstallation>;
66
+ /**
67
+ * Defense-in-depth validation after an agent run. Every commit is inspected,
68
+ * so an illegal add followed by a delete cannot disappear in an endpoint diff.
69
+ */
70
+ export declare function validateMemfsChanges(memoryDir: string, baseRevision: string, policy: MemfsWritePolicy, options?: {
71
+ baselineDirectories?: readonly string[];
72
+ }): Promise<MemfsValidationResult>;
73
+ /** Read a materialized file in tests/callers without exposing path traversal. */
74
+ export declare function readMemfsFile(memoryDir: string, path: string): Promise<string>;
75
+ //# sourceMappingURL=memfs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memfs.d.ts","sourceRoot":"","sources":["../../src/dream/memf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AAC,qBAAqB,CAAC,CA+EhC;AAED,iFAAiF;AACjF,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGpF"}
@@ -0,0 +1,67 @@
1
+ import type { NormalizedRecord } from "./types.js";
2
+ export declare const TOOL_INPUT_MAX_CHARS = 20000;
3
+ export declare const TOOL_RESULT_MAX_CHARS = 2500;
4
+ export declare const CODEX_INJECTED_PREFIXES: string[];
5
+ export declare function truncateText(text: string, limit: number): string;
6
+ /**
7
+ * Timestamp from the raw formats: ISO string or epoch millis. Suffix-less
8
+ * (naive) timestamps are treated as UTC so ordering is stable.
9
+ */
10
+ export declare function parseTimestamp(value: unknown): Date | null;
11
+ /**
12
+ * ISO timestamps for n records: real where present, interpolated in gaps,
13
+ * synthesized monotonically when the source recorded none.
14
+ */
15
+ export declare function fillTimestamps(n: number, anchors: Map<number, Date>, createdAt: Date | null, durationSeconds: number | null): string[];
16
+ /**
17
+ * Return the args string (and whether it was reshaped). Byte-verbatim when
18
+ * under the cap and already a JSON object; otherwise reshaped to a valid JSON
19
+ * object, trimming the longest string values until the serialization fits.
20
+ */
21
+ export declare function shrinkArgs(rawInput: string): {
22
+ args: string;
23
+ shrunk: boolean;
24
+ };
25
+ /**
26
+ * Flatten a content field (string | block list) into text; image blocks
27
+ * render as a placeholder.
28
+ */
29
+ export declare function blocksText(content: unknown): string;
30
+ /** One raw content block, as emitted by a per-harness parser. */
31
+ export interface PseudoRow {
32
+ role: "user" | "assistant" | "tool_use" | "tool_result";
33
+ turnType: "user_prompt" | "system_injected" | "assistant_thinking" | "assistant_response" | "tool_use" | "tool_result";
34
+ content?: string;
35
+ timestamp?: Date | null;
36
+ toolName?: string;
37
+ toolCallId?: string;
38
+ toolInputJson?: string;
39
+ model?: string;
40
+ }
41
+ /** Session-level context mined from the raw store during parsing. */
42
+ export interface SessionContext {
43
+ source: string;
44
+ cwd?: string;
45
+ gitBranch?: string;
46
+ model?: string;
47
+ createdAt?: Date | null;
48
+ durationSeconds?: number | null;
49
+ }
50
+ export type NormalizeRowsResult = {
51
+ status: "ok";
52
+ records: NormalizedRecord[];
53
+ } | {
54
+ status: string;
55
+ records?: undefined;
56
+ };
57
+ /**
58
+ * Normalize ordered pseudo-rows into v1 records. Returns `{status: "ok",
59
+ * records}` or a `skipped:…` / `invalid:…` status with no output records.
60
+ */
61
+ export declare function normalizeSessionRows(rows: PseudoRow[], context: SessionContext): NormalizeRowsResult;
62
+ /**
63
+ * Minimal structural validation of the normalized-v1 contract. Returns an
64
+ * error string, or null when valid.
65
+ */
66
+ export declare function validateRecords(records: NormalizedRecord[]): string | null;
67
+ //# sourceMappingURL=normalize-core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-core.d.ts","sourceRoot":"","sources":["../../src/dream/normalize-core.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAInD,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAC3C,eAAO,MAAM,qBAAqB,OAAQ,CAAC;AAgB3C,eAAO,MAAM,uBAAuB,UAKnC,CAAC;AAYF,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAGhE;AAMD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,GAAG,IAAI,CAW1D;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,CAAC,EAAE,MAAM,EACT,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,EAC1B,SAAS,EAAE,IAAI,GAAG,IAAI,EACtB,eAAe,EAAE,MAAM,GAAG,IAAI,GAC7B,MAAM,EAAE,CAmCV;AAID;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,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