@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
|
@@ -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,40 +3,93 @@
|
|
|
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
|
constructor(message, code, data) {
|
|
8
|
-
super(message);
|
|
14
|
+
super(message + " " + formatJson({ cause: data }));
|
|
9
15
|
// this.name = "RpcError";
|
|
10
16
|
this.message = message;
|
|
11
17
|
this.code = code;
|
|
12
18
|
this.data = data;
|
|
13
19
|
}
|
|
14
20
|
}
|
|
15
|
-
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
23
|
+
* @since 0.6.0
|
|
24
|
+
*/
|
|
16
25
|
export const PARSE_ERROR = (data) => new SystemError("Invalid JSON payload", A2A.ErrorCodeParseError, data);
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
28
|
+
* @since 0.6.0
|
|
29
|
+
*/
|
|
17
30
|
export const INVALID_REQUEST = (data) => new SystemError("Request payload validation error", A2A.ErrorCodeInvalidRequest, data);
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
33
|
+
* @since 0.6.0
|
|
34
|
+
*/
|
|
18
35
|
export const METHOD_NOT_FOUND = (data) => new SystemError("Method not found", A2A.ErrorCodeMethodNotFound, data);
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
38
|
+
* @since 0.6.0
|
|
39
|
+
*/
|
|
19
40
|
export const INVALID_PARAMS = (data) => new SystemError("Invalid parameters", A2A.ErrorCodeInvalidParams, data);
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
43
|
+
* @since 0.6.0
|
|
44
|
+
*/
|
|
20
45
|
export const INTERNAL_ERROR = (data) => new SystemError("Internal error", A2A.ErrorCodeInternalError, data);
|
|
46
|
+
/**
|
|
47
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
48
|
+
* @since 0.6.0
|
|
49
|
+
*/
|
|
21
50
|
export const TASK_NOT_FOUND = (data) => new SystemError("Task not found", A2A.ErrorCodeTaskNotFound, data);
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
53
|
+
* @since 0.6.0
|
|
54
|
+
*/
|
|
22
55
|
export const TASK_NOT_CANCELABLE = (data) => new SystemError("Task cannot be canceled", A2A.ErrorCodeTaskNotCancelable, data);
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
58
|
+
* @since 0.6.0
|
|
59
|
+
*/
|
|
23
60
|
export const PUSH_NOTIFICATION_NOT_SUPPORTED = (data) => new SystemError("Push Notifications is not supported", A2A.ErrorCodePushNotificationNotSupported, data);
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
63
|
+
* @since 0.6.0
|
|
64
|
+
*/
|
|
24
65
|
export const AUTHENTICATED_EXTENDED_CARD_NOT_CONFIGURED = (data) => new SystemError("Authenticated Extended Card is not configured", A2A.ErrorCodeAuthenticatedExtendedCardNotConfigured, data);
|
|
66
|
+
/**
|
|
67
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
68
|
+
* @since 0.6.0
|
|
69
|
+
*/
|
|
25
70
|
export const UNSUPPORTED_OPERATION = (data) => new SystemError("This operation is not supported", A2A.ErrorCodeUnsupportedOperation, data);
|
|
71
|
+
/**
|
|
72
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
73
|
+
* @since 0.6.0
|
|
74
|
+
*/
|
|
26
75
|
export const CONTENT_TYPE_NOT_SUPPORTED = (data) => new SystemError("Content type not supported", A2A.ErrorCodeContentTypeNotSupported, data);
|
|
76
|
+
/**
|
|
77
|
+
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
78
|
+
* @since 0.6.0
|
|
79
|
+
*/
|
|
27
80
|
export const INVALID_AGENT_RESPONSE = (data) => new SystemError("Invalid agent response", A2A.ErrorCodeInvalidAgentResponse, data);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
81
|
+
/**
|
|
82
|
+
* @deprecated Use {@link describe.update.failed} instead
|
|
83
|
+
* @since 0.6.0
|
|
84
|
+
*/
|
|
85
|
+
export const FAILED_UPDATE = (taskId, contextId, messageId = "failed-update", errMessage) => {
|
|
86
|
+
return describe.update.failed({
|
|
87
|
+
taskId,
|
|
88
|
+
contextId,
|
|
89
|
+
final: true,
|
|
90
|
+
message: describe.message({
|
|
36
91
|
messageId,
|
|
37
|
-
role: "agent",
|
|
38
92
|
parts: [{ kind: "text", text: errMessage }],
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
93
|
+
}),
|
|
94
|
+
});
|
|
95
|
+
};
|
|
@@ -6,7 +6,7 @@ import { executeJsonRpcRequest, executeGetRequest, } from "../transport/rpc/rpc-
|
|
|
6
6
|
import { executeStreamEvents } from "../transport/streaming/event-stream.js";
|
|
7
7
|
import { INTERNAL_ERROR } from "../utils/common/errors.js";
|
|
8
8
|
import { logger } from "../config/index.js";
|
|
9
|
-
import
|
|
9
|
+
import * as describe from "../create/describe.js";
|
|
10
10
|
/**
|
|
11
11
|
* A2AClient is the main client class for interacting with Agent2Agent (A2A) protocol-compliant services.
|
|
12
12
|
* It provides methods for sending tasks, retrieving statuses, canceling operations, and handling streaming responses.
|
|
@@ -108,10 +108,10 @@ export class A2AClient {
|
|
|
108
108
|
*/
|
|
109
109
|
async sendMessage(params) {
|
|
110
110
|
return await executeJsonRpcRequest(this.agentUrl, "message/send", typeof params === "string"
|
|
111
|
-
?
|
|
111
|
+
? describe.messageSendParams(params)
|
|
112
112
|
: typeof params === "object" && "message" in params
|
|
113
113
|
? params
|
|
114
|
-
:
|
|
114
|
+
: describe.messageSendParams({ message: params }), this.customHeaders);
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
117
|
* @deprecated Use sendMessage instead.
|
|
@@ -128,7 +128,7 @@ export class A2AClient {
|
|
|
128
128
|
* @returns An AsyncIterable that yields TaskStatusUpdateEvent/TaskArtifactUpdateEvent/Task/Message payloads.
|
|
129
129
|
*/
|
|
130
130
|
sendStreamingMessage(params) {
|
|
131
|
-
return executeStreamEvents(this.agentUrl, "message/stream",
|
|
131
|
+
return executeStreamEvents(this.agentUrl, "message/stream", describe.messageSendParams(params), this.customHeaders);
|
|
132
132
|
}
|
|
133
133
|
/**
|
|
134
134
|
* @deprecated Use sendStreamingMessage instead.
|
package/dist/config/default.d.ts
CHANGED
package/dist/config/default.js
CHANGED
package/dist/config/index.d.ts
CHANGED
package/dist/config/index.js
CHANGED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 The Artinet Project
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { A2A } from "../types/index.js";
|
|
6
|
+
import { ArtifactUpdateParams, StatusUpdateParams, TaskParams } from "./task-builder.js";
|
|
7
|
+
import { MessageParams } from "./message-builder.js";
|
|
8
|
+
export interface BaseArguments {
|
|
9
|
+
message: A2A.MessageSendParams;
|
|
10
|
+
context: A2A.Context;
|
|
11
|
+
skip: () => Promise<void> | void;
|
|
12
|
+
}
|
|
13
|
+
export type BaseArgs = Record<string, unknown>;
|
|
14
|
+
export type EmptyArgs = Record<string, never>;
|
|
15
|
+
export type empty = EmptyArgs;
|
|
16
|
+
export type bargs = BaseArgs;
|
|
17
|
+
export type InputArguments<CarriedArguments extends BaseArgs = EmptyArgs> = BaseArguments & Partial<{
|
|
18
|
+
content: string;
|
|
19
|
+
args: CarriedArguments;
|
|
20
|
+
}>;
|
|
21
|
+
export type AcceptedKinds = "text" | "file" | "data" | "message" | "artifact-update" | "status-update" | "task";
|
|
22
|
+
/**
|
|
23
|
+
* State will be inherited from the context, so we don't allow the user to pass those arguments back to us.
|
|
24
|
+
*/
|
|
25
|
+
export type Stateless<T> = T extends object ? Omit<T, "taskId" | "contextId"> : T;
|
|
26
|
+
export type data = A2A.DataPart["data"];
|
|
27
|
+
export type file = A2A.FilePart["file"];
|
|
28
|
+
export type text = A2A.TextPart["text"];
|
|
29
|
+
export type sMessage = Stateless<MessageParams>;
|
|
30
|
+
export type sArtifact = Stateless<ArtifactUpdateParams>;
|
|
31
|
+
export type sUpdate = Stateless<StatusUpdateParams>;
|
|
32
|
+
export type sTask = Stateless<TaskParams>;
|
|
33
|
+
export type AcceptedParts = data | file | text;
|
|
34
|
+
export type AcceptedArrayValues = AcceptedParts | sUpdate | sArtifact;
|
|
35
|
+
export type AcceptedReturnValues = AcceptedParts | sMessage | sArtifact | sUpdate | sTask;
|
|
36
|
+
export type ReturnValue<Ret extends AcceptedReturnValues> = {
|
|
37
|
+
reply: Ret extends AcceptedArrayValues ? Array<Ret> | Ret : Ret;
|
|
38
|
+
};
|
|
39
|
+
export type ReturnAndCarry<Ret extends AcceptedReturnValues, Carried extends BaseArgs = EmptyArgs> = ReturnValue<Ret> & {
|
|
40
|
+
args: Carried;
|
|
41
|
+
};
|
|
42
|
+
export type Reply<Ret extends AcceptedReturnValues, Carried extends BaseArgs = EmptyArgs> = ReturnValue<Ret> | ReturnAndCarry<Ret, Carried> | Ret | (Ret extends AcceptedArrayValues ? Array<Ret> : never);
|
|
43
|
+
export type rep<R extends AcceptedReturnValues, C extends BaseArgs> = Reply<R, C>;
|
|
44
|
+
export type Invocable<Ret extends AcceptedReturnValues = A2A.TextPart["text"], Input extends BaseArgs = EmptyArgs, Carried extends BaseArgs = EmptyArgs, Response extends Reply<Ret, Carried> = Reply<Ret, Carried>> = (params: InputArguments<Input>) => Promise<Response> | Response;
|
|
45
|
+
export type Step<Ret extends AcceptedReturnValues, Input extends BaseArgs = EmptyArgs, Carry extends BaseArgs = EmptyArgs> = Invocable<Ret, Input, Carry, Reply<Ret, Carry>>;
|
|
46
|
+
export type Transform<Ret extends AcceptedReturnValues> = (payload: Ret | Array<Ret>, context: A2A.Context) => AsyncGenerator<A2A.Update, void, unknown>;
|
|
47
|
+
export type Resolved<Ret extends AcceptedReturnValues = A2A.TextPart["text"], Input extends BaseArgs = EmptyArgs, Carried extends BaseArgs = EmptyArgs, Response extends Reply<Ret, Carried> = Reply<Ret, Carried>, Kind extends AcceptedKinds = "text"> = {
|
|
48
|
+
id: string;
|
|
49
|
+
step: Invocable<Ret, Input, Carried, Response>;
|
|
50
|
+
kind: Kind;
|
|
51
|
+
handler: Transform<Ret>;
|
|
52
|
+
};
|
|
53
|
+
export type inferCarry<Carried> = Carried extends ReturnAndCarry<any, infer Carry> ? Carry : EmptyArgs;
|
|
54
|
+
export type inC<Carried> = Carried extends ReturnAndCarry<any, infer Carry> ? Carry : EmptyArgs;
|
|
55
|
+
export interface AgentBuilder<Input extends BaseArgs = EmptyArgs> {
|
|
56
|
+
/**
|
|
57
|
+
* Add a step to the builder.
|
|
58
|
+
* @param step - The step to add.
|
|
59
|
+
* @returns A new builder with the step added.
|
|
60
|
+
*/
|
|
61
|
+
addStep<Ret extends AcceptedReturnValues = A2A.TextPart["text"], Carried extends BaseArgs = EmptyArgs, Response extends Reply<Ret, Carried> = Reply<Ret, Carried>, Kind extends AcceptedKinds = "text">(step: Resolved<Ret, Input, Carried, Response, Kind>): AgentBuilder<inC<Response>>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Carry Only Returns
|
|
65
|
+
* @internal
|
|
66
|
+
* Potential Upgrade:
|
|
67
|
+
* Currently enforce that args cant be passed back without a reply,
|
|
68
|
+
* but may allow carry only returns in the future.
|
|
69
|
+
*
|
|
70
|
+
* ```typescript
|
|
71
|
+
* type CarryOnly<Carried extends BaseArgs> = {
|
|
72
|
+
* args: Carried;
|
|
73
|
+
* } & {
|
|
74
|
+
* reply: never;
|
|
75
|
+
* };
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 The Artinet Project
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
export {};
|
|
6
|
+
/**
|
|
7
|
+
* Carry Only Returns
|
|
8
|
+
* @internal
|
|
9
|
+
* Potential Upgrade:
|
|
10
|
+
* Currently enforce that args cant be passed back without a reply,
|
|
11
|
+
* but may allow carry only returns in the future.
|
|
12
|
+
*
|
|
13
|
+
* ```typescript
|
|
14
|
+
* type CarryOnly<Carried extends BaseArgs> = {
|
|
15
|
+
* args: Carried;
|
|
16
|
+
* } & {
|
|
17
|
+
* reply: never;
|
|
18
|
+
* };
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 The Artinet Project
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { A2A } from "../types/index.js";
|
|
6
|
+
export type AgentCardParams = (Partial<A2A.AgentCard> & Required<Pick<A2A.AgentCard, "name">>) | string;
|
|
7
|
+
export declare const isAgentCardParams: (params: any) => params is AgentCardParams;
|
|
8
|
+
export declare class AgentCard {
|
|
9
|
+
private readonly _agentCard;
|
|
10
|
+
constructor(params: Partial<A2A.AgentCard> & Required<Pick<A2A.AgentCard, "name">>);
|
|
11
|
+
get agentCard(): A2A.AgentCard;
|
|
12
|
+
static create(params: AgentCardParams): A2A.AgentCard;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Use {@link card} instead
|
|
16
|
+
* @since 0.6.0
|
|
17
|
+
*/
|
|
18
|
+
export declare const AgentCardBuilder: typeof AgentCard;
|
|
19
|
+
/**
|
|
20
|
+
* Convenience factory function for creating an {@link A2A.AgentCard} with default parameters.
|
|
21
|
+
*
|
|
22
|
+
* @returns New {@link A2A.AgentCard} with default parameters
|
|
23
|
+
* @defaults {
|
|
24
|
+
* description: "An agent that can use the A2A protocol.",
|
|
25
|
+
* url: "https://localhost:3000/a2a",
|
|
26
|
+
* version: "0.0.0",
|
|
27
|
+
* capabilities: {},
|
|
28
|
+
* defaultInputModes: [],
|
|
29
|
+
* defaultOutputModes: [],
|
|
30
|
+
* skills: [],
|
|
31
|
+
* preferredTransport: "JSONRPC",
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const agentCard = card("My Agent");
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @public
|
|
40
|
+
* @since 0.6.0
|
|
41
|
+
*/
|
|
42
|
+
export declare const card: typeof AgentCard.create;
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated Use {@link card} instead
|
|
45
|
+
* @since 0.6.0
|
|
46
|
+
*/
|
|
47
|
+
export declare const createAgentCard: typeof AgentCard.create;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 The Artinet Project
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
export const isAgentCardParams = (params) => {
|
|
6
|
+
return (typeof params === "string" ||
|
|
7
|
+
(typeof params === "object" && params !== null && "name" in params));
|
|
8
|
+
};
|
|
9
|
+
export class AgentCard {
|
|
10
|
+
_agentCard;
|
|
11
|
+
constructor(params) {
|
|
12
|
+
this._agentCard = {
|
|
13
|
+
protocolVersion: "0.3.0",
|
|
14
|
+
description: "An agent that can use the A2A protocol.",
|
|
15
|
+
url: "https://localhost:3000/a2a",
|
|
16
|
+
version: "0.0.0",
|
|
17
|
+
capabilities: {},
|
|
18
|
+
defaultInputModes: [],
|
|
19
|
+
defaultOutputModes: [],
|
|
20
|
+
skills: [],
|
|
21
|
+
preferredTransport: "JSONRPC",
|
|
22
|
+
...params,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
get agentCard() {
|
|
26
|
+
return this._agentCard;
|
|
27
|
+
}
|
|
28
|
+
static create(params) {
|
|
29
|
+
return new AgentCard(typeof params === "string" ? { name: params } : params)
|
|
30
|
+
.agentCard;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated Use {@link card} instead
|
|
35
|
+
* @since 0.6.0
|
|
36
|
+
*/
|
|
37
|
+
export const AgentCardBuilder = AgentCard;
|
|
38
|
+
/**
|
|
39
|
+
* Convenience factory function for creating an {@link A2A.AgentCard} with default parameters.
|
|
40
|
+
*
|
|
41
|
+
* @returns New {@link A2A.AgentCard} with default parameters
|
|
42
|
+
* @defaults {
|
|
43
|
+
* description: "An agent that can use the A2A protocol.",
|
|
44
|
+
* url: "https://localhost:3000/a2a",
|
|
45
|
+
* version: "0.0.0",
|
|
46
|
+
* capabilities: {},
|
|
47
|
+
* defaultInputModes: [],
|
|
48
|
+
* defaultOutputModes: [],
|
|
49
|
+
* skills: [],
|
|
50
|
+
* preferredTransport: "JSONRPC",
|
|
51
|
+
* }
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const agentCard = card("My Agent");
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
59
|
+
* @since 0.6.0
|
|
60
|
+
*/
|
|
61
|
+
export const card = AgentCard.create;
|
|
62
|
+
/**
|
|
63
|
+
* @deprecated Use {@link card} instead
|
|
64
|
+
* @since 0.6.0
|
|
65
|
+
*/
|
|
66
|
+
export const createAgentCard = AgentCard.create;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|