@evident-ai/runner-cdk 3.5.2-dev.8d3aa06 → 3.5.2-dev.bbd799b

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.
Files changed (34) hide show
  1. package/README.md +91 -40
  2. package/dist/controller-lambda/handler.js +16 -16
  3. package/dist/evident-scale-to-zero-construct.js +7 -0
  4. package/dist/image-version-pruner-lambda/handler.js +28250 -0
  5. package/dist/image-version-reporter-lambda/handler.js +15 -8
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.js +3 -2
  8. package/dist/microvm/constants.d.ts +1 -1
  9. package/dist/microvm/constants.js +7 -4
  10. package/dist/microvm/construct.d.ts +12 -8
  11. package/dist/microvm/construct.js +42 -33
  12. package/dist/microvm/controller/handle-doorbell.d.ts +2 -2
  13. package/dist/microvm/controller/handle-doorbell.js +2 -2
  14. package/dist/microvm/image/stage-context.d.ts +13 -38
  15. package/dist/microvm/image/stage-context.js +31 -118
  16. package/dist/microvm/image-version-pruner/construct.d.ts +13 -0
  17. package/dist/microvm/image-version-pruner/construct.js +79 -0
  18. package/dist/microvm/image-version-pruner/handler.d.ts +20 -0
  19. package/dist/microvm/image-version-pruner/handler.js +116 -0
  20. package/dist/microvm/image-version-reporter/construct.d.ts +1 -1
  21. package/dist/microvm/image-version-reporter/construct.js +3 -3
  22. package/dist/microvm/image-version-reporter/handler.d.ts +2 -2
  23. package/dist/microvm/image-version-reporter/handler.js +9 -7
  24. package/dist/microvm/shapes.d.ts +10 -21
  25. package/dist/microvm/shapes.js +10 -17
  26. package/dist/waker-lambda/handler.js +3 -3
  27. package/package.json +3 -3
  28. package/dist/microvm-image-context/Dockerfile +0 -190
  29. package/dist/microvm-image-context/hook-server.js +0 -286
  30. package/dist/microvm-image-context/hooks/common.sh +0 -905
  31. package/dist/microvm-image-context/hooks/resume +0 -81
  32. package/dist/microvm-image-context/hooks/run +0 -95
  33. package/dist/microvm-image-context/hooks/suspend +0 -21
  34. package/dist/microvm-image-context/hooks/terminate +0 -36
@@ -1,190 +0,0 @@
1
- # Generic MicroVM runner image
2
- #
3
- # Built for linux/arm64 (Lambda MicroVMs run on Graviton only) and with ONE
4
- # process: the hook server. `overlay/setup-root` and `overlay/setup-workspace`
5
- # are the extension point for deployment-specific packages, dependency
6
- # installation and build warm-up.
7
- #
8
- # THE BOOT SPLIT — the rule that governs everything below. AWS snapshots this
9
- # image ONCE at build and every MicroVM resumes from that same snapshot, so
10
- # anything unique or secret baked in here is shared by every VM launched from
11
- # this image version. Therefore this image must NOT start the tunnel
12
- # (`evident run`), clone the repo, or carry any credential, machine ID or
13
- # generated secret. Identity arrives per-VM in the `/run` hook payload.
14
- # `aws/runner-cdk/src/microvm/image/dockerfile.test.ts` fails the build if this
15
- # regresses.
16
- #
17
- # No `--platform` on FROM: AWS builds this natively on Graviton. Build it
18
- # locally with `docker build --platform linux/arm64`.
19
- #
20
- # Node major tracks `.nvmrc` / the root `engines.node` (22) so the image runs
21
- # the same runtime as CI — `evident-runner/src/node-version.test.ts` fails if
22
- # they drift. The Debian codename is pinned explicitly (`bookworm`, what
23
- # `node:22-slim` resolves to today) so a future default bump to a newer Debian
24
- # can't silently change the apt package set this image asserts on below.
25
- FROM node:22-bookworm-slim
26
-
27
- ENV PNPM_HOME="/pnpm"
28
- ENV PATH="$PNPM_HOME:$PATH"
29
- RUN corepack enable && corepack prepare pnpm@9.15.0 --activate
30
-
31
- # System tooling + GitHub CLI + AWS CLI, in a single layer.
32
- # - awscli (v2): required — durable-state persistence uses `aws s3`.
33
- # - procps: required at RUNTIME for process inspection and debugging. Listed
34
- # explicitly so apt keeps it.
35
- # - gnupg, unzip: BUILD-ONLY (gh apt key / AWS CLI bundle); purged in this layer.
36
- #
37
- # Purge build-only packages BY NAME — do NOT use `apt-get autoremove`, which
38
- # once cascaded into shared libs and swept `procps` out of the runner image. The
39
- # binary assertion further down fails the build if any required binary is gone.
40
- RUN apt-get update \
41
- && apt-get install -y --no-install-recommends \
42
- ca-certificates curl git jq less procps psmisc ripgrep \
43
- gnupg unzip \
44
- # --- GitHub CLI (`gh`) from the official apt repo ---
45
- && mkdir -p -m 755 /etc/apt/keyrings \
46
- && curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \
47
- -o /etc/apt/keyrings/githubcli-archive-keyring.gpg \
48
- && chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
49
- && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \
50
- > /etc/apt/sources.list.d/github-cli.list \
51
- && apt-get update \
52
- && apt-get install -y --no-install-recommends gh \
53
- # --- AWS CLI v2 (aarch64 bundle; this image is arm64 only) ---
54
- && curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o /tmp/awscliv2.zip \
55
- && unzip -q /tmp/awscliv2.zip -d /tmp \
56
- && /tmp/aws/install \
57
- && aws --version \
58
- # --- Drop the build-only packages (BY NAME, no autoremove) + caches ---
59
- && apt-get purge -y gnupg unzip \
60
- && rm -rf /tmp/aws /tmp/awscliv2.zip /var/lib/apt/lists/*
61
-
62
- # Litestream — replicates the OpenCode SQLite session DB to S3 so history
63
- # survives VM replacement. Pinned + checksum-verified: a wrong LITESTREAM_SHA256
64
- # fails the build at `sha256sum -c`. The checksum is for the arm64 tarball and
65
- # is NOT interchangeable with the ECS runner image's. Note the release tag keeps
66
- # the `v` but the filename does not.
67
- # `/run` restores opencode.db from S3 (#812 WI-2) — one bounded `litestream
68
- # restore` attempt — then starts a backgrounded `litestream replicate` once
69
- # opencode has opened the DB (WI-3); `/suspend`/`/resume`/`/terminate` flush,
70
- # restart and stop it in turn (WI-4). Do not remove as dead code.
71
- ARG LITESTREAM_VERSION=0.5.16
72
- ARG LITESTREAM_SHA256=678022e4103145302598e35d37f8718392d42e153feeb1e2d4a64dd0cd3aaf10
73
- RUN curl -fsSL -o /tmp/litestream.tar.gz \
74
- "https://github.com/benbjohnson/litestream/releases/download/v${LITESTREAM_VERSION}/litestream-${LITESTREAM_VERSION}-linux-arm64.tar.gz" \
75
- && echo "${LITESTREAM_SHA256} /tmp/litestream.tar.gz" | sha256sum -c - \
76
- && tar -C /usr/local/bin -xzf /tmp/litestream.tar.gz litestream \
77
- && chmod +x /usr/local/bin/litestream \
78
- && rm -f /tmp/litestream.tar.gz \
79
- && litestream version
80
-
81
- # The AI agent runtime, the Evident CLI and the Claude Code CLI, installed
82
- # globally and pinned via build args so image versions are reproducible.
83
- # OPENCODE_VERSION is a DELIBERATE PIN, not a floating tag — see #537: a
84
- # floating `opencode-ai@latest` install was implicated in unbounded runner
85
- # memory growth / OOM kills. Keep it in lockstep with the ECS runner image's.
86
- # EVIDENT_CLI_VERSION is DELIBERATELY the floating `dev` tag, matching the ECS
87
- # runner image. This is a
88
- # development environment: it should track the head of the CLI so changes are
89
- # testable without a version bump in every PR that touches a hook.
90
- # RUNNER_SYNCHRONISER_VERSION floats on `dev` for the identical reason.
91
- ARG OPENCODE_VERSION=1.18.3
92
- ARG EVIDENT_CLI_VERSION=dev
93
- ARG CLAUDE_CODE_VERSION=latest
94
- ARG RUNNER_SYNCHRONISER_VERSION=dev
95
- RUN npm install -g \
96
- "opencode-ai@${OPENCODE_VERSION}" \
97
- "@evident-ai/cli@${EVIDENT_CLI_VERSION}" \
98
- "@anthropic-ai/claude-code@${CLAUDE_CODE_VERSION}" \
99
- "@evident-ai/runner-synchroniser@${RUNNER_SYNCHRONISER_VERSION}" \
100
- && opencode --version \
101
- && evident --version \
102
- && npm cache clean --force
103
-
104
- # Assert every REQUIRED runtime binary survived every layer above (fail loud).
105
- # Placed after the last install so it covers the apt purge, the litestream
106
- # extraction and the global npm installs in one pass.
107
- RUN for bin in ps pgrep pkill curl aws gh git jq rg litestream runner-synchroniser opencode evident timeout; do \
108
- command -v "$bin" >/dev/null 2>&1 || { echo "FATAL: required binary '$bin' missing from image" >&2; exit 1; }; \
109
- done \
110
- && curl -fsS -o /dev/null https://cli.github.com \
111
- || { echo "FATAL: curl TLS smoke test failed (broken TLS libs)" >&2; exit 1; }
112
-
113
- # Non-root user that owns the workspace. uid/gid pinned to 10001 for stable file
114
- # ownership (opencode.db, ~/.claude/.credentials.json) across rebuilds.
115
- RUN groupadd --system --gid 10001 runner \
116
- && useradd --system --uid 10001 --gid 10001 \
117
- --create-home --home-dir /home/runner runner
118
-
119
- # The hook server: the ONLY process this image starts, and it starts nothing
120
- # itself until AWS calls a hook. It is an esbuild bundle of
121
- # src/microvm/image/hook-server.ts, placed next to this Dockerfile by
122
- # `stageMicrovmImageContext()` — which is why this file is not buildable
123
- # straight from the source tree.
124
- COPY hook-server.js /usr/local/lib/evident/hook-server.js
125
-
126
- # One executable per lifecycle phase. There is deliberately no `ready` and no
127
- # `validate` script: the snapshot is shared by every VM started from this image
128
- # version, so nothing per-VM may run before /run — which leaves those two phases
129
- # with nothing to do, and the runtime answers them 200 without running anything.
130
- COPY hooks /etc/evident/hooks
131
-
132
- # Workspace: the repository the agent works on, baked in. A resumed VM must be
133
- # useful in milliseconds, while a clone costs minutes — so the checkout happens
134
- # here; dependency installation and build warm-up belong to the deployment overlay.
135
- #
136
- # This does not weaken the boot split: source, git history and node_modules are
137
- # neither secret nor per-VM-unique, so sharing them across every VM from this
138
- # snapshot is exactly right. No credential is involved either — the repo travels
139
- # in the build context (cloned by `stageMicrovmImageContext()` from a local
140
- # checkout), not through a `git clone` needing a token. `origin` is the plain
141
- # HTTPS GitHub URL; the credential that makes it fetchable and pushable arrives
142
- # per-VM, so the agent is what brings this checkout up to date.
143
- ENV WORKSPACE=/workspace
144
- ENV HOME=/home/runner
145
- #
146
- # The machine-id files are created EMPTY and runner-owned so that /run can
147
- # actually rewrite them: the hooks run as uid 10001, and neither `/etc` nor
148
- # `/var/lib/dbus` is writable by it, so without this the regeneration is a
149
- # permanent no-op and every VM from this snapshot shares one machine id. Empty
150
- # is the correct unset state — it is the absence of an identity, so nothing
151
- # per-VM-unique enters the shared snapshot.
152
- RUN mkdir -p /var/lib/dbus /home/runner/.local/state/evident \
153
- && install -o runner -g runner -m 0644 /dev/null /etc/machine-id \
154
- && install -o runner -g runner -m 0644 /dev/null /var/lib/dbus/machine-id \
155
- && chown -R runner:runner /home/runner
156
-
157
- # Deployment additions are always present because staging writes no-op defaults
158
- # when no overlay is supplied.
159
- COPY overlay /etc/evident/overlay
160
- # HOME is already /home/runner, so root-warmed npx/npm state must be runner-owned
161
- # or the runner's first npm/pnpm call would fail with EACCES.
162
- RUN /etc/evident/overlay/setup-root \
163
- && chown -R runner:runner /home/runner
164
- COPY --chown=10001:10001 repo ${WORKSPACE}
165
- WORKDIR ${WORKSPACE}
166
- USER runner
167
-
168
- # The staged context deliberately ships no `.git/index` (it is not byte-stable,
169
- # so shipping it would re-roll the image version on every deploy) — without this
170
- # reset the agent's workspace reports ~1400 files as staged deletions. Runs as
171
- # `runner` (not root) so the rebuilt index is runner-owned and writable later.
172
- RUN git reset --quiet
173
-
174
- # Deployment-specific dependency installation and build work belongs here. This runs
175
- # as `runner` in `${WORKSPACE}`, so everything it writes is agent-writable.
176
- #
177
- # Keep the overlay's install and build in one layer: pnpm hard-links `node_modules`
178
- # into its content-addressed store, and hard links only survive within a single layer.
179
- RUN /etc/evident/overlay/setup-workspace
180
-
181
- # Port AWS calls the MicroVM hooks on.
182
- ENV HOOKS_PORT=8080
183
- # OpenCode loopback port the CLI tunnels to (matches `evident run` default).
184
- ENV OPENCODE_PORT=4096
185
-
186
- EXPOSE 8080
187
-
188
- # No ENTRYPOINT shell: the hook server is started directly, and it must be the
189
- # only thing running until AWS calls /run.
190
- CMD ["node", "/usr/local/lib/evident/hook-server.js"]
@@ -1,286 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJS = (cb, mod) => function __require() {
9
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
-
28
- // ../lambda-microvm-runtime/dist/runtime.js
29
- var require_runtime = __commonJS({
30
- "../lambda-microvm-runtime/dist/runtime.js"(exports2) {
31
- "use strict";
32
- Object.defineProperty(exports2, "__esModule", { value: true });
33
- exports2.HOOK_SIGTERM_SECONDS = exports2.HOOK_PATHS = exports2.HOOK_NAMES = exports2.HOOK_PATH_PREFIX = void 0;
34
- exports2.parseRunEnvelope = parseRunEnvelope;
35
- exports2.createMicrovmRuntime = createMicrovmRuntime;
36
- var node_http_1 = require("node:http");
37
- exports2.HOOK_PATH_PREFIX = "/aws/lambda-microvms/runtime/v1";
38
- exports2.HOOK_NAMES = ["ready", "validate", "run", "resume", "suspend", "terminate"];
39
- exports2.HOOK_PATHS = Object.fromEntries(exports2.HOOK_NAMES.map((name) => [name, `${exports2.HOOK_PATH_PREFIX}/${name}`]));
40
- var RUN_HOOK_PAYLOAD_MAX_BYTES = 16384;
41
- var MAX_BODY_BYTES = RUN_HOOK_PAYLOAD_MAX_BYTES * 8;
42
- exports2.HOOK_SIGTERM_SECONDS = 55;
43
- var DEFAULT_TIMEOUT_SECONDS = exports2.HOOK_SIGTERM_SECONDS;
44
- var DEFAULT_KILL_GRACE_SECONDS = 10;
45
- function readBody(request) {
46
- return new Promise((resolve, reject) => {
47
- const chunks = [];
48
- let size = 0;
49
- let oversize = false;
50
- request.on("data", (chunk) => {
51
- if (oversize) {
52
- return;
53
- }
54
- size += chunk.length;
55
- if (size > MAX_BODY_BYTES) {
56
- oversize = true;
57
- resolve(null);
58
- return;
59
- }
60
- chunks.push(chunk);
61
- });
62
- request.on("end", () => {
63
- if (!oversize) {
64
- resolve(Buffer.concat(chunks).toString("utf8"));
65
- }
66
- });
67
- request.on("error", reject);
68
- });
69
- }
70
- function parseRunEnvelope(rawBody) {
71
- let parsed;
72
- try {
73
- parsed = JSON.parse(rawBody);
74
- } catch {
75
- throw new Error("run hook body is not valid JSON");
76
- }
77
- if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
78
- throw new Error("run hook body is not a JSON object");
79
- }
80
- const envelope = parsed;
81
- const microvmId = envelope.microvmId;
82
- const runHookPayload = envelope.runHookPayload;
83
- if (typeof microvmId !== "string" || microvmId === "") {
84
- throw new Error("run hook body is missing microvmId");
85
- }
86
- if (typeof runHookPayload !== "string") {
87
- throw new Error("run hook body is missing runHookPayload");
88
- }
89
- return { microvmId, runHookPayload };
90
- }
91
- function createMicrovmRuntime({ hooksDir, spawn, hasScript, timeoutSeconds = DEFAULT_TIMEOUT_SECONDS, killGraceSeconds = DEFAULT_KILL_GRACE_SECONDS }) {
92
- function runScript(hook, script, env, payload) {
93
- return new Promise((resolve) => {
94
- const child = spawn(script, { env });
95
- let settled = false;
96
- let escalation;
97
- const settle = (outcome) => {
98
- if (settled) {
99
- return;
100
- }
101
- settled = true;
102
- clearTimeout(timer);
103
- resolve(outcome);
104
- };
105
- const timer = setTimeout(() => {
106
- console.error(`[hook] hook=${hook} status=timeout limit_seconds=${timeoutSeconds}`);
107
- child.kill("SIGTERM");
108
- escalation = setTimeout(() => {
109
- console.error(`[hook] hook=${hook} status=kill_escalated grace_seconds=${killGraceSeconds}`);
110
- child.kill("SIGKILL");
111
- }, killGraceSeconds * 1e3);
112
- escalation.unref();
113
- settle({ statusCode: 500, message: "hook timed out" });
114
- }, timeoutSeconds * 1e3);
115
- timer.unref();
116
- child.once("error", (error) => {
117
- console.error(`[hook] hook=${hook} status=spawn_failed error=${error.message}`);
118
- settle({ statusCode: 500, message: "hook could not be started" });
119
- });
120
- child.once("exit", (code) => {
121
- clearTimeout(escalation);
122
- if (code === 0) {
123
- settle({ statusCode: 200, message: hook });
124
- return;
125
- }
126
- console.error(`[hook] hook=${hook} status=failed exit_code=${code}`);
127
- settle({ statusCode: 500, message: "hook failed" });
128
- });
129
- if (payload !== void 0 && child.stdin) {
130
- child.stdin.write(payload);
131
- child.stdin.end();
132
- } else {
133
- child.stdin?.end();
134
- }
135
- });
136
- }
137
- async function dispatch(hook, rawBody) {
138
- const env = { ...process.env };
139
- let payload;
140
- if (hook === "run") {
141
- const envelope = parseRunEnvelope(rawBody);
142
- env.MICROVM_ID = envelope.microvmId;
143
- payload = envelope.runHookPayload;
144
- }
145
- const script = `${hooksDir}/${hook}`;
146
- if (!hasScript(script)) {
147
- return { statusCode: 200, message: `${hook} (no script)` };
148
- }
149
- const outcome = await runScript(hook, script, env, payload);
150
- if (hook === "terminate" && outcome.statusCode !== 200) {
151
- console.error("[hook] hook=terminate status=reported_ok_despite_failure");
152
- return { statusCode: 200, message: "terminate (best effort)" };
153
- }
154
- return outcome;
155
- }
156
- return (0, node_http_1.createServer)((request, response) => {
157
- const send = (statusCode, message) => {
158
- response.writeHead(statusCode, { "content-type": "application/json" });
159
- response.end(JSON.stringify({ message }));
160
- };
161
- const path = (request.url ?? "").split("?")[0];
162
- const hook = exports2.HOOK_NAMES.find((name) => exports2.HOOK_PATHS[name] === path);
163
- if (!hook) {
164
- request.resume();
165
- send(404, "unknown hook path");
166
- return;
167
- }
168
- if (request.method !== "POST") {
169
- request.resume();
170
- send(405, "hook requires POST");
171
- return;
172
- }
173
- void readBody(request).then(async (body) => {
174
- if (body === null) {
175
- send(413, "hook body too large");
176
- return;
177
- }
178
- try {
179
- const outcome = await dispatch(hook, body);
180
- send(outcome.statusCode, outcome.message);
181
- } catch (error) {
182
- send(400, error instanceof Error ? error.message : "bad request");
183
- }
184
- }).catch((error) => {
185
- console.error(`[hook] hook=${hook} status=unhandled_error error=${error instanceof Error ? error.message : String(error)}`);
186
- send(500, "hook failed");
187
- });
188
- });
189
- }
190
- }
191
- });
192
-
193
- // ../lambda-microvm-runtime/dist/node-runtime.js
194
- var require_node_runtime = __commonJS({
195
- "../lambda-microvm-runtime/dist/node-runtime.js"(exports2) {
196
- "use strict";
197
- Object.defineProperty(exports2, "__esModule", { value: true });
198
- exports2.createNodeRuntime = createNodeRuntime2;
199
- var node_child_process_1 = require("node:child_process");
200
- var node_fs_1 = require("node:fs");
201
- var runtime_1 = require_runtime();
202
- function createNodeRuntime2({ hooksDir, timeoutSeconds, killGraceSeconds }) {
203
- return (0, runtime_1.createMicrovmRuntime)({
204
- hooksDir,
205
- timeoutSeconds,
206
- killGraceSeconds,
207
- hasScript: (script) => {
208
- try {
209
- (0, node_fs_1.accessSync)(script, node_fs_1.constants.X_OK);
210
- return true;
211
- } catch {
212
- return false;
213
- }
214
- },
215
- spawn: (script, options) => {
216
- const child = (0, node_child_process_1.spawn)(script, {
217
- env: options.env,
218
- // stdin is a pipe so the run payload never has to travel in argv.
219
- stdio: ["pipe", "inherit", "inherit"],
220
- // Its own process group, so a signal can reach the tree the script
221
- // built — a hook shells out, and stopping only the shell orphans the
222
- // synchroniser or probe it was waiting on.
223
- detached: true
224
- });
225
- child.kill = (signal) => {
226
- try {
227
- process.kill(-child.pid, signal);
228
- return true;
229
- } catch (error) {
230
- if (error.code !== "ESRCH") {
231
- console.error(`[hook] script=${script} status=signal_failed signal=${String(signal)} error=${error instanceof Error ? error.message : String(error)}`);
232
- }
233
- return false;
234
- }
235
- };
236
- child.stdin?.on("error", (error) => {
237
- console.error(`[hook] script=${script} status=stdin_write_failed error=${error.message}`);
238
- });
239
- return child;
240
- }
241
- });
242
- }
243
- }
244
- });
245
-
246
- // ../lambda-microvm-runtime/dist/index.js
247
- var require_dist = __commonJS({
248
- "../lambda-microvm-runtime/dist/index.js"(exports2) {
249
- "use strict";
250
- Object.defineProperty(exports2, "__esModule", { value: true });
251
- exports2.createNodeRuntime = exports2.HOOK_SIGTERM_SECONDS = exports2.HOOK_PATH_PREFIX = exports2.HOOK_PATHS = exports2.HOOK_NAMES = exports2.parseRunEnvelope = exports2.createMicrovmRuntime = void 0;
252
- var runtime_1 = require_runtime();
253
- Object.defineProperty(exports2, "createMicrovmRuntime", { enumerable: true, get: function() {
254
- return runtime_1.createMicrovmRuntime;
255
- } });
256
- Object.defineProperty(exports2, "parseRunEnvelope", { enumerable: true, get: function() {
257
- return runtime_1.parseRunEnvelope;
258
- } });
259
- Object.defineProperty(exports2, "HOOK_NAMES", { enumerable: true, get: function() {
260
- return runtime_1.HOOK_NAMES;
261
- } });
262
- Object.defineProperty(exports2, "HOOK_PATHS", { enumerable: true, get: function() {
263
- return runtime_1.HOOK_PATHS;
264
- } });
265
- Object.defineProperty(exports2, "HOOK_PATH_PREFIX", { enumerable: true, get: function() {
266
- return runtime_1.HOOK_PATH_PREFIX;
267
- } });
268
- Object.defineProperty(exports2, "HOOK_SIGTERM_SECONDS", { enumerable: true, get: function() {
269
- return runtime_1.HOOK_SIGTERM_SECONDS;
270
- } });
271
- var node_runtime_1 = require_node_runtime();
272
- Object.defineProperty(exports2, "createNodeRuntime", { enumerable: true, get: function() {
273
- return node_runtime_1.createNodeRuntime;
274
- } });
275
- }
276
- });
277
-
278
- // ../../runner/docker-images/microvm/hook-server.ts
279
- var import_lambda_microvm_runtime = __toESM(require_dist());
280
- var HOOKS_DIR = "/etc/evident/hooks";
281
- var HOOKS_PORT = 8080;
282
- var server = (0, import_lambda_microvm_runtime.createNodeRuntime)({ hooksDir: HOOKS_DIR });
283
- var port = Number(process.env.HOOKS_PORT ?? HOOKS_PORT);
284
- server.listen(port, "0.0.0.0", () => {
285
- console.log(`[hook] server listening on 0.0.0.0:${port}`);
286
- });