@axiom-lattice/cli-a2a 0.1.1
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/.turbo/turbo-build.log +51 -0
- package/CHANGELOG.md +7 -0
- package/LICENSE +201 -0
- package/README.md +290 -0
- package/__tests__/opencode-executor.test.ts +159 -0
- package/agents/opencode-example/config.json +64 -0
- package/dist/bridge-7ZUDKCZT.mjs +271 -0
- package/dist/bridge-7ZUDKCZT.mjs.map +1 -0
- package/dist/chunk-35NFMGMS.mjs +27 -0
- package/dist/chunk-35NFMGMS.mjs.map +1 -0
- package/dist/chunk-G7AGL2QA.mjs +284 -0
- package/dist/chunk-G7AGL2QA.mjs.map +1 -0
- package/dist/chunk-LXL47XMZ.mjs +43 -0
- package/dist/chunk-LXL47XMZ.mjs.map +1 -0
- package/dist/chunk-NQIDRU47.mjs +178 -0
- package/dist/chunk-NQIDRU47.mjs.map +1 -0
- package/dist/chunk-VSZ3DACI.mjs +179 -0
- package/dist/chunk-VSZ3DACI.mjs.map +1 -0
- package/dist/chunk-VZEH3EPJ.mjs +56 -0
- package/dist/chunk-VZEH3EPJ.mjs.map +1 -0
- package/dist/chunk-WNCDOYZS.mjs +187 -0
- package/dist/chunk-WNCDOYZS.mjs.map +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +1562 -0
- package/dist/cli.js.map +1 -0
- package/dist/cli.mjs +293 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/executor-OWPVDUXH.mjs +11 -0
- package/dist/executor-OWPVDUXH.mjs.map +1 -0
- package/dist/executor-RVBGAWUF.mjs +11 -0
- package/dist/executor-RVBGAWUF.mjs.map +1 -0
- package/dist/executor-XWHWUVQ3.mjs +11 -0
- package/dist/executor-XWHWUVQ3.mjs.map +1 -0
- package/dist/executors-QIIKBUMJ.mjs +15 -0
- package/dist/executors-QIIKBUMJ.mjs.map +1 -0
- package/dist/index.d.mts +295 -0
- package/dist/index.d.ts +295 -0
- package/dist/index.js +942 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +44 -0
- package/dist/index.mjs.map +1 -0
- package/jest.config.js +16 -0
- package/package.json +63 -0
- package/src/bridge.ts +355 -0
- package/src/cli.ts +384 -0
- package/src/config/defaults.ts +109 -0
- package/src/config/index.ts +16 -0
- package/src/config/loader.ts +121 -0
- package/src/config/types.ts +163 -0
- package/src/executors/claude/client.ts +138 -0
- package/src/executors/claude/executor.ts +111 -0
- package/src/executors/codex/client.ts +139 -0
- package/src/executors/codex/executor.ts +118 -0
- package/src/executors/events.ts +117 -0
- package/src/executors/index.ts +54 -0
- package/src/executors/opencode/client.ts +149 -0
- package/src/executors/opencode/executor.ts +112 -0
- package/src/index.ts +54 -0
- package/src/logger.ts +78 -0
- package/src/server/agent-card.ts +51 -0
- package/src/server/index.ts +124 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OpenCodeExecutor,
|
|
3
|
+
createOpenCodeExecutor
|
|
4
|
+
} from "./chunk-WNCDOYZS.mjs";
|
|
5
|
+
import "./chunk-LXL47XMZ.mjs";
|
|
6
|
+
import "./chunk-VZEH3EPJ.mjs";
|
|
7
|
+
export {
|
|
8
|
+
OpenCodeExecutor,
|
|
9
|
+
createOpenCodeExecutor
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=executor-RVBGAWUF.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TaskState,
|
|
3
|
+
createExecutor,
|
|
4
|
+
getExecutor,
|
|
5
|
+
registerExecutor,
|
|
6
|
+
v4
|
|
7
|
+
} from "./chunk-35NFMGMS.mjs";
|
|
8
|
+
export {
|
|
9
|
+
TaskState,
|
|
10
|
+
createExecutor,
|
|
11
|
+
getExecutor,
|
|
12
|
+
registerExecutor,
|
|
13
|
+
v4 as uuidv4
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=executors-QIIKBUMJ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import { AgentExecutor, RequestContext, ExecutionEventBus } from '@a2a-js/sdk/server';
|
|
3
|
+
export { AgentExecutor, ExecutionEventBus, RequestContext } from '@a2a-js/sdk/server';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Unified configuration types for the CLI A2A gateway.
|
|
7
|
+
*
|
|
8
|
+
* Each provider (OpenCode, Codex, Claude Code) extends the base config
|
|
9
|
+
* with its own connection settings. A single config file can declare
|
|
10
|
+
* multiple providers, and the CLI selects one at startup via --provider.
|
|
11
|
+
*/
|
|
12
|
+
interface AgentCardConfig {
|
|
13
|
+
/** Human-readable agent name */
|
|
14
|
+
name: string;
|
|
15
|
+
/** Agent description shown to orchestrators / callers */
|
|
16
|
+
description: string;
|
|
17
|
+
/** Protocol version (default: "0.3.0") */
|
|
18
|
+
protocolVersion?: string;
|
|
19
|
+
/** Agent version string */
|
|
20
|
+
version?: string;
|
|
21
|
+
/** Skills advertised on the agent card */
|
|
22
|
+
skills?: SkillConfig[];
|
|
23
|
+
/** Supported input modes */
|
|
24
|
+
defaultInputModes?: string[];
|
|
25
|
+
/** Supported output modes */
|
|
26
|
+
defaultOutputModes?: string[];
|
|
27
|
+
/** Enable streaming */
|
|
28
|
+
streaming?: boolean;
|
|
29
|
+
/** Enable push notifications */
|
|
30
|
+
pushNotifications?: boolean;
|
|
31
|
+
/** Provider info */
|
|
32
|
+
provider?: {
|
|
33
|
+
organization: string;
|
|
34
|
+
url?: string;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
interface SkillConfig {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
description: string;
|
|
41
|
+
tags?: string[];
|
|
42
|
+
examples?: string[];
|
|
43
|
+
}
|
|
44
|
+
interface ServerConfig {
|
|
45
|
+
/** A2A server port */
|
|
46
|
+
port?: number;
|
|
47
|
+
/** Bind address */
|
|
48
|
+
hostname?: string;
|
|
49
|
+
/** Hostname advertised in agent card URLs */
|
|
50
|
+
advertiseHost?: string;
|
|
51
|
+
/** Protocol for advertised URLs */
|
|
52
|
+
advertiseProtocol?: 'http' | 'https';
|
|
53
|
+
}
|
|
54
|
+
interface SessionConfig {
|
|
55
|
+
/** Session title prefix */
|
|
56
|
+
titlePrefix?: string;
|
|
57
|
+
/** Reuse sessions by A2A contextId */
|
|
58
|
+
reuseByContext?: boolean;
|
|
59
|
+
/** Session TTL in ms */
|
|
60
|
+
ttl?: number;
|
|
61
|
+
/** Cleanup interval in ms */
|
|
62
|
+
cleanupInterval?: number;
|
|
63
|
+
}
|
|
64
|
+
interface FeatureFlags {
|
|
65
|
+
/** Auto-approve all permission requests */
|
|
66
|
+
autoApprovePermissions?: boolean;
|
|
67
|
+
/** Auto-answer question prompts */
|
|
68
|
+
autoAnswerQuestions?: boolean;
|
|
69
|
+
/** Stream artifact chunks individually vs buffer */
|
|
70
|
+
streamArtifactChunks?: boolean;
|
|
71
|
+
/** Enable polling fallback on SSE failure */
|
|
72
|
+
enablePollingFallback?: boolean;
|
|
73
|
+
}
|
|
74
|
+
interface TimeoutConfig {
|
|
75
|
+
/** Timeout for a single prompt in ms */
|
|
76
|
+
prompt?: number;
|
|
77
|
+
/** Polling interval in ms */
|
|
78
|
+
pollingInterval?: number;
|
|
79
|
+
/** Health check interval in ms */
|
|
80
|
+
healthCheck?: number;
|
|
81
|
+
}
|
|
82
|
+
interface LoggingConfig {
|
|
83
|
+
/** Log level */
|
|
84
|
+
level?: 'debug' | 'info' | 'warn' | 'error';
|
|
85
|
+
}
|
|
86
|
+
interface OpenCodeConfig {
|
|
87
|
+
/** OpenCode server base URL */
|
|
88
|
+
baseUrl?: string;
|
|
89
|
+
/** Target project directory */
|
|
90
|
+
projectDirectory?: string;
|
|
91
|
+
/** Model identifier (e.g. "anthropic/claude-sonnet-4-20250514") */
|
|
92
|
+
model?: string;
|
|
93
|
+
/** Agent preset name */
|
|
94
|
+
agent?: string;
|
|
95
|
+
/** System prompt */
|
|
96
|
+
systemPrompt?: string;
|
|
97
|
+
/** How system prompt is applied */
|
|
98
|
+
systemPromptMode?: 'append' | 'replace';
|
|
99
|
+
/** Context file name */
|
|
100
|
+
contextFile?: string;
|
|
101
|
+
/** Prompt for building context */
|
|
102
|
+
contextPrompt?: string;
|
|
103
|
+
}
|
|
104
|
+
interface CodexConfig {
|
|
105
|
+
/** Codex CLI path */
|
|
106
|
+
cliPath?: string;
|
|
107
|
+
/** Working directory */
|
|
108
|
+
workdir?: string;
|
|
109
|
+
/** Model identifier */
|
|
110
|
+
model?: string;
|
|
111
|
+
/** API key for OpenAI */
|
|
112
|
+
apiKey?: string;
|
|
113
|
+
}
|
|
114
|
+
interface ClaudeCodeConfig {
|
|
115
|
+
/** Claude Code CLI path */
|
|
116
|
+
cliPath?: string;
|
|
117
|
+
/** Working directory */
|
|
118
|
+
workdir?: string;
|
|
119
|
+
/** Model identifier */
|
|
120
|
+
model?: string;
|
|
121
|
+
/** API key for Anthropic */
|
|
122
|
+
apiKey?: string;
|
|
123
|
+
}
|
|
124
|
+
type ProviderType = 'opencode' | 'codex' | 'claude';
|
|
125
|
+
interface AgentConfig {
|
|
126
|
+
/** Active provider to use */
|
|
127
|
+
provider: ProviderType;
|
|
128
|
+
/** Agent card identity */
|
|
129
|
+
agentCard: AgentCardConfig;
|
|
130
|
+
/** Server settings */
|
|
131
|
+
server?: ServerConfig;
|
|
132
|
+
/** Session management */
|
|
133
|
+
session?: SessionConfig;
|
|
134
|
+
/** Feature flags */
|
|
135
|
+
features?: FeatureFlags;
|
|
136
|
+
/** Timeout settings */
|
|
137
|
+
timeouts?: TimeoutConfig;
|
|
138
|
+
/** Logging settings */
|
|
139
|
+
logging?: LoggingConfig;
|
|
140
|
+
/** Provider-specific connection configs */
|
|
141
|
+
opencode?: OpenCodeConfig;
|
|
142
|
+
codex?: CodexConfig;
|
|
143
|
+
claude?: ClaudeCodeConfig;
|
|
144
|
+
/** Directory containing config file (populated at runtime) */
|
|
145
|
+
configDir?: string;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Config loader — reads JSON config files and resolves the final config
|
|
150
|
+
* by merging layers: defaults ← config file ← env overrides ← CLI args.
|
|
151
|
+
*/
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Read and parse a JSON config file.
|
|
155
|
+
*/
|
|
156
|
+
declare function loadConfigFile(filePath: string): Partial<AgentConfig>;
|
|
157
|
+
/**
|
|
158
|
+
* Resolve full config from defaults + file + env.
|
|
159
|
+
*/
|
|
160
|
+
declare function resolveConfig(configPath?: string, cliOverrides?: Partial<AgentConfig>): Required<AgentConfig>;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* A2A HTTP Server
|
|
164
|
+
*
|
|
165
|
+
* Creates an Express server with standard A2A endpoints:
|
|
166
|
+
* - GET /.well-known/agent-card.json → Agent Card
|
|
167
|
+
* - POST /a2a/jsonrpc → JSON-RPC transport
|
|
168
|
+
* - POST /a2a/rest → REST transport
|
|
169
|
+
* - GET /health → Health check
|
|
170
|
+
*/
|
|
171
|
+
|
|
172
|
+
interface ServerHandle {
|
|
173
|
+
app: ReturnType<typeof express>;
|
|
174
|
+
server: ReturnType<ReturnType<typeof express>['listen']>;
|
|
175
|
+
shutdown(): Promise<void>;
|
|
176
|
+
}
|
|
177
|
+
declare function createA2AServer(config: Required<AgentConfig>): Promise<ServerHandle>;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Executor types and common interfaces for CLI A2A providers.
|
|
181
|
+
*
|
|
182
|
+
* Each provider (OpenCode, Codex, Claude) implements its own executor
|
|
183
|
+
* conforming to the A2AExecutor interface which extends the SDK's
|
|
184
|
+
* AgentExecutor with lifecycle methods (initialize, shutdown).
|
|
185
|
+
*/
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Extended executor interface with lifecycle methods.
|
|
189
|
+
*
|
|
190
|
+
* The base AgentExecutor from @a2a-js/sdk only defines execute() and
|
|
191
|
+
* cancelTask(). We add initialize() for server setup and shutdown()
|
|
192
|
+
* for graceful cleanup.
|
|
193
|
+
*/
|
|
194
|
+
interface A2AExecutor extends AgentExecutor {
|
|
195
|
+
initialize(): Promise<void>;
|
|
196
|
+
shutdown(): Promise<void>;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Factory function type: given resolved config, produce an executor.
|
|
201
|
+
*/
|
|
202
|
+
type ExecutorFactory = (config: Required<AgentConfig>) => A2AExecutor;
|
|
203
|
+
declare function registerExecutor(provider: ProviderType, factory: ExecutorFactory): void;
|
|
204
|
+
declare function getExecutor(provider: ProviderType): ExecutorFactory | undefined;
|
|
205
|
+
declare function createExecutor(config: Required<AgentConfig>): A2AExecutor;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* OpenCode A2A Executor
|
|
209
|
+
*
|
|
210
|
+
* Bridges the local OpenCode CLI to the A2A protocol. Spawns `opencode run`
|
|
211
|
+
* as a child process for each request and captures stdout as the response.
|
|
212
|
+
* Same spawn pattern as Codex and Claude Code executors.
|
|
213
|
+
*/
|
|
214
|
+
|
|
215
|
+
declare class OpenCodeExecutor implements A2AExecutor {
|
|
216
|
+
private config;
|
|
217
|
+
private client;
|
|
218
|
+
private initialized;
|
|
219
|
+
constructor(config: Required<AgentConfig>);
|
|
220
|
+
initialize(): Promise<void>;
|
|
221
|
+
shutdown(): Promise<void>;
|
|
222
|
+
execute(ctx: RequestContext, bus: ExecutionEventBus): Promise<void>;
|
|
223
|
+
cancelTask(taskId: string, bus: ExecutionEventBus): Promise<void>;
|
|
224
|
+
private extractText;
|
|
225
|
+
}
|
|
226
|
+
declare function createOpenCodeExecutor(config: Required<AgentConfig>): A2AExecutor;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Codex A2A Executor
|
|
230
|
+
*
|
|
231
|
+
* Bridges the local Codex CLI to the A2A protocol. Spawns Codex as a
|
|
232
|
+
* child process for each request and captures stdout as the response.
|
|
233
|
+
*/
|
|
234
|
+
|
|
235
|
+
declare class CodexExecutor implements A2AExecutor {
|
|
236
|
+
private config;
|
|
237
|
+
private client;
|
|
238
|
+
private initialized;
|
|
239
|
+
constructor(config: Required<AgentConfig>);
|
|
240
|
+
initialize(): Promise<void>;
|
|
241
|
+
shutdown(): Promise<void>;
|
|
242
|
+
execute(ctx: RequestContext, bus: ExecutionEventBus): Promise<void>;
|
|
243
|
+
cancelTask(taskId: string, bus: ExecutionEventBus): Promise<void>;
|
|
244
|
+
private extractText;
|
|
245
|
+
}
|
|
246
|
+
declare function createCodexExecutor(config: Required<AgentConfig>): A2AExecutor;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Claude Code A2A Executor
|
|
250
|
+
*
|
|
251
|
+
* Bridges the local Claude Code CLI to the A2A protocol. Spawns Claude Code
|
|
252
|
+
* in non-interactive print mode (`-p`) for each request and captures stdout
|
|
253
|
+
* as the response.
|
|
254
|
+
*/
|
|
255
|
+
|
|
256
|
+
declare class ClaudeExecutor implements A2AExecutor {
|
|
257
|
+
private config;
|
|
258
|
+
private client;
|
|
259
|
+
private initialized;
|
|
260
|
+
constructor(config: Required<AgentConfig>);
|
|
261
|
+
initialize(): Promise<void>;
|
|
262
|
+
shutdown(): Promise<void>;
|
|
263
|
+
execute(ctx: RequestContext, bus: ExecutionEventBus): Promise<void>;
|
|
264
|
+
cancelTask(taskId: string, bus: ExecutionEventBus): Promise<void>;
|
|
265
|
+
private extractText;
|
|
266
|
+
}
|
|
267
|
+
declare function createClaudeExecutor(config: Required<AgentConfig>): A2AExecutor;
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Lightweight structured logger for the CLI A2A gateway.
|
|
271
|
+
*
|
|
272
|
+
* Uses pino-compatible structured logging. In production mode the output is
|
|
273
|
+
* JSON; in dev mode it is pretty-printed via pino-pretty.
|
|
274
|
+
*/
|
|
275
|
+
declare enum LogLevel {
|
|
276
|
+
DEBUG = 10,
|
|
277
|
+
INFO = 20,
|
|
278
|
+
WARN = 30,
|
|
279
|
+
ERROR = 40
|
|
280
|
+
}
|
|
281
|
+
declare class Logger {
|
|
282
|
+
private level;
|
|
283
|
+
private name;
|
|
284
|
+
constructor(name: string);
|
|
285
|
+
setLevel(level: LogLevel): void;
|
|
286
|
+
child(name: string): Logger;
|
|
287
|
+
debug(msg: string, ctx?: Record<string, unknown>): void;
|
|
288
|
+
info(msg: string, ctx?: Record<string, unknown>): void;
|
|
289
|
+
warn(msg: string, ctx?: Record<string, unknown>): void;
|
|
290
|
+
error(msg: string, ctx?: Record<string, unknown>): void;
|
|
291
|
+
private log;
|
|
292
|
+
}
|
|
293
|
+
declare const logger: Logger;
|
|
294
|
+
|
|
295
|
+
export { type A2AExecutor, type AgentCardConfig, type AgentConfig, type ClaudeCodeConfig, ClaudeExecutor, type CodexConfig, CodexExecutor, type ExecutorFactory, type FeatureFlags, LogLevel, type LoggingConfig, type OpenCodeConfig, OpenCodeExecutor, type ProviderType, type ServerConfig, type ServerHandle, type SessionConfig, type SkillConfig, type TimeoutConfig, createA2AServer, createClaudeExecutor, createCodexExecutor, createExecutor, createOpenCodeExecutor, getExecutor, loadConfigFile, logger, registerExecutor, resolveConfig };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import { AgentExecutor, RequestContext, ExecutionEventBus } from '@a2a-js/sdk/server';
|
|
3
|
+
export { AgentExecutor, ExecutionEventBus, RequestContext } from '@a2a-js/sdk/server';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Unified configuration types for the CLI A2A gateway.
|
|
7
|
+
*
|
|
8
|
+
* Each provider (OpenCode, Codex, Claude Code) extends the base config
|
|
9
|
+
* with its own connection settings. A single config file can declare
|
|
10
|
+
* multiple providers, and the CLI selects one at startup via --provider.
|
|
11
|
+
*/
|
|
12
|
+
interface AgentCardConfig {
|
|
13
|
+
/** Human-readable agent name */
|
|
14
|
+
name: string;
|
|
15
|
+
/** Agent description shown to orchestrators / callers */
|
|
16
|
+
description: string;
|
|
17
|
+
/** Protocol version (default: "0.3.0") */
|
|
18
|
+
protocolVersion?: string;
|
|
19
|
+
/** Agent version string */
|
|
20
|
+
version?: string;
|
|
21
|
+
/** Skills advertised on the agent card */
|
|
22
|
+
skills?: SkillConfig[];
|
|
23
|
+
/** Supported input modes */
|
|
24
|
+
defaultInputModes?: string[];
|
|
25
|
+
/** Supported output modes */
|
|
26
|
+
defaultOutputModes?: string[];
|
|
27
|
+
/** Enable streaming */
|
|
28
|
+
streaming?: boolean;
|
|
29
|
+
/** Enable push notifications */
|
|
30
|
+
pushNotifications?: boolean;
|
|
31
|
+
/** Provider info */
|
|
32
|
+
provider?: {
|
|
33
|
+
organization: string;
|
|
34
|
+
url?: string;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
interface SkillConfig {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
description: string;
|
|
41
|
+
tags?: string[];
|
|
42
|
+
examples?: string[];
|
|
43
|
+
}
|
|
44
|
+
interface ServerConfig {
|
|
45
|
+
/** A2A server port */
|
|
46
|
+
port?: number;
|
|
47
|
+
/** Bind address */
|
|
48
|
+
hostname?: string;
|
|
49
|
+
/** Hostname advertised in agent card URLs */
|
|
50
|
+
advertiseHost?: string;
|
|
51
|
+
/** Protocol for advertised URLs */
|
|
52
|
+
advertiseProtocol?: 'http' | 'https';
|
|
53
|
+
}
|
|
54
|
+
interface SessionConfig {
|
|
55
|
+
/** Session title prefix */
|
|
56
|
+
titlePrefix?: string;
|
|
57
|
+
/** Reuse sessions by A2A contextId */
|
|
58
|
+
reuseByContext?: boolean;
|
|
59
|
+
/** Session TTL in ms */
|
|
60
|
+
ttl?: number;
|
|
61
|
+
/** Cleanup interval in ms */
|
|
62
|
+
cleanupInterval?: number;
|
|
63
|
+
}
|
|
64
|
+
interface FeatureFlags {
|
|
65
|
+
/** Auto-approve all permission requests */
|
|
66
|
+
autoApprovePermissions?: boolean;
|
|
67
|
+
/** Auto-answer question prompts */
|
|
68
|
+
autoAnswerQuestions?: boolean;
|
|
69
|
+
/** Stream artifact chunks individually vs buffer */
|
|
70
|
+
streamArtifactChunks?: boolean;
|
|
71
|
+
/** Enable polling fallback on SSE failure */
|
|
72
|
+
enablePollingFallback?: boolean;
|
|
73
|
+
}
|
|
74
|
+
interface TimeoutConfig {
|
|
75
|
+
/** Timeout for a single prompt in ms */
|
|
76
|
+
prompt?: number;
|
|
77
|
+
/** Polling interval in ms */
|
|
78
|
+
pollingInterval?: number;
|
|
79
|
+
/** Health check interval in ms */
|
|
80
|
+
healthCheck?: number;
|
|
81
|
+
}
|
|
82
|
+
interface LoggingConfig {
|
|
83
|
+
/** Log level */
|
|
84
|
+
level?: 'debug' | 'info' | 'warn' | 'error';
|
|
85
|
+
}
|
|
86
|
+
interface OpenCodeConfig {
|
|
87
|
+
/** OpenCode server base URL */
|
|
88
|
+
baseUrl?: string;
|
|
89
|
+
/** Target project directory */
|
|
90
|
+
projectDirectory?: string;
|
|
91
|
+
/** Model identifier (e.g. "anthropic/claude-sonnet-4-20250514") */
|
|
92
|
+
model?: string;
|
|
93
|
+
/** Agent preset name */
|
|
94
|
+
agent?: string;
|
|
95
|
+
/** System prompt */
|
|
96
|
+
systemPrompt?: string;
|
|
97
|
+
/** How system prompt is applied */
|
|
98
|
+
systemPromptMode?: 'append' | 'replace';
|
|
99
|
+
/** Context file name */
|
|
100
|
+
contextFile?: string;
|
|
101
|
+
/** Prompt for building context */
|
|
102
|
+
contextPrompt?: string;
|
|
103
|
+
}
|
|
104
|
+
interface CodexConfig {
|
|
105
|
+
/** Codex CLI path */
|
|
106
|
+
cliPath?: string;
|
|
107
|
+
/** Working directory */
|
|
108
|
+
workdir?: string;
|
|
109
|
+
/** Model identifier */
|
|
110
|
+
model?: string;
|
|
111
|
+
/** API key for OpenAI */
|
|
112
|
+
apiKey?: string;
|
|
113
|
+
}
|
|
114
|
+
interface ClaudeCodeConfig {
|
|
115
|
+
/** Claude Code CLI path */
|
|
116
|
+
cliPath?: string;
|
|
117
|
+
/** Working directory */
|
|
118
|
+
workdir?: string;
|
|
119
|
+
/** Model identifier */
|
|
120
|
+
model?: string;
|
|
121
|
+
/** API key for Anthropic */
|
|
122
|
+
apiKey?: string;
|
|
123
|
+
}
|
|
124
|
+
type ProviderType = 'opencode' | 'codex' | 'claude';
|
|
125
|
+
interface AgentConfig {
|
|
126
|
+
/** Active provider to use */
|
|
127
|
+
provider: ProviderType;
|
|
128
|
+
/** Agent card identity */
|
|
129
|
+
agentCard: AgentCardConfig;
|
|
130
|
+
/** Server settings */
|
|
131
|
+
server?: ServerConfig;
|
|
132
|
+
/** Session management */
|
|
133
|
+
session?: SessionConfig;
|
|
134
|
+
/** Feature flags */
|
|
135
|
+
features?: FeatureFlags;
|
|
136
|
+
/** Timeout settings */
|
|
137
|
+
timeouts?: TimeoutConfig;
|
|
138
|
+
/** Logging settings */
|
|
139
|
+
logging?: LoggingConfig;
|
|
140
|
+
/** Provider-specific connection configs */
|
|
141
|
+
opencode?: OpenCodeConfig;
|
|
142
|
+
codex?: CodexConfig;
|
|
143
|
+
claude?: ClaudeCodeConfig;
|
|
144
|
+
/** Directory containing config file (populated at runtime) */
|
|
145
|
+
configDir?: string;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Config loader — reads JSON config files and resolves the final config
|
|
150
|
+
* by merging layers: defaults ← config file ← env overrides ← CLI args.
|
|
151
|
+
*/
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Read and parse a JSON config file.
|
|
155
|
+
*/
|
|
156
|
+
declare function loadConfigFile(filePath: string): Partial<AgentConfig>;
|
|
157
|
+
/**
|
|
158
|
+
* Resolve full config from defaults + file + env.
|
|
159
|
+
*/
|
|
160
|
+
declare function resolveConfig(configPath?: string, cliOverrides?: Partial<AgentConfig>): Required<AgentConfig>;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* A2A HTTP Server
|
|
164
|
+
*
|
|
165
|
+
* Creates an Express server with standard A2A endpoints:
|
|
166
|
+
* - GET /.well-known/agent-card.json → Agent Card
|
|
167
|
+
* - POST /a2a/jsonrpc → JSON-RPC transport
|
|
168
|
+
* - POST /a2a/rest → REST transport
|
|
169
|
+
* - GET /health → Health check
|
|
170
|
+
*/
|
|
171
|
+
|
|
172
|
+
interface ServerHandle {
|
|
173
|
+
app: ReturnType<typeof express>;
|
|
174
|
+
server: ReturnType<ReturnType<typeof express>['listen']>;
|
|
175
|
+
shutdown(): Promise<void>;
|
|
176
|
+
}
|
|
177
|
+
declare function createA2AServer(config: Required<AgentConfig>): Promise<ServerHandle>;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Executor types and common interfaces for CLI A2A providers.
|
|
181
|
+
*
|
|
182
|
+
* Each provider (OpenCode, Codex, Claude) implements its own executor
|
|
183
|
+
* conforming to the A2AExecutor interface which extends the SDK's
|
|
184
|
+
* AgentExecutor with lifecycle methods (initialize, shutdown).
|
|
185
|
+
*/
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Extended executor interface with lifecycle methods.
|
|
189
|
+
*
|
|
190
|
+
* The base AgentExecutor from @a2a-js/sdk only defines execute() and
|
|
191
|
+
* cancelTask(). We add initialize() for server setup and shutdown()
|
|
192
|
+
* for graceful cleanup.
|
|
193
|
+
*/
|
|
194
|
+
interface A2AExecutor extends AgentExecutor {
|
|
195
|
+
initialize(): Promise<void>;
|
|
196
|
+
shutdown(): Promise<void>;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Factory function type: given resolved config, produce an executor.
|
|
201
|
+
*/
|
|
202
|
+
type ExecutorFactory = (config: Required<AgentConfig>) => A2AExecutor;
|
|
203
|
+
declare function registerExecutor(provider: ProviderType, factory: ExecutorFactory): void;
|
|
204
|
+
declare function getExecutor(provider: ProviderType): ExecutorFactory | undefined;
|
|
205
|
+
declare function createExecutor(config: Required<AgentConfig>): A2AExecutor;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* OpenCode A2A Executor
|
|
209
|
+
*
|
|
210
|
+
* Bridges the local OpenCode CLI to the A2A protocol. Spawns `opencode run`
|
|
211
|
+
* as a child process for each request and captures stdout as the response.
|
|
212
|
+
* Same spawn pattern as Codex and Claude Code executors.
|
|
213
|
+
*/
|
|
214
|
+
|
|
215
|
+
declare class OpenCodeExecutor implements A2AExecutor {
|
|
216
|
+
private config;
|
|
217
|
+
private client;
|
|
218
|
+
private initialized;
|
|
219
|
+
constructor(config: Required<AgentConfig>);
|
|
220
|
+
initialize(): Promise<void>;
|
|
221
|
+
shutdown(): Promise<void>;
|
|
222
|
+
execute(ctx: RequestContext, bus: ExecutionEventBus): Promise<void>;
|
|
223
|
+
cancelTask(taskId: string, bus: ExecutionEventBus): Promise<void>;
|
|
224
|
+
private extractText;
|
|
225
|
+
}
|
|
226
|
+
declare function createOpenCodeExecutor(config: Required<AgentConfig>): A2AExecutor;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Codex A2A Executor
|
|
230
|
+
*
|
|
231
|
+
* Bridges the local Codex CLI to the A2A protocol. Spawns Codex as a
|
|
232
|
+
* child process for each request and captures stdout as the response.
|
|
233
|
+
*/
|
|
234
|
+
|
|
235
|
+
declare class CodexExecutor implements A2AExecutor {
|
|
236
|
+
private config;
|
|
237
|
+
private client;
|
|
238
|
+
private initialized;
|
|
239
|
+
constructor(config: Required<AgentConfig>);
|
|
240
|
+
initialize(): Promise<void>;
|
|
241
|
+
shutdown(): Promise<void>;
|
|
242
|
+
execute(ctx: RequestContext, bus: ExecutionEventBus): Promise<void>;
|
|
243
|
+
cancelTask(taskId: string, bus: ExecutionEventBus): Promise<void>;
|
|
244
|
+
private extractText;
|
|
245
|
+
}
|
|
246
|
+
declare function createCodexExecutor(config: Required<AgentConfig>): A2AExecutor;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Claude Code A2A Executor
|
|
250
|
+
*
|
|
251
|
+
* Bridges the local Claude Code CLI to the A2A protocol. Spawns Claude Code
|
|
252
|
+
* in non-interactive print mode (`-p`) for each request and captures stdout
|
|
253
|
+
* as the response.
|
|
254
|
+
*/
|
|
255
|
+
|
|
256
|
+
declare class ClaudeExecutor implements A2AExecutor {
|
|
257
|
+
private config;
|
|
258
|
+
private client;
|
|
259
|
+
private initialized;
|
|
260
|
+
constructor(config: Required<AgentConfig>);
|
|
261
|
+
initialize(): Promise<void>;
|
|
262
|
+
shutdown(): Promise<void>;
|
|
263
|
+
execute(ctx: RequestContext, bus: ExecutionEventBus): Promise<void>;
|
|
264
|
+
cancelTask(taskId: string, bus: ExecutionEventBus): Promise<void>;
|
|
265
|
+
private extractText;
|
|
266
|
+
}
|
|
267
|
+
declare function createClaudeExecutor(config: Required<AgentConfig>): A2AExecutor;
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Lightweight structured logger for the CLI A2A gateway.
|
|
271
|
+
*
|
|
272
|
+
* Uses pino-compatible structured logging. In production mode the output is
|
|
273
|
+
* JSON; in dev mode it is pretty-printed via pino-pretty.
|
|
274
|
+
*/
|
|
275
|
+
declare enum LogLevel {
|
|
276
|
+
DEBUG = 10,
|
|
277
|
+
INFO = 20,
|
|
278
|
+
WARN = 30,
|
|
279
|
+
ERROR = 40
|
|
280
|
+
}
|
|
281
|
+
declare class Logger {
|
|
282
|
+
private level;
|
|
283
|
+
private name;
|
|
284
|
+
constructor(name: string);
|
|
285
|
+
setLevel(level: LogLevel): void;
|
|
286
|
+
child(name: string): Logger;
|
|
287
|
+
debug(msg: string, ctx?: Record<string, unknown>): void;
|
|
288
|
+
info(msg: string, ctx?: Record<string, unknown>): void;
|
|
289
|
+
warn(msg: string, ctx?: Record<string, unknown>): void;
|
|
290
|
+
error(msg: string, ctx?: Record<string, unknown>): void;
|
|
291
|
+
private log;
|
|
292
|
+
}
|
|
293
|
+
declare const logger: Logger;
|
|
294
|
+
|
|
295
|
+
export { type A2AExecutor, type AgentCardConfig, type AgentConfig, type ClaudeCodeConfig, ClaudeExecutor, type CodexConfig, CodexExecutor, type ExecutorFactory, type FeatureFlags, LogLevel, type LoggingConfig, type OpenCodeConfig, OpenCodeExecutor, type ProviderType, type ServerConfig, type ServerHandle, type SessionConfig, type SkillConfig, type TimeoutConfig, createA2AServer, createClaudeExecutor, createCodexExecutor, createExecutor, createOpenCodeExecutor, getExecutor, loadConfigFile, logger, registerExecutor, resolveConfig };
|