cdk-local 0.52.0 → 0.53.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/cli.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import { a as createLocalStartApiCommand } from "./cloud-map-resolver-D0OCnW6R.js";
3
- import { a as createLocalRunTaskCommand, i as createLocalStartServiceCommand, o as createLocalInvokeAgentCoreCommand, r as createLocalStartAlbCommand, s as createLocalInvokeCommand, t as createLocalListCommand } from "./local-list-v8D51s5a.js";
2
+ import { a as createLocalStartApiCommand } from "./cloud-map-resolver-CbSdXQjx.js";
3
+ import { a as createLocalRunTaskCommand, i as createLocalStartServiceCommand, o as createLocalInvokeAgentCoreCommand, r as createLocalStartAlbCommand, s as createLocalInvokeCommand, t as createLocalListCommand } from "./local-list-B1RsKINr.js";
4
4
  import { Command } from "commander";
5
5
 
6
6
  //#region src/cli/index.ts
7
7
  const program = new Command();
8
- program.name("cdkl").description("Run AWS CDK stacks locally with Docker.").version("0.52.0");
8
+ program.name("cdkl").description("Run AWS CDK stacks locally with Docker.").version("0.53.0");
9
9
  program.addCommand(createLocalInvokeCommand());
10
10
  program.addCommand(createLocalInvokeAgentCoreCommand());
11
11
  program.addCommand(createLocalStartApiCommand());
@@ -24,6 +24,8 @@ import { setTimeout as setTimeout$1 } from "node:timers/promises";
24
24
  import { readFile } from "fs/promises";
25
25
  import { join as join$1 } from "path";
26
26
  import { unzipSync } from "fflate";
27
+ import { Sha256 } from "@aws-crypto/sha256-js";
28
+ import { SignatureV4 } from "@smithy/signature-v4";
27
29
  import { WebSocket, WebSocketServer } from "ws";
28
30
  import { createServer as createServer$1 } from "node:http";
29
31
  import { createServer as createServer$2 } from "node:https";
@@ -8030,7 +8032,8 @@ async function invokeAgentCore(host, port, event, options) {
8030
8032
  "Content-Type": "application/json",
8031
8033
  Accept: "application/json, text/event-stream",
8032
8034
  [AGENTCORE_SESSION_ID_HEADER]: options.sessionId,
8033
- ...options.authorization && { Authorization: options.authorization }
8035
+ ...options.authorization && { Authorization: options.authorization },
8036
+ ...options.additionalHeaders ?? {}
8034
8037
  },
8035
8038
  body,
8036
8039
  signal: controller.signal
@@ -8084,6 +8087,71 @@ async function streamBody(body, onChunk) {
8084
8087
  }
8085
8088
  }
8086
8089
 
8090
+ //#endregion
8091
+ //#region src/local/agentcore-sigv4-sign.ts
8092
+ /**
8093
+ * Client-side SigV4 signing for `cdkl invoke-agentcore --sigv4`.
8094
+ *
8095
+ * AgentCore's `InvokeAgentRuntime` API authenticates inbound `/invocations`
8096
+ * requests with IAM SigV4 when the runtime declares no
8097
+ * `customJwtAuthorizer`. The deployed cloud verifies the signature; a locally
8098
+ * running agent never does (no AWS public-key infra inside the container),
8099
+ * but an agent that introspects the `Authorization` header (e.g. via the
8100
+ * `bedrock-agentcore` SDK's request context) sees the same shape it would in
8101
+ * the cloud — header parity for debugging and local-dev of IAM-aware agents.
8102
+ *
8103
+ * Signing is OPT-IN via `--sigv4` on the command. Default behavior is
8104
+ * unchanged: no Authorization header on an unauthenticated invoke.
8105
+ */
8106
+ /** AWS service name for AgentCore InvokeAgentRuntime SigV4 signing. */
8107
+ const AGENTCORE_SIGV4_SERVICE = "bedrock-agentcore";
8108
+ /**
8109
+ * Build a SigV4 signature for a `POST /invocations` request to the local
8110
+ * AgentCore container. Returns the headers that must be forwarded.
8111
+ */
8112
+ async function signAgentCoreInvocation(opts) {
8113
+ const signer = new SignatureV4({
8114
+ credentials: {
8115
+ accessKeyId: opts.credentials.accessKeyId,
8116
+ secretAccessKey: opts.credentials.secretAccessKey,
8117
+ ...opts.credentials.sessionToken && { sessionToken: opts.credentials.sessionToken }
8118
+ },
8119
+ region: opts.region,
8120
+ service: AGENTCORE_SIGV4_SERVICE,
8121
+ sha256: Sha256
8122
+ });
8123
+ const request = {
8124
+ method: opts.method ?? "POST",
8125
+ protocol: "http:",
8126
+ hostname: opts.host,
8127
+ port: opts.port,
8128
+ path: opts.path,
8129
+ headers: {
8130
+ "Content-Type": "application/json",
8131
+ Host: `${opts.host}:${opts.port}`,
8132
+ [AGENTCORE_SESSION_ID_HEADER]: opts.sessionId
8133
+ },
8134
+ body: opts.body
8135
+ };
8136
+ const signed = await signer.sign(request, { ...opts.now && { signingDate: new Date(opts.now()) } });
8137
+ const get = (name) => {
8138
+ const lower = name.toLowerCase();
8139
+ for (const [k, v] of Object.entries(signed.headers)) if (k.toLowerCase() === lower) return v;
8140
+ };
8141
+ const authorization = get("authorization");
8142
+ const amzDate = get("x-amz-date");
8143
+ const amzContentSha256 = get("x-amz-content-sha256");
8144
+ if (!authorization || !amzDate) throw new Error("SigV4 signing produced no Authorization / X-Amz-Date header — internal error");
8145
+ const out = {
8146
+ authorization,
8147
+ amzDate,
8148
+ amzContentSha256: amzContentSha256 ?? ""
8149
+ };
8150
+ const amzSecurityToken = get("x-amz-security-token");
8151
+ if (amzSecurityToken) out.amzSecurityToken = amzSecurityToken;
8152
+ return out;
8153
+ }
8154
+
8087
8155
  //#endregion
8088
8156
  //#region src/local/agentcore-mcp-client.ts
8089
8157
  /**
@@ -17721,5 +17789,5 @@ function extractDnsRecords(serviceProps) {
17721
17789
  }
17722
17790
 
17723
17791
  //#endregion
17724
- export { attachAuthorizers as $, substituteAgainstState as $t, buildHttpApiV2Event as A, AGENTCORE_RUNTIME_TYPE as An, buildDockerImage as At, ConnectionRegistry as B, readCdkPathOrUndefined as Bn, streamLogs as Bt, computeRequestIdentityHash as C, discoverWebSocketApisOrThrow as Cn, getDockerImageBySourceHash as Ct, matchRoute as D, resolveLambdaArnIntrinsic as Dn, buildContainerImage as Dt, invokeTokenAuthorizer as E, pickRefLogicalId as En, architectureToPlatform as Et, tryParseStatus as F, derivePseudoParametersFromRegion as Fn, execEnvForSecrets as Ft, buildDisconnectEvent as G, withErrorHandling as Gn, TASK_ROLE_ACCOUNT_PLACEHOLDER as Gt, handleConnectionsRequest as H, CdkLocalError as Hn, resolveRuntimeFileExtension as Ht, VtlEvaluationError as I, substituteImagePlaceholders as In, pickFreePort as It, buildJwksUrlFromIssuer as J, commonOptions as Jn, derivePartitionAndUrlSuffix as Jt, buildMessageEvent as K, applyRoleArnIfSet as Kn, applyCrossStackResolverToTask as Kt, HOST_GATEWAY_MIN_VERSION as L, tryResolveImageFnJoin as Ln, pullImage as Lt, evaluateResponseParameters as M, pickAgentCoreCandidateStack as Mn, SENSITIVE_ENV_KEYS as Mt, pickResponseTemplate as N, resolveAgentCoreTarget as Nn, appendEnvFlags as Nt, translateLambdaResponse as O, AGENTCORE_HTTP_PROTOCOL as On, parseEcrUri as Ot, selectIntegrationResponse as P, resolveLambdaTarget as Pn, ensureDockerAvailable as Pt, verifyJwtViaDiscovery as Q, warnIfDeprecatedRegion as Qn, applyDeployedEnvFallback as Qt, probeHostGatewaySupport as R, matchStacks as Rn, removeContainer as Rt, buildMethodArn as S, discoverWebSocketApis as Sn, AssetManifestLoader as St, invokeRequestAuthorizer as T, discoverRoutes as Tn, waitForRieReady as Tt, parseConnectionsPath as U, LocalInvokeBuildError as Un, resolveRuntimeImage as Ut, buildMgmtEndpointEnvUrl as V, resolveCdkPathToLogicalIds as Vn, resolveRuntimeCodeMountPath as Vt, buildConnectEvent as W, LocalStartServiceError as Wn, EcsTaskResolutionError as Wt, verifyCognitoJwt as X, deprecatedRegionOption as Xn, parseEcsTarget as Xt, createJwksCache as Y, contextOptions as Yn, detectEcsImageResolutionNeeds as Yt, verifyJwtAuthorizer as Z, parseContextOptions as Zn, resolveEcsTaskTarget as Zt, readMtlsMaterialsFromDisk as _, Synthesizer as _n, computeCodeImageTag as _t, createLocalStartApiCommand as a, LocalStateSourceError as an, invokeAgentCoreWs as at, resolveServiceIntegrationParameters as b, countTargets as bn, writeProfileCredentialsFile as bt, resolveProfileCredentials as c, rejectExplicitCfnStackWithMultipleStacks as cn, MCP_PROTOCOL_VERSION as ct, attachStageContext as d, resolveCfnStackName as dn, AGENTCORE_SESSION_ID_HEADER as dt, substituteAgainstStateAsync as en, applyCorsResponseHeaders as et, buildStageMap as f, CfnLocalStateProvider as fn, invokeAgentCore as ft, groupRoutesByServer as g, resolveWatchConfig as gn, buildAgentCoreCodeImage as gt, filterRoutesByApiIdentifiers as h, resolveApp as hn, SUPPORTED_CODE_RUNTIMES as ht, getPublishedHostPort as i, materializeLayerFromArn as in, matchPreflight as it, buildRestV1Event as j, AgentCoreResolutionError as jn, DockerRunnerError as jt, applyAuthorizerOverlay as k, AGENTCORE_MCP_PROTOCOL as kn, pullEcrImage as kt, createAuthorizerCache as l, resolveCfnFallbackRegion as ln, mcpInvokeOnce as lt, filterRoutesByApiIdentifier as m, resolveSsmParameters as mn, downloadAndExtractS3Bundle as mt, CloudMapRegistry as n, substituteEnvVarsFromStateAsync as nn, buildCorsConfigFromCloudFrontChain as nt, createWatchPredicates as o, createLocalStateProvider as on, MCP_CONTAINER_PORT as ot, availableApiIdentifiers as p, collectSsmParameterRefs as pn, waitForAgentCorePing as pt, buildCognitoJwksUrl as q, appOptions as qn, checkVolumeHostPath as qt, getContainerNetworkIp as r, resolveEnvVars as rn, isFunctionUrlOacFronted as rt, resolveApiTargetSubset as s, isCfnFlagPresent as sn, MCP_PATH as st, buildCloudMapIndex as t, substituteEnvVarsFromState as tn, buildCorsConfigByApiId as tt, createFileWatcher as u, resolveCfnRegion as un, parseSseForJsonRpc as ut, startApiServer as v, resolveMultiTarget as vn, renderCodeDockerfile as vt, evaluateCachedLambdaPolicy as w, parseSelectionExpressionPath as wn, invokeRie as wt, defaultCredentialsLoader as x, listTargets as xn, singleFlight as xt, resolveSelectionExpression as y, resolveSingleTarget as yn, toCmdArgv as yt, bufferToBody as z, buildCdkPathIndex as zn, runDetached as zt };
17725
- //# sourceMappingURL=cloud-map-resolver-D0OCnW6R.js.map
17792
+ export { attachAuthorizers as $, parseContextOptions as $n, resolveEcsTaskTarget as $t, buildHttpApiV2Event as A, AGENTCORE_HTTP_PROTOCOL as An, parseEcrUri as At, ConnectionRegistry as B, matchStacks as Bn, removeContainer as Bt, computeRequestIdentityHash as C, listTargets as Cn, singleFlight as Ct, matchRoute as D, discoverRoutes as Dn, waitForRieReady as Dt, invokeTokenAuthorizer as E, parseSelectionExpressionPath as En, invokeRie as Et, tryParseStatus as F, resolveAgentCoreTarget as Fn, appendEnvFlags as Ft, buildDisconnectEvent as G, LocalInvokeBuildError as Gn, resolveRuntimeImage as Gt, handleConnectionsRequest as H, readCdkPathOrUndefined as Hn, streamLogs as Ht, VtlEvaluationError as I, resolveLambdaTarget as In, ensureDockerAvailable as It, buildJwksUrlFromIssuer as J, applyRoleArnIfSet as Jn, applyCrossStackResolverToTask as Jt, buildMessageEvent as K, LocalStartServiceError as Kn, EcsTaskResolutionError as Kt, HOST_GATEWAY_MIN_VERSION as L, derivePseudoParametersFromRegion as Ln, execEnvForSecrets as Lt, evaluateResponseParameters as M, AGENTCORE_RUNTIME_TYPE as Mn, buildDockerImage as Mt, pickResponseTemplate as N, AgentCoreResolutionError as Nn, DockerRunnerError as Nt, translateLambdaResponse as O, pickRefLogicalId as On, architectureToPlatform as Ot, selectIntegrationResponse as P, pickAgentCoreCandidateStack as Pn, SENSITIVE_ENV_KEYS as Pt, verifyJwtViaDiscovery as Q, deprecatedRegionOption as Qn, parseEcsTarget as Qt, probeHostGatewaySupport as R, substituteImagePlaceholders as Rn, pickFreePort as Rt, buildMethodArn as S, countTargets as Sn, writeProfileCredentialsFile as St, invokeRequestAuthorizer as T, discoverWebSocketApisOrThrow as Tn, getDockerImageBySourceHash as Tt, parseConnectionsPath as U, resolveCdkPathToLogicalIds as Un, resolveRuntimeCodeMountPath as Ut, buildMgmtEndpointEnvUrl as V, buildCdkPathIndex as Vn, runDetached as Vt, buildConnectEvent as W, CdkLocalError as Wn, resolveRuntimeFileExtension as Wt, verifyCognitoJwt as X, commonOptions as Xn, derivePartitionAndUrlSuffix as Xt, createJwksCache as Y, appOptions as Yn, checkVolumeHostPath as Yt, verifyJwtAuthorizer as Z, contextOptions as Zn, detectEcsImageResolutionNeeds as Zt, readMtlsMaterialsFromDisk as _, resolveApp as _n, SUPPORTED_CODE_RUNTIMES as _t, createLocalStartApiCommand as a, resolveEnvVars as an, invokeAgentCoreWs as at, resolveServiceIntegrationParameters as b, resolveMultiTarget as bn, renderCodeDockerfile as bt, resolveProfileCredentials as c, createLocalStateProvider as cn, MCP_PROTOCOL_VERSION as ct, attachStageContext as d, resolveCfnFallbackRegion as dn, AGENTCORE_SIGV4_SERVICE as dt, applyDeployedEnvFallback as en, warnIfDeprecatedRegion as er, applyCorsResponseHeaders as et, buildStageMap as f, resolveCfnRegion as fn, signAgentCoreInvocation as ft, groupRoutesByServer as g, resolveSsmParameters as gn, downloadAndExtractS3Bundle as gt, filterRoutesByApiIdentifiers as h, collectSsmParameterRefs as hn, waitForAgentCorePing as ht, getPublishedHostPort as i, substituteEnvVarsFromStateAsync as in, matchPreflight as it, buildRestV1Event as j, AGENTCORE_MCP_PROTOCOL as jn, pullEcrImage as jt, applyAuthorizerOverlay as k, resolveLambdaArnIntrinsic as kn, buildContainerImage as kt, createAuthorizerCache as l, isCfnFlagPresent as ln, mcpInvokeOnce as lt, filterRoutesByApiIdentifier as m, CfnLocalStateProvider as mn, invokeAgentCore as mt, CloudMapRegistry as n, substituteAgainstStateAsync as nn, buildCorsConfigFromCloudFrontChain as nt, createWatchPredicates as o, materializeLayerFromArn as on, MCP_CONTAINER_PORT as ot, availableApiIdentifiers as p, resolveCfnStackName as pn, AGENTCORE_SESSION_ID_HEADER as pt, buildCognitoJwksUrl as q, withErrorHandling as qn, TASK_ROLE_ACCOUNT_PLACEHOLDER as qt, getContainerNetworkIp as r, substituteEnvVarsFromState as rn, isFunctionUrlOacFronted as rt, resolveApiTargetSubset as s, LocalStateSourceError as sn, MCP_PATH as st, buildCloudMapIndex as t, substituteAgainstState as tn, buildCorsConfigByApiId as tt, createFileWatcher as u, rejectExplicitCfnStackWithMultipleStacks as un, parseSseForJsonRpc as ut, startApiServer as v, resolveWatchConfig as vn, buildAgentCoreCodeImage as vt, evaluateCachedLambdaPolicy as w, discoverWebSocketApis as wn, AssetManifestLoader as wt, defaultCredentialsLoader as x, resolveSingleTarget as xn, toCmdArgv as xt, resolveSelectionExpression as y, Synthesizer as yn, computeCodeImageTag as yt, bufferToBody as z, tryResolveImageFnJoin as zn, pullImage as zt };
17793
+ //# sourceMappingURL=cloud-map-resolver-CbSdXQjx.js.map