@artinet/sdk 0.6.0-preview.1 → 0.6.0-preview.2
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 +1 -1
- package/dist/browser/client/a2a-client.js +4 -4
- package/dist/browser/config/index.d.ts +1 -1
- package/dist/browser/config/index.js +1 -1
- package/dist/browser/create/agentcard-builder.d.ts +47 -0
- package/dist/browser/create/agentcard-builder.js +65 -0
- package/dist/browser/create/base.d.ts +4 -0
- package/dist/browser/create/base.js +1 -0
- package/dist/browser/create/describe.d.ts +8 -0
- package/dist/browser/create/describe.js +8 -0
- package/dist/browser/create/message-builder.d.ts +78 -0
- package/dist/browser/create/message-builder.js +108 -0
- package/dist/browser/create/part-builder.d.ts +60 -0
- package/dist/browser/create/part-builder.js +81 -0
- package/dist/browser/create/task-builder.d.ts +251 -0
- package/dist/browser/create/task-builder.js +379 -0
- package/dist/browser/transport/rpc/parser.d.ts +1 -1
- package/dist/browser/transport/rpc/parser.js +2 -1
- package/dist/browser/types/a2a/a2a.d.ts +7 -3
- package/dist/browser/types/a2a/index.d.ts +3 -1
- package/dist/browser/types/a2a/index.js +0 -1
- package/dist/browser/utils/common/constants.d.ts +0 -5
- package/dist/browser/utils/common/constants.js +0 -27
- package/dist/browser/utils/common/errors.d.ts +57 -1
- package/dist/browser/utils/common/errors.js +68 -15
- package/dist/client/a2a-client.js +4 -4
- package/dist/config/default.d.ts +1 -1
- package/dist/config/default.js +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +1 -1
- package/dist/create/agent-builder.d.ts +77 -0
- package/dist/create/agent-builder.js +20 -0
- package/dist/create/agentcard-builder.d.ts +47 -0
- package/dist/create/agentcard-builder.js +66 -0
- package/dist/create/base.d.ts +4 -0
- package/dist/create/base.js +1 -0
- package/dist/create/create.d.ts +762 -0
- package/dist/create/create.js +556 -0
- package/dist/create/describe.d.ts +8 -0
- package/dist/create/describe.js +8 -0
- package/dist/create/index.d.ts +4 -0
- package/dist/create/index.js +4 -0
- package/dist/create/message-builder.d.ts +78 -0
- package/dist/create/message-builder.js +110 -0
- package/dist/create/part-builder.d.ts +60 -0
- package/dist/create/part-builder.js +84 -0
- package/dist/create/status-builder.d.ts +26 -0
- package/dist/create/status-builder.js +46 -0
- package/dist/create/task-builder.d.ts +251 -0
- package/dist/create/task-builder.js +384 -0
- package/dist/create/transform.d.ts +16 -0
- package/dist/create/transform.js +106 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/server/express/errors.js +4 -8
- package/dist/server/express/middeware.js +17 -38
- package/dist/server/express/server.d.ts +6 -1
- package/dist/server/express/server.js +30 -12
- package/dist/services/a2a/execute.d.ts +5 -0
- package/dist/services/a2a/execute.js +7 -0
- package/dist/services/a2a/factory/context.d.ts +1 -1
- package/dist/services/a2a/factory/context.js +2 -3
- package/dist/services/a2a/factory/handler.js +3 -3
- package/dist/services/a2a/factory/index.d.ts +0 -1
- package/dist/services/a2a/factory/index.js +0 -1
- package/dist/services/a2a/factory/service.d.ts +2 -2
- package/dist/services/a2a/factory/service.js +2 -2
- package/dist/services/a2a/factory/state-machine.d.ts +1 -1
- package/dist/services/a2a/factory/state-machine.js +30 -8
- package/dist/services/a2a/handlers/artifact.d.ts +2 -5
- package/dist/services/a2a/handlers/artifact.js +21 -32
- package/dist/services/a2a/handlers/cancel-task.js +7 -5
- package/dist/services/a2a/handlers/resubscribe-task.d.ts +10 -2
- package/dist/services/a2a/handlers/resubscribe-task.js +21 -18
- package/dist/services/a2a/handlers/send-message.js +6 -10
- package/dist/services/a2a/handlers/stream-message.d.ts +10 -2
- package/dist/services/a2a/handlers/stream-message.js +5 -1
- package/dist/services/a2a/handlers/update.js +11 -6
- package/dist/services/a2a/helpers/content.d.ts +5 -1
- package/dist/services/a2a/helpers/content.js +5 -1
- package/dist/services/a2a/helpers/index.d.ts +2 -2
- package/dist/services/a2a/helpers/index.js +2 -2
- package/dist/services/a2a/index.d.ts +1 -1
- package/dist/services/a2a/index.js +1 -1
- package/dist/services/a2a/managers.js +7 -1
- package/dist/services/a2a/service.d.ts +6 -2
- package/dist/services/a2a/service.js +52 -59
- package/dist/services/a2a/state-machine.d.ts +3 -3
- package/dist/services/a2a/state-machine.js +2 -0
- package/dist/transport/rpc/parser.d.ts +1 -1
- package/dist/transport/rpc/parser.js +2 -1
- package/dist/types/a2a/a2a.d.ts +7 -3
- package/dist/types/a2a/index.d.ts +3 -1
- package/dist/types/a2a/index.js +0 -1
- package/dist/utils/common/constants.d.ts +0 -5
- package/dist/utils/common/constants.js +0 -27
- package/dist/utils/common/errors.d.ts +57 -1
- package/dist/utils/common/errors.js +68 -15
- package/dist/utils/common/parse.d.ts +1 -1
- package/dist/utils/common/schema-validation.d.ts +1 -1
- package/package.json +7 -4
- package/dist/browser/services/a2a/helpers/message-builder.d.ts +0 -17
- package/dist/browser/services/a2a/helpers/message-builder.js +0 -66
- package/dist/browser/types/a2a/builder.d.ts +0 -43
- package/dist/browser/types/a2a/builder.js +0 -5
- package/dist/services/a2a/factory/builder.d.ts +0 -292
- package/dist/services/a2a/factory/builder.js +0 -370
- package/dist/services/a2a/helpers/agentcard-builder.d.ts +0 -11
- package/dist/services/a2a/helpers/agentcard-builder.js +0 -27
- package/dist/services/a2a/helpers/message-builder.d.ts +0 -17
- package/dist/services/a2a/helpers/message-builder.js +0 -66
- package/dist/types/a2a/builder.d.ts +0 -43
- package/dist/types/a2a/builder.js +0 -5
|
@@ -32,10 +32,11 @@ export class Contexts extends Manager {
|
|
|
32
32
|
});
|
|
33
33
|
logger.debug(`Contexts[create]: params`, { params });
|
|
34
34
|
const baseContext = createBaseContext(params);
|
|
35
|
+
//todo: consider allowing ContextParams to cascade
|
|
35
36
|
const context = {
|
|
36
37
|
...createContext({
|
|
37
38
|
baseContext: baseContext,
|
|
38
|
-
taskId: params.task
|
|
39
|
+
taskId: params.task.id,
|
|
39
40
|
messenger: params.messenger,
|
|
40
41
|
references: params.references,
|
|
41
42
|
extensions: params.extensions,
|
|
@@ -64,6 +65,11 @@ export class Tasks extends Manager {
|
|
|
64
65
|
}
|
|
65
66
|
async update(context, update) {
|
|
66
67
|
logger.info(`Tasks[update]: updating task`, { taskId: context.taskId });
|
|
68
|
+
logger.debug(`Tasks[update]: update`, { update });
|
|
69
|
+
logger.debug(`Tasks[update]: context`, { context });
|
|
70
|
+
logger.debug(`Tasks[update]: context task`, {
|
|
71
|
+
task: await context.getTask(),
|
|
72
|
+
});
|
|
67
73
|
const task = await handleUpdate({
|
|
68
74
|
context,
|
|
69
75
|
task: await context.getTask(),
|
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { A2A } from "../../types/index.js";
|
|
6
6
|
import { ServiceParams } from "./factory/service.js";
|
|
7
|
+
/**
|
|
8
|
+
* @note We endeavor to remove all optional parameters from below this class.
|
|
9
|
+
* This will allow the service to act as the boundary to our Hexagonal Architecture.
|
|
10
|
+
*/
|
|
7
11
|
export declare class Service implements A2A.Service {
|
|
8
12
|
private _agentCard;
|
|
9
13
|
private _engine;
|
|
@@ -38,10 +42,10 @@ export declare class Service implements A2A.Service {
|
|
|
38
42
|
cancelTask(params: A2A.TaskIdParams, context?: A2A.Context, options?: A2A.ServiceOptions): Promise<A2A.Task>;
|
|
39
43
|
sendMessage(params: A2A.MessageSendParams, context?: A2A.Context, options?: A2A.ServiceOptions): Promise<A2A.SendMessageSuccessResult>;
|
|
40
44
|
sendMessage(message: string | A2A.MessageSendParams["message"], context?: A2A.Context, options?: A2A.ServiceOptions): Promise<A2A.SendMessageSuccessResult>;
|
|
41
|
-
_sendMessage(params: A2A.MessageSendParams, context?: A2A.Context, options?: A2A.ServiceOptions): Promise<A2A.SendMessageSuccessResult>;
|
|
45
|
+
protected _sendMessage(params: A2A.MessageSendParams, context?: A2A.Context, options?: A2A.ServiceOptions): Promise<A2A.SendMessageSuccessResult>;
|
|
42
46
|
streamMessage(params: A2A.MessageSendParams, context?: A2A.Context, options?: A2A.ServiceOptions): AsyncGenerator<A2A.Update>;
|
|
43
47
|
streamMessage(message: string, context?: A2A.Context, options?: A2A.ServiceOptions): AsyncGenerator<A2A.Update>;
|
|
44
|
-
|
|
48
|
+
sendMessageStream(params: A2A.MessageSendParams, context?: A2A.Context, options?: A2A.ServiceOptions): AsyncGenerator<A2A.Update>;
|
|
45
49
|
resubscribe(params: A2A.TaskIdParams, context?: A2A.Context, options?: A2A.ServiceOptions): AsyncGenerator<A2A.Update>;
|
|
46
50
|
static create(params: ServiceParams): Service;
|
|
47
51
|
}
|
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { A2A } from "../../types/index.js";
|
|
6
|
-
import { createMessageSendParams } from "./helpers/message-builder.js";
|
|
7
6
|
import { validateSchema } from "../../utils/common/schema-validation.js";
|
|
8
|
-
import
|
|
7
|
+
import * as describe from "../../create/describe.js";
|
|
9
8
|
import { INVALID_REQUEST, TASK_NOT_FOUND } from "../../utils/common/errors.js";
|
|
10
|
-
import { v4 as uuidv4 } from "uuid";
|
|
11
9
|
import { Messenger } from "./messenger.js";
|
|
12
10
|
import { execute } from "./execute.js";
|
|
13
11
|
import { createService } from "./factory/service.js";
|
|
@@ -37,6 +35,10 @@ const getExtensions = async (extensions) => {
|
|
|
37
35
|
logger.warn("getExtensions: not implemented", { extensions });
|
|
38
36
|
return [];
|
|
39
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* @note We endeavor to remove all optional parameters from below this class.
|
|
40
|
+
* This will allow the service to act as the boundary to our Hexagonal Architecture.
|
|
41
|
+
*/
|
|
40
42
|
export class Service {
|
|
41
43
|
_agentCard;
|
|
42
44
|
_engine;
|
|
@@ -115,29 +117,22 @@ export class Service {
|
|
|
115
117
|
async stop() {
|
|
116
118
|
logger.info(`Service[stop]`);
|
|
117
119
|
for (const context of await this.contexts.list()) {
|
|
118
|
-
await context.publisher.onCancel(
|
|
119
|
-
role: "agent",
|
|
120
|
-
parts: [
|
|
121
|
-
{
|
|
122
|
-
kind: "text",
|
|
123
|
-
text: "service stopped",
|
|
124
|
-
},
|
|
125
|
-
],
|
|
126
|
-
messageId: uuidv4(),
|
|
127
|
-
kind: "message",
|
|
128
|
-
taskId: context.taskId,
|
|
120
|
+
await context.publisher.onCancel(describe.update.canceled({
|
|
129
121
|
contextId: context.contextId,
|
|
122
|
+
taskId: context.taskId,
|
|
123
|
+
message: describe.message("service stopped"),
|
|
130
124
|
}));
|
|
131
125
|
}
|
|
132
126
|
return;
|
|
133
127
|
}
|
|
134
128
|
async getTask(params, context, options) {
|
|
135
|
-
|
|
136
|
-
|
|
129
|
+
const taskParams = await validateSchema(A2A.TaskQueryParamsSchema, params);
|
|
130
|
+
logger.info(`Service[getTask]:`, { taskId: taskParams.id });
|
|
131
|
+
const task = await this.tasks.get(taskParams.id);
|
|
137
132
|
if (!task) {
|
|
138
|
-
throw TASK_NOT_FOUND({ taskId:
|
|
133
|
+
throw TASK_NOT_FOUND({ taskId: taskParams.id });
|
|
139
134
|
}
|
|
140
|
-
return await this.methods.getTask(
|
|
135
|
+
return await this.methods.getTask(taskParams, context ??
|
|
141
136
|
(await this.contexts.create({
|
|
142
137
|
contextId: task.contextId,
|
|
143
138
|
service: this,
|
|
@@ -148,12 +143,13 @@ export class Service {
|
|
|
148
143
|
})));
|
|
149
144
|
}
|
|
150
145
|
async cancelTask(params, context, options) {
|
|
151
|
-
|
|
152
|
-
|
|
146
|
+
const taskParams = await validateSchema(A2A.TaskIdParamsSchema, params);
|
|
147
|
+
logger.info(`Service[cancelTask]:`, { taskId: taskParams.id });
|
|
148
|
+
const task = await this.tasks.get(taskParams.id);
|
|
153
149
|
if (!task) {
|
|
154
|
-
throw TASK_NOT_FOUND({ taskId:
|
|
150
|
+
throw TASK_NOT_FOUND({ taskId: taskParams.id });
|
|
155
151
|
}
|
|
156
|
-
return await this.methods.cancelTask(
|
|
152
|
+
return await this.methods.cancelTask(taskParams, context ??
|
|
157
153
|
(await this.contexts.create({
|
|
158
154
|
contextId: task.contextId,
|
|
159
155
|
service: this,
|
|
@@ -164,89 +160,86 @@ export class Service {
|
|
|
164
160
|
})));
|
|
165
161
|
}
|
|
166
162
|
async sendMessage(paramsOrMessage, context, options) {
|
|
167
|
-
const params =
|
|
168
|
-
? createMessageSendParams(paramsOrMessage)
|
|
169
|
-
: typeof paramsOrMessage === "object" && "message" in paramsOrMessage
|
|
170
|
-
? paramsOrMessage
|
|
171
|
-
: createMessageSendParams({
|
|
172
|
-
message: paramsOrMessage,
|
|
173
|
-
});
|
|
163
|
+
const params = describe.messageSendParams(paramsOrMessage);
|
|
174
164
|
return await this._sendMessage(params, context, options);
|
|
175
165
|
}
|
|
176
166
|
async _sendMessage(params, context, options) {
|
|
167
|
+
const messageParams = await validateSchema(A2A.MessageSendParamsSchema, params);
|
|
177
168
|
logger.info(`Service[sendMessage]:`, {
|
|
178
|
-
messageId:
|
|
169
|
+
messageId: messageParams.message.messageId,
|
|
170
|
+
});
|
|
171
|
+
logger.debug(`Service[sendMessage]:`, {
|
|
172
|
+
taskId: messageParams.message.taskId,
|
|
179
173
|
});
|
|
180
|
-
logger.debug(`Service[sendMessage]:`, { taskId: params.message.taskId });
|
|
181
174
|
logger.debug(`Service[sendMessage]:`, {
|
|
182
|
-
contextId:
|
|
175
|
+
contextId: messageParams.message.contextId,
|
|
183
176
|
});
|
|
184
177
|
const task = await this.tasks.create({
|
|
185
|
-
id:
|
|
186
|
-
contextId:
|
|
187
|
-
history: [
|
|
178
|
+
id: messageParams.message.taskId,
|
|
179
|
+
contextId: messageParams.message.contextId,
|
|
180
|
+
history: [messageParams.message],
|
|
188
181
|
metadata: {
|
|
189
|
-
...
|
|
182
|
+
...messageParams.metadata,
|
|
190
183
|
},
|
|
191
184
|
});
|
|
192
|
-
return await this.methods.sendMessage(
|
|
185
|
+
return await this.methods.sendMessage(messageParams, context ??
|
|
193
186
|
(await this.contexts.create({
|
|
194
187
|
contextId: task.contextId,
|
|
195
188
|
service: this,
|
|
196
189
|
abortSignal: options?.abortSignal,
|
|
197
190
|
task: task,
|
|
198
191
|
overrides: this.overrides,
|
|
199
|
-
messenger: Messenger.create(
|
|
200
|
-
references: await getReferences(this.tasks,
|
|
201
|
-
extensions: await getExtensions(
|
|
192
|
+
messenger: Messenger.create(messageParams),
|
|
193
|
+
references: await getReferences(this.tasks, messageParams.message.referenceTaskIds),
|
|
194
|
+
extensions: await getExtensions(messageParams.message.extensions),
|
|
202
195
|
})));
|
|
203
196
|
}
|
|
204
197
|
async *streamMessage(paramsOrMessage, context, options) {
|
|
205
|
-
const params =
|
|
206
|
-
|
|
207
|
-
: paramsOrMessage;
|
|
208
|
-
yield* this._streamMessage(params, context, options);
|
|
198
|
+
const params = describe.messageSendParams(paramsOrMessage);
|
|
199
|
+
yield* this.sendMessageStream(params, context, options);
|
|
209
200
|
}
|
|
210
|
-
async *
|
|
201
|
+
async *sendMessageStream(params, context, options) {
|
|
202
|
+
const messageParams = await validateSchema(A2A.MessageSendParamsSchema, params);
|
|
211
203
|
logger.info("Service[streamMessage]:", {
|
|
212
|
-
taskId:
|
|
213
|
-
contextId:
|
|
204
|
+
taskId: messageParams.message.taskId,
|
|
205
|
+
contextId: messageParams.message.contextId,
|
|
214
206
|
});
|
|
215
207
|
const task = await this.tasks.create({
|
|
216
|
-
id:
|
|
217
|
-
contextId:
|
|
218
|
-
history: [
|
|
208
|
+
id: messageParams.message.taskId,
|
|
209
|
+
contextId: messageParams.message.contextId,
|
|
210
|
+
history: [messageParams.message],
|
|
219
211
|
metadata: {
|
|
220
|
-
...
|
|
212
|
+
...messageParams.metadata,
|
|
221
213
|
},
|
|
222
214
|
});
|
|
223
215
|
logger.debug("Service[streamMessage]: task created", {
|
|
224
216
|
taskId: task.id,
|
|
225
217
|
contextId: task.contextId,
|
|
226
218
|
});
|
|
227
|
-
yield* this.methods.streamMessage(
|
|
219
|
+
yield* this.methods.streamMessage(messageParams, context ??
|
|
228
220
|
(await this.contexts.create({
|
|
229
221
|
contextId: task.contextId,
|
|
230
222
|
service: this,
|
|
231
223
|
abortSignal: options?.abortSignal,
|
|
232
224
|
task: task,
|
|
233
225
|
overrides: this.overrides,
|
|
234
|
-
messenger: Messenger.create(
|
|
235
|
-
references: await getReferences(this.tasks,
|
|
236
|
-
extensions: await getExtensions(
|
|
226
|
+
messenger: Messenger.create(messageParams),
|
|
227
|
+
references: await getReferences(this.tasks, messageParams.message.referenceTaskIds),
|
|
228
|
+
extensions: await getExtensions(messageParams.message.extensions),
|
|
237
229
|
})));
|
|
238
230
|
}
|
|
239
231
|
async *resubscribe(params, context, options) {
|
|
240
|
-
|
|
241
|
-
|
|
232
|
+
const taskParams = await validateSchema(A2A.TaskIdParamsSchema, params);
|
|
233
|
+
logger.info(`Service[resubscribe]:`, { taskId: taskParams.id });
|
|
234
|
+
const task = await this.tasks.get(taskParams.id);
|
|
242
235
|
if (!task) {
|
|
243
|
-
throw TASK_NOT_FOUND({ taskId:
|
|
236
|
+
throw TASK_NOT_FOUND({ taskId: taskParams.id });
|
|
244
237
|
}
|
|
245
238
|
logger.debug("Service[resubscribe]:", {
|
|
246
239
|
taskId: task.id,
|
|
247
240
|
contextId: task.contextId,
|
|
248
241
|
});
|
|
249
|
-
yield* this.methods.resubscribe(
|
|
242
|
+
yield* this.methods.resubscribe(taskParams, context ??
|
|
250
243
|
(await this.contexts.create({
|
|
251
244
|
contextId: task.contextId,
|
|
252
245
|
service: this,
|
|
@@ -3,16 +3,16 @@ import { A2A } from "../../types/index.js";
|
|
|
3
3
|
export declare class StateMachine extends EventEmitter<A2A.Emissions> implements A2A.EventPublisher {
|
|
4
4
|
readonly _contextId: string;
|
|
5
5
|
private readonly _consumer;
|
|
6
|
-
private _currentTask
|
|
6
|
+
private _currentTask;
|
|
7
7
|
onStart: (context: A2A.Context) => Promise<A2A.Task>;
|
|
8
8
|
onCancel: (update: A2A.Update) => Promise<void>;
|
|
9
9
|
onUpdate: (update: A2A.Update) => Promise<A2A.Task>;
|
|
10
10
|
onError: (error: any) => Promise<void>;
|
|
11
11
|
onComplete: () => Promise<void>;
|
|
12
|
-
constructor(_contextId: string, _consumer: A2A.EventConsumer, _currentTask
|
|
12
|
+
constructor(_contextId: string, _consumer: A2A.EventConsumer, _currentTask: A2A.Task);
|
|
13
13
|
get currentTask(): A2A.Task;
|
|
14
14
|
private set currentTask(value);
|
|
15
15
|
get consumer(): A2A.EventConsumer;
|
|
16
16
|
get contextId(): string;
|
|
17
|
-
static create(contextId: string, service: A2A.Service, task
|
|
17
|
+
static create(contextId: string, service: A2A.Service, task: A2A.Task, overrides?: Partial<Omit<A2A.EventConsumer, "contextId">>): StateMachine;
|
|
18
18
|
}
|
|
@@ -34,6 +34,8 @@ export class StateMachine extends EventEmitter {
|
|
|
34
34
|
if (this.consumer.onError) {
|
|
35
35
|
await this.consumer.onError(error, this.currentTask);
|
|
36
36
|
}
|
|
37
|
+
if (!this.listenerCount("error"))
|
|
38
|
+
return;
|
|
37
39
|
this.emit("error", error, this.currentTask);
|
|
38
40
|
};
|
|
39
41
|
onComplete = async () => {
|
|
@@ -12,4 +12,4 @@ import { MCP } from "../../types/index.js";
|
|
|
12
12
|
* @returns The parsed and validated response object
|
|
13
13
|
* @throws A2AError if the response contains an error or is invalid
|
|
14
14
|
*/
|
|
15
|
-
export declare function parseResponse<Res extends MCP.JSONRPCResponse | MCP.
|
|
15
|
+
export declare function parseResponse<Res extends MCP.JSONRPCResponse | MCP.JSONRPCErrorResponse>(data: string): Res;
|
|
@@ -21,7 +21,8 @@ export function parseResponse(data) {
|
|
|
21
21
|
try {
|
|
22
22
|
const parsed = JSON.parse(data); //todo: leverage safe parse
|
|
23
23
|
if (parsed.error) {
|
|
24
|
-
|
|
24
|
+
//MCP Error defs may be a wee bit restrictive
|
|
25
|
+
const parsedError = MCP.JSONRPCErrorResponseSchema.safeParse(parsed);
|
|
25
26
|
if (!parsedError.success) {
|
|
26
27
|
throw PARSE_ERROR(parsedError.error);
|
|
27
28
|
}
|
package/dist/types/a2a/a2a.d.ts
CHANGED
|
@@ -256,10 +256,14 @@ export declare const UpdateSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
256
256
|
lastChunk: z.ZodOptional<z.ZodBoolean>;
|
|
257
257
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
258
258
|
}, z.core.$strip>]>;
|
|
259
|
-
export type Update = z.
|
|
259
|
+
export type Update = z.output<typeof UpdateSchema>;
|
|
260
260
|
export type Engine = (context: Context) => AsyncGenerator<Update, void, unknown>;
|
|
261
261
|
export interface BaseContext extends core.Context<Task> {
|
|
262
262
|
readonly service: Service;
|
|
263
|
+
/**
|
|
264
|
+
* Considering ommit OnStart & OnComplete from Context consumers.
|
|
265
|
+
* That way the user cannot inadvertently trigger a start/completion out of band.
|
|
266
|
+
*/
|
|
263
267
|
readonly publisher: EventPublisher;
|
|
264
268
|
}
|
|
265
269
|
export interface Context extends BaseContext {
|
|
@@ -270,9 +274,9 @@ export interface Context extends BaseContext {
|
|
|
270
274
|
references?: Task[];
|
|
271
275
|
getTask: () => Promise<Task>;
|
|
272
276
|
}
|
|
273
|
-
export type ContextParams = Omit<BaseContext, "publisher" | "isCancelled" | "getState" | "abortSignal"> & Omit<Partial<Context>, "userMessage"> & {
|
|
277
|
+
export type ContextParams = Omit<BaseContext, "publisher" | "isCancelled" | "getState" | "abortSignal"> & Omit<Partial<Context>, "userMessage" | "taskId"> & {
|
|
274
278
|
messenger: MessageConsumerProxy;
|
|
275
|
-
task
|
|
279
|
+
task: Task;
|
|
276
280
|
overrides?: Partial<Omit<EventConsumer, "contextId">>;
|
|
277
281
|
abortSignal?: AbortSignal;
|
|
278
282
|
};
|
package/dist/types/a2a/index.js
CHANGED
|
@@ -3,9 +3,4 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
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
6
|
export declare const FINAL_STATES: A2A.TaskState[];
|
|
@@ -3,33 +3,6 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { A2A } from "../../types/index.js";
|
|
6
|
-
import { getCurrentTimestamp } from "./utils.js";
|
|
7
|
-
//todo: protocol specific so move to a2a folder
|
|
8
|
-
export const STATUS_UPDATE = (taskId, contextId, status, message, timestamp = getCurrentTimestamp(), final = false) => {
|
|
9
|
-
return {
|
|
10
|
-
taskId: taskId,
|
|
11
|
-
contextId: contextId,
|
|
12
|
-
kind: "status-update",
|
|
13
|
-
status: {
|
|
14
|
-
state: status,
|
|
15
|
-
message: message,
|
|
16
|
-
timestamp: timestamp,
|
|
17
|
-
},
|
|
18
|
-
final: final,
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
export const WORKING_UPDATE = (taskId, contextId, message, timestamp) => {
|
|
22
|
-
return STATUS_UPDATE(taskId, contextId, A2A.TaskState.working, message, timestamp);
|
|
23
|
-
};
|
|
24
|
-
export const CANCEL_UPDATE = (taskId, contextId, message, timestamp) => {
|
|
25
|
-
return STATUS_UPDATE(taskId, contextId, A2A.TaskState.canceled, message, timestamp, true);
|
|
26
|
-
};
|
|
27
|
-
export const SUBMITTED_UPDATE = (taskId, contextId, message, timestamp) => {
|
|
28
|
-
return STATUS_UPDATE(taskId, contextId, A2A.TaskState.submitted, message, timestamp);
|
|
29
|
-
};
|
|
30
|
-
export const FAILED_UPDATE_EVENT = (taskId, contextId, message, timestamp) => {
|
|
31
|
-
return STATUS_UPDATE(taskId, contextId, A2A.TaskState.failed, message, timestamp, true);
|
|
32
|
-
};
|
|
33
6
|
export const FINAL_STATES = [
|
|
34
7
|
A2A.TaskState.completed,
|
|
35
8
|
A2A.TaskState.failed,
|
|
@@ -3,22 +3,78 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { A2A, MCP } from "../../types/index.js";
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
8
|
+
* @since 0.6.0
|
|
9
|
+
*/
|
|
10
|
+
export declare class SystemError<T extends MCP.JSONRPCErrorResponse> extends Error {
|
|
7
11
|
message: string;
|
|
8
12
|
code: T["error"]["code"];
|
|
9
13
|
data: T["error"]["data"];
|
|
10
14
|
constructor(message: string, code: T["error"]["code"], data: T["error"]["data"]);
|
|
11
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
18
|
+
* @since 0.6.0
|
|
19
|
+
*/
|
|
12
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
|
+
*/
|
|
13
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
|
+
*/
|
|
14
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
|
+
* @since 0.6.0
|
|
34
|
+
*/
|
|
15
35
|
export declare const INVALID_PARAMS: <T extends A2A.InvalidParamsError>(data: T["error"]["data"]) => SystemError<T>;
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
38
|
+
* @since 0.6.0
|
|
39
|
+
*/
|
|
16
40
|
export declare const INTERNAL_ERROR: <T extends A2A.InternalError>(data: T["error"]["data"]) => SystemError<T>;
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
43
|
+
* @since 0.6.0
|
|
44
|
+
*/
|
|
17
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
|
+
* @since 0.6.0
|
|
49
|
+
*/
|
|
18
50
|
export declare const TASK_NOT_CANCELABLE: <T extends A2A.TaskNotCancelableError>(data: T["error"]["data"]) => SystemError<T>;
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
53
|
+
* @since 0.6.0
|
|
54
|
+
*/
|
|
19
55
|
export declare const PUSH_NOTIFICATION_NOT_SUPPORTED: <T extends A2A.A2AError>(data: T["error"]["data"]) => SystemError<T>;
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
58
|
+
* @since 0.6.0
|
|
59
|
+
*/
|
|
20
60
|
export declare const AUTHENTICATED_EXTENDED_CARD_NOT_CONFIGURED: <T extends A2A.AuthenticatedExtendedCardNotConfiguredError>(data: T["error"]["data"]) => SystemError<T>;
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
63
|
+
* @since 0.6.0
|
|
64
|
+
*/
|
|
21
65
|
export declare const UNSUPPORTED_OPERATION: <T extends A2A.A2AError>(data: T["error"]["data"]) => SystemError<T>;
|
|
66
|
+
/**
|
|
67
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
68
|
+
* @since 0.6.0
|
|
69
|
+
*/
|
|
22
70
|
export declare const CONTENT_TYPE_NOT_SUPPORTED: <T extends A2A.ContentTypeNotSupportedError>(data: T["error"]["data"]) => SystemError<T>;
|
|
71
|
+
/**
|
|
72
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
73
|
+
* @since 0.6.0
|
|
74
|
+
*/
|
|
23
75
|
export declare const INVALID_AGENT_RESPONSE: <T extends A2A.InvalidAgentResponseError>(data: T["error"]["data"]) => SystemError<T>;
|
|
76
|
+
/**
|
|
77
|
+
* @deprecated Use {@link describe.update.failed} instead
|
|
78
|
+
* @since 0.6.0
|
|
79
|
+
*/
|
|
24
80
|
export declare const FAILED_UPDATE: (taskId: string, contextId: string, messageId: string | undefined, errMessage: string) => A2A.TaskStatusUpdateEvent;
|
|
@@ -3,43 +3,96 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { A2A } from "../../types/index.js";
|
|
6
|
+
import * as describe from "../../create/describe.js";
|
|
7
|
+
import { formatJson } from "./utils.js";
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
10
|
+
* @since 0.6.0
|
|
11
|
+
*/
|
|
6
12
|
export class SystemError extends Error {
|
|
7
13
|
message;
|
|
8
14
|
code;
|
|
9
15
|
data;
|
|
10
16
|
constructor(message, code, data) {
|
|
11
|
-
super(message);
|
|
17
|
+
super(message + " " + formatJson({ cause: data }));
|
|
12
18
|
// this.name = "RpcError";
|
|
13
19
|
this.message = message;
|
|
14
20
|
this.code = code;
|
|
15
21
|
this.data = data;
|
|
16
22
|
}
|
|
17
23
|
}
|
|
18
|
-
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
26
|
+
* @since 0.6.0
|
|
27
|
+
*/
|
|
19
28
|
export const PARSE_ERROR = (data) => new SystemError("Invalid JSON payload", A2A.ErrorCodeParseError, data);
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
31
|
+
* @since 0.6.0
|
|
32
|
+
*/
|
|
20
33
|
export const INVALID_REQUEST = (data) => new SystemError("Request payload validation error", A2A.ErrorCodeInvalidRequest, data);
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
36
|
+
* @since 0.6.0
|
|
37
|
+
*/
|
|
21
38
|
export const METHOD_NOT_FOUND = (data) => new SystemError("Method not found", A2A.ErrorCodeMethodNotFound, data);
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
41
|
+
* @since 0.6.0
|
|
42
|
+
*/
|
|
22
43
|
export const INVALID_PARAMS = (data) => new SystemError("Invalid parameters", A2A.ErrorCodeInvalidParams, data);
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
46
|
+
* @since 0.6.0
|
|
47
|
+
*/
|
|
23
48
|
export const INTERNAL_ERROR = (data) => new SystemError("Internal error", A2A.ErrorCodeInternalError, data);
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
51
|
+
* @since 0.6.0
|
|
52
|
+
*/
|
|
24
53
|
export const TASK_NOT_FOUND = (data) => new SystemError("Task not found", A2A.ErrorCodeTaskNotFound, data);
|
|
54
|
+
/**
|
|
55
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
56
|
+
* @since 0.6.0
|
|
57
|
+
*/
|
|
25
58
|
export const TASK_NOT_CANCELABLE = (data) => new SystemError("Task cannot be canceled", A2A.ErrorCodeTaskNotCancelable, data);
|
|
59
|
+
/**
|
|
60
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
61
|
+
* @since 0.6.0
|
|
62
|
+
*/
|
|
26
63
|
export const PUSH_NOTIFICATION_NOT_SUPPORTED = (data) => new SystemError("Push Notifications is not supported", A2A.ErrorCodePushNotificationNotSupported, data);
|
|
64
|
+
/**
|
|
65
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
66
|
+
* @since 0.6.0
|
|
67
|
+
*/
|
|
27
68
|
export const AUTHENTICATED_EXTENDED_CARD_NOT_CONFIGURED = (data) => new SystemError("Authenticated Extended Card is not configured", A2A.ErrorCodeAuthenticatedExtendedCardNotConfigured, data);
|
|
69
|
+
/**
|
|
70
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
71
|
+
* @since 0.6.0
|
|
72
|
+
*/
|
|
28
73
|
export const UNSUPPORTED_OPERATION = (data) => new SystemError("This operation is not supported", A2A.ErrorCodeUnsupportedOperation, data);
|
|
74
|
+
/**
|
|
75
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
76
|
+
* @since 0.6.0
|
|
77
|
+
*/
|
|
29
78
|
export const CONTENT_TYPE_NOT_SUPPORTED = (data) => new SystemError("Content type not supported", A2A.ErrorCodeContentTypeNotSupported, data);
|
|
79
|
+
/**
|
|
80
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
81
|
+
* @since 0.6.0
|
|
82
|
+
*/
|
|
30
83
|
export const INVALID_AGENT_RESPONSE = (data) => new SystemError("Invalid agent response", A2A.ErrorCodeInvalidAgentResponse, data);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
84
|
+
/**
|
|
85
|
+
* @deprecated Use {@link describe.update.failed} instead
|
|
86
|
+
* @since 0.6.0
|
|
87
|
+
*/
|
|
88
|
+
export const FAILED_UPDATE = (taskId, contextId, messageId = "failed-update", errMessage) => {
|
|
89
|
+
return describe.update.failed({
|
|
90
|
+
taskId,
|
|
91
|
+
contextId,
|
|
92
|
+
final: true,
|
|
93
|
+
message: describe.message({
|
|
39
94
|
messageId,
|
|
40
|
-
role: "agent",
|
|
41
95
|
parts: [{ kind: "text", text: errMessage }],
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
96
|
+
}),
|
|
97
|
+
});
|
|
98
|
+
};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { z } from "zod/v4";
|
|
6
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.
|
|
7
|
+
export declare function safeParseSchema<T extends z.ZodSchema>(json: string, schema: T): Promise<z.output<T>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { z } from "zod/v4";
|
|
2
|
-
export declare function validateSchema<T extends z.ZodSchema>(schema: T, data: unknown): Promise<z.
|
|
2
|
+
export declare function validateSchema<T extends z.ZodSchema>(schema: T, data: unknown): Promise<z.output<T>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artinet/sdk",
|
|
3
|
-
"version": "0.6.0-preview.
|
|
3
|
+
"version": "0.6.0-preview.2",
|
|
4
4
|
"description": "A TypeScript SDK for building collaborative AI agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,22 +28,22 @@
|
|
|
28
28
|
"default": "./dist/types/index.js"
|
|
29
29
|
},
|
|
30
30
|
"./pino": {
|
|
31
|
+
"types": "./dist/extensions/pino.d.ts",
|
|
31
32
|
"node": {
|
|
32
|
-
"types": "./dist/extensions/pino.d.ts",
|
|
33
33
|
"import": "./dist/extensions/pino.js",
|
|
34
34
|
"default": "./dist/extensions/pino.js"
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"./winston": {
|
|
38
|
+
"types": "./dist/extensions/winston.d.ts",
|
|
38
39
|
"node": {
|
|
39
|
-
"types": "./dist/extensions/winston.d.ts",
|
|
40
40
|
"import": "./dist/extensions/winston.js",
|
|
41
41
|
"default": "./dist/extensions/winston.js"
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
"./otel": {
|
|
45
|
+
"types": "./dist/extensions/opentelemetry.d.ts",
|
|
45
46
|
"node": {
|
|
46
|
-
"types": "./dist/extensions/opentelemetry.d.ts",
|
|
47
47
|
"import": "./dist/extensions/opentelemetry.js",
|
|
48
48
|
"default": "./dist/extensions/opentelemetry.js"
|
|
49
49
|
}
|
|
@@ -130,6 +130,7 @@
|
|
|
130
130
|
}
|
|
131
131
|
},
|
|
132
132
|
"devDependencies": {
|
|
133
|
+
"@a2a-js/sdk": "^0.3.7",
|
|
133
134
|
"@cfworker/json-schema": "^4.1.1",
|
|
134
135
|
"@eslint/js": "^9.25.1",
|
|
135
136
|
"@opentelemetry/api": "^1.9.0",
|
|
@@ -143,11 +144,13 @@
|
|
|
143
144
|
"globals": "^16.0.0",
|
|
144
145
|
"jest": "^30.2.0",
|
|
145
146
|
"msw": "^2.7.5",
|
|
147
|
+
"@modelcontextprotocol/sdk": "^1.24.3",
|
|
146
148
|
"pino": "^10.1.0",
|
|
147
149
|
"pino-caller": "^4.0.0",
|
|
148
150
|
"pino-pretty": "^13.1.3",
|
|
149
151
|
"rimraf": "^6.1.2",
|
|
150
152
|
"supertest": "latest",
|
|
153
|
+
"@trpc/server": "^11.4.3",
|
|
151
154
|
"ts-jest": "^29.3.2",
|
|
152
155
|
"ts-node": "^10.9.1",
|
|
153
156
|
"ts-patch": "^3.3.0",
|