@evident-ai/runner-cdk 0.1.1-dev.da88f8e → 3.4.1-dev.0ef5061
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 +24 -14
- package/dist/controller-lambda/handler.js +14 -8
- package/dist/evident-scale-to-zero-construct.d.ts +16 -4
- package/dist/evident-scale-to-zero-construct.js +19 -14
- package/dist/image-version-reporter-lambda/handler.js +129 -0
- package/dist/microvm/constants.js +2 -3
- package/dist/microvm/construct.d.ts +34 -2
- package/dist/microvm/construct.js +38 -0
- package/dist/microvm/controller/handle-doorbell.js +11 -8
- package/dist/microvm/controller/microvm-client.d.ts +7 -1
- package/dist/microvm/controller/shape-catalogue.d.ts +1 -1
- package/dist/microvm/controller/shape-catalogue.js +1 -1
- package/dist/microvm/image-version-reporter/construct.d.ts +35 -0
- package/dist/microvm/image-version-reporter/construct.js +91 -0
- package/dist/microvm/image-version-reporter/handler.d.ts +26 -0
- package/dist/microvm/image-version-reporter/handler.js +104 -0
- package/dist/microvm-image-context/Dockerfile +10 -7
- package/dist/microvm-image-context/hook-server.js +2 -6
- package/dist/microvm-image-context/hooks/common.sh +247 -545
- package/dist/microvm-image-context/hooks/resume +9 -10
- package/dist/microvm-image-context/hooks/run +16 -33
- package/dist/microvm-image-context/hooks/suspend +3 -0
- package/dist/microvm-image-context/hooks/terminate +3 -0
- package/dist/waker/construct.js +1 -1
- package/package.json +10 -8
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
#
|
|
3
3
|
# Re-dial with the identity /run left behind. There is no step that could fetch
|
|
4
|
-
# a fresh runner key, so the one from /run is what resumes.
|
|
5
|
-
# session-DB replicator
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
4
|
+
# a fresh runner key, so the one from /run is what resumes. The CLI delegated by
|
|
5
|
+
# start_tunnel owns the session-DB replicator's post-resume start. The interval
|
|
6
|
+
# credential sync loop (#1868 WI-3) stays here because /suspend stops it too, so
|
|
7
|
+
# a resumed VM that never restarted it here would never sync credentials again
|
|
8
|
+
# for the rest of its life.
|
|
9
9
|
set -euo pipefail
|
|
10
10
|
|
|
11
11
|
# shellcheck source=./common.sh
|
|
@@ -41,11 +41,10 @@ fi
|
|
|
41
41
|
|
|
42
42
|
# Tolerant, never fatal: a resume that fails costs the user their whole
|
|
43
43
|
# session, so a broken durable-state config degrades to "no session-DB
|
|
44
|
-
#
|
|
45
|
-
#
|
|
46
|
-
# already-running) handle the rest — this needs no logic of its own.
|
|
44
|
+
# replication" rather than a failed resume. The CLI's own guards handle the
|
|
45
|
+
# rest — this needs no logic of its own.
|
|
47
46
|
load_state_config || warn "could not resolve durable-state config; the session DB will not resume replicating"
|
|
48
|
-
|
|
47
|
+
start_credential_sync
|
|
49
48
|
|
|
50
49
|
# Diagnostic-only, unlike /run's gate: a failed resume costs the user their
|
|
51
50
|
# whole session, so this never exits — it only converts a silent "resumed but
|
|
@@ -61,7 +60,7 @@ start_litestream
|
|
|
61
60
|
# measures in ~2 s (see the waker note in common.sh).
|
|
62
61
|
#
|
|
63
62
|
# Safe to leave running past the hook's own exit: the runtime waits on the
|
|
64
|
-
# script's `'exit'`, not `'close'` (
|
|
63
|
+
# script's `'exit'`, not `'close'` (aws/lambda-microvm-runtime/src/
|
|
65
64
|
# runtime.ts), so a lingering child never delays the HTTP response. Its stdio
|
|
66
65
|
# is deliberately NOT redirected — that inherited fd is how the RUNNER-KEY-*
|
|
67
66
|
# line reaches CloudWatch, which is the whole point of running it at all.
|
|
@@ -28,6 +28,7 @@ cleanup() {
|
|
|
28
28
|
stop_tunnel || warn "stop_tunnel failed while cleaning up"
|
|
29
29
|
stop_opencode || warn "stop_opencode failed while cleaning up"
|
|
30
30
|
kill_litestream || warn "kill_litestream failed while cleaning up"
|
|
31
|
+
stop_credential_sync || warn "stop_credential_sync failed while cleaning up"
|
|
31
32
|
}
|
|
32
33
|
trap cleanup EXIT
|
|
33
34
|
|
|
@@ -51,20 +52,20 @@ regenerate_machine_id
|
|
|
51
52
|
# reads it, and left behind for the hooks that flush back to the same prefix.
|
|
52
53
|
printf '%s\n' "${state_prefix}" >"${STATE_PREFIX_FILE}"
|
|
53
54
|
|
|
54
|
-
# 3 — start reading the litestream
|
|
55
|
-
#
|
|
56
|
-
#
|
|
55
|
+
# 3 — start reading the litestream and aws CLI binaries NOW. The reads run in
|
|
56
|
+
# the background and overlap the CLI's own node startup and auth round trip,
|
|
57
|
+
# keeping their cold first touches off the path to the first credential fetch.
|
|
57
58
|
prewarm_litestream
|
|
59
|
+
prewarm_aws_cli
|
|
58
60
|
|
|
59
|
-
# 4 —
|
|
60
|
-
#
|
|
61
|
-
|
|
62
|
-
restore_credentials
|
|
61
|
+
# 4 — export the durable-state config before anything that reads it. Fatal,
|
|
62
|
+
# because the CLI and the teardown hooks must agree on this runner's state prefix.
|
|
63
|
+
load_state_config || exit 1
|
|
63
64
|
|
|
64
65
|
# 5 — does the runner key in this payload actually authenticate against
|
|
65
|
-
# Evident? Checked here, before
|
|
66
|
-
#
|
|
67
|
-
#
|
|
66
|
+
# Evident? Checked here, before the tunnel spends any of this boot's time on a key
|
|
67
|
+
# that cannot work, and before anything has started that cleanup would need to
|
|
68
|
+
# tear down. Fatal ONLY on contrary evidence
|
|
68
69
|
# (check_runner_key's own contract, common.sh): a key the API actively rejects
|
|
69
70
|
# cannot work regardless, and failing here costs ~5s against the ~10 minutes a
|
|
70
71
|
# runner that can never connect would otherwise burn before the lifecycle cron
|
|
@@ -72,29 +73,11 @@ restore_credentials
|
|
|
72
73
|
# it warns and this VM still boots.
|
|
73
74
|
check_runner_key "${runner_key}" "${api_url}" || exit 1
|
|
74
75
|
|
|
75
|
-
# 6 — the
|
|
76
|
-
#
|
|
77
|
-
|
|
78
|
-
# DB may ever fail /run), so there is deliberately no `||` here to catch.
|
|
79
|
-
restore_session_db
|
|
80
|
-
log "session DB restore done ${SECONDS}s into the hook"
|
|
76
|
+
# 6 — the interval credential sync (#1868 WI-3). It stays before the context file
|
|
77
|
+
# is written. Bare: every guard inside start_credential_sync is its own `return 0`.
|
|
78
|
+
start_credential_sync
|
|
81
79
|
|
|
82
|
-
# 7 —
|
|
83
|
-
# snapshot would carry its installation id and database into every VM. Not
|
|
84
|
-
# waited on: a slow opencode boot is not a reason to fail /run (the tunnel CLI
|
|
85
|
-
# auto-starts opencode when it finds none healthy,
|
|
86
|
-
# apps/cli/src/commands/ensure-opencode.ts, and the api-worker lifecycle cron
|
|
87
|
-
# reclaims a runner that never comes online).
|
|
88
|
-
start_opencode
|
|
89
|
-
|
|
90
|
-
# 8 — begin replicating the session DB (#812 WI-3), now that opencode has
|
|
91
|
-
# opened it and before any work can arrive over the tunnel. Bare, like
|
|
92
|
-
# restore_session_db above: start_litestream never returns non-zero (every
|
|
93
|
-
# guard inside it is its own `return 0`), so there is nothing here for
|
|
94
|
-
# `set -e` to abort on.
|
|
95
|
-
start_litestream
|
|
96
|
-
|
|
97
|
-
# 9 — the first per-VM identity on the wire. The subshell's umask makes the file
|
|
80
|
+
# 7 — the first per-VM identity on the wire. The subshell's umask makes the file
|
|
98
81
|
# unreadable to anyone else from the moment it exists, before the key is in it.
|
|
99
82
|
(
|
|
100
83
|
umask 077
|
|
@@ -106,6 +89,6 @@ start_litestream
|
|
|
106
89
|
# attempt cap (apps/cli/src/lib/tunnel/connection.ts), and a control-plane
|
|
107
90
|
# reclaim pass (the api-worker lifecycle cron) is what decides whether a
|
|
108
91
|
# runner that never connects gets suspended.
|
|
109
|
-
start_tunnel "${runner_key}" "${api_url}" "${tunnel_url}"
|
|
92
|
+
start_tunnel "${runner_key}" "${api_url}" "${tunnel_url}" true true
|
|
110
93
|
|
|
111
94
|
run_succeeded=true
|
|
@@ -8,6 +8,9 @@ set -euo pipefail
|
|
|
8
8
|
# shellcheck source=./common.sh
|
|
9
9
|
source "$(dirname "$0")/common.sh"
|
|
10
10
|
|
|
11
|
+
# Stopped BEFORE the boundary flush (#1868 WI-3): the interval loop and this
|
|
12
|
+
# flush must not race each other on the same credential stores.
|
|
13
|
+
stop_credential_sync
|
|
11
14
|
sync_credentials
|
|
12
15
|
stop_tunnel
|
|
13
16
|
|
|
@@ -8,6 +8,9 @@ set -uo pipefail
|
|
|
8
8
|
# shellcheck source=./common.sh
|
|
9
9
|
source "$(dirname "$0")/common.sh"
|
|
10
10
|
|
|
11
|
+
# Stopped BEFORE the boundary flush (#1868 WI-3): the interval loop and this
|
|
12
|
+
# flush must not race each other on the same credential stores.
|
|
13
|
+
stop_credential_sync
|
|
11
14
|
sync_credentials
|
|
12
15
|
stop_tunnel
|
|
13
16
|
|
package/dist/waker/construct.js
CHANGED
|
@@ -56,7 +56,7 @@ class EvidentWaker extends constructs_1.Construct {
|
|
|
56
56
|
runtime: lambda.Runtime.NODEJS_22_X,
|
|
57
57
|
// Pre-bundled at PACKAGE build time (`pnpm --filter @evident-ai/runner-cdk
|
|
58
58
|
// build`, see scripts/build.ts), not at synth time: esbuild inlines
|
|
59
|
-
// @evident/
|
|
59
|
+
// @evident/sdk's HMAC verifier into
|
|
60
60
|
// dist/waker-lambda/handler.js, so neither this package's published npm
|
|
61
61
|
// artifact (which ships dist/ already built) nor a consuming app needs
|
|
62
62
|
// that private workspace package, or esbuild, on synth's PATH. Requires
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evident-ai/runner-cdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.4.1-dev.0ef5061",
|
|
4
4
|
"description": "Reusable CDK constructs for an Evident agent runner: a single scale-to-zero Fargate runner (task + service + per-agent self-stop role + waker Lambda), or a per-session AWS Lambda MicroVM that boots on demand and suspends between messages. Instantiate once per agent from your own stack.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -15,13 +15,14 @@
|
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
17
|
"build": "pnpm run build-bundled-deps && ts-node scripts/build.ts",
|
|
18
|
-
"//build-bundled-deps": "scripts/build.ts esbuild-bundles
|
|
19
|
-
"build-bundled-deps": "pnpm --filter @evident-ai/lambda-microvm-runtime build",
|
|
18
|
+
"//build-bundled-deps": "scripts/build.ts esbuild-bundles runner/docker-images/microvm/hook-server.ts, which imports @evident-ai/lambda-microvm-runtime by its built `main`. @evident-ai/lambda-microvm-cdk is a workspace:* devDependency whose types resolve through its own dist/, so tsc --project tsconfig.build.json cannot compile src/microvm/{shapes,construct}.ts without it. Chained into `build` rather than left to turbo's `^build` because publish-runner-cdk.yaml and infrastructure/evident-runner's build-runner-cdk-dep invoke `pnpm --filter @evident-ai/runner-cdk build` directly, which bypasses turbo entirely.",
|
|
19
|
+
"build-bundled-deps": "pnpm --filter @evident-ai/lambda-microvm-cdk build && pnpm --filter @evident-ai/lambda-microvm-runtime build",
|
|
20
20
|
"typecheck": "tsc --noEmit",
|
|
21
21
|
"test": "node --test --require ts-node/register 'src/**/*.test.ts'",
|
|
22
22
|
"format": "prettier --write 'src/**/*.ts'",
|
|
23
23
|
"lint": "eslint 'src/**/*.ts' --max-warnings=0"
|
|
24
24
|
},
|
|
25
|
+
"//peerDependencies": "@evident-ai/lambda-microvm-cdk is a registry range here, never workspace:*: publish-runner-cdk.yaml ships this package with `npm publish`, not `pnpm publish`, so pnpm's workspace-protocol substitution never runs and a workspace: range would reach npm literally, breaking every external install. Enforced by src/published-surface.test.ts. The matching devDependency is workspace:* so this monorepo's own build compiles against aws/lambda-microvm-cdk's source.",
|
|
25
26
|
"peerDependencies": {
|
|
26
27
|
"@evident-ai/lambda-microvm-cdk": "^0.1.1",
|
|
27
28
|
"aws-cdk-lib": "^2.240.0",
|
|
@@ -31,16 +32,17 @@
|
|
|
31
32
|
"@aws-sdk/client-ecs": "^3.682.0",
|
|
32
33
|
"@aws-sdk/client-lambda-microvms": "^3.1095.0",
|
|
33
34
|
"@aws-sdk/client-secrets-manager": "^3.682.0",
|
|
34
|
-
"@evident-ai/lambda-microvm-cdk": "
|
|
35
|
+
"@evident-ai/lambda-microvm-cdk": "workspace:*",
|
|
35
36
|
"@evident-ai/lambda-microvm-runtime": "workspace:*",
|
|
36
|
-
"@evident/
|
|
37
|
+
"@evident/sdk": "workspace:*",
|
|
37
38
|
"@types/node": "^22",
|
|
38
39
|
"aws-cdk-lib": "^2.240.0",
|
|
39
40
|
"constructs": "^10.5.0",
|
|
40
41
|
"esbuild": "^0.25.2",
|
|
41
42
|
"prettier": "^3.3.3",
|
|
42
43
|
"ts-node": "^10.9.2",
|
|
43
|
-
"typescript": "^5.6.3"
|
|
44
|
+
"typescript": "^5.6.3",
|
|
45
|
+
"runner-microvm-image": "workspace:*"
|
|
44
46
|
},
|
|
45
47
|
"publishConfig": {
|
|
46
48
|
"access": "public"
|
|
@@ -48,9 +50,9 @@
|
|
|
48
50
|
"repository": {
|
|
49
51
|
"type": "git",
|
|
50
52
|
"url": "https://github.com/sroze/evident.git",
|
|
51
|
-
"directory": "
|
|
53
|
+
"directory": "aws/runner-cdk"
|
|
52
54
|
},
|
|
53
55
|
"homepage": "https://evident.run",
|
|
54
|
-
"author": "Evident <
|
|
56
|
+
"author": "Evident <hello@evident.run>",
|
|
55
57
|
"license": "MIT"
|
|
56
58
|
}
|