@alvin0/ai-agent-sdk-core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (623) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +52 -0
  3. package/dist/agent/accounting/common.js +2 -0
  4. package/dist/agent/accounting/common.js.map +1 -0
  5. package/dist/agent/accounting/config.js +2 -0
  6. package/dist/agent/accounting/config.js.map +1 -0
  7. package/dist/agent/accounting/contracts.d.ts +36 -0
  8. package/dist/agent/accounting/contracts.d.ts.map +1 -0
  9. package/dist/agent/accounting/delivery/accounting-data.js +2 -0
  10. package/dist/agent/accounting/delivery/accounting-data.js.map +1 -0
  11. package/dist/agent/accounting/delivery/config.js +2 -0
  12. package/dist/agent/accounting/delivery/config.js.map +1 -0
  13. package/dist/agent/accounting/delivery/data.js +2 -0
  14. package/dist/agent/accounting/delivery/data.js.map +1 -0
  15. package/dist/agent/accounting/delivery/support-errors.js +2 -0
  16. package/dist/agent/accounting/delivery/support-errors.js.map +1 -0
  17. package/dist/agent/accounting/delivery/terminal.js +2 -0
  18. package/dist/agent/accounting/delivery/terminal.js.map +1 -0
  19. package/dist/agent/accounting/delivery-types.d.ts +43 -0
  20. package/dist/agent/accounting/delivery-types.d.ts.map +1 -0
  21. package/dist/agent/accounting/error.d.ts +18 -0
  22. package/dist/agent/accounting/error.d.ts.map +1 -0
  23. package/dist/agent/accounting/error.js +2 -0
  24. package/dist/agent/accounting/error.js.map +1 -0
  25. package/dist/agent/accounting/estimate.js +2 -0
  26. package/dist/agent/accounting/estimate.js.map +1 -0
  27. package/dist/agent/accounting/event-buffer.js +2 -0
  28. package/dist/agent/accounting/event-buffer.js.map +1 -0
  29. package/dist/agent/accounting/ledger.js +2 -0
  30. package/dist/agent/accounting/ledger.js.map +1 -0
  31. package/dist/agent/accounting/report.d.ts +70 -0
  32. package/dist/agent/accounting/report.d.ts.map +1 -0
  33. package/dist/agent/accounting/usage.d.ts +13 -0
  34. package/dist/agent/accounting/usage.d.ts.map +1 -0
  35. package/dist/agent/accounting/usage.js +2 -0
  36. package/dist/agent/accounting/usage.js.map +1 -0
  37. package/dist/agent/context/section.d.ts +15 -0
  38. package/dist/agent/context/section.d.ts.map +1 -0
  39. package/dist/agent/context/section.js +2 -0
  40. package/dist/agent/context/section.js.map +1 -0
  41. package/dist/agent/context/types.d.ts +98 -0
  42. package/dist/agent/context/types.d.ts.map +1 -0
  43. package/dist/agent/define/definition.d.ts +110 -0
  44. package/dist/agent/define/definition.d.ts.map +1 -0
  45. package/dist/agent/define/definition.js +2 -0
  46. package/dist/agent/define/definition.js.map +1 -0
  47. package/dist/agent/define/instructions.js +2 -0
  48. package/dist/agent/define/instructions.js.map +1 -0
  49. package/dist/agent/define/output-format.js +2 -0
  50. package/dist/agent/define/output-format.js.map +1 -0
  51. package/dist/agent/define/session/accounting.js +2 -0
  52. package/dist/agent/define/session/accounting.js.map +1 -0
  53. package/dist/agent/define/session/common.js +2 -0
  54. package/dist/agent/define/session/common.js.map +1 -0
  55. package/dist/agent/define/session/config.js +2 -0
  56. package/dist/agent/define/session/config.js.map +1 -0
  57. package/dist/agent/define/session/model-config.js +2 -0
  58. package/dist/agent/define/session/model-config.js.map +1 -0
  59. package/dist/agent/define/session/observer.js +2 -0
  60. package/dist/agent/define/session/observer.js.map +1 -0
  61. package/dist/agent/define/session/run-seal.js +2 -0
  62. package/dist/agent/define/session/run-seal.js.map +1 -0
  63. package/dist/agent/define/session/runtime-binding.js +2 -0
  64. package/dist/agent/define/session/runtime-binding.js.map +1 -0
  65. package/dist/agent/define/session/runtime-compaction.js +2 -0
  66. package/dist/agent/define/session/runtime-compaction.js.map +1 -0
  67. package/dist/agent/define/session/runtime-memory.js +2 -0
  68. package/dist/agent/define/session/runtime-memory.js.map +1 -0
  69. package/dist/agent/define/session/skills.js +2 -0
  70. package/dist/agent/define/session/skills.js.map +1 -0
  71. package/dist/agent/define/session/trace-accounting.js +2 -0
  72. package/dist/agent/define/session/trace-accounting.js.map +1 -0
  73. package/dist/agent/define/session/types.d.ts +217 -0
  74. package/dist/agent/define/session/types.d.ts.map +1 -0
  75. package/dist/agent/define/session/validation.js +2 -0
  76. package/dist/agent/define/session/validation.js.map +1 -0
  77. package/dist/agent/define/session.d.ts +77 -0
  78. package/dist/agent/define/session.d.ts.map +1 -0
  79. package/dist/agent/define/session.js +2 -0
  80. package/dist/agent/define/session.js.map +1 -0
  81. package/dist/agent/history/config.js +2 -0
  82. package/dist/agent/history/config.js.map +1 -0
  83. package/dist/agent/history/history.d.ts +33 -0
  84. package/dist/agent/history/history.d.ts.map +1 -0
  85. package/dist/agent/history/history.js +2 -0
  86. package/dist/agent/history/history.js.map +1 -0
  87. package/dist/agent/history/normalize.d.ts +7 -0
  88. package/dist/agent/history/normalize.d.ts.map +1 -0
  89. package/dist/agent/history/normalize.js +2 -0
  90. package/dist/agent/history/normalize.js.map +1 -0
  91. package/dist/agent/history/project.d.ts +14 -0
  92. package/dist/agent/history/project.d.ts.map +1 -0
  93. package/dist/agent/history/project.js +2 -0
  94. package/dist/agent/history/project.js.map +1 -0
  95. package/dist/agent/history/types.d.ts +85 -0
  96. package/dist/agent/history/types.d.ts.map +1 -0
  97. package/dist/agent/history/validation.js +2 -0
  98. package/dist/agent/history/validation.js.map +1 -0
  99. package/dist/agent/loop/events.d.ts +213 -0
  100. package/dist/agent/loop/events.d.ts.map +1 -0
  101. package/dist/agent/loop/queue.js +2 -0
  102. package/dist/agent/loop/queue.js.map +1 -0
  103. package/dist/agent/loop/run-turn.d.ts +8 -0
  104. package/dist/agent/loop/run-turn.d.ts.map +1 -0
  105. package/dist/agent/loop/run-turn.js +2 -0
  106. package/dist/agent/loop/run-turn.js.map +1 -0
  107. package/dist/agent/loop/schedule.d.ts +62 -0
  108. package/dist/agent/loop/schedule.d.ts.map +1 -0
  109. package/dist/agent/loop/schedule.js +3 -0
  110. package/dist/agent/loop/schedule.js.map +1 -0
  111. package/dist/agent/loop/turn/cancellation.js +2 -0
  112. package/dist/agent/loop/turn/cancellation.js.map +1 -0
  113. package/dist/agent/loop/turn/common.js +2 -0
  114. package/dist/agent/loop/turn/common.js.map +1 -0
  115. package/dist/agent/loop/turn/config.js +2 -0
  116. package/dist/agent/loop/turn/config.js.map +1 -0
  117. package/dist/agent/loop/turn/content.js +4 -0
  118. package/dist/agent/loop/turn/content.js.map +1 -0
  119. package/dist/agent/loop/turn/hooks.js +2 -0
  120. package/dist/agent/loop/turn/hooks.js.map +1 -0
  121. package/dist/agent/loop/turn/model-round.js +2 -0
  122. package/dist/agent/loop/turn/model-round.js.map +1 -0
  123. package/dist/agent/loop/turn/repetition.js +2 -0
  124. package/dist/agent/loop/turn/repetition.js.map +1 -0
  125. package/dist/agent/loop/turn/types.d.ts +82 -0
  126. package/dist/agent/loop/turn/types.d.ts.map +1 -0
  127. package/dist/agent/loop/turn/usage-stop.js +2 -0
  128. package/dist/agent/loop/turn/usage-stop.js.map +1 -0
  129. package/dist/agent/loop/turn/validation.js +2 -0
  130. package/dist/agent/loop/turn/validation.js.map +1 -0
  131. package/dist/agent/loop/types.d.ts +82 -0
  132. package/dist/agent/loop/types.d.ts.map +1 -0
  133. package/dist/agent/memory/accounting-binding.js +2 -0
  134. package/dist/agent/memory/accounting-binding.js.map +1 -0
  135. package/dist/agent/memory/compaction-config.d.ts +63 -0
  136. package/dist/agent/memory/compaction-config.d.ts.map +1 -0
  137. package/dist/agent/memory/compaction-config.js +2 -0
  138. package/dist/agent/memory/compaction-config.js.map +1 -0
  139. package/dist/agent/memory/compaction.d.ts +62 -0
  140. package/dist/agent/memory/compaction.d.ts.map +1 -0
  141. package/dist/agent/memory/compaction.js +6 -0
  142. package/dist/agent/memory/compaction.js.map +1 -0
  143. package/dist/agent/memory/memory.d.ts +61 -0
  144. package/dist/agent/memory/memory.d.ts.map +1 -0
  145. package/dist/agent/memory/memory.js +5 -0
  146. package/dist/agent/memory/memory.js.map +1 -0
  147. package/dist/agent/memory/persistence-types.d.ts +44 -0
  148. package/dist/agent/memory/persistence-types.d.ts.map +1 -0
  149. package/dist/agent/memory/surface-compaction.d.ts +6 -0
  150. package/dist/agent/memory/surface-compaction.d.ts.map +1 -0
  151. package/dist/agent/memory/surface-compaction.js +4 -0
  152. package/dist/agent/memory/surface-compaction.js.map +1 -0
  153. package/dist/agent/memory/token-estimator.d.ts +12 -0
  154. package/dist/agent/memory/token-estimator.d.ts.map +1 -0
  155. package/dist/agent/memory/token-estimator.js +2 -0
  156. package/dist/agent/memory/token-estimator.js.map +1 -0
  157. package/dist/agent/mode/run-agent.d.ts +79 -0
  158. package/dist/agent/mode/run-agent.d.ts.map +1 -0
  159. package/dist/agent/mode/run-agent.js +4 -0
  160. package/dist/agent/mode/run-agent.js.map +1 -0
  161. package/dist/agent/mode/user-input.d.ts +61 -0
  162. package/dist/agent/mode/user-input.d.ts.map +1 -0
  163. package/dist/agent/mode/user-input.js +2 -0
  164. package/dist/agent/mode/user-input.js.map +1 -0
  165. package/dist/agent/skill/catalog.d.ts +53 -0
  166. package/dist/agent/skill/catalog.d.ts.map +1 -0
  167. package/dist/agent/skill/catalog.js +2 -0
  168. package/dist/agent/skill/catalog.js.map +1 -0
  169. package/dist/agent/skill/definition.d.ts +106 -0
  170. package/dist/agent/skill/definition.d.ts.map +1 -0
  171. package/dist/agent/skill/definition.js +2 -0
  172. package/dist/agent/skill/definition.js.map +1 -0
  173. package/dist/agent/skill/provider/config.d.ts +11 -0
  174. package/dist/agent/skill/provider/config.d.ts.map +1 -0
  175. package/dist/agent/skill/provider/config.js +2 -0
  176. package/dist/agent/skill/provider/config.js.map +1 -0
  177. package/dist/agent/skill/provider/context.js +2 -0
  178. package/dist/agent/skill/provider/context.js.map +1 -0
  179. package/dist/agent/skill/provider/definition.d.ts +6 -0
  180. package/dist/agent/skill/provider/definition.d.ts.map +1 -0
  181. package/dist/agent/skill/provider/definition.js +2 -0
  182. package/dist/agent/skill/provider/definition.js.map +1 -0
  183. package/dist/agent/skill/provider/snapshot.js +2 -0
  184. package/dist/agent/skill/provider/snapshot.js.map +1 -0
  185. package/dist/agent/skill/provider/types.d.ts +49 -0
  186. package/dist/agent/skill/provider/types.d.ts.map +1 -0
  187. package/dist/agent/skill/tools.d.ts +45 -0
  188. package/dist/agent/skill/tools.d.ts.map +1 -0
  189. package/dist/agent/skill/tools.js +14 -0
  190. package/dist/agent/skill/tools.js.map +1 -0
  191. package/dist/agent/team/common.d.ts +26 -0
  192. package/dist/agent/team/common.d.ts.map +1 -0
  193. package/dist/agent/team/common.js +2 -0
  194. package/dist/agent/team/common.js.map +1 -0
  195. package/dist/agent/team/composed.d.ts +45 -0
  196. package/dist/agent/team/composed.d.ts.map +1 -0
  197. package/dist/agent/team/composed.js +2 -0
  198. package/dist/agent/team/composed.js.map +1 -0
  199. package/dist/agent/team/contracts.d.ts +54 -0
  200. package/dist/agent/team/contracts.d.ts.map +1 -0
  201. package/dist/agent/team/managed.d.ts +527 -0
  202. package/dist/agent/team/managed.d.ts.map +1 -0
  203. package/dist/agent/team/managed.js +4 -0
  204. package/dist/agent/team/managed.js.map +1 -0
  205. package/dist/agent/team/team.d.ts +142 -0
  206. package/dist/agent/team/team.d.ts.map +1 -0
  207. package/dist/agent/team/team.js +2 -0
  208. package/dist/agent/team/team.js.map +1 -0
  209. package/dist/agent/team/types.d.ts +170 -0
  210. package/dist/agent/team/types.d.ts.map +1 -0
  211. package/dist/agent/tool/approval.d.ts +106 -0
  212. package/dist/agent/tool/approval.d.ts.map +1 -0
  213. package/dist/agent/tool/approval.js +2 -0
  214. package/dist/agent/tool/approval.js.map +1 -0
  215. package/dist/agent/tool/capture.js +2 -0
  216. package/dist/agent/tool/capture.js.map +1 -0
  217. package/dist/agent/tool/config.js +2 -0
  218. package/dist/agent/tool/config.js.map +1 -0
  219. package/dist/agent/tool/definition.d.ts +227 -0
  220. package/dist/agent/tool/definition.d.ts.map +1 -0
  221. package/dist/agent/tool/definition.js +2 -0
  222. package/dist/agent/tool/definition.js.map +1 -0
  223. package/dist/agent/tool/errors.d.ts +82 -0
  224. package/dist/agent/tool/errors.d.ts.map +1 -0
  225. package/dist/agent/tool/errors.js +2 -0
  226. package/dist/agent/tool/errors.js.map +1 -0
  227. package/dist/agent/tool/execution.d.ts +60 -0
  228. package/dist/agent/tool/execution.d.ts.map +1 -0
  229. package/dist/agent/tool/execution.js +2 -0
  230. package/dist/agent/tool/execution.js.map +1 -0
  231. package/dist/agent/tool/output-budget.d.ts +159 -0
  232. package/dist/agent/tool/output-budget.d.ts.map +1 -0
  233. package/dist/agent/tool/output-budget.js +3 -0
  234. package/dist/agent/tool/output-budget.js.map +1 -0
  235. package/dist/agent/tool/pipeline.d.ts +98 -0
  236. package/dist/agent/tool/pipeline.d.ts.map +1 -0
  237. package/dist/agent/tool/pipeline.js +4 -0
  238. package/dist/agent/tool/pipeline.js.map +1 -0
  239. package/dist/agent/tool/registry.d.ts +70 -0
  240. package/dist/agent/tool/registry.d.ts.map +1 -0
  241. package/dist/agent/tool/registry.js +2 -0
  242. package/dist/agent/tool/registry.js.map +1 -0
  243. package/dist/agent/tool/schema.d.ts +12 -0
  244. package/dist/agent/tool/schema.d.ts.map +1 -0
  245. package/dist/agent/tool/schema.js +2 -0
  246. package/dist/agent/tool/schema.js.map +1 -0
  247. package/dist/agent/tool/source-types.d.ts +25 -0
  248. package/dist/agent/tool/source-types.d.ts.map +1 -0
  249. package/dist/agent/trace/trace.d.ts +63 -0
  250. package/dist/agent/trace/trace.d.ts.map +1 -0
  251. package/dist/agent/trace/trace.js +2 -0
  252. package/dist/agent/trace/trace.js.map +1 -0
  253. package/dist/agent.d.ts +52 -0
  254. package/dist/agent.js +1 -0
  255. package/dist/async/settlement.d.ts +6 -0
  256. package/dist/async/settlement.d.ts.map +1 -0
  257. package/dist/async/settlement.js +2 -0
  258. package/dist/async/settlement.js.map +1 -0
  259. package/dist/capability/common/config.js +2 -0
  260. package/dist/capability/common/config.js.map +1 -0
  261. package/dist/capability/common/data.js +2 -0
  262. package/dist/capability/common/data.js.map +1 -0
  263. package/dist/composition/agent/author.d.ts +12 -0
  264. package/dist/composition/agent/author.d.ts.map +1 -0
  265. package/dist/composition/agent/author.js +2 -0
  266. package/dist/composition/agent/author.js.map +1 -0
  267. package/dist/composition/agent/definition.js +2 -0
  268. package/dist/composition/agent/definition.js.map +1 -0
  269. package/dist/composition/agent/native-event.js +2 -0
  270. package/dist/composition/agent/native-event.js.map +1 -0
  271. package/dist/composition/agent/native-tools.js +2 -0
  272. package/dist/composition/agent/native-tools.js.map +1 -0
  273. package/dist/composition/agent/options.js +2 -0
  274. package/dist/composition/agent/options.js.map +1 -0
  275. package/dist/composition/agent/policy.js +2 -0
  276. package/dist/composition/agent/policy.js.map +1 -0
  277. package/dist/composition/agent/public-message.js +2 -0
  278. package/dist/composition/agent/public-message.js.map +1 -0
  279. package/dist/composition/agent/session.js +2 -0
  280. package/dist/composition/agent/session.js.map +1 -0
  281. package/dist/composition/agent/types.d.ts +218 -0
  282. package/dist/composition/agent/types.d.ts.map +1 -0
  283. package/dist/composition/common/counter.js +2 -0
  284. package/dist/composition/common/counter.js.map +1 -0
  285. package/dist/composition/common/errors.d.ts +15 -0
  286. package/dist/composition/common/errors.d.ts.map +1 -0
  287. package/dist/composition/common/errors.js +2 -0
  288. package/dist/composition/common/errors.js.map +1 -0
  289. package/dist/composition/common/json-data.js +2 -0
  290. package/dist/composition/common/json-data.js.map +1 -0
  291. package/dist/composition/credential/config.d.ts +5 -0
  292. package/dist/composition/credential/config.d.ts.map +1 -0
  293. package/dist/composition/credential/config.js +2 -0
  294. package/dist/composition/credential/config.js.map +1 -0
  295. package/dist/composition/credential/definition.d.ts +9 -0
  296. package/dist/composition/credential/definition.d.ts.map +1 -0
  297. package/dist/composition/credential/definition.js +2 -0
  298. package/dist/composition/credential/definition.js.map +1 -0
  299. package/dist/composition/credential/types.d.ts +38 -0
  300. package/dist/composition/credential/types.d.ts.map +1 -0
  301. package/dist/composition/delivery/ack.js +2 -0
  302. package/dist/composition/delivery/ack.js.map +1 -0
  303. package/dist/composition/delivery/attempt.js +2 -0
  304. package/dist/composition/delivery/attempt.js.map +1 -0
  305. package/dist/composition/delivery/batch.js +2 -0
  306. package/dist/composition/delivery/batch.js.map +1 -0
  307. package/dist/composition/delivery/checkpoint.js +2 -0
  308. package/dist/composition/delivery/checkpoint.js.map +1 -0
  309. package/dist/composition/delivery/event.js +2 -0
  310. package/dist/composition/delivery/event.js.map +1 -0
  311. package/dist/composition/delivery/resource.d.ts +11 -0
  312. package/dist/composition/delivery/resource.d.ts.map +1 -0
  313. package/dist/composition/delivery/resource.js +2 -0
  314. package/dist/composition/delivery/resource.js.map +1 -0
  315. package/dist/composition/delivery/staging.js +2 -0
  316. package/dist/composition/delivery/staging.js.map +1 -0
  317. package/dist/composition/diagnostics/config.js +2 -0
  318. package/dist/composition/diagnostics/config.js.map +1 -0
  319. package/dist/composition/diagnostics/ring.d.ts +12 -0
  320. package/dist/composition/diagnostics/ring.d.ts.map +1 -0
  321. package/dist/composition/diagnostics/ring.js +2 -0
  322. package/dist/composition/diagnostics/ring.js.map +1 -0
  323. package/dist/composition/exporter/definition.d.ts +7 -0
  324. package/dist/composition/exporter/definition.d.ts.map +1 -0
  325. package/dist/composition/exporter/definition.js +2 -0
  326. package/dist/composition/exporter/definition.js.map +1 -0
  327. package/dist/composition/exporter/lifecycle.js +2 -0
  328. package/dist/composition/exporter/lifecycle.js.map +1 -0
  329. package/dist/composition/exporter/preflight.js +2 -0
  330. package/dist/composition/exporter/preflight.js.map +1 -0
  331. package/dist/composition/exporter/types.d.ts +25 -0
  332. package/dist/composition/exporter/types.d.ts.map +1 -0
  333. package/dist/composition/exporter/types.js +2 -0
  334. package/dist/composition/exporter/types.js.map +1 -0
  335. package/dist/composition/identity/agent.js +2 -0
  336. package/dist/composition/identity/agent.js.map +1 -0
  337. package/dist/composition/lifecycle/bounded.js +2 -0
  338. package/dist/composition/lifecycle/bounded.js.map +1 -0
  339. package/dist/composition/lifecycle/operations.js +2 -0
  340. package/dist/composition/lifecycle/operations.js.map +1 -0
  341. package/dist/composition/lifecycle/types.d.ts +13 -0
  342. package/dist/composition/lifecycle/types.d.ts.map +1 -0
  343. package/dist/composition/lifecycle/types.js +2 -0
  344. package/dist/composition/lifecycle/types.js.map +1 -0
  345. package/dist/composition/logging/config.js +2 -0
  346. package/dist/composition/logging/config.js.map +1 -0
  347. package/dist/composition/logging/integration.js +2 -0
  348. package/dist/composition/logging/integration.js.map +1 -0
  349. package/dist/composition/logging/logger.d.ts +9 -0
  350. package/dist/composition/logging/logger.d.ts.map +1 -0
  351. package/dist/composition/logging/logger.js +2 -0
  352. package/dist/composition/logging/logger.js.map +1 -0
  353. package/dist/composition/memory/config.d.ts +10 -0
  354. package/dist/composition/memory/config.d.ts.map +1 -0
  355. package/dist/composition/memory/config.js +2 -0
  356. package/dist/composition/memory/config.js.map +1 -0
  357. package/dist/composition/memory/definition.d.ts +7 -0
  358. package/dist/composition/memory/definition.d.ts.map +1 -0
  359. package/dist/composition/memory/definition.js +2 -0
  360. package/dist/composition/memory/definition.js.map +1 -0
  361. package/dist/composition/memory/key.js +2 -0
  362. package/dist/composition/memory/key.js.map +1 -0
  363. package/dist/composition/memory/resume.js +2 -0
  364. package/dist/composition/memory/resume.js.map +1 -0
  365. package/dist/composition/memory/run.js +2 -0
  366. package/dist/composition/memory/run.js.map +1 -0
  367. package/dist/composition/model-catalog/config.js +2 -0
  368. package/dist/composition/model-catalog/config.js.map +1 -0
  369. package/dist/composition/model-catalog/manager.js +2 -0
  370. package/dist/composition/model-catalog/manager.js.map +1 -0
  371. package/dist/composition/model-catalog/options.js +2 -0
  372. package/dist/composition/model-catalog/options.js.map +1 -0
  373. package/dist/composition/model-catalog/types.d.ts +9 -0
  374. package/dist/composition/model-catalog/types.d.ts.map +1 -0
  375. package/dist/composition/observation/config.js +2 -0
  376. package/dist/composition/observation/config.js.map +1 -0
  377. package/dist/composition/observation/extensions.js +2 -0
  378. package/dist/composition/observation/extensions.js.map +1 -0
  379. package/dist/composition/observation/final-report.d.ts +6 -0
  380. package/dist/composition/observation/final-report.d.ts.map +1 -0
  381. package/dist/composition/observation/final-report.js +2 -0
  382. package/dist/composition/observation/final-report.js.map +1 -0
  383. package/dist/composition/observation/health.d.ts +13 -0
  384. package/dist/composition/observation/health.d.ts.map +1 -0
  385. package/dist/composition/observation/port.d.ts +11 -0
  386. package/dist/composition/observation/port.d.ts.map +1 -0
  387. package/dist/composition/observation/port.js +2 -0
  388. package/dist/composition/observation/port.js.map +1 -0
  389. package/dist/composition/preflight.js +2 -0
  390. package/dist/composition/preflight.js.map +1 -0
  391. package/dist/composition/provider/activation.js +2 -0
  392. package/dist/composition/provider/activation.js.map +1 -0
  393. package/dist/composition/provider/definition.d.ts +7 -0
  394. package/dist/composition/provider/definition.d.ts.map +1 -0
  395. package/dist/composition/provider/definition.js +2 -0
  396. package/dist/composition/provider/definition.js.map +1 -0
  397. package/dist/composition/provider/model-selection.js +2 -0
  398. package/dist/composition/provider/model-selection.js.map +1 -0
  399. package/dist/composition/provider/preflight.js +2 -0
  400. package/dist/composition/provider/preflight.js.map +1 -0
  401. package/dist/composition/provider/types.d.ts +38 -0
  402. package/dist/composition/provider/types.d.ts.map +1 -0
  403. package/dist/composition/provider/types.js +2 -0
  404. package/dist/composition/provider/types.js.map +1 -0
  405. package/dist/composition/queue/config.js +2 -0
  406. package/dist/composition/queue/config.js.map +1 -0
  407. package/dist/composition/queue/scheduler.js +2 -0
  408. package/dist/composition/queue/scheduler.js.map +1 -0
  409. package/dist/composition/queue/store.js +2 -0
  410. package/dist/composition/queue/store.js.map +1 -0
  411. package/dist/composition/runtime/config.js +2 -0
  412. package/dist/composition/runtime/config.js.map +1 -0
  413. package/dist/composition/runtime/owner.js +2 -0
  414. package/dist/composition/runtime/owner.js.map +1 -0
  415. package/dist/composition/runtime/public.d.ts +7 -0
  416. package/dist/composition/runtime/public.d.ts.map +1 -0
  417. package/dist/composition/runtime/public.js +2 -0
  418. package/dist/composition/runtime/public.js.map +1 -0
  419. package/dist/composition/runtime/types.d.ts +76 -0
  420. package/dist/composition/runtime/types.d.ts.map +1 -0
  421. package/dist/composition/startup.js +2 -0
  422. package/dist/composition/startup.js.map +1 -0
  423. package/dist/composition/team/config.js +2 -0
  424. package/dist/composition/team/config.js.map +1 -0
  425. package/dist/composition/team/options.js +2 -0
  426. package/dist/composition/team/options.js.map +1 -0
  427. package/dist/composition/team/runtime.js +2 -0
  428. package/dist/composition/team/runtime.js.map +1 -0
  429. package/dist/composition/team/types.d.ts +63 -0
  430. package/dist/composition/team/types.d.ts.map +1 -0
  431. package/dist/composition/tool-source/config.d.ts +5 -0
  432. package/dist/composition/tool-source/config.d.ts.map +1 -0
  433. package/dist/composition/tool-source/config.js +2 -0
  434. package/dist/composition/tool-source/config.js.map +1 -0
  435. package/dist/composition/tool-source/definition.d.ts +7 -0
  436. package/dist/composition/tool-source/definition.d.ts.map +1 -0
  437. package/dist/composition/tool-source/definition.js +2 -0
  438. package/dist/composition/tool-source/definition.js.map +1 -0
  439. package/dist/composition/tool-source/snapshot.js +2 -0
  440. package/dist/composition/tool-source/snapshot.js.map +1 -0
  441. package/dist/contract/adapter.d.ts +91 -0
  442. package/dist/contract/adapter.d.ts.map +1 -0
  443. package/dist/contract/adapter.js +2 -0
  444. package/dist/contract/adapter.js.map +1 -0
  445. package/dist/contract/call-config.d.ts +36 -0
  446. package/dist/contract/call-config.d.ts.map +1 -0
  447. package/dist/contract/call-config.js +2 -0
  448. package/dist/contract/call-config.js.map +1 -0
  449. package/dist/contract/generate-options.d.ts +41 -0
  450. package/dist/contract/generate-options.d.ts.map +1 -0
  451. package/dist/contract/model-info.d.ts +99 -0
  452. package/dist/contract/model-info.d.ts.map +1 -0
  453. package/dist/contract/output-format.d.ts +18 -0
  454. package/dist/contract/output-format.d.ts.map +1 -0
  455. package/dist/contract/retry-policy.d.ts +104 -0
  456. package/dist/contract/retry-policy.d.ts.map +1 -0
  457. package/dist/contract/retry-policy.js +2 -0
  458. package/dist/contract/retry-policy.js.map +1 -0
  459. package/dist/contract/tool.d.ts +65 -0
  460. package/dist/contract/tool.d.ts.map +1 -0
  461. package/dist/contract/tool.js +2 -0
  462. package/dist/contract/tool.js.map +1 -0
  463. package/dist/errors/agent-sdk-error.d.ts +88 -0
  464. package/dist/errors/agent-sdk-error.d.ts.map +1 -0
  465. package/dist/errors/agent-sdk-error.js +2 -0
  466. package/dist/errors/agent-sdk-error.js.map +1 -0
  467. package/dist/errors/capability-identity.d.ts +10 -0
  468. package/dist/errors/capability-identity.d.ts.map +1 -0
  469. package/dist/errors/capability-identity.js +2 -0
  470. package/dist/errors/capability-identity.js.map +1 -0
  471. package/dist/errors/failure.d.ts +33 -0
  472. package/dist/errors/failure.d.ts.map +1 -0
  473. package/dist/errors/failure.js +2 -0
  474. package/dist/errors/failure.js.map +1 -0
  475. package/dist/errors/model-error.d.ts +83 -0
  476. package/dist/errors/model-error.d.ts.map +1 -0
  477. package/dist/errors/model-error.js +2 -0
  478. package/dist/errors/model-error.js.map +1 -0
  479. package/dist/http/api-key.d.ts +47 -0
  480. package/dist/http/api-key.d.ts.map +1 -0
  481. package/dist/http/api-key.js +2 -0
  482. package/dist/http/api-key.js.map +1 -0
  483. package/dist/http/attribution.d.ts +51 -0
  484. package/dist/http/attribution.d.ts.map +1 -0
  485. package/dist/http/attribution.js +2 -0
  486. package/dist/http/attribution.js.map +1 -0
  487. package/dist/index.d.ts +70 -0
  488. package/dist/index.js +1 -0
  489. package/dist/logging/types.d.ts +53 -0
  490. package/dist/logging/types.d.ts.map +1 -0
  491. package/dist/logging/types.js +2 -0
  492. package/dist/logging/types.js.map +1 -0
  493. package/dist/memory.d.ts +10 -0
  494. package/dist/memory.js +1 -0
  495. package/dist/message/content.d.ts +125 -0
  496. package/dist/message/content.d.ts.map +1 -0
  497. package/dist/message/message.d.ts +154 -0
  498. package/dist/message/message.d.ts.map +1 -0
  499. package/dist/message/message.js +2 -0
  500. package/dist/message/message.js.map +1 -0
  501. package/dist/message/projection.d.ts +34 -0
  502. package/dist/message/projection.d.ts.map +1 -0
  503. package/dist/message/projection.js +2 -0
  504. package/dist/message/projection.js.map +1 -0
  505. package/dist/observability/bus.d.ts +7 -0
  506. package/dist/observability/bus.d.ts.map +1 -0
  507. package/dist/observability/bus.js +2 -0
  508. package/dist/observability/bus.js.map +1 -0
  509. package/dist/observability/exporters.d.ts +39 -0
  510. package/dist/observability/exporters.d.ts.map +1 -0
  511. package/dist/observability/exporters.js +2 -0
  512. package/dist/observability/exporters.js.map +1 -0
  513. package/dist/observability/logger.js +2 -0
  514. package/dist/observability/logger.js.map +1 -0
  515. package/dist/observability/projections.d.ts +12 -0
  516. package/dist/observability/projections.d.ts.map +1 -0
  517. package/dist/observability/projections.js +2 -0
  518. package/dist/observability/projections.js.map +1 -0
  519. package/dist/observability/types.d.ts +103 -0
  520. package/dist/observability/types.d.ts.map +1 -0
  521. package/dist/observability.d.ts +20 -0
  522. package/dist/observability.js +1 -0
  523. package/dist/observation/boundaries.js +2 -0
  524. package/dist/observation/boundaries.js.map +1 -0
  525. package/dist/observation/context.d.ts +39 -0
  526. package/dist/observation/context.d.ts.map +1 -0
  527. package/dist/observation/context.js +2 -0
  528. package/dist/observation/context.js.map +1 -0
  529. package/dist/observation/event.d.ts +50 -0
  530. package/dist/observation/event.d.ts.map +1 -0
  531. package/dist/observation/event.js +2 -0
  532. package/dist/observation/event.js.map +1 -0
  533. package/dist/observation/port.d.ts +56 -0
  534. package/dist/observation/port.d.ts.map +1 -0
  535. package/dist/observation/port.js +2 -0
  536. package/dist/observation/port.js.map +1 -0
  537. package/dist/observation/privacy.js +2 -0
  538. package/dist/observation/privacy.js.map +1 -0
  539. package/dist/observation/report.d.ts +117 -0
  540. package/dist/observation/report.d.ts.map +1 -0
  541. package/dist/observation/report.js +2 -0
  542. package/dist/observation/report.js.map +1 -0
  543. package/dist/observation/telemetry-types.d.ts +29 -0
  544. package/dist/observation/telemetry-types.d.ts.map +1 -0
  545. package/dist/observation/usage.d.ts +52 -0
  546. package/dist/observation/usage.d.ts.map +1 -0
  547. package/dist/observation/usage.js +2 -0
  548. package/dist/observation/usage.js.map +1 -0
  549. package/dist/platform/adapter.js +2 -0
  550. package/dist/platform/adapter.js.map +1 -0
  551. package/dist/platform/capability-operation.js +2 -0
  552. package/dist/platform/capability-operation.js.map +1 -0
  553. package/dist/platform/config.js +2 -0
  554. package/dist/platform/config.js.map +1 -0
  555. package/dist/platform/logger-platform.js +2 -0
  556. package/dist/platform/logger-platform.js.map +1 -0
  557. package/dist/platform/resources.js +2 -0
  558. package/dist/platform/resources.js.map +1 -0
  559. package/dist/plugin/provider-plugin.d.ts +37 -0
  560. package/dist/plugin/provider-plugin.d.ts.map +1 -0
  561. package/dist/plugin/provider-plugin.js +2 -0
  562. package/dist/plugin/provider-plugin.js.map +1 -0
  563. package/dist/primitives/brand.d.ts +61 -0
  564. package/dist/primitives/brand.d.ts.map +1 -0
  565. package/dist/primitives/brand.js +2 -0
  566. package/dist/primitives/brand.js.map +1 -0
  567. package/dist/primitives/freeze.d.ts +20 -0
  568. package/dist/primitives/freeze.d.ts.map +1 -0
  569. package/dist/primitives/freeze.js +2 -0
  570. package/dist/primitives/freeze.js.map +1 -0
  571. package/dist/primitives/json-snapshot.js +2 -0
  572. package/dist/primitives/json-snapshot.js.map +1 -0
  573. package/dist/primitives/json.d.ts +32 -0
  574. package/dist/primitives/json.d.ts.map +1 -0
  575. package/dist/primitives/json.js +2 -0
  576. package/dist/primitives/json.js.map +1 -0
  577. package/dist/primitives/never.d.ts +22 -0
  578. package/dist/primitives/never.d.ts.map +1 -0
  579. package/dist/primitives/never.js +2 -0
  580. package/dist/primitives/never.js.map +1 -0
  581. package/dist/primitives/snapshot.d.ts +10 -0
  582. package/dist/primitives/snapshot.d.ts.map +1 -0
  583. package/dist/primitives/snapshot.js +2 -0
  584. package/dist/primitives/snapshot.js.map +1 -0
  585. package/dist/primitives/version.d.ts +6 -0
  586. package/dist/primitives/version.d.ts.map +1 -0
  587. package/dist/primitives/version.js +2 -0
  588. package/dist/primitives/version.js.map +1 -0
  589. package/dist/provider.d.ts +19 -0
  590. package/dist/provider.js +1 -0
  591. package/dist/runtime/model-call-handle.js +2 -0
  592. package/dist/runtime/model-call-handle.js.map +1 -0
  593. package/dist/runtime/model-metadata.js +2 -0
  594. package/dist/runtime/model-metadata.js.map +1 -0
  595. package/dist/runtime/model-stream.js +2 -0
  596. package/dist/runtime/model-stream.js.map +1 -0
  597. package/dist/runtime/registry.d.ts +171 -0
  598. package/dist/runtime/registry.d.ts.map +1 -0
  599. package/dist/runtime/registry.js +2 -0
  600. package/dist/runtime/registry.js.map +1 -0
  601. package/dist/runtime/with-retry.d.ts +45 -0
  602. package/dist/runtime/with-retry.d.ts.map +1 -0
  603. package/dist/runtime/with-retry.js +2 -0
  604. package/dist/runtime/with-retry.js.map +1 -0
  605. package/dist/skills.d.ts +8 -0
  606. package/dist/skills.js +1 -0
  607. package/dist/stream/assembler.d.ts +86 -0
  608. package/dist/stream/assembler.d.ts.map +1 -0
  609. package/dist/stream/assembler.js +2 -0
  610. package/dist/stream/assembler.js.map +1 -0
  611. package/dist/stream/chunk.d.ts +135 -0
  612. package/dist/stream/chunk.d.ts.map +1 -0
  613. package/dist/stream/idle-timeout.d.ts +30 -0
  614. package/dist/stream/idle-timeout.d.ts.map +1 -0
  615. package/dist/stream/idle-timeout.js +2 -0
  616. package/dist/stream/idle-timeout.js.map +1 -0
  617. package/dist/support-safe/error.d.ts +29 -0
  618. package/dist/support-safe/error.d.ts.map +1 -0
  619. package/dist/support-safe/error.js +2 -0
  620. package/dist/support-safe/error.js.map +1 -0
  621. package/dist/tools.d.ts +15 -0
  622. package/dist/tools.js +1 -0
  623. package/package.json +96 -0
@@ -0,0 +1,70 @@
1
+ import { ToolSchema } from "../../contract/tool.js";
2
+ import { ToolDefinition, ToolExecutionMode } from "./definition.js";
3
+ //#region src/agent/tool/registry.d.ts
4
+ /** Read-only view of a set of tools. */
5
+ interface ToolCatalog {
6
+ /** Look up a tool, or `undefined` when it is absent from this view. */
7
+ get(name: string): ToolDefinition | undefined;
8
+ /** Whether this view exposes a tool by that name. */
9
+ has(name: string): boolean;
10
+ /** Every exposed name, in registration order. */
11
+ names(): readonly string[];
12
+ /** The schemas to send the model — internals stripped. */
13
+ schemas(): readonly ToolSchema[];
14
+ /** How a call to this tool may be scheduled. Fail-closed for unknown names. */
15
+ executionMode(name: string, args: unknown): ToolExecutionMode;
16
+ }
17
+ /** Which tools a view exposes. */
18
+ interface ToolFilter {
19
+ /** Expose only these. Omit to start from everything. */
20
+ allow?: readonly string[];
21
+ /** Remove these, applied after `allow`. */
22
+ deny?: readonly string[];
23
+ }
24
+ /** Codes the registry raises. */
25
+ declare const REGISTRY_ERROR_CODES: Readonly<{
26
+ readonly DUPLICATE_TOOL: 'DUPLICATE_TOOL';
27
+ readonly INVALID_TOOL: 'INVALID_TOOL';
28
+ readonly UNKNOWN_TOOL_FILTER: 'UNKNOWN_TOOL_FILTER';
29
+ }>;
30
+ /** Holds the tools an agent may call. */
31
+ declare class ToolRegistry implements ToolCatalog {
32
+ private readonly tools;
33
+ /**
34
+ * Register a tool.
35
+ * @param definition - the tool; validated before it is accepted.
36
+ * @returns a disposer that removes exactly this registration.
37
+ */
38
+ register<Args>(definition: ToolDefinition<Args>): () => void;
39
+ /**
40
+ * Register several tools atomically.
41
+ *
42
+ * All-or-nothing: if any is invalid or duplicated, none are registered, so a
43
+ * caller cannot end up with half a toolset and no indication of it.
44
+ * @param definitions - the tools.
45
+ * @returns one disposer removing all of them.
46
+ */
47
+ registerAll(definitions: readonly ToolDefinition<never>[]): () => void;
48
+ get(name: string): ToolDefinition | undefined;
49
+ has(name: string): boolean;
50
+ names(): readonly string[];
51
+ schemas(): readonly ToolSchema[];
52
+ executionMode(name: string, args: unknown): ToolExecutionMode;
53
+ /**
54
+ * A restricted view, for handing a narrower toolset to a sub-agent.
55
+ *
56
+ * Unknown names in the filter THROW rather than being ignored, because a typo in
57
+ * a deny list silently grants the capability it was meant to remove — the
58
+ * failure mode is invisible and points the wrong way.
59
+ *
60
+ * The view is a live projection, not a copy. An `allow` list is closed, so
61
+ * tools registered later stay hidden; a `deny` list is an open subtraction, so
62
+ * they appear. See {@link FilteredCatalog}.
63
+ * @param filter - which names to expose.
64
+ * @returns a read-only catalog.
65
+ */
66
+ view(filter: ToolFilter): ToolCatalog;
67
+ }
68
+ //#endregion
69
+ export { REGISTRY_ERROR_CODES, ToolCatalog, ToolFilter, ToolRegistry };
70
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","names":[],"sources":["../../../src/agent/tool/registry.ts"],"mappings":";;;;UAyBiB;;EAEf,IAAI,eAAe;;EAEnB,IAAI;;EAEJ;;EAEA,oBAAoB;;EAEpB,cAAc,cAAc,gBAAgB;;;UAI7B;;EAEf;;EAEA;;;cAIW,sBAAoB;;;;;;cAwGpB,wBAAwB;mBAClB;;;;;;EAOjB,SAAS,MAAM,YAAY,eAAe;;;;;;;;;EA2B1C,YAAY,sBAAsB;EAelC,IAAI,eAAe;EAInB,IAAI;EAIJ;EAIA,oBAAoB;EAIpB,cAAc,cAAc,gBAAgB;;;;;;;;;;;;;;EAiB5C,KAAK,QAAQ,aAAa"}
@@ -0,0 +1,2 @@
1
+ import{deepFreeze as e}from"../../primitives/freeze.js";import{AgentSdkError as t}from"../../errors/agent-sdk-error.js";import{TOOL_REGISTRY_ERROR_CODES as n}from"./config.js";import{executionModeOf as r}from"./definition.js";const i=n;function a(t){return{name:t.name,description:t.description,parameters:e(structuredClone(t.parameters))}}function o(e){if(typeof e.name!=`string`||e.name.length===0)throw new t(`a tool must have a non-empty name`,i.INVALID_TOOL);if(typeof e.description!=`string`||e.description.length===0)throw new t(`tool "${e.name}" must have a non-empty description; it is what the model reads to decide when to call it`,i.INVALID_TOOL);if(typeof e.parameters!=`object`||e.parameters===null)throw new t(`tool "${e.name}" must declare a JSON Schema object for its parameters`,i.INVALID_TOOL);if(typeof e.execute!=`function`)throw new t(`tool "${e.name}" must implement execute()`,i.INVALID_TOOL);if(e.timeoutMs!==void 0&&(!Number.isFinite(e.timeoutMs)||e.timeoutMs<=0))throw new t(`tool "${e.name}" declared a non-positive timeoutMs`,i.INVALID_TOOL)}var s=class{source;allow;deny;constructor(e,t,n){this.source=e,this.allow=t,this.deny=n}exposes(e){return this.deny.has(e)?!1:this.allow===void 0||this.allow.has(e)}get(e){return this.exposes(e)?this.source.get(e):void 0}has(e){return this.exposes(e)&&this.source.has(e)}names(){return this.source.names().filter(e=>this.exposes(e))}schemas(){return this.source.schemas().filter(e=>this.exposes(e.name))}executionMode(e,t){return r(this.get(e),t)}},c=class{tools=new Map;register(e){let n=e;if(o(n),this.tools.has(n.name))throw new t(`a tool named "${n.name}" is already registered`,i.DUPLICATE_TOOL);return this.tools.set(n.name,n),()=>{this.tools.get(n.name)===n&&this.tools.delete(n.name)}}registerAll(e){let t=[];try{for(let n of e)t.push(this.register(n))}catch(e){for(let e of t.reverse())e();throw e}return()=>{for(let e of t.reverse())e()}}get(e){return this.tools.get(e)}has(e){return this.tools.has(e)}names(){return[...this.tools.keys()]}schemas(){return[...this.tools.values()].map(a)}executionMode(e,t){return r(this.tools.get(e),t)}view(e){for(let n of[...e.allow??[],...e.deny??[]])if(!this.tools.has(n))throw new t(`tool filter names "${n}", which is not registered`,i.UNKNOWN_TOOL_FILTER);return new s(this,e.allow===void 0?void 0:new Set(e.allow),new Set(e.deny??[]))}};export{i as REGISTRY_ERROR_CODES,c as ToolRegistry};
2
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","names":[],"sources":["../../../src/agent/tool/registry.ts"],"sourcesContent":["/**\n * Where tools live, and what the model is allowed to see of them.\n *\n * The registry's one non-obvious job is the **allowlist when producing schemas**.\n * A `ToolDefinition` carries `execute`, `timeoutMs`, `isConcurrencySafe`, `render`,\n * and `meta` alongside the three fields the provider wants. Sending the object as\n * it stands would leak internal policy into the prompt — `timeoutMs` in particular\n * invites the model to reason about deadlines it has no business knowing. So\n * {@link ToolRegistry.schemas} rebuilds each entry from exactly\n * `{ name, description, parameters }`.\n *\n * @module ai-agent-sdk/agent/tool/registry\n */\n\nimport type { ToolSchema } from '../../contract/index.ts'\nimport { AgentSdkError } from '../../errors/index.ts'\nimport { deepFreeze } from '../../primitives/index.ts'\nimport {\n executionModeOf,\n type ToolDefinition,\n type ToolExecutionMode,\n} from './definition.ts'\nimport { TOOL_REGISTRY_ERROR_CODES } from './config.ts'\n\n/** Read-only view of a set of tools. */\nexport interface ToolCatalog {\n /** Look up a tool, or `undefined` when it is absent from this view. */\n get(name: string): ToolDefinition | undefined\n /** Whether this view exposes a tool by that name. */\n has(name: string): boolean\n /** Every exposed name, in registration order. */\n names(): readonly string[]\n /** The schemas to send the model — internals stripped. */\n schemas(): readonly ToolSchema[]\n /** How a call to this tool may be scheduled. Fail-closed for unknown names. */\n executionMode(name: string, args: unknown): ToolExecutionMode\n}\n\n/** Which tools a view exposes. */\nexport interface ToolFilter {\n /** Expose only these. Omit to start from everything. */\n allow?: readonly string[]\n /** Remove these, applied after `allow`. */\n deny?: readonly string[]\n}\n\n/** Codes the registry raises. */\nexport const REGISTRY_ERROR_CODES = TOOL_REGISTRY_ERROR_CODES\n\n/** Rebuild a schema with only the fields the provider should receive. */\nfunction publicSchema(definition: ToolDefinition): ToolSchema {\n return {\n name: definition.name,\n description: definition.description,\n // Snapshot and freeze: the same definition object is reused across every\n // request, and a provider adapter or a middleware that mutated `parameters`\n // in place would corrupt every later turn.\n parameters: deepFreeze(structuredClone(definition.parameters)),\n }\n}\n\nfunction assertValid(definition: ToolDefinition): void {\n if (typeof definition.name !== 'string' || definition.name.length === 0) {\n throw new AgentSdkError('a tool must have a non-empty name', REGISTRY_ERROR_CODES.INVALID_TOOL)\n }\n if (typeof definition.description !== 'string' || definition.description.length === 0) {\n // Not pedantry: the description IS the tool's interface to the model, and an\n // undescribed tool gets called wrongly or not at all.\n throw new AgentSdkError(\n `tool \"${definition.name}\" must have a non-empty description; it is what the model reads to decide when to call it`,\n REGISTRY_ERROR_CODES.INVALID_TOOL,\n )\n }\n if (typeof definition.parameters !== 'object' || definition.parameters === null) {\n throw new AgentSdkError(\n `tool \"${definition.name}\" must declare a JSON Schema object for its parameters`,\n REGISTRY_ERROR_CODES.INVALID_TOOL,\n )\n }\n if (typeof definition.execute !== 'function') {\n throw new AgentSdkError(\n `tool \"${definition.name}\" must implement execute()`,\n REGISTRY_ERROR_CODES.INVALID_TOOL,\n )\n }\n if (definition.timeoutMs !== undefined\n && (!Number.isFinite(definition.timeoutMs) || definition.timeoutMs <= 0)) {\n throw new AgentSdkError(\n `tool \"${definition.name}\" declared a non-positive timeoutMs`,\n REGISTRY_ERROR_CODES.INVALID_TOOL,\n )\n }\n}\n\n/**\n * A filtered, read-only projection of a registry.\n *\n * The two filter halves are evaluated LAZILY and mean different things, which is\n * the subtle part:\n *\n * - `allow` is a closed list — \"only these\" — so a tool registered later is not in\n * it and correctly stays hidden.\n * - `deny` is an open subtraction — \"everything except these\" — so a tool\n * registered later IS exposed.\n *\n * Snapshotting the registry's names at construction would collapse the second case\n * into the first: `view({ deny: ['exec'] })` would silently freeze the toolset,\n * and a tool added afterwards would go missing with nothing to point at.\n */\nclass FilteredCatalog implements ToolCatalog {\n private readonly source: ToolCatalog\n private readonly allow: ReadonlySet<string> | undefined\n private readonly deny: ReadonlySet<string>\n\n constructor(\n source: ToolCatalog,\n allow: ReadonlySet<string> | undefined,\n deny: ReadonlySet<string>,\n ) {\n this.source = source\n this.allow = allow\n this.deny = deny\n }\n\n private exposes(name: string): boolean {\n if (this.deny.has(name)) return false\n return this.allow === undefined || this.allow.has(name)\n }\n\n get(name: string): ToolDefinition | undefined {\n return this.exposes(name) ? this.source.get(name) : undefined\n }\n\n has(name: string): boolean {\n return this.exposes(name) && this.source.has(name)\n }\n\n names(): readonly string[] {\n return this.source.names().filter(name => this.exposes(name))\n }\n\n schemas(): readonly ToolSchema[] {\n return this.source.schemas().filter(schema => this.exposes(schema.name))\n }\n\n executionMode(name: string, args: unknown): ToolExecutionMode {\n return executionModeOf(this.get(name), args)\n }\n}\n\n/** Holds the tools an agent may call. */\nexport class ToolRegistry implements ToolCatalog {\n private readonly tools = new Map<string, ToolDefinition>()\n\n /**\n * Register a tool.\n * @param definition - the tool; validated before it is accepted.\n * @returns a disposer that removes exactly this registration.\n */\n register<Args>(definition: ToolDefinition<Args>): () => void {\n const entry = definition as ToolDefinition\n assertValid(entry)\n if (this.tools.has(entry.name)) {\n // Silently shadowing would make which implementation runs depend on import\n // order, which is invisible at the call site.\n throw new AgentSdkError(\n `a tool named \"${entry.name}\" is already registered`,\n REGISTRY_ERROR_CODES.DUPLICATE_TOOL,\n )\n }\n this.tools.set(entry.name, entry)\n return () => {\n // Guard the identity: a later re-registration under the same name must not\n // be removed by a stale disposer.\n if (this.tools.get(entry.name) === entry) this.tools.delete(entry.name)\n }\n }\n\n /**\n * Register several tools atomically.\n *\n * All-or-nothing: if any is invalid or duplicated, none are registered, so a\n * caller cannot end up with half a toolset and no indication of it.\n * @param definitions - the tools.\n * @returns one disposer removing all of them.\n */\n registerAll(definitions: readonly ToolDefinition<never>[]): () => void {\n const disposers: (() => void)[] = []\n try {\n for (const definition of definitions) {\n disposers.push(this.register(definition as ToolDefinition))\n }\n } catch (error: unknown) {\n for (const dispose of disposers.reverse()) dispose()\n throw error\n }\n return () => {\n for (const dispose of disposers.reverse()) dispose()\n }\n }\n\n get(name: string): ToolDefinition | undefined {\n return this.tools.get(name)\n }\n\n has(name: string): boolean {\n return this.tools.has(name)\n }\n\n names(): readonly string[] {\n return [...this.tools.keys()]\n }\n\n schemas(): readonly ToolSchema[] {\n return [...this.tools.values()].map(publicSchema)\n }\n\n executionMode(name: string, args: unknown): ToolExecutionMode {\n return executionModeOf(this.tools.get(name), args)\n }\n\n /**\n * A restricted view, for handing a narrower toolset to a sub-agent.\n *\n * Unknown names in the filter THROW rather than being ignored, because a typo in\n * a deny list silently grants the capability it was meant to remove — the\n * failure mode is invisible and points the wrong way.\n *\n * The view is a live projection, not a copy. An `allow` list is closed, so\n * tools registered later stay hidden; a `deny` list is an open subtraction, so\n * they appear. See {@link FilteredCatalog}.\n * @param filter - which names to expose.\n * @returns a read-only catalog.\n */\n view(filter: ToolFilter): ToolCatalog {\n for (const name of [...filter.allow ?? [], ...filter.deny ?? []]) {\n if (!this.tools.has(name)) {\n throw new AgentSdkError(\n `tool filter names \"${name}\", which is not registered`,\n REGISTRY_ERROR_CODES.UNKNOWN_TOOL_FILTER,\n )\n }\n }\n return new FilteredCatalog(\n this,\n filter.allow === undefined ? undefined : new Set(filter.allow),\n new Set(filter.deny ?? []),\n )\n }\n}\n"],"mappings":"kOA+CA,MAAa,EAAuB,EAGpC,SAAS,EAAa,EAAwC,CAC5D,MAAO,CACL,KAAM,EAAW,KACjB,YAAa,EAAW,YAIxB,WAAY,EAAW,gBAAgB,EAAW,UAAU,CAAC,CAC/D,CACF,CAEA,SAAS,EAAY,EAAkC,CACrD,GAAI,OAAO,EAAW,MAAS,UAAY,EAAW,KAAK,SAAW,EACpE,MAAM,IAAI,EAAc,oCAAqC,EAAqB,YAAY,EAEhG,GAAI,OAAO,EAAW,aAAgB,UAAY,EAAW,YAAY,SAAW,EAGlF,MAAM,IAAI,EACR,SAAS,EAAW,KAAK,2FACzB,EAAqB,YACvB,EAEF,GAAI,OAAO,EAAW,YAAe,UAAY,EAAW,aAAe,KACzE,MAAM,IAAI,EACR,SAAS,EAAW,KAAK,wDACzB,EAAqB,YACvB,EAEF,GAAI,OAAO,EAAW,SAAY,WAChC,MAAM,IAAI,EACR,SAAS,EAAW,KAAK,4BACzB,EAAqB,YACvB,EAEF,GAAI,EAAW,YAAc,IAAA,KACvB,CAAC,OAAO,SAAS,EAAW,SAAS,GAAK,EAAW,WAAa,GACtE,MAAM,IAAI,EACR,SAAS,EAAW,KAAK,qCACzB,EAAqB,YACvB,CAEJ,C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AM,KAAW,EAAU,QAAQ,EAAG,EAAQ,EACnD,MAAM,CACR,CACA,UAAa,CACX,IAAK,IAAM,KAAW,EAAU,QAAQ,EAAG,EAAQ,CACrD,CACF,CAEA,IAAI,EAA0C,CAC5C,OAAO,KAAK,MAAM,IAAI,CAAI,CAC5B,CAEA,IAAI,EAAuB,CACzB,OAAO,KAAK,MAAM,IAAI,CAAI,CAC5B,CAEA,OAA2B,CACzB,MAAO,CAAC,GAAG,KAAK,MAAM,KAAK,CAAC,CAC9B,CAEA,SAAiC,CAC/B,MAAO,CAAC,GAAG,KAAK,MAAM,OAAO,CAAC,CAAC,CAAC,IAAI,CAAY,CAClD,CAEA,cAAc,EAAc,EAAkC,CAC5D,OAAO,EAAgB,KAAK,MAAM,IAAI,CAAI,EAAG,CAAI,CACnD,CAeA,KAAK,EAAiC,CACpC,IAAK,IAAM,IAAQ,CAAC,GAAG,EAAO,OAAS,CAAC,EAAG,GAAG,EAAO,MAAQ,CAAC,CAAC,EAC7D,GAAI,CAAC,KAAK,MAAM,IAAI,CAAI,EACtB,MAAM,IAAI,EACR,sBAAsB,EAAK,4BAC3B,EAAqB,mBACvB,EAGJ,OAAO,IAAI,EACT,KACA,EAAO,QAAU,IAAA,GAAY,IAAA,GAAY,IAAI,IAAI,EAAO,KAAK,EAC7D,IAAI,IAAI,EAAO,MAAQ,CAAC,CAAC,CAC3B,CACF,CACF"}
@@ -0,0 +1,12 @@
1
+ import { JsonObject } from "../../primitives/json.js";
2
+ import { ToolDefinition } from "./definition.js";
3
+ //#region src/agent/tool/schema.d.ts
4
+ /** Adapt a schema library once: its JSON Schema and validator share one source. */
5
+ interface RuntimeSchema<T> {
6
+ readonly jsonSchema: JsonObject;
7
+ readonly parse: (value: unknown) => T;
8
+ }
9
+ declare function defineToolFromSchema<T>(schema: RuntimeSchema<T>, definition: Omit<ToolDefinition<T>, 'parameters' | 'parse'>): ToolDefinition<T>;
10
+ //#endregion
11
+ export { RuntimeSchema, defineToolFromSchema };
12
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","names":[],"sources":["../../../src/agent/tool/schema.ts"],"mappings":";;;;UAIiB,cAAc;WACpB,YAAY;WACZ,QAAQ,mBAAmB;;iBAGtB,qBAAqB,GACnC,QAAQ,cAAc,IACtB,YAAY,KAAK,eAAe,8BAC/B,eAAe"}
@@ -0,0 +1,2 @@
1
+ import{defineTool as e}from"./definition.js";function t(t,n){let r=t.parse.bind(t);return e({...n,parameters:t.jsonSchema,parse:r})}export{t as defineToolFromSchema};
2
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","names":[],"sources":["../../../src/agent/tool/schema.ts"],"sourcesContent":["import type { JsonObject } from '../../primitives/index.ts'\nimport { defineTool, type ToolDefinition } from './definition.ts'\n\n/** Adapt a schema library once: its JSON Schema and validator share one source. */\nexport interface RuntimeSchema<T> {\n readonly jsonSchema: JsonObject\n readonly parse: (value: unknown) => T\n}\n\nexport function defineToolFromSchema<T>(\n schema: RuntimeSchema<T>,\n definition: Omit<ToolDefinition<T>, 'parameters' | 'parse'>,\n): ToolDefinition<T> {\n const parse = schema.parse.bind(schema)\n return defineTool({ ...definition, parameters: schema.jsonSchema, parse })\n}\n"],"mappings":"6CASA,SAAgB,EACd,EACA,EACmB,CACnB,IAAM,EAAQ,EAAO,MAAM,KAAK,CAAM,EACtC,OAAO,EAAW,CAAE,GAAG,EAAY,WAAY,EAAO,WAAY,OAAM,CAAC,CAC3E"}
@@ -0,0 +1,25 @@
1
+ import { SdkLogger } from "../../logging/types.js";
2
+ import { ToolDefinition } from "./definition.js";
3
+ //#region src/agent/tool/source-types.d.ts
4
+ interface ToolCatalogSnapshot {
5
+ readonly revision: string;
6
+ readonly tools: readonly ToolDefinition[];
7
+ }
8
+ interface ToolSourceSnapshotOptions {
9
+ readonly signal: AbortSignal;
10
+ readonly logger: SdkLogger;
11
+ }
12
+ interface ToolSource {
13
+ readonly kind: 'tool-source';
14
+ readonly apiVersion: 1;
15
+ readonly id: string;
16
+ readonly snapshot: (options: ToolSourceSnapshotOptions) => ToolCatalogSnapshot;
17
+ }
18
+ type ToolSourceDefinition = Omit<ToolSource, 'kind' | 'apiVersion'>;
19
+ interface ToolSourceRunReference {
20
+ readonly sourceId: string;
21
+ readonly revision: string;
22
+ }
23
+ //#endregion
24
+ export { ToolCatalogSnapshot, ToolSource, ToolSourceDefinition, ToolSourceRunReference, ToolSourceSnapshotOptions };
25
+ //# sourceMappingURL=source-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-types.d.ts","names":[],"sources":["../../../src/agent/tool/source-types.ts"],"mappings":";;;UAGiB;WACN;WACA,gBAAgB;;UAGV;WACN,QAAQ;WACR,QAAQ;;UAGF;WACN;WACA;WACA;WACA,WAAW,SAAS,8BAA8B;;KAGjD,uBAAuB,KAAK;UAGvB;WACN;WACA"}
@@ -0,0 +1,63 @@
1
+ import { TokenUsage } from "../../stream/chunk.js";
2
+ import { SpanId, TraceId, createSpanId, createTraceId, traceparent } from "../../observation/context.js";
3
+ //#region src/agent/trace/trace.d.ts
4
+ interface TraceRef {
5
+ readonly traceId: TraceId;
6
+ readonly spanId: SpanId;
7
+ readonly parentSpanId: SpanId | null;
8
+ }
9
+ type AgentSpanKind = 'invoke_agent' | 'chat' | 'execute_tool' | 'compact';
10
+ type AgentSpanStatus = 'success' | 'error' | 'aborted' | 'unknown';
11
+ interface TraceSpanStart {
12
+ readonly type: 'span-start';
13
+ readonly trace: TraceRef;
14
+ readonly at: string;
15
+ readonly name: string;
16
+ readonly kind: AgentSpanKind;
17
+ readonly attributes?: Readonly<Record<string, unknown>>;
18
+ /**
19
+ * What went INTO this step, when the step has an input worth keeping.
20
+ *
21
+ * The counterpart of {@link TraceSpanEnd.output}, and bounded by whoever
22
+ * emits it: a model round's whole request can be a hundred thousand tokens,
23
+ * so what lands here is a summary of the request — the tools offered and the
24
+ * tail of the conversation — not a copy of it. A span with nothing
25
+ * interesting to declare omits the field rather than sending an empty object.
26
+ */
27
+ readonly input?: unknown;
28
+ }
29
+ interface TraceSpanEnd {
30
+ readonly type: 'span-end';
31
+ readonly trace: TraceRef;
32
+ readonly at: string;
33
+ readonly status: AgentSpanStatus;
34
+ readonly output?: unknown;
35
+ readonly usage?: TokenUsage;
36
+ readonly error?: {
37
+ readonly type: string;
38
+ readonly message: string;
39
+ readonly code?: string;
40
+ };
41
+ }
42
+ type TraceEvent = TraceSpanStart | TraceSpanEnd;
43
+ interface AgentProcessSpan {
44
+ readonly traceId: TraceId;
45
+ readonly spanId: SpanId;
46
+ readonly parentSpanId: SpanId | null;
47
+ readonly name: string;
48
+ readonly kind: AgentSpanKind;
49
+ readonly startedAt: string;
50
+ readonly durationMs: number | null;
51
+ readonly status: AgentSpanStatus;
52
+ readonly attributes?: Readonly<Record<string, unknown>>;
53
+ readonly input?: unknown;
54
+ readonly output?: unknown;
55
+ readonly usage?: TokenUsage;
56
+ readonly error?: TraceSpanEnd['error'];
57
+ readonly children: readonly AgentProcessSpan[];
58
+ }
59
+ /** Project span lifecycle events into the nested shape expected by call-graph UIs. */
60
+ declare function buildTraceTree(events: readonly TraceEvent[]): readonly AgentProcessSpan[];
61
+ //#endregion
62
+ export { AgentProcessSpan, AgentSpanKind, AgentSpanStatus, type SpanId, TraceEvent, type TraceId, TraceRef, TraceSpanEnd, TraceSpanStart, buildTraceTree };
63
+ //# sourceMappingURL=trace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace.d.ts","names":[],"sources":["../../../src/agent/trace/trace.ts"],"mappings":";;;UAMiB;WACN,SAAS;WACT,QAAQ;WACR,cAAc;;KAGb;KACA;UAEK;WACN;WACA,OAAO;WACP;WACA;WACA,MAAM;WACN,aAAa,SAAS;;;;;;;;;;WAUtB;;UAGM;WACN;WACA,OAAO;WACP;WACA,QAAQ;WACR;WACA,QAAQ;WACR;aAAmB;aAAuB;aAA0B;;;KAGnE,aAAa,iBAAiB;UAEzB;WACN,SAAS;WACT,QAAQ;WACR,cAAc;WACd;WACA,MAAM;WACN;WACA;WACA,QAAQ;WACR,aAAa,SAAS;WACtB;WACA;WACA,QAAQ;WACR,QAAQ;WACR,mBAAmB;;;iBAId,eAAe,iBAAiB,wBAAwB"}
@@ -0,0 +1,2 @@
1
+ import{deepFreeze as e}from"../../primitives/freeze.js";import{createSpanId as t,createTraceId as n}from"../../observation/context.js";function r(t){let n=[],r=new Map;for(let e of t){if(e.type===`span-start`){let t={traceId:e.trace.traceId,spanId:e.trace.spanId,parentSpanId:e.trace.parentSpanId,name:e.name,kind:e.kind,startedAt:e.at,durationMs:null,status:`unknown`,...e.attributes===void 0?{}:{attributes:e.attributes},...e.input===void 0?{}:{input:e.input},children:[]};r.set(t.spanId,t);let i=t.parentSpanId===null?void 0:r.get(t.parentSpanId);i===void 0?n.push(t):i.children.push(t);continue}let t=r.get(e.trace.spanId);if(t===void 0)continue;t.status=e.status;let i=Date.parse(t.startedAt),a=Date.parse(e.at);t.durationMs=Number.isFinite(i)&&Number.isFinite(a)?Math.max(0,a-i):null,e.output!==void 0&&(t.output=e.output),e.usage!==void 0&&(t.usage=e.usage),e.error!==void 0&&(t.error=e.error)}return e(structuredClone(n))}export{r as buildTraceTree,t as createSpanId,n as createTraceId};
2
+ //# sourceMappingURL=trace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace.js","names":[],"sources":["../../../src/agent/trace/trace.ts"],"sourcesContent":["import { deepFreeze } from '../../primitives/index.ts'\nimport { createSpanId, createTraceId, traceparent, type SpanId, type TraceId } from '../../observation/index.ts'\nimport type { TokenUsage } from '../../stream/index.ts'\nexport { createSpanId, createTraceId, traceparent }\nexport type { SpanId, TraceId }\n\nexport interface TraceRef {\n readonly traceId: TraceId\n readonly spanId: SpanId\n readonly parentSpanId: SpanId | null\n}\n\nexport type AgentSpanKind = 'invoke_agent' | 'chat' | 'execute_tool' | 'compact'\nexport type AgentSpanStatus = 'success' | 'error' | 'aborted' | 'unknown'\n\nexport interface TraceSpanStart {\n readonly type: 'span-start'\n readonly trace: TraceRef\n readonly at: string\n readonly name: string\n readonly kind: AgentSpanKind\n readonly attributes?: Readonly<Record<string, unknown>>\n /**\n * What went INTO this step, when the step has an input worth keeping.\n *\n * The counterpart of {@link TraceSpanEnd.output}, and bounded by whoever\n * emits it: a model round's whole request can be a hundred thousand tokens,\n * so what lands here is a summary of the request — the tools offered and the\n * tail of the conversation — not a copy of it. A span with nothing\n * interesting to declare omits the field rather than sending an empty object.\n */\n readonly input?: unknown\n}\n\nexport interface TraceSpanEnd {\n readonly type: 'span-end'\n readonly trace: TraceRef\n readonly at: string\n readonly status: AgentSpanStatus\n readonly output?: unknown\n readonly usage?: TokenUsage\n readonly error?: { readonly type: string; readonly message: string; readonly code?: string }\n}\n\nexport type TraceEvent = TraceSpanStart | TraceSpanEnd\n\nexport interface AgentProcessSpan {\n readonly traceId: TraceId\n readonly spanId: SpanId\n readonly parentSpanId: SpanId | null\n readonly name: string\n readonly kind: AgentSpanKind\n readonly startedAt: string\n readonly durationMs: number | null\n readonly status: AgentSpanStatus\n readonly attributes?: Readonly<Record<string, unknown>>\n readonly input?: unknown\n readonly output?: unknown\n readonly usage?: TokenUsage\n readonly error?: TraceSpanEnd['error']\n readonly children: readonly AgentProcessSpan[]\n}\n\n/** Project span lifecycle events into the nested shape expected by call-graph UIs. */\nexport function buildTraceTree(events: readonly TraceEvent[]): readonly AgentProcessSpan[] {\n interface Mutable {\n traceId: TraceId\n spanId: SpanId\n parentSpanId: SpanId | null\n name: string\n kind: AgentSpanKind\n startedAt: string\n durationMs: number | null\n status: AgentSpanStatus\n attributes?: Readonly<Record<string, unknown>>\n input?: unknown\n output?: unknown\n usage?: TokenUsage\n error?: TraceSpanEnd['error']\n children: Mutable[]\n }\n const roots: Mutable[] = []\n const byId = new Map<SpanId, Mutable>()\n for (const event of events) {\n if (event.type === 'span-start') {\n const span: Mutable = {\n traceId: event.trace.traceId,\n spanId: event.trace.spanId,\n parentSpanId: event.trace.parentSpanId,\n name: event.name,\n kind: event.kind,\n startedAt: event.at,\n durationMs: null,\n status: 'unknown',\n ...event.attributes === undefined ? {} : { attributes: event.attributes },\n ...event.input === undefined ? {} : { input: event.input },\n children: [],\n }\n byId.set(span.spanId, span)\n const parent = span.parentSpanId === null ? undefined : byId.get(span.parentSpanId)\n if (parent === undefined) roots.push(span)\n else parent.children.push(span)\n continue\n }\n const span = byId.get(event.trace.spanId)\n if (span === undefined) continue\n span.status = event.status\n const start = Date.parse(span.startedAt)\n const end = Date.parse(event.at)\n span.durationMs = Number.isFinite(start) && Number.isFinite(end) ? Math.max(0, end - start) : null\n if (event.output !== undefined) span.output = event.output\n if (event.usage !== undefined) span.usage = event.usage\n if (event.error !== undefined) span.error = event.error\n }\n return deepFreeze(structuredClone(roots))\n}\n"],"mappings":"uIAgEA,SAAgB,EAAe,EAA4D,CAiBzF,IAAM,EAAmB,CAAC,EACpB,EAAO,IAAI,IACjB,IAAK,IAAM,KAAS,EAAQ,CAC1B,GAAI,EAAM,OAAS,aAAc,CAC/B,IAAM,EAAgB,CACpB,QAAS,EAAM,MAAM,QACrB,OAAQ,EAAM,MAAM,OACpB,aAAc,EAAM,MAAM,aAC1B,KAAM,EAAM,KACZ,KAAM,EAAM,KACZ,UAAW,EAAM,GACjB,WAAY,KACZ,OAAQ,UACR,GAAG,EAAM,aAAe,IAAA,GAAY,CAAC,EAAI,CAAE,WAAY,EAAM,UAAW,EACxE,GAAG,EAAM,QAAU,IAAA,GAAY,CAAC,EAAI,CAAE,MAAO,EAAM,KAAM,EACzD,SAAU,CAAC,CACb,EACA,EAAK,IAAI,EAAK,OAAQ,CAAI,EAC1B,IAAM,EAAS,EAAK,eAAiB,KAAO,IAAA,GAAY,EAAK,IAAI,EAAK,YAAY,EAC9E,IAAW,IAAA,GAAW,EAAM,KAAK,CAAI,EACpC,EAAO,SAAS,KAAK,CAAI,EAC9B,QACF,CACA,IAAM,EAAO,EAAK,IAAI,EAAM,MAAM,MAAM,EACxC,GAAI,IAAS,IAAA,GAAW,SACxB,EAAK,OAAS,EAAM,OACpB,IAAM,EAAQ,KAAK,MAAM,EAAK,SAAS,EACjC,EAAM,KAAK,MAAM,EAAM,EAAE,EAC/B,EAAK,WAAa,OAAO,SAAS,CAAK,GAAK,OAAO,SAAS,CAAG,EAAI,KAAK,IAAI,EAAG,EAAM,CAAK,EAAI,KAC1F,EAAM,SAAW,IAAA,KAAW,EAAK,OAAS,EAAM,QAChD,EAAM,QAAU,IAAA,KAAW,EAAK,MAAQ,EAAM,OAC9C,EAAM,QAAU,IAAA,KAAW,EAAK,MAAQ,EAAM,MACpD,CACA,OAAO,EAAW,gBAAgB,CAAK,CAAC,CAC1C"}
@@ -0,0 +1,52 @@
1
+ import { SdkLogger } from "./logging/types.js";
2
+ import { AgentMessageSource } from "./message/message.js";
3
+ import { SupportSafeError, UsageCoverageSummary } from "./support-safe/error.js";
4
+ import { ToolCallPosition, ToolDefinition, ToolExecutionMode, ToolExecutionResult, ToolFailure, ToolRunContext, ToolSuccess, defineTool, executionModeOf, renderJsonValue } from "./agent/tool/definition.js";
5
+ import { MemorySpillStoreLimits, SPILL_TOOL_NAME, SpillRecord, SpillSlice, SpillStore, ToolOutputOverflowPolicy, TruncatedText, createMemorySpillStore, estimateTextBlockTokens, estimateTextTokens, previewForSpill, readSpillTool, truncateMiddleToTokens } from "./agent/tool/output-budget.js";
6
+ import { HistorySurfaceNode, projectHistorySurface, projectMessages } from "./agent/history/project.js";
7
+ import { CompactionBackoffReason, HistoryEntry, HistoryEvent, HistoryLimits, HistorySnapshot, SurfaceOp } from "./agent/history/types.js";
8
+ import { History } from "./agent/history/history.js";
9
+ import { ApprovalBroker, ApprovalDecision, ApprovalRequest, ApprovalStateStore, InteractiveApprovalBroker, InteractiveApprovalBrokerOptions, createApprovalBroker, createApprovalRequest, fixedApprovalBroker, withApprovalPersistence } from "./agent/tool/approval.js";
10
+ import { REGISTRY_ERROR_CODES, ToolCatalog, ToolFilter, ToolRegistry } from "./agent/tool/registry.js";
11
+ import { AuthorizationOutcome, AuthorizedToolCall, DispatchToolCallOptions, PostToolDecision, PreToolDecision, PreparedToolCall, ToolCallContext, ToolCallRequest, ToolInterceptor, authorizeToolCall, dispatchAuthorizedToolCall, dispatchToolCall, finalizeToolCall, prepareToolCall, toolFailure } from "./agent/tool/pipeline.js";
12
+ import { AgentProcessSpan, AgentSpanKind, AgentSpanStatus, TraceEvent, TraceRef, TraceSpanEnd, TraceSpanStart, buildTraceTree } from "./agent/trace/trace.js";
13
+ import { RunLedgerLimits, RunOperationCounts, RunUsageReport, TrackedOperationKind, UsageEstimationInput, UsageEstimator, UsagePolicy } from "./agent/accounting/report.js";
14
+ import { AgentEvent, AssistantContentTiming, BeforeStepContext, CheckpointContext, ExhaustedBudget, RequestErrorContext, StepDecision, StreamedAssistantTextPhase, TurnEndContext, TurnEndReason, TurnHooks, TurnOutcome } from "./agent/loop/events.js";
15
+ import { TurnBounds } from "./agent/loop/types.js";
16
+ import { ModelCallPolicyDecision, RunAccountingPort } from "./agent/accounting/contracts.js";
17
+ import { RunTurnOptions } from "./agent/loop/turn/types.js";
18
+ import { runTurn } from "./agent/loop/run-turn.js";
19
+ import { InteractiveUserInputBroker, InteractiveUserInputBrokerOptions, UserInputAnswer, UserInputBroker, UserInputDecision, UserInputOption, UserInputQuestion, UserInputRequest, UserInputResponse, createUserInputBroker, fixedUserInputBroker } from "./agent/mode/user-input.js";
20
+ import { AGENT_CONTROL_TOOLS, AgentMode, AgentRunEvent, AgentRunOutcome, BasicAgentOptions, CompletionSubmission, DeepAgentOptions, HumanInLoopAgentOptions, RunAgentOptions, runAgent } from "./agent/mode/run-agent.js";
21
+ import { TeamMemberAttachmentOptions, TeamPort, TeamSessionPort, TeamToolAccess } from "./agent/team/contracts.js";
22
+ import { AgentCompactionConfig, AgentCompactionOptions, resolveCompactionConfig } from "./agent/memory/compaction-config.js";
23
+ import { RunReport, RunTerminalRecord } from "./agent/accounting/delivery-types.js";
24
+ import { COMPACTION_INSTRUCTION, CompactionResult, ContextCompactor, ContextCompactorOptions } from "./agent/memory/compaction.js";
25
+ import { AgentMemory, AgentMemoryConfig, AgentMemoryConfigInput, AgentMemoryItem, AgentMemoryKind, AgentMemorySeed, AgentMemorySnapshot, resolveMemoryConfig } from "./agent/memory/memory.js";
26
+ import { MAX_SKILL_DESCRIPTION_CHARS, MAX_SKILL_ID_CHARS, MAX_SKILL_INSTRUCTIONS_CHARS, MAX_SKILL_NAME_CHARS, MAX_SKILL_RESOURCE_CHARS, MAX_SKILL_RESOURCE_PATH_CHARS, SKILL_ID_PATTERN, SkillCandidate, SkillDefinition, SkillDefinitionInput, SkillInvocationPolicy, SkillLookupOptions, SkillProvider, SkillProviderListOptions, SkillResourceBase, SkillResourceSummary, SkillSource, SkillSummary, defineSkill, defineSkillProvider, validateCandidate, validateSkillId, validateSkillResourcePath, validateSkillSource } from "./agent/skill/definition.js";
27
+ import { SkillCatalog, SkillCatalogOptions } from "./agent/skill/catalog.js";
28
+ import { AgentSkillOptions, ResolvedAgentSkillOptions, SKILL_TOOL_NAMES, createSkillTools, renderSkillCatalog, resolveSkillOptions } from "./agent/skill/tools.js";
29
+ import { AgentDefinition, AgentDefinitionInput, AgentDefinitionOverrides, CloneAgentOverrides, DefinedAgent } from "./agent/define/definition.js";
30
+ import { AgentInput, AgentInvocationOptions, AgentResponse, AgentResumeSessionOptions, AgentRunHandle, AgentRuntimeLimits, AgentSessionOptions, AgentSessionSnapshot, AgentTeamMemberOptions } from "./agent/define/session/types.js";
31
+ import { AgentSession } from "./agent/define/session.js";
32
+ import { AgentMemberOutcome, AgentMessageDelivery, AgentMessageRecord, AgentTeamEvent, AgentTeamMember, AgentTeamOptions, LinkAgentOptions, LinkedAgentResult, LinkedAgentSendInput, LinkedAgentTransport, SendAgentMessageRequest, SendAgentMessageResult } from "./agent/team/types.js";
33
+ import { AgentTeam } from "./agent/team/team.js";
34
+ import { DEFAULT_MIN_WAIT_TIMEOUT_MS, DEFAULT_WAIT_TIMEOUT_MS } from "./agent/team/common.js";
35
+ import { DefinedAgentTeam, DefinedAgentTeamMemberInput, DefinedAgentTeamOptions, createDefinedAgentTeam } from "./agent/team/composed.js";
36
+ import { normalizeToolPairing } from "./agent/history/normalize.js";
37
+ import { DEFAULT_SPAWN_SETUP_TIMEOUT_MS, DEFAULT_WORKER_CLOSE_TIMEOUT_MS, ManagedAgentRole, ManagedAgentSpawnContext, ManagedAgentSpawnRequest, ManagedAgentTeam, ManagedAgentTeamOptions, ManagedAgentWorker, ManagedAgentWorkerResult, ManagedAgentWorkerStatus, ResolvedManagedAgentSpawnRequest, WriteScopeConflictPolicy, completedHistoryPrefix, createManagedAgentTeam } from "./agent/team/managed.js";
38
+ import { AGENT_ACCOUNTING_ERROR_CODES, AgentRunError } from "./agent/accounting/error.js";
39
+ import { authoritativeTokenUsage, budgetTokenTotal, summarizeModelCallUsage } from "./agent/accounting/usage.js";
40
+ import { RunToolCallsOptions, ToolCallsOutcome, runToolCalls } from "./agent/loop/schedule.js";
41
+ import { estimateContextTokens, estimateMessageTokens } from "./agent/memory/token-estimator.js";
42
+ import { selectCompactablePrefix } from "./agent/memory/surface-compaction.js";
43
+ import { TOOL_ERROR_CODES, ToolError, ToolErrorDisposition, toolErrorDisposition } from "./agent/tool/errors.js";
44
+ import { RuntimeSchema, defineToolFromSchema } from "./agent/tool/schema.js";
45
+ import { ToolExecutionBackend, ToolExecutionCapabilities, ToolExecutionRequest, ToolExecutionStore, ToolOperation, ToolOperationClaim, createToolExecutionInterceptor, localToolExecutionBackend } from "./agent/tool/execution.js";
46
+ import { RuntimeAgent, RuntimeAgentBindingInput, RuntimeAgentDefinition, RuntimeAgentDefinitionInput, RuntimeAgentInvocationOptions, RuntimeAgentLimits, RuntimeAgentResponse, RuntimeAgentRunEvent, RuntimeAgentRunHandle, RuntimeAgentSession, RuntimeAgentSessionOptions, RuntimeAgentSessionSnapshot } from "./composition/agent/types.js";
47
+ import { cloneAgent, defineAgent } from "./composition/agent/author.js";
48
+ import { CapabilityIdentityConflict } from "./errors/capability-identity.js";
49
+ import { AgentTeamMemberInput, RuntimeAgentTeam, RuntimeAgentTeamEvent, RuntimeAgentTeamOptions } from "./composition/team/types.js";
50
+ import { AgentRuntime, AgentRuntimeOptions, RuntimeCloseReport } from "./composition/runtime/types.js";
51
+ import { createAgentRuntime } from "./composition/runtime/public.js";
52
+ export { AGENT_ACCOUNTING_ERROR_CODES, AGENT_CONTROL_TOOLS, type AgentCompactionConfig, type AgentCompactionOptions, type AgentDefinition, type AgentDefinitionInput, type AgentDefinitionOverrides, type AgentEvent, type AgentInput, type AgentInvocationOptions, type AgentMemberOutcome, AgentMemory, type AgentMemoryConfig, type AgentMemoryConfigInput, type AgentMemoryItem, type AgentMemoryKind, type AgentMemorySeed, type AgentMemorySnapshot, type AgentMessageDelivery, type AgentMessageRecord, type AgentMessageSource, type AgentMode, type AgentProcessSpan, type AgentResponse, type AgentResumeSessionOptions, AgentRunError, type AgentRunEvent, type AgentRunHandle, type AgentRunOutcome, type AgentRuntime, type AgentRuntimeLimits, type AgentRuntimeOptions, AgentSession, type AgentSessionOptions, type AgentSessionSnapshot, type AgentSkillOptions, type AgentSpanKind, type AgentSpanStatus, AgentTeam, type AgentTeamEvent, type AgentTeamMember, type AgentTeamMemberInput, type AgentTeamMemberOptions, type AgentTeamOptions, type ApprovalBroker, type ApprovalDecision, type ApprovalRequest, type ApprovalStateStore, type AssistantContentTiming, type AuthorizationOutcome, type AuthorizedToolCall, type BasicAgentOptions, type BeforeStepContext, COMPACTION_INSTRUCTION, type CapabilityIdentityConflict, type CheckpointContext, type CloneAgentOverrides, type CompactionBackoffReason, type CompactionResult, type CompletionSubmission, ContextCompactor, type ContextCompactorOptions, DEFAULT_MIN_WAIT_TIMEOUT_MS, DEFAULT_SPAWN_SETUP_TIMEOUT_MS, DEFAULT_WAIT_TIMEOUT_MS, DEFAULT_WORKER_CLOSE_TIMEOUT_MS, type DeepAgentOptions, type DefinedAgent, DefinedAgentTeam, type DefinedAgentTeamMemberInput, type DefinedAgentTeamOptions, type DispatchToolCallOptions, type ExhaustedBudget, History, type HistoryEntry, type HistoryEvent, type HistoryLimits, type HistorySnapshot, type HistorySurfaceNode, type HumanInLoopAgentOptions, type InteractiveApprovalBroker, type InteractiveApprovalBrokerOptions, type InteractiveUserInputBroker, type InteractiveUserInputBrokerOptions, type LinkAgentOptions, type LinkedAgentResult, type LinkedAgentSendInput, type LinkedAgentTransport, MAX_SKILL_DESCRIPTION_CHARS, MAX_SKILL_ID_CHARS, MAX_SKILL_INSTRUCTIONS_CHARS, MAX_SKILL_NAME_CHARS, MAX_SKILL_RESOURCE_CHARS, MAX_SKILL_RESOURCE_PATH_CHARS, type ManagedAgentRole, type ManagedAgentSpawnContext, type ManagedAgentSpawnRequest, ManagedAgentTeam, type ManagedAgentTeamOptions, type ManagedAgentWorker, type ManagedAgentWorkerResult, type ManagedAgentWorkerStatus, type MemorySpillStoreLimits, type ModelCallPolicyDecision, type PostToolDecision, type PreToolDecision, type PreparedToolCall, type RequestErrorContext, type ResolvedAgentSkillOptions, type ResolvedManagedAgentSpawnRequest, type RunAccountingPort, type RunAgentOptions, type RunLedgerLimits, type RunOperationCounts, type RunReport, type RunTerminalRecord, type RunToolCallsOptions, type RunTurnOptions, type RunUsageReport, type RuntimeAgent, type RuntimeAgentBindingInput, type RuntimeAgentDefinition, type RuntimeAgentDefinitionInput, type RuntimeAgentInvocationOptions, type RuntimeAgentLimits, type RuntimeAgentResponse, type RuntimeAgentRunEvent, type RuntimeAgentRunHandle, type RuntimeAgentSession, type RuntimeAgentSessionOptions, type RuntimeAgentSessionSnapshot, type RuntimeAgentTeam, type RuntimeAgentTeamEvent, type RuntimeAgentTeamOptions, type RuntimeCloseReport, type RuntimeSchema, SKILL_ID_PATTERN, SKILL_TOOL_NAMES, SPILL_TOOL_NAME, type SdkLogger, type SendAgentMessageRequest, type SendAgentMessageResult, type SkillCandidate, SkillCatalog, type SkillCatalogOptions, type SkillDefinition, type SkillDefinitionInput, type SkillInvocationPolicy, type SkillLookupOptions, type SkillProvider, type SkillProviderListOptions, type SkillResourceBase, type SkillResourceSummary, type SkillSource, type SkillSummary, type SpillRecord, type SpillSlice, type SpillStore, type StepDecision, type StreamedAssistantTextPhase, type SupportSafeError, type SurfaceOp, TOOL_ERROR_CODES, REGISTRY_ERROR_CODES as TOOL_REGISTRY_ERROR_CODES, type TeamMemberAttachmentOptions, type TeamPort, type TeamSessionPort, type TeamToolAccess, type ToolCallContext, type ToolCallPosition, type ToolCallRequest, type ToolCallsOutcome, type ToolCatalog, type ToolDefinition, ToolError, type ToolErrorDisposition, type ToolExecutionBackend, type ToolExecutionCapabilities, type ToolExecutionMode, type ToolExecutionRequest, type ToolExecutionResult, type ToolExecutionStore, type ToolFailure, type ToolFilter, type ToolInterceptor, type ToolOperation, type ToolOperationClaim, type ToolOutputOverflowPolicy, ToolRegistry, type ToolRunContext, type ToolSuccess, type TraceEvent, type TraceRef, type TraceSpanEnd, type TraceSpanStart, type TrackedOperationKind, type TruncatedText, type TurnBounds, type TurnEndContext, type TurnEndReason, type TurnHooks, type TurnOutcome, type UsageCoverageSummary, type UsageEstimationInput, type UsageEstimator, type UsagePolicy, type UserInputAnswer, type UserInputBroker, type UserInputDecision, type UserInputOption, type UserInputQuestion, type UserInputRequest, type UserInputResponse, type WriteScopeConflictPolicy, authoritativeTokenUsage, authorizeToolCall, budgetTokenTotal, buildTraceTree, cloneAgent, completedHistoryPrefix, createAgentRuntime, createApprovalBroker, createApprovalRequest, createDefinedAgentTeam, createManagedAgentTeam, createMemorySpillStore, createSkillTools, createToolExecutionInterceptor, createUserInputBroker, defineAgent, defineSkill, defineSkillProvider, defineTool, defineToolFromSchema, dispatchAuthorizedToolCall, dispatchToolCall, estimateContextTokens, estimateMessageTokens, estimateTextBlockTokens, estimateTextTokens, executionModeOf, finalizeToolCall, fixedApprovalBroker, fixedUserInputBroker, localToolExecutionBackend, normalizeToolPairing, prepareToolCall, previewForSpill, projectHistorySurface, projectMessages, readSpillTool, renderJsonValue, renderSkillCatalog, resolveCompactionConfig, resolveMemoryConfig, resolveSkillOptions, runAgent, runToolCalls, runTurn, selectCompactablePrefix, summarizeModelCallUsage, toolErrorDisposition, toolFailure, truncateMiddleToTokens, validateCandidate, validateSkillId, validateSkillResourcePath, validateSkillSource, withApprovalPersistence };
package/dist/agent.js ADDED
@@ -0,0 +1 @@
1
+ import{AgentMemory as e,resolveMemoryConfig as t}from"./agent/memory/memory.js";import{normalizeToolPairing as n}from"./agent/history/normalize.js";import{estimateContextTokens as r,estimateMessageTokens as i}from"./agent/memory/token-estimator.js";import{selectCompactablePrefix as a}from"./agent/memory/surface-compaction.js";import{COMPACTION_INSTRUCTION as o,ContextCompactor as s}from"./agent/memory/compaction.js";import{resolveCompactionConfig as c}from"./agent/memory/compaction-config.js";import{MAX_SKILL_DESCRIPTION_CHARS as l,MAX_SKILL_ID_CHARS as u,MAX_SKILL_INSTRUCTIONS_CHARS as d,MAX_SKILL_NAME_CHARS as f,MAX_SKILL_RESOURCE_CHARS as p,MAX_SKILL_RESOURCE_PATH_CHARS as m,SKILL_ID_PATTERN as h,defineSkill as g,defineSkillProvider as _,validateCandidate as v,validateSkillId as y,validateSkillResourcePath as b,validateSkillSource as x}from"./agent/skill/definition.js";import{SkillCatalog as S}from"./agent/skill/catalog.js";import{defineTool as C,executionModeOf as w,renderJsonValue as T}from"./agent/tool/definition.js";import{SKILL_TOOL_NAMES as E,createSkillTools as D,renderSkillCatalog as O,resolveSkillOptions as k}from"./agent/skill/tools.js";import{authoritativeTokenUsage as A,budgetTokenTotal as j,summarizeModelCallUsage as M}from"./agent/accounting/usage.js";import{REGISTRY_ERROR_CODES as N,ToolRegistry as P}from"./agent/tool/registry.js";import{projectHistorySurface as F,projectMessages as I}from"./agent/history/project.js";import{History as L}from"./agent/history/history.js";import{AGENT_ACCOUNTING_ERROR_CODES as R,AgentRunError as z}from"./agent/accounting/error.js";import{buildTraceTree as B}from"./agent/trace/trace.js";import{SPILL_TOOL_NAME as V,createMemorySpillStore as H,estimateTextBlockTokens as U,estimateTextTokens as W,previewForSpill as G,readSpillTool as K,truncateMiddleToTokens as q}from"./agent/tool/output-budget.js";import{TOOL_ERROR_CODES as J,ToolError as Y,toolErrorDisposition as X}from"./agent/tool/errors.js";import{createApprovalBroker as Z,createApprovalRequest as Q,fixedApprovalBroker as $,withApprovalPersistence as ee}from"./agent/tool/approval.js";import{authorizeToolCall as te,dispatchAuthorizedToolCall as ne,dispatchToolCall as re,finalizeToolCall as ie,prepareToolCall as ae,toolFailure as oe}from"./agent/tool/pipeline.js";import{runToolCalls as se}from"./agent/loop/schedule.js";import{runTurn as ce}from"./agent/loop/run-turn.js";import{AGENT_CONTROL_TOOLS as le,runAgent as ue}from"./agent/mode/run-agent.js";import{AgentSession as de}from"./agent/define/session.js";import{DEFAULT_MIN_WAIT_TIMEOUT_MS as fe,DEFAULT_WAIT_TIMEOUT_MS as pe}from"./agent/team/common.js";import{AgentTeam as me}from"./agent/team/team.js";import{createAgentRuntime as he}from"./composition/runtime/public.js";import{cloneAgent as ge,defineAgent as _e}from"./composition/agent/author.js";import{createUserInputBroker as ve,fixedUserInputBroker as ye}from"./agent/mode/user-input.js";import{defineToolFromSchema as be}from"./agent/tool/schema.js";import{createToolExecutionInterceptor as xe,localToolExecutionBackend as Se}from"./agent/tool/execution.js";import{DefinedAgentTeam as Ce,createDefinedAgentTeam as we}from"./agent/team/composed.js";import{DEFAULT_SPAWN_SETUP_TIMEOUT_MS as Te,DEFAULT_WORKER_CLOSE_TIMEOUT_MS as Ee,ManagedAgentTeam as De,completedHistoryPrefix as Oe,createManagedAgentTeam as ke}from"./agent/team/managed.js";export{R as AGENT_ACCOUNTING_ERROR_CODES,le as AGENT_CONTROL_TOOLS,e as AgentMemory,z as AgentRunError,de as AgentSession,me as AgentTeam,o as COMPACTION_INSTRUCTION,s as ContextCompactor,fe as DEFAULT_MIN_WAIT_TIMEOUT_MS,Te as DEFAULT_SPAWN_SETUP_TIMEOUT_MS,pe as DEFAULT_WAIT_TIMEOUT_MS,Ee as DEFAULT_WORKER_CLOSE_TIMEOUT_MS,Ce as DefinedAgentTeam,L as History,l as MAX_SKILL_DESCRIPTION_CHARS,u as MAX_SKILL_ID_CHARS,d as MAX_SKILL_INSTRUCTIONS_CHARS,f as MAX_SKILL_NAME_CHARS,p as MAX_SKILL_RESOURCE_CHARS,m as MAX_SKILL_RESOURCE_PATH_CHARS,De as ManagedAgentTeam,h as SKILL_ID_PATTERN,E as SKILL_TOOL_NAMES,V as SPILL_TOOL_NAME,S as SkillCatalog,J as TOOL_ERROR_CODES,N as TOOL_REGISTRY_ERROR_CODES,Y as ToolError,P as ToolRegistry,A as authoritativeTokenUsage,te as authorizeToolCall,j as budgetTokenTotal,B as buildTraceTree,ge as cloneAgent,Oe as completedHistoryPrefix,he as createAgentRuntime,Z as createApprovalBroker,Q as createApprovalRequest,we as createDefinedAgentTeam,ke as createManagedAgentTeam,H as createMemorySpillStore,D as createSkillTools,xe as createToolExecutionInterceptor,ve as createUserInputBroker,_e as defineAgent,g as defineSkill,_ as defineSkillProvider,C as defineTool,be as defineToolFromSchema,ne as dispatchAuthorizedToolCall,re as dispatchToolCall,r as estimateContextTokens,i as estimateMessageTokens,U as estimateTextBlockTokens,W as estimateTextTokens,w as executionModeOf,ie as finalizeToolCall,$ as fixedApprovalBroker,ye as fixedUserInputBroker,Se as localToolExecutionBackend,n as normalizeToolPairing,ae as prepareToolCall,G as previewForSpill,F as projectHistorySurface,I as projectMessages,K as readSpillTool,T as renderJsonValue,O as renderSkillCatalog,c as resolveCompactionConfig,t as resolveMemoryConfig,k as resolveSkillOptions,ue as runAgent,se as runToolCalls,ce as runTurn,a as selectCompactablePrefix,M as summarizeModelCallUsage,X as toolErrorDisposition,oe as toolFailure,q as truncateMiddleToTokens,v as validateCandidate,y as validateSkillId,b as validateSkillResourcePath,x as validateSkillSource,ee as withApprovalPersistence};
@@ -0,0 +1,6 @@
1
+ //#region src/async/settlement.d.ts
2
+ /** Bounded waiting for cooperative teardown paths. */
3
+ declare function waitForSettlement(promise: Promise<unknown>, timeoutMs: number): Promise<boolean>;
4
+ //#endregion
5
+ export { waitForSettlement };
6
+ //# sourceMappingURL=settlement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settlement.d.ts","names":[],"sources":["../../src/async/settlement.ts"],"mappings":";;iBAEsB,kBACpB,SAAS,kBACT,oBACC"}
@@ -0,0 +1,2 @@
1
+ async function e(e,t){if(!Number.isFinite(t)||t<=0)throw RangeError(`settlement timeoutMs must be a positive finite number`);let n,r=e.then(()=>!0,()=>!0),i=new Promise(e=>{n=setTimeout(()=>e(!1),t)});try{return await Promise.race([r,i])}finally{n!==void 0&&clearTimeout(n)}}export{e as waitForSettlement};
2
+ //# sourceMappingURL=settlement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settlement.js","names":[],"sources":["../../src/async/settlement.ts"],"sourcesContent":["/** Bounded waiting for cooperative teardown paths. */\n\nexport async function waitForSettlement(\n promise: Promise<unknown>,\n timeoutMs: number,\n): Promise<boolean> {\n if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {\n throw new RangeError('settlement timeoutMs must be a positive finite number')\n }\n let timer: ReturnType<typeof setTimeout> | undefined\n const settled = promise.then(() => true, () => true)\n const expired = new Promise<false>(resolve => {\n timer = setTimeout(() => resolve(false), timeoutMs)\n })\n try {\n return await Promise.race([settled, expired])\n } finally {\n if (timer !== undefined) clearTimeout(timer)\n }\n}\n"],"mappings":"AAEA,eAAsB,EACpB,EACA,EACkB,CAClB,GAAI,CAAC,OAAO,SAAS,CAAS,GAAK,GAAa,EAC9C,MAAU,WAAW,uDAAuD,EAE9E,IAAI,EACE,EAAU,EAAQ,SAAW,OAAY,EAAI,EAC7C,EAAU,IAAI,QAAe,GAAW,CAC5C,EAAQ,eAAiB,EAAQ,EAAK,EAAG,CAAS,CACpD,CAAC,EACD,GAAI,CACF,OAAO,MAAM,QAAQ,KAAK,CAAC,EAAS,CAAO,CAAC,CAC9C,QAAU,CACJ,IAAU,IAAA,IAAW,aAAa,CAAK,CAC7C,CACF"}
@@ -0,0 +1,2 @@
1
+ const e=Object.freeze({providers:128,exporters:128,routesPerProvider:128,identityBytes:256,displayNameBytes:1024,modelIdBytes:1024}),t=Object.freeze({INVALID:`MODEL_TARGET_INVALID`,UNKNOWN_ROUTE:`MODEL_ROUTE_UNAVAILABLE`,MISSING_DEFAULT:`MODEL_DEFAULT_MISSING`,AMBIGUOUS_DEFAULT:`MODEL_DEFAULT_AMBIGUOUS`});export{e as COMPOSITION_LIMITS,t as MODEL_BINDING_ERROR_CODES};
2
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","names":[],"sources":["../../../src/capability/common/config.ts"],"sourcesContent":["/** Shared resource bounds for inert capability metadata; no model/provider defaults. */\nexport const COMPOSITION_LIMITS = Object.freeze({\n providers: 128,\n exporters: 128,\n routesPerProvider: 128,\n identityBytes: 256,\n displayNameBytes: 1_024,\n modelIdBytes: 1_024,\n})\n\nexport const MODEL_BINDING_ERROR_CODES = Object.freeze({\n INVALID: 'MODEL_TARGET_INVALID',\n UNKNOWN_ROUTE: 'MODEL_ROUTE_UNAVAILABLE',\n MISSING_DEFAULT: 'MODEL_DEFAULT_MISSING',\n AMBIGUOUS_DEFAULT: 'MODEL_DEFAULT_AMBIGUOUS',\n})\n"],"mappings":"AACA,MAAa,EAAqB,OAAO,OAAO,CAC9C,UAAW,IACX,UAAW,IACX,kBAAmB,IACnB,cAAe,IACf,iBAAkB,KAClB,aAAc,IAChB,CAAC,EAEY,EAA4B,OAAO,OAAO,CACrD,QAAS,uBACT,cAAe,0BACf,gBAAiB,wBACjB,kBAAmB,yBACrB,CAAC"}
@@ -0,0 +1,2 @@
1
+ function e(e){if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(`Expected a composition data object`);return e}function t(e,t,n=!0){let r=Object.getOwnPropertyDescriptor(e,t);if(r===void 0){if(!n)return;throw TypeError(`Required composition data field is absent`)}if(!(`value`in r))throw TypeError(`Composition metadata must not use accessors`);return r.value}function n(e,t){if(typeof e!=`string`||e.length===0||e.trim()!==e||e.length>t||new TextEncoder().encode(e).byteLength>t)throw TypeError(`Invalid bounded composition text`);return e}function r(e,n){if(!Array.isArray(e))throw TypeError(`Expected a composition data array`);let r=t(e,`length`);if(!Number.isSafeInteger(r)||Number(r)<0||Number(r)>n)throw TypeError(`Composition array exceeds its bound`);let i=[];for(let n=0;n<Number(r);n++)i.push(t(e,String(n)));return Object.freeze(i)}function i(e){if(e!==void 0){if(!(e instanceof AbortSignal))throw TypeError(`Invalid AbortSignal`);return e}}function a(e,t){let n=Reflect.get(e,t);if(typeof n!=`function`)throw TypeError(`Required capability method is absent`);return(...t)=>Reflect.apply(n,e,t)}function o(e,t){let n=Reflect.get(e,t);if(n!==void 0){if(typeof n!=`function`)throw TypeError(`Optional capability method is invalid`);return(...t)=>Reflect.apply(n,e,t)}}export{r as arrayData,n as boundedText,a as capturedMethod,o as capturedOptionalMethod,e as objectValue,i as optionalAbortSignal,t as ownData};
2
+ //# sourceMappingURL=data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.js","names":[],"sources":["../../../src/capability/common/data.ts"],"sourcesContent":["/** Data fields never invoke accessors. Proxy reflection failures are handled by the caller. */\nexport function objectValue(value: unknown): object {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new TypeError('Expected a composition data object')\n }\n return value\n}\n\nexport function ownData(value: object, key: string, required = true): unknown {\n const descriptor = Object.getOwnPropertyDescriptor(value, key)\n if (descriptor === undefined) {\n if (!required) return undefined\n throw new TypeError('Required composition data field is absent')\n }\n if (!('value' in descriptor)) throw new TypeError('Composition metadata must not use accessors')\n return descriptor.value\n}\n\nexport function boundedText(value: unknown, maxBytes: number): string {\n if (typeof value !== 'string' || value.length === 0 || value.trim() !== value\n || value.length > maxBytes || new TextEncoder().encode(value).byteLength > maxBytes) {\n throw new TypeError('Invalid bounded composition text')\n }\n return value\n}\n\nexport function arrayData(value: unknown, maxItems: number): readonly unknown[] {\n if (!Array.isArray(value)) throw new TypeError('Expected a composition data array')\n const length = ownData(value, 'length')\n if (!Number.isSafeInteger(length) || Number(length) < 0 || Number(length) > maxItems) {\n throw new TypeError('Composition array exceeds its bound')\n }\n const result: unknown[] = []\n for (let index = 0; index < Number(length); index++) result.push(ownData(value, String(index)))\n return Object.freeze(result)\n}\n\nexport function optionalAbortSignal(value: unknown): AbortSignal | undefined {\n if (value === undefined) return undefined\n if (!(value instanceof AbortSignal)) throw new TypeError('Invalid AbortSignal')\n return value\n}\n\nexport function capturedMethod<Args extends readonly unknown[], Result>(\n receiver: object,\n key: string,\n): (...args: Args) => Result {\n const method: unknown = Reflect.get(receiver, key)\n if (typeof method !== 'function') throw new TypeError('Required capability method is absent')\n return (...args: Args): Result => Reflect.apply(method, receiver, args) as Result\n}\n\nexport function capturedOptionalMethod<Args extends readonly unknown[], Result>(\n receiver: object,\n key: string,\n): ((...args: Args) => Result) | undefined {\n const method: unknown = Reflect.get(receiver, key)\n if (method === undefined) return undefined\n if (typeof method !== 'function') throw new TypeError('Optional capability method is invalid')\n return (...args: Args): Result => Reflect.apply(method, receiver, args) as Result\n}\n"],"mappings":"AACA,SAAgB,EAAY,EAAwB,CAClD,GAAI,OAAO,GAAU,WAAY,GAAkB,MAAM,QAAQ,CAAK,EACpE,MAAU,UAAU,oCAAoC,EAE1D,OAAO,CACT,CAEA,SAAgB,EAAQ,EAAe,EAAa,EAAW,GAAe,CAC5E,IAAM,EAAa,OAAO,yBAAyB,EAAO,CAAG,EAC7D,GAAI,IAAe,IAAA,GAAW,CAC5B,GAAI,CAAC,EAAU,OACf,MAAU,UAAU,2CAA2C,CACjE,CACA,GAAI,EAAE,UAAW,GAAa,MAAU,UAAU,6CAA6C,EAC/F,OAAO,EAAW,KACpB,CAEA,SAAgB,EAAY,EAAgB,EAA0B,CACpE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";
2
+ import { RuntimeAgentDefinition, RuntimeAgentDefinitionInput } from "./types.js";
3
+ //#region src/composition/agent/author.d.ts
4
+ declare function defineAgent(input: RuntimeAgentDefinitionInput): RuntimeAgentDefinition;
5
+ declare function defineAgent(input: AgentDefinitionInput): DefinedAgent;
6
+ declare function cloneAgent(source: AgentDefinition, overrides: CloneAgentOverrides): DefinedAgent;
7
+ declare function cloneAgent(source: RuntimeAgentDefinition, overrides: Partial<Omit<RuntimeAgentDefinitionInput, 'id'>> & {
8
+ readonly id: string;
9
+ }): RuntimeAgentDefinition;
10
+ //#endregion
11
+ export { cloneAgent, defineAgent };
12
+ //# sourceMappingURL=author.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"author.d.ts","names":[],"sources":["../../../src/composition/agent/author.ts"],"mappings":";;;iBAYgB,YAAY,OAAO,8BAA8B;iBACjD,YAAY,OAAO,uBAAuB;iBAS1C,WAAW,QAAQ,iBAAiB,WAAW,sBAAsB;iBACrE,WACd,QAAQ,wBACR,WAAW,QAAQ,KAAK;WAAiD;IACxE"}
@@ -0,0 +1,2 @@
1
+ import{objectValue as e,ownData as t}from"../../capability/common/data.js";import{cloneAgent as n,defineAgent as r}from"../../agent/define/definition.js";import{cloneRuntimeAgentDefinition as i,defineRuntimeAgentDefinition as a}from"./definition.js";function o(e){return c(e)?a(e):r(e)}function s(e,t){return c(e)?i(e,t):n(e,t)}function c(n){let r=e(n),i=t(r,`model`,!1);if(i===void 0||typeof i==`string`)return!1;if(typeof i==`object`&&i&&!Array.isArray(i))return!0;throw TypeError(`Agent model must be a string, a model target object, or omitted`)}export{s as cloneAgent,o as defineAgent};
2
+ //# sourceMappingURL=author.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"author.js","names":["defineAdvancedAgent","cloneAdvancedAgent"],"sources":["../../../src/composition/agent/author.ts"],"sourcesContent":["import {\n cloneAgent as cloneAdvancedAgent,\n defineAgent as defineAdvancedAgent,\n type AgentDefinition,\n type AgentDefinitionInput,\n type CloneAgentOverrides,\n type DefinedAgent,\n} from '../../agent/define/definition.ts'\nimport { objectValue, ownData } from '../common/data.ts'\nimport { cloneRuntimeAgentDefinition, defineRuntimeAgentDefinition } from './definition.ts'\nimport type { RuntimeAgentDefinition, RuntimeAgentDefinitionInput } from './types.ts'\n\nexport function defineAgent(input: RuntimeAgentDefinitionInput): RuntimeAgentDefinition\nexport function defineAgent(input: AgentDefinitionInput): DefinedAgent\nexport function defineAgent(\n input: AgentDefinitionInput | RuntimeAgentDefinitionInput,\n): DefinedAgent | RuntimeAgentDefinition {\n return runtimeDiscriminant(input)\n ? defineRuntimeAgentDefinition(input as RuntimeAgentDefinitionInput)\n : defineAdvancedAgent(input as AgentDefinitionInput)\n}\n\nexport function cloneAgent(source: AgentDefinition, overrides: CloneAgentOverrides): DefinedAgent\nexport function cloneAgent(\n source: RuntimeAgentDefinition,\n overrides: Partial<Omit<RuntimeAgentDefinitionInput, 'id'>> & { readonly id: string },\n): RuntimeAgentDefinition\nexport function cloneAgent(\n source: AgentDefinition | RuntimeAgentDefinition,\n overrides: CloneAgentOverrides | (Partial<Omit<RuntimeAgentDefinitionInput, 'id'>> & { readonly id: string }),\n): DefinedAgent | RuntimeAgentDefinition {\n return runtimeDiscriminant(source)\n ? cloneRuntimeAgentDefinition(source as RuntimeAgentDefinition,\n overrides as Partial<Omit<RuntimeAgentDefinitionInput, 'id'>> & { readonly id: string })\n : cloneAdvancedAgent(source as AgentDefinition, overrides as CloneAgentOverrides)\n}\n\nfunction runtimeDiscriminant(value: unknown): boolean {\n const source = objectValue(value)\n const model = ownData(source, 'model', false)\n if (model === undefined || typeof model === 'string') return false\n if (typeof model === 'object' && model !== null && !Array.isArray(model)) return true\n throw new TypeError('Agent model must be a string, a model target object, or omitted')\n}\n"],"mappings":"0PAcA,SAAgB,EACd,EACuC,CACvC,OAAO,EAAoB,CAAK,EAC5B,EAA6B,CAAoC,EACjEA,EAAoB,CAA6B,CACvD,CAOA,SAAgB,EACd,EACA,EACuC,CACvC,OAAO,EAAoB,CAAM,EAC7B,EAA4B,EAC5B,CAAuF,EACvFC,EAAmB,EAA2B,CAAgC,CACpF,CAEA,SAAS,EAAoB,EAAyB,CACpD,IAAM,EAAS,EAAY,CAAK,EAC1B,EAAQ,EAAQ,EAAQ,QAAS,EAAK,EAC5C,GAAI,IAAU,IAAA,IAAa,OAAO,GAAU,SAAU,MAAO,GAC7D,GAAI,OAAO,GAAU,UAAY,GAAkB,CAAC,MAAM,QAAQ,CAAK,EAAG,MAAO,GACjF,MAAU,UAAU,iEAAiE,CACvF"}
@@ -0,0 +1,2 @@
1
+ import{ReasoningEffortId as e}from"../../primitives/brand.js";import{objectValue as t,ownData as n}from"../../capability/common/data.js";import{captureMemoryBinding as r}from"../memory/definition.js";import{captureRuntimeSkillSources as i}from"../../agent/skill/provider/definition.js";import{captureToolDefinitions as a}from"../../agent/tool/capture.js";import{captureModelTarget as o,resolveAgentModel as s}from"../provider/model-selection.js";import{defineAgent as c}from"../../agent/define/definition.js";import{captureToolSources as l}from"../tool-source/definition.js";import{captureNativeTools as u,captureToolChoice as d}from"./native-tools.js";import{captureRuntimeContextSections as f}from"./policy.js";import{assertAgentIdentitySnapshot as p}from"../identity/agent.js";const m=new Set([`id`,`name`,`description`,`model`,`instructions`,`effort`,`maxTokens`,`mode`,`tools`,`nativeTools`,`toolChoice`,`outputFormat`,`toolSources`,`skills`,`allowedSkillIds`,`memory`,`contextSections`,`compaction`,`maxTurns`,`maxToolCalls`,`commentary`]);function h(e){let t=v(e),n=_(e,Object.freeze({providers:Object.freeze([Object.freeze({id:`definition-author`,displayName:`Definition author`,family:`definition-author`,routes:Object.freeze([t.provider]),defaultModel:t})])})),r=n.legacy;return Object.freeze({id:r.id,name:r.name,...r.description===void 0?{}:{description:r.description},model:t,instructions:r.instructions,...n.effort===void 0?{}:{effort:n.effort},...n.maxTokens===void 0?{}:{maxTokens:n.maxTokens},mode:r.mode,tools:r.tools,nativeTools:r.nativeTools,...r.toolChoice===void 0?{}:{toolChoice:r.toolChoice},...r.outputFormat===void 0?{}:{outputFormat:r.outputFormat},toolSources:n.toolSources,skills:r.skills,...r.skillIds===void 0?{}:{allowedSkillIds:r.skillIds},...n.memory===void 0?{}:{memory:n.memory},compaction:y(r.compaction),maxTurns:r.maxTurns,maxToolCalls:r.maxToolCalls,commentary:r.commentary})}function g(e,r){let i=t(e),a=t(r);if(Reflect.ownKeys(a).some(e=>typeof e!=`string`||!m.has(e)))throw TypeError(`Runtime agent overrides contain unsupported fields`);let o=Object.create(null);for(let e of m){let t=n(a,e,!1),r=t===void 0?n(i,e,!1):t;r!==void 0&&(o[e]=r)}if(n(a,`id`,!1)===void 0)throw TypeError(`Runtime agent clone requires an id`);return h(o)}function _(o,h){let g=t(o);if(Reflect.ownKeys(g).some(e=>typeof e!=`string`||!m.has(e)))throw TypeError(`Runtime agent definition contains unsupported fields`);let _=Object.fromEntries([...m].map(e=>[e,n(g,e,!1)])),v=s(h,_.model);if(_.effort!==void 0&&typeof _.effort!=`string`)throw TypeError(`Runtime agent effort must be a string`);let y=_.effort===void 0?void 0:e(_.effort),b=_.maxTokens,x=_.tools===void 0?void 0:a(_.tools),S=l(_.toolSources),C=u(_.nativeTools),w=d(_.toolChoice),T=_.memory===void 0?void 0:r(_.memory),E=_.skills===void 0?void 0:i(_.skills),D=f(_.contextSections);p({...x===void 0?{}:{tools:x},nativeTools:C,...E===void 0?{}:{skills:E},..._.allowedSkillIds===void 0?{}:{allowedSkillIds:_.allowedSkillIds}});let O=c({id:_.id,..._.name===void 0?{}:{name:_.name},..._.description===void 0?{}:{description:_.description},provider:v.provider,model:v.id,effort:y??`medium`,...b===void 0?{}:{maxTokens:b},instructions:_.instructions,..._.mode===void 0?{}:{mode:_.mode},...x===void 0?{}:{tools:x},...C.length===0?{}:{nativeTools:C},...E===void 0?{}:{skills:E},..._.allowedSkillIds===void 0?{}:{skillIds:_.allowedSkillIds},...w===void 0?{}:{toolChoice:w},...D===void 0?{}:{contextSections:D},..._.outputFormat===void 0?{}:{outputFormat:_.outputFormat},..._.compaction===void 0?{}:{compaction:_.compaction},..._.maxTurns===void 0?{}:{maxTurns:_.maxTurns},..._.maxToolCalls===void 0?{}:{maxToolCalls:_.maxToolCalls},..._.commentary===void 0?{}:{commentary:_.commentary}});return Object.freeze({model:v,...y===void 0?{}:{effort:y},...b===void 0?{}:{maxTokens:b},legacy:O,toolSources:S,...T===void 0?{}:{memory:T}})}function v(e){let r=t(e);if(Reflect.ownKeys(r).some(e=>typeof e!=`string`||!m.has(e)))throw TypeError(`Runtime agent definition contains unsupported fields`);return o(n(r,`model`),!1)}function y(e){return e!==!1&&Object.freeze({auto:e.auto,...e.maxInputTokens===void 0?{}:{maxInputTokens:e.maxInputTokens},thresholdRatio:e.thresholdRatio,...e.retainRatio===void 0?{}:{retainRatio:e.retainRatio},...e.retainTokens===void 0?{}:{retainTokens:e.retainTokens},...e.summarizationProvider===void 0?{}:{summarizationProvider:e.summarizationProvider},...e.summarizationModel===void 0?{}:{summarizationModel:e.summarizationModel},...e.summarizationEffort===void 0?{}:{summarizationEffort:e.summarizationEffort},maxSummaryTokens:e.maxSummaryTokens,compactionRetries:e.compactionRetries,maxOverflowRetries:e.maxOverflowRetries,maxSummaryInputChars:e.maxSummaryInputChars,maxSummaryRequestChars:e.maxSummaryRequestChars,maxSummaryRequestBytes:e.maxSummaryRequestBytes,maxSummaryResponseBytes:e.maxSummaryResponseBytes,maxSummaryStreamEvents:e.maxSummaryStreamEvents,summaryTimeoutMs:e.summaryTimeoutMs,teardownTimeoutMs:e.teardownTimeoutMs,maxToolResultChars:e.maxToolResultChars})}export{_ as bindRuntimeAgentDefinition,g as cloneRuntimeAgentDefinition,h as defineRuntimeAgentDefinition};
2
+ //# sourceMappingURL=definition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.js","names":[],"sources":["../../../src/composition/agent/definition.ts"],"sourcesContent":["import { defineAgent, type DefinedAgent } from '../../agent/define/definition.ts'\nimport { ReasoningEffortId } from '../../primitives/brand.ts'\nimport { objectValue, ownData } from '../common/data.ts'\nimport { captureModelTarget, resolveAgentModel } from '../provider/model-selection.ts'\nimport type { ModelTarget, ProviderSelection } from '../provider/types.ts'\nimport type {\n RuntimeAgentBindingInput, RuntimeAgentDefinition, RuntimeAgentDefinitionInput,\n} from './types.ts'\nimport { captureToolDefinitions } from '../../agent/tool/capture.ts'\nimport { captureToolSources } from '../tool-source/definition.ts'\nimport type { CapturedToolSource } from '../tool-source/types.ts'\nimport { captureNativeTools, captureToolChoice } from './native-tools.ts'\nimport { captureMemoryBinding } from '../memory/definition.ts'\nimport type { CapturedMemoryBinding } from '../memory/types.ts'\nimport { captureRuntimeSkillSources } from '../skill-provider/definition.ts'\nimport { captureRuntimeContextSections } from './policy.ts'\nimport type { AgentCompactionConfig, AgentCompactionOptions } from '../../agent/memory/compaction-config.ts'\nimport { assertAgentIdentitySnapshot } from '../identity/agent.ts'\n\nconst KEYS = new Set(['id', 'name', 'description', 'model', 'instructions', 'effort', 'maxTokens', 'mode',\n 'tools', 'nativeTools', 'toolChoice', 'outputFormat', 'toolSources', 'skills', 'allowedSkillIds', 'memory',\n 'contextSections', 'compaction',\n 'maxTurns', 'maxToolCalls', 'commentary'])\n\nexport interface BoundRuntimeAgentDefinition {\n readonly model: ModelTarget\n readonly effort?: ReturnType<typeof ReasoningEffortId>\n readonly maxTokens?: number\n readonly legacy: DefinedAgent\n readonly toolSources: readonly CapturedToolSource[]\n readonly memory?: CapturedMemoryBinding\n}\n\n/** Validate and detach one reusable runtime definition without resolving a live provider. */\nexport function defineRuntimeAgentDefinition(input: RuntimeAgentDefinitionInput): RuntimeAgentDefinition {\n const target = captureAuthorTarget(input)\n const selection: ProviderSelection = Object.freeze({ providers: Object.freeze([Object.freeze({\n id: 'definition-author', displayName: 'Definition author', family: 'definition-author',\n routes: Object.freeze([target.provider]), defaultModel: target,\n })]) })\n const bound = bindRuntimeAgentDefinition(input, selection)\n const legacy = bound.legacy\n return Object.freeze({ id: legacy.id, name: legacy.name,\n ...(legacy.description === undefined ? {} : { description: legacy.description }),\n model: target, instructions: legacy.instructions,\n ...(bound.effort === undefined ? {} : { effort: bound.effort }),\n ...(bound.maxTokens === undefined ? {} : { maxTokens: bound.maxTokens }),\n mode: legacy.mode, tools: legacy.tools, nativeTools: legacy.nativeTools,\n ...(legacy.toolChoice === undefined ? {} : { toolChoice: legacy.toolChoice }),\n ...(legacy.outputFormat === undefined ? {} : { outputFormat: legacy.outputFormat }),\n toolSources: bound.toolSources, skills: legacy.skills,\n ...(legacy.skillIds === undefined ? {} : { allowedSkillIds: legacy.skillIds }),\n ...(bound.memory === undefined ? {} : { memory: bound.memory }),\n compaction: compactionInput(legacy.compaction), maxTurns: legacy.maxTurns,\n maxToolCalls: legacy.maxToolCalls, commentary: legacy.commentary })\n}\n\nexport function cloneRuntimeAgentDefinition(\n sourceValue: RuntimeAgentDefinition,\n overridesValue: Partial<Omit<RuntimeAgentDefinitionInput, 'id'>> & { readonly id: string },\n): RuntimeAgentDefinition {\n const source = objectValue(sourceValue), overrides = objectValue(overridesValue)\n if (Reflect.ownKeys(overrides).some(key => typeof key !== 'string' || !KEYS.has(key))) {\n throw new TypeError('Runtime agent overrides contain unsupported fields')\n }\n const merged: Record<string, unknown> = Object.create(null) as Record<string, unknown>\n for (const key of KEYS) {\n const override = ownData(overrides, key, false)\n const value = override === undefined ? ownData(source, key, false) : override\n if (value !== undefined) merged[key] = value\n }\n if (ownData(overrides, 'id', false) === undefined) throw new TypeError('Runtime agent clone requires an id')\n return defineRuntimeAgentDefinition(merged as unknown as RuntimeAgentDefinitionInput)\n}\n\n/** Capture one runtime definition and resolve its immutable target before any model operation. */\nexport function bindRuntimeAgentDefinition(\n input: RuntimeAgentBindingInput,\n selection: ProviderSelection,\n): BoundRuntimeAgentDefinition {\n const source = objectValue(input)\n if (Reflect.ownKeys(source).some(key => typeof key !== 'string' || !KEYS.has(key))) {\n throw new TypeError('Runtime agent definition contains unsupported fields')\n }\n const values = Object.fromEntries([...KEYS].map(key => [key, ownData(source, key, false)])) as Record<string, unknown>\n const target = resolveAgentModel(selection, values.model)\n if (values.effort !== undefined && typeof values.effort !== 'string') throw new TypeError('Runtime agent effort must be a string')\n const effort = values.effort === undefined ? undefined : ReasoningEffortId(values.effort)\n const maxTokens = values.maxTokens as number | undefined\n const tools = values.tools === undefined ? undefined : captureToolDefinitions(values.tools)\n const toolSources = captureToolSources(values.toolSources)\n const nativeTools = captureNativeTools(values.nativeTools)\n const toolChoice = captureToolChoice(values.toolChoice)\n const memory = values.memory === undefined ? undefined : captureMemoryBinding(values.memory)\n const skills = values.skills === undefined ? undefined : captureRuntimeSkillSources(values.skills)\n const contextSections = captureRuntimeContextSections(values.contextSections)\n assertAgentIdentitySnapshot({ ...(tools === undefined ? {} : { tools }), nativeTools,\n ...(skills === undefined ? {} : { skills }), ...(values.allowedSkillIds === undefined ? {} : {\n allowedSkillIds: values.allowedSkillIds as readonly string[],\n }) })\n const legacy = defineAgent({\n id: values.id as string,\n ...(values.name === undefined ? {} : { name: values.name as string }),\n ...(values.description === undefined ? {} : { description: values.description as string }),\n provider: target.provider, model: target.id,\n // Legacy definitions require a value; the runtime session override below preserves omission.\n effort: effort ?? 'medium',\n ...(maxTokens === undefined ? {} : { maxTokens }), instructions: values.instructions as string,\n ...(values.mode === undefined ? {} : { mode: values.mode as NonNullable<RuntimeAgentBindingInput['mode']> }),\n ...(tools === undefined ? {} : { tools }),\n ...(nativeTools.length === 0 ? {} : { nativeTools }),\n ...(skills === undefined ? {} : { skills: skills as DefinedAgent['skills'] }),\n ...(values.allowedSkillIds === undefined ? {} : { skillIds: values.allowedSkillIds as readonly string[] }),\n ...(toolChoice === undefined ? {} : { toolChoice }),\n ...(contextSections === undefined ? {} : { contextSections }),\n ...(values.outputFormat === undefined ? {} : {\n outputFormat: values.outputFormat as NonNullable<RuntimeAgentBindingInput['outputFormat']>,\n }),\n ...(values.compaction === undefined ? {} : { compaction: values.compaction as NonNullable<RuntimeAgentBindingInput['compaction']> }),\n ...(values.maxTurns === undefined ? {} : { maxTurns: values.maxTurns as number | 'auto' }),\n ...(values.maxToolCalls === undefined ? {} : { maxToolCalls: values.maxToolCalls as number }),\n ...(values.commentary === undefined ? {} : { commentary: values.commentary as NonNullable<RuntimeAgentBindingInput['commentary']> }),\n })\n return Object.freeze({ model: target, ...(effort === undefined ? {} : { effort }),\n ...(maxTokens === undefined ? {} : { maxTokens }), legacy, toolSources,\n ...(memory === undefined ? {} : { memory }) })\n}\n\nfunction captureAuthorTarget(input: RuntimeAgentDefinitionInput): ModelTarget {\n const source = objectValue(input)\n if (Reflect.ownKeys(source).some(key => typeof key !== 'string' || !KEYS.has(key))) {\n throw new TypeError('Runtime agent definition contains unsupported fields')\n }\n return captureModelTarget(ownData(source, 'model'), false)\n}\n\nfunction compactionInput(value: AgentCompactionConfig | false): AgentCompactionOptions | false {\n if (value === false) return false\n return Object.freeze({ auto: value.auto,\n ...(value.maxInputTokens === undefined ? {} : { maxInputTokens: value.maxInputTokens }),\n thresholdRatio: value.thresholdRatio,\n ...(value.retainRatio === undefined ? {} : { retainRatio: value.retainRatio }),\n ...(value.retainTokens === undefined ? {} : { retainTokens: value.retainTokens }),\n ...(value.summarizationProvider === undefined ? {} : { summarizationProvider: value.summarizationProvider }),\n ...(value.summarizationModel === undefined ? {} : { summarizationModel: value.summarizationModel }),\n ...(value.summarizationEffort === undefined ? {} : { summarizationEffort: value.summarizationEffort }),\n maxSummaryTokens: value.maxSummaryTokens, compactionRetries: value.compactionRetries,\n maxOverflowRetries: value.maxOverflowRetries, maxSummaryInputChars: value.maxSummaryInputChars,\n maxSummaryRequestChars: value.maxSummaryRequestChars, maxSummaryRequestBytes: value.maxSummaryRequestBytes,\n maxSummaryResponseBytes: value.maxSummaryResponseBytes, maxSummaryStreamEvents: value.maxSummaryStreamEvents,\n summaryTimeoutMs: value.summaryTimeoutMs, teardownTimeoutMs: value.teardownTimeoutMs,\n maxToolResultChars: value.maxToolResultCh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I,CAAE,sBAAuB,EAAM,qBAAsB,EAC1G,GAAI,EAAM,qBAAuB,IAAA,GAAY,CAAC,EAAI,CAAE,mBAAoB,EAAM,kBAAmB,EACjG,GAAI,EAAM,sBAAwB,IAAA,GAAY,CAAC,EAAI,CAAE,oBAAqB,EAAM,mBAAoB,EACpG,iBAAkB,EAAM,iBAAkB,kBAAmB,EAAM,kBACnE,mBAAoB,EAAM,mBAAoB,qBAAsB,EAAM,qBAC1E,uBAAwB,EAAM,uBAAwB,uBAAwB,EAAM,uBACpF,wBAAyB,EAAM,wBAAyB,uBAAwB,EAAM,uBACtF,iBAAkB,EAAM,iBAAkB,kBAAmB,EAAM,kBACnE,mBAAoB,EAAM,kBAAmB,CAAC,CAClD"}
@@ -0,0 +1,2 @@
1
+ import{cloneJsonValue as e}from"../common/json-data.js";import{publicContent as t}from"./public-message.js";function n(e,n){let a=r(e.arguments),o=e.content.length===0?void 0:r(t(e.content));return{type:`assistant-native-tool`,callId:e.id,provider:n,name:e.name,status:i(e.status),...a===void 0?{}:{input:a},...o===void 0?{}:{output:o}}}function r(t){if(t!==void 0)try{return e(t)}catch{return}}function i(e){return e===`started`||e===`completed`||e===`failed`?e:`unknown`}export{n as projectNativeToolEvent};
2
+ //# sourceMappingURL=native-event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-event.js","names":[],"sources":["../../../src/composition/agent/native-event.ts"],"sourcesContent":["import { publicContent } from './public-message.ts'\nimport type { NativeToolCallBlock } from '../../message/content.ts'\nimport type { JsonValue } from '../../primitives/index.ts'\nimport { cloneJsonValue } from '../common/json-data.ts'\n\nexport interface ProjectedNativeToolEvent {\n readonly type: 'assistant-native-tool'\n readonly callId: string\n readonly provider: string\n readonly name: string\n readonly status: 'started' | 'completed' | 'failed' | 'unknown'\n readonly input?: JsonValue\n readonly output?: JsonValue\n}\n\n/** Detach optional provider payloads into the same bounded JSON envelope used by composition metadata. */\nexport function projectNativeToolEvent(\n call: NativeToolCallBlock,\n provider: string,\n): ProjectedNativeToolEvent {\n const input = optionalPayload(call.arguments)\n const output = call.content.length === 0 ? undefined : optionalPayload(publicContent(call.content))\n return {\n type: 'assistant-native-tool', callId: call.id, provider, name: call.name,\n status: nativeStatus(call.status),\n ...(input === undefined ? {} : { input }),\n ...(output === undefined ? {} : { output }),\n }\n}\n\nfunction optionalPayload(value: unknown): JsonValue | undefined {\n if (value === undefined) return undefined\n try { return cloneJsonValue(value) } catch { return undefined }\n}\n\nfunction nativeStatus(value: string | undefined): ProjectedNativeToolEvent['status'] {\n return value === 'started' || value === 'completed' || value === 'failed' ? value : 'unknown'\n}\n"],"mappings":"4GAgBA,SAAgB,EACd,EACA,EAC0B,CAC1B,IAAM,EAAQ,EAAgB,EAAK,SAAS,EACtC,EAAS,EAAK,QAAQ,SAAW,EAAI,IAAA,GAAY,EAAgB,EAAc,EAAK,OAAO,CAAC,EAClG,MAAO,CACL,KAAM,wBAAyB,OAAQ,EAAK,GAAI,WAAU,KAAM,EAAK,KACrE,OAAQ,EAAa,EAAK,MAAM,EAChC,GAAI,IAAU,IAAA,GAAY,CAAC,EAAI,CAAE,OAAM,EACvC,GAAI,IAAW,IAAA,GAAY,CAAC,EAAI,CAAE,QAAO,CAC3C,CACF,CAEA,SAAS,EAAgB,EAAuC,CAC1D,OAAU,IAAA,GACd,GAAI,CAAE,OAAO,EAAe,CAAK,CAAE,MAAQ,CAAE,MAAiB,CAChE,CAEA,SAAS,EAAa,EAA+D,CACnF,OAAO,IAAU,WAAa,IAAU,aAAe,IAAU,SAAW,EAAQ,SACtF"}
@@ -0,0 +1,2 @@
1
+ import{AgentSdkError as e}from"../../errors/agent-sdk-error.js";import{arrayData as t,boundedText as n,objectValue as r,ownData as i}from"../../capability/common/data.js";import{cloneJsonObject as a}from"../common/json-data.js";const o=Object.freeze({tools:128,domains:128,textBytes:1024}),s=`NATIVE_TOOL_CONFIG_INVALID`;function c(n){if(n===void 0)return Object.freeze([]);try{return Object.freeze(t(n,o.tools).map(e=>u(e)))}catch(t){throw t instanceof e&&t.code===s?t:v(t)}}function l(e){if(e!==void 0){if(e===`auto`||e===`none`||e===`required`)return e;try{let t=r(e);_(t,[`type`,`name`]);let a=i(t,`type`),s=n(i(t,`name`),o.textBytes);if(a===`tool`||a===`native`&&(s===`web-search`||s===`image-generation`))return Object.freeze({type:a,name:s});throw v()}catch(e){throw v(e)}}}function u(e){let t=r(a(e));if(i(t,`type`)!==`native`)throw v();let n=i(t,`name`);if(n===`web-search`)return d(t);if(n===`image-generation`)return f(t);throw v()}function d(e){_(e,[`type`,`name`,`searchContextSize`,`allowedDomains`,`blockedDomains`,`userLocation`,`maxUses`]);let t=i(e,`searchContextSize`,!1);if(t!==void 0&&t!==`low`&&t!==`medium`&&t!==`high`)throw v();let n=p(i(e,`allowedDomains`,!1)),r=p(i(e,`blockedDomains`,!1)),a=m(i(e,`userLocation`,!1)),o=h(i(e,`maxUses`,!1));return Object.freeze({type:`native`,name:`web-search`,...t===void 0?{}:{searchContextSize:t},...n===void 0?{}:{allowedDomains:n},...r===void 0?{}:{blockedDomains:r},...a===void 0?{}:{userLocation:a},...o===void 0?{}:{maxUses:o}})}function f(e){_(e,[`type`,`name`,`size`,`quality`,`format`,`background`,`partialImages`]);let t=g(i(e,`size`,!1),[`auto`,`1024x1024`,`1536x1024`,`1024x1536`]),n=g(i(e,`quality`,!1),[`auto`,`low`,`medium`,`high`]),r=g(i(e,`format`,!1),[`png`,`jpeg`,`webp`]),a=g(i(e,`background`,!1),[`auto`,`transparent`,`opaque`]),o=h(i(e,`partialImages`,!1));return Object.freeze({type:`native`,name:`image-generation`,...t===void 0?{}:{size:t},...n===void 0?{}:{quality:n},...r===void 0?{}:{format:r},...a===void 0?{}:{background:a},...o===void 0?{}:{partialImages:o}})}function p(e){if(e!==void 0)return Object.freeze(t(e,o.domains).map(e=>n(e,o.textBytes)))}function m(e){if(e===void 0)return;let t=r(e);_(t,[`city`,`region`,`country`,`timezone`]);let a=e=>{let r=i(t,e,!1);return r===void 0?void 0:n(r,o.textBytes)},s=a(`city`),c=a(`region`),l=a(`country`),u=a(`timezone`);return Object.freeze({...s===void 0?{}:{city:s},...c===void 0?{}:{region:c},...l===void 0?{}:{country:l},...u===void 0?{}:{timezone:u}})}function h(e){if(e!==void 0){if(!Number.isSafeInteger(e)||Number(e)<0)throw v();return Number(e)}}function g(e,t){if(e!==void 0){if(!t.includes(e))throw v();return e}}function _(e,t){let n=new Set(t);if(Reflect.ownKeys(e).some(e=>typeof e!=`string`||!n.has(e)))throw v()}function v(t){return new e(`Provider-native tool configuration is invalid`,s,t===void 0?void 0:{cause:t})}export{c as captureNativeTools,l as captureToolChoice};
2
+ //# sourceMappingURL=native-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-tools.js","names":[],"sources":["../../../src/composition/agent/native-tools.ts"],"sourcesContent":["import type {\n NativeImageGenerationTool, NativeToolSchema, NativeWebSearchTool, ToolChoice, WebSearchLocation,\n} from '../../contract/tool.ts'\nimport { AgentSdkError } from '../../errors/agent-sdk-error.ts'\nimport { arrayData, boundedText, objectValue, ownData } from '../common/data.ts'\nimport { cloneJsonObject } from '../common/json-data.ts'\n\nconst LIMITS = Object.freeze({ tools: 128, domains: 128, textBytes: 1_024 })\nconst ERROR_CODE = 'NATIVE_TOOL_CONFIG_INVALID'\n\n/** Validate and detach provider-native configuration before model resolution/dispatch. */\nexport function captureNativeTools(value: unknown): readonly NativeToolSchema[] {\n if (value === undefined) return Object.freeze([])\n try {\n return Object.freeze(arrayData(value, LIMITS.tools).map(entry => captureNativeTool(entry)))\n } catch (error) {\n if (error instanceof AgentSdkError && error.code === ERROR_CODE) throw error\n throw invalid(error)\n }\n}\n\nexport function captureToolChoice(value: unknown): ToolChoice | undefined {\n if (value === undefined) return undefined\n if (value === 'auto' || value === 'none' || value === 'required') return value\n try {\n const source = objectValue(value)\n exactKeys(source, ['type', 'name'])\n const type = ownData(source, 'type'), name = boundedText(ownData(source, 'name'), LIMITS.textBytes)\n if (type === 'tool') return Object.freeze({ type, name })\n if (type === 'native' && (name === 'web-search' || name === 'image-generation')) {\n return Object.freeze({ type, name })\n }\n throw invalid()\n } catch (error) { throw invalid(error) }\n}\n\nfunction captureNativeTool(value: unknown): NativeToolSchema {\n const source = objectValue(cloneJsonObject(value))\n if (ownData(source, 'type') !== 'native') throw invalid()\n const name = ownData(source, 'name')\n if (name === 'web-search') return webSearch(source)\n if (name === 'image-generation') return imageGeneration(source)\n throw invalid()\n}\n\nfunction webSearch(source: object): NativeWebSearchTool {\n exactKeys(source, ['type', 'name', 'searchContextSize', 'allowedDomains', 'blockedDomains', 'userLocation', 'maxUses'])\n const context = ownData(source, 'searchContextSize', false)\n if (context !== undefined && context !== 'low' && context !== 'medium' && context !== 'high') throw invalid()\n const allowedDomains = domains(ownData(source, 'allowedDomains', false))\n const blockedDomains = domains(ownData(source, 'blockedDomains', false))\n const userLocation = location(ownData(source, 'userLocation', false))\n const maxUses = boundedInteger(ownData(source, 'maxUses', false))\n return Object.freeze({ type: 'native', name: 'web-search',\n ...(context === undefined ? {} : { searchContextSize: context }),\n ...(allowedDomains === undefined ? {} : { allowedDomains }),\n ...(blockedDomains === undefined ? {} : { blockedDomains }),\n ...(userLocation === undefined ? {} : { userLocation }),\n ...(maxUses === undefined ? {} : { maxUses }) })\n}\n\nfunction imageGeneration(source: object): NativeImageGenerationTool {\n exactKeys(source, ['type', 'name', 'size', 'quality', 'format', 'background', 'partialImages'])\n const size = choice(ownData(source, 'size', false), ['auto', '1024x1024', '1536x1024', '1024x1536'])\n const quality = choice(ownData(source, 'quality', false), ['auto', 'low', 'medium', 'high'])\n const format = choice(ownData(source, 'format', false), ['png', 'jpeg', 'webp'])\n const background = choice(ownData(source, 'background', false), ['auto', 'transparent', 'opaque'])\n const partialImages = boundedInteger(ownData(source, 'partialImages', false))\n return Object.freeze({ type: 'native', name: 'image-generation',\n ...(size === undefined ? {} : { size }), ...(quality === undefined ? {} : { quality }),\n ...(format === undefined ? {} : { format }), ...(background === undefined ? {} : { background }),\n ...(partialImages === undefined ? {} : { partialImages }) })\n}\n\nfunction domains(value: unknown): readonly string[] | undefined {\n if (value === undefined) return undefined\n return Object.freeze(arrayData(value, LIMITS.domains).map(item => boundedText(item, LIMITS.textBytes)))\n}\n\nfunction location(value: unknown): WebSearchLocation | undefined {\n if (value === undefined) return undefined\n const source = objectValue(value)\n exactKeys(source, ['city', 'region', 'country', 'timezone'])\n const field = (key: string): string | undefined => {\n const entry = ownData(source, key, false)\n return entry === undefined ? undefined : boundedText(entry, LIMITS.textBytes)\n }\n const city = field('city'), region = field('region'), country = field('country'), timezone = field('timezone')\n return Object.freeze({ ...(city === undefined ? {} : { city }), ...(region === undefined ? {} : { region }),\n ...(country === undefined ? {} : { country }), ...(timezone === undefined ? {} : { timezone }) })\n}\n\nfunction boundedInteger(value: unknown): number | undefined {\n if (value === undefined) return undefined\n if (!Number.isSafeInteger(value) || Number(value) < 0) throw invalid()\n return Number(value)\n}\n\nfunction choice<const T extends string>(value: unknown, values: readonly T[]): T | undefined {\n if (value === undefined) return undefined\n if (!values.includes(value as T)) throw invalid()\n return value as T\n}\n\nfunction exactKeys(source: object, allowed: readonly string[]): void {\n const expected = new Set(allowed)\n if (Reflect.ownKeys(source).some(key => typeof key !== 'string' || !expected.has(key))) throw invalid()\n}\n\nfunction invalid(cause?: unknown): AgentSdkError {\n return new AgentSdkError('Provider-native tool configuration is invalid', ERROR_CODE,\n cause === undefined ? undefined : { cause })\n}\n"],"mappings":"oOAOA,MAAM,EAAS,OAAO,OAAO,CAAE,MAAO,IAAK,QAAS,IAAK,UAAW,IAAM,CAAC,EACrE,EAAa,6BAGnB,SAAgB,EAAmB,EAA6C,CAC9E,GAAI,IAAU,IAAA,GAAW,OAAO,OAAO,OAAO,CAAC,CAAC,EAChD,GAAI,CACF,OAAO,OAAO,OAAO,EAAU,EAAO,EAAO,KAAK,CAAC,CAAC,IAAI,GAAS,EAAkB,CAAK,CAAC,CAAC,CAC5F,OAAS,EAAO,CAEd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AAK,GAAO,OAAO,GAAQ,UAAY,CAAC,EAAS,IAAI,CAAG,CAAC,EAAG,MAAM,EAAQ,CACxG,CAEA,SAAS,EAAQ,EAAgC,CAC/C,OAAO,IAAI,EAAc,gDAAiD,EACxE,IAAU,IAAA,GAAY,IAAA,GAAY,CAAE,OAAM,CAAC,CAC/C"}
@@ -0,0 +1,2 @@
1
+ import{objectValue as e,optionalAbortSignal as t,ownData as n}from"../../capability/common/data.js";import{captureMemoryBinding as r}from"../memory/definition.js";import{captureRuntimeSkillSources as i}from"../../agent/skill/provider/definition.js";import{captureToolDefinitions as a}from"../../agent/tool/capture.js";import{captureAdditionalInstructions as o}from"../../agent/define/instructions.js";import{captureOutputFormat as s}from"../../agent/define/output-format.js";import{captureToolSources as c}from"../tool-source/definition.js";import{captureApprovalBroker as l,captureInterceptors as u,captureRuntimeContextSections as d,captureSpillStore as f,captureTurnHooks as p,captureUsagePolicy as m,captureUserInputBroker as h}from"./policy.js";const g=new Set([`signal`,`additionalInstructions`,`onEvent`,`imagePolicy`,`structuredOutput`]),_=new Set([`conversationId`,`tools`,`toolSources`,`skills`,`memory`,`skillCwd`,`userInput`,`approvals`,`spillStore`,`interceptors`,`contextSections`,`hooks`,`usagePolicy`,`historyLimits`,`ledgerLimits`,`eventBufferLimits`,`runtimeLimits`,`compaction`]);function v(t){if(t===void 0)return Object.freeze({});let o=e(t);if(Reflect.ownKeys(o).some(e=>typeof e!=`string`||!_.has(e)))throw TypeError(`Runtime session options contain unsupported fields`);let s=Object.fromEntries([..._].map(e=>[e,n(o,e,!1)])),g=s.tools===void 0?void 0:a(s.tools),v=s.toolSources===void 0?void 0:c(s.toolSources),y=l(s.approvals),b=f(s.spillStore),x=h(s.userInput),S=u(s.interceptors),C=d(s.contextSections),w=p(s.hooks),T=m(s.usagePolicy),E=s.memory===!1||s.memory===void 0?s.memory:r(s.memory),D=s.skills===void 0?void 0:i(s.skills);return Object.freeze({...s.conversationId===void 0?{}:{conversationId:s.conversationId},...g===void 0?{}:{tools:g},...v===void 0?{}:{toolSources:v},...D===void 0?{}:{skills:D},...E===void 0?{}:{memory:E},...s.skillCwd===void 0?{}:{skillCwd:s.skillCwd},...x===void 0?{}:{userInput:x},...y===void 0?{}:{approvals:y},...b===void 0?{}:{spillStore:b},...S===void 0?{}:{interceptors:S},...C===void 0?{}:{contextSections:C},...w===void 0?{}:{hooks:w},...T===void 0?{}:{usagePolicy:T},...s.historyLimits===void 0?{}:{historyLimits:s.historyLimits},...s.ledgerLimits===void 0?{}:{ledgerLimits:s.ledgerLimits},...s.eventBufferLimits===void 0?{}:{eventBufferLimits:s.eventBufferLimits},...s.runtimeLimits===void 0?{}:{runtimeLimits:s.runtimeLimits},...s.compaction===void 0?{}:{compaction:s.compaction}})}function y(r){if(r===void 0)return Object.freeze({});let i=e(r);if(Reflect.ownKeys(i).some(e=>typeof e!=`string`||!g.has(e)))throw TypeError(`Runtime invocation options contain unsupported fields`);let a=n(i,`structuredOutput`,!1),c;if(a!==void 0){let t=e(a),r=e(n(t,`schema`)),i=n(r,`parse`);if(typeof i!=`function`)throw TypeError(`structuredOutput schema requires a synchronous parser`);let o=s({type:`json_schema`,name:n(t,`name`),schema:n(r,`jsonSchema`)});if(o.type!==`json_schema`)throw TypeError(`structuredOutput requires JSON Schema`);c=Object.freeze({name:o.name,schema:Object.freeze({jsonSchema:o.schema,parse:i.bind(r)})})}let l=n(i,`imagePolicy`,!1);if(l!==void 0&&l!==`strict`&&l!==`project`)throw TypeError(`imagePolicy must be strict or project`);let u=t(n(i,`signal`,!1)),d=o(n(i,`additionalInstructions`,!1)),f=n(i,`onEvent`,!1);if(f!==void 0&&typeof f!=`function`)throw TypeError(`Runtime event observer must be callable`);return Object.freeze({...c===void 0?{}:{structuredOutput:c},...l===void 0?{}:{imagePolicy:l},...u===void 0?{}:{signal:u},...d===void 0?{}:{additionalInstructions:d},...f===void 0?{}:{onEvent:f}})}export{y as captureInvocationOptions,v as captureRuntimeSessionOptions};
2
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","names":[],"sources":["../../../src/composition/agent/options.ts"],"sourcesContent":["import { captureOutputFormat } from '../../agent/define/output-format.ts'\nimport { objectValue, optionalAbortSignal, ownData } from '../common/data.ts'\nimport { captureAdditionalInstructions } from './instructions.ts'\nimport { captureToolDefinitions } from '../../agent/tool/capture.ts'\nimport {\n captureApprovalBroker, captureInterceptors, captureRuntimeContextSections, captureSpillStore,\n captureTurnHooks, captureUsagePolicy, captureUserInputBroker,\n} from './policy.ts'\nimport type { RuntimeAgentInvocationOptions, RuntimeAgentSessionOptions } from './types.ts'\nimport { captureToolSources } from '../tool-source/definition.ts'\nimport { captureMemoryBinding } from '../memory/definition.ts'\nimport { captureRuntimeSkillSources } from '../skill-provider/definition.ts'\n\nconst KEYS = new Set(['signal', 'additionalInstructions', 'onEvent', 'imagePolicy', 'structuredOutput'])\nconst SESSION_KEYS = new Set(['conversationId', 'tools', 'toolSources', 'skills', 'memory', 'skillCwd',\n 'userInput', 'approvals', 'spillStore', 'interceptors', 'contextSections', 'hooks', 'usagePolicy', 'historyLimits',\n 'ledgerLimits',\n 'eventBufferLimits', 'runtimeLimits', 'compaction'])\n\nexport interface CapturedInvocationOptions {\n readonly structuredOutput?: NonNullable<RuntimeAgentInvocationOptions['structuredOutput']>\n readonly imagePolicy?: 'strict' | 'project'\n readonly signal?: AbortSignal\n readonly additionalInstructions?: string\n readonly onEvent?: NonNullable<RuntimeAgentInvocationOptions['onEvent']>\n}\n\n/** Capture all session option references before any agent or capability method can run. */\nexport function captureRuntimeSessionOptions(input: unknown): RuntimeAgentSessionOptions {\n if (input === undefined) return Object.freeze({})\n const source = objectValue(input)\n if (Reflect.ownKeys(source).some(key => typeof key !== 'string' || !SESSION_KEYS.has(key))) {\n throw new TypeError('Runtime session options contain unsupported fields')\n }\n const value = Object.fromEntries([...SESSION_KEYS].map(key => [key, ownData(source, key, false)])) as Record<string, unknown>\n const tools = value.tools === undefined ? undefined : captureToolDefinitions(value.tools)\n const toolSources = value.toolSources === undefined ? undefined : captureToolSources(value.toolSources)\n const approvals = captureApprovalBroker(value.approvals)\n const spillStore = captureSpillStore(value.spillStore)\n const userInput = captureUserInputBroker(value.userInput)\n const interceptors = captureInterceptors(value.interceptors)\n const contextSections = captureRuntimeContextSections(value.contextSections)\n const hooks = captureTurnHooks(value.hooks)\n const usagePolicy = captureUsagePolicy(value.usagePolicy)\n const memory = value.memory === false || value.memory === undefined\n ? value.memory\n : captureMemoryBinding(value.memory)\n const skills = value.skills === undefined ? undefined : captureRuntimeSkillSources(value.skills)\n return Object.freeze({\n ...(value.conversationId === undefined ? {} : { conversationId: value.conversationId as string }),\n ...(tools === undefined ? {} : { tools }),\n ...(toolSources === undefined ? {} : { toolSources }),\n ...(skills === undefined ? {} : { skills }),\n ...(memory === undefined ? {} : { memory }),\n ...(value.skillCwd === undefined ? {} : { skillCwd: value.skillCwd as string }),\n ...(userInput === undefined ? {} : { userInput }),\n ...(approvals === undefined ? {} : { approvals }),\n ...(spillStore === undefined ? {} : { spillStore }),\n ...(interceptors === undefined ? {} : { interceptors }),\n ...(contextSections === undefined ? {} : { contextSections }),\n ...(hooks === undefined ? {} : { hooks }),\n ...(usagePolicy === undefined ? {} : { usagePolicy }),\n ...(value.historyLimits === undefined ? {} : {\n historyLimits: value.historyLimits as NonNullable<RuntimeAgentSessionOptions['historyLimits']>,\n }),\n ...(value.ledgerLimits === undefined ? {} : {\n ledgerLimits: value.ledgerLimits as NonNullable<RuntimeAgentSessionOptions['ledgerLimits']>,\n }),\n ...(value.eventBufferLimits === undefined ? {} : {\n eventBufferLimits: value.eventBufferLimits as NonNullable<RuntimeAgentSessionOptions['eventBufferLimits']>,\n }),\n ...(value.runtimeLimits === undefined ? {} : {\n runtimeLimits: value.runtimeLimits as NonNullable<RuntimeAgentSessionOptions['runtimeLimits']>,\n }),\n ...(value.compaction === undefined ? {} : {\n compaction: value.compaction as NonNullable<RuntimeAgentSessionOptions['compaction']>,\n }),\n })\n}\n\nexport function captureInvocationOptions(input: unknown): CapturedInvocationOptions {\n if (input === undefined) return Object.freeze({})\n const source = objectValue(input)\n if (Reflect.ownKeys(source).some(key => typeof key !== 'string' || !KEYS.has(key))) {\n throw new TypeError('Runtime invocation options contain unsupported fields')\n }\n const structured = ownData(source, 'structuredOutput', false)\n let structuredOutput: RuntimeAgentInvocationOptions['structuredOutput']\n if (structured !== undefined) {\n const output = objectValue(structured), schema = objectValue(ownData(output, 'schema'))\n const parse = ownData(schema, 'parse')\n if (typeof parse !== 'function') throw new TypeError('structuredOutput schema requires a synchronous parser')\n const format = captureOutputFormat({ type: 'json_schema', name: ownData(output, 'name') as string,\n schema: ownData(schema, 'jsonSchema') as import('../../primitives/index.ts').JsonObject })!\n if (format.type !== 'json_schema') throw new TypeError('structuredOutput requires JSON Schema')\n structuredOutput = Object.freeze({ name: format.name, schema: Object.freeze({ jsonSchema: format.schema,\n parse: parse.bind(schema) as (value: unknown) => import('../../primitives/index.ts').JsonValue }) })\n }\n const imagePolicy = ownData(source, 'imagePolicy', false)\n if (imagePolicy !== undefined && imagePolicy !== 'strict' && imagePolicy !== 'project') throw new TypeError('imagePolicy must be strict or project')\n const signal = optionalAbortSignal(ownData(source, 'signal', false))\n const additionalInstructions = captureAdditionalInstructions(ownData(source, 'additionalInstructions', false))\n const onEvent = ownData(source, 'onEvent', false)\n if (onEvent !== undefined && typeof onEvent !== 'function') throw new TypeError('Runtime event observer must be callable')\n return Object.freeze({ ...(structuredOutput === undefined ? {} : { structuredOutput }), ...(imagePolicy === undefined ? {} : { imagePolicy }), ...(signal === undefined ? {} : { signal }),\n ...(additionalInstructions === undefined ? {} : { additionalInstructions }),\n ...(onEvent === undefined ? {} : { onEvent: onEvent as NonNullable<RuntimeAgentInvocationOptions['onEvent']> }) })\n}\n"],"mappings":"8uBAaA,MAAM,EAAO,IAAI,IAAI,CAAC,SAAU,yBAA0B,UAAW,cAAe,kBAAkB,CAAC,EACjG,EAAe,IAA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
@@ -0,0 +1,2 @@
1
+ import{arrayData as e,boundedText as t,objectValue as n,ownData as r}from"../../capability/common/data.js";import{captureContextSections as i}from"../../agent/context/section.js";const a=Object.freeze({interceptors:128,contextSections:64,identityBytes:256});function o(o){if(o!==void 0)return i(e(o,a.contextSections).map(e=>{let i=n(e),o=t(r(i,`id`),a.identityBytes),s=p(i,`resolve`,!0),c=r(i,`retractionText`,!1);return{id:o,resolve:s,...c===void 0?{}:{retractionText:t(c,a.identityBytes*16)}}}))}function s(e){if(e===void 0)return;let t=p(n(e),`request`,!0);return Object.freeze({request:t})}function c(e){if(e===void 0)return;let t=p(n(e),`request`,!0);return Object.freeze({request:t})}function l(e){if(e===void 0)return;let t=n(e),r=p(t,`save`,!0),i=p(t,`read`,!0),a=p(t,`search`,!0);return Object.freeze({save:r,read:i,search:a})}function u(i){if(i!==void 0)return Object.freeze(e(i,a.interceptors).map(e=>{let i=n(e),o=t(r(i,`name`),a.identityBytes),s=p(i,`before`,!1),c=p(i,`around`,!1),l=p(i,`after`,!1);return Object.freeze({name:o,...s===void 0?{}:{before:s},...c===void 0?{}:{around:c},...l===void 0?{}:{after:l}})}))}function d(e){if(e===void 0)return;let t=n(e),r=p(t,`beforeStep`,!1),i=p(t,`onRequestError`,!1),a=p(t,`checkpoint`,!1),o=p(t,`onTurnEnd`,!1);return Object.freeze({...r===void 0?{}:{beforeStep:r},...i===void 0?{}:{onRequestError:i},...a===void 0?{}:{checkpoint:a},...o===void 0?{}:{onTurnEnd:o}})}function f(e){if(e===void 0)return;let i=n(e),o=r(i,`onMissing`,!1);if(o!==void 0&&o!==`warn`&&o!==`estimate`&&o!==`fail`)throw TypeError(`Runtime usage policy is invalid`);let s=r(i,`estimator`,!1),c=r(i,`estimateTimeoutMs`,!1);if(c!==void 0&&(typeof c!=`number`||!Number.isSafeInteger(c)||c<1||c>2147483647))throw TypeError(`Runtime usage estimateTimeoutMs is invalid`);let l;if(s!==void 0){let e=n(s),i=t(r(e,`id`),a.identityBytes),o=p(e,`estimate`,!0);l=Object.freeze({id:i,estimate:o})}return Object.freeze({...o===void 0?{}:{onMissing:o},...c===void 0?{}:{estimateTimeoutMs:c},...l===void 0?{}:{estimator:l}})}function p(e,t,n){let r;try{r=Reflect.get(e,t)}catch{throw TypeError(`Runtime policy method '${t}' could not be captured`)}if(!(r===void 0&&!n)){if(typeof r!=`function`)throw TypeError(`Runtime policy method '${t}' is invalid`);return(...t)=>Reflect.apply(r,e,t)}}export{s as captureApprovalBroker,u as captureInterceptors,o as captureRuntimeContextSections,l as captureSpillStore,d as captureTurnHooks,f as captureUsagePolicy,c as captureUserInputBroker};
2
+ //# sourceMappingURL=policy.js.map