@strands-agents/sdk 1.16.0 → 1.18.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.
Files changed (192) hide show
  1. package/README.md +1 -1
  2. package/dist/src/agent/agent-metadata.d.ts +12 -0
  3. package/dist/src/agent/agent-metadata.d.ts.map +1 -0
  4. package/dist/src/agent/agent-metadata.js +2 -0
  5. package/dist/src/agent/agent-metadata.js.map +1 -0
  6. package/dist/src/agent/agent.d.ts +11 -28
  7. package/dist/src/agent/agent.d.ts.map +1 -1
  8. package/dist/src/agent/agent.js +21 -54
  9. package/dist/src/agent/agent.js.map +1 -1
  10. package/dist/src/context-manager/context-manager.d.ts +47 -5
  11. package/dist/src/context-manager/context-manager.d.ts.map +1 -1
  12. package/dist/src/context-manager/context-manager.js +114 -16
  13. package/dist/src/context-manager/context-manager.js.map +1 -1
  14. package/dist/src/context-manager/methods/summarize.d.ts +8 -2
  15. package/dist/src/context-manager/methods/summarize.d.ts.map +1 -1
  16. package/dist/src/context-manager/methods/summarize.js +9 -2
  17. package/dist/src/context-manager/methods/summarize.js.map +1 -1
  18. package/dist/src/context-manager/methods/truncate.d.ts +2 -2
  19. package/dist/src/context-manager/methods/truncate.d.ts.map +1 -1
  20. package/dist/src/context-manager/methods/truncate.js +0 -2
  21. package/dist/src/context-manager/methods/truncate.js.map +1 -1
  22. package/dist/src/context-manager/modes/agentic/agentic-context.d.ts +2 -2
  23. package/dist/src/context-manager/presets.d.ts +42 -0
  24. package/dist/src/context-manager/presets.d.ts.map +1 -0
  25. package/dist/src/context-manager/presets.js +71 -0
  26. package/dist/src/context-manager/presets.js.map +1 -0
  27. package/dist/src/context-manager/retrieval-tool.d.ts +29 -0
  28. package/dist/src/context-manager/retrieval-tool.d.ts.map +1 -0
  29. package/dist/src/context-manager/retrieval-tool.js +116 -0
  30. package/dist/src/context-manager/retrieval-tool.js.map +1 -0
  31. package/dist/src/context-manager/stash.d.ts +107 -0
  32. package/dist/src/context-manager/stash.d.ts.map +1 -0
  33. package/dist/src/context-manager/stash.js +189 -0
  34. package/dist/src/context-manager/stash.js.map +1 -0
  35. package/dist/src/context-manager/strategies/offload/base.d.ts +23 -13
  36. package/dist/src/context-manager/strategies/offload/base.d.ts.map +1 -1
  37. package/dist/src/context-manager/strategies/offload/base.js +67 -25
  38. package/dist/src/context-manager/strategies/offload/base.js.map +1 -1
  39. package/dist/src/context-manager/strategies/offload/drop.d.ts +2 -2
  40. package/dist/src/context-manager/strategies/offload/drop.d.ts.map +1 -1
  41. package/dist/src/context-manager/strategies/offload/drop.js +6 -4
  42. package/dist/src/context-manager/strategies/offload/drop.js.map +1 -1
  43. package/dist/src/context-manager/strategies/offload/index.d.ts +1 -1
  44. package/dist/src/context-manager/strategies/offload/index.js +1 -1
  45. package/dist/src/context-manager/strategies/offload/summarize.d.ts +2 -2
  46. package/dist/src/context-manager/strategies/offload/summarize.d.ts.map +1 -1
  47. package/dist/src/context-manager/strategies/offload/summarize.js +22 -25
  48. package/dist/src/context-manager/strategies/offload/summarize.js.map +1 -1
  49. package/dist/src/context-manager/strategies/offload/truncate.d.ts +2 -2
  50. package/dist/src/context-manager/strategies/offload/truncate.d.ts.map +1 -1
  51. package/dist/src/context-manager/strategies/offload/truncate.js +34 -12
  52. package/dist/src/context-manager/strategies/offload/truncate.js.map +1 -1
  53. package/dist/src/context-manager/types.d.ts +46 -2
  54. package/dist/src/context-manager/types.d.ts.map +1 -1
  55. package/dist/src/experimental/index.d.ts +6 -0
  56. package/dist/src/experimental/index.d.ts.map +1 -1
  57. package/dist/src/experimental/index.js +3 -0
  58. package/dist/src/experimental/index.js.map +1 -1
  59. package/dist/src/index.d.ts +11 -3
  60. package/dist/src/index.d.ts.map +1 -1
  61. package/dist/src/index.js +2 -1
  62. package/dist/src/index.js.map +1 -1
  63. package/dist/src/mcp/client.d.ts +3 -2
  64. package/dist/src/mcp/client.d.ts.map +1 -1
  65. package/dist/src/mcp/client.js +3 -2
  66. package/dist/src/mcp/client.js.map +1 -1
  67. package/dist/src/mcp/config.d.ts +11 -1
  68. package/dist/src/mcp/config.d.ts.map +1 -1
  69. package/dist/src/mcp/config.js.map +1 -1
  70. package/dist/src/mcp/config.node.d.ts +3 -2
  71. package/dist/src/mcp/config.node.d.ts.map +1 -1
  72. package/dist/src/mcp/config.node.js +6 -3
  73. package/dist/src/mcp/config.node.js.map +1 -1
  74. package/dist/src/mcp/index.d.ts +1 -1
  75. package/dist/src/mcp/index.d.ts.map +1 -1
  76. package/dist/src/models/defaults.d.ts.map +1 -1
  77. package/dist/src/models/defaults.js +1 -0
  78. package/dist/src/models/defaults.js.map +1 -1
  79. package/dist/src/models/model.d.ts +12 -2
  80. package/dist/src/models/model.d.ts.map +1 -1
  81. package/dist/src/models/model.js.map +1 -1
  82. package/dist/src/models/openai/cache.d.ts +38 -2
  83. package/dist/src/models/openai/cache.d.ts.map +1 -1
  84. package/dist/src/models/openai/cache.js +64 -14
  85. package/dist/src/models/openai/cache.js.map +1 -1
  86. package/dist/src/models/openai/chat-adapter.d.ts.map +1 -1
  87. package/dist/src/models/openai/chat-adapter.js +10 -4
  88. package/dist/src/models/openai/chat-adapter.js.map +1 -1
  89. package/dist/src/models/openai/mantle.js +1 -1
  90. package/dist/src/models/openai/mantle.js.map +1 -1
  91. package/dist/src/models/openai/responses-adapter.js +1 -1
  92. package/dist/src/models/openai/responses-adapter.js.map +1 -1
  93. package/dist/src/models/routing/classifier-strategy.d.ts +87 -0
  94. package/dist/src/models/routing/classifier-strategy.d.ts.map +1 -0
  95. package/dist/src/models/routing/classifier-strategy.js +285 -0
  96. package/dist/src/models/routing/classifier-strategy.js.map +1 -0
  97. package/dist/src/models/routing/index.d.ts +2 -0
  98. package/dist/src/models/routing/index.d.ts.map +1 -1
  99. package/dist/src/models/routing/index.js +1 -0
  100. package/dist/src/models/routing/index.js.map +1 -1
  101. package/dist/src/models/routing/router.d.ts +14 -2
  102. package/dist/src/models/routing/router.d.ts.map +1 -1
  103. package/dist/src/models/routing/router.js +43 -8
  104. package/dist/src/models/routing/router.js.map +1 -1
  105. package/dist/src/models/vercel.d.ts +9 -1
  106. package/dist/src/models/vercel.d.ts.map +1 -1
  107. package/dist/src/models/vercel.js +248 -7
  108. package/dist/src/models/vercel.js.map +1 -1
  109. package/dist/src/plugins/plugin.d.ts +1 -1
  110. package/dist/src/plugins/registry.js +1 -1
  111. package/dist/src/plugins/registry.js.map +1 -1
  112. package/dist/src/sandbox/errors.d.ts +5 -1
  113. package/dist/src/sandbox/errors.d.ts.map +1 -1
  114. package/dist/src/sandbox/errors.js +7 -1
  115. package/dist/src/sandbox/errors.js.map +1 -1
  116. package/dist/src/sandbox/stream-process.js +1 -1
  117. package/dist/src/sandbox/stream-process.js.map +1 -1
  118. package/dist/src/session/session-manager.d.ts +5 -1
  119. package/dist/src/session/session-manager.d.ts.map +1 -1
  120. package/dist/src/session/session-manager.js +51 -1
  121. package/dist/src/session/session-manager.js.map +1 -1
  122. package/dist/src/session/snapshot-storage-adapter.d.ts.map +1 -1
  123. package/dist/src/session/snapshot-storage-adapter.js +1 -0
  124. package/dist/src/session/snapshot-storage-adapter.js.map +1 -1
  125. package/dist/src/storage/in-memory-storage.d.ts +9 -0
  126. package/dist/src/storage/in-memory-storage.d.ts.map +1 -1
  127. package/dist/src/storage/in-memory-storage.js +18 -2
  128. package/dist/src/storage/in-memory-storage.js.map +1 -1
  129. package/dist/src/storage/local-file-storage.d.ts +9 -2
  130. package/dist/src/storage/local-file-storage.d.ts.map +1 -1
  131. package/dist/src/storage/local-file-storage.js +17 -4
  132. package/dist/src/storage/local-file-storage.js.map +1 -1
  133. package/dist/src/storage/s3-storage.d.ts +4 -0
  134. package/dist/src/storage/s3-storage.d.ts.map +1 -1
  135. package/dist/src/storage/s3-storage.js +8 -0
  136. package/dist/src/storage/s3-storage.js.map +1 -1
  137. package/dist/src/storage/search/qmd.d.ts +10 -6
  138. package/dist/src/storage/search/qmd.d.ts.map +1 -1
  139. package/dist/src/storage/search/qmd.js +4 -6
  140. package/dist/src/storage/search/qmd.js.map +1 -1
  141. package/dist/src/storage/search/types.d.ts +14 -2
  142. package/dist/src/storage/search/types.d.ts.map +1 -1
  143. package/dist/src/storage/storage.d.ts +8 -0
  144. package/dist/src/storage/storage.d.ts.map +1 -1
  145. package/dist/src/storage/storage.js +18 -0
  146. package/dist/src/storage/storage.js.map +1 -1
  147. package/dist/src/telemetry/tracer.d.ts.map +1 -1
  148. package/dist/src/telemetry/tracer.js +4 -2
  149. package/dist/src/telemetry/tracer.js.map +1 -1
  150. package/dist/src/tsconfig.tsbuildinfo +1 -1
  151. package/dist/src/types/agent.d.ts +7 -0
  152. package/dist/src/types/agent.d.ts.map +1 -1
  153. package/dist/src/types/agent.js.map +1 -1
  154. package/dist/src/vended-plugins/context-offloader/search.d.ts.map +1 -1
  155. package/dist/src/vended-plugins/context-offloader/search.js +4 -2
  156. package/dist/src/vended-plugins/context-offloader/search.js.map +1 -1
  157. package/dist/src/vended-tools/index.d.ts +5 -3
  158. package/dist/src/vended-tools/index.d.ts.map +1 -1
  159. package/dist/src/vended-tools/index.js +5 -3
  160. package/dist/src/vended-tools/index.js.map +1 -1
  161. package/dist/src/vended-tools/notebook/index.d.ts +2 -1
  162. package/dist/src/vended-tools/notebook/index.d.ts.map +1 -1
  163. package/dist/src/vended-tools/notebook/index.js +1 -1
  164. package/dist/src/vended-tools/notebook/index.js.map +1 -1
  165. package/dist/src/vended-tools/notebook/notebook.d.ts +38 -8
  166. package/dist/src/vended-tools/notebook/notebook.d.ts.map +1 -1
  167. package/dist/src/vended-tools/notebook/notebook.js +130 -79
  168. package/dist/src/vended-tools/notebook/notebook.js.map +1 -1
  169. package/dist/src/vended-tools/shell/make-shell.d.ts.map +1 -1
  170. package/dist/src/vended-tools/shell/make-shell.js +7 -3
  171. package/dist/src/vended-tools/shell/make-shell.js.map +1 -1
  172. package/dist/src/vended-tools/shell/types.d.ts +10 -5
  173. package/dist/src/vended-tools/shell/types.d.ts.map +1 -1
  174. package/dist/src/vended-tools/shell/types.js +7 -2
  175. package/dist/src/vended-tools/shell/types.js.map +1 -1
  176. package/dist/src/vended-tools/web-fetch/extract.d.ts +23 -0
  177. package/dist/src/vended-tools/web-fetch/extract.d.ts.map +1 -0
  178. package/dist/src/vended-tools/web-fetch/extract.js +130 -0
  179. package/dist/src/vended-tools/web-fetch/extract.js.map +1 -0
  180. package/dist/src/vended-tools/web-fetch/index.d.ts +9 -0
  181. package/dist/src/vended-tools/web-fetch/index.d.ts.map +1 -0
  182. package/dist/src/vended-tools/web-fetch/index.js +7 -0
  183. package/dist/src/vended-tools/web-fetch/index.js.map +1 -0
  184. package/dist/src/vended-tools/web-fetch/types.d.ts +40 -0
  185. package/dist/src/vended-tools/web-fetch/types.d.ts.map +1 -0
  186. package/dist/src/vended-tools/web-fetch/types.js +8 -0
  187. package/dist/src/vended-tools/web-fetch/types.js.map +1 -0
  188. package/dist/src/vended-tools/web-fetch/web-fetch.d.ts +14 -0
  189. package/dist/src/vended-tools/web-fetch/web-fetch.d.ts.map +1 -0
  190. package/dist/src/vended-tools/web-fetch/web-fetch.js +175 -0
  191. package/dist/src/vended-tools/web-fetch/web-fetch.js.map +1 -0
  192. package/package.json +18 -5
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Retrieval tool for accessing stashed (L1) content.
3
+ *
4
+ * Registered automatically when the ContextManager has storage configured.
5
+ *
6
+ * @internal
7
+ */
8
+ import { z } from 'zod';
9
+ import { tool } from '../tools/tool-factory.js';
10
+ import { isSearchableContent, searchContent } from '../vended-plugins/context-offloader/search.js';
11
+ import { DocumentBlock, ImageBlock, VideoBlock } from '../types/media.js';
12
+ import { Message, ToolUseBlock } from '../types/messages.js';
13
+ export const RETRIEVAL_TOOL_NAME = 'retrieve_context';
14
+ const DEFAULT_MAX_RESULT_TOKENS = 10_000;
15
+ const CHARS_PER_TOKEN = 4;
16
+ const retrievalInputSchema = z.object({
17
+ reference: z.string().describe('The reference key from the offload placeholder.'),
18
+ pattern: z.string().optional().describe('Regex or keyword to grep for. Returns matching lines with context.'),
19
+ line_range: z
20
+ .object({
21
+ start: z.number().int().min(1).describe('First line to return (1-indexed).'),
22
+ end: z.number().int().min(1).describe('Last line to return (1-indexed).'),
23
+ })
24
+ .optional()
25
+ .describe('Return only this span of lines.'),
26
+ context_lines: z.number().int().min(0).optional().describe('Lines of context around each match (default: 5).'),
27
+ });
28
+ /**
29
+ * Creates the retrieval tool for the given stash.
30
+ *
31
+ * @param stash - The stash instance to retrieve from
32
+ * @param maxResultTokens - Maximum tokens in the retrieval result
33
+ * @returns A Tool that can retrieve stashed content
34
+ *
35
+ * @internal
36
+ */
37
+ export function createRetrievalTool(stash, maxResultTokens) {
38
+ const maxChars = (maxResultTokens ?? DEFAULT_MAX_RESULT_TOKENS) * CHARS_PER_TOKEN;
39
+ return tool({
40
+ name: RETRIEVAL_TOOL_NAME,
41
+ description: 'Retrieve content that was offloaded from context.\n\n' +
42
+ 'When content is offloaded (truncated, dropped, or summarized), the original is ' +
43
+ 'persisted and a reference key is left in its place. Use this tool with that ' +
44
+ 'reference to access the original content.\n\n' +
45
+ 'Options:\n' +
46
+ ' - pattern: regex/keyword to find matching lines with context\n' +
47
+ ' - line_range: { start, end } to read a specific span\n' +
48
+ ' - Without pattern/line_range: returns the full original content\n\n' +
49
+ 'Examples:\n' +
50
+ ' { reference: "1_toolu_abc_0", pattern: "error" }\n' +
51
+ ' { reference: "1_toolu_abc_0", line_range: { start: 10, end: 25 } }\n' +
52
+ ' { reference: "1_toolu_abc_0" }',
53
+ inputSchema: retrievalInputSchema,
54
+ callback: async (input) => {
55
+ const result = await stash.retrieve(input.reference);
56
+ if (!result) {
57
+ return `Error: reference not found: ${input.reference}`;
58
+ }
59
+ if (!input.pattern && !input.line_range) {
60
+ if (result.data && typeof result.data === 'object' && !Array.isArray(result.data)) {
61
+ const media = restoreMedia(result.data);
62
+ if (media)
63
+ return media;
64
+ }
65
+ const serialized = JSON.stringify(result.data);
66
+ if (serialized.length <= maxChars)
67
+ return result.data;
68
+ return `${serialized.slice(0, maxChars)}\n\n[truncated]`;
69
+ }
70
+ const text = extractText(result.data);
71
+ if (!text || !isSearchableContent('text/plain')) {
72
+ return `Error: cannot search non-text content. Omit pattern/line_range to retrieve full content.`;
73
+ }
74
+ const contextLines = input.context_lines ?? 5;
75
+ return searchContent(text, { pattern: input.pattern, line_range: input.line_range, context_lines: contextLines }, maxChars);
76
+ },
77
+ });
78
+ }
79
+ /**
80
+ * Tracks toolUseIds from retrieval tool invocations so their results
81
+ * can be excluded from stashing (prevents retrieval loops).
82
+ *
83
+ * @internal
84
+ */
85
+ export function trackRetrievalToolUseIds(message, skipSet) {
86
+ if (message.role !== 'assistant')
87
+ return;
88
+ for (const block of message.content) {
89
+ if (block instanceof ToolUseBlock && block.name === RETRIEVAL_TOOL_NAME) {
90
+ skipSet.add(block.toolUseId);
91
+ }
92
+ }
93
+ }
94
+ function restoreMedia(data) {
95
+ if ('image' in data)
96
+ return ImageBlock.fromJSON(data);
97
+ if ('document' in data)
98
+ return DocumentBlock.fromJSON(data);
99
+ if ('video' in data)
100
+ return VideoBlock.fromJSON(data);
101
+ return null;
102
+ }
103
+ function extractText(data) {
104
+ if (typeof data === 'string')
105
+ return data;
106
+ if (data && typeof data === 'object') {
107
+ if ('text' in data && typeof data.text === 'string') {
108
+ return data.text;
109
+ }
110
+ if ('json' in data) {
111
+ return JSON.stringify(data.json, null, 2);
112
+ }
113
+ }
114
+ return null;
115
+ }
116
+ //# sourceMappingURL=retrieval-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retrieval-tool.js","sourceRoot":"","sources":["../../../src/context-manager/retrieval-tool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AAC/C,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAA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I,IAAI,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC,SAAS,CAAE,IAAgC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;QACxE,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * L1 stash: durable storage for offloaded context content.
3
+ *
4
+ * When the ContextManager offloads content from the context window, the
5
+ * original is persisted here so the agent can retrieve it on demand via the
6
+ * retrieval tool.
7
+ *
8
+ * @internal
9
+ */
10
+ import { type Storage } from '../storage/storage.js';
11
+ import { Message } from '../types/messages.js';
12
+ import type { ContentBlock } from '../types/messages.js';
13
+ import type { JSONValue } from '../types/json.js';
14
+ /** @internal */
15
+ export declare const STASH_PREFIX = "context";
16
+ /** Format stash refs for display in placeholders. Returns '' when refs is empty. */
17
+ export declare function formatStashRefs(refs: string[]): string;
18
+ /**
19
+ * Wraps a Storage backend with key management and content framing for the
20
+ * ContextManager's L1 stash.
21
+ *
22
+ * @internal
23
+ */
24
+ export declare class Stash {
25
+ private readonly _storage;
26
+ private readonly _baseStorage;
27
+ private readonly _sessionId;
28
+ /** Name of the base storage constructor, for diagnostic logging. */
29
+ readonly storageTypeName: string;
30
+ constructor(storage: Storage, sessionId: string, agentId: string);
31
+ /**
32
+ * Store a serialized block and return a deterministic reference key.
33
+ *
34
+ * Keys are deterministic (`<id>_<blockIndex>`) so they can be recomputed
35
+ * via {@link refsFor} after a process restart or snapshot restore.
36
+ *
37
+ * @param id - Identifier component for the key (e.g. toolUseId)
38
+ * @param blockIndex - Index of the block within the tool result
39
+ * @param data - Serialized bytes to persist
40
+ * @returns Reference key for retrieval
41
+ */
42
+ store(id: string, blockIndex: number, data: Uint8Array): Promise<string>;
43
+ /**
44
+ * Compute the deterministic reference keys for a content block.
45
+ *
46
+ * For a {@link ToolResultBlock}, returns one key per inner content item
47
+ * (`<toolUseId>_<i>`). For any other block, returns a single key
48
+ * (`<trackingId>_<blockIndex>`).
49
+ *
50
+ * @param block - The content block
51
+ * @param message - The message containing the block
52
+ * @param blockIndex - Index of the block within the message
53
+ * @returns Array of reference keys
54
+ */
55
+ refsFor(block: ContentBlock, message: Message, blockIndex: number): string[];
56
+ /**
57
+ * Eagerly stash all content from a message on arrival.
58
+ * Called via MessageAddedEvent so content is persisted before any strategy runs.
59
+ *
60
+ * @param message - The message whose content should be persisted
61
+ * @param skipToolUseIds - ToolUseIds to skip (e.g. retrieval tool results)
62
+ */
63
+ storeMessage(message: Message, skipToolUseIds?: ReadonlySet<string>): Promise<void>;
64
+ /**
65
+ * Retrieve previously stashed content as its serialized JSON form.
66
+ *
67
+ * @param reference - Key returned by a previous store call
68
+ * @returns The deserialized block data (from `toJSON()`), or null if not found
69
+ */
70
+ retrieve(reference: string): Promise<{
71
+ data: unknown;
72
+ } | null>;
73
+ /**
74
+ * List all stashed references.
75
+ */
76
+ list(): Promise<string[]>;
77
+ /**
78
+ * Delete a stashed entry.
79
+ */
80
+ delete(reference: string): Promise<void>;
81
+ /**
82
+ * Delete all entries in this stash instance.
83
+ */
84
+ clear(): Promise<void>;
85
+ /**
86
+ * Delete all stash data for this session across all agents.
87
+ *
88
+ * Unlike {@link clear}, which is scoped to this agent's namespace,
89
+ * this scans `context/<sessionId>/` on the base storage to catch data
90
+ * from every agent that wrote to the session.
91
+ */
92
+ clearSession(): Promise<void>;
93
+ /**
94
+ * Serialize all stash entries into a plain object for snapshot persistence.
95
+ *
96
+ * @returns Map of reference keys to their stored JSON values
97
+ */
98
+ takeSnapshot(): Promise<Record<string, JSONValue>>;
99
+ /**
100
+ * Restore stash entries from a previously captured snapshot.
101
+ *
102
+ * @param entries - Map of reference keys to their JSON values (from {@link takeSnapshot})
103
+ */
104
+ loadSnapshot(entries: Record<string, JSONValue>): Promise<void>;
105
+ private _storeToolResult;
106
+ }
107
+ //# sourceMappingURL=stash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stash.d.ts","sourceRoot":"","sources":["../../../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;IAMpE;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAI/B;;OAEG;IACG,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK9C;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAK5B;;;;;;OAMG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAMnC;;;;OAIG;IACG,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAYxD;;;;OAIG;IACG,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;YAIvD,gBAAgB;CAY/B"}
@@ -0,0 +1,189 @@
1
+ /**
2
+ * L1 stash: durable storage for offloaded context content.
3
+ *
4
+ * When the ContextManager offloads content from the context window, the
5
+ * original is persisted here so the agent can retrieve it on demand via the
6
+ * retrieval tool.
7
+ *
8
+ * @internal
9
+ */
10
+ import { namespace as namespaceStorage } from '../storage/storage.js';
11
+ import { Message, ToolResultBlock, ToolUseBlock, CachePointBlock, ReasoningBlock } from '../types/messages.js';
12
+ import { logger } from '../logging/logger.js';
13
+ /** @internal */
14
+ export const STASH_PREFIX = 'context';
15
+ function encode(value) {
16
+ return new TextEncoder().encode(JSON.stringify(value));
17
+ }
18
+ function decode(bytes) {
19
+ return JSON.parse(new TextDecoder().decode(bytes));
20
+ }
21
+ /** Format stash refs for display in placeholders. Returns '' when refs is empty. */
22
+ export function formatStashRefs(refs) {
23
+ if (refs.length === 0)
24
+ return '';
25
+ if (refs.length === 1)
26
+ return ` [ref: ${refs[0]}]`;
27
+ return ` [refs: ${refs.join(', ')}]`;
28
+ }
29
+ /**
30
+ * Wraps a Storage backend with key management and content framing for the
31
+ * ContextManager's L1 stash.
32
+ *
33
+ * @internal
34
+ */
35
+ export class Stash {
36
+ _storage;
37
+ _baseStorage;
38
+ _sessionId;
39
+ /** Name of the base storage constructor, for diagnostic logging. */
40
+ storageTypeName;
41
+ constructor(storage, sessionId, agentId) {
42
+ this._baseStorage = storage;
43
+ this._sessionId = sessionId;
44
+ this._storage = namespaceStorage(storage, `${STASH_PREFIX}/${sessionId}/scopes/agent/${agentId}`);
45
+ this.storageTypeName = storage.constructor.name || 'unknown';
46
+ }
47
+ /**
48
+ * Store a serialized block and return a deterministic reference key.
49
+ *
50
+ * Keys are deterministic (`<id>_<blockIndex>`) so they can be recomputed
51
+ * via {@link refsFor} after a process restart or snapshot restore.
52
+ *
53
+ * @param id - Identifier component for the key (e.g. toolUseId)
54
+ * @param blockIndex - Index of the block within the tool result
55
+ * @param data - Serialized bytes to persist
56
+ * @returns Reference key for retrieval
57
+ */
58
+ async store(id, blockIndex, data) {
59
+ const key = `${id}_${blockIndex}`;
60
+ await this._storage.write(key, data);
61
+ return key;
62
+ }
63
+ /**
64
+ * Compute the deterministic reference keys for a content block.
65
+ *
66
+ * For a {@link ToolResultBlock}, returns one key per inner content item
67
+ * (`<toolUseId>_<i>`). For any other block, returns a single key
68
+ * (`<trackingId>_<blockIndex>`).
69
+ *
70
+ * @param block - The content block
71
+ * @param message - The message containing the block
72
+ * @param blockIndex - Index of the block within the message
73
+ * @returns Array of reference keys
74
+ */
75
+ refsFor(block, message, blockIndex) {
76
+ if (block instanceof ToolResultBlock) {
77
+ return Array.from({ length: block.content.length }, (_, index) => `${block.toolUseId}_${index}`);
78
+ }
79
+ return [`${message.trackingId}_${blockIndex}`];
80
+ }
81
+ /**
82
+ * Eagerly stash all content from a message on arrival.
83
+ * Called via MessageAddedEvent so content is persisted before any strategy runs.
84
+ *
85
+ * @param message - The message whose content should be persisted
86
+ * @param skipToolUseIds - ToolUseIds to skip (e.g. retrieval tool results)
87
+ */
88
+ async storeMessage(message, skipToolUseIds) {
89
+ for (let blockIndex = 0; blockIndex < message.content.length; blockIndex++) {
90
+ const block = message.content[blockIndex];
91
+ if (block instanceof ToolResultBlock) {
92
+ if (skipToolUseIds?.has(block.toolUseId))
93
+ continue;
94
+ await this._storeToolResult(block);
95
+ }
96
+ else if (block instanceof ToolUseBlock || block instanceof CachePointBlock || block instanceof ReasoningBlock) {
97
+ continue;
98
+ }
99
+ else {
100
+ try {
101
+ await this.store(message.trackingId, blockIndex, encode(block.toJSON()));
102
+ }
103
+ catch (error) {
104
+ logger.warn(`trackingId=<${message.trackingId}>, error=<${error}> | failed to stash block`);
105
+ }
106
+ }
107
+ }
108
+ }
109
+ /**
110
+ * Retrieve previously stashed content as its serialized JSON form.
111
+ *
112
+ * @param reference - Key returned by a previous store call
113
+ * @returns The deserialized block data (from `toJSON()`), or null if not found
114
+ */
115
+ async retrieve(reference) {
116
+ const bytes = await this._storage.read(reference);
117
+ if (bytes === null)
118
+ return null;
119
+ return { data: decode(bytes) };
120
+ }
121
+ /**
122
+ * List all stashed references.
123
+ */
124
+ async list() {
125
+ return this._storage.list('');
126
+ }
127
+ /**
128
+ * Delete a stashed entry.
129
+ */
130
+ async delete(reference) {
131
+ await this._storage.delete(reference);
132
+ logger.debug(`reference=<${reference}> | stash entry deleted`);
133
+ }
134
+ /**
135
+ * Delete all entries in this stash instance.
136
+ */
137
+ async clear() {
138
+ const keys = await this.list();
139
+ await Promise.all(keys.map((key) => this.delete(key)));
140
+ }
141
+ /**
142
+ * Delete all stash data for this session across all agents.
143
+ *
144
+ * Unlike {@link clear}, which is scoped to this agent's namespace,
145
+ * this scans `context/<sessionId>/` on the base storage to catch data
146
+ * from every agent that wrote to the session.
147
+ */
148
+ async clearSession() {
149
+ const prefix = `${STASH_PREFIX}/${this._sessionId}/`;
150
+ const keys = await this._baseStorage.list(prefix);
151
+ await Promise.all(keys.map((key) => this._baseStorage.delete(key)));
152
+ }
153
+ /**
154
+ * Serialize all stash entries into a plain object for snapshot persistence.
155
+ *
156
+ * @returns Map of reference keys to their stored JSON values
157
+ */
158
+ async takeSnapshot() {
159
+ const keys = await this.list();
160
+ const results = await Promise.all(keys.map((key) => this.retrieve(key).then((result) => [key, result])));
161
+ const entries = {};
162
+ for (const [key, result] of results) {
163
+ if (result) {
164
+ entries[key] = result.data;
165
+ }
166
+ }
167
+ return entries;
168
+ }
169
+ /**
170
+ * Restore stash entries from a previously captured snapshot.
171
+ *
172
+ * @param entries - Map of reference keys to their JSON values (from {@link takeSnapshot})
173
+ */
174
+ async loadSnapshot(entries) {
175
+ await Promise.all(Object.entries(entries).map(([key, data]) => this._storage.write(key, encode(data))));
176
+ }
177
+ async _storeToolResult(block) {
178
+ for (let blockIndex = 0; blockIndex < block.content.length; blockIndex++) {
179
+ const item = block.content[blockIndex];
180
+ try {
181
+ await this.store(block.toolUseId, blockIndex, encode(item.toJSON()));
182
+ }
183
+ catch (error) {
184
+ logger.warn(`toolUseId=<${block.toolUseId}>, blockIndex=<${blockIndex}>, error=<${error}> | failed to stash sub-block`);
185
+ }
186
+ }
187
+ }
188
+ }
189
+ //# sourceMappingURL=stash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stash.js","sourceRoot":"","sources":["../../../src/context-manager/stash.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAgB,MAAM,uBAAuB,CAAA;AACnF,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAG9G,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAE7C,gBAAgB;AAChB,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAA;AAErC,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;AACxD,CAAC;AAED,SAAS,MAAM,CAAC,KAAiB;IAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAA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AAa,KAAK,+BAA+B,CAC3G,CAAA;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
@@ -1,12 +1,11 @@
1
1
  /**
2
2
  * Base offload strategy and shared infrastructure.
3
- *
4
- * @internal
5
3
  */
6
- import { Message, TextBlock, ToolResultBlock } from '../../../types/messages.js';
4
+ import { Message, ToolResultBlock } from '../../../types/messages.js';
7
5
  import type { ContentBlock } from '../../../types/messages.js';
8
6
  import type { LocalAgent } from '../../../types/agent.js';
9
7
  import type { ContextStrategy, ContextState } from '../../types.js';
8
+ import type { Stash } from '../../stash.js';
10
9
  /**
11
10
  * Target for offload operations. This union is intentionally extensible — new
12
11
  * string-literal members can be added freely as new content categories emerge.
@@ -17,6 +16,8 @@ import type { ContextStrategy, ContextState } from '../../types.js';
17
16
  * - `"userText"` — text blocks in user messages (excluding tool results)
18
17
  * - `string[]` — tool results from specific tools, namespaced with `tool::` (e.g. `['tool::bash']`); prefix with `!` to exclude
19
18
  * - `"*"` — all content in the context window (tool results + text blocks)
19
+ *
20
+ * @experimental
20
21
  */
21
22
  export type OffloadTarget = '*' | 'toolResults' | 'toolResultErrors' | 'assistantText' | 'userText' | string[];
22
23
  /**
@@ -30,13 +31,19 @@ export type OffloadTarget = '*' | 'toolResults' | 'toolResultErrors' | 'assistan
30
31
  * When multiple strategies target the same content, they don't conflict — strategies
31
32
  * run as an ordered pipeline, and once an earlier strategy shrinks a block, it falls
32
33
  * below the next strategy's threshold and gets skipped automatically.
34
+ *
35
+ * @experimental
33
36
  */
34
37
  export interface OffloadConditions {
35
38
  /** Token threshold above which individual blocks are offloaded. */
36
39
  threshold?: number;
37
40
  /** Context utilization ratio (0-1+) above which the strategy fires. */
38
41
  utilization?: number;
39
- /** Number of most recent matching messages to leave untouched. */
42
+ /**
43
+ * How many recent matching messages to leave untouched.
44
+ * - Integer (1 or above): absolute count of messages to preserve.
45
+ * - Decimal (between 0 and 1 exclusive): ratio of matching messages to preserve (e.g. 0.7 = keep 70%).
46
+ */
40
47
  preserveRecent?: number;
41
48
  }
42
49
  /**
@@ -56,10 +63,12 @@ export declare function toolMatchesTarget(block: ToolResultBlock, target: Offloa
56
63
  export declare function targetMatchesMessage(target: OffloadTarget | undefined, message: Message): boolean;
57
64
  export declare function messageMatchesTarget(message: Message, target: OffloadTarget | undefined, toolNameMap: Map<string, string>, toolIncludeFilter: Set<string> | undefined, toolExcludeFilter: Set<string> | undefined): boolean;
58
65
  /**
59
- * Returns target-matching messages excluding the N most recent matches.
60
- * First filters to only messages that match the target, then removes the last N from that set.
66
+ * Returns target-matching messages excluding the most recent matches.
67
+ * First filters to only messages that match the target, then removes the tail.
68
+ *
69
+ * @param preserveRecent - Integer (1 or above): absolute count. Decimal (between 0 and 1 exclusive): ratio of matches to keep.
61
70
  */
62
- export declare function getOldestMatches(messages: Message[], target: OffloadTarget | undefined, count: number, toolNameMap: Map<string, string>, toolIncludeFilter: Set<string> | undefined, toolExcludeFilter: Set<string> | undefined): Message[];
71
+ export declare function getOldestMatches(messages: Message[], target: OffloadTarget | undefined, preserveRecent: number, toolNameMap: Map<string, string>, toolIncludeFilter: Set<string> | undefined, toolExcludeFilter: Set<string> | undefined): Message[];
63
72
  /**
64
73
  * Collects a message and its paired partner (if any) for safe removal.
65
74
  * If removing a message would orphan a tool-use/tool-result pair, includes the partner
@@ -97,17 +106,17 @@ export declare abstract class BaseOffloadStrategy implements ContextStrategy {
97
106
  protected readonly _threshold: number | undefined;
98
107
  protected readonly _utilizationThreshold: number | undefined;
99
108
  protected readonly _preserveRecent: number;
100
- protected readonly _removalRatio: number;
101
109
  protected readonly _includeFilter: Set<string> | undefined;
102
110
  protected readonly _excludeFilter: Set<string> | undefined;
111
+ protected _stash: Stash | undefined;
103
112
  constructor(target?: OffloadTarget, conditions?: OffloadConditions);
104
113
  /** Whether this strategy operates at message-level (batch) vs per-block. */
105
114
  protected get _isMessageLevel(): boolean;
106
- init(agent: LocalAgent): void;
115
+ init(agent: LocalAgent, stash?: Stash): void;
107
116
  apply(context: ContextState): Promise<boolean>;
108
117
  /** Per-block execution: walk each message, transform individual blocks above threshold. */
109
118
  private _applyPerBlock;
110
- /** Message-level execution: remove oldest 30% of eligible messages with pair safety. */
119
+ /** Message-level execution: remove eligible messages with pair safety. */
111
120
  protected _applyPerMessage(context: ContextState): Promise<boolean>;
112
121
  /** Override to insert a marker when messages are removed. Return null for no marker. */
113
122
  protected _makeRemovalMarker(_count: number): string | null;
@@ -118,7 +127,7 @@ export declare abstract class BaseOffloadStrategy implements ContextStrategy {
118
127
  /** Collect eligible messages for message-level operations, respecting preserveRecent, head-pin, and threshold. */
119
128
  protected _getEligibleMessages(context: ContextState): Promise<Message[]>;
120
129
  /** Transform a block. Return the replacement, or null to skip. */
121
- protected abstract _replaceBlock(block: TextBlock | ToolResultBlock, tokens: number, message: Message, agent: LocalAgent): Promise<ContentBlock | null>;
130
+ protected abstract _replaceBlock(block: ContentBlock, tokens: number, message: Message, agent: LocalAgent, stashRefs: string[]): Promise<ContentBlock | null>;
122
131
  }
123
132
  /**
124
133
  * Last-resort strategy that recomputes utilization and drops the oldest 20% of messages
@@ -131,10 +140,11 @@ export declare abstract class BaseOffloadStrategy implements ContextStrategy {
131
140
  */
132
141
  export declare class EmergencyTruncateStrategy extends BaseOffloadStrategy {
133
142
  readonly name = "offload:emergency-truncate";
134
- protected readonly _removalRatio = 0.2;
135
143
  constructor();
136
- init(): void;
144
+ init(_agent: LocalAgent, stash?: Stash): void;
137
145
  apply(context: ContextState): Promise<boolean>;
146
+ /** Drop the oldest 20% of non-head messages each pass. */
147
+ protected _applyPerMessage(context: ContextState): Promise<boolean>;
138
148
  protected _replaceBlock(): Promise<ContentBlock | null>;
139
149
  }
140
150
  //# sourceMappingURL=base.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../../src/context-manager/strategies/offload/base.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,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