@contentful/experience-design-system-generation 2.35.1-dev-build-236b6909.0 → 2.35.1-dev-build-b8da2525.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json +1 -1
- package/dist/src/agent-names.js +13 -7
- package/dist/src/controller/create-generation-endpoint.d.ts +2 -2
- package/dist/src/controller/create-generation-endpoint.js +6 -4
- package/dist/src/controller/helpers/validate-generation-request.d.ts +1 -1
- package/dist/src/controller/helpers/validate-generation-request.js +11 -9
- package/dist/src/index.d.ts +21 -21
- package/dist/src/index.js +14 -14
- package/dist/src/orchestrator/execute-generation-orchestrator.d.ts +2 -2
- package/dist/src/orchestrator/execute-generation-orchestrator.js +1 -1
- package/dist/src/services/agent/helpers/build-agent-args.d.ts +1 -1
- package/dist/src/services/agent/helpers/build-agent-args.js +45 -26
- package/dist/src/services/agent/helpers/check-agent-auth.d.ts +2 -2
- package/dist/src/services/agent/helpers/check-agent-auth.js +10 -10
- package/dist/src/services/agent/helpers/check-claude-auth.d.ts +1 -1
- package/dist/src/services/agent/helpers/check-claude-auth.js +11 -11
- package/dist/src/services/agent/helpers/describe-agent-failure.d.ts +1 -1
- package/dist/src/services/agent/helpers/describe-agent-failure.js +6 -2
- package/dist/src/services/agent/helpers/extract-sentinel-output.d.ts +1 -1
- package/dist/src/services/agent/helpers/extract-sentinel-output.js +4 -4
- package/dist/src/services/agent/helpers/resolve-agent-binary.d.ts +1 -1
- package/dist/src/services/agent/helpers/resolve-agent-binary.js +1 -1
- package/dist/src/services/agent/local-cli-agent-invoker.d.ts +1 -1
- package/dist/src/services/agent/local-cli-agent-invoker.js +2 -2
- package/dist/src/services/agent/run-agent.d.ts +4 -4
- package/dist/src/services/agent/run-agent.js +23 -18
- package/dist/src/services/parsing/helpers/parse-selection-slot-evidence.d.ts +2 -0
- package/dist/src/services/parsing/helpers/parse-selection-slot-evidence.js +66 -0
- package/dist/src/services/parsing/helpers/read-tool-call-objects.js +6 -6
- package/dist/src/services/parsing/parse-map-token-tool-calls.d.ts +1 -1
- package/dist/src/services/parsing/parse-map-token-tool-calls.js +14 -9
- package/dist/src/services/parsing/parse-prop-tool-calls.d.ts +1 -1
- package/dist/src/services/parsing/parse-prop-tool-calls.js +55 -35
- package/dist/src/services/parsing/parse-select-tool-calls.d.ts +1 -1
- package/dist/src/services/parsing/parse-select-tool-calls.js +21 -7
- package/dist/src/services/parsing/parse-token-tool-calls.d.ts +1 -1
- package/dist/src/services/parsing/parse-token-tool-calls.js +19 -14
- package/dist/src/services/prompts/build-prompt.d.ts +2 -2
- package/dist/src/services/prompts/build-prompt.js +5 -4
- package/dist/src/services/prompts/helpers/build-preamble.d.ts +1 -1
- package/dist/src/services/prompts/helpers/build-preamble.js +19 -11
- package/dist/src/services/prompts/helpers/format-source-refs.d.ts +1 -1
- package/dist/src/services/prompts/helpers/format-source-refs.js +8 -8
- package/dist/src/services/prompts/helpers/format-token-candidates.d.ts +1 -1
- package/dist/src/services/prompts/helpers/format-token-candidates.js +27 -27
- package/dist/src/services/prompts/helpers/resolve-skill-file.d.ts +2 -2
- package/dist/src/services/prompts/helpers/resolve-skill-file.js +12 -12
- package/dist/src/types/agent.d.ts +2 -2
- package/dist/src/types/contract.d.ts +3 -3
- package/dist/src/types/invoker.d.ts +2 -2
- package/dist/src/types/prompt.d.ts +4 -3
- package/dist/src/types/tool-calls.d.ts +23 -10
- package/package.json +2 -2
- package/skills/select-components.md +43 -8
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/experience-design-system-generation",
|
|
3
|
-
"version": "2.35.1-dev-build-
|
|
3
|
+
"version": "2.35.1-dev-build-b8da2525.0",
|
|
4
4
|
"description": "Agent-invocation and skill-prompt engine for the Contentful Experience Design System SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/dist/src/agent-names.js
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
export const AGENT_NAMES = [
|
|
2
|
-
|
|
1
|
+
export const AGENT_NAMES = [
|
|
2
|
+
"claude",
|
|
3
|
+
"codex",
|
|
4
|
+
"opencode",
|
|
5
|
+
"cursor",
|
|
6
|
+
"copilot",
|
|
7
|
+
];
|
|
8
|
+
export const DEFAULT_AGENT_NAME = "claude";
|
|
3
9
|
export const AGENT_BINARIES = {
|
|
4
|
-
claude:
|
|
5
|
-
codex:
|
|
6
|
-
opencode:
|
|
7
|
-
cursor:
|
|
8
|
-
copilot:
|
|
10
|
+
claude: "claude",
|
|
11
|
+
codex: "codex",
|
|
12
|
+
opencode: "opencode",
|
|
13
|
+
cursor: "cursor-agent",
|
|
14
|
+
copilot: "copilot",
|
|
9
15
|
};
|
|
10
16
|
export function isAgentName(value) {
|
|
11
17
|
return AGENT_NAMES.includes(value);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { GenerationEndpoint, GenerationEndpointOptions, GenerationEndpointRequest, GenerationEndpointResponse } from
|
|
2
|
-
export type { GenerationEndpoint, GenerationEndpointOptions, GenerationEndpointRequest, GenerationEndpointResponse };
|
|
1
|
+
import type { GenerationEndpoint, GenerationEndpointOptions, GenerationEndpointRequest, GenerationEndpointResponse } from "../types/contract.js";
|
|
2
|
+
export type { GenerationEndpoint, GenerationEndpointOptions, GenerationEndpointRequest, GenerationEndpointResponse, };
|
|
3
3
|
export declare function createGenerationEndpoint(options?: GenerationEndpointOptions): GenerationEndpoint;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { validateGenerationRequest } from
|
|
2
|
-
import { executeGenerationOrchestrator } from
|
|
3
|
-
import { createLocalCliAgentInvoker } from
|
|
1
|
+
import { validateGenerationRequest } from "./helpers/validate-generation-request.js";
|
|
2
|
+
import { executeGenerationOrchestrator } from "../orchestrator/execute-generation-orchestrator.js";
|
|
3
|
+
import { createLocalCliAgentInvoker } from "../services/agent/local-cli-agent-invoker.js";
|
|
4
4
|
export function createGenerationEndpoint(options = {}) {
|
|
5
|
-
const invoker = createLocalCliAgentInvoker({
|
|
5
|
+
const invoker = createLocalCliAgentInvoker({
|
|
6
|
+
onDebugEvent: options.onDebugEvent,
|
|
7
|
+
});
|
|
6
8
|
return {
|
|
7
9
|
async run(request) {
|
|
8
10
|
validateGenerationRequest(request);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { GenerationEndpointRequest } from
|
|
1
|
+
import type { GenerationEndpointRequest } from "../../types/contract.js";
|
|
2
2
|
export declare function validateGenerationRequest(request: GenerationEndpointRequest): void;
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { isAgentName } from
|
|
1
|
+
import { isAgentName } from "../../agent-names.js";
|
|
2
2
|
export function validateGenerationRequest(request) {
|
|
3
|
-
if (request === null || typeof request !==
|
|
4
|
-
throw new TypeError(
|
|
3
|
+
if (request === null || typeof request !== "object") {
|
|
4
|
+
throw new TypeError("createGenerationEndpoint requires a request object");
|
|
5
5
|
}
|
|
6
6
|
if (!isAgentName(request.agent)) {
|
|
7
7
|
throw new TypeError(`createGenerationEndpoint requires agent to be a valid agent name, got: ${String(request.agent)}`);
|
|
8
8
|
}
|
|
9
|
-
if (typeof request.timeoutMs !==
|
|
10
|
-
throw new TypeError(
|
|
9
|
+
if (typeof request.timeoutMs !== "number" || request.timeoutMs <= 0) {
|
|
10
|
+
throw new TypeError("createGenerationEndpoint requires timeoutMs to be a positive number");
|
|
11
11
|
}
|
|
12
|
-
if (request.promptOptions === null ||
|
|
13
|
-
|
|
12
|
+
if (request.promptOptions === null ||
|
|
13
|
+
typeof request.promptOptions !== "object") {
|
|
14
|
+
throw new TypeError("createGenerationEndpoint requires promptOptions to be an object");
|
|
14
15
|
}
|
|
15
|
-
if (request.onOutput !== undefined &&
|
|
16
|
-
|
|
16
|
+
if (request.onOutput !== undefined &&
|
|
17
|
+
typeof request.onOutput !== "function") {
|
|
18
|
+
throw new TypeError("createGenerationEndpoint requires onOutput to be a function when provided");
|
|
17
19
|
}
|
|
18
20
|
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
export { AGENT_NAMES, AGENT_BINARIES, DEFAULT_AGENT_NAME, isAgentName } from
|
|
2
|
-
export type { AgentName } from
|
|
3
|
-
export type { AgentAuthStatus, AgentDebugEvent, AgentRunResult } from
|
|
4
|
-
export type { ClassifyComponentCall, ClassifyPropCall, ClassifySlotCall, ExcludePropCall, MapTokenPropCall, ParsedMapTokenPropToolCalls, ParsedSelectToolCalls, ParsedTokenToolCalls, ParsedToolCalls, RejectComponentCall, SelectComponentCall, SelectToolCall, SetGroupCall, SetTokenCall, ToolCall, TokenToolCall, } from
|
|
5
|
-
export type { ComponentSourceRef, GeneratedCdf, Mode, PromptOptions, Skill } from
|
|
6
|
-
export { createGenerationEndpoint } from
|
|
7
|
-
export type { GenerationEndpoint, GenerationEndpointOptions, GenerationEndpointRequest, GenerationEndpointResponse, } from
|
|
8
|
-
export { executeGenerationOrchestrator } from
|
|
9
|
-
export type { GenerationOrchestratorRequest } from
|
|
10
|
-
export { agentSupportsBedrock, buildAgentArgs as buildArgs, resolveAgentModel, } from
|
|
11
|
-
export { resolveAgentBinary as resolveBinary } from
|
|
12
|
-
export { checkAgentAuth } from
|
|
13
|
-
export { runAgent, describeAgentFailure, extractSentinelOutput } from
|
|
14
|
-
export { parsePropToolCallLines as parseToolCallLines } from
|
|
15
|
-
export { parseSelectToolCallLines } from
|
|
16
|
-
export { parseTokenToolCallLines } from
|
|
17
|
-
export { parseMapTokenPropToolCallLines } from
|
|
18
|
-
export { buildPrompt, formatCustomPromptBanner, resolveSkillPath } from
|
|
19
|
-
export { formatGenerateProgressLine } from
|
|
20
|
-
export { createLocalCliAgentInvoker } from
|
|
21
|
-
export type { AgentInvoker, InvokeAgentOptions, LocalCliAgentInvokerOptions as CreateLocalCliAgentInvokerOptions, } from
|
|
1
|
+
export { AGENT_NAMES, AGENT_BINARIES, DEFAULT_AGENT_NAME, isAgentName, } from "./agent-names.js";
|
|
2
|
+
export type { AgentName } from "./agent-names.js";
|
|
3
|
+
export type { AgentAuthStatus, AgentDebugEvent, AgentRunResult, } from "./types/agent.js";
|
|
4
|
+
export type { ClassifyComponentCall, ClassifyPropCall, ClassifySlotCall, ExcludePropCall, MapTokenPropCall, ParsedMapTokenPropToolCalls, ParsedSelectToolCalls, ParsedTokenToolCalls, ParsedToolCalls, RejectComponentCall, SelectComponentCall, SelectToolCall, SelectionSlotEvidence, SelectionSlotEvidenceCitation, SetGroupCall, SetTokenCall, ToolCall, TokenToolCall, } from "./types/tool-calls.js";
|
|
5
|
+
export type { ComponentSourceRef, GeneratedCdf, Mode, PromptOptions, Skill, } from "./types/prompt.js";
|
|
6
|
+
export { createGenerationEndpoint } from "./controller/create-generation-endpoint.js";
|
|
7
|
+
export type { GenerationEndpoint, GenerationEndpointOptions, GenerationEndpointRequest, GenerationEndpointResponse, } from "./controller/create-generation-endpoint.js";
|
|
8
|
+
export { executeGenerationOrchestrator } from "./orchestrator/execute-generation-orchestrator.js";
|
|
9
|
+
export type { GenerationOrchestratorRequest } from "./orchestrator/execute-generation-orchestrator.js";
|
|
10
|
+
export { agentSupportsBedrock, buildAgentArgs as buildArgs, resolveAgentModel, } from "./services/agent/helpers/build-agent-args.js";
|
|
11
|
+
export { resolveAgentBinary as resolveBinary } from "./services/agent/helpers/resolve-agent-binary.js";
|
|
12
|
+
export { checkAgentAuth } from "./services/agent/helpers/check-agent-auth.js";
|
|
13
|
+
export { runAgent, describeAgentFailure, extractSentinelOutput, } from "./services/agent/run-agent.js";
|
|
14
|
+
export { parsePropToolCallLines as parseToolCallLines } from "./services/parsing/parse-prop-tool-calls.js";
|
|
15
|
+
export { parseSelectToolCallLines } from "./services/parsing/parse-select-tool-calls.js";
|
|
16
|
+
export { parseTokenToolCallLines } from "./services/parsing/parse-token-tool-calls.js";
|
|
17
|
+
export { parseMapTokenPropToolCallLines } from "./services/parsing/parse-map-token-tool-calls.js";
|
|
18
|
+
export { buildPrompt, formatCustomPromptBanner, resolveSkillPath, } from "./services/prompts/build-prompt.js";
|
|
19
|
+
export { formatGenerateProgressLine } from "./progress.js";
|
|
20
|
+
export { createLocalCliAgentInvoker } from "./services/agent/local-cli-agent-invoker.js";
|
|
21
|
+
export type { AgentInvoker, InvokeAgentOptions, LocalCliAgentInvokerOptions as CreateLocalCliAgentInvokerOptions, } from "./types/invoker.js";
|
package/dist/src/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
// Agent identity
|
|
2
|
-
export { AGENT_NAMES, AGENT_BINARIES, DEFAULT_AGENT_NAME, isAgentName } from
|
|
2
|
+
export { AGENT_NAMES, AGENT_BINARIES, DEFAULT_AGENT_NAME, isAgentName, } from "./agent-names.js";
|
|
3
3
|
// Generation endpoint (primary entry point)
|
|
4
|
-
export { createGenerationEndpoint } from
|
|
4
|
+
export { createGenerationEndpoint } from "./controller/create-generation-endpoint.js";
|
|
5
5
|
// Orchestrator (lower-level — for callers that supply their own invoker)
|
|
6
|
-
export { executeGenerationOrchestrator } from
|
|
6
|
+
export { executeGenerationOrchestrator } from "./orchestrator/execute-generation-orchestrator.js";
|
|
7
7
|
// Agent execution (low-level)
|
|
8
|
-
export { agentSupportsBedrock, buildAgentArgs as buildArgs, resolveAgentModel, } from
|
|
9
|
-
export { resolveAgentBinary as resolveBinary } from
|
|
10
|
-
export { checkAgentAuth } from
|
|
11
|
-
export { runAgent, describeAgentFailure, extractSentinelOutput } from
|
|
8
|
+
export { agentSupportsBedrock, buildAgentArgs as buildArgs, resolveAgentModel, } from "./services/agent/helpers/build-agent-args.js";
|
|
9
|
+
export { resolveAgentBinary as resolveBinary } from "./services/agent/helpers/resolve-agent-binary.js";
|
|
10
|
+
export { checkAgentAuth } from "./services/agent/helpers/check-agent-auth.js";
|
|
11
|
+
export { runAgent, describeAgentFailure, extractSentinelOutput, } from "./services/agent/run-agent.js";
|
|
12
12
|
// Tool call parsing
|
|
13
|
-
export { parsePropToolCallLines as parseToolCallLines } from
|
|
14
|
-
export { parseSelectToolCallLines } from
|
|
15
|
-
export { parseTokenToolCallLines } from
|
|
16
|
-
export { parseMapTokenPropToolCallLines } from
|
|
13
|
+
export { parsePropToolCallLines as parseToolCallLines } from "./services/parsing/parse-prop-tool-calls.js";
|
|
14
|
+
export { parseSelectToolCallLines } from "./services/parsing/parse-select-tool-calls.js";
|
|
15
|
+
export { parseTokenToolCallLines } from "./services/parsing/parse-token-tool-calls.js";
|
|
16
|
+
export { parseMapTokenPropToolCallLines } from "./services/parsing/parse-map-token-tool-calls.js";
|
|
17
17
|
// Prompt building
|
|
18
|
-
export { buildPrompt, formatCustomPromptBanner, resolveSkillPath } from
|
|
18
|
+
export { buildPrompt, formatCustomPromptBanner, resolveSkillPath, } from "./services/prompts/build-prompt.js";
|
|
19
19
|
// Progress reporting
|
|
20
|
-
export { formatGenerateProgressLine } from
|
|
20
|
+
export { formatGenerateProgressLine } from "./progress.js";
|
|
21
21
|
// Backward-compat exports — CLI callers still use these; migrate to createGenerationEndpoint
|
|
22
|
-
export { createLocalCliAgentInvoker } from
|
|
22
|
+
export { createLocalCliAgentInvoker } from "./services/agent/local-cli-agent-invoker.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { GenerationEndpointRequest, GenerationEndpointResponse } from
|
|
2
|
-
import type { AgentInvoker } from
|
|
1
|
+
import type { GenerationEndpointRequest, GenerationEndpointResponse } from "../types/contract.js";
|
|
2
|
+
import type { AgentInvoker } from "../services/agent/local-cli-agent-invoker.js";
|
|
3
3
|
export interface GenerationOrchestratorRequest extends GenerationEndpointRequest {
|
|
4
4
|
readonly invoker: AgentInvoker;
|
|
5
5
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { buildPrompt } from
|
|
1
|
+
import { buildPrompt } from "../services/prompts/build-prompt.js";
|
|
2
2
|
export async function executeGenerationOrchestrator(request) {
|
|
3
3
|
const prompt = await buildPrompt(request.promptOptions);
|
|
4
4
|
return request.invoker.invoke({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentName } from
|
|
1
|
+
import type { AgentName } from "../../../agent-names.js";
|
|
2
2
|
/** Per-agent env vars that switch model calls to AWS Bedrock. */
|
|
3
3
|
export declare const BEDROCK_ENV_BY_AGENT: Partial<Record<AgentName, Record<string, string>>>;
|
|
4
4
|
export declare function agentSupportsBedrock(agent: AgentName): boolean;
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
/** Per-agent env vars that switch model calls to AWS Bedrock. */
|
|
2
2
|
export const BEDROCK_ENV_BY_AGENT = {
|
|
3
|
-
claude: { CLAUDE_CODE_USE_BEDROCK:
|
|
3
|
+
claude: { CLAUDE_CODE_USE_BEDROCK: "1" },
|
|
4
4
|
};
|
|
5
|
-
const BEDROCK_CAPABLE_AGENTS = new Set([
|
|
5
|
+
const BEDROCK_CAPABLE_AGENTS = new Set([
|
|
6
|
+
"claude",
|
|
7
|
+
"codex",
|
|
8
|
+
"opencode",
|
|
9
|
+
]);
|
|
6
10
|
export function agentSupportsBedrock(agent) {
|
|
7
11
|
return BEDROCK_CAPABLE_AGENTS.has(agent);
|
|
8
12
|
}
|
|
9
|
-
const DEFAULT_CODEX_BEDROCK_REGION =
|
|
10
|
-
const DEFAULT_OPENCODE_MODEL =
|
|
11
|
-
const DEFAULT_CODEX_BEDROCK_MODEL =
|
|
13
|
+
const DEFAULT_CODEX_BEDROCK_REGION = "us-east-1";
|
|
14
|
+
const DEFAULT_OPENCODE_MODEL = "claude-haiku-4-5";
|
|
15
|
+
const DEFAULT_CODEX_BEDROCK_MODEL = "openai.gpt-5.6-luna";
|
|
12
16
|
const DEFAULT_MODELS = {
|
|
13
|
-
claude:
|
|
17
|
+
claude: "haiku",
|
|
14
18
|
opencode: DEFAULT_OPENCODE_MODEL,
|
|
15
|
-
cursor:
|
|
16
|
-
copilot:
|
|
19
|
+
cursor: "gpt-mini",
|
|
20
|
+
copilot: "Auto",
|
|
17
21
|
};
|
|
18
22
|
function withBedrockProviderPrefix(model) {
|
|
19
|
-
return model.includes(
|
|
23
|
+
return model.includes("/") ? model : `amazon-bedrock/${model}`;
|
|
20
24
|
}
|
|
21
25
|
export function resolveAgentModel(agent, explicit, bedrock = false) {
|
|
22
26
|
if (explicit && explicit.trim())
|
|
@@ -24,35 +28,50 @@ export function resolveAgentModel(agent, explicit, bedrock = false) {
|
|
|
24
28
|
const override = process.env[`EDS_AGENT_MODEL_${agent.toUpperCase()}`];
|
|
25
29
|
if (override && override.trim())
|
|
26
30
|
return override.trim();
|
|
27
|
-
if (bedrock && agent ===
|
|
31
|
+
if (bedrock && agent === "codex")
|
|
28
32
|
return DEFAULT_CODEX_BEDROCK_MODEL;
|
|
29
|
-
if (bedrock && agent ===
|
|
33
|
+
if (bedrock && agent === "opencode")
|
|
30
34
|
return withBedrockProviderPrefix(DEFAULT_OPENCODE_MODEL);
|
|
31
35
|
return DEFAULT_MODELS[agent];
|
|
32
36
|
}
|
|
33
37
|
function codexBedrockConfigArgs() {
|
|
34
|
-
const region = process.env.AWS_REGION?.trim() ||
|
|
35
|
-
|
|
38
|
+
const region = process.env.AWS_REGION?.trim() ||
|
|
39
|
+
process.env.AWS_DEFAULT_REGION?.trim() ||
|
|
40
|
+
DEFAULT_CODEX_BEDROCK_REGION;
|
|
41
|
+
return [
|
|
42
|
+
"-c",
|
|
43
|
+
"model_provider=amazon-bedrock",
|
|
44
|
+
"-c",
|
|
45
|
+
`model_providers.amazon-bedrock.region=${region}`,
|
|
46
|
+
];
|
|
36
47
|
}
|
|
37
48
|
export function buildAgentArgs(agent, prompt, model, promptViaStdin = false, bedrock = false) {
|
|
38
49
|
const resolvedModel = resolveAgentModel(agent, model, bedrock);
|
|
39
|
-
const modelArg = resolvedModel ? [
|
|
50
|
+
const modelArg = resolvedModel ? ["--model", resolvedModel] : [];
|
|
40
51
|
const promptArg = promptViaStdin ? [] : [prompt];
|
|
41
52
|
switch (agent) {
|
|
42
|
-
case
|
|
43
|
-
return [
|
|
44
|
-
case
|
|
53
|
+
case "claude":
|
|
54
|
+
return ["--print", ...modelArg, ...promptArg];
|
|
55
|
+
case "codex": {
|
|
45
56
|
const bedrockArgs = bedrock ? codexBedrockConfigArgs() : [];
|
|
46
|
-
return [
|
|
57
|
+
return [
|
|
58
|
+
"exec",
|
|
59
|
+
...bedrockArgs,
|
|
60
|
+
...modelArg,
|
|
61
|
+
"--dangerously-bypass-approvals-and-sandbox",
|
|
62
|
+
...promptArg,
|
|
63
|
+
];
|
|
47
64
|
}
|
|
48
|
-
case
|
|
49
|
-
return [
|
|
50
|
-
case
|
|
51
|
-
return [
|
|
52
|
-
case
|
|
53
|
-
const copilotModel = resolveAgentModel(
|
|
54
|
-
const copilotModelArg = !copilotModel || copilotModel ===
|
|
55
|
-
|
|
65
|
+
case "opencode":
|
|
66
|
+
return ["run", ...modelArg, ...promptArg];
|
|
67
|
+
case "cursor":
|
|
68
|
+
return ["--print", ...modelArg, ...promptArg];
|
|
69
|
+
case "copilot": {
|
|
70
|
+
const copilotModel = resolveAgentModel("copilot", model);
|
|
71
|
+
const copilotModelArg = !copilotModel || copilotModel === "Auto"
|
|
72
|
+
? []
|
|
73
|
+
: ["--model", copilotModel];
|
|
74
|
+
return ["-p", ...promptArg, ...copilotModelArg, "--allow-all-tools"];
|
|
56
75
|
}
|
|
57
76
|
}
|
|
58
77
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { AgentName } from
|
|
2
|
-
import type { AgentAuthStatus } from
|
|
1
|
+
import type { AgentName } from "../../../agent-names.js";
|
|
2
|
+
import type { AgentAuthStatus } from "../../../types/agent.js";
|
|
3
3
|
export declare function checkAgentAuth(agent: AgentName): Promise<AgentAuthStatus>;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { spawn } from
|
|
2
|
-
import { resolveAgentBinary } from
|
|
3
|
-
import { checkClaudeAuth } from
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { resolveAgentBinary } from "./resolve-agent-binary.js";
|
|
3
|
+
import { checkClaudeAuth } from "./check-claude-auth.js";
|
|
4
4
|
export async function checkAgentAuth(agent) {
|
|
5
5
|
const binary = resolveAgentBinary(agent);
|
|
6
6
|
const binaryExists = await new Promise((resolve) => {
|
|
7
|
-
if (binary.startsWith(
|
|
8
|
-
import(
|
|
7
|
+
if (binary.startsWith("/")) {
|
|
8
|
+
import("node:fs/promises").then((fs) => fs.access(binary).then(() => resolve(true), () => resolve(false)));
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
|
-
const child = spawn(process.platform ===
|
|
12
|
-
child.on(
|
|
11
|
+
const child = spawn(process.platform === "win32" ? "where" : "which", [binary], { stdio: "ignore" });
|
|
12
|
+
child.on("close", (code) => resolve(code === 0));
|
|
13
13
|
});
|
|
14
14
|
if (!binaryExists)
|
|
15
|
-
return
|
|
16
|
-
if (agent !==
|
|
17
|
-
return
|
|
15
|
+
return "not-found";
|
|
16
|
+
if (agent !== "claude")
|
|
17
|
+
return "ok";
|
|
18
18
|
return checkClaudeAuth(binary);
|
|
19
19
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { AgentAuthStatus } from
|
|
1
|
+
import type { AgentAuthStatus } from "../../../types/agent.js";
|
|
2
2
|
export declare function checkClaudeAuth(binary: string): Promise<AgentAuthStatus>;
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { spawn } from
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
2
|
export function checkClaudeAuth(binary) {
|
|
3
3
|
return new Promise((resolve) => {
|
|
4
|
-
const child = spawn(binary, [
|
|
5
|
-
stdio: [
|
|
4
|
+
const child = spawn(binary, ["auth", "status", "--json"], {
|
|
5
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
6
6
|
});
|
|
7
|
-
let stdout =
|
|
7
|
+
let stdout = "";
|
|
8
8
|
let done = false;
|
|
9
9
|
const timer = setTimeout(() => {
|
|
10
10
|
if (!done) {
|
|
11
11
|
done = true;
|
|
12
|
-
child.kill(
|
|
13
|
-
resolve(
|
|
12
|
+
child.kill("SIGTERM");
|
|
13
|
+
resolve("unauthenticated");
|
|
14
14
|
}
|
|
15
15
|
}, 5000);
|
|
16
|
-
child.stdout?.on(
|
|
16
|
+
child.stdout?.on("data", (chunk) => {
|
|
17
17
|
stdout += chunk.toString();
|
|
18
18
|
});
|
|
19
|
-
child.on(
|
|
19
|
+
child.on("close", (code) => {
|
|
20
20
|
if (done)
|
|
21
21
|
return;
|
|
22
22
|
done = true;
|
|
23
23
|
clearTimeout(timer);
|
|
24
24
|
if (code !== 0) {
|
|
25
|
-
resolve(
|
|
25
|
+
resolve("unauthenticated");
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
28
|
try {
|
|
29
29
|
const status = JSON.parse(stdout);
|
|
30
|
-
resolve(status.loggedIn ?
|
|
30
|
+
resolve(status.loggedIn ? "ok" : "unauthenticated");
|
|
31
31
|
}
|
|
32
32
|
catch {
|
|
33
|
-
resolve(
|
|
33
|
+
resolve("unauthenticated");
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { AgentRunResult } from
|
|
1
|
+
import type { AgentRunResult } from "../../../types/agent.js";
|
|
2
2
|
export declare function describeAgentFailure(result: AgentRunResult, maxDetail?: number): string;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export function describeAgentFailure(result, maxDetail = 800) {
|
|
2
|
-
const base = result.exitCode !== 0
|
|
3
|
-
|
|
2
|
+
const base = result.exitCode !== 0
|
|
3
|
+
? `agent exited with code ${result.exitCode}`
|
|
4
|
+
: "agent produced no tool calls";
|
|
5
|
+
const detail = (result.stderr.trim() || result.stdout.trim())
|
|
6
|
+
.slice(-maxDetail)
|
|
7
|
+
.trim();
|
|
4
8
|
return detail ? `${base} — ${detail}` : base;
|
|
5
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function extractSentinelOutput(stdout: string): string | null |
|
|
1
|
+
export declare function extractSentinelOutput(stdout: string): string | null | "multiple";
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export function extractSentinelOutput(stdout) {
|
|
2
|
-
const START =
|
|
3
|
-
const END =
|
|
2
|
+
const START = "<<<EDS_OUTPUT_START>>>";
|
|
3
|
+
const END = "<<<EDS_OUTPUT_END>>>";
|
|
4
4
|
const startIdx = stdout.indexOf(START);
|
|
5
5
|
const endIdx = stdout.indexOf(END);
|
|
6
6
|
if (startIdx === -1 || endIdx === -1 || endIdx <= startIdx)
|
|
7
7
|
return null;
|
|
8
8
|
const secondStart = stdout.indexOf(START, startIdx + START.length);
|
|
9
9
|
if (secondStart !== -1 && secondStart < endIdx)
|
|
10
|
-
return
|
|
10
|
+
return "multiple";
|
|
11
11
|
const afterStart = stdout.indexOf(END, startIdx);
|
|
12
12
|
const secondEnd = stdout.indexOf(END, afterStart + END.length);
|
|
13
13
|
if (secondEnd !== -1)
|
|
14
|
-
return
|
|
14
|
+
return "multiple";
|
|
15
15
|
return stdout.slice(startIdx + START.length, endIdx).trim();
|
|
16
16
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type AgentName } from
|
|
1
|
+
import { type AgentName } from "../../../agent-names.js";
|
|
2
2
|
export declare function resolveAgentBinary(agent: AgentName): string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { AgentInvoker, InvokeAgentOptions, LocalCliAgentInvokerOptions } from
|
|
1
|
+
import type { AgentInvoker, InvokeAgentOptions, LocalCliAgentInvokerOptions } from "../../types/invoker.js";
|
|
2
2
|
export type { AgentInvoker, InvokeAgentOptions, LocalCliAgentInvokerOptions };
|
|
3
3
|
export declare function createLocalCliAgentInvoker(options?: LocalCliAgentInvokerOptions): AgentInvoker;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { runAgent } from
|
|
2
|
-
import { checkAgentAuth } from
|
|
1
|
+
import { runAgent } from "./run-agent.js";
|
|
2
|
+
import { checkAgentAuth } from "./helpers/check-agent-auth.js";
|
|
3
3
|
export function createLocalCliAgentInvoker(options = {}) {
|
|
4
4
|
const { onDebugEvent } = options;
|
|
5
5
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { AgentName } from
|
|
2
|
-
import type { AgentRunResult, AgentDebugEvent } from
|
|
3
|
-
import { describeAgentFailure } from
|
|
4
|
-
import { extractSentinelOutput } from
|
|
1
|
+
import type { AgentName } from "../../agent-names.js";
|
|
2
|
+
import type { AgentRunResult, AgentDebugEvent } from "../../types/agent.js";
|
|
3
|
+
import { describeAgentFailure } from "./helpers/describe-agent-failure.js";
|
|
4
|
+
import { extractSentinelOutput } from "./helpers/extract-sentinel-output.js";
|
|
5
5
|
export { describeAgentFailure, extractSentinelOutput };
|
|
6
6
|
export declare function runAgent(options: {
|
|
7
7
|
agent: AgentName;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { spawn } from
|
|
2
|
-
import { resolveAgentBinary } from
|
|
3
|
-
import { buildAgentArgs, BEDROCK_ENV_BY_AGENT } from
|
|
4
|
-
import { describeAgentFailure } from
|
|
5
|
-
import { extractSentinelOutput } from
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { resolveAgentBinary } from "./helpers/resolve-agent-binary.js";
|
|
3
|
+
import { buildAgentArgs, BEDROCK_ENV_BY_AGENT, } from "./helpers/build-agent-args.js";
|
|
4
|
+
import { describeAgentFailure } from "./helpers/describe-agent-failure.js";
|
|
5
|
+
import { extractSentinelOutput } from "./helpers/extract-sentinel-output.js";
|
|
6
6
|
export { describeAgentFailure, extractSentinelOutput };
|
|
7
7
|
export async function runAgent(options) {
|
|
8
|
-
const { agent, prompt, timeoutMs, model, onOutput, promptViaStdin, onDebugEvent } = options;
|
|
9
|
-
const bedrock = options.bedrock ?? process.env.EDS_BEDROCK ===
|
|
8
|
+
const { agent, prompt, timeoutMs, model, onOutput, promptViaStdin, onDebugEvent, } = options;
|
|
9
|
+
const bedrock = options.bedrock ?? process.env.EDS_BEDROCK === "1";
|
|
10
10
|
const binary = resolveAgentBinary(agent);
|
|
11
11
|
const useStdin = !!promptViaStdin;
|
|
12
12
|
const args = buildAgentArgs(agent, prompt, model, useStdin, bedrock);
|
|
13
13
|
const startedAt = Date.now();
|
|
14
|
-
onDebugEvent?.(
|
|
14
|
+
onDebugEvent?.("run.start", {
|
|
15
15
|
agent,
|
|
16
16
|
binary,
|
|
17
17
|
model,
|
|
@@ -23,11 +23,11 @@ export async function runAgent(options) {
|
|
|
23
23
|
return new Promise((resolve) => {
|
|
24
24
|
const bedrockEnv = bedrock ? BEDROCK_ENV_BY_AGENT[agent] : undefined;
|
|
25
25
|
const child = spawn(binary, args, {
|
|
26
|
-
stdio: [
|
|
26
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
27
27
|
...(bedrockEnv ? { env: { ...process.env, ...bedrockEnv } } : {}),
|
|
28
28
|
});
|
|
29
29
|
if (useStdin && child.stdin) {
|
|
30
|
-
child.stdin.on(
|
|
30
|
+
child.stdin.on("error", () => { });
|
|
31
31
|
child.stdin.write(prompt, () => {
|
|
32
32
|
child.stdin?.end();
|
|
33
33
|
});
|
|
@@ -35,25 +35,30 @@ export async function runAgent(options) {
|
|
|
35
35
|
else {
|
|
36
36
|
child.stdin?.end();
|
|
37
37
|
}
|
|
38
|
-
let stdout =
|
|
39
|
-
let stderr =
|
|
38
|
+
let stdout = "";
|
|
39
|
+
let stderr = "";
|
|
40
40
|
let timedOut = false;
|
|
41
41
|
const timer = setTimeout(() => {
|
|
42
42
|
timedOut = true;
|
|
43
|
-
child.kill(
|
|
43
|
+
child.kill("SIGTERM");
|
|
44
44
|
}, timeoutMs);
|
|
45
|
-
child.stdout?.on(
|
|
45
|
+
child.stdout?.on("data", (chunk) => {
|
|
46
46
|
const text = chunk.toString();
|
|
47
47
|
stdout += text;
|
|
48
48
|
onOutput?.(text);
|
|
49
49
|
});
|
|
50
|
-
child.stderr?.on(
|
|
50
|
+
child.stderr?.on("data", (chunk) => {
|
|
51
51
|
stderr += chunk.toString();
|
|
52
52
|
});
|
|
53
|
-
child.on(
|
|
53
|
+
child.on("close", (code, signal) => {
|
|
54
54
|
clearTimeout(timer);
|
|
55
|
-
const result = {
|
|
56
|
-
|
|
55
|
+
const result = {
|
|
56
|
+
exitCode: signal ? 1 : (code ?? 1),
|
|
57
|
+
stdout,
|
|
58
|
+
stderr,
|
|
59
|
+
timedOut,
|
|
60
|
+
};
|
|
61
|
+
onDebugEvent?.("run.end", {
|
|
57
62
|
agent,
|
|
58
63
|
model,
|
|
59
64
|
durationMs: Date.now() - startedAt,
|