@alvin0/ai-agent-sdk-a2a 0.1.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 +29 -0
- package/dist/cleanup-report-CTjMJ9EU.mjs +146 -0
- package/dist/cleanup-report-CTjMJ9EU.mjs.map +1 -0
- package/dist/client-2bhYYreC.mjs +651 -0
- package/dist/client-2bhYYreC.mjs.map +1 -0
- package/dist/client-DmkHTq-_.d.mts +84 -0
- package/dist/client-DmkHTq-_.d.mts.map +1 -0
- package/dist/client.d.mts +2 -0
- package/dist/client.mjs +3 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +4 -0
- package/dist/server-BX1bnVUG.mjs +577 -0
- package/dist/server-BX1bnVUG.mjs.map +1 -0
- package/dist/server-ejQSEjqI.d.mts +116 -0
- package/dist/server-ejQSEjqI.d.mts.map +1 -0
- package/dist/server.d.mts +2 -0
- package/dist/server.mjs +3 -0
- package/package.json +86 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { A2A_PROTOCOL_VERSION as A2A_PROTOCOL_VERSION$1, AgentCard, AgentCard as AgentCard$1, AgentProvider, Message, Part, Role as Role$1, SecurityRequirement, SecurityScheme, Task, TaskState as TaskState$1 } from "@a2a-js/sdk";
|
|
2
|
+
import { ModelRegistry, SdkLogger, SupportSafeError } from "@alvin0/ai-agent-sdk-core";
|
|
3
|
+
import { AgentEvent as AgentEvent$1, AgentExecutor, AgentExecutor as AgentExecutor$1, DefaultExecutionEventBus, DefaultExecutionEventBusManager, DefaultRequestHandler, DefaultRequestHandler as DefaultRequestHandler$1, ExecutionEventBus, ExecutionEventBus as ExecutionEventBus$1, InMemoryTaskStore as InMemoryTaskStore$1, JsonRpcTransportHandler, RequestContext, RequestContext as RequestContext$1, ServerCallContext, TaskStore, TaskStore as TaskStore$1 } from "@a2a-js/sdk/server";
|
|
4
|
+
import { AgentSession, AgentSessionOptions, DefinedAgent } from "@alvin0/ai-agent-sdk-core/agent";
|
|
5
|
+
//#region src/server/agent-card.d.ts
|
|
6
|
+
interface AgentCardFromDefinitionOptions {
|
|
7
|
+
readonly url: string;
|
|
8
|
+
readonly protocolBinding?: 'JSONRPC' | 'HTTP+JSON' | 'GRPC' | (string & {});
|
|
9
|
+
readonly version?: string;
|
|
10
|
+
readonly provider?: AgentProvider;
|
|
11
|
+
readonly documentationUrl?: string;
|
|
12
|
+
readonly iconUrl?: string;
|
|
13
|
+
readonly tags?: readonly string[];
|
|
14
|
+
readonly examples?: readonly string[];
|
|
15
|
+
readonly securitySchemes?: Readonly<Record<string, SecurityScheme>>;
|
|
16
|
+
readonly securityRequirements?: readonly SecurityRequirement[];
|
|
17
|
+
readonly requireHttps?: boolean;
|
|
18
|
+
}
|
|
19
|
+
declare function createAgentCardFromDefinition(agent: DefinedAgent, options: AgentCardFromDefinitionOptions): AgentCard;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/server.d.ts
|
|
22
|
+
interface DefinedAgentA2AExecutorOptions {
|
|
23
|
+
readonly agent: DefinedAgent;
|
|
24
|
+
readonly logger?: SdkLogger;
|
|
25
|
+
/** Required unless createSession supplies a fully configured session. */
|
|
26
|
+
readonly registry?: ModelRegistry;
|
|
27
|
+
readonly sessionOptions?: Omit<AgentSessionOptions, 'conversationId' | 'registry'>;
|
|
28
|
+
/** Customize session construction for request-specific registries, tools, or policy. */
|
|
29
|
+
readonly createSession?: (context: RequestContext, signal?: AbortSignal) => AgentSession | Promise<AgentSession>;
|
|
30
|
+
/** Opt-in host policy: reject calls without an authenticated A2A principal. */
|
|
31
|
+
readonly requireAuthenticated?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Map a request to the host's ownership boundary (user, device, workspace,
|
|
34
|
+
* API client, etc.). Defaults to the authenticated A2A principal.
|
|
35
|
+
*/
|
|
36
|
+
readonly sessionOwner?: (context: RequestContext, signal?: AbortSignal) => string | Promise<string>;
|
|
37
|
+
/** Maximum retained context sessions. Defaults to 1,000. */
|
|
38
|
+
readonly maxSessions?: number;
|
|
39
|
+
/** Maximum tasks executing or queued across the executor. Defaults to 1,000. */
|
|
40
|
+
readonly maxRunningTasks?: number;
|
|
41
|
+
/** Maximum tasks executing or queued against one retained session. Defaults to 16. */
|
|
42
|
+
readonly maxTasksPerSession?: number;
|
|
43
|
+
/** Idle session retention. Defaults to 30 minutes. */
|
|
44
|
+
readonly sessionTtlMs?: number;
|
|
45
|
+
/** Maximum serialized inbound A2A message size. Defaults to 1 MiB. */
|
|
46
|
+
readonly maxInputBytes?: number;
|
|
47
|
+
/** Maximum UTF-8 response size published to A2A. Defaults to 1 MiB. */
|
|
48
|
+
readonly maxOutputBytes?: number;
|
|
49
|
+
/** Maximum time dispose waits for cooperative providers. Defaults to 30 seconds. */
|
|
50
|
+
readonly disposeTimeoutMs?: number;
|
|
51
|
+
/** End-to-end bound for session creation, queueing, and agent execution. Defaults to 10 minutes. */
|
|
52
|
+
readonly taskTimeoutMs?: number;
|
|
53
|
+
/** Maximum wait for the private error observer. Defaults to 5 seconds. */
|
|
54
|
+
readonly observerTimeoutMs?: number;
|
|
55
|
+
/** Return raw internal error text to callers. Unsafe and disabled by default. */
|
|
56
|
+
readonly exposeInternalErrors?: boolean;
|
|
57
|
+
/** Receives the original error for private logging/telemetry. */
|
|
58
|
+
readonly onError?: (error: unknown, context: RequestContext) => void | Promise<void>;
|
|
59
|
+
}
|
|
60
|
+
interface A2ADisposeReport {
|
|
61
|
+
readonly status: 'disposed' | 'failed' | 'timed-out';
|
|
62
|
+
readonly alreadyDisposed: boolean;
|
|
63
|
+
readonly error?: SupportSafeError;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Adapt a provider-neutral DefinedAgent to the official A2A AgentExecutor contract.
|
|
67
|
+
* Sessions are retained by A2A contextId, so protocol follow-ups preserve history.
|
|
68
|
+
*/
|
|
69
|
+
declare class DefinedAgentA2AExecutor implements AgentExecutor {
|
|
70
|
+
private readonly options;
|
|
71
|
+
private readonly sessions;
|
|
72
|
+
private readonly running;
|
|
73
|
+
private readonly maxSessions;
|
|
74
|
+
private readonly maxRunningTasks;
|
|
75
|
+
private readonly maxTasksPerSession;
|
|
76
|
+
private readonly sessionTtlMs;
|
|
77
|
+
private readonly maxInputBytes;
|
|
78
|
+
private readonly maxOutputBytes;
|
|
79
|
+
private readonly disposeTimeoutMs;
|
|
80
|
+
private readonly taskTimeoutMs;
|
|
81
|
+
private readonly observerTimeoutMs;
|
|
82
|
+
private disposed;
|
|
83
|
+
private disposeTask;
|
|
84
|
+
private disposeReport;
|
|
85
|
+
constructor(options: DefinedAgentA2AExecutorOptions);
|
|
86
|
+
execute(context: RequestContext, eventBus: ExecutionEventBus): Promise<void>;
|
|
87
|
+
cancelTask(taskId: string, eventBus: ExecutionEventBus): Promise<void>;
|
|
88
|
+
/** Cancel active work and permanently release retained context sessions. */
|
|
89
|
+
dispose(reason?: unknown): Promise<void>;
|
|
90
|
+
/** Return bounded support evidence while retaining dispose() compatibility. */
|
|
91
|
+
disposeWithReport(reason?: unknown): Promise<A2ADisposeReport>;
|
|
92
|
+
private acquireContextSession;
|
|
93
|
+
private releaseContextSession;
|
|
94
|
+
private pruneSessions;
|
|
95
|
+
private resolveSessionKey;
|
|
96
|
+
private assertAccess;
|
|
97
|
+
private assertInputBudget;
|
|
98
|
+
private publishFailure;
|
|
99
|
+
private reportError;
|
|
100
|
+
private createContextSession;
|
|
101
|
+
}
|
|
102
|
+
interface DefinedAgentA2AServerOptions extends DefinedAgentA2AExecutorOptions {
|
|
103
|
+
readonly agentCard: AgentCard;
|
|
104
|
+
readonly taskStore?: TaskStore;
|
|
105
|
+
}
|
|
106
|
+
interface DefinedAgentA2AServer {
|
|
107
|
+
readonly agentCard: AgentCard;
|
|
108
|
+
readonly executor: DefinedAgentA2AExecutor;
|
|
109
|
+
readonly taskStore: TaskStore;
|
|
110
|
+
readonly requestHandler: DefaultRequestHandler;
|
|
111
|
+
}
|
|
112
|
+
/** Assemble the transport-neutral official A2A server components. */
|
|
113
|
+
declare function createDefinedAgentA2AServer(options: DefinedAgentA2AServerOptions): DefinedAgentA2AServer;
|
|
114
|
+
//#endregion
|
|
115
|
+
export { TaskStore$1 as C, createAgentCardFromDefinition as E, TaskState$1 as S, AgentCardFromDefinitionOptions as T, Part as _, AgentExecutor$1 as a, ServerCallContext as b, DefaultRequestHandler$1 as c, DefinedAgentA2AServer as d, DefinedAgentA2AServerOptions as f, Message as g, JsonRpcTransportHandler as h, AgentEvent$1 as i, DefinedAgentA2AExecutor as l, InMemoryTaskStore$1 as m, A2A_PROTOCOL_VERSION$1 as n, DefaultExecutionEventBus as o, ExecutionEventBus$1 as p, AgentCard$1 as r, DefaultExecutionEventBusManager as s, A2ADisposeReport as t, DefinedAgentA2AExecutorOptions as u, RequestContext$1 as v, createDefinedAgentA2AServer as w, Task as x, Role$1 as y };
|
|
116
|
+
//# sourceMappingURL=server-ejQSEjqI.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-ejQSEjqI.d.mts","names":[],"sources":["../src/server/agent-card.ts","../src/server.ts"],"mappings":";;;;;UAIiB;WACN;WACA;WACA;WACA,WAAW;WACX;WACA;WACA;WACA;WACA,kBAAkB,SAAS,eAAe;WAC1C,gCAAgC;WAChC;;iBAGK,8BACd,OAAO,cACP,SAAS,iCACR;;;UCec;WACN,OAAO;WACP,SAAS;;WAET,WAAW;WACX,iBAAiB,KAAK;;WAEtB,iBACP,SAAS,gBACT,SAAS,gBACN,eAAe,QAAQ;;WAEnB;;;;;WAKA,gBAAgB,SAAS,gBAAgB,SAAS,yBAAyB;;WAE3E;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA,WAAW,gBAAgB,SAAS,0BAA0B;;UAGxD;WACN;WACA;WACA,QAAQ;;;;;;cAyBN,mCAAmC;mBAC7B;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;UACT;UACA;UACA;EAER,YAAY,SAAS;EAqBf,QAAQ,SAAS,gBAAgB,UAAU,oBAAoB;EA0I/D,WAAW,gBAAgB,UAAU,oBAAoB;;EAuBzD,QAAQ,mBAAuD;;EAsC/D,kBAAkB,mBAAmB,QAAQ;UAarC;UAmCN;UASA;UAMM;UAWN;UAOA;UAMA;UAgBM;UAMA;;UAiBC,qCAAqC;WAC3C,WAAW;WACX,YAAY;;UAGN;WACN,WAAW;WACX,UAAU;WACV,WAAW;WACX,gBAAgB;;;iBAIX,4BACd,SAAS,+BACR"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { C as TaskStore, E as createAgentCardFromDefinition, S as TaskState, T as AgentCardFromDefinitionOptions, _ as Part, a as AgentExecutor, b as ServerCallContext, c as DefaultRequestHandler, d as DefinedAgentA2AServer, f as DefinedAgentA2AServerOptions, g as Message, h as JsonRpcTransportHandler, i as AgentEvent, l as DefinedAgentA2AExecutor, m as InMemoryTaskStore, n as A2A_PROTOCOL_VERSION, o as DefaultExecutionEventBus, p as ExecutionEventBus, r as AgentCard, s as DefaultExecutionEventBusManager, t as A2ADisposeReport, u as DefinedAgentA2AExecutorOptions, v as RequestContext, w as createDefinedAgentA2AServer, x as Task, y as Role } from "./server-ejQSEjqI.mjs";
|
|
2
|
+
export { A2ADisposeReport, A2A_PROTOCOL_VERSION, type AgentCard, type AgentCardFromDefinitionOptions, AgentEvent, type AgentExecutor, DefaultExecutionEventBus, DefaultExecutionEventBusManager, DefaultRequestHandler, DefinedAgentA2AExecutor, DefinedAgentA2AExecutorOptions, DefinedAgentA2AServer, DefinedAgentA2AServerOptions, type ExecutionEventBus, InMemoryTaskStore, JsonRpcTransportHandler, type Message, type Part, type RequestContext, Role, ServerCallContext, type Task, TaskState, type TaskStore, createAgentCardFromDefinition, createDefinedAgentA2AServer };
|
package/dist/server.mjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as DefaultRequestHandler, c as JsonRpcTransportHandler, d as TaskState, f as createDefinedAgentA2AServer, i as DefaultExecutionEventBusManager, l as Role, n as AgentEvent, o as DefinedAgentA2AExecutor, p as createAgentCardFromDefinition, r as DefaultExecutionEventBus, s as InMemoryTaskStore, t as A2A_PROTOCOL_VERSION, u as ServerCallContext } from "./server-BX1bnVUG.mjs";
|
|
2
|
+
|
|
3
|
+
export { A2A_PROTOCOL_VERSION, AgentEvent, DefaultExecutionEventBus, DefaultExecutionEventBusManager, DefaultRequestHandler, DefinedAgentA2AExecutor, InMemoryTaskStore, JsonRpcTransportHandler, Role, ServerCallContext, TaskState, createAgentCardFromDefinition, createDefinedAgentA2AServer };
|
package/package.json
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alvin0/ai-agent-sdk-a2a",
|
|
3
|
+
"author": {
|
|
4
|
+
"name": "alvin0 - chaulamdinhai",
|
|
5
|
+
"email": "chaulamdinhai@gmail.com"
|
|
6
|
+
},
|
|
7
|
+
"version": "0.1.0",
|
|
8
|
+
"description": "Node-elevated official A2A client/server bridge for ai-agent-sdk",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/alvin0/ai-agent-sdk.git",
|
|
13
|
+
"directory": "packages/a2a"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/alvin0/ai-agent-sdk/tree/main/packages/a2a#readme",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/alvin0/ai-agent-sdk/issues"
|
|
18
|
+
},
|
|
19
|
+
"type": "module",
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md",
|
|
24
|
+
"LICENSE"
|
|
25
|
+
],
|
|
26
|
+
"main": "./dist/index.mjs",
|
|
27
|
+
"types": "./dist/index.d.mts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.mts",
|
|
31
|
+
"import": "./dist/index.mjs",
|
|
32
|
+
"default": "./dist/index.mjs"
|
|
33
|
+
},
|
|
34
|
+
"./client": {
|
|
35
|
+
"types": "./dist/client.d.mts",
|
|
36
|
+
"import": "./dist/client.mjs",
|
|
37
|
+
"default": "./dist/client.mjs"
|
|
38
|
+
},
|
|
39
|
+
"./server": {
|
|
40
|
+
"types": "./dist/server.d.mts",
|
|
41
|
+
"import": "./dist/server.mjs",
|
|
42
|
+
"default": "./dist/server.mjs"
|
|
43
|
+
},
|
|
44
|
+
"./package.json": "./package.json"
|
|
45
|
+
},
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public",
|
|
48
|
+
"provenance": true
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@a2a-js/sdk": "1.1.0"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"@alvin0/ai-agent-sdk-core": "^0.1.0"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@alvin0/ai-agent-sdk-core": "^0.1.0",
|
|
58
|
+
"@arethetypeswrong/cli": "0.18.5",
|
|
59
|
+
"@types/node": "26.4.0",
|
|
60
|
+
"publint": "0.3.24",
|
|
61
|
+
"tsdown": "0.22.14",
|
|
62
|
+
"typescript": "7.0.2",
|
|
63
|
+
"vitest": "4.1.11",
|
|
64
|
+
"wrangler": "4.127.1"
|
|
65
|
+
},
|
|
66
|
+
"engines": {
|
|
67
|
+
"node": ">=22.12"
|
|
68
|
+
},
|
|
69
|
+
"aiAgentSdk": {
|
|
70
|
+
"runtime": "node",
|
|
71
|
+
"coreApi": 1,
|
|
72
|
+
"roles": [
|
|
73
|
+
"agent-transport"
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
"scripts": {
|
|
77
|
+
"build": "tsdown",
|
|
78
|
+
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true});require('node:fs').rmSync('artifacts',{recursive:true,force:true})\"",
|
|
79
|
+
"typecheck": "tsc --noEmit",
|
|
80
|
+
"test": "vitest run --config vitest.config.ts",
|
|
81
|
+
"pack": "pnpm pack --pack-destination artifacts",
|
|
82
|
+
"test:pack": "node scripts/test-packed.mts",
|
|
83
|
+
"check:publint": "publint",
|
|
84
|
+
"check:types": "attw --profile esm-only --pack ."
|
|
85
|
+
}
|
|
86
|
+
}
|