cdk-local 0.119.0 → 0.120.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.
@@ -23890,7 +23890,7 @@ function writeRawHttpError(socket, statusCode, message) {
23890
23890
  if (socket.destroyed) return;
23891
23891
  const body = `${message}\n`;
23892
23892
  const lines = [
23893
- `HTTP/1.1 ${statusCode} ${STATUS_TEXT[statusCode] ?? "Error"}`,
23893
+ `HTTP/1.1 ${statusCode} ${STATUS_TEXT$1[statusCode] ?? "Error"}`,
23894
23894
  "content-type: text/plain; charset=utf-8",
23895
23895
  `content-length: ${Buffer.byteLength(body)}`,
23896
23896
  "connection: close",
@@ -23943,7 +23943,7 @@ function writeRawHttpRedirect(socket, action, req, listenerPort, scheme) {
23943
23943
  function writeRawHttpFixedResponse(socket, action) {
23944
23944
  if (socket.destroyed) return;
23945
23945
  const body = action.messageBody ?? "";
23946
- const statusText = STATUS_TEXT[action.statusCode] ?? "";
23946
+ const statusText = STATUS_TEXT$1[action.statusCode] ?? "";
23947
23947
  const contentType = sanitizeRawHeaderValue(action.contentType ?? "text/plain; charset=utf-8");
23948
23948
  const lines = [
23949
23949
  `HTTP/1.1 ${action.statusCode} ${statusText}`,
@@ -23963,7 +23963,7 @@ function sanitizeRawHeaderValue(value) {
23963
23963
  return value.replace(/[\r\n]/g, " ");
23964
23964
  }
23965
23965
  /** Minimal HTTP/1.1 status text map for the codes the raw writers emit. */
23966
- const STATUS_TEXT = {
23966
+ const STATUS_TEXT$1 = {
23967
23967
  301: "Moved Permanently",
23968
23968
  302: "Found",
23969
23969
  401: "Unauthorized",
@@ -28402,6 +28402,15 @@ function buildViewerResponseEvent(requestEvent, response) {
28402
28402
  }
28403
28403
  };
28404
28404
  }
28405
+ /** Serialize a CloudFront request's `querystring` object back to a raw string. */
28406
+ function serializeCfQueryString(qs) {
28407
+ const parts = [];
28408
+ for (const [key, val] of Object.entries(qs)) {
28409
+ const values = val.multiValue && val.multiValue.length > 0 ? val.multiValue : [{ value: val.value }];
28410
+ for (const v of values) parts.push(v.value === "" ? encodeURIComponent(key) : `${encodeURIComponent(key)}=${encodeURIComponent(v.value)}`);
28411
+ }
28412
+ return parts.join("&");
28413
+ }
28405
28414
  function parseQueryStringToCf(raw) {
28406
28415
  const out = {};
28407
28416
  if (!raw) return out;
@@ -28460,6 +28469,7 @@ const CLOUDFRONT_FUNCTION_TYPE = "AWS::CloudFront::Function";
28460
28469
  const S3_BUCKET_TYPE = "AWS::S3::Bucket";
28461
28470
  const LAMBDA_URL_TYPE = "AWS::Lambda::Url";
28462
28471
  const LAMBDA_FUNCTION_TYPE = "AWS::Lambda::Function";
28472
+ const LAMBDA_VERSION_TYPE = "AWS::Lambda::Version";
28463
28473
  /**
28464
28474
  * Resolve a distribution logical id within a stack into its routing model.
28465
28475
  * `originOverrides` maps an origin id to a local directory (the `--origin`
@@ -28565,10 +28575,9 @@ function resolveBehaviors(dc, functions, distLogicalId, template) {
28565
28575
  return behaviors;
28566
28576
  }
28567
28577
  function resolveBehavior(behavior, pathPattern, functions, distLogicalId, template) {
28568
- const resolved = {
28569
- targetOriginId: typeof behavior["TargetOriginId"] === "string" ? behavior["TargetOriginId"] : "",
28570
- hasLambdaEdge: Array.isArray(behavior["LambdaFunctionAssociations"]) ? behavior["LambdaFunctionAssociations"].length > 0 : false
28571
- };
28578
+ const resolved = { targetOriginId: typeof behavior["TargetOriginId"] === "string" ? behavior["TargetOriginId"] : "" };
28579
+ const lambdaEdge = resolveLambdaEdgeAssociations(behavior, template, distLogicalId);
28580
+ if (lambdaEdge) resolved.lambdaEdge = lambdaEdge;
28572
28581
  if (pathPattern !== void 0) resolved.pathPattern = pathPattern;
28573
28582
  const cors = resolveResponseHeadersPolicyCors(template, behavior["ResponseHeadersPolicyId"]);
28574
28583
  if (cors) resolved.cors = cors;
@@ -28600,6 +28609,55 @@ function pickFunctionLogicalIdFromArn(value) {
28600
28609
  const getAtt = value["Fn::GetAtt"];
28601
28610
  if (Array.isArray(getAtt) && getAtt.length === 2 && typeof getAtt[0] === "string") return getAtt[0];
28602
28611
  }
28612
+ /**
28613
+ * Resolve a behavior's `LambdaFunctionAssociations[]` into the per-event-type
28614
+ * backing-function map (issue #400). Each association names a
28615
+ * `LambdaFunctionARN` (a versioned ARN) + an `EventType` + `IncludeBody`.
28616
+ */
28617
+ function resolveLambdaEdgeAssociations(behavior, template, distLogicalId) {
28618
+ const assocs = Array.isArray(behavior["LambdaFunctionAssociations"]) ? behavior["LambdaFunctionAssociations"] : [];
28619
+ const out = {};
28620
+ for (const a of assocs) {
28621
+ if (!a || typeof a !== "object") continue;
28622
+ const assoc = a;
28623
+ const eventType = assoc["EventType"];
28624
+ const functionLogicalId = pickLambdaEdgeFunctionLogicalId(assoc["LambdaFunctionARN"], template);
28625
+ if (!functionLogicalId) {
28626
+ getLogger().warn(`Distribution '${distLogicalId}': a Lambda@Edge association references a LambdaFunctionARN cdk-local could not resolve to a local AWS::Lambda::Function; it will not run.`);
28627
+ continue;
28628
+ }
28629
+ const entry = {
28630
+ functionLogicalId,
28631
+ includeBody: assoc["IncludeBody"] === true
28632
+ };
28633
+ if (eventType === "viewer-request") out.viewerRequest = entry;
28634
+ else if (eventType === "origin-request") out.originRequest = entry;
28635
+ else if (eventType === "origin-response") out.originResponse = entry;
28636
+ else if (eventType === "viewer-response") out.viewerResponse = entry;
28637
+ }
28638
+ return Object.keys(out).length > 0 ? out : void 0;
28639
+ }
28640
+ /**
28641
+ * Resolve a `LambdaFunctionARN` (a versioned function ARN) to the backing
28642
+ * `AWS::Lambda::Function` logical id. CDK wires the association to a
28643
+ * `lambda.Version` (`{Ref: <Version>}` returns the qualified ARN), whose
28644
+ * `FunctionName` references the function. A direct (unqualified) function ref
28645
+ * is also accepted. Returns `undefined` when it cannot reach an
28646
+ * `AWS::Lambda::Function` (e.g. an imported cross-region EdgeFunction ARN).
28647
+ */
28648
+ function pickLambdaEdgeFunctionLogicalId(value, template) {
28649
+ const candidate = refLogicalId(value) ?? getAttLogicalId(value);
28650
+ if (!candidate) return void 0;
28651
+ const resources = template.Resources ?? {};
28652
+ const resource = resources[candidate];
28653
+ if (!resource) return void 0;
28654
+ if (resource.Type === LAMBDA_FUNCTION_TYPE) return candidate;
28655
+ if (resource.Type === LAMBDA_VERSION_TYPE) {
28656
+ const fnName = (resource.Properties ?? {})["FunctionName"];
28657
+ const fnId = refLogicalId(fnName) ?? getAttLogicalId(fnName);
28658
+ if (fnId && resources[fnId]?.Type === LAMBDA_FUNCTION_TYPE) return fnId;
28659
+ }
28660
+ }
28603
28661
  function resolveOrigins(dc, template, stack, overrides) {
28604
28662
  const out = /* @__PURE__ */ new Map();
28605
28663
  const origins = Array.isArray(dc["Origins"]) ? dc["Origins"] : [];
@@ -28799,6 +28857,261 @@ function isCloudFrontDistribution(resource) {
28799
28857
  return resource.Type === CLOUDFRONT_DISTRIBUTION_TYPE;
28800
28858
  }
28801
28859
 
28860
+ //#endregion
28861
+ //#region src/local/cloudfront-edge-event.ts
28862
+ /** Convert a normalized HTTP header map into the Lambda@Edge multi-map. */
28863
+ function httpHeadersToEdge(headers) {
28864
+ const out = {};
28865
+ for (const [name, values] of Object.entries(headers)) {
28866
+ const lower = name.toLowerCase();
28867
+ out[lower] = values.map((value) => ({
28868
+ key: name,
28869
+ value
28870
+ }));
28871
+ }
28872
+ return out;
28873
+ }
28874
+ /**
28875
+ * Flatten a Lambda@Edge header multi-map into a single-valued `{ name: value }`
28876
+ * map (comma-joining duplicates), EXCEPT `set-cookie`, whose values are returned
28877
+ * separately so multiple cookies survive. Pseudo / read-only headers CloudFront
28878
+ * forbids a function from setting are dropped.
28879
+ */
28880
+ function edgeHeadersToHttp(headers) {
28881
+ const out = {};
28882
+ const setCookies = [];
28883
+ for (const [name, entries] of Object.entries(headers)) {
28884
+ if (!Array.isArray(entries)) continue;
28885
+ const lower = name.toLowerCase();
28886
+ if (READ_ONLY_RESPONSE_HEADERS.has(lower)) continue;
28887
+ if (lower === "set-cookie") {
28888
+ for (const e of entries) if (e && typeof e.value === "string") setCookies.push(e.value);
28889
+ continue;
28890
+ }
28891
+ const values = entries.filter((e) => e && typeof e.value === "string").map((e) => e.value);
28892
+ if (values.length > 0) out[lower] = values.join(", ");
28893
+ }
28894
+ return {
28895
+ headers: out,
28896
+ setCookies
28897
+ };
28898
+ }
28899
+ /**
28900
+ * Headers a Lambda@Edge function is not allowed to add/modify on a response (a
28901
+ * subset CloudFront blackholes). We drop them rather than fail the response.
28902
+ */
28903
+ const READ_ONLY_RESPONSE_HEADERS = new Set([
28904
+ "connection",
28905
+ "content-length",
28906
+ "keep-alive",
28907
+ "proxy-authenticate",
28908
+ "proxy-authorization",
28909
+ "te",
28910
+ "trailer",
28911
+ "transfer-encoding",
28912
+ "upgrade"
28913
+ ]);
28914
+ /** Build the request-stage event (`viewer-request` / `origin-request`). */
28915
+ function buildEdgeRequestEvent(args) {
28916
+ return { Records: [{ cf: {
28917
+ config: {
28918
+ ...args.config,
28919
+ eventType: args.eventType
28920
+ },
28921
+ request: toEdgeRequest(args.request, args.includeBody)
28922
+ } }] };
28923
+ }
28924
+ /** Build the response-stage event (`origin-response` / `viewer-response`). */
28925
+ function buildEdgeResponseEvent(args) {
28926
+ return { Records: [{ cf: {
28927
+ config: {
28928
+ ...args.config,
28929
+ eventType: args.eventType
28930
+ },
28931
+ request: toEdgeRequest(args.request, false),
28932
+ response: {
28933
+ status: String(args.response.statusCode),
28934
+ statusDescription: statusText(args.response.statusCode),
28935
+ headers: httpHeadersToEdge(toMultiMap(args.response.headers))
28936
+ }
28937
+ } }] };
28938
+ }
28939
+ function toEdgeRequest(input, includeBody) {
28940
+ const request = {
28941
+ clientIp: input.clientIp,
28942
+ method: input.method,
28943
+ uri: input.uri,
28944
+ querystring: input.querystring,
28945
+ headers: httpHeadersToEdge(input.headers)
28946
+ };
28947
+ if (includeBody) request.body = {
28948
+ action: "read-only",
28949
+ data: (input.body ?? Buffer.alloc(0)).toString("base64"),
28950
+ encoding: "base64",
28951
+ inputTruncated: false
28952
+ };
28953
+ return request;
28954
+ }
28955
+ function interpretEdgeRequestResult(result, fallback) {
28956
+ if (!result || typeof result !== "object") return {
28957
+ kind: "continue",
28958
+ request: fallback
28959
+ };
28960
+ const obj = result;
28961
+ if ("status" in obj) return {
28962
+ kind: "response",
28963
+ response: coerceEdgeResponse(obj)
28964
+ };
28965
+ return {
28966
+ kind: "continue",
28967
+ request: coerceEdgeRequest(obj, fallback)
28968
+ };
28969
+ }
28970
+ /** Interpret a response-stage handler's return value as the (modified) response. */
28971
+ function interpretEdgeResponseResult(result, fallback) {
28972
+ if (!result || typeof result !== "object") return fallback;
28973
+ return coerceEdgeResponse(result, fallback);
28974
+ }
28975
+ /** Collapse an {@link EdgeResponse} into the server's status / headers / body. */
28976
+ function edgeResponseToResult(response, fallbackBody) {
28977
+ const statusCode = Number.parseInt(response.status, 10);
28978
+ const { headers, setCookies } = edgeHeadersToHttp(response.headers ?? {});
28979
+ let body;
28980
+ if (response.body !== void 0) body = response.bodyEncoding === "base64" ? Buffer.from(response.body, "base64") : Buffer.from(response.body);
28981
+ else body = fallbackBody ?? Buffer.alloc(0);
28982
+ return {
28983
+ statusCode: Number.isFinite(statusCode) ? statusCode : 500,
28984
+ headers,
28985
+ setCookies,
28986
+ body
28987
+ };
28988
+ }
28989
+ /**
28990
+ * Server-facing request-stage orchestration: given a handler's raw return value
28991
+ * and the current request input, produce either the (modified) request to
28992
+ * continue with, or the generated response to short-circuit.
28993
+ */
28994
+ function applyEdgeRequestResult(result, base) {
28995
+ const outcome = interpretEdgeRequestResult(result, toEdgeRequest(base, false));
28996
+ if (outcome.kind === "response") return {
28997
+ kind: "response",
28998
+ response: edgeResponseToResult(outcome.response)
28999
+ };
29000
+ return {
29001
+ kind: "continue",
29002
+ request: applyEdgeRequest(base, outcome.request)
29003
+ };
29004
+ }
29005
+ /**
29006
+ * Server-facing response-stage orchestration: apply a handler's modified
29007
+ * response over the current status / headers, keeping the origin body unless the
29008
+ * function replaced it.
29009
+ */
29010
+ function applyEdgeResponseResult(result, base, originBody) {
29011
+ return edgeResponseToResult(interpretEdgeResponseResult(result, {
29012
+ status: String(base.statusCode),
29013
+ headers: httpHeadersToEdge(toMultiMap(base.headers))
29014
+ }), originBody);
29015
+ }
29016
+ /** Apply a request-stage function's modified request back onto the server's request input. */
29017
+ function applyEdgeRequest(base, request) {
29018
+ const out = {
29019
+ clientIp: base.clientIp,
29020
+ method: typeof request.method === "string" ? request.method : base.method,
29021
+ uri: typeof request.uri === "string" ? request.uri : base.uri,
29022
+ querystring: typeof request.querystring === "string" ? request.querystring : base.querystring,
29023
+ headers: edgeHeadersToRawMap(request.headers) ?? base.headers
29024
+ };
29025
+ if (request.body && request.body.action === "replace" && typeof request.body.data === "string") out.body = request.body.encoding === "base64" ? Buffer.from(request.body.data, "base64") : Buffer.from(request.body.data);
29026
+ else if (base.body !== void 0) out.body = base.body;
29027
+ return out;
29028
+ }
29029
+ function edgeHeadersToRawMap(headers) {
29030
+ if (!headers || typeof headers !== "object") return void 0;
29031
+ const out = {};
29032
+ for (const [name, entries] of Object.entries(headers)) {
29033
+ if (!Array.isArray(entries)) continue;
29034
+ out[name.toLowerCase()] = entries.filter((e) => e && typeof e.value === "string").map((e) => e.value);
29035
+ }
29036
+ return out;
29037
+ }
29038
+ function coerceEdgeRequest(obj, fallback) {
29039
+ const out = {
29040
+ clientIp: typeof obj["clientIp"] === "string" ? obj["clientIp"] : fallback.clientIp,
29041
+ method: typeof obj["method"] === "string" ? obj["method"] : fallback.method,
29042
+ uri: typeof obj["uri"] === "string" ? obj["uri"] : fallback.uri,
29043
+ querystring: typeof obj["querystring"] === "string" ? obj["querystring"] : fallback.querystring,
29044
+ headers: coerceEdgeHeaders(obj["headers"]) ?? fallback.headers
29045
+ };
29046
+ const body = obj["body"];
29047
+ if (body && typeof body === "object") {
29048
+ const b = body;
29049
+ out.body = {
29050
+ action: b["action"] === "replace" ? "replace" : "read-only",
29051
+ data: typeof b["data"] === "string" ? b["data"] : "",
29052
+ encoding: b["encoding"] === "text" ? "text" : "base64",
29053
+ inputTruncated: b["inputTruncated"] === true
29054
+ };
29055
+ }
29056
+ return out;
29057
+ }
29058
+ function coerceEdgeResponse(obj, fallback) {
29059
+ const out = {
29060
+ status: typeof obj["status"] === "string" ? obj["status"] : typeof obj["status"] === "number" ? String(obj["status"]) : fallback?.status ?? "200",
29061
+ headers: coerceEdgeHeaders(obj["headers"]) ?? fallback?.headers ?? {}
29062
+ };
29063
+ if (typeof obj["statusDescription"] === "string") out.statusDescription = obj["statusDescription"];
29064
+ else if (fallback?.statusDescription !== void 0) out.statusDescription = fallback.statusDescription;
29065
+ if (typeof obj["body"] === "string") {
29066
+ out.body = obj["body"];
29067
+ if (obj["bodyEncoding"] === "base64" || obj["bodyEncoding"] === "text") out.bodyEncoding = obj["bodyEncoding"];
29068
+ }
29069
+ return out;
29070
+ }
29071
+ /** Coerce an arbitrary value into the EdgeHeaders shape, tolerating a bare `{name: 'value'}` map. */
29072
+ function coerceEdgeHeaders(value) {
29073
+ if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
29074
+ const out = {};
29075
+ for (const [name, raw] of Object.entries(value)) {
29076
+ const lower = name.toLowerCase();
29077
+ if (Array.isArray(raw)) out[lower] = raw.filter((e) => !!e && typeof e === "object").map((e) => ({
29078
+ key: typeof e["key"] === "string" ? e["key"] : name,
29079
+ value: typeof e["value"] === "string" ? e["value"] : String(e["value"] ?? "")
29080
+ }));
29081
+ else if (typeof raw === "string") out[lower] = [{
29082
+ key: name,
29083
+ value: raw
29084
+ }];
29085
+ }
29086
+ return out;
29087
+ }
29088
+ function toMultiMap(headers) {
29089
+ const out = {};
29090
+ for (const [name, value] of Object.entries(headers)) out[name] = [value];
29091
+ return out;
29092
+ }
29093
+ function statusText(code) {
29094
+ return STATUS_TEXT[code] ?? "";
29095
+ }
29096
+ const STATUS_TEXT = {
29097
+ 200: "OK",
29098
+ 201: "Created",
29099
+ 204: "No Content",
29100
+ 301: "Moved Permanently",
29101
+ 302: "Found",
29102
+ 303: "See Other",
29103
+ 304: "Not Modified",
29104
+ 307: "Temporary Redirect",
29105
+ 308: "Permanent Redirect",
29106
+ 400: "Bad Request",
29107
+ 401: "Unauthorized",
29108
+ 403: "Forbidden",
29109
+ 404: "Not Found",
29110
+ 500: "Internal Server Error",
29111
+ 502: "Bad Gateway",
29112
+ 503: "Service Unavailable"
29113
+ };
29114
+
28802
29115
  //#endregion
28803
29116
  //#region src/local/cloudfront-lambda-origin.ts
28804
29117
  /**
@@ -28983,9 +29296,10 @@ function contentTypeForKey(key) {
28983
29296
  async function startCloudFrontServer(options) {
28984
29297
  const logger = getLogger().child("cloudfront");
28985
29298
  const lambdaInvokers = options.lambdaInvokers ?? /* @__PURE__ */ new Map();
29299
+ const edgeInvokers = options.edgeInvokers ?? /* @__PURE__ */ new Map();
28986
29300
  const state = { distribution: options.distribution };
28987
29301
  const handler = (req, res) => {
28988
- handleRequest$1(req, res, state, lambdaInvokers, logger).catch((err) => {
29302
+ handleRequest$1(req, res, state, lambdaInvokers, edgeInvokers, logger).catch((err) => {
28989
29303
  logger.warn(`Request handling failed: ${err instanceof Error ? err.message : String(err)}`);
28990
29304
  if (!res.headersSent) {
28991
29305
  res.statusCode = 500;
@@ -29015,7 +29329,7 @@ async function startCloudFrontServer(options) {
29015
29329
  };
29016
29330
  }
29017
29331
  /** The per-request pipeline: behavior match -> viewer-request -> origin -> viewer-response. */
29018
- async function handleRequest$1(req, res, state, lambdaInvokers, logger) {
29332
+ async function handleRequest$1(req, res, state, lambdaInvokers, edgeInvokers, logger) {
29019
29333
  const distribution = state.distribution;
29020
29334
  const rawUrl = req.url ?? "/";
29021
29335
  const queryIdx = rawUrl.indexOf("?");
@@ -29038,37 +29352,72 @@ async function handleRequest$1(req, res, state, lambdaInvokers, logger) {
29038
29352
  return;
29039
29353
  }
29040
29354
  }
29355
+ const config = {
29356
+ distributionDomainName: req.headers.host ?? "localhost",
29357
+ distributionId: distribution.logicalId,
29358
+ requestId: `cdkl-${Date.now().toString(36)}-${Math.floor(performance.now()).toString(36)}`
29359
+ };
29360
+ const clientIp = req.socket.remoteAddress ?? "127.0.0.1";
29041
29361
  let requestEvent = buildViewerRequestEvent({
29042
29362
  method: req.method ?? "GET",
29043
29363
  uri,
29044
29364
  querystring,
29045
29365
  headers: req.headers,
29046
- ip: req.socket.remoteAddress ?? "127.0.0.1",
29366
+ ip: clientIp,
29047
29367
  distributionId: distribution.logicalId,
29048
29368
  domainName: req.headers.host ?? "localhost",
29049
- requestId: `cdkl-${Date.now().toString(36)}-${Math.floor(performance.now()).toString(36)}`
29369
+ requestId: config.requestId
29050
29370
  });
29051
- let effectiveUri = uri;
29052
29371
  if (behavior.viewerRequest) {
29053
29372
  const outcome = await runViewerRequest(behavior.viewerRequest, requestEvent);
29054
29373
  if (outcome.kind === "response") {
29055
29374
  writeCfResponse(res, outcome.response, logger);
29056
29375
  return;
29057
29376
  }
29058
- effectiveUri = outcome.request.uri;
29059
29377
  requestEvent = {
29060
29378
  ...requestEvent,
29061
29379
  request: outcome.request
29062
29380
  };
29063
29381
  }
29382
+ let edgeInput = {
29383
+ clientIp,
29384
+ method: requestEvent.request.method,
29385
+ uri: requestEvent.request.uri,
29386
+ querystring: serializeCfQueryString(requestEvent.request.querystring),
29387
+ headers: cfHeadersToRawMap(requestEvent.request.headers)
29388
+ };
29389
+ for (const eventType of ["viewer-request", "origin-request"]) {
29390
+ const assoc = eventType === "viewer-request" ? behavior.lambdaEdge?.viewerRequest : behavior.lambdaEdge?.originRequest;
29391
+ if (!assoc) continue;
29392
+ const invoke = edgeInvokers.get(assoc.functionLogicalId);
29393
+ if (!invoke) {
29394
+ logger.warn(`Lambda@Edge ${eventType} function '${assoc.functionLogicalId}' was not booted (added after start-up); skipping. Restart start-cloudfront.`);
29395
+ continue;
29396
+ }
29397
+ if (assoc.includeBody && edgeInput.body === void 0) edgeInput = {
29398
+ ...edgeInput,
29399
+ body: await readRequestBody(req)
29400
+ };
29401
+ const outcome = applyEdgeRequestResult(await invoke(buildEdgeRequestEvent({
29402
+ eventType,
29403
+ config,
29404
+ request: edgeInput,
29405
+ includeBody: assoc.includeBody
29406
+ })), edgeInput);
29407
+ if (outcome.kind === "response") {
29408
+ writeEdgeResponse(res, outcome.response, behavior, req, logger);
29409
+ return;
29410
+ }
29411
+ edgeInput = outcome.request;
29412
+ }
29064
29413
  const origin = distribution.origins.get(behavior.targetOriginId);
29065
- const originResult = await serveFromOrigin(origin, behavior, {
29066
- uri: effectiveUri,
29067
- querystring,
29068
- method: req.method ?? "GET",
29069
- headers: req.headers,
29070
- readBody: () => readRequestBody(req),
29071
- sourceIp: req.socket.remoteAddress ?? "127.0.0.1",
29414
+ const originResult = await serveFromOrigin(origin, {
29415
+ uri: edgeInput.uri,
29416
+ querystring: edgeInput.querystring,
29417
+ method: edgeInput.method,
29418
+ headers: rawMapToIncomingHeaders(edgeInput.headers),
29419
+ readBody: () => edgeInput.body !== void 0 ? Promise.resolve(edgeInput.body) : readRequestBody(req),
29420
+ sourceIp: clientIp,
29072
29421
  distribution,
29073
29422
  lambdaInvokers,
29074
29423
  logger
@@ -29076,16 +29425,47 @@ async function handleRequest$1(req, res, state, lambdaInvokers, logger) {
29076
29425
  if (!originResult) return writePlain(res, 502, originUnavailableMessage(origin, behavior));
29077
29426
  let finalStatus = originResult.statusCode;
29078
29427
  let finalHeaders = originResult.headers;
29428
+ let finalBody = originResult.body;
29429
+ const setCookies = [...originResult.setCookies ?? []];
29430
+ if (behavior.lambdaEdge?.originResponse) {
29431
+ const r = await runEdgeResponseStage(behavior.lambdaEdge.originResponse, "origin-response", {
29432
+ config,
29433
+ request: edgeInput,
29434
+ statusCode: finalStatus,
29435
+ headers: finalHeaders,
29436
+ body: finalBody
29437
+ }, edgeInvokers, logger);
29438
+ if (r) {
29439
+ finalStatus = r.statusCode;
29440
+ finalHeaders = r.headers;
29441
+ finalBody = r.body;
29442
+ setCookies.push(...r.setCookies);
29443
+ }
29444
+ }
29079
29445
  if (behavior.viewerResponse) {
29080
29446
  const responseEvent = buildViewerResponseEvent(requestEvent, {
29081
- statusCode: originResult.statusCode,
29082
- headers: originResult.headers
29447
+ statusCode: finalStatus,
29448
+ headers: finalHeaders
29083
29449
  });
29084
29450
  const mutated = await runViewerResponse(behavior.viewerResponse, responseEvent);
29085
29451
  finalStatus = mutated.statusCode;
29086
- finalHeaders = cfHeadersToPlain(mutated.headers, originResult.headers);
29452
+ finalHeaders = cfHeadersToPlain(mutated.headers, finalHeaders);
29453
+ }
29454
+ if (behavior.lambdaEdge?.viewerResponse) {
29455
+ const r = await runEdgeResponseStage(behavior.lambdaEdge.viewerResponse, "viewer-response", {
29456
+ config,
29457
+ request: edgeInput,
29458
+ statusCode: finalStatus,
29459
+ headers: finalHeaders,
29460
+ body: finalBody
29461
+ }, edgeInvokers, logger);
29462
+ if (r) {
29463
+ finalStatus = r.statusCode;
29464
+ finalHeaders = r.headers;
29465
+ finalBody = r.body;
29466
+ setCookies.push(...r.setCookies);
29467
+ }
29087
29468
  }
29088
- const setCookies = [...originResult.setCookies ?? []];
29089
29469
  for (const name of Object.keys(finalHeaders)) if (name.toLowerCase() === "set-cookie") {
29090
29470
  setCookies.push(finalHeaders[name]);
29091
29471
  delete finalHeaders[name];
@@ -29101,7 +29481,54 @@ async function handleRequest$1(req, res, state, lambdaInvokers, logger) {
29101
29481
  const origin = req.headers.origin;
29102
29482
  applyCorsResponseHeadersFromConfig(res, behavior.cors, typeof origin === "string" ? origin : void 0);
29103
29483
  }
29104
- res.end(originResult.body);
29484
+ res.end(finalBody);
29485
+ }
29486
+ /** Run a Lambda@Edge response-stage function, returning the modified response (or undefined when no invoker). */
29487
+ async function runEdgeResponseStage(assoc, eventType, ctx, edgeInvokers, logger) {
29488
+ const invoke = edgeInvokers.get(assoc.functionLogicalId);
29489
+ if (!invoke) {
29490
+ logger.warn(`Lambda@Edge ${eventType} function '${assoc.functionLogicalId}' was not booted (added after start-up); skipping. Restart start-cloudfront.`);
29491
+ return;
29492
+ }
29493
+ return applyEdgeResponseResult(await invoke(buildEdgeResponseEvent({
29494
+ eventType,
29495
+ config: ctx.config,
29496
+ request: ctx.request,
29497
+ response: {
29498
+ statusCode: ctx.statusCode,
29499
+ headers: ctx.headers
29500
+ }
29501
+ })), {
29502
+ statusCode: ctx.statusCode,
29503
+ headers: ctx.headers
29504
+ }, ctx.body);
29505
+ }
29506
+ /** Write a Lambda@Edge generated response (request-stage short-circuit), incl. CORS. */
29507
+ function writeEdgeResponse(res, result, behavior, req, logger) {
29508
+ if (!req.readableEnded) req.resume();
29509
+ res.statusCode = result.statusCode;
29510
+ setHeadersSafely(res, result.headers, logger);
29511
+ if (result.setCookies.length > 0) try {
29512
+ res.setHeader("set-cookie", result.setCookies);
29513
+ } catch {}
29514
+ if (behavior.cors) {
29515
+ const origin = req.headers.origin;
29516
+ applyCorsResponseHeadersFromConfig(res, behavior.cors, typeof origin === "string" ? origin : void 0);
29517
+ }
29518
+ res.end(result.body);
29519
+ }
29520
+ /** Convert a CloudFront-Function header map (`{name: CfValue}`) into the raw `{name: string[]}` form. */
29521
+ function cfHeadersToRawMap(cf) {
29522
+ const out = {};
29523
+ for (const [name, val] of Object.entries(cf)) if (val.multiValue && val.multiValue.length > 0) out[name] = val.multiValue.map((m) => m.value);
29524
+ else out[name] = [val.value];
29525
+ return out;
29526
+ }
29527
+ /** Convert a raw `{name: string[]}` header map into Node's `IncomingHttpHeaders` shape. */
29528
+ function rawMapToIncomingHeaders(headers) {
29529
+ const out = {};
29530
+ for (const [name, values] of Object.entries(headers)) out[name] = values.length === 1 ? values[0] : values;
29531
+ return out;
29105
29532
  }
29106
29533
  /**
29107
29534
  * Convert Node's `IncomingMessage.headers` (`Record<string, string | string[]>`)
@@ -29138,9 +29565,8 @@ function setHeadersSafely(res, headers, logger) {
29138
29565
  logger.warn(`Skipping invalid response header '${name}': ${err instanceof Error ? err.message : String(err)}`);
29139
29566
  }
29140
29567
  }
29141
- async function serveFromOrigin(origin, behavior, args) {
29142
- const { distribution, logger } = args;
29143
- if (behavior.hasLambdaEdge) logger.warn(`Behavior ${behavior.pathPattern ?? "(default)"} carries a Lambda@Edge association; cdk-local does not run Lambda@Edge — serving the origin only.`);
29568
+ async function serveFromOrigin(origin, args) {
29569
+ const { distribution } = args;
29144
29570
  if (!origin) return void 0;
29145
29571
  if (origin.kind === "lambda-url") {
29146
29572
  const invoke = args.lambdaInvokers.get(origin.functionLogicalId);
@@ -29518,12 +29944,58 @@ async function bootLambdaUrlOrigins(distribution, stacks, opts) {
29518
29944
  runners
29519
29945
  };
29520
29946
  }
29947
+ /**
29948
+ * Boot one warm RIE container per unique Lambda@Edge function across the
29949
+ * distribution's behaviors (issue #400), returning the runners + an invoker map
29950
+ * keyed by backing-function logical id for {@link startCloudFrontServer}. Each
29951
+ * function gets the SAME container env as a direct `cdkl invoke` (declared env
29952
+ * vars + `--from-cfn-stack` substitution + `--assume-role` creds) via the shared
29953
+ * {@link resolveLambdaContainerEnv}. A function that cannot be booted is
29954
+ * warn-and-skipped (its edge stage will not run); booted once at start-up, NOT
29955
+ * rebuilt on a `--watch` reload.
29956
+ */
29957
+ async function bootLambdaEdgeFunctions(distribution, stacks, opts) {
29958
+ const logger = getLogger();
29959
+ const invokers = /* @__PURE__ */ new Map();
29960
+ const runners = [];
29961
+ const functionLogicalIds = /* @__PURE__ */ new Set();
29962
+ for (const behavior of distribution.behaviors) {
29963
+ const edge = behavior.lambdaEdge;
29964
+ if (!edge) continue;
29965
+ for (const assoc of [
29966
+ edge.viewerRequest,
29967
+ edge.originRequest,
29968
+ edge.originResponse,
29969
+ edge.viewerResponse
29970
+ ]) if (assoc) functionLogicalIds.add(assoc.functionLogicalId);
29971
+ }
29972
+ for (const functionLogicalId of functionLogicalIds) try {
29973
+ const lambda = resolveLambdaTarget(functionLogicalId, stacks);
29974
+ const containerEnv = await resolveLambdaContainerEnv(lambda, opts.envOptions, opts.profileCredentials);
29975
+ const runner = createFrontDoorLambdaRunner(lambda, {
29976
+ containerHost: opts.containerHost,
29977
+ skipPull: opts.skipPull,
29978
+ ...opts.envOptions.region !== void 0 && { region: opts.envOptions.region },
29979
+ containerEnv: containerEnv.env,
29980
+ ...containerEnv.sensitiveEnvKeys.length > 0 && { sensitiveEnvKeys: new Set(containerEnv.sensitiveEnvKeys) }
29981
+ });
29982
+ logger.info(`Booting Lambda@Edge container for ${functionLogicalId} (the function runs locally via RIE)...`);
29983
+ await runner.start();
29984
+ runners.push(runner);
29985
+ invokers.set(functionLogicalId, (event) => runner.invoke(event));
29986
+ } catch (err) {
29987
+ logger.warn(`Could not boot Lambda@Edge function '${functionLogicalId}'; its stage will be skipped: ${err instanceof Error ? err.message : String(err)}`);
29988
+ }
29989
+ return {
29990
+ invokers,
29991
+ runners
29992
+ };
29993
+ }
29521
29994
  /** Emit boot-time WARNs for parts of the distribution cdk-local does not serve. */
29522
29995
  function warnUnsupported(distribution) {
29523
29996
  const logger = getLogger();
29524
29997
  for (const origin of distribution.origins.values()) if (origin.kind === "custom") logger.warn(`Origin '${origin.originId}' is a custom (non-S3, non-Lambda-Function-URL) origin (${origin.domainName}); ${getEmbedConfig().cliName} start-cloudfront serves S3 origins and Lambda Function URL origins only. Requests routed to it return 502.`);
29525
29998
  else if (origin.kind === "s3-unresolved") logger.warn(`Origin '${origin.originId}' is an S3 origin with no resolvable local source (no BucketDeployment found, or its source could not be located in the cloud assembly). Point it at a directory with --origin ${origin.originId}=<dir>. Requests routed to it return 502.`);
29526
- if (distribution.behaviors.some((b) => b.hasLambdaEdge)) logger.warn("One or more cache behaviors carry a Lambda@Edge association; cdk-local does not run Lambda@Edge functions — only CloudFront Functions + the S3 origin are served.");
29527
29999
  }
29528
30000
  async function localStartCloudFrontCommand(target, options) {
29529
30001
  const logger = getLogger();
@@ -29579,24 +30051,33 @@ async function localStartCloudFrontCommand(target, options) {
29579
30051
  ...options.stackRegion !== void 0 && { stackRegion: options.stackRegion }
29580
30052
  };
29581
30053
  await attachKvsModules(initial.distribution, initial.stacks, options, profileCredentials, logger);
29582
- const { invokers: lambdaInvokers, runners: lambdaRunners } = await bootLambdaUrlOrigins(initial.distribution, initial.stacks, {
30054
+ const bootOpts = {
29583
30055
  containerHost: options.host,
29584
30056
  skipPull: options.pull === false,
29585
30057
  envOptions,
29586
30058
  ...profileCredentials !== void 0 && { profileCredentials }
29587
- });
29588
- let tls;
29589
- if (tlsRequested) tls = await resolveFrontDoorTlsMaterials({
29590
- certPath: options.tlsCert,
29591
- keyPath: options.tlsKey
29592
- });
29593
- const server = await startCloudFrontServer({
29594
- distribution: initial.distribution,
29595
- host: options.host,
29596
- port: basePort,
29597
- ...tls && { tls },
29598
- ...lambdaInvokers.size > 0 && { lambdaInvokers }
29599
- });
30059
+ };
30060
+ const { invokers: lambdaInvokers, runners: lambdaRunners } = await bootLambdaUrlOrigins(initial.distribution, initial.stacks, bootOpts);
30061
+ const { invokers: edgeInvokers, runners: edgeRunners } = await bootLambdaEdgeFunctions(initial.distribution, initial.stacks, bootOpts);
30062
+ let server;
30063
+ try {
30064
+ let tls;
30065
+ if (tlsRequested) tls = await resolveFrontDoorTlsMaterials({
30066
+ certPath: options.tlsCert,
30067
+ keyPath: options.tlsKey
30068
+ });
30069
+ server = await startCloudFrontServer({
30070
+ distribution: initial.distribution,
30071
+ host: options.host,
30072
+ port: basePort,
30073
+ ...tls && { tls },
30074
+ ...lambdaInvokers.size > 0 && { lambdaInvokers },
30075
+ ...edgeInvokers.size > 0 && { edgeInvokers }
30076
+ });
30077
+ } catch (err) {
30078
+ await Promise.all([...lambdaRunners, ...edgeRunners].map((r) => r.stop().catch(() => void 0)));
30079
+ throw err;
30080
+ }
29600
30081
  process.stdout.write(`CloudFront distribution serving on ${server.url} (${initial.distribution.logicalId})\n`);
29601
30082
  process.stdout.write("^C to stop.\n");
29602
30083
  let watcher;
@@ -29640,8 +30121,8 @@ async function localStartCloudFrontCommand(target, options) {
29640
30121
  try {
29641
30122
  await server.close();
29642
30123
  } catch {}
29643
- await Promise.all(lambdaRunners.map((r) => r.stop().catch((err) => {
29644
- logger.debug(`Lambda origin runner stop failed: ${err instanceof Error ? err.message : String(err)}`);
30124
+ await Promise.all([...lambdaRunners, ...edgeRunners].map((r) => r.stop().catch((err) => {
30125
+ logger.debug(`Lambda runner stop failed: ${err instanceof Error ? err.message : String(err)}`);
29645
30126
  })));
29646
30127
  process.exit(exitCode);
29647
30128
  };
@@ -34707,5 +35188,5 @@ function addStudioSpecificOptions(cmd) {
34707
35188
  }
34708
35189
 
34709
35190
  //#endregion
34710
- export { createUnboundCloudFrontModule as $, pickResponseTemplate as $n, resolveAgentCoreTarget as $r, AGENTCORE_SESSION_ID_HEADER as $t, parseOriginOverrides as A, buildCognitoJwksUrl as An, CfnLocalStateProvider as Ar, describePinnedImageUri as At, CLOUDFRONT_DISTRIBUTION_TYPE as B, invokeTokenAuthorizer as Bn, filterWebSocketApisByIdentifiers as Br, addInvokeAgentCoreSpecificOptions as Bt, addListSpecificOptions as C, filterRoutesByApiIdentifiers as Cn, LocalStateSourceError as Cr, ImageOverrideError as Ct, addStartCloudFrontSpecificOptions as D, resolveSelectionExpression as Dn, resolveCfnFallbackRegion as Dr, parseImageOverrideFlags as Dt, LocalStartCloudFrontError as E, startApiServer as En, rejectExplicitCfnStackWithMultipleStacks as Er, mergeForService as Et, resolveDeployedKvsArnByName as F, verifyJwtViaDiscovery as Fn, countTargets as Fr, DEFAULT_SHADOW_READY_TIMEOUT_MS as Ft, pickTargetFunctionLogicalId as G, isFunctionUrlOacFronted as Gn, resolveLambdaArnIntrinsic as Gr, a2aInvokeOnce as Gt, isCloudFrontDistribution as H, applyCorsResponseHeaders as Hn, webSocketApiMatchesIdentifier as Hr, invokeAgentCoreWs as Ht, matchBehavior as I, buildMethodArn as In, listTargets as Ir, SOFT_RELOAD_COMPLETION_LOG_SUFFIX as It, runViewerRequest as J, translateLambdaResponse as Jn, AGENTCORE_HTTP_PROTOCOL as Jr, MCP_PROTOCOL_VERSION as Jt, resolveCloudFrontDistribution as K, matchPreflight as Kn, AGENTCORE_A2A_PROTOCOL as Kr, MCP_CONTAINER_PORT as Kt, startCloudFrontServer as L, computeRequestIdentityHash as Ln, availableWebSocketApiIdentifiers as Lr, setShadowReadyTimeoutMs as Lt, idFromArn as M, createJwksCache as Mn, resolveSsmParameters as Mr, listPinnedTargets as Mt, resolveKvsModulesForDistribution as N, verifyCognitoJwt as Nn, resolveWatchConfig as Nr, buildCloudMapIndex as Nt, createLocalStartCloudFrontCommand as O, resolveServiceIntegrationParameters as On, resolveCfnRegion as Or, resolveImageOverrides as Ot, createDeployedKvsDataSource as P, verifyJwtAuthorizer as Pn, resolveSingleTarget as Pr, CloudMapRegistry as Pt, createLocalFileKvsDataSource as Q, evaluateResponseParameters as Qn, pickAgentCoreCandidateStack as Qr, signAgentCoreInvocation as Qt, serveFromStaticOrigin as R, evaluateCachedLambdaPolicy as Rn, discoverWebSocketApis as Rr, getContainerNetworkIp as Rt, StudioEventBus as S, filterRoutesByApiIdentifier as Sn, substituteEnvVarsFromStateAsync as Sr, runEcsServiceEmulator as St, formatTargetListing as T, readMtlsMaterialsFromDisk as Tn, isCfnFlagPresent as Tr, enforceImageOverrideOrphans as Tt, pickFunctionUrlLogicalIdFromOrigin as U, buildCorsConfigByApiId as Un, discoverRoutes as Ur, A2A_CONTAINER_PORT as Ut, extractKvsAssociations as V, attachAuthorizers as Vn, parseSelectionExpressionPath as Vr, createLocalInvokeAgentCoreCommand as Vt, pickKvsLogicalIdFromArn as W, buildCorsConfigFromCloudFrontChain as Wn, pickRefLogicalId as Wr, A2A_PATH as Wt, stripCloudFrontImport as X, buildHttpApiV2Event as Xn, AGENTCORE_RUNTIME_TYPE as Xr, parseSseForJsonRpc as Xt, runViewerResponse as Y, applyAuthorizerOverlay as Yn, AGENTCORE_MCP_PROTOCOL as Yr, mcpInvokeOnce as Yt, createCloudFrontModule as Z, buildRestV1Event as Zn, AgentCoreResolutionError as Zr, AGENTCORE_SIGV4_SERVICE as Zt, filterStudioTargetGroups as _, attachStageContext as _n, resolveRuntimeImage as _r, ecsClusterOption as _t, createLocalStudioCommand as a, buildStsClientConfig as ai, computeCodeImageTag as an, bufferToBody as ar, isApplicationLoadBalancer as at, renderStudioHtml as b, resolveEnvVars$1 as bn, substituteAgainstStateAsync as br, resolveEcsAssumeRoleOption as bt, startStudioProxy as c, classifySourceChange as cn, handleConnectionsRequest as cr, createLocalStartServiceCommand as ct, createStudioDispatcher as d, addStartApiSpecificOptions as dn, buildDisconnectEvent as dr, createLocalRunTaskCommand as dt, derivePseudoParametersFromRegion as ei, invokeAgentCore as en, selectIntegrationResponse as er, addAlbSpecificOptions as et, filterStudioCustomResources as f, createLocalStartApiCommand as fn, buildMessageEvent as fr, MAX_TASKS_SUBNET_RANGE_CAP as ft, annotatePinnedEcsTargets as g, createFileWatcher as gn, resolveRuntimeFileExtension as gr, buildEcsImageResolutionContext$1 as gt, annotateEcsTaskPinnedTargets as h, createAuthorizerCache as hn, resolveRuntimeCodeMountPath as hr, addImageOverrideOptions as ht, coerceStopRequest as i, LocalInvokeBuildError as ii, buildAgentCoreCodeImage as in, probeHostGatewaySupport as ir, resolveAlbTarget as it, resolveCloudFrontTarget as j, buildJwksUrlFromIssuer as jn, collectSsmParameterRefs as jr, isLocalCdkAssetImage as jt, parseKvsFileOverrides as k, defaultCredentialsLoader as kn, resolveCfnStackName as kr, runImageOverrideBuilds as kt, relayServeRequest as l, addInvokeSpecificOptions as ln, parseConnectionsPath as lr, serviceStrategy as lt, annotateAlbPinnedBackingServices as m, resolveApiTargetSubset as mn, buildContainerImage as mr, addEcsAssumeRoleOptions as mt, coerceRunRequest as n, substituteImagePlaceholders as ni, downloadAndExtractS3Bundle as nn, VtlEvaluationError as nr, createLocalStartAlbCommand as nt, resolveServeBaseUrl as o, resolveProfileCredentials as oi, renderCodeDockerfile as on, ConnectionRegistry as or, resolveAlbFrontDoor as ot, isCustomResourceLambdaTarget as p, createWatchPredicates as pn, architectureToPlatform as pr, addCommonEcsServiceOptions as pt, compileCloudFrontFunction as q, matchRoute as qn, AGENTCORE_AGUI_PROTOCOL as qr, MCP_PATH as qt, coerceServeRequest as r, tryResolveImageFnJoin as ri, SUPPORTED_CODE_RUNTIMES as rn, HOST_GATEWAY_MIN_VERSION as rr, parseLbPortOverrides as rt, createStudioServeManager as s, toCmdArgv as sn, buildMgmtEndpointEnvUrl as sr, addStartServiceSpecificOptions as st, addStudioSpecificOptions as t, formatStateRemedy as ti, waitForAgentCorePing as tn, tryParseStatus as tr, albStrategy as tt, reinvoke as u, createLocalInvokeCommand as un, buildConnectEvent as ur, addRunTaskSpecificOptions as ut, startStudioServer as v, buildStageMap as vn, EcsTaskResolutionError as vr, parseMaxTasks as vt, createLocalListCommand as w, groupRoutesByServer as wn, createLocalStateProvider as wr, buildImageOverrideTag as wt, createStudioStore as x, availableApiIdentifiers as xn, substituteEnvVarsFromState as xr, resolveSharedSidecarCredentials as xt, toStudioTargetGroups as y, materializeLayerFromArn as yn, substituteAgainstState as yr, parseRestartPolicy as yt, serveLambdaUrlOrigin as z, invokeRequestAuthorizer as zn, discoverWebSocketApisOrThrow as zr, attachContainerLogStreamer as zt };
34711
- //# sourceMappingURL=local-studio-DPEUB-rH.js.map
35191
+ export { resolveCloudFrontDistribution as $, matchPreflight as $n, AGENTCORE_A2A_PROTOCOL as $r, MCP_CONTAINER_PORT as $t, parseOriginOverrides as A, filterRoutesByApiIdentifiers as An, LocalStateSourceError as Ar, ImageOverrideError as At, applyEdgeRequestResult as B, verifyCognitoJwt as Bn, resolveWatchConfig as Br, buildCloudMapIndex as Bt, addListSpecificOptions as C, createFileWatcher as Cn, resolveRuntimeFileExtension as Cr, buildEcsImageResolutionContext$1 as Ct, addStartCloudFrontSpecificOptions as D, resolveEnvVars$1 as Dn, substituteAgainstStateAsync as Dr, resolveEcsAssumeRoleOption as Dt, LocalStartCloudFrontError as E, materializeLayerFromArn as En, substituteAgainstState as Er, parseRestartPolicy as Et, resolveDeployedKvsArnByName as F, resolveServiceIntegrationParameters as Fn, resolveCfnRegion as Fr, resolveImageOverrides as Ft, httpHeadersToEdge as G, evaluateCachedLambdaPolicy as Gn, discoverWebSocketApis as Gr, getContainerNetworkIp as Gt, buildEdgeRequestEvent as H, verifyJwtViaDiscovery as Hn, countTargets as Hr, DEFAULT_SHADOW_READY_TIMEOUT_MS as Ht, matchBehavior as I, defaultCredentialsLoader as In, resolveCfnStackName as Ir, runImageOverrideBuilds as It, isCloudFrontDistribution as J, attachAuthorizers as Jn, parseSelectionExpressionPath as Jr, createLocalInvokeAgentCoreCommand as Jt, CLOUDFRONT_DISTRIBUTION_TYPE as K, invokeRequestAuthorizer as Kn, discoverWebSocketApisOrThrow as Kr, attachContainerLogStreamer as Kt, startCloudFrontServer as L, buildCognitoJwksUrl as Ln, CfnLocalStateProvider as Lr, describePinnedImageUri as Lt, idFromArn as M, readMtlsMaterialsFromDisk as Mn, isCfnFlagPresent as Mr, enforceImageOverrideOrphans as Mt, resolveKvsModulesForDistribution as N, startApiServer as Nn, rejectExplicitCfnStackWithMultipleStacks as Nr, mergeForService as Nt, createLocalStartCloudFrontCommand as O, availableApiIdentifiers as On, substituteEnvVarsFromState as Or, resolveSharedSidecarCredentials as Ot, createDeployedKvsDataSource as P, resolveSelectionExpression as Pn, resolveCfnFallbackRegion as Pr, parseImageOverrideFlags as Pt, pickTargetFunctionLogicalId as Q, isFunctionUrlOacFronted as Qn, resolveLambdaArnIntrinsic as Qr, a2aInvokeOnce as Qt, serveFromStaticOrigin as R, buildJwksUrlFromIssuer as Rn, collectSsmParameterRefs as Rr, isLocalCdkAssetImage as Rt, StudioEventBus as S, createAuthorizerCache as Sn, resolveRuntimeCodeMountPath as Sr, addImageOverrideOptions as St, formatTargetListing as T, buildStageMap as Tn, EcsTaskResolutionError as Tr, parseMaxTasks as Tt, buildEdgeResponseEvent as U, buildMethodArn as Un, listTargets as Ur, SOFT_RELOAD_COMPLETION_LOG_SUFFIX as Ut, applyEdgeResponseResult as V, verifyJwtAuthorizer as Vn, resolveSingleTarget as Vr, CloudMapRegistry as Vt, edgeHeadersToHttp as W, computeRequestIdentityHash as Wn, availableWebSocketApiIdentifiers as Wr, setShadowReadyTimeoutMs as Wt, pickKvsLogicalIdFromArn as X, buildCorsConfigByApiId as Xn, discoverRoutes as Xr, A2A_CONTAINER_PORT as Xt, pickFunctionUrlLogicalIdFromOrigin as Y, applyCorsResponseHeaders as Yn, webSocketApiMatchesIdentifier as Yr, invokeAgentCoreWs as Yt, pickLambdaEdgeFunctionLogicalId as Z, buildCorsConfigFromCloudFrontChain as Zn, pickRefLogicalId as Zr, A2A_PATH as Zt, filterStudioTargetGroups as _, createLocalInvokeCommand as _n, buildConnectEvent as _r, addRunTaskSpecificOptions as _t, createLocalStudioCommand as a, pickAgentCoreCandidateStack as ai, signAgentCoreInvocation as an, evaluateResponseParameters as ar, createLocalFileKvsDataSource as at, renderStudioHtml as b, createWatchPredicates as bn, architectureToPlatform as br, addCommonEcsServiceOptions as bt, startStudioProxy as c, formatStateRemedy as ci, waitForAgentCorePing as cn, tryParseStatus as cr, albStrategy as ct, createStudioDispatcher as d, LocalInvokeBuildError as di, buildAgentCoreCodeImage as dn, probeHostGatewaySupport as dr, resolveAlbTarget as dt, AGENTCORE_AGUI_PROTOCOL as ei, MCP_PATH as en, matchRoute as er, compileCloudFrontFunction as et, filterStudioCustomResources as f, buildStsClientConfig as fi, computeCodeImageTag as fn, bufferToBody as fr, isApplicationLoadBalancer as ft, annotatePinnedEcsTargets as g, addInvokeSpecificOptions as gn, parseConnectionsPath as gr, serviceStrategy as gt, annotateEcsTaskPinnedTargets as h, classifySourceChange as hn, handleConnectionsRequest as hr, createLocalStartServiceCommand as ht, coerceStopRequest as i, AgentCoreResolutionError as ii, AGENTCORE_SIGV4_SERVICE as in, buildRestV1Event as ir, createCloudFrontModule as it, resolveCloudFrontTarget as j, groupRoutesByServer as jn, createLocalStateProvider as jr, buildImageOverrideTag as jt, parseKvsFileOverrides as k, filterRoutesByApiIdentifier as kn, substituteEnvVarsFromStateAsync as kr, runEcsServiceEmulator as kt, relayServeRequest as l, substituteImagePlaceholders as li, downloadAndExtractS3Bundle as ln, VtlEvaluationError as lr, createLocalStartAlbCommand as lt, annotateAlbPinnedBackingServices as m, toCmdArgv as mn, buildMgmtEndpointEnvUrl as mr, addStartServiceSpecificOptions as mt, coerceRunRequest as n, AGENTCORE_MCP_PROTOCOL as ni, mcpInvokeOnce as nn, applyAuthorizerOverlay as nr, runViewerResponse as nt, resolveServeBaseUrl as o, resolveAgentCoreTarget as oi, AGENTCORE_SESSION_ID_HEADER as on, pickResponseTemplate as or, createUnboundCloudFrontModule as ot, isCustomResourceLambdaTarget as p, resolveProfileCredentials as pi, renderCodeDockerfile as pn, ConnectionRegistry as pr, resolveAlbFrontDoor as pt, extractKvsAssociations as q, invokeTokenAuthorizer as qn, filterWebSocketApisByIdentifiers as qr, addInvokeAgentCoreSpecificOptions as qt, coerceServeRequest as r, AGENTCORE_RUNTIME_TYPE as ri, parseSseForJsonRpc as rn, buildHttpApiV2Event as rr, stripCloudFrontImport as rt, createStudioServeManager as s, derivePseudoParametersFromRegion as si, invokeAgentCore as sn, selectIntegrationResponse as sr, addAlbSpecificOptions as st, addStudioSpecificOptions as t, AGENTCORE_HTTP_PROTOCOL as ti, MCP_PROTOCOL_VERSION as tn, translateLambdaResponse as tr, runViewerRequest as tt, reinvoke as u, tryResolveImageFnJoin as ui, SUPPORTED_CODE_RUNTIMES as un, HOST_GATEWAY_MIN_VERSION as ur, parseLbPortOverrides as ut, startStudioServer as v, addStartApiSpecificOptions as vn, buildDisconnectEvent as vr, createLocalRunTaskCommand as vt, createLocalListCommand as w, attachStageContext as wn, resolveRuntimeImage as wr, ecsClusterOption as wt, createStudioStore as x, resolveApiTargetSubset as xn, buildContainerImage as xr, addEcsAssumeRoleOptions as xt, toStudioTargetGroups as y, createLocalStartApiCommand as yn, buildMessageEvent as yr, MAX_TASKS_SUBNET_RANGE_CAP as yt, serveLambdaUrlOrigin as z, createJwksCache as zn, resolveSsmParameters as zr, listPinnedTargets as zt };
35192
+ //# sourceMappingURL=local-studio--ndMb9dM.js.map