@agentick/core 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (626) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +875 -0
  3. package/dist/.tsbuildinfo +1 -0
  4. package/dist/.tsbuildinfo.build +1 -0
  5. package/dist/agent.d.ts +32 -0
  6. package/dist/agent.d.ts.map +1 -0
  7. package/dist/agent.js +26 -0
  8. package/dist/agent.js.map +1 -0
  9. package/dist/agentick-instance.d.ts +285 -0
  10. package/dist/agentick-instance.d.ts.map +1 -0
  11. package/dist/agentick-instance.js +700 -0
  12. package/dist/agentick-instance.js.map +1 -0
  13. package/dist/aidk-instance.d.ts +294 -0
  14. package/dist/aidk-instance.d.ts.map +1 -0
  15. package/dist/aidk-instance.js +340 -0
  16. package/dist/aidk-instance.js.map +1 -0
  17. package/dist/app/session-store.d.ts +57 -0
  18. package/dist/app/session-store.d.ts.map +1 -0
  19. package/dist/app/session-store.js +87 -0
  20. package/dist/app/session-store.js.map +1 -0
  21. package/dist/app/session.d.ts +209 -0
  22. package/dist/app/session.d.ts.map +1 -0
  23. package/dist/app/session.js +2131 -0
  24. package/dist/app/session.js.map +1 -0
  25. package/dist/app/sqlite-session-store.d.ts +60 -0
  26. package/dist/app/sqlite-session-store.d.ts.map +1 -0
  27. package/dist/app/sqlite-session-store.js +234 -0
  28. package/dist/app/sqlite-session-store.js.map +1 -0
  29. package/dist/app/types.d.ts +1461 -0
  30. package/dist/app/types.d.ts.map +1 -0
  31. package/dist/app/types.js +14 -0
  32. package/dist/app/types.js.map +1 -0
  33. package/dist/app.d.ts +79 -0
  34. package/dist/app.d.ts.map +1 -0
  35. package/dist/app.js +83 -0
  36. package/dist/app.js.map +1 -0
  37. package/dist/channels/adapters/index.d.ts +2 -0
  38. package/dist/channels/adapters/index.d.ts.map +1 -0
  39. package/dist/channels/adapters/index.js +2 -0
  40. package/dist/channels/adapters/index.js.map +1 -0
  41. package/dist/channels/adapters/redis.d.ts +77 -0
  42. package/dist/channels/adapters/redis.d.ts.map +1 -0
  43. package/dist/channels/adapters/redis.js +259 -0
  44. package/dist/channels/adapters/redis.js.map +1 -0
  45. package/dist/channels/index.d.ts +38 -0
  46. package/dist/channels/index.d.ts.map +1 -0
  47. package/dist/channels/index.js +38 -0
  48. package/dist/channels/index.js.map +1 -0
  49. package/dist/channels/service.d.ts +684 -0
  50. package/dist/channels/service.d.ts.map +1 -0
  51. package/dist/channels/service.js +870 -0
  52. package/dist/channels/service.js.map +1 -0
  53. package/dist/channels/transports/index.d.ts +4 -0
  54. package/dist/channels/transports/index.d.ts.map +1 -0
  55. package/dist/channels/transports/index.js +4 -0
  56. package/dist/channels/transports/index.js.map +1 -0
  57. package/dist/channels/transports/socketio.d.ts +98 -0
  58. package/dist/channels/transports/socketio.d.ts.map +1 -0
  59. package/dist/channels/transports/socketio.js +246 -0
  60. package/dist/channels/transports/socketio.js.map +1 -0
  61. package/dist/channels/transports/streamable-http.d.ts +107 -0
  62. package/dist/channels/transports/streamable-http.d.ts.map +1 -0
  63. package/dist/channels/transports/streamable-http.js +353 -0
  64. package/dist/channels/transports/streamable-http.js.map +1 -0
  65. package/dist/channels/transports/websocket.d.ts +117 -0
  66. package/dist/channels/transports/websocket.d.ts.map +1 -0
  67. package/dist/channels/transports/websocket.js +416 -0
  68. package/dist/channels/transports/websocket.js.map +1 -0
  69. package/dist/com/index.d.ts +29 -0
  70. package/dist/com/index.d.ts.map +1 -0
  71. package/dist/com/index.js +29 -0
  72. package/dist/com/index.js.map +1 -0
  73. package/dist/com/object-model.d.ts +634 -0
  74. package/dist/com/object-model.d.ts.map +1 -0
  75. package/dist/com/object-model.js +963 -0
  76. package/dist/com/object-model.js.map +1 -0
  77. package/dist/com/types.d.ts +192 -0
  78. package/dist/com/types.d.ts.map +1 -0
  79. package/dist/com/types.js +1 -0
  80. package/dist/com/types.js.map +1 -0
  81. package/dist/compiler/collector.d.ts +16 -0
  82. package/dist/compiler/collector.d.ts.map +1 -0
  83. package/dist/compiler/collector.js +388 -0
  84. package/dist/compiler/collector.js.map +1 -0
  85. package/dist/compiler/content-block-registry.d.ts +11 -0
  86. package/dist/compiler/content-block-registry.d.ts.map +1 -0
  87. package/dist/compiler/content-block-registry.js +312 -0
  88. package/dist/compiler/content-block-registry.js.map +1 -0
  89. package/dist/compiler/extractors.d.ts +68 -0
  90. package/dist/compiler/extractors.d.ts.map +1 -0
  91. package/dist/compiler/extractors.js +547 -0
  92. package/dist/compiler/extractors.js.map +1 -0
  93. package/dist/compiler/fiber-compiler.d.ts +203 -0
  94. package/dist/compiler/fiber-compiler.d.ts.map +1 -0
  95. package/dist/compiler/fiber-compiler.js +498 -0
  96. package/dist/compiler/fiber-compiler.js.map +1 -0
  97. package/dist/compiler/fiber.d.ts +61 -0
  98. package/dist/compiler/fiber.d.ts.map +1 -0
  99. package/dist/compiler/fiber.js +244 -0
  100. package/dist/compiler/fiber.js.map +1 -0
  101. package/dist/compiler/index.d.ts +18 -0
  102. package/dist/compiler/index.d.ts.map +1 -0
  103. package/dist/compiler/index.js +38 -0
  104. package/dist/compiler/index.js.map +1 -0
  105. package/dist/compiler/scheduler.d.ts +95 -0
  106. package/dist/compiler/scheduler.d.ts.map +1 -0
  107. package/dist/compiler/scheduler.js +138 -0
  108. package/dist/compiler/scheduler.js.map +1 -0
  109. package/dist/compiler/structure-renderer.d.ts +42 -0
  110. package/dist/compiler/structure-renderer.d.ts.map +1 -0
  111. package/dist/compiler/structure-renderer.js +189 -0
  112. package/dist/compiler/structure-renderer.js.map +1 -0
  113. package/dist/compiler/types.d.ts +96 -0
  114. package/dist/compiler/types.d.ts.map +1 -0
  115. package/dist/compiler/types.js +19 -0
  116. package/dist/compiler/types.js.map +1 -0
  117. package/dist/component/component-hooks.d.ts +68 -0
  118. package/dist/component/component-hooks.d.ts.map +1 -0
  119. package/dist/component/component-hooks.js +112 -0
  120. package/dist/component/component-hooks.js.map +1 -0
  121. package/dist/component/component.d.ts +314 -0
  122. package/dist/component/component.d.ts.map +1 -0
  123. package/dist/component/component.js +64 -0
  124. package/dist/component/component.js.map +1 -0
  125. package/dist/component/index.d.ts +47 -0
  126. package/dist/component/index.d.ts.map +1 -0
  127. package/dist/component/index.js +47 -0
  128. package/dist/component/index.js.map +1 -0
  129. package/dist/component/tentickle-component.d.ts +185 -0
  130. package/dist/component/tentickle-component.d.ts.map +1 -0
  131. package/dist/component/tentickle-component.js +182 -0
  132. package/dist/component/tentickle-component.js.map +1 -0
  133. package/dist/content/index.d.ts +12 -0
  134. package/dist/content/index.d.ts.map +1 -0
  135. package/dist/content/index.js +17 -0
  136. package/dist/content/index.js.map +1 -0
  137. package/dist/context/index.d.ts +51 -0
  138. package/dist/context/index.d.ts.map +1 -0
  139. package/dist/context/index.js +69 -0
  140. package/dist/context/index.js.map +1 -0
  141. package/dist/core/channel-helpers.d.ts +31 -0
  142. package/dist/core/channel-helpers.d.ts.map +1 -0
  143. package/dist/core/channel-helpers.js +62 -0
  144. package/dist/core/channel-helpers.js.map +1 -0
  145. package/dist/core/channel.d.ts +164 -0
  146. package/dist/core/channel.d.ts.map +1 -0
  147. package/dist/core/channel.js +199 -0
  148. package/dist/core/channel.js.map +1 -0
  149. package/dist/core/context.d.ts +412 -0
  150. package/dist/core/context.d.ts.map +1 -0
  151. package/dist/core/context.js +290 -0
  152. package/dist/core/context.js.map +1 -0
  153. package/dist/core/event-buffer.d.ts +212 -0
  154. package/dist/core/event-buffer.d.ts.map +1 -0
  155. package/dist/core/event-buffer.js +346 -0
  156. package/dist/core/event-buffer.js.map +1 -0
  157. package/dist/core/execution-helpers.d.ts +179 -0
  158. package/dist/core/execution-helpers.d.ts.map +1 -0
  159. package/dist/core/execution-helpers.js +212 -0
  160. package/dist/core/execution-helpers.js.map +1 -0
  161. package/dist/core/execution-tracker.d.ts +53 -0
  162. package/dist/core/execution-tracker.d.ts.map +1 -0
  163. package/dist/core/execution-tracker.js +309 -0
  164. package/dist/core/execution-tracker.js.map +1 -0
  165. package/dist/core/index.d.ts +58 -0
  166. package/dist/core/index.d.ts.map +1 -0
  167. package/dist/core/index.js +58 -0
  168. package/dist/core/index.js.map +1 -0
  169. package/dist/core/logger.d.ts +341 -0
  170. package/dist/core/logger.d.ts.map +1 -0
  171. package/dist/core/logger.js +346 -0
  172. package/dist/core/logger.js.map +1 -0
  173. package/dist/core/metrics-helpers.d.ts +40 -0
  174. package/dist/core/metrics-helpers.d.ts.map +1 -0
  175. package/dist/core/metrics-helpers.js +72 -0
  176. package/dist/core/metrics-helpers.js.map +1 -0
  177. package/dist/core/otel-provider.d.ts +54 -0
  178. package/dist/core/otel-provider.d.ts.map +1 -0
  179. package/dist/core/otel-provider.js +107 -0
  180. package/dist/core/otel-provider.js.map +1 -0
  181. package/dist/core/procedure-graph.d.ts +136 -0
  182. package/dist/core/procedure-graph.d.ts.map +1 -0
  183. package/dist/core/procedure-graph.js +272 -0
  184. package/dist/core/procedure-graph.js.map +1 -0
  185. package/dist/core/procedure.d.ts +755 -0
  186. package/dist/core/procedure.d.ts.map +1 -0
  187. package/dist/core/procedure.js +899 -0
  188. package/dist/core/procedure.js.map +1 -0
  189. package/dist/core/stream.d.ts +106 -0
  190. package/dist/core/stream.d.ts.map +1 -0
  191. package/dist/core/stream.js +186 -0
  192. package/dist/core/stream.js.map +1 -0
  193. package/dist/core/telemetry.d.ts +182 -0
  194. package/dist/core/telemetry.d.ts.map +1 -0
  195. package/dist/core/telemetry.js +124 -0
  196. package/dist/core/telemetry.js.map +1 -0
  197. package/dist/engine/client-tool-coordinator.d.ts +50 -0
  198. package/dist/engine/client-tool-coordinator.d.ts.map +1 -0
  199. package/dist/engine/client-tool-coordinator.js +121 -0
  200. package/dist/engine/client-tool-coordinator.js.map +1 -0
  201. package/dist/engine/engine-events.d.ts +117 -0
  202. package/dist/engine/engine-events.d.ts.map +1 -0
  203. package/dist/engine/engine-events.js +178 -0
  204. package/dist/engine/engine-events.js.map +1 -0
  205. package/dist/engine/engine-response.d.ts +48 -0
  206. package/dist/engine/engine-response.d.ts.map +1 -0
  207. package/dist/engine/engine-response.js +2 -0
  208. package/dist/engine/engine-response.js.map +1 -0
  209. package/dist/engine/execution-graph.d.ts +104 -0
  210. package/dist/engine/execution-graph.d.ts.map +1 -0
  211. package/dist/engine/execution-graph.js +257 -0
  212. package/dist/engine/execution-graph.js.map +1 -0
  213. package/dist/engine/execution-handle.d.ts +212 -0
  214. package/dist/engine/execution-handle.d.ts.map +1 -0
  215. package/dist/engine/execution-handle.js +602 -0
  216. package/dist/engine/execution-handle.js.map +1 -0
  217. package/dist/engine/execution-types.d.ts +248 -0
  218. package/dist/engine/execution-types.d.ts.map +1 -0
  219. package/dist/engine/execution-types.js +23 -0
  220. package/dist/engine/execution-types.js.map +1 -0
  221. package/dist/engine/index.d.ts +21 -0
  222. package/dist/engine/index.d.ts.map +1 -0
  223. package/dist/engine/index.js +23 -0
  224. package/dist/engine/index.js.map +1 -0
  225. package/dist/engine/tool-confirmation-coordinator.d.ts +74 -0
  226. package/dist/engine/tool-confirmation-coordinator.d.ts.map +1 -0
  227. package/dist/engine/tool-confirmation-coordinator.js +137 -0
  228. package/dist/engine/tool-confirmation-coordinator.js.map +1 -0
  229. package/dist/engine/tool-executor.d.ts +127 -0
  230. package/dist/engine/tool-executor.d.ts.map +1 -0
  231. package/dist/engine/tool-executor.js +363 -0
  232. package/dist/engine/tool-executor.js.map +1 -0
  233. package/dist/hibernation/index.d.ts +126 -0
  234. package/dist/hibernation/index.d.ts.map +1 -0
  235. package/dist/hibernation/index.js +127 -0
  236. package/dist/hibernation/index.js.map +1 -0
  237. package/dist/hooks/base-hook-registry.d.ts +41 -0
  238. package/dist/hooks/base-hook-registry.d.ts.map +1 -0
  239. package/dist/hooks/base-hook-registry.js +76 -0
  240. package/dist/hooks/base-hook-registry.js.map +1 -0
  241. package/dist/hooks/com-state.d.ts +40 -0
  242. package/dist/hooks/com-state.d.ts.map +1 -0
  243. package/dist/hooks/com-state.js +90 -0
  244. package/dist/hooks/com-state.js.map +1 -0
  245. package/dist/hooks/context-info.d.ts +139 -0
  246. package/dist/hooks/context-info.d.ts.map +1 -0
  247. package/dist/hooks/context-info.js +115 -0
  248. package/dist/hooks/context-info.js.map +1 -0
  249. package/dist/hooks/context-internal.d.ts +21 -0
  250. package/dist/hooks/context-internal.d.ts.map +1 -0
  251. package/dist/hooks/context-internal.js +20 -0
  252. package/dist/hooks/context-internal.js.map +1 -0
  253. package/dist/hooks/context.d.ts +64 -0
  254. package/dist/hooks/context.d.ts.map +1 -0
  255. package/dist/hooks/context.js +83 -0
  256. package/dist/hooks/context.js.map +1 -0
  257. package/dist/hooks/data.d.ts +33 -0
  258. package/dist/hooks/data.d.ts.map +1 -0
  259. package/dist/hooks/data.js +84 -0
  260. package/dist/hooks/data.js.map +1 -0
  261. package/dist/hooks/formatter-context.d.ts +34 -0
  262. package/dist/hooks/formatter-context.d.ts.map +1 -0
  263. package/dist/hooks/formatter-context.js +34 -0
  264. package/dist/hooks/formatter-context.js.map +1 -0
  265. package/dist/hooks/hook-registry.d.ts +45 -0
  266. package/dist/hooks/hook-registry.d.ts.map +1 -0
  267. package/dist/hooks/hook-registry.js +109 -0
  268. package/dist/hooks/hook-registry.js.map +1 -0
  269. package/dist/hooks/index.d.ts +20 -0
  270. package/dist/hooks/index.d.ts.map +1 -0
  271. package/dist/hooks/index.js +47 -0
  272. package/dist/hooks/index.js.map +1 -0
  273. package/dist/hooks/knob.d.ts +87 -0
  274. package/dist/hooks/knob.d.ts.map +1 -0
  275. package/dist/hooks/knob.js +129 -0
  276. package/dist/hooks/knob.js.map +1 -0
  277. package/dist/hooks/knobs-component.d.ts +70 -0
  278. package/dist/hooks/knobs-component.d.ts.map +1 -0
  279. package/dist/hooks/knobs-component.js +300 -0
  280. package/dist/hooks/knobs-component.js.map +1 -0
  281. package/dist/hooks/lifecycle.d.ts +158 -0
  282. package/dist/hooks/lifecycle.d.ts.map +1 -0
  283. package/dist/hooks/lifecycle.js +217 -0
  284. package/dist/hooks/lifecycle.js.map +1 -0
  285. package/dist/hooks/message-context.d.ts +101 -0
  286. package/dist/hooks/message-context.d.ts.map +1 -0
  287. package/dist/hooks/message-context.js +145 -0
  288. package/dist/hooks/message-context.js.map +1 -0
  289. package/dist/hooks/policy-context.d.ts.map +1 -0
  290. package/dist/hooks/runtime-context.d.ts +122 -0
  291. package/dist/hooks/runtime-context.d.ts.map +1 -0
  292. package/dist/hooks/runtime-context.js +149 -0
  293. package/dist/hooks/runtime-context.js.map +1 -0
  294. package/dist/hooks/signal.d.ts +267 -0
  295. package/dist/hooks/signal.d.ts.map +1 -0
  296. package/dist/hooks/signal.js +825 -0
  297. package/dist/hooks/signal.js.map +1 -0
  298. package/dist/hooks/types.d.ts +179 -0
  299. package/dist/hooks/types.d.ts.map +1 -0
  300. package/dist/hooks/types.js +5 -0
  301. package/dist/hooks/types.js.map +1 -0
  302. package/dist/index.d.ts +20 -0
  303. package/dist/index.d.ts.map +1 -0
  304. package/dist/index.js +50 -0
  305. package/dist/index.js.map +1 -0
  306. package/dist/jsx/components/agent.d.ts +64 -0
  307. package/dist/jsx/components/agent.d.ts.map +1 -0
  308. package/dist/jsx/components/agent.js +80 -0
  309. package/dist/jsx/components/agent.js.map +1 -0
  310. package/dist/jsx/components/complete.d.ts +65 -0
  311. package/dist/jsx/components/complete.d.ts.map +1 -0
  312. package/dist/jsx/components/complete.js +64 -0
  313. package/dist/jsx/components/complete.js.map +1 -0
  314. package/dist/jsx/components/content.d.ts +98 -0
  315. package/dist/jsx/components/content.d.ts.map +1 -0
  316. package/dist/jsx/components/content.js +51 -0
  317. package/dist/jsx/components/content.js.map +1 -0
  318. package/dist/jsx/components/harness.d.ts +118 -0
  319. package/dist/jsx/components/harness.d.ts.map +1 -0
  320. package/dist/jsx/components/harness.js +117 -0
  321. package/dist/jsx/components/harness.js.map +1 -0
  322. package/dist/jsx/components/index.d.ts +11 -0
  323. package/dist/jsx/components/index.d.ts.map +1 -0
  324. package/dist/jsx/components/index.js +11 -0
  325. package/dist/jsx/components/index.js.map +1 -0
  326. package/dist/jsx/components/markdown.d.ts +31 -0
  327. package/dist/jsx/components/markdown.d.ts.map +1 -0
  328. package/dist/jsx/components/markdown.js +17 -0
  329. package/dist/jsx/components/markdown.js.map +1 -0
  330. package/dist/jsx/components/messages.d.ts +283 -0
  331. package/dist/jsx/components/messages.d.ts.map +1 -0
  332. package/dist/jsx/components/messages.js +257 -0
  333. package/dist/jsx/components/messages.js.map +1 -0
  334. package/dist/jsx/components/model.d.ts +94 -0
  335. package/dist/jsx/components/model.d.ts.map +1 -0
  336. package/dist/jsx/components/model.js +96 -0
  337. package/dist/jsx/components/model.js.map +1 -0
  338. package/dist/jsx/components/primitives.d.ts +117 -0
  339. package/dist/jsx/components/primitives.d.ts.map +1 -0
  340. package/dist/jsx/components/primitives.js +83 -0
  341. package/dist/jsx/components/primitives.js.map +1 -0
  342. package/dist/jsx/components/renderer.d.ts +24 -0
  343. package/dist/jsx/components/renderer.d.ts.map +1 -0
  344. package/dist/jsx/components/renderer.js +11 -0
  345. package/dist/jsx/components/renderer.js.map +1 -0
  346. package/dist/jsx/components/semantic.d.ts +155 -0
  347. package/dist/jsx/components/semantic.d.ts.map +1 -0
  348. package/dist/jsx/components/semantic.js +39 -0
  349. package/dist/jsx/components/semantic.js.map +1 -0
  350. package/dist/jsx/components/timeline.d.ts +157 -0
  351. package/dist/jsx/components/timeline.d.ts.map +1 -0
  352. package/dist/jsx/components/timeline.js +357 -0
  353. package/dist/jsx/components/timeline.js.map +1 -0
  354. package/dist/jsx/components/token-budget.d.ts +70 -0
  355. package/dist/jsx/components/token-budget.d.ts.map +1 -0
  356. package/dist/jsx/components/token-budget.js +135 -0
  357. package/dist/jsx/components/token-budget.js.map +1 -0
  358. package/dist/jsx/components/xml.d.ts +27 -0
  359. package/dist/jsx/components/xml.d.ts.map +1 -0
  360. package/dist/jsx/components/xml.js +17 -0
  361. package/dist/jsx/components/xml.js.map +1 -0
  362. package/dist/jsx/index.d.ts +58 -0
  363. package/dist/jsx/index.d.ts.map +1 -0
  364. package/dist/jsx/index.js +59 -0
  365. package/dist/jsx/index.js.map +1 -0
  366. package/dist/jsx/jsx-runtime.d.ts +370 -0
  367. package/dist/jsx/jsx-runtime.d.ts.map +1 -0
  368. package/dist/jsx/jsx-runtime.js +79 -0
  369. package/dist/jsx/jsx-runtime.js.map +1 -0
  370. package/dist/jsx/jsx-types.d.ts +23 -0
  371. package/dist/jsx/jsx-types.d.ts.map +1 -0
  372. package/dist/jsx/jsx-types.js +1 -0
  373. package/dist/jsx/jsx-types.js.map +1 -0
  374. package/dist/mcp/client.d.ts +46 -0
  375. package/dist/mcp/client.d.ts.map +1 -0
  376. package/dist/mcp/client.js +138 -0
  377. package/dist/mcp/client.js.map +1 -0
  378. package/dist/mcp/component.d.ts +95 -0
  379. package/dist/mcp/component.d.ts.map +1 -0
  380. package/dist/mcp/component.js +185 -0
  381. package/dist/mcp/component.js.map +1 -0
  382. package/dist/mcp/create-mcp-tool.d.ts +191 -0
  383. package/dist/mcp/create-mcp-tool.d.ts.map +1 -0
  384. package/dist/mcp/create-mcp-tool.js +228 -0
  385. package/dist/mcp/create-mcp-tool.js.map +1 -0
  386. package/dist/mcp/index.d.ts +49 -0
  387. package/dist/mcp/index.d.ts.map +1 -0
  388. package/dist/mcp/index.js +48 -0
  389. package/dist/mcp/index.js.map +1 -0
  390. package/dist/mcp/service.d.ts +39 -0
  391. package/dist/mcp/service.d.ts.map +1 -0
  392. package/dist/mcp/service.js +77 -0
  393. package/dist/mcp/service.js.map +1 -0
  394. package/dist/mcp/tool.d.ts +55 -0
  395. package/dist/mcp/tool.d.ts.map +1 -0
  396. package/dist/mcp/tool.js +119 -0
  397. package/dist/mcp/tool.js.map +1 -0
  398. package/dist/mcp/types.d.ts +72 -0
  399. package/dist/mcp/types.d.ts.map +1 -0
  400. package/dist/mcp/types.js +6 -0
  401. package/dist/mcp/types.js.map +1 -0
  402. package/dist/middleware/defaults.d.ts +9 -0
  403. package/dist/middleware/defaults.d.ts.map +1 -0
  404. package/dist/middleware/defaults.js +47 -0
  405. package/dist/middleware/defaults.js.map +1 -0
  406. package/dist/model/adapter-helpers.d.ts +161 -0
  407. package/dist/model/adapter-helpers.d.ts.map +1 -0
  408. package/dist/model/adapter-helpers.js +351 -0
  409. package/dist/model/adapter-helpers.js.map +1 -0
  410. package/dist/model/adapter.d.ts +399 -0
  411. package/dist/model/adapter.d.ts.map +1 -0
  412. package/dist/model/adapter.js +497 -0
  413. package/dist/model/adapter.js.map +1 -0
  414. package/dist/model/index.d.ts +54 -0
  415. package/dist/model/index.d.ts.map +1 -0
  416. package/dist/model/index.js +55 -0
  417. package/dist/model/index.js.map +1 -0
  418. package/dist/model/model-hooks.d.ts +45 -0
  419. package/dist/model/model-hooks.d.ts.map +1 -0
  420. package/dist/model/model-hooks.js +24 -0
  421. package/dist/model/model-hooks.js.map +1 -0
  422. package/dist/model/model.d.ts +302 -0
  423. package/dist/model/model.d.ts.map +1 -0
  424. package/dist/model/model.js +20 -0
  425. package/dist/model/model.js.map +1 -0
  426. package/dist/model/simple-adapter.d.ts +176 -0
  427. package/dist/model/simple-adapter.d.ts.map +1 -0
  428. package/dist/model/simple-adapter.js +264 -0
  429. package/dist/model/simple-adapter.js.map +1 -0
  430. package/dist/model/stream-accumulator.d.ts +284 -0
  431. package/dist/model/stream-accumulator.d.ts.map +1 -0
  432. package/dist/model/stream-accumulator.js +532 -0
  433. package/dist/model/stream-accumulator.js.map +1 -0
  434. package/dist/model/utils/index.d.ts +2 -0
  435. package/dist/model/utils/index.d.ts.map +1 -0
  436. package/dist/model/utils/index.js +2 -0
  437. package/dist/model/utils/index.js.map +1 -0
  438. package/dist/model/utils/language-model.d.ts +26 -0
  439. package/dist/model/utils/language-model.d.ts.map +1 -0
  440. package/dist/model/utils/language-model.js +706 -0
  441. package/dist/model/utils/language-model.js.map +1 -0
  442. package/dist/procedure/index.d.ts +20 -0
  443. package/dist/procedure/index.d.ts.map +1 -0
  444. package/dist/procedure/index.js +19 -0
  445. package/dist/procedure/index.js.map +1 -0
  446. package/dist/reconciler/devtools-bridge.d.ts +40 -0
  447. package/dist/reconciler/devtools-bridge.d.ts.map +1 -0
  448. package/dist/reconciler/devtools-bridge.js +79 -0
  449. package/dist/reconciler/devtools-bridge.js.map +1 -0
  450. package/dist/reconciler/host-config.d.ts +39 -0
  451. package/dist/reconciler/host-config.d.ts.map +1 -0
  452. package/dist/reconciler/host-config.js +195 -0
  453. package/dist/reconciler/host-config.js.map +1 -0
  454. package/dist/reconciler/index.d.ts +7 -0
  455. package/dist/reconciler/index.d.ts.map +1 -0
  456. package/dist/reconciler/index.js +7 -0
  457. package/dist/reconciler/index.js.map +1 -0
  458. package/dist/reconciler/reconciler.d.ts +47 -0
  459. package/dist/reconciler/reconciler.d.ts.map +1 -0
  460. package/dist/reconciler/reconciler.js +89 -0
  461. package/dist/reconciler/reconciler.js.map +1 -0
  462. package/dist/reconciler/types.d.ts +86 -0
  463. package/dist/reconciler/types.d.ts.map +1 -0
  464. package/dist/reconciler/types.js +37 -0
  465. package/dist/reconciler/types.js.map +1 -0
  466. package/dist/renderers/base.d.ts +98 -0
  467. package/dist/renderers/base.d.ts.map +1 -0
  468. package/dist/renderers/base.js +82 -0
  469. package/dist/renderers/base.js.map +1 -0
  470. package/dist/renderers/index.d.ts +31 -0
  471. package/dist/renderers/index.d.ts.map +1 -0
  472. package/dist/renderers/index.js +31 -0
  473. package/dist/renderers/index.js.map +1 -0
  474. package/dist/renderers/markdown.d.ts +48 -0
  475. package/dist/renderers/markdown.d.ts.map +1 -0
  476. package/dist/renderers/markdown.js +432 -0
  477. package/dist/renderers/markdown.js.map +1 -0
  478. package/dist/renderers/types.d.ts +7 -0
  479. package/dist/renderers/types.d.ts.map +1 -0
  480. package/dist/renderers/types.js +7 -0
  481. package/dist/renderers/types.js.map +1 -0
  482. package/dist/renderers/xml.d.ts +49 -0
  483. package/dist/renderers/xml.d.ts.map +1 -0
  484. package/dist/renderers/xml.js +444 -0
  485. package/dist/renderers/xml.js.map +1 -0
  486. package/dist/state/boundary.d.ts +347 -0
  487. package/dist/state/boundary.d.ts.map +1 -0
  488. package/dist/state/boundary.js +341 -0
  489. package/dist/state/boundary.js.map +1 -0
  490. package/dist/state/context.d.ts +138 -0
  491. package/dist/state/context.d.ts.map +1 -0
  492. package/dist/state/context.js +139 -0
  493. package/dist/state/context.js.map +1 -0
  494. package/dist/state/hooks.d.ts +798 -0
  495. package/dist/state/hooks.d.ts.map +1 -0
  496. package/dist/state/hooks.js +1437 -0
  497. package/dist/state/hooks.js.map +1 -0
  498. package/dist/state/index.d.ts +72 -0
  499. package/dist/state/index.d.ts.map +1 -0
  500. package/dist/state/index.js +73 -0
  501. package/dist/state/index.js.map +1 -0
  502. package/dist/state/signal.d.ts +223 -0
  503. package/dist/state/signal.d.ts.map +1 -0
  504. package/dist/state/signal.js +699 -0
  505. package/dist/state/signal.js.map +1 -0
  506. package/dist/state/use-state.d.ts +210 -0
  507. package/dist/state/use-state.d.ts.map +1 -0
  508. package/dist/state/use-state.js +327 -0
  509. package/dist/state/use-state.js.map +1 -0
  510. package/dist/tentickle-instance.d.ts +285 -0
  511. package/dist/tentickle-instance.d.ts.map +1 -0
  512. package/dist/tentickle-instance.js +700 -0
  513. package/dist/tentickle-instance.js.map +1 -0
  514. package/dist/testing/act.d.ts +59 -0
  515. package/dist/testing/act.d.ts.map +1 -0
  516. package/dist/testing/act.js +92 -0
  517. package/dist/testing/act.js.map +1 -0
  518. package/dist/testing/async-helpers.d.ts +99 -0
  519. package/dist/testing/async-helpers.d.ts.map +1 -0
  520. package/dist/testing/async-helpers.js +193 -0
  521. package/dist/testing/async-helpers.js.map +1 -0
  522. package/dist/testing/compile-agent.d.ts +101 -0
  523. package/dist/testing/compile-agent.d.ts.map +1 -0
  524. package/dist/testing/compile-agent.js +136 -0
  525. package/dist/testing/compile-agent.js.map +1 -0
  526. package/dist/testing/index.d.ts +57 -0
  527. package/dist/testing/index.d.ts.map +1 -0
  528. package/dist/testing/index.js +59 -0
  529. package/dist/testing/index.js.map +1 -0
  530. package/dist/testing/mock-app.d.ts +163 -0
  531. package/dist/testing/mock-app.d.ts.map +1 -0
  532. package/dist/testing/mock-app.js +393 -0
  533. package/dist/testing/mock-app.js.map +1 -0
  534. package/dist/testing/mocks.d.ts +142 -0
  535. package/dist/testing/mocks.d.ts.map +1 -0
  536. package/dist/testing/mocks.js +191 -0
  537. package/dist/testing/mocks.js.map +1 -0
  538. package/dist/testing/render-agent.d.ts +146 -0
  539. package/dist/testing/render-agent.d.ts.map +1 -0
  540. package/dist/testing/render-agent.js +200 -0
  541. package/dist/testing/render-agent.js.map +1 -0
  542. package/dist/testing/test-adapter.d.ts +157 -0
  543. package/dist/testing/test-adapter.d.ts.map +1 -0
  544. package/dist/testing/test-adapter.js +297 -0
  545. package/dist/testing/test-adapter.js.map +1 -0
  546. package/dist/testing/test-model.d.ts +132 -0
  547. package/dist/testing/test-model.d.ts.map +1 -0
  548. package/dist/testing/test-model.js +260 -0
  549. package/dist/testing/test-model.js.map +1 -0
  550. package/dist/tool/index.d.ts +61 -0
  551. package/dist/tool/index.d.ts.map +1 -0
  552. package/dist/tool/index.js +63 -0
  553. package/dist/tool/index.js.map +1 -0
  554. package/dist/tool/tool-hooks.d.ts +45 -0
  555. package/dist/tool/tool-hooks.d.ts.map +1 -0
  556. package/dist/tool/tool-hooks.js +35 -0
  557. package/dist/tool/tool-hooks.js.map +1 -0
  558. package/dist/tool/tool.d.ts +403 -0
  559. package/dist/tool/tool.d.ts.map +1 -0
  560. package/dist/tool/tool.js +176 -0
  561. package/dist/tool/tool.js.map +1 -0
  562. package/dist/types.d.ts +442 -0
  563. package/dist/types.d.ts.map +1 -0
  564. package/dist/types.js +97 -0
  565. package/dist/types.js.map +1 -0
  566. package/dist/utils/abort-utils.d.ts +5 -0
  567. package/dist/utils/abort-utils.d.ts.map +1 -0
  568. package/dist/utils/abort-utils.js +50 -0
  569. package/dist/utils/abort-utils.js.map +1 -0
  570. package/dist/utils/classify-error.d.ts +19 -0
  571. package/dist/utils/classify-error.d.ts.map +1 -0
  572. package/dist/utils/classify-error.js +77 -0
  573. package/dist/utils/classify-error.js.map +1 -0
  574. package/dist/utils/index.d.ts +21 -0
  575. package/dist/utils/index.d.ts.map +1 -0
  576. package/dist/utils/index.js +21 -0
  577. package/dist/utils/index.js.map +1 -0
  578. package/dist/utils/normalization.d.ts +6 -0
  579. package/dist/utils/normalization.d.ts.map +1 -0
  580. package/dist/utils/normalization.js +103 -0
  581. package/dist/utils/normalization.js.map +1 -0
  582. package/dist/utils/registry.d.ts +15 -0
  583. package/dist/utils/registry.d.ts.map +1 -0
  584. package/dist/utils/registry.js +28 -0
  585. package/dist/utils/registry.js.map +1 -0
  586. package/dist/utils/schema.d.ts +7 -0
  587. package/dist/utils/schema.d.ts.map +1 -0
  588. package/dist/utils/schema.js +13 -0
  589. package/dist/utils/schema.js.map +1 -0
  590. package/dist/utils/token-estimate.d.ts +87 -0
  591. package/dist/utils/token-estimate.d.ts.map +1 -0
  592. package/dist/utils/token-estimate.js +199 -0
  593. package/dist/utils/token-estimate.js.map +1 -0
  594. package/dist/v2/reconciler/host-config.d.ts +31 -0
  595. package/dist/v2/reconciler/host-config.d.ts.map +1 -0
  596. package/dist/v2/reconciler/host-config.js +197 -0
  597. package/dist/v2/reconciler/host-config.js.map +1 -0
  598. package/dist/v2/reconciler/index.d.ts +7 -0
  599. package/dist/v2/reconciler/index.d.ts.map +1 -0
  600. package/dist/v2/reconciler/index.js +7 -0
  601. package/dist/v2/reconciler/index.js.map +1 -0
  602. package/dist/v2/reconciler/reconciler.d.ts +39 -0
  603. package/dist/v2/reconciler/reconciler.d.ts.map +1 -0
  604. package/dist/v2/reconciler/reconciler.js +54 -0
  605. package/dist/v2/reconciler/reconciler.js.map +1 -0
  606. package/dist/v2/reconciler/types.d.ts +64 -0
  607. package/dist/v2/reconciler/types.d.ts.map +1 -0
  608. package/dist/v2/reconciler/types.js +20 -0
  609. package/dist/v2/reconciler/types.js.map +1 -0
  610. package/dist/v2/renderers/index.d.ts +7 -0
  611. package/dist/v2/renderers/index.d.ts.map +1 -0
  612. package/dist/v2/renderers/index.js +7 -0
  613. package/dist/v2/renderers/index.js.map +1 -0
  614. package/dist/v2/renderers/markdown.d.ts +16 -0
  615. package/dist/v2/renderers/markdown.d.ts.map +1 -0
  616. package/dist/v2/renderers/markdown.js +65 -0
  617. package/dist/v2/renderers/markdown.js.map +1 -0
  618. package/dist/v2/renderers/types.d.ts +26 -0
  619. package/dist/v2/renderers/types.d.ts.map +1 -0
  620. package/dist/v2/renderers/types.js +6 -0
  621. package/dist/v2/renderers/types.js.map +1 -0
  622. package/dist/v2/renderers/xml.d.ts +17 -0
  623. package/dist/v2/renderers/xml.d.ts.map +1 -0
  624. package/dist/v2/renderers/xml.js +73 -0
  625. package/dist/v2/renderers/xml.js.map +1 -0
  626. package/package.json +49 -0
@@ -0,0 +1,798 @@
1
+ /**
2
+ * V2 Hooks Implementation
3
+ *
4
+ * React-inspired hooks for function components in the tick-based agent model.
5
+ * Key difference from React: async-first, effects can be async.
6
+ *
7
+ * Rules of Hooks:
8
+ * 1. Only call hooks at the top level of a function component
9
+ * 2. Only call hooks from function components or custom hooks
10
+ * 3. Call hooks in the same order every render
11
+ */
12
+ import type { FiberNode, RenderContext, StateHookResult, ReducerHookResult, RefObject, AsyncResult, EffectCallback } from "../compiler/types";
13
+ import { type Signal, type ComputedSignal, type ReadonlySignal } from "./signal";
14
+ import type { COM } from "../com/object-model";
15
+ import type { COMTimelineEntry } from "../com/types";
16
+ import type { TickState } from "../component/component";
17
+ import type { CompiledStructure } from "../compiler/types";
18
+ import type { ExecutionMessage } from "../engine/execution-types";
19
+ /**
20
+ * Get current render context. Throws if called outside render.
21
+ */
22
+ export declare function getCurrentContext(): RenderContext;
23
+ /**
24
+ * Set render context (called by compiler).
25
+ */
26
+ export declare function setRenderContext(ctx: RenderContext | null): void;
27
+ /**
28
+ * Get current fiber (for advanced use).
29
+ */
30
+ export declare function getCurrentFiber(): FiberNode | null;
31
+ /**
32
+ * Get the COM (Context Object Model) for the current render.
33
+ *
34
+ * Use this instead of receiving COM as a component parameter.
35
+ * This makes components have standard React-like signatures: `(props) => JSX.Element`
36
+ *
37
+ * @example
38
+ * ```tsx
39
+ * // Before (legacy pattern with magic args):
40
+ * const MyComponent = (props, com, state) => { ... };
41
+ *
42
+ * // After (recommended hook pattern):
43
+ * const MyComponent = (props) => {
44
+ * const com = useCom();
45
+ * const state = useTickState();
46
+ * // ...
47
+ * };
48
+ * ```
49
+ */
50
+ export declare function useCom(): COM;
51
+ /**
52
+ * Get the TickState for the current render.
53
+ *
54
+ * TickState contains:
55
+ * - `tick`: Current tick number (1-indexed)
56
+ * - `previous`: COMInput from previous tick (conversation history)
57
+ * - `current`: COMOutput from current tick (model response)
58
+ * - `stop(reason)`: Function to stop execution
59
+ * - `queuedMessages`: Messages received during execution
60
+ *
61
+ * @example
62
+ * ```tsx
63
+ * const MyComponent = (props) => {
64
+ * const state = useTickState();
65
+ * console.log(`Tick ${state.tick}`);
66
+ * // Access previous conversation via state.previous?.timeline
67
+ * };
68
+ * ```
69
+ */
70
+ export declare function useTickState(): TickState;
71
+ /**
72
+ * useState - Local component state.
73
+ *
74
+ * State persists across renders via fiber storage.
75
+ *
76
+ * @example
77
+ * ```tsx
78
+ * // Old (deprecated):
79
+ * const [count, setCount] = useState(0);
80
+ *
81
+ * // New (recommended):
82
+ * const count = useSignal(0);
83
+ * count.set(10) or count.update(n => n + 1)
84
+ * ```
85
+ */
86
+ export declare function useState<S>(initialState: S | (() => S)): StateHookResult<S>;
87
+ /**
88
+ * useReducer - State with reducer pattern.
89
+ */
90
+ export declare function useReducer<S, A>(reducer: (state: S, action: A) => S, initialArg: S, init?: (arg: S) => S): ReducerHookResult<S, A>;
91
+ /**
92
+ * useSignal - Signal-based state in function components.
93
+ *
94
+ * Provides full signal API (not just [value, setter]).
95
+ * Automatically triggers recompiles when the signal is updated (like useState).
96
+ *
97
+ * @example
98
+ * ```tsx
99
+ * function Counter() {
100
+ * const count = useSignal(0);
101
+ * return <Text>Count: {count()}</Text>;
102
+ * }
103
+ * ```
104
+ */
105
+ export declare function useSignal<T>(initialValue: T): Signal<T>;
106
+ /**
107
+ * useComState - COM-bound shared state.
108
+ *
109
+ * Returns a signal bound to COM state. State is shared across all components
110
+ * and persisted. Changes automatically trigger recompilation.
111
+ *
112
+ * @example
113
+ * ```tsx
114
+ * function Timeline() {
115
+ * const messages = useComState('timeline', []);
116
+ * return <Timeline>{messages().map(...)}</Timeline>;
117
+ * }
118
+ * ```
119
+ */
120
+ export declare function useComState<T>(key: string, initialValue: T): Signal<T>;
121
+ /**
122
+ * useWatch - Read-only COM state observation.
123
+ * Returns a ReadonlySignal for reactive access to the watched state.
124
+ *
125
+ * @example
126
+ * ```tsx
127
+ * function StatusDisplay() {
128
+ * const status = useWatch('agentStatus', 'idle');
129
+ * return <Text>Status: {status()}</Text>;
130
+ * }
131
+ * ```
132
+ */
133
+ export declare function useWatch<T>(key: string, defaultValue?: T): ReadonlySignal<T | undefined>;
134
+ /**
135
+ * useInput - Reactive prop access with default value.
136
+ */
137
+ export declare function useInput<T>(propKey: string, defaultValue?: T): T | undefined;
138
+ /**
139
+ * useEffect - Side effect after commit.
140
+ *
141
+ * Unlike React, callback CAN be async.
142
+ * Signals/computed values in deps array are automatically unwrapped.
143
+ *
144
+ * During hydration:
145
+ * - Mount effects (deps = []) are skipped (state is restored, not fresh)
146
+ * - Effects with deps still run (deps might have changed since snapshot)
147
+ *
148
+ * @example
149
+ * ```tsx
150
+ * function Logger() {
151
+ * const message = useComState('message', '');
152
+ *
153
+ * useEffect(async () => {
154
+ * await logToServer(message()); // Read signal value
155
+ * return () => console.log('cleanup');
156
+ * }, [message]); // Signal auto-tracked by value
157
+ * }
158
+ * ```
159
+ */
160
+ export declare function useEffect(create: EffectCallback, deps?: unknown[]): void;
161
+ /**
162
+ * useInit - Component initialization that runs once on mount.
163
+ * Can be async and should be awaited if it returns a Promise.
164
+ * Runs DURING render, blocking until complete.
165
+ *
166
+ * Use for: loading initial data, setting up state before first render
167
+ *
168
+ * @example
169
+ * ```tsx
170
+ * function MyComponent() {
171
+ * const data = useComState('data', []);
172
+ *
173
+ * await useInit(async (com, state) => {
174
+ * const initialData = await loadData();
175
+ * data.set(initialData);
176
+ * });
177
+ *
178
+ * return <Section>{data().map(...)}</Section>;
179
+ * }
180
+ * ```
181
+ */
182
+ export declare function useInit(callback: (com: COM, state: TickState) => void | Promise<void>): Promise<void>;
183
+ /**
184
+ * useOnMount - Run once when component mounts as a side effect.
185
+ * Runs AFTER render (as an effect), does not block rendering.
186
+ * Use for non-critical side effects like logging, analytics.
187
+ *
188
+ * For blocking initialization, use `useInit` instead.
189
+ *
190
+ * @example
191
+ * ```tsx
192
+ * function MyComponent() {
193
+ * useOnMount((com) => {
194
+ * log.info('Component mounted');
195
+ * });
196
+ * return <Text>Hello</Text>;
197
+ * }
198
+ * ```
199
+ */
200
+ export declare function useOnMount(callback: (com: COM) => void | Promise<void>): void;
201
+ /**
202
+ * useOnUnmount - Run once when component unmounts.
203
+ */
204
+ export declare function useOnUnmount(callback: (com: COM) => void | Promise<void>): void;
205
+ /**
206
+ * useTickStart - Run at start of each tick, before render.
207
+ *
208
+ * @deprecated Use `useOnTickStart` instead for consistent naming convention.
209
+ */
210
+ export declare function useTickStart(callback: (com: COM, state: TickState) => void | Promise<void>): void;
211
+ /**
212
+ * useTickEnd - Run at end of each tick, after model execution.
213
+ *
214
+ * @deprecated Use `useOnTickEnd` instead for consistent naming convention.
215
+ */
216
+ export declare function useTickEnd(callback: (com: COM, state: TickState) => void | Promise<void>): void;
217
+ /**
218
+ * useAfterCompile - Run after compile, can request recompile.
219
+ *
220
+ * @deprecated Use `useOnAfterCompile` instead for consistent naming convention.
221
+ */
222
+ export declare function useAfterCompile(callback: (com: COM, compiled: CompiledStructure, state: TickState) => void): void;
223
+ /**
224
+ * useOnMessage - Handle execution messages.
225
+ *
226
+ * Called immediately when messages are sent to the running execution via:
227
+ * - RuntimeSession.sendMessage() - Direct programmatic injection
228
+ * - ExecutionHandle.send() - Via handle reference
229
+ * - Channel events with type='message' - From client
230
+ *
231
+ * Messages are processed immediately when they arrive, not at tick boundaries.
232
+ * Use com.abort() to interrupt execution if needed, or update state for the next tick.
233
+ * Messages are also available in TickState.queuedMessages during render.
234
+ *
235
+ * @example
236
+ * ```tsx
237
+ * function InteractiveAgent() {
238
+ * const feedback = useComState('userFeedback', []);
239
+ *
240
+ * useOnMessage((com, message, state) => {
241
+ * if (message.type === 'stop') {
242
+ * com.abort('User requested stop');
243
+ * } else if (message.type === 'feedback') {
244
+ * feedback.update(f => [...f, message.content]);
245
+ * }
246
+ * });
247
+ *
248
+ * return <Section>{feedback().map(f => <Paragraph>{f}</Paragraph>)}</Section>;
249
+ * }
250
+ * ```
251
+ */
252
+ export declare function useOnMessage(callback: (com: COM, message: ExecutionMessage, state: TickState) => void | Promise<void>): void;
253
+ /**
254
+ * useOnTickStart - Run at start of each tick, before render.
255
+ *
256
+ * This is the canonical hook for tick-start lifecycle.
257
+ * Alias: useTickStart (deprecated, prefer useOnTickStart)
258
+ *
259
+ * @example
260
+ * ```tsx
261
+ * function MyAgent() {
262
+ * useOnTickStart((com, state) => {
263
+ * console.log(`Starting tick ${state.tick}`);
264
+ * });
265
+ * return <System>You are helpful.</System>;
266
+ * }
267
+ * ```
268
+ */
269
+ export declare function useOnTickStart(callback: (com: COM, state: TickState) => void | Promise<void>): void;
270
+ /**
271
+ * useOnAfterRender - Run after render/reconciliation, before compile.
272
+ *
273
+ * Use this to inspect or modify state after all components have rendered
274
+ * but before the context is compiled and sent to the model.
275
+ *
276
+ * @example
277
+ * ```tsx
278
+ * function MyAgent() {
279
+ * useOnAfterRender((com, state) => {
280
+ * console.log('Components rendered, about to compile');
281
+ * });
282
+ * return <System>You are helpful.</System>;
283
+ * }
284
+ * ```
285
+ */
286
+ export declare function useOnAfterRender(callback: (com: COM, state: TickState) => void | Promise<void>): void;
287
+ /**
288
+ * useOnAfterCompile - Run after compile, before model call.
289
+ *
290
+ * Use this to transform the compiled structure before it's sent to the model.
291
+ * Can request recompile if needed.
292
+ *
293
+ * This is the canonical hook for after-compile lifecycle.
294
+ * Alias: useAfterCompile (deprecated, prefer useOnAfterCompile)
295
+ *
296
+ * @example
297
+ * ```tsx
298
+ * function MyAgent() {
299
+ * useOnAfterCompile((com, compiled, state) => {
300
+ * // Inspect or modify compiled structure
301
+ * if (compiled.tokenCount > 10000) {
302
+ * // Request summarization
303
+ * }
304
+ * });
305
+ * return <System>You are helpful.</System>;
306
+ * }
307
+ * ```
308
+ */
309
+ export declare function useOnAfterCompile(callback: (com: COM, compiled: CompiledStructure, state: TickState) => void): void;
310
+ /**
311
+ * useOnTickEnd - Run at end of each tick, after model execution.
312
+ *
313
+ * Use this to process model response, decide on continuation, or clean up.
314
+ *
315
+ * This is the canonical hook for tick-end lifecycle.
316
+ * Alias: useTickEnd (deprecated, prefer useOnTickEnd)
317
+ *
318
+ * @example
319
+ * ```tsx
320
+ * function MyAgent() {
321
+ * useOnTickEnd((com, state) => {
322
+ * console.log(`Tick ${state.tick} complete`);
323
+ * if (state.response?.stopReason === 'stop') {
324
+ * com.complete();
325
+ * }
326
+ * });
327
+ * return <System>You are helpful.</System>;
328
+ * }
329
+ * ```
330
+ */
331
+ export declare function useOnTickEnd(callback: (com: COM, state: TickState) => void | Promise<void>): void;
332
+ /**
333
+ * useOnComplete - Run when session completes (all ticks done).
334
+ *
335
+ * This hook runs once when the session finishes execution, whether through:
336
+ * - Natural completion (shouldContinue returns false)
337
+ * - Explicit com.complete() call
338
+ * - Error or abort
339
+ *
340
+ * Use this for cleanup, final logging, or teardown logic.
341
+ *
342
+ * @example
343
+ * ```tsx
344
+ * function MyAgent() {
345
+ * useOnComplete((com, state) => {
346
+ * console.log(`Session complete after ${state.tick} ticks`);
347
+ * // Cleanup resources
348
+ * });
349
+ * return <System>You are helpful.</System>;
350
+ * }
351
+ * ```
352
+ */
353
+ export declare function useOnComplete(callback: (com: COM, state: TickState) => void | Promise<void>): void;
354
+ /**
355
+ * useAsync - Async data fetching.
356
+ *
357
+ * Unlike React (which needs Suspense), we just track loading state.
358
+ * The tick can wait for async work to complete.
359
+ *
360
+ * @example
361
+ * ```tsx
362
+ * function UserProfile({ userId }) {
363
+ * const { data: user, loading, error } = useAsync(
364
+ * () => fetchUser(userId),
365
+ * [userId]
366
+ * );
367
+ *
368
+ * if (loading) return null;
369
+ * if (error) return <Text>Error: {error.message}</Text>;
370
+ *
371
+ * return <Text>User: {user.name}</Text>;
372
+ * }
373
+ * ```
374
+ */
375
+ export declare function useAsync<T>(asyncFn: () => Promise<T>, deps: unknown[]): AsyncResult<T>;
376
+ /**
377
+ * useMemo - Memoize expensive computation.
378
+ */
379
+ export declare function useMemo<T>(factory: () => T, deps: unknown[]): T;
380
+ /**
381
+ * useComputed - Create a reactive computed signal that persists across renders.
382
+ *
383
+ * Unlike useMemo which returns a plain value, useComputed returns a ComputedSignal
384
+ * that automatically tracks dependencies and updates when they change.
385
+ * The computed signal is disposed and recreated only when deps change.
386
+ *
387
+ * @example
388
+ * ```typescript
389
+ * const timeline = useComState('timeline', []);
390
+ * const recentMessages = useComputed(() => timeline().slice(-10), []);
391
+ *
392
+ * // Read the computed value
393
+ * const messages = recentMessages(); // or recentMessages.value
394
+ * ```
395
+ */
396
+ export declare function useComputed<T>(computation: () => T, deps?: unknown[]): ComputedSignal<T>;
397
+ /**
398
+ * useCallback - Memoize callback function.
399
+ */
400
+ export declare function useCallback<T extends (...args: unknown[]) => unknown>(callback: T, deps: unknown[]): T;
401
+ /**
402
+ * useRef - Mutable ref that persists across renders.
403
+ */
404
+ export declare function useRef<T>(initialValue: T): RefObject<T>;
405
+ /**
406
+ * useCOMRef - Get component ref from COM.
407
+ */
408
+ export declare function useCOMRef<T>(refName: string): T | undefined;
409
+ /**
410
+ * usePrevious - Track previous value.
411
+ */
412
+ export declare function usePrevious<T>(value: T): T | undefined;
413
+ /**
414
+ * useToggle - Boolean toggle state.
415
+ */
416
+ export declare function useToggle(initial?: boolean): [boolean, () => void];
417
+ /**
418
+ * useCounter - Numeric counter.
419
+ */
420
+ export declare function useCounter(initial?: number): {
421
+ count: number;
422
+ increment: () => void;
423
+ decrement: () => void;
424
+ set: (n: number) => void;
425
+ reset: () => void;
426
+ };
427
+ /**
428
+ * useAbortSignal - Get abort signal for current execution.
429
+ */
430
+ export declare function useAbortSignal(): AbortSignal | undefined;
431
+ /**
432
+ * useDebugValue - Display value in devtools (no-op in production).
433
+ */
434
+ export declare function useDebugValue<T>(value: T, formatter?: (value: T) => unknown): void;
435
+ /**
436
+ * Result of useTick() hook.
437
+ */
438
+ export interface UseTickResult {
439
+ /** Request a tick to be scheduled */
440
+ requestTick(): void;
441
+ /** Cancel a pending tick request */
442
+ cancelTick(): void;
443
+ /** Current tick status: 'idle' | 'running' | 'pending' */
444
+ tickStatus: "idle" | "running" | "pending";
445
+ /** Total number of ticks executed */
446
+ tickCount: number;
447
+ }
448
+ /**
449
+ * useTick - Control tick execution from within a component.
450
+ *
451
+ * This hook provides components with the ability to:
452
+ * - Request a new tick (e.g., when enough messages have accumulated)
453
+ * - Cancel a pending tick request
454
+ * - Check the current tick status
455
+ * - Get the total tick count
456
+ *
457
+ * @example
458
+ * ```tsx
459
+ * function BatchProcessor() {
460
+ * const { requestTick, tickStatus, tickCount } = useTick();
461
+ * const queue = useComState('queue', []);
462
+ *
463
+ * useEffect(() => {
464
+ * // Request tick when queue has 10 items and we're idle
465
+ * if (queue().length >= 10 && tickStatus === 'idle') {
466
+ * requestTick();
467
+ * }
468
+ * }, [queue().length, tickStatus]);
469
+ *
470
+ * return <Section>Tick {tickCount}: {queue().length} items</Section>;
471
+ * }
472
+ * ```
473
+ */
474
+ export declare function useTick(): UseTickResult;
475
+ import type { Channel, ChannelEvent } from "../core/channel";
476
+ /**
477
+ * Result of useChannel() hook.
478
+ * Provides access to a named channel for pub/sub communication.
479
+ */
480
+ export interface UseChannelResult {
481
+ /**
482
+ * The underlying Channel instance.
483
+ * May be undefined if channels are not configured.
484
+ */
485
+ channel: Channel | undefined;
486
+ /**
487
+ * Subscribe to channel events.
488
+ * Returns an unsubscribe function.
489
+ *
490
+ * @example
491
+ * ```tsx
492
+ * const { subscribe } = useChannel('updates');
493
+ * useEffect(() => subscribe(handleEvent), []);
494
+ * ```
495
+ */
496
+ subscribe: (handler: (event: ChannelEvent) => void) => () => void;
497
+ /**
498
+ * Publish an event to the channel.
499
+ *
500
+ * @example
501
+ * ```tsx
502
+ * const { publish } = useChannel('events');
503
+ * publish({ type: 'status', payload: { ready: true } });
504
+ * ```
505
+ */
506
+ publish: (event: Omit<ChannelEvent, "channel">) => void;
507
+ /**
508
+ * Wait for a response to a specific request.
509
+ *
510
+ * @example
511
+ * ```tsx
512
+ * const { waitForResponse, publish } = useChannel('confirmations');
513
+ * publish({ type: 'request', id: 'confirm-1', payload: { action: 'delete' } });
514
+ * const response = await waitForResponse('confirm-1', 30000);
515
+ * ```
516
+ */
517
+ waitForResponse: (requestId: string, timeoutMs?: number) => Promise<ChannelEvent>;
518
+ /**
519
+ * Whether the channel is available.
520
+ * False if channel service is not configured.
521
+ */
522
+ available: boolean;
523
+ }
524
+ /**
525
+ * useChannel - Access a named channel for pub/sub communication.
526
+ *
527
+ * Channels enable real-time bidirectional communication between components
528
+ * and external code (UI, other services, etc.).
529
+ *
530
+ * Use cases:
531
+ * - User input during model execution (e.g., stop button, feedback)
532
+ * - Progress updates to UI
533
+ * - Tool confirmation dialogs
534
+ * - Live data streaming to/from external systems
535
+ *
536
+ * @param name - Channel name (e.g., 'progress', 'user-input', 'tool:confirm')
537
+ * @returns Channel access object with subscribe, publish, and waitForResponse
538
+ *
539
+ * @example Basic subscription
540
+ * ```tsx
541
+ * function ProgressDisplay() {
542
+ * const [progress, setProgress] = useState(0);
543
+ * const { subscribe, available } = useChannel('progress');
544
+ *
545
+ * useEffect(() => {
546
+ * if (!available) return;
547
+ * return subscribe((event) => {
548
+ * if (event.type === 'update') {
549
+ * setProgress(event.payload.percent);
550
+ * }
551
+ * });
552
+ * }, [available]);
553
+ *
554
+ * return <Section>Progress: {progress}%</Section>;
555
+ * }
556
+ * ```
557
+ *
558
+ * @example Request/Response pattern
559
+ * ```tsx
560
+ * function ConfirmationHandler() {
561
+ * const { publish, waitForResponse, available } = useChannel('confirmations');
562
+ *
563
+ * const confirmAction = async (action: string) => {
564
+ * if (!available) throw new Error('Channels not available');
565
+ *
566
+ * const requestId = crypto.randomUUID();
567
+ * publish({ type: 'request', id: requestId, payload: { action } });
568
+ * const response = await waitForResponse(requestId, 30000);
569
+ * return response.payload.confirmed;
570
+ * };
571
+ *
572
+ * // ...
573
+ * }
574
+ * ```
575
+ *
576
+ * @example Publishing events
577
+ * ```tsx
578
+ * function StatusReporter() {
579
+ * const { publish } = useChannel('status');
580
+ *
581
+ * useTickEnd(() => {
582
+ * publish({ type: 'tick-complete', payload: { timestamp: Date.now() } });
583
+ * });
584
+ *
585
+ * return null;
586
+ * }
587
+ * ```
588
+ */
589
+ export declare function useChannel(name: string): UseChannelResult;
590
+ /**
591
+ * useChannelSubscription - Subscribe to channel events with automatic cleanup.
592
+ *
593
+ * This is a convenience hook that combines useChannel with useEffect for
594
+ * the common pattern of subscribing to a channel and cleaning up on unmount.
595
+ *
596
+ * @param name - Channel name
597
+ * @param handler - Event handler function
598
+ * @param deps - Dependencies array (handler is only updated when deps change)
599
+ *
600
+ * @example
601
+ * ```tsx
602
+ * function NotificationListener() {
603
+ * const [notifications, setNotifications] = useState<string[]>([]);
604
+ *
605
+ * useChannelSubscription('notifications', (event) => {
606
+ * if (event.type === 'new') {
607
+ * setNotifications(n => [...n, event.payload.message]);
608
+ * }
609
+ * }, []);
610
+ *
611
+ * return <Section>{notifications.map(n => <Text>{n}</Text>)}</Section>;
612
+ * }
613
+ * ```
614
+ */
615
+ export declare function useChannelSubscription(name: string, handler: (event: ChannelEvent) => void, deps?: unknown[]): void;
616
+ /**
617
+ * Options for filtering and limiting conversation history.
618
+ */
619
+ export interface ConversationHistoryOptions {
620
+ /**
621
+ * Filter function to include/exclude entries.
622
+ * @example Filter out system messages: (e) => e.message?.role !== 'system'
623
+ */
624
+ filter?: (entry: COMTimelineEntry) => boolean;
625
+ /**
626
+ * Maximum number of entries to return (from the end).
627
+ * @example Last 10 messages: { limit: 10 }
628
+ */
629
+ limit?: number;
630
+ /**
631
+ * Include only entries from specific roles.
632
+ * @example Only user/assistant: { roles: ['user', 'assistant'] }
633
+ */
634
+ roles?: Array<"user" | "assistant" | "tool" | "system">;
635
+ }
636
+ /**
637
+ * Get the full conversation history across all ticks.
638
+ *
639
+ * Combines `state.previous.timeline` (history) with `state.current.timeline`
640
+ * (current tick) into a single array.
641
+ *
642
+ * This is a utility hook that extracts data from TickState - it doesn't use the
643
+ * fiber system and can be called anywhere you have access to TickState.
644
+ *
645
+ * @param state - The TickState from component context
646
+ * @param options - Optional filtering and limiting
647
+ * @returns Array of timeline entries
648
+ *
649
+ * @example Basic usage
650
+ * ```tsx
651
+ * const ChatAgent = ({ message }: Props) => {
652
+ * const history = useConversationHistory();
653
+ *
654
+ * return (
655
+ * <>
656
+ * <Model model={claude} />
657
+ * <System>You are helpful.</System>
658
+ * {history.map((entry, i) => (
659
+ * <Message key={i} {...entry.message} />
660
+ * ))}
661
+ * <User>{message}</User>
662
+ * </>
663
+ * );
664
+ * };
665
+ * ```
666
+ *
667
+ * @example With options
668
+ * ```tsx
669
+ * const history = useConversationHistory({
670
+ * roles: ['user', 'assistant'], // Exclude tool messages
671
+ * limit: 10, // Last 10 messages
672
+ * });
673
+ * ```
674
+ */
675
+ export declare function useConversationHistory(options?: ConversationHistoryOptions): COMTimelineEntry[];
676
+ /**
677
+ * Get just the messages from conversation history (convenience wrapper).
678
+ *
679
+ * @param options - Optional filtering and limiting
680
+ * @returns Array of messages (excluding entries without messages)
681
+ */
682
+ export declare function useMessages(options?: ConversationHistoryOptions): Array<COMTimelineEntry["message"]>;
683
+ /**
684
+ * Get message count from conversation history.
685
+ *
686
+ * @returns Number of messages in history
687
+ */
688
+ export declare function useMessageCount(): number;
689
+ /**
690
+ * Get messages queued for the next tick.
691
+ *
692
+ * Messages can be queued via:
693
+ * - `session.queue.exec(msg)` - Queue a message for later processing
694
+ * - `session.interrupt(msg)` - Interrupt and queue a message
695
+ * - `RuntimeSession.sendMessage(msg)` - Direct programmatic injection
696
+ *
697
+ * Queued messages are available during render and can be used to show
698
+ * pending messages in the UI or to process them in the current tick.
699
+ *
700
+ * @returns Array of queued execution messages
701
+ *
702
+ * @example Show pending messages
703
+ * ```tsx
704
+ * const ChatWithPending = () => {
705
+ * const history = useConversationHistory();
706
+ * const pending = useQueuedMessages();
707
+ *
708
+ * return (
709
+ * <>
710
+ * {history.map((entry, i) => (
711
+ * <Message key={i} {...entry.message} />
712
+ * ))}
713
+ * {pending.length > 0 && (
714
+ * <System>Processing {pending.length} pending message(s)...</System>
715
+ * )}
716
+ * </>
717
+ * );
718
+ * };
719
+ * ```
720
+ *
721
+ * @example Process pending messages
722
+ * ```tsx
723
+ * const Agent = () => {
724
+ * const pending = useQueuedMessages();
725
+ *
726
+ * // Access the first pending message if any
727
+ * const firstPending = pending[0];
728
+ * if (firstPending?.type === 'interrupt') {
729
+ * return <System>Handling interrupt: {firstPending.content}</System>;
730
+ * }
731
+ *
732
+ * return <AssistantMessage />;
733
+ * };
734
+ * ```
735
+ */
736
+ export declare function useQueuedMessages(): ExecutionMessage[];
737
+ /**
738
+ * Inject historical timeline entries into the conversation.
739
+ *
740
+ * Use this to load an existing conversation when the component mounts.
741
+ * The entries are injected once (on first render) and then available via
742
+ * `useConversationHistory()` and `<Timeline />`.
743
+ *
744
+ * This hook only injects on the first render. On subsequent renders (tick 2+),
745
+ * the timeline naturally includes all entries via `TickState.previous.timeline`.
746
+ *
747
+ * @param entries - Timeline entries to inject, or a function that returns them
748
+ * @param deps - Dependency array (like useEffect). If omitted, injects once on mount.
749
+ *
750
+ * @example Basic usage with static entries
751
+ * ```tsx
752
+ * const ChatAgent = ({ conversationHistory }: Props) => {
753
+ * useInjectHistory(conversationHistory);
754
+ * return <Timeline />;
755
+ * };
756
+ * ```
757
+ *
758
+ * @example Async loading in useInit
759
+ * ```tsx
760
+ * const ChatAgent = ({ conversationId }: Props) => {
761
+ * const [loaded, setLoaded] = useState(false);
762
+ *
763
+ * await useInit(async () => {
764
+ * const conversation = await loadConversation(conversationId);
765
+ * injectHistory(conversation.entries); // Use standalone function
766
+ * setLoaded(true);
767
+ * });
768
+ *
769
+ * if (!loaded) return null;
770
+ * return <Timeline />;
771
+ * };
772
+ * ```
773
+ */
774
+ export declare function useInjectHistory(entries: COMTimelineEntry[] | (() => COMTimelineEntry[]), deps?: unknown[]): void;
775
+ /**
776
+ * Standalone function to inject history (for use in useInit or async contexts).
777
+ *
778
+ * Unlike the hook, this can be called anywhere you have access to COM.
779
+ *
780
+ * @param com - The COM instance
781
+ * @param entries - Timeline entries to inject
782
+ *
783
+ * @example
784
+ * ```tsx
785
+ * const ChatAgent = ({ conversationId }: Props) => {
786
+ * const com = useCom();
787
+ *
788
+ * await useInit(async () => {
789
+ * const conversation = await loadConversation(conversationId);
790
+ * injectHistory(com, conversation.entries);
791
+ * });
792
+ *
793
+ * return <Timeline />;
794
+ * };
795
+ * ```
796
+ */
797
+ export declare function injectHistory(com: COM, entries: COMTimelineEntry[]): void;
798
+ //# sourceMappingURL=hooks.d.ts.map