@truefoundry/trueforge-core 0.0.0 → 0.1.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (557) hide show
  1. package/LICENSE +21 -0
  2. package/dist/agent-session/ITurnResourceResolver.d.ts +69 -0
  3. package/dist/agent-session/ITurnResourceResolver.d.ts.map +1 -0
  4. package/dist/agent-session/ITurnResourceResolver.js +19 -0
  5. package/dist/agent-session/ITurnResourceResolver.js.map +1 -0
  6. package/dist/agent-session/ITurnResourceResolver.mjs +1 -0
  7. package/dist/agent-session/ITurnResourceResolver.mjs.map +1 -0
  8. package/dist/agent-session/SessionHandle.d.ts +81 -0
  9. package/dist/agent-session/SessionHandle.d.ts.map +1 -0
  10. package/dist/agent-session/SessionHandle.js +392 -0
  11. package/dist/agent-session/SessionHandle.js.map +1 -0
  12. package/dist/agent-session/SessionHandle.mjs +371 -0
  13. package/dist/agent-session/SessionHandle.mjs.map +1 -0
  14. package/dist/agent-session/Sessions.d.ts +25 -0
  15. package/dist/agent-session/Sessions.d.ts.map +1 -0
  16. package/dist/agent-session/Sessions.js +71 -0
  17. package/dist/agent-session/Sessions.js.map +1 -0
  18. package/dist/agent-session/Sessions.mjs +46 -0
  19. package/dist/agent-session/Sessions.mjs.map +1 -0
  20. package/dist/agent-session/TurnHandle.d.ts +88 -0
  21. package/dist/agent-session/TurnHandle.d.ts.map +1 -0
  22. package/dist/agent-session/TurnHandle.js +490 -0
  23. package/dist/agent-session/TurnHandle.js.map +1 -0
  24. package/dist/agent-session/TurnHandle.mjs +469 -0
  25. package/dist/agent-session/TurnHandle.mjs.map +1 -0
  26. package/dist/agent-session/TurnResourceResolver.d.ts +154 -0
  27. package/dist/agent-session/TurnResourceResolver.d.ts.map +1 -0
  28. package/dist/agent-session/TurnResourceResolver.js +178 -0
  29. package/dist/agent-session/TurnResourceResolver.js.map +1 -0
  30. package/dist/agent-session/TurnResourceResolver.mjs +153 -0
  31. package/dist/agent-session/TurnResourceResolver.mjs.map +1 -0
  32. package/dist/agent-session/builtinsFromSpec.d.ts +19 -0
  33. package/dist/agent-session/builtinsFromSpec.d.ts.map +1 -0
  34. package/dist/agent-session/builtinsFromSpec.js +73 -0
  35. package/dist/agent-session/builtinsFromSpec.js.map +1 -0
  36. package/dist/agent-session/builtinsFromSpec.mjs +48 -0
  37. package/dist/agent-session/builtinsFromSpec.mjs.map +1 -0
  38. package/dist/agent-session/index.d.ts +29 -0
  39. package/dist/agent-session/index.d.ts.map +1 -0
  40. package/dist/agent-session/index.js +117 -0
  41. package/dist/agent-session/index.js.map +1 -0
  42. package/dist/agent-session/index.mjs +84 -0
  43. package/dist/agent-session/index.mjs.map +1 -0
  44. package/dist/agent-session/models/SessionRecord.d.ts +34 -0
  45. package/dist/agent-session/models/SessionRecord.d.ts.map +1 -0
  46. package/dist/agent-session/models/SessionRecord.js +19 -0
  47. package/dist/agent-session/models/SessionRecord.js.map +1 -0
  48. package/dist/agent-session/models/SessionRecord.mjs +1 -0
  49. package/dist/agent-session/models/SessionRecord.mjs.map +1 -0
  50. package/dist/agent-session/models/TurnRecord.d.ts +37 -0
  51. package/dist/agent-session/models/TurnRecord.d.ts.map +1 -0
  52. package/dist/agent-session/models/TurnRecord.js +31 -0
  53. package/dist/agent-session/models/TurnRecord.js.map +1 -0
  54. package/dist/agent-session/models/TurnRecord.mjs +6 -0
  55. package/dist/agent-session/models/TurnRecord.mjs.map +1 -0
  56. package/dist/agent-session/schemas/agentSpec.d.ts +142 -0
  57. package/dist/agent-session/schemas/agentSpec.d.ts.map +1 -0
  58. package/dist/agent-session/schemas/agentSpec.js +170 -0
  59. package/dist/agent-session/schemas/agentSpec.js.map +1 -0
  60. package/dist/agent-session/schemas/agentSpec.mjs +154 -0
  61. package/dist/agent-session/schemas/agentSpec.mjs.map +1 -0
  62. package/dist/agent-session/schemas/events.d.ts +1037 -0
  63. package/dist/agent-session/schemas/events.d.ts.map +1 -0
  64. package/dist/agent-session/schemas/events.js +80 -0
  65. package/dist/agent-session/schemas/events.js.map +1 -0
  66. package/dist/agent-session/schemas/events.mjs +69 -0
  67. package/dist/agent-session/schemas/events.mjs.map +1 -0
  68. package/dist/agent-session/schemas/pagination.d.ts +9 -0
  69. package/dist/agent-session/schemas/pagination.d.ts.map +1 -0
  70. package/dist/agent-session/schemas/pagination.js +36 -0
  71. package/dist/agent-session/schemas/pagination.js.map +1 -0
  72. package/dist/agent-session/schemas/pagination.mjs +11 -0
  73. package/dist/agent-session/schemas/pagination.mjs.map +1 -0
  74. package/dist/agent-session/schemas/session.d.ts +319 -0
  75. package/dist/agent-session/schemas/session.d.ts.map +1 -0
  76. package/dist/agent-session/schemas/session.js +58 -0
  77. package/dist/agent-session/schemas/session.js.map +1 -0
  78. package/dist/agent-session/schemas/session.mjs +30 -0
  79. package/dist/agent-session/schemas/session.mjs.map +1 -0
  80. package/dist/agent-session/schemas/turn.d.ts +494 -0
  81. package/dist/agent-session/schemas/turn.d.ts.map +1 -0
  82. package/dist/agent-session/schemas/turn.js +131 -0
  83. package/dist/agent-session/schemas/turn.js.map +1 -0
  84. package/dist/agent-session/schemas/turn.mjs +102 -0
  85. package/dist/agent-session/schemas/turn.mjs.map +1 -0
  86. package/dist/agent-session/store/ISessionStore.d.ts +310 -0
  87. package/dist/agent-session/store/ISessionStore.d.ts.map +1 -0
  88. package/dist/agent-session/store/ISessionStore.js +19 -0
  89. package/dist/agent-session/store/ISessionStore.js.map +1 -0
  90. package/dist/agent-session/store/ISessionStore.mjs +1 -0
  91. package/dist/agent-session/store/ISessionStore.mjs.map +1 -0
  92. package/dist/agent-session/store/InMemorySessionStore.d.ts +55 -0
  93. package/dist/agent-session/store/InMemorySessionStore.d.ts.map +1 -0
  94. package/dist/agent-session/store/InMemorySessionStore.js +475 -0
  95. package/dist/agent-session/store/InMemorySessionStore.js.map +1 -0
  96. package/dist/agent-session/store/InMemorySessionStore.mjs +461 -0
  97. package/dist/agent-session/store/InMemorySessionStore.mjs.map +1 -0
  98. package/dist/agent-session/store/OffsetPageToken.d.ts +13 -0
  99. package/dist/agent-session/store/OffsetPageToken.d.ts.map +1 -0
  100. package/dist/agent-session/store/OffsetPageToken.js +60 -0
  101. package/dist/agent-session/store/OffsetPageToken.js.map +1 -0
  102. package/dist/agent-session/store/OffsetPageToken.mjs +32 -0
  103. package/dist/agent-session/store/OffsetPageToken.mjs.map +1 -0
  104. package/dist/agent-session/store/PageToken.d.ts +4 -0
  105. package/dist/agent-session/store/PageToken.d.ts.map +1 -0
  106. package/dist/agent-session/store/PageToken.js +45 -0
  107. package/dist/agent-session/store/PageToken.js.map +1 -0
  108. package/dist/agent-session/store/PageToken.mjs +19 -0
  109. package/dist/agent-session/store/PageToken.mjs.map +1 -0
  110. package/dist/agent-session/store/SessionEventPageToken.d.ts +14 -0
  111. package/dist/agent-session/store/SessionEventPageToken.d.ts.map +1 -0
  112. package/dist/agent-session/store/SessionEventPageToken.js +70 -0
  113. package/dist/agent-session/store/SessionEventPageToken.js.map +1 -0
  114. package/dist/agent-session/store/SessionEventPageToken.mjs +42 -0
  115. package/dist/agent-session/store/SessionEventPageToken.mjs.map +1 -0
  116. package/dist/agent-session/store/SessionListPageToken.d.ts +24 -0
  117. package/dist/agent-session/store/SessionListPageToken.d.ts.map +1 -0
  118. package/dist/agent-session/store/SessionListPageToken.js +66 -0
  119. package/dist/agent-session/store/SessionListPageToken.js.map +1 -0
  120. package/dist/agent-session/store/SessionListPageToken.mjs +38 -0
  121. package/dist/agent-session/store/SessionListPageToken.mjs.map +1 -0
  122. package/dist/agent-session/store/SessionStoreErrors.d.ts +43 -0
  123. package/dist/agent-session/store/SessionStoreErrors.d.ts.map +1 -0
  124. package/dist/agent-session/store/SessionStoreErrors.js +126 -0
  125. package/dist/agent-session/store/SessionStoreErrors.js.map +1 -0
  126. package/dist/agent-session/store/SessionStoreErrors.mjs +92 -0
  127. package/dist/agent-session/store/SessionStoreErrors.mjs.map +1 -0
  128. package/dist/agent-session/store/assertCreateTurnThreadDelta.d.ts +18 -0
  129. package/dist/agent-session/store/assertCreateTurnThreadDelta.d.ts.map +1 -0
  130. package/dist/agent-session/store/assertCreateTurnThreadDelta.js +67 -0
  131. package/dist/agent-session/store/assertCreateTurnThreadDelta.js.map +1 -0
  132. package/dist/agent-session/store/assertCreateTurnThreadDelta.mjs +42 -0
  133. package/dist/agent-session/store/assertCreateTurnThreadDelta.mjs.map +1 -0
  134. package/dist/core/InstructionBuilder.d.ts +71 -0
  135. package/dist/core/InstructionBuilder.d.ts.map +1 -0
  136. package/dist/core/InstructionBuilder.js +95 -0
  137. package/dist/core/InstructionBuilder.js.map +1 -0
  138. package/dist/core/InstructionBuilder.mjs +69 -0
  139. package/dist/core/InstructionBuilder.mjs.map +1 -0
  140. package/dist/core/capabilities/AgentCapability.d.ts +32 -0
  141. package/dist/core/capabilities/AgentCapability.d.ts.map +1 -0
  142. package/dist/core/capabilities/AgentCapability.js +19 -0
  143. package/dist/core/capabilities/AgentCapability.js.map +1 -0
  144. package/dist/core/capabilities/AgentCapability.mjs +1 -0
  145. package/dist/core/capabilities/AgentCapability.mjs.map +1 -0
  146. package/dist/core/capabilities/AgentContextProcessor.d.ts +30 -0
  147. package/dist/core/capabilities/AgentContextProcessor.d.ts.map +1 -0
  148. package/dist/core/capabilities/AgentContextProcessor.js +19 -0
  149. package/dist/core/capabilities/AgentContextProcessor.js.map +1 -0
  150. package/dist/core/capabilities/AgentContextProcessor.mjs +1 -0
  151. package/dist/core/capabilities/AgentContextProcessor.mjs.map +1 -0
  152. package/dist/core/capabilities/ToolResponseProcessor.d.ts +12 -0
  153. package/dist/core/capabilities/ToolResponseProcessor.d.ts.map +1 -0
  154. package/dist/core/capabilities/ToolResponseProcessor.js +19 -0
  155. package/dist/core/capabilities/ToolResponseProcessor.js.map +1 -0
  156. package/dist/core/capabilities/ToolResponseProcessor.mjs +1 -0
  157. package/dist/core/capabilities/ToolResponseProcessor.mjs.map +1 -0
  158. package/dist/core/capabilities/builtins/AskUserQuestion.d.ts +11 -0
  159. package/dist/core/capabilities/builtins/AskUserQuestion.d.ts.map +1 -0
  160. package/dist/core/capabilities/builtins/AskUserQuestion.js +90 -0
  161. package/dist/core/capabilities/builtins/AskUserQuestion.js.map +1 -0
  162. package/dist/core/capabilities/builtins/AskUserQuestion.mjs +64 -0
  163. package/dist/core/capabilities/builtins/AskUserQuestion.mjs.map +1 -0
  164. package/dist/core/capabilities/builtins/ContextCompaction.d.ts +23 -0
  165. package/dist/core/capabilities/builtins/ContextCompaction.d.ts.map +1 -0
  166. package/dist/core/capabilities/builtins/ContextCompaction.js +235 -0
  167. package/dist/core/capabilities/builtins/ContextCompaction.js.map +1 -0
  168. package/dist/core/capabilities/builtins/ContextCompaction.mjs +208 -0
  169. package/dist/core/capabilities/builtins/ContextCompaction.mjs.map +1 -0
  170. package/dist/core/capabilities/builtins/CurrentDateTime.d.ts +17 -0
  171. package/dist/core/capabilities/builtins/CurrentDateTime.d.ts.map +1 -0
  172. package/dist/core/capabilities/builtins/CurrentDateTime.js +75 -0
  173. package/dist/core/capabilities/builtins/CurrentDateTime.js.map +1 -0
  174. package/dist/core/capabilities/builtins/CurrentDateTime.mjs +47 -0
  175. package/dist/core/capabilities/builtins/CurrentDateTime.mjs.map +1 -0
  176. package/dist/core/capabilities/builtins/DynamicSubAgents.d.ts +39 -0
  177. package/dist/core/capabilities/builtins/DynamicSubAgents.d.ts.map +1 -0
  178. package/dist/core/capabilities/builtins/DynamicSubAgents.js +176 -0
  179. package/dist/core/capabilities/builtins/DynamicSubAgents.js.map +1 -0
  180. package/dist/core/capabilities/builtins/DynamicSubAgents.mjs +134 -0
  181. package/dist/core/capabilities/builtins/DynamicSubAgents.mjs.map +1 -0
  182. package/dist/core/capabilities/builtins/LargeToolResponse.d.ts +40 -0
  183. package/dist/core/capabilities/builtins/LargeToolResponse.d.ts.map +1 -0
  184. package/dist/core/capabilities/builtins/LargeToolResponse.js +225 -0
  185. package/dist/core/capabilities/builtins/LargeToolResponse.js.map +1 -0
  186. package/dist/core/capabilities/builtins/LargeToolResponse.mjs +186 -0
  187. package/dist/core/capabilities/builtins/LargeToolResponse.mjs.map +1 -0
  188. package/dist/core/capabilities/builtins/OpenUI.d.ts +31 -0
  189. package/dist/core/capabilities/builtins/OpenUI.d.ts.map +1 -0
  190. package/dist/core/capabilities/builtins/OpenUI.js +376 -0
  191. package/dist/core/capabilities/builtins/OpenUI.js.map +1 -0
  192. package/dist/core/capabilities/builtins/OpenUI.mjs +326 -0
  193. package/dist/core/capabilities/builtins/OpenUI.mjs.map +1 -0
  194. package/dist/core/errors.d.ts +33 -0
  195. package/dist/core/errors.d.ts.map +1 -0
  196. package/dist/core/errors.js +88 -0
  197. package/dist/core/errors.js.map +1 -0
  198. package/dist/core/errors.mjs +57 -0
  199. package/dist/core/errors.mjs.map +1 -0
  200. package/dist/core/events/PassthroughEvents.d.ts +30 -0
  201. package/dist/core/events/PassthroughEvents.d.ts.map +1 -0
  202. package/dist/core/events/PassthroughEvents.js +19 -0
  203. package/dist/core/events/PassthroughEvents.js.map +1 -0
  204. package/dist/core/events/PassthroughEvents.mjs +1 -0
  205. package/dist/core/events/PassthroughEvents.mjs.map +1 -0
  206. package/dist/core/events/schema.d.ts +1103 -0
  207. package/dist/core/events/schema.d.ts.map +1 -0
  208. package/dist/core/events/schema.js +337 -0
  209. package/dist/core/events/schema.js.map +1 -0
  210. package/dist/core/events/schema.mjs +283 -0
  211. package/dist/core/events/schema.mjs.map +1 -0
  212. package/dist/core/index.d.ts +60 -0
  213. package/dist/core/index.d.ts.map +1 -0
  214. package/dist/core/index.js +209 -0
  215. package/dist/core/index.js.map +1 -0
  216. package/dist/core/index.mjs +144 -0
  217. package/dist/core/index.mjs.map +1 -0
  218. package/dist/core/llm/ILLM.d.ts +15 -0
  219. package/dist/core/llm/ILLM.d.ts.map +1 -0
  220. package/dist/core/llm/ILLM.js +19 -0
  221. package/dist/core/llm/ILLM.js.map +1 -0
  222. package/dist/core/llm/ILLM.mjs +1 -0
  223. package/dist/core/llm/ILLM.mjs.map +1 -0
  224. package/dist/core/llm/LLMTypes.d.ts +369 -0
  225. package/dist/core/llm/LLMTypes.d.ts.map +1 -0
  226. package/dist/core/llm/LLMTypes.js +170 -0
  227. package/dist/core/llm/LLMTypes.js.map +1 -0
  228. package/dist/core/llm/LLMTypes.mjs +133 -0
  229. package/dist/core/llm/LLMTypes.mjs.map +1 -0
  230. package/dist/core/llm/VercelAILLM.d.ts +228 -0
  231. package/dist/core/llm/VercelAILLM.d.ts.map +1 -0
  232. package/dist/core/llm/VercelAILLM.js +1042 -0
  233. package/dist/core/llm/VercelAILLM.js.map +1 -0
  234. package/dist/core/llm/VercelAILLM.mjs +999 -0
  235. package/dist/core/llm/VercelAILLM.mjs.map +1 -0
  236. package/dist/core/llm/openaiSchemas.d.ts +190 -0
  237. package/dist/core/llm/openaiSchemas.d.ts.map +1 -0
  238. package/dist/core/llm/openaiSchemas.js +144 -0
  239. package/dist/core/llm/openaiSchemas.js.map +1 -0
  240. package/dist/core/llm/openaiSchemas.mjs +107 -0
  241. package/dist/core/llm/openaiSchemas.mjs.map +1 -0
  242. package/dist/core/llm/responseFormat.d.ts +25 -0
  243. package/dist/core/llm/responseFormat.d.ts.map +1 -0
  244. package/dist/core/llm/responseFormat.js +58 -0
  245. package/dist/core/llm/responseFormat.js.map +1 -0
  246. package/dist/core/llm/responseFormat.mjs +32 -0
  247. package/dist/core/llm/responseFormat.mjs.map +1 -0
  248. package/dist/core/llm/toOpenAIChatMessage.d.ts +11 -0
  249. package/dist/core/llm/toOpenAIChatMessage.d.ts.map +1 -0
  250. package/dist/core/llm/toOpenAIChatMessage.js +95 -0
  251. package/dist/core/llm/toOpenAIChatMessage.js.map +1 -0
  252. package/dist/core/llm/toOpenAIChatMessage.mjs +70 -0
  253. package/dist/core/llm/toOpenAIChatMessage.mjs.map +1 -0
  254. package/dist/core/llm/usage.d.ts +4 -0
  255. package/dist/core/llm/usage.d.ts.map +1 -0
  256. package/dist/core/llm/usage.js +52 -0
  257. package/dist/core/llm/usage.js.map +1 -0
  258. package/dist/core/llm/usage.mjs +26 -0
  259. package/dist/core/llm/usage.mjs.map +1 -0
  260. package/dist/core/mcp/ClientSideTool.d.ts +10 -0
  261. package/dist/core/mcp/ClientSideTool.d.ts.map +1 -0
  262. package/dist/core/mcp/ClientSideTool.js +56 -0
  263. package/dist/core/mcp/ClientSideTool.js.map +1 -0
  264. package/dist/core/mcp/ClientSideTool.mjs +31 -0
  265. package/dist/core/mcp/ClientSideTool.mjs.map +1 -0
  266. package/dist/core/mcp/IMCPServer.d.ts +78 -0
  267. package/dist/core/mcp/IMCPServer.d.ts.map +1 -0
  268. package/dist/core/mcp/IMCPServer.js +63 -0
  269. package/dist/core/mcp/IMCPServer.js.map +1 -0
  270. package/dist/core/mcp/IMCPServer.mjs +33 -0
  271. package/dist/core/mcp/IMCPServer.mjs.map +1 -0
  272. package/dist/core/mcp/LocalToolMCP.d.ts +39 -0
  273. package/dist/core/mcp/LocalToolMCP.d.ts.map +1 -0
  274. package/dist/core/mcp/LocalToolMCP.js +121 -0
  275. package/dist/core/mcp/LocalToolMCP.js.map +1 -0
  276. package/dist/core/mcp/LocalToolMCP.mjs +98 -0
  277. package/dist/core/mcp/LocalToolMCP.mjs.map +1 -0
  278. package/dist/core/mcp/RemoteMCP.d.ts +67 -0
  279. package/dist/core/mcp/RemoteMCP.d.ts.map +1 -0
  280. package/dist/core/mcp/RemoteMCP.js +244 -0
  281. package/dist/core/mcp/RemoteMCP.js.map +1 -0
  282. package/dist/core/mcp/RemoteMCP.mjs +222 -0
  283. package/dist/core/mcp/RemoteMCP.mjs.map +1 -0
  284. package/dist/core/mcp/ToolSelectorPolicy.d.ts +52 -0
  285. package/dist/core/mcp/ToolSelectorPolicy.d.ts.map +1 -0
  286. package/dist/core/mcp/ToolSelectorPolicy.js +108 -0
  287. package/dist/core/mcp/ToolSelectorPolicy.js.map +1 -0
  288. package/dist/core/mcp/ToolSelectorPolicy.mjs +90 -0
  289. package/dist/core/mcp/ToolSelectorPolicy.mjs.map +1 -0
  290. package/dist/core/mcp/ToolSet.d.ts +31 -0
  291. package/dist/core/mcp/ToolSet.d.ts.map +1 -0
  292. package/dist/core/mcp/ToolSet.js +119 -0
  293. package/dist/core/mcp/ToolSet.js.map +1 -0
  294. package/dist/core/mcp/ToolSet.mjs +98 -0
  295. package/dist/core/mcp/ToolSet.mjs.map +1 -0
  296. package/dist/core/mcp/convertMCPServers.d.ts +22 -0
  297. package/dist/core/mcp/convertMCPServers.d.ts.map +1 -0
  298. package/dist/core/mcp/convertMCPServers.js +89 -0
  299. package/dist/core/mcp/convertMCPServers.js.map +1 -0
  300. package/dist/core/mcp/convertMCPServers.mjs +64 -0
  301. package/dist/core/mcp/convertMCPServers.mjs.map +1 -0
  302. package/dist/core/mcp/executeToolCalls.d.ts +31 -0
  303. package/dist/core/mcp/executeToolCalls.d.ts.map +1 -0
  304. package/dist/core/mcp/executeToolCalls.js +168 -0
  305. package/dist/core/mcp/executeToolCalls.js.map +1 -0
  306. package/dist/core/mcp/executeToolCalls.mjs +149 -0
  307. package/dist/core/mcp/executeToolCalls.mjs.map +1 -0
  308. package/dist/core/mcp/pagination.d.ts +11 -0
  309. package/dist/core/mcp/pagination.d.ts.map +1 -0
  310. package/dist/core/mcp/pagination.js +49 -0
  311. package/dist/core/mcp/pagination.js.map +1 -0
  312. package/dist/core/mcp/pagination.mjs +24 -0
  313. package/dist/core/mcp/pagination.mjs.map +1 -0
  314. package/dist/core/mcp/remoteMcpClient.d.ts +36 -0
  315. package/dist/core/mcp/remoteMcpClient.d.ts.map +1 -0
  316. package/dist/core/mcp/remoteMcpClient.js +138 -0
  317. package/dist/core/mcp/remoteMcpClient.js.map +1 -0
  318. package/dist/core/mcp/remoteMcpClient.mjs +112 -0
  319. package/dist/core/mcp/remoteMcpClient.mjs.map +1 -0
  320. package/dist/core/mcp/toolNames.d.ts +6 -0
  321. package/dist/core/mcp/toolNames.d.ts.map +1 -0
  322. package/dist/core/mcp/toolNames.js +59 -0
  323. package/dist/core/mcp/toolNames.js.map +1 -0
  324. package/dist/core/mcp/toolNames.mjs +33 -0
  325. package/dist/core/mcp/toolNames.mjs.map +1 -0
  326. package/dist/core/mcp/toolSelectors.d.ts +28 -0
  327. package/dist/core/mcp/toolSelectors.d.ts.map +1 -0
  328. package/dist/core/mcp/toolSelectors.js +113 -0
  329. package/dist/core/mcp/toolSelectors.js.map +1 -0
  330. package/dist/core/mcp/toolSelectors.mjs +78 -0
  331. package/dist/core/mcp/toolSelectors.mjs.map +1 -0
  332. package/dist/core/runtime/AgentDefinition.d.ts +23 -0
  333. package/dist/core/runtime/AgentDefinition.d.ts.map +1 -0
  334. package/dist/core/runtime/AgentDefinition.js +19 -0
  335. package/dist/core/runtime/AgentDefinition.js.map +1 -0
  336. package/dist/core/runtime/AgentDefinition.mjs +1 -0
  337. package/dist/core/runtime/AgentDefinition.mjs.map +1 -0
  338. package/dist/core/runtime/AgentThread.d.ts +64 -0
  339. package/dist/core/runtime/AgentThread.d.ts.map +1 -0
  340. package/dist/core/runtime/AgentThread.js +1065 -0
  341. package/dist/core/runtime/AgentThread.js.map +1 -0
  342. package/dist/core/runtime/AgentThread.mjs +1062 -0
  343. package/dist/core/runtime/AgentThread.mjs.map +1 -0
  344. package/dist/core/runtime/AgentThread.types.d.ts +123 -0
  345. package/dist/core/runtime/AgentThread.types.d.ts.map +1 -0
  346. package/dist/core/runtime/AgentThread.types.js +46 -0
  347. package/dist/core/runtime/AgentThread.types.js.map +1 -0
  348. package/dist/core/runtime/AgentThread.types.mjs +20 -0
  349. package/dist/core/runtime/AgentThread.types.mjs.map +1 -0
  350. package/dist/core/runtime/AgentThreadOrchestrator.d.ts +35 -0
  351. package/dist/core/runtime/AgentThreadOrchestrator.d.ts.map +1 -0
  352. package/dist/core/runtime/AgentThreadOrchestrator.js +433 -0
  353. package/dist/core/runtime/AgentThreadOrchestrator.js.map +1 -0
  354. package/dist/core/runtime/AgentThreadOrchestrator.mjs +418 -0
  355. package/dist/core/runtime/AgentThreadOrchestrator.mjs.map +1 -0
  356. package/dist/core/runtime/CreateDynamicSubAgentThread.d.ts +11 -0
  357. package/dist/core/runtime/CreateDynamicSubAgentThread.d.ts.map +1 -0
  358. package/dist/core/runtime/CreateDynamicSubAgentThread.js +19 -0
  359. package/dist/core/runtime/CreateDynamicSubAgentThread.js.map +1 -0
  360. package/dist/core/runtime/CreateDynamicSubAgentThread.mjs +1 -0
  361. package/dist/core/runtime/CreateDynamicSubAgentThread.mjs.map +1 -0
  362. package/dist/core/runtime/DeferredTool.d.ts +34 -0
  363. package/dist/core/runtime/DeferredTool.d.ts.map +1 -0
  364. package/dist/core/runtime/DeferredTool.js +321 -0
  365. package/dist/core/runtime/DeferredTool.js.map +1 -0
  366. package/dist/core/runtime/DeferredTool.mjs +287 -0
  367. package/dist/core/runtime/DeferredTool.mjs.map +1 -0
  368. package/dist/core/runtime/OpenToolCallCloser.d.ts +21 -0
  369. package/dist/core/runtime/OpenToolCallCloser.d.ts.map +1 -0
  370. package/dist/core/runtime/OpenToolCallCloser.js +92 -0
  371. package/dist/core/runtime/OpenToolCallCloser.js.map +1 -0
  372. package/dist/core/runtime/OpenToolCallCloser.mjs +66 -0
  373. package/dist/core/runtime/OpenToolCallCloser.mjs.map +1 -0
  374. package/dist/core/runtime/UserInputMessage.d.ts +16 -0
  375. package/dist/core/runtime/UserInputMessage.d.ts.map +1 -0
  376. package/dist/core/runtime/UserInputMessage.js +183 -0
  377. package/dist/core/runtime/UserInputMessage.js.map +1 -0
  378. package/dist/core/runtime/UserInputMessage.mjs +157 -0
  379. package/dist/core/runtime/UserInputMessage.mjs.map +1 -0
  380. package/dist/core/runtime/contextUsage.d.ts +17 -0
  381. package/dist/core/runtime/contextUsage.d.ts.map +1 -0
  382. package/dist/core/runtime/contextUsage.js +56 -0
  383. package/dist/core/runtime/contextUsage.js.map +1 -0
  384. package/dist/core/runtime/contextUsage.mjs +28 -0
  385. package/dist/core/runtime/contextUsage.mjs.map +1 -0
  386. package/dist/core/runtime/contextUtils.d.ts +30 -0
  387. package/dist/core/runtime/contextUtils.d.ts.map +1 -0
  388. package/dist/core/runtime/contextUtils.js +198 -0
  389. package/dist/core/runtime/contextUtils.js.map +1 -0
  390. package/dist/core/runtime/contextUtils.mjs +148 -0
  391. package/dist/core/runtime/contextUtils.mjs.map +1 -0
  392. package/dist/core/runtime/metrics.d.ts +22 -0
  393. package/dist/core/runtime/metrics.d.ts.map +1 -0
  394. package/dist/core/runtime/metrics.js +89 -0
  395. package/dist/core/runtime/metrics.js.map +1 -0
  396. package/dist/core/runtime/metrics.mjs +61 -0
  397. package/dist/core/runtime/metrics.mjs.map +1 -0
  398. package/dist/core/sandbox/Sandbox.d.ts +121 -0
  399. package/dist/core/sandbox/Sandbox.d.ts.map +1 -0
  400. package/dist/core/sandbox/Sandbox.js +572 -0
  401. package/dist/core/sandbox/Sandbox.js.map +1 -0
  402. package/dist/core/sandbox/Sandbox.mjs +536 -0
  403. package/dist/core/sandbox/Sandbox.mjs.map +1 -0
  404. package/dist/core/sandbox/SandboxErrors.d.ts +30 -0
  405. package/dist/core/sandbox/SandboxErrors.d.ts.map +1 -0
  406. package/dist/core/sandbox/SandboxErrors.js +102 -0
  407. package/dist/core/sandbox/SandboxErrors.js.map +1 -0
  408. package/dist/core/sandbox/SandboxErrors.mjs +71 -0
  409. package/dist/core/sandbox/SandboxErrors.mjs.map +1 -0
  410. package/dist/core/sandbox/SandboxNatsBridge.d.ts +33 -0
  411. package/dist/core/sandbox/SandboxNatsBridge.d.ts.map +1 -0
  412. package/dist/core/sandbox/SandboxNatsBridge.js +222 -0
  413. package/dist/core/sandbox/SandboxNatsBridge.js.map +1 -0
  414. package/dist/core/sandbox/SandboxNatsBridge.mjs +201 -0
  415. package/dist/core/sandbox/SandboxNatsBridge.mjs.map +1 -0
  416. package/dist/core/sandbox/constants.d.ts +10 -0
  417. package/dist/core/sandbox/constants.d.ts.map +1 -0
  418. package/dist/core/sandbox/constants.js +37 -0
  419. package/dist/core/sandbox/constants.js.map +1 -0
  420. package/dist/core/sandbox/constants.mjs +10 -0
  421. package/dist/core/sandbox/constants.mjs.map +1 -0
  422. package/dist/core/sandbox/provider/DaytonaProvider.d.ts +80 -0
  423. package/dist/core/sandbox/provider/DaytonaProvider.d.ts.map +1 -0
  424. package/dist/core/sandbox/provider/DaytonaProvider.js +346 -0
  425. package/dist/core/sandbox/provider/DaytonaProvider.js.map +1 -0
  426. package/dist/core/sandbox/provider/DaytonaProvider.mjs +326 -0
  427. package/dist/core/sandbox/provider/DaytonaProvider.mjs.map +1 -0
  428. package/dist/core/sandbox/provider/Provider.d.ts +83 -0
  429. package/dist/core/sandbox/provider/Provider.d.ts.map +1 -0
  430. package/dist/core/sandbox/provider/Provider.js +43 -0
  431. package/dist/core/sandbox/provider/Provider.js.map +1 -0
  432. package/dist/core/sandbox/provider/Provider.mjs +17 -0
  433. package/dist/core/sandbox/provider/Provider.mjs.map +1 -0
  434. package/dist/core/sandbox/provider/TFYSandboxProvider.d.ts +41 -0
  435. package/dist/core/sandbox/provider/TFYSandboxProvider.d.ts.map +1 -0
  436. package/dist/core/sandbox/provider/TFYSandboxProvider.js +180 -0
  437. package/dist/core/sandbox/provider/TFYSandboxProvider.js.map +1 -0
  438. package/dist/core/sandbox/provider/TFYSandboxProvider.mjs +147 -0
  439. package/dist/core/sandbox/provider/TFYSandboxProvider.mjs.map +1 -0
  440. package/dist/core/sandbox/sandboxImage.d.ts +6 -0
  441. package/dist/core/sandbox/sandboxImage.d.ts.map +1 -0
  442. package/dist/core/sandbox/sandboxImage.js +31 -0
  443. package/dist/core/sandbox/sandboxImage.js.map +1 -0
  444. package/dist/core/sandbox/sandboxImage.mjs +6 -0
  445. package/dist/core/sandbox/sandboxImage.mjs.map +1 -0
  446. package/dist/core/sandbox/sandboxScripts.gen.d.ts +5 -0
  447. package/dist/core/sandbox/sandboxScripts.gen.d.ts.map +1 -0
  448. package/dist/core/sandbox/sandboxScripts.gen.js +343 -0
  449. package/dist/core/sandbox/sandboxScripts.gen.js.map +1 -0
  450. package/dist/core/sandbox/sandboxScripts.gen.mjs +318 -0
  451. package/dist/core/sandbox/sandboxScripts.gen.mjs.map +1 -0
  452. package/dist/core/sandbox/skills/ISkillMounter.d.ts +7 -0
  453. package/dist/core/sandbox/skills/ISkillMounter.d.ts.map +1 -0
  454. package/dist/core/sandbox/skills/ISkillMounter.js +19 -0
  455. package/dist/core/sandbox/skills/ISkillMounter.js.map +1 -0
  456. package/dist/core/sandbox/skills/ISkillMounter.mjs +1 -0
  457. package/dist/core/sandbox/skills/ISkillMounter.mjs.map +1 -0
  458. package/dist/core/sandbox/skills/SkillMounter.d.ts +17 -0
  459. package/dist/core/sandbox/skills/SkillMounter.d.ts.map +1 -0
  460. package/dist/core/sandbox/skills/SkillMounter.js +73 -0
  461. package/dist/core/sandbox/skills/SkillMounter.js.map +1 -0
  462. package/dist/core/sandbox/skills/SkillMounter.mjs +48 -0
  463. package/dist/core/sandbox/skills/SkillMounter.mjs.map +1 -0
  464. package/dist/core/sandbox/skills/constants.d.ts +10 -0
  465. package/dist/core/sandbox/skills/constants.d.ts.map +1 -0
  466. package/dist/core/sandbox/skills/constants.js +56 -0
  467. package/dist/core/sandbox/skills/constants.js.map +1 -0
  468. package/dist/core/sandbox/skills/constants.mjs +28 -0
  469. package/dist/core/sandbox/skills/constants.mjs.map +1 -0
  470. package/dist/core/sandbox/skills/index.d.ts +5 -0
  471. package/dist/core/sandbox/skills/index.d.ts.map +1 -0
  472. package/dist/core/sandbox/skills/index.js +40 -0
  473. package/dist/core/sandbox/skills/index.js.map +1 -0
  474. package/dist/core/sandbox/skills/index.mjs +11 -0
  475. package/dist/core/sandbox/skills/index.mjs.map +1 -0
  476. package/dist/core/tracing/AgentTracing.d.ts +38 -0
  477. package/dist/core/tracing/AgentTracing.d.ts.map +1 -0
  478. package/dist/core/tracing/AgentTracing.js +19 -0
  479. package/dist/core/tracing/AgentTracing.js.map +1 -0
  480. package/dist/core/tracing/AgentTracing.mjs +1 -0
  481. package/dist/core/tracing/AgentTracing.mjs.map +1 -0
  482. package/dist/core/tracing/NoopAgentTracing.d.ts +3 -0
  483. package/dist/core/tracing/NoopAgentTracing.d.ts.map +1 -0
  484. package/dist/core/tracing/NoopAgentTracing.js +79 -0
  485. package/dist/core/tracing/NoopAgentTracing.js.map +1 -0
  486. package/dist/core/tracing/NoopAgentTracing.mjs +54 -0
  487. package/dist/core/tracing/NoopAgentTracing.mjs.map +1 -0
  488. package/dist/core/util/abort.d.ts +2 -0
  489. package/dist/core/util/abort.d.ts.map +1 -0
  490. package/dist/core/util/abort.js +38 -0
  491. package/dist/core/util/abort.js.map +1 -0
  492. package/dist/core/util/abort.mjs +13 -0
  493. package/dist/core/util/abort.mjs.map +1 -0
  494. package/dist/core/util/errorLogFields.d.ts +6 -0
  495. package/dist/core/util/errorLogFields.d.ts.map +1 -0
  496. package/dist/core/util/errorLogFields.js +36 -0
  497. package/dist/core/util/errorLogFields.js.map +1 -0
  498. package/dist/core/util/errorLogFields.mjs +11 -0
  499. package/dist/core/util/errorLogFields.mjs.map +1 -0
  500. package/dist/core/util/promiseUtils.d.ts +7 -0
  501. package/dist/core/util/promiseUtils.d.ts.map +1 -0
  502. package/dist/core/util/promiseUtils.js +82 -0
  503. package/dist/core/util/promiseUtils.js.map +1 -0
  504. package/dist/core/util/promiseUtils.mjs +55 -0
  505. package/dist/core/util/promiseUtils.mjs.map +1 -0
  506. package/dist/index.d.ts +7 -0
  507. package/dist/index.d.ts.map +1 -0
  508. package/dist/index.js +44 -0
  509. package/dist/index.js.map +1 -0
  510. package/dist/index.mjs +8 -0
  511. package/dist/index.mjs.map +1 -0
  512. package/dist/package.json +3 -0
  513. package/dist/request-reply/client.d.ts +21 -0
  514. package/dist/request-reply/client.d.ts.map +1 -0
  515. package/dist/request-reply/client.js +92 -0
  516. package/dist/request-reply/client.js.map +1 -0
  517. package/dist/request-reply/client.mjs +67 -0
  518. package/dist/request-reply/client.mjs.map +1 -0
  519. package/dist/request-reply/errors.d.ts +23 -0
  520. package/dist/request-reply/errors.d.ts.map +1 -0
  521. package/dist/request-reply/errors.js +66 -0
  522. package/dist/request-reply/errors.js.map +1 -0
  523. package/dist/request-reply/errors.mjs +39 -0
  524. package/dist/request-reply/errors.mjs.map +1 -0
  525. package/dist/request-reply/executor.d.ts +70 -0
  526. package/dist/request-reply/executor.d.ts.map +1 -0
  527. package/dist/request-reply/executor.js +267 -0
  528. package/dist/request-reply/executor.js.map +1 -0
  529. package/dist/request-reply/executor.mjs +232 -0
  530. package/dist/request-reply/executor.mjs.map +1 -0
  531. package/dist/request-reply/index.d.ts +16 -0
  532. package/dist/request-reply/index.d.ts.map +1 -0
  533. package/dist/request-reply/index.js +47 -0
  534. package/dist/request-reply/index.js.map +1 -0
  535. package/dist/request-reply/index.mjs +16 -0
  536. package/dist/request-reply/index.mjs.map +1 -0
  537. package/dist/request-reply/router.d.ts +20 -0
  538. package/dist/request-reply/router.d.ts.map +1 -0
  539. package/dist/request-reply/router.js +55 -0
  540. package/dist/request-reply/router.js.map +1 -0
  541. package/dist/request-reply/router.mjs +30 -0
  542. package/dist/request-reply/router.mjs.map +1 -0
  543. package/dist/request-reply/types.d.ts +25 -0
  544. package/dist/request-reply/types.d.ts.map +1 -0
  545. package/dist/request-reply/types.js +54 -0
  546. package/dist/request-reply/types.js.map +1 -0
  547. package/dist/request-reply/types.mjs +28 -0
  548. package/dist/request-reply/types.mjs.map +1 -0
  549. package/dist/request-reply/utils.d.ts +9 -0
  550. package/dist/request-reply/utils.d.ts.map +1 -0
  551. package/dist/request-reply/utils.js +51 -0
  552. package/dist/request-reply/utils.js.map +1 -0
  553. package/dist/request-reply/utils.mjs +22 -0
  554. package/dist/request-reply/utils.mjs.map +1 -0
  555. package/package.json +127 -6
  556. package/README.md +0 -4
  557. package/index.js +0 -1
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/agent-session/schemas/turn.ts
21
+ var turn_exports = {};
22
+ __export(turn_exports, {
23
+ CancellationReason: () => CancellationReason,
24
+ CreateTurnRequestSchema: () => CreateTurnRequestSchema,
25
+ TurnInputItemSchema: () => TurnInputItemSchema,
26
+ TurnMetricsSchema: () => TurnMetricsSchema,
27
+ TurnSchema: () => TurnSchema,
28
+ TurnStateCancelledReasonSchema: () => TurnStateCancelledReasonSchema,
29
+ TurnStateCancelledSchema: () => TurnStateCancelledSchema,
30
+ TurnStateDoneSchema: () => TurnStateDoneSchema,
31
+ TurnStateErrorSchema: () => TurnStateErrorSchema,
32
+ TurnStateRunningSchema: () => TurnStateRunningSchema,
33
+ TurnStateSchema: () => TurnStateSchema
34
+ });
35
+ module.exports = __toCommonJS(turn_exports);
36
+ var import_zod_openapi = require("@hono/zod-openapi");
37
+ var import_schema = require("../../core/events/schema.js");
38
+ var CancellationReason = /* @__PURE__ */ ((CancellationReason2) => {
39
+ CancellationReason2["ServerExecutionTimeout"] = "server-execution-timeout";
40
+ CancellationReason2["ClientCancelled"] = "client-cancelled";
41
+ CancellationReason2["CancelledForNextTurn"] = "cancelled-for-next-turn";
42
+ CancellationReason2["Abandoned"] = "abandoned";
43
+ return CancellationReason2;
44
+ })(CancellationReason || {});
45
+ var TurnStateRunningSchema = import_zod_openapi.z.object({
46
+ status: import_zod_openapi.z.literal("running").describe("Turn is still executing.")
47
+ }).openapi("TurnStateRunning");
48
+ var TurnStateCancelledReasonSchema = import_zod_openapi.z.enum(CancellationReason).describe("Reason for the cancellation.").openapi("TurnStateCancelledReason");
49
+ var TurnMetricsSchema = import_zod_openapi.z.object({
50
+ total_input_tokens: import_zod_openapi.z.number().int().nonnegative().optional().describe("Total input tokens across model calls in this turn."),
51
+ total_output_tokens: import_zod_openapi.z.number().int().nonnegative().optional().describe("Total output tokens across model calls in this turn."),
52
+ total_tokens: import_zod_openapi.z.number().int().nonnegative().optional().describe("Total tokens (input + output) across model calls in this turn."),
53
+ total_cache_read_tokens: import_zod_openapi.z.number().int().nonnegative().optional().describe("Total cache-read tokens across model calls in this turn."),
54
+ total_cache_write_tokens: import_zod_openapi.z.number().int().nonnegative().optional().describe("Total cache-write tokens across model calls in this turn."),
55
+ total_reasoning_tokens: import_zod_openapi.z.number().int().nonnegative().optional().describe("Total reasoning tokens across model calls in this turn."),
56
+ total_cost_in_usd: import_zod_openapi.z.number().nonnegative().optional().describe("Estimated total cost in USD for this turn.")
57
+ }).openapi("TurnMetrics");
58
+ var TurnStateCancelledSchema = import_zod_openapi.z.object({
59
+ status: import_zod_openapi.z.literal("cancelled").describe("Turn was cancelled before completion."),
60
+ reason: TurnStateCancelledReasonSchema,
61
+ completed_at: import_zod_openapi.z.string().describe("ISO 8601 time when cancellation completed."),
62
+ metrics: TurnMetricsSchema.optional().describe("Optional billable aggregate for work done before cancel.")
63
+ }).openapi("TurnStateCancelled");
64
+ var TurnStateErrorSchema = import_zod_openapi.z.object({
65
+ status: import_zod_openapi.z.literal("error").describe("Turn ended with an error."),
66
+ message: import_zod_openapi.z.string().describe("Human-readable error message."),
67
+ completed_at: import_zod_openapi.z.string().describe("ISO 8601 time when the error state was recorded."),
68
+ metrics: TurnMetricsSchema.optional().describe("Optional billable aggregate for work done before the error.")
69
+ }).openapi("TurnStateError");
70
+ var TurnStateDoneSchema = import_zod_openapi.z.object({
71
+ status: import_zod_openapi.z.literal("done").describe("Turn finished (possibly paused for required actions)."),
72
+ output: import_zod_openapi.z.union([import_schema.ModelMessageEventSchema, import_zod_openapi.z.null()]).describe("Final `model.message` for the turn, or null when the turn ended paused without a final message."),
73
+ required_actions: import_zod_openapi.z.array(import_schema.ActionRequiredEventSchema).describe(
74
+ "Pending actions (`tool.approval_required`, `tool.response_required`, `mcp.auth_required`); empty when none."
75
+ ),
76
+ completed_at: import_zod_openapi.z.string().describe("ISO 8601 time when the turn reached a terminal state."),
77
+ metrics: TurnMetricsSchema.optional().describe("Optional billable aggregate for the whole turn.")
78
+ }).openapi("TurnStateDone");
79
+ var TurnStateSchema = import_zod_openapi.z.discriminatedUnion("status", [
80
+ TurnStateRunningSchema,
81
+ TurnStateDoneSchema,
82
+ TurnStateCancelledSchema,
83
+ TurnStateErrorSchema
84
+ ]).openapi("TurnState");
85
+ var TurnInputItemSchema = import_zod_openapi.z.discriminatedUnion("type", [
86
+ import_schema.AgentInputUserMessageSchema,
87
+ import_schema.UserToolApprovalMessageSchema,
88
+ import_schema.UserToolResponseMessageSchema
89
+ ]).openapi("TurnInputItem");
90
+ var TurnSchema = import_zod_openapi.z.object({
91
+ id: import_zod_openapi.z.string().describe("Unique turn id."),
92
+ session_id: import_zod_openapi.z.string().describe("Session that owns this turn."),
93
+ previous_turn_id: import_zod_openapi.z.string().nullable().describe("Prior turn this turn chains from; null for a root turn."),
94
+ input: import_zod_openapi.z.array(TurnInputItemSchema).optional().describe("Input items supplied when the turn was created."),
95
+ state: TurnStateSchema,
96
+ created_at: import_zod_openapi.z.string().describe("ISO 8601 creation timestamp.")
97
+ }).openapi("Turn");
98
+ var CreateTurnRequestSchema = import_zod_openapi.z.object({
99
+ input: import_zod_openapi.z.array(TurnInputItemSchema).optional().describe(
100
+ "Turn input items: user messages and/or approval/tool-response resumes. Do not mix user messages with approval or tool-response items."
101
+ ),
102
+ previous_turn_id: import_zod_openapi.z.union([import_zod_openapi.z.literal("auto"), import_zod_openapi.z.literal("none"), import_zod_openapi.z.string().min(1)]).optional().default("auto").describe(`Defaults to 'auto' (chain to session last turn). Use 'none' for a new root turn.`).openapi("PreviousTurnIdInput"),
103
+ stream: import_zod_openapi.z.boolean().optional().default(true).describe("When true (default), stream turn events as SSE. When false, return the running turn immediately.")
104
+ }).superRefine((data, ctx) => {
105
+ if (!data.input) return;
106
+ const hasUser = data.input.some((msg) => "type" in msg && msg.type === "user.message");
107
+ const hasApprovalOrToolResponse = data.input.some(
108
+ (msg) => "type" in msg && (msg.type === "user.tool_approval" || msg.type === "user.tool_response")
109
+ );
110
+ if (hasUser && hasApprovalOrToolResponse) {
111
+ ctx.addIssue({
112
+ code: "custom",
113
+ message: "input must not mix user messages with approval decisions or client-side tool responses"
114
+ });
115
+ }
116
+ }).openapi("CreateTurnRequest");
117
+ // Annotate the CommonJS export names for ESM import in node:
118
+ 0 && (module.exports = {
119
+ CancellationReason,
120
+ CreateTurnRequestSchema,
121
+ TurnInputItemSchema,
122
+ TurnMetricsSchema,
123
+ TurnSchema,
124
+ TurnStateCancelledReasonSchema,
125
+ TurnStateCancelledSchema,
126
+ TurnStateDoneSchema,
127
+ TurnStateErrorSchema,
128
+ TurnStateRunningSchema,
129
+ TurnStateSchema
130
+ });
131
+ //# sourceMappingURL=turn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/agent-session/schemas/turn.ts"],"sourcesContent":["/** Turn product schemas: turn state, input items, and create-turn request. */\nimport { z } from '@hono/zod-openapi';\nimport {\n ActionRequiredEventSchema,\n AgentInputUserMessageSchema,\n ModelMessageEventSchema,\n UserToolApprovalMessageSchema,\n UserToolResponseMessageSchema,\n} from '../../core/events/schema';\n\nexport enum CancellationReason {\n // AbortController.abort() reason for the max-execution timer.\n ServerExecutionTimeout = 'server-execution-timeout',\n // Emitted when the client cancels the run.\n ClientCancelled = 'client-cancelled',\n // Prior turn aborted because the client started a new turn.\n CancelledForNextTurn = 'cancelled-for-next-turn',\n // Process shutting down (SIGTERM/SIGINT).\n Abandoned = 'abandoned',\n}\n\nexport const TurnStateRunningSchema = z\n .object({\n status: z.literal('running').describe('Turn is still executing.'),\n })\n .openapi('TurnStateRunning');\n\nexport const TurnStateCancelledReasonSchema = z\n .enum(CancellationReason)\n .describe('Reason for the cancellation.')\n .openapi('TurnStateCancelledReason');\n\n/** Billable aggregate for one turn. */\nexport const TurnMetricsSchema = z\n .object({\n total_input_tokens: z\n .number()\n .int()\n .nonnegative()\n .optional()\n .describe('Total input tokens across model calls in this turn.'),\n total_output_tokens: z\n .number()\n .int()\n .nonnegative()\n .optional()\n .describe('Total output tokens across model calls in this turn.'),\n total_tokens: z\n .number()\n .int()\n .nonnegative()\n .optional()\n .describe('Total tokens (input + output) across model calls in this turn.'),\n total_cache_read_tokens: z\n .number()\n .int()\n .nonnegative()\n .optional()\n .describe('Total cache-read tokens across model calls in this turn.'),\n total_cache_write_tokens: z\n .number()\n .int()\n .nonnegative()\n .optional()\n .describe('Total cache-write tokens across model calls in this turn.'),\n total_reasoning_tokens: z\n .number()\n .int()\n .nonnegative()\n .optional()\n .describe('Total reasoning tokens across model calls in this turn.'),\n total_cost_in_usd: z.number().nonnegative().optional().describe('Estimated total cost in USD for this turn.'),\n })\n .openapi('TurnMetrics');\n\nexport const TurnStateCancelledSchema = z\n .object({\n status: z.literal('cancelled').describe('Turn was cancelled before completion.'),\n reason: TurnStateCancelledReasonSchema,\n completed_at: z.string().describe('ISO 8601 time when cancellation completed.'),\n metrics: TurnMetricsSchema.optional().describe('Optional billable aggregate for work done before cancel.'),\n })\n .openapi('TurnStateCancelled');\n\nexport const TurnStateErrorSchema = z\n .object({\n status: z.literal('error').describe('Turn ended with an error.'),\n message: z.string().describe('Human-readable error message.'),\n completed_at: z.string().describe('ISO 8601 time when the error state was recorded.'),\n metrics: TurnMetricsSchema.optional().describe('Optional billable aggregate for work done before the error.'),\n })\n .openapi('TurnStateError');\n\nexport const TurnStateDoneSchema = z\n .object({\n status: z.literal('done').describe('Turn finished (possibly paused for required actions).'),\n output: z\n .union([ModelMessageEventSchema, z.null()])\n .describe('Final `model.message` for the turn, or null when the turn ended paused without a final message.'),\n required_actions: z\n .array(ActionRequiredEventSchema)\n .describe(\n 'Pending actions (`tool.approval_required`, `tool.response_required`, `mcp.auth_required`); empty when none.',\n ),\n completed_at: z.string().describe('ISO 8601 time when the turn reached a terminal state.'),\n metrics: TurnMetricsSchema.optional().describe('Optional billable aggregate for the whole turn.'),\n })\n .openapi('TurnStateDone');\n\nexport const TurnStateSchema = z\n .discriminatedUnion('status', [\n TurnStateRunningSchema,\n TurnStateDoneSchema,\n TurnStateCancelledSchema,\n TurnStateErrorSchema,\n ])\n .openapi('TurnState');\n\nexport const TurnInputItemSchema = z\n .discriminatedUnion('type', [\n AgentInputUserMessageSchema,\n UserToolApprovalMessageSchema,\n UserToolResponseMessageSchema,\n ])\n .openapi('TurnInputItem');\n\nexport const TurnSchema = z\n .object({\n id: z.string().describe('Unique turn id.'),\n session_id: z.string().describe('Session that owns this turn.'),\n previous_turn_id: z.string().nullable().describe('Prior turn this turn chains from; null for a root turn.'),\n input: z.array(TurnInputItemSchema).optional().describe('Input items supplied when the turn was created.'),\n state: TurnStateSchema,\n created_at: z.string().describe('ISO 8601 creation timestamp.'),\n })\n .openapi('Turn');\n\n/**\n * Wire type for the previous_turn_id field. Includes the default so the schema\n * can be referenced directly without re-wrapping (re-wrapping strips the $ref).\n */\nexport const CreateTurnRequestSchema = z\n .object({\n input: z\n .array(TurnInputItemSchema)\n .optional()\n .describe(\n 'Turn input items: user messages and/or approval/tool-response resumes. Do not mix user messages with approval or tool-response items.',\n ),\n previous_turn_id: z\n .union([z.literal('auto'), z.literal('none'), z.string().min(1)])\n .optional()\n .default('auto')\n .describe(`Defaults to 'auto' (chain to session last turn). Use 'none' for a new root turn.`)\n .openapi('PreviousTurnIdInput'),\n stream: z\n .boolean()\n .optional()\n .default(true)\n .describe('When true (default), stream turn events as SSE. When false, return the running turn immediately.'),\n })\n .superRefine((data, ctx) => {\n if (!data.input) return;\n const hasUser = data.input.some(msg => 'type' in msg && msg.type === 'user.message');\n const hasApprovalOrToolResponse = data.input.some(\n msg => 'type' in msg && (msg.type === 'user.tool_approval' || msg.type === 'user.tool_response'),\n );\n if (hasUser && hasApprovalOrToolResponse) {\n ctx.addIssue({\n code: 'custom',\n message: 'input must not mix user messages with approval decisions or client-side tool responses',\n });\n }\n })\n .openapi('CreateTurnRequest');\n\nexport type Turn = z.infer<typeof TurnSchema>;\nexport type TurnInputItem = z.infer<typeof TurnInputItemSchema>;\nexport type TurnState = z.infer<typeof TurnStateSchema>;\nexport type TerminalTurnState = Exclude<TurnState, { status: 'running' }>;\nexport type TurnMetrics = z.infer<typeof TurnMetricsSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,yBAAkB;AAClB,oBAMO;AAEA,IAAK,qBAAL,kBAAKA,wBAAL;AAEL,EAAAA,oBAAA,4BAAyB;AAEzB,EAAAA,oBAAA,qBAAkB;AAElB,EAAAA,oBAAA,0BAAuB;AAEvB,EAAAA,oBAAA,eAAY;AARF,SAAAA;AAAA,GAAA;AAWL,IAAM,yBAAyB,qBACnC,OAAO;AAAA,EACN,QAAQ,qBAAE,QAAQ,SAAS,EAAE,SAAS,0BAA0B;AAClE,CAAC,EACA,QAAQ,kBAAkB;AAEtB,IAAM,iCAAiC,qBAC3C,KAAK,kBAAkB,EACvB,SAAS,8BAA8B,EACvC,QAAQ,0BAA0B;AAG9B,IAAM,oBAAoB,qBAC9B,OAAO;AAAA,EACN,oBAAoB,qBACjB,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,SAAS,EACT,SAAS,qDAAqD;AAAA,EACjE,qBAAqB,qBAClB,OAAO,EACP,IAAI,EACJ,YAAY,EACZ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AAI,CAAC,KAAK,MAAO;AACjB,QAAM,UAAU,KAAK,MAAM,KAAK,SAAO,UAAU,OAAO,IAAI,SAAS,cAAc;AACnF,QAAM,4BAA4B,KAAK,MAAM;AAAA,IAC3C,SAAO,UAAU,QAAQ,IAAI,SAAS,wBAAwB,IAAI,SAAS;AAAA,EAC7E;AACA,MAAI,WAAW,2BAA2B;AACxC,QAAI,SAAS;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AACF,CAAC,EACA,QAAQ,mBAAmB;","names":["CancellationReason"]}
@@ -0,0 +1,102 @@
1
+ // src/agent-session/schemas/turn.ts
2
+ import { z } from "@hono/zod-openapi";
3
+ import {
4
+ ActionRequiredEventSchema,
5
+ AgentInputUserMessageSchema,
6
+ ModelMessageEventSchema,
7
+ UserToolApprovalMessageSchema,
8
+ UserToolResponseMessageSchema
9
+ } from "../../core/events/schema.mjs";
10
+ var CancellationReason = /* @__PURE__ */ ((CancellationReason2) => {
11
+ CancellationReason2["ServerExecutionTimeout"] = "server-execution-timeout";
12
+ CancellationReason2["ClientCancelled"] = "client-cancelled";
13
+ CancellationReason2["CancelledForNextTurn"] = "cancelled-for-next-turn";
14
+ CancellationReason2["Abandoned"] = "abandoned";
15
+ return CancellationReason2;
16
+ })(CancellationReason || {});
17
+ var TurnStateRunningSchema = z.object({
18
+ status: z.literal("running").describe("Turn is still executing.")
19
+ }).openapi("TurnStateRunning");
20
+ var TurnStateCancelledReasonSchema = z.enum(CancellationReason).describe("Reason for the cancellation.").openapi("TurnStateCancelledReason");
21
+ var TurnMetricsSchema = z.object({
22
+ total_input_tokens: z.number().int().nonnegative().optional().describe("Total input tokens across model calls in this turn."),
23
+ total_output_tokens: z.number().int().nonnegative().optional().describe("Total output tokens across model calls in this turn."),
24
+ total_tokens: z.number().int().nonnegative().optional().describe("Total tokens (input + output) across model calls in this turn."),
25
+ total_cache_read_tokens: z.number().int().nonnegative().optional().describe("Total cache-read tokens across model calls in this turn."),
26
+ total_cache_write_tokens: z.number().int().nonnegative().optional().describe("Total cache-write tokens across model calls in this turn."),
27
+ total_reasoning_tokens: z.number().int().nonnegative().optional().describe("Total reasoning tokens across model calls in this turn."),
28
+ total_cost_in_usd: z.number().nonnegative().optional().describe("Estimated total cost in USD for this turn.")
29
+ }).openapi("TurnMetrics");
30
+ var TurnStateCancelledSchema = z.object({
31
+ status: z.literal("cancelled").describe("Turn was cancelled before completion."),
32
+ reason: TurnStateCancelledReasonSchema,
33
+ completed_at: z.string().describe("ISO 8601 time when cancellation completed."),
34
+ metrics: TurnMetricsSchema.optional().describe("Optional billable aggregate for work done before cancel.")
35
+ }).openapi("TurnStateCancelled");
36
+ var TurnStateErrorSchema = z.object({
37
+ status: z.literal("error").describe("Turn ended with an error."),
38
+ message: z.string().describe("Human-readable error message."),
39
+ completed_at: z.string().describe("ISO 8601 time when the error state was recorded."),
40
+ metrics: TurnMetricsSchema.optional().describe("Optional billable aggregate for work done before the error.")
41
+ }).openapi("TurnStateError");
42
+ var TurnStateDoneSchema = z.object({
43
+ status: z.literal("done").describe("Turn finished (possibly paused for required actions)."),
44
+ output: z.union([ModelMessageEventSchema, z.null()]).describe("Final `model.message` for the turn, or null when the turn ended paused without a final message."),
45
+ required_actions: z.array(ActionRequiredEventSchema).describe(
46
+ "Pending actions (`tool.approval_required`, `tool.response_required`, `mcp.auth_required`); empty when none."
47
+ ),
48
+ completed_at: z.string().describe("ISO 8601 time when the turn reached a terminal state."),
49
+ metrics: TurnMetricsSchema.optional().describe("Optional billable aggregate for the whole turn.")
50
+ }).openapi("TurnStateDone");
51
+ var TurnStateSchema = z.discriminatedUnion("status", [
52
+ TurnStateRunningSchema,
53
+ TurnStateDoneSchema,
54
+ TurnStateCancelledSchema,
55
+ TurnStateErrorSchema
56
+ ]).openapi("TurnState");
57
+ var TurnInputItemSchema = z.discriminatedUnion("type", [
58
+ AgentInputUserMessageSchema,
59
+ UserToolApprovalMessageSchema,
60
+ UserToolResponseMessageSchema
61
+ ]).openapi("TurnInputItem");
62
+ var TurnSchema = z.object({
63
+ id: z.string().describe("Unique turn id."),
64
+ session_id: z.string().describe("Session that owns this turn."),
65
+ previous_turn_id: z.string().nullable().describe("Prior turn this turn chains from; null for a root turn."),
66
+ input: z.array(TurnInputItemSchema).optional().describe("Input items supplied when the turn was created."),
67
+ state: TurnStateSchema,
68
+ created_at: z.string().describe("ISO 8601 creation timestamp.")
69
+ }).openapi("Turn");
70
+ var CreateTurnRequestSchema = z.object({
71
+ input: z.array(TurnInputItemSchema).optional().describe(
72
+ "Turn input items: user messages and/or approval/tool-response resumes. Do not mix user messages with approval or tool-response items."
73
+ ),
74
+ previous_turn_id: z.union([z.literal("auto"), z.literal("none"), z.string().min(1)]).optional().default("auto").describe(`Defaults to 'auto' (chain to session last turn). Use 'none' for a new root turn.`).openapi("PreviousTurnIdInput"),
75
+ stream: z.boolean().optional().default(true).describe("When true (default), stream turn events as SSE. When false, return the running turn immediately.")
76
+ }).superRefine((data, ctx) => {
77
+ if (!data.input) return;
78
+ const hasUser = data.input.some((msg) => "type" in msg && msg.type === "user.message");
79
+ const hasApprovalOrToolResponse = data.input.some(
80
+ (msg) => "type" in msg && (msg.type === "user.tool_approval" || msg.type === "user.tool_response")
81
+ );
82
+ if (hasUser && hasApprovalOrToolResponse) {
83
+ ctx.addIssue({
84
+ code: "custom",
85
+ message: "input must not mix user messages with approval decisions or client-side tool responses"
86
+ });
87
+ }
88
+ }).openapi("CreateTurnRequest");
89
+ export {
90
+ CancellationReason,
91
+ CreateTurnRequestSchema,
92
+ TurnInputItemSchema,
93
+ TurnMetricsSchema,
94
+ TurnSchema,
95
+ TurnStateCancelledReasonSchema,
96
+ TurnStateCancelledSchema,
97
+ TurnStateDoneSchema,
98
+ TurnStateErrorSchema,
99
+ TurnStateRunningSchema,
100
+ TurnStateSchema
101
+ };
102
+ //# sourceMappingURL=turn.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/agent-session/schemas/turn.ts"],"sourcesContent":["/** Turn product schemas: turn state, input items, and create-turn request. */\nimport { z } from '@hono/zod-openapi';\nimport {\n ActionRequiredEventSchema,\n AgentInputUserMessageSchema,\n ModelMessageEventSchema,\n UserToolApprovalMessageSchema,\n UserToolResponseMessageSchema,\n} from '../../core/events/schema';\n\nexport enum CancellationReason {\n // AbortController.abort() reason for the max-execution timer.\n ServerExecutionTimeout = 'server-execution-timeout',\n // Emitted when the client cancels the run.\n ClientCancelled = 'client-cancelled',\n // Prior turn aborted because the client started a new turn.\n CancelledForNextTurn = 'cancelled-for-next-turn',\n // Process shutting down (SIGTERM/SIGINT).\n Abandoned = 'abandoned',\n}\n\nexport const TurnStateRunningSchema = z\n .object({\n status: z.literal('running').describe('Turn is still executing.'),\n })\n .openapi('TurnStateRunning');\n\nexport const TurnStateCancelledReasonSchema = z\n .enum(CancellationReason)\n .describe('Reason for the cancellation.')\n .openapi('TurnStateCancelledReason');\n\n/** Billable aggregate for one turn. */\nexport const TurnMetricsSchema = z\n .object({\n total_input_tokens: z\n .number()\n .int()\n .nonnegative()\n .optional()\n .describe('Total input tokens across model calls in this turn.'),\n total_output_tokens: z\n .number()\n .int()\n .nonnegative()\n .optional()\n .describe('Total output tokens across model calls in this turn.'),\n total_tokens: z\n .number()\n .int()\n .nonnegative()\n .optional()\n .describe('Total tokens (input + output) across model calls in this turn.'),\n total_cache_read_tokens: z\n .number()\n .int()\n .nonnegative()\n .optional()\n .describe('Total cache-read tokens across model calls in this turn.'),\n total_cache_write_tokens: z\n .number()\n .int()\n .nonnegative()\n .optional()\n .describe('Total cache-write tokens across model calls in this turn.'),\n total_reasoning_tokens: z\n .number()\n .int()\n .nonnegative()\n .optional()\n .describe('Total reasoning tokens across model calls in this turn.'),\n total_cost_in_usd: z.number().nonnegative().optional().describe('Estimated total cost in USD for this turn.'),\n })\n .openapi('TurnMetrics');\n\nexport const TurnStateCancelledSchema = z\n .object({\n status: z.literal('cancelled').describe('Turn was cancelled before completion.'),\n reason: TurnStateCancelledReasonSchema,\n completed_at: z.string().describe('ISO 8601 time when cancellation completed.'),\n metrics: TurnMetricsSchema.optional().describe('Optional billable aggregate for work done before cancel.'),\n })\n .openapi('TurnStateCancelled');\n\nexport const TurnStateErrorSchema = z\n .object({\n status: z.literal('error').describe('Turn ended with an error.'),\n message: z.string().describe('Human-readable error message.'),\n completed_at: z.string().describe('ISO 8601 time when the error state was recorded.'),\n metrics: TurnMetricsSchema.optional().describe('Optional billable aggregate for work done before the error.'),\n })\n .openapi('TurnStateError');\n\nexport const TurnStateDoneSchema = z\n .object({\n status: z.literal('done').describe('Turn finished (possibly paused for required actions).'),\n output: z\n .union([ModelMessageEventSchema, z.null()])\n .describe('Final `model.message` for the turn, or null when the turn ended paused without a final message.'),\n required_actions: z\n .array(ActionRequiredEventSchema)\n .describe(\n 'Pending actions (`tool.approval_required`, `tool.response_required`, `mcp.auth_required`); empty when none.',\n ),\n completed_at: z.string().describe('ISO 8601 time when the turn reached a terminal state.'),\n metrics: TurnMetricsSchema.optional().describe('Optional billable aggregate for the whole turn.'),\n })\n .openapi('TurnStateDone');\n\nexport const TurnStateSchema = z\n .discriminatedUnion('status', [\n TurnStateRunningSchema,\n TurnStateDoneSchema,\n TurnStateCancelledSchema,\n TurnStateErrorSchema,\n ])\n .openapi('TurnState');\n\nexport const TurnInputItemSchema = z\n .discriminatedUnion('type', [\n AgentInputUserMessageSchema,\n UserToolApprovalMessageSchema,\n UserToolResponseMessageSchema,\n ])\n .openapi('TurnInputItem');\n\nexport const TurnSchema = z\n .object({\n id: z.string().describe('Unique turn id.'),\n session_id: z.string().describe('Session that owns this turn.'),\n previous_turn_id: z.string().nullable().describe('Prior turn this turn chains from; null for a root turn.'),\n input: z.array(TurnInputItemSchema).optional().describe('Input items supplied when the turn was created.'),\n state: TurnStateSchema,\n created_at: z.string().describe('ISO 8601 creation timestamp.'),\n })\n .openapi('Turn');\n\n/**\n * Wire type for the previous_turn_id field. Includes the default so the schema\n * can be referenced directly without re-wrapping (re-wrapping strips the $ref).\n */\nexport const CreateTurnRequestSchema = z\n .object({\n input: z\n .array(TurnInputItemSchema)\n .optional()\n .describe(\n 'Turn input items: user messages and/or approval/tool-response resumes. Do not mix user messages with approval or tool-response items.',\n ),\n previous_turn_id: z\n .union([z.literal('auto'), z.literal('none'), z.string().min(1)])\n .optional()\n .default('auto')\n .describe(`Defaults to 'auto' (chain to session last turn). Use 'none' for a new root turn.`)\n .openapi('PreviousTurnIdInput'),\n stream: z\n .boolean()\n .optional()\n .default(true)\n .describe('When true (default), stream turn events as SSE. When false, return the running turn immediately.'),\n })\n .superRefine((data, ctx) => {\n if (!data.input) return;\n const hasUser = data.input.some(msg => 'type' in msg && msg.type === 'user.message');\n const hasApprovalOrToolResponse = data.input.some(\n msg => 'type' in msg && (msg.type === 'user.tool_approval' || msg.type === 'user.tool_response'),\n );\n if (hasUser && hasApprovalOrToolResponse) {\n ctx.addIssue({\n code: 'custom',\n message: 'input must not mix user messages with approval decisions or client-side tool responses',\n });\n }\n })\n .openapi('CreateTurnRequest');\n\nexport type Turn = z.infer<typeof TurnSchema>;\nexport type TurnInputItem = z.infer<typeof TurnInputItemSchema>;\nexport type TurnState = z.infer<typeof TurnStateSchema>;\nexport type TerminalTurnState = Exclude<TurnState, { status: 'running' }>;\nexport type TurnMetrics = z.infer<typeof TurnMetricsSchema>;\n"],"mappings":";AACA,SAAS,SAAS;AAClB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,IAAK,qBAAL,kBAAKA,wBAAL;AAEL,EAAAA,oBAAA,4BAAyB;AAEzB,EAAAA,oBAAA,qBAAkB;AAElB,EAAAA,oBAAA,0BAAuB;AAEvB,EAAAA,oBAAA,eAAY;AARF,SAAAA;AAAA,GAAA;AAWL,IAAM,yBAAyB,EACnC,OAAO;AAAA,EACN,QAAQ,EAAE,QAAQ,SAAS,EAAE,SAAS,0BAA0B;AAClE,CAAC,EACA,QAAQ,kBAAkB;A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I,CAAC,CAAC,CAAC,EAC/D,SAAS,EACT,QAAQ,MAAM,EACd,SAAS,kFAAkF,EAC3F,QAAQ,qBAAqB;AAAA,EAChC,QAAQ,EACL,QAAQ,EACR,SAAS,EACT,QAAQ,IAAI,EACZ,SAAS,kGAAkG;AAChH,CAAC,EACA,YAAY,CAAC,MAAM,QAAQ;AAC1B,MAAI,CAAC,KAAK,MAAO;AACjB,QAAM,UAAU,KAAK,MAAM,KAAK,SAAO,UAAU,OAAO,IAAI,SAAS,cAAc;AACnF,QAAM,4BAA4B,KAAK,MAAM;AAAA,IAC3C,SAAO,UAAU,QAAQ,IAAI,SAAS,wBAAwB,IAAI,SAAS;AAAA,EAC7E;AACA,MAAI,WAAW,2BAA2B;AACxC,QAAI,SAAS;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AACF,CAAC,EACA,QAAQ,mBAAmB;","names":["CancellationReason"]}
@@ -0,0 +1,310 @@
1
+ import type { JsonValue } from '../../core/capabilities/AgentCapability';
2
+ import type { MCPServerInitInfo, ThreadOverwriteContextEvent } from '../../core/events/schema';
3
+ import type { AgentThreadSnapshot, ContextMessage, SubAgentCompletionMarker } from '../../core/runtime/AgentThread.types';
4
+ import type { CurrentContextUsage } from '../../core/runtime/contextUsage';
5
+ import type { SandboxInfo } from '../../core/sandbox/Sandbox';
6
+ import type { SessionRecord } from '../models/SessionRecord';
7
+ import type { TurnRecord } from '../models/TurnRecord';
8
+ import type { PersistedTurnEvent, SessionEventItem } from '../schemas/events';
9
+ import type { TokenPagination } from '../schemas/pagination';
10
+ import type { TerminalTurnState } from '../schemas/turn';
11
+ /**
12
+ * Caller-supplied fields for creating a session; the store owns timestamps and tip state.
13
+ * `agent` is a discriminated reference | inline binding.
14
+ */
15
+ export type CreateSessionInput<TSessionCustom extends object = Record<string, never>> = Pick<SessionRecord<TSessionCustom>, 'tenant_id' | 'session_id' | 'agent' | 'created_by'> & {
16
+ custom: TSessionCustom | null;
17
+ };
18
+ /**
19
+ * PATCH fields for an existing session; `undefined` fields are left unchanged.
20
+ * `agent` may be set only on inline sessions, and only as an inline arm (`{ type: 'inline', spec }`).
21
+ */
22
+ export type UpdateSessionInput<TSessionCustom extends object = Record<string, never>> = Pick<SessionRecord<TSessionCustom>, 'tenant_id' | 'session_id'> & {
23
+ agent: Extract<SessionRecord<TSessionCustom>['agent'], {
24
+ type: 'inline';
25
+ }> | undefined;
26
+ title: SessionRecord<TSessionCustom>['title'] | undefined;
27
+ };
28
+ export interface GetSessionInput {
29
+ tenant_id: string;
30
+ session_id: string;
31
+ }
32
+ export interface DeleteSessionInput {
33
+ tenant_id: string;
34
+ session_id: string;
35
+ }
36
+ export interface ListSessionsInput {
37
+ tenant_id: string;
38
+ limit: number;
39
+ page_token: string | undefined;
40
+ order: 'asc' | 'desc' | undefined;
41
+ /** Inclusive lower bound on `created_at` (instant). */
42
+ start_timestamp: Date | undefined;
43
+ /** Inclusive upper bound on `created_at` (instant). */
44
+ end_timestamp: Date | undefined;
45
+ /** When set, only sessions bound to this named agent id. */
46
+ agent_id: string | undefined;
47
+ /** When set, only sessions created by this identity. */
48
+ created_by: string | undefined;
49
+ }
50
+ /** Turn row fields without assembled snapshot (create input / listTurns). */
51
+ export type TurnRecordWithoutSnapshot<TTurnCustom extends object = Record<string, never>> = Omit<TurnRecord<TTurnCustom>, 'snapshot'>;
52
+ /** Thread registration; mutable per-turn data arrives through dedicated createTurn fields. */
53
+ export type NewThreadInit = Omit<AgentThreadSnapshot, 'context' | 'current_context_usage' | 'completion' | 'capability_state'>;
54
+ /** Full post-send capability map for one thread. */
55
+ export type ThreadCapabilityStateInit = Pick<AgentThreadSnapshot, 'thread_id' | 'capability_state'>;
56
+ /** One drained send() append batch for one thread; writer = the new turn. */
57
+ export interface TurnContextAppend {
58
+ thread_id: string;
59
+ context: ContextMessage[];
60
+ current_context_usage: CurrentContextUsage | null;
61
+ }
62
+ export interface CreateTurnInput<TTurnCustom extends object = Record<string, never>> {
63
+ turn: TurnRecordWithoutSnapshot<TTurnCustom>;
64
+ /** Threads absent on the previous turn (turn 1: the root thread; else empty). */
65
+ new_threads: NewThreadInit[];
66
+ /**
67
+ * All new messages, for new and carried-forward threads alike — collected by
68
+ * draining orchestrator.send() BEFORE this call. Draining without persisting is
69
+ * safe: send() mutates only in-memory threads, and if createTurn fails the whole
70
+ * in-memory state (orchestrator, threads, resolver) is discarded — so either this
71
+ * turn commits atomically with its appends, or nothing was persisted at all.
72
+ */
73
+ new_context_appends: TurnContextAppend[];
74
+ /**
75
+ * Complete post-send capability maps: exactly one entry per turn thread.
76
+ * Authoritative for this turn; the store does not carry capability rows forward.
77
+ */
78
+ capability_states: ThreadCapabilityStateInit[];
79
+ /** Set only if session.title is NULL (first write wins). */
80
+ update_session_title_if_not_exist: string | null;
81
+ }
82
+ export interface FreezeAndGetTurnInput {
83
+ session_id: string;
84
+ turn_id: string;
85
+ /** Caller-built cancelled turn.done event; store persists atomically with state flip when it cancels. */
86
+ turn_done_event: PersistedTurnEvent;
87
+ }
88
+ export interface GetTurnInput {
89
+ session_id: string;
90
+ turn_id: string;
91
+ }
92
+ export interface ListTurnsInput {
93
+ session_id: string;
94
+ limit: number;
95
+ page_token: string | undefined;
96
+ }
97
+ export interface UpdateTurnStateInput {
98
+ session_id: string;
99
+ turn_id: string;
100
+ state: TerminalTurnState;
101
+ /** Caller-built turn.done; written atomically with the state flip in the same tx. */
102
+ turn_done_event: PersistedTurnEvent;
103
+ }
104
+ export interface AppendToEventsInput {
105
+ session_id: string;
106
+ turn_id: string;
107
+ events: PersistedTurnEvent[];
108
+ }
109
+ export interface AddThreadsInput {
110
+ session_id: string;
111
+ turn_id: string;
112
+ threads: AgentThreadSnapshot[];
113
+ }
114
+ export interface RemoveThreadsInput {
115
+ session_id: string;
116
+ turn_id: string;
117
+ thread_ids: string[];
118
+ }
119
+ export interface AppendToThreadContextInput {
120
+ session_id: string;
121
+ turn_id: string;
122
+ thread_id: string;
123
+ context: ContextMessage[];
124
+ current_context_usage: CurrentContextUsage | null;
125
+ completion: SubAgentCompletionMarker | null;
126
+ }
127
+ export interface OverwriteThreadContextInput {
128
+ session_id: string;
129
+ turn_id: string;
130
+ event: ThreadOverwriteContextEvent;
131
+ }
132
+ export interface PatchMCPServersInput {
133
+ session_id: string;
134
+ turn_id: string;
135
+ mcp_servers: MCPServerInitInfo[];
136
+ }
137
+ export interface PatchSandboxInfoInput {
138
+ session_id: string;
139
+ turn_id: string;
140
+ sandbox_info: SandboxInfo;
141
+ }
142
+ export interface PatchThreadCapabilityStateInput {
143
+ session_id: string;
144
+ turn_id: string;
145
+ thread_id: string;
146
+ key: string;
147
+ state: JsonValue;
148
+ }
149
+ export interface ListTurnEventsInput {
150
+ session_id: string;
151
+ turn_id: string;
152
+ limit: number;
153
+ page_token: string | undefined;
154
+ order: 'asc' | 'desc' | undefined;
155
+ }
156
+ export interface ListSessionEventsInput {
157
+ session_id: string;
158
+ limit: number;
159
+ page_token: string | undefined;
160
+ last_turn_id: string | undefined;
161
+ }
162
+ /**
163
+ * Session/turn persistence contract. Pure durability: no streaming, SSE, or
164
+ * subscription members. Callers authorize the parent session before using
165
+ * turn-scoped operations, which rely on globally unique session_id values.
166
+ * Capability maps are initialized atomically by createTurn and subsequently
167
+ * updated through patchThreadCapabilityState. Agent binding is session-scoped
168
+ * as a discriminated `agent` (ref | value); named agents are not hydrated on read.
169
+ */
170
+ export interface ISessionStore<TSessionCustom extends object = Record<string, never>, TTurnCustom extends object = Record<string, never>> {
171
+ /**
172
+ * Persists a discriminated `agent` (ref | value). SQL backends may flatten to columns.
173
+ * `session_id` is globally unique across tenants.
174
+ * Persists caller-supplied `created_by` (immutable after create).
175
+ * Sets `last_activity_timestamp_ms` (= now) on create.
176
+ */
177
+ createSession(input: CreateSessionInput<TSessionCustom>): Promise<void>;
178
+ /** Permanently removes a session and all related data; missing sessions are a no-op. */
179
+ deleteSession(input: DeleteSessionInput): Promise<void>;
180
+ /**
181
+ * Returns the session as stored (ref agents are not hydrated to a value).
182
+ * Does **not** bump `last_activity_timestamp_ms` (read path).
183
+ */
184
+ getSession(input: GetSessionInput): Promise<SessionRecord<TSessionCustom> | undefined>;
185
+ /**
186
+ * PATCH semantics — update only the provided fields:
187
+ * - agent: replace inline binding (inline sessions only; reference → invariant error).
188
+ * - title: set/replace the session title.
189
+ * Bumps `last_activity_timestamp_ms` (= now) in the same update.
190
+ */
191
+ updateSession(input: UpdateSessionInput<TSessionCustom>): Promise<void>;
192
+ /**
193
+ * Paginated list of the tenant's sessions ordered by `updated_at`
194
+ * (`order` defaults to `desc`, `session_id` tie-break). `page_token` is a
195
+ * keyset cursor on `(updated_at, session_id)`. `start_timestamp` /
196
+ * `end_timestamp` are inclusive instant bounds on `created_at`. Optional
197
+ * `agent_id` filters ref-bound sessions; optional `created_by` filters by
198
+ * creator identity. Does **not** bump `last_activity_timestamp_ms` (read path).
199
+ */
200
+ listSessions(input: ListSessionsInput): Promise<{
201
+ data: SessionRecord<TSessionCustom>[];
202
+ pagination: TokenPagination;
203
+ }>;
204
+ /**
205
+ * Creates the turn AND advances `session.last_turn_id`. Context merging is the
206
+ * store's responsibility: `new_context_appends` and `new_threads` are applied
207
+ * on top of the previous turn's snapshot when `turn.previous_turn_id` is set.
208
+ * `capability_states` is the complete authoritative map for every resulting
209
+ * thread and is persisted directly without store-side carry-forward.
210
+ *
211
+ * Atomicity (store contract): insert turn + set `last_turn_id` (+ session
212
+ * turn-list append if the backend has one) MUST be one atomic unit per
213
+ * session. Concurrent createTurn on the same session must not drop a turn
214
+ * row or leave `last_turn_id` pointing at a turn that was never created.
215
+ * The implementation supplies the mechanism (session lock, row lock/tx, …).
216
+ *
217
+ * Also bumps `session.last_activity_timestamp_ms` in that same atomic unit.
218
+ *
219
+ * Fork semantics for `turn.previous_turn_id`:
220
+ * - `null` — new root turn (no parent); always allowed.
221
+ * - string — fork/chain from that turn when it exists. Tip-equality is NOT
222
+ * required; concurrent forks from the same tip both succeed. Unknown id is
223
+ * allowed (relaxed) and treated as no inheritance. If that turn exists and
224
+ * is still `running`, reject with {@link PreviousTurnRunningError} —
225
+ * callers must {@link freezeAndGetTurn} first.
226
+ * `last_turn_id` always advances to the new turn in the same atomic unit.
227
+ *
228
+ * `update_session_title_if_not_exist`: when set AND `session.title` is
229
+ * unset/null, set it in the same atomic unit; an existing title is NEVER
230
+ * overwritten (first write wins). The caller derives the value; the store
231
+ * only conditionally sets it.
232
+ */
233
+ createTurn(input: CreateTurnInput<TTurnCustom>): Promise<void>;
234
+ /**
235
+ * One tx: (a) conditionally cancel a running turn with
236
+ * {@link CancellationReason.CancelledForNextTurn}; (b) if it did cancel,
237
+ * insert the caller-built `turn_done_event` — already-terminal turns skip the
238
+ * event insert; (c) return the now-immutable turn record. Missing turn →
239
+ * {@link TurnNotFoundError}.
240
+ */
241
+ freezeAndGetTurn(input: FreezeAndGetTurnInput): Promise<TurnRecord<TTurnCustom>>;
242
+ /** Returns the turn record, or undefined if not found in this session. */
243
+ getTurn(input: GetTurnInput): Promise<TurnRecord<TTurnCustom> | undefined>;
244
+ /** Paginated list of turn rows (no snapshot); use getTurn for assembled snapshot. */
245
+ listTurns(input: ListTurnsInput): Promise<{
246
+ data: TurnRecordWithoutSnapshot<TTurnCustom>[];
247
+ pagination: TokenPagination;
248
+ }>;
249
+ /**
250
+ * Writes the terminal state and `turn_done_event` atomically. Store contract —
251
+ * **first terminal write wins**:
252
+ * - Allowed: `running` → `done` | `cancelled` | `error`.
253
+ * - Rejected with **409** (or equivalent conflict): any write when status is already
254
+ * terminal — including done→cancelled, cancelled→done, error→*, terminal→running.
255
+ * - Missing turn → 404 / not-found.
256
+ *
257
+ * Check under the same concurrency control as other turn mutations (lock/CAS) —
258
+ * not a racy read-then-write outside the critical section.
259
+ */
260
+ updateTurnState(input: UpdateTurnStateInput): Promise<void>;
261
+ /**
262
+ * Durable event log for the turn. MUST include lifecycle rows: a
263
+ * `TurnCreatedEvent` at the start of the stream and a terminal `TurnDoneEvent`
264
+ * (or its cancelled/error shape) at the end. Every turn written through this
265
+ * API persists lifecycle in the stream — implementations never synthesize
266
+ * missing created/done rows on read. Every event MUST carry `id` and
267
+ * `created_at`; `id` is a monotonic ULID and is the primary within-turn sort
268
+ * key. `created_at` records event creation time but is not the order key.
269
+ */
270
+ appendToEvents(input: AppendToEventsInput): Promise<void>;
271
+ /** Adds thread snapshots to the turn (sub-agent spawns). */
272
+ addThreads(input: AddThreadsInput): Promise<void>;
273
+ /** Removes threads from the turn by id. */
274
+ removeThreads(input: RemoveThreadsInput): Promise<void>;
275
+ /** Appends messages to a thread's context; optionally updates usage / completion marker. */
276
+ appendToThreadContext(input: AppendToThreadContextInput): Promise<void>;
277
+ /** Replaces a thread's context wholesale (context-overwrite event). */
278
+ overwriteThreadContext(input: OverwriteThreadContextInput): Promise<void>;
279
+ /** Patches the turn snapshot's MCP server init info (by source id). */
280
+ patchMCPServers(input: PatchMCPServersInput): Promise<void>;
281
+ /** Patches the turn snapshot's sandbox info (id for cross-turn reattach). */
282
+ patchSandboxInfo(input: PatchSandboxInfoInput): Promise<void>;
283
+ /** Generic capability KV — store has zero Plan/feature knowledge. */
284
+ patchThreadCapabilityState(input: PatchThreadCapabilityStateInput): Promise<void>;
285
+ /** Paginated read ordered lexically by monotonic `event.id` (asc default). */
286
+ listTurnEvents(input: ListTurnEventsInput): Promise<{
287
+ data: PersistedTurnEvent[];
288
+ pagination: TokenPagination;
289
+ }>;
290
+ /**
291
+ * Paginated session-wide feed of persisted events across turns, including
292
+ * turn.created / turn.done lifecycle rows. Reads only — never synthesizes.
293
+ *
294
+ * Includes events from **running** turns (the HTTP layer may 409 separately;
295
+ * that is not store semantics). Ordering: newest turn first, then monotonic
296
+ * `event.id` descending within each turn. `last_turn_id` anchors the window
297
+ * to that turn plus its ancestors; when omitted, the session's current
298
+ * `last_turn_id` selects the active branch. Continuation page tokens encode
299
+ * that anchor and take precedence over `last_turn_id`, so later session
300
+ * activity cannot move an in-progress pagination walk to another branch.
301
+ * `ancestor_ids` may include only the previous N ancestors and need not reach
302
+ * the root — implementations must spill through older turns' own
303
+ * `ancestor_ids` when needed. Sibling branches from forks are excluded.
304
+ */
305
+ listSessionEvents(input: ListSessionEventsInput): Promise<{
306
+ data: SessionEventItem[];
307
+ pagination: TokenPagination;
308
+ }>;
309
+ }
310
+ //# sourceMappingURL=ISessionStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ISessionStore.d.ts","sourceRoot":"","sources":["../../../src/agent-session/store/ISessionStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAC/F,OAAO,KAAK,EACV,mBAAmB,EACnB,cAAc,EACd,wBAAwB,EACzB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD;;;GAGG;AACH,MAAM,MAAM,kBAAkB,CAAC,cAAc,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,IAAI,CAC1F,aAAa,CAAC,cAAc,CAAC,EAC7B,WAAW,GAAG,YAAY,GAAG,OAAO,GAAG,YAAY,CACpD,GAAG;IACF,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;CAC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EAAqE;IACrE,0BAA0B,CAAC,KAAK,EAAE,+BAA+B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAElF,8EAA8E;IAC9E,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC;QAClD,IAAI,EAAE,kBAAkB,EAAE,CAAC;QAC3B,UAAU,EAAE,eAAe,CAAC;KAC7B,CAAC,CAAC;IAEH;;;;;;;;;;;;;;OAcG;IACH,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC;QACxD,IAAI,EAAE,gBAAgB,EAAE,CAAC;QACzB,UAAU,EAAE,eAAe,CAAC;KAC7B,CAAC,CAAC;CACJ"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/agent-session/store/ISessionStore.ts
17
+ var ISessionStore_exports = {};
18
+ module.exports = __toCommonJS(ISessionStore_exports);
19
+ //# sourceMappingURL=ISessionStore.js.map