@1agents/acp-service 0.5.4 → 0.6.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.
@@ -0,0 +1,426 @@
1
+ /** Main-agent tools backed by standard A2A, with a durable completion inbox. */
2
+ import { createHash, randomUUID, timingSafeEqual } from 'node:crypto';
3
+ import { closeSync, fsyncSync, mkdirSync, openSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
4
+ import http from 'node:http';
5
+ import path from 'node:path';
6
+ import { CancelTaskRequest, GetTaskRequest, SendMessageRequest, Task } from '@a2a-js/sdk';
7
+ import { ClientFactory, DefaultAgentCardResolver, JsonRpcTransportFactory } from '@a2a-js/sdk/client';
8
+ import { reportAndHoldRegistration } from '@1agents/dreammate-node/client';
9
+ import { z } from 'zod';
10
+ import { FileA2AStore } from './store.js';
11
+ const string = z.string().trim().min(1).max(512);
12
+ const endpoint = z.string().url().refine(value => {
13
+ const url = new URL(value);
14
+ return ['http:', 'https:'].includes(url.protocol) && !url.username && !url.password;
15
+ }, 'Expected an HTTP(S) URL without embedded credentials');
16
+ const configSchema = z.object({
17
+ stateDirectory: string,
18
+ port: z.number().int().min(0).max(65535).default(36814),
19
+ remotes: z.record(string, z.object({ url: endpoint, token: string }).strict()),
20
+ callback: z.object({ host: string, port: z.number().int().min(0).max(65535), url: endpoint, token: string }).strict().optional(),
21
+ notificationTargets: z.record(string, z.object({ url: endpoint, token: string }).strict()).default({}),
22
+ pollIntervalMs: z.number().int().min(50).max(60_000).default(3000),
23
+ }).strict();
24
+ const originFields = { originSessionId: string };
25
+ const taskFields = { ...originFields, remote: string, taskId: string };
26
+ const prompt = z.string().min(1).max(256 * 1024).refine(value => Boolean(value.trim()), 'Prompt must contain text');
27
+ const spawnSchema = z.object({ ...originFields, remote: string, prompt,
28
+ cwd: string.refine(value => path.posix.isAbsolute(value), 'cwd must be an absolute remote path'),
29
+ agentPreset: string.optional(), notificationTarget: string.optional(), title: string.optional(),
30
+ }).strict();
31
+ const taskSchema = z.object(taskFields).strict();
32
+ const messageSchema = z.object({ ...taskFields, prompt }).strict();
33
+ const inboxSchema = z.object(originFields).strict();
34
+ const ackSchema = z.object({ ...originFields, noticeId: string }).strict();
35
+ export const REMOTE_AGENT_METHODS = {
36
+ remote_agent_spawn: { description: '在配置的远端 DSH 工作目录中派发独立任务,立即返回 taskId。prompt 必须包含完整上下文。cwd 是远端绝对路径;每次 spawn 创建新会话。完成事件进入 originSessionId 的持久收件箱。', parameters: z.toJSONSchema(spawnSchema) },
37
+ remote_agent_get: { description: '查询当前主会话派发的远端任务。离线时返回缓存与 stale 标记,离线不等于任务失败。', parameters: z.toJSONSchema(taskSchema) },
38
+ remote_agent_cancel: { description: '取消指定远端任务,只取消这项任务自己的执行。', parameters: z.toJSONSchema(taskSchema) },
39
+ remote_agent_message: { description: '向同一个远端 DSH 会话发送后续指令,返回新 taskId,复用 contextId 与 cwd。', parameters: z.toJSONSchema(messageSchema) },
40
+ remote_agent_list: { description: '列出当前主会话派发的远端任务。', parameters: z.toJSONSchema(inboxSchema) },
41
+ remote_agent_inbox: { description: '读取当前主会话未确认的完成或需要输入通知。读取不删除;处理后调用 remote_agent_ack。', parameters: z.toJSONSchema(inboxSchema) },
42
+ remote_agent_ack: { description: '确认主会话已处理指定通知。noticeId 稳定,重复确认安全。', parameters: z.toJSONSchema(ackSchema) },
43
+ };
44
+ const terminal = new Set(['TASK_STATE_COMPLETED', 'TASK_STATE_FAILED', 'TASK_STATE_CANCELED', 'TASK_STATE_REJECTED']);
45
+ const actionable = new Set([...terminal, 'TASK_STATE_INPUT_REQUIRED', 'TASK_STATE_AUTH_REQUIRED']);
46
+ const wire = (task) => Task.toJSON(task);
47
+ const taskState = (job) => wire(Task.fromJSON(job.task)).status?.state ?? 'TASK_STATE_UNSPECIFIED';
48
+ const resultText = (task) => task.artifacts.flatMap(artifact => artifact.parts
49
+ .filter(part => part.content?.$case === 'text').map(part => part.content.value)).join('\n') ||
50
+ task.status?.message?.parts.filter(part => part.content?.$case === 'text').map(part => part.content.value).join('\n') || '';
51
+ function atomicJson(file, value) {
52
+ const temp = `${file}.${randomUUID()}.tmp`;
53
+ const fd = openSync(temp, 'wx', 0o600);
54
+ try {
55
+ writeFileSync(fd, JSON.stringify(value));
56
+ fsyncSync(fd);
57
+ }
58
+ finally {
59
+ closeSync(fd);
60
+ }
61
+ renameSync(temp, file);
62
+ const dir = openSync(path.dirname(file), 'r');
63
+ try {
64
+ fsyncSync(dir);
65
+ }
66
+ finally {
67
+ closeSync(dir);
68
+ }
69
+ }
70
+ export class RemoteAgentGateway {
71
+ config;
72
+ lease;
73
+ stateFile;
74
+ state;
75
+ clients = new Map();
76
+ refreshing = new Map();
77
+ delivering = new Set();
78
+ controllers = new Set();
79
+ operations = new Set();
80
+ reconciling;
81
+ timer;
82
+ closed = false;
83
+ constructor(input) {
84
+ this.config = configSchema.parse(input);
85
+ if (!path.isAbsolute(this.config.stateDirectory))
86
+ throw new Error('stateDirectory must be absolute');
87
+ mkdirSync(this.config.stateDirectory, { recursive: true, mode: 0o700 });
88
+ // Reuse the A2A store's tested single-owner lease, in a separate empty
89
+ // directory: local restarts must never mark remote executions failed.
90
+ this.lease = new FileA2AStore(path.join(this.config.stateDirectory, 'lease'));
91
+ this.stateFile = path.join(this.config.stateDirectory, 'gateway.json');
92
+ try {
93
+ this.state = JSON.parse(readFileSync(this.stateFile, 'utf8'));
94
+ if (this.state.version !== 1 || !Array.isArray(this.state.jobs) || !Array.isArray(this.state.notices))
95
+ throw new Error('Invalid gateway state');
96
+ for (const job of this.state.jobs) {
97
+ string.parse(job.originSessionId);
98
+ string.parse(job.remote);
99
+ string.parse(job.taskId);
100
+ if (Task.fromJSON(job.task).id !== job.taskId)
101
+ throw new Error('Invalid gateway task ID');
102
+ }
103
+ }
104
+ catch (error) {
105
+ if (error.code !== 'ENOENT') {
106
+ this.lease.close();
107
+ throw error;
108
+ }
109
+ this.state = { version: 1, jobs: [], notices: [] };
110
+ }
111
+ this.timer = setInterval(() => { void this.reconcile(); }, this.config.pollIntervalMs);
112
+ this.timer.unref();
113
+ void this.reconcile();
114
+ }
115
+ save() { atomicJson(this.stateFile, this.state); }
116
+ client(remote) {
117
+ const config = this.config.remotes[remote];
118
+ if (!config)
119
+ throw new Error(`Unknown remote: ${remote}`);
120
+ let pending = this.clients.get(remote);
121
+ if (!pending) {
122
+ const fetchImpl = async (input, init) => {
123
+ if (this.closed)
124
+ throw new Error('Gateway is closed');
125
+ const url = new URL(input instanceof Request ? input.url : String(input));
126
+ if (url.origin !== new URL(config.url).origin)
127
+ throw new Error('Agent Card endpoint must use the configured remote origin');
128
+ const controller = new AbortController();
129
+ this.controllers.add(controller);
130
+ const signal = AbortSignal.any([controller.signal, AbortSignal.timeout(10_000), ...(init?.signal ? [init.signal] : [])]);
131
+ try {
132
+ return await fetch(input, { ...init, signal, redirect: 'error' });
133
+ }
134
+ finally {
135
+ this.controllers.delete(controller);
136
+ }
137
+ };
138
+ pending = new ClientFactory({ transports: [new JsonRpcTransportFactory({ fetchImpl })],
139
+ cardResolver: new DefaultAgentCardResolver({ fetchImpl }), clientConfig: { polling: true } }).createFromUrl(config.url);
140
+ this.clients.set(remote, pending);
141
+ void pending.catch(() => { if (this.clients.get(remote) === pending)
142
+ this.clients.delete(remote); });
143
+ }
144
+ return pending;
145
+ }
146
+ auth(remote) { return { serviceParameters: { Authorization: `Bearer ${this.config.remotes[remote].token}` } }; }
147
+ job(params) {
148
+ const job = this.state.jobs.find(value => value.remote === params.remote && value.taskId === params.taskId && value.originSessionId === params.originSessionId);
149
+ if (!job)
150
+ throw new Error('Task not found for this origin session');
151
+ return job;
152
+ }
153
+ view(job) {
154
+ const task = Task.fromJSON(job.task);
155
+ return { remote: job.remote, taskId: job.taskId, contextId: job.contextId, originSessionId: job.originSessionId,
156
+ cwd: job.cwd, agentPreset: job.agentPreset, sessionId: task.metadata?.['1agents']?.sessionId,
157
+ state: taskState(job), result: resultText(task), checkedAt: job.checkedAt, stale: Boolean(job.stale) };
158
+ }
159
+ accept(task, fields) {
160
+ const target = task.metadata?.['1agents'];
161
+ const job = { ...fields, taskId: task.id, contextId: task.contextId, task: wire(task), checkedAt: new Date().toISOString(),
162
+ cwd: typeof target?.cwd === 'string' ? target.cwd : fields.cwd,
163
+ agentPreset: typeof target?.agentPreset === 'string' ? target.agentPreset : fields.agentPreset };
164
+ this.state.jobs.push(job);
165
+ this.update(job, task);
166
+ return job;
167
+ }
168
+ update(job, task) {
169
+ if (task.id !== job.taskId || task.contextId !== job.contextId)
170
+ throw new Error('Remote returned a different task');
171
+ const previous = Task.fromJSON(job.task);
172
+ if ((terminal.has(taskState(job)) && !terminal.has(wire(task).status?.state)) ||
173
+ Date.parse(previous.status?.timestamp ?? '') > Date.parse(task.status?.timestamp ?? ''))
174
+ return;
175
+ job.task = wire(task);
176
+ job.checkedAt = new Date().toISOString();
177
+ job.stale = false;
178
+ const state = taskState(job);
179
+ if (actionable.has(state)) {
180
+ const noticeId = createHash('sha256').update(JSON.stringify([job.remote, job.taskId, state, task.status?.timestamp])).digest('hex');
181
+ if (!this.state.notices.some(value => value.notice.noticeId === noticeId))
182
+ this.state.notices.push({ target: job.notificationTarget,
183
+ notice: { noticeId, originSessionId: job.originSessionId, remote: job.remote, taskId: job.taskId, contextId: job.contextId,
184
+ cwd: job.cwd, agentPreset: job.agentPreset, title: job.title, state, result: resultText(task), createdAt: new Date().toISOString() } });
185
+ }
186
+ this.save();
187
+ }
188
+ async refresh(job) {
189
+ const key = `${job.remote}:${job.taskId}`;
190
+ const previous = this.refreshing.get(key);
191
+ if (previous)
192
+ return previous;
193
+ const pending = (async () => {
194
+ try {
195
+ const client = await this.client(job.remote);
196
+ this.update(job, await client.getTask(GetTaskRequest.fromJSON({ id: job.taskId }), this.auth(job.remote)));
197
+ }
198
+ catch {
199
+ job.stale = true;
200
+ this.save();
201
+ }
202
+ })();
203
+ this.refreshing.set(key, pending);
204
+ try {
205
+ await pending;
206
+ }
207
+ finally {
208
+ this.refreshing.delete(key);
209
+ }
210
+ }
211
+ async reconcile() {
212
+ if (this.closed)
213
+ return;
214
+ if (this.reconciling)
215
+ return this.reconciling;
216
+ const pending = (async () => {
217
+ await Promise.allSettled(this.state.jobs.filter(job => !terminal.has(taskState(job))).map(job => this.refresh(job)));
218
+ if (this.closed)
219
+ return;
220
+ await Promise.allSettled(this.state.notices.filter(record => record.target && !record.delivered && !record.acknowledged).map(record => this.deliver(record)));
221
+ })();
222
+ this.reconciling = pending;
223
+ try {
224
+ await pending;
225
+ }
226
+ finally {
227
+ this.reconciling = undefined;
228
+ }
229
+ }
230
+ async deliver(record) {
231
+ const id = record.notice.noticeId;
232
+ const target = this.config.notificationTargets[record.target];
233
+ if (!target || this.delivering.has(id))
234
+ return;
235
+ this.delivering.add(id);
236
+ const controller = new AbortController();
237
+ this.controllers.add(controller);
238
+ try {
239
+ const response = await fetch(target.url, { method: 'POST', redirect: 'error', signal: AbortSignal.any([controller.signal, AbortSignal.timeout(5000)]),
240
+ headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${target.token}`, 'Idempotency-Key': id }, body: JSON.stringify(record.notice) });
241
+ await response.body?.cancel();
242
+ if (response.ok) {
243
+ record.delivered = true;
244
+ this.save();
245
+ }
246
+ }
247
+ catch { /* Durable outbox retries on the next tick, with the same ID. */ }
248
+ finally {
249
+ this.controllers.delete(controller);
250
+ this.delivering.delete(id);
251
+ }
252
+ }
253
+ async invoke(method, params) {
254
+ if (this.closed)
255
+ throw new Error('Gateway is closed');
256
+ const operation = this.invokeMethod(method, params);
257
+ this.operations.add(operation);
258
+ try {
259
+ return await operation;
260
+ }
261
+ finally {
262
+ this.operations.delete(operation);
263
+ }
264
+ }
265
+ async invokeMethod(method, params) {
266
+ if (method === 'remote_agent_spawn') {
267
+ const input = spawnSchema.parse(params);
268
+ if (input.notificationTarget && !this.config.notificationTargets[input.notificationTarget])
269
+ throw new Error('Unknown notificationTarget');
270
+ const client = await this.client(input.remote);
271
+ const task = await client.sendMessage(SendMessageRequest.fromJSON({ message: { messageId: randomUUID(), role: 'ROLE_USER', parts: [{ text: input.prompt }] },
272
+ metadata: { '1agents': { cwd: input.cwd, ...(input.agentPreset ? { agentPreset: input.agentPreset } : {}) } },
273
+ configuration: { returnImmediately: true, ...(this.config.callback ? { taskPushNotificationConfig: { url: this.config.callback.url,
274
+ authentication: { scheme: 'Bearer', credentials: this.config.callback.token } } } : {}) } }), this.auth(input.remote));
275
+ if (!('id' in task))
276
+ throw new Error('Remote did not return an A2A Task');
277
+ return this.view(this.accept(task, { remote: input.remote, originSessionId: input.originSessionId, cwd: input.cwd, agentPreset: input.agentPreset, title: input.title, notificationTarget: input.notificationTarget }));
278
+ }
279
+ if (method === 'remote_agent_get' || method === 'remote_agent_cancel') {
280
+ const job = this.job(taskSchema.parse(params));
281
+ if (method === 'remote_agent_cancel') {
282
+ const client = await this.client(job.remote);
283
+ this.update(job, await client.cancelTask(CancelTaskRequest.fromJSON({ id: job.taskId }), this.auth(job.remote)));
284
+ }
285
+ else
286
+ await this.refresh(job);
287
+ return this.view(job);
288
+ }
289
+ if (method === 'remote_agent_message') {
290
+ const input = messageSchema.parse(params), previous = this.job(input);
291
+ const client = await this.client(input.remote);
292
+ const task = await client.sendMessage(SendMessageRequest.fromJSON({ message: { messageId: randomUUID(), role: 'ROLE_USER', contextId: previous.contextId, parts: [{ text: input.prompt }] },
293
+ configuration: { returnImmediately: true, ...(this.config.callback ? { taskPushNotificationConfig: { url: this.config.callback.url,
294
+ authentication: { scheme: 'Bearer', credentials: this.config.callback.token } } } : {}) } }), this.auth(input.remote));
295
+ if (!('id' in task))
296
+ throw new Error('Remote did not return an A2A Task');
297
+ return this.view(this.accept(task, { remote: previous.remote, originSessionId: previous.originSessionId, cwd: previous.cwd, agentPreset: previous.agentPreset,
298
+ title: previous.title, notificationTarget: previous.notificationTarget }));
299
+ }
300
+ if (method === 'remote_agent_list' || method === 'remote_agent_inbox') {
301
+ const { originSessionId } = inboxSchema.parse(params);
302
+ return method === 'remote_agent_list' ? { tasks: this.state.jobs.filter(job => job.originSessionId === originSessionId).map(job => this.view(job)) } :
303
+ { notices: this.state.notices.filter(record => record.notice.originSessionId === originSessionId && !record.acknowledged).map(record => record.notice) };
304
+ }
305
+ if (method === 'remote_agent_ack') {
306
+ const input = ackSchema.parse(params);
307
+ const notice = this.state.notices.find(record => record.notice.originSessionId === input.originSessionId && record.notice.noticeId === input.noticeId);
308
+ if (!notice)
309
+ throw new Error('Notice not found for this origin session');
310
+ notice.acknowledged = true;
311
+ this.save();
312
+ return { acknowledged: true, noticeId: input.noticeId };
313
+ }
314
+ throw new Error(`Unknown method: ${method}`);
315
+ }
316
+ /** Push events are hints. GetTask remains authoritative, including after missed callbacks. */
317
+ async receivePush(event) {
318
+ const value = z.object({ task: z.object({ id: string }).passthrough().optional(), statusUpdate: z.object({ taskId: string }).passthrough().optional(),
319
+ artifactUpdate: z.object({ taskId: string }).passthrough().optional() }).passthrough().parse(event);
320
+ const taskId = value.task?.id ?? value.statusUpdate?.taskId ?? value.artifactUpdate?.taskId;
321
+ if (!taskId)
322
+ throw new Error('Missing A2A event task ID');
323
+ await Promise.allSettled(this.state.jobs.filter(job => job.taskId === taskId).map(job => this.refresh(job)));
324
+ }
325
+ async close() {
326
+ if (this.closed)
327
+ return;
328
+ this.closed = true;
329
+ clearInterval(this.timer);
330
+ for (const controller of this.controllers)
331
+ controller.abort();
332
+ await Promise.allSettled([...this.refreshing.values(), ...this.operations, ...(this.reconciling ? [this.reconciling] : [])]);
333
+ // Delivery promises release their controllers after abort; HTTP requests
334
+ // may have already succeeded, so any retry keeps the stable notice ID.
335
+ this.lease.close();
336
+ }
337
+ }
338
+ async function body(req) {
339
+ let length = 0;
340
+ const chunks = [];
341
+ for await (const data of req) {
342
+ length += data.length;
343
+ if (length > 1024 * 1024)
344
+ throw new Error('Request body too large');
345
+ chunks.push(Buffer.from(data));
346
+ }
347
+ return JSON.parse(Buffer.concat(chunks).toString('utf8'));
348
+ }
349
+ function json(res, status, data) {
350
+ res.writeHead(status, { 'Content-Type': 'application/json', 'Cache-Control': 'no-store' });
351
+ res.end(JSON.stringify(data));
352
+ }
353
+ function authenticated(req, token) {
354
+ const expected = Buffer.from(`Bearer ${token}`), supplied = Buffer.from(req.headers.authorization ?? '');
355
+ return supplied.length === expected.length && timingSafeEqual(supplied, expected);
356
+ }
357
+ async function listen(server, port, host) {
358
+ await new Promise((resolve, reject) => { server.once('error', reject); server.listen(port, host, resolve); });
359
+ return server.address().port;
360
+ }
361
+ async function stop(server) {
362
+ server.closeIdleConnections();
363
+ await new Promise(resolve => server.close(() => resolve()));
364
+ }
365
+ export async function serveA2AGateway(input, options = {}) {
366
+ const gateway = new RemoteAgentGateway(input);
367
+ const server = http.createServer((req, res) => {
368
+ void (async () => {
369
+ try {
370
+ if (req.method === 'GET' && req.url === '/health')
371
+ return json(res, 200, { status: 'ok', service: 'a2a-gateway', remotes: Object.keys(gateway.config.remotes) });
372
+ if (req.method !== 'POST' || req.url !== '/invoke')
373
+ return json(res, 404, { error: 'No route' });
374
+ // Local tools are trusted. The separate tailnet receiver below never exposes /invoke.
375
+ if (req.headers.origin)
376
+ return json(res, 403, { error: 'Browser-origin invocation is not allowed' });
377
+ const request = z.object({ method: string.optional(), capability: string.optional(), params: z.unknown() }).parse(await body(req));
378
+ return json(res, 200, await gateway.invoke(request.method ?? request.capability ?? '', request.params));
379
+ }
380
+ catch (error) {
381
+ json(res, 400, { error: error instanceof z.ZodError ? 'Invalid method parameters' : error instanceof Error ? error.message : 'Invocation failed' });
382
+ }
383
+ })();
384
+ });
385
+ let receiver;
386
+ let callbackPort;
387
+ try {
388
+ const port = await listen(server, gateway.config.port, '127.0.0.1');
389
+ if (gateway.config.callback) {
390
+ const callback = gateway.config.callback;
391
+ receiver = http.createServer((req, res) => {
392
+ void (async () => {
393
+ if (!authenticated(req, callback.token))
394
+ return json(res, 401, { error: 'Unauthorized' });
395
+ if (req.method !== 'POST' || req.url !== new URL(callback.url).pathname)
396
+ return json(res, 404, { error: 'No route' });
397
+ try {
398
+ const event = await body(req);
399
+ json(res, 202, { accepted: true });
400
+ void gateway.receivePush(event).catch(() => { });
401
+ }
402
+ catch {
403
+ json(res, 400, { error: 'Invalid A2A event' });
404
+ }
405
+ })();
406
+ });
407
+ callbackPort = await listen(receiver, callback.port, callback.host);
408
+ }
409
+ const entry = { id: 'a2a-gateway', name: 'DSH 远端智能体', kind: 'agent_runtime',
410
+ capabilities: Object.keys(REMOTE_AGENT_METHODS), execution: 'http', port, reachability: 'localhost', health: '/health', methods: REMOTE_AGENT_METHODS };
411
+ const registration = options.report === false ? undefined : await reportAndHoldRegistration(entry);
412
+ let stopped = false;
413
+ return { gateway, port, callbackPort, registration, close: async () => {
414
+ if (stopped)
415
+ return;
416
+ stopped = true;
417
+ await gateway.close();
418
+ await Promise.all([stop(server), ...(receiver ? [stop(receiver)] : [])]);
419
+ } };
420
+ }
421
+ catch (error) {
422
+ await gateway.close();
423
+ await Promise.all([stop(server), ...(receiver ? [stop(receiver)] : [])]);
424
+ throw error;
425
+ }
426
+ }
@@ -0,0 +1,7 @@
1
+ /** Shared A2A 1.0 server, persistent state and host-independent executor interfaces. */
2
+ export { createA2AServer } from './server.js';
3
+ export type { A2AServerOptions } from './server.js';
4
+ export { FileA2AStore } from './store.js';
5
+ export type { A2ABackend, A2APrepareInput, A2ARunResult, A2ATarget } from './types.js';
6
+ export { RemoteAgentGateway, serveA2AGateway, REMOTE_AGENT_METHODS } from './gateway.js';
7
+ export type { A2AGatewayConfig, RemoteAgentNotice } from './gateway.js';
@@ -0,0 +1,4 @@
1
+ /** Shared A2A 1.0 server, persistent state and host-independent executor interfaces. */
2
+ export { createA2AServer } from './server.js';
3
+ export { FileA2AStore } from './store.js';
4
+ export { RemoteAgentGateway, serveA2AGateway, REMOTE_AGENT_METHODS } from './gateway.js';
@@ -0,0 +1,22 @@
1
+ import type { IncomingMessage, ServerResponse } from 'node:http';
2
+ import { AgentCard } from '@a2a-js/sdk';
3
+ import { type A2AExecutionOptions } from './executor.js';
4
+ import type { A2ABackend } from './types.js';
5
+ /** Remote execution is explicitly enabled with a host-owned bearer credential. */
6
+ export interface A2AServerOptions extends A2AExecutionOptions {
7
+ backend: A2ABackend;
8
+ stateDirectory: string;
9
+ publicUrl: string;
10
+ token: string;
11
+ path?: string;
12
+ /** Webhook destinations must belong to one of these exact HTTP(S) origins. */
13
+ pushNotificationOrigins?: string[];
14
+ }
15
+ /** Create the A2A 1.0 host without opening a port or importing DSH. */
16
+ export declare function createA2AServer(options: A2AServerOptions): Promise<{
17
+ path: string;
18
+ card: AgentCard;
19
+ handler: (request: IncomingMessage, response: ServerResponse) => Promise<void>;
20
+ cardHandler: (request: IncomingMessage, response: ServerResponse) => Promise<void>;
21
+ close: () => Promise<void>;
22
+ }>;