@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,88 @@
1
+ //#region src/errors/agent-sdk-error.d.ts
2
+ /**
3
+ * Error taxonomy: a stable machine-routable `code` beside the human-readable
4
+ * `message`, plus the wording classifiers adapters share.
5
+ *
6
+ * The taxonomy is a string `code`, deliberately NOT a TypeScript enum, so a
7
+ * third-party adapter can introduce its own code without a core release. Route
8
+ * on `code`; never parse `message`.
9
+ *
10
+ * @module ai-agent-sdk/core/errors/agent-sdk-error
11
+ */
12
+ /**
13
+ * Base class for every error this SDK raises. Carries a stable `code` and
14
+ * supports `cause` chaining through the standard `ErrorOptions`.
15
+ */
16
+ declare class AgentSdkError extends Error {
17
+ /** Stable machine-routable failure class (e.g. `RATE_LIMIT`); route on this, never on `message`. */
18
+ readonly code: string;
19
+ constructor(message: string, code: string, options?: ErrorOptions);
20
+ }
21
+ /** A request was rejected because it exceeded the model's context window. */
22
+ declare const CONTEXT_WINDOW_EXCEEDED_CODE = "CONTEXT_WINDOW_EXCEEDED";
23
+ /** The account's quota, balance, or credit is exhausted  Enot a transient rate limit. */
24
+ declare const QUOTA_EXCEEDED_CODE = "QUOTA";
25
+ /**
26
+ * The response completed normally but carried no content at all.
27
+ *
28
+ * Providers occasionally emit a degenerate completion: a terminal stop with
29
+ * zero output. Adapters classify that as this failure rather than yielding an
30
+ * empty assistant message, because an empty message silently ends the turn with
31
+ * nothing for the caller or the agent loop to act on. Nothing durable was
32
+ * produced, so this IS in the default retryable set.
33
+ */
34
+ declare const EMPTY_RESPONSE_CODE = "EMPTY_RESPONSE";
35
+ /** No credential was available anywhere for the request. */
36
+ declare const MISSING_CREDENTIAL_CODE = "MISSING_CREDENTIAL";
37
+ /**
38
+ * A credential was supplied but cannot be used  Emalformed, not absent.
39
+ *
40
+ * Distinct from {@link MISSING_CREDENTIAL_CODE} because the fix differs: correct
41
+ * the stored value rather than supply one. Deliberately outside the default
42
+ * retryable set, since a malformed credential fails identically every time.
43
+ */
44
+ declare const INVALID_CREDENTIAL_CODE = "INVALID_CREDENTIAL";
45
+ /**
46
+ * Recognize context-overflow wording.
47
+ *
48
+ * Both providers report this as a generic HTTP 400, so status alone cannot
49
+ * separate "your prompt is too long" (worth compacting and retrying) from
50
+ * "your request is malformed" (worth failing). The classifier is deliberately
51
+ * narrow: it only fires when the wording names the context window, because a
52
+ * false positive would make the caller compact history to fix a schema bug.
53
+ * @param detail - provider error code/type/message text joined into one string.
54
+ * @returns true when the detail identifies a request exceeding the model context window.
55
+ */
56
+ declare function isContextWindowExceededError(detail: string): boolean;
57
+ /**
58
+ * Recognize an exhausted account quota rather than a transient request-rate limit.
59
+ *
60
+ * The distinction matters because both can arrive as HTTP 429 and their retry
61
+ * behaviour is opposite: a rate limit clears on its own, a spent balance never
62
+ * does. Checked BEFORE the 429 mapping for that reason.
63
+ * @param detail - provider error code/type/message text joined into one string.
64
+ * @returns true only for terminal quota, balance, credit, budget, or usage-limit wording.
65
+ */
66
+ declare function isQuotaExceededError(detail: string): boolean;
67
+ /**
68
+ * Render a thrown value with its full `cause` chain and `AggregateError` members.
69
+ *
70
+ * Transport wrappers are the motivation: undici surfaces a bare
71
+ * `TypeError: fetch failed` whose actual reason (DNS, TLS, ECONNRESET) lives
72
+ * only in `cause`. Diagnostic surfaces only  Enever parse the result; route on
73
+ * {@link AgentSdkError.code}.
74
+ * @param value - the caught value (`unknown` in catch clauses).
75
+ * @returns the outermost message first, each cause appended with `: ` (skipped
76
+ * when it repeats the wrapper message verbatim), and AggregateError members
77
+ * bracketed and `; `-joined.
78
+ */
79
+ declare function errorChain(value: unknown): string;
80
+ /**
81
+ * Narrow an arbitrary thrown value to an {@link AgentSdkError}.
82
+ * @param value - the caught value (`unknown` in catch clauses).
83
+ * @returns true only for real instances; duck-typed or cross-realm errors do not narrow.
84
+ */
85
+ declare function isAgentSdkError(value: unknown): value is AgentSdkError;
86
+ //#endregion
87
+ export { AgentSdkError, CONTEXT_WINDOW_EXCEEDED_CODE, EMPTY_RESPONSE_CODE, INVALID_CREDENTIAL_CODE, MISSING_CREDENTIAL_CODE, QUOTA_EXCEEDED_CODE, errorChain, isAgentSdkError, isContextWindowExceededError, isQuotaExceededError };
88
+ //# sourceMappingURL=agent-sdk-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-sdk-error.d.ts","names":[],"sources":["../../src/errors/agent-sdk-error.ts"],"mappings":";;;;;;;;;;;;;;;cAea,sBAAsB;;WAExB;EAET,YAAY,iBAAiB,cAAc,UAAU;;;cAQ1C;;cAGA;;;;;;;;;;cAWA;;cAGA;;;;;;;;cASA;;;;;;;;;;;;iBAoCG,6BAA6B;;;;;;;;;;iBAiB7B,qBAAqB;;;;;;;;;;;;;iBAoBrB,WAAW;;;;;;iBA+CX,gBAAgB,iBAAiB,SAAS"}
@@ -0,0 +1,2 @@
1
+ var e=class extends Error{code;constructor(e,t,n){super(e,n),this.code=t,this.name=new.target.name}};const t=`CONTEXT_WINDOW_EXCEEDED`,n=`QUOTA`,r=`EMPTY_RESPONSE`,i=`MISSING_CREDENTIAL`,a=`INVALID_CREDENTIAL`,o=new RegExp(String.raw`(?:^|[^a-z0-9])context[\s_-](?:length|window)[\s_-]`+String.raw`(?:exceed(?:ed|s)?|overflow(?:ed)?|limit[\s_-]exceeded)(?:$|[^a-z0-9])`,`i`),s=new RegExp(String.raw`\b(?:request|prompt|input|messages?)\s+(?:is\s+|are\s+)?`+String.raw`too\s+(?:large|long)\s+for\s+(?:(?:this|the)\s+)?`+String.raw`(?:model(?:'s)?\s+)?context(?:\s+window)?\b`,`i`),c=new RegExp(String.raw`\b(?:input|prompt|request|messages?)\b.{0,40}`+String.raw`\b(?:exceed(?:s|ed)?|overflows?|is\s+larger\s+than)\b.{0,40}`+String.raw`\b(?:the\s+)?(?:model(?:'s)?\s+)?context(?:\s+(?:length|window))?\b`,`i`);function l(e){return o.test(e)||/\b(?:maximum|max)(?:\s+(?:allowed|supported))?\s+context\s+(?:length|window)\b/i.test(e)||s.test(e)||/\b(?:input|prompt|request)\s+(?:is\s+)?too\s+(?:long|large)\s+for\s+(?:this|the)\s+model\b/i.test(e)||c.test(e)}function u(e){return/\binsufficient[\s_-]+(?:quota|balance|credits?)\b/i.test(e)||/\b(?:quota|usage[\s_-]+limit)[\s_-]+(?:exceeded|exhausted|reached)\b/i.test(e)||/\bexceed(?:ed|s)?[\s_-]+(?:(?:your|the)[\s_-]+)?(?:current[\s_-]+)?quota\b/i.test(e)||/\b(?:balance|credits?)[\s_-]+(?:exhausted|depleted)\b/i.test(e)||/\bout[\s_-]+of[\s_-]+(?:credits?|budget)\b/i.test(e)}function d(e){let t=new Set,n=e=>{if(t.has(e))return`<circular cause>`;t.add(e);try{if(!(e instanceof Error)){if(typeof e==`object`&&e){let t=Object.getOwnPropertyDescriptor(e,`message`);if(t!==void 0&&`value`in t&&typeof t.value==`string`)return t.value}return String(e)}let t=e.message===``?e.name:e.message,r=e instanceof AggregateError&&e.errors.length>0?` [${e.errors.map(n).join(`; `)}]`:``,i=e.cause===void 0||e.cause===null?``:n(e.cause);return`${t}${r}${i===``||i===t?``:`: ${i}`}`}catch{return`<unrenderable value>`}finally{t.delete(e)}};return n(e)}function f(t){return t instanceof e}export{e as AgentSdkError,t as CONTEXT_WINDOW_EXCEEDED_CODE,r as EMPTY_RESPONSE_CODE,a as INVALID_CREDENTIAL_CODE,i as MISSING_CREDENTIAL_CODE,n as QUOTA_EXCEEDED_CODE,d as errorChain,f as isAgentSdkError,l as isContextWindowExceededError,u as isQuotaExceededError};
2
+ //# sourceMappingURL=agent-sdk-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-sdk-error.js","names":[],"sources":["../../src/errors/agent-sdk-error.ts"],"sourcesContent":["/**\n * Error taxonomy: a stable machine-routable `code` beside the human-readable\n * `message`, plus the wording classifiers adapters share.\n *\n * The taxonomy is a string `code`, deliberately NOT a TypeScript enum, so a\n * third-party adapter can introduce its own code without a core release. Route\n * on `code`; never parse `message`.\n *\n * @module ai-agent-sdk/core/errors/agent-sdk-error\n */\n\n/**\n * Base class for every error this SDK raises. Carries a stable `code` and\n * supports `cause` chaining through the standard `ErrorOptions`.\n */\nexport class AgentSdkError extends Error {\n /** Stable machine-routable failure class (e.g. `RATE_LIMIT`); route on this, never on `message`. */\n readonly code: string\n\n constructor(message: string, code: string, options?: ErrorOptions) {\n super(message, options)\n this.code = code\n this.name = new.target.name\n }\n}\n\n/** A request was rejected because it exceeded the model's context window. */\nexport const CONTEXT_WINDOW_EXCEEDED_CODE = 'CONTEXT_WINDOW_EXCEEDED'\n\n/** The account's quota, balance, or credit is exhausted  Enot a transient rate limit. */\nexport const QUOTA_EXCEEDED_CODE = 'QUOTA'\n\n/**\n * The response completed normally but carried no content at all.\n *\n * Providers occasionally emit a degenerate completion: a terminal stop with\n * zero output. Adapters classify that as this failure rather than yielding an\n * empty assistant message, because an empty message silently ends the turn with\n * nothing for the caller or the agent loop to act on. Nothing durable was\n * produced, so this IS in the default retryable set.\n */\nexport const EMPTY_RESPONSE_CODE = 'EMPTY_RESPONSE'\n\n/** No credential was available anywhere for the request. */\nexport const MISSING_CREDENTIAL_CODE = 'MISSING_CREDENTIAL'\n\n/**\n * A credential was supplied but cannot be used  Emalformed, not absent.\n *\n * Distinct from {@link MISSING_CREDENTIAL_CODE} because the fix differs: correct\n * the stored value rather than supply one. Deliberately outside the default\n * retryable set, since a malformed credential fails identically every time.\n */\nexport const INVALID_CREDENTIAL_CODE = 'INVALID_CREDENTIAL'\n\n/** Structured codes and phrases that explicitly name a context bound being exceeded. */\nconst STRUCTURED_CONTEXT_OVERFLOW = new RegExp(\n String.raw`(?:^|[^a-z0-9])context[\\s_-](?:length|window)[\\s_-]`\n + String.raw`(?:exceed(?:ed|s)?|overflow(?:ed)?|limit[\\s_-]exceeded)(?:$|[^a-z0-9])`,\n 'i',\n)\n\n/** Request-size wording that ties \"too large\" directly to model context capacity. */\nconst TOO_LARGE_FOR_CONTEXT = new RegExp(\n String.raw`\\b(?:request|prompt|input|messages?)\\s+(?:is\\s+|are\\s+)?`\n + String.raw`too\\s+(?:large|long)\\s+for\\s+(?:(?:this|the)\\s+)?`\n + String.raw`(?:model(?:'s)?\\s+)?context(?:\\s+window)?\\b`,\n 'i',\n)\n\n/** \"Exceeds\" wording is only safe to classify when its object is explicitly the model context. */\nconst EXCEEDS_MODEL_CONTEXT = new RegExp(\n String.raw`\\b(?:input|prompt|request|messages?)\\b.{0,40}`\n + String.raw`\\b(?:exceed(?:s|ed)?|overflows?|is\\s+larger\\s+than)\\b.{0,40}`\n + String.raw`\\b(?:the\\s+)?(?:model(?:'s)?\\s+)?context(?:\\s+(?:length|window))?\\b`,\n 'i',\n)\n\n/**\n * Recognize context-overflow wording.\n *\n * Both providers report this as a generic HTTP 400, so status alone cannot\n * separate \"your prompt is too long\" (worth compacting and retrying) from\n * \"your request is malformed\" (worth failing). The classifier is deliberately\n * narrow: it only fires when the wording names the context window, because a\n * false positive would make the caller compact history to fix a schema bug.\n * @param detail - provider error code/type/message text joined into one string.\n * @returns true when the detail identifies a request exceeding the model context window.\n */\nexport function isContextWindowExceededError(detail: string): boolean {\n return STRUCTURED_CONTEXT_OVERFLOW.test(detail)\n || /\\b(?:maximum|max)(?:\\s+(?:allowed|supported))?\\s+context\\s+(?:length|window)\\b/i.test(detail)\n || TOO_LARGE_FOR_CONTEXT.test(detail)\n || /\\b(?:input|prompt|request)\\s+(?:is\\s+)?too\\s+(?:long|large)\\s+for\\s+(?:this|the)\\s+model\\b/i.test(detail)\n || EXCEEDS_MODEL_CONTEXT.test(detail)\n}\n\n/**\n * Recognize an exhausted account quota rather than a transient request-rate limit.\n *\n * The distinction matters because both can arrive as HTTP 429 and their retry\n * behaviour is opposite: a rate limit clears on its own, a spent balance never\n * does. Checked BEFORE the 429 mapping for that reason.\n * @param detail - provider error code/type/message text joined into one string.\n * @returns true only for terminal quota, balance, credit, budget, or usage-limit wording.\n */\nexport function isQuotaExceededError(detail: string): boolean {\n return /\\binsufficient[\\s_-]+(?:quota|balance|credits?)\\b/i.test(detail)\n || /\\b(?:quota|usage[\\s_-]+limit)[\\s_-]+(?:exceeded|exhausted|reached)\\b/i.test(detail)\n || /\\bexceed(?:ed|s)?[\\s_-]+(?:(?:your|the)[\\s_-]+)?(?:current[\\s_-]+)?quota\\b/i.test(detail)\n || /\\b(?:balance|credits?)[\\s_-]+(?:exhausted|depleted)\\b/i.test(detail)\n || /\\bout[\\s_-]+of[\\s_-]+(?:credits?|budget)\\b/i.test(detail)\n}\n\n/**\n * Render a thrown value with its full `cause` chain and `AggregateError` members.\n *\n * Transport wrappers are the motivation: undici surfaces a bare\n * `TypeError: fetch failed` whose actual reason (DNS, TLS, ECONNRESET) lives\n * only in `cause`. Diagnostic surfaces only  Enever parse the result; route on\n * {@link AgentSdkError.code}.\n * @param value - the caught value (`unknown` in catch clauses).\n * @returns the outermost message first, each cause appended with `: ` (skipped\n * when it repeats the wrapper message verbatim), and AggregateError members\n * bracketed and `; `-joined.\n */\nexport function errorChain(value: unknown): string {\n // Tracks the ACTIVE recursion path (entries removed on exit), so only true\n // cycles are flagged and a diamond-shared cause still renders in full.\n const path = new Set<unknown>()\n const render = (current: unknown): string => {\n if (path.has(current)) return '<circular cause>'\n path.add(current)\n try {\n if (!(current instanceof Error)) {\n if (typeof current === 'object' && current !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(current, 'message')\n if (descriptor !== undefined && 'value' in descriptor && typeof descriptor.value === 'string') {\n return descriptor.value\n }\n }\n return String(current)\n }\n const message = current.message === '' ? current.name : current.message\n const members = current instanceof AggregateError && current.errors.length > 0\n ? ` [${current.errors.map(render).join('; ')}]`\n : ''\n const causeText = current.cause === undefined || current.cause === null\n ? ''\n : render(current.cause)\n // Wrappers built as `new AgentSdkError(String(value), code, { cause: value })`\n // repeat their cause verbatim; rendering it twice would only add noise.\n const cause = causeText === '' || causeText === message ? '' : `: ${causeText}`\n return `${message}${members}${cause}`\n } catch {\n // Only hostile coercion reaches here: a throwing toString/Symbol.toPrimitive\n // on a non-Error, or a throwing message/name/cause getter on an Error\n // subclass from a third-party SDK. This renderer feeds logs and user-facing\n // notices, so nothing may escape it. Inner frames catch their own throws,\n // so one hostile node collapses without taking the whole chain with it.\n return '<unrenderable value>'\n } finally {\n path.delete(current)\n }\n }\n return render(value)\n}\n\n/**\n * Narrow an arbitrary thrown value to an {@link AgentSdkError}.\n * @param value - the caught value (`unknown` in catch clauses).\n * @returns true only for real instances; duck-typed or cross-realm errors do not narrow.\n */\nexport function isAgentSdkError(value: unknown): value is AgentSdkError {\n return value instanceof AgentSdkError\n}\n"],"mappings":"AAeA,IAAa,EAAb,cAAmC,KAAM,CAEvC,KAEA,YAAY,EAAiB,EAAc,EAAwB,CACjE,MAAM,EAAS,CAAO,EACtB,KAAK,KAAO,EACZ,KAAK,KAAO,WAAW,IACzB,CACF,EAGA,MAAa,EAA+B,0BAG/B,EAAsB,QAWtB,EAAsB,iBAGtB,EAA0B,qBAS1B,EAA0B,qBAGjC,EAA8B,IAAI,OACtC,OAAO,GAAG,sDACR,OAAO,GAAG,yEACZ,GACF,EAGM,EAAwB,IAAI,OAChC,OAAO,GAAG,2DACR,OAAO,GAAG,oDACV,OAAO,GAAG,8CACZ,GACF,EAGM,EAAwB,IAAI,OAChC,OAAO,GAAG,gDACR,OAAO,GAAG,+DACV,OAAO,GAAG,sEACZ,GACF,EAaA,SAAgB,EAA6B,EAAyB,CACpE,OAAO,EAA4B,KAAK,CAAM,GACzC,kFAAkF,KAAK,CAAM,GAC7F,EAAsB,KAAK,CAAM,GACjC,8FAA8F,KAAK,CAAM,GACzG,EAAsB,KAAK,CAAM,CACxC,CAWA,SAAgB,EAAqB,EAAyB,CAC5D,MAAO,qDAAqD,KAAK,CAAM,GAClE,wEAAwE,KAAK,CAAM,GACnF,8EAA8E,KAAK,CAAM,GACzF,yDAAyD,KAAK,CAAM,GACpE,8CAA8C,KAAK,CAAM,CAChE,CAcA,SAAgB,EAAW,EAAwB,CAGjD,IAAM,EAAO,IAAI,IACX,EAAU,GAA6B,CAC3C,GAAI,EAAK,IAAI,CAAO,EAAG,MAAO,mBAC9B,EAAK,IAAI,CAAO,EAChB,GAAI,CACF,GAAI,EAAE,aAAmB,OAAQ,CAC/B,GAAI,OAAO,GAAY,UAAY,EAAkB,CACnD,IAAM,EAAa,OAAO,yBAAyB,EAAS,SAAS,EACrE,GAAI,IAAe,IAAA,IAAa,UAAW,GAAc,OAAO,EAAW,OAAU,SACnF,OAAO,EAAW,KAEtB,CACA,OAAO,OAAO,CAAO,CACvB,CACA,IAAM,EAAU,EAAQ,UAAY,GAAK,EAAQ,KAAO,EAAQ,QAC1D,EAAU,aAAmB,gBAAkB,EAAQ,OAAO,OAAS,EACzE,KAAK,EAAQ,OAAO,IAAI,CAAM,CAAC,CAAC,KAAK,IAAI,EAAE,GAC3C,GACE,EAAY,EAAQ,QAAU,IAAA,IAAa,EAAQ,QAAU,KAC/D,GACA,EAAO,EAAQ,KAAK,EAIxB,MAAO,GAAG,IAAU,IADN,IAAc,IAAM,IAAc,EAAU,GAAK,KAAK,KAEtE,MAAQ,CAMN,MAAO,sBACT,QAAU,CACR,EAAK,OAAO,CAAO,CACrB,CACF,EACA,OAAO,EAAO,CAAK,CACrB,CAOA,SAAgB,EAAgB,EAAwC,CACtE,OAAO,aAAiB,CAC1B"}
@@ -0,0 +1,10 @@
1
+ //#region src/errors/capability-identity.d.ts
2
+ interface CapabilityIdentityConflict {
3
+ readonly namespace: 'provider-plugin-id' | 'provider-route' | 'observation-exporter-id' | 'tool-source-id' | 'tool-name' | 'skill-provider-id' | 'skill-id' | 'team-member-name';
4
+ readonly key: string;
5
+ readonly firstIndex: number;
6
+ readonly secondIndex: number;
7
+ }
8
+ //#endregion
9
+ export { CapabilityIdentityConflict };
10
+ //# sourceMappingURL=capability-identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability-identity.d.ts","names":[],"sources":["../../src/errors/capability-identity.ts"],"mappings":";UAEiB;WACN;WAEA;WACA;WACA"}
@@ -0,0 +1,2 @@
1
+ import{AgentSdkError as e}from"./agent-sdk-error.js";const t=`[redacted]`,n=new WeakMap;function r(e,n,r){return Object.freeze({namespace:e,key:t,firstIndex:n,secondIndex:r})}function i(t,n,i,a){return c(new e(`Capability identity conflicts in this scope`,t),r(n,i,a))}function a(e,t,n){let r=new Map;for(let[a,o]of n.entries()){let n=r.get(o);if(n!==void 0)throw i(e,t,n,a);r.set(o,a)}}function o(e,t){if(typeof t!=`object`&&typeof t!=`function`||t===null)return e;let r=n.get(t);return r===void 0?e:c(e,r)}function s(e){return(typeof e==`object`||typeof e==`function`)&&e!==null&&n.has(e)}function c(e,t){return Object.defineProperty(e,"conflict",{value:t,enumerable:!0,configurable:!1,writable:!1}),n.set(e,t),e}export{t as REDACTED_IDENTITY_KEY,a as assertCapabilityIdentityNamespace,r as capabilityIdentityConflict,i as capabilityIdentityError,o as inheritCapabilityIdentityConflict,s as isCapabilityIdentityError};
2
+ //# sourceMappingURL=capability-identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability-identity.js","names":[],"sources":["../../src/errors/capability-identity.ts"],"sourcesContent":["import { AgentSdkError } from './agent-sdk-error.ts'\n\nexport interface CapabilityIdentityConflict {\n readonly namespace: 'provider-plugin-id' | 'provider-route' | 'observation-exporter-id'\n | 'tool-source-id' | 'tool-name' | 'skill-provider-id' | 'skill-id' | 'team-member-name'\n readonly key: string\n readonly firstIndex: number\n readonly secondIndex: number\n}\n\nexport const REDACTED_IDENTITY_KEY = '[redacted]'\n\nexport type CapabilityIdentityError = AgentSdkError & {\n readonly conflict: CapabilityIdentityConflict\n}\n\nconst conflicts = new WeakMap<object, CapabilityIdentityConflict>()\n\nexport function capabilityIdentityConflict(\n namespace: CapabilityIdentityConflict['namespace'],\n firstIndex: number,\n secondIndex: number,\n): CapabilityIdentityConflict {\n return Object.freeze({ namespace, key: REDACTED_IDENTITY_KEY, firstIndex, secondIndex })\n}\n\nexport function capabilityIdentityError(\n code: string,\n namespace: CapabilityIdentityConflict['namespace'],\n firstIndex: number,\n secondIndex: number,\n): CapabilityIdentityError {\n const error = new AgentSdkError('Capability identity conflicts in this scope', code) as CapabilityIdentityError\n return attachCapabilityIdentityConflict(error, capabilityIdentityConflict(namespace, firstIndex, secondIndex))\n}\n\nexport function assertCapabilityIdentityNamespace(\n code: string,\n namespace: CapabilityIdentityConflict['namespace'],\n identities: readonly string[],\n): void {\n const seen = new Map<string, number>()\n for (const [index, identity] of identities.entries()) {\n const first = seen.get(identity)\n if (first !== undefined) throw capabilityIdentityError(code, namespace, first, index)\n seen.set(identity, index)\n }\n}\n\nexport function inheritCapabilityIdentityConflict<T extends Error>(target: T, source: unknown): T {\n if ((typeof source !== 'object' && typeof source !== 'function') || source === null) return target\n const conflict = conflicts.get(source)\n return conflict === undefined ? target : attachCapabilityIdentityConflict(target, conflict)\n}\n\nexport function isCapabilityIdentityError(value: unknown): value is CapabilityIdentityError {\n return (typeof value === 'object' || typeof value === 'function')\n && value !== null && conflicts.has(value)\n}\n\nfunction attachCapabilityIdentityConflict<T extends Error>(\n error: T,\n conflict: CapabilityIdentityConflict,\n): T {\n Object.defineProperty(error, 'conflict', {\n value: conflict, enumerable: true, configurable: false, writable: false,\n })\n conflicts.set(error, conflict)\n return error\n}\n"],"mappings":"qDAUA,MAAa,EAAwB,aAM/B,EAAY,IAAI,QAEtB,SAAgB,EACd,EACA,EACA,EAC4B,CAC5B,OAAO,OAAO,OAAO,CAAE,YAAW,IAAK,EAAuB,aAAY,aAAY,CAAC,CACzF,CAEA,SAAgB,EACd,EACA,EACA,EACA,EACyB,CAEzB,OAAO,EAAiC,IADtB,EAAc,8CAA+C,CACnC,EAAG,EAA2B,EAAW,EAAY,CAAW,CAAC,CAC/G,CAEA,SAAgB,EACd,EACA,EACA,EACM,CACN,IAAM,EAAO,IAAI,IACjB,IAAK,GAAM,CAAC,EAAO,KAAa,EAAW,QAAQ,EAAG,CACpD,IAAM,EAAQ,EAAK,IAAI,CAAQ,EAC/B,GAAI,IAAU,IAAA,GAAW,MAAM,EAAwB,EAAM,EAAW,EAAO,CAAK,EACpF,EAAK,IAAI,EAAU,CAAK,CAC1B,CACF,CAEA,SAAgB,EAAmD,EAAW,EAAoB,CAChG,GAAK,OAAO,GAAW,UAAY,OAAO,GAAW,YAAe,IAAW,KAAM,OAAO,EAC5F,IAAM,EAAW,EAAU,IAAI,CAAM,EACrC,OAAO,IAAa,IAAA,GAAY,EAAS,EAAiC,EAAQ,CAAQ,CAC5F,CAEA,SAAgB,EAA0B,EAAkD,CAC1F,OAAQ,OAAO,GAAU,UAAY,OAAO,GAAU,aACjD,IAAU,MAAQ,EAAU,IAAI,CAAK,CAC5C,CAEA,SAAS,EACP,EACA,EACG,CAKH,OAJA,OAAO,eAAe,EAAO,WAAY,CACvC,MAAO,EAAU,WAAY,GAAM,aAAc,GAAO,SAAU,EACpE,CAAC,EACD,EAAU,IAAI,EAAO,CAAQ,EACtB,CACT"}
@@ -0,0 +1,33 @@
1
+ import { ProviderRequestId } from "../primitives/brand.js";
2
+ //#region src/errors/failure.d.ts
3
+ /**
4
+ * Serializable facts about a provider or transport failure.
5
+ *
6
+ * The live `Error` is what you throw; this is its data twin, safe to log, persist,
7
+ * or send across a process boundary — an `Error` survives neither
8
+ * `structuredClone` nor JSON with its class intact.
9
+ *
10
+ * Note what is deliberately absent: any judgement about whether to retry. These
11
+ * are facts; policy decides.
12
+ */
13
+ interface ModelFailure {
14
+ /** Human-readable provider or transport failure summary. */
15
+ readonly message: string;
16
+ /** Stable provider-neutral machine-routing code. */
17
+ readonly code: string;
18
+ /** HTTP status returned by the provider, when available. */
19
+ readonly status?: number;
20
+ /** Provider-requested delay in milliseconds, when valid and available. */
21
+ readonly providerRetryAfterMs?: number;
22
+ /** Opaque provider-issued request identifier, for support escalation. */
23
+ readonly requestId?: ProviderRequestId;
24
+ }
25
+ /**
26
+ * Detach serializable provider facts from a value thrown by an adapter.
27
+ * @param value - arbitrary value thrown during adapter dispatch or iteration.
28
+ * @returns immutable provider-neutral facts, suitable for a terminal finish chunk.
29
+ */
30
+ declare function normalizeModelFailure(value: unknown): ModelFailure;
31
+ //#endregion
32
+ export { ModelFailure, normalizeModelFailure };
33
+ //# sourceMappingURL=failure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"failure.d.ts","names":[],"sources":["../../src/errors/failure.ts"],"mappings":";;;;;;;;;;;;UAoCiB;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA,YAAY;;;;;;;iBAQP,sBAAsB,iBAAiB"}
@@ -0,0 +1,2 @@
1
+ import{AgentSdkError as e}from"./agent-sdk-error.js";import{MODEL_ERROR_CODES as t}from"./model-error.js";const n=new TextEncoder,r=Symbol(`invalid failure data`),i=Object.freeze({messageBytes:2048,codeBytes:128,requestIdBytes:1024});function a(n){let r=o(n)?n:void 0,i=r===void 0?void 0:u(r);if(r!==void 0&&i!==void 0&&i.code===l(r))return i;let a=s(n)?n:new e(c(n),t.UNKNOWN,{cause:n});return Object.freeze({message:m(a),code:h(a)})}function o(e){return typeof e==`object`&&!!e||typeof e==`function`}function s(e){try{return e instanceof Error}catch{return!1}}function c(e){try{let t=String(e);return t.length>0?t:`model adapter failed`}catch{return`model adapter failed`}}function l(e){try{let t=Object.getOwnPropertyDescriptor(e,`code`);return t!==void 0&&`value`in t?t.value:void 0}catch{return}}function u(e){try{let t=Object.getOwnPropertyDescriptor(e,`failure`);return t!==void 0&&`value`in t?d(t.value):void 0}catch{return}}function d(e){if(!o(e)||Array.isArray(e))return;let t=f(e,`message`),n=f(e,`code`),a=f(e,`status`),s=f(e,`providerRetryAfterMs`),c=f(e,`requestId`);if(!(t===r||n===r||a===r||s===r||c===r||!p(t,i.messageBytes)||!p(n,i.codeBytes)||a!==void 0&&(!Number.isSafeInteger(a)||a<100||a>599)||s!==void 0&&(!Number.isFinite(s)||s<=0)||c!==void 0&&!p(c,i.requestIdBytes)))return Object.freeze({message:t,code:n,...a===void 0?{}:{status:a},...s===void 0?{}:{providerRetryAfterMs:s},...c===void 0?{}:{requestId:c}})}function f(e,t){try{let n=Object.getOwnPropertyDescriptor(e,t);return n===void 0?void 0:`value`in n?n.value:r}catch{return r}}function p(e,t){return typeof e==`string`&&e.length>0&&n.encode(e).byteLength<=t}function m(e){let t=f(e,`message`);return p(t,i.messageBytes)?t:`model adapter failed`}function h(n){try{let r=l(n);return n instanceof e&&p(r,i.codeBytes)?r:t.UNKNOWN}catch{return t.UNKNOWN}}export{a as normalizeModelFailure};
2
+ //# sourceMappingURL=failure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"failure.js","names":[],"sources":["../../src/errors/failure.ts"],"sourcesContent":["/**\n * The serializable twin of a failure, and the hardened boundary that produces one\n * from an arbitrary thrown value.\n *\n * This module is written defensively on purpose. The value being normalized may\n * come from a third-party SDK, and such objects can define `message`, `code`, or\n * `failure` as GETTERS that throw, or sit behind a Proxy. If normalization itself\n * threw, the original failure would be replaced by a confusing secondary one — so\n * every read goes through `getOwnPropertyDescriptor`, checks for a data property,\n * and is individually contained.\n *\n * @module ai-agent-sdk/core/errors/failure\n */\n\nimport type { ProviderRequestId } from '../primitives/brand.ts'\nimport { AgentSdkError } from './agent-sdk-error.ts'\nimport { MODEL_ERROR_CODES } from './model-error.ts'\n\nconst ENCODER = new TextEncoder()\nconst INVALID_DATA = Symbol('invalid failure data')\nconst FAILURE_ENVELOPE_LIMITS = Object.freeze({\n messageBytes: 2_048,\n codeBytes: 128,\n requestIdBytes: 1_024,\n})\n\n/**\n * Serializable facts about a provider or transport failure.\n *\n * The live `Error` is what you throw; this is its data twin, safe to log, persist,\n * or send across a process boundary — an `Error` survives neither\n * `structuredClone` nor JSON with its class intact.\n *\n * Note what is deliberately absent: any judgement about whether to retry. These\n * are facts; policy decides.\n */\nexport interface ModelFailure {\n /** Human-readable provider or transport failure summary. */\n readonly message: string\n /** Stable provider-neutral machine-routing code. */\n readonly code: string\n /** HTTP status returned by the provider, when available. */\n readonly status?: number\n /** Provider-requested delay in milliseconds, when valid and available. */\n readonly providerRetryAfterMs?: number\n /** Opaque provider-issued request identifier, for support escalation. */\n readonly requestId?: ProviderRequestId\n}\n\n/**\n * Detach serializable provider facts from a value thrown by an adapter.\n * @param value - arbitrary value thrown during adapter dispatch or iteration.\n * @returns immutable provider-neutral facts, suitable for a terminal finish chunk.\n */\nexport function normalizeModelFailure(value: unknown): ModelFailure {\n const source = objectLike(value) ? value : undefined\n // A ModelError from a DIFFERENT copy of this package keeps its own data but not\n // its class identity, so `instanceof` misses it. Trust the carried facts only\n // when both own properties survive validation and agree with each other.\n const carried = source === undefined ? undefined : ownFailureSnapshot(source)\n if (source !== undefined && carried !== undefined && carried.code === ownErrorCode(source)) return carried\n const error = isError(value)\n ? value\n : new AgentSdkError(thrownMessage(value), MODEL_ERROR_CODES.UNKNOWN, { cause: value })\n return Object.freeze({\n message: errorMessage(error),\n code: agentSdkErrorCode(error),\n })\n}\n\nfunction objectLike(value: unknown): value is object {\n return (typeof value === 'object' && value !== null) || typeof value === 'function'\n}\n\nfunction isError(value: unknown): value is Error {\n try { return value instanceof Error } catch { return false }\n}\n\n/** Render a non-Error throw without letting hostile coercion escape. */\nfunction thrownMessage(value: unknown): string {\n try {\n const message = String(value)\n return message.length > 0 ? message : 'model adapter failed'\n } catch {\n return 'model adapter failed'\n }\n}\n\n/** Read a foreign error's own data-backed `code` without invoking accessors. */\nfunction ownErrorCode(error: object): unknown {\n try {\n const descriptor = Object.getOwnPropertyDescriptor(error, 'code')\n return descriptor !== undefined && 'value' in descriptor ? descriptor.value : undefined\n } catch {\n return undefined\n }\n}\n\n/** Snapshot an own data property without invoking an SDK-defined accessor. */\nfunction ownFailureSnapshot(error: object): ModelFailure | undefined {\n try {\n const descriptor = Object.getOwnPropertyDescriptor(error, 'failure')\n return descriptor !== undefined && 'value' in descriptor\n ? failureSnapshot(descriptor.value)\n : undefined\n } catch {\n return undefined\n }\n}\n\n/** Validate and detach an arbitrary serializable failure payload. */\nfunction failureSnapshot(value: unknown): ModelFailure | undefined {\n if (!objectLike(value) || Array.isArray(value)) return undefined\n const message = ownFailureData(value, 'message')\n const code = ownFailureData(value, 'code')\n const status = ownFailureData(value, 'status')\n const providerRetryAfterMs = ownFailureData(value, 'providerRetryAfterMs')\n const requestId = ownFailureData(value, 'requestId')\n if (message === INVALID_DATA || code === INVALID_DATA || status === INVALID_DATA\n || providerRetryAfterMs === INVALID_DATA || requestId === INVALID_DATA\n || !boundedString(message, FAILURE_ENVELOPE_LIMITS.messageBytes)\n || !boundedString(code, FAILURE_ENVELOPE_LIMITS.codeBytes)\n || (status !== undefined && (!Number.isSafeInteger(status) || (status as number) < 100 || (status as number) > 599))\n || (providerRetryAfterMs !== undefined\n && (!Number.isFinite(providerRetryAfterMs) || (providerRetryAfterMs as number) <= 0))\n || (requestId !== undefined && !boundedString(requestId, FAILURE_ENVELOPE_LIMITS.requestIdBytes))) {\n return undefined\n }\n return Object.freeze({\n message,\n code,\n ...status === undefined ? {} : { status: status as number },\n ...providerRetryAfterMs === undefined ? {} : { providerRetryAfterMs: providerRetryAfterMs as number },\n ...requestId === undefined ? {} : { requestId: requestId as ProviderRequestId },\n })\n}\n\nfunction ownFailureData(source: object, key: PropertyKey): unknown {\n try {\n const descriptor = Object.getOwnPropertyDescriptor(source, key)\n if (descriptor === undefined) return undefined\n return 'value' in descriptor ? descriptor.value : INVALID_DATA\n } catch {\n return INVALID_DATA\n }\n}\n\nfunction boundedString(value: unknown, maxBytes: number): value is string {\n return typeof value === 'string' && value.length > 0\n && ENCODER.encode(value).byteLength <= maxBytes\n}\n\n/** Read an error message without letting an accessor replace the primary failure. */\nfunction errorMessage(error: Error): string {\n const message = ownFailureData(error, 'message')\n if (boundedString(message, FAILURE_ENVELOPE_LIMITS.messageBytes)) return message\n return 'model adapter failed'\n}\n\n/**\n * Trust only codes from this SDK's taxonomy.\n *\n * A third-party SDK's `code` is not our vocabulary — adopting it could let an\n * unrelated string like `ERR_BAD_REQUEST` collide with a retry allow-list entry.\n */\nfunction agentSdkErrorCode(error: Error): string {\n try {\n const code = ownErrorCode(error)\n return error instanceof AgentSdkError\n && boundedString(code, FAILURE_ENVELOPE_LIMITS.codeBytes)\n ? code\n : MODEL_ERROR_CODES.UNKNOWN\n } catch {\n return MODEL_ERROR_CODES.UNKNOWN\n }\n}\n"],"mappings":"0GAkBA,MAAM,EAAU,IAAI,YACd,EAAe,OAAO,sBAAsB,EAC5C,EAA0B,OAAO,OAAO,CAC5C,aAAc,KACd,UAAW,IACX,eAAgB,IAClB,CAAC,EA8BD,SAAgB,EAAsB,EAA8B,CAClE,IAAM,EAAS,EAAW,CAAK,EAAI,EAAQ,IAAA,GAIrC,EAAU,IAAW,IAAA,GAAY,IAAA,GAAY,EAAmB,CAAM,EAC5E,GAAI,IAAW,IAAA,IAAa,IAAY,IAAA,IAAa,EAAQ,OAAS,EAAa,CAAM,EAAG,OAAO,EACnG,IAAM,EAAQ,EAAQ,CAAK,EACvB,EACA,IAAI,EAAc,EAAc,CAAK,EAAG,EAAkB,QAAS,CAAE,MAAO,CAAM,CAAC,EACvF,OAAO,OAAO,OAAO,CACnB,QAAS,EAAa,CAAK,EAC3B,KAAM,EAAkB,CAAK,CAC/B,CAAC,CACH,CAEA,SAAS,EAAW,EAAiC,CACnD,OAAQ,OAAO,GAAU,YAAY,GAAmB,OAAO,GAAU,UAC3E,CAEA,SAAS,EAAQ,EAAgC,CAC/C,GAAI,CAAE,OAAO,aAAiB,KAAM,MAAQ,CAAE,MAAO,EAAM,CAC7D,CAGA,SAAS,EAAc,EAAwB,CAC7C,GAAI,CACF,IAAM,EAAU,OAAO,CAAK,EAC5B,OAAO,EAAQ,OAAS,EAAI,EAAU,sBACxC,MAAQ,CACN,MAAO,sBACT,CACF,CAGA,SAAS,EAAa,EAAwB,CAC5C,GAAI,CACF,IAAM,EAAa,OAAO,yBAAyB,EAAO,MAAM,EAChE,OAAO,IAAe,IAAA,IAAa,UAAW,EAAa,EAAW,MAAQ,IAAA,EAChF,MAAQ,CACN,MACF,CACF,CAGA,SAAS,EAAmB,EAAyC,CACnE,GAAI,CACF,IAAM,EAAa,OAAO,yBAAyB,EAAO,SAAS,EACnE,OAAO,IAAe,IAAA,IAAa,UAAW,EAC1C,EAAgB,EAAW,KAAK,EAChC,IAAA,EACN,MAAQ,CACN,MACF,CACF,CAGA,SAAS,EAAgB,EAA0C,CACjE,GAAI,CAAC,EAAW,CAAK,GAAK,MAAM,QAAQ,CAAK,EAAG,OAChD,IAAM,EAAU,EAAe,EAAO,SAAS,EACzC,EAAO,EAAe,EAAO,MAAM,EACnC,EAAS,EAAe,EAAO,QAAQ,EACvC,EAAuB,EAAe,EAAO,sBAAsB,EACnE,EAAY,EAAe,EAAO,WAAW,EAC/C,SAAY,GAAgB,IAAS,GAAgB,IAAW,GAC/D,IAAyB,GAAgB,IAAc,GACvD,CAAC,EAAc,EAAS,EAAwB,YAAY,GAC5D,CAAC,EAAc,EAAM,EAAwB,SAAS,GACrD,IAAW,IAAA,KAAc,CAAC,OAAO,cAAc,CAAM,GAAM,EAAoB,KAAQ,EAAoB,MAC3G,IAAyB,IAAA,KACvB,CAAC,OAAO,SAAS,CAAoB,GAAM,GAAmC,IAChF,IAAc,IAAA,IAAa,CAAC,EAAc,EAAW,EAAwB,cAAc,GAGjG,OAAO,OAAO,OAAO,CACnB,UACA,OACA,GAAG,IAAW,IAAA,GAAY,CAAC,EAAI,CAAU,QAAiB,EAC1D,GAAG,IAAyB,IAAA,GAAY,CAAC,EAAI,CAAwB,sBAA+B,EACpG,GAAG,IAAc,IAAA,GAAY,CAAC,EAAI,CAAa,WAA+B,CAChF,CAAC,CACH,CAEA,SAAS,EAAe,EAAgB,EAA2B,CACjE,GAAI,CACF,IAAM,EAAa,OAAO,yBAAyB,EAAQ,CAAG,EAE9D,OADI,IAAe,IAAA,GAAW,OACvB,UAAW,EAAa,EAAW,MAAQ,CACpD,MAAQ,CACN,OAAO,CACT,CACF,CAEA,SAAS,EAAc,EAAgB,EAAmC,CACxE,OAAO,OAAO,GAAU,UAAY,EAAM,OAAS,GAC9C,EAAQ,OAAO,CAAK,CAAC,CAAC,YAAc,CAC3C,CAGA,SAAS,EAAa,EAAsB,CAC1C,IAAM,EAAU,EAAe,EAAO,SAAS,EAE/C,OADI,EAAc,EAAS,EAAwB,YAAY,EAAU,EAClE,sBACT,CAQA,SAAS,EAAkB,EAAsB,CAC/C,GAAI,CACF,IAAM,EAAO,EAAa,CAAK,EAC/B,OAAO,aAAiB,GACnB,EAAc,EAAM,EAAwB,SAAS,EACtD,EACA,EAAkB,OACxB,MAAQ,CACN,OAAO,EAAkB,OAC3B,CACF"}
@@ -0,0 +1,83 @@
1
+ import { ProviderRequestId } from "../primitives/brand.js";
2
+ import { ModelFailure } from "./failure.js";
3
+ import { AgentSdkError } from "./agent-sdk-error.js";
4
+ //#region src/errors/model-error.d.ts
5
+ /** Structured provider facts and cause accepted by {@link ModelError}. */
6
+ interface ModelErrorOptions extends ErrorOptions {
7
+ /** Valid HTTP status observed at the provider boundary. */
8
+ status?: number;
9
+ /** Positive finite provider-requested delay in milliseconds. */
10
+ providerRetryAfterMs?: number;
11
+ /** Non-empty opaque provider request id. */
12
+ requestId?: ProviderRequestId;
13
+ }
14
+ /**
15
+ * Typed error for model-call failures, carrying a stable `code` from the shared
16
+ * taxonomy plus the serializable {@link failure} twin.
17
+ *
18
+ * The constructor validates rather than trusts. An out-of-range `status` or a
19
+ * negative `providerRetryAfterMs` means an adapter misread a header, and letting
20
+ * that through would put a retry to sleep for a nonsense duration.
21
+ */
22
+ declare class ModelError extends AgentSdkError {
23
+ /** Serializable facts retained beside this live Error. */
24
+ readonly failure: ModelFailure;
25
+ /**
26
+ * @param message - non-empty human-readable failure summary.
27
+ * @param code - non-empty stable provider-neutral machine code.
28
+ * @param options - optional cause and validated serializable provider facts.
29
+ */
30
+ constructor(message: string, code: string, options?: ModelErrorOptions);
31
+ }
32
+ /**
33
+ * Codes produced at the provider boundary.
34
+ *
35
+ * Exported as a frozen object rather than a TS enum so that a third-party
36
+ * adapter can emit its own code without this union having to know about it.
37
+ * Retry eligibility is decided by policy against these values, never by the
38
+ * adapter that assigns them  Esee `retry-policy.ts`.
39
+ */
40
+ declare const MODEL_ERROR_CODES: Readonly<{
41
+ /** Credentials were rejected (401/403). */
42
+ readonly AUTH: 'AUTH';
43
+ /** Transient request-rate limiting (429). */
44
+ readonly RATE_LIMIT: 'RATE_LIMIT';
45
+ /** Provider-side fault (5xx). */
46
+ readonly SERVER: 'SERVER';
47
+ /** The provider stopped producing output for longer than the idle bound. */
48
+ readonly TIMEOUT: 'TIMEOUT';
49
+ /** The request never completed at the network layer. */
50
+ readonly TRANSPORT: 'TRANSPORT';
51
+ /** The caller's signal aborted the request. */
52
+ readonly ABORTED: 'ABORTED';
53
+ /** An adapter ignored cancellation and may still own live work. */
54
+ readonly TEARDOWN_TIMEOUT: 'MODEL_TEARDOWN_TIMEOUT';
55
+ /** The provider rejected the request as malformed (400/413). */
56
+ readonly INVALID_REQUEST: 'INVALID_REQUEST';
57
+ /** A well-formed response could not be parsed. */
58
+ readonly MALFORMED_RESPONSE: 'MALFORMED_RESPONSE';
59
+ /** The response body ended before its terminating sentinel. */
60
+ readonly STREAM_CLOSED: 'STREAM_CLOSED';
61
+ /** The request carried content the selected model cannot accept. */
62
+ readonly UNSUPPORTED_CONTENT: 'UNSUPPORTED_CONTENT';
63
+ /** The request set an option this provider has no equivalent for. */
64
+ readonly UNSUPPORTED_OPTION: 'UNSUPPORTED_OPTION';
65
+ /** Nothing classified it; treated as non-retryable. */
66
+ readonly UNKNOWN: 'UNKNOWN';
67
+ }>;
68
+ /** Registry-level codes, raised before any provider I/O happens. */
69
+ declare const REGISTRY_ERROR_CODES: Readonly<{
70
+ readonly NO_ADAPTER: 'NO_ADAPTER';
71
+ readonly DUPLICATE_ADAPTER: 'DUPLICATE_ADAPTER';
72
+ readonly INVALID_ADAPTER: 'INVALID_ADAPTER';
73
+ readonly INVALID_CATALOG: 'INVALID_CATALOG';
74
+ readonly INVALID_MODEL_INFO: 'INVALID_MODEL_INFO';
75
+ readonly UNSUPPORTED_REASONING_EFFORT: 'UNSUPPORTED_REASONING_EFFORT';
76
+ readonly UNSUPPORTED_NATIVE_TOOL: 'UNSUPPORTED_NATIVE_TOOL';
77
+ readonly OUTPUT_TOKEN_LIMIT_EXCEEDED: 'OUTPUT_TOKEN_LIMIT_EXCEEDED';
78
+ readonly INVALID_PREPARED_CALL: 'INVALID_PREPARED_CALL';
79
+ readonly REGISTRATION_DISPOSED: 'REGISTRATION_DISPOSED';
80
+ }>;
81
+ //#endregion
82
+ export { MODEL_ERROR_CODES, ModelError, ModelErrorOptions, REGISTRY_ERROR_CODES };
83
+ //# sourceMappingURL=model-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-error.d.ts","names":[],"sources":["../../src/errors/model-error.ts"],"mappings":";;;;;UAiBiB,0BAA0B;;EAEzC;;EAEA;;EAEA,YAAY;;;;;;;;;;cAWD,mBAAmB;;WAErB,SAAS;;;;;;EAOlB,YAAY,iBAAiB,cAAc,UAAU;;;;;;;;;;cAyC1C,mBAAiB;;WAEtB;;WAEM;;WAEJ;;WAEC;;WAEE;;WAEF;;WAES;;WAED;;WAEG;;WAEL;;WAEM;;WAED;;WAEX;;;cAIE,sBAAoB;WACnB;WACO;WACF;WACA;WACG;WACU;WACL;WACI;WACN;WACA"}
@@ -0,0 +1,2 @@
1
+ import{AgentSdkError as e}from"./agent-sdk-error.js";var t=class extends e{failure;constructor(e,t,n){if(typeof e!=`string`||e.length===0)throw Error(`ModelError message must be a non-empty string`);if(typeof t!=`string`||t.length===0)throw Error(`ModelError code must be a non-empty string`);if(n?.status!==void 0&&(!Number.isInteger(n.status)||n.status<100||n.status>599))throw Error(`ModelError status must be an integer from 100 through 599`);if(n?.providerRetryAfterMs!==void 0&&(!Number.isFinite(n.providerRetryAfterMs)||n.providerRetryAfterMs<=0))throw Error(`ModelError providerRetryAfterMs must be a positive finite number`);if(n?.requestId!==void 0&&(typeof n.requestId!=`string`||n.requestId.length===0))throw Error(`ModelError requestId must be a non-empty string`);super(e,t,n),this.name=`ModelError`,this.failure=Object.freeze({message:e,code:t,...n?.status===void 0?{}:{status:n.status},...n?.providerRetryAfterMs===void 0?{}:{providerRetryAfterMs:n.providerRetryAfterMs},...n?.requestId===void 0?{}:{requestId:n.requestId}})}};const n=Object.freeze({AUTH:`AUTH`,RATE_LIMIT:`RATE_LIMIT`,SERVER:`SERVER`,TIMEOUT:`TIMEOUT`,TRANSPORT:`TRANSPORT`,ABORTED:`ABORTED`,TEARDOWN_TIMEOUT:`MODEL_TEARDOWN_TIMEOUT`,INVALID_REQUEST:`INVALID_REQUEST`,MALFORMED_RESPONSE:`MALFORMED_RESPONSE`,STREAM_CLOSED:`STREAM_CLOSED`,UNSUPPORTED_CONTENT:`UNSUPPORTED_CONTENT`,UNSUPPORTED_OPTION:`UNSUPPORTED_OPTION`,UNKNOWN:`UNKNOWN`}),r=Object.freeze({NO_ADAPTER:`NO_ADAPTER`,DUPLICATE_ADAPTER:`DUPLICATE_ADAPTER`,INVALID_ADAPTER:`INVALID_ADAPTER`,INVALID_CATALOG:`INVALID_CATALOG`,INVALID_MODEL_INFO:`INVALID_MODEL_INFO`,UNSUPPORTED_REASONING_EFFORT:`UNSUPPORTED_REASONING_EFFORT`,UNSUPPORTED_NATIVE_TOOL:`UNSUPPORTED_NATIVE_TOOL`,OUTPUT_TOKEN_LIMIT_EXCEEDED:`OUTPUT_TOKEN_LIMIT_EXCEEDED`,INVALID_PREPARED_CALL:`INVALID_PREPARED_CALL`,REGISTRATION_DISPOSED:`REGISTRATION_DISPOSED`});export{n as MODEL_ERROR_CODES,t as ModelError,r as REGISTRY_ERROR_CODES};
2
+ //# sourceMappingURL=model-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-error.js","names":[],"sources":["../../src/errors/model-error.ts"],"sourcesContent":["/**\n * The error adapters throw, and the codes they classify failures into.\n *\n * {@link ModelError} validates its own inputs and exposes a frozen serializable\n * twin ({@link ModelFailure}). The pairing is the point: a live `Error` is what\n * you throw, and a plain data object is what you log, persist, or send across a\n * process boundary  Ean `Error` does not survive `structuredClone` or JSON with\n * its class intact.\n *\n * @module ai-agent-sdk/core/errors/model-error\n */\n\nimport type { ProviderRequestId } from '../primitives/brand.ts'\nimport { AgentSdkError } from './agent-sdk-error.ts'\nimport type { ModelFailure } from './failure.ts'\n\n/** Structured provider facts and cause accepted by {@link ModelError}. */\nexport interface ModelErrorOptions extends ErrorOptions {\n /** Valid HTTP status observed at the provider boundary. */\n status?: number\n /** Positive finite provider-requested delay in milliseconds. */\n providerRetryAfterMs?: number\n /** Non-empty opaque provider request id. */\n requestId?: ProviderRequestId\n}\n\n/**\n * Typed error for model-call failures, carrying a stable `code` from the shared\n * taxonomy plus the serializable {@link failure} twin.\n *\n * The constructor validates rather than trusts. An out-of-range `status` or a\n * negative `providerRetryAfterMs` means an adapter misread a header, and letting\n * that through would put a retry to sleep for a nonsense duration.\n */\nexport class ModelError extends AgentSdkError {\n /** Serializable facts retained beside this live Error. */\n readonly failure: ModelFailure\n\n /**\n * @param message - non-empty human-readable failure summary.\n * @param code - non-empty stable provider-neutral machine code.\n * @param options - optional cause and validated serializable provider facts.\n */\n constructor(message: string, code: string, options?: ModelErrorOptions) {\n if (typeof message !== 'string' || message.length === 0) {\n throw new Error('ModelError message must be a non-empty string')\n }\n if (typeof code !== 'string' || code.length === 0) {\n throw new Error('ModelError code must be a non-empty string')\n }\n if (options?.status !== undefined\n && (!Number.isInteger(options.status) || options.status < 100 || options.status > 599)) {\n throw new Error('ModelError status must be an integer from 100 through 599')\n }\n if (options?.providerRetryAfterMs !== undefined\n && (!Number.isFinite(options.providerRetryAfterMs) || options.providerRetryAfterMs <= 0)) {\n throw new Error('ModelError providerRetryAfterMs must be a positive finite number')\n }\n if (options?.requestId !== undefined\n && (typeof options.requestId !== 'string' || options.requestId.length === 0)) {\n throw new Error('ModelError requestId must be a non-empty string')\n }\n super(message, code, options)\n this.name = 'ModelError'\n this.failure = Object.freeze({\n message,\n code,\n ...options?.status === undefined ? {} : { status: options.status },\n ...options?.providerRetryAfterMs === undefined\n ? {}\n : { providerRetryAfterMs: options.providerRetryAfterMs },\n ...options?.requestId === undefined ? {} : { requestId: options.requestId },\n })\n }\n}\n\n/**\n * Codes produced at the provider boundary.\n *\n * Exported as a frozen object rather than a TS enum so that a third-party\n * adapter can emit its own code without this union having to know about it.\n * Retry eligibility is decided by policy against these values, never by the\n * adapter that assigns them  Esee `retry-policy.ts`.\n */\nexport const MODEL_ERROR_CODES = Object.freeze({\n /** Credentials were rejected (401/403). */\n AUTH: 'AUTH',\n /** Transient request-rate limiting (429). */\n RATE_LIMIT: 'RATE_LIMIT',\n /** Provider-side fault (5xx). */\n SERVER: 'SERVER',\n /** The provider stopped producing output for longer than the idle bound. */\n TIMEOUT: 'TIMEOUT',\n /** The request never completed at the network layer. */\n TRANSPORT: 'TRANSPORT',\n /** The caller's signal aborted the request. */\n ABORTED: 'ABORTED',\n /** An adapter ignored cancellation and may still own live work. */\n TEARDOWN_TIMEOUT: 'MODEL_TEARDOWN_TIMEOUT',\n /** The provider rejected the request as malformed (400/413). */\n INVALID_REQUEST: 'INVALID_REQUEST',\n /** A well-formed response could not be parsed. */\n MALFORMED_RESPONSE: 'MALFORMED_RESPONSE',\n /** The response body ended before its terminating sentinel. */\n STREAM_CLOSED: 'STREAM_CLOSED',\n /** The request carried content the selected model cannot accept. */\n UNSUPPORTED_CONTENT: 'UNSUPPORTED_CONTENT',\n /** The request set an option this provider has no equivalent for. */\n UNSUPPORTED_OPTION: 'UNSUPPORTED_OPTION',\n /** Nothing classified it; treated as non-retryable. */\n UNKNOWN: 'UNKNOWN',\n} as const)\n\n/** Registry-level codes, raised before any provider I/O happens. */\nexport const REGISTRY_ERROR_CODES = Object.freeze({\n NO_ADAPTER: 'NO_ADAPTER',\n DUPLICATE_ADAPTER: 'DUPLICATE_ADAPTER',\n INVALID_ADAPTER: 'INVALID_ADAPTER',\n INVALID_CATALOG: 'INVALID_CATALOG',\n INVALID_MODEL_INFO: 'INVALID_MODEL_INFO',\n UNSUPPORTED_REASONING_EFFORT: 'UNSUPPORTED_REASONING_EFFORT',\n UNSUPPORTED_NATIVE_TOOL: 'UNSUPPORTED_NATIVE_TOOL',\n OUTPUT_TOKEN_LIMIT_EXCEEDED: 'OUTPUT_TOKEN_LIMIT_EXCEEDED',\n INVALID_PREPARED_CALL: 'INVALID_PREPARED_CALL',\n REGISTRATION_DISPOSED: 'REGISTRATION_DISPOSED',\n} as const)\n"],"mappings":"qDAkCA,IAAa,EAAb,cAAgC,CAAc,CAE5C,QAOA,YAAY,EAAiB,EAAc,EAA6B,CACtE,GAAI,OAAO,GAAY,UAAY,EAAQ,SAAW,EACpD,MAAU,MAAM,+CAA+C,EAEjE,GAAI,OAAO,GAAS,UAAY,EAAK,SAAW,EAC9C,MAAU,MAAM,4CAA4C,EAE9D,GAAI,GAAS,SAAW,IAAA,KAClB,CAAC,OAAO,UAAU,EAAQ,MAAM,GAAK,EAAQ,OAAS,KAAO,EAAQ,OAAS,KAClF,MAAU,MAAM,2DAA2D,EAE7E,GAAI,GAAS,uBAAyB,IAAA,KAChC,CAAC,OAAO,SAAS,EAAQ,oBAAoB,GAAK,EAAQ,sBAAwB,GACtF,MAAU,MAAM,kEAAkE,EAEpF,GAAI,GAAS,YAAc,IAAA,KACrB,OAAO,EAAQ,WAAc,UAAY,EAAQ,UAAU,SAAW,GAC1E,MAAU,MAAM,iDAAiD,EAEnE,MAAM,EAAS,EAAM,CAAO,EAC5B,KAAK,KAAO,aACZ,KAAK,QAAU,OAAO,OAAO,CAC3B,UACA,OACA,GAAG,GAAS,SAAW,IAAA,GAAY,CAAC,EAAI,CAAE,OAAQ,EAAQ,MAAO,EACjE,GAAG,GAAS,uBAAyB,IAAA,GACjC,CAAC,EACD,CAAE,qBAAsB,EAAQ,oBAAqB,EACzD,GAAG,GAAS,YAAc,IAAA,GAAY,CAAC,EAAI,CAAE,UAAW,EAAQ,SAAU,CAC5E,CAAC,CACH,CACF,EAUA,MAAa,EAAoB,OAAO,OAAO,CAE7C,KAAM,OAEN,WAAY,aAEZ,OAAQ,SAER,QAAS,UAET,UAAW,YAEX,QAAS,UAET,iBAAkB,yBAElB,gBAAiB,kBAEjB,mBAAoB,qBAEpB,cAAe,gBAEf,oBAAqB,sBAErB,mBAAoB,qBAEpB,QAAS,SACX,CAAU,EAGG,EAAuB,OAAO,OAAO,CAChD,WAAY,aACZ,kBAAmB,oBACnB,gBAAiB,kBACjB,gBAAiB,kBACjB,mBAAoB,qBACpB,6BAA8B,+BAC9B,wBAAyB,0BACzB,4BAA6B,8BAC7B,sBAAuB,wBACvB,sBAAuB,uBACzB,CAAU"}
@@ -0,0 +1,47 @@
1
+ //#region src/http/api-key.d.ts
2
+ /**
3
+ * The one definition of a well-formed provider API key, shared by every adapter
4
+ * that puts one into an HTTP header.
5
+ *
6
+ * @module ai-agent-sdk/core/http/api-key
7
+ */
8
+ /** Why a supplied API key cannot be used. */
9
+ type ApiKeyRejection = 'empty' | 'illegalCharacters';
10
+ /** The verdict on one supplied API key. */
11
+ type ApiKeyCheck = {
12
+ readonly ok: true;
13
+ readonly value: string;
14
+ } | {
15
+ readonly ok: false;
16
+ readonly reason: ApiKeyRejection;
17
+ };
18
+ /**
19
+ * Judge one SUPPLIED API key, trimming surrounding whitespace first.
20
+ *
21
+ * Trimming is silent because a padded key has exactly one sensible reading, and
22
+ * keys routinely pick up whitespace from `.env` files and shell exports. Every
23
+ * other defect is reported rather than repaired.
24
+ *
25
+ * Absence is a state this function never sees: a route may legitimately
26
+ * authenticate through ambient provider credential discovery, so the caller
27
+ * decides whether a value was supplied at all before asking.
28
+ * @param raw - the key exactly as configured, stored, or typed.
29
+ * @returns the trimmed key, or why it cannot be used.
30
+ */
31
+ declare function normalizeApiKey(raw: string): ApiKeyCheck;
32
+ /**
33
+ * Accept one supplied credential, or refuse it with a diagnosis.
34
+ *
35
+ * Fails here rather than inside `fetch`, whose ByteString refusal names a UTF-16
36
+ * code point instead of the setting to change. The key itself NEVER enters the
37
+ * message: `ref` names where to fix it, and echoing any part of a secret into a
38
+ * log or a UI is precisely the failure this avoids.
39
+ * @param raw - the credential exactly as supplied.
40
+ * @param provider - the refusing provider name, prefixed to the diagnostic.
41
+ * @param ref - how the credential was referenced (e.g. an env var name).
42
+ * @returns the trimmed, usable key.
43
+ */
44
+ declare function assertUsableApiKey(raw: string, provider: string, ref: string): string;
45
+ //#endregion
46
+ export { ApiKeyCheck, ApiKeyRejection, assertUsableApiKey, normalizeApiKey };
47
+ //# sourceMappingURL=api-key.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-key.d.ts","names":[],"sources":["../../src/http/api-key.ts"],"mappings":";;;;;;;;KAsBY;;KAGA;WACG;WAAmB;;WACnB;WAAoB,QAAQ;;;;;;;;;;;;;;;iBAe3B,gBAAgB,cAAc;;;;;;;;;;;;;iBAmB9B,mBAAmB,aAAa,kBAAkB"}
@@ -0,0 +1,2 @@
1
+ import{AgentSdkError as e,INVALID_CREDENTIAL_CODE as t}from"../errors/agent-sdk-error.js";const n=/^[\x21-\x7E]+$/;function r(e){let t=e.trim();return t.length===0?{ok:!1,reason:`empty`}:n.test(t)?{ok:!0,value:t}:{ok:!1,reason:`illegalCharacters`}}function i(n,i,a){let o=r(n);if(o.ok)return o.value;throw new e(o.reason===`empty`?`${i}: the API key resolved from ${a} is blank; set ${a} to the raw key`:`${i}: the API key resolved from ${a} contains characters no HTTP header can carry; set ${a} to the raw key alone`,t)}export{i as assertUsableApiKey,r as normalizeApiKey};
2
+ //# sourceMappingURL=api-key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-key.js","names":[],"sources":["../../src/http/api-key.ts"],"sourcesContent":["/**\n * The one definition of a well-formed provider API key, shared by every adapter\n * that puts one into an HTTP header.\n *\n * @module ai-agent-sdk/core/http/api-key\n */\n\nimport { AgentSdkError, INVALID_CREDENTIAL_CODE } from '../errors/agent-sdk-error.ts'\n\n/**\n * Characters an HTTP header value carries verbatim and every known provider key\n * uses: printable ASCII, space excluded.\n *\n * A key outside this set cannot reach ANY provider, because `fetch` refuses to\n * build the header  Eso this is a transport invariant, not one vendor's policy.\n * Latin-1 is excluded on purpose: a header could carry it, but no provider\n * issues it, and admitting it would trade a local explained refusal for an\n * opaque 401 much later.\n */\nconst LEGAL_API_KEY = /^[\\x21-\\x7E]+$/\n\n/** Why a supplied API key cannot be used. */\nexport type ApiKeyRejection = 'empty' | 'illegalCharacters'\n\n/** The verdict on one supplied API key. */\nexport type ApiKeyCheck =\n | { readonly ok: true; readonly value: string }\n | { readonly ok: false; readonly reason: ApiKeyRejection }\n\n/**\n * Judge one SUPPLIED API key, trimming surrounding whitespace first.\n *\n * Trimming is silent because a padded key has exactly one sensible reading, and\n * keys routinely pick up whitespace from `.env` files and shell exports. Every\n * other defect is reported rather than repaired.\n *\n * Absence is a state this function never sees: a route may legitimately\n * authenticate through ambient provider credential discovery, so the caller\n * decides whether a value was supplied at all before asking.\n * @param raw - the key exactly as configured, stored, or typed.\n * @returns the trimmed key, or why it cannot be used.\n */\nexport function normalizeApiKey(raw: string): ApiKeyCheck {\n const value = raw.trim()\n if (value.length === 0) return { ok: false, reason: 'empty' }\n if (!LEGAL_API_KEY.test(value)) return { ok: false, reason: 'illegalCharacters' }\n return { ok: true, value }\n}\n\n/**\n * Accept one supplied credential, or refuse it with a diagnosis.\n *\n * Fails here rather than inside `fetch`, whose ByteString refusal names a UTF-16\n * code point instead of the setting to change. The key itself NEVER enters the\n * message: `ref` names where to fix it, and echoing any part of a secret into a\n * log or a UI is precisely the failure this avoids.\n * @param raw - the credential exactly as supplied.\n * @param provider - the refusing provider name, prefixed to the diagnostic.\n * @param ref - how the credential was referenced (e.g. an env var name).\n * @returns the trimmed, usable key.\n */\nexport function assertUsableApiKey(raw: string, provider: string, ref: string): string {\n const checked = normalizeApiKey(raw)\n if (checked.ok) return checked.value\n throw new AgentSdkError(\n checked.reason === 'empty'\n ? `${provider}: the API key resolved from ${ref} is blank; set ${ref} to the raw key`\n : `${provider}: the API key resolved from ${ref} contains characters no HTTP header can carry;`\n + ` set ${ref} to the raw key alone`,\n INVALID_CREDENTIAL_CODE,\n )\n}\n"],"mappings":"0FAmBA,MAAM,EAAgB,iBAuBtB,SAAgB,EAAgB,EAA0B,CACxD,IAAM,EAAQ,EAAI,KAAK,EAGvB,OAFI,EAAM,SAAW,EAAU,CAAE,GAAI,GAAO,OAAQ,OAAQ,EACvD,EAAc,KAAK,CAAK,EACtB,CAAE,GAAI,GAAM,OAAM,EADc,CAAE,GAAI,GAAO,OAAQ,mBAAoB,CAElF,CAcA,SAAgB,EAAmB,EAAa,EAAkB,EAAqB,CACrF,IAAM,EAAU,EAAgB,CAAG,EACnC,GAAI,EAAQ,GAAI,OAAO,EAAQ,MAC/B,MAAM,IAAI,EACR,EAAQ,SAAW,QACf,GAAG,EAAS,8BAA8B,EAAI,iBAAiB,EAAI,iBACnE,GAAG,EAAS,8BAA8B,EAAI,qDACpC,EAAI,uBAClB,CACF,CACF"}
@@ -0,0 +1,51 @@
1
+ import { SDK_VERSION } from "../primitives/version.js";
2
+ //#region src/http/attribution.d.ts
3
+ /**
4
+ * This package's version, mirrored from `package.json`.
5
+ *
6
+ * A literal rather than a runtime manifest read, because the bundle targets
7
+ * neutral platforms where no module loader is guaranteed. Keep it in step with
8
+ * `package.json` on release.
9
+ */
10
+ /**
11
+ * Static PUBLIC application identity sent to providers.
12
+ *
13
+ * Every field is a public product fact, safe on every request. No secrets, local
14
+ * paths, prompt text, or per-user identifiers belong here, and nothing
15
+ * per-request may influence the values.
16
+ */
17
+ interface AppIdentity {
18
+ /** `User-Agent` product token (lowercase, hyphenated). */
19
+ product: string;
20
+ /** Product version. */
21
+ version: string;
22
+ /** Home URL of the app, used as the `User-Agent` comment. */
23
+ url: string;
24
+ }
25
+ /**
26
+ * This SDK's own identity: the default every adapter sends.
27
+ *
28
+ * An application that needs its own identity passes one to
29
+ * {@link attributionHeaders}; omission falls back here.
30
+ */
31
+ declare const APP_IDENTITY: AppIdentity;
32
+ /**
33
+ * The standard `User-Agent` value: `product/version (+url)`.
34
+ *
35
+ * The parenthesized `+url` comment is the conventional self-identification form
36
+ * (RFC 9110 §10.1.5 product-plus-comment syntax).
37
+ * @param identity - the identity to render; defaults to {@link APP_IDENTITY}.
38
+ * @returns the ready-to-send header value.
39
+ */
40
+ declare function userAgent(identity?: AppIdentity): string;
41
+ /**
42
+ * Build the attribution headers an adapter sends on every provider request.
43
+ *
44
+ * Header names are lowercase; HTTP field names are case-insensitive on the wire.
45
+ * @param identity - the identity to send; defaults to {@link APP_IDENTITY}.
46
+ * @returns headers to merge into the provider request.
47
+ */
48
+ declare function attributionHeaders(identity?: AppIdentity): Record<string, string>;
49
+ //#endregion
50
+ export { APP_IDENTITY, AppIdentity, attributionHeaders, userAgent };
51
+ //# sourceMappingURL=attribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attribution.d.ts","names":[],"sources":["../../src/http/attribution.ts"],"mappings":";;;;;;;;;;;;;;;;UA2BiB;;EAEf;;EAEA;;EAEA;;;;;;;;cASW,cAAc;;;;;;;;;iBAcX,UAAU,WAAU;;;;;;;;iBAWpB,mBAAmB,WAAU,cAA6B"}
@@ -0,0 +1,2 @@
1
+ import{SDK_VERSION as e}from"../primitives/version.js";const t={product:`ai-agent-sdk`,version:e,url:`https://github.com/dinh-ai/ai-agent-sdk`};function n(e=t){return`${e.product}/${e.version} (+${e.url})`}function r(e=t){return{"user-agent":n(e)}}export{t as APP_IDENTITY,e as SDK_VERSION,r as attributionHeaders,n as userAgent};
2
+ //# sourceMappingURL=attribution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attribution.js","names":[],"sources":["../../src/http/attribution.ts"],"sourcesContent":["/**\n * The non-secret product identity every provider request sends as `User-Agent`.\n *\n * Centralized so adapters cannot drift apart, and defaulted so that omitting the\n * argument cannot silently suppress attribution.\n *\n * @module ai-agent-sdk/core/http/attribution\n */\n\nimport { SDK_VERSION } from '../primitives/version.ts'\n\nexport { SDK_VERSION }\n\n/**\n * This package's version, mirrored from `package.json`.\n *\n * A literal rather than a runtime manifest read, because the bundle targets\n * neutral platforms where no module loader is guaranteed. Keep it in step with\n * `package.json` on release.\n */\n/**\n * Static PUBLIC application identity sent to providers.\n *\n * Every field is a public product fact, safe on every request. No secrets, local\n * paths, prompt text, or per-user identifiers belong here, and nothing\n * per-request may influence the values.\n */\nexport interface AppIdentity {\n /** `User-Agent` product token (lowercase, hyphenated). */\n product: string\n /** Product version. */\n version: string\n /** Home URL of the app, used as the `User-Agent` comment. */\n url: string\n}\n\n/**\n * This SDK's own identity: the default every adapter sends.\n *\n * An application that needs its own identity passes one to\n * {@link attributionHeaders}; omission falls back here.\n */\nexport const APP_IDENTITY: AppIdentity = {\n product: 'ai-agent-sdk',\n version: SDK_VERSION,\n url: 'https://github.com/dinh-ai/ai-agent-sdk',\n}\n\n/**\n * The standard `User-Agent` value: `product/version (+url)`.\n *\n * The parenthesized `+url` comment is the conventional self-identification form\n * (RFC 9110 §10.1.5 product-plus-comment syntax).\n * @param identity - the identity to render; defaults to {@link APP_IDENTITY}.\n * @returns the ready-to-send header value.\n */\nexport function userAgent(identity: AppIdentity = APP_IDENTITY): string {\n return `${identity.product}/${identity.version} (+${identity.url})`\n}\n\n/**\n * Build the attribution headers an adapter sends on every provider request.\n *\n * Header names are lowercase; HTTP field names are case-insensitive on the wire.\n * @param identity - the identity to send; defaults to {@link APP_IDENTITY}.\n * @returns headers to merge into the provider request.\n */\nexport function attributionHeaders(identity: AppIdentity = APP_IDENTITY): Record<string, string> {\n return { 'user-agent': userAgent(identity) }\n}\n"],"mappings":"uDA0CA,MAAa,EAA4B,CACvC,QAAS,eACT,QAAS,EACT,IAAK,yCACP,EAUA,SAAgB,EAAU,EAAwB,EAAsB,CACtE,MAAO,GAAG,EAAS,QAAQ,GAAG,EAAS,QAAQ,KAAK,EAAS,IAAI,EACnE,CASA,SAAgB,EAAmB,EAAwB,EAAsC,CAC/F,MAAO,CAAE,aAAc,EAAU,CAAQ,CAAE,CAC7C"}
@@ -0,0 +1,70 @@
1
+ import { Branded, MessageId, ProviderRequestId, ReasoningEffortId, ToolCallId } from "./primitives/brand.js";
2
+ import { ModelFailure, normalizeModelFailure } from "./errors/failure.js";
3
+ import { JsonObject, JsonValue, isJsonValue } from "./primitives/json.js";
4
+ import { AssistantTextPhase, ContentBlock, ContentBlockMap, ContentBlockType, ImageBlock, ImageDetail, ImageMediaType, ImageSource, NativeToolCallBlock, ReasoningBlock, TextAnnotation, TextAnnotationMap, TextBlock, ToolCallBlock, ToolResultBlock, UrlCitationAnnotation } from "./message/content.js";
5
+ import { FinishReason, FinishReasonMap, ReplayEnvelope, StreamChunk, TokenUsage } from "./stream/chunk.js";
6
+ import { AgentSdkError, CONTEXT_WINDOW_EXCEEDED_CODE, EMPTY_RESPONSE_CODE, INVALID_CREDENTIAL_CODE, MISSING_CREDENTIAL_CODE, QUOTA_EXCEEDED_CODE, errorChain, isAgentSdkError, isContextWindowExceededError, isQuotaExceededError } from "./errors/agent-sdk-error.js";
7
+ import { CorrelationContext, ObservationRunScope, SpanId, TraceId, createObservationRunScope, createOperationId, createSpanId, createTraceId, freezeCorrelation, isSpanId, isTraceId, traceparent } from "./observation/context.js";
8
+ import { ObservationEvent, ObservationEventName, ObservationPhase, ObservationPriority, ObservationResource, ObservationResourceInput, OperationStatus, SafeErrorRecord, safeErrorRecord } from "./observation/event.js";
9
+ import { CaptureReceipt, DeliveryMode, NOOP_OBSERVATION_PORT, ObservationBoundary, ObservationDeliverySummary, ObservationPort, ObservationSpan, ObservationSpanName, OpenObservationSpanInput, createCoreSpan, disabledDeliverySummary, snapshotObservationSpan, validObservationSpan, validateCaptureReceipt } from "./observation/port.js";
10
+ import { AttemptUsageReport, DispatchState, UsageAdditionResult, UsageCounters, UsageCoverage, UsageValidationResult, addUsageCounters, classifyUsageCoverage, hasUsageCounters, possiblyBilledAttemptsWithoutUsage, validateUsageCounters } from "./observation/usage.js";
11
+ import { LogLevel, SdkLogger } from "./logging/types.js";
12
+ import { EndProviderAttemptInput, ModelCallHandle, ModelCallObservationError, ModelCallReport, ModelInvocationContext, OBSERVATION_ERROR_CODES, ProviderAttemptHandle, ProviderRetryScheduledInput, StartProviderAttemptInput } from "./observation/report.js";
13
+ import { A2AMessageSource, AgentMessageSource, AssistantMessage, AssistantProvenance, Message, MessageSource, MessageSourceMap, ModelMessageSource, ToolMessageSource, ToolResultMessage, ToolResultMessageInput, UserMessage, createAssistantMessage, createMessage, createTextMessage, createToolResultMessage, createUserMessage, freezeMessage } from "./message/message.js";
14
+ import { ModelToolSchema, NativeImageGenerationTool, NativeToolName, NativeToolSchema, NativeToolSchemaMap, NativeWebSearchTool, ToolChoice, ToolSchema, WebSearchLocation, isNativeToolSchema } from "./contract/tool.js";
15
+ import { JsonSchemaOutputFormat, ModelOutputFormat, TextOutputFormat } from "./contract/output-format.js";
16
+ import { GenerateOptions } from "./contract/generate-options.js";
17
+ import { SupportSafeError } from "./support-safe/error.js";
18
+ import { ModelCatalogOptions, ModelCatalogSnapshot, ModelCatalogState, ModelContext, ModelInfo, ModelModality, ModelModalityMap, ModelReasoningInfo, ProviderInfo, ReasoningEffortInfo, ResolvedModelInfo } from "./contract/model-info.js";
19
+ import { AlwaysRetryPolicyConfig, BackoffConfig, MAX_TIMER_DELAY_MS, NormalRetryPolicyConfig, ResolvedAlwaysRetryPolicy, ResolvedNormalRetryPolicy, ResolvedRetryBackoff, ResolvedRetryPolicy, RetryPolicyConfig, backoffDelayMs, isRetryable, resolveRetryPolicy } from "./contract/retry-policy.js";
20
+ import { ModelAdapter, PreparedAdapterCall } from "./contract/adapter.js";
21
+ import { CallConfig, CallConfigAdapterDefaults, callConfigEquals } from "./contract/call-config.js";
22
+ import { contentHasImage, projectImagesForTextModel, textOnlyImageText } from "./message/projection.js";
23
+ import { deepFreeze } from "./primitives/freeze.js";
24
+ import { assertNever } from "./primitives/never.js";
25
+ import { detachedFrozen } from "./primitives/snapshot.js";
26
+ import { SDK_VERSION } from "./primitives/version.js";
27
+ import { ToolDefinition, ToolRunContext, defineTool } from "./agent/tool/definition.js";
28
+ import { MODEL_ERROR_CODES, ModelError, ModelErrorOptions, REGISTRY_ERROR_CODES } from "./errors/model-error.js";
29
+ import { BlockAssembler } from "./stream/assembler.js";
30
+ import { withIdleTimeout } from "./stream/idle-timeout.js";
31
+ import { ApprovalBroker, ApprovalDecision, ApprovalRequest, ApprovalStateStore, InteractiveApprovalBroker, InteractiveApprovalBrokerOptions, createApprovalBroker, createApprovalRequest, fixedApprovalBroker, withApprovalPersistence } from "./agent/tool/approval.js";
32
+ import { AdapterRegistrationHandle, ModelProviderPlugin, ModelProviderRegistrar, PLUGIN_ERROR_CODES, PluginError, PluginRegistrationHandle, StreamMiddleware } from "./plugin/provider-plugin.js";
33
+ import { ModelRegistry, ModelRegistryOptions, PreparedCall } from "./runtime/registry.js";
34
+ import { RetryAttempt, WithRetryOptions, withRetry } from "./runtime/with-retry.js";
35
+ import { ContextSection, ContextSectionResolveInput, ContextSectionScope, ContextSectionState, ContextToolTouch } from "./agent/context/types.js";
36
+ import { InteractiveUserInputBroker, InteractiveUserInputBrokerOptions, UserInputAnswer, UserInputBroker, UserInputDecision, UserInputOption, UserInputQuestion, UserInputRequest, UserInputResponse, createUserInputBroker, fixedUserInputBroker } from "./agent/mode/user-input.js";
37
+ import { AgentCompactionConfig, AgentCompactionOptions, resolveCompactionConfig } from "./agent/memory/compaction-config.js";
38
+ import { ObservationDeliveryAck, ObservationDeliveryBatch, ObservationExportItem, RunReport, RunTerminalRecord } from "./agent/accounting/delivery-types.js";
39
+ import { COMPACTION_INSTRUCTION, CompactionResult, ContextCompactor, ContextCompactorOptions } from "./agent/memory/compaction.js";
40
+ import { AgentMemory, AgentMemoryConfig, AgentMemoryConfigInput, AgentMemoryItem, AgentMemoryKind, AgentMemorySeed, AgentMemorySnapshot, resolveMemoryConfig } from "./agent/memory/memory.js";
41
+ 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";
42
+ import { SKILL_ERROR_CODES, SKILL_PROVIDER_API_VERSION } from "./agent/skill/provider/config.js";
43
+ import { ActivatedSkillSnapshot, RuntimeSkillCandidate, RuntimeSkillLookupOptions, RuntimeSkillSource, SkillCatalogSnapshot, SkillProviderDefinition, SkillProviderPlugin, SkillProviderPluginDefinition, SkillReference } from "./agent/skill/provider/types.js";
44
+ import { SkillCatalog, SkillCatalogOptions } from "./agent/skill/catalog.js";
45
+ import { AgentSkillOptions, ResolvedAgentSkillOptions, SKILL_TOOL_NAMES, createSkillTools, renderSkillCatalog, resolveSkillOptions } from "./agent/skill/tools.js";
46
+ import { AgentDefinition, AgentDefinitionInput, AgentDefinitionOverrides, CloneAgentOverrides, DefinedAgent } from "./agent/define/definition.js";
47
+ import { AgentInput } from "./agent/define/session/types.js";
48
+ import { MemoryBinding, MemoryCommitInput, MemoryCommitResult, MemoryLoadResult, MemoryScope, MemoryStore, MemoryStoreDefinition, MemoryStoreOptions } from "./agent/memory/persistence-types.js";
49
+ import { estimateContextTokens, estimateMessageTokens } from "./agent/memory/token-estimator.js";
50
+ import { selectCompactablePrefix } from "./agent/memory/surface-compaction.js";
51
+ import { RuntimeSchema, defineToolFromSchema } from "./agent/tool/schema.js";
52
+ import { ToolExecutionBackend, ToolExecutionCapabilities, ToolExecutionRequest, ToolExecutionStore, ToolOperation, ToolOperationClaim, createToolExecutionInterceptor, localToolExecutionBackend } from "./agent/tool/execution.js";
53
+ import { RuntimeProviderInfo } from "./composition/provider/types.js";
54
+ import { OBSERVATION_EXPORTER_API_VERSION, ObservationExporterPlugin, ObservationExporterPluginDefinition, RuntimeObservationExporterRegistration } from "./composition/exporter/types.js";
55
+ import { RuntimeAgent, RuntimeAgentBindingInput, RuntimeAgentDefinition, RuntimeAgentDefinitionInput, RuntimeAgentInvocationOptions, RuntimeAgentLimits, RuntimeAgentResponse, RuntimeAgentRunEvent, RuntimeAgentRunEventContext, RuntimeAgentRunHandle, RuntimeAgentSession, RuntimeAgentSessionOptions, RuntimeAgentSessionSnapshot } from "./composition/agent/types.js";
56
+ import { cloneAgent, defineAgent } from "./composition/agent/author.js";
57
+ import { CapabilityIdentityConflict } from "./errors/capability-identity.js";
58
+ import { RuntimeModelCatalogSnapshot } from "./composition/model-catalog/types.js";
59
+ import { AgentTeamMemberInput, RuntimeAgentTeam, RuntimeAgentTeamEvent, RuntimeAgentTeamOptions } from "./composition/team/types.js";
60
+ import { AgentRuntime, AgentRuntimeOptions, DiagnosticSnapshot, RuntimeCloseReport, RuntimeObservationResourceInput, RuntimeOwnerObservabilityOptions } from "./composition/runtime/types.js";
61
+ import { createAgentRuntime } from "./composition/runtime/public.js";
62
+ import { waitForSettlement } from "./async/settlement.js";
63
+ import { ApiKeyCheck, ApiKeyRejection, assertUsableApiKey, normalizeApiKey } from "./http/api-key.js";
64
+ import { APP_IDENTITY, AppIdentity, attributionHeaders, userAgent } from "./http/attribution.js";
65
+ import { MEMORY_ERROR_CODES, MEMORY_STORE_API_VERSION } from "./composition/memory/config.js";
66
+ import { defineMemoryStore } from "./composition/memory/definition.js";
67
+ import { defineSkillProviderPlugin } from "./agent/skill/provider/definition.js";
68
+ import { defineObservationExporter } from "./composition/exporter/definition.js";
69
+ import { CONTEXT_SECTION_ID_PATTERN, CONTEXT_SECTION_INVALID, MAX_CONTEXT_SECTION_TEXT_BYTES, defineContextSection } from "./agent/context/section.js";
70
+ export { type A2AMessageSource, APP_IDENTITY, type ActivatedSkillSnapshot, type AdapterRegistrationHandle, type AgentCompactionConfig, type AgentCompactionOptions, type AgentDefinition, type AgentDefinitionInput, type AgentDefinitionOverrides, type AgentInput, AgentMemory, type AgentMemoryConfig, type AgentMemoryConfigInput, type AgentMemoryItem, type AgentMemoryKind, type AgentMemorySeed, type AgentMemorySnapshot, type AgentMessageSource, type AgentRuntime, type AgentRuntimeOptions, AgentSdkError, type AgentSkillOptions, type AgentTeamMemberInput, type AlwaysRetryPolicyConfig, type ApiKeyCheck, type ApiKeyRejection, type AppIdentity, type ApprovalBroker, type ApprovalDecision, type ApprovalRequest, type ApprovalStateStore, type AssistantMessage, type AssistantProvenance, type AssistantTextPhase, type AttemptUsageReport, type BackoffConfig, BlockAssembler, type Branded, COMPACTION_INSTRUCTION, CONTEXT_SECTION_ID_PATTERN, CONTEXT_SECTION_INVALID, CONTEXT_WINDOW_EXCEEDED_CODE, type CallConfig, type CallConfigAdapterDefaults, type CapabilityIdentityConflict, type CaptureReceipt, type CloneAgentOverrides, type CompactionResult, type ContentBlock, type ContentBlockMap, type ContentBlockType, ContextCompactor, type ContextCompactorOptions, type ContextSection, type ContextSectionResolveInput, type ContextSectionScope, type ContextSectionState, type ContextToolTouch, type CorrelationContext, type DefinedAgent, type DeliveryMode, type DiagnosticSnapshot, type DispatchState, EMPTY_RESPONSE_CODE, type EndProviderAttemptInput, type FinishReason, type FinishReasonMap, type GenerateOptions, INVALID_CREDENTIAL_CODE, type ImageBlock, type ImageDetail, type ImageMediaType, type ImageSource, type InteractiveApprovalBroker, type InteractiveApprovalBrokerOptions, type InteractiveUserInputBroker, type InteractiveUserInputBrokerOptions, type JsonObject, type JsonSchemaOutputFormat, type JsonValue, type LogLevel, MAX_CONTEXT_SECTION_TEXT_BYTES, 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, MAX_TIMER_DELAY_MS, MEMORY_ERROR_CODES, MEMORY_STORE_API_VERSION, MISSING_CREDENTIAL_CODE, MODEL_ERROR_CODES, type MemoryBinding, type MemoryCommitInput, type MemoryCommitResult, type MemoryLoadResult, type MemoryScope, type MemoryStore, type MemoryStoreDefinition, type MemoryStoreOptions, type Message, MessageId, type MessageSource, type MessageSourceMap, ModelAdapter, type ModelCallHandle, ModelCallObservationError, type ModelCallReport, type ModelCatalogOptions, type ModelCatalogSnapshot, type ModelCatalogState, type ModelContext, ModelError, type ModelErrorOptions, type ModelFailure, type ModelInfo, type ModelInvocationContext, type ModelMessageSource, type ModelModality, type ModelModalityMap, type ModelOutputFormat, type ModelProviderPlugin, type ModelProviderRegistrar, type ModelReasoningInfo, ModelRegistry, type ModelRegistryOptions, type ModelToolSchema, NOOP_OBSERVATION_PORT, type NativeImageGenerationTool, type NativeToolCallBlock, type NativeToolName, type NativeToolSchema, type NativeToolSchemaMap, type NativeWebSearchTool, type NormalRetryPolicyConfig, OBSERVATION_ERROR_CODES, OBSERVATION_EXPORTER_API_VERSION, type ObservationBoundary, type ObservationDeliveryAck, type ObservationDeliveryBatch, type ObservationDeliverySummary, type ObservationEvent, type ObservationEventName, type ObservationExportItem, type ObservationExporterPlugin, type ObservationExporterPluginDefinition, type ObservationPhase, type ObservationPort, type ObservationPriority, type ObservationResource, type ObservationResourceInput, type ObservationRunScope, type ObservationSpan, type ObservationSpanName, type OpenObservationSpanInput, type OperationStatus, PLUGIN_ERROR_CODES, PluginError, type PluginRegistrationHandle, type PreparedAdapterCall, type PreparedCall, type ProviderAttemptHandle, type ProviderInfo, ProviderRequestId, type ProviderRetryScheduledInput, QUOTA_EXCEEDED_CODE, REGISTRY_ERROR_CODES, type ReasoningBlock, ReasoningEffortId, type ReasoningEffortInfo, type ReplayEnvelope, type ResolvedAgentSkillOptions, type ResolvedAlwaysRetryPolicy, type ResolvedModelInfo, type ResolvedNormalRetryPolicy, type ResolvedRetryBackoff, type ResolvedRetryPolicy, type RetryAttempt, type RetryPolicyConfig, type RunReport, type RunTerminalRecord, type RuntimeAgent, type RuntimeAgentBindingInput, type RuntimeAgentDefinition, type RuntimeAgentDefinitionInput, type RuntimeAgentInvocationOptions, type RuntimeAgentLimits, type RuntimeAgentResponse, type RuntimeAgentRunEvent, type RuntimeAgentRunEventContext, type RuntimeAgentRunHandle, type RuntimeAgentSession, type RuntimeAgentSessionOptions, type RuntimeAgentSessionSnapshot, type RuntimeAgentTeam, type RuntimeAgentTeamEvent, type RuntimeAgentTeamOptions, type RuntimeCloseReport, type RuntimeModelCatalogSnapshot, type RuntimeObservationExporterRegistration, type RuntimeObservationResourceInput, type RuntimeOwnerObservabilityOptions, type RuntimeProviderInfo, type RuntimeSchema, type RuntimeSkillCandidate, type RuntimeSkillLookupOptions, type RuntimeSkillSource, SDK_VERSION, SKILL_ERROR_CODES, SKILL_ID_PATTERN, SKILL_PROVIDER_API_VERSION, SKILL_TOOL_NAMES, type SafeErrorRecord, type SdkLogger, type SkillCandidate, SkillCatalog, type SkillCatalogOptions, type SkillCatalogSnapshot, type SkillDefinition, type SkillDefinitionInput, type SkillInvocationPolicy, type SkillLookupOptions, type SkillProvider, type SkillProviderDefinition, type SkillProviderListOptions, type SkillProviderPlugin, type SkillProviderPluginDefinition, type SkillReference, type SkillResourceBase, type SkillResourceSummary, type SkillSource, type SkillSummary, type SpanId, type StartProviderAttemptInput, type StreamChunk, type StreamMiddleware, type SupportSafeError, type TextAnnotation, type TextAnnotationMap, type TextBlock, type TextOutputFormat, type TokenUsage, type ToolCallBlock, ToolCallId, type ToolChoice, type ToolDefinition, type ToolExecutionBackend, type ToolExecutionCapabilities, type ToolExecutionRequest, type ToolExecutionStore, type ToolMessageSource, type ToolOperation, type ToolOperationClaim, type ToolResultBlock, type ToolResultMessage, type ToolResultMessageInput, type ToolRunContext, type ToolSchema, type TraceId, type UrlCitationAnnotation, type UsageAdditionResult, type UsageCounters, type UsageCoverage, type UsageValidationResult, type UserInputAnswer, type UserInputBroker, type UserInputDecision, type UserInputOption, type UserInputQuestion, type UserInputRequest, type UserInputResponse, type UserMessage, type WebSearchLocation, type WithRetryOptions, addUsageCounters, assertNever, assertUsableApiKey, attributionHeaders, backoffDelayMs, callConfigEquals, classifyUsageCoverage, cloneAgent, contentHasImage, createAgentRuntime, createApprovalBroker, createApprovalRequest, createAssistantMessage, createCoreSpan, createMessage, createObservationRunScope, createOperationId, createSkillTools, createSpanId, createTextMessage, createToolExecutionInterceptor, createToolResultMessage, createTraceId, createUserInputBroker, createUserMessage, deepFreeze, defineAgent, defineContextSection, defineMemoryStore, defineObservationExporter, defineSkill, defineSkillProvider, defineSkillProviderPlugin, defineTool, defineToolFromSchema, detachedFrozen, disabledDeliverySummary, errorChain, estimateContextTokens, estimateMessageTokens, fixedApprovalBroker, fixedUserInputBroker, freezeCorrelation, freezeMessage, hasUsageCounters, isAgentSdkError, isContextWindowExceededError, isJsonValue, isNativeToolSchema, isQuotaExceededError, isRetryable, isSpanId, isTraceId, localToolExecutionBackend, normalizeApiKey, normalizeModelFailure, possiblyBilledAttemptsWithoutUsage, projectImagesForTextModel, renderSkillCatalog, resolveCompactionConfig, resolveMemoryConfig, resolveRetryPolicy, resolveSkillOptions, safeErrorRecord, selectCompactablePrefix, snapshotObservationSpan, textOnlyImageText, traceparent, userAgent, validObservationSpan, validateCandidate, validateCaptureReceipt, validateSkillId, validateSkillResourcePath, validateSkillSource, validateUsageCounters, waitForSettlement, withApprovalPersistence, withIdleTimeout, withRetry };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{MessageId as e,ProviderRequestId as t,ReasoningEffortId as n,ToolCallId as r}from"./primitives/brand.js";import{deepFreeze as i}from"./primitives/freeze.js";import{isJsonValue as a}from"./primitives/json.js";import{assertNever as o}from"./primitives/never.js";import{detachedFrozen as s}from"./primitives/snapshot.js";import{SDK_VERSION as c}from"./primitives/version.js";import{waitForSettlement as l}from"./async/settlement.js";import{createObservationRunScope as u,createOperationId as d,createSpanId as f,createTraceId as p,freezeCorrelation as m,isSpanId as h,isTraceId as g,traceparent as _}from"./observation/context.js";import{safeErrorRecord as v}from"./observation/event.js";import{NOOP_OBSERVATION_PORT as y,createCoreSpan as b,disabledDeliverySummary as x,snapshotObservationSpan as S,validObservationSpan as C,validateCaptureReceipt as w}from"./observation/port.js";import{AgentSdkError as T,CONTEXT_WINDOW_EXCEEDED_CODE as E,EMPTY_RESPONSE_CODE as D,INVALID_CREDENTIAL_CODE as O,MISSING_CREDENTIAL_CODE as k,QUOTA_EXCEEDED_CODE as A,errorChain as j,isAgentSdkError as M,isContextWindowExceededError as N,isQuotaExceededError as P}from"./errors/agent-sdk-error.js";import{ModelCallObservationError as F,OBSERVATION_ERROR_CODES as I}from"./observation/report.js";import{addUsageCounters as L,classifyUsageCoverage as R,hasUsageCounters as z,possiblyBilledAttemptsWithoutUsage as B,validateUsageCounters as V}from"./observation/usage.js";import{PLUGIN_ERROR_CODES as H,PluginError as U}from"./plugin/provider-plugin.js";import{MODEL_ERROR_CODES as W,ModelError as G,REGISTRY_ERROR_CODES as K}from"./errors/model-error.js";import{normalizeModelFailure as q}from"./errors/failure.js";import{createAssistantMessage as J,createMessage as Y,createTextMessage as X,createToolResultMessage as Z,createUserMessage as Q,freezeMessage as $}from"./message/message.js";import{contentHasImage as ee,projectImagesForTextModel as te,textOnlyImageText as ne}from"./message/projection.js";import{BlockAssembler as re}from"./stream/assembler.js";import{withIdleTimeout as ie}from"./stream/idle-timeout.js";import{ModelAdapter as ae}from"./contract/adapter.js";import{callConfigEquals as oe}from"./contract/call-config.js";import{MAX_TIMER_DELAY_MS as se,backoffDelayMs as ce,isRetryable as le,resolveRetryPolicy as ue}from"./contract/retry-policy.js";import{isNativeToolSchema as de}from"./contract/tool.js";import{ModelRegistry as fe}from"./runtime/registry.js";import{withRetry as pe}from"./runtime/with-retry.js";import{assertUsableApiKey as me,normalizeApiKey as he}from"./http/api-key.js";import{APP_IDENTITY as ge,attributionHeaders as _e,userAgent as ve}from"./http/attribution.js";import{AgentMemory as ye,resolveMemoryConfig as be}from"./agent/memory/memory.js";import{estimateContextTokens as xe,estimateMessageTokens as Se}from"./agent/memory/token-estimator.js";import{selectCompactablePrefix as Ce}from"./agent/memory/surface-compaction.js";import{COMPACTION_INSTRUCTION as we,ContextCompactor as Te}from"./agent/memory/compaction.js";import{resolveCompactionConfig as Ee}from"./agent/memory/compaction-config.js";import{MEMORY_ERROR_CODES as De,MEMORY_STORE_API_VERSION as Oe}from"./composition/memory/config.js";import{defineMemoryStore as ke}from"./composition/memory/definition.js";import{MAX_SKILL_DESCRIPTION_CHARS as Ae,MAX_SKILL_ID_CHARS as je,MAX_SKILL_INSTRUCTIONS_CHARS as Me,MAX_SKILL_NAME_CHARS as Ne,MAX_SKILL_RESOURCE_CHARS as Pe,MAX_SKILL_RESOURCE_PATH_CHARS as Fe,SKILL_ID_PATTERN as Ie,defineSkill as Le,defineSkillProvider as Re,validateCandidate as ze,validateSkillId as Be,validateSkillResourcePath as Ve,validateSkillSource as He}from"./agent/skill/definition.js";import{SKILL_ERROR_CODES as Ue,SKILL_PROVIDER_API_VERSION as We}from"./agent/skill/provider/config.js";import{defineSkillProviderPlugin as Ge}from"./agent/skill/provider/definition.js";import{SkillCatalog as Ke}from"./agent/skill/catalog.js";import{defineTool as qe}from"./agent/tool/definition.js";import{SKILL_TOOL_NAMES as Je,createSkillTools as Ye,renderSkillCatalog as Xe,resolveSkillOptions as Ze}from"./agent/skill/tools.js";import{OBSERVATION_EXPORTER_API_VERSION as Qe}from"./composition/exporter/types.js";import{CONTEXT_SECTION_ID_PATTERN as $e,CONTEXT_SECTION_INVALID as et,MAX_CONTEXT_SECTION_TEXT_BYTES as tt,defineContextSection as nt}from"./agent/context/section.js";import{createApprovalBroker as rt,createApprovalRequest as it,fixedApprovalBroker as at,withApprovalPersistence as ot}from"./agent/tool/approval.js";import{createAgentRuntime as st}from"./composition/runtime/public.js";import{cloneAgent as ct,defineAgent as lt}from"./composition/agent/author.js";import{defineObservationExporter as ut}from"./composition/exporter/definition.js";import{createUserInputBroker as dt,fixedUserInputBroker as ft}from"./agent/mode/user-input.js";import{defineToolFromSchema as pt}from"./agent/tool/schema.js";import{createToolExecutionInterceptor as mt,localToolExecutionBackend as ht}from"./agent/tool/execution.js";export{ge as APP_IDENTITY,ye as AgentMemory,T as AgentSdkError,re as BlockAssembler,we as COMPACTION_INSTRUCTION,$e as CONTEXT_SECTION_ID_PATTERN,et as CONTEXT_SECTION_INVALID,E as CONTEXT_WINDOW_EXCEEDED_CODE,Te as ContextCompactor,D as EMPTY_RESPONSE_CODE,O as INVALID_CREDENTIAL_CODE,tt as MAX_CONTEXT_SECTION_TEXT_BYTES,Ae as MAX_SKILL_DESCRIPTION_CHARS,je as MAX_SKILL_ID_CHARS,Me as MAX_SKILL_INSTRUCTIONS_CHARS,Ne as MAX_SKILL_NAME_CHARS,Pe as MAX_SKILL_RESOURCE_CHARS,Fe as MAX_SKILL_RESOURCE_PATH_CHARS,se as MAX_TIMER_DELAY_MS,De as MEMORY_ERROR_CODES,Oe as MEMORY_STORE_API_VERSION,k as MISSING_CREDENTIAL_CODE,W as MODEL_ERROR_CODES,e as MessageId,ae as ModelAdapter,F as ModelCallObservationError,G as ModelError,fe as ModelRegistry,y as NOOP_OBSERVATION_PORT,I as OBSERVATION_ERROR_CODES,Qe as OBSERVATION_EXPORTER_API_VERSION,H as PLUGIN_ERROR_CODES,U as PluginError,t as ProviderRequestId,A as QUOTA_EXCEEDED_CODE,K as REGISTRY_ERROR_CODES,n as ReasoningEffortId,c as SDK_VERSION,Ue as SKILL_ERROR_CODES,Ie as SKILL_ID_PATTERN,We as SKILL_PROVIDER_API_VERSION,Je as SKILL_TOOL_NAMES,Ke as SkillCatalog,r as ToolCallId,L as addUsageCounters,o as assertNever,me as assertUsableApiKey,_e as attributionHeaders,ce as backoffDelayMs,oe as callConfigEquals,R as classifyUsageCoverage,ct as cloneAgent,ee as contentHasImage,st as createAgentRuntime,rt as createApprovalBroker,it as createApprovalRequest,J as createAssistantMessage,b as createCoreSpan,Y as createMessage,u as createObservationRunScope,d as createOperationId,Ye as createSkillTools,f as createSpanId,X as createTextMessage,mt as createToolExecutionInterceptor,Z as createToolResultMessage,p as createTraceId,dt as createUserInputBroker,Q as createUserMessage,i as deepFreeze,lt as defineAgent,nt as defineContextSection,ke as defineMemoryStore,ut as defineObservationExporter,Le as defineSkill,Re as defineSkillProvider,Ge as defineSkillProviderPlugin,qe as defineTool,pt as defineToolFromSchema,s as detachedFrozen,x as disabledDeliverySummary,j as errorChain,xe as estimateContextTokens,Se as estimateMessageTokens,at as fixedApprovalBroker,ft as fixedUserInputBroker,m as freezeCorrelation,$ as freezeMessage,z as hasUsageCounters,M as isAgentSdkError,N as isContextWindowExceededError,a as isJsonValue,de as isNativeToolSchema,P as isQuotaExceededError,le as isRetryable,h as isSpanId,g as isTraceId,ht as localToolExecutionBackend,he as normalizeApiKey,q as normalizeModelFailure,B as possiblyBilledAttemptsWithoutUsage,te as projectImagesForTextModel,Xe as renderSkillCatalog,Ee as resolveCompactionConfig,be as resolveMemoryConfig,ue as resolveRetryPolicy,Ze as resolveSkillOptions,v as safeErrorRecord,Ce as selectCompactablePrefix,S as snapshotObservationSpan,ne as textOnlyImageText,_ as traceparent,ve as userAgent,C as validObservationSpan,ze as validateCandidate,w as validateCaptureReceipt,Be as validateSkillId,Ve as validateSkillResourcePath,He as validateSkillSource,V as validateUsageCounters,l as waitForSettlement,ot as withApprovalPersistence,ie as withIdleTimeout,pe as withRetry};