@evident-ai/runner-cdk 3.4.1-dev.3adba63 → 3.4.1-dev.59c7df3
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 +2 -2
- package/dist/controller-lambda/handler.js +1 -1
- package/dist/evident-scale-to-zero-construct.d.ts +16 -4
- package/dist/evident-scale-to-zero-construct.js +15 -9
- package/dist/microvm/construct.js +5 -1
- package/dist/microvm/controller/shape-catalogue.d.ts +1 -1
- package/dist/microvm/controller/shape-catalogue.js +1 -1
- package/dist/microvm-image-context/Dockerfile +2 -2
- package/dist/microvm-image-context/hooks/common.sh +241 -643
- package/dist/microvm-image-context/hooks/resume +8 -9
- package/dist/microvm-image-context/hooks/run +16 -39
- package/dist/microvm-image-context/hooks/suspend +3 -0
- package/dist/microvm-image-context/hooks/terminate +3 -0
- package/package.json +1 -1
|
@@ -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
|
|
@@ -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,35 +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
|
-
apply_runner_opencode_config
|
|
84
|
-
|
|
85
|
-
# 8 — configure git after credentials are restored and before agent shells start.
|
|
86
|
-
configure_github_access
|
|
87
|
-
|
|
88
|
-
# 9 — opencode. Started here, not at build time: a warm process in the shared
|
|
89
|
-
# snapshot would carry its installation id and database into every VM. Not
|
|
90
|
-
# waited on: a slow opencode boot is not a reason to fail /run (the tunnel CLI
|
|
91
|
-
# auto-starts opencode when it finds none healthy,
|
|
92
|
-
# apps/cli/src/commands/ensure-opencode.ts, and the api-worker lifecycle cron
|
|
93
|
-
# reclaims a runner that never comes online).
|
|
94
|
-
start_opencode
|
|
95
|
-
|
|
96
|
-
# 10 — begin replicating the session DB (#812 WI-3), now that opencode has
|
|
97
|
-
# opened it and before any work can arrive over the tunnel. Bare, like
|
|
98
|
-
# restore_session_db above: start_litestream never returns non-zero (every
|
|
99
|
-
# guard inside it is its own `return 0`), so there is nothing here for
|
|
100
|
-
# `set -e` to abort on.
|
|
101
|
-
start_litestream
|
|
102
|
-
|
|
103
|
-
# 11 — 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
|
|
104
81
|
# unreadable to anyone else from the moment it exists, before the key is in it.
|
|
105
82
|
(
|
|
106
83
|
umask 077
|
|
@@ -112,6 +89,6 @@ start_litestream
|
|
|
112
89
|
# attempt cap (apps/cli/src/lib/tunnel/connection.ts), and a control-plane
|
|
113
90
|
# reclaim pass (the api-worker lifecycle cron) is what decides whether a
|
|
114
91
|
# runner that never connects gets suspended.
|
|
115
|
-
start_tunnel "${runner_key}" "${api_url}" "${tunnel_url}"
|
|
92
|
+
start_tunnel "${runner_key}" "${api_url}" "${tunnel_url}" true true
|
|
116
93
|
|
|
117
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evident-ai/runner-cdk",
|
|
3
|
-
"version": "3.4.1-dev.
|
|
3
|
+
"version": "3.4.1-dev.59c7df3",
|
|
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",
|