@linnlabs/linnkit 0.32.0 → 0.32.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 (468) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/context-manager/features/context-compaction/definitions/contextCheckpointFormat.d.cts +3 -0
  3. package/dist/context-manager/features/context-compaction/definitions/contextCheckpointFormat.d.ts +3 -0
  4. package/dist/context-manager/features/context-compaction/definitions/historySummaryDraft.d.cts +22 -0
  5. package/dist/context-manager/features/context-compaction/definitions/historySummaryDraft.d.ts +22 -0
  6. package/dist/context-manager/profiles/agent/config.d.cts +33 -0
  7. package/dist/context-manager/profiles/agent/config.d.ts +33 -0
  8. package/dist/context-manager/profiles/agent/context/AgentContextManager.d.cts +132 -0
  9. package/dist/context-manager/profiles/agent/context/AgentContextManager.d.ts +132 -0
  10. package/dist/context-manager/profiles/agent/context/ConversationSession.d.cts +131 -0
  11. package/dist/context-manager/profiles/agent/context/ConversationSession.d.ts +131 -0
  12. package/dist/context-manager/profiles/agent/context/config.d.cts +191 -0
  13. package/dist/context-manager/profiles/agent/context/config.d.ts +191 -0
  14. package/dist/context-manager/profiles/agent/context/index.d.cts +8 -0
  15. package/dist/context-manager/profiles/agent/context/index.d.ts +8 -0
  16. package/dist/context-manager/profiles/agent/context/providers/AgentCoreContextProvider.d.cts +52 -0
  17. package/dist/context-manager/profiles/agent/context/providers/AgentCoreContextProvider.d.ts +52 -0
  18. package/dist/context-manager/profiles/agent/context/providers/AgentWorkingMemoryProvider.d.cts +50 -0
  19. package/dist/context-manager/profiles/agent/context/providers/AgentWorkingMemoryProvider.d.ts +50 -0
  20. package/dist/context-manager/profiles/agent/context/providers/base.d.cts +11 -0
  21. package/dist/context-manager/profiles/agent/context/providers/base.d.ts +11 -0
  22. package/dist/context-manager/profiles/agent/context/providers/index.d.cts +12 -0
  23. package/dist/context-manager/profiles/agent/context/providers/index.d.ts +12 -0
  24. package/dist/context-manager/profiles/agent/contracts.d.cts +27 -0
  25. package/dist/context-manager/profiles/agent/contracts.d.ts +27 -0
  26. package/dist/context-manager/profiles/agent/orchestration/AgentMessageOrchestrator.d.cts +140 -0
  27. package/dist/context-manager/profiles/agent/orchestration/AgentMessageOrchestrator.d.ts +140 -0
  28. package/dist/context-manager/profiles/agent/orchestration/index.d.cts +1 -0
  29. package/dist/context-manager/profiles/agent/orchestration/index.d.ts +1 -0
  30. package/dist/context-manager/profiles/agent/preprocessors/base.d.cts +17 -0
  31. package/dist/context-manager/profiles/agent/preprocessors/base.d.ts +17 -0
  32. package/dist/context-manager/profiles/agent/preprocessors/index.d.cts +117 -0
  33. package/dist/context-manager/profiles/agent/preprocessors/index.d.ts +117 -0
  34. package/dist/context-manager/profiles/agent/preprocessors/toolHistoryCompressor.d.cts +47 -0
  35. package/dist/context-manager/profiles/agent/preprocessors/toolHistoryCompressor.d.ts +47 -0
  36. package/dist/context-manager/profiles/agent/preprocessors/toolReplayProtocolGuard.d.cts +27 -0
  37. package/dist/context-manager/profiles/agent/preprocessors/toolReplayProtocolGuard.d.ts +27 -0
  38. package/dist/context-manager/profiles/agent/tasks/BaseAgentTask.d.cts +43 -0
  39. package/dist/context-manager/profiles/agent/tasks/BaseAgentTask.d.ts +43 -0
  40. package/dist/context-manager/profiles/agent/tasks/base.d.cts +18 -0
  41. package/dist/context-manager/profiles/agent/tasks/base.d.ts +18 -0
  42. package/dist/context-manager/profiles/agent/tasks/index.d.cts +2 -0
  43. package/dist/context-manager/profiles/agent/tasks/index.d.ts +2 -0
  44. package/dist/context-manager/profiles/agent/tools/ToolManager.d.cts +27 -0
  45. package/dist/context-manager/profiles/agent/tools/ToolManager.d.ts +27 -0
  46. package/dist/context-manager/profiles/agent/tools/index.d.cts +1 -0
  47. package/dist/context-manager/profiles/agent/tools/index.d.ts +1 -0
  48. package/dist/context-manager/profiles/agent/utils/eventConverter.d.cts +15 -0
  49. package/dist/context-manager/profiles/agent/utils/eventConverter.d.ts +15 -0
  50. package/dist/context-manager/profiles/agent/utils/index.d.cts +2 -0
  51. package/dist/context-manager/profiles/agent/utils/index.d.ts +2 -0
  52. package/dist/context-manager/profiles/agent/utils/toolOutputSummarizer.d.cts +26 -0
  53. package/dist/context-manager/profiles/agent/utils/toolOutputSummarizer.d.ts +26 -0
  54. package/dist/context-manager/shared/MessageFormatter.d.cts +55 -0
  55. package/dist/context-manager/shared/MessageFormatter.d.ts +55 -0
  56. package/dist/context-manager/shared/agentSpecAdapter.d.cts +63 -0
  57. package/dist/context-manager/shared/agentSpecAdapter.d.ts +63 -0
  58. package/dist/context-manager/shared/context-manager-base.d.cts +102 -0
  59. package/dist/context-manager/shared/context-manager-base.d.ts +102 -0
  60. package/dist/context-manager/shared/context-pipeline.d.cts +42 -0
  61. package/dist/context-manager/shared/context-pipeline.d.ts +42 -0
  62. package/dist/context-manager/shared/context-trace.d.cts +102 -0
  63. package/dist/context-manager/shared/context-trace.d.ts +102 -0
  64. package/dist/context-manager/shared/contextPolicyMerge.d.cts +19 -0
  65. package/dist/context-manager/shared/contextPolicyMerge.d.ts +19 -0
  66. package/dist/context-manager/shared/contracts/chatLineMessage.d.cts +15 -0
  67. package/dist/context-manager/shared/contracts/chatLineMessage.d.ts +15 -0
  68. package/dist/context-manager/shared/fences/FenceRegistry.d.cts +24 -0
  69. package/dist/context-manager/shared/fences/FenceRegistry.d.ts +24 -0
  70. package/dist/context-manager/shared/image-input-estimation.d.cts +16 -0
  71. package/dist/context-manager/shared/image-input-estimation.d.ts +16 -0
  72. package/dist/context-manager/shared/policies/MustKeepPolicy.d.cts +19 -0
  73. package/dist/context-manager/shared/policies/MustKeepPolicy.d.ts +19 -0
  74. package/dist/context-manager/shared/preprocessors/base.d.cts +43 -0
  75. package/dist/context-manager/shared/preprocessors/base.d.ts +43 -0
  76. package/dist/context-manager/shared/preprocessors/currentTurnMessageAssembler.d.cts +26 -0
  77. package/dist/context-manager/shared/preprocessors/currentTurnMessageAssembler.d.ts +26 -0
  78. package/dist/context-manager/shared/preprocessors/fenceLifetimeManager.d.cts +18 -0
  79. package/dist/context-manager/shared/preprocessors/fenceLifetimeManager.d.ts +18 -0
  80. package/dist/context-manager/shared/preprocessors/historyPurification.d.cts +19 -0
  81. package/dist/context-manager/shared/preprocessors/historyPurification.d.ts +19 -0
  82. package/dist/context-manager/shared/preprocessors/priority.d.cts +17 -0
  83. package/dist/context-manager/shared/preprocessors/priority.d.ts +17 -0
  84. package/dist/context-manager/shared/providers/base.d.cts +106 -0
  85. package/dist/context-manager/shared/providers/base.d.ts +106 -0
  86. package/dist/context-manager/shared/providers/registry.d.cts +11 -0
  87. package/dist/context-manager/shared/providers/registry.d.ts +11 -0
  88. package/dist/context-manager/shared/token-calibration.d.cts +25 -0
  89. package/dist/context-manager/shared/token-calibration.d.ts +25 -0
  90. package/dist/context-manager.d.cts +34 -1559
  91. package/dist/context-manager.d.ts +34 -1559
  92. package/dist/contracts/agentSpec.d.cts +869 -0
  93. package/dist/contracts/agentSpec.d.ts +869 -0
  94. package/dist/{audit-XsNMTt0-.d.cts → contracts/audit.d.cts} +33 -33
  95. package/dist/{audit-XsNMTt0-.d.ts → contracts/audit.d.ts} +33 -33
  96. package/dist/contracts/constants.d.cts +3 -0
  97. package/dist/contracts/constants.d.ts +3 -0
  98. package/dist/contracts/contextCompaction.d.cts +43 -0
  99. package/dist/contracts/contextCompaction.d.ts +43 -0
  100. package/dist/contracts/contextPolicy.d.cts +1121 -0
  101. package/dist/contracts/contextPolicy.d.ts +1121 -0
  102. package/dist/{final-answer-oOQ_7nPt.d.ts → contracts/events.d.cts} +1219 -1222
  103. package/dist/{final-answer-B0_kx5_U.d.cts → contracts/events.d.ts} +1219 -1222
  104. package/dist/{execution-B7e01ZjW.d.cts → contracts/execution.d.cts} +21 -21
  105. package/dist/{execution-B7e01ZjW.d.ts → contracts/execution.d.ts} +21 -21
  106. package/dist/contracts/final-answer.d.cts +7 -0
  107. package/dist/contracts/final-answer.d.ts +7 -0
  108. package/dist/contracts/identity/definitions.d.cts +70 -0
  109. package/dist/contracts/identity/definitions.d.ts +70 -0
  110. package/dist/contracts/identity/generators.d.cts +33 -0
  111. package/dist/contracts/identity/generators.d.ts +33 -0
  112. package/dist/contracts/identity/invariants.d.cts +24 -0
  113. package/dist/contracts/identity/invariants.d.ts +24 -0
  114. package/dist/contracts/json.d.cts +12 -0
  115. package/dist/contracts/json.d.ts +12 -0
  116. package/dist/{provider-continuation-CTZdCB--.d.cts → contracts/messages.d.cts} +210 -957
  117. package/dist/{provider-continuation-CTZdCB--.d.ts → contracts/messages.d.ts} +210 -957
  118. package/dist/contracts/provider-continuation.d.cts +609 -0
  119. package/dist/contracts/provider-continuation.d.ts +609 -0
  120. package/dist/contracts/reasoning.d.cts +77 -0
  121. package/dist/contracts/reasoning.d.ts +77 -0
  122. package/dist/contracts/resource-ref.d.cts +73 -0
  123. package/dist/contracts/resource-ref.d.ts +73 -0
  124. package/dist/contracts/runtime-status.d.cts +8 -0
  125. package/dist/contracts/runtime-status.d.ts +8 -0
  126. package/dist/contracts/sse-framing.d.cts +28 -0
  127. package/dist/contracts/sse-framing.d.ts +28 -0
  128. package/dist/{index-Cp1_oUj0.d.ts → contracts/sse.d.cts} +1218 -1574
  129. package/dist/{index-JYf6n2Ik.d.cts → contracts/sse.d.ts} +1218 -1574
  130. package/dist/contracts/sub-run-trace-payload.d.cts +187 -0
  131. package/dist/contracts/sub-run-trace-payload.d.ts +187 -0
  132. package/dist/{summarization-CMMLhaCe.d.ts → contracts/summarization.d.cts} +2 -2
  133. package/dist/{summarization-kLeweZ5-.d.cts → contracts/summarization.d.ts} +2 -2
  134. package/dist/contracts/token-accounting.d.cts +1177 -0
  135. package/dist/contracts/token-accounting.d.ts +1177 -0
  136. package/dist/{token-calibration-GtFyMJtM.d.cts → contracts/token-calibration.d.cts} +1 -42
  137. package/dist/{token-calibration-GtFyMJtM.d.ts → contracts/token-calibration.d.ts} +1 -42
  138. package/dist/{reasoning-bffu9R2B.d.cts → contracts/token-usage.d.cts} +9 -84
  139. package/dist/{reasoning-bffu9R2B.d.ts → contracts/token-usage.d.ts} +9 -84
  140. package/dist/contracts.d.cts +24 -10
  141. package/dist/contracts.d.ts +24 -10
  142. package/dist/index.d.cts +14 -77
  143. package/dist/index.d.ts +14 -77
  144. package/dist/ports/agent-invocation.d.cts +42 -0
  145. package/dist/ports/agent-invocation.d.ts +42 -0
  146. package/dist/{audit-DnuOSwWE.d.ts → ports/audit.d.cts} +2 -2
  147. package/dist/{audit-C9LPbPib.d.cts → ports/audit.d.ts} +2 -2
  148. package/dist/ports/canonical-inference.d.cts +135 -0
  149. package/dist/ports/canonical-inference.d.ts +135 -0
  150. package/dist/ports/llm-call.d.cts +109 -0
  151. package/dist/ports/llm-call.d.ts +109 -0
  152. package/dist/ports/llm-input-materialization.d.cts +69 -0
  153. package/dist/ports/llm-input-materialization.d.ts +69 -0
  154. package/dist/{token-counter-BjiHQEJ-.d.ts → ports/token-counter.d.cts} +3 -3
  155. package/dist/{token-counter-DiGIoaq2.d.cts → ports/token-counter.d.ts} +3 -3
  156. package/dist/{tokenizer-yIFTTc-W.d.ts → ports/tokenizer.d.cts} +2 -2
  157. package/dist/{tokenizer-Dz5Y3KT0.d.cts → ports/tokenizer.d.ts} +2 -2
  158. package/dist/ports/tool-schema.d.cts +30 -0
  159. package/dist/ports/tool-schema.d.ts +30 -0
  160. package/dist/ports/usage-normalizer.d.cts +16 -0
  161. package/dist/ports/usage-normalizer.d.ts +16 -0
  162. package/dist/ports.d.cts +10 -9
  163. package/dist/ports.d.ts +10 -9
  164. package/dist/quickstart/defineAgent.d.cts +12 -0
  165. package/dist/quickstart/defineAgent.d.ts +12 -0
  166. package/dist/quickstart/defineConfig.d.cts +7 -0
  167. package/dist/quickstart/defineConfig.d.ts +7 -0
  168. package/dist/quickstart/runAgent.d.cts +12 -0
  169. package/dist/quickstart/runAgent.d.ts +12 -0
  170. package/dist/quickstart/toolRuntime.d.cts +14 -0
  171. package/dist/quickstart/toolRuntime.d.ts +14 -0
  172. package/dist/{runAgent-jxZ0uNto.d.ts → quickstart/types.d.cts} +10 -28
  173. package/dist/{runAgent-QiBiFXHR.d.cts → quickstart/types.d.ts} +10 -28
  174. package/dist/quickstart.d.cts +5 -23
  175. package/dist/quickstart.d.ts +5 -23
  176. package/dist/runtime-kernel/audit/compositeAudit.d.cts +23 -0
  177. package/dist/runtime-kernel/audit/compositeAudit.d.ts +23 -0
  178. package/dist/runtime-kernel/audit/consoleAudit.d.cts +10 -0
  179. package/dist/runtime-kernel/audit/consoleAudit.d.ts +10 -0
  180. package/dist/runtime-kernel/audit/emitAudit.d.cts +31 -0
  181. package/dist/runtime-kernel/audit/emitAudit.d.ts +31 -0
  182. package/dist/runtime-kernel/audit/eventStoreAudit.d.cts +27 -0
  183. package/dist/runtime-kernel/audit/eventStoreAudit.d.ts +27 -0
  184. package/dist/runtime-kernel/audit/fileAudit.d.cts +22 -0
  185. package/dist/runtime-kernel/audit/fileAudit.d.ts +22 -0
  186. package/dist/runtime-kernel/audit/index.d.cts +6 -0
  187. package/dist/runtime-kernel/audit/index.d.ts +6 -0
  188. package/dist/runtime-kernel/audit/noopAudit.d.cts +5 -0
  189. package/dist/runtime-kernel/audit/noopAudit.d.ts +5 -0
  190. package/dist/runtime-kernel/child-run-trace/childRunParentTraceProjection.d.cts +26 -0
  191. package/dist/runtime-kernel/child-run-trace/childRunParentTraceProjection.d.ts +26 -0
  192. package/dist/runtime-kernel/child-run-trace/index.d.cts +4 -0
  193. package/dist/runtime-kernel/child-run-trace/index.d.ts +4 -0
  194. package/dist/runtime-kernel/child-run-trace/projectChildRuntimeEventToSubRunTrace.d.cts +10 -0
  195. package/dist/runtime-kernel/child-run-trace/projectChildRuntimeEventToSubRunTrace.d.ts +10 -0
  196. package/dist/runtime-kernel/child-run-trace/runtimeEventSubRunTracePublisher.d.cts +47 -0
  197. package/dist/runtime-kernel/child-run-trace/runtimeEventSubRunTracePublisher.d.ts +47 -0
  198. package/dist/runtime-kernel/child-run-trace/subrunTrace.types.d.cts +81 -0
  199. package/dist/runtime-kernel/child-run-trace/subrunTrace.types.d.ts +81 -0
  200. package/dist/runtime-kernel/child-runs/childRunInvoker.d.cts +101 -0
  201. package/dist/runtime-kernel/child-runs/childRunInvoker.d.ts +101 -0
  202. package/dist/runtime-kernel/child-runs/historyPolicy.d.cts +9 -0
  203. package/dist/runtime-kernel/child-runs/historyPolicy.d.ts +9 -0
  204. package/dist/runtime-kernel/child-runs/index.d.cts +3 -0
  205. package/dist/runtime-kernel/child-runs/index.d.ts +3 -0
  206. package/dist/runtime-kernel/child-runs/types.d.cts +82 -0
  207. package/dist/runtime-kernel/child-runs/types.d.ts +82 -0
  208. package/dist/runtime-kernel/enrichment/index.d.cts +2 -0
  209. package/dist/runtime-kernel/enrichment/index.d.ts +2 -0
  210. package/dist/runtime-kernel/enrichment/registry.d.cts +25 -0
  211. package/dist/runtime-kernel/enrichment/registry.d.ts +25 -0
  212. package/dist/runtime-kernel/enrichment/types.d.cts +83 -0
  213. package/dist/runtime-kernel/enrichment/types.d.ts +83 -0
  214. package/dist/runtime-kernel/events/agent-to-runtime.d.cts +6 -0
  215. package/dist/runtime-kernel/events/agent-to-runtime.d.ts +6 -0
  216. package/dist/{agentEvents-yvamy9xt.d.cts → runtime-kernel/events/agentEvents.d.cts} +127 -126
  217. package/dist/{agentEvents-DhXdKeXD.d.ts → runtime-kernel/events/agentEvents.d.ts} +127 -126
  218. package/dist/runtime-kernel/events/eventGovernance.d.cts +47 -0
  219. package/dist/runtime-kernel/events/eventGovernance.d.ts +47 -0
  220. package/dist/runtime-kernel/events/eventMappers.d.cts +41 -0
  221. package/dist/runtime-kernel/events/eventMappers.d.ts +41 -0
  222. package/dist/runtime-kernel/events/finalAnswerAssembler.d.cts +27 -0
  223. package/dist/runtime-kernel/events/finalAnswerAssembler.d.ts +27 -0
  224. package/dist/runtime-kernel/events/finalAnswerCompletion.d.cts +6 -0
  225. package/dist/runtime-kernel/events/finalAnswerCompletion.d.ts +6 -0
  226. package/dist/runtime-kernel/events/provider-sidecar.d.cts +33 -0
  227. package/dist/runtime-kernel/events/provider-sidecar.d.ts +33 -0
  228. package/dist/runtime-kernel/events/runtime-to-ai-message.d.cts +14 -0
  229. package/dist/runtime-kernel/events/runtime-to-ai-message.d.ts +14 -0
  230. package/dist/runtime-kernel/events.d.cts +7 -5
  231. package/dist/runtime-kernel/events.d.ts +7 -5
  232. package/dist/runtime-kernel/execution/event-bus.d.cts +52 -0
  233. package/dist/runtime-kernel/execution/event-bus.d.ts +52 -0
  234. package/dist/runtime-kernel/execution/eventBusEventPersistence.d.cts +40 -0
  235. package/dist/runtime-kernel/execution/eventBusEventPersistence.d.ts +40 -0
  236. package/dist/runtime-kernel/execution/index.d.cts +5 -0
  237. package/dist/runtime-kernel/execution/index.d.ts +5 -0
  238. package/dist/runtime-kernel/execution/runtimeErrorEventFactory.d.cts +46 -0
  239. package/dist/runtime-kernel/execution/runtimeErrorEventFactory.d.ts +46 -0
  240. package/dist/runtime-kernel/execution/runtimeEventPublisher.d.cts +34 -0
  241. package/dist/runtime-kernel/execution/runtimeEventPublisher.d.ts +34 -0
  242. package/dist/runtime-kernel/execution/sequencer.d.cts +69 -0
  243. package/dist/runtime-kernel/execution/sequencer.d.ts +69 -0
  244. package/dist/runtime-kernel/graph-engine/checkpointer/base.d.cts +59 -0
  245. package/dist/runtime-kernel/graph-engine/checkpointer/base.d.ts +59 -0
  246. package/dist/runtime-kernel/graph-engine/checkpointer/memoryCheckpointer.d.cts +14 -0
  247. package/dist/runtime-kernel/graph-engine/checkpointer/memoryCheckpointer.d.ts +14 -0
  248. package/dist/runtime-kernel/graph-engine/definitions/primaryPromptCapacityError.d.cts +22 -0
  249. package/dist/runtime-kernel/graph-engine/definitions/primaryPromptCapacityError.d.ts +22 -0
  250. package/dist/runtime-kernel/graph-engine/engine.d.cts +64 -0
  251. package/dist/runtime-kernel/graph-engine/engine.d.ts +64 -0
  252. package/dist/runtime-kernel/graph-engine/event-store/base.d.cts +26 -0
  253. package/dist/runtime-kernel/graph-engine/event-store/base.d.ts +26 -0
  254. package/dist/runtime-kernel/graph-engine/event-store/memoryEventStore.d.cts +14 -0
  255. package/dist/runtime-kernel/graph-engine/event-store/memoryEventStore.d.ts +14 -0
  256. package/dist/runtime-kernel/graph-engine/executor.d.cts +59 -0
  257. package/dist/runtime-kernel/graph-engine/executor.d.ts +59 -0
  258. package/dist/runtime-kernel/graph-engine/executorContextBuilder.d.cts +104 -0
  259. package/dist/runtime-kernel/graph-engine/executorContextBuilder.d.ts +104 -0
  260. package/dist/runtime-kernel/graph-engine/functions/createHostToolCallBootstrap.d.cts +41 -0
  261. package/dist/runtime-kernel/graph-engine/functions/createHostToolCallBootstrap.d.ts +41 -0
  262. package/dist/runtime-kernel/graph-engine/functions/engineStateSnapshot.d.cts +23 -0
  263. package/dist/runtime-kernel/graph-engine/functions/engineStateSnapshot.d.ts +23 -0
  264. package/dist/runtime-kernel/graph-engine/functions/evaluatePrimaryPromptCapacity.d.cts +15 -0
  265. package/dist/runtime-kernel/graph-engine/functions/evaluatePrimaryPromptCapacity.d.ts +15 -0
  266. package/dist/runtime-kernel/graph-engine/functions/runtimeFailureFact.d.cts +7 -0
  267. package/dist/runtime-kernel/graph-engine/functions/runtimeFailureFact.d.ts +7 -0
  268. package/dist/runtime-kernel/graph-engine/index.d.cts +18 -0
  269. package/dist/runtime-kernel/graph-engine/index.d.ts +18 -0
  270. package/dist/runtime-kernel/graph-engine/nodes/llmNode.d.cts +26 -0
  271. package/dist/runtime-kernel/graph-engine/nodes/llmNode.d.ts +26 -0
  272. package/dist/runtime-kernel/graph-engine/nodes/llmNode.eventBridge.d.cts +6 -0
  273. package/dist/runtime-kernel/graph-engine/nodes/llmNode.eventBridge.d.ts +6 -0
  274. package/dist/runtime-kernel/graph-engine/nodes/toolNode.d.cts +44 -0
  275. package/dist/runtime-kernel/graph-engine/nodes/toolNode.d.ts +44 -0
  276. package/dist/runtime-kernel/graph-engine/nodes/userNode.d.cts +8 -0
  277. package/dist/runtime-kernel/graph-engine/nodes/userNode.d.ts +8 -0
  278. package/dist/runtime-kernel/graph-engine/nodes/waitUserNode.d.cts +15 -0
  279. package/dist/runtime-kernel/graph-engine/nodes/waitUserNode.d.ts +15 -0
  280. package/dist/runtime-kernel/graph-engine/tick-pipeline/types.d.cts +57 -0
  281. package/dist/runtime-kernel/graph-engine/tick-pipeline/types.d.ts +57 -0
  282. package/dist/runtime-kernel/graph-engine/types.d.cts +143 -0
  283. package/dist/runtime-kernel/graph-engine/types.d.ts +143 -0
  284. package/dist/runtime-kernel/llm/caller.d.cts +50 -0
  285. package/dist/runtime-kernel/llm/caller.d.ts +50 -0
  286. package/dist/runtime-kernel/llm/canonical-inference/definitions/canonicalInferenceStreamState.d.cts +28 -0
  287. package/dist/runtime-kernel/llm/canonical-inference/definitions/canonicalInferenceStreamState.d.ts +28 -0
  288. package/dist/runtime-kernel/llm/canonical-inference/functions/advanceCanonicalInferenceStreamState.d.cts +6 -0
  289. package/dist/runtime-kernel/llm/canonical-inference/functions/advanceCanonicalInferenceStreamState.d.ts +6 -0
  290. package/dist/runtime-kernel/llm/canonical-inference/orchestration/consumeCanonicalInferenceStream.d.cts +6 -0
  291. package/dist/runtime-kernel/llm/canonical-inference/orchestration/consumeCanonicalInferenceStream.d.ts +6 -0
  292. package/dist/runtime-kernel/llm/definitions/llmCallInvocationContext.d.cts +29 -0
  293. package/dist/runtime-kernel/llm/definitions/llmCallInvocationContext.d.ts +29 -0
  294. package/dist/runtime-kernel/llm/definitions/llmFallbackObserver.d.cts +26 -0
  295. package/dist/runtime-kernel/llm/definitions/llmFallbackObserver.d.ts +26 -0
  296. package/dist/runtime-kernel/llm/functions/evaluateFallbackPromptCapacity.d.cts +9 -0
  297. package/dist/runtime-kernel/llm/functions/evaluateFallbackPromptCapacity.d.ts +9 -0
  298. package/dist/runtime-kernel/llm/index.d.cts +22 -0
  299. package/dist/runtime-kernel/llm/index.d.ts +22 -0
  300. package/dist/runtime-kernel/llm/input-capabilities/definitions/modelInputCapability.d.cts +24 -0
  301. package/dist/runtime-kernel/llm/input-capabilities/definitions/modelInputCapability.d.ts +24 -0
  302. package/dist/runtime-kernel/llm/input-capabilities/definitions/modelInputCapabilityError.d.cts +31 -0
  303. package/dist/runtime-kernel/llm/input-capabilities/definitions/modelInputCapabilityError.d.ts +31 -0
  304. package/dist/runtime-kernel/llm/input-capabilities/functions/createModelInputCompatibilityError.d.cts +13 -0
  305. package/dist/runtime-kernel/llm/input-capabilities/functions/createModelInputCompatibilityError.d.ts +13 -0
  306. package/dist/runtime-kernel/llm/input-capabilities/functions/deriveModelInputRequirement.d.cts +6 -0
  307. package/dist/runtime-kernel/llm/input-capabilities/functions/deriveModelInputRequirement.d.ts +6 -0
  308. package/dist/runtime-kernel/llm/input-capabilities/functions/evaluateModelInputCompatibility.d.cts +7 -0
  309. package/dist/runtime-kernel/llm/input-capabilities/functions/evaluateModelInputCompatibility.d.ts +7 -0
  310. package/dist/runtime-kernel/llm/input-capabilities/orchestration/assertModelInputCompatibility.d.cts +10 -0
  311. package/dist/runtime-kernel/llm/input-capabilities/orchestration/assertModelInputCompatibility.d.ts +10 -0
  312. package/dist/runtime-kernel/llm/modelCatalog.d.cts +62 -0
  313. package/dist/runtime-kernel/llm/modelCatalog.d.ts +62 -0
  314. package/dist/runtime-kernel/llm/modelResolver.d.cts +40 -0
  315. package/dist/runtime-kernel/llm/modelResolver.d.ts +40 -0
  316. package/dist/runtime-kernel/llm/policies/defaultPolicyEngine.d.cts +15 -0
  317. package/dist/runtime-kernel/llm/policies/defaultPolicyEngine.d.ts +15 -0
  318. package/dist/runtime-kernel/llm/policies/policyEngine.d.cts +18 -0
  319. package/dist/runtime-kernel/llm/policies/policyEngine.d.ts +18 -0
  320. package/dist/runtime-kernel/llm/policies/types.d.cts +27 -0
  321. package/dist/runtime-kernel/llm/policies/types.d.ts +27 -0
  322. package/dist/runtime-kernel/llm/request-builder.d.cts +22 -0
  323. package/dist/runtime-kernel/llm/request-builder.d.ts +22 -0
  324. package/dist/runtime-kernel/llm/usage-telemetry.d.cts +17 -0
  325. package/dist/runtime-kernel/llm/usage-telemetry.d.ts +17 -0
  326. package/dist/runtime-kernel/run-context/index.d.cts +1 -0
  327. package/dist/runtime-kernel/run-context/index.d.ts +1 -0
  328. package/dist/runtime-kernel/run-context/types.d.cts +44 -0
  329. package/dist/runtime-kernel/run-context/types.d.ts +44 -0
  330. package/dist/runtime-kernel/run-supervisor/definitions/runSupervisorContracts.d.cts +131 -0
  331. package/dist/runtime-kernel/run-supervisor/definitions/runSupervisorContracts.d.ts +131 -0
  332. package/dist/runtime-kernel/run-supervisor/index.d.cts +6 -0
  333. package/dist/runtime-kernel/run-supervisor/index.d.ts +6 -0
  334. package/dist/runtime-kernel/run-supervisor/memoryRunRegistryStore.d.cts +15 -0
  335. package/dist/runtime-kernel/run-supervisor/memoryRunRegistryStore.d.ts +15 -0
  336. package/dist/runtime-kernel/run-supervisor/runErrors.d.cts +24 -0
  337. package/dist/runtime-kernel/run-supervisor/runErrors.d.ts +24 -0
  338. package/dist/runtime-kernel/run-supervisor/runHandle.d.cts +155 -0
  339. package/dist/runtime-kernel/run-supervisor/runHandle.d.ts +155 -0
  340. package/dist/runtime-kernel/run-supervisor/runRegistryStorePort.d.cts +47 -0
  341. package/dist/runtime-kernel/run-supervisor/runRegistryStorePort.d.ts +47 -0
  342. package/dist/runtime-kernel/run-supervisor/runSupervisor.d.cts +57 -0
  343. package/dist/runtime-kernel/run-supervisor/runSupervisor.d.ts +57 -0
  344. package/dist/runtime-kernel/system-reminder/apply.d.cts +38 -0
  345. package/dist/runtime-kernel/system-reminder/apply.d.ts +38 -0
  346. package/dist/runtime-kernel/system-reminder/helpers.d.cts +11 -0
  347. package/dist/runtime-kernel/system-reminder/helpers.d.ts +11 -0
  348. package/dist/runtime-kernel/system-reminder/index.d.cts +7 -0
  349. package/dist/runtime-kernel/system-reminder/index.d.ts +7 -0
  350. package/dist/runtime-kernel/system-reminder/registry.d.cts +17 -0
  351. package/dist/runtime-kernel/system-reminder/registry.d.ts +17 -0
  352. package/dist/runtime-kernel/system-reminder/rules.d.cts +20 -0
  353. package/dist/runtime-kernel/system-reminder/rules.d.ts +20 -0
  354. package/dist/runtime-kernel/system-reminder/templates.d.cts +10 -0
  355. package/dist/runtime-kernel/system-reminder/templates.d.ts +10 -0
  356. package/dist/runtime-kernel/system-reminder/triggers.d.cts +10 -0
  357. package/dist/runtime-kernel/system-reminder/triggers.d.ts +10 -0
  358. package/dist/runtime-kernel/system-reminder/types.d.cts +46 -0
  359. package/dist/runtime-kernel/system-reminder/types.d.ts +46 -0
  360. package/dist/runtime-kernel/telemetry/index.d.cts +3 -0
  361. package/dist/runtime-kernel/telemetry/index.d.ts +3 -0
  362. package/dist/runtime-kernel/telemetry/noopTelemetry.d.cts +5 -0
  363. package/dist/runtime-kernel/telemetry/noopTelemetry.d.ts +5 -0
  364. package/dist/runtime-kernel/telemetry/telemetryEvents.d.cts +5 -0
  365. package/dist/runtime-kernel/telemetry/telemetryEvents.d.ts +5 -0
  366. package/dist/runtime-kernel/telemetry/telemetryPort.d.cts +95 -0
  367. package/dist/runtime-kernel/telemetry/telemetryPort.d.ts +95 -0
  368. package/dist/runtime-kernel/testkit/defaultGraphExecutor.d.cts +23 -0
  369. package/dist/runtime-kernel/testkit/defaultGraphExecutor.d.ts +23 -0
  370. package/dist/runtime-kernel/testkit/graphLoopHarness.d.cts +49 -0
  371. package/dist/runtime-kernel/testkit/graphLoopHarness.d.ts +49 -0
  372. package/dist/runtime-kernel/token-accounting/functions.d.cts +27 -0
  373. package/dist/runtime-kernel/token-accounting/functions.d.ts +27 -0
  374. package/dist/runtime-kernel/token-accounting/index.d.cts +1 -0
  375. package/dist/runtime-kernel/token-accounting/index.d.ts +1 -0
  376. package/dist/runtime-kernel/tools/argNormalizer.d.cts +10 -0
  377. package/dist/runtime-kernel/tools/argNormalizer.d.ts +10 -0
  378. package/dist/runtime-kernel/tools/conversationView.d.cts +22 -0
  379. package/dist/runtime-kernel/tools/conversationView.d.ts +22 -0
  380. package/dist/runtime-kernel/tools/idempotency/toolIdempotency.d.cts +25 -0
  381. package/dist/runtime-kernel/tools/idempotency/toolIdempotency.d.ts +25 -0
  382. package/dist/runtime-kernel/tools/index.d.cts +15 -0
  383. package/dist/runtime-kernel/tools/index.d.ts +15 -0
  384. package/dist/runtime-kernel/tools/model-input/definitions/toolModelInput.d.cts +51 -0
  385. package/dist/runtime-kernel/tools/model-input/definitions/toolModelInput.d.ts +51 -0
  386. package/dist/runtime-kernel/tools/model-input/definitions/toolModelInputPolicy.d.cts +17 -0
  387. package/dist/runtime-kernel/tools/model-input/definitions/toolModelInputPolicy.d.ts +17 -0
  388. package/dist/runtime-kernel/tools/model-input/functions/parseToolModelInputDeclaration.d.cts +17 -0
  389. package/dist/runtime-kernel/tools/model-input/functions/parseToolModelInputDeclaration.d.ts +17 -0
  390. package/dist/runtime-kernel/tools/model-input/orchestration/resolveToolModelInput.d.cts +16 -0
  391. package/dist/runtime-kernel/tools/model-input/orchestration/resolveToolModelInput.d.ts +16 -0
  392. package/dist/runtime-kernel/tools/ports.d.cts +119 -0
  393. package/dist/runtime-kernel/tools/ports.d.ts +119 -0
  394. package/dist/runtime-kernel/tools/schema/functions/assertToolParameterSchema.d.cts +15 -0
  395. package/dist/runtime-kernel/tools/schema/functions/assertToolParameterSchema.d.ts +15 -0
  396. package/dist/runtime-kernel/tools/toolContextPatch.d.cts +14 -0
  397. package/dist/runtime-kernel/tools/toolContextPatch.d.ts +14 -0
  398. package/dist/runtime-kernel/tools/toolContextRuntime.d.cts +37 -0
  399. package/dist/runtime-kernel/tools/toolContextRuntime.d.ts +37 -0
  400. package/dist/runtime-kernel/tools/toolContracts.d.cts +109 -0
  401. package/dist/runtime-kernel/tools/toolContracts.d.ts +109 -0
  402. package/dist/runtime-kernel/tools/toolExecutionContext.d.cts +104 -0
  403. package/dist/runtime-kernel/tools/toolExecutionContext.d.ts +104 -0
  404. package/dist/runtime-kernel/tools/ui-types.d.cts +72 -0
  405. package/dist/runtime-kernel/tools/ui-types.d.ts +72 -0
  406. package/dist/runtime-kernel.d.cts +106 -20
  407. package/dist/runtime-kernel.d.ts +106 -20
  408. package/dist/shared/defaultTokenizerPort.d.cts +29 -0
  409. package/dist/shared/defaultTokenizerPort.d.ts +29 -0
  410. package/dist/shared/errorClassifier.d.cts +42 -0
  411. package/dist/shared/errorClassifier.d.ts +42 -0
  412. package/dist/shared/llmAuditProjection.d.cts +11 -0
  413. package/dist/shared/llmAuditProjection.d.ts +11 -0
  414. package/dist/shared/llmAuditRecorder.d.cts +44 -0
  415. package/dist/shared/llmAuditRecorder.d.ts +44 -0
  416. package/dist/shared/llmImageInputError.d.cts +34 -0
  417. package/dist/shared/llmImageInputError.d.ts +34 -0
  418. package/dist/shared/llmTelemetryContext.d.cts +52 -0
  419. package/dist/shared/llmTelemetryContext.d.ts +52 -0
  420. package/dist/shared/logger.d.cts +12 -0
  421. package/dist/shared/logger.d.ts +12 -0
  422. package/dist/{prompt-budget-yciFkC9U.d.cts → shared/prompt-budget.d.cts} +2 -1
  423. package/dist/{prompt-budget-yciFkC9U.d.ts → shared/prompt-budget.d.ts} +2 -1
  424. package/dist/testkit/agent-harness/assertions.d.cts +10 -0
  425. package/dist/testkit/agent-harness/assertions.d.ts +10 -0
  426. package/dist/testkit/agent-harness/scriptedInferenceHarness.d.cts +52 -0
  427. package/dist/testkit/agent-harness/scriptedInferenceHarness.d.ts +52 -0
  428. package/dist/testkit/context-harness/invariants/index.d.cts +7 -0
  429. package/dist/testkit/context-harness/invariants/index.d.ts +7 -0
  430. package/dist/testkit/context-harness/invariants/types.d.cts +32 -0
  431. package/dist/testkit/context-harness/invariants/types.d.ts +32 -0
  432. package/dist/testkit/context-harness/replayHarness.d.cts +18 -0
  433. package/dist/testkit/context-harness/replayHarness.d.ts +18 -0
  434. package/dist/testkit/mocks/tokenizerPort.d.cts +17 -0
  435. package/dist/testkit/mocks/tokenizerPort.d.ts +17 -0
  436. package/dist/testkit/run-harness/collectingAuditPort.d.cts +21 -0
  437. package/dist/testkit/run-harness/collectingAuditPort.d.ts +21 -0
  438. package/dist/testkit/run-harness/invariants/index.d.cts +7 -0
  439. package/dist/testkit/run-harness/invariants/index.d.ts +7 -0
  440. package/dist/testkit/run-harness/invariants/types.d.cts +48 -0
  441. package/dist/testkit/run-harness/invariants/types.d.ts +48 -0
  442. package/dist/testkit/run-harness/mockTelemetryPort.d.cts +35 -0
  443. package/dist/testkit/run-harness/mockTelemetryPort.d.ts +35 -0
  444. package/dist/testkit/run-harness/runSupervisorHarness.d.cts +60 -0
  445. package/dist/testkit/run-harness/runSupervisorHarness.d.ts +60 -0
  446. package/dist/testkit/tool-fixtures/toolContext.d.cts +19 -0
  447. package/dist/testkit/tool-fixtures/toolContext.d.ts +19 -0
  448. package/dist/testkit.d.cts +17 -277
  449. package/dist/testkit.d.ts +17 -277
  450. package/package.json +6 -4
  451. package/dist/base-DRRrRhxS.d.cts +0 -216
  452. package/dist/base-DVyQIl_d.d.ts +0 -216
  453. package/dist/defaultGraphExecutor-Chr16eYO.d.cts +0 -914
  454. package/dist/defaultGraphExecutor-hT7dchpC.d.ts +0 -914
  455. package/dist/index-1pE6gSpV.d.cts +0 -172
  456. package/dist/index-C2PSqU1I.d.cts +0 -1971
  457. package/dist/index-CZMXtw4h.d.ts +0 -1971
  458. package/dist/index-D_csW7Zl.d.ts +0 -172
  459. package/dist/index-DpSWZ1L6.d.ts +0 -67
  460. package/dist/index-oCM3XEu2.d.cts +0 -67
  461. package/dist/llm-input-materialization-Vce5Swvc.d.ts +0 -366
  462. package/dist/llm-input-materialization-r-V3n9U-.d.cts +0 -366
  463. package/dist/runHandle--l0kE205.d.cts +0 -490
  464. package/dist/runHandle-ouLd6Tgp.d.ts +0 -490
  465. package/dist/token-accounting-19cXG7hM.d.cts +0 -3342
  466. package/dist/token-accounting-CVW37Uri.d.ts +0 -3342
  467. package/dist/toolContracts--KrHHNCY.d.cts +0 -424
  468. package/dist/toolContracts-BQ4kIso_.d.ts +0 -424
@@ -1,1559 +1,34 @@
1
- import { A as AiMessage, R as RuntimeResourceRef, P as ProviderContinuation, a as AssistantReplayPart, b as AssistantMessage, T as ToolCallId } from './provider-continuation-CTZdCB--.cjs';
2
- import { A as AgentContextInjection, L as LlmImageInputPlacement, a as LlmImageInputEstimatorPort, I as ImageInputAdmissionEvidence } from './llm-input-materialization-r-V3n9U-.cjs';
3
- import { A as AgentSpecToolOutputPolicy, a as AgentSpecContextTracePolicy, b as AgentSpecSystemReminderPolicy, c as AgentSpec, d as AgentSpecContextPolicy, e as AgentSpecContextPolicyInput, f as AgentSpecTokenEstimationPolicy, C as ContextTokenComponent } from './token-accounting-19cXG7hM.cjs';
4
- import { I as IContextProvider$1, P as ProviderContext$1, C as ContextTraceCollector, M as MessageProcessingState, B as BaseContextProvider$1, a as ProviderResult, R as RemoteTokenCountTrace, b as ContextTrace, T as ToolReplayProtocolPolicy } from './base-DRRrRhxS.cjs';
5
- export { c as ContextProviderError, d as ContextProviderErrorCode, e as ContextProviderErrorOptions, f as ContextTraceEvent, g as ContextTraceMessageDecisionEvent, h as ContextTraceProviderEvent, i as TOOL_HISTORY_OVERFLOW_ERROR_CODE, j as TOOL_REPLAY_PROTOCOL_ERROR_CODE, k as isContextProviderError } from './base-DRRrRhxS.cjs';
6
- import { T as TokenUsageCalibrationTrace, a as TokenUsageCalibrationSample, C as ContextBuildTokenEstimate, b as ContextCompactionCandidate, R as ResolvedContextCompactionPolicy, c as ContextCompactionPlan } from './token-calibration-GtFyMJtM.cjs';
7
- import { T as TokenRoute, P as PromptUsageMeasurementPolicy, a as TokenCountSource, b as TokenCountConfidence } from './reasoning-bffu9R2B.cjs';
8
- import { T as TokenCounterPort } from './token-counter-DiGIoaq2.cjs';
9
- import { T as TokenizerPort } from './tokenizer-Dz5Y3KT0.cjs';
10
- import { H as HistorySummaryEvent, R as RuntimeEvent } from './final-answer-B0_kx5_U.cjs';
11
- import { T as ToolArgs } from './toolContracts--KrHHNCY.cjs';
12
- import { E as EffectivePromptBudget } from './prompt-budget-yciFkC9U.cjs';
13
- import 'zod';
14
-
15
- type FenceLlmRole = 'user' | 'system';
16
- type FencePlacement = 'after-system' | 'before-current-user' | 'after-current-user' | 'after-last-tool-result';
17
- type FenceLifetime = 'turn-only' | 'persisted';
18
- interface FenceDescriptor {
19
- kind: string;
20
- llmRole: FenceLlmRole;
21
- placement: FencePlacement;
22
- lifetime: FenceLifetime;
23
- mustKeep?: boolean;
24
- maxBudgetFraction?: number;
25
- formatter: (content: string, attrs: Record<string, unknown>) => string;
26
- }
27
- type FenceInjection = AgentContextInjection;
28
- interface FenceRegistry {
29
- register(descriptor: FenceDescriptor): void;
30
- get(kind: string): FenceDescriptor | undefined;
31
- list(): FenceDescriptor[];
32
- }
33
- declare function createFenceRegistry(descriptors?: FenceDescriptor[]): FenceRegistry;
34
-
35
- type MessageType = AiMessage['type'];
36
- type MessageRole = AiMessage['role'];
37
- interface ChatMessage {
38
- id?: string;
39
- timestamp?: number;
40
- role: MessageRole;
41
- content: string;
42
- type?: MessageType;
43
- name?: string;
44
- metadata?: Record<string, unknown>;
45
- }
46
-
47
- interface MessageFormatOptions {
48
- nativeTools?: boolean;
49
- fenceRegistry?: FenceRegistry;
50
- }
51
- interface MessageFormatterOptions {
52
- fenceRegistry?: FenceRegistry;
53
- }
54
- type NativeToolCallingMessage = {
55
- role: 'system';
56
- content: string;
57
- } | {
58
- role: 'user';
59
- content: string;
60
- attachments?: RuntimeResourceRef[];
61
- } | {
62
- role: 'assistant';
63
- content: string;
64
- provider_continuations?: ProviderContinuation[];
65
- assistant_replay_parts?: AssistantReplayPart[];
66
- } | {
67
- role: 'assistant';
68
- content: string | null;
69
- tool_calls: unknown[];
70
- provider_continuations?: ProviderContinuation[];
71
- assistant_replay_parts?: AssistantReplayPart[];
72
- } | {
73
- role: 'tool';
74
- tool_call_id: string;
75
- content: string;
76
- attachments?: RuntimeResourceRef[];
77
- };
78
- declare class MessageFormatter {
79
- private readonly fenceRegistry?;
80
- constructor(options?: MessageFormatterOptions);
81
- format(messages: AiMessage[], options: {
82
- nativeTools: true;
83
- }): NativeToolCallingMessage[];
84
- format(messages: AiMessage[], options?: {
85
- nativeTools?: false;
86
- }): ChatMessage[];
87
- private formatSingleMessage;
88
- }
89
- declare const messageFormatter: MessageFormatter;
90
- declare function createMessageFormatter(options?: MessageFormatterOptions): MessageFormatter;
91
- declare function formatAgentLlmMessages(messages: AiMessage[], options?: Pick<MessageFormatOptions, 'fenceRegistry'>): NativeToolCallingMessage[];
92
- type LlmMessage = ChatMessage | NativeToolCallingMessage;
93
-
94
- interface MustKeepTruncationRule {
95
- messageType?: AiMessage['type'] | string;
96
- metadataFragmentType?: string;
97
- fenceKind?: string;
98
- maxBudgetFraction: number;
99
- strategyName: string;
100
- }
101
- interface MustKeepPolicy {
102
- alwaysKeepTypes: Array<AiMessage['type'] | string>;
103
- alwaysKeepFenceKinds: string[];
104
- truncationRules: MustKeepTruncationRule[];
105
- }
106
- declare const DEFAULT_MUST_KEEP_POLICY: MustKeepPolicy;
107
- declare function findMatchingTruncationRule(message: AiMessage, policy: MustKeepPolicy): MustKeepTruncationRule | undefined;
108
-
109
- interface AgentContextBuilderConfigOverrides {
110
- DEFAULT_MAX_TOKENS?: number;
111
- RESERVED_FOR_RESPONSE?: number;
112
- WORKING_MEMORY_BUDGET_PERCENTAGE?: number;
113
- TOOL_PAIRING_SEARCH_RANGE?: number;
114
- MIN_TOOL_INTERACTIONS_TO_KEEP?: number;
115
- MAX_RECENT_TOOL_RUNS_TO_KEEP?: number;
116
- MAX_TOOL_INTERACTION_GROUPS_TO_KEEP?: number;
117
- AVG_CHARS_PER_TOKEN?: number;
118
- TOOL_CALL_OVERHEAD_TOKENS?: number;
119
- TOKEN_ENCODING_NAME?: string;
120
- }
121
- interface AgentSpecPreprocessorOptions {
122
- toolHistory?: {
123
- strategy?: 'per-pair' | 'per-run' | 'none';
124
- retentionMode?: 'drop' | 'compress';
125
- keepLatestToolPairs?: number;
126
- keepLatestRuns?: number;
127
- maxInteractionGroups?: number;
128
- overflowStrategy?: 'keep-latest' | 'fail-fast';
129
- };
130
- }
131
- interface AgentSpecProviderOptions {
132
- mustKeep?: MustKeepPolicy;
133
- contextTrace?: AgentSpecContextTracePolicy;
134
- }
135
- interface AgentSpecExecutionOptions {
136
- toolOutput?: AgentSpecToolOutputPolicy;
137
- }
138
- interface AgentSpecRuntimeOptions {
139
- contextBuilderConfig: AgentContextBuilderConfigOverrides;
140
- preprocessorOptions: AgentSpecPreprocessorOptions;
141
- providerOptions: AgentSpecProviderOptions;
142
- executionOptions: AgentSpecExecutionOptions;
143
- systemReminder?: AgentSpecSystemReminderPolicy;
144
- }
145
- /**
146
- * 把 AgentSpec 的上下文策略转换成 AgentContextManager 能识别的配置覆盖。
147
- * 注意:profileId 只用于宿主路由,这里不消费。
148
- */
149
- declare function agentSpecToContextBuilderConfig(spec: AgentSpec): AgentContextBuilderConfigOverrides;
150
- declare function contextPolicyToContextBuilderConfig(policy: AgentSpecContextPolicy): AgentContextBuilderConfigOverrides;
151
- /**
152
- * 把 contextPolicy.toolHistory 原样转成交给 agent preprocessor registry 的配置。
153
- */
154
- declare function contextPolicyToPreprocessorOptions(policy: AgentSpecContextPolicy | undefined): AgentSpecPreprocessorOptions;
155
- /**
156
- * 提供给后续 provider registry 重建链路使用。
157
- * F1.2 只做映射,不在这里创建 provider,避免 shared 层反向依赖 agent profile 实现。
158
- */
159
- declare function contextPolicyToProviderOptions(policy: AgentSpecContextPolicy | undefined): AgentSpecProviderOptions;
160
- declare function contextPolicyToMustKeepPolicy(policy: AgentSpecContextPolicy | undefined): MustKeepPolicy | undefined;
161
- declare function contextPolicyToSystemReminderOptions(policy: AgentSpecContextPolicy | undefined): AgentSpecSystemReminderPolicy | undefined;
162
- declare function contextPolicyToExecutionOptions(policy: AgentSpecContextPolicy | undefined): AgentSpecExecutionOptions;
163
- declare function agentSpecToRuntimeOptions(spec: AgentSpec): AgentSpecRuntimeOptions;
164
- declare function contextPolicyToRuntimeOptions(policy: AgentSpecContextPolicy): AgentSpecRuntimeOptions;
165
-
166
- declare class ContextProviderRegistry$1<TConfig = unknown> {
167
- private providers;
168
- register(provider: IContextProvider$1<TConfig>): void;
169
- getAllProviders(): IContextProvider$1<TConfig>[];
170
- getProvider(name: string): IContextProvider$1<TConfig> | undefined;
171
- clear(): void;
172
- }
173
-
174
- interface ContextPipelineStats<TPhase extends PropertyKey> {
175
- phaseTiming: Record<TPhase, number>;
176
- phaseTokenUsage: Record<TPhase, {
177
- used: number;
178
- percentage: number;
179
- }>;
180
- messageStats: {
181
- original: number;
182
- afterCoreContext: number;
183
- afterWorkingMemory: number;
184
- };
185
- }
186
- interface RunContextPipelineOptions<TConfig, TContext extends ProviderContext$1<TConfig>, TPhase extends PropertyKey, TStats extends ContextPipelineStats<TPhase>> {
187
- messages: AiMessage[];
188
- totalBudget: number;
189
- buildStats: TStats;
190
- providerRegistry: ContextProviderRegistry$1<TConfig>;
191
- providerContext: TContext;
192
- estimateTokens: (message: AiMessage) => {
193
- tokens: number;
194
- tokenCalibration?: TokenUsageCalibrationTrace;
195
- };
196
- getPhaseByProviderName: (providerName: string) => TPhase | null;
197
- debug?: (message: string, data?: Record<string, unknown>) => void;
198
- contextTrace?: ContextTraceCollector;
199
- }
200
- interface RunContextPipelineResult {
201
- finalMessages: AiMessage[];
202
- finalTokens: number;
203
- strategiesApplied: string[];
204
- states: MessageProcessingState[];
205
- }
206
- declare function runContextPipeline<TConfig, TContext extends ProviderContext$1<TConfig>, TPhase extends PropertyKey, TStats extends ContextPipelineStats<TPhase>>(options: RunContextPipelineOptions<TConfig, TContext, TPhase, TStats>): Promise<RunContextPipelineResult>;
207
-
208
- interface MergeContextPolicyParams {
209
- frameworkDefault?: AgentSpecContextPolicyInput;
210
- hostFallback?: AgentSpecContextPolicyInput;
211
- agentSpec?: AgentSpecContextPolicyInput;
212
- }
213
- /**
214
- * 合并三层 contextPolicy。
215
- *
216
- * 中文备注:
217
- * - 优先级:frameworkDefault < hostFallback < agentSpec;
218
- * - 按分组做字段级合并;
219
- * - 数组字段整体替换,不做 concat,避免 host/agent 的规则顺序变得不可预测。
220
- */
221
- declare function mergeContextPolicy(params: MergeContextPolicyParams): AgentSpecContextPolicy;
222
-
223
- interface ToolSummaryProvider {
224
- getTool(toolName: string): {
225
- getExecutionSummary?: (output: string) => string;
226
- } | undefined;
227
- }
228
- interface PreprocessorContext {
229
- debugMode?: boolean;
230
- model?: string;
231
- toolSummaryProvider?: ToolSummaryProvider;
232
- }
233
- interface PreprocessorResult {
234
- messages: AiMessage[];
235
- stats: {
236
- originalCount: number;
237
- processedCount: number;
238
- removedCount: number;
239
- modifiedCount: number;
240
- };
241
- appliedStrategies: string[];
242
- }
243
- interface IPreprocessor {
244
- readonly name: string;
245
- readonly description: string;
246
- readonly priority: number;
247
- process(messages: AiMessage[], context: PreprocessorContext): Promise<PreprocessorResult>;
248
- shouldSkip?(messages: AiMessage[], context: PreprocessorContext): boolean;
249
- }
250
- declare abstract class BasePreprocessor implements IPreprocessor {
251
- abstract readonly name: string;
252
- abstract readonly description: string;
253
- abstract readonly priority: number;
254
- private readonly logger;
255
- protected constructor(loggerName?: string);
256
- abstract process(messages: AiMessage[], context: PreprocessorContext): Promise<PreprocessorResult>;
257
- shouldSkip?(messages: AiMessage[], context: PreprocessorContext): boolean;
258
- protected createResult(originalMessages: AiMessage[], processedMessages: AiMessage[], appliedStrategies: string[], modifiedCount?: number): PreprocessorResult;
259
- protected debug(message: string, data?: Record<string, unknown>, context?: PreprocessorContext): void;
260
- }
261
-
262
- /**
263
- * Preprocessor 执行顺序。
264
- *
265
- * 中文说明:数字仍是 registry 的排序机制,但业务含义集中在这里命名,
266
- * 避免各 preprocessor 用 0/0.5/1/10/15 这种魔法数隐式耦合。
267
- */
268
- declare const PREPROCESSOR_PRIORITY: {
269
- readonly toolHistoryCompression: 0;
270
- readonly toolReplayProtocolGuard: 0.5;
271
- readonly historyPurification: 1;
272
- readonly currentTurnAssembly: 10;
273
- readonly fenceLifetimeCleanup: 15;
274
- };
275
- type PreprocessorPriorityName = keyof typeof PREPROCESSOR_PRIORITY;
276
-
277
- interface HistoryPurificationConfig {
278
- logPrefix?: string;
279
- }
280
- declare class HistoryPurificationPreprocessor extends BasePreprocessor {
281
- readonly name = "HistoryPurificationPreprocessor";
282
- readonly description = "\u57FA\u4E8E\u6458\u8981ID\u5217\u8868\u7684\u5386\u53F2\u51C0\u5316\u5904\u7406\u5668";
283
- readonly priority: 1;
284
- constructor(config?: HistoryPurificationConfig);
285
- process(messages: AiMessage[], context: PreprocessorContext): Promise<PreprocessorResult>;
286
- shouldSkip(messages: AiMessage[], context: PreprocessorContext): boolean;
287
- private findLatestSummary;
288
- private cleanHistoryWithSummaryReplacement;
289
- }
290
-
291
- interface FenceLifetimePreprocessorOptions {
292
- fenceRegistry: FenceRegistry;
293
- }
294
- declare class FenceLifetimePreprocessor extends BasePreprocessor {
295
- readonly name = "FenceLifetimePreprocessor";
296
- readonly description = "Removes expired turn-only context injection messages from history";
297
- readonly priority: 15;
298
- private readonly fenceRegistry;
299
- constructor(options: FenceLifetimePreprocessorOptions);
300
- process(messages: AiMessage[], context: PreprocessorContext): Promise<PreprocessorResult>;
301
- }
302
-
303
- interface CurrentTurnMessageAssemblerOptions {
304
- fenceRegistry: FenceRegistry;
305
- }
306
- /**
307
- * 组装当前轮 prompt block。
308
- *
309
- * 中文说明:
310
- * - formatter 只负责把单条消息转成 wire 形态,不负责猜测相邻消息是否应该合并;
311
- * - 当前轮 system-side fence 在这里合入 system_prompt;
312
- * - 当前轮 user-side fence 在这里合入同一条 user_input,未注入的 fence 不产生空标签。
313
- */
314
- declare class CurrentTurnMessageAssembler extends BasePreprocessor {
315
- readonly name = "CurrentTurnMessageAssembler";
316
- readonly description = "Assembles current-turn fences into system_prompt and user_input messages";
317
- readonly priority: 10;
318
- private readonly fenceRegistry;
319
- constructor(options: CurrentTurnMessageAssemblerOptions);
320
- process(messages: AiMessage[], _context: PreprocessorContext): Promise<PreprocessorResult>;
321
- }
322
-
323
- /**
324
- * @file src/agent/context-manager/profiles/agent/contracts.ts
325
- */
326
-
327
- /**
328
- * Minimal request contract used by package-neutral agent profile code.
329
- * Product-specific invoke requests can extend this shape.
330
- */
331
- interface AgentProfileRequest {
332
- query: string;
333
- /** 当前轮 user_input 的不可变事件身份;存在时禁止再用 query 猜测消息。 */
334
- currentUserEventId?: string;
335
- /** 当前轮尚未进入 history 时,构造 user_input 所需的 durable 资源引用。 */
336
- currentUserAttachments?: RuntimeResourceRef[];
337
- promptKey: string;
338
- model_id?: string;
339
- modelId?: string;
340
- availableTools?: string[];
341
- conversationHistory?: AiMessage[];
342
- fences?: FenceInjection[];
343
- }
344
-
345
- type contracts_AgentProfileRequest = AgentProfileRequest;
346
- declare namespace contracts {
347
- export type { contracts_AgentProfileRequest as AgentProfileRequest };
348
- }
349
-
350
- declare const AGENT_CONSTANTS: {
351
- readonly DEFAULT_MAX_STEPS: 80;
352
- readonly DEFAULT_TIMEOUT_MS: 300000;
353
- readonly DEFAULT_MAX_RETRIES: 3;
354
- readonly DEFAULT_RETRY_DELAY_MS: 1000;
355
- };
356
- interface AgentConfig {
357
- defaultModelId: string;
358
- maxSteps: number;
359
- defaultTools: string[];
360
- timeoutMs: number;
361
- debug: boolean;
362
- /**
363
- * @deprecated 不再参与上下文裁剪。
364
- * 中文备注:Agent 历史保留现在由 `contextPolicy.budget` 与 `contextPolicy.toolHistory`
365
- * 共同决定;保留这个字段只是为了兼容可能读取 `DEFAULT_AGENT_CONFIG` 的旧接入方。
366
- */
367
- maxHistoryLength: number;
368
- tokenBudget: {
369
- maxTokens: number;
370
- reservedForResponse: number;
371
- };
372
- contextProcessingTimeoutMs: number;
373
- retry: {
374
- maxRetries: number;
375
- enableEmptyResponseRetry: boolean;
376
- retryDelayMs: number;
377
- };
378
- }
379
- declare const DEFAULT_AGENT_CONFIG: AgentConfig;
380
-
381
- declare const config_AGENT_CONSTANTS: typeof AGENT_CONSTANTS;
382
- type config_AgentConfig = AgentConfig;
383
- declare const config_DEFAULT_AGENT_CONFIG: typeof DEFAULT_AGENT_CONFIG;
384
- declare namespace config {
385
- export { config_AGENT_CONSTANTS as AGENT_CONSTANTS, type config_AgentConfig as AgentConfig, config_DEFAULT_AGENT_CONFIG as DEFAULT_AGENT_CONFIG };
386
- }
387
-
388
- /**
389
- * @file src/agent/context/config.ts
390
- * @description Agent上下文构建策略配置 - Agent Provider pipeline 配置中心
391
- *
392
- * 🎯 目的: 为Agent的ContextManager提供所有策略参数的可配置中心
393
- * 📖 详情: 实现 Agent README 中描述的 Provider pipeline,专注于工具交互优化
394
- * 🔧 特色: P1-P3优先级填充策略,工具调用配对保留机制
395
- */
396
- /**
397
- * Agent上下文构建器核心配置
398
- *
399
- * 🎯 统一管理Agent专用的Token限制、触发条件和策略参数
400
- * 🔧 特别针对工具交互场景进行优化
401
- */
402
- declare const AGENT_CONTEXT_BUILDER_CONFIG: {
403
- /** 独立 Context Manager 没有模型 route 时使用的总窗口 fallback。 */
404
- DEFAULT_MAX_TOKENS: number;
405
- /** 独立 Context Manager 没有模型 route 时使用的最大输出 fallback。 */
406
- RESERVED_FOR_RESPONSE: number;
407
- /**
408
- * 工作记忆填充目标百分比
409
- * - **基准**: 可用上下文总预算
410
- * - **说明**: Agent 工作记忆层会尽力填充到此百分比
411
- */
412
- WORKING_MEMORY_BUDGET_PERCENTAGE: number;
413
- /**
414
- * P1优先级:工具交互配对保留
415
- * - 工具调用(tool_calls)和工具结果(tool)必须配对保留
416
- * - 最高优先级,确保工具交互完整性
417
- */
418
- P1_TOOL_INTERACTION_PRIORITY: number;
419
- /**
420
- * P2优先级:纯文本对话
421
- * - 不包含工具调用的user和assistant消息
422
- * - 按时间倒序填充
423
- */
424
- P2_TEXT_CONVERSATION_PRIORITY: number;
425
- /**
426
- * P3优先级:历史工具交互
427
- * - 较旧的工具调用记录
428
- * - 仍然需要配对保留
429
- */
430
- P3_HISTORICAL_TOOL_PRIORITY: number;
431
- /**
432
- * 工具调用配对搜索范围
433
- * - 在多少条消息范围内搜索工具调用的配对
434
- */
435
- TOOL_PAIRING_SEARCH_RANGE: number;
436
- /**
437
- * 工具交互保留的最小数量
438
- * - 即使预算不足,也要保留最近的几组工具交互
439
- */
440
- MIN_TOOL_INTERACTIONS_TO_KEEP: number;
441
- /**
442
- * P1:最近工具 turn 的原始 tool_calls/tool_output 保护窗口
443
- * - 目的:当前 turn + 最近历史 turn 内,工具 input 原样保留,避免构建期改写误导模型
444
- */
445
- MAX_RECENT_TOOL_RUNS_TO_KEEP: number;
446
- /**
447
- * P1+P3:工作记忆层最多保留的工具交互组总数(超过则直接丢弃)
448
- * - 目的:对 user 之前的“历史工具交互”做硬上限,避免工具历史过长污染上下文
449
- * - 注意:这里的“工具交互组”既包括原始 tool_calls/tool_output 配对,也包括被预处理压缩成
450
- * assistant 文本的“工具执行记录摘要”(metadata.isCompressedToolHistory === true)
451
- */
452
- MAX_TOOL_INTERACTION_GROUPS_TO_KEEP: number;
453
- /** 核心上下文保留层消息类型 - 第一阶段 */
454
- CORE_MESSAGE_TYPES: readonly ["system_prompt", "user_input"];
455
- /** P1优先级内容类型 - Agent专用 */
456
- P1_CONTENT_TYPES: readonly ["tool_calls", "tool_output"];
457
- /** P2优先级内容类型 - Agent专用 */
458
- P2_CONTENT_TYPES: readonly ["final_answer", "user_input"];
459
- /** P3优先级内容类型 - Agent专用 */
460
- P3_CONTENT_TYPES: readonly ["historical_tool_calls", "historical_tool_result"];
461
- /** 平均每个字符的token估算比例 */
462
- AVG_CHARS_PER_TOKEN: number;
463
- /** 工具调用的额外Token开销估算 */
464
- TOOL_CALL_OVERHEAD_TOKENS: number;
465
- /**
466
- * Token 精确估算用的“模型标识”(用于映射到 tiktoken encoding)
467
- *
468
- * 说明:
469
- * - 这里只用于默认 `TokenizerPort` 的 encoding 选择,不用于真实 LLM 调用;
470
- * - 为避免把某个具体业务模型写死在这里,统一使用 tiktoken 的默认 encoding:cl100k_base。
471
- */
472
- TOKEN_ENCODING_NAME: string;
473
- /** 是否启用详细的构建统计 */
474
- ENABLE_BUILD_STATS: boolean;
475
- /** 是否启用阶段执行时间统计 */
476
- ENABLE_TIMING_STATS: boolean;
477
- /** 上下文构建超时阈值 (毫秒) */
478
- PROCESSING_TIMEOUT_MS: number;
479
- /** 工具交互配对失败警告阈值 */
480
- TOOL_PAIRING_FAILURE_WARNING_THRESHOLD: number;
481
- };
482
- /**
483
- * Agent上下文构建策略配置的类型定义
484
- */
485
- interface AgentContextBuilderConfig {
486
- DEFAULT_MAX_TOKENS: number;
487
- RESERVED_FOR_RESPONSE: number;
488
- WORKING_MEMORY_BUDGET_PERCENTAGE: number;
489
- P1_TOOL_INTERACTION_PRIORITY: number;
490
- P2_TEXT_CONVERSATION_PRIORITY: number;
491
- P3_HISTORICAL_TOOL_PRIORITY: number;
492
- TOOL_PAIRING_SEARCH_RANGE: number;
493
- MIN_TOOL_INTERACTIONS_TO_KEEP: number;
494
- MAX_RECENT_TOOL_RUNS_TO_KEEP: number;
495
- MAX_TOOL_INTERACTION_GROUPS_TO_KEEP: number;
496
- CORE_MESSAGE_TYPES: readonly string[];
497
- P1_CONTENT_TYPES: readonly string[];
498
- P2_CONTENT_TYPES: readonly string[];
499
- P3_CONTENT_TYPES: readonly string[];
500
- AVG_CHARS_PER_TOKEN: number;
501
- TOOL_CALL_OVERHEAD_TOKENS: number;
502
- TOKEN_ENCODING_NAME: string;
503
- ENABLE_BUILD_STATS: boolean;
504
- ENABLE_TIMING_STATS: boolean;
505
- PROCESSING_TIMEOUT_MS: number;
506
- TOOL_PAIRING_FAILURE_WARNING_THRESHOLD: number;
507
- }
508
- /**
509
- * Agent专用阶段执行优先级枚举
510
- */
511
- declare enum AgentBuildPhase {
512
- /** 阶段1: 核心上下文保留层 */
513
- CORE_CONTEXT = 1,
514
- /** 阶段2: 工作记忆填充层 (P1-P4优先级) */
515
- WORKING_MEMORY = 2
516
- }
517
- /**
518
- * Agent专用消息优先级枚举
519
- */
520
- declare enum AgentMessagePriority {
521
- /** P1: 工具交互 - 最高优先级 */
522
- TOOL_INTERACTION = 1,
523
- /** P2: 纯文本对话 - 高优先级 */
524
- TEXT_CONVERSATION = 2,
525
- /** P3: 历史工具交互 - 中优先级 */
526
- HISTORICAL_TOOL = 3,
527
- /** P4: 循环填充 - 低优先级 */
528
- CIRCULAR_FILL = 4
529
- }
530
- /**
531
- * Agent上下文构建统计接口
532
- */
533
- interface AgentContextBuildStats {
534
- /** 构建开始时间 */
535
- startTime: number;
536
- /** 各阶段执行时间 */
537
- phaseTiming: Record<AgentBuildPhase, number>;
538
- /** 各阶段token使用情况 */
539
- phaseTokenUsage: Record<AgentBuildPhase, {
540
- used: number;
541
- percentage: number;
542
- }>;
543
- /** 消息数量统计 */
544
- messageStats: {
545
- original: number;
546
- afterCoreContext: number;
547
- afterWorkingMemory: number;
548
- };
549
- /** 优先级处理统计 */
550
- priorityStats: {
551
- p1ToolInteractions: number;
552
- p2TextConversations: number;
553
- p3HistoricalTools: number;
554
- p4CircularFill: number;
555
- };
556
- /** 工具交互统计 */
557
- toolStats: {
558
- totalToolCalls: number;
559
- pairedToolCalls: number;
560
- unpairedToolCalls: number;
561
- toolPairingSuccessRate: number;
562
- };
563
- /** 文档片段是否被截断 */
564
- documentTruncated: boolean;
565
- /** 总构建时间 */
566
- totalTime: number;
567
- }
568
- /**
569
- * 创建自定义Agent上下文构建配置的辅助函数
570
- */
571
- declare function createAgentContextBuilderConfig(overrides: Partial<AgentContextBuilderConfig>): AgentContextBuilderConfig;
572
- /**
573
- * 验证Agent配置有效性的辅助函数
574
- */
575
- declare function validateAgentConfig(config: AgentContextBuilderConfig): boolean;
576
-
577
- type ProviderContext = ProviderContext$1<AgentContextBuilderConfig>;
578
- type IContextProvider = IContextProvider$1<AgentContextBuilderConfig>;
579
- declare abstract class BaseContextProvider extends BaseContextProvider$1<AgentContextBuilderConfig> implements IContextProvider {
580
- }
581
-
582
- /**
583
- * @file src/agent/context/providers/AgentCoreContextProvider.ts
584
- * @description Agent专用核心上下文保留层Provider - 第一阶段上下文构建
585
- *
586
- * 🎯 职责: 识别并保留必须保留的核心消息(Agent专用逻辑)
587
- * 📖 规则: 系统提示词、工具描述、最新用户输入、注入的上下文始终无条件保留
588
- * ✨ Agent特性: 支持宿主通过 MustKeepPolicy 声明必保留 fence,确保工具调用上下文的完整性
589
- * 🔧 工具优先: 优先保留工具调用相关的核心消息
590
- *
591
- * 🏗️ 架构优化: 工具描述现在由 AgentContextManager 统一管理,而不是在 MessageFormatter 中特殊处理
592
- * 这确保了架构的一致性和调试的透明性
593
- */
594
-
595
- interface AgentCoreContextProviderOptions {
596
- mustKeepPolicy?: MustKeepPolicy;
597
- }
598
- /**
599
- * Agent专用核心上下文保留层Provider
600
- *
601
- * 实现Agent README中描述的第一阶段:核心上下文保留层 (Must-Keep)
602
- * 内容包括:系统提示词、用户当前请求、宿主显式声明的必保留 fence。
603
- */
604
- declare class AgentCoreContextProvider extends BaseContextProvider {
605
- readonly name = "AgentCoreContextProvider";
606
- readonly description = "Agent\u6838\u5FC3\u4E0A\u4E0B\u6587\u4FDD\u7559\u5C42 - \u8BC6\u522B\u5E76\u4FDD\u7559\u7CFB\u7EDF\u63D0\u793A\u8BCD\u3001\u6700\u65B0\u7528\u6237\u8F93\u5165\u548C\u6CE8\u5165\u7684\u4E0A\u4E0B\u6587";
607
- readonly priority = 1;
608
- private readonly mustKeepPolicy;
609
- constructor(options?: AgentCoreContextProviderOptions);
610
- provide(states: MessageProcessingState[], availableBudget: number, context: ProviderContext): Promise<ProviderResult>;
611
- /**
612
- * 判断是否为核心消息 - Agent专用逻辑
613
- *
614
- * 🎯 Agent核心上下文保留规则:
615
- * 1. 保留 system_prompt(系统级消息)
616
- * 2. 保留最新的 user 消息 (current_user_request)
617
- * 3. 保留 MustKeepPolicy 指定的 fence
618
- * 4. 对命中的 MustKeepPolicy.truncationRules 做 Token 截断
619
- */
620
- private isCoreMessage;
621
- /**
622
- * 内容截断 - 保持完整词汇
623
- * 复用ContextManager中的逻辑
624
- */
625
- private truncateContent;
626
- }
627
-
628
- /**
629
- * @file src/agent/context/providers/AgentWorkingMemoryProvider.ts
630
- * @description Agent专用工作记忆填充层Provider - 第二阶段上下文构建
631
- *
632
- * 🎯 职责: 实现Agent的P1-P3优先级填充策略
633
- * 📖 策略: P1(工具交互) > P2(纯文本对话) > P3(历史工具交互)
634
- * ✨ Agent特性: 工具调用优先级、配对保留策略
635
- * 🔧 核心逻辑: 保留工具调用时,必须确保其对应的另一半也被保留
636
- */
637
-
638
- /**
639
- * Agent专用工作记忆填充层Provider
640
- *
641
- * 实现Agent README中描述的第二阶段:工作记忆填充层 (Working Memory)
642
- * 工具调用为最高优先级,确保工具交互的完整性
643
- */
644
- declare class AgentWorkingMemoryProvider extends BaseContextProvider {
645
- readonly name = "AgentWorkingMemoryProvider";
646
- readonly description = "Agent\u5DE5\u4F5C\u8BB0\u5FC6\u586B\u5145\u5C42 - \u5DE5\u5177\u4F18\u5148\u7684\u53CD\u5411\u586B\u5145\u7B56\u7565\uFF0C\u652F\u6301\u914D\u5BF9\u4FDD\u7559";
647
- readonly priority = 2;
648
- private readonly matcher;
649
- private readonly tagger;
650
- private readonly config;
651
- constructor(customConfig?: Partial<AgentContextBuilderConfig>);
652
- /**
653
- * 类型守卫:用于安全读取 ProviderContext 上的"扩展字段"
654
- * 注意:ProviderContext 本身是稳定契约,扩展字段来自编排层(不应污染接口定义)。
655
- */
656
- private isRecord;
657
- /**
658
- * 读取当前上下文阶段(如果编排层提供了 currentPhase)
659
- * - 禁止 any 类型断言:这里用 Record 逐层收窄。
660
- */
661
- private readCurrentPhase;
662
- /**
663
- * 创建调试函数
664
- */
665
- private createDebugFn;
666
- provide(states: MessageProcessingState[], availableBudget: number, context: ProviderContext): Promise<ProviderResult>;
667
- /**
668
- * 计算当前已使用的Token数
669
- */
670
- private calculateUsedTokens;
671
- }
672
-
673
- /**
674
- * @file src/agent/context-manager/profiles/agent/context/providers/index.ts
675
- * @description Agent profile provider 协议与实现导出
676
- */
677
-
678
- declare class ContextProviderRegistry extends ContextProviderRegistry$1<AgentContextBuilderConfig> {
679
- }
680
-
681
- type LogPayload = Record<string, unknown> | undefined;
682
- declare class Logger {
683
- private readonly moduleName;
684
- constructor(moduleName: string);
685
- debug(message: string, data?: LogPayload): void;
686
- info(message: string, data?: LogPayload): void;
687
- warn(message: string, data?: LogPayload): void;
688
- error(message: string, data?: LogPayload): void;
689
- private log;
690
- }
691
-
692
- interface TokenUsageCalibrationState {
693
- enabled: boolean;
694
- route?: TokenRoute;
695
- sampleCount: number;
696
- coefficient?: number;
697
- minSamples?: number;
698
- minCoefficient?: number;
699
- maxCoefficient?: number;
700
- sampleLedgerEntryIds?: string[];
701
- }
702
- interface CalibrateTokenEstimateInput {
703
- localEstimateTokens: number;
704
- state: TokenUsageCalibrationState;
705
- }
706
- interface CalibratedTokenEstimate {
707
- tokens: number;
708
- trace: TokenUsageCalibrationTrace;
709
- }
710
- declare function calibrateTokenEstimate(input: CalibrateTokenEstimateInput): CalibratedTokenEstimate;
711
-
712
- interface MessageImageInputEstimate {
713
- readonly activeModelId: string;
714
- readonly attachmentIndex: number;
715
- readonly attachmentId: string;
716
- readonly resourceId: string;
717
- readonly placement: LlmImageInputPlacement;
718
- readonly width: number;
719
- readonly height: number;
720
- readonly estimatedTokens: number;
721
- readonly profileId: string;
722
- readonly estimatorVersion: string;
723
- }
724
-
725
- interface ContextManagerBaseConfig {
726
- AVG_CHARS_PER_TOKEN: number;
727
- TOOL_CALL_OVERHEAD_TOKENS?: number;
728
- TOKEN_ENCODING_NAME?: string;
729
- }
730
- interface ContextManagerBaseOptions<TConfig, TRegistry> {
731
- debugMode?: boolean;
732
- customConfig?: Partial<TConfig>;
733
- providerRegistry?: TRegistry;
734
- tokenizer?: TokenizerPort;
735
- tokenizerModelId?: string;
736
- tokenCounter?: TokenCounterPort;
737
- tokenRoute?: TokenRoute;
738
- remoteCount?: AgentSpecTokenEstimationPolicy['remoteCount'];
739
- tokenCalibration?: {
740
- policy?: AgentSpecTokenEstimationPolicy['calibration'];
741
- route?: TokenRoute;
742
- samples?: readonly TokenUsageCalibrationSample[];
743
- };
744
- imageInputEstimator?: LlmImageInputEstimatorPort;
745
- }
746
- interface ContextManagerBaseInit<TConfig, TRegistry> {
747
- defaultConfig: TConfig;
748
- validateConfig: (config: TConfig) => boolean;
749
- createRegistry: () => TRegistry;
750
- loggerName: string;
751
- invalidConfigMessage: string;
752
- }
753
- declare abstract class ContextManagerBase<TConfig extends ContextManagerBaseConfig, TRegistry extends ContextProviderRegistry$1<TConfig>> {
754
- protected config: TConfig;
755
- protected debugMode: boolean;
756
- protected providerRegistry: TRegistry;
757
- protected logger: Logger;
758
- protected tokenizer: TokenizerPort;
759
- protected tokenizerModelId?: string;
760
- private readonly tokenCounter?;
761
- private readonly tokenRoute?;
762
- private readonly remoteCountPolicy?;
763
- private tokenCalibrationState;
764
- private readonly validateConfigFn;
765
- private readonly invalidConfigMessage;
766
- private readonly hasCustomTokenizer;
767
- private readonly imageInputEstimator?;
768
- protected constructor(options: ContextManagerBaseOptions<TConfig, TRegistry>, init: ContextManagerBaseInit<TConfig, TRegistry>);
769
- private createDefaultTokenizer;
770
- protected estimateTokens(message: AiMessage): number;
771
- protected estimateTextTokens(text: string): number;
772
- protected estimateTokensWithCalibrationTrace(message: AiMessage): {
773
- tokens: number;
774
- calibrationTrace: ReturnType<typeof calibrateTokenEstimate>['trace'];
775
- };
776
- protected estimateImageInputs(message: AiMessage): MessageImageInputEstimate[];
777
- protected getTokenCalibrationTrace(): ReturnType<typeof calibrateTokenEstimate>['trace'];
778
- protected getTokenRoute(): TokenRoute | undefined;
779
- protected getPromptUsageMeasurementPolicy(): PromptUsageMeasurementPolicy;
780
- protected estimateLocalTokens(messages: readonly AiMessage[]): number;
781
- protected countMessagesWithRemoteCounter(input: {
782
- messages: readonly AiMessage[];
783
- localEstimateTokens: number;
784
- signal?: AbortSignal;
785
- }): Promise<{
786
- tokens: number;
787
- trace: RemoteTokenCountTrace;
788
- }>;
789
- protected debug(message: string, data?: Record<string, unknown>): void;
790
- protected runPipeline<TContext extends ProviderContext$1<TConfig>, TPhase extends PropertyKey, TStats extends ContextPipelineStats<TPhase>>(options: {
791
- messages: AiMessage[];
792
- totalBudget: number;
793
- buildStats: TStats;
794
- providerContext: TContext;
795
- getPhaseByProviderName: (providerName: string) => TPhase | null;
796
- contextTrace?: ContextTraceCollector;
797
- }): Promise<RunContextPipelineResult>;
798
- getConfig(): TConfig;
799
- updateConfig(newConfig: Partial<TConfig>): void;
800
- /**
801
- * 更新传给 TokenizerPort 的模型 ID。
802
- *
803
- * 中文备注:同一个 context manager 被复用到不同模型时,host 必须同步更新这里;
804
- * AgentMessageOrchestrator 会按 request 自动处理,直接使用 ContextManager 的高级接入方才需要手动调用。
805
- */
806
- updateTokenizerModelId(modelId: string | undefined): void;
807
- updateTokenCalibration(input: ContextManagerBaseOptions<TConfig, TRegistry>['tokenCalibration']): void;
808
- }
809
-
810
- type ContextCheckpointValidationFailure = 'invalid_envelope' | 'missing_section' | 'invalid_section_order' | 'empty_section' | 'instruction_like_content' | 'output_too_large';
811
-
812
- type HistorySummaryDraftResult = {
813
- readonly kind: 'ready';
814
- readonly message: AiMessage;
815
- readonly event: HistorySummaryEvent;
816
- readonly compressionRatio: number;
817
- readonly summaryTokenEstimate: number;
818
- } | {
819
- readonly kind: 'ineffective';
820
- readonly compressionRatio: number;
821
- readonly summaryTokenEstimate: number;
822
- };
823
- type ContextCompactionDraftPreparationResult = HistorySummaryDraftResult | {
824
- readonly kind: 'invalid';
825
- readonly reason: ContextCheckpointValidationFailure;
826
- readonly tokenEstimate: number;
827
- };
828
-
829
- /**
830
- * 上下文构建结果接口
831
- */
832
- interface ContextBuildResult {
833
- /** 构建后的消息列表 */
834
- messages: AiMessage[];
835
- /** Token使用情况 */
836
- tokenUsage: {
837
- used: number;
838
- remaining: number;
839
- messageBudget: number;
840
- inputBudget: number;
841
- toolDefinitionTokens: number;
842
- source: TokenCountSource;
843
- confidence: TokenCountConfidence;
844
- };
845
- /** Graph 对 reminder 后最终 Prompt 计数时复用的已解析策略。 */
846
- promptUsageMeasurementPolicy: PromptUsageMeasurementPolicy;
847
- /** 处理统计信息 */
848
- processingStats: {
849
- originalCount: number;
850
- keptCount: number;
851
- truncatedCount: number;
852
- tokenDistribution: Record<string, number>;
853
- strategiesApplied: string[];
854
- recommendations: string[];
855
- buildStats?: AgentContextBuildStats;
856
- };
857
- /** 是否进行了截断 */
858
- truncated: boolean;
859
- /** 截断的消息数量 */
860
- truncatedCount?: number;
861
- /** 应用的策略列表 */
862
- strategies: {
863
- applied: string[];
864
- recommendations: string[];
865
- };
866
- /** ContextTrace:解释本次上下文构建如何保留/裁剪消息。 */
867
- contextTrace?: ContextTrace;
868
- /** 构建期 token 估算快照,用于 host 把本地估算与响应后 actual usage 配对。 */
869
- tokenEstimate?: ContextBuildTokenEstimate;
870
- /** 构建期上下文分项 token 估算,用于 trace、账本与 host 面板后端。 */
871
- tokenComponents?: ContextTokenComponent[];
872
- /** provider attempt 用来按 active profile 复核 final context 的短生命周期预算证据。 */
873
- imageInputAdmissionEvidence?: ImageInputAdmissionEvidence;
874
- /** Graph 在最终 Prompt 计量后可执行的纯压缩候选。 */
875
- contextCompactionCandidate?: ContextCompactionCandidate;
876
- /** 本次 build 已解析的压缩策略;无候选时 Graph 仍需它判定终态。 */
877
- contextCompactionPolicy: ResolvedContextCompactionPolicy;
878
- }
879
- /**
880
- * Agent专用智能上下文管理器
881
- *
882
- * 🎯 核心职责:
883
- * 1. 编排Provider执行,构建优化的上下文
884
- * 2. 保证工具调用的完整性和配对保留
885
- * 3. 使用统一配置,不感知对话阶段
886
- *
887
- * 🏗️ 架构特性:
888
- * - Provider策略模式: 实现高内聚、低耦合
889
- * - 责任链模式: 按优先级编排Provider
890
- * - 专注于Provider编排,不负责消息构建
891
- */
892
- declare class AgentContextManager extends ContextManagerBase<AgentContextBuilderConfig, ContextProviderRegistry> {
893
- constructor(options?: {
894
- debugMode?: boolean;
895
- customConfig?: Partial<AgentContextBuilderConfig>;
896
- providerRegistry?: ContextProviderRegistry;
897
- tokenizer?: TokenizerPort;
898
- tokenizerModelId?: string;
899
- tokenCounter?: TokenCounterPort;
900
- tokenRoute?: TokenRoute;
901
- remoteCount?: ContextManagerBaseOptions<AgentContextBuilderConfig, ContextProviderRegistry>['remoteCount'];
902
- tokenCalibration?: ContextManagerBaseOptions<AgentContextBuilderConfig, ContextProviderRegistry>['tokenCalibration'];
903
- imageInputEstimator?: LlmImageInputEstimatorPort;
904
- });
905
- /**
906
- * 主入口:为Agent构建智能上下文
907
- * 专门处理预处理过的消息,专注于上下文优化
908
- */
909
- buildContextFromPreprocessedMessages(request: AgentProfileRequest, preprocessedMessages: AiMessage[], totalBudget: number, traceOptions?: {
910
- policy?: AgentSpecContextTracePolicy;
911
- effectiveContextPolicy?: AgentSpecContextPolicy;
912
- budgetDetails?: {
913
- inputBudgetTokens: number;
914
- toolDefinitionTokens: number;
915
- };
916
- }): Promise<ContextBuildResult>;
917
- /**
918
- * 校验模型生成的 checkpoint,并创建尚未发布的 summary draft。
919
- *
920
- * 中文备注:该方法只做确定性规则,不调用模型、不发布事件。Graph 只有在重建后的
921
- * Prompt 通过容量校验后,才允许把这里返回的事实提交到 EventStore。
922
- */
923
- prepareContextCompactionDraft(input: {
924
- id: string;
925
- conversationId: string;
926
- turnId: string;
927
- timestamp: number;
928
- checkpointContent: string;
929
- plan: ContextCompactionPlan;
930
- maxOutputTokens: number;
931
- }): ContextCompactionDraftPreparationResult;
932
- private initializeBuildStats;
933
- private buildFinalResult;
934
- private buildImageInputAdmissionEvidence;
935
- private buildContextTokenEstimate;
936
- private buildTokenUsageMeasurement;
937
- /**
938
- * 生成优化建议
939
- */
940
- private generateRecommendations;
941
- }
942
-
943
- /**
944
- * 对话会话管理类
945
- *
946
- * 单一职责:管理当前会话的消息存储和基础CRUD操作
947
- * - 存储和检索消息
948
- * - 维护对话历史的完整性
949
- * - 提供基础的消息查询功能
950
- *
951
- * 不负责:Token管理、智能截断、优先级分析(这些由WorkingContextManager处理)
952
- */
953
- declare class ConversationSession {
954
- private messages;
955
- private systemPrompt;
956
- /**
957
- * 构造函数
958
- * @param systemPrompt 系统提示词
959
- */
960
- constructor(systemPrompt: string);
961
- /**
962
- * 添加消息到会话
963
- * @param role 消息角色
964
- * @param content 消息内容
965
- */
966
- addMessage(role: 'user' | 'assistant', content: string): void;
967
- /**
968
- * 添加用户消息
969
- * @param content 用户消息内容
970
- * @param id 可选的消息ID,如果不提供则自动生成
971
- */
972
- addUserMessage(content: string, id?: string, attachments?: RuntimeResourceRef[]): void;
973
- /**
974
- * 添加助手消息,可能包含工具调用
975
- * @param content 文本内容(可选)
976
- * @param type 消息类型
977
- * @param metadata 消息元数据(可选)
978
- * @param id 可选的消息ID,如果不提供则自动生成
979
- */
980
- addAssistantMessage(content: string | null, type: AssistantMessage['type'], metadata?: AiMessage['metadata'], id?: string): void;
981
- /**
982
- * 添加从历史记录加载的工具输出消息
983
- * @param content 消息内容
984
- * @param metadata 消息元数据
985
- */
986
- addToolOutputMessage(content: string, metadata: AiMessage['metadata'], attachments?: RuntimeResourceRef[]): void;
987
- /**
988
- * 添加工具调用的响应结果
989
- * @param toolCallId 工具调用的唯一ID
990
- * @param content 工具执行返回的结果(通常是字符串格式)
991
- * @param toolName 工具名称(可选)
992
- * @param id 可选的消息ID,如果不提供则自动生成
993
- */
994
- addToolResponse(toolCallId: ToolCallId, content: string, toolName: string, id?: string, attachments?: RuntimeResourceRef[], metadata?: AiMessage['metadata']): void;
995
- /**
996
- * 追加一条已构造完成的消息。
997
- *
998
- * 中文备注:
999
- * - 该方法用于回放阶段写入“已是最终形态”的消息,例如 `history_summary`;
1000
- * - 这样 core 侧只依赖最小写入端口,不需要直接感知 `ConversationSession` 的私有字段结构。
1001
- */
1002
- appendMessage(message: AiMessage): void;
1003
- /**
1004
- * 获取完整的对话历史记录
1005
- * @returns 消息数组
1006
- */
1007
- getHistory(): AiMessage[];
1008
- /**
1009
- * 清空对话历史,只保留系统提示词
1010
- */
1011
- clear(): void;
1012
- /**
1013
- * 更新系统提示词
1014
- * @param newSystemPrompt 新的系统提示词
1015
- */
1016
- updateSystemPrompt(newSystemPrompt: string): void;
1017
- /**
1018
- * 获取当前系统提示词
1019
- * @returns 系统提示词字符串
1020
- */
1021
- getSystemPrompt(): string;
1022
- /**
1023
- * 获取消息总数(不包括系统消息)
1024
- * @returns 消息数量
1025
- */
1026
- getMessageCount(): number;
1027
- /**
1028
- * 获取最近的n条用户消息
1029
- * @param n 消息数量
1030
- * @returns 用户消息数组
1031
- */
1032
- getRecentUserMessages(n: number): AiMessage[];
1033
- /**
1034
- * 获取最近的n条助手消息
1035
- * @param n 消息数量
1036
- * @returns 助手消息数组
1037
- */
1038
- getRecentAssistantMessages(n: number): AiMessage[];
1039
- /**
1040
- * 检查是否有待处理的工具调用
1041
- * @returns 是否有未响应的工具调用
1042
- */
1043
- hasPendingToolCalls(): boolean;
1044
- /**
1045
- * 获取待处理的工具调用
1046
- * @returns 待处理的工具调用数组
1047
- */
1048
- getPendingToolCalls(): Array<{
1049
- id: string;
1050
- type: 'function';
1051
- function: {
1052
- name: string;
1053
- arguments: string;
1054
- };
1055
- }>;
1056
- /**
1057
- * 将历史记录序列化为JSON
1058
- * @returns JSON字符串
1059
- */
1060
- serialize(): string;
1061
- /**
1062
- * 从JSON反序列化历史记录
1063
- * @param json JSON字符串
1064
- * @returns ConversationSession实例
1065
- */
1066
- static deserialize(json: string): ConversationSession;
1067
- }
1068
-
1069
- declare const index$5_AGENT_CONTEXT_BUILDER_CONFIG: typeof AGENT_CONTEXT_BUILDER_CONFIG;
1070
- type index$5_AgentBuildPhase = AgentBuildPhase;
1071
- declare const index$5_AgentBuildPhase: typeof AgentBuildPhase;
1072
- type index$5_AgentContextBuildStats = AgentContextBuildStats;
1073
- type index$5_AgentContextBuilderConfig = AgentContextBuilderConfig;
1074
- type index$5_AgentContextManager = AgentContextManager;
1075
- declare const index$5_AgentContextManager: typeof AgentContextManager;
1076
- type index$5_AgentCoreContextProvider = AgentCoreContextProvider;
1077
- declare const index$5_AgentCoreContextProvider: typeof AgentCoreContextProvider;
1078
- type index$5_AgentMessagePriority = AgentMessagePriority;
1079
- declare const index$5_AgentMessagePriority: typeof AgentMessagePriority;
1080
- type index$5_AgentWorkingMemoryProvider = AgentWorkingMemoryProvider;
1081
- declare const index$5_AgentWorkingMemoryProvider: typeof AgentWorkingMemoryProvider;
1082
- type index$5_BaseContextProvider = BaseContextProvider;
1083
- declare const index$5_BaseContextProvider: typeof BaseContextProvider;
1084
- type index$5_ContextBuildResult = ContextBuildResult;
1085
- type index$5_ContextProviderRegistry = ContextProviderRegistry;
1086
- declare const index$5_ContextProviderRegistry: typeof ContextProviderRegistry;
1087
- type index$5_ConversationSession = ConversationSession;
1088
- declare const index$5_ConversationSession: typeof ConversationSession;
1089
- type index$5_IContextProvider = IContextProvider;
1090
- declare const index$5_MessageProcessingState: typeof MessageProcessingState;
1091
- type index$5_ProviderContext = ProviderContext;
1092
- declare const index$5_ProviderResult: typeof ProviderResult;
1093
- declare const index$5_createAgentContextBuilderConfig: typeof createAgentContextBuilderConfig;
1094
- declare const index$5_validateAgentConfig: typeof validateAgentConfig;
1095
- declare namespace index$5 {
1096
- export { index$5_AGENT_CONTEXT_BUILDER_CONFIG as AGENT_CONTEXT_BUILDER_CONFIG, index$5_AgentBuildPhase as AgentBuildPhase, type index$5_AgentContextBuildStats as AgentContextBuildStats, type index$5_AgentContextBuilderConfig as AgentContextBuilderConfig, index$5_AgentContextManager as AgentContextManager, index$5_AgentCoreContextProvider as AgentCoreContextProvider, index$5_AgentMessagePriority as AgentMessagePriority, index$5_AgentWorkingMemoryProvider as AgentWorkingMemoryProvider, index$5_BaseContextProvider as BaseContextProvider, type index$5_ContextBuildResult as ContextBuildResult, index$5_ContextProviderRegistry as ContextProviderRegistry, index$5_ConversationSession as ConversationSession, type index$5_IContextProvider as IContextProvider, index$5_MessageProcessingState as MessageProcessingState, type index$5_ProviderContext as ProviderContext, index$5_ProviderResult as ProviderResult, index$5_createAgentContextBuilderConfig as createAgentContextBuilderConfig, index$5_validateAgentConfig as validateAgentConfig };
1097
- }
1098
-
1099
- type ToolHistoryCompressionStrategy = 'per-pair' | 'per-run' | 'none';
1100
- type ToolHistoryOverflowStrategy = 'keep-latest' | 'fail-fast';
1101
- type ToolHistoryRetentionMode = 'drop' | 'compress';
1102
- interface ToolHistoryCompressorOptions {
1103
- strategy?: ToolHistoryCompressionStrategy;
1104
- retentionMode?: ToolHistoryRetentionMode;
1105
- keepLatestToolPairs?: number;
1106
- keepLatestRuns?: number;
1107
- maxInteractionGroups?: number;
1108
- overflowStrategy?: ToolHistoryOverflowStrategy;
1109
- }
1110
- /**
1111
- * 工具历史保留预处理器。
1112
- *
1113
- * 三种策略边界:
1114
- * - per-pair:按全局最近 N 组完整工具交互保留,其余按 retentionMode 处理。
1115
- * - per-run:按 user_input 划分 run,完整保留最近 K 个历史 run 内的工具组,避免腰斩同一轮工具链。
1116
- * - none:不做常规压缩,仅在 maxInteractionGroups 显式触发时执行安全阀。
1117
- *
1118
- * retentionMode 边界:
1119
- * - drop:默认行为。旧工具组超过保留窗口后直接移除,避免改写历史前缀和制造伪 final_answer。
1120
- * - compress:兼容旧行为。把旧工具组替换为自然语言摘要,用于小上下文或审计友好的历史线索保留。
1121
- *
1122
- * 注意:本处理器只决定“工具组是原样保留、删除,还是压缩为摘要消息”。
1123
- * 构建期不再二次截断 tool_call arguments 或 tool_output;output 的尺寸治理只发生在执行期 observationGovernance。
1124
- */
1125
- declare class ToolHistoryCompressorPreprocessor extends BasePreprocessor {
1126
- readonly name = "ToolHistoryCompressorPreprocessor";
1127
- readonly description = "\u5DE5\u5177\u5386\u53F2\u4FDD\u7559\u5904\u7406\u5668 - \u6309\u7B56\u7565\u4FDD\u7559\u3001\u5220\u9664\u6216\u538B\u7F29\u8F83\u65E9\u7684\u5386\u53F2\u5DE5\u5177\u8C03\u7528\u5BF9";
1128
- readonly priority: 0;
1129
- private summarizer;
1130
- private readonly options;
1131
- constructor(options?: ToolHistoryCompressorOptions);
1132
- process(messages: AiMessage[], context: PreprocessorContext): Promise<PreprocessorResult>;
1133
- shouldSkip(messages: AiMessage[], context: PreprocessorContext): boolean;
1134
- private processToolCallPairsInHistory;
1135
- private selectGroupsToKeep;
1136
- private enforceMaxInteractionGroups;
1137
- private compressToolInteractionGroup;
1138
- }
1139
-
1140
- interface ToolReplayProtocolGuardOptions {
1141
- policy?: ToolReplayProtocolPolicy;
1142
- priority?: number;
1143
- }
1144
- declare function resolveToolReplayProtocolPolicy(context: PreprocessorContext, explicitPolicy?: ToolReplayProtocolPolicy): ToolReplayProtocolPolicy;
1145
- /**
1146
- * Agent 工具回放协议守卫。
1147
- *
1148
- * 要求 continuation 的路由只能回放带完整 producer identity 的结构化工具组。
1149
- * 缺失时立即失败,避免把损坏的历史伪装成普通文本或伪造 provider 空字段。
1150
- */
1151
- declare class ToolReplayProtocolGuardPreprocessor extends BasePreprocessor {
1152
- readonly name = "ToolReplayProtocolGuardPreprocessor";
1153
- readonly description = "\u5DE5\u5177\u56DE\u653E\u534F\u8BAE\u5B88\u536B - \u62D2\u7EDD\u7F3A\u5C11\u6709\u5E8F provider continuation \u7684\u7ED3\u6784\u5316\u5DE5\u5177\u5386\u53F2";
1154
- readonly priority: number;
1155
- private readonly explicitPolicy?;
1156
- constructor(options?: ToolReplayProtocolGuardOptions);
1157
- shouldSkip(messages: AiMessage[], context: PreprocessorContext): boolean;
1158
- process(messages: AiMessage[], context: PreprocessorContext): Promise<PreprocessorResult>;
1159
- }
1160
-
1161
- interface DefaultAgentPreprocessorRegistryOptions {
1162
- fenceRegistry?: FenceRegistry;
1163
- toolHistory?: ToolHistoryCompressorOptions;
1164
- }
1165
- /**
1166
- * 预处理器注册表 - 管理所有预处理器及其执行顺序
1167
- */
1168
- declare class PreprocessorRegistry {
1169
- private preprocessors;
1170
- /**
1171
- * 注册预处理器
1172
- */
1173
- register(preprocessor: IPreprocessor): void;
1174
- /**
1175
- * 获取指定名称的预处理器
1176
- */
1177
- getPreprocessor(name: string): IPreprocessor | undefined;
1178
- /**
1179
- * 获取所有预处理器,按优先级排序
1180
- */
1181
- getAllPreprocessors(): IPreprocessor[];
1182
- /**
1183
- * 获取已注册的预处理器名称列表
1184
- */
1185
- getRegisteredNames(): string[];
1186
- /**
1187
- * 检查是否已注册指定预处理器
1188
- */
1189
- isRegistered(name: string): boolean;
1190
- /**
1191
- * 获取注册的预处理器数量
1192
- */
1193
- getCount(): number;
1194
- }
1195
- /**
1196
- * 预处理管道 - 按顺序执行所有预处理器
1197
- */
1198
- declare class PreprocessorPipeline {
1199
- private registry;
1200
- private context;
1201
- private readonly logger;
1202
- constructor(registry: PreprocessorRegistry, context?: PreprocessorContext);
1203
- /**
1204
- * 执行完整的预处理管道
1205
- *
1206
- * @param messages 输入消息列表
1207
- * @returns 预处理管道的汇总结果
1208
- */
1209
- process(messages: AiMessage[]): Promise<PreprocessorPipelineResult>;
1210
- /**
1211
- * 更新预处理上下文
1212
- */
1213
- updateContext(newContext: Partial<PreprocessorContext>): void;
1214
- /**
1215
- * 获取当前上下文
1216
- */
1217
- getContext(): PreprocessorContext;
1218
- /**
1219
- * 调试日志
1220
- */
1221
- private debug;
1222
- }
1223
- /**
1224
- * 预处理管道结果接口
1225
- */
1226
- interface PreprocessorPipelineResult {
1227
- /** 预处理后的消息列表 */
1228
- messages: AiMessage[];
1229
- /** 管道级别的统计信息 */
1230
- pipelineStats: {
1231
- originalCount: number;
1232
- finalCount: number;
1233
- totalRemovedCount: number;
1234
- processingTime: number;
1235
- preprocessorsExecuted: number;
1236
- appliedStrategies: string[];
1237
- };
1238
- /** 各个预处理器的详细结果 */
1239
- individualResults: Array<{
1240
- preprocessor: string;
1241
- result: PreprocessorResult;
1242
- }>;
1243
- }
1244
- /**
1245
- * 创建默认的Agent预处理器注册表
1246
- *
1247
- * 🔥 这里定义了Agent预处理管道的默认配置:
1248
- * 1. ToolHistoryCompressorPreprocessor (toolHistoryCompression) - 工具历史保留/删除,最先执行
1249
- * 2. ToolReplayProtocolGuardPreprocessor (toolReplayProtocolGuard) - 工具回放协议守卫,仅治理历史轮次
1250
- * 3. HistoryPurificationPreprocessor (historyPurification) - Agent历史净化,在压缩后执行
1251
- *
1252
- * 💡 未来可扩展:
1253
- * - 新增 preprocessor 时先在 PREPROCESSOR_PRIORITY 中声明稳定阶段,再接入 registry。
1254
- */
1255
- declare function createDefaultAgentPreprocessorRegistry(options?: DefaultAgentPreprocessorRegistryOptions): PreprocessorRegistry;
1256
- /**
1257
- * 创建默认的Agent预处理管道
1258
- *
1259
- * @param context 预处理上下文配置
1260
- * @returns 配置好的Agent预处理管道实例
1261
- */
1262
- declare function createDefaultAgentPreprocessorPipeline(context?: PreprocessorContext, options?: DefaultAgentPreprocessorRegistryOptions): PreprocessorPipeline;
1263
-
1264
- type index$4_BasePreprocessor = BasePreprocessor;
1265
- declare const index$4_BasePreprocessor: typeof BasePreprocessor;
1266
- type index$4_CurrentTurnMessageAssembler = CurrentTurnMessageAssembler;
1267
- declare const index$4_CurrentTurnMessageAssembler: typeof CurrentTurnMessageAssembler;
1268
- type index$4_DefaultAgentPreprocessorRegistryOptions = DefaultAgentPreprocessorRegistryOptions;
1269
- type index$4_FenceLifetimePreprocessor = FenceLifetimePreprocessor;
1270
- declare const index$4_FenceLifetimePreprocessor: typeof FenceLifetimePreprocessor;
1271
- type index$4_HistoryPurificationPreprocessor = HistoryPurificationPreprocessor;
1272
- declare const index$4_HistoryPurificationPreprocessor: typeof HistoryPurificationPreprocessor;
1273
- type index$4_IPreprocessor = IPreprocessor;
1274
- type index$4_PreprocessorContext = PreprocessorContext;
1275
- type index$4_PreprocessorPipeline = PreprocessorPipeline;
1276
- declare const index$4_PreprocessorPipeline: typeof PreprocessorPipeline;
1277
- type index$4_PreprocessorPipelineResult = PreprocessorPipelineResult;
1278
- type index$4_PreprocessorRegistry = PreprocessorRegistry;
1279
- declare const index$4_PreprocessorRegistry: typeof PreprocessorRegistry;
1280
- type index$4_PreprocessorResult = PreprocessorResult;
1281
- type index$4_ToolHistoryCompressionStrategy = ToolHistoryCompressionStrategy;
1282
- type index$4_ToolHistoryCompressorOptions = ToolHistoryCompressorOptions;
1283
- type index$4_ToolHistoryCompressorPreprocessor = ToolHistoryCompressorPreprocessor;
1284
- declare const index$4_ToolHistoryCompressorPreprocessor: typeof ToolHistoryCompressorPreprocessor;
1285
- type index$4_ToolHistoryOverflowStrategy = ToolHistoryOverflowStrategy;
1286
- type index$4_ToolHistoryRetentionMode = ToolHistoryRetentionMode;
1287
- type index$4_ToolReplayProtocolGuardOptions = ToolReplayProtocolGuardOptions;
1288
- type index$4_ToolReplayProtocolGuardPreprocessor = ToolReplayProtocolGuardPreprocessor;
1289
- declare const index$4_ToolReplayProtocolGuardPreprocessor: typeof ToolReplayProtocolGuardPreprocessor;
1290
- declare const index$4_ToolReplayProtocolPolicy: typeof ToolReplayProtocolPolicy;
1291
- type index$4_ToolSummaryProvider = ToolSummaryProvider;
1292
- declare const index$4_createDefaultAgentPreprocessorPipeline: typeof createDefaultAgentPreprocessorPipeline;
1293
- declare const index$4_createDefaultAgentPreprocessorRegistry: typeof createDefaultAgentPreprocessorRegistry;
1294
- declare const index$4_resolveToolReplayProtocolPolicy: typeof resolveToolReplayProtocolPolicy;
1295
- declare namespace index$4 {
1296
- export { index$4_BasePreprocessor as BasePreprocessor, index$4_CurrentTurnMessageAssembler as CurrentTurnMessageAssembler, type index$4_DefaultAgentPreprocessorRegistryOptions as DefaultAgentPreprocessorRegistryOptions, index$4_FenceLifetimePreprocessor as FenceLifetimePreprocessor, index$4_HistoryPurificationPreprocessor as HistoryPurificationPreprocessor, type index$4_IPreprocessor as IPreprocessor, type index$4_PreprocessorContext as PreprocessorContext, index$4_PreprocessorPipeline as PreprocessorPipeline, type index$4_PreprocessorPipelineResult as PreprocessorPipelineResult, index$4_PreprocessorRegistry as PreprocessorRegistry, type index$4_PreprocessorResult as PreprocessorResult, type index$4_ToolHistoryCompressionStrategy as ToolHistoryCompressionStrategy, type index$4_ToolHistoryCompressorOptions as ToolHistoryCompressorOptions, index$4_ToolHistoryCompressorPreprocessor as ToolHistoryCompressorPreprocessor, type index$4_ToolHistoryOverflowStrategy as ToolHistoryOverflowStrategy, type index$4_ToolHistoryRetentionMode as ToolHistoryRetentionMode, type index$4_ToolReplayProtocolGuardOptions as ToolReplayProtocolGuardOptions, index$4_ToolReplayProtocolGuardPreprocessor as ToolReplayProtocolGuardPreprocessor, index$4_ToolReplayProtocolPolicy as ToolReplayProtocolPolicy, type index$4_ToolSummaryProvider as ToolSummaryProvider, index$4_createDefaultAgentPreprocessorPipeline as createDefaultAgentPreprocessorPipeline, index$4_createDefaultAgentPreprocessorRegistry as createDefaultAgentPreprocessorRegistry, index$4_resolveToolReplayProtocolPolicy as resolveToolReplayProtocolPolicy };
1297
- }
1298
-
1299
- interface ToolManagerRegistry extends ToolSummaryProvider {
1300
- getAvailableToolNames(toolNames?: string[]): string[];
1301
- validateToolCall(toolName: string, args: ToolArgs): {
1302
- success: boolean;
1303
- error?: string;
1304
- };
1305
- }
1306
- interface DynamicToolContext {
1307
- request: AgentProfileRequest;
1308
- }
1309
- declare class ToolManager {
1310
- private readonly registry;
1311
- constructor(registry: ToolManagerRegistry);
1312
- getAvailableToolNames(context: DynamicToolContext): string[];
1313
- validateToolCall(toolName: string, args: ToolArgs, context: DynamicToolContext): {
1314
- success: boolean;
1315
- error?: string;
1316
- };
1317
- getSummaryProvider(): ToolSummaryProvider;
1318
- }
1319
-
1320
- interface IAgentTask {
1321
- readonly name: string;
1322
- buildMessages(request: AgentProfileRequest, history: AiMessage[]): AiMessage[];
1323
- processResponse(rawResponse: string): string;
1324
- processStreamChunk(chunk: string): string;
1325
- getPreferredModelCapability?(): string;
1326
- }
1327
- type AgentTaskResolver = (promptKey: string) => IAgentTask;
1328
- interface IAgentTaskRegistry {
1329
- register(promptKey: string, task: IAgentTask): void;
1330
- getTask(promptKey: string): IAgentTask | null;
1331
- getAllTaskKeys(): string[];
1332
- }
1333
-
1334
- interface AgentOrchestratorOptions {
1335
- tokenBudget: {
1336
- maxTokens: number;
1337
- reservedForResponse: number;
1338
- };
1339
- processing: {
1340
- debugMode?: boolean;
1341
- preserveMetadata?: boolean;
1342
- };
1343
- model?: string;
1344
- resolveToolReplayProtocolPolicy?: (params: {
1345
- request: AgentProfileRequest;
1346
- modelId: string;
1347
- }) => ToolReplayProtocolPolicy | undefined;
1348
- resolveContextPolicy?: (request: AgentProfileRequest) => AgentSpecContextPolicy | undefined;
1349
- createProviderRegistry?: (params: {
1350
- request: AgentProfileRequest;
1351
- contextPolicy: AgentSpecContextPolicy | undefined;
1352
- contextBuilderConfig: Partial<AgentContextBuilderConfig>;
1353
- }) => ContextProviderRegistry;
1354
- resolveTokenCalibration?: (params: {
1355
- request: AgentProfileRequest;
1356
- modelId: string;
1357
- contextPolicy: AgentSpecContextPolicy | undefined;
1358
- }) => {
1359
- route?: TokenRoute;
1360
- samples?: readonly TokenUsageCalibrationSample[];
1361
- } | undefined;
1362
- taskResolver: AgentTaskResolver;
1363
- providerRegistry: ContextProviderRegistry;
1364
- fenceRegistry?: FenceRegistry;
1365
- tokenizer?: TokenizerPort;
1366
- tokenCounter?: TokenCounterPort;
1367
- imageInputEstimator?: LlmImageInputEstimatorPort;
1368
- resolveTokenRoute?: (params: {
1369
- request: AgentProfileRequest;
1370
- modelId: string;
1371
- contextPolicy: AgentSpecContextPolicy | undefined;
1372
- }) => TokenRoute | undefined;
1373
- }
1374
- interface AgentProcessingResult {
1375
- messages: AiMessage[];
1376
- contextBuildResult: ContextBuildResult;
1377
- promptBudget: EffectivePromptBudget;
1378
- metadata: {
1379
- originalCount: number;
1380
- processedCount: number;
1381
- processingStats: ContextBuildResult['processingStats'];
1382
- truncated: boolean;
1383
- truncatedCount?: number;
1384
- };
1385
- }
1386
- type AgentContextCompactionApplyResult = {
1387
- readonly kind: 'ready';
1388
- readonly processingResult: AgentProcessingResult;
1389
- readonly pendingSummaryEvent: HistorySummaryEvent;
1390
- readonly compressionRatio: number;
1391
- readonly summaryTokenEstimate: number;
1392
- } | {
1393
- readonly kind: 'invalid';
1394
- readonly reason: ContextCheckpointValidationFailure | 'replacement_survived' | 'orphan_tool_output';
1395
- readonly tokenEstimate?: number;
1396
- readonly messageId?: string;
1397
- } | {
1398
- readonly kind: 'ineffective';
1399
- readonly compressionRatio: number;
1400
- readonly summaryTokenEstimate: number;
1401
- };
1402
- declare class AgentMessageOrchestrator {
1403
- private baseAgentContextManager;
1404
- private options;
1405
- private readonly taskResolver;
1406
- private baseContextConfig;
1407
- private readonly logger;
1408
- constructor(options: AgentOrchestratorOptions);
1409
- private createAgentContextManager;
1410
- private buildPreprocessorPipelineForRequest;
1411
- private resolvePreprocessorModel;
1412
- private resolveContextPolicy;
1413
- private assembleRequestContext;
1414
- processAgentConversation(request: AgentProfileRequest, history: RuntimeEvent[], toolManager: ToolManager, extraOptions?: {
1415
- promptBudgetLimits: {
1416
- modelContextWindowTokens: number;
1417
- modelMaxOutputTokens: number;
1418
- toolDefinitionTokens: number;
1419
- };
1420
- }): Promise<AgentProcessingResult>;
1421
- /**
1422
- * 把通过校验的 checkpoint 作为 pending history fact 注入,并重跑正常上下文链路。
1423
- *
1424
- * 中文备注:这里不发布摘要。Graph 必须先对 rebuilt Prompt 重新计量并通过 admission,
1425
- * 才能提交 pendingSummaryEvent。
1426
- */
1427
- applyContextCompaction(request: AgentProfileRequest, history: RuntimeEvent[], toolManager: ToolManager, input: {
1428
- id: string;
1429
- conversationId: string;
1430
- turnId: string;
1431
- timestamp: number;
1432
- checkpointContent: string;
1433
- plan: ContextCompactionPlan;
1434
- maxOutputTokens: number;
1435
- promptBudgetLimits: {
1436
- modelContextWindowTokens: number;
1437
- modelMaxOutputTokens: number;
1438
- toolDefinitionTokens: number;
1439
- };
1440
- }): Promise<AgentContextCompactionApplyResult>;
1441
- private buildCompleteMessageList;
1442
- private runPreprocessorPipeline;
1443
- private buildContextFromPreprocessedMessages;
1444
- private debug;
1445
- updateOptions(newOptions: Partial<AgentOrchestratorOptions>): void;
1446
- getContextManager(): AgentContextManager;
1447
- getContextInfo(): {
1448
- config: AgentContextBuilderConfig;
1449
- };
1450
- }
1451
-
1452
- type index$3_AgentMessageOrchestrator = AgentMessageOrchestrator;
1453
- declare const index$3_AgentMessageOrchestrator: typeof AgentMessageOrchestrator;
1454
- type index$3_AgentOrchestratorOptions = AgentOrchestratorOptions;
1455
- type index$3_AgentProcessingResult = AgentProcessingResult;
1456
- declare namespace index$3 {
1457
- export { index$3_AgentMessageOrchestrator as AgentMessageOrchestrator, type index$3_AgentOrchestratorOptions as AgentOrchestratorOptions, type index$3_AgentProcessingResult as AgentProcessingResult };
1458
- }
1459
-
1460
- /**
1461
- * @file src/agent/context-manager/profiles/agent/tasks/BaseAgentTask.ts
1462
- * @description Agent任务的抽象基类 - 处理Agent通用逻辑
1463
- *
1464
- * 专注于核心消息构建,将复杂的上下文管理交给 AgentContextManager
1465
- */
1466
-
1467
- interface BaseAgentTaskOptions {
1468
- fenceRegistry?: FenceRegistry;
1469
- }
1470
- /**
1471
- * Agent任务的抽象基类
1472
- *
1473
- * @abstract
1474
- * @description
1475
- * 现在只负责构建 Agent 任务的核心消息骨架:
1476
- * - system prompt
1477
- * - host-provided context injection messages
1478
- * - 当前 user query
1479
- * - 按时序附加 history
1480
- */
1481
- declare abstract class BaseAgentTask implements IAgentTask {
1482
- abstract readonly name: string;
1483
- private readonly fenceRegistry?;
1484
- constructor(options?: BaseAgentTaskOptions);
1485
- protected abstract getSystemPrompt(request: AgentProfileRequest): string;
1486
- getSystemPromptForRequest(request: AgentProfileRequest): string;
1487
- buildMessages(request: AgentProfileRequest, history: AiMessage[]): AiMessage[];
1488
- private createCurrentUserMessage;
1489
- private createFenceMessages;
1490
- private createFenceMessage;
1491
- private insertAfterLastToolResult;
1492
- processResponse(rawResponse: string): string;
1493
- processStreamChunk(chunk: string): string;
1494
- }
1495
-
1496
- type index$2_AgentTaskResolver = AgentTaskResolver;
1497
- type index$2_BaseAgentTask = BaseAgentTask;
1498
- declare const index$2_BaseAgentTask: typeof BaseAgentTask;
1499
- type index$2_IAgentTask = IAgentTask;
1500
- type index$2_IAgentTaskRegistry = IAgentTaskRegistry;
1501
- declare namespace index$2 {
1502
- export { type index$2_AgentTaskResolver as AgentTaskResolver, index$2_BaseAgentTask as BaseAgentTask, type index$2_IAgentTask as IAgentTask, type index$2_IAgentTaskRegistry as IAgentTaskRegistry };
1503
- }
1504
-
1505
- type index$1_DynamicToolContext = DynamicToolContext;
1506
- type index$1_ToolManager = ToolManager;
1507
- declare const index$1_ToolManager: typeof ToolManager;
1508
- type index$1_ToolManagerRegistry = ToolManagerRegistry;
1509
- declare namespace index$1 {
1510
- export { type index$1_DynamicToolContext as DynamicToolContext, index$1_ToolManager as ToolManager, type index$1_ToolManagerRegistry as ToolManagerRegistry };
1511
- }
1512
-
1513
- declare function convertEventToAiMessage(event: RuntimeEvent): AiMessage;
1514
- declare function convertEventsToAiMessages(events: RuntimeEvent[]): AiMessage[];
1515
- interface AiMessageEventContext {
1516
- conversation_id: string;
1517
- turn_id: string;
1518
- timestamp?: number;
1519
- metadata?: RuntimeEvent['metadata'];
1520
- ephemeral?: boolean;
1521
- }
1522
- declare function convertAiMessageToEvent(message: AiMessage, context: AiMessageEventContext): RuntimeEvent;
1523
-
1524
- type UnknownRecord = Record<string, unknown>;
1525
- interface SummarizerConfig {
1526
- fullContentThreshold: number;
1527
- textPreviewLength: number;
1528
- arrayPreviewCount: number;
1529
- objectPreviewFieldCount: number;
1530
- }
1531
- declare const DEFAULT_SUMMARIZER_CONFIG: SummarizerConfig;
1532
- declare class ToolOutputSummarizer {
1533
- private config;
1534
- constructor(config?: Partial<SummarizerConfig>);
1535
- getSummary(toolName: string, output: string, toolSummaryProvider?: ToolSummaryProvider): string;
1536
- formatToolArgs(args: UnknownRecord): string;
1537
- private tryToolSpecificSummary;
1538
- private createGenericSummary;
1539
- private summarizeArray;
1540
- private summarizeObject;
1541
- private summarizeText;
1542
- }
1543
- declare const createDefaultToolOutputSummarizer: (config?: Partial<SummarizerConfig>) => ToolOutputSummarizer;
1544
- declare const summarizeToolOutput: (toolName: string, output: string, toolSummaryProvider?: ToolSummaryProvider, config?: Partial<SummarizerConfig>) => string;
1545
-
1546
- declare const index_DEFAULT_SUMMARIZER_CONFIG: typeof DEFAULT_SUMMARIZER_CONFIG;
1547
- type index_SummarizerConfig = SummarizerConfig;
1548
- type index_ToolOutputSummarizer = ToolOutputSummarizer;
1549
- declare const index_ToolOutputSummarizer: typeof ToolOutputSummarizer;
1550
- declare const index_convertAiMessageToEvent: typeof convertAiMessageToEvent;
1551
- declare const index_convertEventToAiMessage: typeof convertEventToAiMessage;
1552
- declare const index_convertEventsToAiMessages: typeof convertEventsToAiMessages;
1553
- declare const index_createDefaultToolOutputSummarizer: typeof createDefaultToolOutputSummarizer;
1554
- declare const index_summarizeToolOutput: typeof summarizeToolOutput;
1555
- declare namespace index {
1556
- export { index_DEFAULT_SUMMARIZER_CONFIG as DEFAULT_SUMMARIZER_CONFIG, type index_SummarizerConfig as SummarizerConfig, index_ToolOutputSummarizer as ToolOutputSummarizer, index_convertAiMessageToEvent as convertAiMessageToEvent, index_convertEventToAiMessage as convertEventToAiMessage, index_convertEventsToAiMessages as convertEventsToAiMessages, index_createDefaultToolOutputSummarizer as createDefaultToolOutputSummarizer, index_summarizeToolOutput as summarizeToolOutput };
1557
- }
1558
-
1559
- export { AGENT_CONSTANTS, AGENT_CONTEXT_BUILDER_CONFIG, type AgentContextBuilderConfigOverrides, type AgentSpecExecutionOptions, type AgentSpecPreprocessorOptions, type AgentSpecProviderOptions, type AgentSpecRuntimeOptions, BaseContextProvider, BasePreprocessor, type ChatMessage, type ContextPipelineStats, ContextProviderRegistry$1 as ContextProviderRegistry, ContextTrace, ContextTraceCollector, CurrentTurnMessageAssembler, type CurrentTurnMessageAssemblerOptions, DEFAULT_MUST_KEEP_POLICY, type FenceDescriptor, type FenceInjection, type FenceLifetime, FenceLifetimePreprocessor, type FenceLifetimePreprocessorOptions, type FenceLlmRole, type FencePlacement, type FenceRegistry, type HistoryPurificationConfig, HistoryPurificationPreprocessor, type IContextProvider, type IPreprocessor, type LlmMessage, type MergeContextPolicyParams, type MessageFormatOptions, type MessageFormatterOptions, MessageProcessingState, type MessageRole, type MessageType, type MustKeepPolicy, type MustKeepTruncationRule, type NativeToolCallingMessage, PREPROCESSOR_PRIORITY, type PreprocessorContext, type PreprocessorPriorityName, type PreprocessorResult, type ProviderContext, ProviderResult, RemoteTokenCountTrace, type RunContextPipelineOptions, type RunContextPipelineResult, IContextProvider$1 as SharedContextProvider, ProviderContext$1 as SharedProviderContext, type ToolSummaryProvider, config as agentConfig, index$5 as agentContext, contracts as agentContracts, index$3 as agentOrchestration, index$4 as agentPreprocessors, agentSpecToContextBuilderConfig, agentSpecToRuntimeOptions, index$2 as agentTasks, index$1 as agentTools, index as agentUtils, contextPolicyToContextBuilderConfig, contextPolicyToExecutionOptions, contextPolicyToMustKeepPolicy, contextPolicyToPreprocessorOptions, contextPolicyToProviderOptions, contextPolicyToRuntimeOptions, contextPolicyToSystemReminderOptions, createFenceRegistry, createMessageFormatter, findMatchingTruncationRule, formatAgentLlmMessages, mergeContextPolicy, messageFormatter, runContextPipeline };
1
+ export { LlmMessage, MessageFormatOptions, MessageFormatterOptions, NativeToolCallingMessage, createMessageFormatter, formatAgentLlmMessages, messageFormatter } from './context-manager/shared/MessageFormatter.cjs';
2
+ export { ChatMessage, MessageRole, MessageType } from './context-manager/shared/contracts/chatLineMessage.cjs';
3
+ export { AgentContextBuilderConfigOverrides, AgentSpecExecutionOptions, AgentSpecPreprocessorOptions, AgentSpecProviderOptions, AgentSpecRuntimeOptions, agentSpecToContextBuilderConfig, agentSpecToRuntimeOptions, contextPolicyToContextBuilderConfig, contextPolicyToExecutionOptions, contextPolicyToMustKeepPolicy, contextPolicyToPreprocessorOptions, contextPolicyToProviderOptions, contextPolicyToRuntimeOptions, contextPolicyToSystemReminderOptions } from './context-manager/shared/agentSpecAdapter.cjs';
4
+ export { ContextPipelineStats, RunContextPipelineOptions, RunContextPipelineResult, runContextPipeline } from './context-manager/shared/context-pipeline.cjs';
5
+ export { MergeContextPolicyParams, mergeContextPolicy } from './context-manager/shared/contextPolicyMerge.cjs';
6
+ export { ContextTrace, ContextTraceCollector, ContextTraceEvent, ContextTraceMessageDecisionEvent, ContextTraceProviderEvent } from './context-manager/shared/context-trace.cjs';
7
+ export { BasePreprocessor, IPreprocessor, PreprocessorContext, PreprocessorResult, ToolSummaryProvider } from './context-manager/shared/preprocessors/base.cjs';
8
+ export { PREPROCESSOR_PRIORITY, PreprocessorPriorityName } from './context-manager/shared/preprocessors/priority.cjs';
9
+ export { HistoryPurificationConfig, HistoryPurificationPreprocessor } from './context-manager/shared/preprocessors/historyPurification.cjs';
10
+ export { FenceLifetimePreprocessor, FenceLifetimePreprocessorOptions } from './context-manager/shared/preprocessors/fenceLifetimeManager.cjs';
11
+ export { CurrentTurnMessageAssembler, CurrentTurnMessageAssemblerOptions } from './context-manager/shared/preprocessors/currentTurnMessageAssembler.cjs';
12
+ export { ContextProviderError, ContextProviderErrorCode, ContextProviderErrorOptions, MessageProcessingState, ProviderResult, RemoteTokenCountTrace, IContextProvider as SharedContextProvider, ProviderContext as SharedProviderContext, TOOL_HISTORY_OVERFLOW_ERROR_CODE, TOOL_REPLAY_PROTOCOL_ERROR_CODE, isContextProviderError } from './context-manager/shared/providers/base.cjs';
13
+ export { ContextProviderRegistry } from './context-manager/shared/providers/registry.cjs';
14
+ export { FenceDescriptor, FenceInjection, FenceLifetime, FenceLlmRole, FencePlacement, FenceRegistry, createFenceRegistry } from './context-manager/shared/fences/FenceRegistry.cjs';
15
+ export { DEFAULT_MUST_KEEP_POLICY, MustKeepPolicy, MustKeepTruncationRule, findMatchingTruncationRule } from './context-manager/shared/policies/MustKeepPolicy.cjs';
16
+ import * as contracts from './context-manager/profiles/agent/contracts.cjs';
17
+ export { contracts as agentContracts };
18
+ import * as config from './context-manager/profiles/agent/config.cjs';
19
+ export { config as agentConfig };
20
+ export { AGENT_CONSTANTS } from './context-manager/profiles/agent/config.cjs';
21
+ import * as index from './context-manager/profiles/agent/context/index.cjs';
22
+ export { index as agentContext };
23
+ import * as index$1 from './context-manager/profiles/agent/orchestration/index.cjs';
24
+ export { index$1 as agentOrchestration };
25
+ import * as index$2 from './context-manager/profiles/agent/preprocessors/index.cjs';
26
+ export { index$2 as agentPreprocessors };
27
+ import * as index$3 from './context-manager/profiles/agent/tasks/index.cjs';
28
+ export { index$3 as agentTasks };
29
+ import * as index$4 from './context-manager/profiles/agent/tools/index.cjs';
30
+ export { index$4 as agentTools };
31
+ import * as index$5 from './context-manager/profiles/agent/utils/index.cjs';
32
+ export { index$5 as agentUtils };
33
+ export { AGENT_CONTEXT_BUILDER_CONFIG } from './context-manager/profiles/agent/context/config.cjs';
34
+ export { BaseContextProvider, IContextProvider, ProviderContext } from './context-manager/profiles/agent/context/providers/base.cjs';