talentos 1.4.18 → 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.
- package/dist/agent-http.js +20 -0
- package/dist/bundled-node.js +114 -0
- package/dist/commands/agent.js +42 -13
- package/dist/gateway-install.js +10 -0
- package/package.json +1 -1
package/dist/agent-http.js
CHANGED
|
@@ -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
|
+
}
|
package/dist/commands/agent.js
CHANGED
|
@@ -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
|
-
|
|
155
|
+
await failed("node", new Error(nodeFloorMessage(process.versions.node)), process.versions.node);
|
|
148
156
|
}
|
|
149
|
-
|
|
157
|
+
await report({ stage: "started" });
|
|
150
158
|
const home = dependencies.home ?? homeDir();
|
|
151
159
|
const linkHash = hashKey(link.token);
|
|
152
|
-
|
|
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: (
|
|
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
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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);
|
package/dist/gateway-install.js
CHANGED
|
@@ -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