cdk-local 0.55.0 → 0.57.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-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-DT8qRbKy.js";
2
+ import { a as createLocalStartApiCommand } from "./cloud-map-resolver-BDAxtbvB.js";
3
+ import { a as createLocalRunTaskCommand, i as createLocalStartServiceCommand, o as createLocalInvokeAgentCoreCommand, r as createLocalStartAlbCommand, s as createLocalInvokeCommand, t as createLocalListCommand } from "./local-list-DmEjNav4.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.55.0");
8
+ program.name("cdkl").description("Run AWS CDK stacks locally with Docker.").version("0.57.0");
9
9
  program.addCommand(createLocalInvokeCommand());
10
10
  program.addCommand(createLocalInvokeAgentCoreCommand());
11
11
  program.addCommand(createLocalStartApiCommand());
@@ -1434,8 +1434,8 @@ function extractArtifact(artifact, logicalId, stackName, resources, region, imag
1434
1434
  };
1435
1435
  const container = art["ContainerConfiguration"];
1436
1436
  if (!container || typeof container !== "object" || Array.isArray(container)) throw new AgentCoreResolutionError(`AgentCore Runtime '${logicalId}' in ${stackName} has no ContainerConfiguration in its AgentRuntimeArtifact.`);
1437
- const uri = resolveImageUri(container["ContainerUri"], resources, region, imageContext);
1438
- if (uri === void 0) throw new AgentCoreResolutionError(`AgentCore Runtime '${logicalId}' in ${stackName} has a ContainerConfiguration.ContainerUri that ${getEmbedConfig().cliName} invoke-agentcore cannot resolve. v1 resolves a literal image URI, an Fn::Sub asset URI (the fromAsset / Dockerfile path), and an imported-ECR Fn::Join. A same-stack AWS::ECR::Repository reference is not supported — build the agent as a fromAsset image, or pin a literal / imported ECR image URI.`);
1437
+ const uri = resolveImageUri(container["ContainerUri"], logicalId, stackName, resources, region, imageContext);
1438
+ if (uri === void 0) throw new AgentCoreResolutionError(`AgentCore Runtime '${logicalId}' in ${stackName} has a ContainerConfiguration.ContainerUri that ${getEmbedConfig().cliName} invoke-agentcore cannot resolve. v1 resolves a literal image URI, an Fn::Sub asset URI (the fromAsset / Dockerfile path), an imported-ECR Fn::Join, and a same-stack AWS::ECR::Repository Fn::Join under --from-cfn-stack — build the agent as a fromAsset image, or pin a literal / imported ECR image URI.`);
1439
1439
  return {
1440
1440
  kind: "container",
1441
1441
  containerUri: uri
@@ -1509,9 +1509,12 @@ function isFromS3BucketIntrinsic(value) {
1509
1509
  * an `Fn::Sub` (the template returned verbatim — `${AWS::*}` placeholders
1510
1510
  * are kept for asset-hash matching / later ECR substitution), and the
1511
1511
  * canonical CDK `Fn::Join` ECR shape via the shared {@link intrinsic-image}
1512
- * resolver. Returns undefined when none apply.
1512
+ * resolver. A same-stack `AWS::ECR::Repository` Fn::Join without
1513
+ * `--from-cfn-stack` throws an `AgentCoreResolutionError` pointing the user
1514
+ * at the right flag (mirroring `cdkl run-task`'s shape). Returns undefined
1515
+ * when none of the supported shapes apply.
1513
1516
  */
1514
- function resolveImageUri(value, resources, region, imageContext) {
1517
+ function resolveImageUri(value, logicalId, stackName, resources, region, imageContext) {
1515
1518
  if (typeof value === "string" && value.length > 0) return value;
1516
1519
  if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
1517
1520
  const obj = value;
@@ -1524,6 +1527,7 @@ function resolveImageUri(value, resources, region, imageContext) {
1524
1527
  return pseudoParameters ? { pseudoParameters } : void 0;
1525
1528
  })());
1526
1529
  if (joinResolved.kind === "resolved") return joinResolved.uri;
1530
+ if (joinResolved.kind === "needs-state") throw new AgentCoreResolutionError(`AgentCore Runtime '${logicalId}' in ${stackName} references same-stack ECR repository '${joinResolved.repoLogicalId}' via Fn::Join. ${getEmbedConfig().cliName} invoke-agentcore cannot resolve the repository URI without state — pass --from-cfn-stack to load the deployed stack state, build via Runtime.fromAsset, or pin a literal / imported ECR image URI.`);
1527
1531
  }
1528
1532
  }
1529
1533
 
@@ -8344,13 +8348,16 @@ function isTransientNetworkError(err) {
8344
8348
  * endpoint (bidirectional streaming, on the same 8080 container as
8345
8349
  * `POST /invocations` + `GET /ping`).
8346
8350
  *
8347
- * v1 is a one-shot send-and-stream transparent pipe: connect to
8348
- * `ws://host:8080/ws`, send the `--event` as the first frame, then stream every
8349
- * received frame to the sink until the server closes the connection. The wire
8350
- * framing over `/ws` is agent-defined (AWS pipes bytes transparently), so this
8351
- * mirrors that it does not interpret the frames. The AgentCore session id is
8352
- * sent on the upgrade as {@link AGENTCORE_SESSION_ID_HEADER}, the way the cloud
8353
- * front door does. An interactive stdin<->ws loop is a follow-up.
8351
+ * Connect to `ws://host:8080/ws`, send the `--event` as the first frame, and
8352
+ * stream every received frame to the sink. When a {@link
8353
+ * InvokeAgentCoreWsOptions.frameSource} is supplied (the `--ws-interactive`
8354
+ * REPL path), additional frames from that async iterable are sent after the
8355
+ * initial event, and the client closes the stream when the iterable is
8356
+ * exhausted (or when the server closes first whichever happens first). The
8357
+ * wire framing over `/ws` is agent-defined (AWS pipes bytes transparently),
8358
+ * so this mirrors that — it does not interpret the frames. The AgentCore
8359
+ * session id is sent on the upgrade as {@link AGENTCORE_SESSION_ID_HEADER},
8360
+ * the way the cloud front door does.
8354
8361
  */
8355
8362
  const WS_PATH = "/ws";
8356
8363
  /**
@@ -8377,14 +8384,43 @@ async function invokeAgentCoreWs(host, port, event, options) {
8377
8384
  };
8378
8385
  const timer = setTimeout(() => {
8379
8386
  finish(() => {
8387
+ stopIterator();
8380
8388
  try {
8381
8389
  ws.terminate();
8382
8390
  } catch {}
8383
8391
  reject(/* @__PURE__ */ new Error(`AgentCore /ws at ${url} timed out after ${options.timeoutMs}ms. The agent may be hung or may not close the stream; check container logs.`));
8384
8392
  });
8385
8393
  }, options.timeoutMs);
8394
+ let iterator;
8395
+ const stopIterator = () => {
8396
+ if (iterator?.return) try {
8397
+ iterator.return();
8398
+ } catch {}
8399
+ iterator = void 0;
8400
+ };
8386
8401
  ws.on("open", () => {
8387
8402
  ws.send(body);
8403
+ if (!options.frameSource) return;
8404
+ (async () => {
8405
+ try {
8406
+ iterator = options.frameSource[Symbol.asyncIterator]();
8407
+ while (!settled) {
8408
+ const next = await iterator.next();
8409
+ if (settled || next.done) break;
8410
+ await new Promise((res, rej) => {
8411
+ ws.send(next.value, (err) => err ? rej(err) : res());
8412
+ });
8413
+ }
8414
+ if (!settled) ws.close();
8415
+ } catch (err) {
8416
+ finish(() => {
8417
+ try {
8418
+ ws.terminate();
8419
+ } catch {}
8420
+ reject(err instanceof Error ? err : new Error(String(err)));
8421
+ });
8422
+ }
8423
+ })();
8388
8424
  });
8389
8425
  ws.on("message", (data) => {
8390
8426
  frames += 1;
@@ -8392,10 +8428,16 @@ async function invokeAgentCoreWs(host, port, event, options) {
8392
8428
  options.onMessage(buf.toString("utf-8"));
8393
8429
  });
8394
8430
  ws.on("close", () => {
8395
- finish(() => resolve({ frames }));
8431
+ finish(() => {
8432
+ stopIterator();
8433
+ resolve({ frames });
8434
+ });
8396
8435
  });
8397
8436
  ws.on("error", (err) => {
8398
- finish(() => reject(err));
8437
+ finish(() => {
8438
+ stopIterator();
8439
+ reject(err);
8440
+ });
8399
8441
  });
8400
8442
  });
8401
8443
  }
@@ -17790,4 +17832,4 @@ function extractDnsRecords(serviceProps) {
17790
17832
 
17791
17833
  //#endregion
17792
17834
  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
17835
+ //# sourceMappingURL=cloud-map-resolver-BDAxtbvB.js.map