@contentful/experience-design-system-generation 2.32.1-dev-build-81eb804.0 → 2.32.1-dev-build-3e401c3.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-generation",
3
- "version": "2.32.1-dev-build-81eb804.0",
3
+ "version": "2.32.1-dev-build-3e401c3.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",
@@ -2,6 +2,7 @@ import type { AgentDebugEvent, AgentAuthStatus, AgentName, AgentRunResult } from
2
2
  export interface InvokeAgentOptions {
3
3
  agent: AgentName;
4
4
  model?: string;
5
+ bedrock?: boolean;
5
6
  prompt: string;
6
7
  timeoutMs: number;
7
8
  onOutput?: (chunk: string) => void;
@@ -102,20 +102,25 @@ export interface ParsedMapTokenPropToolCalls {
102
102
  }
103
103
  export declare function parseMapTokenPropToolCallLines(stdout: string): ParsedMapTokenPropToolCalls;
104
104
  export declare function resolveBinary(agent: AgentName): string;
105
+ export declare function agentSupportsBedrock(agent: AgentName): boolean;
105
106
  /**
106
107
  * Resolve the model for an agent. Explicit flag/creds value wins, then a
107
108
  * per-agent `EDS_AGENT_MODEL_<AGENT>` env override (mirrors the
108
109
  * `EDS_AGENT_BINARY_<AGENT>` pattern), otherwise the lightweight default for
109
- * that agent.
110
+ * that agent. `bedrock` only affects the fallback default, and only for
111
+ * agents whose model id changes shape under Bedrock (codex, opencode) — an
112
+ * explicit value or env override is never rewritten.
110
113
  */
111
- export declare function resolveAgentModel(agent: AgentName, explicit?: string): string;
114
+ export declare function resolveAgentModel(agent: AgentName, explicit?: string, bedrock?: boolean): string;
112
115
  export type AgentDebugEvent = (name: string, payload?: Record<string, unknown>) => void;
113
- export declare function buildArgs(agent: AgentName, prompt: string, model?: string, promptViaStdin?: boolean): string[];
116
+ export declare function buildArgs(agent: AgentName, prompt: string, model?: string, promptViaStdin?: boolean, bedrock?: boolean): string[];
114
117
  export declare function runAgent(options: {
115
118
  agent: AgentName;
116
119
  prompt: string;
117
120
  timeoutMs: number;
118
121
  model?: string;
122
+ /** Apply the selected agent's Bedrock-routing env vars when enabled. */
123
+ bedrock?: boolean;
119
124
  onOutput?: (chunk: string) => void;
120
125
  /**
121
126
  * Deliver the prompt on stdin instead of as an argv positional. Required for
@@ -280,34 +280,80 @@ export function resolveBinary(agent) {
280
280
  return override.trim();
281
281
  return AGENT_BINARIES[agent];
282
282
  }
283
+ /** Per-agent env vars that switch model calls to AWS Bedrock. */
284
+ const BEDROCK_ENV_BY_AGENT = {
285
+ claude: { CLAUDE_CODE_USE_BEDROCK: '1' },
286
+ };
287
+ /**
288
+ * Agents with a working Bedrock routing mechanism, of any shape (env var,
289
+ * argv config override, or a provider-prefixed model string) — not just the
290
+ * env-var agents in BEDROCK_ENV_BY_AGENT. cursor is excluded: its own Bedrock
291
+ * support is currently broken for non-interactive/CI use.
292
+ */
293
+ const BEDROCK_CAPABLE_AGENTS = new Set(['claude', 'codex', 'opencode']);
294
+ export function agentSupportsBedrock(agent) {
295
+ return BEDROCK_CAPABLE_AGENTS.has(agent);
296
+ }
297
+ const DEFAULT_CODEX_BEDROCK_REGION = 'us-east-1';
283
298
  /**
284
299
  * Default models per agent — lightweight/fast picks to control cost when no
285
300
  * explicit model is configured. cursor uses `gpt-mini` (verified alias from
286
- * GetUsableModels; haiku is not available in cursor's model catalog).
301
+ * GetUsableModels; haiku is not available in cursor's model catalog). codex's
302
+ * default differs on Bedrock: the model id there carries an `openai.` prefix,
303
+ * required by the Bedrock provider and absent from the direct api.openai.com
304
+ * id.
287
305
  */
288
306
  const DEFAULT_MODELS = {
289
307
  claude: 'haiku',
290
- codex: 'gpt-5.4-mini', // requires OPENAI_API_KEY; ChatGPT account users must pass --model
308
+ codex: 'gpt-5.6-luna', // requires OPENAI_API_KEY; ChatGPT account users must pass --model
291
309
  opencode: 'claude-haiku-4-5',
292
310
  cursor: 'gpt-mini', // cursor alias for gpt-5.4-mini-medium; haiku not in cursor's catalog
293
311
  copilot: 'Auto', // the only model guaranteed on every Copilot plan (Free/Pro/Business/Enterprise); Pro+ users override via EDS_AGENT_MODEL_COPILOT
294
312
  };
313
+ const DEFAULT_CODEX_BEDROCK_MODEL = 'openai.gpt-5.6-luna';
295
314
  /**
296
315
  * Resolve the model for an agent. Explicit flag/creds value wins, then a
297
316
  * per-agent `EDS_AGENT_MODEL_<AGENT>` env override (mirrors the
298
317
  * `EDS_AGENT_BINARY_<AGENT>` pattern), otherwise the lightweight default for
299
- * that agent.
318
+ * that agent. `bedrock` only affects the fallback default, and only for
319
+ * agents whose model id changes shape under Bedrock (codex, opencode) — an
320
+ * explicit value or env override is never rewritten.
300
321
  */
301
- export function resolveAgentModel(agent, explicit) {
322
+ export function resolveAgentModel(agent, explicit, bedrock = false) {
302
323
  if (explicit && explicit.trim())
303
324
  return explicit.trim();
304
325
  const override = process.env[`EDS_AGENT_MODEL_${agent.toUpperCase()}`];
305
326
  if (override && override.trim())
306
327
  return override.trim();
328
+ if (bedrock && agent === 'codex')
329
+ return DEFAULT_CODEX_BEDROCK_MODEL;
330
+ if (bedrock && agent === 'opencode')
331
+ return withBedrockProviderPrefix(DEFAULT_MODELS.opencode);
307
332
  return DEFAULT_MODELS[agent];
308
333
  }
309
- export function buildArgs(agent, prompt, model, promptViaStdin = false) {
310
- const modelArg = ['--model', resolveAgentModel(agent, model)];
334
+ /**
335
+ * opencode selects providers via a `provider/model` string rather than a
336
+ * flag or env var, so routing it through Bedrock means rewriting the model
337
+ * string itself. Left alone if it already carries a provider prefix (an
338
+ * explicit --model / EDS_AGENT_MODEL_OPENCODE value naming its own
339
+ * provider), since resolveAgentModel only applies this to the bare default.
340
+ */
341
+ function withBedrockProviderPrefix(model) {
342
+ return model.includes('/') ? model : `amazon-bedrock/${model}`;
343
+ }
344
+ /**
345
+ * codex has no Bedrock env var; it requires `-c` config overrides
346
+ * (`model_provider` + the Bedrock provider's region) passed as argv, per the
347
+ * org's verified codex-bedrock-security-review setup. Region comes from the
348
+ * environment's own AWS region var, falling back to us-east-1 — the region
349
+ * gpt-5.6-luna's Bedrock endpoint requires — when neither is set.
350
+ */
351
+ function codexBedrockConfigArgs() {
352
+ const region = process.env.AWS_REGION?.trim() || process.env.AWS_DEFAULT_REGION?.trim() || DEFAULT_CODEX_BEDROCK_REGION;
353
+ return ['-c', 'model_provider=amazon-bedrock', '-c', `model_providers.amazon-bedrock.region=${region}`];
354
+ }
355
+ export function buildArgs(agent, prompt, model, promptViaStdin = false, bedrock = false) {
356
+ const modelArg = ['--model', resolveAgentModel(agent, model, bedrock)];
311
357
  // When the prompt is delivered on stdin, omit it from argv — a large prompt
312
358
  // as a command-line argument overflows ARG_MAX (spawn E2BIG). All four CLIs
313
359
  // read the prompt from stdin when it isn't passed positionally.
@@ -315,9 +361,11 @@ export function buildArgs(agent, prompt, model, promptViaStdin = false) {
315
361
  switch (agent) {
316
362
  case 'claude':
317
363
  return ['--print', ...modelArg, ...promptArg];
318
- case 'codex':
364
+ case 'codex': {
365
+ const bedrockArgs = bedrock ? codexBedrockConfigArgs() : [];
319
366
  // --dangerously-bypass-approvals-and-sandbox required for non-interactive use
320
- return ['exec', ...modelArg, '--dangerously-bypass-approvals-and-sandbox', ...promptArg];
367
+ return ['exec', ...bedrockArgs, ...modelArg, '--dangerously-bypass-approvals-and-sandbox', ...promptArg];
368
+ }
321
369
  case 'opencode':
322
370
  return ['run', ...modelArg, ...promptArg];
323
371
  case 'cursor':
@@ -346,21 +394,29 @@ export function buildArgs(agent, prompt, model, promptViaStdin = false) {
346
394
  }
347
395
  export async function runAgent(options) {
348
396
  const { agent, prompt, timeoutMs, model, onOutput, promptViaStdin, onDebugEvent } = options;
397
+ // Fall back to the process-wide EDS_BEDROCK signal (set once by the CLI's
398
+ // top-level --bedrock resolution and inherited by every spawned subprocess)
399
+ // when a call site doesn't pass `bedrock` explicitly — closes the gap for
400
+ // call sites that forget to thread the flag through by hand.
401
+ const bedrock = options.bedrock ?? process.env.EDS_BEDROCK === '1';
349
402
  const binary = resolveBinary(agent);
350
403
  const useStdin = !!promptViaStdin;
351
- const args = buildArgs(agent, prompt, model, useStdin);
404
+ const args = buildArgs(agent, prompt, model, useStdin, bedrock);
352
405
  const startedAt = Date.now();
353
406
  onDebugEvent?.('run.start', {
354
407
  agent,
355
408
  binary,
356
409
  model,
410
+ bedrock: !!bedrock,
357
411
  timeoutMs,
358
412
  promptLen: prompt.length,
359
413
  promptHead: prompt.slice(0, 500),
360
414
  });
361
415
  return new Promise((resolve) => {
416
+ const bedrockEnv = bedrock ? BEDROCK_ENV_BY_AGENT[agent] : undefined;
362
417
  const child = spawn(binary, args, {
363
418
  stdio: ['pipe', 'pipe', 'pipe'],
419
+ ...(bedrockEnv ? { env: { ...process.env, ...bedrockEnv } } : {}),
364
420
  });
365
421
  if (useStdin && child.stdin) {
366
422
  // Guard against EPIPE: the child may close stdin before we finish
@@ -1,6 +1,6 @@
1
1
  export { AGENT_NAMES, DEFAULT_AGENT_NAME, isAgentName } from './agent-names.js';
2
2
  export type { AgentName } from './agent-names.js';
3
- export { buildArgs, checkAgentAuth, describeAgentFailure, extractSentinelOutput, parseMapTokenPropToolCallLines, parseSelectToolCallLines, parseTokenToolCallLines, parseToolCallLines, resolveAgentModel, resolveBinary, runAgent, } from './agent-runner.js';
3
+ export { agentSupportsBedrock, buildArgs, checkAgentAuth, describeAgentFailure, extractSentinelOutput, parseMapTokenPropToolCallLines, parseSelectToolCallLines, parseTokenToolCallLines, parseToolCallLines, resolveAgentModel, resolveBinary, runAgent, } from './agent-runner.js';
4
4
  export type { AgentAuthStatus, AgentDebugEvent, AgentRunResult, ClassifyComponentCall, ClassifyPropCall, ClassifySlotCall, ExcludePropCall, MapTokenPropCall, ParsedMapTokenPropToolCalls, ParsedSelectToolCalls, ParsedTokenToolCalls, ParsedToolCalls, RejectComponentCall, SelectComponentCall, SelectToolCall, SetGroupCall, SetTokenCall, ToolCall, TokenToolCall, } from './agent-runner.js';
5
5
  export { createLocalCliAgentInvoker } from './agent-invoker.js';
6
6
  export type { AgentInvoker, CreateLocalCliAgentInvokerOptions, InvokeAgentOptions } from './agent-invoker.js';
package/dist/src/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // Agent identity
2
2
  export { AGENT_NAMES, DEFAULT_AGENT_NAME, isAgentName } from './agent-names.js';
3
3
  // Agent invocation (low-level)
4
- export { buildArgs, checkAgentAuth, describeAgentFailure, extractSentinelOutput, parseMapTokenPropToolCallLines, parseSelectToolCallLines, parseTokenToolCallLines, parseToolCallLines, resolveAgentModel, resolveBinary, runAgent, } from './agent-runner.js';
4
+ export { agentSupportsBedrock, buildArgs, checkAgentAuth, describeAgentFailure, extractSentinelOutput, parseMapTokenPropToolCallLines, parseSelectToolCallLines, parseTokenToolCallLines, parseToolCallLines, resolveAgentModel, resolveBinary, runAgent, } from './agent-runner.js';
5
5
  // Agent invocation (interface)
6
6
  export { createLocalCliAgentInvoker } from './agent-invoker.js';
7
7
  // Prompt building
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-generation",
3
- "version": "2.32.1-dev-build-81eb804.0",
3
+ "version": "2.32.1-dev-build-3e401c3.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.32.1-dev-build-81eb804.0"
25
+ "@contentful/experience-design-system-types": "2.32.1-dev-build-3e401c3.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@tsconfig/node24": "^24.0.4",