@artinet/sdk 0.6.0-preview.2 → 0.6.0-preview.3
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 +7 -16
- package/dist/create/status-builder.d.ts +4 -0
- package/dist/extensions/otel.d.ts +3 -0
- package/dist/extensions/otel.js +3 -0
- package/dist/extensions/pino.d.ts +3 -0
- package/dist/extensions/pino.js +3 -0
- package/dist/extensions/winston.d.ts +3 -0
- package/dist/extensions/winston.js +3 -0
- package/dist/server/express/server.d.ts +14 -0
- package/dist/server/express/server.js +14 -0
- package/dist/services/a2a/handlers/update.js +5 -7
- package/dist/services/a2a/service.js +2 -2
- package/dist/transport/trpc/a2a/routes/message/route.js +2 -1
- package/dist/transport/trpc/a2a/routes/tasks/route.js +2 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -67,22 +67,13 @@ npm install @a2a-js/sdk @modelcontextprotocol/sdk @trpc/server
|
|
|
67
67
|
**Server:**
|
|
68
68
|
|
|
69
69
|
```typescript
|
|
70
|
-
import {
|
|
71
|
-
|
|
72
|
-
const { app } =
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
.createAgent({
|
|
78
|
-
agentCard: "QuickStart Agent",
|
|
79
|
-
}),
|
|
80
|
-
basePath: "/a2a",
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
app.listen(3000, () => {
|
|
84
|
-
console.log("A2A Server running at http://localhost:3000/a2a");
|
|
85
|
-
});
|
|
70
|
+
import { cr8 } from "@artinet/sdk";
|
|
71
|
+
|
|
72
|
+
const { app } = cr8("QuickStart Agent")
|
|
73
|
+
.text(async ({ content }) => {
|
|
74
|
+
return `You said: ${content}`;
|
|
75
|
+
}) //start an a2a server on port 3000
|
|
76
|
+
.server.start(3000);
|
|
86
77
|
```
|
|
87
78
|
|
|
88
79
|
**Client:**
|
package/dist/extensions/otel.js
CHANGED
package/dist/extensions/pino.js
CHANGED
|
@@ -21,6 +21,20 @@ export interface ServerParams {
|
|
|
21
21
|
register?: boolean;
|
|
22
22
|
}
|
|
23
23
|
export declare function rpcParser(req: express.Request, res: express.Response, next: express.NextFunction): void;
|
|
24
|
+
/**
|
|
25
|
+
* @note Best used with the `cr8` builder.
|
|
26
|
+
* @param {ServerParams} params - The server parameters
|
|
27
|
+
* @returns {ExpressAgentServer} - The express agent server
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const { app, agent, start } = createAgentServer({
|
|
31
|
+
* agent: cr8("MyAgent")
|
|
32
|
+
* .text("Hello, world!")
|
|
33
|
+
* .agent,
|
|
34
|
+
* basePath: "/a2a",
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
24
38
|
export declare function createAgentServer({ app, basePath, agentCardPath, agent, corsOptions, extendedAgentCard, register, port, }: ServerParams): {
|
|
25
39
|
app: express.Express;
|
|
26
40
|
agent: Agent;
|
|
@@ -48,6 +48,20 @@ const registerAgent = async (agentCard) => {
|
|
|
48
48
|
logger.debug("registerAgent: not implemented", { agentCard });
|
|
49
49
|
return Promise.resolve(agentCard);
|
|
50
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* @note Best used with the `cr8` builder.
|
|
53
|
+
* @param {ServerParams} params - The server parameters
|
|
54
|
+
* @returns {ExpressAgentServer} - The express agent server
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const { app, agent, start } = createAgentServer({
|
|
58
|
+
* agent: cr8("MyAgent")
|
|
59
|
+
* .text("Hello, world!")
|
|
60
|
+
* .agent,
|
|
61
|
+
* basePath: "/a2a",
|
|
62
|
+
* });
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
51
65
|
export function createAgentServer({ app = express(), basePath = "/", agentCardPath = "/.well-known/agent-card.json", agent, corsOptions, extendedAgentCard, register = false, port, }) {
|
|
52
66
|
const agentInstance = ensureAgent(agent);
|
|
53
67
|
app.use(cors(corsOptions));
|
|
@@ -18,7 +18,7 @@ const updateHistory = (task, updateMessage) => {
|
|
|
18
18
|
export const handleMessageUpdate = async ({ task, update, }) => {
|
|
19
19
|
const validated = await validateSchema(A2A.MessageSchema, update);
|
|
20
20
|
if (validated.taskId && task.id !== validated.taskId) {
|
|
21
|
-
throw new Error(`updateMessage: Invalid task id: ${validated.taskId} ${formatJson({
|
|
21
|
+
throw new Error(`updateMessage: Invalid task id: incoming: ${validated.taskId} expected: ${task.id} ${formatJson({
|
|
22
22
|
cause: {
|
|
23
23
|
validated,
|
|
24
24
|
actual: task.id,
|
|
@@ -32,7 +32,7 @@ export const handleMessageUpdate = async ({ task, update, }) => {
|
|
|
32
32
|
export const handleTaskUpdate = async ({ context, task, update, }) => {
|
|
33
33
|
const validated = await validateSchema(A2A.TaskSchema, update);
|
|
34
34
|
if (task.id !== validated.id) {
|
|
35
|
-
throw new Error(`updateTask: Invalid task id: ${validated.id}`, {
|
|
35
|
+
throw new Error(`updateTask: Invalid task id: incoming: ${validated.id} expected: ${task.id}`, {
|
|
36
36
|
cause: validated,
|
|
37
37
|
});
|
|
38
38
|
}
|
|
@@ -45,7 +45,7 @@ export const handleTaskUpdate = async ({ context, task, update, }) => {
|
|
|
45
45
|
export const handleStatusUpdate = async ({ task, update, }) => {
|
|
46
46
|
const validated = await validateSchema(A2A.TaskStatusUpdateEventSchema, update);
|
|
47
47
|
if (validated.taskId && task.id !== validated.taskId) {
|
|
48
|
-
throw new Error(`updateTaskStatusUpdate: Invalid task id: ${validated.taskId}`, { cause: validated });
|
|
48
|
+
throw new Error(`updateTaskStatusUpdate: Invalid task id: incoming: ${validated.taskId} expected: ${task.id}`, { cause: validated });
|
|
49
49
|
}
|
|
50
50
|
task.status = validated.status;
|
|
51
51
|
task.status.timestamp = getCurrentTimestamp();
|
|
@@ -57,13 +57,11 @@ export const handleStatusUpdate = async ({ task, update, }) => {
|
|
|
57
57
|
export const handleArtifactUpdate = async ({ task, update }) => {
|
|
58
58
|
const validated = await validateSchema(A2A.TaskArtifactUpdateEventSchema, update);
|
|
59
59
|
if (validated.taskId && task.id !== validated.taskId) {
|
|
60
|
-
throw new Error(`updateTaskArtifactUpdate: Invalid task id: ${validated.taskId}`, {
|
|
60
|
+
throw new Error(`updateTaskArtifactUpdate: Invalid task id: incoming: ${validated.taskId} expected: ${task.id}`, {
|
|
61
61
|
cause: validated,
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
validated.taskId = task.id;
|
|
66
|
-
}
|
|
64
|
+
validated.taskId = task.id;
|
|
67
65
|
task.artifacts = upsertArtifact(task.artifacts ?? [], validated);
|
|
68
66
|
return task;
|
|
69
67
|
};
|
|
@@ -31,8 +31,8 @@ const createMessageParams = (task) => {
|
|
|
31
31
|
/**
|
|
32
32
|
* @note Comprehensive Extension system coming in a future release
|
|
33
33
|
*/
|
|
34
|
-
const getExtensions = async (
|
|
35
|
-
logger.warn("getExtensions: not implemented", { extensions });
|
|
34
|
+
const getExtensions = async (_extensions) => {
|
|
35
|
+
// logger.warn("getExtensions: not implemented", { extensions });
|
|
36
36
|
return [];
|
|
37
37
|
};
|
|
38
38
|
/**
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { router, A2AProcedure } from "../../trpc.js";
|
|
6
|
-
import { INVALID_PARAMS
|
|
6
|
+
import { INVALID_PARAMS } from "../../../../../utils/common/errors.js";
|
|
7
|
+
import { zAsyncIterable } from "../../../../../utils/common/zAsyncIterable.js";
|
|
7
8
|
import { A2A } from "../../../../../types/index.js";
|
|
8
9
|
const sendMessageRoute = A2AProcedure.input(A2A.MessageSendParamsSchema)
|
|
9
10
|
.output(A2A.SendMessageSuccessResultSchema)
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
import { z } from "zod/v4";
|
|
6
6
|
import { router, A2AProcedure } from "../../trpc.js";
|
|
7
7
|
import { A2A } from "../../../../../types/index.js";
|
|
8
|
-
import { INVALID_REQUEST, PUSH_NOTIFICATION_NOT_SUPPORTED,
|
|
8
|
+
import { INVALID_REQUEST, PUSH_NOTIFICATION_NOT_SUPPORTED, } from "../../../../../utils/common/errors.js";
|
|
9
|
+
import { zAsyncIterable } from "../../../../../utils/common/zAsyncIterable.js";
|
|
9
10
|
const pushNotificationConfigRouter = router({
|
|
10
11
|
set: A2AProcedure.input(A2A.TaskPushNotificationConfigSchema)
|
|
11
12
|
.output(A2A.TaskPushNotificationConfigSchema)
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -6,6 +6,5 @@ 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.js";
|
|
10
9
|
export * from "./common/parse.js";
|
|
11
10
|
export * from "./storage/file.js";
|
package/dist/utils/index.js
CHANGED
|
@@ -6,6 +6,5 @@ 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.js";
|
|
10
9
|
export * from "./common/parse.js";
|
|
11
10
|
export * from "./storage/file.js";
|
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.3",
|
|
4
4
|
"description": "A TypeScript SDK for building collaborative AI agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
},
|
|
92
92
|
"homepage": "https://github.com/the-artinet-project/artinet-sdk#readme",
|
|
93
93
|
"dependencies": {
|
|
94
|
-
"@artinet/types": "^0.0.9-alpha.
|
|
94
|
+
"@artinet/types": "^0.0.9-alpha.4",
|
|
95
95
|
"cors": "^2.8.5",
|
|
96
96
|
"escape-html": "^1.0.3",
|
|
97
97
|
"eventsource-parser": "^3.0.1",
|