@artinet/sdk 0.6.0-preview.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/README.md +100 -59
  2. package/dist/browser/browser.d.ts +2 -7
  3. package/dist/browser/browser.js +2 -7
  4. package/dist/browser/config/observability.d.ts +1 -1
  5. package/dist/browser/create/message-builder.d.ts +1 -1
  6. package/dist/browser/create/message-builder.js +19 -7
  7. package/dist/browser/create/task-builder.js +1 -1
  8. package/dist/browser/messenger/index.d.ts +1 -0
  9. package/dist/browser/messenger/index.js +1 -0
  10. package/dist/browser/messenger/messenger.d.ts +119 -0
  11. package/dist/browser/messenger/messenger.js +245 -0
  12. package/dist/browser/types/a2a/a2a.d.ts +38 -20
  13. package/dist/browser/types/a2a/a2a.js +0 -1
  14. package/dist/browser/types/core/core.d.ts +4 -2
  15. package/dist/browser/types/index.d.ts +0 -1
  16. package/dist/browser/types/index.js +0 -1
  17. package/dist/browser/types/storage.d.ts +2 -14
  18. package/dist/browser/types/storage.js +0 -4
  19. package/dist/browser/utils/{common/constants.d.ts → constants.d.ts} +1 -1
  20. package/dist/{utils/common → browser/utils}/constants.js +1 -1
  21. package/dist/browser/utils/{common/errors.d.ts → errors.d.ts} +17 -36
  22. package/dist/browser/utils/errors.js +76 -0
  23. package/dist/browser/utils/index.d.ts +6 -0
  24. package/dist/browser/utils/index.js +6 -0
  25. package/dist/{utils/common → browser/utils}/parse.js +1 -1
  26. package/dist/{utils/common → browser/utils}/schema-validation.js +2 -2
  27. package/dist/config/index.d.ts +1 -1
  28. package/dist/config/observability.d.ts +1 -1
  29. package/dist/create/agent-builder.d.ts +1 -1
  30. package/dist/create/create.d.ts +19 -20
  31. package/dist/create/create.js +33 -101
  32. package/dist/create/message-builder.d.ts +1 -1
  33. package/dist/create/message-builder.js +19 -7
  34. package/dist/create/status-builder.d.ts +4 -0
  35. package/dist/create/task-builder.js +1 -1
  36. package/dist/extensions/otel.d.ts +3 -0
  37. package/dist/extensions/otel.js +3 -0
  38. package/dist/extensions/pino.d.ts +3 -0
  39. package/dist/extensions/pino.js +3 -0
  40. package/dist/extensions/winston.d.ts +3 -0
  41. package/dist/extensions/winston.js +3 -0
  42. package/dist/index.d.ts +3 -3
  43. package/dist/index.js +3 -3
  44. package/dist/messenger/index.d.ts +1 -0
  45. package/dist/messenger/index.js +1 -0
  46. package/dist/messenger/messenger.d.ts +119 -0
  47. package/dist/messenger/messenger.js +251 -0
  48. package/dist/server/adapters/a2a_request_handler.d.ts +889 -0
  49. package/dist/server/adapters/a2a_request_handler.js +241 -0
  50. package/dist/server/adapters/loadable.d.ts +7 -0
  51. package/dist/server/adapters/loadable.js +73 -0
  52. package/dist/server/adapters/notifications.d.ts +26 -0
  53. package/dist/server/adapters/notifications.js +77 -0
  54. package/dist/server/express/server.d.ts +24 -18
  55. package/dist/server/express/server.js +41 -62
  56. package/dist/server/express/utils.d.ts +14 -0
  57. package/dist/server/express/{errors.js → utils.js} +22 -0
  58. package/dist/server/index.d.ts +4 -1
  59. package/dist/server/index.js +4 -1
  60. package/dist/server/params.d.ts +115 -0
  61. package/dist/server/params.js +21 -0
  62. package/dist/services/a2a/factory/context.d.ts +2 -1
  63. package/dist/services/a2a/factory/context.js +4 -3
  64. package/dist/services/a2a/factory/handler.d.ts +1 -1
  65. package/dist/services/a2a/factory/handler.js +7 -6
  66. package/dist/services/a2a/factory/service.d.ts +1 -1
  67. package/dist/services/a2a/factory/service.js +2 -2
  68. package/dist/services/a2a/factory/state-machine.js +9 -6
  69. package/dist/services/a2a/handlers/cancel-task.d.ts +1 -1
  70. package/dist/services/a2a/handlers/get-task.d.ts +1 -1
  71. package/dist/services/a2a/handlers/resubscribe-task.d.ts +2 -2
  72. package/dist/services/a2a/handlers/send-message.d.ts +1 -1
  73. package/dist/services/a2a/handlers/stream-message.d.ts +2 -2
  74. package/dist/services/a2a/handlers/update.js +7 -9
  75. package/dist/services/a2a/index.d.ts +0 -1
  76. package/dist/services/a2a/index.js +0 -1
  77. package/dist/services/a2a/managers.js +2 -1
  78. package/dist/services/a2a/messenger.d.ts +1 -1
  79. package/dist/services/a2a/messenger.js +1 -1
  80. package/dist/services/a2a/service.d.ts +26 -21
  81. package/dist/services/a2a/service.js +161 -93
  82. package/dist/services/a2a/state-machine.d.ts +1 -1
  83. package/dist/services/a2a/state-machine.js +2 -1
  84. package/dist/services/a2a/streams.js +1 -1
  85. package/dist/services/core/manager.d.ts +5 -0
  86. package/dist/services/core/manager.js +6 -0
  87. package/dist/services/mcp/service.js +1 -1
  88. package/dist/{utils/storage → storage}/file.d.ts +4 -2
  89. package/dist/{utils/storage → storage}/file.js +5 -4
  90. package/dist/storage/index.d.ts +1 -0
  91. package/dist/storage/index.js +2 -0
  92. package/dist/storage/sqlite.d.ts +353 -0
  93. package/dist/storage/sqlite.js +85 -0
  94. package/dist/transport/trpc/a2a/factory/router.d.ts +16 -16
  95. package/dist/transport/trpc/a2a/routes/info.d.ts +2 -2
  96. package/dist/transport/trpc/a2a/routes/message/route.d.ts +3 -3
  97. package/dist/transport/trpc/a2a/routes/message/route.js +2 -1
  98. package/dist/transport/trpc/a2a/routes/tasks/route.d.ts +4 -4
  99. package/dist/transport/trpc/a2a/routes/tasks/route.js +3 -2
  100. package/dist/types/a2a/a2a.d.ts +38 -20
  101. package/dist/types/a2a/a2a.js +0 -1
  102. package/dist/types/core/core.d.ts +4 -2
  103. package/dist/types/index.d.ts +0 -1
  104. package/dist/types/index.js +0 -1
  105. package/dist/types/storage.d.ts +2 -14
  106. package/dist/types/storage.js +0 -4
  107. package/dist/utils/{common/constants.d.ts → constants.d.ts} +1 -1
  108. package/dist/{browser/utils/common → utils}/constants.js +1 -1
  109. package/dist/utils/{common/errors.d.ts → errors.d.ts} +17 -36
  110. package/dist/utils/errors.js +80 -0
  111. package/dist/utils/index.d.ts +6 -11
  112. package/dist/utils/index.js +6 -11
  113. package/dist/utils/parse.d.ts +7 -0
  114. package/dist/utils/parse.js +14 -0
  115. package/dist/utils/schema-validation.d.ts +2 -0
  116. package/dist/utils/schema-validation.js +12 -0
  117. package/package.json +35 -22
  118. package/dist/browser/client/a2a-client.d.ts +0 -127
  119. package/dist/browser/client/a2a-client.js +0 -233
  120. package/dist/browser/client/index.d.ts +0 -1
  121. package/dist/browser/client/index.js +0 -1
  122. package/dist/browser/transport/rpc/parser.d.ts +0 -15
  123. package/dist/browser/transport/rpc/parser.js +0 -49
  124. package/dist/browser/transport/rpc/rpc-client.d.ts +0 -80
  125. package/dist/browser/transport/rpc/rpc-client.js +0 -189
  126. package/dist/browser/transport/streaming/event-stream.d.ts +0 -25
  127. package/dist/browser/transport/streaming/event-stream.js +0 -100
  128. package/dist/browser/types/client.d.ts +0 -133
  129. package/dist/browser/types/client.js +0 -5
  130. package/dist/browser/utils/common/errors.js +0 -95
  131. package/dist/client/a2a-client.d.ts +0 -127
  132. package/dist/client/a2a-client.js +0 -237
  133. package/dist/client/index.d.ts +0 -1
  134. package/dist/client/index.js +0 -1
  135. package/dist/server/express/errors.d.ts +0 -9
  136. package/dist/server/express/index.d.ts +0 -3
  137. package/dist/server/express/index.js +0 -3
  138. package/dist/server/express/middeware.d.ts +0 -7
  139. package/dist/server/express/middeware.js +0 -121
  140. package/dist/transport/index.d.ts +0 -3
  141. package/dist/transport/index.js +0 -4
  142. package/dist/transport/rpc/parser.d.ts +0 -15
  143. package/dist/transport/rpc/parser.js +0 -49
  144. package/dist/transport/rpc/rpc-client.d.ts +0 -80
  145. package/dist/transport/rpc/rpc-client.js +0 -189
  146. package/dist/transport/streaming/event-stream.d.ts +0 -25
  147. package/dist/transport/streaming/event-stream.js +0 -100
  148. package/dist/types/client.d.ts +0 -133
  149. package/dist/types/client.js +0 -5
  150. package/dist/utils/common/errors.js +0 -98
  151. /package/dist/{utils/common → browser/utils}/parse.d.ts +0 -0
  152. /package/dist/{utils/common → browser/utils}/schema-validation.d.ts +0 -0
  153. /package/dist/browser/utils/{common/utils.d.ts → utils.d.ts} +0 -0
  154. /package/dist/browser/utils/{common/utils.js → utils.js} +0 -0
  155. /package/dist/utils/{common/utils.d.ts → utils.d.ts} +0 -0
  156. /package/dist/utils/{common/utils.js → utils.js} +0 -0
  157. /package/dist/utils/{common/zAsyncIterable-v3.d.ts → zAsyncIterable-v3.d.ts} +0 -0
  158. /package/dist/utils/{common/zAsyncIterable-v3.js → zAsyncIterable-v3.js} +0 -0
  159. /package/dist/utils/{common/zAsyncIterable.d.ts → zAsyncIterable.d.ts} +0 -0
  160. /package/dist/utils/{common/zAsyncIterable.js → zAsyncIterable.js} +0 -0
@@ -49,7 +49,7 @@ export declare const taskRouter: import("@trpc/server").TRPCBuiltRouter<{
49
49
  id: string;
50
50
  contextId: string;
51
51
  status: {
52
- state: "failed" | "unknown" | "completed" | "canceled" | "rejected" | "working" | "submitted" | "input-required" | "auth-required";
52
+ state: "unknown" | "submitted" | "working" | "input-required" | "completed" | "canceled" | "failed" | "rejected" | "auth-required";
53
53
  message?: {
54
54
  role: "user" | "agent";
55
55
  parts: ({
@@ -155,7 +155,7 @@ export declare const taskRouter: import("@trpc/server").TRPCBuiltRouter<{
155
155
  contextId: string;
156
156
  kind: "status-update";
157
157
  status: {
158
- state: "failed" | "unknown" | "completed" | "canceled" | "rejected" | "working" | "submitted" | "input-required" | "auth-required";
158
+ state: "unknown" | "submitted" | "working" | "input-required" | "completed" | "canceled" | "failed" | "rejected" | "auth-required";
159
159
  message?: {
160
160
  role: "user" | "agent";
161
161
  parts: ({
@@ -242,7 +242,7 @@ export declare const taskRouter: import("@trpc/server").TRPCBuiltRouter<{
242
242
  id: string;
243
243
  contextId: string;
244
244
  status: {
245
- state: "failed" | "unknown" | "completed" | "canceled" | "rejected" | "working" | "submitted" | "input-required" | "auth-required";
245
+ state: "unknown" | "submitted" | "working" | "input-required" | "completed" | "canceled" | "failed" | "rejected" | "auth-required";
246
246
  message?: {
247
247
  role: "user" | "agent";
248
248
  parts: ({
@@ -355,7 +355,7 @@ export declare const taskRouter: import("@trpc/server").TRPCBuiltRouter<{
355
355
  id: string;
356
356
  contextId: string;
357
357
  status: {
358
- state: "failed" | "unknown" | "completed" | "canceled" | "rejected" | "working" | "submitted" | "input-required" | "auth-required";
358
+ state: "unknown" | "submitted" | "working" | "input-required" | "completed" | "canceled" | "failed" | "rejected" | "auth-required";
359
359
  message?: {
360
360
  role: "user" | "agent";
361
361
  parts: ({
@@ -5,7 +5,8 @@
5
5
  import { z } from "zod/v4";
6
6
  import { router, A2AProcedure } from "../../trpc.js";
7
7
  import { A2A } from "../../../../../types/index.js";
8
- import { INVALID_REQUEST, PUSH_NOTIFICATION_NOT_SUPPORTED, zAsyncIterable, } from "../../../../../utils/index.js";
8
+ import { INVALID_REQUEST, PUSH_NOTIFICATION_NOT_SUPPORTED, } from "../../../../../utils/errors.js";
9
+ import { zAsyncIterable } from "../../../../../utils/zAsyncIterable.js";
9
10
  const pushNotificationConfigRouter = router({
10
11
  set: A2AProcedure.input(A2A.TaskPushNotificationConfigSchema)
11
12
  .output(A2A.TaskPushNotificationConfigSchema)
@@ -19,7 +20,7 @@ const pushNotificationConfigRouter = router({
19
20
  console.warn("task/pushNotificationConfig/get", input);
20
21
  throw PUSH_NOTIFICATION_NOT_SUPPORTED("Push notifications not supported");
21
22
  }),
22
- list: A2AProcedure.input(A2A.ListTaskPushNotificationConfigsParamsSchema)
23
+ list: A2AProcedure.input(A2A.ListTaskPushNotificationConfigParamsSchema)
23
24
  .output(A2A.ListTaskPushNotificationConfigResultSchema)
24
25
  .query(async ({ input }) => {
25
26
  console.warn("task/pushNotificationConfig/list", input);
@@ -2,7 +2,7 @@
2
2
  * Copyright 2025 The Artinet Project
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
- import { AgentCard, Message, Task, AgentExtension, TaskQueryParams, TaskIdParams, MessageSendParams, SendMessageSuccessResult } from "@artinet/types/a2a";
5
+ import { AgentCard, Message, Task, AgentExtension, TaskQueryParams, TaskIdParams, MessageSendParams, SendMessageSuccessResult, PushNotificationConfig } from "@artinet/types/a2a";
6
6
  import { core } from "../core/index.js";
7
7
  import { z } from "zod/v4";
8
8
  export type AgentCardParams = (Partial<AgentCard> & Required<Pick<AgentCard, "name">>) | string;
@@ -46,14 +46,14 @@ export declare const UpdateSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
46
46
  contextId: z.ZodString;
47
47
  status: z.ZodObject<{
48
48
  state: z.ZodEnum<{
49
- failed: "failed";
50
49
  unknown: "unknown";
50
+ submitted: "submitted";
51
+ working: "working";
52
+ "input-required": "input-required";
51
53
  completed: "completed";
52
54
  canceled: "canceled";
55
+ failed: "failed";
53
56
  rejected: "rejected";
54
- working: "working";
55
- submitted: "submitted";
56
- "input-required": "input-required";
57
57
  "auth-required": "auth-required";
58
58
  }>;
59
59
  message: z.ZodOptional<z.ZodObject<{
@@ -168,14 +168,14 @@ export declare const UpdateSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
168
168
  kind: z.ZodLiteral<"status-update">;
169
169
  status: z.ZodObject<{
170
170
  state: z.ZodEnum<{
171
- failed: "failed";
172
171
  unknown: "unknown";
172
+ submitted: "submitted";
173
+ working: "working";
174
+ "input-required": "input-required";
173
175
  completed: "completed";
174
176
  canceled: "canceled";
177
+ failed: "failed";
175
178
  rejected: "rejected";
176
- working: "working";
177
- submitted: "submitted";
178
- "input-required": "input-required";
179
179
  "auth-required": "auth-required";
180
180
  }>;
181
181
  message: z.ZodOptional<z.ZodObject<{
@@ -272,13 +272,13 @@ export interface Context extends BaseContext {
272
272
  readonly messages: MessageConsumerProxy;
273
273
  extensions?: AgentExtension[];
274
274
  references?: Task[];
275
+ userId?: string;
275
276
  getTask: () => Promise<Task>;
276
277
  }
277
278
  export type ContextParams = Omit<BaseContext, "publisher" | "isCancelled" | "getState" | "abortSignal"> & Omit<Partial<Context>, "userMessage" | "taskId"> & {
278
279
  messenger: MessageConsumerProxy;
279
280
  task: Task;
280
281
  overrides?: Partial<Omit<EventConsumer, "contextId">>;
281
- abortSignal?: AbortSignal;
282
282
  };
283
283
  export interface Contexts extends core.Contexts<Context> {
284
284
  create: (params: ContextParams) => Promise<Context>;
@@ -294,20 +294,38 @@ export interface Cancellations extends Omit<core.Manager<void>, "get"> {
294
294
  }
295
295
  export interface Connections extends Omit<core.Manager<void>, "get"> {
296
296
  }
297
- export interface ServiceOptions {
298
- abortSignal?: AbortSignal;
297
+ export interface Notifier {
298
+ notify: (task: Task, update: Update, context?: Context) => Promise<void>;
299
+ register: (taskId: string, config: PushNotificationConfig) => Promise<void>;
300
+ }
301
+ export type ServiceOptions = Pick<ContextParams, "userId" | "extensions"> & {
302
+ task?: Task;
303
+ signal?: AbortSignal;
304
+ notifier?: Notifier;
305
+ };
306
+ export interface Handles {
307
+ getTask: (input: TaskQueryParams, context: Context) => Promise<Task>;
308
+ cancelTask: (input: TaskIdParams, context: Context) => Promise<Task>;
309
+ sendMessage: (message: MessageSendParams, context: Context) => Promise<SendMessageSuccessResult>;
310
+ /**
311
+ * @deprecated Use sendMessageStream instead
312
+ */
313
+ streamMessage: (message: MessageSendParams, context: Context) => AsyncGenerator<Update>;
314
+ sendMessageStream: (message: MessageSendParams, context: Context) => AsyncGenerator<Update>;
315
+ resubscribe: (input: TaskIdParams, context: Context) => AsyncGenerator<Update>;
299
316
  }
300
317
  export interface RequestHandler {
301
- getTask: (input: TaskQueryParams, context?: Context, options?: ServiceOptions) => Promise<Task>;
302
- cancelTask: (input: TaskIdParams, context?: Context, options?: ServiceOptions) => Promise<Task>;
303
- sendMessage: (message: MessageSendParams, context?: Context, options?: ServiceOptions) => Promise<SendMessageSuccessResult>;
304
- streamMessage: (message: MessageSendParams, context?: Context, options?: ServiceOptions) => AsyncGenerator<Update>;
305
- resubscribe: (input: TaskIdParams, context?: Context, options?: ServiceOptions) => AsyncGenerator<Update>;
318
+ getTask: (input: TaskQueryParams, options?: ServiceOptions) => Promise<Task>;
319
+ cancelTask: (input: TaskIdParams, options?: ServiceOptions) => Promise<Task>;
320
+ sendMessage: (message: MessageSendParams, options?: ServiceOptions) => Promise<SendMessageSuccessResult>;
321
+ /**
322
+ * @deprecated Use sendMessageStream instead
323
+ */
324
+ streamMessage: (message: MessageSendParams, options?: ServiceOptions) => AsyncGenerator<Update>;
325
+ sendMessageStream: (message: MessageSendParams, options?: ServiceOptions) => AsyncGenerator<Update>;
326
+ resubscribe: (input: TaskIdParams, options?: ServiceOptions) => AsyncGenerator<Update>;
306
327
  getAgentCard: () => Promise<AgentCard>;
307
328
  }
308
- export interface ExtendedHandler extends RequestHandler {
309
- getAuthenticatedExtendedCard: () => Promise<AgentCard>;
310
- }
311
329
  export interface Stream {
312
330
  readonly contextId: string;
313
331
  isAlive: boolean;
@@ -2,7 +2,6 @@
2
2
  * Copyright 2025 The Artinet Project
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
- //lets stay really granular with the imports
6
5
  import { TaskArtifactUpdateEventSchema, MessageSchema, TaskSchema, TaskStatusUpdateEventSchema, } from "@artinet/types/a2a";
7
6
  import { z } from "zod/v4";
8
7
  export const UpdateSchema = z.discriminatedUnion("kind", [
@@ -1,4 +1,5 @@
1
- import { EventEmitter } from "events";
1
+ import { EventEmitter } from "eventemitter3";
2
+ import { IStore } from "../storage.js";
2
3
  export interface Service<Params extends object = object, Result extends unknown = void> {
3
4
  execute: (params: Params) => Promise<Result>;
4
5
  stop: () => Promise<void>;
@@ -11,9 +12,10 @@ export interface Context<State extends object = object> {
11
12
  readonly publisher?: Publisher;
12
13
  readonly getState: (args?: string) => Promise<State | undefined>;
13
14
  metadata?: Record<string, unknown>;
15
+ /**hooks allow consumers to modify context on the fly*/
14
16
  readonly hooks?: Record<string, (...args: unknown[]) => Promise<unknown>>;
15
17
  }
16
- export interface Manager<T = object> {
18
+ export interface Manager<T = object> extends IStore<T> {
17
19
  get: (id: string) => Promise<T | undefined>;
18
20
  set: (id: string, data?: T) => Promise<void>;
19
21
  delete: (id: string) => Promise<void>;
@@ -1,7 +1,6 @@
1
1
  export * from "./a2a/index.js";
2
2
  export * from "./core/index.js";
3
3
  export * from "./mcp/index.js";
4
- export * from "./client.js";
5
4
  export * from "./protocol.js";
6
5
  export * from "./storage.js";
7
6
  export * from "./utils/index.js";
@@ -1,7 +1,6 @@
1
1
  export * from "./a2a/index.js";
2
2
  export * from "./core/index.js";
3
3
  export * from "./mcp/index.js";
4
- export * from "./client.js";
5
4
  export * from "./protocol.js";
6
5
  export * from "./storage.js";
7
6
  export * from "./utils/index.js";
@@ -1,18 +1,6 @@
1
1
  /**
2
- * Copyright 2025 The Artinet Project
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
- /**
6
- * Interface for a store of data.
7
- * @deprecated Use IStore instead
8
- * @template T - The type of data to store
9
- */
10
- export interface Store<T> {
11
- set(data: T, id?: string): Promise<void>;
12
- get(id: string): Promise<T | undefined>;
13
- }
14
- /**
15
- * Interface for a store of data.
2
+ * @note prefer implementing `Manager` instead of `IStore` as it provides a more robust interface.
3
+ * Interface for a store of data.
16
4
  * @template T - The type of data to store
17
5
  */
18
6
  export interface IStore<T> {
@@ -1,5 +1 @@
1
- /**
2
- * Copyright 2025 The Artinet Project
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
1
  export {};
@@ -2,5 +2,5 @@
2
2
  * Copyright 2025 The Artinet Project
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
- import { A2A } from "../../types/index.js";
5
+ import { A2A } from "../types/index.js";
6
6
  export declare const FINAL_STATES: A2A.TaskState[];
@@ -2,7 +2,7 @@
2
2
  * Copyright 2025 The Artinet Project
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
- import { A2A } from "../../types/index.js";
5
+ import { A2A } from "../types/index.js";
6
6
  export const FINAL_STATES = [
7
7
  A2A.TaskState.completed,
8
8
  A2A.TaskState.failed,
@@ -2,77 +2,58 @@
2
2
  * Copyright 2025 The Artinet Project
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
- import { A2A, MCP } from "../../types/index.js";
5
+ import { A2A, MCP } from "../types/index.js";
6
6
  /**
7
- * @deprecated Use errors from the `@a2a-js/sdk` package instead
8
7
  * @since 0.6.0
9
8
  */
10
9
  export declare class SystemError<T extends MCP.JSONRPCErrorResponse> extends Error {
11
- message: string;
12
10
  code: T["error"]["code"];
13
- data: T["error"]["data"];
14
- constructor(message: string, code: T["error"]["code"], data: T["error"]["data"]);
11
+ data?: T["error"]["data"];
12
+ taskId?: string;
13
+ message: string;
14
+ constructor(message: string, code: T["error"]["code"], data?: T["error"]["data"], taskId?: string);
15
15
  }
16
16
  /**
17
- * @deprecated Use errors from the `@a2a-js/sdk` package instead
18
- * @since 0.6.0
19
- */
20
- export declare const PARSE_ERROR: <T extends A2A.JSONParseError>(data: T["error"]["data"]) => SystemError<T>;
21
- /**
22
- * @deprecated Use errors from the `@a2a-js/sdk` package instead
23
- * @since 0.6.0
24
- */
25
- export declare const INVALID_REQUEST: <T extends A2A.InvalidRequestError>(data: T["error"]["data"]) => SystemError<T>;
26
- /**
27
- * @deprecated Use errors from the `@a2a-js/sdk` package instead
28
- * @since 0.6.0
29
- */
30
- export declare const METHOD_NOT_FOUND: <T extends A2A.MethodNotFoundError>(data: T["error"]["data"]) => SystemError<T>;
31
- /**
32
- * @deprecated Use errors from the `@a2a-js/sdk` package instead
33
17
  * @since 0.6.0
34
18
  */
35
- export declare const INVALID_PARAMS: <T extends A2A.InvalidParamsError>(data: T["error"]["data"]) => SystemError<T>;
19
+ export declare const PARSE_ERROR: <T extends A2A.JSONParseError>(data: T["error"]["data"], taskId?: string) => SystemError<T>;
36
20
  /**
37
- * @deprecated Use errors from the `@a2a-js/sdk` package instead
38
21
  * @since 0.6.0
39
22
  */
40
- export declare const INTERNAL_ERROR: <T extends A2A.InternalError>(data: T["error"]["data"]) => SystemError<T>;
23
+ export declare const INVALID_REQUEST: <T extends A2A.InvalidRequestError>(data: T["error"]["data"], taskId?: string) => SystemError<T>;
41
24
  /**
42
- * @deprecated Use errors from the `@a2a-js/sdk` package instead
43
- * @since 0.6.0
44
- */
45
- export declare const TASK_NOT_FOUND: <T extends A2A.TaskNotFoundError>(data: T["error"]["data"]) => SystemError<T>;
46
- /**
47
- * @deprecated Use errors from the `@a2a-js/sdk` package instead
48
25
  * @since 0.6.0
49
26
  */
50
- export declare const TASK_NOT_CANCELABLE: <T extends A2A.TaskNotCancelableError>(data: T["error"]["data"]) => SystemError<T>;
27
+ export declare const METHOD_NOT_FOUND: <T extends A2A.MethodNotFoundError>(data: T["error"]["data"], taskId?: string) => SystemError<T>;
28
+ export declare const INVALID_PARAMS: <T extends A2A.InvalidParamsError>(data: T["error"]["data"], taskId?: string) => SystemError<T>;
29
+ export declare const INTERNAL_ERROR: <T extends A2A.InternalError>(data: T["error"]["data"], taskId?: string) => SystemError<T>;
30
+ export declare const TASK_NOT_FOUND: <T extends A2A.TaskNotFoundError>(data: T["error"]["data"], taskId?: string) => SystemError<T>;
31
+ export declare const TASK_NOT_CANCELABLE: <T extends A2A.TaskNotCancelableError>(data: T["error"]["data"], taskId?: string) => SystemError<T>;
51
32
  /**
52
33
  * @deprecated Use errors from the `@a2a-js/sdk` package instead
53
34
  * @since 0.6.0
54
35
  */
55
- export declare const PUSH_NOTIFICATION_NOT_SUPPORTED: <T extends A2A.A2AError>(data: T["error"]["data"]) => SystemError<T>;
36
+ export declare const PUSH_NOTIFICATION_NOT_SUPPORTED: <T extends A2A.PushNotificationNotSupportedError>(data: T["error"]["data"], taskId?: string) => SystemError<T>;
56
37
  /**
57
38
  * @deprecated Use errors from the `@a2a-js/sdk` package instead
58
39
  * @since 0.6.0
59
40
  */
60
- export declare const AUTHENTICATED_EXTENDED_CARD_NOT_CONFIGURED: <T extends A2A.AuthenticatedExtendedCardNotConfiguredError>(data: T["error"]["data"]) => SystemError<T>;
41
+ export declare const AUTHENTICATED_EXTENDED_CARD_NOT_CONFIGURED: <T extends A2A.AuthenticatedExtendedCardNotConfiguredError>(data: T["error"]["data"], taskId?: string) => SystemError<T>;
61
42
  /**
62
43
  * @deprecated Use errors from the `@a2a-js/sdk` package instead
63
44
  * @since 0.6.0
64
45
  */
65
- export declare const UNSUPPORTED_OPERATION: <T extends A2A.A2AError>(data: T["error"]["data"]) => SystemError<T>;
46
+ export declare const UNSUPPORTED_OPERATION: <T extends A2A.A2AError>(data: T["error"]["data"], taskId?: string) => SystemError<T>;
66
47
  /**
67
48
  * @deprecated Use errors from the `@a2a-js/sdk` package instead
68
49
  * @since 0.6.0
69
50
  */
70
- export declare const CONTENT_TYPE_NOT_SUPPORTED: <T extends A2A.ContentTypeNotSupportedError>(data: T["error"]["data"]) => SystemError<T>;
51
+ export declare const CONTENT_TYPE_NOT_SUPPORTED: <T extends A2A.ContentTypeNotSupportedError>(data: T["error"]["data"], taskId?: string) => SystemError<T>;
71
52
  /**
72
53
  * @deprecated Use errors from the `@a2a-js/sdk` package instead
73
54
  * @since 0.6.0
74
55
  */
75
- export declare const INVALID_AGENT_RESPONSE: <T extends A2A.InvalidAgentResponseError>(data: T["error"]["data"]) => SystemError<T>;
56
+ export declare const INVALID_AGENT_RESPONSE: <T extends A2A.InvalidAgentResponseError>(data: T["error"]["data"], taskId?: string) => SystemError<T>;
76
57
  /**
77
58
  * @deprecated Use {@link describe.update.failed} instead
78
59
  * @since 0.6.0
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Copyright 2025 The Artinet Project
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { A2A } from "../types/index.js";
6
+ import * as describe from "../create/describe.js";
7
+ /**
8
+ * @since 0.6.0
9
+ */
10
+ export class SystemError extends Error {
11
+ code;
12
+ data;
13
+ taskId;
14
+ message;
15
+ constructor(message, code, data, taskId) {
16
+ super(message);
17
+ // this.name = "RpcError";
18
+ this.code = code;
19
+ this.data = data;
20
+ this.taskId = taskId;
21
+ this.message = message;
22
+ }
23
+ }
24
+ /**
25
+ * @since 0.6.0
26
+ */
27
+ export const PARSE_ERROR = (data, taskId) => new SystemError("Invalid JSON payload", A2A.ErrorCodeParseError, data, taskId);
28
+ /**
29
+ * @since 0.6.0
30
+ */
31
+ export const INVALID_REQUEST = (data, taskId) => new SystemError("Request payload validation error", A2A.ErrorCodeInvalidRequest, data, taskId);
32
+ /**
33
+ * @since 0.6.0
34
+ */
35
+ export const METHOD_NOT_FOUND = (data, taskId) => new SystemError("Method not found", A2A.ErrorCodeMethodNotFound, data, taskId);
36
+ export const INVALID_PARAMS = (data, taskId) => new SystemError("Invalid parameters", A2A.ErrorCodeInvalidParams, data, taskId);
37
+ export const INTERNAL_ERROR = (data, taskId) => new SystemError("Internal error", A2A.ErrorCodeInternalError, data, taskId);
38
+ export const TASK_NOT_FOUND = (data, taskId) => new SystemError("Task not found", A2A.ErrorCodeTaskNotFound, data, taskId);
39
+ export const TASK_NOT_CANCELABLE = (data, taskId) => new SystemError("Task cannot be canceled", A2A.ErrorCodeTaskNotCancelable, data, taskId);
40
+ /**
41
+ * @deprecated Use errors from the `@a2a-js/sdk` package instead
42
+ * @since 0.6.0
43
+ */
44
+ export const PUSH_NOTIFICATION_NOT_SUPPORTED = (data, taskId) => new SystemError("Push Notifications is not supported", A2A.ErrorCodePushNotificationNotSupported, data, taskId);
45
+ /**
46
+ * @deprecated Use errors from the `@a2a-js/sdk` package instead
47
+ * @since 0.6.0
48
+ */
49
+ export const AUTHENTICATED_EXTENDED_CARD_NOT_CONFIGURED = (data, taskId) => new SystemError("Authenticated Extended Card is not configured", A2A.ErrorCodeAuthenticatedExtendedCardNotConfigured, data, taskId);
50
+ /**
51
+ * @deprecated Use errors from the `@a2a-js/sdk` package instead
52
+ * @since 0.6.0
53
+ */
54
+ export const UNSUPPORTED_OPERATION = (data, taskId) => new SystemError("This operation is not supported", A2A.ErrorCodeUnsupportedOperation, data, taskId);
55
+ /**
56
+ * @deprecated Use errors from the `@a2a-js/sdk` package instead
57
+ * @since 0.6.0
58
+ */
59
+ export const CONTENT_TYPE_NOT_SUPPORTED = (data, taskId) => new SystemError("Content type not supported", A2A.ErrorCodeContentTypeNotSupported, data, taskId);
60
+ /**
61
+ * @deprecated Use errors from the `@a2a-js/sdk` package instead
62
+ * @since 0.6.0
63
+ */
64
+ export const INVALID_AGENT_RESPONSE = (data, taskId) => new SystemError("Invalid agent response", A2A.ErrorCodeInvalidAgentResponse, data, taskId);
65
+ /**
66
+ * @deprecated Use {@link describe.update.failed} instead
67
+ * @since 0.6.0
68
+ */
69
+ export const FAILED_UPDATE = (taskId, contextId, messageId = "failed-update", errMessage) => {
70
+ return describe.update.failed({
71
+ taskId,
72
+ contextId,
73
+ final: true,
74
+ message: describe.message({
75
+ role: "agent",
76
+ messageId,
77
+ parts: [{ kind: "text", text: errMessage }],
78
+ }),
79
+ });
80
+ };
@@ -1,11 +1,6 @@
1
- /**
2
- * @deprecated Many of these utils will be removed in the next major release.
3
- * @fileoverview Provides a collection of utility functions for the Artinet SDK.
4
- */
5
- export * from "./common/constants.js";
6
- export * from "./common/errors.js";
7
- export * from "./common/schema-validation.js";
8
- export * from "./common/utils.js";
9
- export * from "./common/zAsyncIterable.js";
10
- export * from "./common/parse.js";
11
- export * from "./storage/file.js";
1
+ /**Only export browser compatible utils */
2
+ export * from "./constants.js";
3
+ export * from "./errors.js";
4
+ export * from "./parse.js";
5
+ export * from "./schema-validation.js";
6
+ export * from "./utils.js";
@@ -1,11 +1,6 @@
1
- /**
2
- * @deprecated Many of these utils will be removed in the next major release.
3
- * @fileoverview Provides a collection of utility functions for the Artinet SDK.
4
- */
5
- export * from "./common/constants.js";
6
- export * from "./common/errors.js";
7
- export * from "./common/schema-validation.js";
8
- export * from "./common/utils.js";
9
- export * from "./common/zAsyncIterable.js";
10
- export * from "./common/parse.js";
11
- export * from "./storage/file.js";
1
+ /**Only export browser compatible utils */
2
+ export * from "./constants.js";
3
+ export * from "./errors.js";
4
+ export * from "./parse.js";
5
+ export * from "./schema-validation.js";
6
+ export * from "./utils.js";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright 2025 The Artinet Project
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { z } from "zod/v4";
6
+ export declare function safeParse<T = any>(json: string): T;
7
+ export declare function safeParseSchema<T extends z.ZodSchema>(json: string, schema: T): Promise<z.output<T>>;
@@ -0,0 +1,14 @@
1
+ import { validateSchema } from "./schema-validation.js";
2
+ import { logger } from "../config/index.js";
3
+ export function safeParse(json) {
4
+ try {
5
+ return JSON.parse(json);
6
+ }
7
+ catch (error) {
8
+ logger.warn("safeParse error:", error, json);
9
+ return {};
10
+ }
11
+ }
12
+ export async function safeParseSchema(json, schema) {
13
+ return await validateSchema(schema, safeParse(json));
14
+ }
@@ -0,0 +1,2 @@
1
+ import { z } from "zod/v4";
2
+ export declare function validateSchema<T extends z.ZodSchema>(schema: T, data: unknown): Promise<z.output<T>>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright 2025 The Artinet Project
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { INVALID_PARAMS } from "./errors.js";
6
+ import { logger } from "../config/index.js";
7
+ export async function validateSchema(schema, data) {
8
+ return await schema.parseAsync(data).catch((error) => {
9
+ logger.error("Schema validation failed", error);
10
+ throw INVALID_PARAMS(error);
11
+ });
12
+ }