talentos 1.4.15 → 1.4.17
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/adapters.js +61 -66
- package/dist/agent/codex-policy.js +3 -0
- package/dist/agent/gemini-probe.js +33 -122
- package/dist/agent/gemini-room.js +92 -0
- package/dist/agent/hermes-login.js +166 -0
- package/dist/agent/hermes-policy.js +179 -0
- package/dist/agent/hermes-probe.js +255 -0
- package/dist/agent/hermes-room.js +99 -0
- package/dist/agent/native/config.js +86 -21
- package/dist/agent/native/gate.js +39 -8
- package/dist/agent/native/hook-entry.js +18 -4
- package/dist/agent/native/launch.js +2 -2
- package/dist/agent/native/paths.js +43 -4
- package/dist/agent/native/policy.js +83 -2
- package/dist/agent/native/project-requests.js +8 -1
- package/dist/agent/native/projects.js +49 -2
- package/dist/agent/native/shell.js +10 -0
- package/dist/agent/packet-order.js +26 -0
- package/dist/agent/provider-login.js +4 -3
- package/dist/agent/room-probe.js +129 -0
- package/dist/agent/room-profile.js +21 -45
- package/dist/agent/room-provider.js +7 -0
- package/dist/agent/room-providers.js +11 -0
- package/dist/agent/serve.js +4 -1
- package/dist/agent-config.js +2 -1
- package/dist/agent-http.js +8 -6
- package/dist/agent-link.js +3 -2
- package/dist/commands/agent-serve.js +6 -6
- package/dist/provider-binary.js +8 -1
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import { realpathSync, statSync } from "node:fs";
|
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
4
|
import { basename, join } from "node:path";
|
|
5
5
|
import { isMissing, writePrivateFile } from "../../agent-config.js";
|
|
6
|
-
import { readNativeConfig, repoRoot, rootProblem, } from "./config.js";
|
|
6
|
+
import { readNativeConfig, refreshNativeIdentity, repoRoot, rootProblem, } from "./config.js";
|
|
7
7
|
export const PROJECTS_FILE = "projects.json";
|
|
8
8
|
export const PROJECTS_MAX = 20;
|
|
9
9
|
const PROJECT_ID = /^[a-f\d]{32}$/u;
|
|
@@ -61,7 +61,18 @@ export async function registerRoot(directory, config, name) {
|
|
|
61
61
|
const projects = await readProjects(directory);
|
|
62
62
|
const known = projects.find((project) => project.root === config.root);
|
|
63
63
|
if (known) {
|
|
64
|
-
|
|
64
|
+
if (known.dev === config.dev && known.ino === config.ino) {
|
|
65
|
+
return known;
|
|
66
|
+
}
|
|
67
|
+
// The same folder after a remount keeps its id, name and sessions; only
|
|
68
|
+
// its device number moved.
|
|
69
|
+
const refreshed = {
|
|
70
|
+
...known,
|
|
71
|
+
dev: config.dev,
|
|
72
|
+
ino: config.ino,
|
|
73
|
+
};
|
|
74
|
+
await writeProjects(directory, projects.map((project) => (project === known ? refreshed : project)));
|
|
75
|
+
return refreshed;
|
|
65
76
|
}
|
|
66
77
|
if (projects.length >= PROJECTS_MAX) {
|
|
67
78
|
throw new Error(`An agent can have ${PROJECTS_MAX} projects. Remove one first.`);
|
|
@@ -74,6 +85,42 @@ export async function registerRoot(directory, config, name) {
|
|
|
74
85
|
await writeProjects(directory, [...projects, project]);
|
|
75
86
|
return project;
|
|
76
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Persists a fresh device number for one project when it is still the same
|
|
90
|
+
* folder (canonical path + inode), keeping its id, name and sessions. Called on
|
|
91
|
+
* the owner-job path so a reboot heals the registry instead of leaving it stale.
|
|
92
|
+
*/
|
|
93
|
+
export async function refreshProjectIdentity(directory, project) {
|
|
94
|
+
try {
|
|
95
|
+
const stats = statSync(realpathSync.native(project.root));
|
|
96
|
+
if (stats.ino !== project.ino || stats.dev === project.dev) {
|
|
97
|
+
return project;
|
|
98
|
+
}
|
|
99
|
+
const healed = { ...project, dev: stats.dev, ino: stats.ino };
|
|
100
|
+
const projects = await readProjects(directory);
|
|
101
|
+
const index = projects.findIndex((entry) => entry.id === project.id);
|
|
102
|
+
if (index === -1) {
|
|
103
|
+
return project;
|
|
104
|
+
}
|
|
105
|
+
const next = [...projects];
|
|
106
|
+
next[index] = healed;
|
|
107
|
+
await writeProjects(directory, next);
|
|
108
|
+
return healed;
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
return project;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Re-check every folder the owner already has and persist a remount's fresh
|
|
116
|
+
* device number. A folder whose path, inode or owner changed is left alone.
|
|
117
|
+
*/
|
|
118
|
+
export async function repairProjectIdentities(directory) {
|
|
119
|
+
await refreshNativeIdentity(directory);
|
|
120
|
+
for (const project of await readProjects(directory)) {
|
|
121
|
+
await refreshProjectIdentity(directory, project);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
77
124
|
/**
|
|
78
125
|
* The repo that contains `folder`, checked like `native enable` checks its
|
|
79
126
|
* root: a git top level, the same folder by device and inode, yours, and
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
// REFUSES everything else it cannot reason about (substitution, expansion,
|
|
4
4
|
// subshells, heredocs, comments, background jobs, env assignments). A refusal
|
|
5
5
|
// is "unparseable", which the policy treats as the strictest ask.
|
|
6
|
+
import { ownerTilde } from "./paths.js";
|
|
6
7
|
const DIGIT = /\d/u;
|
|
7
8
|
const ONE_DIGIT = /^\d$/u;
|
|
8
9
|
const ASSIGNMENT = /^[A-Za-z_]\w*=/u;
|
|
9
10
|
const SEPARATORS = new Set([";", "|", "&", "\n"]);
|
|
11
|
+
const TILDE_NAME = /^[^\s/;|&<>]*/u;
|
|
10
12
|
export function parseShell(source) {
|
|
11
13
|
const commands = [];
|
|
12
14
|
let argv = [];
|
|
@@ -151,6 +153,14 @@ export function parseShell(source) {
|
|
|
151
153
|
}
|
|
152
154
|
continue;
|
|
153
155
|
}
|
|
156
|
+
// A leading `~name` is another login's home, to zsh any variable's folder
|
|
157
|
+
// (`~HOME`), and `~-`/`~+` are the shell's last and current folder. Only `~`
|
|
158
|
+
// and the owner's own login name a folder the policy can judge (#14873).
|
|
159
|
+
if (c === "~" &&
|
|
160
|
+
!started &&
|
|
161
|
+
!ownerTilde(TILDE_NAME.exec(source.slice(i + 1))?.[0] ?? "")) {
|
|
162
|
+
return fail("tilde expansion");
|
|
163
|
+
}
|
|
154
164
|
if (c === "*" || c === "?" || c === "[") {
|
|
155
165
|
glob = true;
|
|
156
166
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// The keys a job's prompt opens with: the ask and the thread it came from. The
|
|
2
|
+
// thread directory closes it, so the room's other threads read as background
|
|
3
|
+
// after the question, never before it. The server's key order does not survive
|
|
4
|
+
// the trip here, so the launcher fixes the order itself.
|
|
5
|
+
const LEADING_KEYS = ["kind", "trigger", "thread", "transcript"];
|
|
6
|
+
const TRAILING_KEYS = ["threadIndex"];
|
|
7
|
+
export function orderPacketForPrompt(packet) {
|
|
8
|
+
const ordered = {};
|
|
9
|
+
const put = (key) => {
|
|
10
|
+
if (key in packet) {
|
|
11
|
+
ordered[key] = packet[key];
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
for (const key of LEADING_KEYS) {
|
|
15
|
+
put(key);
|
|
16
|
+
}
|
|
17
|
+
for (const key of Object.keys(packet)) {
|
|
18
|
+
if (!(LEADING_KEYS.includes(key) || TRAILING_KEYS.includes(key))) {
|
|
19
|
+
put(key);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
for (const key of TRAILING_KEYS) {
|
|
23
|
+
put(key);
|
|
24
|
+
}
|
|
25
|
+
return ordered;
|
|
26
|
+
}
|
|
@@ -5,8 +5,9 @@ import { promisify } from "node:util";
|
|
|
5
5
|
import { homeDir } from "../install.js";
|
|
6
6
|
import { childEnvironment } from "./adapters.js";
|
|
7
7
|
import { matchFailureText } from "./provider-failure.js";
|
|
8
|
-
// Gemini CLI
|
|
9
|
-
// (gemini-login.ts), so here it is
|
|
8
|
+
// Gemini CLI and Hermes Agent have no status command: their sign-in is read
|
|
9
|
+
// from what they leave (gemini-login.ts, hermes-login.ts), so here it is
|
|
10
|
+
// always "can't tell".
|
|
10
11
|
const STATUS_COMMAND = {
|
|
11
12
|
claude_code: ["auth", "status", "--json"],
|
|
12
13
|
codex: ["login", "status"],
|
|
@@ -81,7 +82,7 @@ export function readProviderLogin(provider, run) {
|
|
|
81
82
|
: undefined;
|
|
82
83
|
}
|
|
83
84
|
export async function probeProviderLogin(input) {
|
|
84
|
-
if (input.provider === "gemini_cli") {
|
|
85
|
+
if (input.provider === "gemini_cli" || input.provider === "hermes_agent") {
|
|
85
86
|
return;
|
|
86
87
|
}
|
|
87
88
|
const args = STATUS_COMMAND[input.provider];
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { createServer } from "node:http";
|
|
3
|
+
import { createInterface } from "node:readline";
|
|
4
|
+
// The parts every provider's boundary probe shares: the loopback stand-in for
|
|
5
|
+
// the room endpoint, the child run with a time limit, and the per-binary cache.
|
|
6
|
+
// The model stand-in is per wire format and lives with the provider's probe
|
|
7
|
+
// (a Gemini one in gemini-probe.ts). Findings the Gemini probe made, which
|
|
8
|
+
// every provider's probe must keep in mind:
|
|
9
|
+
// - a catch-all deny does not remove MCP tools from what the model is offered;
|
|
10
|
+
// - a server marked trusted lets every tool it lists past the policy;
|
|
11
|
+
// - what holds is an include list on the MCP server itself;
|
|
12
|
+
// - the CLI makes a non-streaming routing call first; the stand-in must answer.
|
|
13
|
+
export const PROBE_MS = 45_000;
|
|
14
|
+
export const MAX_BYTES = 2_000_000;
|
|
15
|
+
export const SECRET = "probe-secret-must-never-reach-the-model";
|
|
16
|
+
export const ROOM_TOOL = "whoami";
|
|
17
|
+
export const NOT_A_ROOM_TOOL = "not_a_room_tool";
|
|
18
|
+
export async function readBody(request) {
|
|
19
|
+
let size = 0;
|
|
20
|
+
const chunks = [];
|
|
21
|
+
for await (const chunk of request) {
|
|
22
|
+
size += chunk.length;
|
|
23
|
+
if (size > MAX_BYTES) {
|
|
24
|
+
throw new Error("Probe request exceeded its limit.");
|
|
25
|
+
}
|
|
26
|
+
chunks.push(chunk);
|
|
27
|
+
}
|
|
28
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The room endpoint stand-in: one room tool and one tool that is not a room
|
|
32
|
+
* tool. Names of the tools a model called are pushed onto `calls`, so a probe
|
|
33
|
+
* can tell that the room tool ran and the other one never did.
|
|
34
|
+
*/
|
|
35
|
+
export function fakeRoom(calls = []) {
|
|
36
|
+
return createServer(async (request, response) => {
|
|
37
|
+
const body = await readBody(request).catch(() => "");
|
|
38
|
+
let message = {};
|
|
39
|
+
try {
|
|
40
|
+
message = JSON.parse(body);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// A GET or an empty body: nothing to answer.
|
|
44
|
+
}
|
|
45
|
+
const reply = (result) => {
|
|
46
|
+
response.setHeader("content-type", "application/json");
|
|
47
|
+
response.end(JSON.stringify({ id: message.id, jsonrpc: "2.0", result }));
|
|
48
|
+
};
|
|
49
|
+
const empty = { properties: {}, type: "object" };
|
|
50
|
+
if (message.method === "initialize") {
|
|
51
|
+
reply({
|
|
52
|
+
capabilities: { tools: {} },
|
|
53
|
+
protocolVersion: "2025-03-26",
|
|
54
|
+
serverInfo: { name: "probe", version: "1" },
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
else if (message.method === "tools/list") {
|
|
58
|
+
reply({
|
|
59
|
+
tools: [
|
|
60
|
+
{ description: "who", inputSchema: empty, name: ROOM_TOOL },
|
|
61
|
+
{ description: "no", inputSchema: empty, name: NOT_A_ROOM_TOOL },
|
|
62
|
+
],
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
else if (message.method === "tools/call") {
|
|
66
|
+
calls.push(String(message.params?.name));
|
|
67
|
+
reply({ content: [{ text: "ok", type: "text" }] });
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
response.statusCode = 202;
|
|
71
|
+
response.end();
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
export function listen(server) {
|
|
76
|
+
return new Promise((resolve, reject) => {
|
|
77
|
+
server.once("error", reject);
|
|
78
|
+
server.listen(0, "127.0.0.1", () => resolve(server.address().port));
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
export const closeServer = (server) => new Promise((resolve) => {
|
|
82
|
+
server.closeAllConnections?.();
|
|
83
|
+
server.close(() => resolve());
|
|
84
|
+
});
|
|
85
|
+
/**
|
|
86
|
+
* Runs the CLI as a job would (packet on stdin, stderr dropped), hands each
|
|
87
|
+
* stdout line to `onLine`, and kills it after PROBE_MS or when `signal` aborts.
|
|
88
|
+
*/
|
|
89
|
+
export async function runProbeChild(input) {
|
|
90
|
+
const child = spawn(input.binary, input.args, {
|
|
91
|
+
cwd: input.cwd,
|
|
92
|
+
env: input.env,
|
|
93
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
94
|
+
});
|
|
95
|
+
// A CLI that exits before reading stdin must fail its probe, not crash the
|
|
96
|
+
// CLI with an unhandled EPIPE.
|
|
97
|
+
child.stdin?.on("error", () => undefined);
|
|
98
|
+
child.stdin?.end(input.stdin);
|
|
99
|
+
const timer = setTimeout(() => child.kill("SIGKILL"), PROBE_MS);
|
|
100
|
+
input.signal?.addEventListener("abort", () => child.kill("SIGKILL"), {
|
|
101
|
+
once: true,
|
|
102
|
+
});
|
|
103
|
+
const lines = createInterface({ input: child.stdout });
|
|
104
|
+
for await (const line of lines) {
|
|
105
|
+
input.onLine(line);
|
|
106
|
+
}
|
|
107
|
+
await new Promise((resolve) => {
|
|
108
|
+
if (child.exitCode === null) {
|
|
109
|
+
child.once("close", () => resolve());
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
resolve();
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
clearTimeout(timer);
|
|
116
|
+
}
|
|
117
|
+
const proofs = new Map();
|
|
118
|
+
/**
|
|
119
|
+
* Runs `prove` once per binary and version and caches the outcome, a failure
|
|
120
|
+
* too, so a bad CLI is not re-probed on every job.
|
|
121
|
+
*/
|
|
122
|
+
export function cachedProof(key, prove) {
|
|
123
|
+
let proof = proofs.get(key);
|
|
124
|
+
if (!proof) {
|
|
125
|
+
proof = prove();
|
|
126
|
+
proofs.set(key, proof);
|
|
127
|
+
}
|
|
128
|
+
return proof;
|
|
129
|
+
}
|
|
@@ -3,9 +3,8 @@ import { access, mkdir, readFile, realpath, rm, rmdir, symlink, } from "node:fs/
|
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { writePrivateFile } from "../agent-config.js";
|
|
5
5
|
import { homeDir } from "../install.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { ProviderFailureError } from "./provider-failure.js";
|
|
6
|
+
import { RoomIsolationError } from "./room-provider.js";
|
|
7
|
+
import { roomProvider } from "./room-providers.js";
|
|
9
8
|
// The room-only profile (#12712): a job for a teammate, a not-ready owner job
|
|
10
9
|
// and every Codex room job sees what TalentOS hands it (the packet and the room
|
|
11
10
|
// tools) and nothing from the owner's own setup. Each job gets an empty working
|
|
@@ -61,23 +60,15 @@ async function claudeLoginSettings(env) {
|
|
|
61
60
|
: {}),
|
|
62
61
|
};
|
|
63
62
|
}
|
|
64
|
-
/** A provider could not be kept apart from the owner's setup, so no job runs. */
|
|
65
|
-
export class RoomIsolationError extends ProviderFailureError {
|
|
66
|
-
constructor(label = "Codex") {
|
|
67
|
-
super("unknown", `${label} could not be isolated from your setup on this computer.`);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
63
|
export async function prepareRoomProfile(input) {
|
|
71
64
|
const jobDir = join(input.directory, ROOM_JOBS, input.jobId.replace(/[^\w-]/gu, ""));
|
|
72
|
-
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
const geminiHome = join(jobDir, "home");
|
|
76
|
-
const cwd = input.provider === "gemini_cli"
|
|
77
|
-
? join(geminiHome, "work")
|
|
78
|
-
: join(jobDir, "cwd");
|
|
65
|
+
const provider = roomProvider(input.provider);
|
|
66
|
+
// A profile builds its own directories; the others get an empty cwd.
|
|
67
|
+
const cwd = join(jobDir, "cwd");
|
|
79
68
|
const profile = {
|
|
80
69
|
cleanup: async () => {
|
|
70
|
+
// A provider's background process goes before the directory it works in.
|
|
71
|
+
await profile.launch?.stop?.().catch(() => undefined);
|
|
81
72
|
await rm(jobDir, { force: true, recursive: true });
|
|
82
73
|
// Claude Code logs under a cache directory named for the cwd: one small
|
|
83
74
|
// directory per job would pile up. Linux and macOS locations only.
|
|
@@ -100,6 +91,20 @@ export async function prepareRoomProfile(input) {
|
|
|
100
91
|
try {
|
|
101
92
|
// A retry of the same job starts from nothing, whatever an earlier attempt left.
|
|
102
93
|
await profile.cleanup();
|
|
94
|
+
if (provider) {
|
|
95
|
+
if (!input.agent) {
|
|
96
|
+
throw new RoomIsolationError(provider.label);
|
|
97
|
+
}
|
|
98
|
+
profile.launch = await provider.prepare({
|
|
99
|
+
agent: input.agent,
|
|
100
|
+
env: input.env,
|
|
101
|
+
instructions: input.instructions ?? "",
|
|
102
|
+
jobDir,
|
|
103
|
+
});
|
|
104
|
+
profile.cwd = profile.launch.cwd;
|
|
105
|
+
profile.env = profile.launch.env;
|
|
106
|
+
return profile;
|
|
107
|
+
}
|
|
103
108
|
await mkdir(cwd, { recursive: true, mode: 0o700 });
|
|
104
109
|
if (input.provider === "claude_code") {
|
|
105
110
|
const login = await claudeLoginSettings(input.env);
|
|
@@ -109,35 +114,6 @@ export async function prepareRoomProfile(input) {
|
|
|
109
114
|
await writePrivateFile(profile.settingsPath, login.file);
|
|
110
115
|
}
|
|
111
116
|
}
|
|
112
|
-
else if (input.provider === "gemini_cli") {
|
|
113
|
-
if (!input.gemini) {
|
|
114
|
-
throw new RoomIsolationError("Gemini CLI");
|
|
115
|
-
}
|
|
116
|
-
const login = readGeminiLogin(input.env);
|
|
117
|
-
const dotGemini = join(geminiHome, ".gemini");
|
|
118
|
-
await mkdir(dotGemini, { mode: 0o700, recursive: true });
|
|
119
|
-
profile.geminiHome = geminiHome;
|
|
120
|
-
profile.env = { ...login.env, GEMINI_CLI_HOME: geminiHome };
|
|
121
|
-
profile.geminiPolicyPath = join(dotGemini, "room-policy.toml");
|
|
122
|
-
await writePrivateFile(profile.geminiPolicyPath, geminiRoomPolicy());
|
|
123
|
-
await writePrivateFile(join(dotGemini, "settings.json"), geminiRoomSettings({
|
|
124
|
-
apiKey: input.gemini.apiKey,
|
|
125
|
-
// An OAuth sign-in with no method named in settings is still OAuth.
|
|
126
|
-
authType: login.authType ??
|
|
127
|
-
(login.files.includes("oauth_creds.json")
|
|
128
|
-
? "oauth-personal"
|
|
129
|
-
: undefined),
|
|
130
|
-
mcpUrl: input.gemini.mcpUrl,
|
|
131
|
-
}));
|
|
132
|
-
// Links, never copies: Gemini refreshes the token in place.
|
|
133
|
-
for (const name of GEMINI_CREDENTIAL_FILES) {
|
|
134
|
-
if (login.files.includes(name)) {
|
|
135
|
-
await symlink(join(login.dir, name), join(dotGemini, name)).catch(() => {
|
|
136
|
-
throw new RoomIsolationError("Gemini CLI");
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
117
|
else {
|
|
142
118
|
profile.codexHome = join(jobDir, "codex-home");
|
|
143
119
|
await mkdir(profile.codexHome, { mode: 0o700 });
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ProviderFailureError } from "./provider-failure.js";
|
|
2
|
+
/** A provider could not be kept apart from the owner's setup, so no job runs. */
|
|
3
|
+
export class RoomIsolationError extends ProviderFailureError {
|
|
4
|
+
constructor(label = "Codex") {
|
|
5
|
+
super("unknown", `${label} could not be isolated from your setup on this computer.`);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { geminiRoomProfile } from "./gemini-room.js";
|
|
2
|
+
import { hermesRoomProfile } from "./hermes-room.js";
|
|
3
|
+
// Every provider that runs as a room-only profile. Claude Code and Codex are
|
|
4
|
+
// not here: they also run the owner's setup and keep their own launch code.
|
|
5
|
+
const ROOM_PROVIDERS = {
|
|
6
|
+
gemini_cli: geminiRoomProfile,
|
|
7
|
+
hermes_agent: hermesRoomProfile,
|
|
8
|
+
};
|
|
9
|
+
export function roomProvider(provider) {
|
|
10
|
+
return ROOM_PROVIDERS[provider];
|
|
11
|
+
}
|
package/dist/agent/serve.js
CHANGED
|
@@ -10,7 +10,7 @@ import { RoomToolsUnavailableError, runProvider, } from "./adapters.js";
|
|
|
10
10
|
import { AgentGateway, GatewayError } from "./gateway.js";
|
|
11
11
|
import { holdMs, renewDelayMs } from "./lease-hold.js";
|
|
12
12
|
import { ApprovalBridge } from "./native/approvals.js";
|
|
13
|
-
import { NativeGate } from "./native/gate.js";
|
|
13
|
+
import { NativeGate, PLAIN_FALLBACK_REASONS } from "./native/gate.js";
|
|
14
14
|
import { ROOM_ONLY_STATUS, roomOnlyStatus } from "./native/native-issue.js";
|
|
15
15
|
import { ProjectRequests } from "./native/project-requests.js";
|
|
16
16
|
import { mirrorOf } from "./native/projects.js";
|
|
@@ -461,6 +461,9 @@ export async function serveAgent(config, directory, version, stop, verify, optio
|
|
|
461
461
|
job,
|
|
462
462
|
workDir,
|
|
463
463
|
owner: owner && { ...owner, watch: bridge },
|
|
464
|
+
...(fellBack && PLAIN_FALLBACK_REASONS.has(fellBack)
|
|
465
|
+
? { fallbackReason: fellBack }
|
|
466
|
+
: {}),
|
|
464
467
|
// Tells the server the job read the web, before it can write
|
|
465
468
|
// what a page steered (#13163).
|
|
466
469
|
webRead: async () => {
|
package/dist/agent-config.js
CHANGED
|
@@ -103,7 +103,8 @@ function isLinkedAgent(value) {
|
|
|
103
103
|
isAbsolute(config.providerPath))) &&
|
|
104
104
|
(config.provider === "claude_code" ||
|
|
105
105
|
config.provider === "codex" ||
|
|
106
|
-
config.provider === "gemini_cli"
|
|
106
|
+
config.provider === "gemini_cli" ||
|
|
107
|
+
config.provider === "hermes_agent"));
|
|
107
108
|
}
|
|
108
109
|
export function isMissing(error) {
|
|
109
110
|
return (error !== null &&
|
package/dist/agent-http.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
2
|
import { childEnvironment } from "./agent/adapters.js";
|
|
3
|
-
import {
|
|
3
|
+
import { roomProvider } from "./agent/room-providers.js";
|
|
4
4
|
import { isSecureUrl, } from "./agent-link.js";
|
|
5
5
|
import { resolveProviderBinary } from "./provider-binary.js";
|
|
6
6
|
const REQUEST_TIMEOUT_MS = 10_000;
|
|
@@ -55,8 +55,8 @@ export async function setupApiOrigin(link, override) {
|
|
|
55
55
|
}
|
|
56
56
|
return apiOrigin(apiUrl);
|
|
57
57
|
}
|
|
58
|
-
//
|
|
59
|
-
// leaves
|
|
58
|
+
// A room-only provider with no sign-in status command is checked by what a
|
|
59
|
+
// sign-in leaves (its profile's signInProblem; Gemini: agent/gemini-login.ts).
|
|
60
60
|
export function inspectProvider(provider, configured) {
|
|
61
61
|
const binary = resolveProviderBinary(provider, configured);
|
|
62
62
|
const version = spawnSync(binary, ["--version"], {
|
|
@@ -67,9 +67,11 @@ export function inspectProvider(provider, configured) {
|
|
|
67
67
|
if (version.status !== 0 || !version.stdout?.trim()) {
|
|
68
68
|
throw new Error(`Install the official ${binary} CLI and sign in before linking.`);
|
|
69
69
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
const room = roomProvider(provider);
|
|
71
|
+
if (room) {
|
|
72
|
+
const problem = room.signInProblem(process.env);
|
|
73
|
+
if (problem) {
|
|
74
|
+
throw new Error(problem);
|
|
73
75
|
}
|
|
74
76
|
return version.stdout.trim().split("\n")[0]?.slice(0, 200) ?? "unknown";
|
|
75
77
|
}
|
package/dist/agent-link.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const INVALID_LINK = "Get a new setup prompt from TalentOS and pass its complete URL with --url.";
|
|
2
|
-
const SETUP_PATH = /^\/agent-setup\/(claude_code|codex|gemini_cli)\/?$/;
|
|
2
|
+
const SETUP_PATH = /^\/agent-setup\/(claude_code|codex|gemini_cli|hermes_agent)\/?$/;
|
|
3
3
|
const FRAGMENT_TOKEN = /((?:#|%23)token(?:=|%3d))[^\s"'<>]+/giu;
|
|
4
4
|
const RAW_KEY = /\btos_[a-z\d_-]+/giu;
|
|
5
5
|
const BEARER = /\bBearer\s+\S+/giu;
|
|
@@ -14,7 +14,8 @@ export function parseAgentLink(value) {
|
|
|
14
14
|
if (!(isSecureUrl(url) &&
|
|
15
15
|
(provider === "claude_code" ||
|
|
16
16
|
provider === "codex" ||
|
|
17
|
-
provider === "gemini_cli"
|
|
17
|
+
provider === "gemini_cli" ||
|
|
18
|
+
provider === "hermes_agent") &&
|
|
18
19
|
!url.search &&
|
|
19
20
|
fragment.size === 1 &&
|
|
20
21
|
tokens.length === 1 &&
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { dirname } from "node:path";
|
|
3
|
-
import { verifyClaudeCode, verifyCodex, verifyCodexImages, verifyCodexWeb,
|
|
3
|
+
import { verifyClaudeCode, verifyCodex, verifyCodexImages, verifyCodexWeb, verifyRoomProvider, } from "../agent/adapters.js";
|
|
4
4
|
import { CodexBoundaryError } from "../agent/codex-probe.js";
|
|
5
5
|
import { AgentGateway, GatewayError } from "../agent/gateway.js";
|
|
6
|
-
import {
|
|
6
|
+
import { roomProvider } from "../agent/room-providers.js";
|
|
7
7
|
import { serveAgent } from "../agent/serve.js";
|
|
8
8
|
import { agentWorkDir, localAgents, storeAgent, } from "../agent-config.js";
|
|
9
9
|
import { AgentHttpError, fetchAgentStatus } from "../agent-http.js";
|
|
@@ -55,6 +55,7 @@ export async function runAgentServe(parsed, options = {}) {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
async function verifyAgent(config, options, signal) {
|
|
58
|
+
const room = roomProvider(config.provider);
|
|
58
59
|
try {
|
|
59
60
|
let binary;
|
|
60
61
|
try {
|
|
@@ -71,8 +72,8 @@ async function verifyAgent(config, options, signal) {
|
|
|
71
72
|
if (config.provider === "claude_code") {
|
|
72
73
|
await verifyClaudeCode(binary);
|
|
73
74
|
}
|
|
74
|
-
else if (
|
|
75
|
-
await
|
|
75
|
+
else if (room) {
|
|
76
|
+
await verifyRoomProvider(room, binary, signal);
|
|
76
77
|
}
|
|
77
78
|
else {
|
|
78
79
|
await verifyCodex(binary, signal);
|
|
@@ -82,8 +83,7 @@ async function verifyAgent(config, options, signal) {
|
|
|
82
83
|
}
|
|
83
84
|
catch (error) {
|
|
84
85
|
if (error instanceof ProviderBinaryError) {
|
|
85
|
-
if (!(error instanceof CodexBoundaryError ||
|
|
86
|
-
error instanceof GeminiBoundaryError)) {
|
|
86
|
+
if (!(error instanceof CodexBoundaryError || room?.isBoundaryError(error))) {
|
|
87
87
|
try {
|
|
88
88
|
await new AgentGateway(config).request("/agent-gateway/provider-unavailable");
|
|
89
89
|
}
|
package/dist/provider-binary.js
CHANGED
|
@@ -5,11 +5,18 @@ const BINARY = {
|
|
|
5
5
|
claude_code: "claude",
|
|
6
6
|
codex: "codex",
|
|
7
7
|
gemini_cli: "gemini",
|
|
8
|
+
hermes_agent: "hermes",
|
|
8
9
|
};
|
|
9
10
|
const LABEL = {
|
|
10
11
|
claude_code: "Claude Code",
|
|
11
12
|
codex: "Codex",
|
|
12
13
|
gemini_cli: "Gemini CLI",
|
|
14
|
+
hermes_agent: "Hermes Agent",
|
|
15
|
+
};
|
|
16
|
+
// TalentOS never installs a provider. Hermes Agent is not an npm package (the
|
|
17
|
+
// one under that name is an unofficial bridge), so its message says where it comes from.
|
|
18
|
+
const INSTALL_HINT = {
|
|
19
|
+
hermes_agent: "install it from hermes-agent.nousresearch.com, then ",
|
|
13
20
|
};
|
|
14
21
|
export class ProviderBinaryError extends Error {
|
|
15
22
|
exitCode = 78;
|
|
@@ -39,7 +46,7 @@ export function resolveProviderBinary(provider, configured) {
|
|
|
39
46
|
}
|
|
40
47
|
}
|
|
41
48
|
const label = LABEL[provider];
|
|
42
|
-
throw new ProviderBinaryError(`${label} not found at ${configured ?? join(homeDir(), ".local/bin", binary)}; run talentos agent repair`);
|
|
49
|
+
throw new ProviderBinaryError(`${label} not found at ${configured ?? join(homeDir(), ".local/bin", binary)}; ${INSTALL_HINT[provider] ?? ""}run talentos agent repair`);
|
|
43
50
|
}
|
|
44
51
|
export function providerPathEnv(binary, home = homeDir(), includeRuntimeNode = true) {
|
|
45
52
|
return [
|
package/package.json
CHANGED