@makaio/framework 1.0.0-dev-1785409369816 → 1.0.0-dev-1786014320559

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 (508) hide show
  1. package/dist/.makaio-build.json +4 -3
  2. package/dist/{account-identity-DFx8pwKL.mjs → account-identity-DGpXd8h_.mjs} +1 -1
  3. package/dist/adapter-BkdJaOOG.mjs +1 -0
  4. package/dist/adapter-subsystem/index.d.mts +138 -6
  5. package/dist/adapter-subsystem/index.mjs +1 -1
  6. package/dist/adapters/acp-client/index.d.mts +105 -7
  7. package/dist/adapters/acp-client/index.mjs +2 -2
  8. package/dist/adapters/config/index.d.mts +1 -1
  9. package/dist/adapters/config/index.mjs +1 -1
  10. package/dist/adapters/index.d.mts +362 -801
  11. package/dist/adapters/index.mjs +6 -6
  12. package/dist/adapters/node.d.mts +1 -1
  13. package/dist/adapters/node.mjs +1 -1
  14. package/dist/adapters/stream-session/index.d.mts +28 -7
  15. package/dist/adapters/stream-session/index.mjs +1 -1
  16. package/dist/agent-namespace-D51PODFf.mjs +1 -0
  17. package/dist/{ajv-DD3SIL2i.mjs → ajv-L5fKxaia.mjs} +2 -2
  18. package/dist/artifact-k3veR4Yx.mjs +1 -0
  19. package/dist/attach-error-BSlc7JfL.mjs +1 -0
  20. package/dist/{auth-DGEdiHF6.mjs → auth-A1K_7q-8.mjs} +1 -1
  21. package/dist/authority-state-bootstrap-YwtEImIB.mjs +1 -0
  22. package/dist/automation-trigger-CuSdQwir.mjs +1 -0
  23. package/dist/await-trigger-ph1S0zVI.mjs +1 -0
  24. package/dist/bus/index.d.mts +19 -5
  25. package/dist/bus/index.mjs +1 -1
  26. package/dist/bus-BIj0_aG6.mjs +1 -0
  27. package/dist/bus-CqgrphNE.mjs +2 -0
  28. package/dist/{canonical-model-BAytQ4NV.mjs → canonical-model-DJASlL4m.mjs} +1 -1
  29. package/dist/{capabilities-BQEp34ir.mjs → capabilities-Bqckjh7G.mjs} +1 -1
  30. package/dist/{client-DbS847wW.mjs → client-BL5__WT0.mjs} +1 -1
  31. package/dist/clients/index.d.mts +2 -2
  32. package/dist/clients/index.mjs +1 -1
  33. package/dist/clients/managed-install.d.mts +1 -1
  34. package/dist/clients/managed-install.mjs +1 -1
  35. package/dist/{compression-74fFeBha.mjs → compression-BbttSqm8.mjs} +1 -1
  36. package/dist/{config-namespace-TVX-hG4I.mjs → config-namespace-CyzeLWSg.mjs} +1 -1
  37. package/dist/{context-resolution-DdyhpH4L.d.mts → context-resolution-CW0ya4QO.d.mts} +13 -13
  38. package/dist/contracts/adapter/index.d.mts +3 -3
  39. package/dist/contracts/adapter/index.mjs +1 -1
  40. package/dist/contracts/adapter/schemas/session-lineage.d.mts +1 -1
  41. package/dist/contracts/artifact/index.d.mts +3 -3
  42. package/dist/contracts/artifact/index.mjs +1 -1
  43. package/dist/contracts/auth/index.d.mts +2 -2
  44. package/dist/contracts/auth/index.mjs +1 -1
  45. package/dist/contracts/automation-trigger/index.d.mts +4 -0
  46. package/dist/contracts/automation-trigger/index.mjs +1 -0
  47. package/dist/contracts/canonical-model/index.d.mts +1 -1
  48. package/dist/contracts/canonical-model/index.mjs +1 -1
  49. package/dist/contracts/capabilities/index.d.mts +1 -1
  50. package/dist/contracts/capabilities/index.mjs +1 -1
  51. package/dist/contracts/client/index.d.mts +2 -2
  52. package/dist/contracts/client/index.mjs +1 -1
  53. package/dist/contracts/common/index.d.mts +1 -1
  54. package/dist/contracts/config/index.d.mts +1 -1
  55. package/dist/contracts/config/index.mjs +1 -1
  56. package/dist/contracts/extension/index.d.mts +6 -5
  57. package/dist/contracts/extension/index.mjs +1 -1
  58. package/dist/contracts/facet/index.d.mts +1 -1
  59. package/dist/contracts/facet/index.mjs +1 -1
  60. package/dist/contracts/harness/index.d.mts +1 -1
  61. package/dist/contracts/harness/index.mjs +1 -1
  62. package/dist/contracts/host/index.d.mts +1 -1
  63. package/dist/contracts/host/index.mjs +1 -1
  64. package/dist/contracts/index.d.mts +181 -120
  65. package/dist/contracts/index.mjs +1 -1
  66. package/dist/contracts/materialization/index.d.mts +3 -3
  67. package/dist/contracts/materialization/index.mjs +1 -1
  68. package/dist/contracts/model-registry/index.d.mts +1 -1
  69. package/dist/contracts/model-registry/index.mjs +1 -1
  70. package/dist/contracts/native-session-supervisor/index.d.mts +1 -1
  71. package/dist/contracts/native-session-supervisor/index.mjs +1 -1
  72. package/dist/contracts/platform/index.d.mts +1 -1
  73. package/dist/contracts/platform/index.mjs +1 -1
  74. package/dist/contracts/provider/index.d.mts +2 -2
  75. package/dist/contracts/provider/index.mjs +1 -1
  76. package/dist/contracts/reaction/index.d.mts +2 -0
  77. package/dist/contracts/reaction/index.mjs +1 -0
  78. package/dist/contracts/session/index.d.mts +3 -3
  79. package/dist/contracts/session/index.mjs +1 -1
  80. package/dist/contracts/shared/index.d.mts +3 -3
  81. package/dist/contracts/shared/index.mjs +1 -1
  82. package/dist/contracts/skill/index.d.mts +1 -1
  83. package/dist/contracts/skill/index.mjs +1 -1
  84. package/dist/contracts/telemetry/index.d.mts +1 -1
  85. package/dist/contracts/telemetry/index.mjs +1 -1
  86. package/dist/contracts/timeout/index.d.mts +1 -1
  87. package/dist/contracts/timeout/index.mjs +1 -1
  88. package/dist/contracts/toast/index.mjs +1 -1
  89. package/dist/contracts/variant/index.d.mts +1 -1
  90. package/dist/contracts/variant/index.mjs +1 -1
  91. package/dist/contracts/worker-node/index.d.mts +1 -1
  92. package/dist/contracts/worker-node/index.mjs +1 -1
  93. package/dist/contracts/workflow/index.d.mts +3 -3
  94. package/dist/contracts/workflow/index.mjs +1 -1
  95. package/dist/contribution-BH-wKsWI.d.mts +35 -0
  96. package/dist/core/index.d.mts +60 -1
  97. package/dist/core/index.mjs +1 -1
  98. package/dist/definition-BYgHlmMw.d.mts +375 -0
  99. package/dist/{definition-CJfiv8xm.mjs → definition-CDg-Jq1T.mjs} +1 -1
  100. package/dist/{detached-extension-handle-Ddfquy5_.mjs → detached-extension-handle-DKd17UB6.mjs} +1 -1
  101. package/dist/drizzle/0031_adapter_session_currency.sql +66 -0
  102. package/dist/drizzle/0032_native_session_ownership.sql +77 -0
  103. package/dist/drizzle/0033_m_msf3hu2s.sql +1 -0
  104. package/dist/drizzle/meta/_journal.json +21 -0
  105. package/dist/{execution-attempt-repository-DWXKY41_.d.mts → execution-attempt-repository-DFyAnchJ.d.mts} +1 -1
  106. package/dist/{execution-target-Cf645pDj.mjs → execution-target-ByNwZh5-.mjs} +1 -1
  107. package/dist/extension-DMdmj9gi.mjs +1 -0
  108. package/dist/extension-DUmibvMk.mjs +1 -0
  109. package/dist/extension-context-CqfddWXs.d.mts +295 -0
  110. package/dist/{extension-discovery-CQRdbVQ6.d.mts → extension-discovery-Fhps4icD.d.mts} +2 -0
  111. package/dist/{extension-namespace-Yu41YepM.mjs → extension-namespace-B554RmCp.mjs} +1 -1
  112. package/dist/extension-package-provenance-Dh_-Z-tE.mjs +1 -0
  113. package/dist/{filesystem-service-DlP2HfDg.mjs → filesystem-service-FAtd9gWH.mjs} +1 -1
  114. package/dist/framework-packages-D_2hBZ-p.mjs +1 -0
  115. package/dist/git/index.mjs +1 -1
  116. package/dist/{globby-1yCVCk8s.mjs → globby-BBLuT_vy.mjs} +1 -1
  117. package/dist/handlers-2yd00VEq.mjs +57 -0
  118. package/dist/{harness-DpwsFsE7.mjs → harness-KxbWGL4I.mjs} +1 -1
  119. package/dist/{hook-responses-Dh1PWXqJ.d.mts → hook-responses-CQZIv3L3.d.mts} +2 -293
  120. package/dist/{index-DCZ8BX9S.d.mts → index-3eUIRy7T.d.mts} +304 -74
  121. package/dist/{index-brqfk9JQ.d.mts → index-B4xdTT3c.d.mts} +6 -6
  122. package/dist/{index-4VfqCjl2.d.mts → index-B5op6AsV.d.mts} +49 -39
  123. package/dist/{index-CMgLxw14.d.mts → index-B6GOuxVy2.d.mts} +18 -18
  124. package/dist/index-BFhJe-Sb.d.mts +302 -0
  125. package/dist/{index-EjsSBQXy2.d.mts → index-BSQ30wYP.d.mts} +1 -1
  126. package/dist/{index-DlsHL9Jg.d.mts → index-BiAYXjgM.d.mts} +25 -25
  127. package/dist/{index-B9UW_vPM.d.mts → index-ByZi9bml.d.mts} +4967 -1509
  128. package/dist/{index-BVlXneHH.d.mts → index-C7HcDpHE.d.mts} +14 -10
  129. package/dist/{index-BskPjMet.d.mts → index-CB4aIUoF.d.mts} +16 -16
  130. package/dist/{index-cqLS1eFV.d.mts → index-CDusRXio.d.mts} +70 -71
  131. package/dist/{index-DnG-QFpG.d.mts → index-CSN_0sCo.d.mts} +18 -1
  132. package/dist/{index-BAXkicoQ.d.mts → index-C__EQfKa.d.mts} +1 -1
  133. package/dist/{index-CLvQsL6s2.d.mts → index-CqQYgsbB.d.mts} +1660 -218
  134. package/dist/{index-BNMnIe-j.d.mts → index-CwDiyJkJ.d.mts} +276 -705
  135. package/dist/{index-GHASUiem.d.mts → index-DBadVauL.d.mts} +1 -1
  136. package/dist/{index-gUhidukN.d.mts → index-DI7-tIL3.d.mts} +299 -2
  137. package/dist/index-DP3o_13U.d.mts +165 -0
  138. package/dist/{index-DSBT83c0.d.mts → index-DcYAAJ0V.d.mts} +24 -3
  139. package/dist/{index-D5Nb7IEP.d.mts → index-Dch_AxUg.d.mts} +77 -39
  140. package/dist/{index-D_ODXsBv.d.mts → index-DcqSUsX6.d.mts} +35 -79
  141. package/dist/{index-B0Kf_OWi.d.mts → index-DgOfgjx3.d.mts} +1 -1
  142. package/dist/{index-Ds5_rDEJ.d.mts → index-DwLRZscE.d.mts} +1 -12
  143. package/dist/{index-DkiTJM5p.d.mts → index-DxYDRoDE2.d.mts} +17 -3
  144. package/dist/{index-CRvpVIqA.d.mts → index-OsbtyMgx2.d.mts} +10 -1
  145. package/dist/{index-BaZeoZoS.d.mts → index-bIe_57cL.d.mts} +1 -1
  146. package/dist/{json-value-Brslhqbm.d.mts → json-value-C1RGgS0a.d.mts} +16 -1
  147. package/dist/{json-value-DmU8ibo_.mjs → json-value-D57aJhVn.mjs} +1 -1
  148. package/dist/kernel/cli/index.d.mts +2 -2
  149. package/dist/kernel/cli/index.mjs +1 -1
  150. package/dist/kernel/cli/register.d.mts +1 -1
  151. package/dist/kernel/cli/register.mjs +1 -1
  152. package/dist/kernel/cli/schemas.mjs +1 -1
  153. package/dist/kernel/extension/index.d.mts +1 -1
  154. package/dist/kernel/extension/index.mjs +1 -1
  155. package/dist/kernel/index.d.mts +9 -9
  156. package/dist/kernel/index.mjs +1 -1
  157. package/dist/kernel/namespace/index.d.mts +2 -2
  158. package/dist/kernel/namespace/index.mjs +1 -1
  159. package/dist/kernel/observability/index.d.mts +1 -1
  160. package/dist/kernel/observability/index.mjs +1 -1
  161. package/dist/kernel/providers/index.d.mts +1 -1
  162. package/dist/kernel/providers/index.mjs +1 -1
  163. package/dist/kernel/window/index.d.mts +1 -1
  164. package/dist/kernel/window/index.mjs +1 -1
  165. package/dist/{lib-C7-s68uf.mjs → lib-B_rJ6r0T.mjs} +1 -1
  166. package/dist/{lib-DErgth_E.mjs → lib-CnOAtohU.mjs} +1 -1
  167. package/dist/load-extensions-CW9uzNR5.mjs +1 -0
  168. package/dist/{load-extensions-BxsDB87B.d.mts → load-extensions-DUpaMQ7G.d.mts} +17 -13
  169. package/dist/{materialization-Jd198K3y.mjs → materialization-CcpCDhXh.mjs} +1 -1
  170. package/dist/mcp-http-server/index.mjs +1 -1
  171. package/dist/model-ZH3L1dPW.mjs +1 -0
  172. package/dist/{namespace-BqxtpNAn.mjs → namespace-B7bntOB8.mjs} +1 -1
  173. package/dist/{namespace-CWUDFGOy.mjs → namespace-BFqkUTJp.mjs} +1 -1
  174. package/dist/{namespace-CjjFvrIA2.d.mts → namespace-CAy4P5mW.d.mts} +29 -29
  175. package/dist/{namespace-B8uKAzWJ.mjs → namespace-CFjdyNXG.mjs} +1 -1
  176. package/dist/{namespace-DV-Hr9sZ.d.mts → namespace-ChnRTUG4.d.mts} +11 -1
  177. package/dist/namespace-CxrOLeeP.mjs +1 -0
  178. package/dist/{namespace-g_mbIZq_.d.mts → namespace-DSlfFhB1.d.mts} +410 -26
  179. package/dist/{namespace-CupOzbRv.d.mts → namespace-DwZwGXgF.d.mts} +24 -20
  180. package/dist/{namespace-TseEI3Pu.d.mts → namespace-Rge9mMI-.d.mts} +36 -28
  181. package/dist/{native-session-supervisor-DRx0MX-d.mjs → native-session-supervisor-fZYPUk0-.mjs} +1 -1
  182. package/dist/node/bus-server/index.d.mts +1 -1
  183. package/dist/node/bus-server/index.mjs +1 -1
  184. package/dist/node/bus-server/server-lifecycle.d.mts +1 -1
  185. package/dist/node/bus-server/server-lifecycle.mjs +1 -1
  186. package/dist/{orchestrator-shared-BHCv-l2O.d.mts → orchestrator-shared-B-KRW1Z0.d.mts} +1 -0
  187. package/dist/orchestrator-shared-CTCZc6Vl.mjs +1 -0
  188. package/dist/ownership-memory-handler-Bblp93YC.mjs +1 -0
  189. package/dist/{package-DWMxGfzK.d.mts → package-Bf3hyuzs.d.mts} +234 -84
  190. package/dist/package-CBdvjyyZ.mjs +1 -0
  191. package/dist/package-CddkNbZI.mjs +1 -0
  192. package/dist/package-ypz4rKvn.mjs +7 -0
  193. package/dist/package.json +1 -1
  194. package/dist/{profile-BTAI31Nt.mjs → profile-BtznZlq3.mjs} +1 -1
  195. package/dist/{provider-context-Dq53Cgzz.mjs → provider-context-BrLZYnDW.mjs} +1 -1
  196. package/dist/{provider-context-PZIQWcqQ.mjs → provider-context-Dh-VOOYF.mjs} +1 -1
  197. package/dist/reaction-BS0k4eNN.mjs +1 -0
  198. package/dist/{registry-wfF2uTty.mjs → registry-BO_bOoky.mjs} +2 -2
  199. package/dist/{resolved-DZgqql2Z.mjs → resolved-DMByz1_2.mjs} +1 -1
  200. package/dist/rules/index.d.mts +1 -1
  201. package/dist/rules/index.mjs +1 -1
  202. package/dist/rules/schemas.d.mts +1 -1
  203. package/dist/runtime-bun/index.mjs +1 -1
  204. package/dist/runtime-node/extension-discovery.d.mts +1 -1
  205. package/dist/runtime-node/extension-validation.d.mts +1 -1
  206. package/dist/runtime-node/extension-validation.mjs +1 -1
  207. package/dist/runtime-node/index.d.mts +4 -4
  208. package/dist/runtime-node/index.mjs +24 -24
  209. package/dist/runtime-node/makaio-config.d.mts +1 -1
  210. package/dist/runtime-node/makaio-config.mjs +1 -1
  211. package/dist/runtime-node/workflow-worker/index.d.mts +1 -1
  212. package/dist/runtime-node/workflow-worker/index.mjs +1 -1
  213. package/dist/runtime-node/workflow-worker/worker-entry.mjs +1 -1
  214. package/dist/{schema-Dd-e89MO.mjs → schema-DBG7Jq5_.mjs} +1 -1
  215. package/dist/{schema-DKUb4rkr.d.mts → schema-DKTzriEY.d.mts} +519 -9
  216. package/dist/{schemas-DrVg4aQQ.d.mts → schemas-9qeeHGBf.d.mts} +8 -8
  217. package/dist/{schemas-CRB2O5zo.mjs → schemas-BqD8LlQw.mjs} +1 -1
  218. package/dist/{schemas-DaHQzpgm.mjs → schemas-CsjN7cmM.mjs} +1 -1
  219. package/dist/schemas-DSkBOdx_.mjs +1 -0
  220. package/dist/schemas-DplrlAyR.mjs +1 -0
  221. package/dist/{schemas-DnYiAvfz.d.mts → schemas-VbB1FTxx.d.mts} +24 -20
  222. package/dist/scoped-bus-ClwTWqX8.mjs +1 -0
  223. package/dist/{selection-BNwTKEVT.mjs → selection-7Ku8DBnh.mjs} +1 -1
  224. package/dist/services/adapter-runtime/index.d.mts +3 -3
  225. package/dist/services/adapter-runtime/index.mjs +1 -1
  226. package/dist/services/adapter-runtime/namespace.d.mts +1 -1
  227. package/dist/services/adapter-runtime/schemas.d.mts +1 -1
  228. package/dist/services/adapter-subsystem/index.d.mts +4 -4
  229. package/dist/services/adapter-subsystem/index.mjs +1 -1
  230. package/dist/services/adapter-subsystem/namespace.d.mts +2 -2
  231. package/dist/services/adapter-subsystem/namespace.mjs +1 -1
  232. package/dist/services/agent-runtime/index.d.mts +2 -2
  233. package/dist/services/agent-runtime/namespace.d.mts +1 -1
  234. package/dist/services/agent-runtime/schemas.d.mts +1 -1
  235. package/dist/services/automation-trigger/index.d.mts +943 -0
  236. package/dist/services/automation-trigger/index.mjs +1 -0
  237. package/dist/services/capability/index.d.mts +1 -1
  238. package/dist/services/capability/index.mjs +1 -1
  239. package/dist/services/codebase/index.d.mts +2 -2
  240. package/dist/services/codebase/namespace.d.mts +1 -1
  241. package/dist/services/codebase/schemas.d.mts +1 -1
  242. package/dist/services/compression/index.d.mts +2 -2
  243. package/dist/services/compression/namespace.d.mts +1 -1
  244. package/dist/services/compression/schemas.d.mts +1 -1
  245. package/dist/services/context-rules/index.d.mts +4 -4
  246. package/dist/services/context-rules/index.mjs +1 -1
  247. package/dist/services/execution-target/index.d.mts +3 -3
  248. package/dist/services/execution-target/index.mjs +1 -1
  249. package/dist/services/execution-target/namespace.d.mts +1 -1
  250. package/dist/services/execution-target/namespace.mjs +1 -1
  251. package/dist/services/execution-target/schemas.d.mts +1 -1
  252. package/dist/services/execution-target/schemas.mjs +1 -1
  253. package/dist/services/filesystem/index.d.mts +1 -1
  254. package/dist/services/filesystem/index.mjs +1 -1
  255. package/dist/services/filesystem/namespace.d.mts +6 -6
  256. package/dist/services/filesystem/schemas.d.mts +3 -3
  257. package/dist/services/git/namespace.mjs +1 -1
  258. package/dist/services/git/schemas.mjs +1 -1
  259. package/dist/services/harness/index.mjs +1 -1
  260. package/dist/services/index.d.mts +459 -93
  261. package/dist/services/index.mjs +1 -1
  262. package/dist/services/log-import/browser.d.mts +2 -2
  263. package/dist/services/log-import/index.d.mts +3 -3
  264. package/dist/services/log-import/log-import.d.mts +1 -1
  265. package/dist/services/log-import/log-import.mjs +1 -1
  266. package/dist/services/log-import/namespace.mjs +1 -1
  267. package/dist/services/log-import/schemas.mjs +1 -1
  268. package/dist/services/materialization/index.d.mts +1 -1
  269. package/dist/services/materialization/index.mjs +1 -1
  270. package/dist/services/model-registry/index.d.mts +1 -1
  271. package/dist/services/model-registry/index.mjs +1 -1
  272. package/dist/services/preferences/index.d.mts +2 -2
  273. package/dist/services/preferences/schemas.d.mts +1 -1
  274. package/dist/services/preferences/storage-namespace.d.mts +2 -2
  275. package/dist/services/provider-context/index.d.mts +1 -1
  276. package/dist/services/provider-context/index.mjs +1 -1
  277. package/dist/services/provider-runtime/index.mjs +1 -1
  278. package/dist/services/session/handlers/index.d.mts +2 -2
  279. package/dist/services/session/handlers/index.mjs +1 -1
  280. package/dist/services/session/index.d.mts +10 -10
  281. package/dist/services/session/index.mjs +1 -1
  282. package/dist/services/session/messages/namespace.d.mts +1 -1
  283. package/dist/services/session/messages/namespace.mjs +1 -1
  284. package/dist/services/session/orchestrator-testing/index.d.mts +1 -1
  285. package/dist/services/session/orchestrator-testing/index.mjs +1 -1
  286. package/dist/services/session/session-events/namespace.d.mts +1 -1
  287. package/dist/services/session/session-events/namespace.mjs +1 -1
  288. package/dist/services/session/storage/namespace.d.mts +1 -1
  289. package/dist/services/session/storage/schema.d.mts +2 -2
  290. package/dist/services/session/storage/schema.mjs +1 -1
  291. package/dist/services/session/testing/index.d.mts +12 -4
  292. package/dist/services/session/testing/index.mjs +36 -4
  293. package/dist/services/session/testing/orchestrator-shared.d.mts +1 -1
  294. package/dist/services/session/testing/orchestrator-shared.mjs +1 -1
  295. package/dist/services/session/turns/namespace.d.mts +1 -1
  296. package/dist/services/session/turns/namespace.mjs +1 -1
  297. package/dist/services/session-editor/index.d.mts +1 -1
  298. package/dist/services/session-editor/index.mjs +1 -1
  299. package/dist/services/settings/index.d.mts +3 -3
  300. package/dist/services/settings/index.mjs +1 -1
  301. package/dist/services/settings/namespace.d.mts +8 -8
  302. package/dist/services/settings/namespace.mjs +1 -1
  303. package/dist/services/settings/storage/clients-namespace.d.mts +1 -1
  304. package/dist/services/settings/storage/clients-namespace.mjs +1 -1
  305. package/dist/services/settings/storage/extension-configs/namespace.d.mts +3 -3
  306. package/dist/services/settings/storage/index.d.mts +3 -3
  307. package/dist/services/settings/storage/index.mjs +1 -1
  308. package/dist/services/settings/storage/providers-namespace.d.mts +1 -1
  309. package/dist/services/settings/storage/providers-namespace.mjs +1 -1
  310. package/dist/services/subagent/index.d.mts +1 -1
  311. package/dist/services/subagent/index.mjs +1 -1
  312. package/dist/services/subagent-template/index.d.mts +2 -2
  313. package/dist/services/subagent-template/namespace.d.mts +1 -1
  314. package/dist/services/subagent-template/schemas.d.mts +1 -1
  315. package/dist/services/tool-approval/index.d.mts +1 -1
  316. package/dist/services/tool-approval/index.mjs +1 -1
  317. package/dist/services/tools/index.d.mts +1 -1
  318. package/dist/services/tools/index.mjs +1 -1
  319. package/dist/services/tray-menu/index.d.mts +3 -3
  320. package/dist/services/tray-menu/index.mjs +1 -1
  321. package/dist/services/tray-menu/namespace.d.mts +1 -1
  322. package/dist/services/tray-menu/schemas.d.mts +1 -1
  323. package/dist/services/turn/index.d.mts +1 -1
  324. package/dist/services/turn/namespace.d.mts +1 -1
  325. package/dist/services/workflow-transitions/index.d.mts +1 -1
  326. package/dist/services/workflow-transitions/index.mjs +1 -1
  327. package/dist/session-BMy2kRpX.mjs +90 -0
  328. package/dist/session-Cipx34j6.mjs +1 -0
  329. package/dist/{session-lineage-B_JW5LpF.d.mts → session-lineage-B_PVa1XN.d.mts} +1 -1
  330. package/dist/shared-BFVuCDPx.mjs +1 -0
  331. package/dist/{skill-BR6rkfLe.mjs → skill-C1D51nhh.mjs} +1 -1
  332. package/dist/{src-DD0v-nIj.mjs → src-xbmzokNe.mjs} +1 -1
  333. package/dist/storage/drizzle/client.d.mts +1 -1
  334. package/dist/storage/drizzle/client.mjs +1 -1
  335. package/dist/storage/drizzle/index.d.mts +42 -2
  336. package/dist/storage/drizzle/index.mjs +1 -1
  337. package/dist/storage/handlers/drizzle/index.d.mts +1 -1
  338. package/dist/storage/handlers/drizzle/index.mjs +1 -1
  339. package/dist/storage/handlers/index.d.mts +1 -1
  340. package/dist/storage/handlers/index.mjs +1 -1
  341. package/dist/tool-approval-service-BVgN9Q1r.mjs +1 -0
  342. package/dist/{tools-PdG9fO1M.mjs → tools-DxwHox1a.mjs} +1 -1
  343. package/dist/{transition-Du3MQzJV.d.mts → transition-BF1nevaC.d.mts} +7 -34
  344. package/dist/{types-DMLDHFR9.d.mts → types-BNjPhj_a.d.mts} +1 -1
  345. package/dist/{types-Dzrwa1GY.d.mts → types-CijlWGwb.d.mts} +2036 -618
  346. package/dist/types-ClpEaoAm.d.mts +2917 -0
  347. package/dist/{types-D7_kevBK.d.mts → types-xCdGghb2.d.mts} +1 -1
  348. package/dist/ui-hooks/index.d.mts +29 -2
  349. package/dist/ui-hooks/index.mjs +1 -1
  350. package/dist/ui-kernel/index.d.mts +2 -2
  351. package/dist/ui-kernel/pages/schemas.d.mts +1 -1
  352. package/dist/ui-views/index.d.mts +1 -1
  353. package/dist/utils/index.d.mts +77 -1
  354. package/dist/utils/index.mjs +2 -2
  355. package/dist/{version-CoCeMxDT.mjs → version-BfNnVAGr.mjs} +1 -1
  356. package/dist/{view-builder-DeFd-k7C.d.mts → view-builder-Bc9dx6jF.d.mts} +1 -1
  357. package/dist/{visibility-qhGWmpSJ.mjs → visibility-Dl1o2I01.mjs} +1 -1
  358. package/dist/{worker-node-Bl9_vqYi.mjs → worker-node-BDOYPEpi.mjs} +1 -1
  359. package/dist/{worker-node-DZTuT1DS.mjs → worker-node-DJ41Tr-F.mjs} +1 -1
  360. package/dist/workflow-Hzc5jlnV.mjs +1 -0
  361. package/dist/workflow-engine/execution-attempt-repository.d.mts +1 -1
  362. package/dist/workflow-engine/index.d.mts +114 -395
  363. package/dist/workflow-engine/index.mjs +1 -1
  364. package/dist/workflow-engine/package.d.mts +1 -1
  365. package/dist/workflow-engine/package.mjs +1 -1
  366. package/dist/workflow-engine/provider-operation.d.mts +1 -1
  367. package/dist/workflow-engine/testing/index.d.mts +2 -2
  368. package/dist/workflow-engine/testing/index.mjs +1 -1
  369. package/dist/workflow-engine/testing/sqlite.d.mts +1 -1
  370. package/dist/workflow-engine/testing/sqlite.mjs +27 -27
  371. package/dist/workflow-engine/workflow-orchestrator.mjs +1 -1
  372. package/dist/workflow-engine/workflow-trigger-binding-consumer.d.mts +46 -0
  373. package/dist/workflow-engine/workflow-trigger-binding-consumer.mjs +1 -0
  374. package/dist/{workflow-transitions-DSc45ixc.mjs → workflow-transitions-DM0fN_eP.mjs} +1 -1
  375. package/dist/workflow-worker-DARC7UZl.mjs +1 -0
  376. package/dist/zod-json-schema-BAGAFfCN.mjs +1 -0
  377. package/package.json +29 -1
  378. package/dist/adapter-D5c5LrPN.mjs +0 -1
  379. package/dist/artifact-DGiXqb11.mjs +0 -1
  380. package/dist/attach-error-C3tngg6J.mjs +0 -1
  381. package/dist/authority-state-bootstrap-GPL_tqaT.mjs +0 -1
  382. package/dist/await-trigger-I3lrepb8.mjs +0 -1
  383. package/dist/bus-B6SAjgOC.mjs +0 -2
  384. package/dist/bus-C2l3K74u.mjs +0 -1
  385. package/dist/extension-DCA4pYrY.mjs +0 -1
  386. package/dist/extension-hjOPs10e.mjs +0 -1
  387. package/dist/framework-packages-C3RWfJDk.mjs +0 -1
  388. package/dist/handlers-CfnLyLfE.mjs +0 -57
  389. package/dist/load-extensions-D0DfjYLC.mjs +0 -1
  390. package/dist/model-BGgVmRnN.mjs +0 -1
  391. package/dist/namespace-DJfUADSV.mjs +0 -1
  392. package/dist/orchestrator-shared-BxmHCPvx.mjs +0 -1
  393. package/dist/package-CNUPPcU1.mjs +0 -7
  394. package/dist/package-Dft_RItb.mjs +0 -1
  395. package/dist/schemas-Cm09dXL4.mjs +0 -1
  396. package/dist/scoped-bus-C9BdNwfM.mjs +0 -1
  397. package/dist/session-BOGCd18q.mjs +0 -1
  398. package/dist/session-BTFiDoGz.mjs +0 -76
  399. package/dist/shared-BQ0CHIVy.mjs +0 -1
  400. package/dist/tool-approval-service-kBA0fRzm.mjs +0 -1
  401. package/dist/types-CJ_QZ1yW.d.mts +0 -1487
  402. package/dist/workflow-BfDbgtIQ.mjs +0 -1
  403. package/dist/workflow-worker-BN9XPxQO.mjs +0 -1
  404. package/dist/{adapter-auth-runtime-DO-FVTXg.mjs → adapter-auth-runtime-D9Lnl7cc.mjs} +0 -0
  405. package/dist/{adapter-binding-DQchUtrK.d.mts → adapter-binding-B-FBoCys.d.mts} +0 -0
  406. package/dist/{attempt-record-codec-CqO1_XnE.mjs → attempt-record-codec-DaFLKR5C.mjs} +0 -0
  407. package/dist/{base-orchestrator-BilsQNW1.d.mts → base-orchestrator-D9u4NyiM.d.mts} +0 -0
  408. package/dist/{capability-service-BqiLlRGA.mjs → capability-service-CJHNkjvm.mjs} +0 -0
  409. package/dist/{client-B--e2qcU.d.mts → client-4ihewPUm.d.mts} +0 -0
  410. package/dist/{client-binary-version-verifier-taewmKTY.mjs → client-binary-version-verifier-DJajc_Ff.mjs} +0 -0
  411. package/dist/{client-binary-version-verifier-CgjM_vGF.d.mts → client-binary-version-verifier-jDDZ64Ah.d.mts} +0 -0
  412. package/dist/{clients-namespace-DfxjG2ZP.d.mts → clients-namespace-DFWuUawf.d.mts} +0 -0
  413. package/dist/{config-namespace-BCqvufbD.d.mts → config-namespace-D1kyZj0B.d.mts} +0 -0
  414. package/dist/{create-static-mount-bbQhTt6W.mjs → create-static-mount-9tnGpIeK.mjs} +0 -0
  415. package/dist/{cross-spawn-B57KZuns.mjs → cross-spawn-BIgueAqr.mjs} +0 -0
  416. package/dist/{cursor-storage-DIFK_9hg.mjs → cursor-storage-ROWfiTh1.mjs} +0 -0
  417. package/dist/{definition-gnKgXU91.d.mts → definition-DB-kKc0d.d.mts} +0 -0
  418. package/dist/{definitions-xrrY0wgz.mjs → definitions-CF6YmEhL.mjs} +0 -0
  419. package/dist/{descriptor-to-package-DvF08krT.mjs → descriptor-to-package-BecVCopf.mjs} +0 -0
  420. package/dist/{drizzle-z_0SiGY8.mjs → drizzle-CPv3vdTE.mjs} +0 -0
  421. package/dist/{esm-CltRnX8_.mjs → esm-CBFWM8u_.mjs} +0 -0
  422. package/dist/{event-CmVjR6Ib.mjs → event-DR8U9Efx.mjs} +0 -0
  423. package/dist/{facet-BCI00njh.mjs → facet-DVsW12iF.mjs} +0 -0
  424. package/dist/{filesystem-service-CQ9yVkSz.d.mts → filesystem-service-Cm2RHKBa.d.mts} +0 -0
  425. package/dist/{handler-Cbv9FqDO.mjs → handler-Bqlk-6BY.mjs} +0 -0
  426. package/dist/{host-Caq6ZfSJ.mjs → host-k5yoyKHg.mjs} +0 -0
  427. package/dist/{identity-D6guMtmi.mjs → identity-DC3Pk0ps.mjs} +0 -0
  428. package/dist/{index-dtsLKOID.d.mts → index-42UdYStR.d.mts} +0 -0
  429. package/dist/{index-DR40QWlw.d.mts → index-BJAB-BW_.d.mts} +0 -0
  430. package/dist/{index-Dm1nUxCF.d.mts → index-BJMezANn.d.mts} +0 -0
  431. package/dist/{index-CnMu8BQl.d.mts → index-BQprJNA_.d.mts} +0 -0
  432. package/dist/{index-Cv-o5Krs.d.mts → index-BRCrFirq.d.mts} +0 -0
  433. package/dist/{index-BVRQEpAg.d.mts → index-BRzHs7Bx.d.mts} +6 -6
  434. /package/dist/{index-DXN_L5D6.d.mts → index-BSbGB23v.d.mts} +0 -0
  435. /package/dist/{index-vA--0lOM.d.mts → index-BVcQcphK.d.mts} +0 -0
  436. /package/dist/{index-ye0oklfU.d.mts → index-BcvqDfcN.d.mts} +0 -0
  437. /package/dist/{index-CGZQVTid.d.mts → index-BeENojSx2.d.mts} +0 -0
  438. /package/dist/{index-DjgLchuQ.d.mts → index-Beo_Ik8-.d.mts} +0 -0
  439. /package/dist/{index-sS6KUlrx.d.mts → index-BgGe9WZz.d.mts} +0 -0
  440. /package/dist/{index-CWHfOz6d.d.mts → index-CK3f0bAL.d.mts} +0 -0
  441. /package/dist/{index-DZunhZec.d.mts → index-CQuRTeRa.d.mts} +0 -0
  442. /package/dist/{index-jTaAHsul.d.mts → index-CRmE88hi.d.mts} +0 -0
  443. /package/dist/{index-CjdRdsd0.d.mts → index-CvW9_SzR.d.mts} +0 -0
  444. /package/dist/{index-ByKi34v5.d.mts → index-CxSSdIZz.d.mts} +0 -0
  445. /package/dist/{index-vcSj12YQ.d.mts → index-E4SET1AA.d.mts} +0 -0
  446. /package/dist/{index-DN4NOCqN2.d.mts → index-Ol9RBB0W2.d.mts} +0 -0
  447. /package/dist/{index-BIdsFcQs2.d.mts → index-aoxdnhJ42.d.mts} +0 -0
  448. /package/dist/{index-SsBHjUqA.d.mts → index-nydhGvXa.d.mts} +0 -0
  449. /package/dist/{jsonl-transport-bQl3JwIu.mjs → jsonl-transport-Bp_6pB2a.mjs} +0 -0
  450. /package/dist/{lib-DOBXZmYX.mjs → lib-Bwdd2m81.mjs} +0 -0
  451. /package/dist/{model-registry-CmgcPDH3.mjs → model-registry-Y854mUml.mjs} +0 -0
  452. /package/dist/{model-registry-xyBKSye-.mjs → model-registry-yURX738J.mjs} +0 -0
  453. /package/dist/{modes-BheyN7SS.mjs → modes-DmUsjHdV.mjs} +0 -0
  454. /package/dist/{namespace-HO2J9sO8.mjs → namespace-B9FEGuEu.mjs} +0 -0
  455. /package/dist/{namespace-jDhZjw-i.d.mts → namespace-Bi3CmYQy.d.mts} +0 -0
  456. /package/dist/{namespace-GPA7zots.d.mts → namespace-BusZERU8.d.mts} +0 -0
  457. /package/dist/{namespace-BOkKoq34.d.mts → namespace-ByP1Iipi.d.mts} +0 -0
  458. /package/dist/{namespace-YytVKIgI.d.mts → namespace-C1D77w7U.d.mts} +0 -0
  459. /package/dist/{namespace-CErHuXtb.d.mts → namespace-C6CVEGH8.d.mts} +0 -0
  460. /package/dist/{namespace-C-9si-fV.mjs → namespace-CfIW0hpQ.mjs} +0 -0
  461. /package/dist/{namespace-YxU1xf-K.mjs → namespace-CkBbNFSU.mjs} +0 -0
  462. /package/dist/{namespace-DWCEo-9M.d.mts → namespace-DX1Ec15L.d.mts} +0 -0
  463. /package/dist/{namespace-CWGKCNZm.mjs → namespace-DbNWsPFY.mjs} +0 -0
  464. /package/dist/{namespace-Cv1RFP7n.d.mts → namespace-Dgg0uoe6.d.mts} +0 -0
  465. /package/dist/{namespace-tGRAod3o.d.mts → namespace-s2y_NFKf.d.mts} +0 -0
  466. /package/dist/{namespace-Blp4c8GK.d.mts → namespace-yREpGJgG.d.mts} +0 -0
  467. /package/dist/{out-CvjtANXN.mjs → out-DrhwCgqM.mjs} +0 -0
  468. /package/dist/{packages-DtEEP0Vt.mjs → packages-FBv3fAOR.mjs} +0 -0
  469. /package/dist/{packages-BZ6pzFIq.d.mts → packages-N3-2Kl-Y.d.mts} +0 -0
  470. /package/dist/{platform-Bv8llU9c.mjs → platform-BrsMv_S3.mjs} +0 -0
  471. /package/dist/{provider-operation-Cxoe2SUr.d.mts → provider-operation-DJ_TLZFf.d.mts} +0 -0
  472. /package/dist/{providers-Co5UszRH.mjs → providers-CCcn4Ndp.mjs} +0 -0
  473. /package/dist/{providers-namespace-DjFkmvBR.d.mts → providers-namespace-DeJBh6MP.d.mts} +0 -0
  474. /package/dist/{quick-lru-CrOpWwrf.mjs → quick-lru-uwB0hP-y.mjs} +0 -0
  475. /package/dist/{schema-introspection-DgWQCpwx.mjs → schema-introspection-C1wvklj9.mjs} +0 -0
  476. /package/dist/{schema-Db-y-09L.mjs → schema-jIapW8Kb.mjs} +0 -0
  477. /package/dist/{schemas-CR8hSqTy.d.mts → schemas-B7zo7Zcx.d.mts} +0 -0
  478. /package/dist/{schemas-CqRm0i9a.mjs → schemas-BNdiVBWh.mjs} +0 -0
  479. /package/dist/{schemas-B1NWNASS.d.mts → schemas-C-Bm6Oac.d.mts} +0 -0
  480. /package/dist/{schemas-BO7uOum6.d.mts → schemas-CD0wOQxx.d.mts} +0 -0
  481. /package/dist/{schemas-N6x2z7Lf.d.mts → schemas-CeUI2i5j.d.mts} +0 -0
  482. /package/dist/{schemas-CwbYk_kZ.d.mts → schemas-Cg-Kwp8c.d.mts} +0 -0
  483. /package/dist/{schemas-BtZqovRH.d.mts → schemas-Cv3rR9Sz.d.mts} +0 -0
  484. /package/dist/{schemas-tDf_WiC8.mjs → schemas-CvHFbzdy.mjs} +0 -0
  485. /package/dist/{schemas-BsVYZviy.d.mts → schemas-DZH9lpxs.d.mts} +0 -0
  486. /package/dist/{schemas-BGExwp3j.mjs → schemas-DgwEVUt-.mjs} +0 -0
  487. /package/dist/{schemas-Bfxskx_2.mjs → schemas-mLpOfMoN.mjs} +0 -0
  488. /package/dist/{schemas-CQyRBqD6.d.mts → schemas-qA279_j_.d.mts} +0 -0
  489. /package/dist/{schemas-miYxK_Z1.d.mts → schemas-sMoRnBdZ.d.mts} +0 -0
  490. /package/dist/{semver-DlM8znk4.mjs → semver-DTXuyLcK.mjs} +0 -0
  491. /package/dist/{server-lifecycle-Dsq56aqC.d.mts → server-lifecycle-C_8iKgat.d.mts} +0 -0
  492. /package/dist/{server-lifecycle-kmQ5PUDv.mjs → server-lifecycle-DKx_fWlq.mjs} +0 -0
  493. /package/dist/{shared-schemas-DXwyMCwZ.mjs → shared-schemas-aahW97QW.mjs} +0 -0
  494. /package/dist/{src-CCu8TwL6.mjs → src-DHqsl5Pg.mjs} +0 -0
  495. /package/dist/{storage-namespace-BSrv0vXR.mjs → storage-namespace-Dz2jsssp.mjs} +0 -0
  496. /package/dist/{storage-namespace-dfywhXR3.d.mts → storage-namespace-Tf3P5yJ5.d.mts} +0 -0
  497. /package/dist/{storage-namespace-definition-BvlX0QV_.d.mts → storage-namespace-definition-BsnYAPot.d.mts} +0 -0
  498. /package/dist/{storage-namespace-definition-CkMKt7-I.mjs → storage-namespace-definition-CDef0E20.mjs} +0 -0
  499. /package/dist/{supports-color-DUugCQsK.mjs → supports-color-i7OTnKcZ.mjs} +0 -0
  500. /package/dist/{telemetry-Pr3oP2rk.mjs → telemetry-BvCBUjFg.mjs} +0 -0
  501. /package/dist/{timeout-DWDhddRJ.mjs → timeout-B0nYjLc8.mjs} +0 -0
  502. /package/dist/{tray-menu-service-BBLa-Rcv.mjs → tray-menu-service-Deo6yyP8.mjs} +0 -0
  503. /package/dist/{types-BrcjaNPZ.d.mts → types-CNS55jvt.d.mts} +0 -0
  504. /package/dist/{types-b54n1o57.d.mts → types-Ce6LL25v.d.mts} +0 -0
  505. /package/dist/{ui-config-CyCdlns_.mjs → ui-config-BIyGzMNL.mjs} +0 -0
  506. /package/dist/{variant-krjlTdJt.mjs → variant-B4uWdxW7.mjs} +0 -0
  507. /package/dist/{window-registry-BDnZLPVx.d.mts → window-registry-BLtVx3Iw.d.mts} +0 -0
  508. /package/dist/{window-registry-I-imZHV_.mjs → window-registry-CoBJq3u4.mjs} +0 -0
@@ -1,1487 +0,0 @@
1
- import { z } from "zod";
2
- import { DeferredPromise, TimeoutConfig, TrackedTimeoutConfig } from "@makaio/framework/utils";
3
- import { AuthenticationError, ExtractSubjectPayload, ExtractSubjectResponse, HandlerForSubjectDefinition, ScopedSubjectDefinition, SubjectRecord } from "@makaio/framework/core";
4
- import { IFilteredBus, IMakaioBus, OnOptions, ScopedBus } from "@makaio/framework/bus";
5
- import { AIModel, AIReasoningLevel, AIReasoningLevel as AIReasoningLevel$1, AdapterAuthBinding, AdapterAuthConstant, AdapterProviderAuth, AdapterProviderDefinitionContract, AgentSchemas, AgentSubjects, AuthCredentialRef, CacheStrategy, JsonValue, McpRuntimeSessionContext, McpSessionContext, McpToolState, Message, MessageBlock, MessageDeliveryMode, MessageDeliveryMode as MessageDeliveryMode$1, MessageInput, MessageOutcome, NativeForkDirective, ProtocolId, ProviderContext, ReasoningLevelMap as ReasoningLevelMap$1, RequestCorrelationContext, ResolvedProviderAuth, ResponseSchemaDescriptor, SendMessageResultInnerResult, SessionContext, StructuredOutputValidation, SystemPrompt, ToolListItem } from "@makaio/framework/contracts";
6
- import { ClientExecutionContext } from "@makaio/framework/contracts/client";
7
- import { SetRequired } from "type-fest";
8
-
9
- //#region adapters/core/src/agent/session-tool-ledger.d.ts
10
- /**
11
- * Single tool tracked in the session ledger.
12
- * Accumulates injection, discovery, and call history across the session lifetime.
13
- */
14
- interface ToolLedgerEntry {
15
- /** Namespaced tool name, e.g. "github__create_issue" */
16
- readonly fullName: string;
17
- /** Original tool name without server prefix, e.g. "create_issue" */
18
- readonly originalName: string;
19
- /** MCP server that provides the tool, e.g. "github" */
20
- readonly serverName: string;
21
- /** Whether the tool is currently in the direct-injection set */
22
- injected: boolean;
23
- /** Turn number when this tool was last included in the injection set */
24
- lastInjectedAtTurn: number | undefined;
25
- /** Whether the model has seen this tool via mcp_discover or mcp_call */
26
- discovered: boolean;
27
- /** Turn number when this tool was first discovered (set once, never overwritten) */
28
- firstDiscoveredAtTurn: number | undefined;
29
- /** Total number of mcp_call invocations across the session */
30
- callCount: number;
31
- /** Turn number of the most recent mcp_call invocation */
32
- lastCalledAtTurn: number | undefined;
33
- }
34
- /**
35
- * Narrowed view of McpSessionContext that the ledger needs.
36
- * Decouples the ledger from the full session context shape.
37
- */
38
- interface LedgerSessionContext {
39
- /** Tools resolved for direct injection in this session */
40
- readonly directTools: readonly McpToolState[];
41
- /** Tools available for discovery (not direct-injected) */
42
- readonly discoverableTools: readonly McpToolState[];
43
- }
44
- /**
45
- * Public contract for the session-scoped tool ledger.
46
- * Tracks injection, discovery, and call state for all MCP tools during a session.
47
- */
48
- interface ISessionToolLedger {
49
- /**
50
- * Replace the current injection set with the provided list.
51
- * Tools not in the new list have their `injected` flag cleared (eviction sweep).
52
- * @param tools - The new set of directly-injected tools
53
- * @param turnNumber - The current turn number
54
- */
55
- recordInjection(tools: readonly ToolListItem[], turnNumber: number): void;
56
- /**
57
- * Record that the model discovered a tool.
58
- * Applies first-discovery semantics: `firstDiscoveredAtTurn` is set only once.
59
- * @param toolFullName - The namespaced tool name, e.g. "github__create_issue"
60
- * @param turnNumber - The current turn number
61
- */
62
- recordDiscovery(toolFullName: string, turnNumber: number): void;
63
- /**
64
- * Record one mcp_call invocation for a tool.
65
- * Implies discovery: also sets `discovered` and `firstDiscoveredAtTurn` if unset.
66
- * @param toolFullName - The namespaced tool name, e.g. "github__create_issue"
67
- * @param turnNumber - The current turn number
68
- */
69
- recordCall(toolFullName: string, turnNumber: number): void;
70
- /**
71
- * Return all entries where `injected === true`.
72
- * @returns Snapshot of currently-injected tool entries
73
- */
74
- getInjectedTools(): readonly ToolLedgerEntry[];
75
- /**
76
- * Return the total call count for a tool, or 0 if not tracked.
77
- * @param toolFullName - The namespaced tool name
78
- * @returns Call count (0 for unknown tools)
79
- */
80
- getCallCount(toolFullName: string): number;
81
- /**
82
- * Return a single ledger entry by full name, or undefined if not tracked.
83
- * @param toolFullName - The namespaced tool name
84
- * @returns The entry, or undefined
85
- */
86
- getEntry(toolFullName: string): ToolLedgerEntry | undefined;
87
- /**
88
- * Return all tracked entries regardless of state.
89
- * @returns Snapshot of all ledger entries
90
- */
91
- getAllEntries(): readonly ToolLedgerEntry[];
92
- /**
93
- * Phase 2 seam: suggest the optimal injection set for the next turn.
94
- * Phase 1 pass-through: returns `context.directTools` mapped to ToolListItem format.
95
- * @param context - Current session context providing direct and discoverable tools
96
- * @param currentTurnNumber - The current turn number (for future scoring heuristics)
97
- * @returns Suggested list of tools to inject for the next turn
98
- */
99
- suggestInjectionSet(context: LedgerSessionContext, currentTurnNumber: number): Promise<readonly ToolListItem[]>;
100
- }
101
- /**
102
- * Agent-scoped ledger that tracks every MCP tool's injection, discovery, and
103
- * call history within a single agent lifecycle.
104
- *
105
- * One instance is created per agent factory call and discarded when
106
- * the agent is torn down. If the adapter switches connectors mid-session
107
- * (e.g. model swap), the same ledger is passed to the new connector so
108
- * history is preserved across the connector boundary.
109
- *
110
- * Follows the same plain-class, no-bus pattern as {@link ToolCallTracker}.
111
- */
112
- declare class SessionToolLedger implements ISessionToolLedger {
113
- private readonly entries;
114
- /**
115
- * Upsert an entry for the given full name, creating it if absent.
116
- * @param fullName - Namespaced tool name
117
- * @returns The existing or newly-created entry (mutable reference)
118
- */
119
- private upsert;
120
- /**
121
- * Replace the current injection set with the provided list.
122
- * Tools absent from the new list have their `injected` flag cleared (eviction sweep).
123
- * @param tools - The new set of directly-injected tools
124
- * @param turnNumber - The current turn number
125
- */
126
- recordInjection(tools: readonly ToolListItem[], turnNumber: number): void;
127
- /**
128
- * Record that the model discovered a tool.
129
- * Applies first-discovery semantics: `firstDiscoveredAtTurn` is only set once.
130
- * @param toolFullName - The namespaced tool name, e.g. "github__create_issue"
131
- * @param turnNumber - The current turn number
132
- */
133
- recordDiscovery(toolFullName: string, turnNumber: number): void;
134
- /**
135
- * Record one mcp_call invocation for a tool.
136
- * Implies discovery: also sets `discovered` and `firstDiscoveredAtTurn` if unset.
137
- * @param toolFullName - The namespaced tool name, e.g. "github__create_issue"
138
- * @param turnNumber - The current turn number
139
- */
140
- recordCall(toolFullName: string, turnNumber: number): void;
141
- /**
142
- * Return all entries where `injected === true`.
143
- * @returns Snapshot of currently-injected tool entries
144
- */
145
- getInjectedTools(): readonly ToolLedgerEntry[];
146
- /**
147
- * Return the total call count for a tool, or 0 if not tracked.
148
- * @param toolFullName - The namespaced tool name
149
- * @returns Call count (0 for unknown tools)
150
- */
151
- getCallCount(toolFullName: string): number;
152
- /**
153
- * Return a single ledger entry by full name, or undefined if not tracked.
154
- * @param toolFullName - The namespaced tool name
155
- * @returns The entry, or undefined
156
- */
157
- getEntry(toolFullName: string): ToolLedgerEntry | undefined;
158
- /**
159
- * Return all tracked entries regardless of state.
160
- * @returns Snapshot of all ledger entries
161
- */
162
- getAllEntries(): readonly ToolLedgerEntry[];
163
- /**
164
- * Phase 1 pass-through: return `context.directTools` mapped to ToolListItem format.
165
- * Phase 2 will replace this with a scoring heuristic that factors in call history
166
- * and discovery patterns.
167
- * @param context - Current session context providing direct and discoverable tools
168
- * @param _currentTurnNumber - The current turn number (reserved for Phase 2 scoring heuristics)
169
- * @returns Suggested list of tools to inject for the next turn
170
- */
171
- suggestInjectionSet(context: LedgerSessionContext, _currentTurnNumber: number): Promise<readonly ToolListItem[]>;
172
- }
173
- //#endregion
174
- //#region node_modules/emittery/index.d.ts
175
- /**
176
- Removes an event subscription.
177
- */
178
- type UnsubscribeFunction = () => void;
179
- //#endregion
180
- //#region adapters/core/src/message-handle/types.d.ts
181
- /**
182
- * Result of a message operation.
183
- */
184
- type MessageResult = {
185
- result?: SendMessageResultInnerResult | null;
186
- error?: Error | string;
187
- outcome: MessageOutcome; /** Present when outcome='superseded': the messageId that replaced this one */
188
- supersededBy?: string; /** Present when outcome='merged': the messageId this was folded into */
189
- mergedInto?: string;
190
- /**
191
- * Structured-output validation result for this turn.
192
- * Present only when a {@link ResponseSchemaDescriptor} was active and validation ran.
193
- */
194
- structuredOutputValidation?: StructuredOutputValidation;
195
- };
196
- /**
197
- * Lifecycle states for a queued message.
198
- */
199
- type MessageState = 'queued' | 'acknowledged' | 'completed' | 'cancelled';
200
- /**
201
- * Options for sending a message.
202
- */
203
- interface SendMessageOptions {
204
- /**
205
- * Custom identifier for message tracking (generated if not provided).
206
- */
207
- messageId?: string;
208
- /**
209
- * Controls delivery behavior.
210
- * @defaultValue 'enqueue'
211
- */
212
- deliveryMode?: MessageDeliveryMode;
213
- }
214
- /**
215
- * Options bag used when creating a message handle.
216
- *
217
- * Passed to {@link MessageHandle} via `AIAgentConnector.createMessageHandle`.
218
- */
219
- interface MessageHandleOptions {
220
- /** Optional stable message identifier; autogenerated when omitted. */
221
- messageId?: string;
222
- /** Optional delivery semantics for queue processing. */
223
- deliveryMode?: MessageDeliveryMode;
224
- /** Optional prior conversation messages to materialize for the turn. */
225
- messageHistory?: Message[];
226
- /** Optional per-turn metadata/context payload for prompt materialization. */
227
- turnContext?: Record<string, JsonValue>;
228
- /** Content-free transport context that must never be added to model input. */
229
- requestCorrelation?: RequestCorrelationContext;
230
- /** Caller-expressed caching intent for the injected history prefix. */
231
- cacheStrategy?: CacheStrategy;
232
- /**
233
- * Per-turn structured-output schema descriptor.
234
- * When set, the agent's structured-output manager validates the terminal
235
- * message against this schema before emitting completion events.
236
- */
237
- responseSchema?: ResponseSchemaDescriptor;
238
- /**
239
- * Whether this message handle was created for an internal retry turn.
240
- * When `true`, the `onMessageSent` callback is suppressed so no
241
- * `user_message.sent` event is emitted for the synthetic retry message.
242
- */
243
- internalRetry?: boolean;
244
- /**
245
- * Lifecycle turnId from the session orchestrator. Distinct from
246
- * `requestCorrelation.turnId` (transport correlation, which may be present
247
- * when no lifecycle turn exists): all user_message lifecycle events for the
248
- * handle pair by this value.
249
- */
250
- turnId?: string;
251
- /**
252
- * Caller decision on provider-native session resume for this dispatch.
253
- * When `false`, the session layer must not arm its pending start-time
254
- * resume target for the turn this handle drives (see
255
- * `ConnectorSendMessageOptions.useNativeResume` for the full contract).
256
- */
257
- useNativeResume?: boolean;
258
- }
259
- /**
260
- * Processing state for agent orchestration.
261
- */
262
- type ProcessingState = 'idle' | 'processing_started' | 'turn_started' | 'step_started' | 'step_finished' | 'turn_finished' | 'processing_finished' | 'active' | 'paused';
263
- //#endregion
264
- //#region adapters/core/src/utils/normalizeMessageInput.d.ts
265
- type NormalizedMessageInput = Required<Message> & {
266
- blocks: MessageBlock[];
267
- message?: string;
268
- };
269
- /**
270
- * Normalizes various MessageInput formats into a consistent structure with blocks and optional message text.
271
- * @param input - The message input to normalize (string or Message object)
272
- * @returns Normalized message with role, blocks array, and optional message text
273
- */
274
- declare function normalizeMessageInput(input: MessageInput): NormalizedMessageInput;
275
- //#endregion
276
- //#region adapters/core/src/message-handle/message-handle.d.ts
277
- type CompletionTransform = (result: MessageResult) => MessageResult | Promise<MessageResult>;
278
- type CompletionObserver = (result: MessageResult) => void;
279
- type CompletionNotification = (handle: MessageHandle, result: MessageResult) => void | Promise<void>;
280
- declare class MessageHandle {
281
- readonly messageId: string;
282
- readonly message: NormalizedMessageInput;
283
- readonly deliveryMode: MessageDeliveryMode;
284
- /**
285
- * Per-turn structured-output schema descriptor.
286
- * When present, the agent validates the terminal message against this
287
- * schema before resolving completion and emitting terminal events.
288
- */
289
- readonly responseSchema?: ResponseSchemaDescriptor | undefined;
290
- /**
291
- * Internal structured-output retry turns must stay hidden from user-message
292
- * lifecycle events while still taking precedence over queued user turns.
293
- */
294
- readonly internalRetry: boolean;
295
- /** Content-free transport correlation for provider requests. */
296
- readonly requestCorrelation?: RequestCorrelationContext | undefined;
297
- /**
298
- * Lifecycle turnId from the session orchestrator (`agent.sendMessage.turnId`).
299
- * Distinct from `requestCorrelation.turnId`, which is transport correlation
300
- * and may be present when no lifecycle turn exists. All user_message
301
- * lifecycle events for this handle (sent/acknowledged/completed) pair by
302
- * this value.
303
- */
304
- readonly turnId?: string | undefined;
305
- /**
306
- * Caller decision on provider-native session resume for this dispatch.
307
- * When `false`, the session layer must not arm its pending start-time
308
- * resume target for the turn this handle drives (see
309
- * `ConnectorSendMessageOptions.useNativeResume` for the full contract).
310
- */
311
- readonly useNativeResume?: boolean | undefined;
312
- protected readonly deferredCompletion: DeferredPromise<MessageResult>;
313
- protected readonly deferredAcknowledgement: DeferredPromise<boolean>;
314
- state: MessageState;
315
- private isAcknowledged;
316
- private completionResult;
317
- private completionStarted;
318
- private readonly completionTransforms;
319
- private readonly completionObservers;
320
- /** If this message was merged into another, the winner's messageId */
321
- mergedInto?: string;
322
- /** If this is the merge winner, messageIds that were folded in */
323
- mergedFrom?: string[];
324
- /** If this message was superseded by replace/immediate, the replacer's messageId */
325
- supersededBy?: string;
326
- /** Adapter session ID - resolved when processing starts */
327
- private readonly deferredAdapterSessionId;
328
- private _adapterSessionId?;
329
- /** Curated message history from sessionContext (mutable for merge propagation) */
330
- private _messageHistory?;
331
- /** Shared cache strategy type from contracts keeps handle options and session context aligned. */
332
- private _cacheStrategy?;
333
- /** Turn-scoped context from PreUserMessage hooks (mutable for merge propagation) */
334
- private _turnContext?;
335
- constructor(messageId: string, message: NormalizedMessageInput, deliveryMode: MessageDeliveryMode, /** Curated message history from sessionContext */
336
-
337
- messageHistory?: Message[], /** Turn-scoped context from PreUserMessage hooks */
338
-
339
- turnContext?: Record<string, JsonValue>,
340
- /**
341
- * Per-turn structured-output schema descriptor.
342
- * When present, the agent validates the terminal message against this
343
- * schema before resolving completion and emitting terminal events.
344
- */
345
-
346
- responseSchema?: ResponseSchemaDescriptor | undefined,
347
- /**
348
- * Internal structured-output retry turns must stay hidden from user-message
349
- * lifecycle events while still taking precedence over queued user turns.
350
- */
351
-
352
- internalRetry?: boolean, /** Caller-expressed caching intent for the injected history prefix */
353
-
354
- cacheStrategy?: CacheStrategy, /** Content-free transport correlation for provider requests. */
355
-
356
- requestCorrelation?: RequestCorrelationContext | undefined,
357
- /**
358
- * Lifecycle turnId from the session orchestrator (`agent.sendMessage.turnId`).
359
- * Distinct from `requestCorrelation.turnId`, which is transport correlation
360
- * and may be present when no lifecycle turn exists. All user_message
361
- * lifecycle events for this handle (sent/acknowledged/completed) pair by
362
- * this value.
363
- */
364
-
365
- turnId?: string | undefined,
366
- /**
367
- * Caller decision on provider-native session resume for this dispatch.
368
- * When `false`, the session layer must not arm its pending start-time
369
- * resume target for the turn this handle drives (see
370
- * `ConnectorSendMessageOptions.useNativeResume` for the full contract).
371
- */
372
-
373
- useNativeResume?: boolean | undefined);
374
- /**
375
- * Curated message history from sessionContext
376
- * @returns The message history array or undefined if not set
377
- */
378
- get messageHistory(): Message[] | undefined;
379
- /** Set messageHistory (used by merge strategies to propagate history) */
380
- set messageHistory(value: Message[] | undefined);
381
- /**
382
- * Caller-expressed caching intent for the injected history prefix
383
- * @returns The cache strategy or undefined if not set
384
- */
385
- get cacheStrategy(): CacheStrategy | undefined;
386
- /** Set cacheStrategy (used by merge strategies to propagate) */
387
- set cacheStrategy(value: CacheStrategy | undefined);
388
- /**
389
- * Turn-scoped context from PreUserMessage hooks
390
- * @returns The turn context record or undefined if not set
391
- */
392
- get turnContext(): Record<string, JsonValue> | undefined;
393
- /** Set turnContext (used by merge strategies to propagate context) */
394
- set turnContext(value: Record<string, JsonValue> | undefined);
395
- /**
396
- * Get adapter session ID synchronously (undefined if not yet set)
397
- * @returns The adapter session ID or undefined if not yet set
398
- */
399
- get adapterSessionId(): string | undefined;
400
- /**
401
- * Set adapter session ID (called by connector when processing starts)
402
- */
403
- set adapterSessionId(value: string | undefined);
404
- /**
405
- * Wait for adapter session ID to be set
406
- * @returns Promise resolving to session ID when processing starts
407
- */
408
- waitForAdapterSessionId(): Promise<string>;
409
- /**
410
- * Whether the message was successfully delivered to the provider.
411
- *
412
- * Returns `true` only when {@link markAcknowledged} was called with
413
- * `delivered = true` (the default). Handles that were completed before
414
- * dispatch (merged, superseded, rejected) auto-resolve acknowledgment
415
- * with `false`, so this getter returns `false` for them.
416
- *
417
- * Used by {@link MessageLifecycleTracker} to decide whether
418
- * `agent.turn.completed` should pair with an earlier `agent.turn.started`.
419
- * @returns `true` when the handle was acknowledged as delivered
420
- */
421
- get wasDelivered(): boolean;
422
- get isProcessed(): boolean;
423
- getState(): MessageState;
424
- /**
425
- * Update message state
426
- * @param state - New message state
427
- */
428
- updateState(state: MessageState): void;
429
- /**
430
- * Cancel a pending message
431
- * @returns True if cancelled, false if already submitted/completed
432
- */
433
- cancel(): Promise<boolean>;
434
- /**
435
- * Mark message as acknowledged
436
- * @param delivered - Whether message was successfully delivered to provider
437
- * (e.g. false if immediate message arrived too late)
438
- */
439
- markAcknowledged(delivered?: boolean): void;
440
- /**
441
- * Register a transform that canonicalizes the terminal result before
442
- * {@link waitForCompletion} resolves.
443
- * @param transform - Transform applied to the raw provider completion result
444
- */
445
- addCompletionTransform(transform: CompletionTransform): void;
446
- /**
447
- * Register an observer that runs after all completion transforms have
448
- * produced the canonical terminal result, but before completion resolves.
449
- * @param observer - Observer called with the final completion result
450
- */
451
- addCompletionObserver(observer: CompletionObserver): void;
452
- /**
453
- * Mark message turn as completed
454
- * @param result - The result message or null if no result available
455
- */
456
- markCompleted(result: MessageResult): void;
457
- /**
458
- * Apply registered completion transforms and publish the canonical result.
459
- * @param result - Raw provider completion result
460
- */
461
- private resolveCompletion;
462
- /**
463
- * Notify registered completion observers without changing terminal outcome.
464
- * @param result - Canonical completion result
465
- */
466
- private notifyCompletionObservers;
467
- waitForAcknowledgment(timeoutMs?: number): Promise<boolean>;
468
- waitForCompletion(timeoutMs?: number): Promise<MessageResult>;
469
- }
470
- /**
471
- * Complete a handle while notifying a callback with the transformed final result.
472
- *
473
- * `markCompleted()` starts async completion transforms before resolving
474
- * waiters. Connector/session layers that cache `lastResult` must observe the
475
- * final transformed value, not the raw provider result they pass into
476
- * `markCompleted()`.
477
- * @param handle - Message handle being completed
478
- * @param result - Raw provider completion result
479
- * @param onComplete - Optional notification callback receiving the final result
480
- * @returns Promise that settles after the final-result callback completes
481
- */
482
- declare function markCompletedWithFinalResult(handle: MessageHandle, result: MessageResult, onComplete?: CompletionNotification): Promise<void>;
483
- //#endregion
484
- //#region adapters/core/src/connector/agent-connector.d.ts
485
- type Forbid<T, K extends PropertyKey> = Omit<T, K> & { [P in K]?: never };
486
- type ForbiddenKeys = 'agentId' | 'adapterId' | 'adapterSessionId' | 'adapterName' | 'sessionId';
487
- /** Extract Subjects type parameter from a ScopedBus */
488
- type ExtractScopedBusSubjects<T> = T extends {
489
- withFilter: (...args: unknown[]) => IFilteredBus<string, infer S>;
490
- } ? S : T extends ScopedBus<string, infer S> ? S : SubjectRecord;
491
- /**
492
- * Abstract base class for AI agent implementations.
493
- *
494
- * Each adapter provides its own message queue implementation (UserMessageQueue).
495
- * This base class provides common infrastructure for state management, bus operations,
496
- * and error handling.
497
- * @typeParam TBus - Scoped bus type for adapter namespace
498
- */
499
- declare abstract class AIAgentConnector<TBus extends ScopedBus<string> = ScopedBus<string>, TConfig extends BaseAgentConnectorConfig<TBus> = BaseAgentConnectorConfig<TBus>> {
500
- /** Unique identifier for this agent instance. */
501
- protected readonly agentId: string;
502
- /** Session ID from the provider (set after connection/start). */
503
- adapterSessionId?: string;
504
- /** Makaio session ID for cross-session correlation and approval routing. */
505
- protected readonly sessionId?: string;
506
- /** Currently active message handle waiting for completion. */
507
- protected pendingMessageHandle?: MessageHandle;
508
- /** Scoped event bus for adapter-specific emission; global bus owns cross-namespace runtime requests. */
509
- private readonly scopedBus;
510
- protected readonly globalBus: IMakaioBus;
511
- /** Filtered event bus for agent-specific (filtered by agentId) message handling. */
512
- private readonly filteredBus;
513
- /** Optional error handler callback. */
514
- protected readonly errorHandler?: (error: Error, terminate: boolean) => void;
515
- /** Deferred promise for interrupt coordination. */
516
- protected deferredInterrupt: DeferredPromise<void> | undefined;
517
- /**
518
- * Raw state emitter stays private so subclasses use updateProcessingState()
519
- * and the public subscription methods instead of coupling to Emittery internals.
520
- */
521
- private readonly emittery;
522
- /** Current processing state of the agent. */
523
- private processingState;
524
- /** Adapter identifier shared across instances of the same adapter type. */
525
- readonly adapterId: string;
526
- /** Resolved timeout configuration with provenance tracking. */
527
- protected readonly timeouts: TrackedTimeoutConfig;
528
- protected lastResult: MessageResult | null;
529
- protected readonly config: TConfig & {
530
- adapterId: string;
531
- };
532
- /** Model used for this agent (subclasses may update when SDK confirms actual model) */
533
- model: string;
534
- /** ProviderConfig UUID used during agent creation, carried for runtime introspection */
535
- providerConfigId?: string;
536
- /** Working directory for agent execution */
537
- cwd: string;
538
- /** Current reasoning effort level, updated by changeReasoningInPlace. */
539
- currentReasoningEffort: AIReasoningLevel | undefined;
540
- /**
541
- * Reasoning levels supported by the current model, forwarded from the config factory.
542
- * `undefined` when the model does not declare reasoning support.
543
- */
544
- supportedReasoningLevels: BaseAgentConnectorConfig['supportedReasoningLevels'];
545
- protected readonly env: Record<string, string>;
546
- /** Monotonically-increasing turn counter for MCP ledger bookkeeping. */
547
- private _currentTurnNumber;
548
- /** Pending canonical turn number staged by {@link setCanonicalTurnNumber}. */
549
- private _pendingCanonicalTurnNumber;
550
- /** Adapter type name for event identification. */
551
- protected readonly adapterName: string;
552
- /** Runtime system prompt from start/initialize options. */
553
- protected systemPrompt?: SystemPrompt;
554
- protected constructor(config: BaseAgentConnectorConfig<TBus> & {
555
- adapterId: string;
556
- });
557
- /**
558
- * Get the current processing state of the agent.
559
- * @returns The current processing state
560
- */
561
- getProcessingState(): ProcessingState;
562
- /**
563
- * Handle pause after rejection or error.
564
- * Subclasses should clear pending messages as appropriate.
565
- * @param _reason - Reason for pause ('rejection' | 'error'); available for subclass overrides
566
- */
567
- protected handlePause(_reason: 'rejection' | 'error'): void;
568
- /**
569
- * Store runtime system prompt for session creation.
570
- * Subclasses may override to apply SDK-specific side effects (e.g., Gemini's setSystemInstruction).
571
- * @param prompt - System prompt from start/initialize options
572
- */
573
- protected captureSystemPrompt(prompt: SystemPrompt | undefined): void;
574
- /**
575
- * Update the agent's processing state.
576
- * State transitions trigger events via emittery.
577
- * @param state - New processing state
578
- */
579
- protected updateProcessingState(state: ProcessingState): Promise<void>;
580
- /**
581
- * Subscribe to processing state changes (idle ↔ processing transitions).
582
- * @param handler - Called with `{ isProcessing: boolean }` on each state change
583
- * @returns Unsubscribe function
584
- */
585
- onProcessingStateChanged(handler: (payload: EmitteryEvents['processingStateChanged']) => Promise<void> | void): UnsubscribeFunction;
586
- /**
587
- * Wait for a single processing state change matching an optional predicate.
588
- * @param predicate - Optional filter, e.g., `(e) => !e.isProcessing` for idle
589
- * @returns Promise resolving to `{ isProcessing: boolean }`
590
- */
591
- onceProcessingStateChanged(predicate?: (eventData: EmitteryEvents['processingStateChanged']) => boolean): Promise<ProcessingState>;
592
- /**
593
- * Initialize the connector's SDK session without sending a message.
594
- * Must set adapterSessionId before returning.
595
- * Called by createAgent for idle agent setup.
596
- * Implementations MUST be idempotent (no-op if already initialized).
597
- * @param options - Optional start options (e.g., systemPrompt for Claude)
598
- */
599
- abstract initialize(options?: ConnectorStartOptions): Promise<void>;
600
- /**
601
- * Start agent with initial message.
602
- * @param message - Normalized user message (role and content)
603
- * @param options - Optional start options (e.g., delivery mode)
604
- * @returns Session ID, agent ID, and message handle for tracking
605
- */
606
- abstract start(message: NormalizedMessageInput, options?: ConnectorStartOptions): Promise<AgentStartResult>;
607
- /**
608
- * Send a message to the agent.
609
- * For initial message, use start() instead.
610
- * @param message - Normalized message content
611
- * @param options - Send options (e.g., delivery mode, message ID)
612
- * @returns Message handle for tracking
613
- */
614
- abstract sendMessage(message: NormalizedMessageInput, options?: ConnectorSendMessageOptions): Promise<MessageHandle>;
615
- /**
616
- * Abort the agent and cleanup resources (panic mode).
617
- * Triggers AbortController which may cause provider errors.
618
- * Use close() for graceful shutdown instead.
619
- */
620
- abstract abort(): void;
621
- /**
622
- * Gracefully close the agent session.
623
- * Unlike abort(), this doesn't trigger AbortController errors.
624
- * Use this for normal shutdown; use abort() for emergency termination.
625
- */
626
- abstract close(): Promise<void>;
627
- /**
628
- * Get session ID, waiting for provider to generate it if not yet available.
629
- * @returns Session ID from provider
630
- */
631
- abstract getAdapterSessionId(): Promise<string>;
632
- /**
633
- * Provider-confirmed adapter session ID, or `undefined` when unconfirmed.
634
- * Default returns `this.adapterSessionId`; Claude connectors override to
635
- * defer until `system.init` confirms the provider-side session.
636
- * @returns Confirmed ID or `undefined`
637
- */
638
- getConfirmedAdapterSessionId(): string | undefined;
639
- /**
640
- * Complete the agent session by waiting for all messages to finish.
641
- * @returns Last message result or null if no messages processed
642
- */
643
- abstract complete(): Promise<MessageResult | null>;
644
- /**
645
- * Create a MessageHandle with standard initialization (messageId, adapterSessionId, onMessageSent).
646
- * @param message - Normalized user message
647
- * @param options - Optional message options (id, delivery mode, history, and turn context)
648
- * @returns Initialized MessageHandle instance
649
- */
650
- protected createMessageHandle(message: NormalizedMessageInput, options?: MessageHandleOptions): MessageHandle;
651
- /** Signal MCP tools changed; connectors with direct-inject refresh override this. */
652
- markToolRefreshPending(): void;
653
- /**
654
- * Stage the canonical orchestrator-assigned turn number for consumption by the next
655
- * {@link consumeTurnNumber} call. The counter is monotonically increasing.
656
- * @param turnNumber - Canonical 1-based turn number from SessionOrchestrator
657
- * @throws RangeError when the value is invalid, regresses, or downgrades a staged value
658
- */
659
- setCanonicalTurnNumber(turnNumber: number): void;
660
- /**
661
- * Advance to the next turn number, consuming any pending canonical value.
662
- * Orchestrator-staged values win; otherwise the local counter increments by one.
663
- * @returns The current turn number after advancement
664
- */
665
- protected consumeTurnNumber(): number;
666
- /**
667
- * Current turn number (read-only). Use {@link consumeTurnNumber} to advance.
668
- * @returns The current turn number
669
- */
670
- protected get currentTurnNumber(): number;
671
- /**
672
- * Staged canonical turn number, or `undefined` if none was staged.
673
- * @returns The pending canonical turn number
674
- */
675
- protected get pendingTurnNumber(): number | undefined;
676
- /**
677
- * Attempt to change the model without a connector swap.
678
- * Subclasses override when the SDK supports in-place model changes.
679
- * Base implementation returns false (swap required).
680
- *
681
- * **Mutation contract:** Implementations MUST NOT mutate `this.model` directly.
682
- * The caller (AIAgent.handleModelChange) owns the `this.model` field update after
683
- * a successful in-place change. Implementations only configure the SDK-internal model
684
- * (e.g., `query.setModel()`, `geminiConfig.setModel()`).
685
- * @param _newModel - The model identifier to switch to
686
- * @returns true if changed in-place, false if swap needed. Exceptions are caught by the
687
- * caller and treated as false (automatic swap fallback), so implementations need not guard.
688
- */
689
- changeModelInPlace(_newModel: string): Promise<boolean>;
690
- /**
691
- * Attempt to change the working directory without a connector swap.
692
- * Subclasses override when the adapter supports in-place cwd changes (e.g., stateless APIs).
693
- * Base implementation returns false (swap required).
694
- *
695
- * **Mutation contract:** Implementations MUST NOT mutate `this.cwd` directly.
696
- * The caller (AIAgent.handleCwdChange) owns the `this.cwd` field update after
697
- * a successful in-place change. Implementations only update SDK-internal state.
698
- * @param _newCwd - The working directory path to switch to
699
- * @returns true if changed in-place, false if swap needed. Exceptions are caught by the
700
- * caller and treated as false (automatic swap fallback), so implementations need not guard.
701
- */
702
- changeCwdInPlace(_newCwd: string): Promise<boolean>;
703
- /**
704
- * Attempt to change reasoning effort without swapping the connector.
705
- *
706
- * Override in subclasses that support in-place reasoning changes (e.g., adapters
707
- * that pass reasoning parameters per-request rather than at session-creation time).
708
- * The base implementation returns `false` so callers fall back to a connector swap.
709
- *
710
- * **Mutation contract:** Implementations MUST NOT mutate `this.currentReasoningEffort`
711
- * directly. The caller owns the `currentReasoningEffort` field update after a successful
712
- * in-place change. Implementations only configure the SDK-internal reasoning parameter.
713
- * @param _newLevel - The new reasoning effort level to apply
714
- * @returns `true` if the change was applied in-place, `false` if a connector swap is needed
715
- */
716
- changeReasoningInPlace(_newLevel: AIReasoningLevel): Promise<boolean>;
717
- /**
718
- * Interrupt the current message processing.
719
- * @returns Promise that resolves when interrupt is handled
720
- */
721
- abstract interrupt(): Promise<void>;
722
- /**
723
- * Marks pending message as failed, calls error handler, resolves completion promise.
724
- * @param error - Error that occurred
725
- * @param terminate - Whether to abort the agent after handling error
726
- * @internal
727
- */
728
- handleError(error: unknown, terminate?: boolean): void;
729
- protected handleToolApprovalDenied(abort: 'not_requested' | 'not_supported' | 'handled', details?: string): void;
730
- getAgentId(): string;
731
- getAdapterName(): string;
732
- /**
733
- * Get timeout value for a specific category.
734
- * @param category - Timeout category (initialization, acknowledgement, completion, toolApproval, eventWait)
735
- * @returns Timeout value in milliseconds
736
- */
737
- getTimeoutMs(category: keyof typeof this.timeouts.values): number;
738
- /**
739
- * Request tool approval via the scoped bus with auto-injected metadata.
740
- *
741
- * Wraps `scopedBus.request()` to automatically include connector identity
742
- * (adapterName, agentId, adapterId, adapterSessionId) in the payload.
743
- * @param subject - Subject definition for the tool approval request
744
- * @param payload - Request payload (metadata fields are forbidden and auto-injected)
745
- * @returns Promise resolving to the approval response
746
- */
747
- protected requestToolApproval<TSubject extends ScopedSubjectDefinition<TBus['namespace']>>(subject: TSubject, payload: Forbid<TSubject['$meta']['payload']['request'], ForbiddenKeys>): Promise<TSubject['$meta']['payload']['response']>;
748
- /**
749
- * Execute a tool approval request with the shared diagnostics wrapper.
750
- *
751
- * Handles the common `RequestError`/`NoHandlerError` path by logging a helpful
752
- * message via `handleError` and re-throwing so callers can decide whether to
753
- * surface the failure or fall back to a denial.
754
- * @param subject - Scoped subject definition for the tool approval request
755
- * @param payload - Payload that must not include adapter metadata
756
- * @returns Tool approval response payload
757
- */
758
- protected requestToolApprovalWithHandling<TSubject extends ScopedSubjectDefinition<TBus['namespace']>>(subject: TSubject, payload: Forbid<TSubject['$meta']['payload']['request'], ForbiddenKeys>): Promise<TSubject['$meta']['payload']['response']>;
759
- /**
760
- * Emit an event via the scoped bus with auto-injected metadata.
761
- *
762
- * Wraps `scopedBus.emit()` to automatically include connector identity
763
- * (adapterName, agentId, adapterId, adapterSessionId) in the payload.
764
- * @param subject - Subject definition for the event
765
- * @param payload - Event payload (metadata fields are forbidden and auto-injected)
766
- * @returns Promise that resolves when the event is emitted
767
- */
768
- protected emit<TSubject extends ScopedSubjectDefinition<TBus['namespace']>>(subject: TSubject, payload: Forbid<TSubject['$meta']['payload'], ForbiddenKeys>): Promise<void>;
769
- /**
770
- * Subscribe to events on the filtered bus (pre-filtered by agentId).
771
- *
772
- * Uses `filteredBus` which only delivers events matching this connector's agentId.
773
- * @param subject - Subject definition to subscribe to
774
- * @param handler - Event handler receiving the event context
775
- * @param options - Optional subscription options (e.g., priority)
776
- * @returns Unsubscribe function
777
- */
778
- on<Subject extends ScopedSubjectDefinition<TBus['namespace']>>(subject: Subject, handler: HandlerForSubjectDefinition<Subject>, options?: OnOptions): () => void;
779
- /**
780
- * Wait for a single event on the filtered bus (pre-filtered by agentId).
781
- *
782
- * Uses `filteredBus` which only delivers events matching this connector's agentId.
783
- * @param subject - Subject definition to wait for
784
- * @param options - Optional options (e.g., predicate filter, timeout)
785
- * @returns Promise resolving to the event context
786
- */
787
- once<Subject extends ScopedSubjectDefinition<TBus['namespace']>>(subject: Subject, options?: Parameters<IFilteredBus<TBus['namespace'], ExtractScopedBusSubjects<TBus>>['once']>[1]): Promise<never>;
788
- protected logLowLevelEvent(_event: unknown): void;
789
- }
790
- //#endregion
791
- //#region adapters/core/src/adapter/ai-adapter-config.d.ts
792
- /**
793
- * Input provided by agent to the config factory.
794
- * Contains partial configuration - adapters provide defaults for missing required fields.
795
- *
796
- * Includes all runtime options from StartAgentRequest (allowedTools, disallowedTools, etc.)
797
- * to ensure they flow through to the connector.
798
- */
799
- interface ConfigFactoryInput<TBus extends ScopedBus<string> = ScopedBus<string>> {
800
- /** Scoped bus for adapter-specific events */
801
- bus: TBus;
802
- /** Global bus for cross-namespace runtime requests */
803
- globalBus?: IMakaioBus;
804
- /** Unique agent identifier (required - generated by AIAgent) */
805
- agentId: string;
806
- /** Adapter instance identifier (required - provided by AIAgent from adapter) */
807
- adapterId: string;
808
- /** Adapter type name (required - provided by AIAgent from adapter) */
809
- adapterName: string;
810
- /** Refs-only normalized provider selection consumed by the common auth runtime. */
811
- providerContext: ProviderContext;
812
- /** Exact HTTP protocol declared by the selected adapter/provider reference. */
813
- providerProtocol?: ProtocolId;
814
- /** Adapter/provider auth metadata selected by `providerContext.definitionId`. */
815
- adapterProviderAuth?: AdapterProviderAuth;
816
- /** Other adapter/provider auth declarations contributing to the scrub union. */
817
- compatibleProviderAuths?: readonly AdapterProviderAuth[];
818
- /** Whether this adapter rejects the unresolved provider state. */
819
- providerContextRequired?: boolean;
820
- /** Provider's session ID for resuming existing conversations */
821
- adapterSessionId?: string;
822
- /** Makaio session ID for tool execution context and multi-session correlation */
823
- sessionId?: string;
824
- /** Previous adapter session ID for resume attempts (from recovery). */
825
- resumeAdapterSessionId?: string;
826
- /** Model to use - optional, adapters provide defaults */
827
- model?: string;
828
- /** Working directory for agent execution */
829
- cwd?: string;
830
- /** Environment variables to pass to agent execution */
831
- env?: Record<string, string>;
832
- /** Reasoning effort for supporting adapters */
833
- reasoningEffort?: AIReasoningLevel$1;
834
- /** Reasoning levels supported by the resolved model, forwarded to the connector. */
835
- supportedReasoningLevels?: ReasoningLevelMap$1;
836
- /** Error handler for connector errors */
837
- errorHandler?: (error: Error, terminate: boolean) => void;
838
- /** Allowed tool names (adapter-specific). Empty array = disable all tools. */
839
- allowedTools?: string[];
840
- /** Disallowed tool names (adapter-specific). Takes precedence over allowedTools. */
841
- disallowedTools?: string[];
842
- /** Directory restrictions for file-system tool execution. */
843
- allowedDirectories?: string[];
844
- /**
845
- * Adapter-specific per-call configuration (non-credential settings).
846
- *
847
- * This receives `startAgent.adapterConfig` at runtime and feeds the existing
848
- * `createAdapterConfigFactory` providerConfig merge slot. It is unrelated to
849
- * ProviderConfig credential entities, which flow through `providerContext`.
850
- */
851
- providerConfig?: Record<string, unknown>;
852
- runtimeTimeouts?: TimeoutConfig;
853
- /** Client identifier for the application this adapter belongs to (e.g., 'claude-code', 'gemini'). */
854
- clientId?: string;
855
- /** Client profile name for session-scoped config isolation. */
856
- clientProfileName?: string;
857
- /** Harness identifier used to resolve per-agent tool governance. */
858
- harnessId?: string;
859
- /**
860
- * Resolved MCP session context including upstream server configs.
861
- * When present, native-passthrough adapters use `servers` to configure SDK MCP connections.
862
- */
863
- mcpSessionContext?: LedgerSessionContext | McpRuntimeSessionContext | McpSessionContext;
864
- /**
865
- * Session-scoped MCP tool ledger.
866
- * Passed through unchanged so connectors can track injection and mcp_call usage.
867
- */
868
- toolLedger?: ISessionToolLedger;
869
- /**
870
- * When true, the agent is ephemeral (one-shot, not a resume/fork target).
871
- *
872
- * Ephemeral agents skip PreUserMessage hooks and are never resumed or forked
873
- * natively. Connectors should disable session persistence for ephemeral agents
874
- * so no transcript is written to the provider's session store.
875
- */
876
- ephemeral?: boolean;
877
- }
878
- /**
879
- * Interface for adapter-specific configuration factories.
880
- *
881
- * Transforms partial ConfigFactoryInput into full adapter-specific config.
882
- * The key responsibility is applying adapter defaults (especially model).
883
- * @example
884
- * ```typescript
885
- * const OpenAIConfigFactory: IAdapterConfigFactory<OpenAINodeAgentConfig> = {
886
- * getConfig: async (input) => ({
887
- * ...input,
888
- * model: input.model ?? 'gpt-4o',
889
- * providerConfig: { debugMode: true },
890
- * }),
891
- * };
892
- * ```
893
- */
894
- interface IAdapterConfigFactory<TConfig extends BaseAgentConnectorConfig, TBus extends ScopedBus<string> = ScopedBus<string>> {
895
- getConfig(input: ConfigFactoryInput<TBus>): Promise<TConfig>;
896
- }
897
- //#endregion
898
- //#region adapters/core/src/types/provider-definition.d.ts
899
- /**
900
- * Runtime adapter provider definition pairing a serializable provider definition
901
- * with optional runtime-only provider configuration metadata.
902
- *
903
- * Aliases {@link AdapterProviderDefinitionContract} from `@makaio/contracts`,
904
- * the single source of truth for the `definition` and `configSchema` fields.
905
- * The domain-specific name keeps adapter implementation signatures readable
906
- * without creating a second provider-definition contract.
907
- *
908
- * Each adapter exports an array of these from its `definition.ts` (via `providers`).
909
- * The `definition` field contains serializable data (models, endpoints, etc.).
910
- * Config schemas are runtime-only — used for UI form generation, never serialized.
911
- */
912
- type AdapterProviderDefinition = AdapterProviderDefinitionContract;
913
- //#endregion
914
- //#region adapters/core/src/config/resolve-adapter-auth.d.ts
915
- /** Stable normalized adapter-auth failure categories. */
916
- type AdapterAuthErrorReason = 'provider-context-unresolved' | 'binding-missing' | 'binding-ambiguous' | 'client-mismatch' | 'credential-resolution-failed' | 'credential-missing' | 'runtime-bus-missing' | 'native-auth-unavailable';
917
- /** Typed, credential-free failure at the normalized adapter-auth boundary. */
918
- declare class AdapterAuthError extends AuthenticationError {
919
- readonly reason: AdapterAuthErrorReason;
920
- /**
921
- * Create a normalized adapter-auth failure.
922
- * @param reason - Stable failure category
923
- * @param message - Credential-free diagnostic
924
- */
925
- constructor(reason: AdapterAuthErrorReason, message: string);
926
- }
927
- /** Plaintext values produced by the trusted credential resolver. */
928
- type ResolvedAuthCredentialValues = Readonly<Record<string, string>>;
929
- /** Resolve normalized credential refs without exposing them outside the trusted consumer. */
930
- type ResolveAuthCredentialRefs = (credentialRefs: Readonly<Record<string, AuthCredentialRef>>) => Promise<ResolvedAuthCredentialValues>;
931
- /** Input for binding one normalized provider selection to an adapter declaration. */
932
- interface BindProviderAuthOptions {
933
- /** Resolved provider authentication selection containing refs but no plaintext. */
934
- readonly auth: ResolvedProviderAuth;
935
- /** Authentication declaration for the selected adapter/provider junction. */
936
- readonly adapterProviderAuth: AdapterProviderAuth;
937
- /** Other compatible declarations whose environment sinks must also be scrubbed. */
938
- readonly compatibleProviderAuths?: readonly AdapterProviderAuth[];
939
- }
940
- /** Immutable refs-only adapter binding emitted before connector-local resolution. */
941
- interface BoundProviderAuthContext {
942
- /** Selected normalized provider authentication. */
943
- readonly auth: ResolvedProviderAuth;
944
- /** The single adapter delivery binding matching the selected method exactly. */
945
- readonly binding: AdapterAuthBinding;
946
- /** Complete adapter-wide environment variables removed before selected delivery. */
947
- readonly scrubEnvVars: readonly string[];
948
- }
949
- /**
950
- * Select optional field IDs from an explicit normalized auth selection.
951
- *
952
- * Trusted credential resolvers use this policy to omit only selected optional
953
- * refs whose backing secret is unavailable. Keeping it next to the binding
954
- * contract guarantees host and container materialization share one rule.
955
- * @param bound - Exact provider/auth binding selected for one adapter runtime.
956
- * @returns Field IDs whose unavailable refs may be omitted during resolution.
957
- */
958
- declare function getOptionalAuthCredentialFields(bound: BoundProviderAuthContext): readonly string[];
959
- /** One immutable connector-owned authentication operation. */
960
- interface ResolvedConnectorAuthDelivery {
961
- /** Adapter-specific operation identifier. */
962
- readonly target: string;
963
- /** Plaintext fields and constant/null suppressions consumed by the operation. */
964
- readonly values: Readonly<Record<string, AdapterAuthConstant>>;
965
- }
966
- /** Immutable connector-local authentication snapshot. */
967
- interface ResolvedAdapterAuth {
968
- /** Selected plaintext values delivered to a spawned process. */
969
- readonly processEnv: Readonly<Record<string, string>>;
970
- /** Selected adapter-specific connector operations. */
971
- readonly connectorDeliveries: readonly ResolvedConnectorAuthDelivery[];
972
- /** Native auth is inherited only for inferred methods. */
973
- readonly configInheritance: 'auth-only' | 'empty';
974
- }
975
- /**
976
- * Bind normalized provider authentication to one exact adapter delivery declaration.
977
- *
978
- * The result remains refs-only and can therefore travel through adapter configuration
979
- * plumbing without exposing plaintext. Every object is cloned by schema parsing and
980
- * deeply frozen so connector startup observes one stable selection.
981
- * @param options - Selected auth plus selected and compatible adapter declarations.
982
- * @returns Immutable refs-only provider auth binding.
983
- */
984
- declare function bindProviderAuth(options: BindProviderAuthOptions): BoundProviderAuthContext;
985
- /**
986
- * Resolve a bound provider auth context into one immutable connector-local snapshot.
987
- *
988
- * Explicit refs are resolved exactly once. Only required fields must materialize;
989
- * unavailable optional fields are omitted from every delivery. Inferred and no-auth
990
- * methods never invoke the credential resolver.
991
- * @param bound - Immutable refs-only adapter binding.
992
- * @param resolveCredentialRefs - Trusted local credential resolver.
993
- * @returns Immutable plaintext delivery snapshot.
994
- */
995
- declare function resolveBoundProviderAuth(bound: BoundProviderAuthContext, resolveCredentialRefs: ResolveAuthCredentialRefs): Promise<ResolvedAdapterAuth>;
996
- //#endregion
997
- //#region adapters/core/src/config/adapter-auth-runtime.d.ts
998
- /** Refs-only config emitted by the common adapter factory. */
999
- type BoundAdapterRuntimeConfig<TBus extends ScopedBus<string> = ScopedBus<string>, TConfig extends BaseAgentConnectorConfig<TBus> = BaseAgentConnectorConfig<TBus>> = TConfig & {
1000
- /** Adapter instance identifier required by connector factories. */adapterId: string; /** Exact normalized auth selection and adapter delivery binding. */
1001
- boundProviderAuth?: BoundProviderAuthContext;
1002
- };
1003
- /** Connector-facing config after auth refs and client state have been materialized. */
1004
- type ResolvedAdapterRuntimeConfig<TBus extends ScopedBus<string> = ScopedBus<string>, TConfig extends BaseAgentConnectorConfig<TBus> = BaseAgentConnectorConfig<TBus>> = Omit<TConfig, 'boundProviderAuth'> & {
1005
- /** Adapter instance identifier required by connector factories. */adapterId: string; /** Selected connector-local auth delivery, including plaintext. */
1006
- adapterAuth?: ResolvedAdapterAuth; /** Selected managed client binary, when this adapter has a client. */
1007
- clientExecution?: ClientExecutionContext; /** Auth-free environment safe for routable/shared execution contexts. */
1008
- contextEnv: Readonly<Record<string, string>>;
1009
- };
1010
- /** Explicit connector-owned client config lease. */
1011
- interface AdapterAuthLeaseHandle {
1012
- /** Client whose isolated config directory is leased. */
1013
- readonly clientId: string;
1014
- /** Connector-unique lease identifier. */
1015
- readonly leaseId: string;
1016
- /** Release the lease exactly once. Repeated calls share the same result. */
1017
- release(): Promise<void>;
1018
- }
1019
- /** Runtime config plus the lease whose lifetime must match its connector. */
1020
- interface PreparedAdapterAuthRuntime<TBus extends ScopedBus<string> = ScopedBus<string>, TConfig extends BaseAgentConnectorConfig<TBus> = BaseAgentConnectorConfig<TBus>> {
1021
- /** Connector-facing config with one immutable auth snapshot. */
1022
- readonly config: ResolvedAdapterRuntimeConfig<TBus, TConfig>;
1023
- /** Explicit lease handle, present only for client-backed adapters. */
1024
- readonly lease?: AdapterAuthLeaseHandle;
1025
- }
1026
- /** Trusted non-serializable strategy for preparing auth in the current host. */
1027
- type AdapterAuthRuntimePreparer<TBus extends ScopedBus<string> = ScopedBus<string>, TConfig extends BaseAgentConnectorConfig<TBus> = BaseAgentConnectorConfig<TBus>> = (config: BoundAdapterRuntimeConfig<TBus, TConfig>) => Promise<PreparedAdapterAuthRuntime<TBus, TConfig>>;
1028
- /** Host-resolved auth material supplied to a runtime without local secret services. */
1029
- interface SuppliedAdapterAuthRuntime {
1030
- /** Auth snapshot already compiled against the selected adapter binding by the host. */
1031
- readonly selectorValidatedAuth: ResolvedAdapterAuth;
1032
- /** Complete host-compiled adapter auth source/sink scrub union. */
1033
- readonly scrubEnvVars: readonly string[];
1034
- /** Non-auth session environment supplied by the host. */
1035
- readonly sessionEnv?: Readonly<Record<string, string>>;
1036
- /** Pre-resolved non-auth binary environment supplied by the host. */
1037
- readonly binaryEnv?: Readonly<Record<string, string>>;
1038
- /** Environment for an externally-owned config lease or mounted native state. */
1039
- readonly leaseEnv?: Readonly<Record<string, string>>;
1040
- }
1041
- /**
1042
- * Prepare the single connector-local auth snapshot and client config lease.
1043
- *
1044
- * Explicit credential refs are resolved exactly once through the encrypted
1045
- * credential channel. The existing session-environment helper remains the
1046
- * sole merge authority: it scrubs the full adapter set before selected auth
1047
- * values are applied last. The caller owns the returned lease and must release
1048
- * it in every connector close or rollback path.
1049
- * @param config - Refs-only config emitted by the adapter config factory
1050
- * @returns Connector-facing config and its explicit lease handle
1051
- */
1052
- declare function prepareAdapterAuthRuntime<TBus extends ScopedBus<string>, TConfig extends BaseAgentConnectorConfig<TBus>>(config: BoundAdapterRuntimeConfig<TBus, TConfig>): Promise<PreparedAdapterAuthRuntime<TBus, TConfig>>;
1053
- /**
1054
- * Apply host-resolved auth without opening credential channels or owning leases.
1055
- *
1056
- * This is the container/bootstrap seam. Its input must already have been
1057
- * selector-validated with {@link resolveBoundProviderAuth} by the trusted host.
1058
- * Every supplied non-auth source is merged before the full scrub union, then
1059
- * only the selected process delivery is injected. Connector deliveries remain
1060
- * structured values and are never serialized or logged here.
1061
- * @param config - Connector config containing only non-auth runtime inputs
1062
- * @param supplied - Host-compiled auth and non-auth environment sources
1063
- * @returns Connector-facing config with one immutable auth snapshot
1064
- */
1065
- declare function applySuppliedAdapterAuthRuntime<TBus extends ScopedBus<string>, TConfig extends BaseAgentConnectorConfig<TBus>>(config: BoundAdapterRuntimeConfig<TBus, TConfig>, supplied: SuppliedAdapterAuthRuntime): Promise<ResolvedAdapterRuntimeConfig<TBus, TConfig>>;
1066
- //#endregion
1067
- //#region adapters/core/src/agent/types.d.ts
1068
- /**
1069
- * Core agent identity fields.
1070
- * Used as base for contexts, configs, and request payloads.
1071
- */
1072
- interface AgentIdentity {
1073
- /** Unique agent identifier */
1074
- agentId: string;
1075
- /** Adapter instance identifier */
1076
- adapterId: string;
1077
- /** Adapter type name (e.g., 'claude-code', 'gemini-sdk') */
1078
- adapterName: string;
1079
- /** Session identifier for multi-turn conversations */
1080
- adapterSessionId?: string;
1081
- }
1082
- /**
1083
- * Runtime options as INPUT - model/cwd optional (adapters provide defaults via configFactory).
1084
- */
1085
- interface AgentRuntimeInput {
1086
- /** Model to use (optional - adapter provides default) */
1087
- model?: string;
1088
- /** Working directory for agent execution (optional - platform provides default) */
1089
- cwd?: string;
1090
- /** Environment variables to pass to agent execution */
1091
- env?: Record<string, string>;
1092
- /** Reasoning effort for supporting adapters */
1093
- reasoningEffort?: AIReasoningLevel$1;
1094
- /** Allowed tool names. Empty array disables all adapter-visible tools. */
1095
- allowedTools?: string[];
1096
- /** Disallowed tool names. Takes precedence over allowedTools. */
1097
- disallowedTools?: string[];
1098
- }
1099
- /**
1100
- * Runtime options as RESOLVED config - model/cwd required (after configFactory applies defaults).
1101
- */
1102
- type AgentRuntimeOptions = SetRequired<AgentRuntimeInput, 'model' | 'cwd'>;
1103
- /**
1104
- * Common context fields for all agent.* subject emissions.
1105
- * AIAgent automatically enriches payloads with these fields.
1106
- */
1107
- type AgentContext = Required<AgentIdentity>;
1108
- /**
1109
- * Execution context for per-agent processors.
1110
- * Baked in at processor creation time, eliminating runtime registry lookups.
1111
- */
1112
- type ExecutionContext = AgentContext;
1113
- interface MinimalAgentConnectorConfig<TBus extends ScopedBus<string> = ScopedBus<string>> {
1114
- bus: TBus;
1115
- globalBus?: IMakaioBus;
1116
- }
1117
- /**
1118
- * Base configuration for AI agent connector instances.
1119
- */
1120
- interface BaseAgentConnectorConfig<TBus extends ScopedBus<string> = ScopedBus<string>, TProviderConfig extends object = object> extends MinimalAgentConnectorConfig<TBus>, Omit<AgentIdentity, 'adapterId'>, AgentRuntimeOptions {
1121
- /** Makaio session ID for tool execution context and multi-session correlation */
1122
- sessionId?: string;
1123
- errorHandler?: (error: Error, terminate: boolean) => void;
1124
- /**
1125
- * Resolved timeout configuration with provenance tracking.
1126
- * Set by configFactory after merging all timeout layers.
1127
- */
1128
- timeouts?: TrackedTimeoutConfig;
1129
- /**
1130
- * UUID of the ProviderConfig entity used during agent creation.
1131
- * Carried on the connector config for runtime introspection and dynamic provider switching.
1132
- */
1133
- providerConfigId?: string;
1134
- /**
1135
- * Refs-only normalized provider selection retained for runtime introspection.
1136
- * Plaintext authentication is available only through {@link adapterAuth}.
1137
- */
1138
- providerContext?: ProviderContext;
1139
- /** Exact HTTP protocol selected by the active adapter/provider reference. */
1140
- providerProtocol?: ProtocolId;
1141
- providerConfig?: TProviderConfig;
1142
- /**
1143
- * Maps supported reasoning levels to provider-native values for the active model.
1144
- *
1145
- * Populated by the config factory when the resolved model declares reasoning support.
1146
- * Absent when the model does not support extended thinking.
1147
- */
1148
- supportedReasoningLevels?: ReasoningLevelMap$1;
1149
- /** Previous adapter session ID for resume attempts. */
1150
- resumeAdapterSessionId?: string;
1151
- /**
1152
- * Provider-native fork directive approved by session orchestration.
1153
- * When present, native-fork capable connectors should branch from the source
1154
- * provider session instead of starting fresh with replayed history.
1155
- */
1156
- nativeFork?: NativeForkDirective;
1157
- /** Resolved harness ID for tool policy lookup. */
1158
- harnessId?: string;
1159
- /** Client identifier for the application this adapter belongs to (e.g., 'claude-code', 'gemini'). */
1160
- clientId?: string;
1161
- /** Client profile name for session-scoped config isolation. */
1162
- clientProfileName?: string;
1163
- /**
1164
- * Auth-free environment safe for bus-routable tool and MCP contexts.
1165
- *
1166
- * The central adapter runtime derives this from the same merged inputs as
1167
- * `env`, but omits the selected process authentication delivery.
1168
- */
1169
- contextEnv?: Readonly<Record<string, string>>;
1170
- /**
1171
- * Single connector-local normalized auth snapshot.
1172
- *
1173
- * Plaintext exists only on this trusted connector config and must never be
1174
- * emitted, persisted, stringified, or copied back into provider context.
1175
- */
1176
- adapterAuth?: ResolvedAdapterAuth;
1177
- /** Managed client binary selected by the central runtime, when applicable. */
1178
- clientExecution?: ClientExecutionContext;
1179
- /** Callback when a user message is enqueued */
1180
- onMessageSent?: (messageHandle: MessageHandle) => void;
1181
- /**
1182
- * Directory restrictions for file-system tool execution.
1183
- * When set, forwarded as `constraints.allowedDirectories` in every tool call.
1184
- * Empty array means no restriction; undefined means no restriction.
1185
- */
1186
- allowedDirectories?: string[];
1187
- /**
1188
- * MCP session context resolved by the orchestrator.
1189
- * Provides the direct and discoverable tool sets for the current session.
1190
- * When present, enables MCP tool injection and ledger tracking.
1191
- *
1192
- * Intentionally narrowed to LedgerSessionContext — the minimal shape the
1193
- * ledger needs. Adapters requiring the full McpSessionContext (with
1194
- * resolution keys / servers) re-declare this field via Omit + intersection
1195
- * in their own config types (e.g. BaseStreamConnectorConfig, ClaudeAgentConfig).
1196
- */
1197
- mcpSessionContext?: LedgerSessionContext | McpRuntimeSessionContext | McpSessionContext;
1198
- /**
1199
- * Session-scoped tool ledger for tracking injection, discovery, and call history.
1200
- * When present, the connector records tool events into this ledger.
1201
- */
1202
- toolLedger?: ISessionToolLedger;
1203
- /**
1204
- * When true, the connector is handling an ephemeral one-shot agent.
1205
- *
1206
- * Ephemeral agents are by contract never resume or fork targets. Connectors
1207
- * that support session persistence should disable it for ephemeral agents so
1208
- * no transcript is written to the provider's session store.
1209
- */
1210
- ephemeral?: boolean;
1211
- }
1212
- /**
1213
- * Configuration for creating an AIAgent instance.
1214
- *
1215
- * Combines agent identity, runtime input, and factory functions.
1216
- * model/cwd are optional here - configFactory provides adapter defaults.
1217
- * @typeParam TBus - The scoped bus type for this adapter
1218
- * @typeParam TConnector - The connector type (for proper factory return typing)
1219
- */
1220
- interface AIAgentConfig<TBus extends ScopedBus<string> = ScopedBus<string>, TConnector extends AIAgentConnector<TBus> = AIAgentConnector<TBus>> extends Omit<AgentIdentity, 'adapterSessionId'>, AgentRuntimeInput {
1221
- /** Adapter-specific session identifier for multi-turn conversations */
1222
- adapterSessionId?: string;
1223
- /** Makaio session identifier */
1224
- sessionId?: string;
1225
- /** Refs-only normalized provider selection set by session orchestration. */
1226
- providerContext?: ProviderContext;
1227
- /** Previous adapter session ID for resume attempts (from recovery). */
1228
- resumeAdapterSessionId?: string;
1229
- /** Resolved harness ID for tool policy lookup. */
1230
- harnessId?: string;
1231
- /** Client identifier for the application this adapter belongs to (e.g., 'claude-code', 'gemini'). */
1232
- clientId?: string;
1233
- /** Client profile name for session-scoped config isolation. */
1234
- clientProfileName?: string;
1235
- /** Trusted non-serializable auth preparation strategy injected by the host. */
1236
- prepareAuthRuntime?: AdapterAuthRuntimePreparer<TBus>;
1237
- /** Global bus instance (defaults to MakaioBus singleton) */
1238
- globalBus?: IMakaioBus;
1239
- /** Scoped bus for adapter-specific events */
1240
- adapterBus: TBus;
1241
- /** Adapter capabilities (e.g., ['streaming', 'tools', 'vision']) */
1242
- capabilities: string[];
1243
- /** Native tools built into the adapter (e.g., ['shell_command', 'apply_patch']) */
1244
- nativeTools: string[];
1245
- /** Available models for this adapter (used for context window lookup) */
1246
- availableModels?: AIModel[];
1247
- /** Resolved provider definitions, including adapter-provider auth metadata. */
1248
- definitionProviders?: readonly AdapterProviderDefinition[];
1249
- /** Allowed tool names (adapter-specific). Empty array = disable all tools. */
1250
- allowedTools?: string[];
1251
- /** Disallowed tool names (adapter-specific). Takes precedence over allowedTools. */
1252
- disallowedTools?: string[];
1253
- /** Directory restrictions for file-system tool execution. */
1254
- allowedDirectories?: string[];
1255
- /** Per-call adapter-specific JSON config forwarded to the adapter config factory. */
1256
- adapterConfig?: Record<string, unknown>;
1257
- /**
1258
- * MCP session context resolved by the orchestrator.
1259
- * Passed through to the connector config so adapters can inject direct tools.
1260
- */
1261
- mcpSessionContext?: LedgerSessionContext | McpRuntimeSessionContext;
1262
- /**
1263
- * Session-scoped ledger tracking MCP injection/discovery/call history.
1264
- * Created once per agent session and passed through unchanged on connector swaps.
1265
- */
1266
- toolLedger?: ISessionToolLedger;
1267
- /**
1268
- * When true, PreUserMessage hooks are skipped for this agent.
1269
- * Use for ephemeral ping agents where session enrichment and context injection
1270
- * are not needed and would be actively harmful.
1271
- */
1272
- ephemeral?: boolean;
1273
- /**
1274
- * Native fork directive from the orchestrator.
1275
- *
1276
- * When present, the adapter should use the provider's branching API
1277
- * rather than replaying history into a fresh session.
1278
- * Populated by AIAdapter.createAgent when the startAgent mode is 'fork'.
1279
- *
1280
- * AIAgent forwards this through config-factory input so standardized adapter
1281
- * config factories can carry it into connector config. Adapter code must not
1282
- * derive this from raw fork-mode request fields.
1283
- */
1284
- nativeFork?: NativeForkDirective;
1285
- /**
1286
- * Config factory - transforms partial input into full adapter-specific config.
1287
- * This is the seam where adapters inject their defaults (especially model).
1288
- */
1289
- configFactory: (input: ConfigFactoryInput<TBus>) => Promise<BaseAgentConnectorConfig<TBus> & {
1290
- adapterId: string;
1291
- }>;
1292
- /**
1293
- * Connector factory - creates connector from full config.
1294
- * Called AFTER configFactory returns the complete configuration.
1295
- * Config includes adapterId (passed through from input by config factory).
1296
- */
1297
- connectorFactory: (config: BaseAgentConnectorConfig<TBus> & {
1298
- adapterId: string;
1299
- }) => TConnector | Promise<TConnector>;
1300
- }
1301
- /**
1302
- * Result returned from agent.start()
1303
- */
1304
- interface AgentStartResult {
1305
- adapterSessionId: string;
1306
- agentId: string;
1307
- messageHandle: MessageHandle;
1308
- }
1309
- /**
1310
- * Options for sending a message to an agent.
1311
- * Extends SendMessageOptions with curated message history and system prompt configuration.
1312
- */
1313
- interface AgentSendMessageOptions extends SendMessageOptions {
1314
- /** Curated message history from orchestration layer */
1315
- messageHistory?: Message[];
1316
- /**
1317
- * System prompt configuration.
1318
- * - `string`: Replace/set the entire system prompt
1319
- * - `{ mode: 'append', content: string }`: Append to adapter's default system prompt
1320
- */
1321
- systemPrompt?: SystemPrompt;
1322
- /**
1323
- * Context signals assembled by SessionOrchestrator.
1324
- * Used by AIAgent to decide: native resume vs fresh with history.
1325
- * Hooks inject context via sessionContext.turnContext (set by replacePayload).
1326
- */
1327
- sessionContext?: SessionContext;
1328
- /**
1329
- * Structured output descriptor for the turn.
1330
- *
1331
- * Adapters that declare `structuredOutput` pass this schema to their native
1332
- * model-level output controls. Other adapters receive an instruction block
1333
- * and the agent validates the terminal output after completion.
1334
- *
1335
- * Validation retries are default-off (`maxRetries: 0`) and fallback
1336
- * enforcement is a no-op unless the host registers structured-output override
1337
- * handlers.
1338
- */
1339
- responseSchema?: ResponseSchemaDescriptor;
1340
- }
1341
- /**
1342
- * Options for starting an agent session.
1343
- * Same as AgentSendMessageOptions - both start() and sendMessage() accept the same options.
1344
- */
1345
- type StartAgentOptions = AgentSendMessageOptions;
1346
- /**
1347
- * Options for connector-level message operations.
1348
- * Extends AgentSendMessageOptions with turnContext for internal AIAgent to Connector communication.
1349
- * AIAgent extracts sessionContext.turnContext and passes it here.
1350
- * Inherits responseSchema from AgentSendMessageOptions.
1351
- */
1352
- interface ConnectorSendMessageOptions extends AgentSendMessageOptions {
1353
- /**
1354
- * Content-free provider transport correlation. This is carried on the
1355
- * message handle and never materialized into the LLM-facing message.
1356
- */
1357
- requestCorrelation?: RequestCorrelationContext;
1358
- /**
1359
- * Lifecycle turnId from the session orchestrator (`agent.sendMessage.turnId`).
1360
- * Carried on the message handle so user_message lifecycle events pair by it.
1361
- * Distinct from `requestCorrelation.turnId`, which is transport correlation
1362
- * and may be present when no lifecycle turn exists.
1363
- */
1364
- turnId?: string;
1365
- /**
1366
- * Turn-scoped context assembled by PreUserMessage hooks and the orchestrator.
1367
- * Extracted from sessionContext.turnContext by AIAgent.
1368
- * Adapters use this to prepend context blocks to the SDK message.
1369
- *
1370
- * ADAPTER CONTRACT: Every adapter MUST materialize turnContext into the
1371
- * LLM-facing message using serializeTurnContext().
1372
- */
1373
- turnContext?: Record<string, JsonValue>;
1374
- /**
1375
- * Caller-expressed caching intent for the injected message history.
1376
- * Adapters map this to provider-specific cache mechanisms.
1377
- */
1378
- cacheStrategy?: CacheStrategy;
1379
- /**
1380
- * Whether this message is an internal retry turn synthesized by the structured-output
1381
- * manager. When `true`, the connector suppresses `user_message.sent` so the retry
1382
- * is not surfaced as a new user message.
1383
- */
1384
- internalRetry?: boolean;
1385
- /**
1386
- * Caller decision on provider-native session resume for this dispatch.
1387
- *
1388
- * The turn pipeline sets this from the agent's native-resume decision. When
1389
- * `false`, the connector MUST NOT arm its pending start-time resume target
1390
- * (`resumeAdapterSessionId`) for this dispatch: the caller has replaced the
1391
- * provider thread with injected `messageHistory`, so natively resuming would
1392
- * double the conversation context. Honoring connectors discard the
1393
- * unconsumed resume target and mint a fresh provider session instead.
1394
- *
1395
- * When `true` or absent, the connector applies its default resume behavior.
1396
- * The flag never affects a connector's continuity of its own
1397
- * provider-confirmed session (intra-generation multi-turn), and it does not
1398
- * cancel an approved `nativeFork` directive — fork is a separate contract.
1399
- */
1400
- useNativeResume?: boolean;
1401
- }
1402
- /**
1403
- * Options for connector-level start operations.
1404
- * Same as ConnectorSendMessageOptions.
1405
- */
1406
- type ConnectorStartOptions = ConnectorSendMessageOptions;
1407
- /** Payload type for `agent.sendMessage` requests. */
1408
- type SendMessageRequestPayload = ExtractSubjectPayload<typeof AgentSubjects.sendMessage>;
1409
- /** Response type for `agent.sendMessage` requests. */
1410
- type SendMessageResponsePayload = ExtractSubjectResponse<typeof AgentSubjects.sendMessage>;
1411
- /** Payload type for `agent.interrupt` requests. */
1412
- type AgentInterruptRequestPayload = ExtractSubjectPayload<typeof AgentSubjects.interrupt>;
1413
- /** Response type for `agent.interrupt` requests. */
1414
- type AgentInterruptResponsePayload = ExtractSubjectResponse<typeof AgentSubjects.interrupt>;
1415
- /** Response type for `agent.getCapabilities` requests. */
1416
- type GetCapabilitiesResponsePayload = ExtractSubjectResponse<typeof AgentSubjects.getCapabilities>;
1417
- /** Payload type for `agent.cwd.change` requests. */
1418
- type AgentCwdChangeRequestPayload = ExtractSubjectPayload<typeof AgentSubjects.cwd.change>;
1419
- /** Response type for `agent.cwd.change` requests. */
1420
- type AgentCwdChangeResponsePayload = ExtractSubjectResponse<typeof AgentSubjects.cwd.change>;
1421
- /** Payload type for `agent.model.change` requests. */
1422
- type AgentModelChangeRequestPayload = ExtractSubjectPayload<typeof AgentSubjects.model.change>;
1423
- /** Response type for `agent.model.change` requests. */
1424
- type AgentModelChangeResponsePayload = ExtractSubjectResponse<typeof AgentSubjects.model.change>;
1425
- /** Payload type for `agent.mcp.servers.set` requests. */
1426
- type AgentMcpServersSetRequestPayload = ExtractSubjectPayload<typeof AgentSubjects.mcp.servers.set>;
1427
- /** Response type for `agent.mcp.servers.set` requests. */
1428
- type AgentMcpServersSetResponsePayload = ExtractSubjectResponse<typeof AgentSubjects.mcp.servers.set>;
1429
- /** Payload type for `agent.credential.change` requests. */
1430
- type AgentCredentialChangeRequestPayload = ExtractSubjectPayload<typeof AgentSubjects.credential.change>;
1431
- /** Response type for `agent.credential.change` requests. */
1432
- type AgentCredentialChangeResponsePayload = ExtractSubjectResponse<typeof AgentSubjects.credential.change>;
1433
- type EmitteryEvents = {
1434
- processingStateChanged: ProcessingState;
1435
- };
1436
- /**
1437
- * Normalized usage metrics for a single agent call.
1438
- * Adapter implementations normalize provider-specific usage data to this format.
1439
- *
1440
- * Derived from the `agent.usage` schema, so the mandatory `granularity` field
1441
- * is part of this type: adapters MUST declare the truthful measurement
1442
- * granularity of every usage signal they normalize (see
1443
- * `docs/architecture/adapters/usage-and-provenance.md`).
1444
- */
1445
- type NormalizedCallUsage = Omit<z.infer<typeof AgentSchemas.usage>, keyof AgentContext | 'model'>;
1446
- /**
1447
- * Input for context window update emission.
1448
- * Adapters provide raw metrics, helper calculates percentage and level.
1449
- */
1450
- interface ContextWindowInput {
1451
- /** Total tokens in context (input + output for next turn prediction) */
1452
- currentTokens: number;
1453
- /** Model's context window limit */
1454
- maxTokens: number;
1455
- /** Cached tokens (optional, reduces cost but still in context) */
1456
- cachedTokens?: number;
1457
- }
1458
- /**
1459
- * Per-call overrides for connector (re)creation paths.
1460
- *
1461
- * Shared by `AIAgent.swapConnector`, config-input assembly, and the connector
1462
- * lifecycle factory so the override surface cannot drift between them.
1463
- */
1464
- type AgentConnectorConfigOverrides = Partial<{
1465
- cwd: string;
1466
- model: string;
1467
- providerContext: ProviderContext;
1468
- adapterSessionId: string;
1469
- /**
1470
- * Provider session the replacement generation should native-resume. Key
1471
- * presence (not value) selects this over the agent config's start-time
1472
- * resume target, so an explicit `undefined` builds a fresh connector
1473
- * instead of silently re-resuming a stale start directive.
1474
- */
1475
- resumeAdapterSessionId: string | undefined;
1476
- mcpSessionContext: McpRuntimeSessionContext | McpSessionContext | LedgerSessionContext;
1477
- /**
1478
- * Target reasoning effort for the replacement generation. Key presence (not
1479
- * value) selects this over the live connector's current effort, so an
1480
- * explicit `undefined` builds a reasoning-less connector. Adapters may
1481
- * consume reasoning only at construction/start, so the replacement must be
1482
- * built with its target effort rather than mutated afterwards.
1483
- */
1484
- reasoningEffort: AIReasoningLevel$1 | undefined;
1485
- }>;
1486
- //#endregion
1487
- export { NormalizedMessageInput as $, PreparedAdapterAuthRuntime as A, ResolvedAdapterAuth as B, NormalizedCallUsage as C, AdapterAuthLeaseHandle as D, StartAgentOptions as E, AdapterAuthError as F, resolveBoundProviderAuth as G, ResolvedConnectorAuthDelivery as H, AdapterAuthErrorReason as I, IAdapterConfigFactory as J, AdapterProviderDefinition as K, BindProviderAuthOptions as L, SuppliedAdapterAuthRuntime as M, applySuppliedAdapterAuthRuntime as N, AdapterAuthRuntimePreparer as O, prepareAdapterAuthRuntime as P, markCompletedWithFinalResult as Q, BoundProviderAuthContext as R, GetCapabilitiesResponsePayload as S, SendMessageResponsePayload as T, bindProviderAuth as U, ResolvedAuthCredentialValues as V, getOptionalAuthCredentialFields as W, MessageDeliveryMode$1 as X, AIAgentConnector as Y, MessageHandle as Z, BaseAgentConnectorConfig as _, AgentCredentialChangeResponsePayload as a, AIModel as at, ContextWindowInput as b, AgentIdentity as c, ISessionToolLedger as ct, AgentMcpServersSetRequestPayload as d, ToolLedgerEntry as dt, normalizeMessageInput as et, AgentMcpServersSetResponsePayload as f, AgentStartResult as g, AgentSendMessageOptions as h, AgentCredentialChangeRequestPayload as i, SendMessageOptions as it, ResolvedAdapterRuntimeConfig as j, BoundAdapterRuntimeConfig as k, AgentInterruptRequestPayload as l, LedgerSessionContext as lt, AgentModelChangeResponsePayload as m, AgentConnectorConfigOverrides as n, MessageState as nt, AgentCwdChangeRequestPayload as o, AIReasoningLevel$1 as ot, AgentModelChangeRequestPayload as p, ConfigFactoryInput as q, AgentContext as r, ProcessingState as rt, AgentCwdChangeResponsePayload as s, ReasoningLevelMap$1 as st, AIAgentConfig as t, MessageResult as tt, AgentInterruptResponsePayload as u, SessionToolLedger as ut, ConnectorSendMessageOptions as v, SendMessageRequestPayload as w, ExecutionContext as x, ConnectorStartOptions as y, ResolveAuthCredentialRefs as z };