@task-handoff/node-agent 0.0.32 → 0.0.34

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.
@@ -33,6 +33,15 @@ load_private_config() {
33
33
  fi
34
34
  }
35
35
 
36
+ start_node_agent_unix_proxy() {
37
+ if [ -z "${TASK_HANDOFF_NODE_AGENT_SOCKET_PATH:-}" ]; then
38
+ return
39
+ fi
40
+ node /run/task-handoff/bootstrap/node-agent-unix-proxy.mjs \
41
+ "${TASK_HANDOFF_NODE_AGENT_SOCKET_PATH}" \
42
+ "${TASK_HANDOFF_NODE_AGENT_PROXY_PORT:-19001}" &
43
+ }
44
+
36
45
  if [ -n "${TASK_HANDOFF_WORKSPACE_SUBDIRECTORY:-}" ]; then
37
46
  export TASK_HANDOFF_WORKSPACE="${TASK_HANDOFF_WORKSPACE:-/workspace}/${TASK_HANDOFF_WORKSPACE_SUBDIRECTORY}"
38
47
  unset TASK_HANDOFF_WORKSPACE_SUBDIRECTORY
@@ -40,6 +49,7 @@ fi
40
49
 
41
50
  if [ "$(id -u)" = "0" ] && [ "${TASK_HANDOFF_PRIVILEGE_DROPPED:-0}" != "1" ]; then
42
51
  load_private_config
52
+ start_node_agent_unix_proxy
43
53
  mkdir -p /data /home/agent
44
54
  chown agent:agent /data /home/agent
45
55
  if [ "${TASK_HANDOFF_WORKSPACE_MODE:-}" = "git-clone" ]; then
@@ -24,6 +24,10 @@ if [ ! -L "${current}" ]; then
24
24
  bootstrap_wait
25
25
  fi
26
26
 
27
+ # The launcher can be restarted by a process whose cwd belongs to the previous
28
+ # release. Keep this process and every child on a directory that survives release cleanup.
29
+ cd -- "${runtime_root}"
30
+
27
31
  exec node --input-type=module - "${current}" <<'NODE'
28
32
  import fs from "node:fs";
29
33
  import path from "node:path";
@@ -0,0 +1,26 @@
1
+ import http from "node:http";
2
+
3
+ const socketPath = process.argv[2];
4
+ const port = Number(process.argv[3] || "19001");
5
+ if (!socketPath || !Number.isInteger(port) || port < 1 || port > 65535) {
6
+ throw new Error("Usage: node-agent-unix-proxy.mjs <socket-path> [port]");
7
+ }
8
+
9
+ const server = http.createServer((request, response) => {
10
+ const upstream = http.request({
11
+ socketPath,
12
+ method: request.method,
13
+ path: request.url,
14
+ headers: request.headers,
15
+ }, (upstreamResponse) => {
16
+ response.writeHead(upstreamResponse.statusCode || 502, upstreamResponse.headers);
17
+ upstreamResponse.pipe(response);
18
+ });
19
+ upstream.on("error", (error) => {
20
+ if (!response.headersSent) response.writeHead(502, { "content-type": "application/json" });
21
+ response.end(JSON.stringify({ error: { code: "NODE_AGENT_CONTAINER_IPC_UNAVAILABLE", message: error.message } }));
22
+ });
23
+ request.pipe(upstream);
24
+ });
25
+
26
+ server.listen(port, "127.0.0.1");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@task-handoff/node-agent",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
4
4
  "description": "Prebuilt TaskHandoff node agent runtime.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "commonjs",
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "packageName": "@task-handoff/controlled-instance",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
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": "7aa3a1ba884827e41b137b39536c8779159dd5382b195b05f409db63436cd635"
9
+ "sha256": "acfc475be928565ae8413911cd34b1ff865b69d5b84b248353404a0c84614b48"
10
10
  }
@@ -0,0 +1 @@
1
+ 60b412243dc69c0fb223202b3f4d8ab0dc03c51d2d6d4d5cf52fbcdc1a1ec69d controlled-instance-runtime-0.0.34-linux-universal.tar.gz
@@ -1 +0,0 @@
1
- 5e54fc3a6d09361b00f96d0acc9874bde412c5399d5272523106253a23e12ebe controlled-instance-runtime-0.0.32-linux-universal.tar.gz