@lleverage-ai/agent-sdk 0.0.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.
Files changed (327) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2321 -0
  3. package/dist/agent.d.ts +52 -0
  4. package/dist/agent.d.ts.map +1 -0
  5. package/dist/agent.js +2122 -0
  6. package/dist/agent.js.map +1 -0
  7. package/dist/backend.d.ts +378 -0
  8. package/dist/backend.d.ts.map +1 -0
  9. package/dist/backend.js +71 -0
  10. package/dist/backend.js.map +1 -0
  11. package/dist/backends/composite.d.ts +258 -0
  12. package/dist/backends/composite.d.ts.map +1 -0
  13. package/dist/backends/composite.js +437 -0
  14. package/dist/backends/composite.js.map +1 -0
  15. package/dist/backends/filesystem.d.ts +268 -0
  16. package/dist/backends/filesystem.d.ts.map +1 -0
  17. package/dist/backends/filesystem.js +623 -0
  18. package/dist/backends/filesystem.js.map +1 -0
  19. package/dist/backends/index.d.ts +14 -0
  20. package/dist/backends/index.d.ts.map +1 -0
  21. package/dist/backends/index.js +14 -0
  22. package/dist/backends/index.js.map +1 -0
  23. package/dist/backends/persistent.d.ts +312 -0
  24. package/dist/backends/persistent.d.ts.map +1 -0
  25. package/dist/backends/persistent.js +519 -0
  26. package/dist/backends/persistent.js.map +1 -0
  27. package/dist/backends/sandbox.d.ts +315 -0
  28. package/dist/backends/sandbox.d.ts.map +1 -0
  29. package/dist/backends/sandbox.js +490 -0
  30. package/dist/backends/sandbox.js.map +1 -0
  31. package/dist/backends/state.d.ts +225 -0
  32. package/dist/backends/state.d.ts.map +1 -0
  33. package/dist/backends/state.js +396 -0
  34. package/dist/backends/state.js.map +1 -0
  35. package/dist/checkpointer/file-saver.d.ts +182 -0
  36. package/dist/checkpointer/file-saver.d.ts.map +1 -0
  37. package/dist/checkpointer/file-saver.js +298 -0
  38. package/dist/checkpointer/file-saver.js.map +1 -0
  39. package/dist/checkpointer/index.d.ts +40 -0
  40. package/dist/checkpointer/index.d.ts.map +1 -0
  41. package/dist/checkpointer/index.js +40 -0
  42. package/dist/checkpointer/index.js.map +1 -0
  43. package/dist/checkpointer/kv-saver.d.ts +142 -0
  44. package/dist/checkpointer/kv-saver.d.ts.map +1 -0
  45. package/dist/checkpointer/kv-saver.js +176 -0
  46. package/dist/checkpointer/kv-saver.js.map +1 -0
  47. package/dist/checkpointer/memory-saver.d.ts +158 -0
  48. package/dist/checkpointer/memory-saver.d.ts.map +1 -0
  49. package/dist/checkpointer/memory-saver.js +222 -0
  50. package/dist/checkpointer/memory-saver.js.map +1 -0
  51. package/dist/checkpointer/types.d.ts +353 -0
  52. package/dist/checkpointer/types.d.ts.map +1 -0
  53. package/dist/checkpointer/types.js +159 -0
  54. package/dist/checkpointer/types.js.map +1 -0
  55. package/dist/context-manager.d.ts +627 -0
  56. package/dist/context-manager.d.ts.map +1 -0
  57. package/dist/context-manager.js +1039 -0
  58. package/dist/context-manager.js.map +1 -0
  59. package/dist/context.d.ts +57 -0
  60. package/dist/context.d.ts.map +1 -0
  61. package/dist/context.js +76 -0
  62. package/dist/context.js.map +1 -0
  63. package/dist/errors/index.d.ts +611 -0
  64. package/dist/errors/index.d.ts.map +1 -0
  65. package/dist/errors/index.js +1023 -0
  66. package/dist/errors/index.js.map +1 -0
  67. package/dist/generation-helpers.d.ts +126 -0
  68. package/dist/generation-helpers.d.ts.map +1 -0
  69. package/dist/generation-helpers.js +181 -0
  70. package/dist/generation-helpers.js.map +1 -0
  71. package/dist/hooks/audit.d.ts +210 -0
  72. package/dist/hooks/audit.d.ts.map +1 -0
  73. package/dist/hooks/audit.js +305 -0
  74. package/dist/hooks/audit.js.map +1 -0
  75. package/dist/hooks/cache.d.ts +180 -0
  76. package/dist/hooks/cache.d.ts.map +1 -0
  77. package/dist/hooks/cache.js +273 -0
  78. package/dist/hooks/cache.js.map +1 -0
  79. package/dist/hooks/guardrails.d.ts +145 -0
  80. package/dist/hooks/guardrails.d.ts.map +1 -0
  81. package/dist/hooks/guardrails.js +326 -0
  82. package/dist/hooks/guardrails.js.map +1 -0
  83. package/dist/hooks/index.d.ts +18 -0
  84. package/dist/hooks/index.d.ts.map +1 -0
  85. package/dist/hooks/index.js +32 -0
  86. package/dist/hooks/index.js.map +1 -0
  87. package/dist/hooks/logging.d.ts +193 -0
  88. package/dist/hooks/logging.d.ts.map +1 -0
  89. package/dist/hooks/logging.js +345 -0
  90. package/dist/hooks/logging.js.map +1 -0
  91. package/dist/hooks/parallel-guardrails.d.ts +268 -0
  92. package/dist/hooks/parallel-guardrails.d.ts.map +1 -0
  93. package/dist/hooks/parallel-guardrails.js +416 -0
  94. package/dist/hooks/parallel-guardrails.js.map +1 -0
  95. package/dist/hooks/rate-limit.d.ts +305 -0
  96. package/dist/hooks/rate-limit.d.ts.map +1 -0
  97. package/dist/hooks/rate-limit.js +372 -0
  98. package/dist/hooks/rate-limit.js.map +1 -0
  99. package/dist/hooks/retry.d.ts +144 -0
  100. package/dist/hooks/retry.d.ts.map +1 -0
  101. package/dist/hooks/retry.js +210 -0
  102. package/dist/hooks/retry.js.map +1 -0
  103. package/dist/hooks/secrets.d.ts +174 -0
  104. package/dist/hooks/secrets.d.ts.map +1 -0
  105. package/dist/hooks/secrets.js +306 -0
  106. package/dist/hooks/secrets.js.map +1 -0
  107. package/dist/hooks.d.ts +229 -0
  108. package/dist/hooks.d.ts.map +1 -0
  109. package/dist/hooks.js +352 -0
  110. package/dist/hooks.js.map +1 -0
  111. package/dist/index.d.ts +97 -0
  112. package/dist/index.d.ts.map +1 -0
  113. package/dist/index.js +182 -0
  114. package/dist/index.js.map +1 -0
  115. package/dist/mcp/env.d.ts +25 -0
  116. package/dist/mcp/env.d.ts.map +1 -0
  117. package/dist/mcp/env.js +18 -0
  118. package/dist/mcp/env.js.map +1 -0
  119. package/dist/mcp/index.d.ts +16 -0
  120. package/dist/mcp/index.d.ts.map +1 -0
  121. package/dist/mcp/index.js +17 -0
  122. package/dist/mcp/index.js.map +1 -0
  123. package/dist/mcp/manager.d.ts +184 -0
  124. package/dist/mcp/manager.d.ts.map +1 -0
  125. package/dist/mcp/manager.js +446 -0
  126. package/dist/mcp/manager.js.map +1 -0
  127. package/dist/mcp/types.d.ts +58 -0
  128. package/dist/mcp/types.d.ts.map +1 -0
  129. package/dist/mcp/types.js +7 -0
  130. package/dist/mcp/types.js.map +1 -0
  131. package/dist/mcp/validation.d.ts +119 -0
  132. package/dist/mcp/validation.d.ts.map +1 -0
  133. package/dist/mcp/validation.js +407 -0
  134. package/dist/mcp/validation.js.map +1 -0
  135. package/dist/mcp/virtual-server.d.ts +78 -0
  136. package/dist/mcp/virtual-server.d.ts.map +1 -0
  137. package/dist/mcp/virtual-server.js +137 -0
  138. package/dist/mcp/virtual-server.js.map +1 -0
  139. package/dist/memory/filesystem-store.d.ts +217 -0
  140. package/dist/memory/filesystem-store.d.ts.map +1 -0
  141. package/dist/memory/filesystem-store.js +343 -0
  142. package/dist/memory/filesystem-store.js.map +1 -0
  143. package/dist/memory/index.d.ts +46 -0
  144. package/dist/memory/index.d.ts.map +1 -0
  145. package/dist/memory/index.js +46 -0
  146. package/dist/memory/index.js.map +1 -0
  147. package/dist/memory/loader.d.ts +396 -0
  148. package/dist/memory/loader.d.ts.map +1 -0
  149. package/dist/memory/loader.js +419 -0
  150. package/dist/memory/loader.js.map +1 -0
  151. package/dist/memory/permissions.d.ts +282 -0
  152. package/dist/memory/permissions.d.ts.map +1 -0
  153. package/dist/memory/permissions.js +297 -0
  154. package/dist/memory/permissions.js.map +1 -0
  155. package/dist/memory/rules.d.ts +249 -0
  156. package/dist/memory/rules.d.ts.map +1 -0
  157. package/dist/memory/rules.js +362 -0
  158. package/dist/memory/rules.js.map +1 -0
  159. package/dist/memory/store.d.ts +286 -0
  160. package/dist/memory/store.d.ts.map +1 -0
  161. package/dist/memory/store.js +263 -0
  162. package/dist/memory/store.js.map +1 -0
  163. package/dist/middleware/apply.d.ts +73 -0
  164. package/dist/middleware/apply.d.ts.map +1 -0
  165. package/dist/middleware/apply.js +219 -0
  166. package/dist/middleware/apply.js.map +1 -0
  167. package/dist/middleware/context.d.ts +33 -0
  168. package/dist/middleware/context.d.ts.map +1 -0
  169. package/dist/middleware/context.js +176 -0
  170. package/dist/middleware/context.js.map +1 -0
  171. package/dist/middleware/index.d.ts +31 -0
  172. package/dist/middleware/index.d.ts.map +1 -0
  173. package/dist/middleware/index.js +32 -0
  174. package/dist/middleware/index.js.map +1 -0
  175. package/dist/middleware/logging.d.ts +137 -0
  176. package/dist/middleware/logging.d.ts.map +1 -0
  177. package/dist/middleware/logging.js +374 -0
  178. package/dist/middleware/logging.js.map +1 -0
  179. package/dist/middleware/types.d.ts +183 -0
  180. package/dist/middleware/types.d.ts.map +1 -0
  181. package/dist/middleware/types.js +11 -0
  182. package/dist/middleware/types.js.map +1 -0
  183. package/dist/observability/events.d.ts +183 -0
  184. package/dist/observability/events.d.ts.map +1 -0
  185. package/dist/observability/events.js +305 -0
  186. package/dist/observability/events.js.map +1 -0
  187. package/dist/observability/index.d.ts +55 -0
  188. package/dist/observability/index.d.ts.map +1 -0
  189. package/dist/observability/index.js +87 -0
  190. package/dist/observability/index.js.map +1 -0
  191. package/dist/observability/logger.d.ts +318 -0
  192. package/dist/observability/logger.d.ts.map +1 -0
  193. package/dist/observability/logger.js +436 -0
  194. package/dist/observability/logger.js.map +1 -0
  195. package/dist/observability/metrics.d.ts +341 -0
  196. package/dist/observability/metrics.d.ts.map +1 -0
  197. package/dist/observability/metrics.js +490 -0
  198. package/dist/observability/metrics.js.map +1 -0
  199. package/dist/observability/preset.d.ts +161 -0
  200. package/dist/observability/preset.d.ts.map +1 -0
  201. package/dist/observability/preset.js +133 -0
  202. package/dist/observability/preset.js.map +1 -0
  203. package/dist/observability/streaming.d.ts +113 -0
  204. package/dist/observability/streaming.d.ts.map +1 -0
  205. package/dist/observability/streaming.js +114 -0
  206. package/dist/observability/streaming.js.map +1 -0
  207. package/dist/observability/tracing.d.ts +378 -0
  208. package/dist/observability/tracing.d.ts.map +1 -0
  209. package/dist/observability/tracing.js +539 -0
  210. package/dist/observability/tracing.js.map +1 -0
  211. package/dist/plugins.d.ts +55 -0
  212. package/dist/plugins.d.ts.map +1 -0
  213. package/dist/plugins.js +63 -0
  214. package/dist/plugins.js.map +1 -0
  215. package/dist/presets/index.d.ts +7 -0
  216. package/dist/presets/index.d.ts.map +1 -0
  217. package/dist/presets/index.js +7 -0
  218. package/dist/presets/index.js.map +1 -0
  219. package/dist/presets/production.d.ts +262 -0
  220. package/dist/presets/production.d.ts.map +1 -0
  221. package/dist/presets/production.js +295 -0
  222. package/dist/presets/production.js.map +1 -0
  223. package/dist/security/index.d.ts +179 -0
  224. package/dist/security/index.d.ts.map +1 -0
  225. package/dist/security/index.js +323 -0
  226. package/dist/security/index.js.map +1 -0
  227. package/dist/subagents/advanced.d.ts +413 -0
  228. package/dist/subagents/advanced.d.ts.map +1 -0
  229. package/dist/subagents/advanced.js +396 -0
  230. package/dist/subagents/advanced.js.map +1 -0
  231. package/dist/subagents/index.d.ts +14 -0
  232. package/dist/subagents/index.d.ts.map +1 -0
  233. package/dist/subagents/index.js +15 -0
  234. package/dist/subagents/index.js.map +1 -0
  235. package/dist/subagents.d.ts +73 -0
  236. package/dist/subagents.d.ts.map +1 -0
  237. package/dist/subagents.js +213 -0
  238. package/dist/subagents.js.map +1 -0
  239. package/dist/task-store/file-store.d.ts +76 -0
  240. package/dist/task-store/file-store.d.ts.map +1 -0
  241. package/dist/task-store/file-store.js +190 -0
  242. package/dist/task-store/file-store.js.map +1 -0
  243. package/dist/task-store/index.d.ts +11 -0
  244. package/dist/task-store/index.d.ts.map +1 -0
  245. package/dist/task-store/index.js +10 -0
  246. package/dist/task-store/index.js.map +1 -0
  247. package/dist/task-store/kv-store.d.ts +140 -0
  248. package/dist/task-store/kv-store.d.ts.map +1 -0
  249. package/dist/task-store/kv-store.js +169 -0
  250. package/dist/task-store/kv-store.js.map +1 -0
  251. package/dist/task-store/memory-store.d.ts +66 -0
  252. package/dist/task-store/memory-store.d.ts.map +1 -0
  253. package/dist/task-store/memory-store.js +125 -0
  254. package/dist/task-store/memory-store.js.map +1 -0
  255. package/dist/task-store/types.d.ts +235 -0
  256. package/dist/task-store/types.d.ts.map +1 -0
  257. package/dist/task-store/types.js +110 -0
  258. package/dist/task-store/types.js.map +1 -0
  259. package/dist/testing/assertions.d.ts +401 -0
  260. package/dist/testing/assertions.d.ts.map +1 -0
  261. package/dist/testing/assertions.js +630 -0
  262. package/dist/testing/assertions.js.map +1 -0
  263. package/dist/testing/index.d.ts +343 -0
  264. package/dist/testing/index.d.ts.map +1 -0
  265. package/dist/testing/index.js +360 -0
  266. package/dist/testing/index.js.map +1 -0
  267. package/dist/testing/mock-agent.d.ts +214 -0
  268. package/dist/testing/mock-agent.d.ts.map +1 -0
  269. package/dist/testing/mock-agent.js +448 -0
  270. package/dist/testing/mock-agent.js.map +1 -0
  271. package/dist/testing/recorder.d.ts +288 -0
  272. package/dist/testing/recorder.d.ts.map +1 -0
  273. package/dist/testing/recorder.js +499 -0
  274. package/dist/testing/recorder.js.map +1 -0
  275. package/dist/tools/execute.d.ts +104 -0
  276. package/dist/tools/execute.d.ts.map +1 -0
  277. package/dist/tools/execute.js +191 -0
  278. package/dist/tools/execute.js.map +1 -0
  279. package/dist/tools/factory.d.ts +260 -0
  280. package/dist/tools/factory.d.ts.map +1 -0
  281. package/dist/tools/factory.js +241 -0
  282. package/dist/tools/factory.js.map +1 -0
  283. package/dist/tools/filesystem.d.ts +215 -0
  284. package/dist/tools/filesystem.d.ts.map +1 -0
  285. package/dist/tools/filesystem.js +311 -0
  286. package/dist/tools/filesystem.js.map +1 -0
  287. package/dist/tools/index.d.ts +33 -0
  288. package/dist/tools/index.d.ts.map +1 -0
  289. package/dist/tools/index.js +33 -0
  290. package/dist/tools/index.js.map +1 -0
  291. package/dist/tools/search.d.ts +59 -0
  292. package/dist/tools/search.d.ts.map +1 -0
  293. package/dist/tools/search.js +94 -0
  294. package/dist/tools/search.js.map +1 -0
  295. package/dist/tools/skills.d.ts +354 -0
  296. package/dist/tools/skills.d.ts.map +1 -0
  297. package/dist/tools/skills.js +413 -0
  298. package/dist/tools/skills.js.map +1 -0
  299. package/dist/tools/task.d.ts +272 -0
  300. package/dist/tools/task.d.ts.map +1 -0
  301. package/dist/tools/task.js +521 -0
  302. package/dist/tools/task.js.map +1 -0
  303. package/dist/tools/todos.d.ts +131 -0
  304. package/dist/tools/todos.d.ts.map +1 -0
  305. package/dist/tools/todos.js +120 -0
  306. package/dist/tools/todos.js.map +1 -0
  307. package/dist/tools/tool-registry.d.ts +424 -0
  308. package/dist/tools/tool-registry.d.ts.map +1 -0
  309. package/dist/tools/tool-registry.js +607 -0
  310. package/dist/tools/tool-registry.js.map +1 -0
  311. package/dist/tools/user-interaction.d.ts +116 -0
  312. package/dist/tools/user-interaction.d.ts.map +1 -0
  313. package/dist/tools/user-interaction.js +147 -0
  314. package/dist/tools/user-interaction.js.map +1 -0
  315. package/dist/tools/utils.d.ts +124 -0
  316. package/dist/tools/utils.d.ts.map +1 -0
  317. package/dist/tools/utils.js +189 -0
  318. package/dist/tools/utils.js.map +1 -0
  319. package/dist/tools.d.ts +74 -0
  320. package/dist/tools.d.ts.map +1 -0
  321. package/dist/tools.js +73 -0
  322. package/dist/tools.js.map +1 -0
  323. package/dist/types.d.ts +2421 -0
  324. package/dist/types.d.ts.map +1 -0
  325. package/dist/types.js +55 -0
  326. package/dist/types.js.map +1 -0
  327. package/package.json +81 -0
@@ -0,0 +1,627 @@
1
+ /**
2
+ * Context management for token tracking and auto-compaction.
3
+ *
4
+ * This module provides tools for managing conversation context, including:
5
+ * - Token counting and budget tracking
6
+ * - Automatic context compaction/summarization
7
+ * - Message history management
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ import type { LanguageModel, ModelMessage } from "ai";
12
+ import type { Agent } from "./types.js";
13
+ /**
14
+ * Interface for counting tokens in text and messages.
15
+ *
16
+ * Implementations can use different tokenization strategies:
17
+ * - Approximate counting (4 chars ≈ 1 token)
18
+ * - Model-specific tokenizers (tiktoken, etc.)
19
+ *
20
+ * @category Context
21
+ */
22
+ export interface TokenCounter {
23
+ /**
24
+ * Count tokens in a text string.
25
+ * @param text - The text to count tokens in
26
+ * @returns The estimated token count
27
+ */
28
+ count(text: string): number;
29
+ /**
30
+ * Count tokens in an array of messages.
31
+ * @param messages - The messages to count tokens in
32
+ * @returns The estimated token count
33
+ */
34
+ countMessages(messages: ModelMessage[]): number;
35
+ /**
36
+ * Invalidate cached token counts.
37
+ * Call this when messages have been modified.
38
+ */
39
+ invalidateCache?(): void;
40
+ }
41
+ /**
42
+ * Creates a simple token counter using character approximation.
43
+ *
44
+ * Uses the common approximation of 4 characters per token.
45
+ * This is faster but less accurate than model-specific tokenizers.
46
+ * Includes a message-level cache to avoid re-counting identical messages.
47
+ *
48
+ * @returns A token counter using character approximation
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * const counter = createApproximateTokenCounter();
53
+ * const tokens = counter.count("Hello, world!"); // ~3 tokens
54
+ * ```
55
+ *
56
+ * @category Context
57
+ */
58
+ export declare function createApproximateTokenCounter(): TokenCounter;
59
+ /**
60
+ * Options for creating a custom token counter.
61
+ *
62
+ * @category Context
63
+ */
64
+ export interface CustomTokenCounterOptions {
65
+ /**
66
+ * Custom function to count tokens in text.
67
+ * Use this to integrate model-specific tokenizers like tiktoken.
68
+ */
69
+ countFn: (text: string) => number;
70
+ /**
71
+ * Overhead tokens per message (default: 4).
72
+ * Accounts for message structure tokens.
73
+ */
74
+ messageOverhead?: number;
75
+ }
76
+ /**
77
+ * Creates a token counter with a custom counting function.
78
+ *
79
+ * Use this to integrate model-specific tokenizers for more accurate counts.
80
+ * Includes a message-level cache to avoid re-counting identical messages.
81
+ *
82
+ * @param options - Configuration for the token counter
83
+ * @returns A token counter using the custom function
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * import { encoding_for_model } from "tiktoken";
88
+ *
89
+ * const encoder = encoding_for_model("gpt-4");
90
+ * const counter = createCustomTokenCounter({
91
+ * countFn: (text) => encoder.encode(text).length,
92
+ * });
93
+ * ```
94
+ *
95
+ * @category Context
96
+ */
97
+ export declare function createCustomTokenCounter(options: CustomTokenCounterOptions): TokenCounter;
98
+ /**
99
+ * Token budget tracking for context management.
100
+ *
101
+ * @category Context
102
+ */
103
+ export interface TokenBudget {
104
+ /** Maximum tokens allowed in context */
105
+ maxTokens: number;
106
+ /** Current token count in context */
107
+ currentTokens: number;
108
+ /** Usage percentage (0-1) */
109
+ usage: number;
110
+ /** Remaining tokens available */
111
+ remaining: number;
112
+ /**
113
+ * Whether this budget is based on actual usage from the model.
114
+ * True if updated with real usage data, false if estimated.
115
+ */
116
+ isActual?: boolean;
117
+ }
118
+ /**
119
+ * Creates a token budget from current usage.
120
+ *
121
+ * @param maxTokens - Maximum tokens allowed
122
+ * @param currentTokens - Current token count
123
+ * @param isActual - Whether this is based on actual model usage (default: false)
124
+ * @returns A token budget object
125
+ *
126
+ * @category Context
127
+ */
128
+ export declare function createTokenBudget(maxTokens: number, currentTokens: number, isActual?: boolean): TokenBudget;
129
+ /**
130
+ * Compaction trigger reason.
131
+ *
132
+ * @category Context
133
+ */
134
+ export type CompactionTrigger = "token_threshold" | "hard_cap" | "growth_rate" | "error_fallback";
135
+ /**
136
+ * Policy for determining when to trigger context compaction.
137
+ *
138
+ * Provides multi-signal triggering beyond simple threshold checks:
139
+ * - Token usage threshold (default: 80% of max)
140
+ * - Hard cap safety (force compaction at 95% to prevent errors)
141
+ * - Growth rate prediction (preemptive compaction)
142
+ * - Error-triggered fallback (emergency compaction on context errors)
143
+ *
144
+ * @category Context
145
+ */
146
+ export interface CompactionPolicy {
147
+ /**
148
+ * Enable compaction (default: true).
149
+ */
150
+ enabled: boolean;
151
+ /**
152
+ * Token usage threshold to trigger compaction (0-1).
153
+ * Compaction occurs when usage >= threshold.
154
+ * @defaultValue 0.8 (80% of max tokens)
155
+ */
156
+ tokenThreshold: number;
157
+ /**
158
+ * Hard cap threshold for safety (0-1).
159
+ * Forces compaction when usage >= hardCapThreshold to prevent errors.
160
+ * @defaultValue 0.95 (95% of max tokens)
161
+ */
162
+ hardCapThreshold: number;
163
+ /**
164
+ * Enable growth rate prediction (default: false).
165
+ * If true, triggers compaction when growth rate suggests next call will exceed threshold.
166
+ */
167
+ enableGrowthRatePrediction: boolean;
168
+ /**
169
+ * Enable error-triggered fallback compaction (default: true).
170
+ * If true, automatically triggers emergency compaction on context length errors.
171
+ */
172
+ enableErrorFallback: boolean;
173
+ /**
174
+ * Custom function to decide if compaction is needed.
175
+ * If provided, overrides default policy logic.
176
+ * @param budget - Current token budget
177
+ * @param messages - Current message history
178
+ * @returns True if compaction should be triggered, and optional trigger reason
179
+ */
180
+ shouldCompact?: (budget: TokenBudget, messages: ModelMessage[]) => {
181
+ trigger: boolean;
182
+ reason?: CompactionTrigger;
183
+ };
184
+ }
185
+ /**
186
+ * Default compaction policy.
187
+ *
188
+ * @category Context
189
+ */
190
+ export declare const DEFAULT_COMPACTION_POLICY: CompactionPolicy;
191
+ /**
192
+ * Compaction strategy type.
193
+ *
194
+ * - **rollup**: Summarize older messages into a single summary (default)
195
+ * - **tiered**: Create multiple summary layers (summary of summary)
196
+ * - **structured**: Generate structured summaries with sections (decisions, tasks, etc.)
197
+ *
198
+ * @category Context
199
+ */
200
+ export type CompactionStrategy = "rollup" | "tiered" | "structured";
201
+ /**
202
+ * Structured summary format with distinct sections.
203
+ * Provides better context organization and parsing.
204
+ *
205
+ * @category Context
206
+ */
207
+ export interface StructuredSummary {
208
+ /** Key decisions made in the conversation */
209
+ decisions: string[];
210
+ /** User preferences and requirements */
211
+ preferences: string[];
212
+ /** Current state of tasks or projects */
213
+ currentState: string[];
214
+ /** Open questions or unresolved issues */
215
+ openQuestions: string[];
216
+ /** Important references (files, IDs, URLs, etc.) */
217
+ references: string[];
218
+ }
219
+ /**
220
+ * Metadata for pinned messages that should always be kept.
221
+ *
222
+ * @category Context
223
+ */
224
+ export interface PinnedMessageMetadata {
225
+ /** Index of the pinned message */
226
+ messageIndex: number;
227
+ /** Reason this message is pinned */
228
+ reason: string;
229
+ /** Timestamp when pinned */
230
+ pinnedAt: number;
231
+ }
232
+ /**
233
+ * Configuration for automatic context summarization.
234
+ *
235
+ * @category Context
236
+ */
237
+ export interface SummarizationConfig {
238
+ /**
239
+ * Number of recent messages to always keep uncompacted.
240
+ * These messages are preserved to maintain recent context.
241
+ * @defaultValue 10
242
+ */
243
+ keepMessageCount: number;
244
+ /**
245
+ * Number of recent tool results to preserve.
246
+ * Tool results are often referenced, so keep some recent ones.
247
+ * @defaultValue 5
248
+ */
249
+ keepToolResultCount: number;
250
+ /**
251
+ * Custom summarization prompt.
252
+ * If not provided, a default prompt is used.
253
+ */
254
+ summaryPrompt?: string;
255
+ /**
256
+ * Compaction strategy to use.
257
+ * @defaultValue "rollup"
258
+ */
259
+ strategy?: CompactionStrategy;
260
+ /**
261
+ * Enable tiered summaries (requires strategy: "tiered").
262
+ * When enabled, creates multiple summary layers over time.
263
+ * @defaultValue false
264
+ */
265
+ enableTieredSummaries?: boolean;
266
+ /**
267
+ * Maximum number of summary tiers (for tiered strategy).
268
+ * @defaultValue 3
269
+ */
270
+ maxSummaryTiers?: number;
271
+ /**
272
+ * Messages per tier (for tiered strategy).
273
+ * Each tier summarizes this many previous summaries.
274
+ * @defaultValue 5
275
+ */
276
+ messagesPerTier?: number;
277
+ /**
278
+ * Enable structured summary format.
279
+ * When true, generates summaries with distinct sections.
280
+ * @defaultValue false
281
+ */
282
+ enableStructuredSummary?: boolean;
283
+ }
284
+ /**
285
+ * Default summarization configuration.
286
+ *
287
+ * @category Context
288
+ */
289
+ export declare const DEFAULT_SUMMARIZATION_CONFIG: SummarizationConfig;
290
+ /**
291
+ * Result from a context compaction operation.
292
+ *
293
+ * @category Context
294
+ */
295
+ export interface CompactionResult {
296
+ /** Number of messages before compaction */
297
+ messagesBefore: number;
298
+ /** Number of messages after compaction */
299
+ messagesAfter: number;
300
+ /** Token count before compaction */
301
+ tokensBefore: number;
302
+ /** Token count after compaction */
303
+ tokensAfter: number;
304
+ /** The generated summary of compacted content */
305
+ summary: string;
306
+ /** Messages that were compacted */
307
+ compactedMessages: ModelMessage[];
308
+ /** New message history after compaction */
309
+ newMessages: ModelMessage[];
310
+ /** Reason compaction was triggered */
311
+ trigger: CompactionTrigger;
312
+ /** Strategy used for compaction */
313
+ strategy?: CompactionStrategy;
314
+ /** Structured summary (if structured format enabled) */
315
+ structuredSummary?: StructuredSummary;
316
+ /** Summary tier level (for tiered summaries) */
317
+ summaryTier?: number;
318
+ }
319
+ /**
320
+ * Status of a background compaction task.
321
+ *
322
+ * @category Context
323
+ */
324
+ export type CompactionTaskStatus = "pending" | "running" | "completed" | "failed";
325
+ /**
326
+ * A background compaction task.
327
+ *
328
+ * @category Context
329
+ */
330
+ export interface CompactionTask {
331
+ /** Unique identifier for this task */
332
+ id: string;
333
+ /** Current status */
334
+ status: CompactionTaskStatus;
335
+ /** Messages to compact */
336
+ messages: ModelMessage[];
337
+ /** Timestamp when task was created */
338
+ createdAt: number;
339
+ /** Timestamp when task started (if running) */
340
+ startedAt?: number;
341
+ /** Timestamp when task completed (if done) */
342
+ completedAt?: number;
343
+ /** Compaction result (if completed) */
344
+ result?: CompactionResult;
345
+ /** Error (if failed) */
346
+ error?: Error;
347
+ /** Reason compaction was triggered */
348
+ trigger: CompactionTrigger;
349
+ }
350
+ /**
351
+ * Options for creating a compaction scheduler.
352
+ *
353
+ * @category Context
354
+ */
355
+ export interface CompactionSchedulerOptions {
356
+ /**
357
+ * Enable background compaction (default: false).
358
+ * When enabled, compaction runs asynchronously after generation completes.
359
+ */
360
+ enableBackgroundCompaction?: boolean;
361
+ /**
362
+ * Debounce delay in milliseconds (default: 5000).
363
+ * Prevents multiple compactions from running in rapid succession.
364
+ */
365
+ debounceDelayMs?: number;
366
+ /**
367
+ * Maximum pending tasks before dropping oldest (default: 3).
368
+ * Prevents unbounded queue growth.
369
+ */
370
+ maxPendingTasks?: number;
371
+ /**
372
+ * Callback when a compaction task completes.
373
+ */
374
+ onTaskComplete?: (task: CompactionTask) => void;
375
+ /**
376
+ * Callback when a compaction task fails.
377
+ */
378
+ onTaskError?: (task: CompactionTask) => void;
379
+ }
380
+ /**
381
+ * Scheduler for managing background compaction tasks.
382
+ *
383
+ * Provides:
384
+ * - Debouncing to avoid rapid consecutive compactions
385
+ * - Background task queue with configurable depth
386
+ * - Task status tracking
387
+ * - Automatic cleanup of completed tasks
388
+ *
389
+ * @category Context
390
+ */
391
+ export interface CompactionScheduler {
392
+ /**
393
+ * Schedule a compaction task.
394
+ * @param messages - Messages to compact
395
+ * @param agent - Agent to use for summarization
396
+ * @param trigger - Reason compaction was triggered
397
+ * @returns Task ID
398
+ */
399
+ schedule(messages: ModelMessage[], agent: Agent, trigger: CompactionTrigger): string;
400
+ /**
401
+ * Get a task by ID.
402
+ * @param id - Task ID
403
+ * @returns The task, or undefined if not found
404
+ */
405
+ getTask(id: string): CompactionTask | undefined;
406
+ /**
407
+ * Get all pending tasks.
408
+ * @returns Array of pending tasks
409
+ */
410
+ getPendingTasks(): CompactionTask[];
411
+ /**
412
+ * Get the most recent completed task result.
413
+ * This can be applied to the next generation if available.
414
+ * @returns The most recent completed result, or undefined
415
+ */
416
+ getLatestResult(): CompactionResult | undefined;
417
+ /**
418
+ * Cancel a pending task.
419
+ * @param id - Task ID
420
+ * @returns True if task was cancelled
421
+ */
422
+ cancel(id: string): boolean;
423
+ /**
424
+ * Clear all completed and failed tasks from history.
425
+ */
426
+ cleanup(): void;
427
+ /**
428
+ * Shutdown the scheduler and cancel all pending tasks.
429
+ */
430
+ shutdown(): void;
431
+ }
432
+ /**
433
+ * Creates a compaction scheduler for managing background compaction tasks.
434
+ *
435
+ * @param contextManager - The context manager to use for compaction
436
+ * @param options - Scheduler configuration options
437
+ * @returns A compaction scheduler instance
438
+ *
439
+ * @example
440
+ * ```typescript
441
+ * const scheduler = createCompactionScheduler(contextManager, {
442
+ * enableBackgroundCompaction: true,
443
+ * debounceDelayMs: 5000,
444
+ * onTaskComplete: (task) => {
445
+ * console.log(`Compaction saved ${task.result?.tokensBefore - task.result?.tokensAfter} tokens`);
446
+ * },
447
+ * });
448
+ *
449
+ * // Schedule a compaction
450
+ * const taskId = scheduler.schedule(messages, agent, "token_threshold");
451
+ *
452
+ * // Later, get the result
453
+ * const result = scheduler.getLatestResult();
454
+ * if (result) {
455
+ * messages = result.newMessages;
456
+ * }
457
+ * ```
458
+ *
459
+ * @category Context
460
+ */
461
+ export declare function createCompactionScheduler(contextManager: ContextManager, options?: CompactionSchedulerOptions): CompactionScheduler;
462
+ /**
463
+ * Options for creating a context manager.
464
+ *
465
+ * @category Context
466
+ */
467
+ export interface ContextManagerOptions {
468
+ /** Maximum tokens allowed in context */
469
+ maxTokens: number;
470
+ /** Token counter to use (default: approximate counter) */
471
+ tokenCounter?: TokenCounter;
472
+ /** Compaction policy configuration */
473
+ policy?: Partial<CompactionPolicy>;
474
+ /** Summarization configuration */
475
+ summarization?: Partial<SummarizationConfig>;
476
+ /** Model to use for summarization (if different from agent model) */
477
+ summarizationModel?: LanguageModel;
478
+ /** Scheduler configuration for background compaction */
479
+ scheduler?: CompactionSchedulerOptions;
480
+ /**
481
+ * Callback when context budget is updated.
482
+ * Useful for emitting events or updating UI.
483
+ */
484
+ onBudgetUpdate?: (budget: TokenBudget) => void;
485
+ /**
486
+ * Callback when compaction occurs.
487
+ * Useful for logging or emitting events.
488
+ */
489
+ onCompact?: (result: CompactionResult) => void;
490
+ }
491
+ /**
492
+ * Manages conversation context with token tracking and auto-compaction.
493
+ *
494
+ * @category Context
495
+ */
496
+ export interface ContextManager {
497
+ /** Current token counter */
498
+ readonly tokenCounter: TokenCounter;
499
+ /** Current compaction policy */
500
+ readonly policy: CompactionPolicy;
501
+ /** Current summarization config */
502
+ readonly summarizationConfig: SummarizationConfig;
503
+ /** Maximum tokens allowed */
504
+ readonly maxTokens: number;
505
+ /** Compaction scheduler (if background compaction is enabled) */
506
+ readonly scheduler?: CompactionScheduler;
507
+ /** Pinned messages that should always be kept */
508
+ readonly pinnedMessages: PinnedMessageMetadata[];
509
+ /**
510
+ * Get the current token budget.
511
+ * @param messages - Current message history
512
+ * @returns The token budget
513
+ */
514
+ getBudget(messages: ModelMessage[]): TokenBudget;
515
+ /**
516
+ * Check if compaction is needed based on current token usage.
517
+ * @param messages - Current message history
518
+ * @returns Object with trigger status and optional reason
519
+ */
520
+ shouldCompact(messages: ModelMessage[]): {
521
+ trigger: boolean;
522
+ reason?: CompactionTrigger;
523
+ };
524
+ /**
525
+ * Compact the message history by summarizing older messages.
526
+ * @param messages - Current message history
527
+ * @param agent - Agent to use for summarization
528
+ * @param trigger - Reason compaction was triggered (default: "token_threshold")
529
+ * @returns Compaction result with new message history
530
+ */
531
+ compact(messages: ModelMessage[], agent: Agent, trigger?: CompactionTrigger): Promise<CompactionResult>;
532
+ /**
533
+ * Process messages, automatically compacting if needed.
534
+ * @param messages - Current message history
535
+ * @param agent - Agent to use for summarization
536
+ * @returns The processed messages (may be compacted)
537
+ */
538
+ process(messages: ModelMessage[], agent: Agent): Promise<ModelMessage[]>;
539
+ /**
540
+ * Update token tracking with actual usage from a model response.
541
+ * This provides more accurate token counts than estimation.
542
+ *
543
+ * @param usage - Token usage from the model response (AI SDK v6 format)
544
+ * @param usage.inputTokens - Tokens used in the input/prompt
545
+ * @param usage.outputTokens - Tokens used in the output/completion
546
+ * @param usage.totalTokens - Total tokens used
547
+ */
548
+ updateUsage?(usage: {
549
+ inputTokens: number | undefined;
550
+ outputTokens: number | undefined;
551
+ totalTokens: number | undefined;
552
+ }): void;
553
+ /**
554
+ * Pin a message to prevent it from being compacted.
555
+ * Pinned messages are always kept in the conversation history.
556
+ *
557
+ * @param messageIndex - Index of the message to pin
558
+ * @param reason - Reason for pinning this message
559
+ */
560
+ pinMessage(messageIndex: number, reason: string): void;
561
+ /**
562
+ * Unpin a message.
563
+ * @param messageIndex - Index of the message to unpin
564
+ */
565
+ unpinMessage(messageIndex: number): void;
566
+ /**
567
+ * Check if a message is pinned.
568
+ * @param messageIndex - Index of the message to check
569
+ * @returns True if the message is pinned
570
+ */
571
+ isPinned(messageIndex: number): boolean;
572
+ }
573
+ /**
574
+ * Creates a context manager for tracking and managing conversation context.
575
+ *
576
+ * @param options - Configuration options
577
+ * @returns A context manager instance
578
+ *
579
+ * @example
580
+ * ```typescript
581
+ * const contextManager = createContextManager({
582
+ * maxTokens: 100000,
583
+ * summarization: {
584
+ * tokenThreshold: 0.75,
585
+ * keepMessageCount: 15,
586
+ * },
587
+ * onBudgetUpdate: (budget) => {
588
+ * console.log(`Context usage: ${(budget.usage * 100).toFixed(1)}%`);
589
+ * },
590
+ * });
591
+ *
592
+ * // Check budget
593
+ * const budget = contextManager.getBudget(messages);
594
+ *
595
+ * // Process messages (auto-compacts if needed)
596
+ * const processedMessages = await contextManager.process(messages, agent);
597
+ * ```
598
+ *
599
+ * @category Context
600
+ */
601
+ export declare function createContextManager(options: ContextManagerOptions): ContextManager;
602
+ /**
603
+ * Extracts tool results from messages.
604
+ *
605
+ * @param messages - Messages to search
606
+ * @returns Array of tool results with their context
607
+ */
608
+ export declare function extractToolResults(messages: ModelMessage[]): Array<{
609
+ toolName: string;
610
+ output: unknown;
611
+ messageIndex: number;
612
+ }>;
613
+ /**
614
+ * Finds the last user message in the conversation.
615
+ *
616
+ * @param messages - Messages to search
617
+ * @returns The last user message content, or undefined
618
+ */
619
+ export declare function findLastUserMessage(messages: ModelMessage[]): string | undefined;
620
+ /**
621
+ * Counts messages by role.
622
+ *
623
+ * @param messages - Messages to count
624
+ * @returns Object with counts per role
625
+ */
626
+ export declare function countMessagesByRole(messages: ModelMessage[]): Record<string, number>;
627
+ //# sourceMappingURL=context-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-manager.d.ts","sourceRoot":"","sources":["../src/context-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAA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