@artinet/sdk 0.5.18 → 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.
- package/README.md +36 -617
- package/dist/browser/browser.d.ts +1 -1
- package/dist/browser/browser.js +1 -1
- package/dist/browser/client/a2a-client.d.ts +19 -18
- package/dist/browser/client/a2a-client.js +18 -6
- package/dist/browser/config/index.d.ts +158 -0
- package/dist/browser/config/index.js +155 -0
- package/dist/browser/config/observability.d.ts +119 -0
- package/dist/browser/config/observability.js +35 -0
- package/dist/browser/services/a2a/helpers/message-builder.d.ts +13 -8
- package/dist/browser/services/a2a/helpers/message-builder.js +5 -0
- package/dist/browser/transport/rpc/parser.d.ts +2 -2
- package/dist/browser/transport/rpc/parser.js +6 -6
- package/dist/browser/transport/rpc/rpc-client.d.ts +5 -5
- package/dist/browser/transport/rpc/rpc-client.js +6 -6
- package/dist/browser/transport/streaming/event-stream.d.ts +3 -3
- package/dist/browser/transport/streaming/event-stream.js +11 -10
- package/dist/browser/types/a2a/a2a.d.ts +378 -0
- package/dist/browser/types/a2a/a2a.js +14 -0
- package/dist/browser/types/a2a/builder.d.ts +43 -0
- package/dist/browser/types/a2a/index.d.ts +3 -0
- package/dist/browser/types/a2a/index.js +2 -0
- package/dist/{types/interfaces → browser/types}/client.d.ts +25 -27
- package/dist/browser/types/core/core.d.ts +31 -0
- package/dist/browser/types/core/index.d.ts +1 -0
- package/dist/browser/types/core/index.js +1 -0
- package/dist/browser/types/index.d.ts +6 -3
- package/dist/browser/types/index.js +6 -3
- package/dist/browser/types/mcp/index.d.ts +1 -0
- package/dist/browser/types/mcp/index.js +1 -0
- package/dist/browser/types/{interfaces/services/mcp/service.d.ts → mcp/mcp.d.ts} +4 -3
- package/dist/browser/types/{interfaces/services/a2a/context.js → mcp/mcp.js} +1 -1
- package/dist/browser/types/storage.d.ts +21 -0
- package/dist/browser/utils/common/constants.d.ts +7 -7
- package/dist/browser/utils/common/constants.js +9 -9
- package/dist/browser/utils/common/errors.d.ts +18 -18
- package/dist/browser/utils/common/errors.js +14 -14
- package/dist/browser/utils/common/utils.d.ts +23 -0
- package/dist/browser/utils/common/utils.js +32 -0
- package/dist/client/a2a-client.d.ts +19 -18
- package/dist/client/a2a-client.js +18 -6
- package/dist/config/default.d.ts +50 -0
- package/dist/config/default.js +62 -0
- package/dist/config/index.d.ts +158 -0
- package/dist/config/index.js +155 -0
- package/dist/config/observability.d.ts +119 -0
- package/dist/config/observability.js +35 -0
- package/dist/extensions/otel.d.ts +98 -0
- package/dist/extensions/otel.js +190 -0
- package/dist/extensions/pino.d.ts +44 -0
- package/dist/extensions/pino.js +107 -0
- package/dist/extensions/winston.d.ts +47 -0
- package/dist/extensions/winston.js +114 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/server/express/errors.js +3 -3
- package/dist/server/express/middeware.d.ts +2 -2
- package/dist/server/express/middeware.js +11 -4
- package/dist/server/express/server.d.ts +9 -56
- package/dist/server/express/server.js +21 -28
- package/dist/services/a2a/execute.d.ts +6 -0
- package/dist/services/a2a/execute.js +25 -0
- package/dist/services/a2a/factory/builder.d.ts +21 -80
- package/dist/services/a2a/factory/builder.js +20 -15
- package/dist/services/a2a/factory/context.d.ts +15 -128
- package/dist/services/a2a/factory/context.js +31 -136
- package/dist/services/a2a/factory/handler.d.ts +6 -0
- package/dist/services/a2a/factory/{method.js → handler.js} +2 -2
- package/dist/services/a2a/factory/index.d.ts +1 -2
- package/dist/services/a2a/factory/index.js +1 -2
- package/dist/services/a2a/factory/service.d.ts +20 -7
- package/dist/services/a2a/factory/service.js +4 -4
- package/dist/services/a2a/factory/state-machine.d.ts +11 -0
- package/dist/services/a2a/factory/state-machine.js +66 -0
- package/dist/services/a2a/{state/update → handlers}/artifact.d.ts +4 -4
- package/dist/services/a2a/handlers/cancel-task.d.ts +11 -0
- package/dist/services/a2a/handlers/cancel-task.js +33 -0
- package/dist/services/a2a/handlers/get-task.d.ts +11 -0
- package/dist/services/a2a/handlers/get-task.js +13 -0
- package/dist/services/a2a/handlers/resubscribe-task.d.ts +11 -0
- package/dist/services/a2a/handlers/resubscribe-task.js +56 -0
- package/dist/services/a2a/handlers/send-message.d.ts +11 -0
- package/dist/services/a2a/handlers/send-message.js +35 -0
- package/dist/services/a2a/handlers/stream-message.d.ts +11 -0
- package/dist/services/a2a/handlers/stream-message.js +19 -0
- package/dist/services/a2a/handlers/update.d.ts +17 -0
- package/dist/services/a2a/handlers/update.js +114 -0
- package/dist/services/a2a/helpers/agentcard-builder.d.ts +9 -5
- package/dist/services/a2a/helpers/agentcard-builder.js +4 -0
- package/dist/services/a2a/helpers/content.d.ts +2 -2
- package/dist/services/a2a/helpers/content.js +4 -0
- package/dist/services/a2a/helpers/history.d.ts +6 -2
- package/dist/services/a2a/helpers/history.js +4 -0
- package/dist/services/a2a/helpers/index.d.ts +2 -2
- package/dist/services/a2a/helpers/index.js +2 -2
- package/dist/services/a2a/helpers/message-builder.d.ts +13 -8
- package/dist/services/a2a/helpers/message-builder.js +5 -0
- package/dist/services/a2a/helpers/part.d.ts +9 -9
- package/dist/services/a2a/helpers/references.d.ts +6 -0
- package/dist/services/a2a/helpers/references.js +22 -0
- package/dist/services/a2a/index.d.ts +9 -5
- package/dist/services/a2a/index.js +8 -5
- package/dist/services/a2a/managers.d.ts +23 -0
- package/dist/services/a2a/managers.js +95 -0
- package/dist/services/a2a/messenger.d.ts +35 -0
- package/dist/services/{core/managers/command.js → a2a/messenger.js} +27 -31
- package/dist/services/a2a/service.d.ts +41 -372
- package/dist/services/a2a/service.js +238 -83
- package/dist/services/a2a/state-machine.d.ts +18 -0
- package/dist/services/a2a/state-machine.js +76 -0
- package/dist/services/a2a/streams.d.ts +22 -0
- package/dist/services/a2a/streams.js +98 -0
- package/dist/services/core/index.d.ts +1 -2
- package/dist/services/core/index.js +1 -2
- package/dist/services/core/manager.d.ts +15 -0
- package/dist/services/core/manager.js +42 -0
- package/dist/services/mcp/service.d.ts +11 -15
- package/dist/services/mcp/service.js +16 -15
- package/dist/transport/index.d.ts +0 -1
- package/dist/transport/index.js +1 -1
- package/dist/transport/rpc/parser.d.ts +2 -2
- package/dist/transport/rpc/parser.js +6 -6
- package/dist/transport/rpc/rpc-client.d.ts +5 -5
- package/dist/transport/rpc/rpc-client.js +6 -6
- package/dist/transport/streaming/event-stream.d.ts +3 -3
- package/dist/transport/streaming/event-stream.js +11 -10
- package/dist/transport/trpc/a2a/factory/router.d.ts +479 -871
- package/dist/transport/trpc/a2a/factory/router.js +2 -2
- package/dist/transport/trpc/a2a/routes/info.d.ts +108 -8
- package/dist/transport/trpc/a2a/routes/info.js +6 -2
- package/dist/transport/trpc/a2a/routes/message/route.d.ts +113 -162
- package/dist/transport/trpc/a2a/routes/message/route.js +7 -13
- package/dist/transport/trpc/a2a/routes/tasks/route.d.ts +114 -212
- package/dist/transport/trpc/a2a/routes/tasks/route.js +16 -19
- package/dist/transport/trpc/a2a/trpc.d.ts +9 -253
- package/dist/types/a2a/a2a.d.ts +378 -0
- package/dist/types/a2a/a2a.js +14 -0
- package/dist/types/a2a/builder.d.ts +43 -0
- package/dist/types/a2a/index.d.ts +3 -0
- package/dist/types/a2a/index.js +2 -0
- package/dist/{browser/types/interfaces → types}/client.d.ts +25 -27
- package/dist/types/core/core.d.ts +31 -0
- package/dist/types/core/index.d.ts +1 -0
- package/dist/types/core/index.js +1 -0
- package/dist/types/index.d.ts +6 -3
- package/dist/types/index.js +6 -3
- package/dist/types/mcp/index.d.ts +1 -0
- package/dist/types/mcp/index.js +1 -0
- package/dist/types/{interfaces/services/mcp/service.d.ts → mcp/mcp.d.ts} +4 -3
- package/dist/{browser/types/interfaces/services/a2a/engine.js → types/mcp/mcp.js} +1 -1
- package/dist/types/storage.d.ts +21 -0
- package/dist/utils/common/constants.d.ts +7 -7
- package/dist/utils/common/constants.js +9 -9
- package/dist/utils/common/errors.d.ts +18 -18
- package/dist/utils/common/errors.js +14 -14
- package/dist/utils/common/parse.d.ts +7 -0
- package/dist/utils/common/parse.js +14 -0
- package/dist/utils/common/schema-validation.d.ts +1 -1
- package/dist/utils/common/schema-validation.js +7 -7
- package/dist/utils/common/utils.d.ts +23 -0
- package/dist/utils/common/utils.js +32 -0
- package/dist/utils/common/zAsyncIterable-v3.d.ts +1 -1
- package/dist/utils/common/zAsyncIterable-v3.js +2 -1
- package/dist/utils/index.d.ts +2 -3
- package/dist/utils/index.js +2 -3
- package/dist/utils/storage/file.d.ts +8 -17
- package/dist/utils/storage/file.js +44 -73
- package/package.json +73 -13
- package/dist/browser/types/ext.d.ts +0 -13
- package/dist/browser/types/ext.js +0 -10
- package/dist/browser/types/interfaces/index.d.ts +0 -3
- package/dist/browser/types/interfaces/index.js +0 -3
- package/dist/browser/types/interfaces/services/a2a/builder.d.ts +0 -37
- package/dist/browser/types/interfaces/services/a2a/context.d.ts +0 -162
- package/dist/browser/types/interfaces/services/a2a/engine.d.ts +0 -7
- package/dist/browser/types/interfaces/services/a2a/index.d.ts +0 -5
- package/dist/browser/types/interfaces/services/a2a/index.js +0 -5
- package/dist/browser/types/interfaces/services/a2a/legacy.d.ts +0 -93
- package/dist/browser/types/interfaces/services/a2a/legacy.js +0 -5
- package/dist/browser/types/interfaces/services/a2a/service.d.ts +0 -413
- package/dist/browser/types/interfaces/services/a2a/service.js +0 -5
- package/dist/browser/types/interfaces/services/core/context/command.d.ts +0 -25
- package/dist/browser/types/interfaces/services/core/context/command.js +0 -5
- package/dist/browser/types/interfaces/services/core/context/context.d.ts +0 -207
- package/dist/browser/types/interfaces/services/core/context/context.js +0 -5
- package/dist/browser/types/interfaces/services/core/context/index.d.ts +0 -3
- package/dist/browser/types/interfaces/services/core/context/index.js +0 -3
- package/dist/browser/types/interfaces/services/core/context/types.d.ts +0 -11
- package/dist/browser/types/interfaces/services/core/context/types.js +0 -5
- package/dist/browser/types/interfaces/services/core/execution/engine.d.ts +0 -106
- package/dist/browser/types/interfaces/services/core/execution/engine.js +0 -5
- package/dist/browser/types/interfaces/services/core/execution/environment.d.ts +0 -11
- package/dist/browser/types/interfaces/services/core/execution/environment.js +0 -5
- package/dist/browser/types/interfaces/services/core/execution/execute.d.ts +0 -7
- package/dist/browser/types/interfaces/services/core/execution/execute.js +0 -5
- package/dist/browser/types/interfaces/services/core/execution/index.d.ts +0 -3
- package/dist/browser/types/interfaces/services/core/execution/index.js +0 -3
- package/dist/browser/types/interfaces/services/core/index.d.ts +0 -4
- package/dist/browser/types/interfaces/services/core/index.js +0 -4
- package/dist/browser/types/interfaces/services/core/managers/cancellation.d.ts +0 -9
- package/dist/browser/types/interfaces/services/core/managers/cancellation.js +0 -5
- package/dist/browser/types/interfaces/services/core/managers/connection.d.ts +0 -9
- package/dist/browser/types/interfaces/services/core/managers/connection.js +0 -5
- package/dist/browser/types/interfaces/services/core/managers/context.d.ts +0 -17
- package/dist/browser/types/interfaces/services/core/managers/context.js +0 -5
- package/dist/browser/types/interfaces/services/core/managers/event.d.ts +0 -328
- package/dist/browser/types/interfaces/services/core/managers/event.js +0 -5
- package/dist/browser/types/interfaces/services/core/managers/index.d.ts +0 -6
- package/dist/browser/types/interfaces/services/core/managers/index.js +0 -6
- package/dist/browser/types/interfaces/services/core/managers/stream.d.ts +0 -217
- package/dist/browser/types/interfaces/services/core/managers/stream.js +0 -5
- package/dist/browser/types/interfaces/services/core/managers/task.d.ts +0 -9
- package/dist/browser/types/interfaces/services/core/service.d.ts +0 -115
- package/dist/browser/types/interfaces/services/core/service.js +0 -5
- package/dist/browser/types/interfaces/services/index.d.ts +0 -4
- package/dist/browser/types/interfaces/services/index.js +0 -4
- package/dist/browser/types/interfaces/services/mcp/index.d.ts +0 -1
- package/dist/browser/types/interfaces/services/mcp/index.js +0 -1
- package/dist/browser/types/interfaces/services/mcp/service.js +0 -5
- package/dist/browser/types/interfaces/storage.d.ts +0 -8
- package/dist/browser/types/schemas/a2a/agent.d.ts +0 -2583
- package/dist/browser/types/schemas/a2a/agent.js +0 -323
- package/dist/browser/types/schemas/a2a/auth.d.ts +0 -908
- package/dist/browser/types/schemas/a2a/auth.js +0 -283
- package/dist/browser/types/schemas/a2a/error.d.ts +0 -396
- package/dist/browser/types/schemas/a2a/error.js +0 -163
- package/dist/browser/types/schemas/a2a/index.d.ts +0 -11
- package/dist/browser/types/schemas/a2a/index.js +0 -11
- package/dist/browser/types/schemas/a2a/kind.d.ts +0 -11
- package/dist/browser/types/schemas/a2a/kind.js +0 -20
- package/dist/browser/types/schemas/a2a/message.d.ts +0 -10343
- package/dist/browser/types/schemas/a2a/message.js +0 -130
- package/dist/browser/types/schemas/a2a/notification.d.ts +0 -1517
- package/dist/browser/types/schemas/a2a/notification.js +0 -203
- package/dist/browser/types/schemas/a2a/parameters.d.ts +0 -956
- package/dist/browser/types/schemas/a2a/parameters.js +0 -241
- package/dist/browser/types/schemas/a2a/protocol.d.ts +0 -14363
- package/dist/browser/types/schemas/a2a/protocol.js +0 -59
- package/dist/browser/types/schemas/a2a/rpc.d.ts +0 -182
- package/dist/browser/types/schemas/a2a/rpc.js +0 -126
- package/dist/browser/types/schemas/a2a/task.d.ts +0 -5886
- package/dist/browser/types/schemas/a2a/task.js +0 -134
- package/dist/browser/types/schemas/a2a/transport.d.ts +0 -31
- package/dist/browser/types/schemas/a2a/transport.js +0 -28
- package/dist/browser/types/schemas/index.d.ts +0 -1
- package/dist/browser/types/schemas/index.js +0 -1
- package/dist/browser/utils/logging/index.d.ts +0 -2
- package/dist/browser/utils/logging/index.js +0 -2
- package/dist/browser/utils/logging/log.d.ts +0 -33
- package/dist/browser/utils/logging/log.js +0 -75
- package/dist/browser/utils/logging/logger.d.ts +0 -18
- package/dist/browser/utils/logging/logger.js +0 -18
- package/dist/services/a2a/factory/event.d.ts +0 -58
- package/dist/services/a2a/factory/event.js +0 -177
- package/dist/services/a2a/factory/method.d.ts +0 -6
- package/dist/services/a2a/managers/cancellation.d.ts +0 -11
- package/dist/services/a2a/managers/cancellation.js +0 -16
- package/dist/services/a2a/managers/connection.d.ts +0 -11
- package/dist/services/a2a/managers/connection.js +0 -16
- package/dist/services/a2a/managers/context.d.ts +0 -11
- package/dist/services/a2a/managers/context.js +0 -16
- package/dist/services/a2a/managers/index.d.ts +0 -5
- package/dist/services/a2a/managers/index.js +0 -5
- package/dist/services/a2a/managers/task.d.ts +0 -11
- package/dist/services/a2a/managers/task.js +0 -16
- package/dist/services/a2a/methods/cancel-task.d.ts +0 -7
- package/dist/services/a2a/methods/cancel-task.js +0 -43
- package/dist/services/a2a/methods/get-task.d.ts +0 -112
- package/dist/services/a2a/methods/get-task.js +0 -16
- package/dist/services/a2a/methods/resubscribe-task.d.ts +0 -7
- package/dist/services/a2a/methods/resubscribe-task.js +0 -80
- package/dist/services/a2a/methods/send-message.d.ts +0 -7
- package/dist/services/a2a/methods/send-message.js +0 -36
- package/dist/services/a2a/methods/stream-message.d.ts +0 -8
- package/dist/services/a2a/methods/stream-message.js +0 -21
- package/dist/services/a2a/state/index.d.ts +0 -3
- package/dist/services/a2a/state/index.js +0 -3
- package/dist/services/a2a/state/load.d.ts +0 -14
- package/dist/services/a2a/state/load.js +0 -71
- package/dist/services/a2a/state/process.d.ts +0 -7
- package/dist/services/a2a/state/process.js +0 -13
- package/dist/services/a2a/state/update/index.d.ts +0 -2
- package/dist/services/a2a/state/update/index.js +0 -2
- package/dist/services/a2a/state/update/update.d.ts +0 -23
- package/dist/services/a2a/state/update/update.js +0 -123
- package/dist/services/core/execution/execute.d.ts +0 -6
- package/dist/services/core/execution/execute.js +0 -25
- package/dist/services/core/execution/index.d.ts +0 -1
- package/dist/services/core/execution/index.js +0 -1
- package/dist/services/core/managers/command.d.ts +0 -39
- package/dist/services/core/managers/event.d.ts +0 -18
- package/dist/services/core/managers/event.js +0 -56
- package/dist/services/core/managers/index.d.ts +0 -3
- package/dist/services/core/managers/index.js +0 -3
- package/dist/services/core/managers/stream.d.ts +0 -20
- package/dist/services/core/managers/stream.js +0 -77
- package/dist/types/ext.d.ts +0 -13
- package/dist/types/ext.js +0 -10
- package/dist/types/interfaces/index.d.ts +0 -3
- package/dist/types/interfaces/index.js +0 -3
- package/dist/types/interfaces/services/a2a/builder.d.ts +0 -37
- package/dist/types/interfaces/services/a2a/context.d.ts +0 -162
- package/dist/types/interfaces/services/a2a/context.js +0 -5
- package/dist/types/interfaces/services/a2a/engine.d.ts +0 -7
- package/dist/types/interfaces/services/a2a/engine.js +0 -5
- package/dist/types/interfaces/services/a2a/index.d.ts +0 -5
- package/dist/types/interfaces/services/a2a/index.js +0 -5
- package/dist/types/interfaces/services/a2a/legacy.d.ts +0 -93
- package/dist/types/interfaces/services/a2a/legacy.js +0 -5
- package/dist/types/interfaces/services/a2a/service.d.ts +0 -413
- package/dist/types/interfaces/services/a2a/service.js +0 -5
- package/dist/types/interfaces/services/core/context/command.d.ts +0 -25
- package/dist/types/interfaces/services/core/context/command.js +0 -5
- package/dist/types/interfaces/services/core/context/context.d.ts +0 -207
- package/dist/types/interfaces/services/core/context/context.js +0 -5
- package/dist/types/interfaces/services/core/context/index.d.ts +0 -3
- package/dist/types/interfaces/services/core/context/index.js +0 -3
- package/dist/types/interfaces/services/core/context/types.d.ts +0 -11
- package/dist/types/interfaces/services/core/context/types.js +0 -5
- package/dist/types/interfaces/services/core/execution/engine.d.ts +0 -106
- package/dist/types/interfaces/services/core/execution/engine.js +0 -5
- package/dist/types/interfaces/services/core/execution/environment.d.ts +0 -11
- package/dist/types/interfaces/services/core/execution/environment.js +0 -5
- package/dist/types/interfaces/services/core/execution/execute.d.ts +0 -7
- package/dist/types/interfaces/services/core/execution/execute.js +0 -5
- package/dist/types/interfaces/services/core/execution/index.d.ts +0 -3
- package/dist/types/interfaces/services/core/execution/index.js +0 -3
- package/dist/types/interfaces/services/core/index.d.ts +0 -4
- package/dist/types/interfaces/services/core/index.js +0 -4
- package/dist/types/interfaces/services/core/managers/cancellation.d.ts +0 -9
- package/dist/types/interfaces/services/core/managers/cancellation.js +0 -5
- package/dist/types/interfaces/services/core/managers/connection.d.ts +0 -9
- package/dist/types/interfaces/services/core/managers/connection.js +0 -5
- package/dist/types/interfaces/services/core/managers/context.d.ts +0 -17
- package/dist/types/interfaces/services/core/managers/context.js +0 -5
- package/dist/types/interfaces/services/core/managers/event.d.ts +0 -328
- package/dist/types/interfaces/services/core/managers/event.js +0 -5
- package/dist/types/interfaces/services/core/managers/index.d.ts +0 -6
- package/dist/types/interfaces/services/core/managers/index.js +0 -6
- package/dist/types/interfaces/services/core/managers/stream.d.ts +0 -217
- package/dist/types/interfaces/services/core/managers/stream.js +0 -5
- package/dist/types/interfaces/services/core/managers/task.d.ts +0 -9
- package/dist/types/interfaces/services/core/service.d.ts +0 -115
- package/dist/types/interfaces/services/core/service.js +0 -5
- package/dist/types/interfaces/services/index.d.ts +0 -4
- package/dist/types/interfaces/services/index.js +0 -4
- package/dist/types/interfaces/services/mcp/index.d.ts +0 -1
- package/dist/types/interfaces/services/mcp/index.js +0 -1
- package/dist/types/interfaces/services/mcp/service.js +0 -5
- package/dist/types/interfaces/storage.d.ts +0 -8
- package/dist/types/schemas/a2a/agent.d.ts +0 -2583
- package/dist/types/schemas/a2a/agent.js +0 -323
- package/dist/types/schemas/a2a/auth.d.ts +0 -908
- package/dist/types/schemas/a2a/auth.js +0 -283
- package/dist/types/schemas/a2a/error.d.ts +0 -396
- package/dist/types/schemas/a2a/error.js +0 -163
- package/dist/types/schemas/a2a/index.d.ts +0 -11
- package/dist/types/schemas/a2a/index.js +0 -11
- package/dist/types/schemas/a2a/kind.d.ts +0 -11
- package/dist/types/schemas/a2a/kind.js +0 -20
- package/dist/types/schemas/a2a/message.d.ts +0 -10343
- package/dist/types/schemas/a2a/message.js +0 -130
- package/dist/types/schemas/a2a/notification.d.ts +0 -1517
- package/dist/types/schemas/a2a/notification.js +0 -203
- package/dist/types/schemas/a2a/parameters.d.ts +0 -956
- package/dist/types/schemas/a2a/parameters.js +0 -241
- package/dist/types/schemas/a2a/protocol.d.ts +0 -14363
- package/dist/types/schemas/a2a/protocol.js +0 -59
- package/dist/types/schemas/a2a/rpc.d.ts +0 -182
- package/dist/types/schemas/a2a/rpc.js +0 -126
- package/dist/types/schemas/a2a/task.d.ts +0 -5886
- package/dist/types/schemas/a2a/task.js +0 -134
- package/dist/types/schemas/a2a/transport.d.ts +0 -31
- package/dist/types/schemas/a2a/transport.js +0 -28
- package/dist/types/schemas/index.d.ts +0 -1
- package/dist/types/schemas/index.js +0 -1
- package/dist/utils/logging/index.d.ts +0 -2
- package/dist/utils/logging/index.js +0 -2
- package/dist/utils/logging/log.d.ts +0 -33
- package/dist/utils/logging/log.js +0 -75
- package/dist/utils/logging/logger.d.ts +0 -18
- package/dist/utils/logging/logger.js +0 -18
- package/dist/utils/storage/memory.d.ts +0 -25
- package/dist/utils/storage/memory.js +0 -47
- /package/dist/browser/types/{interfaces/services/a2a → a2a}/builder.js +0 -0
- /package/dist/browser/types/{interfaces/client.js → client.js} +0 -0
- /package/dist/browser/types/{interfaces/services/core/managers/task.js → core/core.js} +0 -0
- /package/dist/browser/types/{interfaces/services/protocol.d.ts → protocol.d.ts} +0 -0
- /package/dist/browser/types/{interfaces/services/protocol.js → protocol.js} +0 -0
- /package/dist/browser/types/{interfaces/storage.js → storage.js} +0 -0
- /package/dist/services/a2a/{state/update → handlers}/artifact.js +0 -0
- /package/dist/services/a2a/{methods → handlers}/index.d.ts +0 -0
- /package/dist/services/a2a/{methods → handlers}/index.js +0 -0
- /package/dist/types/{interfaces/services/a2a → a2a}/builder.js +0 -0
- /package/dist/types/{interfaces/client.js → client.js} +0 -0
- /package/dist/types/{interfaces/services/core/managers/task.js → core/core.js} +0 -0
- /package/dist/types/{interfaces/services/protocol.d.ts → protocol.d.ts} +0 -0
- /package/dist/types/{interfaces/services/protocol.js → protocol.js} +0 -0
- /package/dist/types/{interfaces/storage.js → storage.js} +0 -0
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
* managing service lifecycle.
|
|
11
11
|
*
|
|
12
12
|
* @module MCPService
|
|
13
|
-
* @version 0.
|
|
13
|
+
* @version 0.6.0-preview
|
|
14
14
|
* @since 0.5.7
|
|
15
15
|
* @author The Artinet Project
|
|
16
16
|
*/
|
|
17
|
-
import {
|
|
17
|
+
import { core } from "../core/index.js";
|
|
18
18
|
/**
|
|
19
19
|
* Main interface for MCP service implementations.
|
|
20
20
|
*
|
|
@@ -40,10 +40,11 @@ import { ServiceInterface } from "../core/index.js";
|
|
|
40
40
|
* @public
|
|
41
41
|
* @since 0.5.7
|
|
42
42
|
*/
|
|
43
|
-
export interface
|
|
43
|
+
export interface Service extends Omit<core.Service, "execute"> {
|
|
44
44
|
/**
|
|
45
45
|
* Registers tools for the MCP service.
|
|
46
46
|
* @param uri - The URI of the agent card resource.
|
|
47
47
|
*/
|
|
48
48
|
registerTools?: (uri: string) => void;
|
|
49
49
|
}
|
|
50
|
+
export * from "@artinet/types/mcp";
|
|
@@ -0,0 +1,21 @@
|
|
|
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.
|
|
16
|
+
* @template T - The type of data to store
|
|
17
|
+
*/
|
|
18
|
+
export interface IStore<T> {
|
|
19
|
+
set(id: string, data: T): Promise<void>;
|
|
20
|
+
get(id: string): Promise<T | undefined>;
|
|
21
|
+
}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Copyright 2025 The Artinet Project
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
export declare const STATUS_UPDATE: (taskId: string, contextId: string, status: TaskState, message?: Message, timestamp?: string, final?: boolean) => TaskStatusUpdateEvent;
|
|
7
|
-
export declare const WORKING_UPDATE: (taskId: string, contextId: string, message?: Message, timestamp?: string) => TaskStatusUpdateEvent;
|
|
8
|
-
export declare const CANCEL_UPDATE: (taskId: string, contextId: string, message?: Message, timestamp?: string) => TaskStatusUpdateEvent;
|
|
9
|
-
export declare const SUBMITTED_UPDATE: (taskId: string, contextId: string, message?: Message, timestamp?: string) => TaskStatusUpdateEvent;
|
|
10
|
-
export declare const FAILED_UPDATE_EVENT: (taskId: string, contextId: string, message?: Message, timestamp?: string) => TaskStatusUpdateEvent;
|
|
11
|
-
export declare const FINAL_STATES: TaskState[];
|
|
5
|
+
import { A2A } from "../../types/index.js";
|
|
6
|
+
export declare const STATUS_UPDATE: (taskId: string, contextId: string, status: A2A.TaskState, message?: A2A.Message, timestamp?: string, final?: boolean) => A2A.TaskStatusUpdateEvent;
|
|
7
|
+
export declare const WORKING_UPDATE: (taskId: string, contextId: string, message?: A2A.Message, timestamp?: string) => A2A.TaskStatusUpdateEvent;
|
|
8
|
+
export declare const CANCEL_UPDATE: (taskId: string, contextId: string, message?: A2A.Message, timestamp?: string) => A2A.TaskStatusUpdateEvent;
|
|
9
|
+
export declare const SUBMITTED_UPDATE: (taskId: string, contextId: string, message?: A2A.Message, timestamp?: string) => A2A.TaskStatusUpdateEvent;
|
|
10
|
+
export declare const FAILED_UPDATE_EVENT: (taskId: string, contextId: string, message?: A2A.Message, timestamp?: string) => A2A.TaskStatusUpdateEvent;
|
|
11
|
+
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 {
|
|
5
|
+
import { A2A } from "../../types/index.js";
|
|
6
6
|
import { getCurrentTimestamp } from "./utils.js";
|
|
7
7
|
//todo: protocol specific so move to a2a folder
|
|
8
8
|
export const STATUS_UPDATE = (taskId, contextId, status, message, timestamp = getCurrentTimestamp(), final = false) => {
|
|
@@ -19,20 +19,20 @@ export const STATUS_UPDATE = (taskId, contextId, status, message, timestamp = ge
|
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
21
|
export const WORKING_UPDATE = (taskId, contextId, message, timestamp) => {
|
|
22
|
-
return STATUS_UPDATE(taskId, contextId, TaskState.working, message, timestamp);
|
|
22
|
+
return STATUS_UPDATE(taskId, contextId, A2A.TaskState.working, message, timestamp);
|
|
23
23
|
};
|
|
24
24
|
export const CANCEL_UPDATE = (taskId, contextId, message, timestamp) => {
|
|
25
|
-
return STATUS_UPDATE(taskId, contextId, TaskState.canceled, message, timestamp, true);
|
|
25
|
+
return STATUS_UPDATE(taskId, contextId, A2A.TaskState.canceled, message, timestamp, true);
|
|
26
26
|
};
|
|
27
27
|
export const SUBMITTED_UPDATE = (taskId, contextId, message, timestamp) => {
|
|
28
|
-
return STATUS_UPDATE(taskId, contextId, TaskState.submitted, message, timestamp);
|
|
28
|
+
return STATUS_UPDATE(taskId, contextId, A2A.TaskState.submitted, message, timestamp);
|
|
29
29
|
};
|
|
30
30
|
export const FAILED_UPDATE_EVENT = (taskId, contextId, message, timestamp) => {
|
|
31
|
-
return STATUS_UPDATE(taskId, contextId, TaskState.failed, message, timestamp, true);
|
|
31
|
+
return STATUS_UPDATE(taskId, contextId, A2A.TaskState.failed, message, timestamp, true);
|
|
32
32
|
};
|
|
33
33
|
export const FINAL_STATES = [
|
|
34
|
-
TaskState.completed,
|
|
35
|
-
TaskState.failed,
|
|
36
|
-
TaskState.canceled,
|
|
37
|
-
TaskState.rejected,
|
|
34
|
+
A2A.TaskState.completed,
|
|
35
|
+
A2A.TaskState.failed,
|
|
36
|
+
A2A.TaskState.canceled,
|
|
37
|
+
A2A.TaskState.rejected,
|
|
38
38
|
];
|
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
* Copyright 2025 The Artinet Project
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
export declare class SystemError<T extends JSONRPCError> extends Error {
|
|
5
|
+
import { A2A, MCP } from "../../types/index.js";
|
|
6
|
+
export declare class SystemError<T extends MCP.JSONRPCError> extends Error {
|
|
7
7
|
message: string;
|
|
8
|
-
code: T["code"];
|
|
9
|
-
data: T["data"];
|
|
10
|
-
constructor(message: string, code: T["code"], data: T["data"]);
|
|
8
|
+
code: T["error"]["code"];
|
|
9
|
+
data: T["error"]["data"];
|
|
10
|
+
constructor(message: string, code: T["error"]["code"], data: T["error"]["data"]);
|
|
11
11
|
}
|
|
12
|
-
export declare const PARSE_ERROR: <T extends JSONParseError>(data: T["data"]) => SystemError<T>;
|
|
13
|
-
export declare const INVALID_REQUEST: <T extends InvalidRequestError>(data: T["data"]) => SystemError<T>;
|
|
14
|
-
export declare const METHOD_NOT_FOUND: <T extends MethodNotFoundError>(data: T["data"]) => SystemError<T>;
|
|
15
|
-
export declare const INVALID_PARAMS: <T extends InvalidParamsError>(data: T["data"]) => SystemError<T>;
|
|
16
|
-
export declare const INTERNAL_ERROR: <T extends InternalError>(data: T["data"]) => SystemError<T>;
|
|
17
|
-
export declare const TASK_NOT_FOUND: <T extends TaskNotFoundError>(data: T["data"]) => SystemError<T>;
|
|
18
|
-
export declare const TASK_NOT_CANCELABLE: <T extends TaskNotCancelableError>(data: T["data"]) => SystemError<T>;
|
|
19
|
-
export declare const PUSH_NOTIFICATION_NOT_SUPPORTED: <T extends A2AError>(data: T["data"]) => SystemError<T>;
|
|
20
|
-
export declare const AUTHENTICATED_EXTENDED_CARD_NOT_CONFIGURED: <T extends AuthenticatedExtendedCardNotConfiguredError>(data: T["data"]) => SystemError<T>;
|
|
21
|
-
export declare const UNSUPPORTED_OPERATION: <T extends A2AError>(data: T["data"]) => SystemError<T>;
|
|
22
|
-
export declare const CONTENT_TYPE_NOT_SUPPORTED: <T extends ContentTypeNotSupportedError>(data: T["data"]) => SystemError<T>;
|
|
23
|
-
export declare const INVALID_AGENT_RESPONSE: <T extends InvalidAgentResponseError>(data: T["data"]) => SystemError<T>;
|
|
24
|
-
export declare const FAILED_UPDATE: (taskId: string, contextId: string, messageId: string | undefined, errMessage: string) => TaskStatusUpdateEvent;
|
|
12
|
+
export declare const PARSE_ERROR: <T extends A2A.JSONParseError>(data: T["error"]["data"]) => SystemError<T>;
|
|
13
|
+
export declare const INVALID_REQUEST: <T extends A2A.InvalidRequestError>(data: T["error"]["data"]) => SystemError<T>;
|
|
14
|
+
export declare const METHOD_NOT_FOUND: <T extends A2A.MethodNotFoundError>(data: T["error"]["data"]) => SystemError<T>;
|
|
15
|
+
export declare const INVALID_PARAMS: <T extends A2A.InvalidParamsError>(data: T["error"]["data"]) => SystemError<T>;
|
|
16
|
+
export declare const INTERNAL_ERROR: <T extends A2A.InternalError>(data: T["error"]["data"]) => SystemError<T>;
|
|
17
|
+
export declare const TASK_NOT_FOUND: <T extends A2A.TaskNotFoundError>(data: T["error"]["data"]) => SystemError<T>;
|
|
18
|
+
export declare const TASK_NOT_CANCELABLE: <T extends A2A.TaskNotCancelableError>(data: T["error"]["data"]) => SystemError<T>;
|
|
19
|
+
export declare const PUSH_NOTIFICATION_NOT_SUPPORTED: <T extends A2A.A2AError>(data: T["error"]["data"]) => SystemError<T>;
|
|
20
|
+
export declare const AUTHENTICATED_EXTENDED_CARD_NOT_CONFIGURED: <T extends A2A.AuthenticatedExtendedCardNotConfiguredError>(data: T["error"]["data"]) => SystemError<T>;
|
|
21
|
+
export declare const UNSUPPORTED_OPERATION: <T extends A2A.A2AError>(data: T["error"]["data"]) => SystemError<T>;
|
|
22
|
+
export declare const CONTENT_TYPE_NOT_SUPPORTED: <T extends A2A.ContentTypeNotSupportedError>(data: T["error"]["data"]) => SystemError<T>;
|
|
23
|
+
export declare const INVALID_AGENT_RESPONSE: <T extends A2A.InvalidAgentResponseError>(data: T["error"]["data"]) => SystemError<T>;
|
|
24
|
+
export declare const FAILED_UPDATE: (taskId: string, contextId: string, messageId: string | undefined, errMessage: string) => A2A.TaskStatusUpdateEvent;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright 2025 The Artinet Project
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { A2A } from "../../types/index.js";
|
|
6
6
|
export class SystemError extends Error {
|
|
7
7
|
message;
|
|
8
8
|
code;
|
|
@@ -16,25 +16,25 @@ export class SystemError extends Error {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
// Factory methods for common errors
|
|
19
|
-
export const PARSE_ERROR = (data) => new SystemError("Invalid JSON payload", ErrorCodeParseError, data);
|
|
20
|
-
export const INVALID_REQUEST = (data) => new SystemError("Request payload validation error", ErrorCodeInvalidRequest, data);
|
|
21
|
-
export const METHOD_NOT_FOUND = (data) => new SystemError("Method not found", ErrorCodeMethodNotFound, data);
|
|
22
|
-
export const INVALID_PARAMS = (data) => new SystemError("Invalid parameters", ErrorCodeInvalidParams, data);
|
|
23
|
-
export const INTERNAL_ERROR = (data) => new SystemError("Internal error", ErrorCodeInternalError, data);
|
|
24
|
-
export const TASK_NOT_FOUND = (data) => new SystemError("Task not found", ErrorCodeTaskNotFound, data);
|
|
25
|
-
export const TASK_NOT_CANCELABLE = (data) => new SystemError("Task cannot be canceled", ErrorCodeTaskNotCancelable, data);
|
|
26
|
-
export const PUSH_NOTIFICATION_NOT_SUPPORTED = (data) => new SystemError("Push Notifications is not supported", ErrorCodePushNotificationNotSupported, data);
|
|
27
|
-
export const AUTHENTICATED_EXTENDED_CARD_NOT_CONFIGURED = (data) => new SystemError("Authenticated Extended Card is not configured", ErrorCodeAuthenticatedExtendedCardNotConfigured, data);
|
|
28
|
-
export const UNSUPPORTED_OPERATION = (data) => new SystemError("This operation is not supported", ErrorCodeUnsupportedOperation, data);
|
|
29
|
-
export const CONTENT_TYPE_NOT_SUPPORTED = (data) => new SystemError("Content type not supported", ErrorCodeContentTypeNotSupported, data);
|
|
30
|
-
export const INVALID_AGENT_RESPONSE = (data) => new SystemError("Invalid agent response", ErrorCodeInvalidAgentResponse, data);
|
|
19
|
+
export const PARSE_ERROR = (data) => new SystemError("Invalid JSON payload", A2A.ErrorCodeParseError, data);
|
|
20
|
+
export const INVALID_REQUEST = (data) => new SystemError("Request payload validation error", A2A.ErrorCodeInvalidRequest, data);
|
|
21
|
+
export const METHOD_NOT_FOUND = (data) => new SystemError("Method not found", A2A.ErrorCodeMethodNotFound, data);
|
|
22
|
+
export const INVALID_PARAMS = (data) => new SystemError("Invalid parameters", A2A.ErrorCodeInvalidParams, data);
|
|
23
|
+
export const INTERNAL_ERROR = (data) => new SystemError("Internal error", A2A.ErrorCodeInternalError, data);
|
|
24
|
+
export const TASK_NOT_FOUND = (data) => new SystemError("Task not found", A2A.ErrorCodeTaskNotFound, data);
|
|
25
|
+
export const TASK_NOT_CANCELABLE = (data) => new SystemError("Task cannot be canceled", A2A.ErrorCodeTaskNotCancelable, data);
|
|
26
|
+
export const PUSH_NOTIFICATION_NOT_SUPPORTED = (data) => new SystemError("Push Notifications is not supported", A2A.ErrorCodePushNotificationNotSupported, data);
|
|
27
|
+
export const AUTHENTICATED_EXTENDED_CARD_NOT_CONFIGURED = (data) => new SystemError("Authenticated Extended Card is not configured", A2A.ErrorCodeAuthenticatedExtendedCardNotConfigured, data);
|
|
28
|
+
export const UNSUPPORTED_OPERATION = (data) => new SystemError("This operation is not supported", A2A.ErrorCodeUnsupportedOperation, data);
|
|
29
|
+
export const CONTENT_TYPE_NOT_SUPPORTED = (data) => new SystemError("Content type not supported", A2A.ErrorCodeContentTypeNotSupported, data);
|
|
30
|
+
export const INVALID_AGENT_RESPONSE = (data) => new SystemError("Invalid agent response", A2A.ErrorCodeInvalidAgentResponse, data);
|
|
31
31
|
export const FAILED_UPDATE = (taskId, contextId, messageId = "failed-update", errMessage) => ({
|
|
32
32
|
taskId,
|
|
33
33
|
contextId,
|
|
34
34
|
kind: "status-update",
|
|
35
35
|
final: true,
|
|
36
36
|
status: {
|
|
37
|
-
state: TaskState.failed,
|
|
37
|
+
state: A2A.TaskState.failed,
|
|
38
38
|
message: {
|
|
39
39
|
messageId,
|
|
40
40
|
role: "agent",
|
|
@@ -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.infer<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
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { z } from "zod/
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
2
|
export declare function validateSchema<T extends z.ZodSchema>(schema: T, data: unknown): Promise<z.infer<T>>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 The Artinet Project
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
1
5
|
import { INVALID_PARAMS } from "../index.js";
|
|
2
|
-
import {
|
|
6
|
+
import { logger } from "../../config/index.js";
|
|
3
7
|
export async function validateSchema(schema, data) {
|
|
4
8
|
return await schema.parseAsync(data).catch((error) => {
|
|
5
|
-
|
|
6
|
-
throw INVALID_PARAMS(
|
|
7
|
-
data: {
|
|
8
|
-
message: error.message,
|
|
9
|
-
},
|
|
10
|
-
});
|
|
9
|
+
logger.error("Schema validation failed", error);
|
|
10
|
+
throw INVALID_PARAMS(error);
|
|
11
11
|
});
|
|
12
12
|
}
|
|
@@ -7,3 +7,26 @@
|
|
|
7
7
|
* @returns The current timestamp as a string.
|
|
8
8
|
*/
|
|
9
9
|
export declare function getCurrentTimestamp(): string;
|
|
10
|
+
/**
|
|
11
|
+
* Sleeps for a given number of milliseconds.
|
|
12
|
+
* @param ms - The number of milliseconds to sleep.
|
|
13
|
+
* @returns A promise that resolves when the sleep is complete.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* await sleep(1000);
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Formats a JSON object into a string with indentation.
|
|
23
|
+
* @param json - The JSON object to format.
|
|
24
|
+
* @returns A string representation of the JSON object.
|
|
25
|
+
*/
|
|
26
|
+
export declare function formatJson(json: object): string;
|
|
27
|
+
/**
|
|
28
|
+
* Formats an error into a standard error object for logging.
|
|
29
|
+
* @param error - The error to format.
|
|
30
|
+
* @returns A standard error object.
|
|
31
|
+
*/
|
|
32
|
+
export declare function formatError(error: unknown): Error;
|
|
@@ -9,3 +9,35 @@
|
|
|
9
9
|
export function getCurrentTimestamp() {
|
|
10
10
|
return new Date().toISOString();
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Sleeps for a given number of milliseconds.
|
|
14
|
+
* @param ms - The number of milliseconds to sleep.
|
|
15
|
+
* @returns A promise that resolves when the sleep is complete.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* await sleep(1000);
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export function sleep(ms) {
|
|
23
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Formats a JSON object into a string with indentation.
|
|
27
|
+
* @param json - The JSON object to format.
|
|
28
|
+
* @returns A string representation of the JSON object.
|
|
29
|
+
*/
|
|
30
|
+
export function formatJson(json) {
|
|
31
|
+
return JSON.stringify(json, null, 2);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Formats an error into a standard error object for logging.
|
|
35
|
+
* @param error - The error to format.
|
|
36
|
+
* @returns A standard error object.
|
|
37
|
+
*/
|
|
38
|
+
export function formatError(error) {
|
|
39
|
+
if (error instanceof Error) {
|
|
40
|
+
return error;
|
|
41
|
+
}
|
|
42
|
+
return new Error(String(error));
|
|
43
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TrackedEnvelope } from "@trpc/server";
|
|
2
|
-
import { z } from "zod";
|
|
2
|
+
import { z } from "zod/v3";
|
|
3
3
|
/**
|
|
4
4
|
* A Zod schema helper designed specifically for validating async iterables. This schema ensures that:
|
|
5
5
|
* 1. The value being validated is an async iterable.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isTrackedEnvelope, tracked } from "@trpc/server";
|
|
2
|
-
import { z } from "zod";
|
|
2
|
+
import { z } from "zod/v3";
|
|
3
|
+
//!Maintain for backwards compatibility
|
|
3
4
|
// v3 version of: https://trpc.io/docs/server/subscriptions#output-validation
|
|
4
5
|
function isAsyncIterable(value) {
|
|
5
6
|
return !!value && typeof value === "object" && Symbol.asyncIterator in value;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export * from "./common/constants.js";
|
|
|
6
6
|
export * from "./common/errors.js";
|
|
7
7
|
export * from "./common/schema-validation.js";
|
|
8
8
|
export * from "./common/utils.js";
|
|
9
|
-
export * from "./common/zAsyncIterable
|
|
10
|
-
export * from "./
|
|
9
|
+
export * from "./common/zAsyncIterable.js";
|
|
10
|
+
export * from "./common/parse.js";
|
|
11
11
|
export * from "./storage/file.js";
|
|
12
|
-
export * from "./storage/memory.js";
|
package/dist/utils/index.js
CHANGED
|
@@ -6,7 +6,6 @@ export * from "./common/constants.js";
|
|
|
6
6
|
export * from "./common/errors.js";
|
|
7
7
|
export * from "./common/schema-validation.js";
|
|
8
8
|
export * from "./common/utils.js";
|
|
9
|
-
export * from "./common/zAsyncIterable
|
|
10
|
-
export * from "./
|
|
9
|
+
export * from "./common/zAsyncIterable.js";
|
|
10
|
+
export * from "./common/parse.js";
|
|
11
11
|
export * from "./storage/file.js";
|
|
12
|
-
export * from "./storage/memory.js";
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
* Copyright 2025 The Artinet Project
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { A2A } from "../../types/index.js";
|
|
6
|
+
import { Tasks } from "../../services/a2a/managers.js";
|
|
6
7
|
/**
|
|
7
8
|
* File-based implementation of the TaskStore interface.
|
|
8
9
|
* Stores tasks and their history as JSON files on disk.
|
|
9
10
|
*/
|
|
10
|
-
export declare class
|
|
11
|
+
export declare class Files extends Tasks {
|
|
11
12
|
private baseDir;
|
|
12
13
|
/**
|
|
13
14
|
* Creates a new FileStore.
|
|
@@ -20,12 +21,6 @@ export declare class FileStore implements TaskManagerInterface<TaskAndHistory> {
|
|
|
20
21
|
* @returns The full file path for the task JSON file
|
|
21
22
|
*/
|
|
22
23
|
private getTaskFilePath;
|
|
23
|
-
/**
|
|
24
|
-
* Constructs the file path for a task's history.
|
|
25
|
-
* @param taskId The task ID
|
|
26
|
-
* @returns The full file path for the history JSON file
|
|
27
|
-
*/
|
|
28
|
-
private getHistoryFilePath;
|
|
29
24
|
/**
|
|
30
25
|
* Ensures the base directory exists.
|
|
31
26
|
* @returns A promise that resolves when the directory exists.
|
|
@@ -44,23 +39,19 @@ export declare class FileStore implements TaskManagerInterface<TaskAndHistory> {
|
|
|
44
39
|
* @returns A promise resolving to the parsed data, or null if the file doesn't exist
|
|
45
40
|
*/
|
|
46
41
|
private readJsonFile;
|
|
47
|
-
/**
|
|
48
|
-
* Type guard to validate the structure of history file content.
|
|
49
|
-
* @param content The content to check
|
|
50
|
-
* @returns True if the content is a valid history file content
|
|
51
|
-
*/
|
|
52
|
-
private isHistoryFileContent;
|
|
53
42
|
/**
|
|
54
43
|
* Loads a task and its history by task ID.
|
|
55
44
|
* @param taskId The ID of the task to load.
|
|
56
45
|
* @returns A promise resolving to the task and history, or null if not found.
|
|
57
46
|
*/
|
|
58
|
-
|
|
47
|
+
get(taskId: string): Promise<A2A.Task | undefined>;
|
|
59
48
|
/**
|
|
60
49
|
* Saves a task and its history.
|
|
61
50
|
* @param data The task and history to save.
|
|
62
51
|
* @returns A promise that resolves when the save is complete.
|
|
63
52
|
*/
|
|
64
|
-
|
|
65
|
-
|
|
53
|
+
set(taskId: string, task?: A2A.Task): Promise<void>;
|
|
54
|
+
delete(taskId: string): Promise<void>;
|
|
55
|
+
has(taskId: string): Promise<boolean>;
|
|
56
|
+
list(): Promise<A2A.Task[]>;
|
|
66
57
|
}
|
|
@@ -2,21 +2,26 @@
|
|
|
2
2
|
* Copyright 2025 The Artinet Project
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { A2A } from "../../types/index.js";
|
|
6
6
|
import fs from "fs/promises";
|
|
7
7
|
import path from "path";
|
|
8
|
+
import { logger } from "../../config/index.js";
|
|
9
|
+
import { Tasks } from "../../services/a2a/managers.js";
|
|
10
|
+
import { formatJson, safeParseSchema } from "../index.js";
|
|
8
11
|
/**
|
|
9
12
|
* File-based implementation of the TaskStore interface.
|
|
10
13
|
* Stores tasks and their history as JSON files on disk.
|
|
11
14
|
*/
|
|
12
|
-
export class
|
|
15
|
+
export class Files extends Tasks {
|
|
13
16
|
baseDir;
|
|
14
17
|
/**
|
|
15
18
|
* Creates a new FileStore.
|
|
16
19
|
* @param baseDir The base directory to store task files in.
|
|
17
20
|
*/
|
|
18
21
|
constructor(baseDir) {
|
|
22
|
+
super(new Map());
|
|
19
23
|
this.baseDir = baseDir;
|
|
24
|
+
logger.info(`FileStore[init]: baseDir`, { baseDir });
|
|
20
25
|
}
|
|
21
26
|
/**
|
|
22
27
|
* Constructs the file path for a task.
|
|
@@ -26,14 +31,6 @@ export class FileStore {
|
|
|
26
31
|
getTaskFilePath(taskId) {
|
|
27
32
|
return path.join(this.baseDir, `${taskId}.task.json`);
|
|
28
33
|
}
|
|
29
|
-
/**
|
|
30
|
-
* Constructs the file path for a task's history.
|
|
31
|
-
* @param taskId The task ID
|
|
32
|
-
* @returns The full file path for the history JSON file
|
|
33
|
-
*/
|
|
34
|
-
getHistoryFilePath(taskId) {
|
|
35
|
-
return path.join(this.baseDir, `${taskId}.history.json`);
|
|
36
|
-
}
|
|
37
34
|
/**
|
|
38
35
|
* Ensures the base directory exists.
|
|
39
36
|
* @returns A promise that resolves when the directory exists.
|
|
@@ -43,7 +40,7 @@ export class FileStore {
|
|
|
43
40
|
await fs.mkdir(this.baseDir, { recursive: true });
|
|
44
41
|
}
|
|
45
42
|
catch (error) {
|
|
46
|
-
|
|
43
|
+
logger.warn(`FileStore[ensureBaseDir]: ${this.baseDir}`, error);
|
|
47
44
|
throw error;
|
|
48
45
|
}
|
|
49
46
|
}
|
|
@@ -53,15 +50,15 @@ export class FileStore {
|
|
|
53
50
|
* @param data The data to write
|
|
54
51
|
* @returns A promise that resolves when the write is complete
|
|
55
52
|
*/
|
|
56
|
-
async writeJsonFile(filePath,
|
|
53
|
+
async writeJsonFile(filePath, task) {
|
|
57
54
|
try {
|
|
58
55
|
await this.ensureBaseDir();
|
|
59
|
-
await fs.writeFile(filePath,
|
|
56
|
+
await fs.writeFile(filePath, formatJson(task), {
|
|
60
57
|
encoding: "utf8",
|
|
61
58
|
});
|
|
62
59
|
}
|
|
63
60
|
catch (error) {
|
|
64
|
-
|
|
61
|
+
logger.warn(`FileStore[writeJsonFile]: ${filePath}`, error);
|
|
65
62
|
throw error;
|
|
66
63
|
}
|
|
67
64
|
}
|
|
@@ -73,88 +70,62 @@ export class FileStore {
|
|
|
73
70
|
async readJsonFile(filePath) {
|
|
74
71
|
try {
|
|
75
72
|
const content = await fs.readFile(filePath, { encoding: "utf8" });
|
|
76
|
-
return
|
|
73
|
+
return await safeParseSchema(content, A2A.TaskSchema);
|
|
77
74
|
}
|
|
78
75
|
catch (error) {
|
|
79
76
|
if (error.code === "ENOENT") {
|
|
80
|
-
|
|
77
|
+
logger.warn(`FileStore[readJsonFile]: ${filePath} not found`);
|
|
81
78
|
return null;
|
|
82
79
|
}
|
|
83
|
-
logError("FileStore", `Failed to read file: ${filePath}`, error);
|
|
84
80
|
throw error;
|
|
85
81
|
}
|
|
86
82
|
}
|
|
87
|
-
/**
|
|
88
|
-
* Type guard to validate the structure of history file content.
|
|
89
|
-
* @param content The content to check
|
|
90
|
-
* @returns True if the content is a valid history file content
|
|
91
|
-
*/
|
|
92
|
-
isHistoryFileContent(content) {
|
|
93
|
-
return (content !== undefined &&
|
|
94
|
-
typeof content === "object" &&
|
|
95
|
-
content !== null &&
|
|
96
|
-
"messageHistory" in content &&
|
|
97
|
-
Array.isArray(content.messageHistory));
|
|
98
|
-
}
|
|
99
83
|
/**
|
|
100
84
|
* Loads a task and its history by task ID.
|
|
101
85
|
* @param taskId The ID of the task to load.
|
|
102
86
|
* @returns A promise resolving to the task and history, or null if not found.
|
|
103
87
|
*/
|
|
104
|
-
async
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
// Read task file first - if it doesn't exist, the task doesn't exist.
|
|
109
|
-
const task = await this.readJsonFile(taskFilePath).catch(() => undefined);
|
|
110
|
-
if (!task) {
|
|
111
|
-
return undefined; // Task not found
|
|
112
|
-
}
|
|
113
|
-
// Task exists, now try to read history. It might not exist yet.
|
|
114
|
-
let history = [];
|
|
115
|
-
try {
|
|
116
|
-
const historyContent = await this.readJsonFile(historyFilePath).catch(() => undefined);
|
|
117
|
-
// Validate the structure
|
|
118
|
-
if (this.isHistoryFileContent(historyContent)) {
|
|
119
|
-
history = historyContent.messageHistory;
|
|
120
|
-
}
|
|
121
|
-
else if (historyContent !== null) {
|
|
122
|
-
// Log a warning if the history file exists but is malformed
|
|
123
|
-
logError("FileStore", `Malformed history file found for task ${taskId}`, new Error("Invalid history file format"), { path: historyFilePath });
|
|
124
|
-
// Proceed with empty history
|
|
125
|
-
}
|
|
126
|
-
// If historyContent is null (file not found), history remains []
|
|
127
|
-
}
|
|
128
|
-
catch (error) {
|
|
129
|
-
// Log error reading history but proceed with empty history
|
|
130
|
-
logError("FileStore", `Error reading history file for task ${taskId}`, error, { path: historyFilePath });
|
|
131
|
-
// Proceed with empty history
|
|
132
|
-
}
|
|
133
|
-
return { task, history };
|
|
88
|
+
async get(taskId) {
|
|
89
|
+
const task = (await super.get(taskId)) ??
|
|
90
|
+
(await this.readJsonFile(this.getTaskFilePath(taskId)).catch(() => undefined));
|
|
91
|
+
return task ?? undefined;
|
|
134
92
|
}
|
|
135
93
|
/**
|
|
136
94
|
* Saves a task and its history.
|
|
137
95
|
* @param data The task and history to save.
|
|
138
96
|
* @returns A promise that resolves when the save is complete.
|
|
139
97
|
*/
|
|
140
|
-
async
|
|
141
|
-
|
|
142
|
-
if (
|
|
98
|
+
async set(taskId, task) {
|
|
99
|
+
logger.debug(`FileStore[set]: ${taskId}`);
|
|
100
|
+
if (!task) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (task && taskId !== task.id) {
|
|
104
|
+
logger.warn("FileStore", `Task ID mismatch: ${taskId} !== ${task.id}`);
|
|
143
105
|
throw new Error("Task ID mismatch");
|
|
144
106
|
}
|
|
145
107
|
const taskFilePath = this.getTaskFilePath(taskId);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
await
|
|
153
|
-
|
|
154
|
-
|
|
108
|
+
await this.writeJsonFile(taskFilePath, task);
|
|
109
|
+
await super.set(taskId, task);
|
|
110
|
+
}
|
|
111
|
+
async delete(taskId) {
|
|
112
|
+
logger.debug(`FileStore[delete]: ${taskId}`);
|
|
113
|
+
const taskFilePath = this.getTaskFilePath(taskId);
|
|
114
|
+
await fs.unlink(taskFilePath);
|
|
115
|
+
await super.delete(taskId);
|
|
116
|
+
}
|
|
117
|
+
async has(taskId) {
|
|
118
|
+
if (await super.has(taskId)) {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
const taskFilePath = this.getTaskFilePath(taskId);
|
|
122
|
+
return fs
|
|
123
|
+
.access(taskFilePath)
|
|
124
|
+
.then(() => true)
|
|
125
|
+
.catch(() => false);
|
|
155
126
|
}
|
|
156
|
-
async
|
|
127
|
+
async list() {
|
|
157
128
|
const taskIds = await fs.readdir(this.baseDir);
|
|
158
|
-
return taskIds.map((taskId) => taskId.
|
|
129
|
+
return Promise.all(taskIds.map((taskId) => this.get(taskId).catch(() => undefined))).then((tasks) => tasks.filter((task) => task !== undefined));
|
|
159
130
|
}
|
|
160
131
|
}
|