@artinet/sdk 0.5.17 → 0.6.0-preview.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (316) hide show
  1. package/README.md +51 -557
  2. package/dist/browser/browser.d.ts +9 -0
  3. package/dist/browser/browser.js +10 -0
  4. package/dist/browser/client/a2a-client.d.ts +127 -0
  5. package/dist/browser/client/a2a-client.js +233 -0
  6. package/dist/browser/client/index.d.ts +1 -0
  7. package/dist/browser/client/index.js +1 -0
  8. package/dist/browser/config/index.d.ts +158 -0
  9. package/dist/browser/config/index.js +155 -0
  10. package/dist/browser/config/observability.d.ts +119 -0
  11. package/dist/browser/config/observability.js +35 -0
  12. package/dist/browser/services/a2a/helpers/message-builder.d.ts +17 -0
  13. package/dist/browser/services/a2a/helpers/message-builder.js +66 -0
  14. package/dist/browser/transport/rpc/parser.d.ts +15 -0
  15. package/dist/browser/transport/rpc/parser.js +48 -0
  16. package/dist/browser/transport/rpc/rpc-client.d.ts +80 -0
  17. package/dist/browser/transport/rpc/rpc-client.js +189 -0
  18. package/dist/browser/transport/streaming/event-stream.d.ts +25 -0
  19. package/dist/browser/transport/streaming/event-stream.js +100 -0
  20. package/dist/browser/types/a2a/a2a.d.ts +378 -0
  21. package/dist/browser/types/a2a/a2a.js +14 -0
  22. package/dist/browser/types/a2a/builder.d.ts +43 -0
  23. package/dist/browser/types/a2a/index.d.ts +3 -0
  24. package/dist/browser/types/a2a/index.js +2 -0
  25. package/dist/{types/interfaces → browser/types}/client.d.ts +25 -27
  26. package/dist/browser/types/core/core.d.ts +31 -0
  27. package/dist/browser/types/core/index.d.ts +1 -0
  28. package/dist/browser/types/core/index.js +1 -0
  29. package/dist/{types/interfaces/services → browser/types}/index.d.ts +3 -0
  30. package/dist/{types/interfaces/services → browser/types}/index.js +3 -0
  31. package/dist/browser/types/mcp/index.d.ts +1 -0
  32. package/dist/browser/types/mcp/index.js +1 -0
  33. package/dist/{types/interfaces/services/mcp/service.d.ts → browser/types/mcp/mcp.d.ts} +4 -3
  34. package/dist/browser/types/mcp/mcp.js +5 -0
  35. package/dist/browser/types/storage.d.ts +21 -0
  36. package/dist/browser/types/utils/index.d.ts +1 -0
  37. package/dist/browser/types/utils/index.js +1 -0
  38. package/dist/browser/types/utils/transform.d.ts +64 -0
  39. package/dist/browser/types/utils/transform.js +35 -0
  40. package/dist/browser/utils/common/constants.d.ts +11 -0
  41. package/dist/browser/utils/common/constants.js +38 -0
  42. package/dist/browser/utils/common/errors.d.ts +24 -0
  43. package/dist/browser/utils/common/errors.js +42 -0
  44. package/dist/browser/utils/common/utils.d.ts +32 -0
  45. package/dist/browser/utils/common/utils.js +43 -0
  46. package/dist/client/a2a-client.d.ts +21 -19
  47. package/dist/client/a2a-client.js +30 -9
  48. package/dist/config/default.d.ts +50 -0
  49. package/dist/config/default.js +62 -0
  50. package/dist/config/index.d.ts +158 -0
  51. package/dist/config/index.js +155 -0
  52. package/dist/config/observability.d.ts +119 -0
  53. package/dist/config/observability.js +35 -0
  54. package/dist/extensions/otel.d.ts +98 -0
  55. package/dist/extensions/otel.js +190 -0
  56. package/dist/extensions/pino.d.ts +44 -0
  57. package/dist/extensions/pino.js +107 -0
  58. package/dist/extensions/winston.d.ts +47 -0
  59. package/dist/extensions/winston.js +114 -0
  60. package/dist/index.d.ts +2 -0
  61. package/dist/index.js +2 -0
  62. package/dist/server/express/errors.js +3 -3
  63. package/dist/server/express/middeware.d.ts +2 -2
  64. package/dist/server/express/middeware.js +36 -9
  65. package/dist/server/express/server.d.ts +9 -55
  66. package/dist/server/express/server.js +51 -32
  67. package/dist/services/a2a/execute.d.ts +6 -0
  68. package/dist/services/a2a/execute.js +25 -0
  69. package/dist/services/a2a/factory/builder.d.ts +21 -80
  70. package/dist/services/a2a/factory/builder.js +23 -13
  71. package/dist/services/a2a/factory/context.d.ts +15 -128
  72. package/dist/services/a2a/factory/context.js +31 -136
  73. package/dist/services/a2a/factory/handler.d.ts +6 -0
  74. package/dist/services/a2a/factory/{method.js → handler.js} +2 -2
  75. package/dist/services/a2a/factory/index.d.ts +1 -2
  76. package/dist/services/a2a/factory/index.js +1 -2
  77. package/dist/services/a2a/factory/service.d.ts +20 -7
  78. package/dist/services/a2a/factory/service.js +4 -4
  79. package/dist/services/a2a/factory/state-machine.d.ts +11 -0
  80. package/dist/services/a2a/factory/state-machine.js +66 -0
  81. package/dist/services/a2a/{state/update → handlers}/artifact.d.ts +4 -4
  82. package/dist/services/a2a/handlers/cancel-task.d.ts +11 -0
  83. package/dist/services/a2a/handlers/cancel-task.js +33 -0
  84. package/dist/services/a2a/handlers/get-task.d.ts +11 -0
  85. package/dist/services/a2a/handlers/get-task.js +13 -0
  86. package/dist/services/a2a/handlers/resubscribe-task.d.ts +11 -0
  87. package/dist/services/a2a/handlers/resubscribe-task.js +56 -0
  88. package/dist/services/a2a/handlers/send-message.d.ts +11 -0
  89. package/dist/services/a2a/handlers/send-message.js +35 -0
  90. package/dist/services/a2a/handlers/stream-message.d.ts +11 -0
  91. package/dist/services/a2a/handlers/stream-message.js +19 -0
  92. package/dist/services/a2a/handlers/update.d.ts +17 -0
  93. package/dist/services/a2a/handlers/update.js +114 -0
  94. package/dist/services/a2a/helpers/agentcard-builder.d.ts +9 -5
  95. package/dist/services/a2a/helpers/agentcard-builder.js +5 -0
  96. package/dist/services/a2a/helpers/content.d.ts +2 -2
  97. package/dist/services/a2a/helpers/content.js +4 -0
  98. package/dist/services/a2a/helpers/history.d.ts +6 -0
  99. package/dist/services/a2a/helpers/history.js +7 -0
  100. package/dist/services/a2a/helpers/index.d.ts +3 -1
  101. package/dist/services/a2a/helpers/index.js +3 -1
  102. package/dist/services/a2a/helpers/message-builder.d.ts +13 -8
  103. package/dist/services/a2a/helpers/message-builder.js +5 -0
  104. package/dist/services/a2a/helpers/part.d.ts +9 -9
  105. package/dist/services/a2a/helpers/references.d.ts +6 -0
  106. package/dist/services/a2a/helpers/references.js +22 -0
  107. package/dist/services/a2a/index.d.ts +9 -5
  108. package/dist/services/a2a/index.js +8 -5
  109. package/dist/services/a2a/managers.d.ts +23 -0
  110. package/dist/services/a2a/managers.js +95 -0
  111. package/dist/services/a2a/messenger.d.ts +35 -0
  112. package/dist/services/{core/managers/command.js → a2a/messenger.js} +27 -31
  113. package/dist/services/a2a/service.d.ts +41 -371
  114. package/dist/services/a2a/service.js +239 -70
  115. package/dist/services/a2a/state-machine.d.ts +18 -0
  116. package/dist/services/a2a/state-machine.js +76 -0
  117. package/dist/services/a2a/streams.d.ts +22 -0
  118. package/dist/services/a2a/streams.js +98 -0
  119. package/dist/services/core/index.d.ts +1 -2
  120. package/dist/services/core/index.js +1 -2
  121. package/dist/services/core/manager.d.ts +15 -0
  122. package/dist/services/core/manager.js +42 -0
  123. package/dist/services/mcp/service.d.ts +11 -15
  124. package/dist/services/mcp/service.js +16 -16
  125. package/dist/transport/index.d.ts +0 -1
  126. package/dist/transport/index.js +1 -1
  127. package/dist/transport/rpc/parser.d.ts +2 -2
  128. package/dist/transport/rpc/parser.js +7 -7
  129. package/dist/transport/rpc/rpc-client.d.ts +5 -5
  130. package/dist/transport/rpc/rpc-client.js +7 -7
  131. package/dist/transport/streaming/event-stream.d.ts +3 -3
  132. package/dist/transport/streaming/event-stream.js +11 -10
  133. package/dist/transport/trpc/a2a/factory/router.d.ts +479 -871
  134. package/dist/transport/trpc/a2a/factory/router.js +2 -2
  135. package/dist/transport/trpc/a2a/routes/info.d.ts +108 -8
  136. package/dist/transport/trpc/a2a/routes/info.js +6 -2
  137. package/dist/transport/trpc/a2a/routes/message/route.d.ts +113 -162
  138. package/dist/transport/trpc/a2a/routes/message/route.js +7 -13
  139. package/dist/transport/trpc/a2a/routes/tasks/route.d.ts +114 -212
  140. package/dist/transport/trpc/a2a/routes/tasks/route.js +16 -19
  141. package/dist/transport/trpc/a2a/trpc.d.ts +9 -253
  142. package/dist/types/a2a/a2a.d.ts +378 -0
  143. package/dist/types/a2a/a2a.js +14 -0
  144. package/dist/types/a2a/builder.d.ts +43 -0
  145. package/dist/types/a2a/index.d.ts +3 -0
  146. package/dist/types/a2a/index.js +2 -0
  147. package/dist/types/client.d.ts +133 -0
  148. package/dist/types/core/core.d.ts +31 -0
  149. package/dist/types/core/core.js +1 -0
  150. package/dist/types/core/index.d.ts +1 -0
  151. package/dist/types/core/index.js +1 -0
  152. package/dist/types/index.d.ts +6 -3
  153. package/dist/types/index.js +6 -3
  154. package/dist/types/mcp/index.d.ts +1 -0
  155. package/dist/types/mcp/index.js +1 -0
  156. package/dist/types/mcp/mcp.d.ts +50 -0
  157. package/dist/types/mcp/mcp.js +5 -0
  158. package/dist/types/protocol.d.ts +33 -0
  159. package/dist/types/protocol.js +34 -0
  160. package/dist/types/storage.d.ts +21 -0
  161. package/dist/utils/common/constants.d.ts +7 -7
  162. package/dist/utils/common/constants.js +10 -10
  163. package/dist/utils/common/errors.d.ts +18 -17
  164. package/dist/utils/common/errors.js +14 -13
  165. package/dist/utils/common/parse.d.ts +7 -0
  166. package/dist/utils/common/parse.js +14 -0
  167. package/dist/utils/common/schema-validation.d.ts +2 -0
  168. package/dist/utils/common/schema-validation.js +12 -0
  169. package/dist/utils/common/utils.d.ts +23 -0
  170. package/dist/utils/common/utils.js +32 -0
  171. package/dist/utils/common/zAsyncIterable-v3.d.ts +1 -1
  172. package/dist/utils/common/zAsyncIterable-v3.js +2 -1
  173. package/dist/utils/index.d.ts +3 -3
  174. package/dist/utils/index.js +3 -3
  175. package/dist/utils/storage/file.d.ts +8 -17
  176. package/dist/utils/storage/file.js +44 -73
  177. package/package.json +86 -23
  178. package/dist/services/a2a/factory/event.d.ts +0 -58
  179. package/dist/services/a2a/factory/event.js +0 -177
  180. package/dist/services/a2a/factory/method.d.ts +0 -6
  181. package/dist/services/a2a/managers/cancellation.d.ts +0 -11
  182. package/dist/services/a2a/managers/cancellation.js +0 -16
  183. package/dist/services/a2a/managers/connection.d.ts +0 -11
  184. package/dist/services/a2a/managers/connection.js +0 -16
  185. package/dist/services/a2a/managers/context.d.ts +0 -11
  186. package/dist/services/a2a/managers/context.js +0 -16
  187. package/dist/services/a2a/managers/index.d.ts +0 -5
  188. package/dist/services/a2a/managers/index.js +0 -5
  189. package/dist/services/a2a/managers/task.d.ts +0 -11
  190. package/dist/services/a2a/managers/task.js +0 -16
  191. package/dist/services/a2a/methods/cancel-task.d.ts +0 -7
  192. package/dist/services/a2a/methods/cancel-task.js +0 -43
  193. package/dist/services/a2a/methods/get-task.d.ts +0 -112
  194. package/dist/services/a2a/methods/get-task.js +0 -14
  195. package/dist/services/a2a/methods/resubscribe-task.d.ts +0 -7
  196. package/dist/services/a2a/methods/resubscribe-task.js +0 -80
  197. package/dist/services/a2a/methods/send-message.d.ts +0 -7
  198. package/dist/services/a2a/methods/send-message.js +0 -19
  199. package/dist/services/a2a/methods/stream-message.d.ts +0 -8
  200. package/dist/services/a2a/methods/stream-message.js +0 -21
  201. package/dist/services/a2a/state/index.d.ts +0 -3
  202. package/dist/services/a2a/state/index.js +0 -3
  203. package/dist/services/a2a/state/load.d.ts +0 -14
  204. package/dist/services/a2a/state/load.js +0 -71
  205. package/dist/services/a2a/state/process.d.ts +0 -7
  206. package/dist/services/a2a/state/process.js +0 -13
  207. package/dist/services/a2a/state/update/index.d.ts +0 -2
  208. package/dist/services/a2a/state/update/index.js +0 -2
  209. package/dist/services/a2a/state/update/update.d.ts +0 -23
  210. package/dist/services/a2a/state/update/update.js +0 -123
  211. package/dist/services/core/execution/execute.d.ts +0 -6
  212. package/dist/services/core/execution/execute.js +0 -25
  213. package/dist/services/core/execution/index.d.ts +0 -1
  214. package/dist/services/core/execution/index.js +0 -1
  215. package/dist/services/core/managers/command.d.ts +0 -39
  216. package/dist/services/core/managers/event.d.ts +0 -18
  217. package/dist/services/core/managers/event.js +0 -56
  218. package/dist/services/core/managers/index.d.ts +0 -3
  219. package/dist/services/core/managers/index.js +0 -3
  220. package/dist/services/core/managers/stream.d.ts +0 -20
  221. package/dist/services/core/managers/stream.js +0 -77
  222. package/dist/types/ext.d.ts +0 -13
  223. package/dist/types/ext.js +0 -10
  224. package/dist/types/interfaces/index.d.ts +0 -3
  225. package/dist/types/interfaces/index.js +0 -3
  226. package/dist/types/interfaces/services/a2a/builder.d.ts +0 -37
  227. package/dist/types/interfaces/services/a2a/context.d.ts +0 -162
  228. package/dist/types/interfaces/services/a2a/engine.d.ts +0 -7
  229. package/dist/types/interfaces/services/a2a/index.d.ts +0 -5
  230. package/dist/types/interfaces/services/a2a/index.js +0 -5
  231. package/dist/types/interfaces/services/a2a/legacy.d.ts +0 -93
  232. package/dist/types/interfaces/services/a2a/service.d.ts +0 -409
  233. package/dist/types/interfaces/services/a2a/service.js +0 -5
  234. package/dist/types/interfaces/services/core/context/command.d.ts +0 -25
  235. package/dist/types/interfaces/services/core/context/command.js +0 -5
  236. package/dist/types/interfaces/services/core/context/context.d.ts +0 -207
  237. package/dist/types/interfaces/services/core/context/context.js +0 -5
  238. package/dist/types/interfaces/services/core/context/index.d.ts +0 -3
  239. package/dist/types/interfaces/services/core/context/index.js +0 -3
  240. package/dist/types/interfaces/services/core/context/types.d.ts +0 -11
  241. package/dist/types/interfaces/services/core/context/types.js +0 -5
  242. package/dist/types/interfaces/services/core/execution/engine.d.ts +0 -106
  243. package/dist/types/interfaces/services/core/execution/engine.js +0 -5
  244. package/dist/types/interfaces/services/core/execution/environment.d.ts +0 -11
  245. package/dist/types/interfaces/services/core/execution/environment.js +0 -5
  246. package/dist/types/interfaces/services/core/execution/execute.d.ts +0 -7
  247. package/dist/types/interfaces/services/core/execution/execute.js +0 -5
  248. package/dist/types/interfaces/services/core/execution/index.d.ts +0 -3
  249. package/dist/types/interfaces/services/core/execution/index.js +0 -3
  250. package/dist/types/interfaces/services/core/index.d.ts +0 -4
  251. package/dist/types/interfaces/services/core/index.js +0 -4
  252. package/dist/types/interfaces/services/core/managers/cancellation.d.ts +0 -9
  253. package/dist/types/interfaces/services/core/managers/cancellation.js +0 -5
  254. package/dist/types/interfaces/services/core/managers/connection.d.ts +0 -9
  255. package/dist/types/interfaces/services/core/managers/connection.js +0 -5
  256. package/dist/types/interfaces/services/core/managers/context.d.ts +0 -17
  257. package/dist/types/interfaces/services/core/managers/context.js +0 -5
  258. package/dist/types/interfaces/services/core/managers/event.d.ts +0 -328
  259. package/dist/types/interfaces/services/core/managers/event.js +0 -5
  260. package/dist/types/interfaces/services/core/managers/index.d.ts +0 -6
  261. package/dist/types/interfaces/services/core/managers/index.js +0 -6
  262. package/dist/types/interfaces/services/core/managers/stream.d.ts +0 -217
  263. package/dist/types/interfaces/services/core/managers/stream.js +0 -5
  264. package/dist/types/interfaces/services/core/managers/task.d.ts +0 -9
  265. package/dist/types/interfaces/services/core/service.d.ts +0 -115
  266. package/dist/types/interfaces/services/core/service.js +0 -5
  267. package/dist/types/interfaces/services/mcp/index.d.ts +0 -1
  268. package/dist/types/interfaces/services/mcp/index.js +0 -1
  269. package/dist/types/interfaces/services/mcp/service.js +0 -5
  270. package/dist/types/interfaces/storage.d.ts +0 -8
  271. package/dist/types/schemas/a2a/agent.d.ts +0 -2583
  272. package/dist/types/schemas/a2a/agent.js +0 -323
  273. package/dist/types/schemas/a2a/auth.d.ts +0 -908
  274. package/dist/types/schemas/a2a/auth.js +0 -283
  275. package/dist/types/schemas/a2a/error.d.ts +0 -396
  276. package/dist/types/schemas/a2a/error.js +0 -163
  277. package/dist/types/schemas/a2a/index.d.ts +0 -11
  278. package/dist/types/schemas/a2a/index.js +0 -11
  279. package/dist/types/schemas/a2a/kind.d.ts +0 -11
  280. package/dist/types/schemas/a2a/kind.js +0 -20
  281. package/dist/types/schemas/a2a/message.d.ts +0 -10343
  282. package/dist/types/schemas/a2a/message.js +0 -130
  283. package/dist/types/schemas/a2a/notification.d.ts +0 -1517
  284. package/dist/types/schemas/a2a/notification.js +0 -203
  285. package/dist/types/schemas/a2a/parameters.d.ts +0 -956
  286. package/dist/types/schemas/a2a/parameters.js +0 -241
  287. package/dist/types/schemas/a2a/protocol.d.ts +0 -14363
  288. package/dist/types/schemas/a2a/protocol.js +0 -59
  289. package/dist/types/schemas/a2a/rpc.d.ts +0 -182
  290. package/dist/types/schemas/a2a/rpc.js +0 -126
  291. package/dist/types/schemas/a2a/task.d.ts +0 -5886
  292. package/dist/types/schemas/a2a/task.js +0 -134
  293. package/dist/types/schemas/a2a/transport.d.ts +0 -31
  294. package/dist/types/schemas/a2a/transport.js +0 -28
  295. package/dist/types/schemas/index.d.ts +0 -1
  296. package/dist/types/schemas/index.js +0 -1
  297. package/dist/utils/logging/index.d.ts +0 -2
  298. package/dist/utils/logging/index.js +0 -2
  299. package/dist/utils/logging/log.d.ts +0 -33
  300. package/dist/utils/logging/log.js +0 -75
  301. package/dist/utils/logging/logger.d.ts +0 -18
  302. package/dist/utils/logging/logger.js +0 -18
  303. package/dist/utils/storage/memory.d.ts +0 -25
  304. package/dist/utils/storage/memory.js +0 -47
  305. /package/dist/{types/interfaces/services → browser/types}/a2a/builder.js +0 -0
  306. /package/dist/{types/interfaces → browser/types}/client.js +0 -0
  307. /package/dist/{types/interfaces/services/core/managers/task.js → browser/types/core/core.js} +0 -0
  308. /package/dist/{types/interfaces/services → browser/types}/protocol.d.ts +0 -0
  309. /package/dist/{types/interfaces/services → browser/types}/protocol.js +0 -0
  310. /package/dist/{types/interfaces → browser/types}/storage.js +0 -0
  311. /package/dist/services/a2a/{state/update → handlers}/artifact.js +0 -0
  312. /package/dist/services/a2a/{methods → handlers}/index.d.ts +0 -0
  313. /package/dist/services/a2a/{methods → handlers}/index.js +0 -0
  314. /package/dist/types/{interfaces/services/a2a/context.js → a2a/builder.js} +0 -0
  315. /package/dist/types/{interfaces/services/a2a/engine.js → client.js} +0 -0
  316. /package/dist/types/{interfaces/services/a2a/legacy.js → storage.js} +0 -0
package/README.md CHANGED
@@ -8,623 +8,117 @@
8
8
 
9
9
  # artinet-sdk
10
10
 
11
- Give your AI agent the power to communicate with any other agent, no matter the framework.
11
+ Create agents that communicate across frameworks.
12
12
 
13
- The artinet-sdk is a TypeScript library that adds a standardized, interoperable communication layer to your agents.
13
+ The artinet-sdk is a TypeScript library that adds a standardized, interoperable communication layer to your agents using the [Agent2Agent (A2A) Protocol](https://github.com/google-a2a/A2A).
14
14
 
15
15
  ## Features
16
16
 
17
- - **Easy To Use:** The AgentBuilder lets you quickly create an Agent2Agent API, while handling all of the communication complexity.
18
- - **No Vendor Lock-In:** Create agents that can communicate with other agents across frameworks and ecosystems with just a few lines of code.
17
+ - **Hassle Free:** Use the AgentBuilder to quickly setup an AgentServer.
18
+ - **No Vendor Lock-In:** Let your agents communicate with other agents across frameworks and ecosystems.
19
19
  - **Flexible Design:** Everything you need to build collaborative agents while remaining modular enough for advanced configuration.
20
+ - **Pluggable Observability:** Bring your own logger (Pino, Winston) and tracer (OpenTelemetry) with zero-config defaults.
20
21
 
21
22
  ## Quick Start
22
23
 
23
- Use the [`create-agent`](https://www.npmjs.com/package/@artinet/create-agent) command:
24
+ **Use the [`create-agent`](https://www.npmjs.com/package/@artinet/create-agent) command:**
24
25
 
25
26
  ```bash
26
27
  npx @artinet/create-agent@latest
27
28
  ```
28
29
 
29
- It has [serveral template projects](https://github.com/the-artinet-project/create-agent/tree/main/templates) that you can use to jump right into agent building.
30
-
31
- ## Table of Contents
32
-
33
- - [artinet-sdk](#artinet-sdk)
34
- - [Features](#features)
35
- - [Quick Start](#quick-start)
36
- - [Table of Contents](#table-of-contents)
37
- - [Installation](#installation)
38
- - [Requirements](#requirements)
39
- - [Example](#example)
40
- - [Running Tests](#running-tests)
41
- - [Usage](#usage)
42
- - [Client](#client)
43
- - [Basic Client Usage](#basic-client-usage)
44
- - [Streaming Updates](#streaming-updates)
45
- - [Authentication](#authentication)
46
- - [Server](#server)
47
- - [Implementing an A2A Agent](#implementing-an-a2a-agent)
48
- - [AgentBuilder](#agentbuilder)
49
- - [AgentEngine](#agentengine)
50
- - [Event Handling/Monitoring \& Message Streaming](#event-handlingmonitoring--message-streaming)
51
- - [Persistent Storage](#persistent-storage)
52
- - [Advanced Server Customization](#advanced-server-customization)
53
- - [Cross Protocol Support](#cross-protocol-support)
54
- - [Contributing](#contributing)
55
- - [License](#license)
56
- - [Acknowledgements](#acknowledgements)
57
-
58
- **Breaking Changes since v0.5.8**
59
-
60
- - Pino has been removed and replaced with console for better portability and is set to silent by default.
61
- - The default handler for streamMessage no longer automatically emits an initial `submitted` and `working` event.
62
- - Agent Registration, Bundling and Deployment utils have been removed (email us: humans@artinet.io for support).
63
- - `@artinet/metadata-validator` has been removed due to build issues.
64
- - getTask now correctly takes TaskQueryParams as an argument vs TaskIdParams in accordance with the A2A spec.
65
- - AgentBuilder now returns a unique messageId for each status update instead of the original user provided messageId.
66
- - AgentBuilder now prefers the contextId & taskId from the calling context.
67
- - In a future release the following packages will be set as peer dependancies to reduce the size of the build: `@modelcontextprotocol/sdk`, `@trpc/server`, `cors`, `express`
68
- - The `history` object from `TaskAndHistory` is deprecated and no longer being updated. Use `Task.history` instead.
69
- - The `A2AClient` now checks `/.well-known/agent-card.json` as a opposed to `/.well-known/agent.json` in-line with the A2A spec.
70
- - The `A2AClient` now uses uses the `AgentCard`.url if an `AgentCard` has been successfully retrieved, else it will default to the `baseUrl`.
71
- - The examples folder will be removed in favor of [`create-agent`](https://github.com/the-artinet-project/create-agent).
72
- - In `Task` the `contextId` field is now required (inline with the A2A spec).
73
- - In `AgentSkill` the `tag` field is now required (inline with the A2A spec).
74
- - ~~Optional fields in Agent2Agent Zod schemas are now nullable for better interoperability.~~ **Nullable Schemas have been reverted.**
75
- - The `EngineBuilder` constructor is now protected and open for extension.
76
- - `AgentBuilder` will now throw an error if it recieves an invalid `FilePart`.
77
- - `createAgent`/`createService` can now take a single string (i.e. agentName) as valid value for the AgentCard and will populate the rest of the required fields with placeholder values (see `src/services/a2a/helpers/agentcard-builder.ts` for reference).
30
+ It has [several template projects](https://github.com/the-artinet-project/create-agent/tree/main/templates) to jump right into agent building.
78
31
 
79
- ## Installation
80
-
81
- ```bash
82
- npm install @artinet/sdk
83
- ```
84
-
85
- ## Requirements
86
-
87
- - [Node.js](https://nodejs.org/en/download) ≥ 18.9.1
88
- - Recommended: 20 || ≥ 22
89
-
90
- <!--
91
-
92
- ## Documentation
93
-
94
- For more detailed documentation visit our documentation site [here](https://the-artinet-project.github.io/artinet-documentation/). -->
95
-
96
- ## Example
97
-
98
- A basic A2A server and client interaction (For simple agents see the [AgentBuilder](#agentbuilder) section). For more detailed examples, see the `examples/` directory.
99
-
100
- **1. Server (`quick-server.ts`)**
32
+ **Or use [`easy-a2a`](https://github.com/the-artinet-project/easy-a2a):**
101
33
 
102
34
  ```typescript
103
- import {
104
- createAgentServer,
105
- AgentBuilder,
106
- Task
107
- } from "@artinet/sdk";
108
-
109
- // Create an agent server
110
- const { app, agent } = createAgentServer({
111
- agent: AgentBuilder()
112
- .text(async ({ content: userInput, context }) => {
113
- const task: Task = context.State().task;
114
- ...
115
- return `You said: ${userInput}`;
116
- })
35
+ const agent = a2a({
36
+ baseURL: "https://your-api.com/api/v1",
37
+ apiKey: "your-api-key",
38
+ })
39
+ .ai("You are a helpful assistant.")
117
40
  .createAgent({
118
- agentCard: "QuickStart Agent",
119
- }),
120
- basePath: "/a2a"
121
- });
122
-
123
- app.listen(3000, () => {
124
- console.log("A2A Server running at http://localhost:3000/a2a");
125
- });
126
- ```
127
-
128
- **2. Client (`quick-client.ts`)**
129
-
130
- ```typescript
131
- import { A2AClient, TaskStatusUpdateEvent } from "@artinet/sdk";
132
-
133
- async function runClient() {
134
- const client = new A2AClient("http://localhost:3000/a2a");
135
-
136
- const stream = client.sendStreamingMessage("Hello World!");
137
-
138
- for await (const update of stream) {
139
- // process the updates
140
- ...
141
- }
142
- console.log("Stream finished.");
143
- }
144
-
145
- await runClient().catch(console.error);
41
+ agentCard: "MyAgent",
42
+ });
146
43
  ```
147
44
 
148
- ## Running Tests
149
-
150
45
  ```bash
151
- npm test
46
+ npm install easy-a2a
152
47
  ```
153
48
 
154
- ## Usage
155
-
156
- ### Client
157
-
158
- Interact with A2A-compliant agents using the `A2AClient`. See `examples/` for more.
159
-
160
- #### Basic Client Usage
161
-
162
- Send a message using `message/send`.
163
-
164
- ```typescript
165
- import { A2AClient, Task } from "@artinet/sdk";
166
-
167
- const client = new A2AClient("https://your-a2a-server.com/a2a");
168
-
169
- const task: Task = await client.sendMessage("What is the capital of France?");
170
- ```
171
-
172
- #### Streaming Updates
173
-
174
- Receive real-time updates via SSE using `message/stream`.
49
+ ## Installation
175
50
 
176
- ```typescript
177
- import {
178
- A2AClient,
179
- Message,
180
- TaskStatusUpdateEvent,
181
- TaskArtifactUpdateEvent,
182
- } from "@artinet/sdk";
183
-
184
- async function runStreamingTask() {
185
- const client = new A2AClient("https://your-a2a-server.com/a2a");
186
-
187
- const stream = client.sendStreamingMessage("Tell me a short story.");
188
-
189
- for await (const update of stream) {
190
- if ((update as TaskStatusUpdateEvent).status) {
191
- console.log("Status:", (update as TaskStatusUpdateEvent).status.state);
192
- } else if ((update as TaskArtifactUpdateEvent).artifact) {
193
- console.log(
194
- "Artifact:",
195
- (update as TaskArtifactUpdateEvent).artifact.name
196
- );
197
- }
198
- }
199
- console.log("Stream finished.");
200
- }
51
+ ```bash
52
+ npm install @artinet/sdk
201
53
  ```
202
54
 
203
- #### Authentication
204
-
205
- Add headers using `addHeader` or `setHeaders`.
55
+ **Peer dependencies (required):**
206
56
 
207
- ```typescript
208
- import { A2AClient } from "@artinet/sdk";
209
-
210
- const client = new A2AClient("https://your-secure-a2a-server.com/a2a");
211
-
212
- // Add a single header
213
- client.addHeader("Authorization", "Bearer your-api-token");
214
-
215
- // Set multiple headers (overwrites existing)
216
- client.setHeaders({ Authorization: "Bearer ...", "X-Custom": "value" });
57
+ ```bash
58
+ npm install @a2a-js/sdk @modelcontextprotocol/sdk
217
59
  ```
218
60
 
219
- ### Server
220
-
221
- Use `createAgentServer()` to embed your Agents in an Express App.
222
-
223
- #### Implementing an A2A Agent
224
-
225
- The SDK provides a variety of options for creating complex ([AgentEngines](#agentengine)) or simple agents ([AgentBuilder](#agentbuilder)).
61
+ ## Requirements
226
62
 
227
- ##### AgentBuilder
63
+ - [Node.js](https://nodejs.org/en/download) ≥ 18.9.1 (Recommended: 20 or ≥ 22)
228
64
 
229
- **Option 1: Using the AgentBuilder (Recommended)**
65
+ ## Example
230
66
 
231
- For simple agents with one or more processing steps, use the `AgentBuilder` pattern:
67
+ **Server:**
232
68
 
233
69
  ```typescript
234
70
  import { createAgentServer, AgentBuilder } from "@artinet/sdk";
235
71
 
236
- //create a simple agent
237
- const simpleAgent = AgentBuilder().text(() => "hello world!");
238
-
239
- //or design a powerful multi-step agent
240
- const { app, agent } = createAgentServer({
72
+ const { app } = createAgentServer({
241
73
  agent: AgentBuilder()
242
- .text(({ content, context }) => {
243
- const userMessage = content ?? "no message detected";
244
- return {
245
- parts: [`Processing: ${userMessage}`], //parts are immediately sent back to the caller as TaskStatusUpdateEvents
246
- args: [userMessage], //args are passed to the next step
247
- };
248
- })
249
- .file(({ args }) => {
250
- const processedText = args[0];
251
- return {
252
- parts: [
253
- {
254
- name: "result.txt",
255
- mimeType: "text/plain",
256
- bytes: `Processed result: ${processedText}`,
257
- },
258
- ],
259
- args: ["file-generated"],
260
- };
74
+ .text(async ({ content }) => {
75
+ return `You said: ${content}`;
261
76
  })
262
- .text(({ args }) => {
263
- const status = args[0];
264
- return `Task completed. Status: ${status}`;
265
- }) //A final Task is returned to the caller which contains all of the emitted parts.
266
77
  .createAgent({
267
- agentCard: "Multi-Step Agent",
78
+ agentCard: "QuickStart Agent",
268
79
  }),
269
80
  basePath: "/a2a",
270
81
  });
271
82
 
272
83
  app.listen(3000, () => {
273
- console.log("Multi-Step A2A Server running on http://localhost:3000/a2a");
274
- });
275
- ```
276
-
277
- The `AgentBuilder` approach is particularly useful when you need:
278
-
279
- - **Step-by-step processing**: Break down complex tasks into discrete, manageable steps
280
- - **Data flow between steps**: Pass results from one step to the next using the `args` parameter
281
- - **Different content types**: Mix text, file, and data processing in a single flow
282
- - **Reusable components**: Build modular agents that can be easily edited or extended
283
-
284
- ##### AgentEngine
285
-
286
- **Option 2: Direct AgentEngine Implementation**
287
-
288
- When you need full control over the execution flow, implement an `AgentEngine` directly:
289
-
290
- ```typescript
291
- import {
292
- createAgentServer,
293
- Context,
294
- AgentEngine,
295
- } from "@artinet/sdk";
296
-
297
- const myAgent: AgentEngine = async function* (context: Context) {
298
- const task: TaskAndHistory = context.State();
299
- yield {
300
- state: "working",
301
- message: {
302
- ...
303
- role: "agent",
304
- parts: [{ kind: "text", text: "Processing..." }],
305
- },
306
- ...
307
- };
308
- yield {
309
- ...
310
- name: "result.txt",
311
- mimeType: "text/plain",
312
- parts: [{ kind: "text", text: "Report data" }],
313
- };
314
-
315
- yield {
316
- ...
317
- state: "completed",
318
- message: {
319
- kind: "message"
320
- role: "agent",
321
- parts: [{ kind: "text", text: "Finished processing." }],
322
- ...
323
- },
324
- };
325
- };
326
-
327
- const { app, agent } = createAgentServer({
328
- agent: {
329
- engine: myAgent,
330
- agentCard: {
331
- name: "Example Agent",
332
- url: "http://localhost:3000/a2a",
333
- version: "1.0.0",
334
- capabilities: { streaming: true },
335
- skills: [{ id: "processor", name: "Text Processor" }],
336
- ...
337
- },
338
- },
339
- basePath: "/a2a",
340
- agentCardPath: "/.well-known/agent-card.json",
341
- });
342
- ```
343
-
344
- #### Event Handling/Monitoring & Message Streaming
345
-
346
- The SDK provides comprehensive event handling & message streaming capabilities that allow you to modify agent execution, subscribe to events, stream commands, and respond to state changes in real-time.
347
-
348
- **Override Event Behaviour**
349
-
350
- When using the service layer, you can provide your own Event Handlers:
351
-
352
- ```typescript
353
- import { createAgent, TaskManager, ContextManager, Command, SendCommandInterface } from "@artinet/sdk";
354
-
355
- const customContextManager = new ContextManger();
356
- const agent = createAgent({
357
- engine: (context: Context){
358
- context.events.on("update", (currentState, nextState) => {
359
- //allow other processes to subscribe to your agent
360
- })
361
- ...
362
- //handle command streams directly within an agent
363
- for await (const command of context.command) {
364
- console.log("new command recieved: ", command);
365
- //will continue polling until the command stream is closed by calling command.close();
366
- }
367
- //or process them via events
368
- context.command.on("send", (command) => {
369
- ...
370
- });
371
- },
372
- agentCard: "Event-Monitored Agent",
373
- contexts: customContextManager,
374
- tasks: new TaskManager(),
375
- eventOverrides: { //for even greater control create your own Event Handlers
376
- onStart: async (context) => {
377
- ...
378
- return currentState;
379
- },
380
- onUpdate: async (currentState, nextState) => {
381
- ...
382
- return currentState;
383
- },
384
- ...
385
- },
386
- });
387
-
388
- const resultPromise = agent.sendMessage({
389
- contextId: "123"
390
- ...
391
- });
392
-
393
- const currentContext = customContextManager.getContext("123");
394
-
395
- //subscribe to the events from a specific context
396
- currentContext.events.on("complete", () {
397
- ...
398
- //errors thrown here will be triggered in the original context
399
- });
400
-
401
- // Advanced: stream new commands into a running context
402
- (currentContext.command as SendCommandInterface<Command>).send({
403
- ...
404
- });
405
-
406
- currentContext.command.close();
407
- ```
408
-
409
- **Available Event Types**
410
-
411
- The EventManager supports the following event types:
412
-
413
- - **`OnStart`/`start`**: Fired when agent execution begins
414
- - **`OnUpdate`/`update`**: Fired on each state update during execution
415
- - **`OnError`/`error`**: Fired when an error occurs during execution
416
- - **`OnComplete`/`complete`**: Fired when agent execution completes successfully
417
- - **`OnCancel`/`cancel`**: Fired when agent execution is cancelled
418
-
419
- #### Persistent Storage
420
-
421
- For Task storage, use one our simple storage providers like `FileStore`. Or implement the `Store` interface to create your own.
422
-
423
- ```typescript
424
- import path from "path";
425
- import fs from "fs";
426
- import { FileStore } from "@artinet/sdk";
427
-
428
- //make sure the directory exists
429
- const dataDir = path.join(process.cwd(), "a2a-data");
430
- if (!fs.existsSync(dataDir)) {
431
- fs.mkdirSync(dataDir, { recursive: true });
432
- }
433
-
434
- const myStore = new FileStore(dataDir);
435
-
436
- const { app, agent } = createAgentServer({
437
- agent: {
438
- engine: myAgent,
439
- agentCard: {
440
- ...
441
- },
442
- tasks: myStore,
443
- },
444
- ...
445
- });
446
- ```
447
-
448
- #### Advanced Server Customization
449
-
450
- Our architecture provides multiple ways to customize your agent server:
451
-
452
- **1. Using `createAgentServer`:**
453
- Easily spin up an A2A Express app `createAgentServer()`:
454
-
455
- ```typescript
456
- const initialApp = express();
457
-
458
- // custom middleware
459
- initialApp.use((req, res, next) => {
460
- ...
461
- next();
462
- });
463
-
464
- const { app, agent } = createAgentServer({
465
- app: initialApp
466
- agent: {
467
- ...
468
- },
469
- });
470
-
471
- // more custom middleware
472
- app.use("/custom", (req, res, next) => {
473
- ...
474
- });
475
-
476
- ```
477
-
478
- **2. Using our JSON-RPC Middleware:**
479
- Directly import our preconfigured JSON-RPC middleware:
480
-
481
- ```typescript
482
- import express from "express";
483
- import { createAgent, jsonRPCMiddleware, errorHandler } from "@artinet/sdk";
484
-
485
- const customApp = express();
486
-
487
- const agent = createAgent({
488
- engine: myAgentLogic,
489
- agentCard: {
490
- ...
491
- },
492
- });
493
-
494
- customApp.use("/auth", yourAuthMiddleware);
495
- customApp.use("/metrics", yourMetricsMiddleware);
496
- customApp.use(express.json());
497
-
498
- // Add A2A middleware
499
- customApp.post("/", async (req, res, next) => {
500
- return await jsonRPCMiddleware(agent, req, res, next);
501
- });
502
- // Dont forget to add error handling*
503
- customApp.use(errorHandler);
504
-
505
- // Serve the agent card
506
- customApp.get("/.well-known/agent-card.json", (req, res) => {
507
- res.json(agent.agentCard);
508
- });
509
-
510
- // Start your custom server
511
- const server = customApp.listen(3000, () => {
512
- console.log("Custom A2A server running on port 3000");
84
+ console.log("A2A Server running at http://localhost:3000/a2a");
513
85
  });
514
86
  ```
515
87
 
516
- **3. Using Custom Transport Layers:**
517
-
518
- Use our preconfigured TRPC router, or create your own integration with WebSockets & other protocols:
519
-
520
- ```typescript
521
- import { createAgentRouter } from "@artinet/sdk";
522
-
523
- const agentRouter = createAgentRouter();
524
- ```
525
-
526
- **Use the Agent:**
527
-
528
- Directly invoke the agent to use it locally:
88
+ **Client:**
529
89
 
530
90
  ```typescript
531
- import { createAgent } from "@artinet/sdk";
532
-
533
- const agent = createAgent({
534
- engine: myAgentLogic,
535
- agentCard: {
536
- ...
537
- },
538
- });
91
+ import { A2AClient } from "@artinet/sdk";
539
92
 
540
- // Wrap these calls in your desired transport logic
541
- const result = await agent.sendMessage({
542
- ...
543
- });
93
+ const client = new A2AClient("http://localhost:3000/a2a");
544
94
 
545
- // Directly process streams
546
- const stream = agent.streamMessage({
547
- ...
548
- });
95
+ const stream = client.sendStreamingMessage("Hello World!");
549
96
 
550
97
  for await (const update of stream) {
551
- ...
98
+ console.log(update);
552
99
  }
553
100
  ```
554
101
 
555
- **Important:** When using custom implementations, ensure you handle:
556
-
557
- - Server-Sent Events (SSE) for `message/stream` and `tasks/resubscribe`
558
- - Agent card endpoints at `/.well-known/agent-card.json`
559
- - Proper error handling and JSON-RPC compliance
560
- - CORS headers if needed for web clients
561
-
562
- #### Cross Protocol Support
563
-
564
- **MCP (Model Context Protocol) Integration**
565
-
566
- The SDK provides a Model Context Protocol (MCP) <-> A2A compatability layer.
567
-
568
- Use `createMCPAgent` to expose your agent via MCP:
569
-
570
- ```typescript
571
- import { createMCPAgent, createAgent } from "@artinet/sdk";
572
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
573
- import { Client } from "@modelcontextprotocol/sdk/client/index.js";
574
-
575
- // Wrap your agent in an MCP Server
576
- const mcpAgent = createMCPAgent({
577
- serverInfo: {
578
- name: "My MCP Agent",
579
- version: "1.0.0",
580
- },
581
- options: {
582
- ...
583
- },
584
- agent: createAgent({
585
- engine: myAgentEngine,
586
- agentCard: "MCP Agent",
587
- }),
588
- agentCardUri: "agent://card", //customize the URI for your AgentCard
589
- });
590
-
591
- // The MCPAgent is a fully compliant MCP Server so you can use it as you normally would.
592
- mcpAgent.registerTool({
593
- ...
594
- });
102
+ ## Documentation
595
103
 
596
- await mcpAgent.connect(new StdioServerTransport());
597
- ```
104
+ | Topic | Description |
105
+ | ------------------------------------------- | ----------------------------------------------------- |
106
+ | [**API Reference**](docs/api-reference.md) | Complete reference of SDK objects, types, and methods |
107
+ | [**Configuration**](docs/configuration.md) | Logging (Pino, Winston) and OpenTelemetry setup |
108
+ | [**Client Usage**](docs/client.md) | A2AClient methods, streaming, browser support |
109
+ | [**Server Implementation**](docs/server.md) | AgentBuilder, AgentEngine, and AgentCard |
110
+ | [**Event Handling**](docs/events.md) | Event subscriptions and custom handlers |
111
+ | [**Storage**](docs/storage.md) | FileStore and custom storage backends |
112
+ | [**Customization**](docs/customization.md) | Middleware, tRPC, custom transports |
113
+ | [**MCP Integration**](docs/mcp.md) | Model Context Protocol compatibility |
114
+ | [**Migration Guide**](docs/migration.md) | Upgrading from v0.5.x to v0.6.0 |
598
115
 
599
- Use an MCP Client to interact with an mcpAgent:
116
+ ## Running Tests
600
117
 
601
- ```typescript
602
- ...
603
- // Access the AgentCard as a Resource
604
- const agentCard = await client.readResource({ uri: "agent://card" });
605
-
606
- // or send messages via Tool Calling
607
- const result = await client.callTool({
608
- name: "send-message",
609
- arguments: {
610
- ...
611
- message: {
612
- ...
613
- parts: [{ kind: "text", text: "Hello from MCP!" }],
614
- },
615
- },
616
- });
118
+ ```bash
119
+ npm test
617
120
  ```
618
121
 
619
- **MCP Tools & Resources:**
620
-
621
- - `send-message`: Send messages to the A2A agent
622
- - `get-task`: Retrieve tasks by ID
623
- - `cancel-task`: Cancel a running task
624
- - `agent://card`: Retrieve the AgentCard
625
- - `send-streaming-message`, `task-resubscribe` & `push-notifications` etc are currently not supported by default.
626
- - Leverage the A2A Zod Schemas to manually implement your own tools.
627
-
628
122
  ## Contributing
629
123
 
630
124
  Contributions are welcome! Please open an issue or submit a Pull Request on [GitHub](https://github.com/the-artinet-project/artinet-sdk).
@@ -0,0 +1,9 @@
1
+ export * from "./types/index.js";
2
+ export * from "./client/index.js";
3
+ export { executeJsonRpcRequest, executeGetRequest, createJsonRpcRequest, sendJsonRpcRequest, } from "./transport/rpc/rpc-client.js";
4
+ export { executeStreamEvents } from "./transport/streaming/event-stream.js";
5
+ export * from "./utils/common/constants.js";
6
+ export * from "./utils/common/errors.js";
7
+ export * from "./utils/common/utils.js";
8
+ export * from "./config/index.js";
9
+ export { A2AClient } from "./client/a2a-client.js";
@@ -0,0 +1,10 @@
1
+ //browser only entry point
2
+ export * from "./types/index.js";
3
+ export * from "./client/index.js";
4
+ export { executeJsonRpcRequest, executeGetRequest, createJsonRpcRequest, sendJsonRpcRequest, } from "./transport/rpc/rpc-client.js";
5
+ export { executeStreamEvents } from "./transport/streaming/event-stream.js";
6
+ export * from "./utils/common/constants.js";
7
+ export * from "./utils/common/errors.js";
8
+ export * from "./utils/common/utils.js";
9
+ export * from "./config/index.js";
10
+ export { A2AClient } from "./client/a2a-client.js";