@cleocode/adapters 2026.4.92 → 2026.4.94
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/dist/index.js +40795 -18064
- package/dist/index.js.map +4 -4
- package/dist/providers/claude-sdk/index.d.ts +10 -4
- package/dist/providers/claude-sdk/index.d.ts.map +1 -1
- package/dist/providers/claude-sdk/spawn.d.ts +29 -28
- package/dist/providers/claude-sdk/spawn.d.ts.map +1 -1
- package/dist/providers/openai-sdk/adapter.d.ts +18 -17
- package/dist/providers/openai-sdk/adapter.d.ts.map +1 -1
- package/dist/providers/openai-sdk/guardrails.d.ts +71 -18
- package/dist/providers/openai-sdk/guardrails.d.ts.map +1 -1
- package/dist/providers/openai-sdk/handoff.d.ts +51 -21
- package/dist/providers/openai-sdk/handoff.d.ts.map +1 -1
- package/dist/providers/openai-sdk/index.d.ts +8 -5
- package/dist/providers/openai-sdk/index.d.ts.map +1 -1
- package/dist/providers/openai-sdk/install.d.ts +1 -1
- package/dist/providers/openai-sdk/spawn.d.ts +54 -21
- package/dist/providers/openai-sdk/spawn.d.ts.map +1 -1
- package/dist/providers/openai-sdk/tracing.d.ts +87 -21
- package/dist/providers/openai-sdk/tracing.d.ts.map +1 -1
- package/dist/providers/shared/sdk-result-mapper.d.ts +9 -7
- package/dist/providers/shared/sdk-result-mapper.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/__tests__/harness-interop.test.ts +451 -0
- package/src/providers/claude-sdk/__tests__/spawn.test.ts +100 -265
- package/src/providers/claude-sdk/index.ts +10 -4
- package/src/providers/claude-sdk/spawn.ts +69 -106
- package/src/providers/openai-sdk/__tests__/openai-sdk-spawn.test.ts +134 -103
- package/src/providers/openai-sdk/adapter.ts +19 -18
- package/src/providers/openai-sdk/guardrails.ts +106 -25
- package/src/providers/openai-sdk/handoff.ts +73 -37
- package/src/providers/openai-sdk/index.ts +28 -4
- package/src/providers/openai-sdk/install.ts +1 -1
- package/src/providers/openai-sdk/manifest.json +4 -4
- package/src/providers/openai-sdk/spawn.ts +213 -48
- package/src/providers/openai-sdk/tracing.ts +105 -22
- package/src/providers/shared/sdk-result-mapper.ts +9 -7
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @packageDocumentation
|
|
3
3
|
*
|
|
4
|
-
* Claude
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Claude SDK spawn provider for CLEO — Vercel AI SDK edition.
|
|
5
|
+
*
|
|
6
|
+
* Uses `@ai-sdk/anthropic` via the Vercel AI SDK (`ai` v6) instead of the
|
|
7
|
+
* legacy `@anthropic-ai/claude-agent-sdk`. CLEO retains its own orchestration
|
|
8
|
+
* primitives (composeSpawnPayload, playbook runtime, agent registry); this
|
|
9
|
+
* provider exposes the LLM bridge for programmatic subagent execution with
|
|
10
|
+
* structured output and session tracking.
|
|
7
11
|
*
|
|
8
12
|
* Enabled via `provider.claude.mode = 'sdk'` in CLEO config.
|
|
9
13
|
*
|
|
10
|
-
* @task T581
|
|
14
|
+
* @task T581 (original)
|
|
15
|
+
* @task T933 (SDK consolidation — Vercel AI SDK migration)
|
|
16
|
+
* @see ADR-052 — SDK consolidation decision
|
|
11
17
|
*/
|
|
12
18
|
export type { McpServerMap, McpStdioConfig } from './mcp-registry.js';
|
|
13
19
|
export { getServers } from './mcp-registry.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/claude-sdk/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/claude-sdk/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,37 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Claude SDK Spawn Provider
|
|
2
|
+
* Claude SDK Spawn Provider — Vercel AI SDK edition.
|
|
3
3
|
*
|
|
4
|
-
* Implements
|
|
5
|
-
*
|
|
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.
|
|
6
9
|
*
|
|
7
10
|
* Differences from `ClaudeCodeSpawnProvider`:
|
|
8
|
-
* - Uses
|
|
11
|
+
* - Uses `generateText()` via Vercel AI SDK instead of a detached child process
|
|
9
12
|
* - Awaits full completion before returning (synchronous output capture)
|
|
10
|
-
* - Session IDs
|
|
13
|
+
* - Session IDs are generated by CLEO and tracked in `SessionStore`
|
|
11
14
|
* - No temp files, no OS PIDs — tracking is purely in-memory session IDs
|
|
12
15
|
* - `canSpawn()` uses 3-tier key resolution (env var → stored key → Claude Code OAuth)
|
|
13
16
|
*
|
|
14
17
|
* CANT enrichment is identical to the CLI provider: `buildCantEnrichedPrompt()`
|
|
15
|
-
* is called before `
|
|
18
|
+
* is called before `generateText()` and the result is passed as the user prompt.
|
|
16
19
|
*
|
|
17
|
-
* @task T581
|
|
20
|
+
* @task T581 (original)
|
|
21
|
+
* @task T933 (SDK consolidation — Vercel AI SDK migration)
|
|
18
22
|
* @see T752 — canSpawn() OAuth fix
|
|
23
|
+
* @see ADR-052 — SDK consolidation decision
|
|
19
24
|
*/
|
|
20
25
|
import type { AdapterSpawnProvider, SpawnContext, SpawnResult } from '@cleocode/contracts';
|
|
21
26
|
/**
|
|
22
|
-
* Spawn provider that uses the
|
|
23
|
-
* subagent execution.
|
|
27
|
+
* Spawn provider that uses the Vercel AI SDK (`ai` v6 + `@ai-sdk/anthropic`)
|
|
28
|
+
* for programmatic subagent execution.
|
|
24
29
|
*
|
|
25
|
-
* Each call to `spawn()` runs a
|
|
26
|
-
* captures the output. Sessions are tracked in `SessionStore` so callers
|
|
27
|
-
*
|
|
28
|
-
* `terminate()`.
|
|
30
|
+
* Each call to `spawn()` runs a single `generateText()` call to completion and
|
|
31
|
+
* captures the output. Sessions are tracked in `SessionStore` so callers can
|
|
32
|
+
* inspect active sessions via `listRunning()` and remove them via `terminate()`.
|
|
29
33
|
*
|
|
30
34
|
* @remarks
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
+
* Unlike the legacy `@anthropic-ai/claude-agent-sdk`, the Vercel AI SDK is
|
|
36
|
+
* strictly an LLM bridge — it does not manage a Claude Code subprocess or
|
|
37
|
+
* provide built-in MCP server wiring. Tool use is available through the SDK's
|
|
38
|
+
* tool system, but CLEO orchestration (composeSpawnPayload, playbooks, the
|
|
39
|
+
* agent registry) remains the source of truth for scaffolding.
|
|
35
40
|
*/
|
|
36
41
|
export declare class ClaudeSDKSpawnProvider implements AdapterSpawnProvider {
|
|
37
42
|
/** In-memory session registry. */
|
|
@@ -44,18 +49,14 @@ export declare class ClaudeSDKSpawnProvider implements AdapterSpawnProvider {
|
|
|
44
49
|
* - `~/.local/share/cleo/anthropic-key` (user-stored via cleo config)
|
|
45
50
|
* - Claude Code OAuth token (zero-config for Claude Code users)
|
|
46
51
|
*
|
|
47
|
-
* No binary check is needed because the SDK manages the Claude Code
|
|
48
|
-
* subprocess internally.
|
|
49
|
-
*
|
|
50
52
|
* @returns `true` when any Anthropic credential is available
|
|
51
53
|
*/
|
|
52
54
|
canSpawn(): Promise<boolean>;
|
|
53
55
|
/**
|
|
54
|
-
* Spawn a subagent using the
|
|
56
|
+
* Spawn a subagent using the Vercel AI SDK.
|
|
55
57
|
*
|
|
56
|
-
* Enriches the prompt via CANT context, runs
|
|
57
|
-
*
|
|
58
|
-
* `SpawnResult` with the final output and exit code.
|
|
58
|
+
* Enriches the prompt via CANT context, runs `generateText()` to completion,
|
|
59
|
+
* and returns a `SpawnResult` with the final output and exit code.
|
|
59
60
|
*
|
|
60
61
|
* @param context - Spawn context with taskId, prompt, options
|
|
61
62
|
* @returns Resolved spawn result (status: 'completed' or 'failed')
|
|
@@ -73,10 +74,10 @@ export declare class ClaudeSDKSpawnProvider implements AdapterSpawnProvider {
|
|
|
73
74
|
/**
|
|
74
75
|
* Remove a session from tracking.
|
|
75
76
|
*
|
|
76
|
-
* The underlying
|
|
77
|
-
* externally once the
|
|
78
|
-
* the store prevents it from appearing in `listRunning()` but
|
|
79
|
-
* interrupt the in-progress
|
|
77
|
+
* The underlying `generateText()` call runs inside `spawn()` and cannot be
|
|
78
|
+
* cancelled externally once the HTTP request is in flight. Removing the
|
|
79
|
+
* entry from the store prevents it from appearing in `listRunning()` but
|
|
80
|
+
* does not interrupt the in-progress request.
|
|
80
81
|
*
|
|
81
82
|
* @param instanceId - ID of the spawn instance to terminate
|
|
82
83
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../../src/providers/claude-sdk/spawn.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../../src/providers/claude-sdk/spawn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAKH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AA+D3F;;;;;;;;;;;;;;GAcG;AACH,qBAAa,sBAAuB,YAAW,oBAAoB;IACjE,kCAAkC;IAClC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAsB;IAE/C;;;;;;;;;OASG;IACG,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC;IAIlC;;;;;;;;OAQG;IACG,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;IAwGxD;;;;;;;OAOG;IACG,WAAW,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAU3C;;;;;;;;;OASG;IACG,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGnD"}
|
|
@@ -1,39 +1,40 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OpenAI
|
|
2
|
+
* OpenAI SDK Adapter — Vercel AI SDK edition.
|
|
3
3
|
*
|
|
4
|
-
* Main `CLEOProviderAdapter` implementation for the OpenAI
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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.
|
|
7
8
|
*
|
|
8
|
-
* @task T582
|
|
9
|
+
* @task T582 (original)
|
|
10
|
+
* @task T933 (SDK consolidation — Vercel AI SDK migration)
|
|
11
|
+
* @see ADR-052 — SDK consolidation decision
|
|
9
12
|
*/
|
|
10
13
|
import type { AdapterCapabilities, AdapterHealthStatus, CLEOProviderAdapter } from '@cleocode/contracts';
|
|
11
14
|
import { OpenAiSdkInstallProvider } from './install.js';
|
|
12
15
|
import { OpenAiSdkSpawnProvider } from './spawn.js';
|
|
13
16
|
/**
|
|
14
|
-
* CLEO provider adapter for the OpenAI
|
|
17
|
+
* CLEO provider adapter for the OpenAI provider.
|
|
15
18
|
*
|
|
16
|
-
* Bridges CLEO's adapter system with the
|
|
17
|
-
* - Spawn: Launches agents via the SDK
|
|
19
|
+
* Bridges CLEO's adapter system with the Vercel AI SDK:
|
|
20
|
+
* - Spawn: Launches agents via the SDK with CLEO-native handoff topology
|
|
18
21
|
* - Install: Manages AGENTS.md @-references and .openai/ config directory
|
|
19
22
|
* - Tracing: Default-on conduit span persistence via `CleoConduitTraceProcessor`
|
|
20
23
|
*
|
|
21
24
|
* @remarks
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* This is also the only provider supporting 100+ LLMs via the Vercel AI SDK
|
|
28
|
-
* bridge (capability flag: `supportsMultiModel`).
|
|
25
|
+
* Handoff topology is CLEO-owned (see `handoff.ts`): lead agents delegate to
|
|
26
|
+
* worker archetypes in sequence, and the concatenated output is returned.
|
|
27
|
+
* The Vercel AI SDK surface (`generateText` / `streamText`) works uniformly
|
|
28
|
+
* across Anthropic, OpenAI, and compatible providers, so the provider keeps
|
|
29
|
+
* the `supportsMultiModel` capability flag.
|
|
29
30
|
*/
|
|
30
31
|
export declare class OpenAiSdkAdapter implements CLEOProviderAdapter {
|
|
31
32
|
/** Unique provider identifier. */
|
|
32
33
|
readonly id = "openai-sdk";
|
|
33
34
|
/** Human-readable provider name. */
|
|
34
|
-
readonly name = "OpenAI
|
|
35
|
+
readonly name = "OpenAI SDK (Vercel AI SDK)";
|
|
35
36
|
/** Adapter version string. */
|
|
36
|
-
readonly version = "
|
|
37
|
+
readonly version = "2.0.0";
|
|
37
38
|
/** Declared capabilities for this provider. */
|
|
38
39
|
capabilities: AdapterCapabilities;
|
|
39
40
|
/** Spawn provider for SDK-backed agent runs with handoff topology. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/providers/openai-sdk/adapter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/providers/openai-sdk/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;;;;;;;;;;;;GAcG;AACH,qBAAa,gBAAiB,YAAW,mBAAmB;IAC1D,kCAAkC;IAClC,QAAQ,CAAC,EAAE,gBAAgB;IAC3B,oCAAoC;IACpC,QAAQ,CAAC,IAAI,gCAAgC;IAC7C,8BAA8B;IAC9B,QAAQ,CAAC,OAAO,WAAW;IAE3B,+CAA+C;IAC/C,YAAY,EAAE,mBAAmB,CAa/B;IAEF,sEAAsE;IACtE,KAAK,EAAE,sBAAsB,CAAC;IAC9B,+EAA+E;IAC/E,OAAO,EAAE,wBAAwB,CAAC;IAElC,oEAAoE;IACpE,OAAO,CAAC,UAAU,CAAuB;IACzC,kDAAkD;IAClD,OAAO,CAAC,WAAW,CAAS;;IAO5B;;;;OAIG;IACG,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKnD;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAK9B;;;;;;;;OAQG;IACG,WAAW,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAuBjD;;OAEG;IACH,aAAa,IAAI,OAAO;IAIxB;;OAEG;IACH,aAAa,IAAI,MAAM,GAAG,IAAI;CAG/B"}
|
|
@@ -1,14 +1,56 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* CLEO permission rules
|
|
2
|
+
* CLEO permission rules for the OpenAI SDK adapter.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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.
|
|
8
10
|
*
|
|
9
|
-
*
|
|
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
|
+
/** Arguments passed to a CLEO input guardrail. */
|
|
19
|
+
export interface CleoInputGuardrailFunctionArgs {
|
|
20
|
+
/** The agent being invoked. Opaque to guardrails. */
|
|
21
|
+
agent: unknown;
|
|
22
|
+
/** Serialised input to scan — may be a string or arbitrary JSON value. */
|
|
23
|
+
input: unknown;
|
|
24
|
+
/** Per-run context (opaque). */
|
|
25
|
+
context: unknown;
|
|
26
|
+
}
|
|
27
|
+
/** Result of evaluating a CLEO input guardrail. */
|
|
28
|
+
export interface CleoGuardrailResult {
|
|
29
|
+
/** When true, the guardrail has tripped and the run MUST be rejected. */
|
|
30
|
+
tripwireTriggered: boolean;
|
|
31
|
+
/** Free-form diagnostic payload for logging and trace spans. */
|
|
32
|
+
outputInfo: unknown;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* CLEO-native replacement for `InputGuardrail` from `@openai/agents`.
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* The shape is identical to the legacy SDK contract so downstream consumers
|
|
39
|
+
* do not require changes. CLEO enforces these guardrails in-process before
|
|
40
|
+
* dispatching a prompt to the Vercel AI SDK.
|
|
41
|
+
*/
|
|
42
|
+
export interface CleoInputGuardrail {
|
|
43
|
+
/** Stable guardrail identifier for logs and trace metadata. */
|
|
44
|
+
name: string;
|
|
45
|
+
/** Execute the guardrail against the current run arguments. */
|
|
46
|
+
execute(args: CleoInputGuardrailFunctionArgs): Promise<CleoGuardrailResult>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @deprecated Use {@link CleoInputGuardrail}. Kept as a named alias for
|
|
50
|
+
* callers that previously imported the legacy `InputGuardrail` name from
|
|
51
|
+
* this module. Removed in a future major.
|
|
10
52
|
*/
|
|
11
|
-
|
|
53
|
+
export type InputGuardrail = CleoInputGuardrail;
|
|
12
54
|
/**
|
|
13
55
|
* Check whether a file-system path is covered by at least one glob pattern.
|
|
14
56
|
*
|
|
@@ -26,42 +68,53 @@ export declare function isPathAllowed(path: string, allowedGlobs: string[]): boo
|
|
|
26
68
|
*
|
|
27
69
|
* @param allowedGlobs - Glob patterns that tool path arguments must match.
|
|
28
70
|
* Pass an empty array to allow all paths (permissive mode).
|
|
29
|
-
* @returns
|
|
71
|
+
* @returns A {@link CleoInputGuardrail} ready to attach to an agent.
|
|
30
72
|
*
|
|
31
73
|
* @example
|
|
32
74
|
* ```typescript
|
|
33
75
|
* const guard = buildPathGuardrail(['/mnt/projects/**', '/tmp/**']);
|
|
34
|
-
* const agent =
|
|
76
|
+
* const agent = buildStandaloneAgent('...', 'gpt-4.1', [guard]);
|
|
35
77
|
* ```
|
|
36
78
|
*/
|
|
37
|
-
export declare function buildPathGuardrail(allowedGlobs: string[]):
|
|
79
|
+
export declare function buildPathGuardrail(allowedGlobs: string[]): CleoInputGuardrail;
|
|
38
80
|
/**
|
|
39
81
|
* Build an input guardrail that documents the tool allowlist for audit purposes.
|
|
40
82
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* span metadata.
|
|
83
|
+
* Tool-name enforcement is primarily structural — agents only receive the
|
|
84
|
+
* tools declared by CLEO orchestration. This guardrail provides an additional
|
|
85
|
+
* audit layer that records the active allowlist in the span metadata.
|
|
45
86
|
*
|
|
46
87
|
* @param allowedTools - Exact tool names permitted for this agent.
|
|
47
88
|
* Pass an empty array to allow all tools (permissive mode).
|
|
48
|
-
* @returns
|
|
89
|
+
* @returns A {@link CleoInputGuardrail} ready to attach to an agent.
|
|
49
90
|
*
|
|
50
91
|
* @example
|
|
51
92
|
* ```typescript
|
|
52
93
|
* const guard = buildToolAllowlistGuardrail(['read', 'write']);
|
|
53
94
|
* ```
|
|
54
95
|
*/
|
|
55
|
-
export declare function buildToolAllowlistGuardrail(allowedTools: string[]):
|
|
96
|
+
export declare function buildToolAllowlistGuardrail(allowedTools: string[]): CleoInputGuardrail;
|
|
56
97
|
/**
|
|
57
98
|
* Build the default CLEO guardrail set from spawn options.
|
|
58
99
|
*
|
|
59
100
|
* Combines path ACL and tool allowlist guards into a single array ready to
|
|
60
|
-
* pass as `inputGuardrails` on an
|
|
101
|
+
* pass as `inputGuardrails` on an agent topology build.
|
|
61
102
|
*
|
|
62
103
|
* @param allowedGlobs - File-path glob allowlist.
|
|
63
104
|
* @param allowedTools - Tool name allowlist.
|
|
64
105
|
* @returns Array of input guardrails to attach to the agent.
|
|
65
106
|
*/
|
|
66
|
-
export declare function buildDefaultGuardrails(allowedGlobs: string[], allowedTools: string[]):
|
|
107
|
+
export declare function buildDefaultGuardrails(allowedGlobs: string[], allowedTools: string[]): CleoInputGuardrail[];
|
|
108
|
+
/**
|
|
109
|
+
* Evaluate a set of CLEO input guardrails against an input payload.
|
|
110
|
+
*
|
|
111
|
+
* Runs every guardrail in sequence and returns the first tripwire result.
|
|
112
|
+
* When no guardrail trips, returns a passing result with diagnostic data
|
|
113
|
+
* aggregated from each guardrail's `outputInfo`.
|
|
114
|
+
*
|
|
115
|
+
* @param guardrails - Guardrails to evaluate.
|
|
116
|
+
* @param input - The input string to test (typically the enriched prompt).
|
|
117
|
+
* @returns Aggregated guardrail result.
|
|
118
|
+
*/
|
|
119
|
+
export declare function evaluateGuardrails(guardrails: CleoInputGuardrail[], input: string): Promise<CleoGuardrailResult>;
|
|
67
120
|
//# sourceMappingURL=guardrails.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guardrails.d.ts","sourceRoot":"","sources":["../../../src/providers/openai-sdk/guardrails.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"guardrails.d.ts","sourceRoot":"","sources":["../../../src/providers/openai-sdk/guardrails.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH,kDAAkD;AAClD,MAAM,WAAW,8BAA8B;IAC7C,qDAAqD;IACrD,KAAK,EAAE,OAAO,CAAC;IACf,0EAA0E;IAC1E,KAAK,EAAE,OAAO,CAAC;IACf,gCAAgC;IAChC,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,mDAAmD;AACnD,MAAM,WAAW,mBAAmB;IAClC,yEAAyE;IACzE,iBAAiB,EAAE,OAAO,CAAC;IAC3B,gEAAgE;IAChE,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,+DAA+D;IAC/D,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,OAAO,CAAC,IAAI,EAAE,8BAA8B,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CAC7E;AAED;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAwBhD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,OAAO,CAG3E;AAMD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,kBAAkB,CA2B7E;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,2BAA2B,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,kBAAkB,CAYtF;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,MAAM,EAAE,EACtB,YAAY,EAAE,MAAM,EAAE,GACrB,kBAAkB,EAAE,CAYtB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,kBAAkB,EAAE,EAChC,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,mBAAmB,CAAC,CAqB9B"}
|
|
@@ -1,29 +1,59 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* CLEO Team topology →
|
|
2
|
+
* CLEO Team topology → lead/worker agent descriptors.
|
|
3
3
|
*
|
|
4
|
-
* CLEO agents are organised in a Lead → Worker hierarchy.
|
|
5
|
-
*
|
|
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:
|
|
6
7
|
*
|
|
7
|
-
* - A Team Lead
|
|
8
|
+
* - A Team Lead is a {@link CleoAgent} whose `handoffs` array lists its workers.
|
|
8
9
|
* - Each Worker archetype (read-only, write, bash) is declared in
|
|
9
10
|
* `WORKER_ARCHETYPES` and built on demand.
|
|
10
11
|
* - The mapping is driven by `SpawnContext.options.handoffs`, which is an
|
|
11
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.
|
|
12
16
|
*
|
|
13
|
-
* @task T582
|
|
17
|
+
* @task T582 (original)
|
|
18
|
+
* @task T933 (SDK consolidation — CLEO-native topology)
|
|
14
19
|
*/
|
|
15
|
-
import type {
|
|
16
|
-
|
|
20
|
+
import type { CleoInputGuardrail } from './guardrails.js';
|
|
21
|
+
/**
|
|
22
|
+
* Agent descriptor used by the CLEO OpenAI adapter.
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* Intentionally mirrors the subset of `@openai/agents`'s `Agent` that CLEO
|
|
26
|
+
* actually consumed. The Vercel AI SDK delivers model inference via
|
|
27
|
+
* `generateText` / `streamText`; handoffs are orchestrated by the spawn
|
|
28
|
+
* provider using this descriptor as input.
|
|
29
|
+
*/
|
|
30
|
+
export interface CleoAgent {
|
|
31
|
+
/** Agent identifier surfaced in trace spans. */
|
|
32
|
+
name: string;
|
|
33
|
+
/** System-level instructions fed to the model. */
|
|
34
|
+
instructions: string;
|
|
35
|
+
/** Vercel AI SDK model identifier (e.g. `gpt-4.1`, `gpt-4.1-mini`). */
|
|
36
|
+
model: string;
|
|
37
|
+
/** Workers this agent may delegate to. Undefined when the agent is a leaf. */
|
|
38
|
+
handoffs?: CleoAgent[];
|
|
39
|
+
/** Input guardrails evaluated before the model call. */
|
|
40
|
+
inputGuardrails?: CleoInputGuardrail[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated Use {@link CleoAgent}. Legacy alias for callers that imported
|
|
44
|
+
* the `Agent` type from this module. Removed in a future major.
|
|
45
|
+
*/
|
|
46
|
+
export type Agent = CleoAgent;
|
|
17
47
|
/**
|
|
18
48
|
* Descriptor for a pre-configured worker agent archetype.
|
|
19
49
|
*
|
|
20
50
|
* Archetypes are declarative templates. `buildWorkerAgent` inflates them into
|
|
21
|
-
* live
|
|
51
|
+
* live {@link CleoAgent} instances.
|
|
22
52
|
*/
|
|
23
53
|
export interface WorkerArchetype {
|
|
24
|
-
/** Archetype identifier (also used as
|
|
54
|
+
/** Archetype identifier (also used as agent name). */
|
|
25
55
|
name: string;
|
|
26
|
-
/** Short description passed as the
|
|
56
|
+
/** Short description passed as the agent instructions. */
|
|
27
57
|
instructions: string;
|
|
28
58
|
/** Preferred model for this archetype. */
|
|
29
59
|
model: string;
|
|
@@ -36,23 +66,23 @@ export interface WorkerArchetype {
|
|
|
36
66
|
*/
|
|
37
67
|
export declare const WORKER_ARCHETYPES: Record<string, WorkerArchetype>;
|
|
38
68
|
/**
|
|
39
|
-
* Build a worker
|
|
69
|
+
* Build a worker {@link CleoAgent} from a named archetype.
|
|
40
70
|
*
|
|
41
71
|
* @param archetypeName - Key in {@link WORKER_ARCHETYPES}.
|
|
42
72
|
* @param guardrails - Input guardrails to attach to the worker agent.
|
|
43
|
-
* @returns A configured
|
|
73
|
+
* @returns A configured agent descriptor or `null` when the archetype is unknown.
|
|
44
74
|
*/
|
|
45
|
-
export declare function buildWorkerAgent(archetypeName: string, guardrails:
|
|
75
|
+
export declare function buildWorkerAgent(archetypeName: string, guardrails: CleoInputGuardrail[]): CleoAgent | null;
|
|
46
76
|
/**
|
|
47
|
-
* Build a team lead
|
|
77
|
+
* Build a team lead {@link CleoAgent} whose `handoffs` reference the given workers.
|
|
48
78
|
*
|
|
49
79
|
* @param leadInstructions - System instructions for the lead agent.
|
|
50
80
|
* @param leadModel - Model to use for the lead agent.
|
|
51
81
|
* @param workers - Worker agents this lead can hand off to.
|
|
52
82
|
* @param guardrails - Input guardrails to attach to the lead agent.
|
|
53
|
-
* @returns A configured lead
|
|
83
|
+
* @returns A configured lead agent descriptor.
|
|
54
84
|
*/
|
|
55
|
-
export declare function buildLeadAgent(leadInstructions: string, leadModel: string, workers:
|
|
85
|
+
export declare function buildLeadAgent(leadInstructions: string, leadModel: string, workers: CleoAgent[], guardrails: CleoInputGuardrail[]): CleoAgent;
|
|
56
86
|
/**
|
|
57
87
|
* Build a simple single-tier agent (no handoffs) from prompt and model.
|
|
58
88
|
*
|
|
@@ -62,9 +92,9 @@ export declare function buildLeadAgent(leadInstructions: string, leadModel: stri
|
|
|
62
92
|
* @param instructions - Agent system instructions.
|
|
63
93
|
* @param model - Model identifier.
|
|
64
94
|
* @param guardrails - Input guardrails.
|
|
65
|
-
* @returns A configured
|
|
95
|
+
* @returns A configured agent descriptor.
|
|
66
96
|
*/
|
|
67
|
-
export declare function buildStandaloneAgent(instructions: string, model: string, guardrails:
|
|
97
|
+
export declare function buildStandaloneAgent(instructions: string, model: string, guardrails: CleoInputGuardrail[]): CleoAgent;
|
|
68
98
|
/** Options for building the agent topology from a spawn context. */
|
|
69
99
|
export interface TopologyOptions {
|
|
70
100
|
/** Prompt / instructions for the entry-point agent. */
|
|
@@ -76,7 +106,7 @@ export interface TopologyOptions {
|
|
|
76
106
|
/** Names of worker archetypes to create and attach as handoffs. */
|
|
77
107
|
handoffNames: string[];
|
|
78
108
|
/** Input guardrails shared across all agents in the topology. */
|
|
79
|
-
guardrails:
|
|
109
|
+
guardrails: CleoInputGuardrail[];
|
|
80
110
|
}
|
|
81
111
|
/**
|
|
82
112
|
* Build the entry-point agent and its worker topology from spawn options.
|
|
@@ -88,7 +118,7 @@ export interface TopologyOptions {
|
|
|
88
118
|
* Unknown archetype names in `handoffNames` are silently skipped.
|
|
89
119
|
*
|
|
90
120
|
* @param options - Topology build options.
|
|
91
|
-
* @returns The entry-point agent
|
|
121
|
+
* @returns The entry-point agent descriptor.
|
|
92
122
|
*/
|
|
93
|
-
export declare function buildAgentTopology(options: TopologyOptions):
|
|
123
|
+
export declare function buildAgentTopology(options: TopologyOptions): CleoAgent;
|
|
94
124
|
//# sourceMappingURL=handoff.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handoff.d.ts","sourceRoot":"","sources":["../../../src/providers/openai-sdk/handoff.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"handoff.d.ts","sourceRoot":"","sources":["../../../src/providers/openai-sdk/handoff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAM1D;;;;;;;;GAQG;AACH,MAAM,WAAW,SAAS;IACxB,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,YAAY,EAAE,MAAM,CAAC;IACrB,uEAAuE;IACvE,KAAK,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC;IACvB,wDAAwD;IACxD,eAAe,CAAC,EAAE,kBAAkB,EAAE,CAAC;CACxC;AAED;;;GAGG;AACH,MAAM,MAAM,KAAK,GAAG,SAAS,CAAC;AAM9B;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,0DAA0D;IAC1D,YAAY,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAmB7D,CAAC;AAMF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,kBAAkB,EAAE,GAC/B,SAAS,GAAG,IAAI,CAUlB;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,gBAAgB,EAAE,MAAM,EACxB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,SAAS,EAAE,EACpB,UAAU,EAAE,kBAAkB,EAAE,GAC/B,SAAS,CAQX;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,kBAAkB,EAAE,GAC/B,SAAS,CAOX;AAMD,oEAAoE;AACpE,MAAM,WAAW,eAAe;IAC9B,uDAAuD;IACvD,YAAY,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,cAAc,CAAC;IACzC,mEAAmE;IACnE,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,iEAAiE;IACjE,UAAU,EAAE,kBAAkB,EAAE,CAAC;CAClC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,eAAe,GAAG,SAAS,CAkBtE"}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @packageDocumentation
|
|
3
3
|
*
|
|
4
|
-
* CLEO provider adapter for the OpenAI
|
|
4
|
+
* CLEO provider adapter for the OpenAI provider, backed by the Vercel AI SDK.
|
|
5
5
|
* Default export is the adapter class for dynamic loading by AdapterManager.
|
|
6
6
|
*
|
|
7
|
-
* @task T582
|
|
7
|
+
* @task T582 (original)
|
|
8
|
+
* @task T933 (SDK consolidation — Vercel AI SDK migration)
|
|
8
9
|
*/
|
|
9
10
|
import { OpenAiSdkAdapter } from './adapter.js';
|
|
10
11
|
export { OpenAiSdkAdapter } from './adapter.js';
|
|
11
|
-
export {
|
|
12
|
-
export
|
|
12
|
+
export type { CleoGuardrailResult, CleoInputGuardrail, CleoInputGuardrailFunctionArgs, InputGuardrail, } from './guardrails.js';
|
|
13
|
+
export { buildDefaultGuardrails, buildPathGuardrail, buildToolAllowlistGuardrail, evaluateGuardrails, isPathAllowed, } from './guardrails.js';
|
|
14
|
+
export type { Agent, CleoAgent, TopologyOptions, WorkerArchetype } from './handoff.js';
|
|
13
15
|
export { buildAgentTopology, buildLeadAgent, buildStandaloneAgent, buildWorkerAgent, WORKER_ARCHETYPES, } from './handoff.js';
|
|
14
16
|
export { OpenAiSdkInstallProvider } from './install.js';
|
|
15
17
|
export type { OpenAiSdkSpawnOptions } from './spawn.js';
|
|
16
|
-
export { OpenAiSdkSpawnProvider } from './spawn.js';
|
|
18
|
+
export { OpenAiSdkSpawnProvider, registerTraceProcessor, setTracingDisabled, unregisterTraceProcessor, } from './spawn.js';
|
|
19
|
+
export type { CleoAgentSpanData, CleoFunctionSpanData, CleoGenericSpanData, CleoHandoffSpanData, CleoSpan, CleoSpanData, CleoSpanKind, CleoTrace, CleoTraceProcessor, } from './tracing.js';
|
|
17
20
|
export { CleoConduitTraceProcessor } from './tracing.js';
|
|
18
21
|
export default OpenAiSdkAdapter;
|
|
19
22
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/openai-sdk/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","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;AAChD,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,8BAA8B,EAC9B,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,2BAA2B,EAC3B,kBAAkB,EAClB,aAAa,GACd,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACvF,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,YAAY,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAEzD,eAAe,gBAAgB,CAAC;AAEhC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,IAAI,gBAAgB,CAEhD"}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import type { AdapterInstallProvider, InstallOptions, InstallResult } from '@cleocode/contracts';
|
|
11
11
|
/**
|
|
12
|
-
* Install provider for the OpenAI
|
|
12
|
+
* Install provider for the OpenAI SDK adapter (Vercel AI SDK).
|
|
13
13
|
*
|
|
14
14
|
* Manages CLEO's integration with OpenAI SDK projects by:
|
|
15
15
|
* 1. Ensuring AGENTS.md contains @-references to CLEO instruction files
|