cdk-local 0.134.0 → 0.135.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/README.md +3 -3
- package/dist/cli.js +2 -2
- package/dist/index.js +1 -1
- package/dist/internal.d.ts +24 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +2 -2
- package/dist/{local-studio-BfroIGQL.js → local-studio-CdpdUbIA.js} +219 -37
- package/dist/local-studio-CdpdUbIA.js.map +1 -0
- package/dist/local-studio-DEKg7YDa.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/local-studio-BfroIGQL.js.map +0 -1
|
@@ -27,7 +27,7 @@ import { Readable } from "node:stream";
|
|
|
27
27
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
28
28
|
import { createServer as createServer$1, request } from "node:http";
|
|
29
29
|
import { createServer as createServer$2 } from "node:https";
|
|
30
|
-
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
30
|
+
import { mkdir, mkdtemp, readFile as readFile$1, readdir, rm, writeFile } from "node:fs/promises";
|
|
31
31
|
import { pipeline } from "node:stream/promises";
|
|
32
32
|
import * as chokidar from "chokidar";
|
|
33
33
|
import { Sha256 } from "@aws-crypto/sha256-js";
|
|
@@ -18213,10 +18213,18 @@ function classifySourceChange(changedPaths, ctx) {
|
|
|
18213
18213
|
* artifact is just source + an `EntryPoint` + a `Runtime`; AWS's managed
|
|
18214
18214
|
* runtime runs the entrypoint, which self-serves the AgentCore HTTP contract
|
|
18215
18215
|
* (`POST /invocations` + `GET /ping` on 8080) — typically via the
|
|
18216
|
-
* `bedrock-agentcore` SDK.
|
|
18217
|
-
*
|
|
18218
|
-
*
|
|
18219
|
-
*
|
|
18216
|
+
* `bedrock-agentcore` SDK. Crucially, the managed runtime does NOT install
|
|
18217
|
+
* dependencies at runtime: deps are vendored INTO the bundle at deploy time
|
|
18218
|
+
* (e.g. `uv pip install --target`), and the runtime resolves them from the
|
|
18219
|
+
* bundle's dependency search path. We replicate that locally faithfully:
|
|
18220
|
+
* generate a Dockerfile for the runtime's base image that copies the bundle
|
|
18221
|
+
* and runs the entrypoint AS-IS (no install). So a bundle that forgot to
|
|
18222
|
+
* vendor its deps fails locally the same way it fails deployed
|
|
18223
|
+
* (`ModuleNotFoundError`) instead of passing locally only because we installed
|
|
18224
|
+
* them — `buildAgentCoreCodeImage` warns up-front with the vendoring recipe
|
|
18225
|
+
* when a dependency manifest is present without vendored deps. The resulting
|
|
18226
|
+
* container speaks the same 8080 contract, so the existing HTTP client drives
|
|
18227
|
+
* it unchanged.
|
|
18220
18228
|
*/
|
|
18221
18229
|
/** AgentCore CodeConfiguration `Runtime` enum → local Docker base image. */
|
|
18222
18230
|
const RUNTIME_BASE_IMAGES = {
|
|
@@ -18239,6 +18247,7 @@ async function buildAgentCoreCodeImage(options) {
|
|
|
18239
18247
|
const base = RUNTIME_BASE_IMAGES[options.runtime];
|
|
18240
18248
|
if (!base) throw new LocalInvokeBuildError(`AgentCore CodeConfiguration runtime '${options.runtime}' is not supported for local execution. Supported runtimes: ${SUPPORTED_CODE_RUNTIMES.join(", ")}.`);
|
|
18241
18249
|
const isNode = options.runtime.startsWith("NODE");
|
|
18250
|
+
await warnIfDependenciesNotVendored(options.sourceDir, options.runtime, isNode, logger);
|
|
18242
18251
|
const dockerfile = renderCodeDockerfile(base, options.entryPoint, isNode);
|
|
18243
18252
|
const tag = computeCodeImageTag(options.sourceDir, options.runtime, options.entryPoint, dockerfile);
|
|
18244
18253
|
const platform = options.architecture === "x86_64" ? "linux/amd64" : "linux/arm64";
|
|
@@ -18275,23 +18284,53 @@ async function buildAgentCoreCodeImage(options) {
|
|
|
18275
18284
|
return tag;
|
|
18276
18285
|
}
|
|
18277
18286
|
/**
|
|
18278
|
-
* Render the generated Dockerfile. Dependencies are installed
|
|
18279
|
-
*
|
|
18280
|
-
*
|
|
18281
|
-
*
|
|
18287
|
+
* Render the generated Dockerfile. Dependencies are NOT installed: the
|
|
18288
|
+
* AgentCore managed runtime resolves deps from the bundle (vendored at deploy
|
|
18289
|
+
* time), so we copy the bundle and run the EntryPoint as-is to match deployed
|
|
18290
|
+
* behavior. The EntryPoint is mapped to a CMD: a bare script (`app.py` /
|
|
18291
|
+
* `server.js`) is run by the interpreter, while an explicit launcher (e.g.
|
|
18292
|
+
* `opentelemetry-instrument`) is run verbatim.
|
|
18282
18293
|
*/
|
|
18283
18294
|
function renderCodeDockerfile(base, entryPoint, isNode) {
|
|
18284
|
-
const installStep = isNode ? "RUN if [ -f package.json ]; then npm install --omit=dev; fi" : "RUN if [ -f requirements.txt ]; then pip install --no-cache-dir -r requirements.txt; elif [ -f pyproject.toml ]; then pip install --no-cache-dir .; fi";
|
|
18285
18295
|
return [
|
|
18286
18296
|
`FROM ${base}`,
|
|
18287
18297
|
"WORKDIR /app",
|
|
18288
18298
|
"COPY . /app",
|
|
18289
|
-
installStep,
|
|
18290
18299
|
"EXPOSE 8080",
|
|
18291
18300
|
`CMD ${JSON.stringify(toCmdArgv(entryPoint, isNode))}`
|
|
18292
18301
|
].join("\n") + "\n";
|
|
18293
18302
|
}
|
|
18294
18303
|
/**
|
|
18304
|
+
* Warn when a code bundle declares a dependency manifest but does not appear to
|
|
18305
|
+
* vendor its dependencies. The AgentCore managed runtime does NOT install deps
|
|
18306
|
+
* at runtime, so an unvendored bundle that "works" only because something
|
|
18307
|
+
* installed deps for it would fail on deploy with `ModuleNotFoundError`. We run
|
|
18308
|
+
* the bundle as-is locally (matching deploy); this surfaces the likely cause
|
|
18309
|
+
* up-front with the vendoring recipe. Heuristic: a Python bundle is considered
|
|
18310
|
+
* vendored if it contains any `*.dist-info` dir (what `pip install --target`
|
|
18311
|
+
* leaves); a Node bundle if it has a `node_modules` dir.
|
|
18312
|
+
*/
|
|
18313
|
+
async function warnIfDependenciesNotVendored(sourceDir, runtime, isNode, logger) {
|
|
18314
|
+
let entries;
|
|
18315
|
+
try {
|
|
18316
|
+
entries = await readdir(sourceDir);
|
|
18317
|
+
} catch {
|
|
18318
|
+
return;
|
|
18319
|
+
}
|
|
18320
|
+
const has = (name) => entries.includes(name);
|
|
18321
|
+
if (isNode) {
|
|
18322
|
+
if (has("package.json") && !has("node_modules")) logger.warn(`AgentCore code bundle '${sourceDir}' declares package.json but does not vendor node_modules. The AgentCore managed runtime does NOT install dependencies at runtime, so the deployed agent will fail to resolve them. Vendor dependencies into the bundle (e.g. 'npm install --omit=dev' in the bundle dir) so the deploy artifact is self-contained. cdk-local runs the bundle as-is to match the deployed runtime.`);
|
|
18323
|
+
return;
|
|
18324
|
+
}
|
|
18325
|
+
const manifest = await pythonManifestDeclaringDeps(sourceDir, entries);
|
|
18326
|
+
const vendored = entries.some((e) => e.endsWith(".dist-info"));
|
|
18327
|
+
if (manifest && !vendored) {
|
|
18328
|
+
const pyVersion = runtime.replace("PYTHON_", "").replace("_", ".");
|
|
18329
|
+
logger.warn(`AgentCore code bundle '${sourceDir}' declares ${manifest} but does not vendor its dependencies. The AgentCore managed runtime does NOT install dependencies at runtime, so the deployed agent will fail with ModuleNotFoundError. Vendor arm64 wheels into the bundle, e.g.:
|
|
18330
|
+
uv pip install --python-platform aarch64-manylinux2014 --python-version ${pyVersion} --target <bundle-dir> -r requirements.txt\ncdk-local runs the bundle as-is to match the deployed runtime.`);
|
|
18331
|
+
}
|
|
18332
|
+
}
|
|
18333
|
+
/**
|
|
18295
18334
|
* Map the EntryPoint argv to a Docker CMD argv. The managed runtime execs the
|
|
18296
18335
|
* entrypoint as the program; a bare script file is run by the language
|
|
18297
18336
|
* interpreter (`python` / `node`), while a non-script first token (a launcher
|
|
@@ -18302,6 +18341,24 @@ function toCmdArgv(entryPoint, isNode) {
|
|
|
18302
18341
|
if (!(isNode ? /\.[cm]?js$/.test(first) : /\.py$/.test(first))) return entryPoint;
|
|
18303
18342
|
return [isNode ? "node" : "python", ...entryPoint];
|
|
18304
18343
|
}
|
|
18344
|
+
/**
|
|
18345
|
+
* Return the Python dependency manifest filename that declares at least one
|
|
18346
|
+
* real dependency, or undefined. A `requirements.txt` that is empty or only
|
|
18347
|
+
* comments/pip-options (the stdlib-only-agent case) declares nothing, so it
|
|
18348
|
+
* must not trigger the unvendored-deps warning.
|
|
18349
|
+
*/
|
|
18350
|
+
async function pythonManifestDeclaringDeps(sourceDir, entries) {
|
|
18351
|
+
if (entries.includes("requirements.txt")) {
|
|
18352
|
+
if ((await readFile$1(join(sourceDir, "requirements.txt"), "utf-8").catch(() => "")).split(/\r?\n/).some((line) => {
|
|
18353
|
+
const t = line.trim();
|
|
18354
|
+
return t.length > 0 && !t.startsWith("#") && !t.startsWith("-");
|
|
18355
|
+
})) return "requirements.txt";
|
|
18356
|
+
}
|
|
18357
|
+
if (entries.includes("pyproject.toml")) {
|
|
18358
|
+
const content = await readFile$1(join(sourceDir, "pyproject.toml"), "utf-8").catch(() => "");
|
|
18359
|
+
if (/dependencies\s*=\s*\[\s*["']/.test(content) || content.includes("[tool.poetry.dependencies]")) return "pyproject.toml";
|
|
18360
|
+
}
|
|
18361
|
+
}
|
|
18305
18362
|
/** Deterministic local tag, stable for identical source + runtime + entrypoint. */
|
|
18306
18363
|
function computeCodeImageTag(sourceDir, runtime, entryPoint, dockerfile) {
|
|
18307
18364
|
const hash = createHash("sha256").update([
|
|
@@ -18412,8 +18469,8 @@ function defaultFetchObject$1(options) {
|
|
|
18412
18469
|
* plain HTTP. `cdkl invoke-agentcore` runs the container, waits for `/ping`,
|
|
18413
18470
|
* then POSTs one event to `/invocations` (invoke-once).
|
|
18414
18471
|
*/
|
|
18415
|
-
const PING_PATH = "/ping";
|
|
18416
|
-
const INVOCATIONS_PATH = "/invocations";
|
|
18472
|
+
const PING_PATH$1 = "/ping";
|
|
18473
|
+
const INVOCATIONS_PATH$1 = "/invocations";
|
|
18417
18474
|
/**
|
|
18418
18475
|
* Header AgentCore Runtime uses to carry the session id to the container.
|
|
18419
18476
|
* Real AgentCore always sends it; we generate one (or pass the user's
|
|
@@ -18450,7 +18507,7 @@ async function waitForAgentCorePing(host, port, timeoutMs = 3e4) {
|
|
|
18450
18507
|
await setTimeout$1(150);
|
|
18451
18508
|
}
|
|
18452
18509
|
const tail = lastDetail ? `: ${lastDetail}` : "";
|
|
18453
|
-
throw new Error(`AgentCore agent did not become ready on ${host}:${port} within ${timeoutMs}ms${tail}. The container may have exited early or may not serve GET ${PING_PATH} — check 'docker logs' output.`);
|
|
18510
|
+
throw new Error(`AgentCore agent did not become ready on ${host}:${port} within ${timeoutMs}ms${tail}. The container may have exited early or may not serve GET ${PING_PATH$1} — check 'docker logs' output.`);
|
|
18454
18511
|
}
|
|
18455
18512
|
/**
|
|
18456
18513
|
* Issue `GET /ping`. Returns the HTTP status on any response, undefined on
|
|
@@ -18461,7 +18518,7 @@ async function pingProbe(host, port, timeoutMs) {
|
|
|
18461
18518
|
const controller = new AbortController();
|
|
18462
18519
|
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
18463
18520
|
try {
|
|
18464
|
-
const response = await fetch(`http://${host}:${port}${PING_PATH}`, {
|
|
18521
|
+
const response = await fetch(`http://${host}:${port}${PING_PATH$1}`, {
|
|
18465
18522
|
method: "GET",
|
|
18466
18523
|
signal: controller.signal
|
|
18467
18524
|
});
|
|
@@ -18500,7 +18557,7 @@ function isTransientNetworkError$2(err) {
|
|
|
18500
18557
|
* a missing sink) is buffered into `raw` and returned verbatim.
|
|
18501
18558
|
*/
|
|
18502
18559
|
async function invokeAgentCore(host, port, event, options) {
|
|
18503
|
-
const url = `http://${host}:${port}${INVOCATIONS_PATH}`;
|
|
18560
|
+
const url = `http://${host}:${port}${INVOCATIONS_PATH$1}`;
|
|
18504
18561
|
const body = JSON.stringify(event ?? {});
|
|
18505
18562
|
const controller = new AbortController();
|
|
18506
18563
|
const timer = setTimeout(() => controller.abort(), options.timeoutMs);
|
|
@@ -30859,17 +30916,19 @@ function decodeBrowserFrame(data, isBinary) {
|
|
|
30859
30916
|
return (Buffer.isBuffer(data) ? data : Array.isArray(data) ? Buffer.concat(data) : Buffer.from(data)).toString("utf-8");
|
|
30860
30917
|
}
|
|
30861
30918
|
/**
|
|
30862
|
-
*
|
|
30863
|
-
*
|
|
30864
|
-
*
|
|
30919
|
+
* Attach the AgentCore `/ws` bridge to an EXISTING `http.Server`: registers a
|
|
30920
|
+
* `WebSocketServer` on `config.path` and, for each inbound (header-less)
|
|
30921
|
+
* client, opens a container `/ws` leg with the session-id / Authorization
|
|
30922
|
+
* headers injected (via {@link bridgeAgentCoreWs}), piping frames both ways.
|
|
30923
|
+
*
|
|
30924
|
+
* Shared by {@link startAgentCoreWsBridge} (a standalone `/ws`-only bridge) and
|
|
30925
|
+
* the HTTP serve (`startAgentCoreHttpServer`, issue #454), which serves the
|
|
30926
|
+
* same warm container's `POST /invocations` + `GET /ping` on the SAME port and
|
|
30927
|
+
* delegates the `/ws` upgrade here. The caller owns `httpServer.listen()` and
|
|
30928
|
+
* the host port; this helper only owns the WebSocket layer.
|
|
30865
30929
|
*/
|
|
30866
|
-
function
|
|
30867
|
-
const host = config.host ?? "127.0.0.1";
|
|
30930
|
+
function attachAgentCoreWsBridge(httpServer, config) {
|
|
30868
30931
|
const path = config.path ?? DEFAULT_PATH;
|
|
30869
|
-
const httpServer = createServer$1((_req, res) => {
|
|
30870
|
-
res.writeHead(426, { "Content-Type": "text/plain" });
|
|
30871
|
-
res.end("Upgrade required: connect over WebSocket.\n");
|
|
30872
|
-
});
|
|
30873
30932
|
const wss = new WebSocketServer({
|
|
30874
30933
|
server: httpServer,
|
|
30875
30934
|
path
|
|
@@ -30911,6 +30970,27 @@ function startAgentCoreWsBridge(config) {
|
|
|
30911
30970
|
handle.close();
|
|
30912
30971
|
});
|
|
30913
30972
|
});
|
|
30973
|
+
return {
|
|
30974
|
+
path,
|
|
30975
|
+
close: () => new Promise((res) => {
|
|
30976
|
+
for (const closeLeg of liveCloses) closeLeg();
|
|
30977
|
+
liveCloses.clear();
|
|
30978
|
+
wss.close(() => res());
|
|
30979
|
+
})
|
|
30980
|
+
};
|
|
30981
|
+
}
|
|
30982
|
+
/**
|
|
30983
|
+
* Start a standalone `/ws`-only bridge server. Resolves once it is listening;
|
|
30984
|
+
* the returned handle carries the connectable `url` and a `close()` that tears
|
|
30985
|
+
* down the server and every live bridged connection.
|
|
30986
|
+
*/
|
|
30987
|
+
function startAgentCoreWsBridge(config) {
|
|
30988
|
+
const host = config.host ?? "127.0.0.1";
|
|
30989
|
+
const httpServer = createServer$1((_req, res) => {
|
|
30990
|
+
res.writeHead(426, { "Content-Type": "text/plain" });
|
|
30991
|
+
res.end("Upgrade required: connect over WebSocket.\n");
|
|
30992
|
+
});
|
|
30993
|
+
const attached = attachAgentCoreWsBridge(httpServer, config);
|
|
30914
30994
|
return new Promise((resolve, reject) => {
|
|
30915
30995
|
httpServer.once("error", reject);
|
|
30916
30996
|
httpServer.listen(config.port ?? 0, host, () => {
|
|
@@ -30918,12 +30998,113 @@ function startAgentCoreWsBridge(config) {
|
|
|
30918
30998
|
httpServer.on("error", (err) => getLogger().debug(`agentcore-ws bridge server error: ${err.message}`));
|
|
30919
30999
|
const port = httpServer.address().port;
|
|
30920
31000
|
resolve({
|
|
30921
|
-
url: `ws://${host}:${port}${path}`,
|
|
31001
|
+
url: `ws://${host}:${port}${attached.path}`,
|
|
30922
31002
|
port,
|
|
30923
31003
|
close: () => new Promise((res) => {
|
|
30924
|
-
|
|
30925
|
-
|
|
30926
|
-
|
|
31004
|
+
attached.close().then(() => httpServer.close(() => res()));
|
|
31005
|
+
})
|
|
31006
|
+
});
|
|
31007
|
+
});
|
|
31008
|
+
});
|
|
31009
|
+
}
|
|
31010
|
+
|
|
31011
|
+
//#endregion
|
|
31012
|
+
//#region src/local/agentcore-http-server.ts
|
|
31013
|
+
/**
|
|
31014
|
+
* Host HTTP serve in front of a warm AgentCore runtime container, the serving
|
|
31015
|
+
* primitive behind `cdkl start-agentcore` for HTTP / AGUI protocols (issue
|
|
31016
|
+
* #454). Unlike the single-shot `cdkl invoke-agentcore` — which boots a
|
|
31017
|
+
* container, POSTs ONE `/invocations`, and tears it down — this keeps the
|
|
31018
|
+
* container warm and serves its native HTTP contract until `^C`, so a client
|
|
31019
|
+
* can hit `POST /invocations` (and `GET /ping`) repeatedly against the SAME
|
|
31020
|
+
* warm container. That mirrors AgentCore's deployed model, where many
|
|
31021
|
+
* `InvokeAgentRuntime` calls on the same `runtimeSessionId` reuse one warm
|
|
31022
|
+
* microVM.
|
|
31023
|
+
*
|
|
31024
|
+
* One host `http.Server` serves all three:
|
|
31025
|
+
* - `GET /ping` -> proxied to the container's `/ping`
|
|
31026
|
+
* - `POST /invocations` -> proxied to the container's `/invocations`
|
|
31027
|
+
* (request body streamed up, response — JSON or SSE — streamed back)
|
|
31028
|
+
* - `/ws` upgrade -> the existing header-injecting bridge
|
|
31029
|
+
* ({@link attachAgentCoreWsBridge}) on the same port, so a header-less
|
|
31030
|
+
* browser `WebSocket` still works exactly as before.
|
|
31031
|
+
*
|
|
31032
|
+
* Auth parity: the boot-resolved `authorization` (the `--bearer-token`
|
|
31033
|
+
* validated once at boot under a `customJwtAuthorizer`, or the `--sigv4`
|
|
31034
|
+
* header set) is injected on every forwarded request — the same model the
|
|
31035
|
+
* `/ws` bridge uses. Per-request inbound JWT verification is out of scope for
|
|
31036
|
+
* this slice.
|
|
31037
|
+
*/
|
|
31038
|
+
const PING_PATH = "/ping";
|
|
31039
|
+
const INVOCATIONS_PATH = "/invocations";
|
|
31040
|
+
/**
|
|
31041
|
+
* Proxy one inbound HTTP request to the warm container, injecting the
|
|
31042
|
+
* session-id + Authorization (+ any extra) headers, and stream the response
|
|
31043
|
+
* back. Used for both `GET /ping` and `POST /invocations`; piping the response
|
|
31044
|
+
* preserves an SSE (`text/event-stream`) stream.
|
|
31045
|
+
*/
|
|
31046
|
+
function proxyToContainer(clientReq, clientRes, config, upstreamPath) {
|
|
31047
|
+
const headers = { ...clientReq.headers };
|
|
31048
|
+
delete headers["host"];
|
|
31049
|
+
headers[AGENTCORE_SESSION_ID_HEADER] = config.sessionId ?? randomUUID();
|
|
31050
|
+
if (config.authorization) headers["authorization"] = config.authorization;
|
|
31051
|
+
const upstream = request({
|
|
31052
|
+
host: config.containerHost,
|
|
31053
|
+
port: config.containerPort,
|
|
31054
|
+
path: upstreamPath,
|
|
31055
|
+
method: clientReq.method,
|
|
31056
|
+
headers
|
|
31057
|
+
}, (upRes) => {
|
|
31058
|
+
clientRes.writeHead(upRes.statusCode ?? 502, upRes.headers);
|
|
31059
|
+
upRes.on("error", () => clientRes.destroy());
|
|
31060
|
+
upRes.pipe(clientRes);
|
|
31061
|
+
});
|
|
31062
|
+
upstream.on("error", (err) => {
|
|
31063
|
+
getLogger().debug(`agentcore http serve upstream error: ${err.message}`);
|
|
31064
|
+
if (!clientRes.headersSent) clientRes.writeHead(502, { "content-type": "application/json" });
|
|
31065
|
+
clientRes.end(JSON.stringify({ error: `upstream error: ${err.message}` }));
|
|
31066
|
+
});
|
|
31067
|
+
clientReq.on("error", (err) => {
|
|
31068
|
+
getLogger().debug(`agentcore http serve client error: ${err.message}`);
|
|
31069
|
+
upstream.destroy();
|
|
31070
|
+
});
|
|
31071
|
+
clientReq.pipe(upstream);
|
|
31072
|
+
}
|
|
31073
|
+
/**
|
|
31074
|
+
* Start the HTTP serve. Resolves once it is listening; the returned handle
|
|
31075
|
+
* carries the connectable `httpUrl` / `wsUrl` and a `close()` that tears down
|
|
31076
|
+
* the server + the `/ws` bridge + every live bridged connection.
|
|
31077
|
+
*/
|
|
31078
|
+
function startAgentCoreHttpServer(config) {
|
|
31079
|
+
const host = config.host ?? "127.0.0.1";
|
|
31080
|
+
const httpServer = createServer$1((req, res) => {
|
|
31081
|
+
const path = (req.url ?? "/").split("?")[0];
|
|
31082
|
+
if (req.method === "GET" && path === PING_PATH) return proxyToContainer(req, res, config, PING_PATH);
|
|
31083
|
+
if (req.method === "POST" && path === INVOCATIONS_PATH) return proxyToContainer(req, res, config, INVOCATIONS_PATH);
|
|
31084
|
+
res.writeHead(404, { "content-type": "application/json" });
|
|
31085
|
+
res.end(JSON.stringify({
|
|
31086
|
+
error: "not found",
|
|
31087
|
+
hint: "POST /invocations or GET /ping (WebSocket: connect to /ws)"
|
|
31088
|
+
}));
|
|
31089
|
+
});
|
|
31090
|
+
const bridge = attachAgentCoreWsBridge(httpServer, {
|
|
31091
|
+
containerHost: config.containerHost,
|
|
31092
|
+
containerPort: config.containerPort,
|
|
31093
|
+
...config.sessionId && { sessionId: config.sessionId },
|
|
31094
|
+
...config.authorization && { authorization: config.authorization }
|
|
31095
|
+
});
|
|
31096
|
+
return new Promise((resolve, reject) => {
|
|
31097
|
+
httpServer.once("error", reject);
|
|
31098
|
+
httpServer.listen(config.port ?? 0, host, () => {
|
|
31099
|
+
httpServer.removeListener("error", reject);
|
|
31100
|
+
httpServer.on("error", (err) => getLogger().debug(`agentcore http serve server error: ${err.message}`));
|
|
31101
|
+
const port = httpServer.address().port;
|
|
31102
|
+
resolve({
|
|
31103
|
+
httpUrl: `http://${host}:${port}`,
|
|
31104
|
+
wsUrl: `ws://${host}:${port}${bridge.path}`,
|
|
31105
|
+
port,
|
|
31106
|
+
close: () => new Promise((res) => {
|
|
31107
|
+
bridge.close().then(() => httpServer.close(() => res()));
|
|
30927
31108
|
})
|
|
30928
31109
|
});
|
|
30929
31110
|
});
|
|
@@ -30972,7 +31153,7 @@ async function localStartAgentCoreCommand(target, options, extraStateProviders)
|
|
|
30972
31153
|
if (options.verbose) logger.setLevel("debug");
|
|
30973
31154
|
let containerId;
|
|
30974
31155
|
let stopLogs;
|
|
30975
|
-
let
|
|
31156
|
+
let server;
|
|
30976
31157
|
let profileCredsFile;
|
|
30977
31158
|
let stateProvider;
|
|
30978
31159
|
let shuttingDown = false;
|
|
@@ -30980,10 +31161,10 @@ async function localStartAgentCoreCommand(target, options, extraStateProviders)
|
|
|
30980
31161
|
const teardown = async () => {
|
|
30981
31162
|
if (tornDown) return;
|
|
30982
31163
|
tornDown = true;
|
|
30983
|
-
if (
|
|
30984
|
-
await
|
|
31164
|
+
if (server) try {
|
|
31165
|
+
await server.close();
|
|
30985
31166
|
} catch (err) {
|
|
30986
|
-
logger.debug(`
|
|
31167
|
+
logger.debug(`server close failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
30987
31168
|
}
|
|
30988
31169
|
if (stopLogs) try {
|
|
30989
31170
|
stopLogs();
|
|
@@ -31069,7 +31250,7 @@ async function localStartAgentCoreCommand(target, options, extraStateProviders)
|
|
|
31069
31250
|
process.on("SIGTERM", () => void shutdown("SIGTERM", 0));
|
|
31070
31251
|
try {
|
|
31071
31252
|
await waitForAgentCorePing(containerHost, containerHostPort, options.timeout);
|
|
31072
|
-
|
|
31253
|
+
server = await startAgentCoreHttpServer({
|
|
31073
31254
|
containerHost,
|
|
31074
31255
|
containerPort: containerHostPort,
|
|
31075
31256
|
host: options.host,
|
|
@@ -31081,7 +31262,8 @@ async function localStartAgentCoreCommand(target, options, extraStateProviders)
|
|
|
31081
31262
|
await teardown();
|
|
31082
31263
|
throw err;
|
|
31083
31264
|
}
|
|
31084
|
-
logger.info(`Server listening on ${
|
|
31265
|
+
logger.info(`Server listening on ${server.wsUrl} (${resolved.logicalId} (AgentCore WebSocket))`);
|
|
31266
|
+
logger.info(`HTTP contract served on ${server.httpUrl} — POST ${server.httpUrl}/invocations, GET ${server.httpUrl}/ping`);
|
|
31085
31267
|
logger.info("Press ^C to shut down.");
|
|
31086
31268
|
await new Promise(() => void 0);
|
|
31087
31269
|
}
|
|
@@ -36666,5 +36848,5 @@ function addStudioSpecificOptions(cmd) {
|
|
|
36666
36848
|
}
|
|
36667
36849
|
|
|
36668
36850
|
//#endregion
|
|
36669
|
-
export {
|
|
36670
|
-
//# sourceMappingURL=local-studio-
|
|
36851
|
+
export { edgeHeadersToHttp as $, verifyJwtViaDiscovery as $n, countTargets as $r, SOFT_RELOAD_COMPLETION_LOG_SUFFIX as $t, startAgentCoreWsBridge as A, createLocalStartApiCommand as An, buildMessageEvent as Ar, addCommonEcsServiceOptions as At, resolveDeployedKvsArnByName as B, filterRoutesByApiIdentifier as Bn, substituteEnvVarsFromStateAsync as Br, ImageOverrideError as Bt, addListSpecificOptions as C, buildStsClientConfig as Ci, computeCodeImageTag as Cn, bufferToBody as Cr, resolveAlbFrontDoor as Ct, createLocalStartAgentCoreCommand as D, addInvokeSpecificOptions as Dn, parseConnectionsPath as Dr, addRunTaskSpecificOptions as Dt, addStartAgentCoreSpecificOptions as E, classifySourceChange as En, handleConnectionsRequest as Er, serviceStrategy as Et, parseOriginOverrides as F, attachStageContext as Fn, resolveRuntimeImage as Fr, parseMaxTasks as Ft, startCloudFrontServer as G, resolveSelectionExpression as Gn, resolveCfnFallbackRegion as Gr, resolveImageOverrides as Gt, classifyS3Error as H, groupRoutesByServer as Hn, createLocalStateProvider as Hr, enforceImageOverrideOrphans as Ht, resolveCloudFrontTarget as I, buildStageMap as In, EcsTaskResolutionError as Ir, parseRestartPolicy as It, serveLambdaUrlOrigin as J, buildCognitoJwksUrl as Jn, CfnLocalStateProvider as Jr, isLocalCdkAssetImage as Jt, resolveErrorResponseCandidates as K, resolveServiceIntegrationParameters as Kn, resolveCfnRegion as Kr, runImageOverrideBuilds as Kt, idFromArn as L, materializeLayerFromArn as Ln, substituteAgainstState as Lr, resolveEcsAssumeRoleOption as Lt, addStartCloudFrontSpecificOptions as M, resolveApiTargetSubset as Mn, buildContainerImage as Mr, addImageOverrideOptions as Mt, createLocalStartCloudFrontCommand as N, createAuthorizerCache as Nn, resolveRuntimeCodeMountPath as Nr, buildEcsImageResolutionContext$1 as Nt, startAgentCoreHttpServer as O, createLocalInvokeCommand as On, buildConnectEvent as Or, createLocalRunTaskCommand as Ot, parseKvsFileOverrides as P, createFileWatcher as Pn, resolveRuntimeFileExtension as Pr, ecsClusterOption as Pt, buildEdgeResponseEvent as Q, verifyJwtAuthorizer as Qn, resolveSingleTarget as Qr, DEFAULT_SHADOW_READY_TIMEOUT_MS as Qt, resolveKvsModulesForDistribution as R, resolveEnvVars$1 as Rn, substituteAgainstStateAsync as Rr, resolveSharedSidecarCredentials as Rt, StudioEventBus as S, LocalInvokeBuildError as Si, buildAgentCoreCodeImage as Sn, probeHostGatewaySupport as Sr, isApplicationLoadBalancer as St, formatTargetListing as T, toCmdArgv as Tn, buildMgmtEndpointEnvUrl as Tr, createLocalStartServiceCommand as Tt, createS3OriginReader as U, readMtlsMaterialsFromDisk as Un, isCfnFlagPresent as Ur, mergeForService as Ut, resolveDeployedOriginBucket as V, filterRoutesByApiIdentifiers as Vn, LocalStateSourceError as Vr, buildImageOverrideTag as Vt, matchBehavior as W, startApiServer as Wn, rejectExplicitCfnStackWithMultipleStacks as Wr, parseImageOverrideFlags as Wt, applyEdgeResponseResult as X, createJwksCache as Xn, resolveSsmParameters as Xr, buildCloudMapIndex as Xt, applyEdgeRequestResult as Y, buildJwksUrlFromIssuer as Yn, collectSsmParameterRefs as Yr, listPinnedTargets as Yt, buildEdgeRequestEvent as Z, verifyCognitoJwt as Zn, resolveWatchConfig as Zr, CloudMapRegistry as Zt, filterStudioTargetGroups as _, resolveAgentCoreTarget as _i, AGENTCORE_SESSION_ID_HEADER as _n, pickResponseTemplate as _r, addAlbSpecificOptions as _t, createLocalStudioCommand as a, parseSelectionExpressionPath as ai, bridgeAgentCoreWs as an, attachAuthorizers as ar, pickFunctionUrlLogicalIdFromOrigin as at, renderStudioHtml as b, substituteImagePlaceholders as bi, downloadAndExtractS3Bundle as bn, VtlEvaluationError as br, parseLbPortOverrides as bt, startStudioProxy as c, pickRefLogicalId as ci, A2A_PATH as cn, buildCorsConfigFromCloudFrontChain as cr, pickTargetFunctionLogicalId as ct, createStudioDispatcher as d, AGENTCORE_AGUI_PROTOCOL as di, MCP_PATH as dn, matchRoute as dr, runViewerRequest as dt, listTargets as ei, setShadowReadyTimeoutMs as en, buildMethodArn as er, httpHeadersToEdge as et, filterStudioCustomResources as f, AGENTCORE_HTTP_PROTOCOL as fi, MCP_PROTOCOL_VERSION as fn, translateLambdaResponse as fr, runViewerResponse as ft, annotatePinnedEcsTargets as g, pickAgentCoreCandidateStack as gi, signAgentCoreInvocation as gn, evaluateResponseParameters as gr, createUnboundCloudFrontModule as gt, annotateEcsTaskPinnedTargets as h, AgentCoreResolutionError as hi, AGENTCORE_SIGV4_SERVICE as hn, buildRestV1Event as hr, createLocalFileKvsDataSource as ht, coerceStopRequest as i, filterWebSocketApisByIdentifiers as ii, createLocalInvokeAgentCoreCommand as in, invokeTokenAuthorizer as ir, isCloudFrontDistribution as it, LocalStartCloudFrontError as j, createWatchPredicates as jn, architectureToPlatform as jr, addEcsAssumeRoleOptions as jt, attachAgentCoreWsBridge as k, addStartApiSpecificOptions as kn, buildDisconnectEvent as kr, MAX_TASKS_SUBNET_RANGE_CAP as kt, relayServeRequest as l, resolveLambdaArnIntrinsic as li, a2aInvokeOnce as ln, isFunctionUrlOacFronted as lr, resolveCloudFrontDistribution as lt, annotateAlbPinnedBackingServices as m, AGENTCORE_RUNTIME_TYPE as mi, parseSseForJsonRpc as mn, buildHttpApiV2Event as mr, createCloudFrontModule as mt, coerceRunRequest as n, discoverWebSocketApis as ni, attachContainerLogStreamer as nn, evaluateCachedLambdaPolicy as nr, describeS3OriginDomain as nt, resolveServeBaseUrl as o, webSocketApiMatchesIdentifier as oi, invokeAgentCoreWs as on, applyCorsResponseHeaders as or, pickKvsLogicalIdFromArn as ot, isCustomResourceLambdaTarget as p, AGENTCORE_MCP_PROTOCOL as pi, mcpInvokeOnce as pn, applyAuthorizerOverlay as pr, stripCloudFrontImport as pt, serveFromStaticOrigin as q, defaultCredentialsLoader as qn, resolveCfnStackName as qr, describePinnedImageUri as qt, coerceServeRequest as r, discoverWebSocketApisOrThrow as ri, addInvokeAgentCoreSpecificOptions as rn, invokeRequestAuthorizer as rr, extractKvsAssociations as rt, createStudioServeManager as s, discoverRoutes as si, A2A_CONTAINER_PORT as sn, buildCorsConfigByApiId as sr, pickLambdaEdgeFunctionLogicalId as st, addStudioSpecificOptions as t, availableWebSocketApiIdentifiers as ti, getContainerNetworkIp as tn, computeRequestIdentityHash as tr, CLOUDFRONT_DISTRIBUTION_TYPE as tt, reinvoke as u, AGENTCORE_A2A_PROTOCOL as ui, MCP_CONTAINER_PORT as un, matchPreflight as ur, compileCloudFrontFunction as ut, startStudioServer as v, derivePseudoParametersFromRegion as vi, invokeAgentCore as vn, selectIntegrationResponse as vr, albStrategy as vt, createLocalListCommand as w, resolveProfileCredentials as wi, renderCodeDockerfile as wn, ConnectionRegistry as wr, addStartServiceSpecificOptions as wt, createStudioStore as x, tryResolveImageFnJoin as xi, SUPPORTED_CODE_RUNTIMES as xn, HOST_GATEWAY_MIN_VERSION as xr, resolveAlbTarget as xt, toStudioTargetGroups as y, formatStateRemedy as yi, waitForAgentCorePing as yn, tryParseStatus as yr, createLocalStartAlbCommand as yt, createDeployedKvsDataSource as z, availableApiIdentifiers as zn, substituteEnvVarsFromState as zr, runEcsServiceEmulator as zt };
|
|
36852
|
+
//# sourceMappingURL=local-studio-CdpdUbIA.js.map
|