cdk-local 0.124.2 → 0.125.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.
@@ -18790,6 +18790,76 @@ function isTransientNetworkError(err) {
18790
18790
  */
18791
18791
  const WS_PATH = "/ws";
18792
18792
  /**
18793
+ * Decode a `ws` {@link RawData} frame to UTF-8 text. `ws` delivers a Buffer by
18794
+ * default (binaryType 'nodebuffer'); handle the fragments / ArrayBuffer shapes
18795
+ * too so a frame is always decoded the same way regardless of source.
18796
+ */
18797
+ function decodeWsFrame(data) {
18798
+ return (Buffer.isBuffer(data) ? data : Array.isArray(data) ? Buffer.concat(data) : Buffer.from(data)).toString("utf-8");
18799
+ }
18800
+ /**
18801
+ * Open `ws://host:port/ws` with the AgentCore session-id (+ optional
18802
+ * `Authorization`) upgrade header and return a handle for bidirectional
18803
+ * frame relay. Sends NO initial frame — the caller drives every frame. Each
18804
+ * received frame is decoded to UTF-8 and passed to {@link
18805
+ * BridgeAgentCoreWsOptions.onMessage}.
18806
+ */
18807
+ function bridgeAgentCoreWs(host, port, options) {
18808
+ const ws = new (options.webSocketImpl ?? WebSocket)(`ws://${host}:${port}${WS_PATH}`, { headers: {
18809
+ [AGENTCORE_SESSION_ID_HEADER]: options.sessionId,
18810
+ ...options.authorization && { Authorization: options.authorization }
18811
+ } });
18812
+ let open = false;
18813
+ let closed = false;
18814
+ const pending = [];
18815
+ const close = () => {
18816
+ if (closed) return;
18817
+ closed = true;
18818
+ options.abortSignal?.removeEventListener("abort", close);
18819
+ try {
18820
+ ws.close();
18821
+ } catch {}
18822
+ };
18823
+ if (options.abortSignal) if (options.abortSignal.aborted) close();
18824
+ else options.abortSignal.addEventListener("abort", close, { once: true });
18825
+ const sendFrame = (text) => {
18826
+ try {
18827
+ ws.send(text);
18828
+ } catch (err) {
18829
+ options.onError?.(err instanceof Error ? err : new Error(String(err)));
18830
+ }
18831
+ };
18832
+ ws.on("open", () => {
18833
+ open = true;
18834
+ if (closed) {
18835
+ try {
18836
+ ws.close();
18837
+ } catch {}
18838
+ return;
18839
+ }
18840
+ options.onOpen?.();
18841
+ for (const frame of pending.splice(0)) sendFrame(frame);
18842
+ });
18843
+ ws.on("message", (data) => options.onMessage(decodeWsFrame(data)));
18844
+ ws.on("close", (code) => {
18845
+ closed = true;
18846
+ options.abortSignal?.removeEventListener("abort", close);
18847
+ options.onClose?.(code);
18848
+ });
18849
+ ws.on("error", (err) => options.onError?.(err));
18850
+ return {
18851
+ send: (text) => {
18852
+ if (closed) return;
18853
+ if (!open) {
18854
+ pending.push(text);
18855
+ return;
18856
+ }
18857
+ sendFrame(text);
18858
+ },
18859
+ close
18860
+ };
18861
+ }
18862
+ /**
18793
18863
  * Open `/ws`, send the event as the first frame, stream received frames to
18794
18864
  * `onMessage`, and resolve when the server closes. Rejects on a connection
18795
18865
  * error or when `timeoutMs` elapses before the server closes.
@@ -27417,7 +27487,7 @@ function resolveAlbFrontDoor(stack, albLogicalId) {
27417
27487
  if (resource.Type !== LISTENER_TYPE) continue;
27418
27488
  const props = resource.Properties ?? {};
27419
27489
  if (refOf(props["LoadBalancerArn"]) !== albLogicalId) continue;
27420
- const port = parsePort(props["Port"]);
27490
+ const port = parsePort$1(props["Port"]);
27421
27491
  if (port === void 0) continue;
27422
27492
  const protocol = typeof props["Protocol"] === "string" ? props["Protocol"] : "HTTP";
27423
27493
  if (protocol !== "HTTP" && protocol !== "HTTPS") {
@@ -27866,7 +27936,7 @@ function refOf(raw) {
27866
27936
  if (typeof ref === "string" && ref.length > 0) return ref;
27867
27937
  }
27868
27938
  }
27869
- function parsePort(raw) {
27939
+ function parsePort$1(raw) {
27870
27940
  if (typeof raw === "number" && Number.isInteger(raw) && raw >= 1 && raw <= 65535) return raw;
27871
27941
  if (typeof raw === "string" && /^\d+$/.test(raw)) {
27872
27942
  const n = parseInt(raw, 10);
@@ -27874,7 +27944,7 @@ function parsePort(raw) {
27874
27944
  }
27875
27945
  }
27876
27946
  function parseContainerPort(raw) {
27877
- return parsePort(raw);
27947
+ return parsePort$1(raw);
27878
27948
  }
27879
27949
  /**
27880
27950
  * Parse a `ForwardConfig.TargetGroups[].Weight`. ALB weights are 0-999; a
@@ -30612,6 +30682,288 @@ function addStartCloudFrontSpecificOptions(cmd) {
30612
30682
  return cmd.addOption(new Option("--port <port>", "HTTP server port (default: auto-allocate)").default("0")).addOption(new Option("--host <host>", "Bind address").default("127.0.0.1")).addOption(new Option("--origin <originId=dir>", "Point a distribution origin at a local directory (repeatable). Use when cdk-local cannot resolve the origin's BucketDeployment source automatically (content uploaded out of band, or a non-CDK bucket).").argParser((value, prev) => [...prev ?? [], value])).addOption(new Option("--kvs-file <kvsLogicalId=file.json>", "Back a CloudFront Function's KeyValueStore reads (cf.kvs().get()) with a local JSON map (repeatable). The key is the AWS::CloudFront::KeyValueStore resource logical id; the file is a flat { \"key\": \"value\" } object. The AWS-free alternative to --from-cfn-stack, which instead reads the deployed store via the GetKey API.").argParser((value, prev) => [...prev ?? [], value])).addOption(new Option("--tls", "Terminate real TLS (HTTPS). Uses --tls-cert / --tls-key when supplied, else an auto-generated self-signed cert.").default(false)).addOption(new Option("--tls-cert <path>", "PEM server certificate for --tls (implies --tls).")).addOption(new Option("--tls-key <path>", "PEM server private key for --tls (implies --tls).")).addOption(new Option("--no-pull", "Skip 'docker pull' for a Lambda Function URL origin's base image (use the locally cached image).")).addOption(new Option("--from-cfn-stack [cfn-stack-name]", "Bind to a deployed CloudFormation stack (ListStackResources). Resolves an S3 origin that has no local BucketDeployment source to its deployed bucket and serves it from real S3 on demand (the front/back-split case: files uploaded out of band), and resolves a Lambda Function URL / Lambda@Edge function's env vars to the deployed physical IDs / exports. Use for CDK apps deployed via the upstream CDK CLI (`cdk deploy`). Bare form uses the resolved stack name; pass a value when the CFn stack name differs.")).addOption(new Option("--cache-origin", "For a deployed-S3 origin (served from real S3 under --from-cfn-stack): keep fetched objects in memory for the session instead of re-reading on every request. Faster repeat reads / fewer S3 GETs, but an out-of-band S3 content change is not reflected until a --watch reload (which clears the cache) or a restart. Off by default (every request re-reads, always current). Not CloudFront CDN caching.").default(false)).addOption(new Option("--stack-region <region>", "Region of the state record to read. Used with --from-cfn-stack as the CFn client region.")).addOption(new Option("--assume-role [arn]", "Assume a Lambda Function URL origin's deployed execution role and forward STS-issued temp credentials into its container so the handler runs with the deployed permissions. Three forms: `--assume-role <arn>` (explicit ARN); `--assume-role` (bare, auto-resolves from state — requires --from-cfn-stack); `--no-assume-role` (opt out). Off by default (the dev shell credentials are forwarded).")).addOption(new Option("--watch", "Hot-reload: re-synth + re-resolve the distribution when the CDK app's source changes (honors cdk.json watch.include/exclude; cdk.out, node_modules, .git are always excluded). The server keeps the previous version serving when synth fails mid-reload.").default(false));
30613
30683
  }
30614
30684
 
30685
+ //#endregion
30686
+ //#region src/local/agentcore-ws-bridge.ts
30687
+ /**
30688
+ * Host-side WebSocket bridge in front of an AgentCore runtime's container
30689
+ * `/ws` endpoint, the serving primitive behind `cdkl start-agentcore`.
30690
+ *
30691
+ * Why a bridge instead of pointing a client straight at the published
30692
+ * container port: the AgentCore `/ws` upgrade requires the
30693
+ * `X-Amzn-Bedrock-AgentCore-Runtime-Session-Id` header (and `Authorization`
30694
+ * under a `customJwtAuthorizer`), but a browser `WebSocket` cannot set custom
30695
+ * request headers. So a browser console connects to THIS header-less bridge,
30696
+ * and the bridge opens a `ws` connection to the container with the headers
30697
+ * injected (via {@link bridgeAgentCoreWs}), piping frames both ways.
30698
+ *
30699
+ * One container connection per inbound client connection; each inbound client
30700
+ * gets its own AgentCore session id (a fresh UUID, unless one is pinned) so a
30701
+ * browser tab is its own session — the way the cloud front door scopes them.
30702
+ */
30703
+ const DEFAULT_PATH = "/ws";
30704
+ function decodeBrowserFrame(data, isBinary) {
30705
+ if (typeof data === "string") return data;
30706
+ return (Buffer.isBuffer(data) ? data : Array.isArray(data) ? Buffer.concat(data) : Buffer.from(data)).toString("utf-8");
30707
+ }
30708
+ /**
30709
+ * Start the bridge server. Resolves once it is listening; the returned handle
30710
+ * carries the connectable `url` and a `close()` that tears down the server and
30711
+ * every live bridged connection.
30712
+ */
30713
+ function startAgentCoreWsBridge(config) {
30714
+ const host = config.host ?? "127.0.0.1";
30715
+ const path = config.path ?? DEFAULT_PATH;
30716
+ const httpServer = createServer$1((_req, res) => {
30717
+ res.writeHead(426, { "Content-Type": "text/plain" });
30718
+ res.end("Upgrade required: connect over WebSocket.\n");
30719
+ });
30720
+ const wss = new WebSocketServer({
30721
+ server: httpServer,
30722
+ path
30723
+ });
30724
+ const liveCloses = /* @__PURE__ */ new Set();
30725
+ wss.on("connection", (browser) => {
30726
+ const sessionId = config.sessionId ?? randomUUID();
30727
+ const handle = bridgeAgentCoreWs(config.containerHost, config.containerPort, {
30728
+ sessionId,
30729
+ ...config.authorization && { authorization: config.authorization },
30730
+ ...config.webSocketImpl && { webSocketImpl: config.webSocketImpl },
30731
+ onMessage: (text) => {
30732
+ if (browser.readyState === browser.OPEN) browser.send(text);
30733
+ },
30734
+ onClose: () => {
30735
+ try {
30736
+ browser.close();
30737
+ } catch {}
30738
+ },
30739
+ onError: (err) => {
30740
+ if (browser.readyState === browser.OPEN) try {
30741
+ browser.send(`[bridge error] ${err.message}`);
30742
+ } catch {}
30743
+ try {
30744
+ browser.close();
30745
+ } catch {}
30746
+ }
30747
+ });
30748
+ liveCloses.add(handle.close);
30749
+ browser.on("message", (data, isBinary) => {
30750
+ handle.send(decodeBrowserFrame(data, isBinary));
30751
+ });
30752
+ browser.on("close", () => {
30753
+ liveCloses.delete(handle.close);
30754
+ handle.close();
30755
+ });
30756
+ browser.on("error", () => {
30757
+ liveCloses.delete(handle.close);
30758
+ handle.close();
30759
+ });
30760
+ });
30761
+ return new Promise((resolve, reject) => {
30762
+ httpServer.once("error", reject);
30763
+ httpServer.listen(config.port ?? 0, host, () => {
30764
+ httpServer.removeListener("error", reject);
30765
+ httpServer.on("error", (err) => getLogger().debug(`agentcore-ws bridge server error: ${err.message}`));
30766
+ const port = httpServer.address().port;
30767
+ resolve({
30768
+ url: `ws://${host}:${port}${path}`,
30769
+ port,
30770
+ close: () => new Promise((res) => {
30771
+ for (const closeLeg of liveCloses) closeLeg();
30772
+ liveCloses.clear();
30773
+ wss.close(() => httpServer.close(() => res()));
30774
+ })
30775
+ });
30776
+ });
30777
+ });
30778
+ }
30779
+
30780
+ //#endregion
30781
+ //#region src/cli/commands/local-start-agentcore.ts
30782
+ /**
30783
+ * Parser for `--port <n>`. Accepts 0 (OS-assigned) through 65535.
30784
+ */
30785
+ function parsePort(raw) {
30786
+ const n = Number(raw);
30787
+ if (!Number.isInteger(n) || n < 0 || n > 65535) throw new CdkLocalError(`--port must be an integer 0-65535, got '${raw}'.`, "INVALID_PORT");
30788
+ return n;
30789
+ }
30790
+ /**
30791
+ * Reject MCP / A2A runtimes: the `/ws` WebSocket endpoint this command serves
30792
+ * exists only on the HTTP / AGUI protocols. MCP (`POST /mcp`) and A2A
30793
+ * (`POST /`) are single-shot request/response contracts with no bidirectional
30794
+ * socket. Exported so a unit test can drive the gate without the Docker
30795
+ * pipeline.
30796
+ */
30797
+ function assertAgentCoreWsServable(resolved) {
30798
+ if (resolved.protocol === "MCP" || resolved.protocol === "A2A") throw new CdkLocalError(`${getEmbedConfig().cliName} start-agentcore serves the HTTP / AGUI /ws WebSocket endpoint, but '${resolved.logicalId}' is a ${resolved.protocol} runtime, which has no /ws. Use \`${getEmbedConfig().cliName} invoke-agentcore\` for ${resolved.protocol} runtimes.`, "LOCAL_START_AGENTCORE_PROTOCOL_UNSUPPORTED");
30799
+ }
30800
+ /**
30801
+ * `cdkl start-agentcore <target>` — boot a Bedrock AgentCore Runtime container
30802
+ * locally and serve its bidirectional `/ws` WebSocket endpoint behind a
30803
+ * long-running host bridge, so a browser (or any WebSocket client) can hold an
30804
+ * interactive multi-frame session against it.
30805
+ *
30806
+ * Why a bridge rather than the published container port directly: the
30807
+ * AgentCore `/ws` upgrade requires the session-id (and, under a
30808
+ * `customJwtAuthorizer`, `Authorization`) header, which a browser `WebSocket`
30809
+ * cannot set. The bridge accepts a header-less client and injects those
30810
+ * headers on the container leg. HTTP / AGUI protocols only — MCP / A2A
30811
+ * runtimes have no `/ws`.
30812
+ *
30813
+ * The container is booted once via the SAME image / env / auth resolution as
30814
+ * `cdkl invoke-agentcore`; the process then blocks until SIGINT / SIGTERM,
30815
+ * tearing down the bridge and the container.
30816
+ */
30817
+ async function localStartAgentCoreCommand(target, options, extraStateProviders) {
30818
+ const logger = getLogger();
30819
+ if (options.verbose) logger.setLevel("debug");
30820
+ let containerId;
30821
+ let stopLogs;
30822
+ let bridge;
30823
+ let profileCredsFile;
30824
+ let stateProvider;
30825
+ let shuttingDown = false;
30826
+ let tornDown = false;
30827
+ const teardown = async () => {
30828
+ if (tornDown) return;
30829
+ tornDown = true;
30830
+ if (bridge) try {
30831
+ await bridge.close();
30832
+ } catch (err) {
30833
+ logger.debug(`bridge close failed: ${err instanceof Error ? err.message : String(err)}`);
30834
+ }
30835
+ if (stopLogs) try {
30836
+ stopLogs();
30837
+ } catch (err) {
30838
+ logger.debug(`streamLogs stop failed: ${err instanceof Error ? err.message : String(err)}`);
30839
+ }
30840
+ if (containerId) try {
30841
+ await removeContainer(containerId);
30842
+ } catch (err) {
30843
+ logger.debug(`removeContainer(${containerId}) failed: ${err instanceof Error ? err.message : String(err)}`);
30844
+ }
30845
+ if (stateProvider) try {
30846
+ stateProvider.dispose();
30847
+ } catch {}
30848
+ if (profileCredsFile) try {
30849
+ await profileCredsFile.dispose();
30850
+ } catch {}
30851
+ };
30852
+ await applyRoleArnIfSet({
30853
+ roleArn: options.roleArn,
30854
+ region: options.region,
30855
+ profile: options.profile
30856
+ });
30857
+ await ensureDockerAvailable();
30858
+ const profileCredentials = options.profile ? await resolveProfileCredentials(options.profile) : void 0;
30859
+ if (options.profile && profileCredentials) profileCredsFile = await writeProfileCredentialsFile(options.profile, profileCredentials);
30860
+ const appCmd = resolveApp(options.app);
30861
+ if (!appCmd) throw new Error(`No CDK app specified. Pass --app, set ${getEmbedConfig().envPrefix}_APP, or add "app" to cdk.json.`);
30862
+ logger.info("Synthesizing CDK app...");
30863
+ const synthesizer = new Synthesizer();
30864
+ const context = parseContextOptions(options.context);
30865
+ const synthOpts = {
30866
+ app: appCmd,
30867
+ output: options.output,
30868
+ ...options.region && { region: options.region },
30869
+ ...options.profile && { profile: options.profile },
30870
+ ...Object.keys(context).length > 0 && { context }
30871
+ };
30872
+ const { stacks } = await synthesizer.synthesize(synthOpts);
30873
+ const resolvedTarget = await resolveSingleTarget(target, {
30874
+ entries: listTargets(stacks).agentCoreRuntimes,
30875
+ message: "Select an AgentCore Runtime to serve",
30876
+ noun: "AgentCore Runtimes",
30877
+ onMissing: () => new CdkLocalError(`${getEmbedConfig().cliName} start-agentcore requires a <target> (an AgentCore Runtime display path or logical ID). Run \`${getEmbedConfig().cliName} list\` to see them, or run it in a TTY to pick interactively.`, "LOCAL_START_AGENTCORE_TARGET_REQUIRED")
30878
+ });
30879
+ const candidate = pickAgentCoreCandidateStack(resolvedTarget, stacks);
30880
+ stateProvider = createLocalStateProvider(options, candidate?.stackName ?? "", await resolveCfnFallbackRegion(options, candidate?.region), extraStateProviders);
30881
+ const { context: imageContext, loaded: loadedState } = stateProvider && candidate ? await buildAgentCoreImageContext(candidate, stateProvider, options) : {
30882
+ context: void 0,
30883
+ loaded: void 0
30884
+ };
30885
+ const resolved = resolveAgentCoreTarget(resolvedTarget, stacks, imageContext);
30886
+ logger.info(`Target: ${resolved.stack.stackName}/${resolved.logicalId} (${resolved.protocol})`);
30887
+ assertAgentCoreWsServable(resolved);
30888
+ const authorization = await resolveInboundAuthorization(resolved, options);
30889
+ await resolveFromS3BucketIntrinsic(resolved, stateProvider, loadedState, imageContext);
30890
+ const image = await resolveAgentCoreImage(resolved, options, loadedState, stateProvider);
30891
+ const { env: dockerEnv, sensitiveEnvKeys } = await buildContainerEnv(resolved, options, profileCredentials, profileCredsFile, stateProvider, loadedState, imageContext);
30892
+ const containerHostPort = await pickFreePort();
30893
+ const containerHost = options.containerHost;
30894
+ const containerName = `${getEmbedConfig().resourceNamePrefix}-agentcore-${process.pid}-${Math.random().toString(36).slice(2, 8)}`;
30895
+ logger.info(`Starting agent container (image=${image}, port=${containerHostPort} -> 8080)...`);
30896
+ containerId = await runDetached({
30897
+ image,
30898
+ mounts: [],
30899
+ env: dockerEnv,
30900
+ cmd: [],
30901
+ hostPort: containerHostPort,
30902
+ host: containerHost,
30903
+ platform: options.platform,
30904
+ name: containerName,
30905
+ ...sensitiveEnvKeys.size > 0 && { sensitiveEnvKeys }
30906
+ });
30907
+ stopLogs = streamLogs(containerId);
30908
+ const shutdown = async (signal, exitCode) => {
30909
+ if (shuttingDown) return;
30910
+ shuttingDown = true;
30911
+ logger.info(`Received ${signal}, shutting down...`);
30912
+ await teardown();
30913
+ process.exit(exitCode);
30914
+ };
30915
+ process.on("SIGINT", () => void shutdown("SIGINT", 130));
30916
+ process.on("SIGTERM", () => void shutdown("SIGTERM", 0));
30917
+ try {
30918
+ await waitForAgentCorePing(containerHost, containerHostPort, options.timeout);
30919
+ bridge = await startAgentCoreWsBridge({
30920
+ containerHost,
30921
+ containerPort: containerHostPort,
30922
+ host: options.host,
30923
+ port: options.port,
30924
+ ...authorization && { authorization },
30925
+ ...options.sessionId && { sessionId: options.sessionId }
30926
+ });
30927
+ } catch (err) {
30928
+ await teardown();
30929
+ throw err;
30930
+ }
30931
+ logger.info(`Server listening on ${bridge.url} (${resolved.logicalId} (AgentCore WebSocket))`);
30932
+ logger.info("Press ^C to shut down.");
30933
+ await new Promise(() => void 0);
30934
+ }
30935
+ /**
30936
+ * `cdkl start-agentcore <target>` — long-running serve for a Bedrock AgentCore
30937
+ * Runtime's `/ws` WebSocket endpoint, fronted by a host bridge that injects the
30938
+ * session-id / Authorization upgrade headers a browser `WebSocket` cannot set.
30939
+ * The serve counterpart of the single-shot `cdkl invoke-agentcore`; the studio
30940
+ * `agentcore-ws` serve kind spawns this command.
30941
+ */
30942
+ function createLocalStartAgentCoreCommand(opts = {}) {
30943
+ setEmbedConfig(opts.embedConfig);
30944
+ const cmd = new Command("start-agentcore").description("Serve a Bedrock AgentCore Runtime's bidirectional /ws WebSocket endpoint locally for an interactive multi-frame session. Boots the AWS::BedrockAgentCore::Runtime container (same image / env / credential resolution as invoke-agentcore), then runs a host WebSocket bridge that injects the AgentCore session-id (and Authorization under a customJwtAuthorizer) on the container upgrade so a header-less client (e.g. a browser) can connect. HTTP / AGUI protocols only (MCP / A2A runtimes have no /ws). Target accepts a CDK display path (MyStack/MyAgent) or stack-qualified logical ID; single-stack apps may omit the prefix. Omit <target> in a TTY to pick from a list. Runs until ^C.").argument("[target]", "CDK display path or stack-qualified logical ID of the AgentCore Runtime to serve (omit to pick interactively in a TTY)").action(withErrorHandling(async (target, options) => {
30945
+ await localStartAgentCoreCommand(target, options, opts.extraStateProviders);
30946
+ }));
30947
+ addStartAgentCoreSpecificOptions(cmd);
30948
+ [
30949
+ ...commonOptions(),
30950
+ ...appOptions(),
30951
+ ...contextOptions
30952
+ ].forEach((opt) => cmd.addOption(opt));
30953
+ cmd.addOption(regionOption);
30954
+ return cmd;
30955
+ }
30956
+ /**
30957
+ * Register the option block `cdkl start-agentcore` adds on top of the shared
30958
+ * common / app / context helpers. Shared with any host CLI (e.g. cdkd's
30959
+ * `local start-agentcore`) wrapping this factory, so adding or renaming a
30960
+ * `start-agentcore`-only flag here propagates without duplicate
30961
+ * `.addOption(...)` blocks. Chainable: returns `cmd`.
30962
+ */
30963
+ function addStartAgentCoreSpecificOptions(cmd) {
30964
+ return cmd.addOption(new Option("--port <n>", "Bridge-server bind port the client (browser) connects to. Default 0 (OS-assigned).").default(0).argParser(parsePort)).addOption(new Option("--host <ip>", "Bridge-server bind host. Default 127.0.0.1.").default("127.0.0.1")).addOption(new Option("--session-id <id>", "Pin one AgentCore runtime session id header value for every connection (default: a fresh random UUID per connection, so each client is its own session).")).addOption(new Option("--bearer-token <jwt>", "Bearer JWT to present when the runtime declares a customJwtAuthorizer. Verified against the runtime's OIDC discovery URL before the container starts, then injected as Authorization: Bearer <jwt> on the container /ws upgrade for every bridged connection.")).addOption(new Option("--no-verify-auth", "Skip inbound JWT verification even when the runtime declares a customJwtAuthorizer (local-dev escape hatch). A --bearer-token, if given, is still forwarded.")).addOption(new Option("--env-vars <file>", "JSON env-var overrides (SAM-compatible: {\"LogicalId\":{\"KEY\":\"VALUE\"}, \"Parameters\": {...}})")).addOption(new Option("--platform <platform>", "docker --platform for the agent container (linux/amd64 or linux/arm64). Defaults to linux/arm64 because the cloud AgentCore Runtime requires arm64.").choices(["linux/amd64", "linux/arm64"]).default("linux/arm64")).addOption(new Option("--no-pull", "Skip docker pull (use cached image) — no-op for the local-build path")).addOption(new Option("--no-build", "Skip docker build on the local-asset path (use the previously-built tag). No-op for the ECR / registry pull paths.")).addOption(new Option("--container-host <host>", "Host IP used to bind the agent container port. Must be a numeric IP. Defaults to 127.0.0.1.").default("127.0.0.1")).addOption(new Option("--timeout <ms>", "Maximum time in milliseconds to wait for the container to become ready (the GET /ping readiness deadline). Default 120000.").default(12e4).argParser(parseTimeoutMs)).addOption(new Option("--assume-role [arn]", "Assume the runtime's execution role and forward STS-issued temp credentials to the container. (1) `--assume-role <arn>` assumes the explicit ARN; (2) `--assume-role` (bare) uses the runtime's literal RoleArn; (3) `--no-assume-role` opts out. Off by default.")).addOption(new Option("--ecr-role-arn <arn>", "Role ARN to assume before authenticating against ECR for cross-account / centralized registries.")).addOption(new Option("--from-cfn-stack [cfn-stack-name]", "Read a deployed CloudFormation stack and substitute Ref / Fn::ImportValue in env vars / image URIs with the deployed physical IDs / exports. Bare form uses the resolved stack name.")).addOption(new Option("--stack-region <region>", "Region of the state record to read. Used with --from-cfn-stack as the CFn client region."));
30965
+ }
30966
+
30615
30967
  //#endregion
30616
30968
  //#region src/cli/commands/local-list.ts
30617
30969
  async function localListCommand(options) {
@@ -35778,5 +36130,5 @@ function addStudioSpecificOptions(cmd) {
35778
36130
  }
35779
36131
 
35780
36132
  //#endregion
35781
- export { isCloudFrontDistribution as $, attachAuthorizers as $n, parseSelectionExpressionPath as $r, createLocalInvokeAgentCoreCommand as $t, parseOriginOverrides as A, buildStageMap as An, EcsTaskResolutionError as Ar, parseMaxTasks as At, startCloudFrontServer as B, resolveServiceIntegrationParameters as Bn, resolveCfnRegion as Br, resolveImageOverrides as Bt, addListSpecificOptions as C, addStartApiSpecificOptions as Cn, buildDisconnectEvent as Cr, createLocalRunTaskCommand as Ct, addStartCloudFrontSpecificOptions as D, createAuthorizerCache as Dn, resolveRuntimeCodeMountPath as Dr, addImageOverrideOptions as Dt, LocalStartCloudFrontError as E, resolveApiTargetSubset as En, buildContainerImage as Er, addEcsAssumeRoleOptions as Et, resolveDeployedKvsArnByName as F, filterRoutesByApiIdentifiers as Fn, LocalStateSourceError as Fr, ImageOverrideError as Ft, applyEdgeResponseResult as G, verifyCognitoJwt as Gn, resolveWatchConfig as Gr, buildCloudMapIndex as Gt, serveFromStaticOrigin as H, buildCognitoJwksUrl as Hn, CfnLocalStateProvider as Hr, describePinnedImageUri as Ht, resolveDeployedOriginBucket as I, groupRoutesByServer as In, createLocalStateProvider as Ir, buildImageOverrideTag as It, edgeHeadersToHttp as J, buildMethodArn as Jn, listTargets as Jr, SOFT_RELOAD_COMPLETION_LOG_SUFFIX as Jt, buildEdgeRequestEvent as K, verifyJwtAuthorizer as Kn, resolveSingleTarget as Kr, CloudMapRegistry as Kt, classifyS3Error as L, readMtlsMaterialsFromDisk as Ln, isCfnFlagPresent as Lr, enforceImageOverrideOrphans as Lt, idFromArn as M, resolveEnvVars$1 as Mn, substituteAgainstStateAsync as Mr, resolveEcsAssumeRoleOption as Mt, resolveKvsModulesForDistribution as N, availableApiIdentifiers as Nn, substituteEnvVarsFromState as Nr, resolveSharedSidecarCredentials as Nt, createLocalStartCloudFrontCommand as O, createFileWatcher as On, resolveRuntimeFileExtension as Or, buildEcsImageResolutionContext$1 as Ot, createDeployedKvsDataSource as P, filterRoutesByApiIdentifier as Pn, substituteEnvVarsFromStateAsync as Pr, runEcsServiceEmulator as Pt, extractKvsAssociations as Q, invokeTokenAuthorizer as Qn, filterWebSocketApisByIdentifiers as Qr, addInvokeAgentCoreSpecificOptions as Qt, createS3OriginReader as R, startApiServer as Rn, rejectExplicitCfnStackWithMultipleStacks as Rr, mergeForService as Rt, StudioEventBus as S, createLocalInvokeCommand as Sn, buildConnectEvent as Sr, addRunTaskSpecificOptions as St, formatTargetListing as T, createWatchPredicates as Tn, architectureToPlatform as Tr, addCommonEcsServiceOptions as Tt, serveLambdaUrlOrigin as U, buildJwksUrlFromIssuer as Un, collectSsmParameterRefs as Ur, isLocalCdkAssetImage as Ut, resolveErrorResponseCandidates as V, defaultCredentialsLoader as Vn, resolveCfnStackName as Vr, runImageOverrideBuilds as Vt, applyEdgeRequestResult as W, createJwksCache as Wn, resolveSsmParameters as Wr, listPinnedTargets as Wt, CLOUDFRONT_DISTRIBUTION_TYPE as X, evaluateCachedLambdaPolicy as Xn, discoverWebSocketApis as Xr, getContainerNetworkIp as Xt, httpHeadersToEdge as Y, computeRequestIdentityHash as Yn, availableWebSocketApiIdentifiers as Yr, setShadowReadyTimeoutMs as Yt, describeS3OriginDomain as Z, invokeRequestAuthorizer as Zn, discoverWebSocketApisOrThrow as Zr, attachContainerLogStreamer as Zt, filterStudioTargetGroups as _, buildStsClientConfig as _i, computeCodeImageTag as _n, bufferToBody as _r, isApplicationLoadBalancer as _t, createLocalStudioCommand as a, AGENTCORE_AGUI_PROTOCOL as ai, MCP_PATH as an, matchRoute as ar, compileCloudFrontFunction as at, renderStudioHtml as b, classifySourceChange as bn, handleConnectionsRequest as br, createLocalStartServiceCommand as bt, startStudioProxy as c, AGENTCORE_RUNTIME_TYPE as ci, parseSseForJsonRpc as cn, buildHttpApiV2Event as cr, stripCloudFrontImport as ct, createStudioDispatcher as d, resolveAgentCoreTarget as di, AGENTCORE_SESSION_ID_HEADER as dn, pickResponseTemplate as dr, createUnboundCloudFrontModule as dt, webSocketApiMatchesIdentifier as ei, invokeAgentCoreWs as en, applyCorsResponseHeaders as er, pickFunctionUrlLogicalIdFromOrigin as et, filterStudioCustomResources as f, derivePseudoParametersFromRegion as fi, invokeAgentCore as fn, selectIntegrationResponse as fr, addAlbSpecificOptions as ft, annotatePinnedEcsTargets as g, LocalInvokeBuildError as gi, buildAgentCoreCodeImage as gn, probeHostGatewaySupport as gr, resolveAlbTarget as gt, annotateEcsTaskPinnedTargets as h, tryResolveImageFnJoin as hi, SUPPORTED_CODE_RUNTIMES as hn, HOST_GATEWAY_MIN_VERSION as hr, parseLbPortOverrides as ht, coerceStopRequest as i, AGENTCORE_A2A_PROTOCOL as ii, MCP_CONTAINER_PORT as in, matchPreflight as ir, resolveCloudFrontDistribution as it, resolveCloudFrontTarget as j, materializeLayerFromArn as jn, substituteAgainstState as jr, parseRestartPolicy as jt, parseKvsFileOverrides as k, attachStageContext as kn, resolveRuntimeImage as kr, ecsClusterOption as kt, relayServeRequest as l, AgentCoreResolutionError as li, AGENTCORE_SIGV4_SERVICE as ln, buildRestV1Event as lr, createCloudFrontModule as lt, annotateAlbPinnedBackingServices as m, substituteImagePlaceholders as mi, downloadAndExtractS3Bundle as mn, VtlEvaluationError as mr, createLocalStartAlbCommand as mt, coerceRunRequest as n, pickRefLogicalId as ni, A2A_PATH as nn, buildCorsConfigFromCloudFrontChain as nr, pickLambdaEdgeFunctionLogicalId as nt, resolveServeBaseUrl as o, AGENTCORE_HTTP_PROTOCOL as oi, MCP_PROTOCOL_VERSION as on, translateLambdaResponse as or, runViewerRequest as ot, isCustomResourceLambdaTarget as p, formatStateRemedy as pi, waitForAgentCorePing as pn, tryParseStatus as pr, albStrategy as pt, buildEdgeResponseEvent as q, verifyJwtViaDiscovery as qn, countTargets as qr, DEFAULT_SHADOW_READY_TIMEOUT_MS as qt, coerceServeRequest as r, resolveLambdaArnIntrinsic as ri, a2aInvokeOnce as rn, isFunctionUrlOacFronted as rr, pickTargetFunctionLogicalId as rt, createStudioServeManager as s, AGENTCORE_MCP_PROTOCOL as si, mcpInvokeOnce as sn, applyAuthorizerOverlay as sr, runViewerResponse as st, addStudioSpecificOptions as t, discoverRoutes as ti, A2A_CONTAINER_PORT as tn, buildCorsConfigByApiId as tr, pickKvsLogicalIdFromArn as tt, reinvoke as u, pickAgentCoreCandidateStack as ui, signAgentCoreInvocation as un, evaluateResponseParameters as ur, createLocalFileKvsDataSource as ut, startStudioServer as v, resolveProfileCredentials as vi, renderCodeDockerfile as vn, ConnectionRegistry as vr, resolveAlbFrontDoor as vt, createLocalListCommand as w, createLocalStartApiCommand as wn, buildMessageEvent as wr, MAX_TASKS_SUBNET_RANGE_CAP as wt, createStudioStore as x, addInvokeSpecificOptions as xn, parseConnectionsPath as xr, serviceStrategy as xt, toStudioTargetGroups as y, toCmdArgv as yn, buildMgmtEndpointEnvUrl as yr, addStartServiceSpecificOptions as yt, matchBehavior as z, resolveSelectionExpression as zn, resolveCfnFallbackRegion as zr, parseImageOverrideFlags as zt };
35782
- //# sourceMappingURL=local-studio-rgRqFe-U.js.map
36133
+ export { CLOUDFRONT_DISTRIBUTION_TYPE as $, computeRequestIdentityHash as $n, availableWebSocketApiIdentifiers as $r, getContainerNetworkIp as $t, addStartCloudFrontSpecificOptions as A, resolveApiTargetSubset as An, buildContainerImage as Ar, addImageOverrideOptions as At, classifyS3Error as B, groupRoutesByServer as Bn, createLocalStateProvider as Br, enforceImageOverrideOrphans as Bt, addListSpecificOptions as C, toCmdArgv as Cn, buildMgmtEndpointEnvUrl as Cr, createLocalStartServiceCommand as Ct, createLocalStartAgentCoreCommand as D, addStartApiSpecificOptions as Dn, buildDisconnectEvent as Dr, MAX_TASKS_SUBNET_RANGE_CAP as Dt, addStartAgentCoreSpecificOptions as E, createLocalInvokeCommand as En, buildConnectEvent as Er, createLocalRunTaskCommand as Et, idFromArn as F, materializeLayerFromArn as Fn, substituteAgainstState as Fr, resolveEcsAssumeRoleOption as Ft, serveFromStaticOrigin as G, defaultCredentialsLoader as Gn, resolveCfnStackName as Gr, describePinnedImageUri as Gt, matchBehavior as H, startApiServer as Hn, rejectExplicitCfnStackWithMultipleStacks as Hr, parseImageOverrideFlags as Ht, resolveKvsModulesForDistribution as I, resolveEnvVars$1 as In, substituteAgainstStateAsync as Ir, resolveSharedSidecarCredentials as It, applyEdgeResponseResult as J, createJwksCache as Jn, resolveSsmParameters as Jr, buildCloudMapIndex as Jt, serveLambdaUrlOrigin as K, buildCognitoJwksUrl as Kn, CfnLocalStateProvider as Kr, isLocalCdkAssetImage as Kt, createDeployedKvsDataSource as L, availableApiIdentifiers as Ln, substituteEnvVarsFromState as Lr, runEcsServiceEmulator as Lt, parseKvsFileOverrides as M, createFileWatcher as Mn, resolveRuntimeFileExtension as Mr, ecsClusterOption as Mt, parseOriginOverrides as N, attachStageContext as Nn, resolveRuntimeImage as Nr, parseMaxTasks as Nt, startAgentCoreWsBridge as O, createLocalStartApiCommand as On, buildMessageEvent as Or, addCommonEcsServiceOptions as Ot, resolveCloudFrontTarget as P, buildStageMap as Pn, EcsTaskResolutionError as Pr, parseRestartPolicy as Pt, httpHeadersToEdge as Q, buildMethodArn as Qn, listTargets as Qr, setShadowReadyTimeoutMs as Qt, resolveDeployedKvsArnByName as R, filterRoutesByApiIdentifier as Rn, substituteEnvVarsFromStateAsync as Rr, ImageOverrideError as Rt, StudioEventBus as S, resolveProfileCredentials as Si, renderCodeDockerfile as Sn, ConnectionRegistry as Sr, addStartServiceSpecificOptions as St, formatTargetListing as T, addInvokeSpecificOptions as Tn, parseConnectionsPath as Tr, addRunTaskSpecificOptions as Tt, startCloudFrontServer as U, resolveSelectionExpression as Un, resolveCfnFallbackRegion as Ur, resolveImageOverrides as Ut, createS3OriginReader as V, readMtlsMaterialsFromDisk as Vn, isCfnFlagPresent as Vr, mergeForService as Vt, resolveErrorResponseCandidates as W, resolveServiceIntegrationParameters as Wn, resolveCfnRegion as Wr, runImageOverrideBuilds as Wt, buildEdgeResponseEvent as X, verifyJwtAuthorizer as Xn, resolveSingleTarget as Xr, DEFAULT_SHADOW_READY_TIMEOUT_MS as Xt, buildEdgeRequestEvent as Y, verifyCognitoJwt as Yn, resolveWatchConfig as Yr, CloudMapRegistry as Yt, edgeHeadersToHttp as Z, verifyJwtViaDiscovery as Zn, countTargets as Zr, SOFT_RELOAD_COMPLETION_LOG_SUFFIX as Zt, filterStudioTargetGroups as _, formatStateRemedy as _i, waitForAgentCorePing as _n, tryParseStatus as _r, createLocalStartAlbCommand as _t, createLocalStudioCommand as a, discoverRoutes as ai, A2A_CONTAINER_PORT as an, buildCorsConfigByApiId as ar, pickLambdaEdgeFunctionLogicalId as at, renderStudioHtml as b, LocalInvokeBuildError as bi, buildAgentCoreCodeImage as bn, probeHostGatewaySupport as br, isApplicationLoadBalancer as bt, startStudioProxy as c, AGENTCORE_A2A_PROTOCOL as ci, MCP_CONTAINER_PORT as cn, matchPreflight as cr, compileCloudFrontFunction as ct, createStudioDispatcher as d, AGENTCORE_MCP_PROTOCOL as di, mcpInvokeOnce as dn, applyAuthorizerOverlay as dr, stripCloudFrontImport as dt, discoverWebSocketApis as ei, attachContainerLogStreamer as en, evaluateCachedLambdaPolicy as er, describeS3OriginDomain as et, filterStudioCustomResources as f, AGENTCORE_RUNTIME_TYPE as fi, parseSseForJsonRpc as fn, buildHttpApiV2Event as fr, createCloudFrontModule as ft, annotatePinnedEcsTargets as g, derivePseudoParametersFromRegion as gi, invokeAgentCore as gn, selectIntegrationResponse as gr, albStrategy as gt, annotateEcsTaskPinnedTargets as h, resolveAgentCoreTarget as hi, AGENTCORE_SESSION_ID_HEADER as hn, pickResponseTemplate as hr, addAlbSpecificOptions as ht, coerceStopRequest as i, webSocketApiMatchesIdentifier as ii, invokeAgentCoreWs as in, applyCorsResponseHeaders as ir, pickKvsLogicalIdFromArn as it, createLocalStartCloudFrontCommand as j, createAuthorizerCache as jn, resolveRuntimeCodeMountPath as jr, buildEcsImageResolutionContext$1 as jt, LocalStartCloudFrontError as k, createWatchPredicates as kn, architectureToPlatform as kr, addEcsAssumeRoleOptions as kt, relayServeRequest as l, AGENTCORE_AGUI_PROTOCOL as li, MCP_PATH as ln, matchRoute as lr, runViewerRequest as lt, annotateAlbPinnedBackingServices as m, pickAgentCoreCandidateStack as mi, signAgentCoreInvocation as mn, evaluateResponseParameters as mr, createUnboundCloudFrontModule as mt, coerceRunRequest as n, filterWebSocketApisByIdentifiers as ni, createLocalInvokeAgentCoreCommand as nn, invokeTokenAuthorizer as nr, isCloudFrontDistribution as nt, resolveServeBaseUrl as o, pickRefLogicalId as oi, A2A_PATH as on, buildCorsConfigFromCloudFrontChain as or, pickTargetFunctionLogicalId as ot, isCustomResourceLambdaTarget as p, AgentCoreResolutionError as pi, AGENTCORE_SIGV4_SERVICE as pn, buildRestV1Event as pr, createLocalFileKvsDataSource as pt, applyEdgeRequestResult as q, buildJwksUrlFromIssuer as qn, collectSsmParameterRefs as qr, listPinnedTargets as qt, coerceServeRequest as r, parseSelectionExpressionPath as ri, bridgeAgentCoreWs as rn, attachAuthorizers as rr, pickFunctionUrlLogicalIdFromOrigin as rt, createStudioServeManager as s, resolveLambdaArnIntrinsic as si, a2aInvokeOnce as sn, isFunctionUrlOacFronted as sr, resolveCloudFrontDistribution as st, addStudioSpecificOptions as t, discoverWebSocketApisOrThrow as ti, addInvokeAgentCoreSpecificOptions as tn, invokeRequestAuthorizer as tr, extractKvsAssociations as tt, reinvoke as u, AGENTCORE_HTTP_PROTOCOL as ui, MCP_PROTOCOL_VERSION as un, translateLambdaResponse as ur, runViewerResponse as ut, startStudioServer as v, substituteImagePlaceholders as vi, downloadAndExtractS3Bundle as vn, VtlEvaluationError as vr, parseLbPortOverrides as vt, createLocalListCommand as w, classifySourceChange as wn, handleConnectionsRequest as wr, serviceStrategy as wt, createStudioStore as x, buildStsClientConfig as xi, computeCodeImageTag as xn, bufferToBody as xr, resolveAlbFrontDoor as xt, toStudioTargetGroups as y, tryResolveImageFnJoin as yi, SUPPORTED_CODE_RUNTIMES as yn, HOST_GATEWAY_MIN_VERSION as yr, resolveAlbTarget as yt, resolveDeployedOriginBucket as z, filterRoutesByApiIdentifiers as zn, LocalStateSourceError as zr, buildImageOverrideTag as zt };
36134
+ //# sourceMappingURL=local-studio-BGi3yHZI.js.map