@task-handoff/node-agent 0.0.34 → 0.0.36
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 +1 -1
- package/dist/node-update-worker.js +1 -1
- package/docker/entrypoint.sh +74 -28
- package/docker/git-provision.sh +11 -7
- package/package.json +1 -1
- package/runtime-artifacts/{controlled-instance-runtime-0.0.34-linux-universal.manifest.json → controlled-instance-runtime-0.0.36-linux-universal.manifest.json} +2 -2
- package/runtime-artifacts/controlled-instance-runtime-0.0.36-linux-universal.tar.gz +0 -0
- package/runtime-artifacts/controlled-instance-runtime-0.0.36-linux-universal.tar.gz.sha256 +1 -0
- package/runtime-artifacts/controlled-instance-runtime-0.0.34-linux-universal.tar.gz +0 -0
- package/runtime-artifacts/controlled-instance-runtime-0.0.34-linux-universal.tar.gz.sha256 +0 -1
package/docker/entrypoint.sh
CHANGED
|
@@ -1,36 +1,75 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
set -euo pipefail
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
# The private config is mounted as a per-instance directory. The legacy single
|
|
5
|
+
# file path stays readable so containers created by older node agents keep
|
|
6
|
+
# starting after a node-agent upgrade.
|
|
7
|
+
readonly private_config_default_path="/run/task-handoff/private/private-config.json"
|
|
8
|
+
readonly private_config_legacy_path="/run/task-handoff/instance-private-config.json"
|
|
9
|
+
|
|
10
|
+
resolve_private_config_path() {
|
|
11
|
+
local candidate
|
|
12
|
+
for candidate in "${TASK_HANDOFF_INSTANCE_PRIVATE_CONFIG_PATH:-}" "${private_config_default_path}" "${private_config_legacy_path}"; do
|
|
13
|
+
if [ -n "${candidate}" ] && [ -f "${candidate}" ]; then
|
|
14
|
+
printf '%s' "${candidate}"
|
|
15
|
+
return 0
|
|
14
16
|
fi
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
done
|
|
18
|
+
return 1
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
# Only the instance identity is required to start. Model environment, catalog,
|
|
22
|
+
# and Codex settings are an optional startup snapshot that the node agent pushes
|
|
23
|
+
# over the authenticated internal API once the instance is registered.
|
|
24
|
+
decode_private_config() {
|
|
25
|
+
node -e '
|
|
19
26
|
const fs = require("node:fs");
|
|
20
27
|
const value = JSON.parse(fs.readFileSync(process.argv[1], "utf8"));
|
|
21
|
-
if (value.version !== 1 || typeof value.
|
|
22
|
-
const
|
|
28
|
+
if (value.version !== 1 || typeof value.instanceId !== "string" || !value.instanceId || typeof value.instanceCredential !== "string" || !value.instanceCredential) process.exit(78);
|
|
29
|
+
const configured = value.environment === undefined ? {} : value.environment;
|
|
30
|
+
if (!configured || typeof configured !== "object" || Array.isArray(configured)) process.exit(78);
|
|
31
|
+
const environment = { ...configured, TASK_HANDOFF_REGISTRATION_TOKEN: value.instanceCredential, TASK_HANDOFF_PRIVATE_CONFIG_LOADED: "1", TASK_HANDOFF_INSTANCE_PRIVATE_CONFIG_PATH: process.argv[1] };
|
|
23
32
|
if (value.modelCatalog !== undefined) environment.TASK_HANDOFF_PRIVATE_MODEL_CATALOG_JSON = JSON.stringify(value.modelCatalog);
|
|
24
33
|
if (value.codexSettings !== undefined) environment.TASK_HANDOFF_PRIVATE_CODEX_SETTINGS_JSON = JSON.stringify(value.codexSettings);
|
|
25
34
|
for (const [key, item] of Object.entries(environment)) {
|
|
26
35
|
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key) || typeof item !== "string") process.exit(78);
|
|
27
36
|
process.stdout.write(`${key}\t${Buffer.from(item).toString("base64")}\n`);
|
|
28
37
|
}
|
|
29
|
-
' "$
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
' "$1"
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
load_private_config() {
|
|
42
|
+
local attempts="${TASK_HANDOFF_PRIVATE_CONFIG_RETRY_ATTEMPTS:-20}"
|
|
43
|
+
local delay_seconds="${TASK_HANDOFF_PRIVATE_CONFIG_RETRY_DELAY_SECONDS:-1}"
|
|
44
|
+
local attempt=1
|
|
45
|
+
local config_path decoded key encoded value
|
|
46
|
+
while :; do
|
|
47
|
+
if config_path="$(resolve_private_config_path)" && decoded="$(decode_private_config "${config_path}")"; then
|
|
48
|
+
while IFS=$'\t' read -r key encoded; do
|
|
49
|
+
if [ -z "${key}" ]; then
|
|
50
|
+
continue
|
|
51
|
+
fi
|
|
52
|
+
if [[ ! "${key}" =~ ^[A-Za-z_][A-Za-z0-9_]*$ ]]; then
|
|
53
|
+
echo "Managed instance private configuration contains an invalid environment key." >&2
|
|
54
|
+
exit 78
|
|
55
|
+
fi
|
|
56
|
+
value="$(printf '%s' "${encoded}" | base64 --decode)"
|
|
57
|
+
export "${key}=${value}"
|
|
58
|
+
done <<< "${decoded}"
|
|
59
|
+
if [ "${TASK_HANDOFF_PRIVATE_CONFIG_LOADED:-}" = "1" ]; then
|
|
60
|
+
return 0
|
|
61
|
+
fi
|
|
62
|
+
echo "Managed instance private configuration could not be applied." >&2
|
|
63
|
+
exit 78
|
|
64
|
+
fi
|
|
65
|
+
if [ "${attempt}" -ge "${attempts}" ]; then
|
|
66
|
+
break
|
|
67
|
+
fi
|
|
68
|
+
attempt=$((attempt + 1))
|
|
69
|
+
sleep "${delay_seconds}"
|
|
70
|
+
done
|
|
71
|
+
echo "Managed instance private configuration is missing or invalid after ${attempts} attempts." >&2
|
|
72
|
+
exit 78
|
|
34
73
|
}
|
|
35
74
|
|
|
36
75
|
start_node_agent_unix_proxy() {
|
|
@@ -78,8 +117,15 @@ bootstrap_workspace() {
|
|
|
78
117
|
fi
|
|
79
118
|
local workspace="${TASK_HANDOFF_WORKSPACE:-/workspace}"
|
|
80
119
|
local mode="${TASK_HANDOFF_WORKSPACE_MODE:-}"
|
|
81
|
-
|
|
82
|
-
|
|
120
|
+
# Workspace Git environment contract (mirrors @task-handoff/protocol/workspace-git).
|
|
121
|
+
# This script is mounted by the node agent that writes the environment, so the
|
|
122
|
+
# workspace keys are the only input. The legacy keys are never read: images
|
|
123
|
+
# bake TASK_HANDOFF_GIT_COMMIT as their build commit and docker run exposes
|
|
124
|
+
# image environment here.
|
|
125
|
+
local git_url="${TASK_HANDOFF_WORKSPACE_GIT_URL:-}"
|
|
126
|
+
local git_ref="${TASK_HANDOFF_WORKSPACE_GIT_REF:-}"
|
|
127
|
+
local git_depth="${TASK_HANDOFF_WORKSPACE_GIT_DEPTH:-}"
|
|
128
|
+
local git_submodules="${TASK_HANDOFF_WORKSPACE_GIT_SUBMODULES:-false}"
|
|
83
129
|
|
|
84
130
|
if [ "${mode}" != "git-clone" ] || [ -z "${git_url}" ]; then
|
|
85
131
|
return
|
|
@@ -97,10 +143,10 @@ bootstrap_workspace() {
|
|
|
97
143
|
fi
|
|
98
144
|
|
|
99
145
|
local clone_args=(clone)
|
|
100
|
-
if [ -n "${
|
|
101
|
-
clone_args+=(--depth "${
|
|
146
|
+
if [ -n "${git_depth}" ]; then
|
|
147
|
+
clone_args+=(--depth "${git_depth}")
|
|
102
148
|
fi
|
|
103
|
-
if [ "${
|
|
149
|
+
if [ "${git_submodules}" = "true" ]; then
|
|
104
150
|
clone_args+=(--recurse-submodules)
|
|
105
151
|
fi
|
|
106
152
|
if [ -n "${git_ref}" ]; then
|
|
@@ -111,8 +157,8 @@ bootstrap_workspace() {
|
|
|
111
157
|
echo "Cloning workspace ${git_url} into ${workspace}."
|
|
112
158
|
git "${clone_args[@]}"
|
|
113
159
|
|
|
114
|
-
if [ -n "${
|
|
115
|
-
git -C "${workspace}" checkout "${
|
|
160
|
+
if [ -n "${TASK_HANDOFF_WORKSPACE_GIT_COMMIT:-}" ]; then
|
|
161
|
+
git -C "${workspace}" checkout "${TASK_HANDOFF_WORKSPACE_GIT_COMMIT}"
|
|
116
162
|
fi
|
|
117
163
|
}
|
|
118
164
|
|
package/docker/git-provision.sh
CHANGED
|
@@ -82,11 +82,15 @@ git_config=(
|
|
|
82
82
|
-c credential.useHttpPath=true
|
|
83
83
|
-c core.sshCommand="node /run/task-handoff/bootstrap/git-provisioning-helper.js ssh"
|
|
84
84
|
)
|
|
85
|
+
# Workspace Git environment contract (mirrors @task-handoff/protocol/workspace-git).
|
|
86
|
+
# Only the TASK_HANDOFF_WORKSPACE_GIT_* keys are provisioning input: released
|
|
87
|
+
# images bake TASK_HANDOFF_GIT_COMMIT as the image build commit and docker run
|
|
88
|
+
# exposes image environment here, so the legacy keys must never be read.
|
|
85
89
|
clone_args=(clone)
|
|
86
90
|
# A commit SHA is not guaranteed to be reachable from a shallow default-branch clone.
|
|
87
|
-
if [ -n "${
|
|
88
|
-
if [ -n "${
|
|
89
|
-
clone_args+=(-- "${
|
|
91
|
+
if [ -n "${TASK_HANDOFF_WORKSPACE_GIT_DEPTH:-}" ] && [ -z "${TASK_HANDOFF_WORKSPACE_GIT_COMMIT:-}" ]; then clone_args+=(--depth "${TASK_HANDOFF_WORKSPACE_GIT_DEPTH}"); fi
|
|
92
|
+
if [ -n "${TASK_HANDOFF_WORKSPACE_GIT_REF:-}" ]; then clone_args+=(--branch "${TASK_HANDOFF_WORKSPACE_GIT_REF}"); fi
|
|
93
|
+
clone_args+=(-- "${TASK_HANDOFF_WORKSPACE_GIT_URL}" "${checkout}")
|
|
90
94
|
|
|
91
95
|
mkdir -p /tmp/task-handoff-git-home
|
|
92
96
|
chown 1000:1000 /tmp/task-handoff-git-home
|
|
@@ -99,12 +103,12 @@ if ! runuser -u agent -- env \
|
|
|
99
103
|
fail CLONE_FAILED 74
|
|
100
104
|
fi
|
|
101
105
|
|
|
102
|
-
if [ -n "${
|
|
103
|
-
if ! runuser -u agent -- git -C "${checkout}" checkout --detach "${
|
|
106
|
+
if [ -n "${TASK_HANDOFF_WORKSPACE_GIT_COMMIT:-}" ]; then
|
|
107
|
+
if ! runuser -u agent -- git -C "${checkout}" checkout --detach "${TASK_HANDOFF_WORKSPACE_GIT_COMMIT}"; then
|
|
104
108
|
fail REF_NOT_FOUND 75
|
|
105
109
|
fi
|
|
106
110
|
fi
|
|
107
|
-
if [ "${
|
|
111
|
+
if [ "${TASK_HANDOFF_WORKSPACE_GIT_SUBMODULES:-false}" = "true" ]; then
|
|
108
112
|
if ! runuser -u agent -- env \
|
|
109
113
|
HOME=/tmp/task-handoff-git-home \
|
|
110
114
|
GIT_TERMINAL_PROMPT=0 \
|
|
@@ -113,7 +117,7 @@ if [ "${TASK_HANDOFF_GIT_SUBMODULES:-false}" = "true" ]; then
|
|
|
113
117
|
fail CLONE_FAILED 74
|
|
114
118
|
fi
|
|
115
119
|
fi
|
|
116
|
-
if [ "${
|
|
120
|
+
if [ "${TASK_HANDOFF_WORKSPACE_GIT_LFS:-false}" = "true" ]; then
|
|
117
121
|
if ! runuser -u agent -- env GIT_TERMINAL_PROMPT=0 GIT_SSH_COMMAND="node /run/task-handoff/bootstrap/git-provisioning-helper.js ssh" git "${git_config[@]}" -C "${checkout}" lfs pull; then
|
|
118
122
|
fail LFS_FAILED 76
|
|
119
123
|
fi
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"packageName": "@task-handoff/controlled-instance",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.36",
|
|
4
4
|
"platform": "linux",
|
|
5
5
|
"arch": "universal",
|
|
6
6
|
"formatVersion": 1,
|
|
7
7
|
"launcherAbi": 1,
|
|
8
8
|
"entrypoint": "dist/controlled-instance-cli.js",
|
|
9
|
-
"sha256": "
|
|
9
|
+
"sha256": "2c73014a7054f38be8a6200bd1361bca6ba7739e02f393f72a518c52a3931e54"
|
|
10
10
|
}
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
75724b25d73b3117159e80ca0724a02c584413d3d5b5975e63b9fc04a0fc9e2d controlled-instance-runtime-0.0.36-linux-universal.tar.gz
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
60b412243dc69c0fb223202b3f4d8ab0dc03c51d2d6d4d5cf52fbcdc1a1ec69d controlled-instance-runtime-0.0.34-linux-universal.tar.gz
|