talentos 1.4.10 → 1.4.11
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/README.md +3 -3
- package/dist/agent/adapters.js +75 -11
- package/dist/agent/codex-policy.js +11 -0
- package/dist/agent/codex-probe.js +9 -5
- package/dist/agent/mcp-entry.js +22 -9
- package/dist/agent/native/approvals.js +15 -11
- package/dist/agent/native/codex-launch.js +1 -0
- package/dist/agent/native/gate.js +35 -1
- package/dist/agent/native/hook-entry.js +31 -8
- package/dist/agent/native/launch.js +1 -0
- package/dist/agent/native/policy.js +62 -14
- package/dist/agent/native/probe.js +13 -1
- package/dist/agent/native/touch.js +15 -1
- package/dist/agent/node-floor.js +140 -0
- package/dist/agent/serve.js +53 -7
- package/dist/agent-http.js +48 -0
- package/dist/agent-session.js +137 -0
- package/dist/args.js +1 -0
- package/dist/client.js +11 -2
- package/dist/commands/agent-session.js +160 -0
- package/dist/commands/agent.js +29 -3
- package/dist/commands/init.js +2 -2
- package/dist/commands/login.js +2 -2
- package/dist/gateway-install.js +50 -11
- package/dist/index.js +13 -4
- package/dist/install.js +39 -14
- package/dist/mcp-proxy.js +30 -2
- package/package.json +2 -2
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { localAgents } from "../agent-config.js";
|
|
2
|
+
import { AgentHttpError, registerSessionKey, revokeSessionKeys, } from "../agent-http.js";
|
|
3
|
+
import { redactAgentOutput } from "../agent-link.js";
|
|
4
|
+
import { readSessionKey, registerSession, removeSessionKey, SESSION_SERVER, SESSION_TARGETS, sessionEntry, sessionSnippet, unregisterSession, writeSessionKey, } from "../agent-session.js";
|
|
5
|
+
import { AgentClient, UNAUTHORIZED } from "../client.js";
|
|
6
|
+
import { dim, emit, warn } from "../format.js";
|
|
7
|
+
import { defaultProbe, detectAgents, homeDir } from "../install.js";
|
|
8
|
+
import { mintKey } from "../login.js";
|
|
9
|
+
import { selectAgents } from "./agent.js";
|
|
10
|
+
const REMOVED = "was removed in TalentOS; run talentos agent link to reconnect.";
|
|
11
|
+
const LABELS = {
|
|
12
|
+
claude: "Claude Code",
|
|
13
|
+
codex: "Codex",
|
|
14
|
+
};
|
|
15
|
+
function isSessionTarget(value) {
|
|
16
|
+
return SESSION_TARGETS.some((target) => target === value);
|
|
17
|
+
}
|
|
18
|
+
function sessionTargets(forOption) {
|
|
19
|
+
if (forOption === undefined) {
|
|
20
|
+
const found = detectAgents(defaultProbe()).filter(isSessionTarget);
|
|
21
|
+
if (found.length === 0) {
|
|
22
|
+
throw new Error("No Claude Code or Codex found. Re-run with --for claude|codex.");
|
|
23
|
+
}
|
|
24
|
+
return found;
|
|
25
|
+
}
|
|
26
|
+
if (forOption === "all") {
|
|
27
|
+
return [...SESSION_TARGETS];
|
|
28
|
+
}
|
|
29
|
+
if (isSessionTarget(forOption)) {
|
|
30
|
+
return [forOption];
|
|
31
|
+
}
|
|
32
|
+
throw new Error(`Unknown --for value: ${forOption}. Use claude, codex or all.`);
|
|
33
|
+
}
|
|
34
|
+
async function oneAgent(parsed, home) {
|
|
35
|
+
const agent = (await selectAgents(parsed, true, home))[0];
|
|
36
|
+
if (!agent) {
|
|
37
|
+
throw new Error("No linked agent matches. Run talentos agent link first.");
|
|
38
|
+
}
|
|
39
|
+
return agent;
|
|
40
|
+
}
|
|
41
|
+
function ended(error) {
|
|
42
|
+
return (error instanceof AgentHttpError &&
|
|
43
|
+
(error.status === 401 || error.status === 410));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Lets this machine's everyday Claude Code or Codex act in rooms as the linked
|
|
47
|
+
* agent: a key of its own, kept in a private file, and a stdio entry that
|
|
48
|
+
* reads it. A repeat run replaces the key.
|
|
49
|
+
*/
|
|
50
|
+
export async function runConnectSession(parsed, dependencies = {}) {
|
|
51
|
+
const home = dependencies.home ?? homeDir();
|
|
52
|
+
const agent = await oneAgent(parsed, home);
|
|
53
|
+
const targets = sessionTargets(parsed.options.for);
|
|
54
|
+
const minted = mintKey();
|
|
55
|
+
try {
|
|
56
|
+
await registerSessionKey(agent, minted.hashedKey);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (ended(error)) {
|
|
60
|
+
throw new Error(`${redactAgentOutput(agent.name)} ${REMOVED}`);
|
|
61
|
+
}
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
// Only after the server accepted the new key: a refusal (a busy agent, a
|
|
65
|
+
// removed one) must leave the other agent's terminal as it was.
|
|
66
|
+
await releaseOtherTerminals(agent, home);
|
|
67
|
+
await writeSessionKey(agent.agentId, { apiKey: minted.rawKey, apiUrl: agent.apiUrl }, home);
|
|
68
|
+
const entry = sessionEntry(agent.agentId, home);
|
|
69
|
+
for (const target of targets) {
|
|
70
|
+
const result = await settle(() => registerSession(target, entry, home));
|
|
71
|
+
if (result.done) {
|
|
72
|
+
emit(`✓ ${LABELS[target]} → ${result.detail}`);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
emit(`· ${LABELS[target]}: ${result.detail}. Add it yourself:\n ${sessionSnippet(target, entry)}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
emit(`${redactAgentOutput(agent.name)} can now act in its rooms from this terminal. ${dim("Turn it off with talentos agent disconnect-session.")}`);
|
|
79
|
+
}
|
|
80
|
+
// One terminal speaks as one agent: the `talentos-room` entry is a single
|
|
81
|
+
// name, so connecting this agent stops any other linked agent's terminal here
|
|
82
|
+
// rather than leave its key live with no entry to use it.
|
|
83
|
+
async function releaseOtherTerminals(agent, home) {
|
|
84
|
+
for (const other of await localAgents(home)) {
|
|
85
|
+
if (other.agentId !== agent.agentId &&
|
|
86
|
+
(await readSessionKey(other.agentId, home))) {
|
|
87
|
+
try {
|
|
88
|
+
await revokeSessionKeys(other);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// The key dies with its agent; the file goes either way.
|
|
92
|
+
}
|
|
93
|
+
await removeSessionKey(other.agentId, home);
|
|
94
|
+
emit(`${redactAgentOutput(other.name)} no longer acts from this terminal: one agent per terminal.`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export async function runDisconnectSession(parsed, dependencies = {}) {
|
|
99
|
+
const home = dependencies.home ?? homeDir();
|
|
100
|
+
const agent = await oneAgent(parsed, home);
|
|
101
|
+
await disconnectSession(agent, home, parsed.options.for);
|
|
102
|
+
emit(`${redactAgentOutput(agent.name)} no longer acts in rooms from this terminal. The ${SESSION_SERVER} entry is removed from every client unless --for names one.`);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Stops the agent's terminal key on the server, then removes the file and the
|
|
106
|
+
* client entries here. A server that cannot be reached is a warning, not a
|
|
107
|
+
* reason to leave the entries behind: the key stays dead once it is reached.
|
|
108
|
+
*/
|
|
109
|
+
export async function disconnectSession(agent, home, forOption) {
|
|
110
|
+
try {
|
|
111
|
+
await revokeSessionKeys(agent);
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
warn(`The server could not confirm the terminal key is stopped (${error instanceof Error ? error.message : "unreachable"}). Unlinking the agent in TalentOS stops it too.`);
|
|
115
|
+
}
|
|
116
|
+
await removeSessionKey(agent.agentId, home);
|
|
117
|
+
for (const target of sessionTargetsForRemoval(forOption)) {
|
|
118
|
+
const result = await settle(() => unregisterSession(target, home));
|
|
119
|
+
if (!result.done) {
|
|
120
|
+
warn(`${LABELS[target]}: ${result.detail}. Remove ${SESSION_SERVER} from it yourself.`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// Removal covers every client: a stale entry is worse than a missing one.
|
|
125
|
+
function sessionTargetsForRemoval(forOption) {
|
|
126
|
+
return forOption === undefined
|
|
127
|
+
? [...SESSION_TARGETS]
|
|
128
|
+
: sessionTargets(forOption);
|
|
129
|
+
}
|
|
130
|
+
async function settle(run) {
|
|
131
|
+
try {
|
|
132
|
+
return await run();
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
return {
|
|
136
|
+
done: false,
|
|
137
|
+
detail: error instanceof Error ? error.message : "could not write it",
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/** Whether this machine's terminal can act as the agent right now. */
|
|
142
|
+
export async function terminalState(agent, home) {
|
|
143
|
+
const key = await readSessionKey(agent.agentId, home);
|
|
144
|
+
if (!key) {
|
|
145
|
+
return "off";
|
|
146
|
+
}
|
|
147
|
+
const client = new AgentClient(key, []);
|
|
148
|
+
try {
|
|
149
|
+
await client.listTools();
|
|
150
|
+
return "on";
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
return error instanceof Error && error.message === UNAUTHORIZED
|
|
154
|
+
? "reconnect"
|
|
155
|
+
: "unknown";
|
|
156
|
+
}
|
|
157
|
+
finally {
|
|
158
|
+
await client.close();
|
|
159
|
+
}
|
|
160
|
+
}
|
package/dist/commands/agent.js
CHANGED
|
@@ -6,6 +6,7 @@ import { agentConfigPath, agentLogPath, agentsDir, agentWorkDir, isMissing, loca
|
|
|
6
6
|
import { AgentHttpError, fetchAgentStatus, inspectProvider, redeemAgent, setupApiOrigin, unlinkRemoteAgent, waitForHeartbeat, } from "../agent-http.js";
|
|
7
7
|
import { parseAgentLink, redactAgentOutput } from "../agent-link.js";
|
|
8
8
|
import { installAgentService, uninstallAgentService, } from "../agent-service.js";
|
|
9
|
+
import { readSessionKey } from "../agent-session.js";
|
|
9
10
|
import { emit, emitJson, renderTable, warn } from "../format.js";
|
|
10
11
|
import { installSharedGateway } from "../gateway-install.js";
|
|
11
12
|
import { homeDir } from "../install.js";
|
|
@@ -113,6 +114,14 @@ export async function runAgent(parsed, dependencies = {}) {
|
|
|
113
114
|
await import("../agent/mcp-entry.js");
|
|
114
115
|
return;
|
|
115
116
|
}
|
|
117
|
+
case "connect-session": {
|
|
118
|
+
const { runConnectSession } = await import("./agent-session.js");
|
|
119
|
+
return await runConnectSession(parsed, { home: dependencies.home });
|
|
120
|
+
}
|
|
121
|
+
case "disconnect-session": {
|
|
122
|
+
const { runDisconnectSession } = await import("./agent-session.js");
|
|
123
|
+
return await runDisconnectSession(parsed, { home: dependencies.home });
|
|
124
|
+
}
|
|
116
125
|
case "native": {
|
|
117
126
|
const { runAgentNative } = await import("./agent-native.js");
|
|
118
127
|
return await runAgentNative(parsed, dependencies.home);
|
|
@@ -129,7 +138,7 @@ export async function runAgent(parsed, dependencies = {}) {
|
|
|
129
138
|
case "logs":
|
|
130
139
|
return await showLogs(parsed);
|
|
131
140
|
default:
|
|
132
|
-
throw new Error("Use talentos agent link | repair | status | list | unlink | logs | native | project.");
|
|
141
|
+
throw new Error("Use talentos agent link | repair | status | list | unlink | logs | connect-session | disconnect-session | native | project.");
|
|
133
142
|
}
|
|
134
143
|
}
|
|
135
144
|
export async function installLinkedAgent(parsed, dependencies = {}) {
|
|
@@ -243,6 +252,7 @@ async function showAgents(parsed) {
|
|
|
243
252
|
provider: status.provider,
|
|
244
253
|
state: status.presence,
|
|
245
254
|
lastSeenAt: status.lastSeenAt,
|
|
255
|
+
terminal: await terminalLabel(agent),
|
|
246
256
|
});
|
|
247
257
|
}
|
|
248
258
|
catch (error) {
|
|
@@ -265,12 +275,24 @@ async function showAgents(parsed) {
|
|
|
265
275
|
? renderTable(["Agent", "Provider", "Status", "ID"], rows.map((row) => [
|
|
266
276
|
row.name,
|
|
267
277
|
row.provider,
|
|
268
|
-
row.hint ?? row.state,
|
|
278
|
+
[row.hint ?? row.state, row.terminal].filter(Boolean).join(" · "),
|
|
269
279
|
row.agentId,
|
|
270
280
|
]))
|
|
271
281
|
: "No agents linked on this machine. Get a setup prompt from TalentOS.");
|
|
272
282
|
}
|
|
273
283
|
}
|
|
284
|
+
// Only an agent whose terminal was ever connected gets a column: the rest of
|
|
285
|
+
// the table stays as it was.
|
|
286
|
+
async function terminalLabel(agent) {
|
|
287
|
+
const { terminalState } = await import("./agent-session.js");
|
|
288
|
+
const state = await terminalState(agent, homeDir());
|
|
289
|
+
return state === "off" ? undefined : TERMINAL_LABELS[state];
|
|
290
|
+
}
|
|
291
|
+
const TERMINAL_LABELS = {
|
|
292
|
+
on: "terminal on",
|
|
293
|
+
reconnect: "terminal needs reconnect (talentos agent connect-session)",
|
|
294
|
+
unknown: "terminal unreachable",
|
|
295
|
+
};
|
|
274
296
|
function agentAccessEnded(error) {
|
|
275
297
|
return (error instanceof AgentHttpError &&
|
|
276
298
|
(error.status === 401 || error.status === 410));
|
|
@@ -283,6 +305,10 @@ async function unlinkLocal(parsed) {
|
|
|
283
305
|
return;
|
|
284
306
|
}
|
|
285
307
|
const revoked = await unlinkRemoteAgent(agent);
|
|
308
|
+
// The terminal's key died with the agent; its entries must not linger.
|
|
309
|
+
if (await readSessionKey(agent.agentId, homeDir())) {
|
|
310
|
+
await (await import("./agent-session.js")).disconnectSession(agent, homeDir());
|
|
311
|
+
}
|
|
286
312
|
await uninstallAgentService(agent);
|
|
287
313
|
await rm(agentConfigPath(agent.agentId), { force: true });
|
|
288
314
|
emit(`Unlinked ${redactAgentOutput(agent.name)} on this machine.`);
|
|
@@ -318,7 +344,7 @@ async function showLogs(parsed) {
|
|
|
318
344
|
await log.close();
|
|
319
345
|
}
|
|
320
346
|
}
|
|
321
|
-
async function selectAgents(parsed, single = false, home) {
|
|
347
|
+
export async function selectAgents(parsed, single = false, home) {
|
|
322
348
|
const selector = parsed.options.agent ?? parsed.args[0];
|
|
323
349
|
const agents = (await localAgents(home)).filter((agent) => !selector || agent.agentId === selector || agent.name === selector);
|
|
324
350
|
if (single && agents.length > 1) {
|
package/dist/commands/init.js
CHANGED
|
@@ -8,7 +8,7 @@ const DONE = "✓";
|
|
|
8
8
|
const SKIPPED = "·";
|
|
9
9
|
const TRAILING_PUNCTUATION = /[.:\s]+$/;
|
|
10
10
|
/**
|
|
11
|
-
* The one command a new member runs: sign in, configure every
|
|
11
|
+
* The one command a new member runs: sign in, configure every agent on
|
|
12
12
|
* this machine at user level, and drop the company's skills where those agents
|
|
13
13
|
* already look for them.
|
|
14
14
|
*/
|
|
@@ -16,7 +16,7 @@ export async function runInit(parsed) {
|
|
|
16
16
|
const session = await signIn(parsed);
|
|
17
17
|
const targets = chosenTargets(parsed.options.for);
|
|
18
18
|
if (targets.length === 0) {
|
|
19
|
-
step(false, "No
|
|
19
|
+
step(false, "No agent found. Re-run with --for claude|cursor|codex.");
|
|
20
20
|
}
|
|
21
21
|
const configured = [];
|
|
22
22
|
for (const target of targets) {
|
package/dist/commands/login.js
CHANGED
|
@@ -6,7 +6,7 @@ import { fetchWhoami, renderWhoami } from "./whoami.js";
|
|
|
6
6
|
const POLL_INTERVAL_MS = 2000;
|
|
7
7
|
/** A 5xx or a dropped wifi must not discard a key the member just approved. */
|
|
8
8
|
const MAX_POLL_FAILURES = 5;
|
|
9
|
-
const REJECTED_KEY = "TalentOS rejected that key. Create a new one in Settings → Agents
|
|
9
|
+
const REJECTED_KEY = "TalentOS rejected that key. Create a new one in Settings → Agents, or run `talentos login` without --key.";
|
|
10
10
|
export async function runLogin(parsed) {
|
|
11
11
|
const session = await authorize(parsed);
|
|
12
12
|
emit(`${bold("Logged in.")}\n${renderWhoami(session.who)}`);
|
|
@@ -72,7 +72,7 @@ export function approvalNotice(start) {
|
|
|
72
72
|
const heading = `Approve this device in TalentOS:\n\n ${bold(start.code)}\n`;
|
|
73
73
|
return start.authorizeUrl
|
|
74
74
|
? `${heading} ${start.authorizeUrl}\n`
|
|
75
|
-
: `${heading}\nOpen TalentOS in your browser, go to Settings → Agents
|
|
75
|
+
: `${heading}\nOpen TalentOS in your browser, go to Settings → Agents, and enter this code.\n`;
|
|
76
76
|
}
|
|
77
77
|
/** Polls until the member decides, riding out transient failures. */
|
|
78
78
|
export async function pollUntilDecided(apiUrl, start, rawKey, deps = { fetchStatus: fetchLoginStatus, wait: sleep }) {
|
package/dist/gateway-install.js
CHANGED
|
@@ -25,6 +25,47 @@ const NPM_ENV = new Set([
|
|
|
25
25
|
"NO_PROXY",
|
|
26
26
|
"NODE_EXTRA_CA_CERTS",
|
|
27
27
|
]);
|
|
28
|
+
/** The environment npm runs with: a PATH that finds this Node, and only the
|
|
29
|
+
* variables npm needs (proxy, CA bundle, `npm_config_*`), never the agent's. */
|
|
30
|
+
export function npmSpawnEnv() {
|
|
31
|
+
const env = {
|
|
32
|
+
PATH: `${process.env.PATH ?? servicePathEnv()}:${dirname(process.execPath)}`,
|
|
33
|
+
};
|
|
34
|
+
for (const [key, value] of Object.entries(process.env)) {
|
|
35
|
+
if ((NPM_ENV.has(key) || key.toLowerCase().startsWith("npm_config_")) &&
|
|
36
|
+
value) {
|
|
37
|
+
env[key] = value;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return env;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The Nodes the launcher would consider starting the gateway with, in its
|
|
44
|
+
* order: TALENTOS_NODE, the `cli/node-path` hint, each PATH entry, the fixed
|
|
45
|
+
* system paths, then installed nvm versions. Not filtered for the version a
|
|
46
|
+
* candidate runs: the caller probes that.
|
|
47
|
+
*/
|
|
48
|
+
export async function launcherNodeCandidates(home = homeDir(), env = process.env) {
|
|
49
|
+
const found = [];
|
|
50
|
+
if (env.TALENTOS_NODE) {
|
|
51
|
+
found.push(env.TALENTOS_NODE);
|
|
52
|
+
}
|
|
53
|
+
const hint = (await readFile(join(home, ".talentos/cli/node-path"), "utf8").catch(() => "")).split("\n")[0];
|
|
54
|
+
if (hint) {
|
|
55
|
+
found.push(hint);
|
|
56
|
+
}
|
|
57
|
+
for (const dir of (env.PATH ?? "").split(":")) {
|
|
58
|
+
if (dir) {
|
|
59
|
+
found.push(join(dir, "node"));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
found.push(...FIXED_NODE_CANDIDATES);
|
|
63
|
+
const nvm = join(home, NVM_NODE_VERSIONS);
|
|
64
|
+
for (const name of (await readdir(nvm).catch(() => [])).sort()) {
|
|
65
|
+
found.push(join(nvm, name, "bin/node"));
|
|
66
|
+
}
|
|
67
|
+
return [...new Set(found)];
|
|
68
|
+
}
|
|
28
69
|
export function gatewayLauncherPath(home = homeDir()) {
|
|
29
70
|
return join(home, ".talentos", "bin", "talentos-gateway");
|
|
30
71
|
}
|
|
@@ -43,6 +84,12 @@ export function servicePathEnv(home = homeDir()) {
|
|
|
43
84
|
]),
|
|
44
85
|
].join(":");
|
|
45
86
|
}
|
|
87
|
+
// Where the launcher looks for a Node after TALENTOS_NODE, the node-path hint
|
|
88
|
+
// and PATH. One list for the shell text below and for `launcherNodeCandidates`,
|
|
89
|
+
// so an update's Node check asks about the Nodes the launcher would start.
|
|
90
|
+
const FIXED_NODE_CANDIDATES = ["/opt/homebrew/bin/node", "/usr/local/bin/node"];
|
|
91
|
+
// Under the home directory; nvm has no stable system bin.
|
|
92
|
+
const NVM_NODE_VERSIONS = ".nvm/versions/node";
|
|
46
93
|
// No user paths are interpolated into executable shell text. The Node hint is data.
|
|
47
94
|
const LAUNCHER = `#!/bin/sh
|
|
48
95
|
set -f
|
|
@@ -92,14 +139,14 @@ for dir in \${PATH:-}; do
|
|
|
92
139
|
IFS=:
|
|
93
140
|
done
|
|
94
141
|
IFS=$old_ifs
|
|
95
|
-
for candidate in
|
|
142
|
+
for candidate in ${FIXED_NODE_CANDIDATES.join(" ")}; do
|
|
96
143
|
if qualifies "$candidate"; then
|
|
97
144
|
start "$candidate" "$@"
|
|
98
145
|
fi
|
|
99
146
|
done
|
|
100
147
|
# nvm has no stable system bin; discover surviving installations at startup.
|
|
101
148
|
set +f
|
|
102
|
-
for candidate in "$root"
|
|
149
|
+
for candidate in "$root"/../${NVM_NODE_VERSIONS}/*/bin/node; do
|
|
103
150
|
if qualifies "$candidate"; then start "$candidate" "$@"; fi
|
|
104
151
|
done
|
|
105
152
|
message="TalentOS gateway requires Node 22.23.4+ or 24.22.1+ (found \${seen_version:-unknown}). Install Node, then run talentos agent repair."
|
|
@@ -268,15 +315,7 @@ export async function installSharedGateway(options = {}) {
|
|
|
268
315
|
await copyPackage(source, join(temporary, "node_modules/talentos"));
|
|
269
316
|
}
|
|
270
317
|
else {
|
|
271
|
-
const npmEnv =
|
|
272
|
-
PATH: `${process.env.PATH ?? servicePathEnv()}:${dirname(process.execPath)}`,
|
|
273
|
-
};
|
|
274
|
-
for (const [key, value] of Object.entries(process.env)) {
|
|
275
|
-
if ((NPM_ENV.has(key) || key.toLowerCase().startsWith("npm_config_")) &&
|
|
276
|
-
value) {
|
|
277
|
-
npmEnv[key] = value;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
318
|
+
const npmEnv = npmSpawnEnv();
|
|
280
319
|
try {
|
|
281
320
|
await exec("npm", [
|
|
282
321
|
"install",
|
package/dist/index.js
CHANGED
|
@@ -4,13 +4,13 @@ import { redactAgentOutput } from "./agent-link.js";
|
|
|
4
4
|
import { parseArgv } from "./args.js";
|
|
5
5
|
import { emit } from "./format.js";
|
|
6
6
|
import { ProviderBinaryError } from "./provider-binary.js";
|
|
7
|
-
const USAGE = `talentos — your team's skills, memory and Talent, from any
|
|
7
|
+
const USAGE = `talentos — your team's skills, memory and Talent, from any agent.
|
|
8
8
|
|
|
9
9
|
Usage: talentos <command> [options]
|
|
10
10
|
|
|
11
11
|
Commands:
|
|
12
12
|
init Connect this machine's agents to TalentOS
|
|
13
|
-
agent <link|repair|status|list|unlink|logs>
|
|
13
|
+
agent <link|repair|status|list|unlink|logs|connect-session> Bring your own agent into Rooms
|
|
14
14
|
login Authorize this machine
|
|
15
15
|
logout Forget the key stored on this machine
|
|
16
16
|
whoami Show the member and org this key acts as
|
|
@@ -35,15 +35,24 @@ talentos agent unlink [name] [--agent <id>]
|
|
|
35
35
|
talentos agent logs [--agent <id>]
|
|
36
36
|
talentos agent repair [--agent <id>]
|
|
37
37
|
talentos agent serve --agent <id>
|
|
38
|
+
talentos agent connect-session [--agent <id>] [--for claude|codex|all]
|
|
39
|
+
talentos agent disconnect-session [--agent <id>] [--for claude|codex|all]
|
|
38
40
|
|
|
39
41
|
The link command checks the provider's CLI login, mints the key locally, and
|
|
40
42
|
installs one user service per agent. Only the key hash is sent to redeem.
|
|
41
43
|
Config is private under ~/.talentos/agents. Never print the setup fragment.
|
|
42
|
-
Serve is supplied by the S6 gateway release; Connected requires its heartbeat
|
|
44
|
+
Serve is supplied by the S6 gateway release; Connected requires its heartbeat.
|
|
45
|
+
|
|
46
|
+
connect-session lets your everyday Claude Code or Codex act in the agent's rooms
|
|
47
|
+
as that agent. It gets a key of its own, kept in a private file under
|
|
48
|
+
~/.talentos/agents (never in the client's config or arguments), and registers a
|
|
49
|
+
talentos-room server. disconnect-session stops the key and removes the entry
|
|
50
|
+
from every client (or only --for one);
|
|
51
|
+
unlinking the agent stops it too.`,
|
|
43
52
|
init: `talentos init [--for claude|cursor|codex|all] [--no-pull] [--name <device>]
|
|
44
53
|
|
|
45
54
|
One command: signs you in (skipped when your stored key still works), writes the
|
|
46
|
-
TalentOS MCP config for every
|
|
55
|
+
TalentOS MCP config for every agent on this machine at USER level, and
|
|
47
56
|
pulls the company's skills into ./.agents/skills (plus ./.claude/skills when
|
|
48
57
|
Claude Code is here). Nothing else is written inside the repo. Safe to re-run.
|
|
49
58
|
|
package/dist/install.js
CHANGED
|
@@ -9,10 +9,9 @@ export const MCP_INSTALL_TARGETS = [...AGENT_TARGETS, "json"];
|
|
|
9
9
|
const AGENTS_SKILLS_DIR = ".agents/skills";
|
|
10
10
|
const CLAUDE_SKILLS_DIR = ".claude/skills";
|
|
11
11
|
const CODEX_HEADER = "[mcp_servers.talentos]";
|
|
12
|
-
const CODEX_SUBTABLE = "[mcp_servers.talentos.";
|
|
13
12
|
const TOML_HEADER_START = "[";
|
|
14
13
|
const TRAILING_NEWLINES = /\n*$/;
|
|
15
|
-
const CONFIG_MODE = 0o600;
|
|
14
|
+
export const CONFIG_MODE = 0o600;
|
|
16
15
|
const GENERIC_HINT = "Add to your client's MCP config:";
|
|
17
16
|
/** A dead MCP server makes `claude mcp list` hang; `init` must not hang with it. */
|
|
18
17
|
const CLAUDE_LIST_TIMEOUT_MS = 10_000;
|
|
@@ -79,6 +78,10 @@ export function buildInstallSnippet(target, credentials) {
|
|
|
79
78
|
? AGENT_SPECS[target].render(credentials)
|
|
80
79
|
: JSON.stringify(cursorEntry(credentials), null, 2);
|
|
81
80
|
}
|
|
81
|
+
/** Where Codex keeps its user-level MCP servers. */
|
|
82
|
+
export function codexConfigPath(home) {
|
|
83
|
+
return (AGENT_SPECS.codex.configPath?.(home) ?? join(home, ".codex", "config.toml"));
|
|
84
|
+
}
|
|
82
85
|
export function homeDir(env = process.env) {
|
|
83
86
|
// An empty HOME is unset; taking it literally would write the key into
|
|
84
87
|
// whatever directory the CLI was started from.
|
|
@@ -118,19 +121,41 @@ export function mergeCursorConfig(existing, credentials) {
|
|
|
118
121
|
return `${JSON.stringify(next, null, 2)}\n`;
|
|
119
122
|
}
|
|
120
123
|
export function upsertCodexBlock(existing, credentials) {
|
|
121
|
-
|
|
124
|
+
return upsertCodexSection(existing, "talentos", AGENT_SPECS.codex.render(credentials));
|
|
125
|
+
}
|
|
126
|
+
/** Replaces or appends the `[mcp_servers.<server>]` block, leaving the rest. */
|
|
127
|
+
export function upsertCodexSection(existing, server, block) {
|
|
122
128
|
if (existing === undefined || existing.trim() === "") {
|
|
123
129
|
return `${block}\n`;
|
|
124
130
|
}
|
|
125
131
|
const lines = existing.split("\n");
|
|
126
|
-
const
|
|
127
|
-
if (
|
|
132
|
+
const bounds = codexSectionBounds(lines, server);
|
|
133
|
+
if (bounds === undefined) {
|
|
128
134
|
return `${existing.replace(TRAILING_NEWLINES, "")}\n\n${block}\n`;
|
|
129
135
|
}
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
136
|
+
const replacement = bounds.end === lines.length ? [block] : [block, ""];
|
|
137
|
+
return `${[...lines.slice(0, bounds.start), ...replacement, ...lines.slice(bounds.end)].join("\n").replace(TRAILING_NEWLINES, "")}\n`;
|
|
138
|
+
}
|
|
139
|
+
/** Drops the `[mcp_servers.<server>]` block; unchanged when there is none. */
|
|
140
|
+
export function removeCodexSection(existing, server) {
|
|
141
|
+
const lines = existing.split("\n");
|
|
142
|
+
const bounds = codexSectionBounds(lines, server);
|
|
143
|
+
if (bounds === undefined) {
|
|
144
|
+
return existing;
|
|
145
|
+
}
|
|
146
|
+
const rest = [...lines.slice(0, bounds.start), ...lines.slice(bounds.end)];
|
|
147
|
+
return `${rest.join("\n").replace(TRAILING_NEWLINES, "")}\n`;
|
|
148
|
+
}
|
|
149
|
+
function codexSectionBounds(lines, server) {
|
|
150
|
+
const header = `[mcp_servers.${server}]`;
|
|
151
|
+
const start = lines.findIndex((line) => line.trim() === header);
|
|
152
|
+
if (start === -1) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const rest = lines
|
|
156
|
+
.slice(start + 1)
|
|
157
|
+
.findIndex((line) => isForeignHeader(line, `[mcp_servers.${server}.`));
|
|
158
|
+
return { end: rest === -1 ? lines.length : start + 1 + rest, start };
|
|
134
159
|
}
|
|
135
160
|
/**
|
|
136
161
|
* Writes the MCP config for one agent at USER level. Nothing lands inside the
|
|
@@ -186,7 +211,7 @@ function applyClaudeInstall(credentials) {
|
|
|
186
211
|
}
|
|
187
212
|
return { applied: true, detail: "claude mcp add --scope user" };
|
|
188
213
|
}
|
|
189
|
-
function claudeRun(args, options = {}) {
|
|
214
|
+
export function claudeRun(args, options = {}) {
|
|
190
215
|
return spawnSync("claude", shellArgs(args), {
|
|
191
216
|
encoding: "utf8",
|
|
192
217
|
shell: process.platform === "win32",
|
|
@@ -194,9 +219,9 @@ function claudeRun(args, options = {}) {
|
|
|
194
219
|
...options,
|
|
195
220
|
});
|
|
196
221
|
}
|
|
197
|
-
function isForeignHeader(line) {
|
|
222
|
+
function isForeignHeader(line, subtable) {
|
|
198
223
|
const trimmed = line.trimStart();
|
|
199
|
-
return
|
|
224
|
+
return trimmed.startsWith(TOML_HEADER_START) && !trimmed.startsWith(subtable);
|
|
200
225
|
}
|
|
201
226
|
function skillDirNames(target) {
|
|
202
227
|
if (target === undefined) {
|
|
@@ -226,7 +251,7 @@ function cursorEntry(credentials) {
|
|
|
226
251
|
},
|
|
227
252
|
};
|
|
228
253
|
}
|
|
229
|
-
async function readIfPresent(path) {
|
|
254
|
+
export async function readIfPresent(path) {
|
|
230
255
|
try {
|
|
231
256
|
return await readFile(path, "utf8");
|
|
232
257
|
}
|
|
@@ -234,7 +259,7 @@ async function readIfPresent(path) {
|
|
|
234
259
|
return;
|
|
235
260
|
}
|
|
236
261
|
}
|
|
237
|
-
function onPath(command) {
|
|
262
|
+
export function onPath(command) {
|
|
238
263
|
const probe = spawnSync(command, shellArgs(["--version"]), {
|
|
239
264
|
stdio: "ignore",
|
|
240
265
|
shell: process.platform === "win32",
|
package/dist/mcp-proxy.js
CHANGED
|
@@ -5,6 +5,23 @@ import { handleRunCommand, RUN_COMMAND_TOOL, stopAllRunCommands, wireShutdown, }
|
|
|
5
5
|
import { UploadRefusal, uploadFile } from "./upload-file.js";
|
|
6
6
|
// The two server steps behind upload_file. The model sees only upload_file.
|
|
7
7
|
const UPLOAD_STEP_TOOLS = new Set(["prepare_upload", "commit_upload"]);
|
|
8
|
+
// A write held for its owner's OK (#13163): the server answers "still waiting"
|
|
9
|
+
// every ~50 s (a request longer than 60 s is cut by the MCP client, 300 s by
|
|
10
|
+
// fetch) while the card stays open for 5 minutes. Ask again, the same call, so
|
|
11
|
+
// the model sees one long call; the 8th answer is the server's final word.
|
|
12
|
+
const STILL_WAITING = "Still waiting for the owner to approve this change";
|
|
13
|
+
const HELD_ASKS_MAX = 8;
|
|
14
|
+
async function callHeld(client, params, signal) {
|
|
15
|
+
let result = await client.callTool(params);
|
|
16
|
+
for (let asks = 1; asks < HELD_ASKS_MAX && !signal.aborted; asks++) {
|
|
17
|
+
const first = result.isError ? result.content?.[0] : undefined;
|
|
18
|
+
if (!(first?.type === "text" && first.text.startsWith(STILL_WAITING))) {
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
result = await client.callTool(params);
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
8
25
|
/**
|
|
9
26
|
* stdio front end for clients that cannot speak streamable HTTP (Codex, older
|
|
10
27
|
* desktop builds). It forwards tool listing and calls verbatim so the tool set
|
|
@@ -29,8 +46,19 @@ ownerJobDir) {
|
|
|
29
46
|
stdin: process.stdin,
|
|
30
47
|
});
|
|
31
48
|
process.once("exit", () => stopAllRunCommands());
|
|
49
|
+
// Codex lists once, as its turn starts. Connecting and listing now means the
|
|
50
|
+
// answer is usually ready by the time it asks, instead of paying the
|
|
51
|
+
// connection and the round trip then. Only that first request takes it, its
|
|
52
|
+
// failure included (the client already waited out a server that is away, so a
|
|
53
|
+
// second round of waiting would pass Codex's own startup timeout); a later
|
|
54
|
+
// listing asks the server again.
|
|
55
|
+
let headStart = client.listTools();
|
|
56
|
+
// The failure is the first request's to report, not an unhandled rejection.
|
|
57
|
+
headStart.catch(() => undefined);
|
|
32
58
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
33
|
-
const
|
|
59
|
+
const pending = headStart ?? client.listTools();
|
|
60
|
+
headStart = undefined;
|
|
61
|
+
const listed = await pending;
|
|
34
62
|
const tools = listed.tools.filter((tool) => !UPLOAD_STEP_TOOLS.has(tool.name));
|
|
35
63
|
return {
|
|
36
64
|
...listed,
|
|
@@ -55,7 +83,7 @@ ownerJobDir) {
|
|
|
55
83
|
isError: true,
|
|
56
84
|
};
|
|
57
85
|
}
|
|
58
|
-
return await client
|
|
86
|
+
return await callHeld(client, { name, arguments: args }, shutdownSignal);
|
|
59
87
|
});
|
|
60
88
|
server.onclose = () => stopAllRunCommands();
|
|
61
89
|
await server.connect(new StdioServerTransport());
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "talentos",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.11",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "TalentOS CLI: push and pull skills, read and write team memory, and delegate work to your Talent from any
|
|
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": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/TalentOSOfficial/talentos-team.git",
|