@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,347 @@
1
+ /**
2
+ * Boundary System for Tentickle
3
+ *
4
+ * Boundaries extend Context with collection-phase effects. They provide a generic
5
+ * mechanism for components that affect how their children are processed during
6
+ * compilation, without hardcoding specific component checks in the compiler.
7
+ *
8
+ * The abstraction ladder:
9
+ * - createContext: render-phase values, read via useContext
10
+ * - createBoundary: render-phase values + collection-phase effects
11
+ * - createFormatter: convenience for formatter boundaries (collection-time)
12
+ * - createPolicy: convenience for policy boundaries (format-time, auto-accumulating)
13
+ *
14
+ * @example Formatter boundary (like XML, Markdown)
15
+ * ```tsx
16
+ * // XML/Markdown use the unified FormatterBoundary
17
+ * <XML>
18
+ * <Content />
19
+ * </XML>
20
+ *
21
+ * // To get the current formatter during render:
22
+ * const formatter = useBoundary(FormatterBoundary);
23
+ * if (formatter) {
24
+ * const formatted = formatter.formatter(blocks);
25
+ * }
26
+ * ```
27
+ *
28
+ * @example Policy boundary (like TokenBudget)
29
+ * ```tsx
30
+ * // Policies auto-accumulate - nested policies are combined
31
+ * <TokenBudget maxTokens={8000} strategy="drop-oldest">
32
+ * <Timeline />
33
+ * <TokenBudget maxTokens={2000} strategy="truncate">
34
+ * <User>{message}</User> {/* Both policies apply \*\/}
35
+ * </TokenBudget>
36
+ * </TokenBudget>
37
+ *
38
+ * // To get all active policies during render:
39
+ * const policyValue = useBoundary(PolicyBoundary);
40
+ * if (policyValue) {
41
+ * console.log('Active policies:', policyValue.policies.map(p => p.name));
42
+ * }
43
+ * ```
44
+ *
45
+ * @module tentickle/boundary
46
+ */
47
+ import type { JSX } from "../jsx/jsx-runtime";
48
+ import { type Context } from "./context";
49
+ import type { Formatter } from "../renderers";
50
+ import type { COMTimelineEntry } from "../com/types";
51
+ /**
52
+ * Symbol used to mark boundary provider components.
53
+ * The fiber compiler detects this to handle boundary effects.
54
+ */
55
+ export declare const BOUNDARY_PROVIDER_SYMBOL: unique symbol;
56
+ /**
57
+ * Boundary class determines how the compiler handles the boundary.
58
+ * - 'formatter': Affects content rendering during collection (e.g., XML, Markdown)
59
+ * - 'policy': Affects entries after collection, during formatInput (e.g., TokenBudget)
60
+ */
61
+ export type BoundaryClass = "formatter" | "policy";
62
+ /**
63
+ * Definition for creating a boundary.
64
+ *
65
+ * @template T - The type of value this boundary holds
66
+ */
67
+ export interface BoundaryDefinition<T> {
68
+ /** Default value when no provider above */
69
+ defaultValue: T | null;
70
+ /** Display name for debugging */
71
+ displayName?: string;
72
+ /** Boundary class - determines how compiler handles it */
73
+ class: BoundaryClass;
74
+ }
75
+ /**
76
+ * A Boundary object created by createBoundary().
77
+ *
78
+ * Boundaries ARE contexts with additional collection-phase effects.
79
+ *
80
+ * @template T - The type of value this boundary holds
81
+ */
82
+ export interface Boundary<T> {
83
+ /** The underlying context (boundaries ARE contexts) */
84
+ readonly Context: Context<T | null>;
85
+ /** Provider component */
86
+ readonly Provider: BoundaryProvider<T>;
87
+ /** Boundary class */
88
+ readonly class: BoundaryClass;
89
+ /** Display name for debugging */
90
+ displayName?: string;
91
+ /**
92
+ * Internal: the definition.
93
+ * @internal
94
+ */
95
+ readonly _definition: BoundaryDefinition<T>;
96
+ }
97
+ /**
98
+ * Props for a boundary Provider component.
99
+ */
100
+ export interface BoundaryProviderProps<T> {
101
+ /** The value to provide */
102
+ value: T;
103
+ /** Child components */
104
+ children?: any;
105
+ }
106
+ /**
107
+ * Internal data attached to boundary providers.
108
+ * @internal
109
+ */
110
+ export interface BoundaryProviderData<T> {
111
+ class: BoundaryClass;
112
+ definition: BoundaryDefinition<T>;
113
+ }
114
+ /**
115
+ * A boundary Provider component type.
116
+ */
117
+ export type BoundaryProvider<T> = {
118
+ (props: BoundaryProviderProps<T>): JSX.Element;
119
+ /** @internal - Boundary data for compiler detection */
120
+ [BOUNDARY_PROVIDER_SYMBOL]: BoundaryProviderData<T>;
121
+ /** Display name for debugging */
122
+ displayName?: string;
123
+ };
124
+ /**
125
+ * Creates a Boundary that extends Context with collection-phase effects.
126
+ *
127
+ * Boundaries can provide:
128
+ * - Context values (readable via useBoundary/useContext during render)
129
+ * - Formatter effects (affect content rendering during collection)
130
+ * - Policy effects (process entries after collection)
131
+ *
132
+ * @param definition - The boundary definition
133
+ * @returns A Boundary object with a Provider component
134
+ *
135
+ * @example
136
+ * ```tsx
137
+ * const MyBoundary = createBoundary({
138
+ * defaultValue: null,
139
+ * displayName: 'MyBoundary',
140
+ * class: 'formatter',
141
+ * formatter: (value) => new MyRenderer(),
142
+ * });
143
+ *
144
+ * // Use it
145
+ * <MyBoundary.Provider value={{}}>
146
+ * {children}
147
+ * </MyBoundary.Provider>
148
+ * ```
149
+ */
150
+ export declare function createBoundary<T>(definition: BoundaryDefinition<T>): Boundary<T>;
151
+ /**
152
+ * Reads the current value of a boundary.
153
+ *
154
+ * This is a convenience wrapper around useContext that works with Boundary objects.
155
+ * Returns the value from the nearest Provider ancestor, or null if no Provider is found.
156
+ *
157
+ * @param boundary - The Boundary object (created by createBoundary)
158
+ * @returns The current boundary value, or null
159
+ *
160
+ * @example
161
+ * ```tsx
162
+ * const TokenBudgetBoundary = createPolicy<TokenBudgetProps>('TokenBudget', process);
163
+ *
164
+ * function TokenCounter() {
165
+ * const budget = useBoundary(TokenBudgetBoundary);
166
+ * if (!budget) return null;
167
+ * return <System>Budget: {budget.maxTokens} tokens</System>;
168
+ * }
169
+ * ```
170
+ */
171
+ export declare function useBoundary<T>(boundary: Boundary<T>): T | null;
172
+ /**
173
+ * Value type for the FormatterBoundary.
174
+ * Just contains a formatter function - ContentRenderer is an internal implementation detail.
175
+ */
176
+ export interface FormatterBoundaryValue {
177
+ /** The formatter function - transforms semantic blocks to content blocks */
178
+ formatter: Formatter;
179
+ }
180
+ /**
181
+ * The unified formatter boundary used by XML, Markdown, JSON, etc.
182
+ *
183
+ * All formatter components (XML, Markdown, JSON) use this single boundary.
184
+ * The value contains a formatter function. Use `useBoundary(FormatterBoundary)`
185
+ * to get the current formatter regardless of which formatter type is active.
186
+ *
187
+ * **Inner wins semantics:** When formatters are nested, the innermost formatter
188
+ * is used for content within its scope.
189
+ *
190
+ * @example
191
+ * ```tsx
192
+ * // In a component - get the current formatter
193
+ * const formatterValue = useBoundary(FormatterBoundary);
194
+ * if (formatterValue) {
195
+ * const formatted = formatterValue.formatter(blocks);
196
+ * }
197
+ *
198
+ * // XML, Markdown, etc. use this boundary internally
199
+ * function XML({ children }) {
200
+ * return (
201
+ * <FormatterBoundary.Provider value={{ formatter: (blocks) => xmlRenderer.format(blocks) }}>
202
+ * {children}
203
+ * </FormatterBoundary.Provider>
204
+ * );
205
+ * }
206
+ * ```
207
+ */
208
+ export declare const FormatterBoundary: Boundary<FormatterBoundaryValue>;
209
+ /**
210
+ * Creates a formatter component that uses the unified FormatterBoundary.
211
+ *
212
+ * This is a convenience function for creating formatter components like XML, Markdown.
213
+ * It creates a component that wraps children in FormatterBoundary.Provider with the
214
+ * provided formatter function.
215
+ *
216
+ * @param name - Display name for debugging
217
+ * @param formatter - The formatter function or factory
218
+ * @returns A component function that provides the formatter to children
219
+ *
220
+ * @example
221
+ * ```tsx
222
+ * // Create a custom formatter
223
+ * const CustomFormat = createFormatter('CustomFormat', (blocks) => {
224
+ * return blocks.map(block => ({ type: 'text', text: `[${block.text}]` }));
225
+ * });
226
+ *
227
+ * // Use it
228
+ * <CustomFormat>
229
+ * <Content />
230
+ * </CustomFormat>
231
+ * ```
232
+ */
233
+ export declare function createFormatter(name: string, formatter: Formatter | (() => Formatter)): (props: {
234
+ children?: any;
235
+ }) => JSX.Element;
236
+ /**
237
+ * Policy process function type.
238
+ * Transforms timeline entries (filtering, summarization, etc.).
239
+ */
240
+ export type PolicyProcessFunction<TConfig = unknown> = (entries: COMTimelineEntry[], config: TConfig) => COMTimelineEntry[] | Promise<COMTimelineEntry[]>;
241
+ /**
242
+ * A single policy in the policy chain.
243
+ */
244
+ export interface PolicyEntry<TConfig = unknown> {
245
+ /** Policy name for debugging/identification */
246
+ name: string;
247
+ /** The process function that transforms entries */
248
+ process: PolicyProcessFunction<TConfig>;
249
+ /** Configuration for this policy instance */
250
+ config: TConfig;
251
+ }
252
+ /**
253
+ * Value type for the PolicyBoundary.
254
+ * Holds an array of accumulated policies.
255
+ */
256
+ export interface PolicyBoundaryValue {
257
+ /** Accumulated policies from all ancestors plus current */
258
+ policies: PolicyEntry[];
259
+ }
260
+ /**
261
+ * The unified policy boundary used by TokenBudget, etc.
262
+ *
263
+ * All policy components use this single boundary. Policies **accumulate** -
264
+ * nested policies don't replace parent policies, they add to them.
265
+ * Use `useBoundary(PolicyBoundary)` to get ALL active policies in scope.
266
+ *
267
+ * **Accumulating semantics:** When policies are nested, ALL policies apply
268
+ * to content within their combined scope, processed in order (outer first).
269
+ *
270
+ * @example
271
+ * ```tsx
272
+ * // In a component - get all active policies
273
+ * const policyValue = useBoundary(PolicyBoundary);
274
+ * if (policyValue) {
275
+ * console.log('Active policies:', policyValue.policies.map(p => p.name));
276
+ * // e.g., ['TokenBudget', 'Summarizer']
277
+ * }
278
+ * ```
279
+ *
280
+ * @example Nested policies accumulate - both TokenBudget AND Summarizer apply
281
+ * ```tsx
282
+ * <TokenBudget maxTokens={8000}>
283
+ * <Summarizer threshold={5000}>
284
+ * <Timeline />
285
+ * </Summarizer>
286
+ * </TokenBudget>
287
+ * ```
288
+ */
289
+ export declare const PolicyBoundary: Boundary<PolicyBoundaryValue>;
290
+ /**
291
+ * Creates a policy component that auto-accumulates into PolicyBoundary.
292
+ *
293
+ * Policy boundaries affect the timeline entries during the formatInput phase,
294
+ * after all entries have been collected. Use this for filtering, transforming,
295
+ * or managing entries (e.g., token budgets, summarization).
296
+ *
297
+ * **Auto-accumulation:** The created component automatically reads parent policies
298
+ * from PolicyBoundary, appends its own policy, and provides the combined list.
299
+ * You don't need to manually handle accumulation.
300
+ *
301
+ * @param name - Display name for debugging
302
+ * @param process - Function to process entries
303
+ * @returns An object with Provider component and usePolicy hook
304
+ *
305
+ * @example Creating a policy
306
+ * ```typescript
307
+ * const tokenBudget = createPolicy<TokenBudgetProps>(
308
+ * 'TokenBudget',
309
+ * async (entries, props) => applyTokenBudget(entries, props)
310
+ * );
311
+ *
312
+ * // Use the Provider - auto-accumulates with parent policies
313
+ * // <tokenBudget.Provider value={{ maxTokens: 4000, strategy: 'drop-oldest' }}>
314
+ * // <Timeline />
315
+ * // </tokenBudget.Provider>
316
+ *
317
+ * // Read this specific policy's config with usePolicy hook
318
+ * // const config = tokenBudget.usePolicy();
319
+ * ```
320
+ */
321
+ export declare function createPolicy<TConfig>(name: string, process: PolicyProcessFunction<TConfig>): {
322
+ /** Provider component that auto-accumulates into PolicyBoundary */
323
+ Provider: (props: {
324
+ value: TConfig;
325
+ children?: any;
326
+ }) => JSX.Element;
327
+ /** Hook to read this specific policy's config (innermost) */
328
+ usePolicy: () => TConfig | null;
329
+ /** The policy name */
330
+ name: string;
331
+ /** The process function */
332
+ process: PolicyProcessFunction<TConfig>;
333
+ };
334
+ /**
335
+ * Check if a component is a boundary provider.
336
+ * Used by the fiber compiler during traversal.
337
+ *
338
+ * @internal
339
+ */
340
+ export declare function isBoundaryProvider(component: unknown): component is BoundaryProvider<unknown>;
341
+ /**
342
+ * Get the boundary data from a provider component.
343
+ *
344
+ * @internal
345
+ */
346
+ export declare function getBoundaryData<T>(provider: BoundaryProvider<T>): BoundaryProviderData<T>;
347
+ //# sourceMappingURL=boundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boundary.d.ts","sourceRoot":"","sources":["../../src/state/boundary.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,341 @@
1
+ /**
2
+ * Boundary System for Tentickle
3
+ *
4
+ * Boundaries extend Context with collection-phase effects. They provide a generic
5
+ * mechanism for components that affect how their children are processed during
6
+ * compilation, without hardcoding specific component checks in the compiler.
7
+ *
8
+ * The abstraction ladder:
9
+ * - createContext: render-phase values, read via useContext
10
+ * - createBoundary: render-phase values + collection-phase effects
11
+ * - createFormatter: convenience for formatter boundaries (collection-time)
12
+ * - createPolicy: convenience for policy boundaries (format-time, auto-accumulating)
13
+ *
14
+ * @example Formatter boundary (like XML, Markdown)
15
+ * ```tsx
16
+ * // XML/Markdown use the unified FormatterBoundary
17
+ * <XML>
18
+ * <Content />
19
+ * </XML>
20
+ *
21
+ * // To get the current formatter during render:
22
+ * const formatter = useBoundary(FormatterBoundary);
23
+ * if (formatter) {
24
+ * const formatted = formatter.formatter(blocks);
25
+ * }
26
+ * ```
27
+ *
28
+ * @example Policy boundary (like TokenBudget)
29
+ * ```tsx
30
+ * // Policies auto-accumulate - nested policies are combined
31
+ * <TokenBudget maxTokens={8000} strategy="drop-oldest">
32
+ * <Timeline />
33
+ * <TokenBudget maxTokens={2000} strategy="truncate">
34
+ * <User>{message}</User> {/* Both policies apply \*\/}
35
+ * </TokenBudget>
36
+ * </TokenBudget>
37
+ *
38
+ * // To get all active policies during render:
39
+ * const policyValue = useBoundary(PolicyBoundary);
40
+ * if (policyValue) {
41
+ * console.log('Active policies:', policyValue.policies.map(p => p.name));
42
+ * }
43
+ * ```
44
+ *
45
+ * @module tentickle/boundary
46
+ */
47
+ import { createElement } from "../jsx/jsx-runtime";
48
+ import { createContext, useContext } from "./context";
49
+ // ============================================================================
50
+ // Types
51
+ // ============================================================================
52
+ /**
53
+ * Symbol used to mark boundary provider components.
54
+ * The fiber compiler detects this to handle boundary effects.
55
+ */
56
+ export const BOUNDARY_PROVIDER_SYMBOL = Symbol.for("tentickle.boundary.provider");
57
+ // ============================================================================
58
+ // createBoundary
59
+ // ============================================================================
60
+ /**
61
+ * Creates a Boundary that extends Context with collection-phase effects.
62
+ *
63
+ * Boundaries can provide:
64
+ * - Context values (readable via useBoundary/useContext during render)
65
+ * - Formatter effects (affect content rendering during collection)
66
+ * - Policy effects (process entries after collection)
67
+ *
68
+ * @param definition - The boundary definition
69
+ * @returns A Boundary object with a Provider component
70
+ *
71
+ * @example
72
+ * ```tsx
73
+ * const MyBoundary = createBoundary({
74
+ * defaultValue: null,
75
+ * displayName: 'MyBoundary',
76
+ * class: 'formatter',
77
+ * formatter: (value) => new MyRenderer(),
78
+ * });
79
+ *
80
+ * // Use it
81
+ * <MyBoundary.Provider value={{}}>
82
+ * {children}
83
+ * </MyBoundary.Provider>
84
+ * ```
85
+ */
86
+ export function createBoundary(definition) {
87
+ const displayName = definition.displayName || "Boundary";
88
+ // Create underlying context (boundaries ARE contexts)
89
+ const Context = createContext(definition.defaultValue, displayName);
90
+ // Create the Provider component
91
+ function Provider(props) {
92
+ // Provider wraps Context.Provider
93
+ // The fiber compiler detects this via BOUNDARY_PROVIDER_SYMBOL
94
+ // and applies the boundary effects during traversal
95
+ return createElement(Context.Provider, {
96
+ value: props.value,
97
+ children: props.children,
98
+ });
99
+ }
100
+ // Mark as boundary provider so compiler can detect it
101
+ const boundaryData = {
102
+ class: definition.class,
103
+ definition,
104
+ };
105
+ Provider[BOUNDARY_PROVIDER_SYMBOL] = boundaryData;
106
+ Provider.displayName = `${displayName}.Provider`;
107
+ // Create the boundary object
108
+ const boundary = {
109
+ Context,
110
+ Provider: Provider,
111
+ class: definition.class,
112
+ displayName,
113
+ _definition: definition,
114
+ };
115
+ return boundary;
116
+ }
117
+ // ============================================================================
118
+ // useBoundary
119
+ // ============================================================================
120
+ /**
121
+ * Reads the current value of a boundary.
122
+ *
123
+ * This is a convenience wrapper around useContext that works with Boundary objects.
124
+ * Returns the value from the nearest Provider ancestor, or null if no Provider is found.
125
+ *
126
+ * @param boundary - The Boundary object (created by createBoundary)
127
+ * @returns The current boundary value, or null
128
+ *
129
+ * @example
130
+ * ```tsx
131
+ * const TokenBudgetBoundary = createPolicy<TokenBudgetProps>('TokenBudget', process);
132
+ *
133
+ * function TokenCounter() {
134
+ * const budget = useBoundary(TokenBudgetBoundary);
135
+ * if (!budget) return null;
136
+ * return <System>Budget: {budget.maxTokens} tokens</System>;
137
+ * }
138
+ * ```
139
+ */
140
+ export function useBoundary(boundary) {
141
+ return useContext(boundary.Context);
142
+ }
143
+ /**
144
+ * The unified formatter boundary used by XML, Markdown, JSON, etc.
145
+ *
146
+ * All formatter components (XML, Markdown, JSON) use this single boundary.
147
+ * The value contains a formatter function. Use `useBoundary(FormatterBoundary)`
148
+ * to get the current formatter regardless of which formatter type is active.
149
+ *
150
+ * **Inner wins semantics:** When formatters are nested, the innermost formatter
151
+ * is used for content within its scope.
152
+ *
153
+ * @example
154
+ * ```tsx
155
+ * // In a component - get the current formatter
156
+ * const formatterValue = useBoundary(FormatterBoundary);
157
+ * if (formatterValue) {
158
+ * const formatted = formatterValue.formatter(blocks);
159
+ * }
160
+ *
161
+ * // XML, Markdown, etc. use this boundary internally
162
+ * function XML({ children }) {
163
+ * return (
164
+ * <FormatterBoundary.Provider value={{ formatter: (blocks) => xmlRenderer.format(blocks) }}>
165
+ * {children}
166
+ * </FormatterBoundary.Provider>
167
+ * );
168
+ * }
169
+ * ```
170
+ */
171
+ export const FormatterBoundary = createBoundary({
172
+ defaultValue: null,
173
+ displayName: "Formatter",
174
+ class: "formatter",
175
+ });
176
+ // ============================================================================
177
+ // createFormatter
178
+ // ============================================================================
179
+ /**
180
+ * Creates a formatter component that uses the unified FormatterBoundary.
181
+ *
182
+ * This is a convenience function for creating formatter components like XML, Markdown.
183
+ * It creates a component that wraps children in FormatterBoundary.Provider with the
184
+ * provided formatter function.
185
+ *
186
+ * @param name - Display name for debugging
187
+ * @param formatter - The formatter function or factory
188
+ * @returns A component function that provides the formatter to children
189
+ *
190
+ * @example
191
+ * ```tsx
192
+ * // Create a custom formatter
193
+ * const CustomFormat = createFormatter('CustomFormat', (blocks) => {
194
+ * return blocks.map(block => ({ type: 'text', text: `[${block.text}]` }));
195
+ * });
196
+ *
197
+ * // Use it
198
+ * <CustomFormat>
199
+ * <Content />
200
+ * </CustomFormat>
201
+ * ```
202
+ */
203
+ export function createFormatter(name, formatter) {
204
+ const resolvedFormatter = typeof formatter === "function" && formatter.length === 0
205
+ ? formatter()
206
+ : formatter;
207
+ function FormatterComponent(props) {
208
+ return createElement(FormatterBoundary.Provider, {
209
+ value: { formatter: resolvedFormatter },
210
+ children: props.children,
211
+ });
212
+ }
213
+ FormatterComponent.displayName = name;
214
+ return FormatterComponent;
215
+ }
216
+ /**
217
+ * The unified policy boundary used by TokenBudget, etc.
218
+ *
219
+ * All policy components use this single boundary. Policies **accumulate** -
220
+ * nested policies don't replace parent policies, they add to them.
221
+ * Use `useBoundary(PolicyBoundary)` to get ALL active policies in scope.
222
+ *
223
+ * **Accumulating semantics:** When policies are nested, ALL policies apply
224
+ * to content within their combined scope, processed in order (outer first).
225
+ *
226
+ * @example
227
+ * ```tsx
228
+ * // In a component - get all active policies
229
+ * const policyValue = useBoundary(PolicyBoundary);
230
+ * if (policyValue) {
231
+ * console.log('Active policies:', policyValue.policies.map(p => p.name));
232
+ * // e.g., ['TokenBudget', 'Summarizer']
233
+ * }
234
+ * ```
235
+ *
236
+ * @example Nested policies accumulate - both TokenBudget AND Summarizer apply
237
+ * ```tsx
238
+ * <TokenBudget maxTokens={8000}>
239
+ * <Summarizer threshold={5000}>
240
+ * <Timeline />
241
+ * </Summarizer>
242
+ * </TokenBudget>
243
+ * ```
244
+ */
245
+ export const PolicyBoundary = createBoundary({
246
+ defaultValue: null,
247
+ displayName: "Policy",
248
+ class: "policy",
249
+ });
250
+ // ============================================================================
251
+ // createPolicy
252
+ // ============================================================================
253
+ /**
254
+ * Creates a policy component that auto-accumulates into PolicyBoundary.
255
+ *
256
+ * Policy boundaries affect the timeline entries during the formatInput phase,
257
+ * after all entries have been collected. Use this for filtering, transforming,
258
+ * or managing entries (e.g., token budgets, summarization).
259
+ *
260
+ * **Auto-accumulation:** The created component automatically reads parent policies
261
+ * from PolicyBoundary, appends its own policy, and provides the combined list.
262
+ * You don't need to manually handle accumulation.
263
+ *
264
+ * @param name - Display name for debugging
265
+ * @param process - Function to process entries
266
+ * @returns An object with Provider component and usePolicy hook
267
+ *
268
+ * @example Creating a policy
269
+ * ```typescript
270
+ * const tokenBudget = createPolicy<TokenBudgetProps>(
271
+ * 'TokenBudget',
272
+ * async (entries, props) => applyTokenBudget(entries, props)
273
+ * );
274
+ *
275
+ * // Use the Provider - auto-accumulates with parent policies
276
+ * // <tokenBudget.Provider value={{ maxTokens: 4000, strategy: 'drop-oldest' }}>
277
+ * // <Timeline />
278
+ * // </tokenBudget.Provider>
279
+ *
280
+ * // Read this specific policy's config with usePolicy hook
281
+ * // const config = tokenBudget.usePolicy();
282
+ * ```
283
+ */
284
+ export function createPolicy(name, process) {
285
+ // Create a context for this specific policy's config
286
+ const PolicyConfigContext = createContext(null, `${name}Config`);
287
+ function PolicyProvider(props) {
288
+ // Get parent policies (auto-accumulation)
289
+ const parentValue = useContext(PolicyBoundary.Context);
290
+ const parentPolicies = parentValue?.policies || [];
291
+ // Create new policy entry
292
+ const newPolicy = {
293
+ name,
294
+ process: process,
295
+ config: props.value,
296
+ };
297
+ // Combine parent policies with this one
298
+ const combinedPolicies = [...parentPolicies, newPolicy];
299
+ // Provide both the combined policies AND this policy's specific config
300
+ return createElement(PolicyBoundary.Provider, {
301
+ value: { policies: combinedPolicies },
302
+ children: createElement(PolicyConfigContext.Provider, {
303
+ value: props.value,
304
+ children: props.children,
305
+ }),
306
+ });
307
+ }
308
+ PolicyProvider.displayName = `${name}.Provider`;
309
+ function usePolicy() {
310
+ return useContext(PolicyConfigContext);
311
+ }
312
+ return {
313
+ Provider: PolicyProvider,
314
+ usePolicy,
315
+ name,
316
+ process,
317
+ };
318
+ }
319
+ // ============================================================================
320
+ // Utilities
321
+ // ============================================================================
322
+ /**
323
+ * Check if a component is a boundary provider.
324
+ * Used by the fiber compiler during traversal.
325
+ *
326
+ * @internal
327
+ */
328
+ export function isBoundaryProvider(component) {
329
+ return (typeof component === "function" &&
330
+ BOUNDARY_PROVIDER_SYMBOL in component &&
331
+ component[BOUNDARY_PROVIDER_SYMBOL] !== undefined);
332
+ }
333
+ /**
334
+ * Get the boundary data from a provider component.
335
+ *
336
+ * @internal
337
+ */
338
+ export function getBoundaryData(provider) {
339
+ return provider[BOUNDARY_PROVIDER_SYMBOL];
340
+ }
341
+ //# sourceMappingURL=boundary.js.map