@cleocode/adapters 2026.5.4 → 2026.5.6
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 +4 -4
- 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 -428
- 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 -310
- 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/adapter.js +0 -88
- package/dist/providers/claude-sdk/adapter.js.map +0 -1
- package/dist/providers/claude-sdk/index.js +0 -34
- package/dist/providers/claude-sdk/index.js.map +0 -1
- package/dist/providers/claude-sdk/install.js +0 -61
- package/dist/providers/claude-sdk/install.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 -251
- 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 -40
- package/dist/providers/codex/index.js.map +0 -1
- package/dist/providers/codex/install.js +0 -132
- package/dist/providers/codex/install.js.map +0 -1
- package/dist/providers/codex/spawn.js +0 -203
- package/dist/providers/codex/spawn.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 -281
- 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 -40
- 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/gemini-cli/spawn.js +0 -195
- package/dist/providers/gemini-cli/spawn.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 -40
- 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/kimi/spawn.js +0 -225
- package/dist/providers/kimi/spawn.js.map +0 -1
- package/dist/providers/openai-sdk/adapter.js +0 -121
- package/dist/providers/openai-sdk/adapter.js.map +0 -1
- package/dist/providers/openai-sdk/guardrails.js +0 -174
- package/dist/providers/openai-sdk/guardrails.js.map +0 -1
- package/dist/providers/openai-sdk/handoff.js +0 -128
- package/dist/providers/openai-sdk/handoff.js.map +0 -1
- package/dist/providers/openai-sdk/index.js +0 -40
- 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 -361
- package/dist/providers/openai-sdk/spawn.js.map +0 -1
- package/dist/providers/openai-sdk/tracing.js +0 -159
- 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 -242
- package/dist/providers/opencode/install.js.map +0 -1
- package/dist/providers/opencode/spawn.js +0 -257
- 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 -183
- 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/hook-template-installer.js +0 -209
- package/dist/providers/shared/hook-template-installer.js.map +0 -1
- package/dist/providers/shared/paths.js +0 -77
- package/dist/providers/shared/paths.js.map +0 -1
- package/dist/providers/shared/sdk-result-mapper.js +0 -55
- 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,251 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Claude SDK Spawn Provider — Vercel AI SDK edition.
|
|
3
|
-
*
|
|
4
|
-
* Implements {@link AdapterSpawnProvider} using the Vercel AI SDK
|
|
5
|
-
* (`ai` v6 + `@ai-sdk/anthropic`) instead of the legacy
|
|
6
|
-
* `@anthropic-ai/claude-agent-sdk`. CLEO retains its own orchestration
|
|
7
|
-
* primitives (`composeSpawnPayload`, playbook runtime, agent registry);
|
|
8
|
-
* the SDK is strictly the LLM bridge.
|
|
9
|
-
*
|
|
10
|
-
* Differences from `ClaudeCodeSpawnProvider`:
|
|
11
|
-
* - Uses `generateText()` via Vercel AI SDK instead of a detached child process
|
|
12
|
-
* - Awaits full completion before returning (synchronous output capture)
|
|
13
|
-
* - Session IDs are generated by CLEO and tracked in `SessionStore`
|
|
14
|
-
* - No temp files, no OS PIDs — tracking is purely in-memory session IDs
|
|
15
|
-
* - `canSpawn()` uses 3-tier key resolution (env var → stored key → Claude Code OAuth)
|
|
16
|
-
*
|
|
17
|
-
* CANT enrichment is identical to the CLI provider: `buildCantEnrichedPrompt()`
|
|
18
|
-
* is called before `generateText()` and the result is passed as the user prompt.
|
|
19
|
-
*
|
|
20
|
-
* @task T581 (original)
|
|
21
|
-
* @task T933 (SDK consolidation — Vercel AI SDK migration)
|
|
22
|
-
* @see T752 — canSpawn() OAuth fix
|
|
23
|
-
* @see ADR-052 — SDK consolidation decision
|
|
24
|
-
*/
|
|
25
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
26
|
-
import { homedir } from 'node:os';
|
|
27
|
-
import { join } from 'node:path';
|
|
28
|
-
import { getErrorMessage } from '@cleocode/contracts';
|
|
29
|
-
import { SessionStore } from './session-store.js';
|
|
30
|
-
import { resolveTools } from './tool-bridge.js';
|
|
31
|
-
// ---------------------------------------------------------------------------
|
|
32
|
-
// Inline 3-tier Anthropic key resolver
|
|
33
|
-
// NOTE: Cannot import from @cleocode/core — circular dependency
|
|
34
|
-
// (@cleocode/core depends on @cleocode/adapters). This is a deliberate
|
|
35
|
-
// inline copy of the resolution logic from anthropic-key-resolver.ts.
|
|
36
|
-
// Keep in sync with packages/core/src/memory/anthropic-key-resolver.ts.
|
|
37
|
-
// T752 — OAuth fix for canSpawn()
|
|
38
|
-
// ---------------------------------------------------------------------------
|
|
39
|
-
/**
|
|
40
|
-
* Resolve the Anthropic API key using a 3-tier priority chain:
|
|
41
|
-
* 1. `ANTHROPIC_API_KEY` environment variable
|
|
42
|
-
* 2. `~/.local/share/cleo/anthropic-key` (user-stored via cleo config)
|
|
43
|
-
* 3. `~/.claude/.credentials.json` → claudeAiOauth.accessToken (Claude Code OAuth)
|
|
44
|
-
*
|
|
45
|
-
* @returns The key/token string, or null if unavailable.
|
|
46
|
-
*/
|
|
47
|
-
function resolveAnthropicApiKey() {
|
|
48
|
-
// 1. Explicit env var
|
|
49
|
-
const envKey = process.env.ANTHROPIC_API_KEY;
|
|
50
|
-
if (envKey?.trim())
|
|
51
|
-
return envKey;
|
|
52
|
-
// 2. CLEO global stored key
|
|
53
|
-
try {
|
|
54
|
-
const xdg = process.env.XDG_DATA_HOME || join(homedir(), '.local', 'share');
|
|
55
|
-
const keyFile = join(xdg, 'cleo', 'anthropic-key');
|
|
56
|
-
if (existsSync(keyFile)) {
|
|
57
|
-
const stored = readFileSync(keyFile, 'utf-8').trim();
|
|
58
|
-
if (stored)
|
|
59
|
-
return stored;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
catch {
|
|
63
|
-
// Not available — continue
|
|
64
|
-
}
|
|
65
|
-
// 3. Claude Code OAuth token (free for Claude Code users)
|
|
66
|
-
try {
|
|
67
|
-
const credPath = join(homedir(), '.claude', '.credentials.json');
|
|
68
|
-
if (!existsSync(credPath))
|
|
69
|
-
return null;
|
|
70
|
-
const raw = readFileSync(credPath, 'utf-8');
|
|
71
|
-
const creds = JSON.parse(raw);
|
|
72
|
-
const token = creds.claudeAiOauth?.accessToken;
|
|
73
|
-
if (token?.trim()) {
|
|
74
|
-
const expiresAt = creds.claudeAiOauth?.expiresAt;
|
|
75
|
-
if (expiresAt && Date.now() > expiresAt)
|
|
76
|
-
return null;
|
|
77
|
-
return token;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
catch {
|
|
81
|
-
// Credentials file missing or unreadable — not an error
|
|
82
|
-
}
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
/** Model used when no model is specified in spawn options. */
|
|
86
|
-
const DEFAULT_MODEL = 'claude-sonnet-4-5';
|
|
87
|
-
/**
|
|
88
|
-
* Spawn provider that uses the Vercel AI SDK (`ai` v6 + `@ai-sdk/anthropic`)
|
|
89
|
-
* for programmatic subagent execution.
|
|
90
|
-
*
|
|
91
|
-
* Each call to `spawn()` runs a single `generateText()` call to completion and
|
|
92
|
-
* captures the output. Sessions are tracked in `SessionStore` so callers can
|
|
93
|
-
* inspect active sessions via `listRunning()` and remove them via `terminate()`.
|
|
94
|
-
*
|
|
95
|
-
* @remarks
|
|
96
|
-
* Unlike the legacy `@anthropic-ai/claude-agent-sdk`, the Vercel AI SDK is
|
|
97
|
-
* strictly an LLM bridge — it does not manage a Claude Code subprocess or
|
|
98
|
-
* provide built-in MCP server wiring. Tool use is available through the SDK's
|
|
99
|
-
* tool system, but CLEO orchestration (composeSpawnPayload, playbooks, the
|
|
100
|
-
* agent registry) remains the source of truth for scaffolding.
|
|
101
|
-
*/
|
|
102
|
-
export class ClaudeSDKSpawnProvider {
|
|
103
|
-
/** In-memory session registry. */
|
|
104
|
-
sessions = new SessionStore();
|
|
105
|
-
/**
|
|
106
|
-
* Check whether the SDK can be used in the current environment.
|
|
107
|
-
*
|
|
108
|
-
* Uses 3-tier key resolution so the provider works with:
|
|
109
|
-
* - `ANTHROPIC_API_KEY` environment variable (explicit)
|
|
110
|
-
* - `~/.local/share/cleo/anthropic-key` (user-stored via cleo config)
|
|
111
|
-
* - Claude Code OAuth token (zero-config for Claude Code users)
|
|
112
|
-
*
|
|
113
|
-
* @returns `true` when any Anthropic credential is available
|
|
114
|
-
*/
|
|
115
|
-
async canSpawn() {
|
|
116
|
-
return !!resolveAnthropicApiKey();
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Spawn a subagent using the Vercel AI SDK.
|
|
120
|
-
*
|
|
121
|
-
* Enriches the prompt via CANT context, runs `generateText()` to completion,
|
|
122
|
-
* and returns a `SpawnResult` with the final output and exit code.
|
|
123
|
-
*
|
|
124
|
-
* @param context - Spawn context with taskId, prompt, options
|
|
125
|
-
* @returns Resolved spawn result (status: 'completed' or 'failed')
|
|
126
|
-
*/
|
|
127
|
-
async spawn(context) {
|
|
128
|
-
const instanceId = `sdk-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
129
|
-
const sessionId = `cleo-${instanceId}`;
|
|
130
|
-
const startTime = new Date().toISOString();
|
|
131
|
-
// Register in session store immediately so listRunning() reflects it
|
|
132
|
-
// before the async generation starts.
|
|
133
|
-
this.sessions.add({
|
|
134
|
-
instanceId,
|
|
135
|
-
sessionId,
|
|
136
|
-
taskId: context.taskId,
|
|
137
|
-
startTime,
|
|
138
|
-
});
|
|
139
|
-
try {
|
|
140
|
-
// CANT enrichment — best-effort, identical to ClaudeCodeSpawnProvider.
|
|
141
|
-
let enrichedPrompt = context.prompt;
|
|
142
|
-
try {
|
|
143
|
-
const { buildCantEnrichedPrompt } = await import('../../cant-context.js');
|
|
144
|
-
enrichedPrompt = await buildCantEnrichedPrompt({
|
|
145
|
-
projectDir: context.workingDirectory ?? process.cwd(),
|
|
146
|
-
basePrompt: context.prompt,
|
|
147
|
-
agentName: context.options?.agentName ?? undefined,
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
catch {
|
|
151
|
-
// CANT enrichment unavailable — use raw prompt
|
|
152
|
-
}
|
|
153
|
-
// Lazy-import the SDK to avoid hard failures when credentials are absent
|
|
154
|
-
// (canSpawn() guards the normal path, but tests may import this module
|
|
155
|
-
// without a key).
|
|
156
|
-
const { createAnthropic } = await import('@ai-sdk/anthropic');
|
|
157
|
-
const { generateText } = await import('ai');
|
|
158
|
-
const apiKey = resolveAnthropicApiKey();
|
|
159
|
-
if (!apiKey) {
|
|
160
|
-
this.sessions.remove(instanceId);
|
|
161
|
-
return {
|
|
162
|
-
instanceId,
|
|
163
|
-
taskId: context.taskId,
|
|
164
|
-
providerId: 'claude-sdk',
|
|
165
|
-
status: 'failed',
|
|
166
|
-
startTime,
|
|
167
|
-
endTime: new Date().toISOString(),
|
|
168
|
-
exitCode: 1,
|
|
169
|
-
error: 'No Anthropic credentials available (env, stored key, or Claude Code OAuth)',
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
// Build the Anthropic provider with the resolved key.
|
|
173
|
-
const anthropicProvider = createAnthropic({ apiKey });
|
|
174
|
-
// Record the tool allowlist in metadata even though the AI SDK lacks
|
|
175
|
-
// built-in tool execution for arbitrary Claude Code tools. Downstream
|
|
176
|
-
// orchestration (composeSpawnPayload) applies allowlists before prompt
|
|
177
|
-
// composition; this array is surfaced so telemetry remains complete.
|
|
178
|
-
const toolAllowlist = context.options?.toolAllowlist;
|
|
179
|
-
const allowedTools = resolveTools(toolAllowlist);
|
|
180
|
-
const modelId = context.options?.model ?? DEFAULT_MODEL;
|
|
181
|
-
const result = await generateText({
|
|
182
|
-
model: anthropicProvider(modelId),
|
|
183
|
-
prompt: enrichedPrompt,
|
|
184
|
-
providerOptions: {
|
|
185
|
-
anthropic: {
|
|
186
|
-
// Preserve allowlist metadata for trace visibility.
|
|
187
|
-
cleoAllowedTools: allowedTools,
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
});
|
|
191
|
-
const endTime = new Date().toISOString();
|
|
192
|
-
this.sessions.remove(instanceId);
|
|
193
|
-
const output = (result.text ?? '').trim();
|
|
194
|
-
return {
|
|
195
|
-
instanceId,
|
|
196
|
-
taskId: context.taskId,
|
|
197
|
-
providerId: 'claude-sdk',
|
|
198
|
-
status: 'completed',
|
|
199
|
-
output,
|
|
200
|
-
exitCode: 0,
|
|
201
|
-
startTime,
|
|
202
|
-
endTime,
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
catch (error) {
|
|
206
|
-
const endTime = new Date().toISOString();
|
|
207
|
-
this.sessions.remove(instanceId);
|
|
208
|
-
return {
|
|
209
|
-
instanceId,
|
|
210
|
-
taskId: context.taskId,
|
|
211
|
-
providerId: 'claude-sdk',
|
|
212
|
-
status: 'failed',
|
|
213
|
-
startTime,
|
|
214
|
-
endTime,
|
|
215
|
-
exitCode: 1,
|
|
216
|
-
error: getErrorMessage(error),
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* List sessions currently tracked as active (spawned but not yet completed).
|
|
222
|
-
*
|
|
223
|
-
* Because SDK sessions run to completion inside `spawn()`, this list is
|
|
224
|
-
* typically empty unless concurrent spawns are in flight.
|
|
225
|
-
*
|
|
226
|
-
* @returns Array of in-flight spawn results
|
|
227
|
-
*/
|
|
228
|
-
async listRunning() {
|
|
229
|
-
return this.sessions.listActive().map((entry) => ({
|
|
230
|
-
instanceId: entry.instanceId,
|
|
231
|
-
taskId: entry.taskId,
|
|
232
|
-
providerId: 'claude-sdk',
|
|
233
|
-
status: 'running',
|
|
234
|
-
startTime: entry.startTime,
|
|
235
|
-
}));
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Remove a session from tracking.
|
|
239
|
-
*
|
|
240
|
-
* The underlying `generateText()` call runs inside `spawn()` and cannot be
|
|
241
|
-
* cancelled externally once the HTTP request is in flight. Removing the
|
|
242
|
-
* entry from the store prevents it from appearing in `listRunning()` but
|
|
243
|
-
* does not interrupt the in-progress request.
|
|
244
|
-
*
|
|
245
|
-
* @param instanceId - ID of the spawn instance to terminate
|
|
246
|
-
*/
|
|
247
|
-
async terminate(instanceId) {
|
|
248
|
-
this.sessions.remove(instanceId);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
//# sourceMappingURL=spawn.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spawn.js","sourceRoot":"","sources":["../../../src/providers/claude-sdk/spawn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,8EAA8E;AAC9E,uCAAuC;AACvC,gEAAgE;AAChE,6EAA6E;AAC7E,4EAA4E;AAC5E,8EAA8E;AAC9E,wCAAwC;AACxC,8EAA8E;AAE9E;;;;;;;GAOG;AACH,SAAS,sBAAsB;IAC7B,sBAAsB;IACtB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;IAC7C,IAAI,MAAM,EAAE,IAAI,EAAE;QAAE,OAAO,MAAM,CAAC;IAElC,4BAA4B;IAC5B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC5E,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC;QACnD,IAAI,UAAU,CAAC,OAAO,CAAC,EA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,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;YACzC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAEjC,OAAO;gBACL,UAAU;gBACV,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,UAAU,EAAE,YAAY;gBACxB,MAAM,EAAE,QAAQ;gBAChB,SAAS;gBACT,OAAO;gBACP,QAAQ,EAAE,CAAC;gBACX,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC;aAC9B,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,WAAW;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAChD,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,UAAU,EAAE,YAAY;YACxB,MAAM,EAAE,SAAkB;YAC1B,SAAS,EAAE,KAAK,CAAC,SAAS;SAC3B,CAAC,CAAC,CAAC;IACN,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,SAAS,CAAC,UAAkB;QAChC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tool Bridge for Claude SDK Spawn Provider
|
|
3
|
-
*
|
|
4
|
-
* Maps CLEO's tool allowlist (string names) to the SDK's `allowedTools`
|
|
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;IAC3B,IAAI,GAAG,OAAO,CAAC;IACxB,8BAA8B;IACrB,OAAO,GAAG,OAAO,CAAC;IAE3B,+CAA+C;IAC/C,YAAY,GAAwB;QAClC,aAAa,EAAE,IAAI;QACnB,mBAAmB,EAAE,CAAC,cAAc,EAAE,kBAAkB,EAAE,MAAM,CAAC;QACjE,aAAa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,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"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @packageDocumentation
|
|
3
|
-
*
|
|
4
|
-
* CLEO provider adapter for OpenAI Codex CLI.
|
|
5
|
-
* Default export is the adapter class for dynamic loading by AdapterManager.
|
|
6
|
-
*
|
|
7
|
-
* @task T162
|
|
8
|
-
* @epic T134
|
|
9
|
-
*/
|
|
10
|
-
import { CodexAdapter } from './adapter.js';
|
|
11
|
-
export { CodexAdapter } from './adapter.js';
|
|
12
|
-
export { CodexHookProvider } from './hooks.js';
|
|
13
|
-
export { CodexInstallProvider } from './install.js';
|
|
14
|
-
export { CodexSpawnProvider } from './spawn.js';
|
|
15
|
-
export default CodexAdapter;
|
|
16
|
-
/**
|
|
17
|
-
* Factory function for creating adapter instances.
|
|
18
|
-
* Used by AdapterManager's dynamic import fallback.
|
|
19
|
-
*
|
|
20
|
-
* @remarks
|
|
21
|
-
* This is the primary entry point for dynamic adapter loading.
|
|
22
|
-
* AdapterManager calls this function when it resolves the codex
|
|
23
|
-
* provider via its import-based discovery mechanism.
|
|
24
|
-
*
|
|
25
|
-
* @returns A new {@link CodexAdapter} instance ready for initialization
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```typescript
|
|
29
|
-
* import { createAdapter } from '@cleocode/adapters/providers/codex';
|
|
30
|
-
*
|
|
31
|
-
* const adapter = createAdapter();
|
|
32
|
-
* await adapter.initialize('/path/to/project');
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* @task T162
|
|
36
|
-
*/
|
|
37
|
-
export function createAdapter() {
|
|
38
|
-
return new CodexAdapter();
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/providers/codex/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,eAAe,YAAY,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,IAAI,YAAY,EAAE,CAAC;AAC5B,CAAC"}
|