@makaio/framework 1.0.0-dev-1779046984397

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 (410) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +363 -0
  3. package/dist/account-identity-Ce1Bwrqi.mjs +1 -0
  4. package/dist/adapter-CbyjCE2d.mjs +1 -0
  5. package/dist/adapters/acp-client/index.d.mts +209 -0
  6. package/dist/adapters/acp-client/index.mjs +1 -0
  7. package/dist/adapters/config/index.d.mts +429 -0
  8. package/dist/adapters/config/index.mjs +1 -0
  9. package/dist/adapters/index.d.mts +4175 -0
  10. package/dist/adapters/index.mjs +11 -0
  11. package/dist/adapters/node.d.mts +263 -0
  12. package/dist/adapters/node.mjs +4 -0
  13. package/dist/adapters/stream-session/index.d.mts +1384 -0
  14. package/dist/adapters/stream-session/index.mjs +1 -0
  15. package/dist/adapters/stream-session/testing/index.d.mts +29 -0
  16. package/dist/adapters/stream-session/testing/index.mjs +1 -0
  17. package/dist/base-orchestrator-9z8TuA5a.d.mts +772 -0
  18. package/dist/bus/index.d.mts +3331 -0
  19. package/dist/bus/index.mjs +1 -0
  20. package/dist/bus-B1seC4M_.mjs +2 -0
  21. package/dist/capability-service-tnpR_TaB.mjs +1 -0
  22. package/dist/chunk-Dc06z0qk.mjs +1 -0
  23. package/dist/chunk-cpUYaJdV.mjs +1 -0
  24. package/dist/cleanEnvForAdapter-DvcIGXTG.mjs +1 -0
  25. package/dist/client-Dh4x4GQN.mjs +1 -0
  26. package/dist/clients/index.d.mts +2786 -0
  27. package/dist/clients/index.mjs +1 -0
  28. package/dist/clients-namespace-B0xAPZ6J.d.mts +332 -0
  29. package/dist/config-namespace-DLSs83zr.d.mts +638 -0
  30. package/dist/config-namespace-MJT8P0Ud.mjs +1 -0
  31. package/dist/contracts/adapter/index.d.mts +3 -0
  32. package/dist/contracts/adapter/index.mjs +1 -0
  33. package/dist/contracts/adapter/schemas/session-lineage.d.mts +2 -0
  34. package/dist/contracts/adapter/schemas/session-lineage.mjs +1 -0
  35. package/dist/contracts/client/index.d.mts +3 -0
  36. package/dist/contracts/client/index.mjs +1 -0
  37. package/dist/contracts/common/index.d.mts +2 -0
  38. package/dist/contracts/common/index.mjs +1 -0
  39. package/dist/contracts/config/index.d.mts +455 -0
  40. package/dist/contracts/config/index.mjs +1 -0
  41. package/dist/contracts/extension/index.d.mts +3 -0
  42. package/dist/contracts/extension/index.mjs +1 -0
  43. package/dist/contracts/harness/index.d.mts +2 -0
  44. package/dist/contracts/harness/index.mjs +1 -0
  45. package/dist/contracts/host/index.d.mts +2 -0
  46. package/dist/contracts/host/index.mjs +1 -0
  47. package/dist/contracts/index.d.mts +12665 -0
  48. package/dist/contracts/index.mjs +1 -0
  49. package/dist/contracts/model-registry/index.d.mts +2 -0
  50. package/dist/contracts/model-registry/index.mjs +1 -0
  51. package/dist/contracts/native-session-supervisor/index.d.mts +2 -0
  52. package/dist/contracts/native-session-supervisor/index.mjs +1 -0
  53. package/dist/contracts/platform/index.d.mts +2 -0
  54. package/dist/contracts/platform/index.mjs +1 -0
  55. package/dist/contracts/provider/index.d.mts +3 -0
  56. package/dist/contracts/provider/index.mjs +1 -0
  57. package/dist/contracts/session/index.d.mts +3 -0
  58. package/dist/contracts/session/index.mjs +1 -0
  59. package/dist/contracts/shared/index.d.mts +2 -0
  60. package/dist/contracts/shared/index.mjs +1 -0
  61. package/dist/contracts/skill/index.d.mts +2 -0
  62. package/dist/contracts/skill/index.mjs +1 -0
  63. package/dist/contracts/toast/index.d.mts +198 -0
  64. package/dist/contracts/toast/index.mjs +1 -0
  65. package/dist/contracts/variant/index.d.mts +2 -0
  66. package/dist/contracts/variant/index.mjs +1 -0
  67. package/dist/core/index.d.mts +1001 -0
  68. package/dist/core/index.mjs +1 -0
  69. package/dist/credential-ref-DLCsoKVZ.mjs +1 -0
  70. package/dist/cursor-storage-DOQdvo9j.mjs +1 -0
  71. package/dist/definition-DkYy1PZz.mjs +1 -0
  72. package/dist/definition-DtUNiGom.d.mts +158 -0
  73. package/dist/definition-DxvZ9e22.d.mts +376 -0
  74. package/dist/drizzle-CWVVw7Er.mjs +1 -0
  75. package/dist/execution-target-BW_uiBVe.mjs +1 -0
  76. package/dist/extension-COqwS-2Q.mjs +1 -0
  77. package/dist/extension-Cbrl4YGX.mjs +1 -0
  78. package/dist/extension-namespace-zaGKi6Qj.mjs +1 -0
  79. package/dist/handlers-iGKUJ380.mjs +41 -0
  80. package/dist/harness-CEq1Zkf9.mjs +1 -0
  81. package/dist/hooks/index.d.mts +423 -0
  82. package/dist/hooks/index.mjs +1 -0
  83. package/dist/host-CXAUGGN0.mjs +1 -0
  84. package/dist/identity-B_A0mE63.mjs +1 -0
  85. package/dist/index-6lyShOoU.d.mts +225 -0
  86. package/dist/index-7sXlairn2.d.mts +43 -0
  87. package/dist/index-BAKM2GMH2.d.mts +535 -0
  88. package/dist/index-BB419vv-.d.mts +3897 -0
  89. package/dist/index-BJOfdtbw.d.mts +729 -0
  90. package/dist/index-BXP9GK5q.d.mts +1075 -0
  91. package/dist/index-BdPwu6c0.d.mts +1730 -0
  92. package/dist/index-BePI0ckL.d.mts +40 -0
  93. package/dist/index-Bigx81Kr.d.mts +37 -0
  94. package/dist/index-BnNqbx2I.d.mts +134 -0
  95. package/dist/index-Bv15sNLn.d.mts +389 -0
  96. package/dist/index-C-myW_aK.d.mts +412 -0
  97. package/dist/index-C9F3Fc1A.d.mts +2938 -0
  98. package/dist/index-CNxS4Tlu.d.mts +1 -0
  99. package/dist/index-CVA0m1g9.d.mts +995 -0
  100. package/dist/index-C_kS2aqV2.d.mts +438 -0
  101. package/dist/index-Ch3ph52M2.d.mts +40 -0
  102. package/dist/index-CnZOKNjU.d.mts +89 -0
  103. package/dist/index-D1T-PPqF.d.mts +67 -0
  104. package/dist/index-D7T8XCku.d.mts +341 -0
  105. package/dist/index-DBQtpFLE.d.mts +4843 -0
  106. package/dist/index-DEw90pa2.d.mts +183 -0
  107. package/dist/index-DQRsGXb5.d.mts +109 -0
  108. package/dist/index-Dd5s4MSm.d.mts +72 -0
  109. package/dist/index-DubqLGH8.d.mts +1002 -0
  110. package/dist/index-ESSDWIB7.d.mts +11 -0
  111. package/dist/index-N5K1NOYs.d.mts +184 -0
  112. package/dist/index-PdUSmPT2.d.mts +180 -0
  113. package/dist/index-SzSiyG61.d.mts +117 -0
  114. package/dist/index-T0471kWA.d.mts +6760 -0
  115. package/dist/index-WKjrpcA_.d.mts +218 -0
  116. package/dist/index-hapw9_En.d.mts +13592 -0
  117. package/dist/index-iID2R9G1.d.mts +1490 -0
  118. package/dist/kernel/cli/index.d.mts +141 -0
  119. package/dist/kernel/cli/index.mjs +1 -0
  120. package/dist/kernel/cli/schemas.d.mts +63 -0
  121. package/dist/kernel/cli/schemas.mjs +1 -0
  122. package/dist/kernel/extension/index.d.mts +2 -0
  123. package/dist/kernel/extension/index.mjs +1 -0
  124. package/dist/kernel/index.d.mts +296 -0
  125. package/dist/kernel/index.mjs +1 -0
  126. package/dist/kernel/namespace/index.d.mts +2 -0
  127. package/dist/kernel/namespace/index.mjs +1 -0
  128. package/dist/kernel/observability/index.d.mts +2 -0
  129. package/dist/kernel/observability/index.mjs +1 -0
  130. package/dist/kernel/providers/index.d.mts +2 -0
  131. package/dist/kernel/providers/index.mjs +1 -0
  132. package/dist/kernel/window/index.d.mts +2 -0
  133. package/dist/kernel/window/index.mjs +1 -0
  134. package/dist/model-registry-BNzpR6TU.mjs +1 -0
  135. package/dist/model-registry-CIscwC52.mjs +1 -0
  136. package/dist/namespace-0yuzAKlr.mjs +1 -0
  137. package/dist/namespace-8cNguvIp.mjs +1 -0
  138. package/dist/namespace-BK2erxpV.d.mts +921 -0
  139. package/dist/namespace-Bmc7AW4J2.mjs +1 -0
  140. package/dist/namespace-C2ufjgaQ.d.mts +767 -0
  141. package/dist/namespace-C54Oj025.d.mts +159 -0
  142. package/dist/namespace-CCDEOwmW.d.mts +1313 -0
  143. package/dist/namespace-CfEWMXBx.mjs +1 -0
  144. package/dist/namespace-CkLUtc0g.d.mts +580 -0
  145. package/dist/namespace-D5Wrt7YU.mjs +1 -0
  146. package/dist/namespace-DZcuLwEA.d.mts +51 -0
  147. package/dist/namespace-Db-p67Rg.mjs +1 -0
  148. package/dist/namespace-FWx6HxaW.d.mts +611 -0
  149. package/dist/namespace-GLGGcWPH.d.mts +43 -0
  150. package/dist/namespace-N0dfwSg6.mjs +1 -0
  151. package/dist/namespace-O5SNY-LV.d.mts +2226 -0
  152. package/dist/namespace-ZbthBQVt.d.mts +142 -0
  153. package/dist/namespace-bq4Prtzn.d.mts +2046 -0
  154. package/dist/namespace-pNcSglBS.mjs +1 -0
  155. package/dist/namespace-ptv-pw_g.d.mts +3019 -0
  156. package/dist/namespace-xkvVw3hf2.d.mts +189 -0
  157. package/dist/native-session-supervisor-L-UIaEfd.mjs +1 -0
  158. package/dist/node/bus-server/index.d.mts +178 -0
  159. package/dist/node/bus-server/index.mjs +1 -0
  160. package/dist/node/bus-server/server-lifecycle.d.mts +2 -0
  161. package/dist/node/bus-server/server-lifecycle.mjs +1 -0
  162. package/dist/node/machine-identity/index.d.mts +85 -0
  163. package/dist/node/machine-identity/index.mjs +3 -0
  164. package/dist/node/transports/index.d.mts +1752 -0
  165. package/dist/node/transports/index.mjs +2 -0
  166. package/dist/orchestrator-shared-DrjtTXYh.d.mts +249 -0
  167. package/dist/orchestrator-shared-Wv1GI2mW.mjs +1 -0
  168. package/dist/platform-BbSLVg5b.mjs +1 -0
  169. package/dist/profile-4StaDQW0.mjs +1 -0
  170. package/dist/provider-context-CNRQ4d5m.mjs +1 -0
  171. package/dist/providers/index.d.mts +135 -0
  172. package/dist/providers/index.mjs +1 -0
  173. package/dist/providers-Cr4Za8a1.mjs +1 -0
  174. package/dist/providers-namespace-CDwxY_DV.d.mts +583 -0
  175. package/dist/schema-BwzXEtT2.d.mts +837 -0
  176. package/dist/schema-CAw_BqaG.mjs +1 -0
  177. package/dist/schema-introspection-D61TT_7b.mjs +1 -0
  178. package/dist/schema-uSGW-6oM.mjs +1 -0
  179. package/dist/schemas-BXstpWVp.mjs +1 -0
  180. package/dist/schemas-BdMU-gew.d.mts +160 -0
  181. package/dist/schemas-C40ZAJ33.mjs +1 -0
  182. package/dist/schemas-C5xtVqdb.d.mts +46 -0
  183. package/dist/schemas-CGZy_rU6.d.mts +13 -0
  184. package/dist/schemas-CLxtoKFy.mjs +1 -0
  185. package/dist/schemas-Co_sVhzz.mjs +1 -0
  186. package/dist/schemas-D9108Iv1.d.mts +182 -0
  187. package/dist/schemas-DENVYyds.d.mts +463 -0
  188. package/dist/schemas-DbWs_hj8.d.mts +174 -0
  189. package/dist/schemas-Di0XnnMX.d.mts +73 -0
  190. package/dist/schemas-KMA1efQg.d.mts +944 -0
  191. package/dist/schemas-qmn5SWPU.d.mts +312 -0
  192. package/dist/schemas-sshQEF3l.d.mts +237 -0
  193. package/dist/server-lifecycle-Cf_SZ27k.d.mts +160 -0
  194. package/dist/server-lifecycle-DbFwlrTW.mjs +1 -0
  195. package/dist/service-base/index.d.mts +98 -0
  196. package/dist/service-base/index.mjs +1 -0
  197. package/dist/services/adapter-runtime/index.d.mts +4 -0
  198. package/dist/services/adapter-runtime/index.mjs +1 -0
  199. package/dist/services/adapter-runtime/namespace.d.mts +2 -0
  200. package/dist/services/adapter-runtime/namespace.mjs +1 -0
  201. package/dist/services/adapter-runtime/schemas.d.mts +2 -0
  202. package/dist/services/adapter-runtime/schemas.mjs +1 -0
  203. package/dist/services/adapter-subsystem/index.d.mts +3 -0
  204. package/dist/services/adapter-subsystem/index.mjs +1 -0
  205. package/dist/services/adapter-subsystem/namespace.d.mts +2 -0
  206. package/dist/services/adapter-subsystem/namespace.mjs +1 -0
  207. package/dist/services/agent-runtime/index.d.mts +3 -0
  208. package/dist/services/agent-runtime/index.mjs +1 -0
  209. package/dist/services/agent-runtime/namespace.d.mts +2 -0
  210. package/dist/services/agent-runtime/namespace.mjs +1 -0
  211. package/dist/services/agent-runtime/schemas.d.mts +2 -0
  212. package/dist/services/agent-runtime/schemas.mjs +1 -0
  213. package/dist/services/capability/index.d.mts +2 -0
  214. package/dist/services/capability/index.mjs +1 -0
  215. package/dist/services/cli-detection/namespace.d.mts +56 -0
  216. package/dist/services/cli-detection/namespace.mjs +1 -0
  217. package/dist/services/codebase/index.d.mts +3 -0
  218. package/dist/services/codebase/index.mjs +1 -0
  219. package/dist/services/codebase/namespace.d.mts +2 -0
  220. package/dist/services/codebase/namespace.mjs +1 -0
  221. package/dist/services/codebase/schemas.d.mts +2 -0
  222. package/dist/services/codebase/schemas.mjs +1 -0
  223. package/dist/services/compression/index.d.mts +3 -0
  224. package/dist/services/compression/index.mjs +1 -0
  225. package/dist/services/compression/namespace.d.mts +2 -0
  226. package/dist/services/compression/namespace.mjs +1 -0
  227. package/dist/services/compression/schemas.d.mts +2 -0
  228. package/dist/services/compression/schemas.mjs +1 -0
  229. package/dist/services/context-rules/index.d.mts +412 -0
  230. package/dist/services/context-rules/index.mjs +1 -0
  231. package/dist/services/credential-change/index.d.mts +17 -0
  232. package/dist/services/credential-change/index.mjs +1 -0
  233. package/dist/services/definition/index.d.mts +2 -0
  234. package/dist/services/definition/index.mjs +1 -0
  235. package/dist/services/definition/namespace.d.mts +71 -0
  236. package/dist/services/definition/namespace.mjs +1 -0
  237. package/dist/services/definition/schemas.d.mts +38 -0
  238. package/dist/services/definition/schemas.mjs +1 -0
  239. package/dist/services/dialog/namespace.d.mts +105 -0
  240. package/dist/services/dialog/namespace.mjs +1 -0
  241. package/dist/services/dialog/schemas.d.mts +109 -0
  242. package/dist/services/dialog/schemas.mjs +1 -0
  243. package/dist/services/execution-target/index.d.mts +4 -0
  244. package/dist/services/execution-target/index.mjs +1 -0
  245. package/dist/services/execution-target/namespace.d.mts +2 -0
  246. package/dist/services/execution-target/namespace.mjs +1 -0
  247. package/dist/services/execution-target/schemas.d.mts +2 -0
  248. package/dist/services/execution-target/schemas.mjs +1 -0
  249. package/dist/services/filesystem/namespace.d.mts +432 -0
  250. package/dist/services/filesystem/namespace.mjs +1 -0
  251. package/dist/services/filesystem/schemas.d.mts +240 -0
  252. package/dist/services/filesystem/schemas.mjs +1 -0
  253. package/dist/services/harness/index.d.mts +861 -0
  254. package/dist/services/harness/index.mjs +1 -0
  255. package/dist/services/harness/storage/schema.d.mts +424 -0
  256. package/dist/services/harness/storage/schema.mjs +1 -0
  257. package/dist/services/index.d.mts +5703 -0
  258. package/dist/services/index.mjs +1 -0
  259. package/dist/services/local-notification/index.d.mts +25 -0
  260. package/dist/services/local-notification/index.mjs +1 -0
  261. package/dist/services/local-notification/namespace.d.mts +73 -0
  262. package/dist/services/local-notification/namespace.mjs +1 -0
  263. package/dist/services/local-notification/schemas.d.mts +88 -0
  264. package/dist/services/local-notification/schemas.mjs +1 -0
  265. package/dist/services/log-import/browser.d.mts +3 -0
  266. package/dist/services/log-import/browser.mjs +1 -0
  267. package/dist/services/log-import/index.d.mts +275 -0
  268. package/dist/services/log-import/index.mjs +2 -0
  269. package/dist/services/log-import/log-import.d.mts +3 -0
  270. package/dist/services/log-import/log-import.mjs +1 -0
  271. package/dist/services/log-import/namespace.d.mts +327 -0
  272. package/dist/services/log-import/namespace.mjs +1 -0
  273. package/dist/services/log-import/schemas.d.mts +217 -0
  274. package/dist/services/log-import/schemas.mjs +1 -0
  275. package/dist/services/model-registry/index.d.mts +2 -0
  276. package/dist/services/model-registry/index.mjs +1 -0
  277. package/dist/services/preferences/index.d.mts +3 -0
  278. package/dist/services/preferences/index.mjs +1 -0
  279. package/dist/services/preferences/schemas.d.mts +2 -0
  280. package/dist/services/preferences/schemas.mjs +1 -0
  281. package/dist/services/preferences/storage-namespace.d.mts +3 -0
  282. package/dist/services/preferences/storage-namespace.mjs +1 -0
  283. package/dist/services/provider-context/index.d.mts +2 -0
  284. package/dist/services/provider-context/index.mjs +1 -0
  285. package/dist/services/provider-runtime/index.d.mts +136 -0
  286. package/dist/services/provider-runtime/index.mjs +1 -0
  287. package/dist/services/session/handlers/index.d.mts +2 -0
  288. package/dist/services/session/handlers/index.mjs +1 -0
  289. package/dist/services/session/index.d.mts +10 -0
  290. package/dist/services/session/index.mjs +1 -0
  291. package/dist/services/session/messages/namespace.d.mts +2 -0
  292. package/dist/services/session/messages/namespace.mjs +1 -0
  293. package/dist/services/session/orchestrator-testing/index.d.mts +2 -0
  294. package/dist/services/session/orchestrator-testing/index.mjs +1 -0
  295. package/dist/services/session/session-events/namespace.d.mts +2 -0
  296. package/dist/services/session/session-events/namespace.mjs +1 -0
  297. package/dist/services/session/storage/namespace.d.mts +2 -0
  298. package/dist/services/session/storage/namespace.mjs +1 -0
  299. package/dist/services/session/storage/schema.d.mts +2 -0
  300. package/dist/services/session/storage/schema.mjs +1 -0
  301. package/dist/services/session/testing/index.d.mts +35 -0
  302. package/dist/services/session/testing/index.mjs +52 -0
  303. package/dist/services/session/testing/orchestrator-shared.d.mts +2 -0
  304. package/dist/services/session/testing/orchestrator-shared.mjs +1 -0
  305. package/dist/services/session/turns/namespace.d.mts +2 -0
  306. package/dist/services/session/turns/namespace.mjs +1 -0
  307. package/dist/services/session-editor/index.d.mts +119 -0
  308. package/dist/services/session-editor/index.mjs +1 -0
  309. package/dist/services/settings/index.d.mts +47 -0
  310. package/dist/services/settings/index.mjs +1 -0
  311. package/dist/services/settings/namespace.d.mts +662 -0
  312. package/dist/services/settings/namespace.mjs +1 -0
  313. package/dist/services/settings/storage/clients-namespace.d.mts +2 -0
  314. package/dist/services/settings/storage/clients-namespace.mjs +1 -0
  315. package/dist/services/settings/storage/extension-configs/namespace.d.mts +184 -0
  316. package/dist/services/settings/storage/extension-configs/namespace.mjs +1 -0
  317. package/dist/services/settings/storage/index.d.mts +4 -0
  318. package/dist/services/settings/storage/index.mjs +1 -0
  319. package/dist/services/settings/storage/providers-namespace.d.mts +2 -0
  320. package/dist/services/settings/storage/providers-namespace.mjs +1 -0
  321. package/dist/services/tool-approval/index.d.mts +2 -0
  322. package/dist/services/tool-approval/index.mjs +1 -0
  323. package/dist/services/tools/index.d.mts +2 -0
  324. package/dist/services/tools/index.mjs +1 -0
  325. package/dist/services/tray-menu/index.d.mts +4 -0
  326. package/dist/services/tray-menu/index.mjs +1 -0
  327. package/dist/services/tray-menu/namespace.d.mts +2 -0
  328. package/dist/services/tray-menu/namespace.mjs +1 -0
  329. package/dist/services/tray-menu/schemas.d.mts +2 -0
  330. package/dist/services/tray-menu/schemas.mjs +1 -0
  331. package/dist/services/turn/index.d.mts +2 -0
  332. package/dist/services/turn/index.mjs +1 -0
  333. package/dist/services/turn/namespace.d.mts +2 -0
  334. package/dist/services/turn/namespace.mjs +1 -0
  335. package/dist/services/turn/schemas.d.mts +335 -0
  336. package/dist/services/turn/schemas.mjs +1 -0
  337. package/dist/services/worker/index.d.mts +3 -0
  338. package/dist/services/worker/index.mjs +1 -0
  339. package/dist/services/worker/namespace.d.mts +2 -0
  340. package/dist/services/worker/namespace.mjs +1 -0
  341. package/dist/services/worker/schemas.d.mts +2 -0
  342. package/dist/services/worker/schemas.mjs +1 -0
  343. package/dist/session-Do6lDZM4.mjs +123 -0
  344. package/dist/session-lineage-Eev4uo4I.d.mts +65 -0
  345. package/dist/session-piI1R5rP.mjs +1 -0
  346. package/dist/shared-DxHLl9UP.mjs +1 -0
  347. package/dist/shared-schemas-BgQv_tnu.mjs +1 -0
  348. package/dist/skill-CB5h-ZFQ.mjs +1 -0
  349. package/dist/storage/drizzle/client.d.mts +78 -0
  350. package/dist/storage/drizzle/client.mjs +1 -0
  351. package/dist/storage/drizzle/index.d.mts +98 -0
  352. package/dist/storage/drizzle/index.mjs +1 -0
  353. package/dist/storage/handlers/drizzle/index.d.mts +2 -0
  354. package/dist/storage/handlers/drizzle/index.mjs +1 -0
  355. package/dist/storage/handlers/index.d.mts +33 -0
  356. package/dist/storage/handlers/index.mjs +1 -0
  357. package/dist/storage/index.d.mts +192 -0
  358. package/dist/storage/index.mjs +1 -0
  359. package/dist/storage-namespace-ADwyijoe.mjs +1 -0
  360. package/dist/storage-namespace-DAm8iWEj.d.mts +221 -0
  361. package/dist/storage-namespace-definition-CHu2k14q.mjs +1 -0
  362. package/dist/storage-namespace-definition-CJgqyXH1.d.mts +17 -0
  363. package/dist/style.css +3782 -0
  364. package/dist/testing/drizzle-harness.d.mts +130 -0
  365. package/dist/testing/drizzle-harness.mjs +1 -0
  366. package/dist/testing/index.d.mts +106 -0
  367. package/dist/testing/index.mjs +1 -0
  368. package/dist/tool-approval-service-BcBSUZCO.mjs +1 -0
  369. package/dist/tools/index.d.mts +825 -0
  370. package/dist/tools/index.mjs +1 -0
  371. package/dist/tools/testing/index.d.mts +53 -0
  372. package/dist/tools/testing/index.mjs +1 -0
  373. package/dist/tools-CDSgj0ee.mjs +1 -0
  374. package/dist/tray-menu-service-CTXC1Elg.mjs +1 -0
  375. package/dist/types-6WxLfoM3.d.mts +31 -0
  376. package/dist/types-BjToUrHp.d.mts +6619 -0
  377. package/dist/types-CD1LJwPc.d.mts +1009 -0
  378. package/dist/types-Cvrj2ogm.d.mts +305 -0
  379. package/dist/types-DYF5LxZY.d.mts +233 -0
  380. package/dist/types-t295YC6T.d.mts +262 -0
  381. package/dist/types-vNpkAe4Y.d.mts +128 -0
  382. package/dist/ui-components/index.d.mts +2342 -0
  383. package/dist/ui-components/index.mjs +8 -0
  384. package/dist/ui-config-CXmbsqZV.mjs +1 -0
  385. package/dist/ui-hooks/index.d.mts +1805 -0
  386. package/dist/ui-hooks/index.mjs +1 -0
  387. package/dist/ui-kernel/index.d.mts +2793 -0
  388. package/dist/ui-kernel/index.mjs +1 -0
  389. package/dist/ui-kernel/pages/namespace.d.mts +88 -0
  390. package/dist/ui-kernel/pages/namespace.mjs +1 -0
  391. package/dist/ui-kernel/pages/schemas.d.mts +2 -0
  392. package/dist/ui-kernel/pages/schemas.mjs +1 -0
  393. package/dist/ui-views/index.d.mts +487 -0
  394. package/dist/ui-views/index.mjs +30 -0
  395. package/dist/utils/health-probe.d.mts +26 -0
  396. package/dist/utils/health-probe.mjs +1 -0
  397. package/dist/utils/index.d.mts +227 -0
  398. package/dist/utils/index.mjs +2 -0
  399. package/dist/utils/keychain.d.mts +31 -0
  400. package/dist/utils/keychain.mjs +1 -0
  401. package/dist/utils/resolve-package-root.d.mts +12 -0
  402. package/dist/utils/resolve-package-root.mjs +1 -0
  403. package/dist/utils/workspace-root.d.mts +27 -0
  404. package/dist/utils/workspace-root.mjs +2 -0
  405. package/dist/variant-D5kSrL3m.mjs +1 -0
  406. package/dist/version-CjS20oXi.mjs +1 -0
  407. package/dist/visibility-CZu8ooOA.mjs +1 -0
  408. package/dist/window-registry-CUftmDr3.mjs +1 -0
  409. package/dist/window-registry-C_IJmY8_.d.mts +130 -0
  410. package/package.json +346 -0
@@ -0,0 +1,1009 @@
1
+ import { z } from "zod";
2
+ import { ExtractSubjectPayload, ExtractSubjectResponse, HandlerForSubjectDefinition, ScopedSubjectDefinition, SubjectRecord } from "@makaio/framework/core";
3
+ import { IFilteredBus, IMakaioBus, OnOptions, ScopedBus } from "@makaio/framework/bus";
4
+ import { AIModel, AIReasoningLevel, AIReasoningLevel as AIReasoningLevel$1, AgentSchemas, AgentSubjects, JsonValue, McpRuntimeSessionContext, McpSessionContext, McpToolState, Message, MessageBlock, MessageDeliveryMode, MessageDeliveryMode as MessageDeliveryMode$1, MessageInput, MessageOutcome, ProviderContext, ReasoningLevelMap as ReasoningLevelMap$1, SendMessageResultInnerResult, SessionContext, SystemPrompt, ToolListItem } from "@makaio/framework/contracts";
5
+ import { DeferredPromise, TimeoutConfig, TrackedTimeoutConfig } from "@makaio/framework/utils";
6
+ import * as _$emittery from "emittery";
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 adapters/core/src/message-handle/types.d.ts
175
+ /**
176
+ * Result of a message operation.
177
+ */
178
+ type MessageResult = {
179
+ result?: SendMessageResultInnerResult | null;
180
+ error?: Error | string;
181
+ outcome: MessageOutcome; /** Present when outcome='superseded': the messageId that replaced this one */
182
+ supersededBy?: string; /** Present when outcome='merged': the messageId this was folded into */
183
+ mergedInto?: string;
184
+ };
185
+ /**
186
+ * Lifecycle states for a queued message.
187
+ */
188
+ type MessageState = 'queued' | 'acknowledged' | 'completed' | 'cancelled';
189
+ /**
190
+ * Options for sending a message.
191
+ */
192
+ interface SendMessageOptions {
193
+ /**
194
+ * Custom identifier for message tracking (generated if not provided).
195
+ */
196
+ messageId?: string;
197
+ /**
198
+ * Controls delivery behavior.
199
+ * @defaultValue 'enqueue'
200
+ */
201
+ deliveryMode?: MessageDeliveryMode;
202
+ }
203
+ /**
204
+ * Processing state for agent orchestration.
205
+ */
206
+ type ProcessingState = 'idle' | 'processing_started' | 'turn_started' | 'step_started' | 'step_finished' | 'turn_finished' | 'processing_finished' | 'active' | 'paused';
207
+ //#endregion
208
+ //#region adapters/core/src/utils/normalizeMessageInput.d.ts
209
+ type NormalizedMessageInput = Required<Message> & {
210
+ blocks: MessageBlock[];
211
+ message?: string;
212
+ };
213
+ /**
214
+ * Normalizes various MessageInput formats into a consistent structure with blocks and optional message text.
215
+ * @param input - The message input to normalize (string or Message object)
216
+ * @returns Normalized message with role, blocks array, and optional message text
217
+ */
218
+ declare function normalizeMessageInput(input: MessageInput): NormalizedMessageInput;
219
+ //#endregion
220
+ //#region adapters/core/src/message-handle/message-handle.d.ts
221
+ declare class MessageHandle {
222
+ readonly messageId: string;
223
+ readonly message: NormalizedMessageInput;
224
+ readonly deliveryMode: MessageDeliveryMode;
225
+ protected readonly deferredCompletion: DeferredPromise<MessageResult>;
226
+ protected readonly deferredAcknowledgement: DeferredPromise<boolean>;
227
+ state: MessageState;
228
+ private isAcknowledged;
229
+ private completionResult;
230
+ /** If this message was merged into another, the winner's messageId */
231
+ mergedInto?: string;
232
+ /** If this is the merge winner, messageIds that were folded in */
233
+ mergedFrom?: string[];
234
+ /** If this message was superseded by replace/immediate, the replacer's messageId */
235
+ supersededBy?: string;
236
+ /** Adapter session ID - resolved when processing starts */
237
+ private readonly deferredAdapterSessionId;
238
+ private _adapterSessionId?;
239
+ /** Curated message history from sessionContext (mutable for merge propagation) */
240
+ private _messageHistory?;
241
+ /** Turn-scoped context from PreUserMessage hooks (mutable for merge propagation) */
242
+ private _turnContext?;
243
+ constructor(messageId: string, message: NormalizedMessageInput, deliveryMode: MessageDeliveryMode, /** Curated message history from sessionContext */
244
+
245
+ messageHistory?: Message[], /** Turn-scoped context from PreUserMessage hooks */
246
+
247
+ turnContext?: Record<string, JsonValue>);
248
+ /**
249
+ * Curated message history from sessionContext
250
+ * @returns The message history array or undefined if not set
251
+ */
252
+ get messageHistory(): Message[] | undefined;
253
+ /** Set messageHistory (used by merge strategies to propagate history) */
254
+ set messageHistory(value: Message[] | undefined);
255
+ /**
256
+ * Turn-scoped context from PreUserMessage hooks
257
+ * @returns The turn context record or undefined if not set
258
+ */
259
+ get turnContext(): Record<string, JsonValue> | undefined;
260
+ /** Set turnContext (used by merge strategies to propagate context) */
261
+ set turnContext(value: Record<string, JsonValue> | undefined);
262
+ /**
263
+ * Get adapter session ID synchronously (undefined if not yet set)
264
+ * @returns The adapter session ID or undefined if not yet set
265
+ */
266
+ get adapterSessionId(): string | undefined;
267
+ /**
268
+ * Set adapter session ID (called by connector when processing starts)
269
+ */
270
+ set adapterSessionId(value: string | undefined);
271
+ /**
272
+ * Wait for adapter session ID to be set
273
+ * @returns Promise resolving to session ID when processing starts
274
+ */
275
+ waitForAdapterSessionId(): Promise<string>;
276
+ get isProcessed(): boolean;
277
+ getState(): MessageState;
278
+ /**
279
+ * Update message state
280
+ * @param state - New message state
281
+ */
282
+ updateState(state: MessageState): void;
283
+ /**
284
+ * Cancel a pending message
285
+ * @returns True if cancelled, false if already submitted/completed
286
+ */
287
+ cancel(): Promise<boolean>;
288
+ /**
289
+ * Mark message as acknowledged
290
+ * @param delivered - Whether message was successfully delivered to provider
291
+ * (e.g. false if immediate message arrived too late)
292
+ */
293
+ markAcknowledged(delivered?: boolean): void;
294
+ /**
295
+ * Mark message turn as completed
296
+ * @param result - The result message or null if no result available
297
+ */
298
+ markCompleted(result: MessageResult): void;
299
+ waitForAcknowledgment(timeoutMs?: number): Promise<boolean>;
300
+ waitForCompletion(timeoutMs?: number): Promise<MessageResult>;
301
+ }
302
+ //#endregion
303
+ //#region adapters/core/src/connector/agent-connector.d.ts
304
+ type Forbid<T, K extends PropertyKey> = Omit<T, K> & { [P in K]?: never };
305
+ type ForbiddenKeys = 'agentId' | 'adapterId' | 'adapterSessionId' | 'adapterName' | 'sessionId';
306
+ /** Extract Subjects type parameter from a ScopedBus */
307
+ type ExtractScopedBusSubjects<T> = T extends {
308
+ withFilter: (...args: unknown[]) => IFilteredBus<string, infer S>;
309
+ } ? S : T extends ScopedBus<string, infer S> ? S : SubjectRecord;
310
+ /**
311
+ * Public options bag used by connectors when creating a message handle.
312
+ */
313
+ interface MessageHandleOptions {
314
+ /** Optional stable message identifier; autogenerated when omitted. */
315
+ messageId?: string;
316
+ /** Optional delivery semantics for queue processing. */
317
+ deliveryMode?: MessageDeliveryMode;
318
+ /** Optional prior conversation messages to materialize for the turn. */
319
+ messageHistory?: Message[];
320
+ /** Optional per-turn metadata/context payload for prompt materialization. */
321
+ turnContext?: Record<string, JsonValue>;
322
+ }
323
+ /**
324
+ * Abstract base class for AI agent implementations.
325
+ *
326
+ * Each adapter provides its own message queue implementation (UserMessageQueue).
327
+ * This base class provides common infrastructure for state management, bus operations,
328
+ * and error handling.
329
+ * @typeParam TBus - Scoped bus type for adapter namespace
330
+ */
331
+ declare abstract class AIAgentConnector<TBus extends ScopedBus<string> = ScopedBus<string>, TConfig extends BaseAgentConnectorConfig<TBus> = BaseAgentConnectorConfig<TBus>> {
332
+ /** Unique identifier for this agent instance. */
333
+ protected readonly agentId: string;
334
+ /** Session ID from the provider (set after connection/start). */
335
+ adapterSessionId?: string;
336
+ /** Makaio session ID for cross-session correlation and approval routing. */
337
+ protected readonly sessionId?: string;
338
+ /** Currently active message handle waiting for completion. */
339
+ protected pendingMessageHandle?: MessageHandle;
340
+ /** Scoped event bus for adapter-specific emission. */
341
+ private readonly scopedBus;
342
+ /** Filtered event bus for agent-specific (filtered by agentId) message handling. */
343
+ private readonly filteredBus;
344
+ /** Optional error handler callback. */
345
+ protected readonly errorHandler?: (error: Error, terminate: boolean) => void;
346
+ /** Deferred promise for interrupt coordination. */
347
+ protected deferredInterrupt: DeferredPromise<void> | undefined;
348
+ /**
349
+ * Raw state emitter stays private so subclasses use updateProcessingState()
350
+ * and the public subscription methods instead of coupling to Emittery internals.
351
+ */
352
+ private readonly emittery;
353
+ /** Current processing state of the agent. */
354
+ private processingState;
355
+ /** Adapter identifier shared across instances of the same adapter type. */
356
+ readonly adapterId: string;
357
+ /** Resolved timeout configuration with provenance tracking. */
358
+ protected readonly timeouts: TrackedTimeoutConfig;
359
+ protected lastResult: MessageResult | null;
360
+ protected readonly config: TConfig & {
361
+ adapterId: string;
362
+ };
363
+ /** Model used for this agent (subclasses may update when SDK confirms actual model) */
364
+ model: string;
365
+ /** ProviderConfig UUID used during agent creation, carried for runtime introspection */
366
+ providerConfigId?: string;
367
+ /** Working directory for agent execution */
368
+ cwd: string;
369
+ /** Current reasoning effort level, updated by changeReasoningInPlace. */
370
+ currentReasoningEffort: AIReasoningLevel | undefined;
371
+ /**
372
+ * Reasoning levels supported by the current model, forwarded from the config factory.
373
+ * `undefined` when the model does not declare reasoning support.
374
+ */
375
+ supportedReasoningLevels: BaseAgentConnectorConfig['supportedReasoningLevels'];
376
+ protected readonly env: Record<string, string>;
377
+ /** Monotonically-increasing turn counter for MCP ledger bookkeeping. */
378
+ private _currentTurnNumber;
379
+ /** Pending canonical turn number staged by {@link setCanonicalTurnNumber}. */
380
+ private _pendingCanonicalTurnNumber;
381
+ /** Adapter type name for event identification. */
382
+ protected readonly adapterName: string;
383
+ /** Runtime system prompt from start/initialize options. */
384
+ protected systemPrompt?: SystemPrompt;
385
+ protected constructor(config: BaseAgentConnectorConfig<TBus> & {
386
+ adapterId: string;
387
+ });
388
+ /**
389
+ * Get the current processing state of the agent.
390
+ * @returns The current processing state
391
+ */
392
+ getProcessingState(): ProcessingState;
393
+ /**
394
+ * Handle pause after rejection or error.
395
+ * Subclasses should clear pending messages as appropriate.
396
+ * @param _reason - Reason for pause ('rejection' | 'error'); available for subclass overrides
397
+ */
398
+ protected handlePause(_reason: 'rejection' | 'error'): void;
399
+ /**
400
+ * Store runtime system prompt for session creation.
401
+ * Subclasses may override to apply SDK-specific side effects (e.g., Gemini's setSystemInstruction).
402
+ * @param prompt - System prompt from start/initialize options
403
+ */
404
+ protected captureSystemPrompt(prompt: SystemPrompt | undefined): void;
405
+ /**
406
+ * Update the agent's processing state.
407
+ * State transitions trigger events via emittery.
408
+ * @param state - New processing state
409
+ */
410
+ protected updateProcessingState(state: ProcessingState): Promise<void>;
411
+ /**
412
+ * Subscribe to processing state changes (idle ↔ processing transitions).
413
+ * @param handler - Called with `{ isProcessing: boolean }` on each state change
414
+ * @returns Unsubscribe function
415
+ */
416
+ onProcessingStateChanged(handler: (payload: EmitteryEvents['processingStateChanged']) => Promise<void> | void): _$emittery.UnsubscribeFunction;
417
+ /**
418
+ * Wait for a single processing state change matching an optional predicate.
419
+ * @param predicate - Optional filter, e.g., `(e) => !e.isProcessing` for idle
420
+ * @returns Promise resolving to `{ isProcessing: boolean }`
421
+ */
422
+ onceProcessingStateChanged(predicate?: (eventData: EmitteryEvents['processingStateChanged']) => boolean): Promise<ProcessingState>;
423
+ /**
424
+ * Initialize the connector's SDK session without sending a message.
425
+ * Must set adapterSessionId before returning.
426
+ * Called by createAgent for idle agent setup.
427
+ * Implementations MUST be idempotent (no-op if already initialized).
428
+ * @param options - Optional start options (e.g., systemPrompt for Claude)
429
+ */
430
+ abstract initialize(options?: ConnectorStartOptions): Promise<void>;
431
+ /**
432
+ * Start agent with initial message.
433
+ * @param message - Normalized user message (role and content)
434
+ * @param options - Optional start options (e.g., delivery mode)
435
+ * @returns Session ID, agent ID, and message handle for tracking
436
+ */
437
+ abstract start(message: NormalizedMessageInput, options?: ConnectorStartOptions): Promise<AgentStartResult>;
438
+ /**
439
+ * Send a message to the agent.
440
+ * For initial message, use start() instead.
441
+ * @param message - Normalized message content
442
+ * @param options - Send options (e.g., delivery mode, message ID)
443
+ * @returns Message handle for tracking
444
+ */
445
+ abstract sendMessage(message: NormalizedMessageInput, options?: ConnectorSendMessageOptions): Promise<MessageHandle>;
446
+ /**
447
+ * Abort the agent and cleanup resources (panic mode).
448
+ * Triggers AbortController which may cause provider errors.
449
+ * Use close() for graceful shutdown instead.
450
+ */
451
+ abstract abort(): void;
452
+ /**
453
+ * Gracefully close the agent session.
454
+ * Unlike abort(), this doesn't trigger AbortController errors.
455
+ * Use this for normal shutdown; use abort() for emergency termination.
456
+ */
457
+ abstract close(): Promise<void>;
458
+ /**
459
+ * Get session ID, waiting for provider to generate it if not yet available.
460
+ * @returns Session ID from provider
461
+ */
462
+ abstract getAdapterSessionId(): Promise<string>;
463
+ /**
464
+ * Complete the agent session by waiting for all messages to finish.
465
+ * @returns Last message result or null if no messages processed
466
+ */
467
+ abstract complete(): Promise<MessageResult | null>;
468
+ /**
469
+ * Create a MessageHandle with standard initialization.
470
+ *
471
+ * Centralizes the pattern used by all connectors:
472
+ * 1. Generate messageId (use provided or generate UUID)
473
+ * 2. Create MessageHandle instance
474
+ * 3. Set adapterSessionId
475
+ * 4. Call onMessageSent callback
476
+ * @param message - Normalized user message
477
+ * @param options - Optional message options (id, delivery mode, history, and turn context)
478
+ * @returns Initialized MessageHandle ready for enqueueing
479
+ */
480
+ protected createMessageHandle(message: NormalizedMessageInput, options?: MessageHandleOptions): MessageHandle;
481
+ /**
482
+ * Signal that MCP tools have changed and should be refreshed at the next turn boundary.
483
+ *
484
+ * Called by the AIAgent layer when receiving MCP bus events (`mcp.tools.updated`,
485
+ * `mcp.tools.enabled`). Connectors that support direct-inject tool refresh (e.g.,
486
+ * `BaseStreamConnector`) override this to set an internal pending-refresh flag.
487
+ * The default implementation is a no-op so connectors that do not manage MCP tools
488
+ * directly are unaffected.
489
+ */
490
+ markToolRefreshPending(): void;
491
+ /**
492
+ * Stage the canonical orchestrator-assigned turn number for consumption by the next
493
+ * {@link consumeTurnNumber} call. The counter is monotonically increasing.
494
+ * @param turnNumber - Canonical 1-based turn number from SessionOrchestrator
495
+ * @throws RangeError when the value is invalid, regresses, or downgrades a staged value
496
+ */
497
+ setCanonicalTurnNumber(turnNumber: number): void;
498
+ /**
499
+ * Advance to the next turn number, consuming any pending canonical value.
500
+ * Orchestrator-staged values win; otherwise the local counter increments by one.
501
+ * @returns The current turn number after advancement
502
+ */
503
+ protected consumeTurnNumber(): number;
504
+ /**
505
+ * Current turn number (read-only). Use {@link consumeTurnNumber} to advance.
506
+ * @returns The current turn number
507
+ */
508
+ protected get currentTurnNumber(): number;
509
+ /**
510
+ * Staged canonical turn number, or `undefined` if none was staged.
511
+ * @returns The pending canonical turn number
512
+ */
513
+ protected get pendingTurnNumber(): number | undefined;
514
+ /**
515
+ * Attempt to change the model without a connector swap.
516
+ * Subclasses override when the SDK supports in-place model changes.
517
+ * Base implementation returns false (swap required).
518
+ *
519
+ * **Mutation contract:** Implementations MUST NOT mutate `this.model` directly.
520
+ * The caller (AIAgent.handleModelChange) owns the `this.model` field update after
521
+ * a successful in-place change. Implementations only configure the SDK-internal model
522
+ * (e.g., `query.setModel()`, `geminiConfig.setModel()`).
523
+ * @param _newModel - The model identifier to switch to
524
+ * @returns true if changed in-place, false if swap needed. Exceptions are caught by the
525
+ * caller and treated as false (automatic swap fallback), so implementations need not guard.
526
+ */
527
+ changeModelInPlace(_newModel: string): Promise<boolean>;
528
+ /**
529
+ * Attempt to change the working directory without a connector swap.
530
+ * Subclasses override when the adapter supports in-place cwd changes (e.g., stateless APIs).
531
+ * Base implementation returns false (swap required).
532
+ *
533
+ * **Mutation contract:** Implementations MUST NOT mutate `this.cwd` directly.
534
+ * The caller (AIAgent.handleCwdChange) owns the `this.cwd` field update after
535
+ * a successful in-place change. Implementations only update SDK-internal state.
536
+ * @param _newCwd - The working directory path to switch to
537
+ * @returns true if changed in-place, false if swap needed. Exceptions are caught by the
538
+ * caller and treated as false (automatic swap fallback), so implementations need not guard.
539
+ */
540
+ changeCwdInPlace(_newCwd: string): Promise<boolean>;
541
+ /**
542
+ * Attempt to change reasoning effort without swapping the connector.
543
+ *
544
+ * Override in subclasses that support in-place reasoning changes (e.g., adapters
545
+ * that pass reasoning parameters per-request rather than at session-creation time).
546
+ * The base implementation returns `false` so callers fall back to a connector swap.
547
+ *
548
+ * **Mutation contract:** Implementations MUST NOT mutate `this.currentReasoningEffort`
549
+ * directly. The caller owns the `currentReasoningEffort` field update after a successful
550
+ * in-place change. Implementations only configure the SDK-internal reasoning parameter.
551
+ * @param _newLevel - The new reasoning effort level to apply
552
+ * @returns `true` if the change was applied in-place, `false` if a connector swap is needed
553
+ */
554
+ changeReasoningInPlace(_newLevel: AIReasoningLevel): Promise<boolean>;
555
+ /**
556
+ * Interrupt the current message processing.
557
+ * @returns Promise that resolves when interrupt is handled
558
+ */
559
+ abstract interrupt(): Promise<void>;
560
+ /**
561
+ * Marks pending message as failed, calls error handler, resolves completion promise.
562
+ * @param error - Error that occurred
563
+ * @param terminate - Whether to abort the agent after handling error
564
+ * @internal
565
+ */
566
+ handleError(error: unknown, terminate?: boolean): void;
567
+ protected handleToolApprovalDenied(abort: 'not_requested' | 'not_supported' | 'handled', details?: string): void;
568
+ getAgentId(): string;
569
+ getAdapterName(): string;
570
+ /**
571
+ * Get timeout value for a specific category.
572
+ * @param category - Timeout category (initialization, acknowledgement, completion, toolApproval, eventWait)
573
+ * @returns Timeout value in milliseconds
574
+ */
575
+ getTimeoutMs(category: keyof typeof this.timeouts.values): number;
576
+ /**
577
+ * Request tool approval via the scoped bus with auto-injected metadata.
578
+ *
579
+ * Wraps `scopedBus.request()` to automatically include connector identity
580
+ * (adapterName, agentId, adapterId, adapterSessionId) in the payload.
581
+ * @param subject - Subject definition for the tool approval request
582
+ * @param payload - Request payload (metadata fields are forbidden and auto-injected)
583
+ * @returns Promise resolving to the approval response
584
+ */
585
+ protected requestToolApproval<TSubject extends ScopedSubjectDefinition<TBus['namespace']>>(subject: TSubject, payload: Forbid<TSubject['$meta']['payload']['request'], ForbiddenKeys>): Promise<TSubject['$meta']['payload']['response']>;
586
+ /**
587
+ * Execute a tool approval request with the shared diagnostics wrapper.
588
+ *
589
+ * Handles the common `RequestError`/`NoHandlerError` path by logging a helpful
590
+ * message via `handleError` and re-throwing so callers can decide whether to
591
+ * surface the failure or fall back to a denial.
592
+ * @param subject - Scoped subject definition for the tool approval request
593
+ * @param payload - Payload that must not include adapter metadata
594
+ * @returns Tool approval response payload
595
+ */
596
+ protected requestToolApprovalWithHandling<TSubject extends ScopedSubjectDefinition<TBus['namespace']>>(subject: TSubject, payload: Forbid<TSubject['$meta']['payload']['request'], ForbiddenKeys>): Promise<TSubject['$meta']['payload']['response']>;
597
+ /**
598
+ * Emit an event via the scoped bus with auto-injected metadata.
599
+ *
600
+ * Wraps `scopedBus.emit()` to automatically include connector identity
601
+ * (adapterName, agentId, adapterId, adapterSessionId) in the payload.
602
+ * @param subject - Subject definition for the event
603
+ * @param payload - Event payload (metadata fields are forbidden and auto-injected)
604
+ * @returns Promise that resolves when the event is emitted
605
+ */
606
+ protected emit<TSubject extends ScopedSubjectDefinition<TBus['namespace']>>(subject: TSubject, payload: Forbid<TSubject['$meta']['payload'], ForbiddenKeys>): Promise<void>;
607
+ /**
608
+ * Subscribe to events on the filtered bus (pre-filtered by agentId).
609
+ *
610
+ * Uses `filteredBus` which only delivers events matching this connector's agentId.
611
+ * @param subject - Subject definition to subscribe to
612
+ * @param handler - Event handler receiving the event context
613
+ * @param options - Optional subscription options (e.g., priority)
614
+ * @returns Unsubscribe function
615
+ */
616
+ on<Subject extends ScopedSubjectDefinition<TBus['namespace']>>(subject: Subject, handler: HandlerForSubjectDefinition<Subject>, options?: OnOptions): () => void;
617
+ /**
618
+ * Wait for a single event on the filtered bus (pre-filtered by agentId).
619
+ *
620
+ * Uses `filteredBus` which only delivers events matching this connector's agentId.
621
+ * @param subject - Subject definition to wait for
622
+ * @param options - Optional options (e.g., predicate filter, timeout)
623
+ * @returns Promise resolving to the event context
624
+ */
625
+ once<Subject extends ScopedSubjectDefinition<TBus['namespace']>>(subject: Subject, options?: Parameters<IFilteredBus<TBus['namespace'], ExtractScopedBusSubjects<TBus>>['once']>[1]): Promise<never>;
626
+ protected logLowLevelEvent(_event: unknown): void;
627
+ }
628
+ //#endregion
629
+ //#region adapters/core/src/adapter/ai-adapter-config.d.ts
630
+ /**
631
+ * Input provided by agent to the config factory.
632
+ * Contains partial configuration - adapters provide defaults for missing required fields.
633
+ *
634
+ * Includes all runtime options from StartAgentRequest (allowedTools, disallowedTools, etc.)
635
+ * to ensure they flow through to the connector.
636
+ */
637
+ interface ConfigFactoryInput<TBus extends ScopedBus<string> = ScopedBus<string>> {
638
+ /** Scoped bus for adapter-specific events */
639
+ bus: TBus;
640
+ /** Unique agent identifier (required - generated by AIAgent) */
641
+ agentId: string;
642
+ /** Adapter instance identifier (required - provided by AIAgent from adapter) */
643
+ adapterId: string;
644
+ /** Adapter type name (required - provided by AIAgent from adapter) */
645
+ adapterName: string;
646
+ /**
647
+ * Unresolved provider context (credential refs, not plaintext).
648
+ * Connectors resolve credentials locally via `resolveConnectorCredentials()`.
649
+ */
650
+ providerContext: ProviderContext;
651
+ /** Provider's session ID for resuming existing conversations */
652
+ adapterSessionId?: string;
653
+ /** Makaio session ID for tool execution context and multi-session correlation */
654
+ sessionId?: string;
655
+ /** Previous adapter session ID for resume attempts (from recovery). */
656
+ resumeAdapterSessionId?: string;
657
+ /** Model to use - optional, adapters provide defaults */
658
+ model?: string;
659
+ /** Working directory for agent execution */
660
+ cwd?: string;
661
+ /** Environment variables to pass to agent execution */
662
+ env?: Record<string, string>;
663
+ /** Reasoning effort for supporting adapters */
664
+ reasoningEffort?: AIReasoningLevel$1;
665
+ /** Reasoning levels supported by the resolved model, forwarded to the connector. */
666
+ supportedReasoningLevels?: ReasoningLevelMap$1;
667
+ /** Error handler for connector errors */
668
+ errorHandler?: (error: Error, terminate: boolean) => void;
669
+ /** Allowed tool names (adapter-specific). Empty array = disable all tools. */
670
+ allowedTools?: string[];
671
+ /** Disallowed tool names (adapter-specific). Takes precedence over allowedTools. */
672
+ disallowedTools?: string[];
673
+ /** Directory restrictions for file-system tool execution. */
674
+ allowedDirectories?: string[];
675
+ /** Provider-specific configuration (non-credential settings). Adapters merge with defaults. */
676
+ providerConfig?: Record<string, unknown>;
677
+ runtimeTimeouts?: TimeoutConfig;
678
+ /** Client identifier for the application this adapter belongs to (e.g., 'claude-code', 'gemini'). */
679
+ clientId?: string;
680
+ /** Client profile name for session-scoped config isolation. */
681
+ clientProfileName?: string;
682
+ /**
683
+ * Resolved MCP session context including upstream server configs.
684
+ * When present, native-passthrough adapters use `servers` to configure SDK MCP connections.
685
+ */
686
+ mcpSessionContext?: LedgerSessionContext | McpRuntimeSessionContext | McpSessionContext;
687
+ /**
688
+ * Session-scoped MCP tool ledger.
689
+ * Passed through unchanged so connectors can track injection and mcp_call usage.
690
+ */
691
+ toolLedger?: ISessionToolLedger;
692
+ }
693
+ /**
694
+ * Interface for adapter-specific configuration factories.
695
+ *
696
+ * Transforms partial ConfigFactoryInput into full adapter-specific config.
697
+ * The key responsibility is applying adapter defaults (especially model).
698
+ * @example
699
+ * ```typescript
700
+ * const OpenAIConfigFactory: IAdapterConfigFactory<OpenAINodeAgentConfig> = {
701
+ * getConfig: async (input) => ({
702
+ * ...input,
703
+ * model: input.model ?? 'gpt-4o',
704
+ * providerConfig: { debugMode: true },
705
+ * }),
706
+ * };
707
+ * ```
708
+ */
709
+ interface IAdapterConfigFactory<TConfig extends BaseAgentConnectorConfig, TBus extends ScopedBus<string> = ScopedBus<string>> {
710
+ getConfig(input: ConfigFactoryInput<TBus>): Promise<TConfig>;
711
+ }
712
+ //#endregion
713
+ //#region adapters/core/src/agent/types.d.ts
714
+ /**
715
+ * Core agent identity fields.
716
+ * Used as base for contexts, configs, and request payloads.
717
+ */
718
+ interface AgentIdentity {
719
+ /** Unique agent identifier */
720
+ agentId: string;
721
+ /** Adapter instance identifier */
722
+ adapterId: string;
723
+ /** Adapter type name (e.g., 'claude-code', 'gemini-sdk') */
724
+ adapterName: string;
725
+ /** Session identifier for multi-turn conversations */
726
+ adapterSessionId?: string;
727
+ }
728
+ /**
729
+ * Runtime options as INPUT - model/cwd optional (adapters provide defaults via configFactory).
730
+ */
731
+ interface AgentRuntimeInput {
732
+ /** Model to use (optional - adapter provides default) */
733
+ model?: string;
734
+ /** Working directory for agent execution (optional - platform provides default) */
735
+ cwd?: string;
736
+ /** Environment variables to pass to agent execution */
737
+ env?: Record<string, string>;
738
+ /** Reasoning effort for supporting adapters */
739
+ reasoningEffort?: AIReasoningLevel$1;
740
+ }
741
+ /**
742
+ * Runtime options as RESOLVED config - model/cwd required (after configFactory applies defaults).
743
+ */
744
+ type AgentRuntimeOptions = SetRequired<AgentRuntimeInput, 'model' | 'cwd'>;
745
+ /**
746
+ * Common context fields for all agent.* subject emissions.
747
+ * AIAgent automatically enriches payloads with these fields.
748
+ */
749
+ type AgentContext = Required<AgentIdentity>;
750
+ /**
751
+ * Execution context for per-agent processors.
752
+ * Baked in at processor creation time, eliminating runtime registry lookups.
753
+ */
754
+ type ExecutionContext = AgentContext;
755
+ interface MinimalAgentConnectorConfig<TBus extends ScopedBus<string> = ScopedBus<string>> {
756
+ bus: TBus;
757
+ }
758
+ /**
759
+ * Base configuration for AI agent connector instances.
760
+ */
761
+ interface BaseAgentConnectorConfig<TBus extends ScopedBus<string> = ScopedBus<string>, TProviderConfig extends object = object> extends MinimalAgentConnectorConfig<TBus>, Omit<AgentIdentity, 'adapterId'>, AgentRuntimeOptions {
762
+ /** Makaio session ID for tool execution context and multi-session correlation */
763
+ sessionId?: string;
764
+ errorHandler?: (error: Error, terminate: boolean) => void;
765
+ /**
766
+ * Resolved timeout configuration with provenance tracking.
767
+ * Set by configFactory after merging all timeout layers.
768
+ */
769
+ timeouts?: TrackedTimeoutConfig;
770
+ /**
771
+ * UUID of the ProviderConfig entity used during agent creation.
772
+ * Carried on the connector config for runtime introspection and dynamic provider switching.
773
+ */
774
+ providerConfigId?: string;
775
+ /**
776
+ * Unresolved provider context (credential refs, not plaintext).
777
+ *
778
+ * Passed through from the factory input so connectors can call
779
+ * `resolveConnectorCredentials()` locally during initialization.
780
+ * Connectors must NOT read plaintext credentials from this field —
781
+ * they must resolve refs via `resolveConnectorCredentials()`.
782
+ */
783
+ providerContext?: ProviderContext;
784
+ providerConfig?: TProviderConfig;
785
+ /**
786
+ * Maps supported reasoning levels to provider-native values for the active model.
787
+ *
788
+ * Populated by the config factory when the resolved model declares reasoning support.
789
+ * Absent when the model does not support extended thinking.
790
+ */
791
+ supportedReasoningLevels?: ReasoningLevelMap$1;
792
+ /** Previous adapter session ID for resume attempts. */
793
+ resumeAdapterSessionId?: string;
794
+ /** Resolved harness ID for tool policy lookup. */
795
+ harnessId?: string;
796
+ /** Client identifier for the application this adapter belongs to (e.g., 'claude-code', 'gemini'). */
797
+ clientId?: string;
798
+ /** Client profile name for session-scoped config isolation. */
799
+ clientProfileName?: string;
800
+ /** Callback when a user message is enqueued */
801
+ onMessageSent?: (messageHandle: MessageHandle) => void;
802
+ /**
803
+ * Directory restrictions for file-system tool execution.
804
+ * When set, forwarded as `constraints.allowedDirectories` in every tool call.
805
+ * Empty array means no restriction; undefined means no restriction.
806
+ */
807
+ allowedDirectories?: string[];
808
+ /**
809
+ * MCP session context resolved by the orchestrator.
810
+ * Provides the direct and discoverable tool sets for the current session.
811
+ * When present, enables MCP tool injection and ledger tracking.
812
+ *
813
+ * Intentionally narrowed to LedgerSessionContext — the minimal shape the
814
+ * ledger needs. Adapters requiring the full McpSessionContext (with
815
+ * resolution keys / servers) re-declare this field via Omit + intersection
816
+ * in their own config types (e.g. BaseStreamConnectorConfig, ClaudeAgentConfig).
817
+ */
818
+ mcpSessionContext?: LedgerSessionContext | McpRuntimeSessionContext | McpSessionContext;
819
+ /**
820
+ * Session-scoped tool ledger for tracking injection, discovery, and call history.
821
+ * When present, the connector records tool events into this ledger.
822
+ */
823
+ toolLedger?: ISessionToolLedger;
824
+ }
825
+ /**
826
+ * Configuration for creating an AIAgent instance.
827
+ *
828
+ * Combines agent identity, runtime input, and factory functions.
829
+ * model/cwd are optional here - configFactory provides adapter defaults.
830
+ * @typeParam TBus - The scoped bus type for this adapter
831
+ * @typeParam TConnector - The connector type (for proper factory return typing)
832
+ */
833
+ interface AIAgentConfig<TBus extends ScopedBus<string> = ScopedBus<string>, TConnector extends AIAgentConnector<TBus> = AIAgentConnector<TBus>> extends Omit<AgentIdentity, 'adapterSessionId'>, AgentRuntimeInput {
834
+ /** Adapter-specific session identifier for multi-turn conversations */
835
+ adapterSessionId?: string;
836
+ /** Makaio session identifier */
837
+ sessionId?: string;
838
+ /**
839
+ * Unresolved provider context (credential refs, not plaintext).
840
+ * Set by the orchestrator before forwarding the startAgent request.
841
+ * Connectors resolve credentials locally via `resolveConnectorCredentials()`.
842
+ */
843
+ providerContext?: ProviderContext;
844
+ /** Previous adapter session ID for resume attempts (from recovery). */
845
+ resumeAdapterSessionId?: string;
846
+ /** Resolved harness ID for tool policy lookup. */
847
+ harnessId?: string;
848
+ /** Client identifier for the application this adapter belongs to (e.g., 'claude-code', 'gemini'). */
849
+ clientId?: string;
850
+ /** Client profile name for session-scoped config isolation. */
851
+ clientProfileName?: string;
852
+ /** Global bus instance (defaults to MakaioBus singleton) */
853
+ globalBus?: IMakaioBus;
854
+ /** Scoped bus for adapter-specific events */
855
+ adapterBus: TBus;
856
+ /** Adapter capabilities (e.g., ['streaming', 'tools', 'vision']) */
857
+ capabilities: string[];
858
+ /** Native tools built into the adapter (e.g., ['shell_command', 'apply_patch']) */
859
+ nativeTools: string[];
860
+ /** Available models for this adapter (used for context window lookup) */
861
+ availableModels?: AIModel[];
862
+ /** Allowed tool names (adapter-specific). Empty array = disable all tools. */
863
+ allowedTools?: string[];
864
+ /** Disallowed tool names (adapter-specific). Takes precedence over allowedTools. */
865
+ disallowedTools?: string[];
866
+ /** Directory restrictions for file-system tool execution. */
867
+ allowedDirectories?: string[];
868
+ /**
869
+ * MCP session context resolved by the orchestrator.
870
+ * Passed through to the connector config so adapters can inject direct tools.
871
+ */
872
+ mcpSessionContext?: LedgerSessionContext | McpRuntimeSessionContext;
873
+ /**
874
+ * Session-scoped ledger tracking MCP injection/discovery/call history.
875
+ * Created once per agent session and passed through unchanged on connector swaps.
876
+ */
877
+ toolLedger?: ISessionToolLedger;
878
+ /**
879
+ * When true, PreUserMessage hooks are skipped for this agent.
880
+ * Use for ephemeral ping agents where session enrichment and context injection
881
+ * are not needed and would be actively harmful.
882
+ */
883
+ ephemeral?: boolean;
884
+ /**
885
+ * Config factory - transforms partial input into full adapter-specific config.
886
+ * This is the seam where adapters inject their defaults (especially model).
887
+ */
888
+ configFactory: (input: ConfigFactoryInput<TBus>) => Promise<BaseAgentConnectorConfig<TBus> & {
889
+ adapterId: string;
890
+ }>;
891
+ /**
892
+ * Connector factory - creates connector from full config.
893
+ * Called AFTER configFactory returns the complete configuration.
894
+ * Config includes adapterId (passed through from input by config factory).
895
+ */
896
+ connectorFactory: (config: BaseAgentConnectorConfig<TBus> & {
897
+ adapterId: string;
898
+ }) => TConnector | Promise<TConnector>;
899
+ }
900
+ /**
901
+ * Result returned from agent.start()
902
+ */
903
+ interface AgentStartResult {
904
+ adapterSessionId: string;
905
+ agentId: string;
906
+ messageHandle: MessageHandle;
907
+ }
908
+ /**
909
+ * Options for sending a message to an agent.
910
+ * Extends SendMessageOptions with curated message history and system prompt configuration.
911
+ */
912
+ interface AgentSendMessageOptions extends SendMessageOptions {
913
+ /** Curated message history from orchestration layer */
914
+ messageHistory?: Message[];
915
+ /**
916
+ * System prompt configuration.
917
+ * - `string`: Replace/set the entire system prompt
918
+ * - `{ mode: 'append', content: string }`: Append to adapter's default system prompt
919
+ */
920
+ systemPrompt?: SystemPrompt;
921
+ /**
922
+ * Context signals assembled by SessionOrchestrator.
923
+ * Used by AIAgent to decide: native resume vs fresh with history.
924
+ * Hooks inject context via sessionContext.turnContext (set by replacePayload).
925
+ */
926
+ sessionContext?: SessionContext;
927
+ /**
928
+ * JSON Schema for structured output.
929
+ * When present and the adapter declares `structuredOutput` capability,
930
+ * the adapter enforces this schema at the model level.
931
+ * Ignored by adapters that lack the capability.
932
+ */
933
+ responseSchema?: Record<string, unknown>;
934
+ }
935
+ /**
936
+ * Options for starting an agent session.
937
+ * Same as AgentSendMessageOptions - both start() and sendMessage() accept the same options.
938
+ */
939
+ type StartAgentOptions = AgentSendMessageOptions;
940
+ /**
941
+ * Options for connector-level message operations.
942
+ * Extends AgentSendMessageOptions with turnContext for internal AIAgent to Connector communication.
943
+ * AIAgent extracts sessionContext.turnContext and passes it here.
944
+ * Inherits responseSchema from AgentSendMessageOptions.
945
+ */
946
+ interface ConnectorSendMessageOptions extends AgentSendMessageOptions {
947
+ /**
948
+ * Turn-scoped context assembled by PreUserMessage hooks and the orchestrator.
949
+ * Extracted from sessionContext.turnContext by AIAgent.
950
+ * Adapters use this to prepend context blocks to the SDK message.
951
+ *
952
+ * ADAPTER CONTRACT: Every adapter MUST materialize turnContext into the
953
+ * LLM-facing message using serializeTurnContext().
954
+ */
955
+ turnContext?: Record<string, JsonValue>;
956
+ }
957
+ /**
958
+ * Options for connector-level start operations.
959
+ * Same as ConnectorSendMessageOptions.
960
+ */
961
+ type ConnectorStartOptions = ConnectorSendMessageOptions;
962
+ /** Payload type for `agent.sendMessage` requests. */
963
+ type SendMessageRequestPayload = ExtractSubjectPayload<typeof AgentSubjects.sendMessage>;
964
+ /** Response type for `agent.sendMessage` requests. */
965
+ type SendMessageResponsePayload = ExtractSubjectResponse<typeof AgentSubjects.sendMessage>;
966
+ /** Payload type for `agent.interrupt` requests. */
967
+ type AgentInterruptRequestPayload = ExtractSubjectPayload<typeof AgentSubjects.interrupt>;
968
+ /** Response type for `agent.interrupt` requests. */
969
+ type AgentInterruptResponsePayload = ExtractSubjectResponse<typeof AgentSubjects.interrupt>;
970
+ /** Response type for `agent.getCapabilities` requests. */
971
+ type GetCapabilitiesResponsePayload = ExtractSubjectResponse<typeof AgentSubjects.getCapabilities>;
972
+ /** Payload type for `agent.cwd.change` requests. */
973
+ type AgentCwdChangeRequestPayload = ExtractSubjectPayload<typeof AgentSubjects.cwd.change>;
974
+ /** Response type for `agent.cwd.change` requests. */
975
+ type AgentCwdChangeResponsePayload = ExtractSubjectResponse<typeof AgentSubjects.cwd.change>;
976
+ /** Payload type for `agent.model.change` requests. */
977
+ type AgentModelChangeRequestPayload = ExtractSubjectPayload<typeof AgentSubjects.model.change>;
978
+ /** Response type for `agent.model.change` requests. */
979
+ type AgentModelChangeResponsePayload = ExtractSubjectResponse<typeof AgentSubjects.model.change>;
980
+ /** Payload type for `agent.mcp.servers.set` requests. */
981
+ type AgentMcpServersSetRequestPayload = ExtractSubjectPayload<typeof AgentSubjects.mcp.servers.set>;
982
+ /** Response type for `agent.mcp.servers.set` requests. */
983
+ type AgentMcpServersSetResponsePayload = ExtractSubjectResponse<typeof AgentSubjects.mcp.servers.set>;
984
+ /** Payload type for `agent.credential.change` requests. */
985
+ type AgentCredentialChangeRequestPayload = ExtractSubjectPayload<typeof AgentSubjects.credential.change>;
986
+ /** Response type for `agent.credential.change` requests. */
987
+ type AgentCredentialChangeResponsePayload = ExtractSubjectResponse<typeof AgentSubjects.credential.change>;
988
+ type EmitteryEvents = {
989
+ processingStateChanged: ProcessingState;
990
+ };
991
+ /**
992
+ * Normalized usage metrics for a single agent call.
993
+ * Adapter implementations normalize provider-specific usage data to this format.
994
+ */
995
+ type NormalizedCallUsage = Omit<z.infer<typeof AgentSchemas.usage>, keyof AgentContext | 'model'>;
996
+ /**
997
+ * Input for context window update emission.
998
+ * Adapters provide raw metrics, helper calculates percentage and level.
999
+ */
1000
+ interface ContextWindowInput {
1001
+ /** Total tokens in context (input + output for next turn prediction) */
1002
+ currentTokens: number;
1003
+ /** Model's context window limit */
1004
+ maxTokens: number;
1005
+ /** Cached tokens (optional, reduces cost but still in context) */
1006
+ cachedTokens?: number;
1007
+ }
1008
+ //#endregion
1009
+ export { MessageHandle as A, ISessionToolLedger as B, SendMessageRequestPayload as C, IAdapterConfigFactory as D, ConfigFactoryInput as E, ProcessingState as F, SessionToolLedger as H, SendMessageOptions as I, AIModel as L, normalizeMessageInput as M, MessageResult as N, AIAgentConnector as O, MessageState as P, AIReasoningLevel$1 as R, NormalizedCallUsage as S, StartAgentOptions as T, ToolLedgerEntry as U, LedgerSessionContext as V, ConnectorSendMessageOptions as _, AgentCwdChangeRequestPayload as a, ExecutionContext as b, AgentInterruptRequestPayload as c, AgentMcpServersSetResponsePayload as d, AgentModelChangeRequestPayload as f, BaseAgentConnectorConfig as g, AgentStartResult as h, AgentCredentialChangeResponsePayload as i, NormalizedMessageInput as j, MessageDeliveryMode$1 as k, AgentInterruptResponsePayload as l, AgentSendMessageOptions as m, AgentContext as n, AgentCwdChangeResponsePayload as o, AgentModelChangeResponsePayload as p, AgentCredentialChangeRequestPayload as r, AgentIdentity as s, AIAgentConfig as t, AgentMcpServersSetRequestPayload as u, ConnectorStartOptions as v, SendMessageResponsePayload as w, GetCapabilitiesResponsePayload as x, ContextWindowInput as y, ReasoningLevelMap$1 as z };