@contentful/experience-design-system-generation 2.35.1-dev-build-9605c7ee.0 → 2.35.1-dev-build-45d6c918.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.d.ts +1 -0
- package/dist/src/agent-names.js +7 -0
- package/dist/src/controller/create-generation-endpoint.d.ts +2 -11
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.js +1 -1
- package/dist/src/services/agent/helpers/check-agent-auth.js +2 -34
- package/dist/src/services/agent/helpers/check-claude-auth.d.ts +2 -0
- package/dist/src/services/agent/helpers/check-claude-auth.js +37 -0
- package/dist/src/services/agent/helpers/describe-agent-failure.d.ts +2 -0
- package/dist/src/services/agent/helpers/describe-agent-failure.js +5 -0
- package/dist/src/services/agent/helpers/extract-sentinel-output.d.ts +1 -0
- package/dist/src/services/agent/helpers/extract-sentinel-output.js +16 -0
- package/dist/src/services/agent/helpers/resolve-agent-binary.d.ts +1 -1
- package/dist/src/services/agent/helpers/resolve-agent-binary.js +1 -7
- package/dist/src/services/agent/local-cli-agent-invoker.d.ts +2 -17
- package/dist/src/services/agent/run-agent.d.ts +3 -2
- package/dist/src/services/agent/run-agent.js +4 -27
- package/dist/src/types/contract.d.ts +8 -0
- package/dist/src/types/invoker.d.ts +17 -0
- package/dist/src/types/invoker.js +1 -0
- package/package.json +2 -2
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-45d6c918.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",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const AGENT_NAMES: readonly ["claude", "codex", "opencode", "cursor", "copilot"];
|
|
2
2
|
export type AgentName = (typeof AGENT_NAMES)[number];
|
|
3
3
|
export declare const DEFAULT_AGENT_NAME: AgentName;
|
|
4
|
+
export declare const AGENT_BINARIES: Record<AgentName, string>;
|
|
4
5
|
export declare function isAgentName(value: string): value is AgentName;
|
package/dist/src/agent-names.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
export const AGENT_NAMES = ['claude', 'codex', 'opencode', 'cursor', 'copilot'];
|
|
2
2
|
export const DEFAULT_AGENT_NAME = 'claude';
|
|
3
|
+
export const AGENT_BINARIES = {
|
|
4
|
+
claude: 'claude',
|
|
5
|
+
codex: 'codex',
|
|
6
|
+
opencode: 'opencode',
|
|
7
|
+
cursor: 'cursor-agent',
|
|
8
|
+
copilot: 'copilot',
|
|
9
|
+
};
|
|
3
10
|
export function isAgentName(value) {
|
|
4
11
|
return AGENT_NAMES.includes(value);
|
|
5
12
|
}
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
import type { GenerationEndpointRequest, GenerationEndpointResponse } from '../types/contract.js';
|
|
4
|
-
export type { GenerationEndpointRequest, GenerationEndpointResponse } from '../types/contract.js';
|
|
5
|
-
export interface GenerationEndpointOptions {
|
|
6
|
-
onDebugEvent?: AgentDebugEvent;
|
|
7
|
-
}
|
|
8
|
-
export interface GenerationEndpoint {
|
|
9
|
-
run(request: GenerationEndpointRequest): Promise<GenerationEndpointResponse>;
|
|
10
|
-
checkAuth(agent: AgentName): Promise<AgentAuthStatus>;
|
|
11
|
-
}
|
|
1
|
+
import type { GenerationEndpoint, GenerationEndpointOptions, GenerationEndpointRequest, GenerationEndpointResponse } from '../types/contract.js';
|
|
2
|
+
export type { GenerationEndpoint, GenerationEndpointOptions, GenerationEndpointRequest, GenerationEndpointResponse };
|
|
12
3
|
export declare function createGenerationEndpoint(options?: GenerationEndpointOptions): GenerationEndpoint;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AGENT_NAMES, DEFAULT_AGENT_NAME, isAgentName } from './agent-names.js';
|
|
1
|
+
export { AGENT_NAMES, AGENT_BINARIES, DEFAULT_AGENT_NAME, isAgentName } from './agent-names.js';
|
|
2
2
|
export type { AgentName } from './agent-names.js';
|
|
3
3
|
export type { AgentAuthStatus, AgentDebugEvent, AgentRunResult } from './types/agent.js';
|
|
4
4
|
export type { ClassifyComponentCall, ClassifyPropCall, ClassifySlotCall, ExcludePropCall, MapTokenPropCall, ParsedMapTokenPropToolCalls, ParsedSelectToolCalls, ParsedTokenToolCalls, ParsedToolCalls, RejectComponentCall, SelectComponentCall, SelectToolCall, SetGroupCall, SetTokenCall, ToolCall, TokenToolCall, } from './types/tool-calls.js';
|
|
@@ -18,4 +18,4 @@ export { parseMapTokenPropToolCallLines } from './services/parsing/parse-map-tok
|
|
|
18
18
|
export { buildPrompt, formatCustomPromptBanner, resolveSkillPath } from './services/prompts/build-prompt.js';
|
|
19
19
|
export { formatGenerateProgressLine } from './progress.js';
|
|
20
20
|
export { createLocalCliAgentInvoker } from './services/agent/local-cli-agent-invoker.js';
|
|
21
|
-
export type { AgentInvoker, InvokeAgentOptions, LocalCliAgentInvokerOptions as CreateLocalCliAgentInvokerOptions, } from './
|
|
21
|
+
export type { AgentInvoker, InvokeAgentOptions, LocalCliAgentInvokerOptions as CreateLocalCliAgentInvokerOptions, } from './types/invoker.js';
|
package/dist/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Agent identity
|
|
2
|
-
export { AGENT_NAMES, DEFAULT_AGENT_NAME, isAgentName } from './agent-names.js';
|
|
2
|
+
export { AGENT_NAMES, AGENT_BINARIES, DEFAULT_AGENT_NAME, isAgentName } from './agent-names.js';
|
|
3
3
|
// Generation endpoint (primary entry point)
|
|
4
4
|
export { createGenerationEndpoint } from './controller/create-generation-endpoint.js';
|
|
5
5
|
// Orchestrator (lower-level — for callers that supply their own invoker)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
2
|
import { resolveAgentBinary } from './resolve-agent-binary.js';
|
|
3
|
+
import { checkClaudeAuth } from './check-claude-auth.js';
|
|
3
4
|
export async function checkAgentAuth(agent) {
|
|
4
5
|
const binary = resolveAgentBinary(agent);
|
|
5
6
|
const binaryExists = await new Promise((resolve) => {
|
|
@@ -14,38 +15,5 @@ export async function checkAgentAuth(agent) {
|
|
|
14
15
|
return 'not-found';
|
|
15
16
|
if (agent !== 'claude')
|
|
16
17
|
return 'ok';
|
|
17
|
-
return
|
|
18
|
-
const child = spawn(binary, ['auth', 'status', '--json'], {
|
|
19
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
20
|
-
});
|
|
21
|
-
let stdout = '';
|
|
22
|
-
let done = false;
|
|
23
|
-
const timer = setTimeout(() => {
|
|
24
|
-
if (!done) {
|
|
25
|
-
done = true;
|
|
26
|
-
child.kill('SIGTERM');
|
|
27
|
-
resolve('unauthenticated');
|
|
28
|
-
}
|
|
29
|
-
}, 5000);
|
|
30
|
-
child.stdout?.on('data', (chunk) => {
|
|
31
|
-
stdout += chunk.toString();
|
|
32
|
-
});
|
|
33
|
-
child.on('close', (code) => {
|
|
34
|
-
if (done)
|
|
35
|
-
return;
|
|
36
|
-
done = true;
|
|
37
|
-
clearTimeout(timer);
|
|
38
|
-
if (code !== 0) {
|
|
39
|
-
resolve('unauthenticated');
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
try {
|
|
43
|
-
const status = JSON.parse(stdout);
|
|
44
|
-
resolve(status.loggedIn ? 'ok' : 'unauthenticated');
|
|
45
|
-
}
|
|
46
|
-
catch {
|
|
47
|
-
resolve('unauthenticated');
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
});
|
|
18
|
+
return checkClaudeAuth(binary);
|
|
51
19
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
export function checkClaudeAuth(binary) {
|
|
3
|
+
return new Promise((resolve) => {
|
|
4
|
+
const child = spawn(binary, ['auth', 'status', '--json'], {
|
|
5
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
6
|
+
});
|
|
7
|
+
let stdout = '';
|
|
8
|
+
let done = false;
|
|
9
|
+
const timer = setTimeout(() => {
|
|
10
|
+
if (!done) {
|
|
11
|
+
done = true;
|
|
12
|
+
child.kill('SIGTERM');
|
|
13
|
+
resolve('unauthenticated');
|
|
14
|
+
}
|
|
15
|
+
}, 5000);
|
|
16
|
+
child.stdout?.on('data', (chunk) => {
|
|
17
|
+
stdout += chunk.toString();
|
|
18
|
+
});
|
|
19
|
+
child.on('close', (code) => {
|
|
20
|
+
if (done)
|
|
21
|
+
return;
|
|
22
|
+
done = true;
|
|
23
|
+
clearTimeout(timer);
|
|
24
|
+
if (code !== 0) {
|
|
25
|
+
resolve('unauthenticated');
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const status = JSON.parse(stdout);
|
|
30
|
+
resolve(status.loggedIn ? 'ok' : 'unauthenticated');
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
resolve('unauthenticated');
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export function describeAgentFailure(result, maxDetail = 800) {
|
|
2
|
+
const base = result.exitCode !== 0 ? `agent exited with code ${result.exitCode}` : 'agent produced no tool calls';
|
|
3
|
+
const detail = (result.stderr.trim() || result.stdout.trim()).slice(-maxDetail).trim();
|
|
4
|
+
return detail ? `${base} — ${detail}` : base;
|
|
5
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function extractSentinelOutput(stdout: string): string | null | 'multiple';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function extractSentinelOutput(stdout) {
|
|
2
|
+
const START = '<<<EDS_OUTPUT_START>>>';
|
|
3
|
+
const END = '<<<EDS_OUTPUT_END>>>';
|
|
4
|
+
const startIdx = stdout.indexOf(START);
|
|
5
|
+
const endIdx = stdout.indexOf(END);
|
|
6
|
+
if (startIdx === -1 || endIdx === -1 || endIdx <= startIdx)
|
|
7
|
+
return null;
|
|
8
|
+
const secondStart = stdout.indexOf(START, startIdx + START.length);
|
|
9
|
+
if (secondStart !== -1 && secondStart < endIdx)
|
|
10
|
+
return 'multiple';
|
|
11
|
+
const afterStart = stdout.indexOf(END, startIdx);
|
|
12
|
+
const secondEnd = stdout.indexOf(END, afterStart + END.length);
|
|
13
|
+
if (secondEnd !== -1)
|
|
14
|
+
return 'multiple';
|
|
15
|
+
return stdout.slice(startIdx + START.length, endIdx).trim();
|
|
16
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AgentName } from '../../../agent-names.js';
|
|
2
2
|
export declare function resolveAgentBinary(agent: AgentName): string;
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
claude: 'claude',
|
|
3
|
-
codex: 'codex',
|
|
4
|
-
opencode: 'opencode',
|
|
5
|
-
cursor: 'cursor-agent',
|
|
6
|
-
copilot: 'copilot',
|
|
7
|
-
};
|
|
1
|
+
import { AGENT_BINARIES } from '../../../agent-names.js';
|
|
8
2
|
export function resolveAgentBinary(agent) {
|
|
9
3
|
const envKey = `EDS_AGENT_BINARY_${agent.toUpperCase()}`;
|
|
10
4
|
const override = process.env[envKey];
|
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export interface InvokeAgentOptions {
|
|
4
|
-
agent: AgentName;
|
|
5
|
-
model?: string;
|
|
6
|
-
bedrock?: boolean;
|
|
7
|
-
prompt: string;
|
|
8
|
-
timeoutMs: number;
|
|
9
|
-
onOutput?: (chunk: string) => void;
|
|
10
|
-
}
|
|
11
|
-
export interface AgentInvoker {
|
|
12
|
-
invoke(options: InvokeAgentOptions): Promise<AgentRunResult>;
|
|
13
|
-
checkAuth(agent: AgentName): Promise<AgentAuthStatus>;
|
|
14
|
-
}
|
|
15
|
-
export interface LocalCliAgentInvokerOptions {
|
|
16
|
-
onDebugEvent?: AgentDebugEvent;
|
|
17
|
-
}
|
|
1
|
+
import type { AgentInvoker, InvokeAgentOptions, LocalCliAgentInvokerOptions } from '../../types/invoker.js';
|
|
2
|
+
export type { AgentInvoker, InvokeAgentOptions, LocalCliAgentInvokerOptions };
|
|
18
3
|
export declare function createLocalCliAgentInvoker(options?: LocalCliAgentInvokerOptions): AgentInvoker;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { AgentName } from '../../agent-names.js';
|
|
2
2
|
import type { AgentRunResult, AgentDebugEvent } from '../../types/agent.js';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { describeAgentFailure } from './helpers/describe-agent-failure.js';
|
|
4
|
+
import { extractSentinelOutput } from './helpers/extract-sentinel-output.js';
|
|
5
|
+
export { describeAgentFailure, extractSentinelOutput };
|
|
5
6
|
export declare function runAgent(options: {
|
|
6
7
|
agent: AgentName;
|
|
7
8
|
prompt: string;
|
|
@@ -1,27 +1,9 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
2
|
import { resolveAgentBinary } from './helpers/resolve-agent-binary.js';
|
|
3
3
|
import { buildAgentArgs, BEDROCK_ENV_BY_AGENT } from './helpers/build-agent-args.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return detail ? `${base} — ${detail}` : base;
|
|
8
|
-
}
|
|
9
|
-
export function extractSentinelOutput(stdout) {
|
|
10
|
-
const START = '<<<EDS_OUTPUT_START>>>';
|
|
11
|
-
const END = '<<<EDS_OUTPUT_END>>>';
|
|
12
|
-
const startIdx = stdout.indexOf(START);
|
|
13
|
-
const endIdx = stdout.indexOf(END);
|
|
14
|
-
if (startIdx === -1 || endIdx === -1 || endIdx <= startIdx)
|
|
15
|
-
return null;
|
|
16
|
-
const secondStart = stdout.indexOf(START, startIdx + START.length);
|
|
17
|
-
if (secondStart !== -1 && secondStart < endIdx)
|
|
18
|
-
return 'multiple';
|
|
19
|
-
const afterStart = stdout.indexOf(END, startIdx);
|
|
20
|
-
const secondEnd = stdout.indexOf(END, afterStart + END.length);
|
|
21
|
-
if (secondEnd !== -1)
|
|
22
|
-
return 'multiple';
|
|
23
|
-
return stdout.slice(startIdx + START.length, endIdx).trim();
|
|
24
|
-
}
|
|
4
|
+
import { describeAgentFailure } from './helpers/describe-agent-failure.js';
|
|
5
|
+
import { extractSentinelOutput } from './helpers/extract-sentinel-output.js';
|
|
6
|
+
export { describeAgentFailure, extractSentinelOutput };
|
|
25
7
|
export async function runAgent(options) {
|
|
26
8
|
const { agent, prompt, timeoutMs, model, onOutput, promptViaStdin, onDebugEvent } = options;
|
|
27
9
|
const bedrock = options.bedrock ?? process.env.EDS_BEDROCK === '1';
|
|
@@ -70,12 +52,7 @@ export async function runAgent(options) {
|
|
|
70
52
|
});
|
|
71
53
|
child.on('close', (code, signal) => {
|
|
72
54
|
clearTimeout(timer);
|
|
73
|
-
const result = {
|
|
74
|
-
exitCode: signal ? 1 : (code ?? 1),
|
|
75
|
-
stdout,
|
|
76
|
-
stderr,
|
|
77
|
-
timedOut,
|
|
78
|
-
};
|
|
55
|
+
const result = { exitCode: signal ? 1 : (code ?? 1), stdout, stderr, timedOut };
|
|
79
56
|
onDebugEvent?.('run.end', {
|
|
80
57
|
agent,
|
|
81
58
|
model,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AgentName } from '../agent-names.js';
|
|
2
|
+
import type { AgentAuthStatus, AgentDebugEvent } from './agent.js';
|
|
2
3
|
import type { PromptOptions } from './prompt.js';
|
|
3
4
|
export interface GenerationEndpointRequest {
|
|
4
5
|
readonly agent: AgentName;
|
|
@@ -14,3 +15,10 @@ export interface GenerationEndpointResponse {
|
|
|
14
15
|
readonly stderr: string;
|
|
15
16
|
readonly timedOut: boolean;
|
|
16
17
|
}
|
|
18
|
+
export interface GenerationEndpointOptions {
|
|
19
|
+
onDebugEvent?: AgentDebugEvent;
|
|
20
|
+
}
|
|
21
|
+
export interface GenerationEndpoint {
|
|
22
|
+
run(request: GenerationEndpointRequest): Promise<GenerationEndpointResponse>;
|
|
23
|
+
checkAuth(agent: AgentName): Promise<AgentAuthStatus>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AgentName } from '../agent-names.js';
|
|
2
|
+
import type { AgentAuthStatus, AgentDebugEvent, AgentRunResult } from './agent.js';
|
|
3
|
+
export interface InvokeAgentOptions {
|
|
4
|
+
agent: AgentName;
|
|
5
|
+
model?: string;
|
|
6
|
+
bedrock?: boolean;
|
|
7
|
+
prompt: string;
|
|
8
|
+
timeoutMs: number;
|
|
9
|
+
onOutput?: (chunk: string) => void;
|
|
10
|
+
}
|
|
11
|
+
export interface AgentInvoker {
|
|
12
|
+
invoke(options: InvokeAgentOptions): Promise<AgentRunResult>;
|
|
13
|
+
checkAuth(agent: AgentName): Promise<AgentAuthStatus>;
|
|
14
|
+
}
|
|
15
|
+
export interface LocalCliAgentInvokerOptions {
|
|
16
|
+
onDebugEvent?: AgentDebugEvent;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/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-45d6c918.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",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"skills/"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@contentful/experience-design-system-types": "2.35.1-dev-build-
|
|
25
|
+
"@contentful/experience-design-system-types": "2.35.1-dev-build-45d6c918.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@tsconfig/node24": "^24.0.4",
|