@contentful/experience-design-system-cli 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-cli",
3
- "version": "2.32.1-dev-build-81eb804.0",
3
+ "version": "2.32.1-dev-build-3e401c3.0",
4
4
  "description": "Contentful Experiences design system import CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,4 +1,68 @@
1
- export { EdsiApiClient, EdsiApiClient as ImportApiClient, DEFAULT_HOST, PREVIEW_ERROR_PREFIX, APPLY_ERROR_PREFIX, VALIDATION_FAILED_CODE, parsePreviewValidationErrors, sanitizeBreakingChanges, } from '../api/clients/edsi-client.js';
2
- export type { PreviewValidationError } from '../api/clients/edsi-client.js';
3
- export { ApiError } from '../errors/api-error.js';
4
- export type { EdsiClientOptions as ApiClientOptions } from '../interfaces/clients/edsi-client-options.js';
1
+ import type { ManifestPayload, ServerPreviewResponse, ApplyOperationResponse, BreakingChange } from '@contentful/experience-design-system-types';
2
+ export declare const DEFAULT_HOST = "https://api.contentful.com";
3
+ export declare const PREVIEW_ERROR_PREFIX = "preview failed:";
4
+ export declare const APPLY_ERROR_PREFIX = "apply failed:";
5
+ export declare const VALIDATION_FAILED_CODE = "\"ValidationFailed\"";
6
+ export interface ApiClientOptions {
7
+ host?: string;
8
+ cmaToken: string;
9
+ spaceId: string;
10
+ environmentId: string;
11
+ retry?: {
12
+ maxAttempts?: number;
13
+ initialDelayMs?: number;
14
+ maxDelayMs?: number;
15
+ sleep?: (delayMs: number) => Promise<void>;
16
+ };
17
+ }
18
+ export declare class ApiError extends Error {
19
+ readonly status: number;
20
+ readonly body: string;
21
+ readonly guidance?: string | undefined;
22
+ constructor(message: string, status: number, body: string, guidance?: string | undefined);
23
+ }
24
+ export interface PreviewValidationError {
25
+ componentName: string;
26
+ path: string;
27
+ message: string;
28
+ }
29
+ /**
30
+ * Parse the JSON body of a 422 from `previewImport()` into structured
31
+ * per-component validation errors. Returns [] for any malformed input
32
+ * so callers can fall back to the generic error path without try/catch.
33
+ *
34
+ * Path shape: `manifest:components/<Name>/$slots/<key>` or
35
+ * `manifest:components/<Name>/$properties/<key>`. Only the component
36
+ * name is extracted today; `path` and `message` are kept verbatim so
37
+ * future surfaces (debug logging, headless retry in SP-4) can render
38
+ * the field-level detail.
39
+ */
40
+ export declare function parsePreviewValidationErrors(body: string): PreviewValidationError[];
41
+ export declare function sanitizeBreakingChanges(raw: unknown): BreakingChange[];
42
+ export declare class ImportApiClient {
43
+ private host;
44
+ private token;
45
+ private spaceId;
46
+ private environmentId;
47
+ private retry;
48
+ private lastRequestId?;
49
+ getLastRequestId(): string | undefined;
50
+ private noteRequestId;
51
+ constructor(opts: ApiClientOptions);
52
+ private base;
53
+ private headers;
54
+ private requestWithRetry;
55
+ validateToken(): Promise<void>;
56
+ checkPreflight(): Promise<void>;
57
+ previewImport(manifest: ManifestPayload, allowDeletions?: boolean): Promise<ServerPreviewResponse>;
58
+ applyImport(manifest: ManifestPayload, options: {
59
+ acknowledgeBreakingChanges: boolean;
60
+ allowDeletions?: boolean;
61
+ }): Promise<ApplyOperationResponse>;
62
+ pollOperation(operationId: string, opts?: {
63
+ intervalMs?: number;
64
+ maxIntervalMs?: number;
65
+ maxAttempts?: number;
66
+ onProgress?: (op: ApplyOperationResponse) => void;
67
+ }): Promise<ApplyOperationResponse>;
68
+ }
@@ -1 +1,4 @@
1
- export { DEFAULT_API_HOST, DEFAULT_CONFIGURED_HOST, toConfiguredHost, toApiHost } from './helpers/url.js';
1
+ export declare const DEFAULT_API_HOST = "https://api.contentful.com";
2
+ export declare const DEFAULT_CONFIGURED_HOST = "api.contentful.com";
3
+ export declare function toConfiguredHost(host?: string): string | undefined;
4
+ export declare function toApiHost(host?: string): string;
@@ -7,6 +7,7 @@ export interface PipelineOptions {
7
7
  cmaToken?: string;
8
8
  agent: string;
9
9
  model?: string;
10
+ bedrock?: boolean;
10
11
  skipAnalyze: boolean;
11
12
  skipGenerate: boolean;
12
13
  print: boolean;
@@ -27,15 +28,6 @@ export interface PipelineOptions {
27
28
  /** When true, auto-reject cycle participants and retry push instead of surfacing an error. */
28
29
  autoRejectCycles?: boolean;
29
30
  allowDeletions?: boolean;
30
- /**
31
- * Fetch existing Components + DesignTokens from the target space+env
32
- * and persist them under outDir/.existing-entities.json so downstream
33
- * agent steps can consume them as context. Requires spaceId +
34
- * environmentId + cmaToken; skipped with a warning otherwise. No-op
35
- * for the agent flow in this PR — the file is written but nothing
36
- * reads it yet.
37
- */
38
- withSpaceContext?: boolean;
39
31
  compositionMode?: CompositionMode;
40
32
  compositionMap?: string;
41
33
  compositionAgent?: boolean;
@@ -7,6 +7,7 @@ export declare function buildSelectAgentArgs(opts: {
7
7
  sessionId: string;
8
8
  agent: string;
9
9
  model?: string;
10
+ bedrock?: boolean;
10
11
  selectPromptPath?: string;
11
12
  noCache?: boolean;
12
13
  }): string[];
@@ -23,6 +24,7 @@ export declare function buildGenerateComponentsArgs(opts: {
23
24
  tokensPath?: string;
24
25
  agent: string;
25
26
  model?: string;
27
+ bedrock?: boolean;
26
28
  noCache?: boolean;
27
29
  generatePromptPath?: string;
28
30
  }): string[];
@@ -49,6 +51,7 @@ export type WizardAppProps = {
49
51
  initialHost?: string;
50
52
  initialAgent?: string;
51
53
  initialModel?: string;
54
+ bedrock?: boolean;
52
55
  initialProjectPath?: string;
53
56
  host?: string;
54
57
  autoAcceptScope?: boolean;
@@ -80,4 +83,4 @@ export type WizardAppProps = {
80
83
  onRunPicked?: (selection: RunPickerSelection) => void;
81
84
  allowDeletions?: boolean;
82
85
  };
83
- export declare function WizardApp({ initialSpaceId, initialEnvironmentId, initialCmaToken, initialHost, initialAgent, initialModel, initialProjectPath, host, autoAcceptScope, autoRejectCycles, compositionMode, compositionMap, compositionAgent, compositionAgentMode, compositionRefresh, generateMap, promptOverrides, noCache, autoFilter, livePreview, noPush, noSave, outDirOverride, onConflictMode, selectPromptPath, generatePromptPath, skipMapTokens, seedExtractSessionId, seedGenerateSessionId, seedTokenSessionId, seedTokensPath, initialStep, initialRawTokensPath, initialRuns, onRunPicked, allowDeletions, }?: WizardAppProps): React.ReactElement;
86
+ export declare function WizardApp({ initialSpaceId, initialEnvironmentId, initialCmaToken, initialHost, initialAgent, initialModel, bedrock, initialProjectPath, host, autoAcceptScope, autoRejectCycles, compositionMode, compositionMap, compositionAgent, compositionAgentMode, compositionRefresh, generateMap, promptOverrides, noCache, autoFilter, livePreview, noPush, noSave, outDirOverride, onConflictMode, selectPromptPath, generatePromptPath, skipMapTokens, seedExtractSessionId, seedGenerateSessionId, seedTokenSessionId, seedTokensPath, initialStep, initialRawTokensPath, initialRuns, onRunPicked, allowDeletions, }?: WizardAppProps): React.ReactElement;
package/dist/src/index.js CHANGED
@@ -275,22 +275,38 @@ function resolveBinary(agent) {
275
275
  return override.trim();
276
276
  return AGENT_BINARIES[agent];
277
277
  }
278
- function resolveAgentModel(agent, explicit) {
278
+ function agentSupportsBedrock(agent) {
279
+ return BEDROCK_CAPABLE_AGENTS.has(agent);
280
+ }
281
+ function resolveAgentModel(agent, explicit, bedrock = false) {
279
282
  if (explicit && explicit.trim())
280
283
  return explicit.trim();
281
284
  const override = process.env[`EDS_AGENT_MODEL_${agent.toUpperCase()}`];
282
285
  if (override && override.trim())
283
286
  return override.trim();
287
+ if (bedrock && agent === "codex")
288
+ return DEFAULT_CODEX_BEDROCK_MODEL;
289
+ if (bedrock && agent === "opencode")
290
+ return withBedrockProviderPrefix(DEFAULT_MODELS.opencode);
284
291
  return DEFAULT_MODELS[agent];
285
292
  }
286
- function buildArgs(agent, prompt2, model, promptViaStdin = false) {
287
- const modelArg = ["--model", resolveAgentModel(agent, model)];
293
+ function withBedrockProviderPrefix(model) {
294
+ return model.includes("/") ? model : `amazon-bedrock/${model}`;
295
+ }
296
+ function codexBedrockConfigArgs() {
297
+ const region = process.env.AWS_REGION?.trim() || process.env.AWS_DEFAULT_REGION?.trim() || DEFAULT_CODEX_BEDROCK_REGION;
298
+ return ["-c", "model_provider=amazon-bedrock", "-c", `model_providers.amazon-bedrock.region=${region}`];
299
+ }
300
+ function buildArgs(agent, prompt2, model, promptViaStdin = false, bedrock = false) {
301
+ const modelArg = ["--model", resolveAgentModel(agent, model, bedrock)];
288
302
  const promptArg = promptViaStdin ? [] : [prompt2];
289
303
  switch (agent) {
290
304
  case "claude":
291
305
  return ["--print", ...modelArg, ...promptArg];
292
- case "codex":
293
- return ["exec", ...modelArg, "--dangerously-bypass-approvals-and-sandbox", ...promptArg];
306
+ case "codex": {
307
+ const bedrockArgs = bedrock ? codexBedrockConfigArgs() : [];
308
+ return ["exec", ...bedrockArgs, ...modelArg, "--dangerously-bypass-approvals-and-sandbox", ...promptArg];
309
+ }
294
310
  case "opencode":
295
311
  return ["run", ...modelArg, ...promptArg];
296
312
  case "cursor":
@@ -304,21 +320,25 @@ function buildArgs(agent, prompt2, model, promptViaStdin = false) {
304
320
  }
305
321
  async function runAgent(options) {
306
322
  const { agent, prompt: prompt2, timeoutMs, model, onOutput, promptViaStdin, onDebugEvent } = options;
323
+ const bedrock = options.bedrock ?? process.env.EDS_BEDROCK === "1";
307
324
  const binary = resolveBinary(agent);
308
325
  const useStdin2 = !!promptViaStdin;
309
- const args = buildArgs(agent, prompt2, model, useStdin2);
326
+ const args = buildArgs(agent, prompt2, model, useStdin2, bedrock);
310
327
  const startedAt = Date.now();
311
328
  onDebugEvent?.("run.start", {
312
329
  agent,
313
330
  binary,
314
331
  model,
332
+ bedrock: !!bedrock,
315
333
  timeoutMs,
316
334
  promptLen: prompt2.length,
317
335
  promptHead: prompt2.slice(0, 500)
318
336
  });
319
337
  return new Promise((resolve27) => {
338
+ const bedrockEnv = bedrock ? BEDROCK_ENV_BY_AGENT[agent] : void 0;
320
339
  const child = spawn(binary, args, {
321
- stdio: ["pipe", "pipe", "pipe"]
340
+ stdio: ["pipe", "pipe", "pipe"],
341
+ ...bedrockEnv ? { env: { ...process.env, ...bedrockEnv } } : {}
322
342
  });
323
343
  if (useStdin2 && child.stdin) {
324
344
  child.stdin.on("error", () => {
@@ -436,7 +456,7 @@ function extractSentinelOutput(stdout) {
436
456
  return "multiple";
437
457
  return stdout.slice(startIdx + START.length, endIdx).trim();
438
458
  }
439
- var VALID_SELECT_TOOL_NAMES, VALID_TOOL_NAMES, VALID_TOKEN_TOOL_NAMES, VALID_CDF_TYPES, VALID_CATEGORIES, AGENT_BINARIES, DEFAULT_MODELS;
459
+ var VALID_SELECT_TOOL_NAMES, VALID_TOOL_NAMES, VALID_TOKEN_TOOL_NAMES, VALID_CDF_TYPES, VALID_CATEGORIES, AGENT_BINARIES, BEDROCK_ENV_BY_AGENT, BEDROCK_CAPABLE_AGENTS, DEFAULT_CODEX_BEDROCK_REGION, DEFAULT_MODELS, DEFAULT_CODEX_BEDROCK_MODEL;
440
460
  var init_agent_runner = __esm({
441
461
  "packages/experience-design-system-generation/dist/src/agent-runner.js"() {
442
462
  "use strict";
@@ -453,9 +473,14 @@ var init_agent_runner = __esm({
453
473
  cursor: "cursor-agent",
454
474
  copilot: "copilot"
455
475
  };
476
+ BEDROCK_ENV_BY_AGENT = {
477
+ claude: { CLAUDE_CODE_USE_BEDROCK: "1" }
478
+ };
479
+ BEDROCK_CAPABLE_AGENTS = /* @__PURE__ */ new Set(["claude", "codex", "opencode"]);
480
+ DEFAULT_CODEX_BEDROCK_REGION = "us-east-1";
456
481
  DEFAULT_MODELS = {
457
482
  claude: "haiku",
458
- codex: "gpt-5.4-mini",
483
+ codex: "gpt-5.6-luna",
459
484
  // requires OPENAI_API_KEY; ChatGPT account users must pass --model
460
485
  opencode: "claude-haiku-4-5",
461
486
  cursor: "gpt-mini",
@@ -463,6 +488,7 @@ var init_agent_runner = __esm({
463
488
  copilot: "Auto"
464
489
  // the only model guaranteed on every Copilot plan (Free/Pro/Business/Enterprise); Pro+ users override via EDS_AGENT_MODEL_COPILOT
465
490
  };
491
+ DEFAULT_CODEX_BEDROCK_MODEL = "openai.gpt-5.6-luna";
466
492
  }
467
493
  });
468
494
 
@@ -852,6 +878,7 @@ var src_exports = {};
852
878
  __export(src_exports, {
853
879
  AGENT_NAMES: () => AGENT_NAMES,
854
880
  DEFAULT_AGENT_NAME: () => DEFAULT_AGENT_NAME,
881
+ agentSupportsBedrock: () => agentSupportsBedrock,
855
882
  buildArgs: () => buildArgs,
856
883
  buildPrompt: () => buildPrompt,
857
884
  checkAgentAuth: () => checkAgentAuth,
@@ -12576,7 +12603,7 @@ var init_src3 = __esm({
12576
12603
  }
12577
12604
  });
12578
12605
 
12579
- // packages/experience-design-system-cli/src/helpers/url.ts
12606
+ // packages/experience-design-system-cli/src/host-utils.ts
12580
12607
  function trimTrailingSlashes(value) {
12581
12608
  return value.replace(/\/+$/, "");
12582
12609
  }
@@ -12599,8 +12626,8 @@ function toApiHost(host) {
12599
12626
  return `https://${normalized}`;
12600
12627
  }
12601
12628
  var DEFAULT_API_HOST, DEFAULT_CONFIGURED_HOST;
12602
- var init_url = __esm({
12603
- "packages/experience-design-system-cli/src/helpers/url.ts"() {
12629
+ var init_host_utils = __esm({
12630
+ "packages/experience-design-system-cli/src/host-utils.ts"() {
12604
12631
  "use strict";
12605
12632
  DEFAULT_API_HOST = "https://api.contentful.com";
12606
12633
  DEFAULT_CONFIGURED_HOST = "api.contentful.com";
@@ -12807,55 +12834,7 @@ var init_user_agent = __esm({
12807
12834
  }
12808
12835
  });
12809
12836
 
12810
- // packages/experience-design-system-cli/src/helpers/http.ts
12811
- function buildHeaders(token) {
12812
- return {
12813
- Authorization: `Bearer ${token}`,
12814
- "Content-Type": "application/json",
12815
- "X-Contentful-User-Agent": buildUserAgent()
12816
- };
12817
- }
12818
- async function request(url, options) {
12819
- const init = {
12820
- method: options.method ?? "GET",
12821
- headers: buildHeaders(options.token)
12822
- };
12823
- if (options.body) init.body = options.body;
12824
- return fetch(url, init);
12825
- }
12826
- var init_http = __esm({
12827
- "packages/experience-design-system-cli/src/helpers/http.ts"() {
12828
- "use strict";
12829
- init_user_agent();
12830
- }
12831
- });
12832
-
12833
- // packages/experience-design-system-cli/src/errors/api-error.ts
12834
- var ERROR_BODY_LOG_CAP, ApiError;
12835
- var init_api_error = __esm({
12836
- "packages/experience-design-system-cli/src/errors/api-error.ts"() {
12837
- "use strict";
12838
- ERROR_BODY_LOG_CAP = 16384;
12839
- ApiError = class extends Error {
12840
- constructor(message, status, body, guidance) {
12841
- super(message);
12842
- this.status = status;
12843
- this.body = body;
12844
- this.guidance = guidance;
12845
- if (body) {
12846
- const trimmed = body.length > ERROR_BODY_LOG_CAP ? body.slice(0, ERROR_BODY_LOG_CAP) + "\u2026" : body;
12847
- this.message = `${message}
12848
- ${trimmed}`;
12849
- }
12850
- }
12851
- status;
12852
- body;
12853
- guidance;
12854
- };
12855
- }
12856
- });
12857
-
12858
- // packages/experience-design-system-cli/src/api/clients/edsi-client.ts
12837
+ // packages/experience-design-system-cli/src/apply/api-client.ts
12859
12838
  function defaultSleep(delayMs) {
12860
12839
  return new Promise((resolve27) => setTimeout(resolve27, delayMs));
12861
12840
  }
@@ -12938,20 +12917,48 @@ function isApsDenialBody(body) {
12938
12917
  return false;
12939
12918
  }
12940
12919
  }
12941
- var PREVIEW_ERROR_PREFIX, APPLY_ERROR_PREFIX, VALIDATION_FAILED_CODE, MAX_RETRY_AFTER_MS, COMPONENT_PATH_PREFIX, PROPERTY_BREAKING_REASONS, SLOT_BREAKING_REASONS, EdsiApiClient;
12942
- var init_edsi_client = __esm({
12943
- "packages/experience-design-system-cli/src/api/clients/edsi-client.ts"() {
12920
+ async function request(url, options) {
12921
+ const headers = {
12922
+ Authorization: `Bearer ${options.token}`,
12923
+ "Content-Type": "application/json",
12924
+ "X-Contentful-User-Agent": buildUserAgent()
12925
+ };
12926
+ const init = {
12927
+ method: options.method ?? "GET",
12928
+ headers
12929
+ };
12930
+ if (options.body) init.body = options.body;
12931
+ return fetch(url, init);
12932
+ }
12933
+ var PREVIEW_ERROR_PREFIX, APPLY_ERROR_PREFIX, VALIDATION_FAILED_CODE, MAX_RETRY_AFTER_MS, ERROR_BODY_LOG_CAP, ApiError, COMPONENT_PATH_PREFIX, PROPERTY_BREAKING_REASONS, SLOT_BREAKING_REASONS, ImportApiClient;
12934
+ var init_api_client = __esm({
12935
+ "packages/experience-design-system-cli/src/apply/api-client.ts"() {
12944
12936
  "use strict";
12945
12937
  init_src3();
12946
- init_url();
12938
+ init_host_utils();
12947
12939
  init_debug_logger();
12948
12940
  init_user_agent();
12949
- init_http();
12950
- init_api_error();
12951
12941
  PREVIEW_ERROR_PREFIX = "preview failed:";
12952
12942
  APPLY_ERROR_PREFIX = "apply failed:";
12953
12943
  VALIDATION_FAILED_CODE = '"ValidationFailed"';
12954
12944
  MAX_RETRY_AFTER_MS = 6e4;
12945
+ ERROR_BODY_LOG_CAP = 16384;
12946
+ ApiError = class extends Error {
12947
+ constructor(message, status, body, guidance) {
12948
+ super(message);
12949
+ this.status = status;
12950
+ this.body = body;
12951
+ this.guidance = guidance;
12952
+ if (body) {
12953
+ const trimmed = body.length > ERROR_BODY_LOG_CAP ? body.slice(0, ERROR_BODY_LOG_CAP) + "\u2026" : body;
12954
+ this.message = `${message}
12955
+ ${trimmed}`;
12956
+ }
12957
+ }
12958
+ status;
12959
+ body;
12960
+ guidance;
12961
+ };
12955
12962
  COMPONENT_PATH_PREFIX = "manifest:components/";
12956
12963
  PROPERTY_BREAKING_REASONS = /* @__PURE__ */ new Set([
12957
12964
  "removed",
@@ -12960,7 +12967,7 @@ var init_edsi_client = __esm({
12960
12967
  "validation_narrowed"
12961
12968
  ]);
12962
12969
  SLOT_BREAKING_REASONS = /* @__PURE__ */ new Set(["slot_removed", "slot_allowed_components_narrowed"]);
12963
- EdsiApiClient = class {
12970
+ ImportApiClient = class {
12964
12971
  host;
12965
12972
  token;
12966
12973
  spaceId;
@@ -13226,15 +13233,6 @@ var init_edsi_client = __esm({
13226
13233
  }
13227
13234
  });
13228
13235
 
13229
- // packages/experience-design-system-cli/src/apply/api-client.ts
13230
- var init_api_client = __esm({
13231
- "packages/experience-design-system-cli/src/apply/api-client.ts"() {
13232
- "use strict";
13233
- init_edsi_client();
13234
- init_api_error();
13235
- }
13236
- });
13237
-
13238
13236
  // packages/experience-design-system-cli/src/lib/error-parser.ts
13239
13237
  function stripLambdaLogPrefix(body) {
13240
13238
  let out = body.replace(LAMBDA_LOG_PREFIX_RE, "");
@@ -14223,14 +14221,6 @@ var init_strip_allowed_components = __esm({
14223
14221
  }
14224
14222
  });
14225
14223
 
14226
- // packages/experience-design-system-cli/src/host-utils.ts
14227
- var init_host_utils = __esm({
14228
- "packages/experience-design-system-cli/src/host-utils.ts"() {
14229
- "use strict";
14230
- init_url();
14231
- }
14232
- });
14233
-
14234
14224
  // packages/experience-design-system-cli/src/credentials-store.ts
14235
14225
  var credentials_store_exports = {};
14236
14226
  __export(credentials_store_exports, {
@@ -14846,7 +14836,7 @@ async function resolveSharedInputs(opts) {
14846
14836
  if (opts.tokens) {
14847
14837
  tokens = await readTokensFromPath("--tokens", opts.tokens);
14848
14838
  }
14849
- const client2 = new EdsiApiClient({
14839
+ const client2 = new ImportApiClient({
14850
14840
  host: opts.host,
14851
14841
  cmaToken,
14852
14842
  spaceId,
@@ -15586,7 +15576,7 @@ function App({ sessionId: sessionId2, artifactsRoot, reviewRoot }) {
15586
15576
  tokens
15587
15577
  );
15588
15578
  if (!manifest.componentsManifest) manifest.componentsManifest = {};
15589
- const client2 = new EdsiApiClient({ cmaToken, spaceId, environmentId });
15579
+ const client2 = new ImportApiClient({ cmaToken, spaceId, environmentId });
15590
15580
  const preview = await client2.previewImport(manifest, true);
15591
15581
  const annotations = {};
15592
15582
  for (const item of preview.components.new) {
@@ -16608,7 +16598,7 @@ var init_save_path_resolver = __esm({
16608
16598
  });
16609
16599
 
16610
16600
  // packages/experience-design-system-cli/src/runs/store.ts
16611
- import { readFile as readFile22, writeFile as writeFile6, mkdir as mkdir6, rename } from "node:fs/promises";
16601
+ import { readFile as readFile22, writeFile as writeFile5, mkdir as mkdir6, rename } from "node:fs/promises";
16612
16602
  import { join as join20 } from "node:path";
16613
16603
  import { homedir as homedir7 } from "node:os";
16614
16604
  import { randomBytes as randomBytes2 } from "node:crypto";
@@ -16671,7 +16661,7 @@ async function writeAtomic(file) {
16671
16661
  await mkdir6(RUNS_DIR, { recursive: true });
16672
16662
  const body = JSON.stringify(file, null, 2) + "\n";
16673
16663
  const tmp = `${RUNS_PATH}.${process.pid}.${Date.now()}.tmp`;
16674
- await writeFile6(tmp, body, { mode: 384 });
16664
+ await writeFile5(tmp, body, { mode: 384 });
16675
16665
  await rename(tmp, RUNS_PATH);
16676
16666
  }
16677
16667
  async function appendRun(input) {
@@ -24153,7 +24143,7 @@ async function runLivePreview(opts) {
24153
24143
  tokens = await readTokensFromPath("tokens", tokensPath);
24154
24144
  }
24155
24145
  const manifest = buildManifest3(components, tokens, { deleteAllComponents: opts.deleteAllComponents === true });
24156
- const client2 = new EdsiApiClient({ host, cmaToken, spaceId, environmentId });
24146
+ const client2 = new ImportApiClient({ host, cmaToken, spaceId, environmentId });
24157
24147
  const startedAt = Date.now();
24158
24148
  let timeoutHandle;
24159
24149
  const timeoutPromise = new Promise((_resolve, reject) => {
@@ -27628,6 +27618,7 @@ import { jsx as jsx52, jsxs as jsxs51 } from "react/jsx-runtime";
27628
27618
  function buildSelectAgentArgs(opts) {
27629
27619
  const args = ["analyze", "select-agent", "--agent", opts.agent, "--session", opts.sessionId, "--exclude-invalid"];
27630
27620
  if (opts.model) args.push("--model", opts.model);
27621
+ if (opts.bedrock) args.push("--bedrock");
27631
27622
  if (opts.selectPromptPath) args.push("--select-prompt-path", opts.selectPromptPath);
27632
27623
  if (opts.noCache) args.push("--no-cache");
27633
27624
  return args;
@@ -27663,6 +27654,7 @@ function buildGenerateComponentsArgs(opts) {
27663
27654
  const args = ["generate", "components", "--agent", opts.agent, "--session", opts.sessionId];
27664
27655
  if (opts.tokensPath) args.push("--tokens", opts.tokensPath);
27665
27656
  if (opts.model) args.push("--model", opts.model);
27657
+ if (opts.bedrock) args.push("--bedrock");
27666
27658
  if (opts.noCache) args.push("--no-cache");
27667
27659
  if (opts.generatePromptPath) args.push("--generate-prompt-path", opts.generatePromptPath);
27668
27660
  return args;
@@ -27705,6 +27697,7 @@ function WizardApp({
27705
27697
  initialHost,
27706
27698
  initialAgent,
27707
27699
  initialModel,
27700
+ bedrock = false,
27708
27701
  initialProjectPath,
27709
27702
  host,
27710
27703
  autoAcceptScope = false,
@@ -27766,6 +27759,7 @@ function WizardApp({
27766
27759
  step: modifyEntryReady || rawTokensEntryReady || pushFromPickerReady ? initialStepResolved : initialRuns && initialRuns.length > 0 ? "run-picker" : initialStepResolved,
27767
27760
  agent: initialAgent ?? "claude",
27768
27761
  ...initialModel ? { agentModel: initialModel } : {},
27762
+ ...bedrock ? { bedrock: true } : {},
27769
27763
  projectPath: initialProjectPath ?? "",
27770
27764
  outDir: initialOutDir,
27771
27765
  rawTokensPath: rawTokensEntryReady ? initialRawTokensPath : "",
@@ -27905,6 +27899,7 @@ If you are using AWS Bedrock, run:
27905
27899
  const result = await new Promise((res) => {
27906
27900
  const tokenArgs = [findCliPath(), "generate", "tokens", "--agent", state.agent, "--raw-tokens", rawTokensPath];
27907
27901
  if (state.agentModel) tokenArgs.push("--model", state.agentModel);
27902
+ if (state.bedrock) tokenArgs.push("--bedrock");
27908
27903
  const child = spawn4("node", tokenArgs);
27909
27904
  let stdout2 = "";
27910
27905
  let stderr = "";
@@ -28025,6 +28020,7 @@ If you are using AWS Bedrock, run:
28025
28020
  if (generateMap) extractArgs.push("--generate-map", generateMap);
28026
28021
  for (const p of promptOverrides ?? []) extractArgs.push("--prompt", p);
28027
28022
  if (state.agent) extractArgs.push("--agent", state.agent);
28023
+ if (state.bedrock) extractArgs.push("--bedrock");
28028
28024
  }
28029
28025
  const child = spawn4("node", extractArgs);
28030
28026
  let stdout2 = "";
@@ -28116,6 +28112,7 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
28116
28112
  sessionId: sessionId2,
28117
28113
  agent: state.agent,
28118
28114
  ...state.agentModel ? { model: state.agentModel } : {},
28115
+ ...state.bedrock ? { bedrock: true } : {},
28119
28116
  selectPromptPath,
28120
28117
  noCache
28121
28118
  });
@@ -28214,6 +28211,7 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
28214
28211
  tokensPath,
28215
28212
  agent: state.agent,
28216
28213
  ...state.agentModel ? { model: state.agentModel } : {},
28214
+ ...state.bedrock ? { bedrock: true } : {},
28217
28215
  noCache: effectiveNoCache
28218
28216
  })
28219
28217
  ];
@@ -28283,6 +28281,7 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
28283
28281
  tokensPath,
28284
28282
  agent: state.agent,
28285
28283
  ...state.agentModel ? { model: state.agentModel } : {},
28284
+ ...state.bedrock ? { bedrock: true } : {},
28286
28285
  noCache: effectiveNoCache,
28287
28286
  generatePromptPath
28288
28287
  })
@@ -28364,7 +28363,7 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
28364
28363
  update({ step: "credentials", credentialsValidating: true, credentialsError: "" });
28365
28364
  try {
28366
28365
  const resolvedHost = resolveWizardHost(host2);
28367
- const client2 = new EdsiApiClient({
28366
+ const client2 = new ImportApiClient({
28368
28367
  cmaToken,
28369
28368
  spaceId,
28370
28369
  environmentId,
@@ -28438,7 +28437,7 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
28438
28437
  update({ step: "previewing" });
28439
28438
  const resolvedHost = resolveWizardHost(host2);
28440
28439
  try {
28441
- const client2 = new EdsiApiClient({
28440
+ const client2 = new ImportApiClient({
28442
28441
  cmaToken,
28443
28442
  spaceId,
28444
28443
  environmentId,
@@ -28600,7 +28599,7 @@ If using a custom --host, make sure the space exists on that host.`
28600
28599
  update({ step: "pushing", pushProgress: null });
28601
28600
  try {
28602
28601
  const resolvedHost = resolveWizardHost(host2);
28603
- const client2 = new EdsiApiClient({
28602
+ const client2 = new ImportApiClient({
28604
28603
  cmaToken,
28605
28604
  spaceId,
28606
28605
  environmentId,
@@ -29790,12 +29789,15 @@ import { isAbsolute as isAbsolute4, join as join15, relative as relative3, resol
29790
29789
  init_src();
29791
29790
  var AGENT_DESCRIPTION = `Agent to use: ${AGENT_NAMES.join(", ")} (defaults to value saved by experiences setup)`;
29792
29791
  var MODEL_DESCRIPTION = "Model to use (defaults to a lightweight per-agent model; override with EDS_AGENT_MODEL_<AGENT>)";
29792
+ var BEDROCK_AGENTS = AGENT_NAMES.filter((agent) => agentSupportsBedrock(agent)).join(", ");
29793
+ var BEDROCK_DESCRIPTION = `Route the selected agent through AWS Bedrock instead of its default model provider (requires AWS credentials in the environment: AWS_PROFILE, or AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY/AWS_SESSION_TOKEN, plus AWS_REGION). Only supported by agents with a Bedrock routing mechanism (currently: ${BEDROCK_AGENTS}).`;
29793
29794
  function addAgentModelOptions(cmd, config = {}) {
29794
29795
  const { agentDescription = AGENT_DESCRIPTION, includeModel = true, modelDescription = MODEL_DESCRIPTION } = config;
29795
29796
  cmd.option("--agent <name>", agentDescription);
29796
29797
  if (includeModel) {
29797
29798
  cmd.option("--model <name>", modelDescription);
29798
29799
  }
29800
+ cmd.option("--bedrock", BEDROCK_DESCRIPTION);
29799
29801
  return cmd;
29800
29802
  }
29801
29803
 
@@ -30584,6 +30586,12 @@ function registerAnalyzeSelectAgentCommand(program) {
30584
30586
  return;
30585
30587
  }
30586
30588
  const agent = agentName;
30589
+ if (opts.bedrock && !agentSupportsBedrock(agent)) {
30590
+ process.stderr.write(`Error: --bedrock is not supported for --agent ${agent}
30591
+ `);
30592
+ await exitWithAnalytics(1);
30593
+ return;
30594
+ }
30587
30595
  const selectPromptPath = opts.selectPromptPath ?? savedCreds.selectPromptPath;
30588
30596
  if (selectPromptPath) {
30589
30597
  const resolvedPath = resolve12(selectPromptPath);
@@ -31827,6 +31835,14 @@ function registerAnalyzeCommand(program) {
31827
31835
  }
31828
31836
  return v;
31829
31837
  })();
31838
+ if (opts.bedrock) {
31839
+ const bedrockAgent = resolveCompositionAgentName(opts.agent);
31840
+ if (!agentSupportsBedrock(bedrockAgent)) {
31841
+ process.stderr.write(`Error: --bedrock is not supported for --agent ${bedrockAgent}
31842
+ `);
31843
+ process.exit(1);
31844
+ }
31845
+ }
31830
31846
  const projectRoot = resolve15(opts.project);
31831
31847
  const outDir = join15(projectRoot, ".contentful");
31832
31848
  let sourceDirectory;
@@ -32673,6 +32689,9 @@ async function runGenerateSkill(skill, opts, verbose = false) {
32673
32689
  );
32674
32690
  }
32675
32691
  const agent = agentName;
32692
+ if (opts.bedrock && !agentSupportsBedrock(agent)) {
32693
+ die2(`Error: --bedrock is not supported for --agent ${agent}`);
32694
+ }
32676
32695
  const generatePromptPath = skill === "components" ? opts.generatePromptPath ?? savedCreds.generatePromptPath : void 0;
32677
32696
  if (generatePromptPath) {
32678
32697
  if (!await pathExists3(resolve17(generatePromptPath))) {
@@ -34337,6 +34356,7 @@ function registerMapTokensCommand(program) {
34337
34356
  }
34338
34357
 
34339
34358
  // packages/experience-design-system-cli/src/import/command.ts
34359
+ init_src();
34340
34360
  init_path_utils();
34341
34361
  import { resolve as resolve25, join as join25 } from "node:path";
34342
34362
 
@@ -34345,72 +34365,14 @@ init_db();
34345
34365
  init_command();
34346
34366
  init_manifest();
34347
34367
  init_api_client();
34348
- import { mkdir as mkdir5, writeFile as writeFile5 } from "node:fs/promises";
34349
- import { join as join18, resolve as resolve21 } from "node:path";
34350
- import { execFile as execFile2 } from "node:child_process";
34351
-
34352
- // packages/experience-design-system-cli/src/api/clients/cma-client.ts
34353
- init_url();
34354
- init_http();
34355
- init_api_error();
34356
- var CMA_PAGE_LIMIT = 100;
34357
- var CmaApiClient = class {
34358
- host;
34359
- token;
34360
- spaceId;
34361
- environmentId;
34362
- constructor(opts) {
34363
- this.host = toApiHost(opts.host);
34364
- this.token = opts.cmaToken;
34365
- this.spaceId = opts.spaceId;
34366
- this.environmentId = opts.environmentId;
34367
- }
34368
- base() {
34369
- return `${this.host}/spaces/${this.spaceId}/environments/${this.environmentId}`;
34370
- }
34371
- async validateToken() {
34372
- const url = `${this.host}/users/me`;
34373
- const res = await request(url, { token: this.token });
34374
- if (res.status === 401) {
34375
- throw new ApiError("CMA token is invalid or revoked", res.status, await res.text());
34376
- }
34377
- if (!res.ok) {
34378
- throw new ApiError(`unexpected error validating token: ${res.status}`, res.status, await res.text());
34379
- }
34380
- }
34381
- async listExistingEntities() {
34382
- const [components, tokens] = await Promise.all([
34383
- this.listAll("component_types", "component_types"),
34384
- this.listAll("design_tokens", "design_tokens")
34385
- ]);
34386
- return { components, tokens };
34387
- }
34388
- async listAll(resourcePath, opName) {
34389
- const items = [];
34390
- let skip = 0;
34391
- while (true) {
34392
- const url = `${this.base()}/${resourcePath}?limit=${CMA_PAGE_LIMIT}&skip=${skip}`;
34393
- const res = await request(url, { token: this.token });
34394
- if (!res.ok) {
34395
- throw new ApiError(`${opName} list failed: ${res.status}`, res.status, await res.text());
34396
- }
34397
- const page = await res.json();
34398
- items.push(...page.items);
34399
- const returned = page.items.length;
34400
- const total = page.total ?? items.length;
34401
- if (returned === 0 || items.length >= total) break;
34402
- skip += returned;
34403
- }
34404
- return items;
34405
- }
34406
- };
34407
-
34408
- // packages/experience-design-system-cli/src/import/orchestrator.ts
34409
34368
  init_contentful_urls();
34410
34369
  init_debug_logger();
34411
34370
  init_analytics();
34412
34371
  init_env();
34413
34372
  init_cli_path();
34373
+ import { mkdir as mkdir5 } from "node:fs/promises";
34374
+ import { join as join18, resolve as resolve21 } from "node:path";
34375
+ import { execFile as execFile2 } from "node:child_process";
34414
34376
  async function runStep(args, cliPath, analyticsSessionId, env = {}, streamStderr = false) {
34415
34377
  const debug = getDebugLogger();
34416
34378
  const startedAt = Date.now();
@@ -34518,66 +34480,11 @@ async function runPipeline(opts, progressWriter, cliPathOverride) {
34518
34480
  await mkdir5(outDir, { recursive: true });
34519
34481
  const steps = [];
34520
34482
  let stepNum = 0;
34521
- const wantsSpaceContext = opts.withSpaceContext === true;
34522
- const canFetchSpaceContext = wantsSpaceContext && !!opts.spaceId && !!opts.environmentId && !!opts.cmaToken;
34523
- const totalSteps = 5 + (opts.print ? 1 : 0) + (canFetchSpaceContext ? 1 : 0);
34483
+ const totalSteps = 5 + (opts.print ? 1 : 0);
34524
34484
  function stepLabel(name) {
34525
34485
  stepNum++;
34526
34486
  return ` Step ${stepNum}/${totalSteps} ${name} `;
34527
34487
  }
34528
- if (wantsSpaceContext && !canFetchSpaceContext) {
34529
- progressWriter(
34530
- " Note: --with-space-context requires --space-id, --environment-id, and --cma-token; skipping context fetch."
34531
- );
34532
- }
34533
- if (canFetchSpaceContext) {
34534
- const fetchLabel = stepLabel("Fetching existing components + design tokens");
34535
- const fetchStepId = createStep(db, sessionId2, "fetch existing entities", {
34536
- spaceId: opts.spaceId,
34537
- environmentId: opts.environmentId
34538
- });
34539
- const t0 = Date.now();
34540
- try {
34541
- const cma = new CmaApiClient({
34542
- host: opts.host,
34543
- cmaToken: opts.cmaToken,
34544
- spaceId: opts.spaceId,
34545
- environmentId: opts.environmentId
34546
- });
34547
- const result = await cma.listExistingEntities();
34548
- const fetchDurationMs = Date.now() - t0;
34549
- const existingEntitiesPath = join18(outDir, ".existing-entities.json");
34550
- await writeFile5(existingEntitiesPath, JSON.stringify(result, null, 2), "utf8");
34551
- updateStep(db, fetchStepId, "complete", {
34552
- components: String(result.components.length),
34553
- tokens: String(result.tokens.length),
34554
- path: existingEntitiesPath
34555
- });
34556
- progressWriter(
34557
- `${fetchLabel}\u2713 ${result.components.length} component${result.components.length === 1 ? "" : "s"}, ${result.tokens.length} token${result.tokens.length === 1 ? "" : "s"} (${(fetchDurationMs / 1e3).toFixed(1)}s)`
34558
- );
34559
- steps.push({
34560
- step: "fetch existing entities",
34561
- status: "complete",
34562
- durationMs: fetchDurationMs,
34563
- detail: { components: result.components.length, tokens: result.tokens.length }
34564
- });
34565
- } catch (error) {
34566
- const fetchDurationMs = Date.now() - t0;
34567
- const message = error instanceof Error ? error.message : String(error);
34568
- updateStep(db, fetchStepId, "failed", {}, message);
34569
- progressWriter(
34570
- `${fetchLabel}\u26A0 fetch failed, continuing without space context (${(fetchDurationMs / 1e3).toFixed(1)}s)`
34571
- );
34572
- progressWriter(` ${message.split("\n")[0]}`);
34573
- steps.push({
34574
- step: "fetch existing entities",
34575
- status: "failed",
34576
- durationMs: fetchDurationMs,
34577
- error: message
34578
- });
34579
- }
34580
- }
34581
34488
  const analyzeLabel = stepLabel("Statically analyzing project");
34582
34489
  const analyzeSkipped = !opts.noCache && opts.skipAnalyze;
34583
34490
  let extractSessionId = null;
@@ -34605,6 +34512,7 @@ async function runPipeline(opts, progressWriter, cliPathOverride) {
34605
34512
  if (opts.generateMap) analyzeArgs.push("--generate-map", opts.generateMap);
34606
34513
  for (const p of opts.promptOverrides ?? []) analyzeArgs.push("--prompt", p);
34607
34514
  if (opts.agent) analyzeArgs.push("--agent", opts.agent);
34515
+ if (opts.bedrock) analyzeArgs.push("--bedrock");
34608
34516
  }
34609
34517
  const r = await runStep(analyzeArgs, cliPath, sessionId2);
34610
34518
  const durationMs = Date.now() - t0;
@@ -34655,6 +34563,7 @@ async function runPipeline(opts, progressWriter, cliPathOverride) {
34655
34563
  if (useAgentSelect) {
34656
34564
  editArgs = ["analyze", "select-agent", "--session", extractSessionId, "--agent", opts.agent];
34657
34565
  if (opts.model) editArgs.push("--model", opts.model);
34566
+ if (opts.bedrock) editArgs.push("--bedrock");
34658
34567
  if (opts.excludeInvalid) editArgs.push("--exclude-invalid");
34659
34568
  if (opts.noCache) editArgs.push("--no-cache");
34660
34569
  if (opts.selectPromptPath) editArgs.push("--select-prompt-path", opts.selectPromptPath);
@@ -34716,6 +34625,7 @@ async function runPipeline(opts, progressWriter, cliPathOverride) {
34716
34625
  const generateLabel = stepLabel("Categorizing component props");
34717
34626
  const generateArgs = ["generate", "components", "--agent", opts.agent];
34718
34627
  if (opts.model) generateArgs.push("--model", opts.model);
34628
+ if (opts.bedrock) generateArgs.push("--bedrock");
34719
34629
  if (extractSessionId) generateArgs.push("--session", extractSessionId);
34720
34630
  if (opts.dryRun) generateArgs.push("--dry-run");
34721
34631
  if (opts.verbose) generateArgs.push("--verbose");
@@ -35529,10 +35439,7 @@ function registerImportCommand(program) {
35529
35439
  "Override a stage prompt (repeatable). value is a file path or literal text, e.g. --prompt composition=./p.md",
35530
35440
  (v, acc) => [...acc, v],
35531
35441
  []
35532
- ).option("--auto-reject-cycles", "Automatically reject components involved in slot cycles and retry").option(
35533
- "--with-space-context",
35534
- "Fetch existing Components + DesignTokens from the target space+env and persist them under <out>/.existing-entities.json for future agent-context enrichment. Requires --space-id, --environment-id, and --cma-token."
35535
- ).option("--auto-filter", "Force the AI auto-filter ON (overrides the credentials.json autoFilter preference)").option(
35442
+ ).option("--auto-reject-cycles", "Automatically reject components involved in slot cycles and retry").option("--auto-filter", "Force the AI auto-filter ON (overrides the credentials.json autoFilter preference)").option(
35536
35443
  "--no-auto-filter",
35537
35444
  "Skip the automatic AI pre-filter; jump straight to manual scope-gate (overrides the credentials.json autoFilter preference; no-op when paired with --auto-accept-scope)"
35538
35445
  ).option(
@@ -35749,6 +35656,11 @@ function registerImportCommand(program) {
35749
35656
  const resolvedAgent = resolveAgent(opts.agent, creds.agent);
35750
35657
  const resolvedModel = resolveModel(opts.model, creds.agentModel);
35751
35658
  const resolvedCompositionMode = resolveCompositionMode(opts, creds.compositionMode);
35659
+ if (opts.bedrock && !(isAgentName(resolvedAgent) && agentSupportsBedrock(resolvedAgent))) {
35660
+ process.stderr.write(`Error: --bedrock is not supported for --agent ${resolvedAgent}
35661
+ `);
35662
+ process.exit(1);
35663
+ }
35752
35664
  const pickerDecision = await shouldShowRunPicker({
35753
35665
  flags: {
35754
35666
  ...opts.pushFromRun !== void 0 ? { pushFromRun: opts.pushFromRun } : {},
@@ -35777,6 +35689,7 @@ function registerImportCommand(program) {
35777
35689
  initialHost: toConfiguredHost(opts.host ?? creds.host) ?? DEFAULT_CONFIGURED_HOST,
35778
35690
  initialAgent: resolvedAgent,
35779
35691
  ...resolvedModel ? { initialModel: resolvedModel } : {},
35692
+ ...opts.bedrock ? { bedrock: true } : {},
35780
35693
  initialProjectPath: opts.project !== "." ? normalizePath(opts.project) : void 0,
35781
35694
  host: opts.host,
35782
35695
  autoAcceptScope,
@@ -35840,6 +35753,11 @@ function registerImportCommand(program) {
35840
35753
  const headlessAgent = resolveAgent(opts.agent, headlessCreds.agent);
35841
35754
  const headlessModel = resolveModel(opts.model, headlessCreds.agentModel);
35842
35755
  const headlessCompositionMode = resolveCompositionMode(opts, headlessCreds.compositionMode);
35756
+ if (opts.bedrock && !(isAgentName(headlessAgent) && agentSupportsBedrock(headlessAgent))) {
35757
+ process.stderr.write(`Error: --bedrock is not supported for --agent ${headlessAgent}
35758
+ `);
35759
+ process.exit(1);
35760
+ }
35843
35761
  const result = await runPipeline(
35844
35762
  {
35845
35763
  project: projectRoot,
@@ -35849,6 +35767,7 @@ function registerImportCommand(program) {
35849
35767
  cmaToken,
35850
35768
  agent: headlessAgent,
35851
35769
  model: headlessModel,
35770
+ ...opts.bedrock ? { bedrock: true } : {},
35852
35771
  tokens: opts.tokens,
35853
35772
  selectAll: opts.selectAll,
35854
35773
  select: opts.select.length > 0 ? opts.select : void 0,
@@ -35867,7 +35786,6 @@ function registerImportCommand(program) {
35867
35786
  dryRun: dryRunForward,
35868
35787
  selectPromptPath: opts.selectPromptPath,
35869
35788
  autoRejectCycles: opts.autoRejectCycles ?? false,
35870
- withSpaceContext: opts.withSpaceContext ?? false,
35871
35789
  allowDeletions: opts.allowDeletions ?? false,
35872
35790
  compositionMode: headlessCompositionMode,
35873
35791
  ...opts.compositionMap ? { compositionMap: opts.compositionMap } : {},
@@ -36987,6 +36905,13 @@ async function runBuild(opts) {
36987
36905
  child.on("exit", (code) => settle(code ?? 1));
36988
36906
  });
36989
36907
  }
36908
+ function resolveBedrockFromAncestors(actionCommand) {
36909
+ for (let c2 = actionCommand; c2; c2 = c2.parent) {
36910
+ const opts = c2.opts();
36911
+ if (opts.bedrock) return true;
36912
+ }
36913
+ return false;
36914
+ }
36990
36915
  function registerImportV2Command(program) {
36991
36916
  program.command("importv2").description("Launch the v2 import TUI (experience-design-system-cli-v2)").action(async () => {
36992
36917
  const { render: render7 } = await import("ink");
@@ -37034,6 +36959,9 @@ function createProgram() {
37034
36959
  break;
37035
36960
  }
37036
36961
  }
36962
+ if (resolveBedrockFromAncestors(actionCommand)) {
36963
+ process.env.EDS_BEDROCK = "1";
36964
+ }
37037
36965
  const chain = [];
37038
36966
  for (let c2 = actionCommand; c2 && c2.parent; c2 = c2.parent) chain.unshift(c2.name());
37039
36967
  const commandChain = chain.join(" ") || actionCommand.name();
@@ -1,13 +1,16 @@
1
1
  import type { Command } from 'commander';
2
2
  export declare const AGENT_DESCRIPTION: string;
3
3
  export declare const MODEL_DESCRIPTION = "Model to use (defaults to a lightweight per-agent model; override with EDS_AGENT_MODEL_<AGENT>)";
4
+ export declare const BEDROCK_DESCRIPTION: string;
4
5
  export interface AgentModelOptionsConfig {
5
6
  agentDescription?: string;
6
7
  includeModel?: boolean;
7
8
  modelDescription?: string;
8
9
  }
9
10
  /**
10
- * Register --agent and optionally --model flags to a Commander command, with customizable descriptions.
11
- * Pass `includeModel: false` for commands where the model dimension is not applicable (e.g., mapping-resolution agents that select an agent for logic, not model choice).
11
+ * Register --agent, --bedrock, and optional --model flags with a Commander
12
+ * command. Pass includeModel: false to omit --model only — --bedrock is
13
+ * independent of model selection (it's a routing switch, not a model choice)
14
+ * and is always registered alongside --agent.
12
15
  */
13
16
  export declare function addAgentModelOptions(cmd: Command, config?: AgentModelOptionsConfig): Command;
@@ -15,5 +15,11 @@ export declare function runBuild(opts: {
15
15
  }): Promise<{
16
16
  exitCode: number;
17
17
  }>;
18
+ /**
19
+ * Walks `actionCommand` and its ancestors for a truthy `--bedrock`. --bedrock
20
+ * is registered per-subcommand (not at program scope, unlike --debug), so a
21
+ * root-level or subcommand-level setting can each carry it.
22
+ */
23
+ export declare function resolveBedrockFromAncestors(actionCommand: Command): boolean;
18
24
  export declare function createProgram(): Command;
19
25
  export {};
@@ -5,7 +5,7 @@ import type { ToolCall, TokenToolCall, ComponentSourceRef } from '@contentful/ex
5
5
  import type { ComponentTypeSummary } from '@contentful/experience-design-system-types';
6
6
  import type { SlotCycle, SlotEdge } from '../analyze/cycle-detection.js';
7
7
  export type StepStatus = 'pending' | 'complete' | 'failed' | 'interrupted';
8
- export type CommandName = 'analyze extract' | 'analyze select' | 'generate components' | 'generate tokens' | 'generate edit' | 'apply preview' | 'apply select' | 'apply push' | 'print components' | 'print tokens' | 'map tokens' | 'fetch existing entities' | 'import';
8
+ export type CommandName = 'analyze extract' | 'analyze select' | 'generate components' | 'generate tokens' | 'generate edit' | 'apply preview' | 'apply select' | 'apply push' | 'print components' | 'print tokens' | 'map tokens' | 'import';
9
9
  export interface SessionRow {
10
10
  id: string;
11
11
  name: string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-cli",
3
- "version": "2.32.1-dev-build-81eb804.0",
3
+ "version": "2.32.1-dev-build-3e401c3.0",
4
4
  "description": "Contentful Experiences design system import CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -39,8 +39,8 @@
39
39
  "svelte": "^5.56.4",
40
40
  "ts-morph": "^27.0.2",
41
41
  "typescript": "^5.9.3",
42
- "@contentful/experience-design-system-cli-v2": "2.32.1-dev-build-81eb804.0",
43
- "@contentful/experience-design-system-types": "2.32.1-dev-build-81eb804.0"
42
+ "@contentful/experience-design-system-cli-v2": "2.32.1-dev-build-3e401c3.0",
43
+ "@contentful/experience-design-system-types": "2.32.1-dev-build-3e401c3.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@tsconfig/node24": "^24.0.4",
@@ -52,9 +52,9 @@
52
52
  "ink-testing-library": "^4.0.0",
53
53
  "typescript-eslint": "^8.67.0",
54
54
  "vitest": "^4.0.16",
55
- "@contentful/experience-design-system-client": "2.32.1-dev-build-81eb804.0",
56
- "@contentful/experience-design-system-generation": "2.32.1-dev-build-81eb804.0",
57
- "@contentful/experience-design-system-extraction": "2.32.1-dev-build-81eb804.0"
55
+ "@contentful/experience-design-system-client": "2.32.1-dev-build-3e401c3.0",
56
+ "@contentful/experience-design-system-generation": "2.32.1-dev-build-3e401c3.0",
57
+ "@contentful/experience-design-system-extraction": "2.32.1-dev-build-3e401c3.0"
58
58
  },
59
59
  "repository": {
60
60
  "type": "git",
@@ -1,13 +0,0 @@
1
- import type { CmaClientOptions } from '../../interfaces/clients/cma-client-options.js';
2
- import type { ExistingEntitiesResponse } from '../../interfaces/responses/existing-entities-response.js';
3
- export declare class CmaApiClient {
4
- private host;
5
- private token;
6
- private spaceId;
7
- private environmentId;
8
- constructor(opts: CmaClientOptions);
9
- private base;
10
- validateToken(): Promise<void>;
11
- listExistingEntities(): Promise<ExistingEntitiesResponse>;
12
- private listAll;
13
- }
@@ -1,47 +0,0 @@
1
- import type { ManifestPayload, ServerPreviewResponse, ApplyOperationResponse, BreakingChange } from '@contentful/experience-design-system-types';
2
- import type { EdsiClientOptions } from '../../interfaces/clients/edsi-client-options.js';
3
- import type { PollOptions } from '../../interfaces/clients/poll-options.js';
4
- export declare const DEFAULT_HOST = "https://api.contentful.com";
5
- export declare const PREVIEW_ERROR_PREFIX = "preview failed:";
6
- export declare const APPLY_ERROR_PREFIX = "apply failed:";
7
- export declare const VALIDATION_FAILED_CODE = "\"ValidationFailed\"";
8
- export interface PreviewValidationError {
9
- componentName: string;
10
- path: string;
11
- message: string;
12
- }
13
- /**
14
- * Parse the JSON body of a 422 from `previewImport()` into structured
15
- * per-component validation errors. Returns [] for any malformed input
16
- * so callers can fall back to the generic error path without try/catch.
17
- *
18
- * Path shape: `manifest:components/<Name>/$slots/<key>` or
19
- * `manifest:components/<Name>/$properties/<key>`. Only the component
20
- * name is extracted today; `path` and `message` are kept verbatim so
21
- * future surfaces (debug logging, headless retry in SP-4) can render
22
- * the field-level detail.
23
- */
24
- export declare function parsePreviewValidationErrors(body: string): PreviewValidationError[];
25
- export declare function sanitizeBreakingChanges(raw: unknown): BreakingChange[];
26
- export declare class EdsiApiClient {
27
- private host;
28
- private token;
29
- private spaceId;
30
- private environmentId;
31
- private retry;
32
- private lastRequestId?;
33
- getLastRequestId(): string | undefined;
34
- private noteRequestId;
35
- constructor(opts: EdsiClientOptions);
36
- private base;
37
- private headers;
38
- private requestWithRetry;
39
- validateToken(): Promise<void>;
40
- checkPreflight(): Promise<void>;
41
- previewImport(manifest: ManifestPayload, allowDeletions?: boolean): Promise<ServerPreviewResponse>;
42
- applyImport(manifest: ManifestPayload, options: {
43
- acknowledgeBreakingChanges: boolean;
44
- allowDeletions?: boolean;
45
- }): Promise<ApplyOperationResponse>;
46
- pollOperation(operationId: string, opts?: PollOptions): Promise<ApplyOperationResponse>;
47
- }
@@ -1,10 +0,0 @@
1
- export { CmaApiClient } from './clients/cma-client.js';
2
- export { EdsiApiClient, DEFAULT_HOST, PREVIEW_ERROR_PREFIX, APPLY_ERROR_PREFIX, VALIDATION_FAILED_CODE, parsePreviewValidationErrors, sanitizeBreakingChanges, } from './clients/edsi-client.js';
3
- export type { PreviewValidationError } from './clients/edsi-client.js';
4
- export { ApiError } from '../errors/api-error.js';
5
- export type { CmaClientOptions } from '../interfaces/clients/cma-client-options.js';
6
- export type { EdsiClientOptions } from '../interfaces/clients/edsi-client-options.js';
7
- export type { PollOptions } from '../interfaces/clients/poll-options.js';
8
- export type { ExistingComponentEntity } from '../interfaces/responses/existing-component-entity.js';
9
- export type { ExistingTokenEntity } from '../interfaces/responses/existing-token-entity.js';
10
- export type { ExistingEntitiesResponse } from '../interfaces/responses/existing-entities-response.js';
@@ -1,6 +0,0 @@
1
- export declare class ApiError extends Error {
2
- readonly status: number;
3
- readonly body: string;
4
- readonly guidance?: string | undefined;
5
- constructor(message: string, status: number, body: string, guidance?: string | undefined);
6
- }
@@ -1,4 +0,0 @@
1
- export declare function buildHeaders(token: string): Record<string, string>;
2
- export declare function request(url: string, options: RequestInit & {
3
- token: string;
4
- }): Promise<Response>;
@@ -1,4 +0,0 @@
1
- export declare const DEFAULT_API_HOST = "https://api.contentful.com";
2
- export declare const DEFAULT_CONFIGURED_HOST = "api.contentful.com";
3
- export declare function toConfiguredHost(host?: string): string | undefined;
4
- export declare function toApiHost(host?: string): string;
@@ -1,6 +0,0 @@
1
- export interface CmaClientOptions {
2
- host?: string;
3
- cmaToken: string;
4
- spaceId: string;
5
- environmentId: string;
6
- }
@@ -1,12 +0,0 @@
1
- export interface EdsiClientOptions {
2
- host?: string;
3
- cmaToken: string;
4
- spaceId: string;
5
- environmentId: string;
6
- retry?: {
7
- maxAttempts?: number;
8
- initialDelayMs?: number;
9
- maxDelayMs?: number;
10
- sleep?: (delayMs: number) => Promise<void>;
11
- };
12
- }
@@ -1,7 +0,0 @@
1
- import type { ApplyOperationResponse } from '@contentful/experience-design-system-types';
2
- export interface PollOptions {
3
- intervalMs?: number;
4
- maxIntervalMs?: number;
5
- maxAttempts?: number;
6
- onProgress?: (op: ApplyOperationResponse) => void;
7
- }
@@ -1,8 +0,0 @@
1
- export interface ExistingComponentEntity {
2
- id: string;
3
- name: string;
4
- description?: string;
5
- contentProperties?: unknown[];
6
- designProperties?: unknown[];
7
- slots?: unknown[];
8
- }
@@ -1,6 +0,0 @@
1
- import type { ExistingComponentEntity } from './existing-component-entity.js';
2
- import type { ExistingTokenEntity } from './existing-token-entity.js';
3
- export interface ExistingEntitiesResponse {
4
- components: ExistingComponentEntity[];
5
- tokens: ExistingTokenEntity[];
6
- }
@@ -1,6 +0,0 @@
1
- export interface ExistingTokenEntity {
2
- id: string;
3
- name: string;
4
- kind: string;
5
- value?: unknown;
6
- }