talentos 1.4.8 → 1.4.9

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.
@@ -0,0 +1,99 @@
1
+ // Which addresses and names a room job's page read may never reach (read_page).
2
+ // A teammate's ask or a page the agent reads can name any URL, and the read runs
3
+ // on the owner's computer, so a name that resolves to loopback, the owner's
4
+ // network or a cloud metadata address would hand a private page to the room.
5
+ // Pure classifier; room-page.ts resolves the name once and connects to the
6
+ // address it checked. Mirrors convex/lib/safeFetch.ts (the CLI package cannot
7
+ // import it).
8
+ const PRIVATE_SUFFIXES = [".local", ".internal", ".localhost"];
9
+ const PRIVATE_NAMES = new Set(["localhost", "ip6-localhost", "metadata"]);
10
+ const TRAILING_DOTS = /\.+$/u;
11
+ const IPV4 = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/u;
12
+ const BRACKETS = /^\[|\]$/gu;
13
+ const DOTTED_TAIL = /^(.*:)(\d{1,3}(?:\.\d{1,3}){3})$/u;
14
+ const GROUP = /^[\da-f]{1,4}$/u;
15
+ function privateIpv4(host) {
16
+ const match = IPV4.exec(host);
17
+ if (!match) {
18
+ return false;
19
+ }
20
+ const octets = match.slice(1).map(Number);
21
+ if (octets.some((octet) => octet > 255)) {
22
+ return true;
23
+ }
24
+ const [a = 0, b = 0, c = 0] = octets;
25
+ return (a === 0 ||
26
+ a === 10 ||
27
+ a === 127 ||
28
+ (a === 100 && b >= 64 && b <= 127) ||
29
+ (a === 169 && b === 254) ||
30
+ (a === 172 && b >= 16 && b <= 31) ||
31
+ (a === 192 && b === 0 && c === 0) ||
32
+ (a === 192 && b === 168) ||
33
+ (a === 198 && (b === 18 || b === 19)) ||
34
+ a >= 224);
35
+ }
36
+ // The eight 16-bit groups of an IPv6 address, or null when it is not one.
37
+ function ipv6Groups(address) {
38
+ let text = address;
39
+ const dotted = DOTTED_TAIL.exec(address);
40
+ if (dotted) {
41
+ const octets = (dotted[2] ?? "").split(".").map(Number);
42
+ if (octets.some((octet) => octet > 255)) {
43
+ return null;
44
+ }
45
+ const [a = 0, b = 0, c = 0, d = 0] = octets;
46
+ text = `${dotted[1]}${(a * 256 + b).toString(16)}:${(c * 256 + d).toString(16)}`;
47
+ }
48
+ const halves = text.split("::");
49
+ if (halves.length > 2) {
50
+ return null;
51
+ }
52
+ const head = halves[0] ? halves[0].split(":") : [];
53
+ const tail = halves[1] ? halves[1].split(":") : [];
54
+ const missing = 8 - head.length - tail.length;
55
+ if (halves.length === 2 ? missing < 1 : missing !== 0) {
56
+ return null;
57
+ }
58
+ const groups = [...head, ...new Array(missing).fill("0"), ...tail];
59
+ return groups.every((group) => GROUP.test(group))
60
+ ? groups.map((group) => Number.parseInt(group, 16))
61
+ : null;
62
+ }
63
+ function privateIpv6(host) {
64
+ const address = host.replace(BRACKETS, "").toLowerCase();
65
+ if (!address.includes(":")) {
66
+ return false;
67
+ }
68
+ const groups = ipv6Groups(address);
69
+ if (!groups) {
70
+ return true;
71
+ }
72
+ const [first = 0, second = 0, third = 0] = groups;
73
+ // Only 2000::/3 is global unicast; loopback, mapped, NAT64, unique-local,
74
+ // link-local and multicast all sit outside it.
75
+ if (first < 0x20_00 || first > 0x3f_ff) {
76
+ return true;
77
+ }
78
+ // Teredo carries IPv4 addresses that can steer the tunnel.
79
+ if (first === 0x20_01 && second === 0) {
80
+ return true;
81
+ }
82
+ // 6to4 carries an IPv4 in bits 16-48.
83
+ if (first === 0x20_02) {
84
+ return privateIpv4(`${Math.floor(second / 256)}.${second % 256}.${Math.floor(third / 256)}.${third % 256}`);
85
+ }
86
+ return false;
87
+ }
88
+ /** True for an address (v4 or v6) that is not a public unicast destination. */
89
+ export function isPrivateAddress(address) {
90
+ return privateIpv4(address) || privateIpv6(address);
91
+ }
92
+ /** True when a URL hostname names a private destination by literal or reserved name. */
93
+ export function isPrivateHostname(raw) {
94
+ const host = raw.toLowerCase().replace(TRAILING_DOTS, "");
95
+ return (host.length === 0 ||
96
+ PRIVATE_NAMES.has(host) ||
97
+ PRIVATE_SUFFIXES.some((suffix) => host.endsWith(suffix)) ||
98
+ isPrivateAddress(host));
99
+ }
@@ -1,5 +1,5 @@
1
1
  import { dirname } from "node:path";
2
- import { disableNative, enableNative, readNativeConfig, } from "../agent/native/config.js";
2
+ import { disableNative, enableNative, readNativeConfig, readNativeFallback, } from "../agent/native/config.js";
3
3
  import { NativeGate } from "../agent/native/gate.js";
4
4
  import { checkRepo, readProjects, registerRoot, removeProject, } from "../agent/native/projects.js";
5
5
  import { agentWorkDir, localAgents, } from "../agent-config.js";
@@ -42,6 +42,11 @@ export async function runAgentNative(parsed, home = homeDir()) {
42
42
  emit(config
43
43
  ? `On. ${agent.name} works in ${shown(config.root, home)} when you ask it in a room.`
44
44
  : `Off. Run talentos agent native enable to let ${agent.name} use your full setup in rooms.`);
45
+ // The detail stays on this computer; the room only saw a neutral line.
46
+ const fallback = config && (await readNativeFallback(directory));
47
+ if (fallback) {
48
+ emit(`Your last room job here ran with room tools only (${new Date(fallback.at).toLocaleString()}): ${fallback.reason}`);
49
+ }
45
50
  return;
46
51
  }
47
52
  const config = await enableNative({
@@ -1,6 +1,6 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import { dirname } from "node:path";
3
- import { verifyClaudeCode, verifyCodex } from "../agent/adapters.js";
3
+ import { verifyClaudeCode, verifyCodex, verifyCodexWeb, } from "../agent/adapters.js";
4
4
  import { CodexBoundaryError } from "../agent/codex-probe.js";
5
5
  import { AgentGateway, GatewayError } from "../agent/gateway.js";
6
6
  import { serveAgent } from "../agent/serve.js";
@@ -72,6 +72,7 @@ async function verifyAgent(config, options, signal) {
72
72
  }
73
73
  else {
74
74
  await verifyCodex(binary, signal);
75
+ await verifyCodexWeb(binary, signal);
75
76
  }
76
77
  }
77
78
  catch (error) {
@@ -12,6 +12,27 @@ import { homeDir } from "../install.js";
12
12
  import { defaultDeviceName, hashKey, mintKey } from "../login.js";
13
13
  import { resolveProviderBinary } from "../provider-binary.js";
14
14
  const MAX_PREVIOUS_AGENT_IDS = 100;
15
+ // The first Node of each release line that carries the Brotli fix (#12871).
16
+ // Only these lines have a published fix, so an odd or newer line (23, 25, 26)
17
+ // is refused rather than assumed safe: running one is exactly what the floor
18
+ // exists to prevent.
19
+ const NODE_FLOORS = { 22: [22, 23, 4], 24: [24, 22, 1] };
20
+ export const NODE_LINES = "Node 22.23.4+ or 24.22.1+";
21
+ export function nodeFloorMessage(version) {
22
+ return `Agent linking requires ${NODE_LINES} (running ${version}).`;
23
+ }
24
+ export function meetsNodeFloor(version) {
25
+ const [major = 0, minor = 0, patch = 0] = version.split(".").map(Number);
26
+ const floor = NODE_FLOORS[major];
27
+ if (!floor) {
28
+ return false;
29
+ }
30
+ const [, floorMinor, floorPatch] = floor;
31
+ if (minor !== floorMinor) {
32
+ return minor > floorMinor;
33
+ }
34
+ return patch >= floorPatch;
35
+ }
15
36
  const REMOVED_AGENT_NOTICE = "removed in TalentOS; run talentos agent link to reconnect";
16
37
  export async function runAgent(parsed, dependencies = {}) {
17
38
  switch (parsed.action) {
@@ -112,8 +133,8 @@ export async function runAgent(parsed, dependencies = {}) {
112
133
  }
113
134
  }
114
135
  export async function installLinkedAgent(parsed, dependencies = {}) {
115
- if (Number(process.versions.node.split(".")[0]) < 20) {
116
- throw new Error("Agent linking requires Node.js 20 or newer.");
136
+ if (!meetsNodeFloor(process.versions.node)) {
137
+ throw new Error(nodeFloorMessage(process.versions.node));
117
138
  }
118
139
  const link = parseAgentLink(parsed.options.url ?? "");
119
140
  const home = dependencies.home ?? homeDir();
@@ -58,8 +58,13 @@ case "$agent" in
58
58
  ''|*[!a-zA-Z0-9_-]*) ;;
59
59
  *) node_missing="$root/agents/$agent/.node-missing" ;;
60
60
  esac
61
+ seen_version=
61
62
  qualifies() {
62
- [ -n "$1" ] && [ -x "$1" ] && "$1" -e 'process.exit(Number(process.versions.node.split(".")[0]) >= 20 ? 0 : 1)' >/dev/null 2>&1
63
+ [ -n "$1" ] && [ -x "$1" ] || return 1
64
+ if [ -z "$seen_version" ]; then
65
+ seen_version=$("$1" -p 'process.versions.node' 2>/dev/null || echo unknown)
66
+ fi
67
+ "$1" -e 'const [a,b,c]=process.versions.node.split(".").map(Number);process.exit((a===22&&(b>23||(b===23&&c>=4)))||(a===24&&(b>22||(b===22&&c>=1)))?0:1)' >/dev/null 2>&1
63
68
  }
64
69
  start() {
65
70
  if [ -n "$node_missing" ]; then /bin/rm -f "$node_missing"; fi
@@ -97,7 +102,7 @@ set +f
97
102
  for candidate in "$root"/../.nvm/versions/node/*/bin/node; do
98
103
  if qualifies "$candidate"; then start "$candidate" "$@"; fi
99
104
  done
100
- message='TalentOS gateway requires Node.js 20 or newer. Install Node, then run talentos agent repair.'
105
+ message="TalentOS gateway requires Node 22.23.4+ or 24.22.1+ (found \${seen_version:-unknown}). Install Node, then run talentos agent repair."
101
106
  if [ -z "$node_missing" ]; then
102
107
  echo "$message" >&2
103
108
  elif (set -C; : > "$node_missing") 2>/dev/null; then
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "talentos",
3
- "version": "1.4.8",
3
+ "version": "1.4.9",
4
4
  "type": "module",
5
5
  "description": "TalentOS CLI: push and pull skills, read and write team memory, and delegate work to your Talent from any coding agent.",
6
6
  "repository": {
@@ -15,7 +15,7 @@
15
15
  "dist"
16
16
  ],
17
17
  "engines": {
18
- "node": ">=20"
18
+ "node": ">=22.23.4 <23 || >=24.22.1 <25"
19
19
  },
20
20
  "scripts": {
21
21
  "start": "tsx src/index.ts",