@artinet/sdk 0.5.16 → 0.5.18

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 (175) hide show
  1. package/README.md +108 -58
  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 +126 -0
  5. package/dist/browser/client/a2a-client.js +221 -0
  6. package/dist/browser/client/index.d.ts +1 -0
  7. package/dist/browser/client/index.js +1 -0
  8. package/dist/browser/services/a2a/helpers/message-builder.d.ts +12 -0
  9. package/dist/browser/services/a2a/helpers/message-builder.js +61 -0
  10. package/dist/browser/transport/rpc/parser.d.ts +15 -0
  11. package/dist/browser/transport/rpc/parser.js +48 -0
  12. package/dist/browser/transport/rpc/rpc-client.d.ts +80 -0
  13. package/dist/browser/transport/rpc/rpc-client.js +189 -0
  14. package/dist/browser/transport/streaming/event-stream.d.ts +25 -0
  15. package/dist/browser/transport/streaming/event-stream.js +99 -0
  16. package/dist/browser/types/ext.d.ts +13 -0
  17. package/dist/browser/types/ext.js +10 -0
  18. package/dist/browser/types/index.d.ts +4 -0
  19. package/dist/browser/types/index.js +4 -0
  20. package/dist/browser/types/interfaces/client.d.ts +135 -0
  21. package/dist/browser/types/interfaces/client.js +5 -0
  22. package/dist/browser/types/interfaces/index.d.ts +3 -0
  23. package/dist/browser/types/interfaces/index.js +3 -0
  24. package/dist/browser/types/interfaces/services/a2a/builder.d.ts +37 -0
  25. package/dist/browser/types/interfaces/services/a2a/builder.js +5 -0
  26. package/dist/browser/types/interfaces/services/a2a/context.d.ts +162 -0
  27. package/dist/browser/types/interfaces/services/a2a/context.js +5 -0
  28. package/dist/browser/types/interfaces/services/a2a/engine.d.ts +7 -0
  29. package/dist/browser/types/interfaces/services/a2a/engine.js +5 -0
  30. package/dist/browser/types/interfaces/services/a2a/index.d.ts +5 -0
  31. package/dist/browser/types/interfaces/services/a2a/index.js +5 -0
  32. package/dist/browser/types/interfaces/services/a2a/legacy.d.ts +93 -0
  33. package/dist/browser/types/interfaces/services/a2a/legacy.js +5 -0
  34. package/dist/browser/types/interfaces/services/a2a/service.d.ts +413 -0
  35. package/dist/browser/types/interfaces/services/a2a/service.js +5 -0
  36. package/dist/browser/types/interfaces/services/core/context/command.d.ts +25 -0
  37. package/dist/browser/types/interfaces/services/core/context/command.js +5 -0
  38. package/dist/browser/types/interfaces/services/core/context/context.d.ts +207 -0
  39. package/dist/browser/types/interfaces/services/core/context/context.js +5 -0
  40. package/dist/browser/types/interfaces/services/core/context/index.d.ts +3 -0
  41. package/dist/browser/types/interfaces/services/core/context/index.js +3 -0
  42. package/dist/browser/types/interfaces/services/core/context/types.d.ts +11 -0
  43. package/dist/browser/types/interfaces/services/core/context/types.js +5 -0
  44. package/dist/browser/types/interfaces/services/core/execution/engine.d.ts +106 -0
  45. package/dist/browser/types/interfaces/services/core/execution/engine.js +5 -0
  46. package/dist/browser/types/interfaces/services/core/execution/environment.d.ts +11 -0
  47. package/dist/browser/types/interfaces/services/core/execution/environment.js +5 -0
  48. package/dist/browser/types/interfaces/services/core/execution/execute.d.ts +7 -0
  49. package/dist/browser/types/interfaces/services/core/execution/execute.js +5 -0
  50. package/dist/browser/types/interfaces/services/core/execution/index.d.ts +3 -0
  51. package/dist/browser/types/interfaces/services/core/execution/index.js +3 -0
  52. package/dist/browser/types/interfaces/services/core/index.d.ts +4 -0
  53. package/dist/browser/types/interfaces/services/core/index.js +4 -0
  54. package/dist/browser/types/interfaces/services/core/managers/cancellation.d.ts +9 -0
  55. package/dist/browser/types/interfaces/services/core/managers/cancellation.js +5 -0
  56. package/dist/browser/types/interfaces/services/core/managers/connection.d.ts +9 -0
  57. package/dist/browser/types/interfaces/services/core/managers/connection.js +5 -0
  58. package/dist/browser/types/interfaces/services/core/managers/context.d.ts +17 -0
  59. package/dist/browser/types/interfaces/services/core/managers/context.js +5 -0
  60. package/dist/browser/types/interfaces/services/core/managers/event.d.ts +328 -0
  61. package/dist/browser/types/interfaces/services/core/managers/event.js +5 -0
  62. package/dist/browser/types/interfaces/services/core/managers/index.d.ts +6 -0
  63. package/dist/browser/types/interfaces/services/core/managers/index.js +6 -0
  64. package/dist/browser/types/interfaces/services/core/managers/stream.d.ts +217 -0
  65. package/dist/browser/types/interfaces/services/core/managers/stream.js +5 -0
  66. package/dist/browser/types/interfaces/services/core/managers/task.d.ts +9 -0
  67. package/dist/browser/types/interfaces/services/core/managers/task.js +1 -0
  68. package/dist/browser/types/interfaces/services/core/service.d.ts +115 -0
  69. package/dist/browser/types/interfaces/services/core/service.js +5 -0
  70. package/dist/browser/types/interfaces/services/index.d.ts +4 -0
  71. package/dist/browser/types/interfaces/services/index.js +4 -0
  72. package/dist/browser/types/interfaces/services/mcp/index.d.ts +1 -0
  73. package/dist/browser/types/interfaces/services/mcp/index.js +1 -0
  74. package/dist/browser/types/interfaces/services/mcp/service.d.ts +49 -0
  75. package/dist/browser/types/interfaces/services/mcp/service.js +5 -0
  76. package/dist/browser/types/interfaces/services/protocol.d.ts +33 -0
  77. package/dist/browser/types/interfaces/services/protocol.js +34 -0
  78. package/dist/browser/types/interfaces/storage.d.ts +8 -0
  79. package/dist/browser/types/interfaces/storage.js +5 -0
  80. package/dist/browser/types/schemas/a2a/agent.d.ts +2583 -0
  81. package/dist/browser/types/schemas/a2a/agent.js +323 -0
  82. package/dist/browser/types/schemas/a2a/auth.d.ts +908 -0
  83. package/dist/browser/types/schemas/a2a/auth.js +283 -0
  84. package/dist/browser/types/schemas/a2a/error.d.ts +396 -0
  85. package/dist/browser/types/schemas/a2a/error.js +163 -0
  86. package/dist/browser/types/schemas/a2a/index.d.ts +11 -0
  87. package/dist/browser/types/schemas/a2a/index.js +11 -0
  88. package/dist/browser/types/schemas/a2a/kind.d.ts +11 -0
  89. package/dist/browser/types/schemas/a2a/kind.js +20 -0
  90. package/dist/browser/types/schemas/a2a/message.d.ts +10343 -0
  91. package/dist/browser/types/schemas/a2a/message.js +130 -0
  92. package/dist/browser/types/schemas/a2a/notification.d.ts +1517 -0
  93. package/dist/browser/types/schemas/a2a/notification.js +203 -0
  94. package/dist/browser/types/schemas/a2a/parameters.d.ts +956 -0
  95. package/dist/browser/types/schemas/a2a/parameters.js +241 -0
  96. package/dist/browser/types/schemas/a2a/protocol.d.ts +14363 -0
  97. package/dist/browser/types/schemas/a2a/protocol.js +59 -0
  98. package/dist/browser/types/schemas/a2a/rpc.d.ts +182 -0
  99. package/dist/browser/types/schemas/a2a/rpc.js +126 -0
  100. package/dist/browser/types/schemas/a2a/task.d.ts +5886 -0
  101. package/dist/browser/types/schemas/a2a/task.js +134 -0
  102. package/dist/browser/types/schemas/a2a/transport.d.ts +31 -0
  103. package/dist/browser/types/schemas/a2a/transport.js +28 -0
  104. package/dist/browser/types/schemas/index.d.ts +1 -0
  105. package/dist/browser/types/schemas/index.js +1 -0
  106. package/dist/browser/types/utils/index.d.ts +1 -0
  107. package/dist/browser/types/utils/index.js +1 -0
  108. package/dist/browser/types/utils/transform.d.ts +64 -0
  109. package/dist/browser/types/utils/transform.js +35 -0
  110. package/dist/browser/utils/common/constants.d.ts +11 -0
  111. package/dist/browser/utils/common/constants.js +38 -0
  112. package/dist/browser/utils/common/errors.d.ts +24 -0
  113. package/dist/browser/utils/common/errors.js +42 -0
  114. package/dist/browser/utils/common/utils.d.ts +9 -0
  115. package/dist/browser/utils/common/utils.js +11 -0
  116. package/dist/browser/utils/logging/index.d.ts +2 -0
  117. package/dist/browser/utils/logging/index.js +2 -0
  118. package/dist/browser/utils/logging/log.d.ts +33 -0
  119. package/dist/browser/utils/logging/log.js +75 -0
  120. package/dist/browser/utils/logging/logger.d.ts +18 -0
  121. package/dist/browser/utils/logging/logger.js +18 -0
  122. package/dist/client/a2a-client.d.ts +2 -1
  123. package/dist/client/a2a-client.js +13 -4
  124. package/dist/server/express/errors.js +1 -1
  125. package/dist/server/express/middeware.d.ts +2 -2
  126. package/dist/server/express/middeware.js +26 -6
  127. package/dist/server/express/server.d.ts +26 -25
  128. package/dist/server/express/server.js +32 -6
  129. package/dist/services/a2a/factory/builder.d.ts +24 -24
  130. package/dist/services/a2a/factory/builder.js +6 -1
  131. package/dist/services/a2a/factory/service.js +2 -1
  132. package/dist/services/a2a/helpers/agentcard-builder.d.ts +7 -0
  133. package/dist/services/a2a/helpers/agentcard-builder.js +23 -0
  134. package/dist/services/a2a/helpers/history.d.ts +2 -0
  135. package/dist/services/a2a/helpers/history.js +3 -0
  136. package/dist/services/a2a/helpers/index.d.ts +3 -0
  137. package/dist/services/a2a/helpers/index.js +3 -0
  138. package/dist/services/a2a/methods/get-task.d.ts +46 -46
  139. package/dist/services/a2a/methods/get-task.js +2 -0
  140. package/dist/services/a2a/methods/send-message.js +18 -1
  141. package/dist/services/a2a/service.d.ts +154 -153
  142. package/dist/services/a2a/service.js +20 -6
  143. package/dist/services/mcp/service.js +0 -1
  144. package/dist/transport/rpc/parser.js +2 -2
  145. package/dist/transport/rpc/rpc-client.js +2 -2
  146. package/dist/transport/trpc/a2a/factory/router.d.ts +1084 -1084
  147. package/dist/transport/trpc/a2a/routes/info.d.ts +36 -36
  148. package/dist/transport/trpc/a2a/routes/message/route.d.ts +225 -225
  149. package/dist/transport/trpc/a2a/routes/tasks/route.d.ts +257 -257
  150. package/dist/transport/trpc/a2a/trpc.d.ts +120 -120
  151. package/dist/types/interfaces/services/a2a/service.d.ts +6 -1
  152. package/dist/types/schemas/a2a/agent.d.ts +818 -818
  153. package/dist/types/schemas/a2a/agent.js +1 -23
  154. package/dist/types/schemas/a2a/auth.d.ts +197 -197
  155. package/dist/types/schemas/a2a/auth.js +4 -19
  156. package/dist/types/schemas/a2a/error.d.ts +24 -24
  157. package/dist/types/schemas/a2a/message.d.ts +4499 -4499
  158. package/dist/types/schemas/a2a/message.js +2 -10
  159. package/dist/types/schemas/a2a/notification.d.ts +403 -403
  160. package/dist/types/schemas/a2a/notification.js +3 -7
  161. package/dist/types/schemas/a2a/parameters.d.ts +264 -264
  162. package/dist/types/schemas/a2a/parameters.js +1 -14
  163. package/dist/types/schemas/a2a/protocol.d.ts +5988 -5988
  164. package/dist/types/schemas/a2a/rpc.d.ts +20 -20
  165. package/dist/types/schemas/a2a/rpc.js +0 -5
  166. package/dist/types/schemas/a2a/task.d.ts +2513 -2513
  167. package/dist/types/schemas/a2a/task.js +10 -11
  168. package/dist/utils/common/constants.js +1 -1
  169. package/dist/utils/common/errors.d.ts +2 -1
  170. package/dist/utils/common/errors.js +2 -1
  171. package/dist/utils/common/schema-validation.d.ts +2 -0
  172. package/dist/utils/common/schema-validation.js +12 -0
  173. package/dist/utils/index.d.ts +1 -0
  174. package/dist/utils/index.js +1 -0
  175. package/package.json +20 -17
@@ -0,0 +1,241 @@
1
+ /**
2
+ * Copyright 2025 The Artinet Project
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { z } from "zod";
6
+ import { KindSchema } from "./kind.js";
7
+ /**
8
+ * @description Defines base properties common to all message or artifact parts.
9
+ */
10
+ export const PartBaseSchema = z
11
+ .object({
12
+ /**
13
+ * @optional Optional metadata associated with this part.
14
+ */
15
+ metadata: z
16
+ .record(z.string(), z.unknown())
17
+ .optional()
18
+ .describe("Optional metadata associated with this part."),
19
+ })
20
+ .describe("Defines base properties common to all message or artifact parts.");
21
+ /**
22
+ * @description Defines base properties for a file.
23
+ */
24
+ export const FileBaseSchema = z
25
+ .object({
26
+ /**
27
+ * @optional An optional name for the file (e.g., "document.pdf").
28
+ */
29
+ name: z
30
+ .string()
31
+ .optional()
32
+ .describe("An optional name for the file (e.g., 'document.pdf')."),
33
+ /**
34
+ * @optional The MIME type of the file (e.g., "application/pdf").
35
+ */
36
+ mimeType: z
37
+ .string()
38
+ .optional()
39
+ .describe("The MIME type of the file (e.g., 'application/pdf')."),
40
+ })
41
+ .describe("Defines base properties for a file.");
42
+ /**
43
+ * @description Represents a file with its content provided directly as a base64-encoded string.
44
+ */
45
+ export const FileWithBytesSchema = FileBaseSchema.extend({
46
+ /**
47
+ * @required The base64-encoded content of the file.
48
+ */
49
+ bytes: z.string().describe("The base64-encoded content of the file."),
50
+ /**
51
+ * @optional The `uri` property must be absent when `bytes` is present.
52
+ */
53
+ uri: z.never().optional().describe("The URI of the file."),
54
+ }).describe("Represents a file with its content provided directly as a base64-encoded string.");
55
+ /**
56
+ * @description Represents a file with its content located at a specific URI.
57
+ */
58
+ export const FileWithUriSchema = FileBaseSchema.extend({
59
+ /**
60
+ * @required A URL pointing to the file's content. (keeping as string for now)
61
+ */
62
+ uri: z.string().describe("A URL pointing to the file's content."),
63
+ /**
64
+ * @optional The `bytes` property must be absent when `uri` is present.
65
+ */
66
+ bytes: z
67
+ .never()
68
+ .optional()
69
+ .describe("The base64-encoded content of the file."),
70
+ }).describe("Represents a file with its content located at a specific URI.");
71
+ /**
72
+ * @description Represents a file with its content provided directly as a base64-encoded string or located at a specific URI.
73
+ */
74
+ export const FileSchema = z
75
+ .union([FileWithBytesSchema, FileWithUriSchema])
76
+ .describe("Represents a file with its content provided directly as a base64-encoded string or located at a specific URI.");
77
+ /**
78
+ * @description Represents a file segment within a message or artifact. The file content can be
79
+ * provided either directly as bytes or as a URI.
80
+ */
81
+ export const FilePartSchema = PartBaseSchema.extend({
82
+ /**
83
+ * @required The type of this part, used as a discriminator. Always 'file'.
84
+ */
85
+ kind: KindSchema.refine((kind) => kind === "file").describe("The type of this object, used as a discriminator. Always 'file' for a FilePart."),
86
+ /**
87
+ * @required The file content, represented as either a URI or as base64-encoded bytes.
88
+ */
89
+ file: FileSchema.describe("The file content, represented as either a URI or as base64-encoded bytes."),
90
+ }).describe("Represents a file segment within a message or artifact.");
91
+ /**
92
+ * @description Represents a text segment within a message or artifact.
93
+ */
94
+ export const TextPartSchema = PartBaseSchema.extend({
95
+ /**
96
+ * @required The type of this object, used as a discriminator. Always 'text' for a TextPart.
97
+ */
98
+ kind: KindSchema.refine((kind) => kind === "text").describe("The type of this object, used as a discriminator. Always 'text' for a TextPart."),
99
+ /**
100
+ * @required The string content of the text part.
101
+ */
102
+ text: z.string().describe("The string content of the text part."),
103
+ }).describe("Represents a text segment within a message or artifact.");
104
+ /**
105
+ * @description Represents a structured data segment (e.g., JSON) within a message or artifact.
106
+ */
107
+ export const DataPartSchema = PartBaseSchema.extend({
108
+ /**
109
+ * @required The type of this object, used as a discriminator. Always 'data' for a DataPart.
110
+ */
111
+ kind: KindSchema.refine((kind) => kind === "data").describe("The type of this object, used as a discriminator. Always 'data' for a DataPart."),
112
+ /**
113
+ * @required The structured data content of the data part.
114
+ */
115
+ data: z
116
+ .record(z.string(), z.unknown())
117
+ .describe("The structured data content of the data part."),
118
+ }).describe("Represents a structured data segment (e.g., JSON) within a message or artifact.");
119
+ /**
120
+ * @description A discriminated union representing a part of a message or artifact, which can
121
+ * be text, a file, or structured data.
122
+ */
123
+ export const PartSchema = z
124
+ .union([TextPartSchema, FilePartSchema, DataPartSchema])
125
+ .describe("A discriminated union representing a part of a message or artifact, which can be text, a file, or structured data.");
126
+ /**
127
+ * @description Represents a file, data structure, or other resource generated by an agent during a task.
128
+ */
129
+ export const ArtifactSchema = z
130
+ .object({
131
+ /**
132
+ * @required A unique identifier for the artifact within the scope of the task.
133
+ */
134
+ artifactId: z
135
+ .string()
136
+ .describe("A unique identifier for the artifact within the scope of the task."),
137
+ /**
138
+ * @optional A human-readable name for the artifact.
139
+ */
140
+ name: z
141
+ .string()
142
+ .optional()
143
+ .describe("A human-readable name for the artifact."),
144
+ /**
145
+ * @optional A human-readable description of the artifact.
146
+ */
147
+ description: z
148
+ .string()
149
+ .optional()
150
+ .describe("A human-readable description of the artifact."),
151
+ /**
152
+ * @optional An array of content parts that make up the artifact.
153
+ */
154
+ parts: z
155
+ .array(PartSchema)
156
+ .describe("An array of content parts that make up the artifact."),
157
+ /**
158
+ * @optional Optional metadata for extensions. The key is an extension-specific identifier.
159
+ */
160
+ metadata: z
161
+ .record(z.string(), z.unknown())
162
+ .optional()
163
+ .describe("Optional metadata for extensions. The key is an extension-specific identifier."),
164
+ /**
165
+ * @optional The URIs of extensions that are relevant to this artifact.
166
+ */
167
+ extension: z
168
+ .array(z.string())
169
+ .optional()
170
+ .describe("The URIs of extensions that are relevant to this artifact."),
171
+ })
172
+ .describe("Represents a file, data structure, or other resource generated by an agent during a task. It can be composed of multiple parts.");
173
+ /**
174
+ * @description Represents the role of a message sender.
175
+ */
176
+ export const MessageRoleSchema = z
177
+ .enum(["user", "agent"])
178
+ .describe("Identifies the sender of the message. `user` for the client, `agent` for the service.");
179
+ /**
180
+ * @description Represents a single message in the conversation between a user and an agent.
181
+ */
182
+ export const MessageSchema = z
183
+ .object({
184
+ /**
185
+ * @required Identifies the sender of the message. `user` for the client, `agent` for the service.
186
+ */
187
+ role: MessageRoleSchema.describe("Identifies the sender of the message. `user` for the client, `agent` for the service."),
188
+ /**
189
+ * @required An array of content parts that form the message body. A message can be
190
+ * composed of multiple parts of different types (e.g., text and files).
191
+ */
192
+ parts: z
193
+ .array(PartSchema)
194
+ .describe("An array of content parts that form the message body. A message can be composed of multiple parts of different types (e.g., text and files)."),
195
+ /**
196
+ * @optional Optional metadata for extensions. The key is an extension-specific identifier.
197
+ */
198
+ metadata: z
199
+ .record(z.string(), z.unknown())
200
+ .optional()
201
+ .describe("Optional metadata for extensions. The key is an extension-specific identifier."),
202
+ /**
203
+ * @optional The URIs of extensions that are relevant to this message.
204
+ */
205
+ extensions: z
206
+ .array(z.string())
207
+ .optional()
208
+ .describe("The URIs of extensions that are relevant to this message."),
209
+ /**
210
+ * @optional A list of other task IDs that this message references for additional context.
211
+ */
212
+ referenceTaskIds: z
213
+ .array(z.string())
214
+ .optional()
215
+ .describe("A list of other task IDs that this message references for additional context."),
216
+ /**
217
+ * @required A unique identifier for the message, typically a UUID, generated by the sender.
218
+ */
219
+ messageId: z
220
+ .string()
221
+ .describe("A unique identifier for the message, typically a UUID, generated by the sender."),
222
+ /**
223
+ * @optional The identifier of the task this message is part of. Can be omitted for the first message of a new task.
224
+ */
225
+ taskId: z
226
+ .string()
227
+ .optional()
228
+ .describe("The identifier of the task this message is part of. Can be omitted for the first message of a new task."),
229
+ /**
230
+ * @optional The context identifier for this message, used to group related interactions.
231
+ */
232
+ contextId: z
233
+ .string()
234
+ .optional()
235
+ .describe("The context identifier for this message, used to group related interactions."),
236
+ /**
237
+ * @required The type of this object, used as a discriminator. Always 'message' for a Message.
238
+ */
239
+ kind: KindSchema.refine((kind) => kind === "message").describe("The type of this object, used as a discriminator. Always 'message' for a Message."),
240
+ })
241
+ .describe("Represents a single message in the conversation between a user and an agent.");