@cleocode/adapters 2026.4.59 → 2026.4.60
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/package.json +3 -3
- package/dist/cant-context.js +0 -711
- package/dist/cant-context.js.map +0 -1
- package/dist/providers/claude-code/adapter.js +0 -222
- package/dist/providers/claude-code/adapter.js.map +0 -1
- package/dist/providers/claude-code/context-monitor.js +0 -159
- package/dist/providers/claude-code/context-monitor.js.map +0 -1
- package/dist/providers/claude-code/hooks.js +0 -395
- package/dist/providers/claude-code/hooks.js.map +0 -1
- package/dist/providers/claude-code/index.js +0 -41
- package/dist/providers/claude-code/index.js.map +0 -1
- package/dist/providers/claude-code/install.js +0 -199
- package/dist/providers/claude-code/install.js.map +0 -1
- package/dist/providers/claude-code/paths.js +0 -41
- package/dist/providers/claude-code/paths.js.map +0 -1
- package/dist/providers/claude-code/spawn.js +0 -198
- package/dist/providers/claude-code/spawn.js.map +0 -1
- package/dist/providers/claude-code/statusline.js +0 -130
- package/dist/providers/claude-code/statusline.js.map +0 -1
- package/dist/providers/claude-code/task-sync.js +0 -119
- package/dist/providers/claude-code/task-sync.js.map +0 -1
- package/dist/providers/claude-code/transport.js +0 -29
- package/dist/providers/claude-code/transport.js.map +0 -1
- package/dist/providers/claude-sdk/index.js +0 -16
- package/dist/providers/claude-sdk/index.js.map +0 -1
- package/dist/providers/claude-sdk/mcp-registry.js +0 -66
- package/dist/providers/claude-sdk/mcp-registry.js.map +0 -1
- package/dist/providers/claude-sdk/session-store.js +0 -84
- package/dist/providers/claude-sdk/session-store.js.map +0 -1
- package/dist/providers/claude-sdk/spawn.js +0 -225
- package/dist/providers/claude-sdk/spawn.js.map +0 -1
- package/dist/providers/claude-sdk/tool-bridge.js +0 -50
- package/dist/providers/claude-sdk/tool-bridge.js.map +0 -1
- package/dist/providers/codex/adapter.js +0 -146
- package/dist/providers/codex/adapter.js.map +0 -1
- package/dist/providers/codex/hooks.js +0 -113
- package/dist/providers/codex/hooks.js.map +0 -1
- package/dist/providers/codex/index.js +0 -39
- package/dist/providers/codex/index.js.map +0 -1
- package/dist/providers/codex/install.js +0 -124
- package/dist/providers/codex/install.js.map +0 -1
- package/dist/providers/cursor/adapter.js +0 -151
- package/dist/providers/cursor/adapter.js.map +0 -1
- package/dist/providers/cursor/hooks.js +0 -208
- package/dist/providers/cursor/hooks.js.map +0 -1
- package/dist/providers/cursor/index.js +0 -36
- package/dist/providers/cursor/index.js.map +0 -1
- package/dist/providers/cursor/install.js +0 -180
- package/dist/providers/cursor/install.js.map +0 -1
- package/dist/providers/cursor/spawn.js +0 -59
- package/dist/providers/cursor/spawn.js.map +0 -1
- package/dist/providers/gemini-cli/adapter.js +0 -158
- package/dist/providers/gemini-cli/adapter.js.map +0 -1
- package/dist/providers/gemini-cli/hooks.js +0 -128
- package/dist/providers/gemini-cli/hooks.js.map +0 -1
- package/dist/providers/gemini-cli/index.js +0 -39
- package/dist/providers/gemini-cli/index.js.map +0 -1
- package/dist/providers/gemini-cli/install.js +0 -124
- package/dist/providers/gemini-cli/install.js.map +0 -1
- package/dist/providers/kimi/adapter.js +0 -145
- package/dist/providers/kimi/adapter.js.map +0 -1
- package/dist/providers/kimi/hooks.js +0 -79
- package/dist/providers/kimi/hooks.js.map +0 -1
- package/dist/providers/kimi/index.js +0 -39
- package/dist/providers/kimi/index.js.map +0 -1
- package/dist/providers/kimi/install.js +0 -124
- package/dist/providers/kimi/install.js.map +0 -1
- package/dist/providers/openai-sdk/adapter.js +0 -120
- package/dist/providers/openai-sdk/adapter.js.map +0 -1
- package/dist/providers/openai-sdk/guardrails.js +0 -139
- package/dist/providers/openai-sdk/guardrails.js.map +0 -1
- package/dist/providers/openai-sdk/handoff.js +0 -124
- package/dist/providers/openai-sdk/handoff.js.map +0 -1
- package/dist/providers/openai-sdk/index.js +0 -39
- package/dist/providers/openai-sdk/index.js.map +0 -1
- package/dist/providers/openai-sdk/install.js +0 -120
- package/dist/providers/openai-sdk/install.js.map +0 -1
- package/dist/providers/openai-sdk/spawn.js +0 -214
- package/dist/providers/openai-sdk/spawn.js.map +0 -1
- package/dist/providers/openai-sdk/tracing.js +0 -157
- package/dist/providers/openai-sdk/tracing.js.map +0 -1
- package/dist/providers/opencode/adapter.js +0 -166
- package/dist/providers/opencode/adapter.js.map +0 -1
- package/dist/providers/opencode/hooks.js +0 -206
- package/dist/providers/opencode/hooks.js.map +0 -1
- package/dist/providers/opencode/index.js +0 -37
- package/dist/providers/opencode/index.js.map +0 -1
- package/dist/providers/opencode/install.js +0 -115
- package/dist/providers/opencode/install.js.map +0 -1
- package/dist/providers/opencode/spawn.js +0 -256
- package/dist/providers/opencode/spawn.js.map +0 -1
- package/dist/providers/pi/adapter.js +0 -220
- package/dist/providers/pi/adapter.js.map +0 -1
- package/dist/providers/pi/hooks.js +0 -223
- package/dist/providers/pi/hooks.js.map +0 -1
- package/dist/providers/pi/index.js +0 -38
- package/dist/providers/pi/index.js.map +0 -1
- package/dist/providers/pi/install.js +0 -175
- package/dist/providers/pi/install.js.map +0 -1
- package/dist/providers/pi/spawn.js +0 -187
- package/dist/providers/pi/spawn.js.map +0 -1
- package/dist/providers/shared/conduit-trace-writer.js +0 -65
- package/dist/providers/shared/conduit-trace-writer.js.map +0 -1
- package/dist/providers/shared/sdk-result-mapper.js +0 -54
- package/dist/providers/shared/sdk-result-mapper.js.map +0 -1
- package/dist/providers/shared/transcript-reader.js +0 -124
- package/dist/providers/shared/transcript-reader.js.map +0 -1
- package/dist/registry.js +0 -92
- package/dist/registry.js.map +0 -1
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Session Store for Claude SDK Spawn Provider
|
|
3
|
-
*
|
|
4
|
-
* Maintains an in-memory map of active SDK sessions keyed by instanceId.
|
|
5
|
-
* Each entry records the session ID returned by the SDK, the task ID, and
|
|
6
|
-
* the start time. Session IDs can be used with `options: { resume: sessionId }`
|
|
7
|
-
* in subsequent `query()` calls for multi-turn continuations.
|
|
8
|
-
*
|
|
9
|
-
* Persistence to conduit.db is intentionally deferred: the in-memory store
|
|
10
|
-
* is sufficient for single-process lifetimes and avoids coupling the spawn
|
|
11
|
-
* provider to the conduit subsystem at construction time.
|
|
12
|
-
*
|
|
13
|
-
* @task T581
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* In-memory store for active Claude SDK sessions.
|
|
17
|
-
*
|
|
18
|
-
* Provides CRUD operations over a `Map<instanceId, SessionEntry>`.
|
|
19
|
-
* Thread-safe within a single Node.js process (single-threaded event loop).
|
|
20
|
-
*/
|
|
21
|
-
export class SessionStore {
|
|
22
|
-
store = new Map();
|
|
23
|
-
/**
|
|
24
|
-
* Register a new session entry.
|
|
25
|
-
*
|
|
26
|
-
* @param entry - The session entry to add
|
|
27
|
-
*/
|
|
28
|
-
add(entry) {
|
|
29
|
-
this.store.set(entry.instanceId, entry);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Update the SDK session ID for an existing entry once it is received
|
|
33
|
-
* from the first SDK message.
|
|
34
|
-
*
|
|
35
|
-
* No-op if the instanceId is not found.
|
|
36
|
-
*
|
|
37
|
-
* @param instanceId - ID of the spawn instance
|
|
38
|
-
* @param sessionId - SDK-assigned session identifier
|
|
39
|
-
*/
|
|
40
|
-
setSessionId(instanceId, sessionId) {
|
|
41
|
-
const entry = this.store.get(instanceId);
|
|
42
|
-
if (entry) {
|
|
43
|
-
entry.sessionId = sessionId;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Retrieve an entry by instance ID.
|
|
48
|
-
*
|
|
49
|
-
* @param instanceId - ID of the spawn instance
|
|
50
|
-
* @returns The session entry, or undefined if not found
|
|
51
|
-
*/
|
|
52
|
-
get(instanceId) {
|
|
53
|
-
return this.store.get(instanceId);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Remove an entry by instance ID.
|
|
57
|
-
*
|
|
58
|
-
* @param instanceId - ID of the spawn instance to remove
|
|
59
|
-
*/
|
|
60
|
-
remove(instanceId) {
|
|
61
|
-
this.store.delete(instanceId);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* List all active session entries.
|
|
65
|
-
*
|
|
66
|
-
* @returns Array of all tracked session entries
|
|
67
|
-
*/
|
|
68
|
-
listActive() {
|
|
69
|
-
return Array.from(this.store.values());
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Return the number of tracked sessions.
|
|
73
|
-
*/
|
|
74
|
-
size() {
|
|
75
|
-
return this.store.size;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Clear all tracked sessions. Intended for testing only.
|
|
79
|
-
*/
|
|
80
|
-
clear() {
|
|
81
|
-
this.store.clear();
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
//# sourceMappingURL=session-store.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session-store.js","sourceRoot":"","sources":["../../../src/providers/claude-sdk/session-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAcH;;;;;GAKG;AACH,MAAM,OAAO,YAAY;IACN,KAAK,GAAG,IAAI,GAAG,EAAwB,CAAC;IAEzD;;;;OAIG;IACH,GAAG,CAAC,KAAmB;QACrB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;;;;OAQG;IACH,YAAY,CAAC,UAAkB,EAAE,SAAiB;QAChD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACzC,IAAI,KAAK,EAAE,CAAC;YACV,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;QAC9B,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,UAAkB;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACpC,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,UAAkB;QACvB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACH,UAAU;QACR,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Claude SDK Spawn Provider
|
|
3
|
-
*
|
|
4
|
-
* Implements `AdapterSpawnProvider` using the `@anthropic-ai/claude-agent-sdk`
|
|
5
|
-
* programmatic API instead of shelling out to the `claude` CLI.
|
|
6
|
-
*
|
|
7
|
-
* Differences from `ClaudeCodeSpawnProvider`:
|
|
8
|
-
* - Uses SDK `query()` instead of a detached child process
|
|
9
|
-
* - Awaits full completion before returning (synchronous output capture)
|
|
10
|
-
* - Session IDs from the SDK enable future multi-turn resumption
|
|
11
|
-
* - No temp files, no OS PIDs — tracking is purely in-memory session IDs
|
|
12
|
-
* - `canSpawn()` checks for `ANTHROPIC_API_KEY` rather than CLI availability
|
|
13
|
-
*
|
|
14
|
-
* CANT enrichment is identical to the CLI provider: `buildCantEnrichedPrompt()`
|
|
15
|
-
* is called before `query()` and the result is passed as the SDK prompt string.
|
|
16
|
-
*
|
|
17
|
-
* @task T581
|
|
18
|
-
*/
|
|
19
|
-
import { getErrorMessage } from '@cleocode/contracts';
|
|
20
|
-
import { getServers } from './mcp-registry.js';
|
|
21
|
-
import { SessionStore } from './session-store.js';
|
|
22
|
-
import { resolveTools } from './tool-bridge.js';
|
|
23
|
-
/** Model used when no model is specified in spawn options. */
|
|
24
|
-
const DEFAULT_MODEL = 'claude-sonnet-4-5';
|
|
25
|
-
/**
|
|
26
|
-
* Spawn provider that uses the Anthropic Claude Agent SDK for programmatic
|
|
27
|
-
* subagent execution.
|
|
28
|
-
*
|
|
29
|
-
* Each call to `spawn()` runs a full SDK `query()` to completion and
|
|
30
|
-
* captures the output. Sessions are tracked in `SessionStore` so callers
|
|
31
|
-
* can inspect active sessions via `listRunning()` and cancel them via
|
|
32
|
-
* `terminate()`.
|
|
33
|
-
*
|
|
34
|
-
* @remarks
|
|
35
|
-
* The `permissionMode: 'bypassPermissions'` + `allowDangerouslySkipPermissions: true`
|
|
36
|
-
* combination mirrors the `--dangerously-skip-permissions` flag used by
|
|
37
|
-
* the CLI provider. Both are required by the SDK when bypassing all tool
|
|
38
|
-
* permission prompts.
|
|
39
|
-
*/
|
|
40
|
-
export class ClaudeSDKSpawnProvider {
|
|
41
|
-
/** In-memory session registry. */
|
|
42
|
-
sessions = new SessionStore();
|
|
43
|
-
/**
|
|
44
|
-
* Check whether the SDK can be used in the current environment.
|
|
45
|
-
*
|
|
46
|
-
* Returns `true` if `ANTHROPIC_API_KEY` is set. No binary check is needed
|
|
47
|
-
* because the SDK manages the Claude Code subprocess internally.
|
|
48
|
-
*
|
|
49
|
-
* @returns `true` when an API key is present
|
|
50
|
-
*/
|
|
51
|
-
async canSpawn() {
|
|
52
|
-
return !!process.env.ANTHROPIC_API_KEY;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Spawn a subagent using the Claude Agent SDK.
|
|
56
|
-
*
|
|
57
|
-
* Enriches the prompt via CANT context, runs the SDK `query()` to
|
|
58
|
-
* completion, captures all assistant text output, and returns a
|
|
59
|
-
* `SpawnResult` with the final output and exit code.
|
|
60
|
-
*
|
|
61
|
-
* @param context - Spawn context with taskId, prompt, options
|
|
62
|
-
* @returns Resolved spawn result (status: 'completed' or 'failed')
|
|
63
|
-
*/
|
|
64
|
-
async spawn(context) {
|
|
65
|
-
const instanceId = `sdk-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
66
|
-
const startTime = new Date().toISOString();
|
|
67
|
-
// Register in session store immediately so listRunning() reflects it
|
|
68
|
-
// before the async query starts.
|
|
69
|
-
this.sessions.add({
|
|
70
|
-
instanceId,
|
|
71
|
-
sessionId: undefined,
|
|
72
|
-
taskId: context.taskId,
|
|
73
|
-
startTime,
|
|
74
|
-
});
|
|
75
|
-
try {
|
|
76
|
-
// CANT enrichment — best-effort, identical to ClaudeCodeSpawnProvider.
|
|
77
|
-
let enrichedPrompt = context.prompt;
|
|
78
|
-
try {
|
|
79
|
-
const { buildCantEnrichedPrompt } = await import('../../cant-context.js');
|
|
80
|
-
enrichedPrompt = await buildCantEnrichedPrompt({
|
|
81
|
-
projectDir: context.workingDirectory ?? process.cwd(),
|
|
82
|
-
basePrompt: context.prompt,
|
|
83
|
-
agentName: context.options?.agentName ?? undefined,
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
catch {
|
|
87
|
-
// CANT enrichment unavailable — use raw prompt
|
|
88
|
-
}
|
|
89
|
-
// Lazy-import the SDK to avoid hard failures when ANTHROPIC_API_KEY
|
|
90
|
-
// is absent (canSpawn() guards the normal path, but tests may import
|
|
91
|
-
// this module without the key).
|
|
92
|
-
const { query } = await import('@anthropic-ai/claude-agent-sdk');
|
|
93
|
-
// Build allowedTools from the spawn context or fall back to CLEO defaults.
|
|
94
|
-
const toolAllowlist = context.options?.toolAllowlist;
|
|
95
|
-
const allowedTools = resolveTools(toolAllowlist);
|
|
96
|
-
// Resolve available MCP servers for the working directory.
|
|
97
|
-
const workDir = context.workingDirectory ?? process.cwd();
|
|
98
|
-
const mcpServers = getServers(workDir);
|
|
99
|
-
// Resume support: pass a prior session ID if provided.
|
|
100
|
-
const resumeSessionId = context.options?.resumeSessionId;
|
|
101
|
-
const sdkQuery = query({
|
|
102
|
-
prompt: enrichedPrompt,
|
|
103
|
-
options: {
|
|
104
|
-
cwd: workDir,
|
|
105
|
-
model: context.options?.model ?? DEFAULT_MODEL,
|
|
106
|
-
allowedTools,
|
|
107
|
-
permissionMode: 'bypassPermissions',
|
|
108
|
-
allowDangerouslySkipPermissions: true,
|
|
109
|
-
...(Object.keys(mcpServers).length > 0 ? { mcpServers } : {}),
|
|
110
|
-
...(resumeSessionId ? { resume: resumeSessionId } : {}),
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
// Stream messages from the SDK, collecting text output and session ID.
|
|
114
|
-
const textParts = [];
|
|
115
|
-
let exitCode = 0;
|
|
116
|
-
let finalError;
|
|
117
|
-
for await (const message of sdkQuery) {
|
|
118
|
-
// Capture the session ID from the first message that carries it.
|
|
119
|
-
if ('session_id' in message && typeof message.session_id === 'string') {
|
|
120
|
-
this.sessions.setSessionId(instanceId, message.session_id);
|
|
121
|
-
}
|
|
122
|
-
if (message.type === 'assistant') {
|
|
123
|
-
// Aggregate text blocks from assistant messages.
|
|
124
|
-
for (const block of message.message.content) {
|
|
125
|
-
if (block.type === 'text') {
|
|
126
|
-
textParts.push(block.text);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
else if (message.type === 'result') {
|
|
131
|
-
if (message.subtype === 'success') {
|
|
132
|
-
// The result field on success contains the final summary text.
|
|
133
|
-
if (message.result) {
|
|
134
|
-
textParts.push(message.result);
|
|
135
|
-
}
|
|
136
|
-
exitCode = message.is_error ? 1 : 0;
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
// Error subtypes: error_max_turns, error_during_execution, etc.
|
|
140
|
-
exitCode = 1;
|
|
141
|
-
if ('errors' in message && Array.isArray(message.errors) && message.errors.length > 0) {
|
|
142
|
-
finalError = message.errors.join('; ');
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
// Fallback: use the subtype string as the error description so
|
|
146
|
-
// `finalError` is always truthy for non-success result messages.
|
|
147
|
-
finalError = String(message.subtype);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
const endTime = new Date().toISOString();
|
|
153
|
-
this.sessions.remove(instanceId);
|
|
154
|
-
const output = textParts.join('\n').trim();
|
|
155
|
-
if (finalError) {
|
|
156
|
-
return {
|
|
157
|
-
instanceId,
|
|
158
|
-
taskId: context.taskId,
|
|
159
|
-
providerId: 'claude-sdk',
|
|
160
|
-
status: 'failed',
|
|
161
|
-
output,
|
|
162
|
-
exitCode,
|
|
163
|
-
startTime,
|
|
164
|
-
endTime,
|
|
165
|
-
error: finalError,
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
return {
|
|
169
|
-
instanceId,
|
|
170
|
-
taskId: context.taskId,
|
|
171
|
-
providerId: 'claude-sdk',
|
|
172
|
-
status: 'completed',
|
|
173
|
-
output,
|
|
174
|
-
exitCode,
|
|
175
|
-
startTime,
|
|
176
|
-
endTime,
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
catch (error) {
|
|
180
|
-
const endTime = new Date().toISOString();
|
|
181
|
-
this.sessions.remove(instanceId);
|
|
182
|
-
return {
|
|
183
|
-
instanceId,
|
|
184
|
-
taskId: context.taskId,
|
|
185
|
-
providerId: 'claude-sdk',
|
|
186
|
-
status: 'failed',
|
|
187
|
-
startTime,
|
|
188
|
-
endTime,
|
|
189
|
-
exitCode: 1,
|
|
190
|
-
error: getErrorMessage(error),
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* List sessions currently tracked as active (spawned but not yet completed).
|
|
196
|
-
*
|
|
197
|
-
* Because SDK sessions run to completion inside `spawn()`, this list is
|
|
198
|
-
* typically empty unless concurrent spawns are in flight.
|
|
199
|
-
*
|
|
200
|
-
* @returns Array of in-flight spawn results
|
|
201
|
-
*/
|
|
202
|
-
async listRunning() {
|
|
203
|
-
return this.sessions.listActive().map((entry) => ({
|
|
204
|
-
instanceId: entry.instanceId,
|
|
205
|
-
taskId: entry.taskId,
|
|
206
|
-
providerId: 'claude-sdk',
|
|
207
|
-
status: 'running',
|
|
208
|
-
startTime: entry.startTime,
|
|
209
|
-
}));
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Remove a session from tracking.
|
|
213
|
-
*
|
|
214
|
-
* The underlying SDK query runs inside `spawn()` and cannot be cancelled
|
|
215
|
-
* externally once the async iterator is in flight. Removing the entry from
|
|
216
|
-
* the store prevents it from appearing in `listRunning()` but does not
|
|
217
|
-
* interrupt the in-progress HTTP request.
|
|
218
|
-
*
|
|
219
|
-
* @param instanceId - ID of the spawn instance to terminate
|
|
220
|
-
*/
|
|
221
|
-
async terminate(instanceId) {
|
|
222
|
-
this.sessions.remove(instanceId);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
//# sourceMappingURL=spawn.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spawn.js","sourceRoot":"","sources":["../../../src/providers/claude-sdk/spawn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,8DAA8D;AAC9D,MAAM,aAAa,GAAG,mBAAmB,CAAC;AAE1C;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,sBAAsB;IACjC,kCAAkC;IACjB,QAAQ,GAAG,IAAI,YAAY,EAAE,CAAC;IAE/C;;;;;;;OAOG;IACH,KAAK,CAAC,QAAQ;QACZ,OAAO,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;IACzC,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,KAAK,CAAC,OAAqB;QAC/B,MAAM,UAAU,GAAG,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC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owedTools`
|
|
5
|
-
* option format. The SDK accepts plain tool name strings such as
|
|
6
|
-
* `"Read"`, `"Bash"`, `"Edit"` for built-in Claude Code tools and
|
|
7
|
-
* `"mcp__<server>__<tool>"` for MCP-backed tools.
|
|
8
|
-
*
|
|
9
|
-
* @task T581
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Default CLEO tool set passed to the SDK when no explicit allowlist
|
|
13
|
-
* is provided in `SpawnContext.options.toolAllowlist`.
|
|
14
|
-
*
|
|
15
|
-
* Mirrors the standard agent tool surface used by the Claude Code CLI
|
|
16
|
-
* `--dangerously-skip-permissions` mode.
|
|
17
|
-
*/
|
|
18
|
-
export const DEFAULT_TOOLS = [
|
|
19
|
-
'Read',
|
|
20
|
-
'Write',
|
|
21
|
-
'Edit',
|
|
22
|
-
'Bash',
|
|
23
|
-
'Glob',
|
|
24
|
-
'Grep',
|
|
25
|
-
];
|
|
26
|
-
/**
|
|
27
|
-
* Resolves a CLEO tool allowlist to the SDK `allowedTools` array.
|
|
28
|
-
*
|
|
29
|
-
* When `allowlist` is undefined or empty, the default CLEO tool set is
|
|
30
|
-
* returned. When an explicit list is provided, it is returned as-is so
|
|
31
|
-
* callers can pass MCP tool strings (`mcp__server__tool`) alongside
|
|
32
|
-
* built-in names without transformation.
|
|
33
|
-
*
|
|
34
|
-
* @param allowlist - Optional array of tool names from `SpawnContext.options`
|
|
35
|
-
* @returns Array of SDK-compatible tool name strings
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```typescript
|
|
39
|
-
* resolveTools(); // ['Read', 'Write', 'Edit', 'Bash', 'Glob', 'Grep']
|
|
40
|
-
* resolveTools(['Read', 'Bash']); // ['Read', 'Bash']
|
|
41
|
-
* resolveTools(['mcp__brain__search']); // ['mcp__brain__search']
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
export function resolveTools(allowlist) {
|
|
45
|
-
if (!allowlist || allowlist.length === 0) {
|
|
46
|
-
return [...DEFAULT_TOOLS];
|
|
47
|
-
}
|
|
48
|
-
return [...allowlist];
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=tool-bridge.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-bridge.js","sourceRoot":"","sources":["../../../src/providers/claude-sdk/tool-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAsB;IAC9C,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;CACE,CAAC;AAEX;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,YAAY,CAAC,SAAoB;IAC/C,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzC,OAAO,CAAC,GAAG,aAAa,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC;AACxB,CAAC"}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Codex CLI Adapter
|
|
3
|
-
*
|
|
4
|
-
* Main CLEOProviderAdapter implementation for OpenAI Codex CLI.
|
|
5
|
-
* Provides hooks and install capabilities for CLEO integration.
|
|
6
|
-
*
|
|
7
|
-
* @task T162
|
|
8
|
-
* @epic T134
|
|
9
|
-
*/
|
|
10
|
-
import { exec } from 'node:child_process';
|
|
11
|
-
import { existsSync } from 'node:fs';
|
|
12
|
-
import { homedir } from 'node:os';
|
|
13
|
-
import { join } from 'node:path';
|
|
14
|
-
import { promisify } from 'node:util';
|
|
15
|
-
import { CodexHookProvider } from './hooks.js';
|
|
16
|
-
import { CodexInstallProvider } from './install.js';
|
|
17
|
-
const execAsync = promisify(exec);
|
|
18
|
-
/**
|
|
19
|
-
* CLEO provider adapter for OpenAI Codex CLI.
|
|
20
|
-
*
|
|
21
|
-
* Bridges CLEO's adapter system with Codex CLI's native capabilities:
|
|
22
|
-
* - Hooks: Maps Codex events (SessionStart, PromptSubmit, ResponseComplete) to CAAMP events
|
|
23
|
-
* - Install: Ensures AGENTS.md references for CLEO instruction files
|
|
24
|
-
*
|
|
25
|
-
* @remarks
|
|
26
|
-
* Codex CLI supports only 3 canonical events (SessionStart, PromptSubmit,
|
|
27
|
-
* ResponseComplete) and has no spawn or transport capabilities. Integration
|
|
28
|
-
* is primarily through instruction files (AGENTS.md).
|
|
29
|
-
*
|
|
30
|
-
* @task T162
|
|
31
|
-
* @epic T134
|
|
32
|
-
*/
|
|
33
|
-
export class CodexAdapter {
|
|
34
|
-
/** Unique provider identifier. */
|
|
35
|
-
id = 'codex';
|
|
36
|
-
/** Human-readable provider name. */
|
|
37
|
-
name = 'Codex';
|
|
38
|
-
/** Adapter version string. */
|
|
39
|
-
version = '1.0.0';
|
|
40
|
-
/** Declared capabilities for this provider. */
|
|
41
|
-
capabilities = {
|
|
42
|
-
supportsHooks: true,
|
|
43
|
-
supportedHookEvents: ['SessionStart', 'UserPromptSubmit', 'Stop'],
|
|
44
|
-
supportsSpawn: false,
|
|
45
|
-
supportsInstall: true,
|
|
46
|
-
supportsInstructionFiles: false,
|
|
47
|
-
supportsContextMonitor: false,
|
|
48
|
-
supportsStatusline: false,
|
|
49
|
-
supportsProviderPaths: false,
|
|
50
|
-
supportsTransport: false,
|
|
51
|
-
supportsTaskSync: false,
|
|
52
|
-
};
|
|
53
|
-
/** Hook provider for CAAMP event mapping. */
|
|
54
|
-
hooks;
|
|
55
|
-
/** Install provider for managing instruction files. */
|
|
56
|
-
install;
|
|
57
|
-
/** Project directory this adapter was initialized with, or null. */
|
|
58
|
-
projectDir = null;
|
|
59
|
-
/** Whether {@link initialize} has been called. */
|
|
60
|
-
initialized = false;
|
|
61
|
-
constructor() {
|
|
62
|
-
this.hooks = new CodexHookProvider();
|
|
63
|
-
this.install = new CodexInstallProvider();
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Initialize the adapter for a given project directory.
|
|
67
|
-
*
|
|
68
|
-
* @param projectDir - Root directory of the project
|
|
69
|
-
* @task T162
|
|
70
|
-
*/
|
|
71
|
-
async initialize(projectDir) {
|
|
72
|
-
this.projectDir = projectDir;
|
|
73
|
-
this.initialized = true;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Dispose the adapter and clean up resources.
|
|
77
|
-
*
|
|
78
|
-
* Unregisters hooks and releases any tracked state.
|
|
79
|
-
* @task T162
|
|
80
|
-
*/
|
|
81
|
-
async dispose() {
|
|
82
|
-
if (this.hooks.isRegistered()) {
|
|
83
|
-
await this.hooks.unregisterNativeHooks();
|
|
84
|
-
}
|
|
85
|
-
this.initialized = false;
|
|
86
|
-
this.projectDir = null;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Run a health check to verify Codex CLI is accessible.
|
|
90
|
-
*
|
|
91
|
-
* Checks:
|
|
92
|
-
* 1. Adapter has been initialized
|
|
93
|
-
* 2. Codex CLI binary is available in PATH
|
|
94
|
-
* 3. ~/.codex/ configuration directory exists
|
|
95
|
-
*
|
|
96
|
-
* @returns Health status with details about each check
|
|
97
|
-
* @task T162
|
|
98
|
-
*/
|
|
99
|
-
async healthCheck() {
|
|
100
|
-
const details = {};
|
|
101
|
-
if (!this.initialized) {
|
|
102
|
-
return {
|
|
103
|
-
healthy: false,
|
|
104
|
-
provider: this.id,
|
|
105
|
-
details: { error: 'Adapter not initialized' },
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
// Check Codex CLI availability
|
|
109
|
-
let cliAvailable = false;
|
|
110
|
-
try {
|
|
111
|
-
const { stdout } = await execAsync('which codex');
|
|
112
|
-
cliAvailable = stdout.trim().length > 0;
|
|
113
|
-
details.cliPath = stdout.trim();
|
|
114
|
-
}
|
|
115
|
-
catch {
|
|
116
|
-
details.cliAvailable = false;
|
|
117
|
-
}
|
|
118
|
-
// Check for Codex CLI config directory
|
|
119
|
-
const codexConfigDir = join(homedir(), '.codex');
|
|
120
|
-
const configExists = existsSync(codexConfigDir);
|
|
121
|
-
details.configDirExists = configExists;
|
|
122
|
-
// Healthy if CLI is available (primary requirement)
|
|
123
|
-
const healthy = cliAvailable;
|
|
124
|
-
details.cliAvailable = cliAvailable;
|
|
125
|
-
return {
|
|
126
|
-
healthy,
|
|
127
|
-
provider: this.id,
|
|
128
|
-
details,
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Check whether the adapter has been initialized.
|
|
133
|
-
* @task T162
|
|
134
|
-
*/
|
|
135
|
-
isInitialized() {
|
|
136
|
-
return this.initialized;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Get the project directory this adapter was initialized with.
|
|
140
|
-
* @task T162
|
|
141
|
-
*/
|
|
142
|
-
getProjectDir() {
|
|
143
|
-
return this.projectDir;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
//# sourceMappingURL=adapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../src/providers/codex/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAMtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAElC;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,YAAY;IACvB,kCAAkC;IACzB,EAAE,GAAG,OAAO,CAAC;IACtB,oCAAoC;IA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AI,CAAC,WAAW,EAAE,CAAC;YACtB,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,QAAQ,EAAE,IAAI,CAAC,EAAE;gBACjB,OAAO,EAAE,EAAE,KAAK,EAAE,yBAAyB,EAAE;aAC9C,CAAC;QACJ,CAAC;QAED,+BAA+B;QAC/B,IAAI,YAAY,GAAG,KAAK,CAAC;QACzB,IAAI,CAAC;YACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,aAAa,CAAC,CAAC;YAClD,YAAY,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;YACxC,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;QAClC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,CAAC,YAAY,GAAG,KAAK,CAAC;QAC/B,CAAC;QAED,uCAAuC;QACvC,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,CAAC;QACjD,MAAM,YAAY,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;QAChD,OAAO,CAAC,eAAe,GAAG,YAAY,CAAC;QAEvC,oDAAoD;QACpD,MAAM,OAAO,GAAG,YAAY,CAAC;QAC7B,OAAO,CAAC,YAAY,GAAG,YAAY,CAAC;QAEpC,OAAO;YACL,OAAO;YACP,QAAQ,EAAE,IAAI,CAAC,EAAE;YACjB,OAAO;SACR,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,aAAa;QACX,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACH,aAAa;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Codex CLI Hook Provider
|
|
3
|
-
*
|
|
4
|
-
* Maps Codex CLI's native hook events to CAAMP canonical hook events.
|
|
5
|
-
* Codex CLI supports 3 canonical events through its hook system.
|
|
6
|
-
*
|
|
7
|
-
* Codex CLI event mapping:
|
|
8
|
-
* - SessionStart -> SessionStart
|
|
9
|
-
* - PromptSubmit -> UserPromptSubmit
|
|
10
|
-
* - ResponseComplete -> Stop
|
|
11
|
-
*
|
|
12
|
-
* @task T162
|
|
13
|
-
* @epic T134
|
|
14
|
-
*/
|
|
15
|
-
import { homedir } from 'node:os';
|
|
16
|
-
import { join } from 'node:path';
|
|
17
|
-
import { readLatestTranscript } from '../shared/transcript-reader.js';
|
|
18
|
-
/**
|
|
19
|
-
* Mapping from Codex CLI native event names to CAAMP canonical event names.
|
|
20
|
-
*/
|
|
21
|
-
const CODEX_EVENT_MAP = {
|
|
22
|
-
SessionStart: 'SessionStart',
|
|
23
|
-
PromptSubmit: 'UserPromptSubmit',
|
|
24
|
-
ResponseComplete: 'Stop',
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Hook provider for Codex CLI.
|
|
28
|
-
*
|
|
29
|
-
* Codex CLI registers hooks via its configuration system at
|
|
30
|
-
* ~/.codex/. Hook handlers are shell commands or script paths that
|
|
31
|
-
* execute when the corresponding event fires.
|
|
32
|
-
*
|
|
33
|
-
* Since hooks are registered through the config system (managed by
|
|
34
|
-
* the install provider), registerNativeHooks and unregisterNativeHooks
|
|
35
|
-
* track registration state without performing filesystem operations.
|
|
36
|
-
*
|
|
37
|
-
* @remarks
|
|
38
|
-
* Codex CLI has a minimal hook surface with only 3 canonical events.
|
|
39
|
-
* Registration state is tracked in-memory because Codex CLI manages
|
|
40
|
-
* hooks through its own configuration system at `~/.codex/`.
|
|
41
|
-
*
|
|
42
|
-
* @task T162
|
|
43
|
-
* @epic T134
|
|
44
|
-
*/
|
|
45
|
-
export class CodexHookProvider {
|
|
46
|
-
/** Whether hooks have been registered for the current session. */
|
|
47
|
-
registered = false;
|
|
48
|
-
/**
|
|
49
|
-
* Map a Codex CLI native event name to a CAAMP hook event name.
|
|
50
|
-
*
|
|
51
|
-
* @param providerEvent - Codex CLI event name (e.g. "SessionStart", "PromptSubmit")
|
|
52
|
-
* @returns CAAMP event name or null if unmapped
|
|
53
|
-
* @task T162
|
|
54
|
-
*/
|
|
55
|
-
mapProviderEvent(providerEvent) {
|
|
56
|
-
return CODEX_EVENT_MAP[providerEvent] ?? null;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Register native hooks for a project.
|
|
60
|
-
*
|
|
61
|
-
* For Codex CLI, hooks are registered via the config system
|
|
62
|
-
* (~/.codex/), which is handled by the install provider.
|
|
63
|
-
* This method marks hooks as registered without performing
|
|
64
|
-
* filesystem operations.
|
|
65
|
-
*
|
|
66
|
-
* @param _projectDir - Project directory (unused; hooks are global)
|
|
67
|
-
* @task T162
|
|
68
|
-
*/
|
|
69
|
-
async registerNativeHooks(_projectDir) {
|
|
70
|
-
this.registered = true;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Unregister native hooks.
|
|
74
|
-
*
|
|
75
|
-
* For Codex CLI, this is a no-op since hooks are managed through
|
|
76
|
-
* the config system. Unregistration happens via the install
|
|
77
|
-
* provider's uninstall method.
|
|
78
|
-
* @task T162
|
|
79
|
-
*/
|
|
80
|
-
async unregisterNativeHooks() {
|
|
81
|
-
this.registered = false;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Check whether hooks have been registered via registerNativeHooks.
|
|
85
|
-
* @task T162
|
|
86
|
-
*/
|
|
87
|
-
isRegistered() {
|
|
88
|
-
return this.registered;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Get the full event mapping for introspection/debugging.
|
|
92
|
-
* @task T162
|
|
93
|
-
*/
|
|
94
|
-
getEventMap() {
|
|
95
|
-
return { ...CODEX_EVENT_MAP };
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Extract a plain-text transcript from Codex CLI session data.
|
|
99
|
-
*
|
|
100
|
-
* Reads the most recent JSON/JSONL session file under `~/.codex/`
|
|
101
|
-
* and returns its turns as a flat string for brain observation extraction.
|
|
102
|
-
*
|
|
103
|
-
* Returns null when no session data is found or on any read error.
|
|
104
|
-
*
|
|
105
|
-
* @param _sessionId - CLEO session ID (unused; reads the most recent file)
|
|
106
|
-
* @param _projectDir - Project directory (unused; Codex CLI uses global paths)
|
|
107
|
-
* @task T162 @epic T134
|
|
108
|
-
*/
|
|
109
|
-
async getTranscript(_sessionId, _projectDir) {
|
|
110
|
-
return readLatestTranscript(join(homedir(), '.codex'));
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
//# sourceMappingURL=hooks.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../src/providers/codex/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAEtE;;GAEG;AACH,MAAM,eAAe,GAA2B;IAC9C,YAAY,EAAE,cAAc;IAC5B,YAAY,EAAE,kBAAkB;IAChC,gBAAgB,EAAE,MAAM;CACzB,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,iBAAiB;IAC5B,kEAAkE;IAC1D,UAAU,GAAG,KAAK,CAAC;IAE3B;;;;;;OAMG;IACH,gBAAgB,CAAC,aAAqB;QACpC,OAAO,eAAe,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC;IAChD,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,mBAAmB,CAAC,WAAmB;QAC3C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IACzB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,qBAAqB;QACzB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,OAAO,EAAE,GAAG,eAAe,EAAE,CAAC;IAChC,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,aAAa,CAAC,UAAkB,EAAE,WAAmB;QACzD,OAAO,oBAAoB,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC;IACzD,CAAC;CACF"}
|