@cleocode/adapters 2026.5.4 → 2026.5.5
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,121 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OpenAI SDK Adapter — Vercel AI SDK edition.
|
|
3
|
-
*
|
|
4
|
-
* Main `CLEOProviderAdapter` implementation for the OpenAI provider, backed
|
|
5
|
-
* by the Vercel AI SDK (`ai` v6 + `@ai-sdk/openai`). Provides spawn and
|
|
6
|
-
* install capabilities. Hooks are not supported — the Vercel AI SDK does not
|
|
7
|
-
* expose a CLI hook system equivalent to Claude Code's.
|
|
8
|
-
*
|
|
9
|
-
* @task T582 (original)
|
|
10
|
-
* @task T933 (SDK consolidation — Vercel AI SDK migration)
|
|
11
|
-
* @see ADR-052 — SDK consolidation decision
|
|
12
|
-
*/
|
|
13
|
-
import { OpenAiSdkInstallProvider } from './install.js';
|
|
14
|
-
import { OpenAiSdkSpawnProvider } from './spawn.js';
|
|
15
|
-
/**
|
|
16
|
-
* CLEO provider adapter for the OpenAI provider.
|
|
17
|
-
*
|
|
18
|
-
* Bridges CLEO's adapter system with the Vercel AI SDK:
|
|
19
|
-
* - Spawn: Launches agents via the SDK with CLEO-native handoff topology
|
|
20
|
-
* - Install: Manages AGENTS.md @-references and .openai/ config directory
|
|
21
|
-
* - Tracing: Default-on conduit span persistence via `CleoConduitTraceProcessor`
|
|
22
|
-
*
|
|
23
|
-
* @remarks
|
|
24
|
-
* Handoff topology is CLEO-owned (see `handoff.ts`): lead agents delegate to
|
|
25
|
-
* worker archetypes in sequence, and the concatenated output is returned.
|
|
26
|
-
* The Vercel AI SDK surface (`generateText` / `streamText`) works uniformly
|
|
27
|
-
* across Anthropic, OpenAI, and compatible providers, so the provider keeps
|
|
28
|
-
* the `supportsMultiModel` capability flag.
|
|
29
|
-
*/
|
|
30
|
-
export class OpenAiSdkAdapter {
|
|
31
|
-
/** Unique provider identifier. */
|
|
32
|
-
id = 'openai-sdk';
|
|
33
|
-
/** Human-readable provider name. */
|
|
34
|
-
name = 'OpenAI SDK (Vercel AI SDK)';
|
|
35
|
-
/** Adapter version string. */
|
|
36
|
-
version = '2.0.0';
|
|
37
|
-
/** Declared capabilities for this provider. */
|
|
38
|
-
capabilities = {
|
|
39
|
-
supportsHooks: false,
|
|
40
|
-
// The SDK does not expose CLI lifecycle hooks equivalent to Claude Code.
|
|
41
|
-
supportedHookEvents: [],
|
|
42
|
-
supportsSpawn: true,
|
|
43
|
-
supportsInstall: true,
|
|
44
|
-
supportsInstructionFiles: true,
|
|
45
|
-
instructionFilePattern: 'AGENTS.md',
|
|
46
|
-
supportsContextMonitor: false,
|
|
47
|
-
supportsStatusline: false,
|
|
48
|
-
supportsProviderPaths: false,
|
|
49
|
-
supportsTransport: false,
|
|
50
|
-
supportsTaskSync: false,
|
|
51
|
-
};
|
|
52
|
-
/** Spawn provider for SDK-backed agent runs with handoff topology. */
|
|
53
|
-
spawn;
|
|
54
|
-
/** Install provider for AGENTS.md and .openai/ config directory management. */
|
|
55
|
-
install;
|
|
56
|
-
/** Project directory this adapter was initialized with, or null. */
|
|
57
|
-
projectDir = null;
|
|
58
|
-
/** Whether {@link initialize} has been called. */
|
|
59
|
-
initialized = false;
|
|
60
|
-
constructor() {
|
|
61
|
-
this.spawn = new OpenAiSdkSpawnProvider();
|
|
62
|
-
this.install = new OpenAiSdkInstallProvider();
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Initialize the adapter for a given project directory.
|
|
66
|
-
*
|
|
67
|
-
* @param projectDir - Root directory of the project.
|
|
68
|
-
*/
|
|
69
|
-
async initialize(projectDir) {
|
|
70
|
-
this.projectDir = projectDir;
|
|
71
|
-
this.initialized = true;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Dispose the adapter and release all resources.
|
|
75
|
-
*/
|
|
76
|
-
async dispose() {
|
|
77
|
-
this.initialized = false;
|
|
78
|
-
this.projectDir = null;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Run a health check to verify the OpenAI SDK is usable.
|
|
82
|
-
*
|
|
83
|
-
* Checks:
|
|
84
|
-
* 1. Adapter has been initialized
|
|
85
|
-
* 2. `OPENAI_API_KEY` is set in the environment
|
|
86
|
-
*
|
|
87
|
-
* @returns Health status with details about each check.
|
|
88
|
-
*/
|
|
89
|
-
async healthCheck() {
|
|
90
|
-
if (!this.initialized) {
|
|
91
|
-
return {
|
|
92
|
-
healthy: false,
|
|
93
|
-
provider: this.id,
|
|
94
|
-
details: { error: 'Adapter not initialized' },
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
const apiKeyPresent = typeof process.env.OPENAI_API_KEY === 'string' && process.env.OPENAI_API_KEY.length > 0;
|
|
98
|
-
return {
|
|
99
|
-
healthy: apiKeyPresent,
|
|
100
|
-
provider: this.id,
|
|
101
|
-
details: {
|
|
102
|
-
apiKeyPresent,
|
|
103
|
-
projectDir: this.projectDir,
|
|
104
|
-
sdkVersion: 'ai@6 + @ai-sdk/openai',
|
|
105
|
-
},
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Check whether the adapter has been initialized.
|
|
110
|
-
*/
|
|
111
|
-
isInitialized() {
|
|
112
|
-
return this.initialized;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Get the project directory this adapter was initialized with.
|
|
116
|
-
*/
|
|
117
|
-
getProjectDir() {
|
|
118
|
-
return this.projectDir;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
//# sourceMappingURL=adapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../src/providers/openai-sdk/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,OAAO,EAAE,wBAAwB,EAAE,MAAM,c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,CAAC,IAAI,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,MAAM,aAAa,GACjB,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;QAE1F,OAAO;YACL,OAAO,EAAE,aAAa;YACtB,QAAQ,EAAE,IAAI,CAAC,EAAE;YACjB,OAAO,EAAE;gBACP,aAAa;gBACb,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,UAAU,EAAE,uBAAuB;aACpC;SACF,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,aAAa;QACX,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,aAAa;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CLEO permission rules for the OpenAI SDK adapter.
|
|
3
|
-
*
|
|
4
|
-
* Historically these rules were expressed as `InputGuardrail` instances from
|
|
5
|
-
* `@openai/agents`. Post T933 (ADR-052 — Vercel AI SDK consolidation) they
|
|
6
|
-
* are CLEO-native objects with the same shape so provider code that relies on
|
|
7
|
-
* their behaviour does not need to change. The Vercel AI SDK does not ship an
|
|
8
|
-
* equivalent guardrail abstraction — CLEO implements its own path ACL and
|
|
9
|
-
* tool allowlist enforcement here.
|
|
10
|
-
*
|
|
11
|
-
* A guardrail evaluates the serialised agent input before the request is sent
|
|
12
|
-
* to the model. A path that falls outside the allowed glob list causes the
|
|
13
|
-
* guardrail to trip and the run is rejected.
|
|
14
|
-
*
|
|
15
|
-
* @task T582 (original)
|
|
16
|
-
* @task T933 (SDK consolidation — provider-neutral rewrite)
|
|
17
|
-
*/
|
|
18
|
-
// ---------------------------------------------------------------------------
|
|
19
|
-
// Helpers
|
|
20
|
-
// ---------------------------------------------------------------------------
|
|
21
|
-
/**
|
|
22
|
-
* Converts a simple glob pattern to a RegExp.
|
|
23
|
-
*
|
|
24
|
-
* Supports `*` (any chars within a segment) and `**` (any chars including `/`).
|
|
25
|
-
* This is a lightweight alternative to the `minimatch` package so no extra
|
|
26
|
-
* dependency is required in the adapters package.
|
|
27
|
-
*
|
|
28
|
-
* @param glob - Glob pattern to convert (e.g. `/mnt/projects/**`).
|
|
29
|
-
* @returns A RegExp that matches paths conforming to the glob.
|
|
30
|
-
*/
|
|
31
|
-
function globToRegex(glob) {
|
|
32
|
-
// Escape regex metacharacters except * and ?
|
|
33
|
-
const escaped = glob.replace(/[.+^${}()|[\]\\]/g, '\\$&');
|
|
34
|
-
// Replace ** first (order matters), then *
|
|
35
|
-
const pattern = escaped.replace(/\*\*/g, '.+').replace(/\*/g, '[^/]*');
|
|
36
|
-
return new RegExp(`^${pattern}$`);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Check whether a file-system path is covered by at least one glob pattern.
|
|
40
|
-
*
|
|
41
|
-
* @param path - The absolute or relative path to test.
|
|
42
|
-
* @param allowedGlobs - Array of glob patterns (supports `*` and `**`).
|
|
43
|
-
* @returns `true` when the path matches at least one pattern.
|
|
44
|
-
*/
|
|
45
|
-
export function isPathAllowed(path, allowedGlobs) {
|
|
46
|
-
if (allowedGlobs.length === 0)
|
|
47
|
-
return true;
|
|
48
|
-
return allowedGlobs.some((glob) => globToRegex(glob).test(path));
|
|
49
|
-
}
|
|
50
|
-
// ---------------------------------------------------------------------------
|
|
51
|
-
// Guardrail builders
|
|
52
|
-
// ---------------------------------------------------------------------------
|
|
53
|
-
/**
|
|
54
|
-
* Build an input guardrail that enforces CLEO file-glob path ACLs.
|
|
55
|
-
*
|
|
56
|
-
* Inspects the serialised agent input for embedded `"path":"..."` fields
|
|
57
|
-
* and rejects the run when a path falls outside the allowlist. This provides
|
|
58
|
-
* an early-exit safety fence before the agent starts consuming model tokens.
|
|
59
|
-
*
|
|
60
|
-
* @param allowedGlobs - Glob patterns that tool path arguments must match.
|
|
61
|
-
* Pass an empty array to allow all paths (permissive mode).
|
|
62
|
-
* @returns A {@link CleoInputGuardrail} ready to attach to an agent.
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* ```typescript
|
|
66
|
-
* const guard = buildPathGuardrail(['/mnt/projects/**', '/tmp/**']);
|
|
67
|
-
* const agent = buildStandaloneAgent('...', 'gpt-4.1', [guard]);
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
export function buildPathGuardrail(allowedGlobs) {
|
|
71
|
-
return {
|
|
72
|
-
name: 'cleo_path_acl',
|
|
73
|
-
execute: async (args) => {
|
|
74
|
-
// Serialise input to a string for heuristic path scanning.
|
|
75
|
-
const inputStr = typeof args.input === 'string' ? args.input : JSON.stringify(args.input);
|
|
76
|
-
// Scan for JSON-encoded `"path":"..."` occurrences in the input text.
|
|
77
|
-
// This is conservative: if no path field is found the guardrail passes.
|
|
78
|
-
const pathMatches = inputStr.matchAll(/"path"\s*:\s*"([^"]+)"/g);
|
|
79
|
-
for (const match of pathMatches) {
|
|
80
|
-
const candidate = match[1];
|
|
81
|
-
if (candidate && !isPathAllowed(candidate, allowedGlobs)) {
|
|
82
|
-
return {
|
|
83
|
-
tripwireTriggered: true,
|
|
84
|
-
outputInfo: {
|
|
85
|
-
reason: `cleo_path_acl: path denied by ACL — ${candidate}`,
|
|
86
|
-
deniedPath: candidate,
|
|
87
|
-
allowedGlobs,
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return { tripwireTriggered: false, outputInfo: null };
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Build an input guardrail that documents the tool allowlist for audit purposes.
|
|
98
|
-
*
|
|
99
|
-
* Tool-name enforcement is primarily structural — agents only receive the
|
|
100
|
-
* tools declared by CLEO orchestration. This guardrail provides an additional
|
|
101
|
-
* audit layer that records the active allowlist in the span metadata.
|
|
102
|
-
*
|
|
103
|
-
* @param allowedTools - Exact tool names permitted for this agent.
|
|
104
|
-
* Pass an empty array to allow all tools (permissive mode).
|
|
105
|
-
* @returns A {@link CleoInputGuardrail} ready to attach to an agent.
|
|
106
|
-
*
|
|
107
|
-
* @example
|
|
108
|
-
* ```typescript
|
|
109
|
-
* const guard = buildToolAllowlistGuardrail(['read', 'write']);
|
|
110
|
-
* ```
|
|
111
|
-
*/
|
|
112
|
-
export function buildToolAllowlistGuardrail(allowedTools) {
|
|
113
|
-
return {
|
|
114
|
-
name: 'cleo_tool_allowlist',
|
|
115
|
-
execute: async (_args) => {
|
|
116
|
-
// Structural enforcement: only listed tools are attached to the agent.
|
|
117
|
-
// This guardrail records the allowlist for audit and always passes.
|
|
118
|
-
return {
|
|
119
|
-
tripwireTriggered: false,
|
|
120
|
-
outputInfo: { allowedTools, checked: true },
|
|
121
|
-
};
|
|
122
|
-
},
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Build the default CLEO guardrail set from spawn options.
|
|
127
|
-
*
|
|
128
|
-
* Combines path ACL and tool allowlist guards into a single array ready to
|
|
129
|
-
* pass as `inputGuardrails` on an agent topology build.
|
|
130
|
-
*
|
|
131
|
-
* @param allowedGlobs - File-path glob allowlist.
|
|
132
|
-
* @param allowedTools - Tool name allowlist.
|
|
133
|
-
* @returns Array of input guardrails to attach to the agent.
|
|
134
|
-
*/
|
|
135
|
-
export function buildDefaultGuardrails(allowedGlobs, allowedTools) {
|
|
136
|
-
const guards = [];
|
|
137
|
-
if (allowedGlobs.length > 0) {
|
|
138
|
-
guards.push(buildPathGuardrail(allowedGlobs));
|
|
139
|
-
}
|
|
140
|
-
if (allowedTools.length > 0) {
|
|
141
|
-
guards.push(buildToolAllowlistGuardrail(allowedTools));
|
|
142
|
-
}
|
|
143
|
-
return guards;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Evaluate a set of CLEO input guardrails against an input payload.
|
|
147
|
-
*
|
|
148
|
-
* Runs every guardrail in sequence and returns the first tripwire result.
|
|
149
|
-
* When no guardrail trips, returns a passing result with diagnostic data
|
|
150
|
-
* aggregated from each guardrail's `outputInfo`.
|
|
151
|
-
*
|
|
152
|
-
* @param guardrails - Guardrails to evaluate.
|
|
153
|
-
* @param input - The input string to test (typically the enriched prompt).
|
|
154
|
-
* @returns Aggregated guardrail result.
|
|
155
|
-
*/
|
|
156
|
-
export async function evaluateGuardrails(guardrails, input) {
|
|
157
|
-
const aggregate = [];
|
|
158
|
-
for (const guard of guardrails) {
|
|
159
|
-
const result = await guard.execute({
|
|
160
|
-
agent: null,
|
|
161
|
-
input,
|
|
162
|
-
context: null,
|
|
163
|
-
});
|
|
164
|
-
if (result.tripwireTriggered) {
|
|
165
|
-
return result;
|
|
166
|
-
}
|
|
167
|
-
aggregate.push({ name: guard.name, outputInfo: result.outputInfo });
|
|
168
|
-
}
|
|
169
|
-
return {
|
|
170
|
-
tripwireTriggered: false,
|
|
171
|
-
outputInfo: aggregate,
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
//# sourceMappingURL=guardrails.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"guardrails.js","sourceRoot":"","sources":["../../../src/providers/openai-sdk/guardrails.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AA8CH,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E;;;;;;;;;GASG;AACH,SAAS,WAAW,CAAC,IAAY;IAC/B,6CAA6C;IAC7C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;IAC1D,2CAA2C;IAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,OAA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AAC;YAC7B,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IACtE,CAAC;IAED,OAAO;QACL,iBAAiB,EAAE,KAAK;QACxB,UAAU,EAAE,SAAS;KACtB,CAAC;AACJ,CAAC"}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CLEO Team topology → lead/worker agent descriptors.
|
|
3
|
-
*
|
|
4
|
-
* CLEO agents are organised in a Lead → Worker hierarchy. Historically this
|
|
5
|
-
* was wired into the `@openai/agents` first-class `handoffs` graph. Post T933
|
|
6
|
-
* (ADR-052 — Vercel AI SDK consolidation) CLEO owns the topology entirely:
|
|
7
|
-
*
|
|
8
|
-
* - A Team Lead is a {@link CleoAgent} whose `handoffs` array lists its workers.
|
|
9
|
-
* - Each Worker archetype (read-only, write, bash) is declared in
|
|
10
|
-
* `WORKER_ARCHETYPES` and built on demand.
|
|
11
|
-
* - The mapping is driven by `SpawnContext.options.handoffs`, which is an
|
|
12
|
-
* array of worker archetype names.
|
|
13
|
-
* - When a lead agent needs to delegate, the spawn provider runs a separate
|
|
14
|
-
* `generateText` call for the selected worker and injects the result back
|
|
15
|
-
* into the lead's context.
|
|
16
|
-
*
|
|
17
|
-
* @task T582 (original)
|
|
18
|
-
* @task T933 (SDK consolidation — CLEO-native topology)
|
|
19
|
-
*/
|
|
20
|
-
/**
|
|
21
|
-
* Registry of built-in CLEO worker archetypes.
|
|
22
|
-
*
|
|
23
|
-
* Callers reference these by name in `SpawnContext.options.handoffs`.
|
|
24
|
-
* New archetypes can be added here without changing the spawn provider.
|
|
25
|
-
*/
|
|
26
|
-
export const WORKER_ARCHETYPES = {
|
|
27
|
-
'worker-read': {
|
|
28
|
-
name: 'worker-read',
|
|
29
|
-
instructions: 'You are a read-only CLEO worker. You may only read files and return findings. Never write, modify, or delete files.',
|
|
30
|
-
model: 'gpt-4.1-mini',
|
|
31
|
-
},
|
|
32
|
-
'worker-write': {
|
|
33
|
-
name: 'worker-write',
|
|
34
|
-
instructions: 'You are a CLEO write worker. You implement code changes directed by the lead agent. Follow the lead agent instructions precisely.',
|
|
35
|
-
model: 'gpt-4.1-mini',
|
|
36
|
-
},
|
|
37
|
-
'worker-bash': {
|
|
38
|
-
name: 'worker-bash',
|
|
39
|
-
instructions: 'You are a CLEO bash worker. You run shell commands directed by the lead agent. Only execute commands explicitly requested.',
|
|
40
|
-
model: 'gpt-4.1-mini',
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
// ---------------------------------------------------------------------------
|
|
44
|
-
// Agent builders
|
|
45
|
-
// ---------------------------------------------------------------------------
|
|
46
|
-
/**
|
|
47
|
-
* Build a worker {@link CleoAgent} from a named archetype.
|
|
48
|
-
*
|
|
49
|
-
* @param archetypeName - Key in {@link WORKER_ARCHETYPES}.
|
|
50
|
-
* @param guardrails - Input guardrails to attach to the worker agent.
|
|
51
|
-
* @returns A configured agent descriptor or `null` when the archetype is unknown.
|
|
52
|
-
*/
|
|
53
|
-
export function buildWorkerAgent(archetypeName, guardrails) {
|
|
54
|
-
const archetype = WORKER_ARCHETYPES[archetypeName];
|
|
55
|
-
if (!archetype)
|
|
56
|
-
return null;
|
|
57
|
-
return {
|
|
58
|
-
name: archetype.name,
|
|
59
|
-
instructions: archetype.instructions,
|
|
60
|
-
model: archetype.model,
|
|
61
|
-
...(guardrails.length > 0 ? { inputGuardrails: guardrails } : {}),
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Build a team lead {@link CleoAgent} whose `handoffs` reference the given workers.
|
|
66
|
-
*
|
|
67
|
-
* @param leadInstructions - System instructions for the lead agent.
|
|
68
|
-
* @param leadModel - Model to use for the lead agent.
|
|
69
|
-
* @param workers - Worker agents this lead can hand off to.
|
|
70
|
-
* @param guardrails - Input guardrails to attach to the lead agent.
|
|
71
|
-
* @returns A configured lead agent descriptor.
|
|
72
|
-
*/
|
|
73
|
-
export function buildLeadAgent(leadInstructions, leadModel, workers, guardrails) {
|
|
74
|
-
return {
|
|
75
|
-
name: 'cleo-lead',
|
|
76
|
-
instructions: leadInstructions,
|
|
77
|
-
model: leadModel,
|
|
78
|
-
...(workers.length > 0 ? { handoffs: workers } : {}),
|
|
79
|
-
...(guardrails.length > 0 ? { inputGuardrails: guardrails } : {}),
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Build a simple single-tier agent (no handoffs) from prompt and model.
|
|
84
|
-
*
|
|
85
|
-
* Used when `SpawnContext.options.tier` is `'worker'` or when no handoff
|
|
86
|
-
* names are provided.
|
|
87
|
-
*
|
|
88
|
-
* @param instructions - Agent system instructions.
|
|
89
|
-
* @param model - Model identifier.
|
|
90
|
-
* @param guardrails - Input guardrails.
|
|
91
|
-
* @returns A configured agent descriptor.
|
|
92
|
-
*/
|
|
93
|
-
export function buildStandaloneAgent(instructions, model, guardrails) {
|
|
94
|
-
return {
|
|
95
|
-
name: 'cleo-worker',
|
|
96
|
-
instructions,
|
|
97
|
-
model,
|
|
98
|
-
...(guardrails.length > 0 ? { inputGuardrails: guardrails } : {}),
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Build the entry-point agent and its worker topology from spawn options.
|
|
103
|
-
*
|
|
104
|
-
* - `tier === 'lead'` or `tier === 'orchestrator'`: creates a lead agent with
|
|
105
|
-
* worker handoffs derived from `handoffNames`.
|
|
106
|
-
* - `tier === 'worker'`: creates a standalone agent with no handoffs.
|
|
107
|
-
*
|
|
108
|
-
* Unknown archetype names in `handoffNames` are silently skipped.
|
|
109
|
-
*
|
|
110
|
-
* @param options - Topology build options.
|
|
111
|
-
* @returns The entry-point agent descriptor.
|
|
112
|
-
*/
|
|
113
|
-
export function buildAgentTopology(options) {
|
|
114
|
-
const { instructions, model, tier, handoffNames, guardrails } = options;
|
|
115
|
-
if (tier === 'worker') {
|
|
116
|
-
return buildStandaloneAgent(instructions, model, guardrails);
|
|
117
|
-
}
|
|
118
|
-
// Build worker agents from archetype names; skip unknown names.
|
|
119
|
-
const workers = handoffNames
|
|
120
|
-
.map((name) => buildWorkerAgent(name, guardrails))
|
|
121
|
-
.filter((a) => a !== null);
|
|
122
|
-
if (workers.length === 0) {
|
|
123
|
-
// Lead with no workers — still usable as a standalone agent.
|
|
124
|
-
return buildStandaloneAgent(instructions, model, guardrails);
|
|
125
|
-
}
|
|
126
|
-
return buildLeadAgent(instructions, model, workers, guardrails);
|
|
127
|
-
}
|
|
128
|
-
//# sourceMappingURL=handoff.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handoff.js","sourceRoot":"","sources":["../../../src/providers/openai-sdk/handoff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAuDH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAoC;IAChE,aAAa,EAAE;QACb,IAAI,EAAE,aAAa;QACnB,YAAY,EACV,qHAAqH;QACvH,KAAK,EAAE,cAAc;KACtB;IACD,cAAc,EAAE;QACd,IAAI,EAAE,cAAc;QACpB,YAAY,EACV,mIAAmI;QACrI,KAAK,EAAE,cAAc;KACtB;IACD,aAAa,EAAE;QACb,IAAI,EAAE,aAAa;QACnB,YAAY,EACV,4HAA4H;QAC9H,KAAK,EAAE,cAAc;KACtB;CACF,CAAC;AAEF,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC9B,aAAqB,EACrB,UAAgC;IAEhC,MAAM,SAAS,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAC;IACnD,IAAI,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IAE5B,OAAO;QACL,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,YAAY,EAAE,SAAS,CAAC,YAAY;Q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gEAAgE;IAChE,MAAM,OAAO,GAAgB,YAAY;SACtC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;SACjD,MAAM,CAAC,CAAC,CAAC,EAAkB,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;IAE7C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,6DAA6D;QAC7D,OAAO,oBAAoB,CAAC,YAAY,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,cAAc,CAAC,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;AAClE,CAAC"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @packageDocumentation
|
|
3
|
-
*
|
|
4
|
-
* CLEO provider adapter for the OpenAI provider, backed by the Vercel AI SDK.
|
|
5
|
-
* Default export is the adapter class for dynamic loading by AdapterManager.
|
|
6
|
-
*
|
|
7
|
-
* @task T582 (original)
|
|
8
|
-
* @task T933 (SDK consolidation — Vercel AI SDK migration)
|
|
9
|
-
*/
|
|
10
|
-
import { OpenAiSdkAdapter } from './adapter.js';
|
|
11
|
-
export { OpenAiSdkAdapter } from './adapter.js';
|
|
12
|
-
export { buildDefaultGuardrails, buildPathGuardrail, buildToolAllowlistGuardrail, evaluateGuardrails, isPathAllowed, } from './guardrails.js';
|
|
13
|
-
export { buildAgentTopology, buildLeadAgent, buildStandaloneAgent, buildWorkerAgent, WORKER_ARCHETYPES, } from './handoff.js';
|
|
14
|
-
export { OpenAiSdkInstallProvider } from './install.js';
|
|
15
|
-
export { OpenAiSdkSpawnProvider, registerTraceProcessor, setTracingDisabled, unregisterTraceProcessor, } from './spawn.js';
|
|
16
|
-
export { CleoConduitTraceProcessor } from './tracing.js';
|
|
17
|
-
export default OpenAiSdkAdapter;
|
|
18
|
-
/**
|
|
19
|
-
* Factory function for creating adapter instances.
|
|
20
|
-
* Used by AdapterManager's dynamic import fallback.
|
|
21
|
-
*
|
|
22
|
-
* @remarks
|
|
23
|
-
* This is the primary entry point for dynamic adapter loading.
|
|
24
|
-
* AdapterManager calls this function when it resolves the openai-sdk
|
|
25
|
-
* provider via its import-based discovery mechanism.
|
|
26
|
-
*
|
|
27
|
-
* @returns A new {@link OpenAiSdkAdapter} instance ready for initialization.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```typescript
|
|
31
|
-
* import { createAdapter } from '@cleocode/adapters/providers/openai-sdk';
|
|
32
|
-
*
|
|
33
|
-
* const adapter = createAdapter();
|
|
34
|
-
* await adapter.initialize('/path/to/project');
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export function createAdapter() {
|
|
38
|
-
return new OpenAiSdkAdapter();
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/providers/openai-sdk/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAOhD,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,2BAA2B,EAC3B,kBAAkB,EAClB,aAAa,GACd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,YAAY,CAAC;AAYpB,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAEzD,eAAe,gBAAgB,CAAC;AAEhC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,IAAI,gBAAgB,EAAE,CAAC;AAChC,CAAC"}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OpenAI SDK Install Provider.
|
|
3
|
-
*
|
|
4
|
-
* Handles CLEO installation into OpenAI SDK environments:
|
|
5
|
-
* - Writes an AGENTS.md file with CLEO @-references
|
|
6
|
-
* - Creates a `.openai/` config stub if it does not exist
|
|
7
|
-
*
|
|
8
|
-
* @task T582
|
|
9
|
-
*/
|
|
10
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
11
|
-
import { join } from 'node:path';
|
|
12
|
-
/** Lines that should appear in AGENTS.md to reference CLEO. */
|
|
13
|
-
const INSTRUCTION_REFERENCES = ['@~/.cleo/templates/CLEO-INJECTION.md', '@.cleo/memory-bridge.md'];
|
|
14
|
-
/**
|
|
15
|
-
* Install provider for the OpenAI SDK adapter (Vercel AI SDK).
|
|
16
|
-
*
|
|
17
|
-
* Manages CLEO's integration with OpenAI SDK projects by:
|
|
18
|
-
* 1. Ensuring AGENTS.md contains @-references to CLEO instruction files
|
|
19
|
-
* 2. Creating the `.openai/` config directory stub if absent
|
|
20
|
-
*
|
|
21
|
-
* @remarks
|
|
22
|
-
* Installation is idempotent — running install multiple times on the same
|
|
23
|
-
* project produces the same result.
|
|
24
|
-
*/
|
|
25
|
-
export class OpenAiSdkInstallProvider {
|
|
26
|
-
/**
|
|
27
|
-
* Install CLEO into an OpenAI SDK project.
|
|
28
|
-
*
|
|
29
|
-
* @param options - Installation options including project directory.
|
|
30
|
-
* @returns Result describing what was installed.
|
|
31
|
-
*/
|
|
32
|
-
async install(options) {
|
|
33
|
-
const { projectDir } = options;
|
|
34
|
-
const installedAt = new Date().toISOString();
|
|
35
|
-
const details = {};
|
|
36
|
-
// Step 1: Ensure AGENTS.md has @-references
|
|
37
|
-
const instructionFileUpdated = this.updateInstructionFile(projectDir);
|
|
38
|
-
if (instructionFileUpdated) {
|
|
39
|
-
details.instructionFile = join(projectDir, 'AGENTS.md');
|
|
40
|
-
}
|
|
41
|
-
// Step 2: Create .openai config directory stub
|
|
42
|
-
const configCreated = this.ensureConfigDir(projectDir);
|
|
43
|
-
if (configCreated) {
|
|
44
|
-
details.configDir = join(projectDir, '.openai');
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
success: true,
|
|
48
|
-
installedAt,
|
|
49
|
-
instructionFileUpdated,
|
|
50
|
-
details,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Uninstall CLEO from the current OpenAI SDK project.
|
|
55
|
-
*
|
|
56
|
-
* Does not remove AGENTS.md references (they are harmless if CLEO is absent).
|
|
57
|
-
*/
|
|
58
|
-
async uninstall() { }
|
|
59
|
-
/**
|
|
60
|
-
* Check whether CLEO is installed in the current OpenAI SDK environment.
|
|
61
|
-
*
|
|
62
|
-
* Checks for `@~/.cleo/templates/CLEO-INJECTION.md` in AGENTS.md.
|
|
63
|
-
*/
|
|
64
|
-
async isInstalled() {
|
|
65
|
-
// A project is considered installed when AGENTS.md contains the first reference.
|
|
66
|
-
// There is no plugin registry for the OpenAI SDK.
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Ensure AGENTS.md contains @-references to CLEO instruction files.
|
|
71
|
-
*
|
|
72
|
-
* @param projectDir - Project root directory.
|
|
73
|
-
*/
|
|
74
|
-
async ensureInstructionReferences(projectDir) {
|
|
75
|
-
this.updateInstructionFile(projectDir);
|
|
76
|
-
}
|
|
77
|
-
// ---------------------------------------------------------------------------
|
|
78
|
-
// Private helpers
|
|
79
|
-
// ---------------------------------------------------------------------------
|
|
80
|
-
/**
|
|
81
|
-
* Update AGENTS.md with CLEO @-references.
|
|
82
|
-
*
|
|
83
|
-
* @returns `true` if the file was created or modified.
|
|
84
|
-
*/
|
|
85
|
-
updateInstructionFile(projectDir) {
|
|
86
|
-
const agentsMdPath = join(projectDir, 'AGENTS.md');
|
|
87
|
-
let content = '';
|
|
88
|
-
let existed = false;
|
|
89
|
-
if (existsSync(agentsMdPath)) {
|
|
90
|
-
content = readFileSync(agentsMdPath, 'utf-8');
|
|
91
|
-
existed = true;
|
|
92
|
-
}
|
|
93
|
-
const missingRefs = INSTRUCTION_REFERENCES.filter((ref) => !content.includes(ref));
|
|
94
|
-
if (missingRefs.length === 0)
|
|
95
|
-
return false;
|
|
96
|
-
const refsBlock = missingRefs.join('\n');
|
|
97
|
-
if (existed) {
|
|
98
|
-
const separator = content.endsWith('\n') ? '' : '\n';
|
|
99
|
-
content = content + separator + refsBlock + '\n';
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
content = refsBlock + '\n';
|
|
103
|
-
}
|
|
104
|
-
writeFileSync(agentsMdPath, content, 'utf-8');
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Create the `.openai/` config directory if it does not exist.
|
|
109
|
-
*
|
|
110
|
-
* @returns `true` if the directory was created.
|
|
111
|
-
*/
|
|
112
|
-
ensureConfigDir(projectDir) {
|
|
113
|
-
const configDir = join(projectDir, '.openai');
|
|
114
|
-
if (existsSync(configDir))
|
|
115
|
-
return false;
|
|
116
|
-
mkdirSync(configDir, { recursive: true });
|
|
117
|
-
return true;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
//# sourceMappingURL=install.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../../src/providers/openai-sdk/install.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,+DAA+D;AAC/D,MAAM,sBAAsB,GAAG,CA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