a2a-codex 1.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.
- package/README.md +451 -0
- package/agents/example/config.json +66 -0
- package/agents/example/start.sh +39 -0
- package/agents/example/workspace/.gitkeep +0 -0
- package/agents/multi-agent/config.json +77 -0
- package/agents/multi-agent/start.sh +36 -0
- package/agents/multi-agent/workspace/.gitkeep +0 -0
- package/agents/read-only-reviewer/config.json +50 -0
- package/agents/read-only-reviewer/start.sh +32 -0
- package/agents/read-only-reviewer/workspace/.gitkeep +0 -0
- package/dist/cli.d.ts +17 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +175 -0
- package/dist/cli.js.map +1 -0
- package/dist/codex/backend-paths.d.ts +12 -0
- package/dist/codex/backend-paths.d.ts.map +1 -0
- package/dist/codex/backend-paths.js +14 -0
- package/dist/codex/backend-paths.js.map +1 -0
- package/dist/codex/capabilities.d.ts +21 -0
- package/dist/codex/capabilities.d.ts.map +1 -0
- package/dist/codex/capabilities.js +16 -0
- package/dist/codex/capabilities.js.map +1 -0
- package/dist/codex/client-factory.d.ts +65 -0
- package/dist/codex/client-factory.d.ts.map +1 -0
- package/dist/codex/client-factory.js +36 -0
- package/dist/codex/client-factory.js.map +1 -0
- package/dist/codex/event-mapper.d.ts +33 -0
- package/dist/codex/event-mapper.d.ts.map +1 -0
- package/dist/codex/event-mapper.js +248 -0
- package/dist/codex/event-mapper.js.map +1 -0
- package/dist/codex/executor.d.ts +29 -0
- package/dist/codex/executor.d.ts.map +1 -0
- package/dist/codex/executor.js +282 -0
- package/dist/codex/executor.js.map +1 -0
- package/dist/codex/index.d.ts +8 -0
- package/dist/codex/index.d.ts.map +1 -0
- package/dist/codex/index.js +7 -0
- package/dist/codex/index.js.map +1 -0
- package/dist/codex/mcp-adapter.d.ts +29 -0
- package/dist/codex/mcp-adapter.d.ts.map +1 -0
- package/dist/codex/mcp-adapter.js +104 -0
- package/dist/codex/mcp-adapter.js.map +1 -0
- package/dist/codex/prompt-builder.d.ts +9 -0
- package/dist/codex/prompt-builder.d.ts.map +1 -0
- package/dist/codex/prompt-builder.js +16 -0
- package/dist/codex/prompt-builder.js.map +1 -0
- package/dist/codex/session-manager.d.ts +54 -0
- package/dist/codex/session-manager.d.ts.map +1 -0
- package/dist/codex/session-manager.js +124 -0
- package/dist/codex/session-manager.js.map +1 -0
- package/dist/config/defaults.d.ts +9 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +60 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/loader.d.ts +16 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +152 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/types.d.ts +224 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +8 -0
- package/dist/config/types.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/server/agent-card.d.ts +7 -0
- package/dist/server/agent-card.d.ts.map +1 -0
- package/dist/server/agent-card.js +20 -0
- package/dist/server/agent-card.js.map +1 -0
- package/dist/server/index.d.ts +22 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +123 -0
- package/dist/server/index.js.map +1 -0
- package/dist/utils/logger.d.ts +30 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +64 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +73 -0
- package/schemas/agent-config.schema.json +615 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Configuration — Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* All configurable aspects of an A2A Codex agent deployment.
|
|
5
|
+
* A single JSON file (or programmatic object) drives the entire wrapper.
|
|
6
|
+
*/
|
|
7
|
+
import type { EventsConfig, MemoryConfig, SubAgentsConfig } from "@a2a-wrapper/core";
|
|
8
|
+
export interface SkillConfig {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
tags?: string[];
|
|
13
|
+
examples?: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface AgentCardConfig {
|
|
16
|
+
name: string;
|
|
17
|
+
description: string;
|
|
18
|
+
protocolVersion?: string;
|
|
19
|
+
version?: string;
|
|
20
|
+
skills?: SkillConfig[];
|
|
21
|
+
defaultInputModes?: string[];
|
|
22
|
+
defaultOutputModes?: string[];
|
|
23
|
+
streaming?: boolean;
|
|
24
|
+
pushNotifications?: boolean;
|
|
25
|
+
/** @deprecated Kept for backward compatibility. Ignored by the agent card builder. */
|
|
26
|
+
stateTransitionHistory?: boolean;
|
|
27
|
+
provider?: {
|
|
28
|
+
organization: string;
|
|
29
|
+
url?: string;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export interface ServerConfig {
|
|
33
|
+
port?: number;
|
|
34
|
+
hostname?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Hostname advertised in agent card URLs (default: "localhost").
|
|
37
|
+
* Set to machine IP or "host.containers.internal" for Docker.
|
|
38
|
+
*/
|
|
39
|
+
advertiseHost?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Protocol used in advertised URLs (default: "http").
|
|
42
|
+
* Set to "https" when deployed behind TLS or a TLS-terminating reverse proxy.
|
|
43
|
+
*/
|
|
44
|
+
advertiseProtocol?: "http" | "https";
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* OpenAI Codex SDK connection and execution settings.
|
|
48
|
+
*
|
|
49
|
+
* All fields map to @openai/codex-sdk ThreadOptions or CodexOptions.
|
|
50
|
+
* The `workingDirectory` field is required at runtime — it must resolve to an
|
|
51
|
+
* existing Git repository directory (unless skipGitRepoCheck is true).
|
|
52
|
+
*/
|
|
53
|
+
export interface CodexConfig {
|
|
54
|
+
/**
|
|
55
|
+
* Absolute path to the Git repository Codex should operate on.
|
|
56
|
+
* Required at runtime (validated by the executor). Supports ${ENV_VAR} substitution.
|
|
57
|
+
*/
|
|
58
|
+
workingDirectory?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Model to use (e.g. "o4-mini", "gpt-4o"). Falls back to Codex default when omitted.
|
|
61
|
+
* Supports ${CODEX_MODEL} environment variable substitution.
|
|
62
|
+
*/
|
|
63
|
+
model?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Codex sandbox mode controlling filesystem access.
|
|
66
|
+
* - "read-only" — analysis and review tasks; no file writes
|
|
67
|
+
* - "workspace-write" — recommended default; writes scoped to workingDirectory
|
|
68
|
+
* - "danger-full-access" — unrestricted; requires explicit opt-in and logs a warning
|
|
69
|
+
* @default "workspace-write"
|
|
70
|
+
*/
|
|
71
|
+
sandboxMode?: "read-only" | "workspace-write" | "danger-full-access";
|
|
72
|
+
/**
|
|
73
|
+
* Tool approval policy for shell commands and MCP tool calls.
|
|
74
|
+
* - "never" — auto-approve all (recommended for headless A2A operation)
|
|
75
|
+
* - "on-failure" — approve only on command failure
|
|
76
|
+
* - "untrusted" — approve tools from untrusted sources
|
|
77
|
+
* - "on-request" — blocked; interactive approvals are incompatible with headless A2A
|
|
78
|
+
* @default "never"
|
|
79
|
+
*/
|
|
80
|
+
approvalPolicy?: "never" | "on-request" | "on-failure" | "untrusted";
|
|
81
|
+
/**
|
|
82
|
+
* Allow Codex to make outbound network requests.
|
|
83
|
+
* Disabled by default for security. Enable only when explicitly required.
|
|
84
|
+
* @default false
|
|
85
|
+
*/
|
|
86
|
+
networkAccessEnabled?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Web search access for Codex.
|
|
89
|
+
* - "disabled" — no web search (default, secure)
|
|
90
|
+
* - "cached" — use cached search results only
|
|
91
|
+
* - "live" — live web search (requires networkAccessEnabled: true)
|
|
92
|
+
* @default "disabled"
|
|
93
|
+
*/
|
|
94
|
+
webSearchMode?: "disabled" | "cached" | "live";
|
|
95
|
+
/**
|
|
96
|
+
* Skip Codex's built-in Git repository validation check.
|
|
97
|
+
* Leave false to ensure the workspace is a real git repo.
|
|
98
|
+
* @default false
|
|
99
|
+
*/
|
|
100
|
+
skipGitRepoCheck?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Additional directories to make accessible to Codex beyond workingDirectory.
|
|
103
|
+
* Each path supports ${ENV_VAR} substitution. Use with care.
|
|
104
|
+
*/
|
|
105
|
+
additionalDirectories?: string[];
|
|
106
|
+
/**
|
|
107
|
+
* Instructions prepended to every Codex prompt as developer context.
|
|
108
|
+
* Use to enforce coding standards, tool usage rules, and safety constraints.
|
|
109
|
+
*/
|
|
110
|
+
developerInstructions?: string;
|
|
111
|
+
/** Override the OpenAI API base URL (useful for corporate proxies). */
|
|
112
|
+
baseUrl?: string;
|
|
113
|
+
/** Override the path to the Codex CLI binary. */
|
|
114
|
+
codexPathOverride?: string;
|
|
115
|
+
/**
|
|
116
|
+
* Additional Codex configuration overrides passed as CodexOptions.config.
|
|
117
|
+
* Mapped to --config key=value CLI arguments. See Codex config reference.
|
|
118
|
+
*/
|
|
119
|
+
configOverrides?: Record<string, unknown>;
|
|
120
|
+
/**
|
|
121
|
+
* Filename for the pre-built domain context file within workingDirectory.
|
|
122
|
+
* @default "context.md"
|
|
123
|
+
*/
|
|
124
|
+
contextFile?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Default prompt used when buildContext() is called without an explicit prompt.
|
|
127
|
+
*/
|
|
128
|
+
contextPrompt?: string;
|
|
129
|
+
}
|
|
130
|
+
export interface SessionConfig {
|
|
131
|
+
titlePrefix?: string;
|
|
132
|
+
/** Reuse sessions by A2A contextId (default: true) */
|
|
133
|
+
reuseByContext?: boolean;
|
|
134
|
+
/** Session TTL in ms (default: 3_600_000 = 1 hour) */
|
|
135
|
+
ttl?: number;
|
|
136
|
+
/** Session cleanup interval in ms (default: 300_000 = 5 min) */
|
|
137
|
+
cleanupInterval?: number;
|
|
138
|
+
}
|
|
139
|
+
export interface FeatureFlags {
|
|
140
|
+
/**
|
|
141
|
+
* Stream artifact chunks individually (A2A spec-correct) vs buffer and send
|
|
142
|
+
* single artifact (inspector-compatible). Default: false (buffered).
|
|
143
|
+
*/
|
|
144
|
+
streamArtifactChunks?: boolean;
|
|
145
|
+
/** Publish reasoning summaries as thinking sideband events. Default: true. */
|
|
146
|
+
emitReasoningSummaries?: boolean;
|
|
147
|
+
/** Publish shell command start/end as tool_call sideband events. Default: true. */
|
|
148
|
+
emitCommandEvents?: boolean;
|
|
149
|
+
/** Publish file change metadata as sideband events. Default: true. */
|
|
150
|
+
emitFileChangeEvents?: boolean;
|
|
151
|
+
}
|
|
152
|
+
export interface TimeoutConfig {
|
|
153
|
+
/** Timeout for a single prompt in ms (default: 600_000 = 10 min) */
|
|
154
|
+
prompt?: number;
|
|
155
|
+
}
|
|
156
|
+
export interface LoggingConfig {
|
|
157
|
+
level?: string;
|
|
158
|
+
}
|
|
159
|
+
export interface McpStdioServerConfig {
|
|
160
|
+
type: "stdio";
|
|
161
|
+
/** Command to launch the MCP server. */
|
|
162
|
+
command: string;
|
|
163
|
+
/** Arguments. Values support ${ENV_VAR} substitution. */
|
|
164
|
+
args?: string[];
|
|
165
|
+
/** Environment variables for the spawned process. Values support ${ENV_VAR} substitution. */
|
|
166
|
+
env?: Record<string, string>;
|
|
167
|
+
enabled?: boolean;
|
|
168
|
+
/** MCP server startup timeout in seconds. */
|
|
169
|
+
startupTimeoutSec?: number;
|
|
170
|
+
/** Per-tool call timeout in seconds. */
|
|
171
|
+
toolTimeoutSec?: number;
|
|
172
|
+
/** Allowlist of tool names to expose. If set, only these tools are accessible. */
|
|
173
|
+
enabledTools?: string[];
|
|
174
|
+
/** Denylist of tool names to block. */
|
|
175
|
+
disabledTools?: string[];
|
|
176
|
+
}
|
|
177
|
+
export interface McpHttpServerConfig {
|
|
178
|
+
type: "http";
|
|
179
|
+
/** URL of the Streamable HTTP MCP server. */
|
|
180
|
+
url: string;
|
|
181
|
+
/**
|
|
182
|
+
* HTTP headers sent with every request.
|
|
183
|
+
* Values support ${ENV_VAR} substitution.
|
|
184
|
+
* Use for bearer tokens: { "Authorization": "Bearer ${TOKEN}" }
|
|
185
|
+
*/
|
|
186
|
+
headers?: Record<string, string>;
|
|
187
|
+
enabled?: boolean;
|
|
188
|
+
toolTimeoutSec?: number;
|
|
189
|
+
}
|
|
190
|
+
export type McpServerConfig = McpStdioServerConfig | McpHttpServerConfig | {
|
|
191
|
+
type: string;
|
|
192
|
+
[k: string]: unknown;
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Complete agent configuration.
|
|
196
|
+
*
|
|
197
|
+
* This is what a JSON config file (e.g. `agents/example/config.json`) maps to.
|
|
198
|
+
* All fields except `agentCard` are optional — sensible secure defaults are applied.
|
|
199
|
+
*/
|
|
200
|
+
export interface AgentConfig {
|
|
201
|
+
agentCard: AgentCardConfig;
|
|
202
|
+
server?: ServerConfig;
|
|
203
|
+
/** Codex SDK connection and execution settings. */
|
|
204
|
+
codex?: CodexConfig;
|
|
205
|
+
session?: SessionConfig;
|
|
206
|
+
features?: FeatureFlags;
|
|
207
|
+
timeouts?: TimeoutConfig;
|
|
208
|
+
logging?: LoggingConfig;
|
|
209
|
+
/**
|
|
210
|
+
* MCP servers to register with Codex at startup.
|
|
211
|
+
* Keys are server names; values are stdio or http server configs.
|
|
212
|
+
* The key "a2a-subagents" is reserved for the sub-agent bridge.
|
|
213
|
+
*/
|
|
214
|
+
mcp?: Record<string, McpServerConfig>;
|
|
215
|
+
events?: EventsConfig;
|
|
216
|
+
memory?: MemoryConfig;
|
|
217
|
+
subAgents?: SubAgentsConfig;
|
|
218
|
+
/**
|
|
219
|
+
* Directory containing the agent's config.json file.
|
|
220
|
+
* Populated automatically by the CLI loader. Do not set manually.
|
|
221
|
+
*/
|
|
222
|
+
configDir?: string;
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../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,CAAC,EAAE,YAAY,CAAC;IACxB,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACtC,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* a2a-codex — Public API
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the executor, config types, and backend constants for
|
|
5
|
+
* programmatic use without importing subdirectory modules directly.
|
|
6
|
+
*/
|
|
7
|
+
export { CodexExecutor } from "./codex/executor.js";
|
|
8
|
+
export { SessionManager } from "./codex/session-manager.js";
|
|
9
|
+
export { EventMapper } from "./codex/event-mapper.js";
|
|
10
|
+
export { CODEX_BACKEND_PATHS } from "./codex/backend-paths.js";
|
|
11
|
+
export { CODEX_CAPABILITIES } from "./codex/capabilities.js";
|
|
12
|
+
export { createCodexClient } from "./codex/client-factory.js";
|
|
13
|
+
export type { CodexClientLike, CodexThreadLike, ThreadEventLike, ThreadItemLike, } from "./codex/client-factory.js";
|
|
14
|
+
export type { AgentConfig, CodexConfig, FeatureFlags, McpStdioServerConfig, McpHttpServerConfig, McpServerConfig, } from "./config/types.js";
|
|
15
|
+
export { DEFAULTS } from "./config/defaults.js";
|
|
16
|
+
export { resolveConfig, loadConfigFile, loadEnvOverrides } from "./config/loader.js";
|
|
17
|
+
export { createA2AServer } from "./server/index.js";
|
|
18
|
+
export type { ServerHandle } from "./server/index.js";
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,YAAY,EACV,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,GACf,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,WAAW,EACX,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* a2a-codex — Public API
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the executor, config types, and backend constants for
|
|
5
|
+
* programmatic use without importing subdirectory modules directly.
|
|
6
|
+
*/
|
|
7
|
+
export { CodexExecutor } from "./codex/executor.js";
|
|
8
|
+
export { SessionManager } from "./codex/session-manager.js";
|
|
9
|
+
export { EventMapper } from "./codex/event-mapper.js";
|
|
10
|
+
export { CODEX_BACKEND_PATHS } from "./codex/backend-paths.js";
|
|
11
|
+
export { CODEX_CAPABILITIES } from "./codex/capabilities.js";
|
|
12
|
+
export { createCodexClient } from "./codex/client-factory.js";
|
|
13
|
+
export { DEFAULTS } from "./config/defaults.js";
|
|
14
|
+
export { resolveConfig, loadConfigFile, loadEnvOverrides } from "./config/loader.js";
|
|
15
|
+
export { createA2AServer } from "./server/index.js";
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAe9D,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-card.d.ts","sourceRoot":"","sources":["../../src/server/agent-card.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAKtD,wBAAgB,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,SAAS,CAcvE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Card Builder
|
|
3
|
+
*/
|
|
4
|
+
import { buildAgentCard as coreBuildAgentCard } from "@a2a-wrapper/core";
|
|
5
|
+
import { logger } from "../utils/logger.js";
|
|
6
|
+
const log = logger.child("agent-card");
|
|
7
|
+
export function buildAgentCard(config) {
|
|
8
|
+
const { agentCard, server } = config;
|
|
9
|
+
const proto = server.advertiseProtocol ?? "http";
|
|
10
|
+
const host = server.advertiseHost ?? server.hostname ?? "localhost";
|
|
11
|
+
const port = server.port ?? 3020;
|
|
12
|
+
const card = coreBuildAgentCard({ agentCard, server });
|
|
13
|
+
log.info("Agent card built", {
|
|
14
|
+
name: card.name,
|
|
15
|
+
url: `${proto}://${host}:${port}`,
|
|
16
|
+
skills: card.skills.length,
|
|
17
|
+
});
|
|
18
|
+
return card;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=agent-card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-card.js","sourceRoot":"","sources":["../../src/server/agent-card.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEzE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;AAEvC,MAAM,UAAU,cAAc,CAAC,MAA6B;IAC1D,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IACrC,MAAM,KAAK,GAAG,MAAM,CAAC,iBAAiB,IAAI,MAAM,CAAC;IACjD,MAAM,IAAI,GAAG,MAAM,CAAC,aAAa,IAAI,MAAM,CAAC,QAAQ,IAAI,WAAW,CAAC;IACpE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC;IAEjC,MAAM,IAAI,GAAG,kBAAkB,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC;IAEvD,GAAG,CAAC,IAAI,CAAC,kBAAkB,EAAE;QAC3B,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,GAAG,EAAE,GAAG,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;QACjC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;KAC3B,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2A Server Bootstrap — a2a-codex
|
|
3
|
+
*
|
|
4
|
+
* Creates an Express server with:
|
|
5
|
+
* - /.well-known/agent-card.json → Agent Card
|
|
6
|
+
* - /a2a/jsonrpc → JSON-RPC transport
|
|
7
|
+
* - /a2a/rest → REST transport
|
|
8
|
+
* - /health → Health check
|
|
9
|
+
* - /context → Read context file
|
|
10
|
+
* - /context/build → Build context file (POST)
|
|
11
|
+
*/
|
|
12
|
+
import express from "express";
|
|
13
|
+
import type { AgentConfig } from "../config/types.js";
|
|
14
|
+
import { CodexExecutor } from "../codex/executor.js";
|
|
15
|
+
export interface ServerHandle {
|
|
16
|
+
app: ReturnType<typeof express>;
|
|
17
|
+
server: ReturnType<ReturnType<typeof express>["listen"]>;
|
|
18
|
+
executor: CodexExecutor;
|
|
19
|
+
shutdown(): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
export declare function createA2AServer(config: Required<AgentConfig>): Promise<ServerHandle>;
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,OAAgC,MAAM,SAAS,CAAC;AASvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAMrD,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;IAChC,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;IACzD,QAAQ,EAAE,aAAa,CAAC;IACxB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAED,wBAAsB,eAAe,CAAC,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAgH1F"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2A Server Bootstrap — a2a-codex
|
|
3
|
+
*
|
|
4
|
+
* Creates an Express server with:
|
|
5
|
+
* - /.well-known/agent-card.json → Agent Card
|
|
6
|
+
* - /a2a/jsonrpc → JSON-RPC transport
|
|
7
|
+
* - /a2a/rest → REST transport
|
|
8
|
+
* - /health → Health check
|
|
9
|
+
* - /context → Read context file
|
|
10
|
+
* - /context/build → Build context file (POST)
|
|
11
|
+
*/
|
|
12
|
+
import express from "express";
|
|
13
|
+
import { AGENT_CARD_PATH } from "@a2a-js/sdk";
|
|
14
|
+
import { DefaultRequestHandler, InMemoryTaskStore } from "@a2a-js/sdk/server";
|
|
15
|
+
import { jsonRpcHandler, restHandler, UserBuilder, } from "@a2a-js/sdk/server/express";
|
|
16
|
+
import { CodexExecutor } from "../codex/executor.js";
|
|
17
|
+
import { buildAgentCard } from "./agent-card.js";
|
|
18
|
+
import { logger } from "../utils/logger.js";
|
|
19
|
+
const log = logger.child("server");
|
|
20
|
+
export async function createA2AServer(config) {
|
|
21
|
+
const { server: srv } = config;
|
|
22
|
+
const port = srv.port ?? 3020;
|
|
23
|
+
const hostname = srv.hostname ?? "0.0.0.0";
|
|
24
|
+
const advertiseHost = srv.advertiseHost ?? "localhost";
|
|
25
|
+
const advertiseProto = srv.advertiseProtocol ?? "http";
|
|
26
|
+
// 1. Executor
|
|
27
|
+
const executor = new CodexExecutor(config);
|
|
28
|
+
await executor.initialize();
|
|
29
|
+
// 2. Agent card
|
|
30
|
+
const agentCard = buildAgentCard(config);
|
|
31
|
+
// 3. A2A request handler
|
|
32
|
+
const taskStore = new InMemoryTaskStore();
|
|
33
|
+
const requestHandler = new DefaultRequestHandler(agentCard, taskStore, executor);
|
|
34
|
+
// 4. Express app
|
|
35
|
+
const app = express();
|
|
36
|
+
app.use((_req, res, next) => {
|
|
37
|
+
res.setHeader("A2A-Version", "0.3");
|
|
38
|
+
next();
|
|
39
|
+
});
|
|
40
|
+
app.get("/health", (_req, res) => {
|
|
41
|
+
res.json({ status: "healthy", agent: agentCard.name });
|
|
42
|
+
});
|
|
43
|
+
// Dynamic agent card handler — rewrites endpoint URLs to match caller's Host header
|
|
44
|
+
const serveAgentCard = (req, res) => {
|
|
45
|
+
const host = req.headers.host || `${advertiseHost}:${port}`;
|
|
46
|
+
const proto = req.headers["x-forwarded-proto"] || advertiseProto;
|
|
47
|
+
const dynamicBase = `${proto}://${host}`;
|
|
48
|
+
const jsonRpcUrl = `${dynamicBase}/a2a/jsonrpc`;
|
|
49
|
+
const restUrl = `${dynamicBase}/a2a/rest`;
|
|
50
|
+
res.json({
|
|
51
|
+
...agentCard,
|
|
52
|
+
url: jsonRpcUrl,
|
|
53
|
+
additionalInterfaces: [
|
|
54
|
+
{ transport: "JSONRPC", url: jsonRpcUrl },
|
|
55
|
+
{ transport: "REST", url: restUrl },
|
|
56
|
+
],
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
app.get(`/${AGENT_CARD_PATH}`, serveAgentCard);
|
|
60
|
+
for (const p of [".well-known/agent.json", ".well-known/agent-json"]) {
|
|
61
|
+
if (p !== AGENT_CARD_PATH)
|
|
62
|
+
app.get(`/${p}`, serveAgentCard);
|
|
63
|
+
}
|
|
64
|
+
app.use("/a2a/jsonrpc", jsonRpcHandler({ requestHandler, userBuilder: UserBuilder.noAuthentication }));
|
|
65
|
+
app.use("/a2a/rest", restHandler({ requestHandler, userBuilder: UserBuilder.noAuthentication }));
|
|
66
|
+
// Context API
|
|
67
|
+
app.get("/context", async (_req, res) => {
|
|
68
|
+
try {
|
|
69
|
+
const content = await executor.getContextContent();
|
|
70
|
+
if (content === null) {
|
|
71
|
+
res.status(404).json({ error: "Context file not found. Use POST /context/build to create it." });
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
res.type("text/markdown").send(content);
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
log.error("Failed to read context", { error: e.message });
|
|
78
|
+
res.status(500).json({ error: e.message });
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
app.use("/context/build", express.json());
|
|
82
|
+
app.post("/context/build", async (req, res) => {
|
|
83
|
+
try {
|
|
84
|
+
const customPrompt = req.body?.prompt;
|
|
85
|
+
const response = await executor.buildContext(customPrompt);
|
|
86
|
+
const content = await executor.getContextContent();
|
|
87
|
+
res.json({ status: "completed", message: "Context file built successfully", response, context: content });
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
log.error("Context build failed", { error: e.message });
|
|
91
|
+
res.status(500).json({ error: e.message });
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
// 5. Start
|
|
95
|
+
const httpServer = app.listen(port, hostname, () => {
|
|
96
|
+
log.info("A2A server started", { bind: hostname, advertise: advertiseHost, port, proto: advertiseProto });
|
|
97
|
+
console.log(`
|
|
98
|
+
╔══════════════════════════════════════════════════════════════╗
|
|
99
|
+
║ Codex A2A Server ║
|
|
100
|
+
╠══════════════════════════════════════════════════════════════╣
|
|
101
|
+
║ Agent: ${agentCard.name}
|
|
102
|
+
║ Workspace: ${config.codex.workingDirectory}
|
|
103
|
+
║ Sandbox: ${config.codex.sandboxMode ?? "workspace-write"}
|
|
104
|
+
║ Bind: ${hostname}:${port}
|
|
105
|
+
║ Agent Card: ${advertiseProto}://${advertiseHost}:${port}/${AGENT_CARD_PATH}
|
|
106
|
+
║ JSON-RPC: ${advertiseProto}://${advertiseHost}:${port}/a2a/jsonrpc
|
|
107
|
+
║ REST API: ${advertiseProto}://${advertiseHost}:${port}/a2a/rest
|
|
108
|
+
║ Health: ${advertiseProto}://${advertiseHost}:${port}/health
|
|
109
|
+
╚══════════════════════════════════════════════════════════════╝
|
|
110
|
+
`);
|
|
111
|
+
});
|
|
112
|
+
return {
|
|
113
|
+
app,
|
|
114
|
+
server: httpServer,
|
|
115
|
+
executor,
|
|
116
|
+
async shutdown() {
|
|
117
|
+
httpServer.close();
|
|
118
|
+
await executor.shutdown();
|
|
119
|
+
log.info("Server shut down");
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,OAAgC,MAAM,SAAS,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EACL,cAAc,EACd,WAAW,EACX,WAAW,GACZ,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AASnC,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,MAA6B;IACjE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;IAC/B,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC;IAC9B,MAAM,QAAQ,GAAG,GAAG,CA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AU,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE;QACjD,GAAG,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,CAAC;QAC1G,OAAO,CAAC,GAAG,CAAC;;;;oBAII,SAAS,CAAC,IAAI;oBACd,MAAM,CAAC,KAAK,CAAC,gBAAgB;oBAC7B,MAAM,CAAC,KAAK,CAAC,WAAW,IAAI,iBAAiB;oBAC7C,QAAQ,IAAI,IAAI;oBAChB,cAAc,MAAM,aAAa,IAAI,IAAI,IAAI,eAAe;oBAC5D,cAAc,MAAM,aAAa,IAAI,IAAI;oBACzC,cAAc,MAAM,aAAa,IAAI,IAAI;oBACzC,cAAc,MAAM,aAAa,IAAI,IAAI;;KAExD,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,GAAG;QACH,MAAM,EAAE,UAAU;QAClB,QAAQ;QACR,KAAK,CAAC,QAAQ;YACZ,UAAU,CAAC,KAAK,EAAE,CAAC;YACnB,MAAM,QAAQ,CAAC,QAAQ,EAAE,CAAC;YAC1B,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC/B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured Logger
|
|
3
|
+
*
|
|
4
|
+
* Leveled, structured logging with child logger support.
|
|
5
|
+
* Output: [ISO timestamp] [LEVEL] [name] message { data }
|
|
6
|
+
*/
|
|
7
|
+
export declare enum LogLevel {
|
|
8
|
+
DEBUG = 0,
|
|
9
|
+
INFO = 1,
|
|
10
|
+
WARN = 2,
|
|
11
|
+
ERROR = 3
|
|
12
|
+
}
|
|
13
|
+
export declare class Logger {
|
|
14
|
+
private readonly name;
|
|
15
|
+
private readonly levelRef;
|
|
16
|
+
constructor(name: string, level?: LogLevel | {
|
|
17
|
+
value: LogLevel;
|
|
18
|
+
});
|
|
19
|
+
setLevel(level: LogLevel): void;
|
|
20
|
+
get level(): LogLevel;
|
|
21
|
+
static parseLevel(str: string): LogLevel;
|
|
22
|
+
child(childName: string): Logger;
|
|
23
|
+
debug(msg: string, data?: Record<string, unknown>): void;
|
|
24
|
+
info(msg: string, data?: Record<string, unknown>): void;
|
|
25
|
+
warn(msg: string, data?: Record<string, unknown>): void;
|
|
26
|
+
error(msg: string, data?: Record<string, unknown>): void;
|
|
27
|
+
private write;
|
|
28
|
+
}
|
|
29
|
+
export declare const logger: Logger;
|
|
30
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,oBAAY,QAAQ;IAClB,KAAK,IAAI;IACT,IAAI,IAAI;IACR,IAAI,IAAI;IACR,KAAK,IAAI;CACV;AASD,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAsB;gBAEnC,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,QAAQ,GAAG;QAAE,KAAK,EAAE,QAAQ,CAAA;KAAkB;IAK/E,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAI/B,IAAI,KAAK,IAAI,QAAQ,CAEpB;IAED,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ;IAUxC,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAIhC,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IACxD,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IACvD,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IACvD,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAExD,OAAO,CAAC,KAAK;CAUd;AAED,eAAO,MAAM,MAAM,QAA0B,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured Logger
|
|
3
|
+
*
|
|
4
|
+
* Leveled, structured logging with child logger support.
|
|
5
|
+
* Output: [ISO timestamp] [LEVEL] [name] message { data }
|
|
6
|
+
*/
|
|
7
|
+
export var LogLevel;
|
|
8
|
+
(function (LogLevel) {
|
|
9
|
+
LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
|
|
10
|
+
LogLevel[LogLevel["INFO"] = 1] = "INFO";
|
|
11
|
+
LogLevel[LogLevel["WARN"] = 2] = "WARN";
|
|
12
|
+
LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
|
|
13
|
+
})(LogLevel || (LogLevel = {}));
|
|
14
|
+
const LEVEL_NAMES = {
|
|
15
|
+
[LogLevel.DEBUG]: "DEBUG",
|
|
16
|
+
[LogLevel.INFO]: "INFO",
|
|
17
|
+
[LogLevel.WARN]: "WARN",
|
|
18
|
+
[LogLevel.ERROR]: "ERROR",
|
|
19
|
+
};
|
|
20
|
+
export class Logger {
|
|
21
|
+
name;
|
|
22
|
+
levelRef;
|
|
23
|
+
constructor(name, level = LogLevel.INFO) {
|
|
24
|
+
this.name = name;
|
|
25
|
+
this.levelRef = typeof level === "object" ? level : { value: level };
|
|
26
|
+
}
|
|
27
|
+
setLevel(level) {
|
|
28
|
+
this.levelRef.value = level;
|
|
29
|
+
}
|
|
30
|
+
get level() {
|
|
31
|
+
return this.levelRef.value;
|
|
32
|
+
}
|
|
33
|
+
static parseLevel(str) {
|
|
34
|
+
switch (str.toLowerCase()) {
|
|
35
|
+
case "debug": return LogLevel.DEBUG;
|
|
36
|
+
case "warn":
|
|
37
|
+
case "warning": return LogLevel.WARN;
|
|
38
|
+
case "error": return LogLevel.ERROR;
|
|
39
|
+
default: return LogLevel.INFO;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
child(childName) {
|
|
43
|
+
return new Logger(`${this.name}:${childName}`, this.levelRef);
|
|
44
|
+
}
|
|
45
|
+
debug(msg, data) { this.write(LogLevel.DEBUG, msg, data); }
|
|
46
|
+
info(msg, data) { this.write(LogLevel.INFO, msg, data); }
|
|
47
|
+
warn(msg, data) { this.write(LogLevel.WARN, msg, data); }
|
|
48
|
+
error(msg, data) { this.write(LogLevel.ERROR, msg, data); }
|
|
49
|
+
write(level, msg, data) {
|
|
50
|
+
if (level < this.levelRef.value)
|
|
51
|
+
return;
|
|
52
|
+
const ts = new Date().toISOString();
|
|
53
|
+
const prefix = `[${ts}] [${LEVEL_NAMES[level]}] [${this.name}]`;
|
|
54
|
+
const line = data ? `${prefix} ${msg} ${JSON.stringify(data)}` : `${prefix} ${msg}`;
|
|
55
|
+
if (level === LogLevel.ERROR)
|
|
56
|
+
console.error(line);
|
|
57
|
+
else if (level === LogLevel.WARN)
|
|
58
|
+
console.warn(line);
|
|
59
|
+
else
|
|
60
|
+
console.log(line);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export const logger = new Logger("a2a-codex");
|
|
64
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAN,IAAY,QAKX;AALD,WAAY,QAAQ;IAClB,yCAAS,CAAA;IACT,uCAAQ,CAAA;IACR,uCAAQ,CAAA;IACR,yCAAS,CAAA;AACX,CAA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