@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
@@ -1,93 +0,0 @@
1
- /**
2
- * Copyright 2025 The Artinet Project
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
- import { type Task, type Message, type MessageSendConfiguration } from "../../../schemas/a2a/index.js";
6
- import { A2AEngine } from "./engine.js";
7
- /**
8
- * @deprecated Task now has a history property.
9
- * Represents a task and its associated message history.
10
- */
11
- export interface TaskAndHistory {
12
- /** The task object */
13
- task: Task;
14
- /**
15
- * @deprecated This property is no longer being updated. Use the task.history property instead.
16
- * The complete message history associated with the task
17
- */
18
- history: Message[];
19
- }
20
- /**
21
- * @deprecated Use the Store interface instead.
22
- * @description Interface for task storage providers.
23
- * Abstracts the storage mechanism for tasks and their message history.
24
- */
25
- export interface TaskStore {
26
- /**
27
- * Saves a task and its associated message history.
28
- * Overwrites existing data if the task ID exists.
29
- * @param data An object containing the task and its history.
30
- * @returns A promise resolving when the save operation is complete.
31
- */
32
- save(data: TaskAndHistory): Promise<void>;
33
- /**
34
- * Loads a task and its history by task ID.
35
- * @param taskId The ID of the task to load.
36
- * @returns A promise resolving to an object containing the Task and its history, or null if not found.
37
- */
38
- load(taskId: string): Promise<TaskAndHistory | null>;
39
- }
40
- /**
41
- * @deprecated This interface will be removed in the future. Use ExecutionContext instead.
42
- * Context object provided to the TaskHandler.
43
- * Contains the information needed for the handler to process the task.
44
- */
45
- export interface TaskContext {
46
- /**
47
- * The context ID of the task.
48
- */
49
- contextId: string;
50
- /**
51
- * The current state of the task when the handler is invoked or resumed.
52
- * This is a snapshot - the latest state may need to be reloaded during async operations.
53
- */
54
- task: Task;
55
- /**
56
- * The specific user message that triggered this handler invocation or resumption.
57
- */
58
- userMessage: Message;
59
- /**
60
- * Function to check if cancellation has been requested for this task.
61
- * Handlers should check this periodically during long-running operations.
62
- * @returns True if cancellation has been requested, false otherwise.
63
- */
64
- isCancelled(): boolean;
65
- /**
66
- * The message history associated with the task up to the point the handler is invoked.
67
- */
68
- history: Message[];
69
- /**
70
- * @description The latest user message that triggered this handler invocation or resumption.
71
- * @note It's unclear whether this is necessary as userMessage already exists
72
- */
73
- latestUserMessage?: Message;
74
- /**
75
- * The configuration for the task.
76
- */
77
- configuration?: MessageSendConfiguration;
78
- }
79
- /**
80
- * Defines the signature for a task handler function.
81
- *
82
- * Handlers are implemented as async generators. They receive context about the
83
- * task and the triggering message. They perform work and yield status
84
- * or artifact updates (TaskYieldUpdate). The server consumes these yields,
85
- * updates the task state in the store, and streams events if applicable.
86
- *
87
- * @deprecated Use A2AEngine instead.
88
- * @param context The TaskContext object containing task details and state.
89
- * @yields Updates to the task's status or artifacts.
90
- * @returns Optionally returns the final complete Task object (needed for non-streaming 'message/send').
91
- * If void is returned, the server uses the last known state after processing all yields.
92
- */
93
- export type TaskHandler = A2AEngine;
@@ -1,409 +0,0 @@
1
- /**
2
- * Copyright 2025 The Artinet Project
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
- /**
6
- * @fileoverview A2A Service Interface Definitions
7
- *
8
- * This module defines interfaces for Agent-to-Agent (A2A) service implementations,
9
- * including factory parameters, method options, and the main service interface.
10
- * It extends the core service framework with A2A-specific functionality for
11
- * agent communication, task management, and message handling.
12
- *
13
- * @module A2AService
14
- * @version 0.5.7
15
- * @since 0.5.6
16
- * @author The Artinet Project
17
- */
18
- import { ConnectionManagerInterface, CancellationManagerInterface, ContextManagerInterface, ServiceInterface, TaskManagerInterface, EventManagerOptions } from "../core/index.js";
19
- import { AgentCard, MessageSendParams, SendMessageSuccessResult, Task, TaskIdParams, TaskQueryParams } from "../../../schemas/a2a/index.js";
20
- import { UpdateEvent, Command, State, Update } from "./context.js";
21
- import { A2AEngine } from "./engine.js";
22
- export type AgentCardParams = (Partial<AgentCard> & Required<Pick<AgentCard, "name">>) | string;
23
- /**
24
- * Configuration parameters for creating A2A service instances.
25
- *
26
- * This interface defines the required and optional components needed to
27
- * instantiate an A2A service, including the agent identity, execution engine,
28
- * and various manager interfaces for handling different aspects of A2A operations.
29
- *
30
- * @example
31
- * ```typescript
32
- * const factoryParams: FactoryParams = {
33
- * agentCard: {
34
- * id: 'agent-123',
35
- * name: 'MyAgent',
36
- * capabilities: ['messaging', 'task-processing']
37
- * },
38
- * engine: createA2AEngine(),
39
- * contexts: createContextManager(),
40
- * connections: createConnectionManager(),
41
- * methods: {
42
- * sendMessage: customSendMessage,
43
- * getTask: customGetTask
44
- * }
45
- * };
46
- *
47
- * const service = createA2AService(factoryParams);
48
- * ```
49
- *
50
- * @public
51
- * @since 0.5.6
52
- */
53
- export interface FactoryParams {
54
- /** Agent identity and capabilities information */
55
- agentCard: AgentCardParams;
56
- /** Execution engine for processing A2A commands */
57
- engine: A2AEngine;
58
- /** Optional context manager for execution state management */
59
- contexts?: ContextManagerInterface<Command, State, Update>;
60
- /** Optional connection manager for agent connections */
61
- connections?: ConnectionManagerInterface;
62
- /** Optional cancellation manager for handling operation cancellations */
63
- cancellations?: CancellationManagerInterface;
64
- /** Optional task manager for task lifecycle management */
65
- tasks?: TaskManagerInterface<State>;
66
- /** Optional custom method implementations */
67
- methods?: Partial<MethodOptions>;
68
- /** Optional event manager configuration overrides */
69
- events?: EventManagerOptions<Command, State, Update>;
70
- }
71
- /**
72
- * Parameters passed to A2A method implementations.
73
- *
74
- * This interface defines the dependencies and context information that
75
- * method implementations receive when they are invoked. It provides access
76
- * to the service instance, execution engine, context management, and
77
- * cancellation mechanisms.
78
- *
79
- * @example
80
- * ```typescript
81
- * const customSendMessage = async (
82
- * message: MessageSendParams,
83
- * params: MethodParams
84
- * ): Promise<SendMessageSuccessResult> => {
85
- * const { service, engine, contextManager, signal } = params;
86
- *
87
- * // Create execution context
88
- * const context = contextManager.createContext(message);
89
- *
90
- * // Check for cancellation
91
- * if (signal.aborted) {
92
- * throw new Error('Operation cancelled');
93
- * }
94
- *
95
- * // Execute message sending
96
- * return await service.execute(engine, context);
97
- * };
98
- * ```
99
- *
100
- * @public
101
- * @since 0.5.6
102
- */
103
- export interface MethodParams {
104
- /** The A2A service instance */
105
- service: A2AServiceInterface<Command, State, Update>;
106
- /** The execution engine for processing */
107
- engine: A2AEngine;
108
- /** Context manager for execution state */
109
- contextManager: ContextManagerInterface<Command, State, Update>;
110
- /** Abort signal for cancellation handling */
111
- signal: AbortSignal;
112
- }
113
- /**
114
- * Custom method implementation options for A2A services.
115
- *
116
- * This interface allows customization of core A2A operations by providing
117
- * alternative implementations for task management, message handling, and
118
- * streaming operations. Each method can be individually overridden to
119
- * provide custom behavior while maintaining the standard interface.
120
- *
121
- * @example
122
- * ```typescript
123
- * const customMethods: MethodOptions = {
124
- * sendMessage: async (message, params) => {
125
- * // Custom message sending logic
126
- * console.log(`Sending message to: ${message.recipient}`);
127
- * const result = await defaultSendMessage(message, params);
128
- * console.log(`Message sent with ID: ${result.messageId}`);
129
- * return result;
130
- * },
131
- *
132
- * getTask: async (input, params) => {
133
- * // Custom task retrieval with caching
134
- * const cached = taskCache.get(input.taskId);
135
- * if (cached) return cached;
136
- *
137
- * const task = await defaultGetTask(input, params);
138
- * taskCache.set(input.taskId, task);
139
- * return task;
140
- * }
141
- * };
142
- * ```
143
- *
144
- * @public
145
- * @since 0.5.6
146
- */
147
- export interface MethodOptions {
148
- /**
149
- * Custom task retrieval implementation.
150
- *
151
- * @param input - Task query parameters
152
- * @param params - Method execution parameters (without engine, contextManager, signal)
153
- * @returns Promise resolving to the requested task
154
- */
155
- getTask: (input: TaskQueryParams, params: Omit<MethodParams, "engine" | "contextManager" | "signal">) => Promise<Task>;
156
- /**
157
- * Task cancellation.
158
- *
159
- * @param input - Task identification parameters
160
- * @param params - Method execution parameters (without engine, signal)
161
- * @returns Promise resolving to the cancelled task
162
- */
163
- cancelTask: (input: TaskIdParams, params: Omit<MethodParams, "engine" | "signal">) => Promise<Task>;
164
- /**
165
- * Message sending.
166
- *
167
- * @param message - Message parameters to send
168
- * @param params - Full method execution parameters
169
- * @returns Promise resolving to send operation result
170
- */
171
- sendMessage: (message: MessageSendParams, params: MethodParams) => Promise<SendMessageSuccessResult>;
172
- /**
173
- * Streaming messages.
174
- *
175
- * @param message - Message parameters to send
176
- * @param params - Full method execution parameters
177
- * @returns AsyncGenerator yielding update events
178
- */
179
- streamMessage: (message: MessageSendParams, params: MethodParams) => AsyncGenerator<UpdateEvent>;
180
- /**
181
- * Resubscription.
182
- *
183
- * @param input - Task identification parameters
184
- * @param params - Full method execution parameters
185
- * @returns AsyncGenerator yielding update events
186
- */
187
- resubscribe: (input: TaskIdParams, params: MethodParams) => AsyncGenerator<UpdateEvent>;
188
- }
189
- /**
190
- * Public interface for A2A service methods.
191
- *
192
- * This interface defines the public API that consumers of A2A services
193
- * can use to interact with agents. It provides simplified method signatures
194
- * that hide internal complexity while exposing the essential functionality
195
- * for agent-to-agent communication.
196
- *
197
- * @example
198
- * ```typescript
199
- * // Using the methods interface
200
- * const service: MethodsInterface = createA2AService(params);
201
- *
202
- * // Get a task
203
- * const task = await service.getTask({ taskId: 'task-123' });
204
- *
205
- * // Send a message
206
- * const result = await service.sendMessage({
207
- * recipient: 'agent-456',
208
- * content: 'Hello, how are you?'
209
- * });
210
- *
211
- * // Stream messages for real-time updates
212
- * for await (const update of service.streamMessage({
213
- * recipient: 'agent-456',
214
- * content: 'Processing your request...'
215
- * })) {
216
- * console.log('Update:', update);
217
- * }
218
- * ```
219
- *
220
- * @public
221
- * @since 0.5.6
222
- */
223
- export interface MethodsInterface {
224
- /**
225
- * Retrieves a task by its ID.
226
- *
227
- * @param input - Task identification parameters
228
- * @returns Promise resolving to the requested task
229
- */
230
- getTask: (input: TaskQueryParams) => Promise<Task>;
231
- /**
232
- * Cancels a task by its ID.
233
- *
234
- * @param input - Task identification parameters
235
- * @returns Promise resolving to the cancelled task
236
- */
237
- cancelTask: (input: TaskIdParams) => Promise<Task>;
238
- /**
239
- * Sends a message to another agent.
240
- *
241
- * @param message - Message parameters to send
242
- * @param params - Optional execution parameters
243
- * @returns Promise resolving to send operation result
244
- */
245
- sendMessage: (message: MessageSendParams, params?: Partial<Omit<MethodParams, "service" | "contextManager">>) => Promise<SendMessageSuccessResult>;
246
- /**
247
- * Sends a message with streaming updates.
248
- *
249
- * @param message - Message parameters to send
250
- * @param params - Optional execution parameters
251
- * @returns AsyncGenerator yielding update events
252
- */
253
- streamMessage: (message: MessageSendParams, params?: Partial<Omit<MethodParams, "service" | "contextManager">>) => AsyncGenerator<UpdateEvent>;
254
- /**
255
- * Resubscribes to updates for a specific task.
256
- *
257
- * @param input - Task identification parameters
258
- * @param params - Optional execution parameters
259
- * @returns AsyncGenerator yielding update events
260
- */
261
- resubscribe: (input: TaskIdParams, params?: Partial<Omit<MethodParams, "service" | "contextManager">>) => AsyncGenerator<UpdateEvent>;
262
- }
263
- /**
264
- * Main interface for A2A service implementations.
265
- *
266
- * This interface extends the core ServiceInterface and MethodsInterface to provide
267
- * a complete A2A service implementation. It includes agent identity management,
268
- * connection tracking, cancellation handling, and state management capabilities
269
- * specific to agent-to-agent communication scenarios.
270
- *
271
- * @template TCommand - The command type, must extend Command
272
- * @template TState - The state type, must extend State
273
- * @template TUpdate - The update type, must extend Update
274
- *
275
- * @example
276
- * ```typescript
277
- * class MyA2AService implements A2AServiceInterface {
278
- * constructor(
279
- * public agentCard: AgentCard,
280
- * private engine: A2AEngine
281
- * ) {}
282
- *
283
- * async execute(engine, context) {
284
- * // Handle execution
285
- * }
286
- *
287
- * async sendMessage(message, params) {
288
- * // Handle message sending
289
- * }
290
- *
291
- * addConnection(id: string) {
292
- * this.connections.add(id);
293
- * console.log(`Added connection: ${id}`);
294
- * }
295
- *
296
- * // ... implement other methods
297
- * }
298
- * ```
299
- *
300
- * @public
301
- * @since 0.5.6
302
- */
303
- export interface A2AServiceInterface<TCommand extends Command = Command, TState extends State = State, TUpdate extends Update = Update> extends ServiceInterface<TCommand, TState, TUpdate>, MethodsInterface {
304
- /**
305
- * Optional event manager configuration overrides.
306
- *
307
- * When present, these overrides customize the default event handling
308
- * behavior for this service instance.
309
- */
310
- readonly eventOverrides: EventManagerOptions<TCommand, TState, TUpdate> | undefined;
311
- /**
312
- * Agent identity and capabilities information.
313
- *
314
- * This card identifies the agent and describes its capabilities,
315
- * which is used for agent discovery and capability matching.
316
- */
317
- agentCard: AgentCard;
318
- /**
319
- * Adds a connection to the active connections registry.
320
- *
321
- * @param id - Unique identifier for the connection
322
- *
323
- * @example
324
- * ```typescript
325
- * service.addConnection('connection-123');
326
- * ```
327
- */
328
- addConnection: (id: string) => void;
329
- /**
330
- * Removes a connection from the active connections registry.
331
- *
332
- * @param id - Unique identifier for the connection
333
- *
334
- * @example
335
- * ```typescript
336
- * service.removeConnection('connection-123');
337
- * ```
338
- */
339
- removeConnection: (id: string) => void;
340
- /**
341
- * Checks if a specific execution context has been cancelled.
342
- *
343
- * @param id - Context or execution identifier
344
- * @returns True if cancelled, false otherwise
345
- *
346
- * @example
347
- * ```typescript
348
- * if (service.isCancelled('context-123')) {
349
- * console.log('Execution was cancelled');
350
- * return;
351
- * }
352
- * ```
353
- */
354
- isCancelled: (id: string) => boolean;
355
- /**
356
- * Adds a cancellation marker for a specific execution context.
357
- *
358
- * @param id - Context or execution identifier to cancel
359
- *
360
- * @example
361
- * ```typescript
362
- * service.addCancellation('context-123');
363
- * ```
364
- */
365
- addCancellation: (id: string) => void;
366
- /**
367
- * Removes a cancellation marker for a specific execution context.
368
- *
369
- * @param id - Context or execution identifier
370
- *
371
- * @example
372
- * ```typescript
373
- * service.removeCancellation('context-123');
374
- * ```
375
- */
376
- removeCancellation: (id: string) => void;
377
- /**
378
- * Retrieves the current state for a specific Task.
379
- *
380
- * @param id - Task identifier
381
- * @returns Promise resolving to the state, or undefined if not found
382
- *
383
- * @example
384
- * ```typescript
385
- * const state = await service.getState('task-123');
386
- * if (state) {
387
- * console.log('Current progress:', state.progress);
388
- * }
389
- * ```
390
- */
391
- getState: (id: string) => Promise<TState | undefined>;
392
- /**
393
- * Sets the state for a specific Task.
394
- *
395
- * @param id - Task identifier
396
- * @param data - The state data to store
397
- * @returns Promise that resolves when state is saved
398
- *
399
- * @example
400
- * ```typescript
401
- * await service.setState('task-123', {
402
- * progress: 0.75,
403
- * status: 'processing',
404
- * data: processedResults
405
- * });
406
- * ```
407
- */
408
- setState: (id: string, data: TState) => Promise<void>;
409
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Copyright 2025 The Artinet Project
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
- export {};
@@ -1,25 +0,0 @@
1
- /**
2
- * Copyright 2025 The Artinet Project
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
- import { CoreCommand } from "./types.js";
6
- import { EventEmitter } from "events";
7
- export interface CommandChannelMap<TCommand extends CoreCommand = CoreCommand> {
8
- send: [TCommand];
9
- close: [];
10
- }
11
- export interface SendCommandInterface<TCommand extends CoreCommand = CoreCommand> {
12
- isOpen: boolean;
13
- send(command: TCommand): void;
14
- }
15
- export interface ReceiveCommandInterface<TCommand extends CoreCommand = CoreCommand> extends AsyncIterable<TCommand, TCommand, TCommand | undefined>, EventEmitter<CommandChannelMap<TCommand>> {
16
- command: TCommand;
17
- commandList: TCommand[];
18
- close(): void;
19
- next(): Promise<IteratorResult<TCommand>>;
20
- return(value: TCommand): Promise<IteratorResult<TCommand>>;
21
- }
22
- export type ReceiveCommandProxyInterface<TCommand extends CoreCommand = CoreCommand> = ReceiveCommandInterface<TCommand> & TCommand;
23
- export interface CommandChannelInterface<TCommand extends CoreCommand = CoreCommand> extends ReceiveCommandInterface<TCommand>, SendCommandInterface<TCommand> {
24
- }
25
- export type CommandChannelProxyInterface<TCommand extends CoreCommand = CoreCommand> = CommandChannelInterface<TCommand> & TCommand;
@@ -1,5 +0,0 @@
1
- /**
2
- * Copyright 2025 The Artinet Project
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
- export {};