@runtypelabs/a2a-aisdk-example 0.0.1 → 0.2.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/LICENSE +21 -0
- package/README.md +357 -0
- package/dist/chunk-OLB7ZZNY.js +1153 -0
- package/dist/chunk-OLB7ZZNY.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +215 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +333 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/vercel/index.d.ts +145 -0
- package/dist/vercel/index.js +926 -0
- package/dist/vercel/index.js.map +1 -0
- package/package.json +83 -4
- package/index.js +0 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { Application } from 'express';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A2A Protocol Types
|
|
5
|
+
*
|
|
6
|
+
* Based on A2A Protocol v0.3
|
|
7
|
+
* https://a2aproject.github.io/A2A/specification/
|
|
8
|
+
*/
|
|
9
|
+
interface AgentCard {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
url: string;
|
|
13
|
+
version: string;
|
|
14
|
+
protocolVersion: string;
|
|
15
|
+
defaultInputModes: Array<'text' | 'file' | 'data'>;
|
|
16
|
+
defaultOutputModes: Array<'text' | 'file' | 'data'>;
|
|
17
|
+
iconUrl?: string;
|
|
18
|
+
provider?: {
|
|
19
|
+
organization: string;
|
|
20
|
+
url?: string;
|
|
21
|
+
};
|
|
22
|
+
capabilities: {
|
|
23
|
+
streaming: boolean;
|
|
24
|
+
pushNotifications: boolean;
|
|
25
|
+
statefulness: 'none' | 'session' | 'task';
|
|
26
|
+
};
|
|
27
|
+
skills: Skill[];
|
|
28
|
+
authentication?: {
|
|
29
|
+
type: 'none' | 'bearer' | 'api_key';
|
|
30
|
+
bearerAuth?: {
|
|
31
|
+
scopes: string[];
|
|
32
|
+
};
|
|
33
|
+
apiKeyAuth?: {
|
|
34
|
+
headerName: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
interface Skill {
|
|
39
|
+
id: string;
|
|
40
|
+
name: string;
|
|
41
|
+
description: string;
|
|
42
|
+
inputModes: Array<'text' | 'file' | 'data'>;
|
|
43
|
+
outputModes: Array<'text' | 'file' | 'data'>;
|
|
44
|
+
tags: string[];
|
|
45
|
+
inputSchema?: Record<string, unknown>;
|
|
46
|
+
}
|
|
47
|
+
interface JsonRpcRequest {
|
|
48
|
+
jsonrpc: '2.0';
|
|
49
|
+
id?: string | number;
|
|
50
|
+
method: string;
|
|
51
|
+
params?: unknown;
|
|
52
|
+
}
|
|
53
|
+
interface JsonRpcResponse {
|
|
54
|
+
jsonrpc: '2.0';
|
|
55
|
+
id?: string | number;
|
|
56
|
+
result?: unknown;
|
|
57
|
+
error?: JsonRpcError;
|
|
58
|
+
}
|
|
59
|
+
interface JsonRpcError {
|
|
60
|
+
code: number;
|
|
61
|
+
message: string;
|
|
62
|
+
data?: unknown;
|
|
63
|
+
}
|
|
64
|
+
declare const JSON_RPC_ERRORS: {
|
|
65
|
+
readonly PARSE_ERROR: -32700;
|
|
66
|
+
readonly INVALID_REQUEST: -32600;
|
|
67
|
+
readonly METHOD_NOT_FOUND: -32601;
|
|
68
|
+
readonly INVALID_PARAMS: -32602;
|
|
69
|
+
readonly INTERNAL_ERROR: -32603;
|
|
70
|
+
readonly TASK_NOT_FOUND: -32001;
|
|
71
|
+
readonly SKILL_NOT_FOUND: -32002;
|
|
72
|
+
readonly UNAUTHORIZED: -32003;
|
|
73
|
+
readonly RATE_LIMITED: -32004;
|
|
74
|
+
readonly TASK_CANCELED: -32005;
|
|
75
|
+
};
|
|
76
|
+
interface MessagePart {
|
|
77
|
+
type: 'text' | 'file' | 'data';
|
|
78
|
+
text?: string;
|
|
79
|
+
data?: unknown;
|
|
80
|
+
mimeType?: string;
|
|
81
|
+
uri?: string;
|
|
82
|
+
}
|
|
83
|
+
interface A2AMessage {
|
|
84
|
+
role: 'user' | 'agent';
|
|
85
|
+
parts: MessagePart[];
|
|
86
|
+
}
|
|
87
|
+
type TaskStatus = 'submitted' | 'working' | 'completed' | 'failed' | 'canceled';
|
|
88
|
+
interface Task {
|
|
89
|
+
id: string;
|
|
90
|
+
contextId?: string;
|
|
91
|
+
status: TaskStatus;
|
|
92
|
+
artifacts?: Artifact[];
|
|
93
|
+
error?: {
|
|
94
|
+
message: string;
|
|
95
|
+
};
|
|
96
|
+
metadata?: Record<string, unknown>;
|
|
97
|
+
}
|
|
98
|
+
interface Artifact {
|
|
99
|
+
name: string;
|
|
100
|
+
parts: MessagePart[];
|
|
101
|
+
index?: number;
|
|
102
|
+
append?: boolean;
|
|
103
|
+
lastChunk?: boolean;
|
|
104
|
+
}
|
|
105
|
+
interface TaskHistoryEntry {
|
|
106
|
+
status: TaskStatus;
|
|
107
|
+
message: string;
|
|
108
|
+
timestamp: string;
|
|
109
|
+
}
|
|
110
|
+
interface TasksSendParams {
|
|
111
|
+
skill: string;
|
|
112
|
+
message: A2AMessage;
|
|
113
|
+
contextId?: string;
|
|
114
|
+
pushNotification?: {
|
|
115
|
+
url: string;
|
|
116
|
+
authentication?: {
|
|
117
|
+
type: 'bearer' | 'api_key';
|
|
118
|
+
token?: string;
|
|
119
|
+
headerName?: string;
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
metadata?: Record<string, unknown>;
|
|
123
|
+
}
|
|
124
|
+
interface TasksGetParams {
|
|
125
|
+
taskId: string;
|
|
126
|
+
includeHistory?: boolean;
|
|
127
|
+
}
|
|
128
|
+
interface TasksCancelParams {
|
|
129
|
+
taskId: string;
|
|
130
|
+
reason?: string;
|
|
131
|
+
}
|
|
132
|
+
interface TaskStatusEvent {
|
|
133
|
+
taskId: string;
|
|
134
|
+
contextId?: string;
|
|
135
|
+
status: TaskStatus;
|
|
136
|
+
message?: string;
|
|
137
|
+
final?: boolean;
|
|
138
|
+
}
|
|
139
|
+
interface TaskArtifactEvent {
|
|
140
|
+
taskId: string;
|
|
141
|
+
artifact: Artifact;
|
|
142
|
+
}
|
|
143
|
+
interface TaskErrorEvent {
|
|
144
|
+
taskId: string;
|
|
145
|
+
error: {
|
|
146
|
+
code: number;
|
|
147
|
+
message: string;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
interface AgentConfig {
|
|
151
|
+
name: string;
|
|
152
|
+
description?: string;
|
|
153
|
+
version?: string;
|
|
154
|
+
port?: number;
|
|
155
|
+
host?: string;
|
|
156
|
+
provider?: {
|
|
157
|
+
organization: string;
|
|
158
|
+
url?: string;
|
|
159
|
+
};
|
|
160
|
+
skills?: SkillConfig[];
|
|
161
|
+
defaultInputModes?: Array<'text' | 'file' | 'data'>;
|
|
162
|
+
defaultOutputModes?: Array<'text' | 'file' | 'data'>;
|
|
163
|
+
llm?: LLMConfig;
|
|
164
|
+
}
|
|
165
|
+
interface SkillConfig {
|
|
166
|
+
id: string;
|
|
167
|
+
name: string;
|
|
168
|
+
description: string;
|
|
169
|
+
systemPrompt?: string;
|
|
170
|
+
inputSchema?: Record<string, unknown>;
|
|
171
|
+
tags?: string[];
|
|
172
|
+
}
|
|
173
|
+
interface LLMConfig {
|
|
174
|
+
provider: 'openai' | 'anthropic';
|
|
175
|
+
model: string;
|
|
176
|
+
/** Gateway model string (e.g. openai/gpt-5-nano) when using Vercel AI Gateway */
|
|
177
|
+
gatewayModel?: string;
|
|
178
|
+
apiKey?: string;
|
|
179
|
+
temperature?: number;
|
|
180
|
+
maxOutputTokens?: number;
|
|
181
|
+
}
|
|
182
|
+
interface ExecutorContext {
|
|
183
|
+
taskId: string;
|
|
184
|
+
contextId?: string;
|
|
185
|
+
skill: SkillConfig;
|
|
186
|
+
message: A2AMessage;
|
|
187
|
+
metadata?: Record<string, unknown>;
|
|
188
|
+
}
|
|
189
|
+
interface ExecutorResult {
|
|
190
|
+
text: string;
|
|
191
|
+
artifacts?: Artifact[];
|
|
192
|
+
}
|
|
193
|
+
interface StreamCallbacks {
|
|
194
|
+
onChunk: (text: string) => Promise<void>;
|
|
195
|
+
onComplete: () => Promise<void>;
|
|
196
|
+
onError: (error: Error) => Promise<void>;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* A2A Protocol Server
|
|
201
|
+
*
|
|
202
|
+
* Express server implementing the A2A (Agent-to-Agent) protocol.
|
|
203
|
+
* Provides agent card discovery and JSON-RPC task execution endpoints.
|
|
204
|
+
*/
|
|
205
|
+
|
|
206
|
+
interface A2AServerOptions {
|
|
207
|
+
config: AgentConfig;
|
|
208
|
+
llmConfig?: LLMConfig;
|
|
209
|
+
echoMode?: boolean;
|
|
210
|
+
}
|
|
211
|
+
interface A2AServer {
|
|
212
|
+
app: Application;
|
|
213
|
+
start: () => Promise<void>;
|
|
214
|
+
stop: () => Promise<void>;
|
|
215
|
+
}
|
|
216
|
+
declare function createA2AServer(options: A2AServerOptions): A2AServer;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* A2A Client
|
|
220
|
+
*
|
|
221
|
+
* Client for testing A2A protocol endpoints, including Runtype's A2A surfaces.
|
|
222
|
+
*/
|
|
223
|
+
|
|
224
|
+
interface A2AClientOptions {
|
|
225
|
+
/** Base URL of the A2A endpoint (with or without /a2a suffix) */
|
|
226
|
+
baseUrl: string;
|
|
227
|
+
/** API key for authentication (optional) */
|
|
228
|
+
apiKey?: string;
|
|
229
|
+
/** Custom headers to include in requests */
|
|
230
|
+
headers?: Record<string, string>;
|
|
231
|
+
}
|
|
232
|
+
declare class A2AClient {
|
|
233
|
+
private baseUrl;
|
|
234
|
+
private rpcUrl;
|
|
235
|
+
private agentCardUrl;
|
|
236
|
+
private apiKey?;
|
|
237
|
+
private headers;
|
|
238
|
+
constructor(options: A2AClientOptions);
|
|
239
|
+
/**
|
|
240
|
+
* Get the agent card for discovery
|
|
241
|
+
*/
|
|
242
|
+
getAgentCard(): Promise<AgentCard>;
|
|
243
|
+
/**
|
|
244
|
+
* Send a task and wait for completion (synchronous)
|
|
245
|
+
*/
|
|
246
|
+
sendTask(params: TasksSendParams): Promise<Task>;
|
|
247
|
+
/**
|
|
248
|
+
* Send a task with streaming (SSE)
|
|
249
|
+
*/
|
|
250
|
+
sendTaskStreaming(params: TasksSendParams, callbacks: {
|
|
251
|
+
onStatus?: (status: string, data: TaskStatusEvent) => void;
|
|
252
|
+
onArtifact?: (artifact: Artifact) => void;
|
|
253
|
+
onError?: (error: JsonRpcError) => void;
|
|
254
|
+
onChunk?: (text: string) => void;
|
|
255
|
+
}): Promise<void>;
|
|
256
|
+
/**
|
|
257
|
+
* Get task status
|
|
258
|
+
*/
|
|
259
|
+
getTask(taskId: string, includeHistory?: boolean): Promise<Task>;
|
|
260
|
+
/**
|
|
261
|
+
* Cancel a task
|
|
262
|
+
*/
|
|
263
|
+
cancelTask(taskId: string, reason?: string): Promise<Task>;
|
|
264
|
+
/**
|
|
265
|
+
* Send a JSON-RPC request
|
|
266
|
+
*/
|
|
267
|
+
private sendJsonRpc;
|
|
268
|
+
/**
|
|
269
|
+
* Get headers for requests
|
|
270
|
+
*/
|
|
271
|
+
private getHeaders;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Create a client for testing a Runtype A2A surface
|
|
275
|
+
*/
|
|
276
|
+
declare function createRuntypeA2AClient(options: {
|
|
277
|
+
productId: string;
|
|
278
|
+
surfaceId: string;
|
|
279
|
+
apiKey: string;
|
|
280
|
+
environment?: 'production' | 'staging' | 'local';
|
|
281
|
+
}): A2AClient;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Agent Executor
|
|
285
|
+
*
|
|
286
|
+
* Executes tasks using the Vercel AI SDK for LLM integration.
|
|
287
|
+
* Supports both streaming and non-streaming responses.
|
|
288
|
+
*/
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Execute a task without streaming
|
|
292
|
+
*/
|
|
293
|
+
declare function executeTask(context: ExecutorContext, llmConfig: LLMConfig, skillsCatalog?: SkillConfig[]): Promise<ExecutorResult>;
|
|
294
|
+
/**
|
|
295
|
+
* Execute a task with streaming
|
|
296
|
+
*/
|
|
297
|
+
declare function executeTaskStreaming(context: ExecutorContext, llmConfig: LLMConfig, callbacks: StreamCallbacks, skillsCatalog?: SkillConfig[]): Promise<void>;
|
|
298
|
+
/**
|
|
299
|
+
* Simple executor for testing (no LLM, just echoes)
|
|
300
|
+
*/
|
|
301
|
+
declare function executeEcho(context: ExecutorContext): Promise<ExecutorResult>;
|
|
302
|
+
/**
|
|
303
|
+
* Simple streaming executor for testing
|
|
304
|
+
*/
|
|
305
|
+
declare function executeEchoStreaming(context: ExecutorContext, callbacks: StreamCallbacks): Promise<void>;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Deterministic Time Executor
|
|
309
|
+
*
|
|
310
|
+
* Computes temporal data using date-fns and the system clock.
|
|
311
|
+
* No LLM generation — all results are deterministic.
|
|
312
|
+
*/
|
|
313
|
+
|
|
314
|
+
declare function executeTimeSkill(context: ExecutorContext): Promise<ExecutorResult>;
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Default Skills Configuration
|
|
318
|
+
*
|
|
319
|
+
* Shared skill definitions for A2A agents. Import these in your agent
|
|
320
|
+
* configuration to avoid duplication across different deployment targets.
|
|
321
|
+
*/
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Default skills available to A2A agents.
|
|
325
|
+
* Includes deterministic time tools and LLM-powered skills.
|
|
326
|
+
*/
|
|
327
|
+
declare const DEFAULT_SKILLS: SkillConfig[];
|
|
328
|
+
/**
|
|
329
|
+
* Default LLM configuration for A2A agents.
|
|
330
|
+
*/
|
|
331
|
+
declare const DEFAULT_LLM_CONFIG: LLMConfig;
|
|
332
|
+
|
|
333
|
+
export { A2AClient, type A2AClientOptions, type A2AMessage, type A2AServer, type A2AServerOptions, type AgentCard, type AgentConfig, type Artifact, DEFAULT_LLM_CONFIG, DEFAULT_SKILLS, type ExecutorContext, type ExecutorResult, JSON_RPC_ERRORS, type JsonRpcError, type JsonRpcRequest, type JsonRpcResponse, type LLMConfig, type MessagePart, type Skill, type SkillConfig, type StreamCallbacks, type Task, type TaskArtifactEvent, type TaskErrorEvent, type TaskHistoryEntry, type TaskStatus, type TaskStatusEvent, type TasksCancelParams, type TasksGetParams, type TasksSendParams, createA2AServer, createRuntypeA2AClient, executeEcho, executeEchoStreaming, executeTask, executeTaskStreaming, executeTimeSkill };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
A2AClient,
|
|
4
|
+
DEFAULT_LLM_CONFIG,
|
|
5
|
+
DEFAULT_SKILLS,
|
|
6
|
+
JSON_RPC_ERRORS,
|
|
7
|
+
createA2AServer,
|
|
8
|
+
createRuntypeA2AClient,
|
|
9
|
+
executeEcho,
|
|
10
|
+
executeEchoStreaming,
|
|
11
|
+
executeTask,
|
|
12
|
+
executeTaskStreaming,
|
|
13
|
+
executeTimeSkill
|
|
14
|
+
} from "./chunk-OLB7ZZNY.js";
|
|
15
|
+
export {
|
|
16
|
+
A2AClient,
|
|
17
|
+
DEFAULT_LLM_CONFIG,
|
|
18
|
+
DEFAULT_SKILLS,
|
|
19
|
+
JSON_RPC_ERRORS,
|
|
20
|
+
createA2AServer,
|
|
21
|
+
createRuntypeA2AClient,
|
|
22
|
+
executeEcho,
|
|
23
|
+
executeEchoStreaming,
|
|
24
|
+
executeTask,
|
|
25
|
+
executeTaskStreaming,
|
|
26
|
+
executeTimeSkill
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
interface Skill {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputModes: Array<'text' | 'file' | 'data'>;
|
|
6
|
+
outputModes: Array<'text' | 'file' | 'data'>;
|
|
7
|
+
tags: string[];
|
|
8
|
+
inputSchema?: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
interface SkillConfig {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
systemPrompt?: string;
|
|
15
|
+
inputSchema?: Record<string, unknown>;
|
|
16
|
+
tags?: string[];
|
|
17
|
+
}
|
|
18
|
+
interface LLMConfig {
|
|
19
|
+
provider: 'openai' | 'anthropic';
|
|
20
|
+
model: string;
|
|
21
|
+
/** Gateway model string (e.g. openai/gpt-5-nano) when using Vercel AI Gateway */
|
|
22
|
+
gatewayModel?: string;
|
|
23
|
+
apiKey?: string;
|
|
24
|
+
temperature?: number;
|
|
25
|
+
maxOutputTokens?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Default Skills Configuration
|
|
30
|
+
*
|
|
31
|
+
* Shared skill definitions for A2A agents. Import these in your agent
|
|
32
|
+
* configuration to avoid duplication across different deployment targets.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Default skills available to A2A agents.
|
|
37
|
+
* Includes deterministic time tools and LLM-powered skills.
|
|
38
|
+
*/
|
|
39
|
+
declare const DEFAULT_SKILLS: SkillConfig[];
|
|
40
|
+
/**
|
|
41
|
+
* Default LLM configuration for A2A agents.
|
|
42
|
+
*/
|
|
43
|
+
declare const DEFAULT_LLM_CONFIG: LLMConfig;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Vercel A2A Configuration
|
|
47
|
+
*
|
|
48
|
+
* Configuration types and helpers for deploying A2A agents to Vercel.
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
interface VercelA2AConfig {
|
|
52
|
+
/** Agent name displayed in the agent card */
|
|
53
|
+
name: string;
|
|
54
|
+
/** Agent description */
|
|
55
|
+
description?: string;
|
|
56
|
+
/** Agent version (default: "1.0.0") */
|
|
57
|
+
version?: string;
|
|
58
|
+
/** Custom skills (defaults to time/*, chat, echo, analyze) */
|
|
59
|
+
skills?: SkillConfig[];
|
|
60
|
+
/** Provider information */
|
|
61
|
+
provider?: {
|
|
62
|
+
organization: string;
|
|
63
|
+
url?: string;
|
|
64
|
+
};
|
|
65
|
+
/** URL where the agent is deployed (for agent card) */
|
|
66
|
+
agentUrl?: string;
|
|
67
|
+
/** Default input modes for agent card */
|
|
68
|
+
defaultInputModes?: Array<'text' | 'file' | 'data'>;
|
|
69
|
+
/** Default output modes for agent card */
|
|
70
|
+
defaultOutputModes?: Array<'text' | 'file' | 'data'>;
|
|
71
|
+
/** Run in echo mode (no LLM, for testing) */
|
|
72
|
+
echoMode?: boolean;
|
|
73
|
+
/** LLM configuration (required unless echoMode is true) */
|
|
74
|
+
llmConfig?: LLMConfig;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Resolve configuration with defaults
|
|
78
|
+
*/
|
|
79
|
+
declare function resolveConfig(config: VercelA2AConfig): Required<Pick<VercelA2AConfig, 'name' | 'description' | 'version' | 'skills' | 'echoMode' | 'defaultInputModes' | 'defaultOutputModes'>> & {
|
|
80
|
+
provider: {
|
|
81
|
+
organization: string;
|
|
82
|
+
url?: string;
|
|
83
|
+
};
|
|
84
|
+
llmConfig: LLMConfig;
|
|
85
|
+
agentUrl?: string;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Convert SkillConfig to A2A Skill format for agent card
|
|
89
|
+
*/
|
|
90
|
+
declare function toAgentCardSkills(skills: SkillConfig[]): Skill[];
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Vercel A2A Request Handlers
|
|
94
|
+
*
|
|
95
|
+
* Stateless request handlers for Vercel serverless/edge functions.
|
|
96
|
+
* These handlers implement the A2A protocol using Web standard Request/Response APIs.
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Create a handler for the agent card endpoint (GET /.well-known/agent.json)
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* // app/.well-known/agent.json/route.ts (Next.js App Router)
|
|
105
|
+
* import { createAgentCardHandler } from '@runtypelabs/a2a-agent-example/vercel'
|
|
106
|
+
*
|
|
107
|
+
* export const GET = createAgentCardHandler({
|
|
108
|
+
* name: 'My Agent',
|
|
109
|
+
* echoMode: true,
|
|
110
|
+
* })
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
declare function createAgentCardHandler(config: VercelA2AConfig): (_request: Request) => Promise<Response>;
|
|
114
|
+
/**
|
|
115
|
+
* Create a handler for the A2A JSON-RPC endpoint (POST /api/a2a)
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* // app/api/a2a/route.ts (Next.js App Router)
|
|
120
|
+
* import { createA2AHandler } from '@runtypelabs/a2a-agent-example/vercel'
|
|
121
|
+
*
|
|
122
|
+
* export const POST = createA2AHandler({
|
|
123
|
+
* name: 'My Agent',
|
|
124
|
+
* llmConfig: { provider: 'openai', model: 'gpt-4o-mini' },
|
|
125
|
+
* })
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
declare function createA2AHandler(config: VercelA2AConfig): (request: Request) => Promise<Response>;
|
|
129
|
+
/**
|
|
130
|
+
* Create both handlers with shared configuration
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```typescript
|
|
134
|
+
* const { agentCardHandler, a2aHandler } = createHandlers({
|
|
135
|
+
* name: 'My Agent',
|
|
136
|
+
* echoMode: true,
|
|
137
|
+
* })
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
declare function createHandlers(config: VercelA2AConfig): {
|
|
141
|
+
agentCardHandler: (_request: Request) => Promise<Response>;
|
|
142
|
+
a2aHandler: (request: Request) => Promise<Response>;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export { DEFAULT_LLM_CONFIG, DEFAULT_SKILLS, type VercelA2AConfig, createA2AHandler, createAgentCardHandler, createHandlers, resolveConfig, toAgentCardSkills };
|