@dexto/core 1.7.2 → 1.8.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 (533) hide show
  1. package/dist/agent/DextoAgent.cjs +157 -62
  2. package/dist/agent/DextoAgent.d.ts +71 -17
  3. package/dist/agent/DextoAgent.d.ts.map +1 -1
  4. package/dist/agent/DextoAgent.js +161 -63
  5. package/dist/agent/agent-options.d.ts +6 -10
  6. package/dist/agent/agent-options.d.ts.map +1 -1
  7. package/dist/agent/agentCard.js +1 -1
  8. package/dist/agent/error-codes.js +1 -1
  9. package/dist/agent/errors.js +1 -1
  10. package/dist/agent/index.d.ts +1 -0
  11. package/dist/agent/index.d.ts.map +1 -1
  12. package/dist/agent/index.js +1 -1
  13. package/dist/agent/schemas.d.ts +2 -2
  14. package/dist/agent/schemas.js +1 -1
  15. package/dist/agent/state-manager.js +1 -1
  16. package/dist/approval/error-codes.cjs +1 -1
  17. package/dist/approval/error-codes.d.ts +1 -1
  18. package/dist/approval/error-codes.d.ts.map +1 -1
  19. package/dist/approval/error-codes.js +2 -2
  20. package/dist/approval/errors.cjs +2 -5
  21. package/dist/approval/errors.d.ts.map +1 -1
  22. package/dist/approval/errors.js +3 -6
  23. package/dist/approval/factory.cjs +19 -4
  24. package/dist/approval/factory.d.ts +4 -1
  25. package/dist/approval/factory.d.ts.map +1 -1
  26. package/dist/approval/factory.js +19 -5
  27. package/dist/approval/index.d.ts +1 -1
  28. package/dist/approval/index.d.ts.map +1 -1
  29. package/dist/approval/index.js +1 -1
  30. package/dist/approval/manager.cjs +168 -26
  31. package/dist/approval/manager.d.ts +46 -12
  32. package/dist/approval/manager.d.ts.map +1 -1
  33. package/dist/approval/manager.js +177 -29
  34. package/dist/approval/schemas.cjs +26 -26
  35. package/dist/approval/schemas.d.ts +29 -29
  36. package/dist/approval/schemas.d.ts.map +1 -1
  37. package/dist/approval/schemas.js +23 -23
  38. package/dist/approval/types.cjs +5 -5
  39. package/dist/approval/types.d.ts +18 -18
  40. package/dist/approval/types.d.ts.map +1 -1
  41. package/dist/approval/types.js +6 -6
  42. package/dist/{chunk-PTJYTZNU.js → chunk-C6A6W6XS.js} +1 -44
  43. package/dist/config/index.cjs +75 -0
  44. package/dist/config/index.d.ts +15 -0
  45. package/dist/config/index.d.ts.map +1 -0
  46. package/dist/config/index.js +50 -0
  47. package/dist/context/compaction/overflow.js +1 -1
  48. package/dist/context/compaction/strategies/noop.js +1 -1
  49. package/dist/context/compaction/strategies/reactive-overflow-compaction.js +1 -1
  50. package/dist/context/content-clone.cjs +131 -0
  51. package/dist/context/content-clone.d.ts +7 -0
  52. package/dist/context/content-clone.d.ts.map +1 -0
  53. package/dist/context/content-clone.js +104 -0
  54. package/dist/context/error-codes.js +1 -1
  55. package/dist/context/errors.js +1 -1
  56. package/dist/context/index.cjs +2 -0
  57. package/dist/context/index.d.ts +1 -0
  58. package/dist/context/index.d.ts.map +1 -1
  59. package/dist/context/index.js +2 -1
  60. package/dist/context/manager.cjs +44 -33
  61. package/dist/context/manager.d.ts +7 -7
  62. package/dist/context/manager.d.ts.map +1 -1
  63. package/dist/context/manager.js +45 -34
  64. package/dist/context/media-helpers.js +1 -1
  65. package/dist/context/schemas.cjs +77 -0
  66. package/dist/context/schemas.d.ts +5 -0
  67. package/dist/context/schemas.d.ts.map +1 -0
  68. package/dist/context/schemas.js +53 -0
  69. package/dist/context/types.js +1 -1
  70. package/dist/context/utils.cjs +70 -69
  71. package/dist/context/utils.d.ts +3 -3
  72. package/dist/context/utils.d.ts.map +1 -1
  73. package/dist/context/utils.js +71 -70
  74. package/dist/errors/DextoBaseError.js +1 -1
  75. package/dist/errors/DextoRuntimeError.js +1 -1
  76. package/dist/errors/DextoValidationError.js +1 -1
  77. package/dist/errors/index.js +1 -1
  78. package/dist/errors/result-bridge.js +1 -1
  79. package/dist/errors/types.js +1 -1
  80. package/dist/events/index.cjs +9 -1
  81. package/dist/events/index.d.ts +20 -8
  82. package/dist/events/index.d.ts.map +1 -1
  83. package/dist/events/index.js +10 -2
  84. package/dist/hooks/builtins/content-policy.js +1 -1
  85. package/dist/hooks/builtins/response-sanitizer.js +1 -1
  86. package/dist/hooks/error-codes.js +1 -1
  87. package/dist/hooks/index.js +1 -1
  88. package/dist/hooks/manager.cjs +1 -1
  89. package/dist/hooks/manager.d.ts +2 -2
  90. package/dist/hooks/manager.d.ts.map +1 -1
  91. package/dist/hooks/manager.js +2 -2
  92. package/dist/hooks/types.d.ts +2 -2
  93. package/dist/hooks/types.d.ts.map +1 -1
  94. package/dist/index.browser.js +1 -1
  95. package/dist/index.cjs +2 -0
  96. package/dist/index.d.ts +1 -0
  97. package/dist/index.d.ts.map +1 -1
  98. package/dist/index.js +2 -1
  99. package/dist/llm/curation-config.js +1 -1
  100. package/dist/llm/curation.js +1 -1
  101. package/dist/llm/error-codes.js +1 -1
  102. package/dist/llm/errors.js +1 -1
  103. package/dist/llm/executor/index.cjs +32 -0
  104. package/dist/llm/executor/index.d.ts +2 -0
  105. package/dist/llm/executor/index.d.ts.map +1 -0
  106. package/dist/llm/executor/index.js +11 -0
  107. package/dist/llm/executor/provider-options.js +1 -1
  108. package/dist/llm/executor/stream-processor.cjs +28 -139
  109. package/dist/llm/executor/stream-processor.d.ts +2 -13
  110. package/dist/llm/executor/stream-processor.d.ts.map +1 -1
  111. package/dist/llm/executor/stream-processor.js +29 -140
  112. package/dist/{session/history/memory.cjs → llm/executor/tool-definitions.cjs} +21 -33
  113. package/dist/llm/executor/tool-definitions.d.ts +4 -0
  114. package/dist/llm/executor/tool-definitions.d.ts.map +1 -0
  115. package/dist/llm/executor/tool-definitions.js +22 -0
  116. package/dist/llm/executor/tool-output-truncator.js +1 -1
  117. package/dist/llm/executor/turn-executor.cjs +1093 -458
  118. package/dist/llm/executor/turn-executor.d.ts +269 -43
  119. package/dist/llm/executor/turn-executor.d.ts.map +1 -1
  120. package/dist/llm/executor/turn-executor.js +1079 -405
  121. package/dist/llm/executor/types.d.ts +6 -0
  122. package/dist/llm/executor/types.d.ts.map +1 -1
  123. package/dist/llm/formatters/vercel.js +1 -1
  124. package/dist/llm/index.cjs +2 -0
  125. package/dist/llm/index.d.ts +1 -0
  126. package/dist/llm/index.d.ts.map +1 -1
  127. package/dist/llm/index.js +2 -1
  128. package/dist/llm/providers/codex-app-server.cjs +22 -2
  129. package/dist/llm/providers/codex-app-server.d.ts.map +1 -1
  130. package/dist/llm/providers/codex-app-server.js +23 -3
  131. package/dist/llm/providers/codex-base-url.js +1 -1
  132. package/dist/llm/providers/local/ai-sdk-adapter.js +1 -1
  133. package/dist/llm/providers/local/downloader.js +1 -1
  134. package/dist/llm/providers/local/error-codes.js +1 -1
  135. package/dist/llm/providers/local/errors.js +1 -1
  136. package/dist/llm/providers/local/gpu-detector.js +1 -1
  137. package/dist/llm/providers/local/index.js +1 -1
  138. package/dist/llm/providers/local/node-llama-provider.js +1 -1
  139. package/dist/llm/providers/local/ollama-provider.js +1 -1
  140. package/dist/llm/providers/local/registry.js +1 -1
  141. package/dist/llm/providers/local/schemas.js +1 -1
  142. package/dist/llm/providers/openrouter-model-registry.js +1 -1
  143. package/dist/llm/reasoning/anthropic-betas.js +1 -1
  144. package/dist/llm/reasoning/anthropic-thinking.js +1 -1
  145. package/dist/llm/reasoning/openai-reasoning-effort.js +1 -1
  146. package/dist/llm/reasoning/profile.js +1 -1
  147. package/dist/llm/reasoning/profiles/anthropic.js +1 -1
  148. package/dist/llm/reasoning/profiles/bedrock.js +1 -1
  149. package/dist/llm/reasoning/profiles/google.js +1 -1
  150. package/dist/llm/reasoning/profiles/openai-compatible.js +1 -1
  151. package/dist/llm/reasoning/profiles/openai.js +1 -1
  152. package/dist/llm/reasoning/profiles/openrouter.js +1 -1
  153. package/dist/llm/reasoning/profiles/shared.js +1 -1
  154. package/dist/llm/reasoning/profiles/vertex.js +1 -1
  155. package/dist/llm/registry/auto-update.js +1 -1
  156. package/dist/llm/registry/index.js +1 -1
  157. package/dist/llm/registry/models.generated.js +1 -1
  158. package/dist/llm/registry/models.manual.js +1 -1
  159. package/dist/llm/registry/sync.js +1 -1
  160. package/dist/llm/resolver.js +1 -1
  161. package/dist/llm/schemas.js +1 -1
  162. package/dist/llm/services/factory.cjs +5 -4
  163. package/dist/llm/services/factory.d.ts +3 -3
  164. package/dist/llm/services/factory.d.ts.map +1 -1
  165. package/dist/llm/services/factory.js +6 -5
  166. package/dist/llm/services/types.d.ts +10 -1
  167. package/dist/llm/services/types.d.ts.map +1 -1
  168. package/dist/llm/services/vercel.cjs +23 -8
  169. package/dist/llm/services/vercel.d.ts +11 -7
  170. package/dist/llm/services/vercel.d.ts.map +1 -1
  171. package/dist/llm/services/vercel.js +24 -9
  172. package/dist/llm/types.js +1 -1
  173. package/dist/llm/usage-metadata.cjs +20 -3
  174. package/dist/llm/usage-metadata.d.ts +1 -0
  175. package/dist/llm/usage-metadata.d.ts.map +1 -1
  176. package/dist/llm/usage-metadata.js +19 -3
  177. package/dist/llm/usage-scope.js +1 -1
  178. package/dist/llm/usage-summary.js +1 -1
  179. package/dist/llm/validation.js +1 -1
  180. package/dist/logger/browser.js +1 -1
  181. package/dist/logger/default-logger-factory.js +1 -1
  182. package/dist/logger/factory.js +1 -1
  183. package/dist/logger/index.js +1 -1
  184. package/dist/logger/logger.js +1 -1
  185. package/dist/logger/v2/dexto-logger.js +1 -1
  186. package/dist/logger/v2/error-codes.js +1 -1
  187. package/dist/logger/v2/errors.js +1 -1
  188. package/dist/logger/v2/schemas.js +1 -1
  189. package/dist/logger/v2/test-utils.js +1 -1
  190. package/dist/logger/v2/transport-factory.js +1 -1
  191. package/dist/logger/v2/transports/console-transport.js +1 -1
  192. package/dist/logger/v2/transports/file-transport.js +1 -1
  193. package/dist/logger/v2/transports/silent-transport.js +1 -1
  194. package/dist/logger/v2/types.js +1 -1
  195. package/dist/mcp/bundled-config.js +1 -1
  196. package/dist/mcp/error-codes.js +1 -1
  197. package/dist/mcp/errors.js +1 -1
  198. package/dist/mcp/index.js +1 -1
  199. package/dist/mcp/manager.js +1 -1
  200. package/dist/mcp/mcp-client.js +1 -1
  201. package/dist/mcp/resolver.js +1 -1
  202. package/dist/mcp/schemas.js +1 -1
  203. package/dist/memory/error-codes.js +1 -1
  204. package/dist/memory/errors.js +1 -1
  205. package/dist/memory/index.js +1 -1
  206. package/dist/memory/manager.cjs +7 -27
  207. package/dist/memory/manager.d.ts +4 -12
  208. package/dist/memory/manager.d.ts.map +1 -1
  209. package/dist/memory/manager.js +8 -28
  210. package/dist/memory/schemas.js +1 -1
  211. package/dist/prompts/error-codes.js +1 -1
  212. package/dist/prompts/errors.js +1 -1
  213. package/dist/prompts/index.js +1 -1
  214. package/dist/prompts/name-validation.js +1 -1
  215. package/dist/prompts/prompt-manager.cjs +9 -38
  216. package/dist/prompts/prompt-manager.d.ts +2 -10
  217. package/dist/prompts/prompt-manager.d.ts.map +1 -1
  218. package/dist/prompts/prompt-manager.js +10 -39
  219. package/dist/prompts/providers/config-prompt-provider.cjs +8 -87
  220. package/dist/prompts/providers/config-prompt-provider.d.ts.map +1 -1
  221. package/dist/prompts/providers/config-prompt-provider.js +9 -88
  222. package/dist/prompts/providers/custom-prompt-provider.cjs +21 -22
  223. package/dist/prompts/providers/custom-prompt-provider.d.ts +19 -4
  224. package/dist/prompts/providers/custom-prompt-provider.d.ts.map +1 -1
  225. package/dist/prompts/providers/custom-prompt-provider.js +22 -23
  226. package/dist/prompts/providers/mcp-prompt-provider.js +1 -1
  227. package/dist/prompts/schemas.cjs +2 -24
  228. package/dist/prompts/schemas.d.ts +0 -52
  229. package/dist/prompts/schemas.d.ts.map +1 -1
  230. package/dist/prompts/schemas.js +3 -25
  231. package/dist/prompts/types.d.ts +5 -32
  232. package/dist/prompts/types.d.ts.map +1 -1
  233. package/dist/prompts/utils.js +1 -1
  234. package/dist/resources/agent-resources-provider.js +1 -1
  235. package/dist/resources/error-codes.js +1 -1
  236. package/dist/resources/errors.js +1 -1
  237. package/dist/resources/handlers/blob-handler.cjs +14 -11
  238. package/dist/resources/handlers/blob-handler.d.ts +4 -4
  239. package/dist/resources/handlers/blob-handler.d.ts.map +1 -1
  240. package/dist/resources/handlers/blob-handler.js +15 -12
  241. package/dist/resources/handlers/factory.cjs +3 -3
  242. package/dist/resources/handlers/factory.js +4 -4
  243. package/dist/resources/handlers/filesystem-handler.js +1 -1
  244. package/dist/resources/handlers/types.d.ts +2 -2
  245. package/dist/resources/handlers/types.d.ts.map +1 -1
  246. package/dist/resources/index.js +1 -1
  247. package/dist/resources/manager.cjs +10 -7
  248. package/dist/resources/manager.d.ts +4 -4
  249. package/dist/resources/manager.d.ts.map +1 -1
  250. package/dist/resources/manager.js +11 -8
  251. package/dist/resources/reference-parser.js +1 -1
  252. package/dist/resources/schemas.cjs +1 -1
  253. package/dist/resources/schemas.d.ts +2 -2
  254. package/dist/resources/schemas.js +2 -2
  255. package/dist/runtime/host-runtime.js +1 -1
  256. package/dist/runtime/index.cjs +3 -0
  257. package/dist/runtime/index.d.ts +2 -0
  258. package/dist/runtime/index.d.ts.map +1 -1
  259. package/dist/runtime/index.js +3 -1
  260. package/dist/runtime/run-context.js +1 -1
  261. package/dist/search/index.js +1 -1
  262. package/dist/search/search-service.cjs +6 -13
  263. package/dist/search/search-service.d.ts +5 -3
  264. package/dist/search/search-service.d.ts.map +1 -1
  265. package/dist/search/search-service.js +7 -14
  266. package/dist/session/chat-session.cjs +264 -108
  267. package/dist/session/chat-session.d.ts +75 -21
  268. package/dist/session/chat-session.d.ts.map +1 -1
  269. package/dist/session/chat-session.js +268 -108
  270. package/dist/session/error-codes.js +1 -1
  271. package/dist/session/errors.js +1 -1
  272. package/dist/session/index.cjs +19 -2
  273. package/dist/session/index.d.ts +4 -3
  274. package/dist/session/index.d.ts.map +1 -1
  275. package/dist/session/index.js +19 -3
  276. package/dist/session/message-queue.cjs +82 -51
  277. package/dist/session/message-queue.d.ts +13 -8
  278. package/dist/session/message-queue.d.ts.map +1 -1
  279. package/dist/session/message-queue.js +83 -52
  280. package/dist/session/queue-clone.cjs +50 -0
  281. package/dist/session/queue-clone.d.ts +5 -0
  282. package/dist/session/queue-clone.d.ts.map +1 -0
  283. package/dist/session/queue-clone.js +25 -0
  284. package/dist/session/schemas.cjs +74 -2
  285. package/dist/session/schemas.d.ts +94 -0
  286. package/dist/session/schemas.d.ts.map +1 -1
  287. package/dist/session/schemas.js +69 -2
  288. package/dist/session/session-manager.cjs +107 -123
  289. package/dist/session/session-manager.d.ts +7 -6
  290. package/dist/session/session-manager.d.ts.map +1 -1
  291. package/dist/session/session-manager.js +108 -124
  292. package/dist/session/title-generator.cjs +14 -26
  293. package/dist/session/title-generator.d.ts +4 -6
  294. package/dist/session/title-generator.d.ts.map +1 -1
  295. package/dist/session/title-generator.js +16 -28
  296. package/dist/session/types.cjs +28 -0
  297. package/dist/session/types.d.ts +5 -1
  298. package/dist/session/types.d.ts.map +1 -1
  299. package/dist/session/types.js +19 -0
  300. package/dist/{session/history/factory.cjs → skills/index.cjs} +9 -9
  301. package/dist/skills/index.d.ts +4 -0
  302. package/dist/skills/index.d.ts.map +1 -0
  303. package/dist/skills/index.js +7 -0
  304. package/dist/skills/skill-manager.cjs +76 -0
  305. package/dist/skills/skill-manager.d.ts +13 -0
  306. package/dist/skills/skill-manager.d.ts.map +1 -0
  307. package/dist/skills/skill-manager.js +53 -0
  308. package/dist/skills/types.d.ts +24 -0
  309. package/dist/skills/types.d.ts.map +1 -0
  310. package/dist/skills/workspace-skill-source.cjs +120 -0
  311. package/dist/skills/workspace-skill-source.d.ts +16 -0
  312. package/dist/skills/workspace-skill-source.d.ts.map +1 -0
  313. package/dist/skills/workspace-skill-source.js +97 -0
  314. package/dist/storage/approvals/types.cjs +38 -0
  315. package/dist/storage/approvals/types.d.ts +54 -0
  316. package/dist/storage/approvals/types.d.ts.map +1 -0
  317. package/dist/storage/approvals/types.js +14 -0
  318. package/dist/storage/artifacts/types.d.ts +73 -0
  319. package/dist/storage/artifacts/types.d.ts.map +1 -0
  320. package/dist/storage/conversation/database.cjs +233 -0
  321. package/dist/storage/conversation/database.d.ts +38 -0
  322. package/dist/storage/conversation/database.d.ts.map +1 -0
  323. package/dist/storage/conversation/database.js +210 -0
  324. package/dist/storage/conversation/types.cjs +16 -0
  325. package/dist/storage/conversation/types.d.ts +21 -0
  326. package/dist/storage/conversation/types.d.ts.map +1 -0
  327. package/dist/storage/conversation/types.js +0 -0
  328. package/dist/storage/database/types.d.ts +4 -0
  329. package/dist/storage/database/types.d.ts.map +1 -1
  330. package/dist/storage/error-codes.js +1 -1
  331. package/dist/storage/errors.cjs +6 -6
  332. package/dist/storage/errors.d.ts +2 -2
  333. package/dist/storage/errors.js +7 -7
  334. package/dist/storage/index.cjs +42 -5
  335. package/dist/storage/index.d.ts +19 -8
  336. package/dist/storage/index.d.ts.map +1 -1
  337. package/dist/storage/index.js +39 -4
  338. package/dist/storage/memories/types.cjs +16 -0
  339. package/dist/storage/memories/types.d.ts +17 -0
  340. package/dist/storage/memories/types.d.ts.map +1 -0
  341. package/dist/storage/memories/types.js +0 -0
  342. package/dist/storage/message-queue/types.cjs +16 -0
  343. package/dist/storage/message-queue/types.d.ts +15 -0
  344. package/dist/storage/message-queue/types.d.ts.map +1 -0
  345. package/dist/storage/message-queue/types.js +0 -0
  346. package/dist/storage/prompts/types.cjs +16 -0
  347. package/dist/storage/prompts/types.d.ts +14 -0
  348. package/dist/storage/prompts/types.d.ts.map +1 -0
  349. package/dist/storage/prompts/types.js +0 -0
  350. package/dist/storage/runtime-events/types.cjs +16 -0
  351. package/dist/storage/runtime-events/types.d.ts +19 -0
  352. package/dist/storage/runtime-events/types.d.ts.map +1 -0
  353. package/dist/storage/runtime-events/types.js +0 -0
  354. package/dist/storage/sessions/types.cjs +16 -0
  355. package/dist/storage/sessions/types.d.ts +19 -0
  356. package/dist/storage/sessions/types.d.ts.map +1 -0
  357. package/dist/storage/sessions/types.js +0 -0
  358. package/dist/storage/stores/backend.cjs +702 -0
  359. package/dist/storage/stores/backend.d.ts +303 -0
  360. package/dist/storage/stores/backend.d.ts.map +1 -0
  361. package/dist/storage/stores/backend.js +677 -0
  362. package/dist/storage/stores/in-memory.cjs +510 -0
  363. package/dist/storage/stores/in-memory.d.ts +11 -0
  364. package/dist/storage/stores/in-memory.d.ts.map +1 -0
  365. package/dist/storage/stores/in-memory.js +487 -0
  366. package/dist/storage/stores/types.cjs +16 -0
  367. package/dist/storage/stores/types.d.ts +36 -0
  368. package/dist/storage/stores/types.d.ts.map +1 -0
  369. package/dist/storage/stores/types.js +0 -0
  370. package/dist/storage/tool-executions/types.cjs +127 -0
  371. package/dist/storage/tool-executions/types.d.ts +193 -0
  372. package/dist/storage/tool-executions/types.d.ts.map +1 -0
  373. package/dist/storage/tool-executions/types.js +96 -0
  374. package/dist/storage/tool-preferences/types.cjs +16 -0
  375. package/dist/storage/tool-preferences/types.d.ts +29 -0
  376. package/dist/storage/tool-preferences/types.d.ts.map +1 -0
  377. package/dist/storage/tool-preferences/types.js +0 -0
  378. package/dist/storage/tool-state/types.cjs +16 -0
  379. package/dist/storage/tool-state/types.d.ts +20 -0
  380. package/dist/storage/tool-state/types.d.ts.map +1 -0
  381. package/dist/storage/tool-state/types.js +0 -0
  382. package/dist/storage/workspaces/types.cjs +16 -0
  383. package/dist/storage/workspaces/types.d.ts +19 -0
  384. package/dist/storage/workspaces/types.d.ts.map +1 -0
  385. package/dist/storage/workspaces/types.js +0 -0
  386. package/dist/systemPrompt/contributors.cjs +10 -14
  387. package/dist/systemPrompt/contributors.d.ts +3 -3
  388. package/dist/systemPrompt/contributors.d.ts.map +1 -1
  389. package/dist/systemPrompt/contributors.js +11 -15
  390. package/dist/systemPrompt/error-codes.js +1 -1
  391. package/dist/systemPrompt/errors.js +1 -1
  392. package/dist/systemPrompt/in-built-prompts.js +1 -1
  393. package/dist/systemPrompt/index.js +1 -1
  394. package/dist/systemPrompt/manager.js +1 -1
  395. package/dist/systemPrompt/registry.js +1 -1
  396. package/dist/systemPrompt/schemas.js +1 -1
  397. package/dist/telemetry/decorators.js +1 -1
  398. package/dist/telemetry/error-codes.js +1 -1
  399. package/dist/telemetry/errors.js +1 -1
  400. package/dist/telemetry/exporters.js +1 -1
  401. package/dist/telemetry/index.js +1 -1
  402. package/dist/telemetry/schemas.js +1 -1
  403. package/dist/telemetry/telemetry.js +1 -1
  404. package/dist/telemetry/utils.js +1 -1
  405. package/dist/test-utils/in-memory-storage.cjs +9 -17
  406. package/dist/test-utils/in-memory-storage.js +9 -16
  407. package/dist/test-utils/session-state-stores.cjs +21 -24
  408. package/dist/test-utils/session-state-stores.js +22 -24
  409. package/dist/tools/{confirmation → approval}/allowed-tools-provider/factory.cjs +1 -1
  410. package/dist/tools/{confirmation → approval}/allowed-tools-provider/factory.d.ts +2 -2
  411. package/dist/tools/approval/allowed-tools-provider/factory.d.ts.map +1 -0
  412. package/dist/tools/{confirmation → approval}/allowed-tools-provider/factory.js +2 -2
  413. package/dist/tools/approval/allowed-tools-provider/in-memory.d.ts.map +1 -0
  414. package/dist/tools/{confirmation → approval}/allowed-tools-provider/in-memory.js +1 -1
  415. package/dist/tools/approval/allowed-tools-provider/storage.cjs +66 -0
  416. package/dist/tools/{confirmation → approval}/allowed-tools-provider/storage.d.ts +4 -10
  417. package/dist/tools/approval/allowed-tools-provider/storage.d.ts.map +1 -0
  418. package/dist/tools/approval/allowed-tools-provider/storage.js +43 -0
  419. package/dist/tools/approval/allowed-tools-provider/types.cjs +16 -0
  420. package/dist/tools/approval/allowed-tools-provider/types.d.ts.map +1 -0
  421. package/dist/tools/approval/allowed-tools-provider/types.js +0 -0
  422. package/dist/tools/approval/session-tool-policy.cjs +269 -0
  423. package/dist/tools/approval/session-tool-policy.d.ts +43 -0
  424. package/dist/tools/approval/session-tool-policy.d.ts.map +1 -0
  425. package/dist/tools/approval/session-tool-policy.js +245 -0
  426. package/dist/tools/define-tool.js +1 -1
  427. package/dist/tools/display-types.js +1 -1
  428. package/dist/tools/error-codes.cjs +3 -3
  429. package/dist/tools/error-codes.d.ts +4 -4
  430. package/dist/tools/error-codes.d.ts.map +1 -1
  431. package/dist/tools/error-codes.js +4 -4
  432. package/dist/tools/errors.cjs +12 -12
  433. package/dist/tools/errors.d.ts +6 -6
  434. package/dist/tools/errors.d.ts.map +1 -1
  435. package/dist/tools/errors.js +13 -13
  436. package/dist/tools/index.cjs +3 -0
  437. package/dist/tools/index.d.ts +3 -0
  438. package/dist/tools/index.d.ts.map +1 -1
  439. package/dist/tools/index.js +3 -1
  440. package/dist/tools/pattern-utils.js +1 -1
  441. package/dist/tools/presentation/tool-presentation.cjs +182 -0
  442. package/dist/tools/presentation/tool-presentation.d.ts +51 -0
  443. package/dist/tools/presentation/tool-presentation.d.ts.map +1 -0
  444. package/dist/tools/presentation/tool-presentation.js +159 -0
  445. package/dist/tools/presentation.js +1 -1
  446. package/dist/tools/schemas.cjs +5 -10
  447. package/dist/tools/schemas.d.ts +1 -4
  448. package/dist/tools/schemas.d.ts.map +1 -1
  449. package/dist/tools/schemas.js +6 -11
  450. package/dist/tools/session-tool-preferences-store.cjs +12 -28
  451. package/dist/tools/session-tool-preferences-store.d.ts +4 -7
  452. package/dist/tools/session-tool-preferences-store.d.ts.map +1 -1
  453. package/dist/tools/session-tool-preferences-store.js +12 -29
  454. package/dist/tools/tool-call-metadata.js +1 -1
  455. package/dist/tools/tool-manager.cjs +871 -834
  456. package/dist/tools/tool-manager.d.ts +94 -96
  457. package/dist/tools/tool-manager.d.ts.map +1 -1
  458. package/dist/tools/tool-manager.js +876 -833
  459. package/dist/tools/types.d.ts +10 -14
  460. package/dist/tools/types.d.ts.map +1 -1
  461. package/dist/utils/api-key-resolver.js +1 -1
  462. package/dist/utils/async-context.js +1 -1
  463. package/dist/utils/debug.js +1 -1
  464. package/dist/utils/defer.js +1 -1
  465. package/dist/utils/env.js +1 -1
  466. package/dist/utils/error-conversion.js +1 -1
  467. package/dist/utils/execution-context.js +1 -1
  468. package/dist/utils/fs-walk.js +1 -1
  469. package/dist/utils/path.js +1 -1
  470. package/dist/utils/redactor.js +1 -1
  471. package/dist/utils/result.js +1 -1
  472. package/dist/utils/safe-stringify.js +1 -1
  473. package/dist/utils/schema.js +1 -1
  474. package/dist/utils/service-initializer.cjs +37 -33
  475. package/dist/utils/service-initializer.d.ts +9 -5
  476. package/dist/utils/service-initializer.d.ts.map +1 -1
  477. package/dist/utils/service-initializer.js +38 -34
  478. package/dist/utils/zod-schema-converter.js +1 -1
  479. package/dist/workspace/error-codes.cjs +5 -1
  480. package/dist/workspace/error-codes.d.ts +4 -0
  481. package/dist/workspace/error-codes.d.ts.map +1 -1
  482. package/dist/workspace/error-codes.js +6 -2
  483. package/dist/workspace/errors.cjs +43 -0
  484. package/dist/workspace/errors.d.ts +9 -0
  485. package/dist/workspace/errors.d.ts.map +1 -1
  486. package/dist/workspace/errors.js +44 -1
  487. package/dist/workspace/index.d.ts +1 -1
  488. package/dist/workspace/index.d.ts.map +1 -1
  489. package/dist/workspace/index.js +1 -1
  490. package/dist/workspace/manager.cjs +21 -29
  491. package/dist/workspace/manager.d.ts +6 -6
  492. package/dist/workspace/manager.d.ts.map +1 -1
  493. package/dist/workspace/manager.js +22 -30
  494. package/dist/workspace/types.d.ts +47 -0
  495. package/dist/workspace/types.d.ts.map +1 -1
  496. package/package.json +114 -2
  497. package/dist/approval/session-approval-store.cjs +0 -91
  498. package/dist/approval/session-approval-store.d.ts +0 -37
  499. package/dist/approval/session-approval-store.d.ts.map +0 -1
  500. package/dist/approval/session-approval-store.js +0 -68
  501. package/dist/session/history/database.cjs +0 -232
  502. package/dist/session/history/database.d.ts +0 -41
  503. package/dist/session/history/database.d.ts.map +0 -1
  504. package/dist/session/history/database.js +0 -209
  505. package/dist/session/history/factory.d.ts +0 -11
  506. package/dist/session/history/factory.d.ts.map +0 -1
  507. package/dist/session/history/factory.js +0 -8
  508. package/dist/session/history/memory.d.ts +0 -22
  509. package/dist/session/history/memory.d.ts.map +0 -1
  510. package/dist/session/history/memory.js +0 -34
  511. package/dist/session/history/types.d.ts +0 -26
  512. package/dist/session/history/types.d.ts.map +0 -1
  513. package/dist/session/message-queue-store.cjs +0 -75
  514. package/dist/session/message-queue-store.d.ts +0 -16
  515. package/dist/session/message-queue-store.d.ts.map +0 -1
  516. package/dist/session/message-queue-store.js +0 -52
  517. package/dist/storage/storage-manager.cjs +0 -209
  518. package/dist/storage/storage-manager.d.ts +0 -77
  519. package/dist/storage/storage-manager.d.ts.map +0 -1
  520. package/dist/storage/storage-manager.js +0 -186
  521. package/dist/tools/confirmation/allowed-tools-provider/factory.d.ts.map +0 -1
  522. package/dist/tools/confirmation/allowed-tools-provider/in-memory.d.ts.map +0 -1
  523. package/dist/tools/confirmation/allowed-tools-provider/storage.cjs +0 -69
  524. package/dist/tools/confirmation/allowed-tools-provider/storage.d.ts.map +0 -1
  525. package/dist/tools/confirmation/allowed-tools-provider/storage.js +0 -46
  526. package/dist/tools/confirmation/allowed-tools-provider/types.d.ts.map +0 -1
  527. /package/dist/{session/history → skills}/types.cjs +0 -0
  528. /package/dist/{session/history → skills}/types.js +0 -0
  529. /package/dist/{tools/confirmation/allowed-tools-provider → storage/artifacts}/types.cjs +0 -0
  530. /package/dist/{tools/confirmation/allowed-tools-provider → storage/artifacts}/types.js +0 -0
  531. /package/dist/tools/{confirmation → approval}/allowed-tools-provider/in-memory.cjs +0 -0
  532. /package/dist/tools/{confirmation → approval}/allowed-tools-provider/in-memory.d.ts +0 -0
  533. /package/dist/tools/{confirmation → approval}/allowed-tools-provider/types.d.ts +0 -0
@@ -5,19 +5,19 @@ import type { Logger } from '../logger/v2/types.js';
5
5
  import type { SanitizedToolResult } from './types.js';
6
6
  import { DynamicContributorContext } from '../systemPrompt/types.js';
7
7
  import { SystemPromptManager } from '../systemPrompt/manager.js';
8
- import type { ConversationHistoryProvider } from '../session/history/types.js';
8
+ import type { ConversationStore } from '../storage/conversation/types.js';
9
9
  import { ValidatedLLMConfig } from '../llm/schemas.js';
10
10
  import type { ToolPresentationSnapshotV1 } from '../tools/types.js';
11
11
  import type { ToolCallMetadata } from '../tools/tool-call-metadata.js';
12
12
  /**
13
13
  * Manages conversation history and provides message formatting capabilities for the LLM context.
14
14
  * The ContextManager is responsible for:
15
- * - Validating and storing conversation messages via the history provider
15
+ * - Validating and storing conversation messages via the conversation store
16
16
  * - Managing the system prompt
17
17
  * - Formatting messages for specific LLM providers through an injected formatter
18
18
  * - Providing access to conversation history
19
19
  *
20
- * Note: All conversation history is stored and retrieved via the injected ConversationHistoryProvider.
20
+ * Note: All conversation history is stored and retrieved via the injected ConversationStore.
21
21
  * The ContextManager does not maintain an internal history cache.
22
22
  * Token counting is handled by the LLM API response, not local estimation.
23
23
  *
@@ -58,7 +58,7 @@ export declare class ContextManager<TMessage = unknown> {
58
58
  * Messages after this index are estimated with length/4 heuristic.
59
59
  */
60
60
  private lastCallMessageCount;
61
- private historyProvider;
61
+ private conversationStore;
62
62
  private readonly sessionId;
63
63
  /**
64
64
  * ResourceManager for resolving blob references in message content.
@@ -76,12 +76,12 @@ export declare class ContextManager<TMessage = unknown> {
76
76
  * @param formatter Formatter implementation for the target LLM provider
77
77
  * @param systemPromptManager SystemPromptManager instance for the conversation
78
78
  * @param maxInputTokens Maximum token limit for the conversation history.
79
- * @param historyProvider Session-scoped ConversationHistoryProvider instance for managing conversation history
79
+ * @param conversationStore Store for managing conversation history
80
80
  * @param sessionId Unique identifier for the conversation session (readonly, for debugging)
81
81
  * @param resourceManager ResourceManager for resolving blob references in messages
82
82
  * @param logger Logger instance for logging
83
83
  */
84
- constructor(llmConfig: ValidatedLLMConfig, formatter: VercelMessageFormatter, systemPromptManager: SystemPromptManager, maxInputTokens: number, historyProvider: ConversationHistoryProvider, sessionId: string, resourceManager: import('../resources/index.js').ResourceManager, logger: Logger);
84
+ constructor(llmConfig: ValidatedLLMConfig, formatter: VercelMessageFormatter, systemPromptManager: SystemPromptManager, maxInputTokens: number, conversationStore: ConversationStore, sessionId: string, resourceManager: import('../resources/index.js').ResourceManager, logger: Logger);
85
85
  /**
86
86
  * Get the ResourceManager instance
87
87
  */
@@ -275,7 +275,7 @@ export declare class ContextManager<TMessage = unknown> {
275
275
  * @param contributorContext The DynamicContributorContext for system prompt contributors and formatting
276
276
  * @param llmContext The llmContext for the formatter to decide which messages to include based on the model's capabilities
277
277
  * @param systemPrompt (Optional) Precomputed system prompt string. If provided, it will be used instead of recomputing the system prompt. Useful for avoiding duplicate computation when both the formatted messages and the raw system prompt are needed in the same request.
278
- * @param history (Optional) Pre-fetched and potentially compressed history. If not provided, will fetch from history provider.
278
+ * @param history (Optional) Pre-fetched and potentially compressed history. If not provided, will fetch from the conversation store.
279
279
  * @returns Formatted messages ready to send to the LLM provider API
280
280
  * @throws Error if formatting or compression fails critically
281
281
  */
@@ -1 +1 @@
1
- {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/context/manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE9E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAUpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAE/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAGvE;;;;;;;;;;;;;GAaG;AACH,qBAAa,cAAc,CAAC,QAAQ,GAA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AkE;YAClE,gBAAgB,CAAC,EAAE,MAAM,CAAC;YAC1B,iFAAiF;YACjF,mBAAmB,CAAC,EAAE,MAAM,CAAC;SAChC,CAAC;KACL,CAAC;IAiGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0CG;IACG,2BAA2B,CAC7B,YAAY,EAAE,MAAM,EACpB,eAAe,EAAE,SAAS,eAAe,EAAE,EAC3C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,GACrF,OAAO,CAAC,MAAM,CAAC;IA0BlB;;;;;;OAMG;IACG,wBAAwB,CAC1B,QAAQ,EAAE,yBAAyB,GACpC,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAKrC;;;OAGG;IACG,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ3C"}
@@ -1,4 +1,4 @@
1
- import "../chunk-PTJYTZNU.js";
1
+ import "../chunk-C6A6W6XS.js";
2
2
  import { randomUUID } from "crypto";
3
3
  import { isSystemMessage, isUserMessage, isAssistantMessage, isToolMessage } from "./types.js";
4
4
  import { DextoLogComponent } from "../logger/v2/types.js";
@@ -47,7 +47,7 @@ class ContextManager {
47
47
  * Messages after this index are estimated with length/4 heuristic.
48
48
  */
49
49
  lastCallMessageCount = null;
50
- historyProvider;
50
+ conversationStore;
51
51
  sessionId;
52
52
  /**
53
53
  * ResourceManager for resolving blob references in message content.
@@ -170,22 +170,22 @@ class ContextManager {
170
170
  * @param formatter Formatter implementation for the target LLM provider
171
171
  * @param systemPromptManager SystemPromptManager instance for the conversation
172
172
  * @param maxInputTokens Maximum token limit for the conversation history.
173
- * @param historyProvider Session-scoped ConversationHistoryProvider instance for managing conversation history
173
+ * @param conversationStore Store for managing conversation history
174
174
  * @param sessionId Unique identifier for the conversation session (readonly, for debugging)
175
175
  * @param resourceManager ResourceManager for resolving blob references in messages
176
176
  * @param logger Logger instance for logging
177
177
  */
178
- constructor(llmConfig, formatter, systemPromptManager, maxInputTokens, historyProvider, sessionId, resourceManager, logger) {
178
+ constructor(llmConfig, formatter, systemPromptManager, maxInputTokens, conversationStore, sessionId, resourceManager, logger) {
179
179
  this.llmConfig = llmConfig;
180
180
  this.formatter = formatter;
181
181
  this.systemPromptManager = systemPromptManager;
182
182
  this.maxInputTokens = maxInputTokens;
183
- this.historyProvider = historyProvider;
183
+ this.conversationStore = conversationStore;
184
184
  this.sessionId = sessionId;
185
185
  this.resourceManager = resourceManager;
186
186
  this.logger = logger.createChild(DextoLogComponent.CONTEXT);
187
187
  this.logger.debug(
188
- `ContextManager: Initialized for session ${sessionId} - history will be managed by ${historyProvider.constructor.name}`
188
+ `ContextManager: Initialized for session ${sessionId} - history will be managed by ${conversationStore.constructor.name}`
189
189
  );
190
190
  }
191
191
  /**
@@ -199,7 +199,7 @@ class ContextManager {
199
199
  * Returns either the original data or a blob reference (@blob:id).
200
200
  */
201
201
  async processUserInput(data, metadata) {
202
- const blobService = this.resourceManager.getBlobStore();
202
+ const artifactStore = this.resourceManager.getArtifactStore();
203
203
  let shouldStoreAsBlob = false;
204
204
  let estimatedSize = 0;
205
205
  if (typeof data === "string") {
@@ -226,20 +226,25 @@ class ContextManager {
226
226
  if (shouldStoreAsBlob) {
227
227
  try {
228
228
  const blobInput = typeof data === "string" && !data.startsWith("data:") && !isLikelyBase64String(data) && !isLikelyBinary ? Buffer.from(data, "utf-8") : data;
229
- const blobRef = await blobService.store(blobInput, {
230
- mimeType: metadata.mimeType,
231
- originalName: metadata.originalName,
232
- source: metadata.source || "user"
229
+ const artifactRef = await artifactStore.store({
230
+ data: blobInput,
231
+ metadata: {
232
+ mimeType: metadata.mimeType,
233
+ ...metadata.originalName !== void 0 && {
234
+ originalName: metadata.originalName
235
+ },
236
+ source: metadata.source || "user"
237
+ }
233
238
  });
234
239
  this.logger.info(
235
- `Stored user input as blob: ${blobRef.uri} (${estimatedSize} bytes, ${metadata.mimeType})`
240
+ `Stored user input as artifact: ${artifactRef.uri} (${estimatedSize} bytes, ${metadata.mimeType})`
236
241
  );
237
242
  this.resourceManager.emitCacheInvalidated({
238
- resourceUri: blobRef.uri,
243
+ resourceUri: artifactRef.uri,
239
244
  serverName: "internal",
240
245
  action: "blob_stored"
241
246
  });
242
- return `@${blobRef.uri}`;
247
+ return `@${artifactRef.uri}`;
243
248
  } catch (error) {
244
249
  this.logger.warn(`Failed to store user input as blob: ${String(error)}`);
245
250
  return data;
@@ -295,7 +300,7 @@ class ContextManager {
295
300
  * This marks the boundary for "new messages" calculation.
296
301
  */
297
302
  async recordLastCallMessageCount() {
298
- const history = await this.historyProvider.getHistory();
303
+ const history = await this.conversationStore.listMessages({ sessionId: this.sessionId });
299
304
  this.lastCallMessageCount = history.length;
300
305
  this.logger.debug(`Recorded lastCallMessageCount: ${this.lastCallMessageCount}`);
301
306
  }
@@ -330,7 +335,9 @@ class ContextManager {
330
335
  * @returns Prepared history and statistics about the transformations
331
336
  */
332
337
  async prepareHistory() {
333
- const fullHistory = await this.historyProvider.getHistory();
338
+ const fullHistory = await this.conversationStore.listMessages({
339
+ sessionId: this.sessionId
340
+ });
334
341
  const originalCount = fullHistory.length;
335
342
  let history = filterCompacted(fullHistory);
336
343
  const filteredCount = history.length;
@@ -382,7 +389,7 @@ ${prompt}`);
382
389
  * @returns Promise that resolves to a read-only copy of the conversation history
383
390
  */
384
391
  async getHistory() {
385
- const history = await this.historyProvider.getHistory();
392
+ const history = await this.conversationStore.listMessages({ sessionId: this.sessionId });
386
393
  return [...history];
387
394
  }
388
395
  /**
@@ -391,7 +398,7 @@ ${prompt}`);
391
398
  * This ensures all message updates are persisted before returning control to the caller.
392
399
  */
393
400
  async flush() {
394
- await this.historyProvider.flush();
401
+ await this.conversationStore.flush({ sessionId: this.sessionId });
395
402
  }
396
403
  /**
397
404
  * Clears the context window without deleting history.
@@ -422,7 +429,7 @@ ${prompt}`);
422
429
  * Used for streaming responses.
423
430
  */
424
431
  async appendAssistantText(messageId, text) {
425
- const history = await this.historyProvider.getHistory();
432
+ const history = await this.conversationStore.listMessages({ sessionId: this.sessionId });
426
433
  const messageIndex = history.findIndex((m) => m.id === messageId);
427
434
  if (messageIndex === -1) {
428
435
  throw ContextError.messageNotFound(messageId);
@@ -444,14 +451,14 @@ ${prompt}`);
444
451
  message.content.push({ type: "text", text });
445
452
  }
446
453
  }
447
- await this.historyProvider.updateMessage(message);
454
+ await this.conversationStore.updateMessage({ sessionId: this.sessionId, message });
448
455
  }
449
456
  /**
450
457
  * Adds a tool call to an existing assistant message.
451
458
  * Used for streaming responses.
452
459
  */
453
460
  async addToolCall(messageId, toolCall) {
454
- const history = await this.historyProvider.getHistory();
461
+ const history = await this.conversationStore.listMessages({ sessionId: this.sessionId });
455
462
  const messageIndex = history.findIndex((m) => m.id === messageId);
456
463
  if (messageIndex === -1) {
457
464
  throw ContextError.messageNotFound(messageId);
@@ -467,14 +474,14 @@ ${prompt}`);
467
474
  message.toolCalls = [];
468
475
  }
469
476
  message.toolCalls.push(toolCall);
470
- await this.historyProvider.updateMessage(message);
477
+ await this.conversationStore.updateMessage({ sessionId: this.sessionId, message });
471
478
  }
472
479
  /**
473
480
  * Updates an existing assistant message with new properties.
474
481
  * Used for finalizing streaming responses (e.g. adding token usage).
475
482
  */
476
483
  async updateAssistantMessage(messageId, updates) {
477
- const history = await this.historyProvider.getHistory();
484
+ const history = await this.conversationStore.listMessages({ sessionId: this.sessionId });
478
485
  const messageIndex = history.findIndex((m) => m.id === messageId);
479
486
  if (messageIndex === -1) {
480
487
  throw ContextError.messageNotFound(messageId);
@@ -487,7 +494,7 @@ ${prompt}`);
487
494
  throw ContextError.messageNotAssistant(messageId);
488
495
  }
489
496
  Object.assign(message, updates);
490
- await this.historyProvider.updateMessage(message);
497
+ await this.conversationStore.updateMessage({ sessionId: this.sessionId, message });
491
498
  }
492
499
  /**
493
500
  * Marks tool messages as compacted (pruned).
@@ -505,7 +512,7 @@ ${prompt}`);
505
512
  if (messageIds.length === 0) {
506
513
  return 0;
507
514
  }
508
- const history = await this.historyProvider.getHistory();
515
+ const history = await this.conversationStore.listMessages({ sessionId: this.sessionId });
509
516
  const timestamp = Date.now();
510
517
  let markedCount = 0;
511
518
  for (const messageId of messageIds) {
@@ -524,7 +531,7 @@ ${prompt}`);
524
531
  continue;
525
532
  }
526
533
  message.compactedAt = timestamp;
527
- await this.historyProvider.updateMessage(message);
534
+ await this.conversationStore.updateMessage({ sessionId: this.sessionId, message });
528
535
  markedCount++;
529
536
  }
530
537
  if (markedCount > 0) {
@@ -586,10 +593,10 @@ ${prompt}`);
586
593
  message.timestamp = Date.now();
587
594
  }
588
595
  this.logger.debug(
589
- `ContextManager: Adding message to history provider: ${JSON.stringify(message, null, 2)}`
596
+ `ContextManager: Adding message to conversation store: ${JSON.stringify(message, null, 2)}`
590
597
  );
591
- await this.historyProvider.saveMessage(message);
592
- const history = await this.historyProvider.getHistory();
598
+ await this.conversationStore.saveMessage({ sessionId: this.sessionId, message });
599
+ const history = await this.conversationStore.listMessages({ sessionId: this.sessionId });
593
600
  this.logger.debug(`ContextManager: History now contains ${history.length} messages`);
594
601
  }
595
602
  /**
@@ -719,12 +726,12 @@ ${prompt}`);
719
726
  * @param contributorContext The DynamicContributorContext for system prompt contributors and formatting
720
727
  * @param llmContext The llmContext for the formatter to decide which messages to include based on the model's capabilities
721
728
  * @param systemPrompt (Optional) Precomputed system prompt string. If provided, it will be used instead of recomputing the system prompt. Useful for avoiding duplicate computation when both the formatted messages and the raw system prompt are needed in the same request.
722
- * @param history (Optional) Pre-fetched and potentially compressed history. If not provided, will fetch from history provider.
729
+ * @param history (Optional) Pre-fetched and potentially compressed history. If not provided, will fetch from the conversation store.
723
730
  * @returns Formatted messages ready to send to the LLM provider API
724
731
  * @throws Error if formatting or compression fails critically
725
732
  */
726
733
  async getFormattedMessages(contributorContext, llmContext, systemPrompt, history) {
727
- let messageHistory = history ?? await this.historyProvider.getHistory();
734
+ let messageHistory = history ?? await this.conversationStore.listMessages({ sessionId: this.sessionId });
728
735
  let allowedMediaTypes = this.llmConfig.allowedMediaTypes;
729
736
  if (!allowedMediaTypes) {
730
737
  try {
@@ -843,7 +850,9 @@ ${prompt}`);
843
850
  const lastInput = this.lastActualInputTokens;
844
851
  const lastOutput = this.lastActualOutputTokens;
845
852
  const lastMsgCount = this.lastCallMessageCount;
846
- const currentHistory = await this.historyProvider.getHistory();
853
+ const currentHistory = await this.conversationStore.listMessages({
854
+ sessionId: this.sessionId
855
+ });
847
856
  const pureEstimate = estimateContextTokens(systemPrompt, preparedHistory, tools);
848
857
  let total;
849
858
  let calculationBasis;
@@ -943,7 +952,9 @@ ${prompt}`);
943
952
  const lastInput = this.lastActualInputTokens;
944
953
  const lastOutput = this.lastActualOutputTokens;
945
954
  const lastMsgCount = this.lastCallMessageCount;
946
- const currentHistory = await this.historyProvider.getHistory();
955
+ const currentHistory = await this.conversationStore.listMessages({
956
+ sessionId: this.sessionId
957
+ });
947
958
  if (lastInput !== null && lastOutput !== null && lastMsgCount !== null) {
948
959
  const newMessages = currentHistory.slice(lastMsgCount);
949
960
  const newMessagesEstimate = estimateMessagesTokens(newMessages);
@@ -972,7 +983,7 @@ ${prompt}`);
972
983
  * Does not reset the system prompt
973
984
  */
974
985
  async resetConversation() {
975
- await this.historyProvider.clearHistory();
986
+ await this.conversationStore.clearMessages({ sessionId: this.sessionId });
976
987
  this.resetActualTokenTracking();
977
988
  this.logger.debug(
978
989
  `ContextManager: Conversation history cleared for session ${this.sessionId}`
@@ -1,4 +1,4 @@
1
- import "../chunk-PTJYTZNU.js";
1
+ import "../chunk-C6A6W6XS.js";
2
2
  function getFileMediaKind(mimeType) {
3
3
  if (mimeType?.startsWith("audio/")) return "audio";
4
4
  if (mimeType?.startsWith("video/")) return "video";
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var schemas_exports = {};
20
+ __export(schemas_exports, {
21
+ ContentPartSchema: () => ContentPartSchema,
22
+ InternalMessageSchema: () => InternalMessageSchema
23
+ });
24
+ module.exports = __toCommonJS(schemas_exports);
25
+ var import_zod = require("zod");
26
+ function isRecord(value) {
27
+ return typeof value === "object" && value !== null && !Array.isArray(value);
28
+ }
29
+ function isContentPart(value) {
30
+ if (!isRecord(value) || typeof value.type !== "string") {
31
+ return false;
32
+ }
33
+ switch (value.type) {
34
+ case "text":
35
+ return typeof value.text === "string";
36
+ case "image":
37
+ return "image" in value;
38
+ case "file":
39
+ return "data" in value && typeof value.mimeType === "string";
40
+ case "resource":
41
+ return typeof value.uri === "string" && typeof value.name === "string" && typeof value.mimeType === "string" && ["text", "image", "audio", "video", "binary"].includes(String(value.kind));
42
+ case "ui-resource":
43
+ return typeof value.uri === "string" && typeof value.mimeType === "string";
44
+ default:
45
+ return false;
46
+ }
47
+ }
48
+ function isContentParts(value) {
49
+ return Array.isArray(value) && value.every(isContentPart);
50
+ }
51
+ const ContentPartSchema = import_zod.z.custom(isContentPart, {
52
+ message: "Expected a Dexto content part."
53
+ });
54
+ const InternalMessageSchema = import_zod.z.custom(
55
+ (value) => {
56
+ if (!isRecord(value)) {
57
+ return false;
58
+ }
59
+ switch (value.role) {
60
+ case "system":
61
+ case "user":
62
+ return isContentParts(value.content);
63
+ case "assistant":
64
+ return value.content === null || isContentParts(value.content);
65
+ case "tool":
66
+ return isContentParts(value.content) && typeof value.toolCallId === "string" && typeof value.name === "string";
67
+ default:
68
+ return false;
69
+ }
70
+ },
71
+ { message: "Expected a Dexto internal message." }
72
+ );
73
+ // Annotate the CommonJS export names for ESM import in node:
74
+ 0 && (module.exports = {
75
+ ContentPartSchema,
76
+ InternalMessageSchema
77
+ });
@@ -0,0 +1,5 @@
1
+ import { z } from 'zod';
2
+ import type { ContentPart, InternalMessage } from './types.js';
3
+ export declare const ContentPartSchema: z.ZodType<ContentPart>;
4
+ export declare const InternalMessageSchema: z.ZodType<InternalMessage>;
5
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/context/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAoC/D,eAAO,MAAM,iBAAiB,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,CAEnD,CAAC;AAEH,eAAO,MAAM,qBAAqB,EAAE,CAAC,CAAC,OAAO,CAAC,eAAe,CAuB5D,CAAC"}
@@ -0,0 +1,53 @@
1
+ import "../chunk-C6A6W6XS.js";
2
+ import { z } from "zod";
3
+ function isRecord(value) {
4
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5
+ }
6
+ function isContentPart(value) {
7
+ if (!isRecord(value) || typeof value.type !== "string") {
8
+ return false;
9
+ }
10
+ switch (value.type) {
11
+ case "text":
12
+ return typeof value.text === "string";
13
+ case "image":
14
+ return "image" in value;
15
+ case "file":
16
+ return "data" in value && typeof value.mimeType === "string";
17
+ case "resource":
18
+ return typeof value.uri === "string" && typeof value.name === "string" && typeof value.mimeType === "string" && ["text", "image", "audio", "video", "binary"].includes(String(value.kind));
19
+ case "ui-resource":
20
+ return typeof value.uri === "string" && typeof value.mimeType === "string";
21
+ default:
22
+ return false;
23
+ }
24
+ }
25
+ function isContentParts(value) {
26
+ return Array.isArray(value) && value.every(isContentPart);
27
+ }
28
+ const ContentPartSchema = z.custom(isContentPart, {
29
+ message: "Expected a Dexto content part."
30
+ });
31
+ const InternalMessageSchema = z.custom(
32
+ (value) => {
33
+ if (!isRecord(value)) {
34
+ return false;
35
+ }
36
+ switch (value.role) {
37
+ case "system":
38
+ case "user":
39
+ return isContentParts(value.content);
40
+ case "assistant":
41
+ return value.content === null || isContentParts(value.content);
42
+ case "tool":
43
+ return isContentParts(value.content) && typeof value.toolCallId === "string" && typeof value.name === "string";
44
+ default:
45
+ return false;
46
+ }
47
+ },
48
+ { message: "Expected a Dexto internal message." }
49
+ );
50
+ export {
51
+ ContentPartSchema,
52
+ InternalMessageSchema
53
+ };
@@ -1,4 +1,4 @@
1
- import "../chunk-PTJYTZNU.js";
1
+ import "../chunk-C6A6W6XS.js";
2
2
  function isTextPart(part) {
3
3
  return part.type === "text";
4
4
  }