talentos 1.4.17 → 1.4.19

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.
@@ -18,6 +18,10 @@ export const PROBE_REVISION = 3;
18
18
  // wait for the room server passes.
19
19
  export const SLOW_LIST_MS = 1500;
20
20
  const RESOURCE_REFUSAL = /Method not found|unknown MCP server/u;
21
+ // Codex 0.165+ refuses a read aimed at a server it does not have with this line
22
+ // alone, without the "resources/read failed:" prefix older ones put first
23
+ // (#14551). Exactly this line: anything longer could carry a resource.
24
+ const BARE_UNKNOWN_SERVER = /^unknown MCP server '[\w.-]+'$/u;
21
25
  const INPUT_TYPES = new Set([
22
26
  "message",
23
27
  "reasoning",
@@ -466,8 +470,9 @@ async function proveCodexBoundary(binary, version, catalog, stop, web = false) {
466
470
  }
467
471
  }
468
472
  else if (typeof output.output !== "string" ||
469
- !output.output.startsWith("resources/read failed:") ||
470
- !RESOURCE_REFUSAL.test(output.output) ||
473
+ !((output.output.startsWith("resources/read failed:") &&
474
+ RESOURCE_REFUSAL.test(output.output)) ||
475
+ BARE_UNKNOWN_SERVER.test(output.output)) ||
471
476
  text.includes(nonce)) {
472
477
  throw new Error("Resource helper did not refuse");
473
478
  }
@@ -27,8 +27,12 @@ const asRefusedBy = (value) => Array.isArray(value) &&
27
27
  function parseReport(line) {
28
28
  try {
29
29
  const value = JSON.parse(line);
30
- if (value.touch === true || value.taint === true) {
31
- return { taint: value.taint === true, touch: value.touch === true };
30
+ if (value.touch === true || value.taint === true || value.web === true) {
31
+ return {
32
+ taint: value.taint === true,
33
+ touch: value.touch === true,
34
+ web: value.web === true,
35
+ };
32
36
  }
33
37
  }
34
38
  catch {
@@ -59,6 +63,7 @@ function parseAsk(line) {
59
63
  }
60
64
  return;
61
65
  }
66
+ const REPORT_KEYS = ["taint", "touch", "web"];
62
67
  export class ApprovalBridge {
63
68
  gateway;
64
69
  onWaiting;
@@ -67,6 +72,7 @@ export class ApprovalBridge {
67
72
  reported = {
68
73
  taint: undefined,
69
74
  touch: undefined,
75
+ web: undefined,
70
76
  };
71
77
  waiting = false;
72
78
  polling = false;
@@ -149,23 +155,24 @@ export class ApprovalBridge {
149
155
  const need = {
150
156
  taint: flags.taint && !this.reported.taint,
151
157
  touch: flags.touch && !this.reported.touch,
158
+ web: flags.web && !this.reported.web,
152
159
  };
153
- if (need.taint || need.touch) {
160
+ if (need.taint || need.touch || need.web) {
154
161
  const request = this.gateway.touch(need).catch((error) => {
155
- for (const key of ["taint", "touch"]) {
162
+ for (const key of REPORT_KEYS) {
156
163
  if (need[key]) {
157
164
  this.reported[key] = undefined;
158
165
  }
159
166
  }
160
167
  throw error;
161
168
  });
162
- for (const key of ["taint", "touch"]) {
169
+ for (const key of REPORT_KEYS) {
163
170
  if (need[key]) {
164
171
  this.reported[key] = request;
165
172
  }
166
173
  }
167
174
  }
168
- const pending = ["taint", "touch"].flatMap((key) => flags[key] && this.reported[key]
175
+ const pending = REPORT_KEYS.flatMap((key) => flags[key] && this.reported[key]
169
176
  ? [this.reported[key]]
170
177
  : []);
171
178
  Promise.all(pending)
@@ -3,7 +3,7 @@ import { appendFileSync, existsSync, lstatSync, mkdirSync, readFileSync, writeFi
3
3
  import { connect } from "node:net";
4
4
  import { dirname, join } from "node:path";
5
5
  import { classifyCall } from "./policy.js";
6
- import { taintsJob, touchesPrivate } from "./touch.js";
6
+ import { readsWeb, taintsJob, touchesPrivate } from "./touch.js";
7
7
  // The PreToolUse hook the owner-native profile installs (#10987). It is its own
8
8
  // small entry so each tool call pays one tiny node start, not the whole CLI.
9
9
  // Allowlist-shaped and fail-closed: any error is a denial. It never prints a
@@ -202,7 +202,8 @@ export async function runHook(jobDir, raw, holdMs = HOLD_MS) {
202
202
  };
203
203
  verdict = classifyCall(call, policy);
204
204
  const touches = touchesPrivate(call, policy, verdict.allow);
205
- const taints = taintsJob(call, policy, verdict.allow ? undefined : verdict.ask);
205
+ const web = readsWeb(call, policy);
206
+ const taints = web || taintsJob(call, policy, verdict.allow ? undefined : verdict.ask);
206
207
  if (!verdict.allow && verdict.ask && context.askSocket) {
207
208
  const held = await holdForOwner(context.askSocket, verdict.ask, holdMs);
208
209
  asked = held.answer;
@@ -224,6 +225,7 @@ export async function runHook(jobDir, raw, holdMs = HOLD_MS) {
224
225
  (await reportTouch(context.askSocket, {
225
226
  taint: taints,
226
227
  touch: touches,
228
+ web,
227
229
  })))) {
228
230
  verdict = { allow: false, reason: HOOK_FAILED, tier: 2 };
229
231
  }
@@ -152,6 +152,48 @@ export function taintsJob(call, context, asked) {
152
152
  (asked?.tier === 1 && !asked.kind.split(" + ").every(isRun)) ||
153
153
  touchesPrivate(call, context, true));
154
154
  }
155
+ // Programs whose job is to bring web text in. `gh` reads issues and pull
156
+ // requests, which anyone can write.
157
+ const WEB_PROGRAMS = new Set(["curl", "gh", "http", "https", "wget", "xh"]);
158
+ // A tool outside the room whose name says it browses or fetches.
159
+ const WEB_TOOL_NAME = /browse|crawl|fetch|navigate|page|scrape|search|url|web/iu;
160
+ const URL_WORD = /[a-z][a-z0-9+.-]*:\/\//iu;
161
+ // The same programs (and a git fetch) found in a command the reader cannot parse.
162
+ const WEB_COMMAND = /(?:^|[\s;&|(`])(?:curl|gh|https?|wget|xh|git\s.*\b(?:clone|fetch|pull))\b/u;
163
+ function shellReadsWeb(source) {
164
+ const parsed = source ? parseShell(source) : undefined;
165
+ if (!parsed?.ok) {
166
+ // Unreadable: judged by its words, so `curl $(` still counts.
167
+ return URL_WORD.test(source ?? "") || WEB_COMMAND.test(source ?? "");
168
+ }
169
+ return parsed.commands.some(({ argv }) => {
170
+ const program = basename(argv[0]?.text ?? "");
171
+ // A script handed an address (`node scrape.js https://...`) reads it.
172
+ return (WEB_PROGRAMS.has(program) || argv.some((word) => URL_WORD.test(word.text)));
173
+ });
174
+ }
175
+ /**
176
+ * Did this call read the web or another room (CLI 1.4.18)? Narrower than
177
+ * `taintsJob`: a local MCP tool, a read outside the folder or an approved
178
+ * script taints the job but is not this. Full access runs the owner's own
179
+ * scripts until a job does this, and the "It read the web" card reads it. A
180
+ * script that fetches without naming an address is not seen (James, 2026-11-04:
181
+ * everything except a push and what follows a real web read).
182
+ */
183
+ export function readsWeb(call, context) {
184
+ const { tool } = call;
185
+ if (tool === "WebSearch" || tool === "WebFetch") {
186
+ return true;
187
+ }
188
+ if (tool.startsWith(ROOM_SERVER_PREFIX)) {
189
+ return (readsOtherRoom(call, context.roomId) || readsOtherRoomFile(call, context));
190
+ }
191
+ if (tool.startsWith("mcp__")) {
192
+ return WEB_TOOL_NAME.test(tool);
193
+ }
194
+ return (tool === "Bash" &&
195
+ (fetchesOutside(call) || shellReadsWeb(text(call.toolInput.command))));
196
+ }
155
197
  function shellTouchesPrivate(source, inside, cwd, home) {
156
198
  const parsed = source ? parseShell(source) : undefined;
157
199
  if (!(parsed?.ok && inside("."))) {
@@ -55,6 +55,26 @@ export async function setupApiOrigin(link, override) {
55
55
  }
56
56
  return apiOrigin(apiUrl);
57
57
  }
58
+ /**
59
+ * Tells the Connect dialog how far this link got, keyed by the prompt's token.
60
+ * Best effort: the setup never waits on it or fails because of it. The API
61
+ * origin is resolved once, on the first report.
62
+ */
63
+ export function linkProgressReporter(link, override) {
64
+ let origin;
65
+ return async (report) => {
66
+ origin ??= setupApiOrigin(link, override).catch(() => undefined);
67
+ const apiUrl = await origin;
68
+ if (!apiUrl) {
69
+ return;
70
+ }
71
+ await safeFetch(`${apiUrl}/agent-link/progress`, {
72
+ body: JSON.stringify({ token: link.token, ...report }),
73
+ headers: { "Content-Type": "application/json" },
74
+ method: "POST",
75
+ }).catch(() => undefined);
76
+ };
77
+ }
58
78
  // A room-only provider with no sign-in status command is checked by what a
59
79
  // sign-in leaves (its profile's signInProblem; Gemini: agent/gemini-login.ts).
60
80
  export function inspectProvider(provider, configured) {
@@ -0,0 +1,114 @@
1
+ import { execFile } from "node:child_process";
2
+ import { createHash, randomUUID } from "node:crypto";
3
+ import { mkdir, readdir, readlink, rename, rm, symlink, writeFile, } from "node:fs/promises";
4
+ import { join } from "node:path";
5
+ import { promisify } from "node:util";
6
+ const exec = promisify(execFile);
7
+ // The gateway's own Node, so the owner's Node, Homebrew or nvm can never stop
8
+ // it (a link on Node 20, a removed nvm version, a Homebrew upgrade past the
9
+ // floor). One pinned release, checked against the sums nodejs.org published for
10
+ // it (SHASUMS256.txt, read 2026-11-04), kept in ~/.talentos/node/<version>
11
+ // with `current` pointing at it. The launcher tries it first after
12
+ // TALENTOS_NODE; the owner's Nodes stay the fallback, so a failed download
13
+ // changes nothing.
14
+ export const BUNDLED_NODE = {
15
+ baseUrl: "https://nodejs.org/dist",
16
+ sha256: {
17
+ "darwin-arm64": "aa9549349e47dffaa42dcf95d6e06ade8c4bdafc980979883b88767670df385a",
18
+ "darwin-x64": "d5e336d588c45be0c37dbd52cc29895593009ca4997a77a1fd02815131ed0e52",
19
+ "linux-arm64": "95c264150aceb7f3437a29fd6984924f5f8d1511ea3cbd6c508b83f6c555dae2",
20
+ "linux-x64": "361718c444e49af2ca5a110c83ba6a8901143f23ab285ebbef0341f391f482a9",
21
+ },
22
+ version: "24.22.2",
23
+ };
24
+ // About 50 MB; a slow link gets the rest of a repair's patience, not forever.
25
+ const DOWNLOAD_MS = 120_000;
26
+ /** The bundled Node the launcher would start, once installed. */
27
+ export function bundledNodePath(home) {
28
+ return join(home, ".talentos", "node", "current", "bin", "node");
29
+ }
30
+ async function runs(node, version) {
31
+ try {
32
+ const { stdout } = await exec(node, ["-p", "process.versions.node"], {
33
+ timeout: 10_000,
34
+ });
35
+ return stdout.trim() === version;
36
+ }
37
+ catch {
38
+ return false;
39
+ }
40
+ }
41
+ /**
42
+ * Installs the pinned Node for this platform if it is not there yet. Best
43
+ * effort: an unknown platform, no network, a checksum mismatch or a broken
44
+ * archive leaves the owner's Node in charge and returns undefined.
45
+ */
46
+ export async function ensureBundledNode(home, options = {}) {
47
+ const release = options.release ?? BUNDLED_NODE;
48
+ const target = `${options.platform ?? process.platform}-${options.arch ?? process.arch}`;
49
+ const expected = release.sha256[target];
50
+ if (!expected) {
51
+ return;
52
+ }
53
+ const root = join(home, ".talentos", "node");
54
+ const name = `v${release.version}`;
55
+ const node = join(root, name, "bin", "node");
56
+ if (!(await runs(node, release.version))) {
57
+ const temporary = join(root, `.install-${randomUUID()}`);
58
+ try {
59
+ await mkdir(temporary, { recursive: true, mode: 0o700 });
60
+ const file = `node-${name}-${target}.tar.gz`;
61
+ const signal = AbortSignal.any([
62
+ AbortSignal.timeout(DOWNLOAD_MS),
63
+ ...(options.signal ? [options.signal] : []),
64
+ ]);
65
+ const response = await (options.fetch ?? fetch)(`${release.baseUrl}/${name}/${file}`, { signal });
66
+ if (!response.ok) {
67
+ return;
68
+ }
69
+ const archive = Buffer.from(await response.arrayBuffer());
70
+ if (createHash("sha256").update(archive).digest("hex") !== expected) {
71
+ return;
72
+ }
73
+ const tarball = join(temporary, file);
74
+ await writeFile(tarball, archive, { mode: 0o600 });
75
+ const unpacked = join(temporary, "unpacked");
76
+ await mkdir(unpacked, { mode: 0o700 });
77
+ // Node itself and npm (gateway updates run it); not the C headers or docs.
78
+ const top = `node-${name}-${target}`;
79
+ await exec("tar", [
80
+ "-xzf",
81
+ tarball,
82
+ "-C",
83
+ unpacked,
84
+ "--strip-components=1",
85
+ `${top}/bin`,
86
+ `${top}/lib`,
87
+ ], { signal, timeout: DOWNLOAD_MS });
88
+ if (!(await runs(join(unpacked, "bin", "node"), release.version))) {
89
+ return;
90
+ }
91
+ await rm(join(root, name), { recursive: true, force: true });
92
+ await rename(unpacked, join(root, name));
93
+ }
94
+ catch {
95
+ return;
96
+ }
97
+ finally {
98
+ await rm(temporary, { recursive: true, force: true });
99
+ }
100
+ }
101
+ const current = join(root, "current");
102
+ if ((await readlink(current).catch(() => "")) !== name) {
103
+ const pointer = join(root, `.current-${randomUUID()}`);
104
+ await symlink(name, pointer);
105
+ await rename(pointer, current);
106
+ }
107
+ // A pin moved on: the old release is no longer started by anything.
108
+ for (const entry of await readdir(root)) {
109
+ if (entry.startsWith("v") && entry !== name) {
110
+ await rm(join(root, entry), { recursive: true, force: true });
111
+ }
112
+ }
113
+ return bundledNodePath(home);
114
+ }
@@ -4,7 +4,7 @@ import { join } from "node:path";
4
4
  import { createInterface } from "node:readline/promises";
5
5
  import { repoRoot } from "../agent/native/config.js";
6
6
  import { agentConfigPath, agentLogPath, agentsDir, agentWorkDir, isMissing, localAgents, storeAgent, writePrivateFile, } from "../agent-config.js";
7
- import { AgentHttpError, fetchAgentStatus, inspectProvider, redeemAgent, setupApiOrigin, unlinkRemoteAgent, waitForHeartbeat, } from "../agent-http.js";
7
+ import { AgentHttpError, fetchAgentStatus, inspectProvider, linkProgressReporter, redeemAgent, setupApiOrigin, unlinkRemoteAgent, waitForHeartbeat, } from "../agent-http.js";
8
8
  import { parseAgentLink, redactAgentOutput } from "../agent-link.js";
9
9
  import { installAgentService, uninstallAgentService, } from "../agent-service.js";
10
10
  import { readSessionKey } from "../agent-session.js";
@@ -143,13 +143,27 @@ export async function runAgent(parsed, dependencies = {}) {
143
143
  }
144
144
  }
145
145
  export async function installLinkedAgent(parsed, dependencies = {}) {
146
+ const link = parseAgentLink(parsed.options.url ?? "");
147
+ // The Connect dialog shows each step and the reason a link stopped (#15553).
148
+ const report = dependencies.reportProgress ??
149
+ linkProgressReporter(link, parsed.options["api-url"] ?? process.env.TALENTOS_API_URL);
150
+ const failed = async (code, error, detail) => {
151
+ await report({ failure: { code, ...(detail ? { detail } : {}) } });
152
+ throw error;
153
+ };
146
154
  if (!meetsNodeFloor(process.versions.node)) {
147
- throw new Error(nodeFloorMessage(process.versions.node));
155
+ await failed("node", new Error(nodeFloorMessage(process.versions.node)), process.versions.node);
148
156
  }
149
- const link = parseAgentLink(parsed.options.url ?? "");
157
+ await report({ stage: "started" });
150
158
  const home = dependencies.home ?? homeDir();
151
159
  const linkHash = hashKey(link.token);
152
- const providerPath = (dependencies.resolveBinary ?? resolveProviderBinary)(link.provider);
160
+ let providerPath = "";
161
+ try {
162
+ providerPath = (dependencies.resolveBinary ?? resolveProviderBinary)(link.provider);
163
+ }
164
+ catch (error) {
165
+ await failed("provider", error);
166
+ }
153
167
  const savedAgents = await localAgents(home);
154
168
  let agent = savedAgents.find((item) => item.linkHash === linkHash && item.provider === link.provider);
155
169
  if (agent) {
@@ -207,7 +221,14 @@ export async function installLinkedAgent(parsed, dependencies = {}) {
207
221
  previousAgentIds: candidates.map((item) => item.agentId),
208
222
  keyHash: hashKey(apiKey),
209
223
  provider: link.provider,
210
- providerVersion: (dependencies.probe ?? inspectProvider)(link.provider, providerPath),
224
+ providerVersion: await (async () => {
225
+ try {
226
+ return (dependencies.probe ?? inspectProvider)(link.provider, providerPath);
227
+ }
228
+ catch (error) {
229
+ return await failed("provider", error);
230
+ }
231
+ })(),
211
232
  deviceName: parsed.options.name ?? defaultDeviceName(),
212
233
  os: process.platform,
213
234
  cliVersion: packageVersion(),
@@ -239,14 +260,22 @@ export async function installLinkedAgent(parsed, dependencies = {}) {
239
260
  agent.connectCwd = connectCwd;
240
261
  await storeAgent(agent, home);
241
262
  }
242
- const service = await (dependencies.install ??
243
- (async (config) => {
244
- if (process.platform !== "win32") {
245
- await installSharedGateway({ home });
246
- }
247
- return await installAgentService(config, { home });
248
- }))(agent);
249
- return { agent, service };
263
+ await report({ stage: "setting_up" });
264
+ let service;
265
+ try {
266
+ service = await (dependencies.install ??
267
+ (async (config) => {
268
+ if (process.platform !== "win32") {
269
+ await installSharedGateway({ home });
270
+ }
271
+ await report({ stage: "starting" });
272
+ return await installAgentService(config, { home });
273
+ }))(agent);
274
+ }
275
+ catch (error) {
276
+ await failed("setup", error);
277
+ }
278
+ return { agent, service: service };
250
279
  }
251
280
  async function showAgents(parsed) {
252
281
  const agents = await selectAgents(parsed);
@@ -6,6 +6,7 @@ import { setTimeout as delay } from "node:timers/promises";
6
6
  import { fileURLToPath } from "node:url";
7
7
  import { promisify } from "node:util";
8
8
  import { writePrivateFile } from "./agent-config.js";
9
+ import { bundledNodePath, ensureBundledNode } from "./bundled-node.js";
9
10
  import { compareGatewayVersions } from "./gateway-version.js";
10
11
  import { homeDir } from "./install.js";
11
12
  const exec = promisify(execFile);
@@ -50,6 +51,7 @@ export async function launcherNodeCandidates(home = homeDir(), env = process.env
50
51
  if (env.TALENTOS_NODE) {
51
52
  found.push(env.TALENTOS_NODE);
52
53
  }
54
+ found.push(bundledNodePath(home));
53
55
  const hint = (await readFile(join(home, ".talentos/cli/node-path"), "utf8").catch(() => "")).split("\n")[0];
54
56
  if (hint) {
55
57
  found.push(hint);
@@ -126,6 +128,10 @@ IFS= read -r node_hint < "$root/cli/node-path" || :
126
128
  if qualifies "\${TALENTOS_NODE:-}"; then
127
129
  start "$TALENTOS_NODE" "$@"
128
130
  fi
131
+ # The gateway's own Node (bundled-node.ts), before any of the owner's.
132
+ if qualifies "$root/node/current/bin/node"; then
133
+ start "$root/node/current/bin/node" "$@"
134
+ fi
129
135
  if qualifies "$node_hint"; then
130
136
  start "$node_hint" "$@"
131
137
  fi
@@ -359,6 +365,10 @@ export async function installSharedGateway(options = {}) {
359
365
  stagedVersion = undefined;
360
366
  const launcher = gatewayLauncherPath(home);
361
367
  await writePrivateFile(launcher, LAUNCHER, 0o700);
368
+ // Best effort: without it the launcher falls back to the owner's Node.
369
+ if (options.bundledNode ?? options.source === undefined) {
370
+ await ensureBundledNode(home, { signal: options.signal });
371
+ }
362
372
  let nodePath = options.nodePath ?? process.execPath;
363
373
  for (const stable of [
364
374
  "/opt/homebrew/bin/node",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "talentos",
3
- "version": "1.4.17",
3
+ "version": "1.4.19",
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 agent.",
6
6
  "repository": {