@ap3x/a2a 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +27 -0
- package/dist/backend.d.ts +89 -0
- package/dist/backend.d.ts.map +1 -0
- package/dist/bindings/grpc.d.ts +121 -0
- package/dist/bindings/grpc.d.ts.map +1 -0
- package/dist/bindings/jsonrpc.d.ts +135 -0
- package/dist/bindings/jsonrpc.d.ts.map +1 -0
- package/dist/bindings/rest.d.ts +75 -0
- package/dist/bindings/rest.d.ts.map +1 -0
- package/dist/chunk-PYM7LV6R.js +1590 -0
- package/dist/client.d.ts +116 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/executor.d.ts +91 -0
- package/dist/executor.d.ts.map +1 -0
- package/dist/grpc-5DAU6EYQ.js +591 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +454 -0
- package/dist/model.d.ts +480 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/server.d.ts +60 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/task-store.d.ts +61 -0
- package/dist/task-store.d.ts.map +1 -0
- package/package.json +26 -15
- package/proto/a2a.proto +813 -0
- package/proto/google/api/annotations.proto +6 -0
- package/proto/google/api/client.proto +4 -0
- package/proto/google/api/field_behavior.proto +4 -0
- package/src/__tests__/a2a-auth-expired.test.ts +0 -84
- package/src/__tests__/a2a.test.ts +0 -87
- package/src/__tests__/handler-sendsubscribe-error.test.ts +0 -32
- package/src/__tests__/sendsubscribe-rejected-promise.test.ts +0 -89
- package/src/__tests__/server-apikey-warning.test.ts +0 -71
- package/src/__tests__/server-body-limit.test.ts +0 -54
- package/src/__tests__/server-security-headers.test.ts +0 -112
- package/src/__tests__/server-timing-safe-auth.test.ts +0 -45
- package/src/__tests__/sse-handler-error-propagation.test.ts +0 -69
- package/src/card/generator.ts +0 -18
- package/src/client/index.ts +0 -172
- package/src/errors.ts +0 -21
- package/src/index.ts +0 -15
- package/src/server/handler.ts +0 -90
- package/src/server/index.ts +0 -208
- package/src/server/sse.ts +0 -49
- package/src/swarm/a2a-agent.ts +0 -34
- package/src/types.ts +0 -50
- package/tsconfig.json +0 -20
- package/vitest.config.ts +0 -4
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type Message, type Task, type TaskState, type TaskStatusUpdateEvent } from "./model";
|
|
2
|
+
/** Thrown when an operation references a task id the store does not hold. */
|
|
3
|
+
export declare class TaskNotFoundError extends Error {
|
|
4
|
+
readonly taskId: string;
|
|
5
|
+
constructor(taskId: string);
|
|
6
|
+
}
|
|
7
|
+
/** Thrown when a transition would leave a terminal state. */
|
|
8
|
+
export declare class IllegalTaskTransitionError extends Error {
|
|
9
|
+
readonly taskId: string;
|
|
10
|
+
readonly from: TaskState;
|
|
11
|
+
readonly to: TaskState;
|
|
12
|
+
constructor(taskId: string, from: TaskState, to: TaskState);
|
|
13
|
+
}
|
|
14
|
+
export type TaskSubscriber = (event: TaskStatusUpdateEvent) => void;
|
|
15
|
+
export interface TaskStoreOptions {
|
|
16
|
+
/** Injected clock (epoch millis) — status timestamps derive from it. */
|
|
17
|
+
now: () => number;
|
|
18
|
+
/**
|
|
19
|
+
* Retain at most this many TERMINAL tasks: each terminal transition evicts
|
|
20
|
+
* the oldest terminal tasks beyond the cap (in-flight tasks are never
|
|
21
|
+
* evicted). Default: unbounded — long-lived servers should set it.
|
|
22
|
+
*/
|
|
23
|
+
maxRetainedTasks?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface CreateTaskOptions {
|
|
26
|
+
/** Multi-turn thread id; generated when omitted. */
|
|
27
|
+
contextId?: string;
|
|
28
|
+
/** Initial message history (e.g. the message that created the task). */
|
|
29
|
+
history?: Message[];
|
|
30
|
+
}
|
|
31
|
+
export interface ListTasksFilter {
|
|
32
|
+
contextId?: string;
|
|
33
|
+
state?: TaskState;
|
|
34
|
+
}
|
|
35
|
+
export declare class TaskStore {
|
|
36
|
+
private readonly now;
|
|
37
|
+
private readonly maxRetainedTasks?;
|
|
38
|
+
private readonly tasks;
|
|
39
|
+
private readonly subscribers;
|
|
40
|
+
constructor(options: TaskStoreOptions);
|
|
41
|
+
/** Create a task in the `submitted` state. */
|
|
42
|
+
create(options?: CreateTaskOptions): Task;
|
|
43
|
+
get(id: string): Task | undefined;
|
|
44
|
+
list(filter?: ListTasksFilter): Task[];
|
|
45
|
+
/**
|
|
46
|
+
* Transition a task to `state`, notify its subscribers, and — when the new
|
|
47
|
+
* state is terminal — clear those subscribers. Leaving a terminal state
|
|
48
|
+
* throws {@link IllegalTaskTransitionError}.
|
|
49
|
+
*/
|
|
50
|
+
updateState(id: string, state: TaskState, message?: Message): Task;
|
|
51
|
+
/** Drop the oldest TERMINAL tasks beyond `maxRetainedTasks` (no-op when unset). */
|
|
52
|
+
private evictBeyondRetention;
|
|
53
|
+
/** Cancel a task (illegal from a terminal state, like any other exit). */
|
|
54
|
+
cancel(id: string): Task;
|
|
55
|
+
/** Subscribe to a task's status updates; returns an unsubscribe function. */
|
|
56
|
+
subscribe(taskId: string, fn: TaskSubscriber): () => void;
|
|
57
|
+
/** Live subscriber count for a task (0 after a terminal transition). */
|
|
58
|
+
subscriberCount(taskId: string): number;
|
|
59
|
+
private timestamp;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=task-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-store.d.ts","sourceRoot":"","sources":["../src/task-store.ts"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,IAAI,EACT,KAAK,SAAS,EACd,KAAK,qBAAqB,EAE3B,MAAM,SAAS,CAAC;AAEjB,6EAA6E;AAC7E,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM;CAK3B;AAED,6DAA6D;AAC7D,qBAAa,0BAA2B,SAAQ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AO,CAAC,oBAAoB;IAe5B,0EAA0E;IAC1E,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAIxB,6EAA6E;IAC7E,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,cAAc,GAAG,MAAM,IAAI;IAczD,wEAAwE;IACxE,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAIvC,OAAO,CAAC,SAAS;CAGlB"}
|
package/package.json
CHANGED
|
@@ -1,27 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ap3x/a2a",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "A2A protocol client, server, and swarm integration
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Agent-to-agent (A2A) protocol client, server, and swarm integration",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/AP3X-Dev/AP3X.git",
|
|
8
|
+
"directory": "packages/a2a"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
5
14
|
"type": "module",
|
|
6
15
|
"main": "./dist/index.js",
|
|
7
16
|
"types": "./dist/index.d.ts",
|
|
8
17
|
"exports": {
|
|
9
18
|
".": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"default": "./dist/index.js"
|
|
12
21
|
}
|
|
13
22
|
},
|
|
14
|
-
"
|
|
15
|
-
|
|
23
|
+
"files": ["dist", "proto"],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup src/index.ts --format esm --clean --tsconfig tsconfig.build.json && tsc -p tsconfig.build.json",
|
|
26
|
+
"prepublishOnly": "node ../../scripts/publish-gate.mjs",
|
|
27
|
+
"test": "vitest run"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@ap3x/agent-core": "0.1.0",
|
|
31
|
+
"@grpc/grpc-js": "^1.13.4",
|
|
32
|
+
"@grpc/proto-loader": "^0.8.0",
|
|
33
|
+
"@sinclair/typebox": "^0.34.49"
|
|
16
34
|
},
|
|
17
35
|
"devDependencies": {
|
|
18
|
-
"
|
|
19
|
-
"vitest": "^2.0.0",
|
|
20
|
-
"@ap3x/core": "1.0.0"
|
|
21
|
-
},
|
|
22
|
-
"scripts": {
|
|
23
|
-
"build": "tsc",
|
|
24
|
-
"test": "vitest run",
|
|
25
|
-
"typecheck": "tsc --noEmit"
|
|
36
|
+
"@a2a-js/sdk": "0.3.13"
|
|
26
37
|
}
|
|
27
|
-
}
|
|
38
|
+
}
|