@contentful/experience-design-system-generation 2.32.1-dev-build-10912f6.0 → 2.32.1-dev-build-d5e6302.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-10912f6.0",
3
+ "version": "2.32.1-dev-build-d5e6302.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 | undefined;
114
+ export declare function resolveAgentModel(agent: AgentName, explicit?: string, bedrock?: boolean): string | undefined;
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,85 @@ 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';
298
+ const DEFAULT_OPENCODE_MODEL = 'claude-haiku-4-5';
283
299
  /**
284
300
  * Default models per agent — lightweight/fast picks to control cost when no
285
- * explicit model is configured. cursor uses `gpt-mini`
286
- * (verified alias from GetUsableModels; haiku is not available in cursor's
287
- * model catalog).
301
+ * explicit model is configured. cursor uses `gpt-mini` (verified alias from
302
+ * GetUsableModels; haiku is not available in cursor's model catalog).
303
+ *
304
+ * codex is deliberately absent: with no entry here it gets no `--model` at
305
+ * all, so the installed Codex CLI picks whatever its account supports. On
306
+ * Bedrock it still needs an explicit id, since the model id there carries an
307
+ * `openai.` prefix required by the Bedrock provider and absent from the
308
+ * direct api.openai.com id — see DEFAULT_CODEX_BEDROCK_MODEL.
288
309
  */
289
310
  const DEFAULT_MODELS = {
290
311
  claude: 'haiku',
291
- opencode: 'claude-haiku-4-5',
312
+ opencode: DEFAULT_OPENCODE_MODEL,
292
313
  cursor: 'gpt-mini', // cursor alias for gpt-5.4-mini-medium; haiku not in cursor's catalog
293
314
  copilot: 'Auto', // the only model guaranteed on every Copilot plan (Free/Pro/Business/Enterprise); Pro+ users override via EDS_AGENT_MODEL_COPILOT
294
315
  };
316
+ const DEFAULT_CODEX_BEDROCK_MODEL = 'openai.gpt-5.6-luna';
295
317
  /**
296
318
  * Resolve the model for an agent. Explicit flag/creds value wins, then a
297
319
  * per-agent `EDS_AGENT_MODEL_<AGENT>` env override (mirrors the
298
320
  * `EDS_AGENT_BINARY_<AGENT>` pattern), otherwise the lightweight default for
299
- * that agent.
321
+ * that agent. `bedrock` only affects the fallback default, and only for
322
+ * agents whose model id changes shape under Bedrock (codex, opencode) — an
323
+ * explicit value or env override is never rewritten.
300
324
  */
301
- export function resolveAgentModel(agent, explicit) {
325
+ export function resolveAgentModel(agent, explicit, bedrock = false) {
302
326
  if (explicit && explicit.trim())
303
327
  return explicit.trim();
304
328
  const override = process.env[`EDS_AGENT_MODEL_${agent.toUpperCase()}`];
305
329
  if (override && override.trim())
306
330
  return override.trim();
331
+ if (bedrock && agent === 'codex')
332
+ return DEFAULT_CODEX_BEDROCK_MODEL;
333
+ if (bedrock && agent === 'opencode')
334
+ return withBedrockProviderPrefix(DEFAULT_OPENCODE_MODEL);
307
335
  return DEFAULT_MODELS[agent];
308
336
  }
309
- export function buildArgs(agent, prompt, model, promptViaStdin = false) {
310
- const resolvedModel = resolveAgentModel(agent, model);
337
+ /**
338
+ * opencode selects providers via a `provider/model` string rather than a
339
+ * flag or env var, so routing it through Bedrock means rewriting the model
340
+ * string itself. Left alone if it already carries a provider prefix (an
341
+ * explicit --model / EDS_AGENT_MODEL_OPENCODE value naming its own
342
+ * provider), since resolveAgentModel only applies this to the bare default.
343
+ */
344
+ function withBedrockProviderPrefix(model) {
345
+ return model.includes('/') ? model : `amazon-bedrock/${model}`;
346
+ }
347
+ /**
348
+ * codex has no Bedrock env var; it requires `-c` config overrides
349
+ * (`model_provider` + the Bedrock provider's region) passed as argv, per the
350
+ * org's verified codex-bedrock-security-review setup. Region comes from the
351
+ * environment's own AWS region var, falling back to us-east-1 — the region
352
+ * gpt-5.6-luna's Bedrock endpoint requires — when neither is set.
353
+ */
354
+ function codexBedrockConfigArgs() {
355
+ const region = process.env.AWS_REGION?.trim() || process.env.AWS_DEFAULT_REGION?.trim() || DEFAULT_CODEX_BEDROCK_REGION;
356
+ return ['-c', 'model_provider=amazon-bedrock', '-c', `model_providers.amazon-bedrock.region=${region}`];
357
+ }
358
+ export function buildArgs(agent, prompt, model, promptViaStdin = false, bedrock = false) {
359
+ // codex with no configured model resolves to undefined — omit --model
360
+ // entirely so the CLI picks its own account-compatible default.
361
+ const resolvedModel = resolveAgentModel(agent, model, bedrock);
311
362
  const modelArg = resolvedModel ? ['--model', resolvedModel] : [];
312
363
  // When the prompt is delivered on stdin, omit it from argv — a large prompt
313
364
  // as a command-line argument overflows ARG_MAX (spawn E2BIG). All four CLIs
@@ -316,9 +367,11 @@ export function buildArgs(agent, prompt, model, promptViaStdin = false) {
316
367
  switch (agent) {
317
368
  case 'claude':
318
369
  return ['--print', ...modelArg, ...promptArg];
319
- case 'codex':
370
+ case 'codex': {
371
+ const bedrockArgs = bedrock ? codexBedrockConfigArgs() : [];
320
372
  // --dangerously-bypass-approvals-and-sandbox required for non-interactive use
321
- return ['exec', ...modelArg, '--dangerously-bypass-approvals-and-sandbox', ...promptArg];
373
+ return ['exec', ...bedrockArgs, ...modelArg, '--dangerously-bypass-approvals-and-sandbox', ...promptArg];
374
+ }
322
375
  case 'opencode':
323
376
  return ['run', ...modelArg, ...promptArg];
324
377
  case 'cursor':
@@ -347,21 +400,29 @@ export function buildArgs(agent, prompt, model, promptViaStdin = false) {
347
400
  }
348
401
  export async function runAgent(options) {
349
402
  const { agent, prompt, timeoutMs, model, onOutput, promptViaStdin, onDebugEvent } = options;
403
+ // Fall back to the process-wide EDS_BEDROCK signal (set once by the CLI's
404
+ // top-level --bedrock resolution and inherited by every spawned subprocess)
405
+ // when a call site doesn't pass `bedrock` explicitly — closes the gap for
406
+ // call sites that forget to thread the flag through by hand.
407
+ const bedrock = options.bedrock ?? process.env.EDS_BEDROCK === '1';
350
408
  const binary = resolveBinary(agent);
351
409
  const useStdin = !!promptViaStdin;
352
- const args = buildArgs(agent, prompt, model, useStdin);
410
+ const args = buildArgs(agent, prompt, model, useStdin, bedrock);
353
411
  const startedAt = Date.now();
354
412
  onDebugEvent?.('run.start', {
355
413
  agent,
356
414
  binary,
357
415
  model,
416
+ bedrock: !!bedrock,
358
417
  timeoutMs,
359
418
  promptLen: prompt.length,
360
419
  promptHead: prompt.slice(0, 500),
361
420
  });
362
421
  return new Promise((resolve) => {
422
+ const bedrockEnv = bedrock ? BEDROCK_ENV_BY_AGENT[agent] : undefined;
363
423
  const child = spawn(binary, args, {
364
424
  stdio: ['pipe', 'pipe', 'pipe'],
425
+ ...(bedrockEnv ? { env: { ...process.env, ...bedrockEnv } } : {}),
365
426
  });
366
427
  if (useStdin && child.stdin) {
367
428
  // 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-10912f6.0",
3
+ "version": "2.32.1-dev-build-d5e6302.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-10912f6.0"
25
+ "@contentful/experience-design-system-types": "2.32.1-dev-build-d5e6302.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@tsconfig/node24": "^24.0.4",