talentos 1.2.0 → 1.4.1

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.
@@ -1,6 +1,7 @@
1
1
  import { dirname } from "node:path";
2
2
  import { disableNative, enableNative, readNativeConfig, } from "../agent/native/config.js";
3
3
  import { NativeGate } from "../agent/native/gate.js";
4
+ import { checkRepo, readProjects, registerRoot, removeProject, } from "../agent/native/projects.js";
4
5
  import { agentWorkDir, localAgents, } from "../agent-config.js";
5
6
  import { emit } from "../format.js";
6
7
  import { homeDir } from "../install.js";
@@ -8,7 +9,7 @@ import { homeDir } from "../install.js";
8
9
  // to "let this agent work on this computer when you ask it in a room". The
9
10
  // server still needs the owner's own confirmation in TalentOS; this only
10
11
  // records consent on this machine and proves the provider can be guarded.
11
- async function pickAgent(parsed, home) {
12
+ async function pickAgent(parsed, home, command = "native enable") {
12
13
  const agents = await localAgents(home);
13
14
  const selector = parsed.options.agent;
14
15
  let chosen;
@@ -19,7 +20,7 @@ async function pickAgent(parsed, home) {
19
20
  chosen = agents[0];
20
21
  }
21
22
  if (!chosen) {
22
- throw new Error("Choose a linked agent with `talentos agent native enable --agent <id>`.");
23
+ throw new Error(`Choose a linked agent with \`talentos agent ${command} --agent <id>\`.`);
23
24
  }
24
25
  return chosen;
25
26
  }
@@ -39,13 +40,10 @@ export async function runAgentNative(parsed, home = homeDir()) {
39
40
  if (action === "status") {
40
41
  const config = await readNativeConfig(directory);
41
42
  emit(config
42
- ? `On. ${agent.name} works in ${shown(config.root, home)} when you ask it in a room where you are the only person.`
43
- : `Off. Run talentos agent native enable to let ${agent.name} use your full setup in rooms only you are in.`);
43
+ ? `On. ${agent.name} works in ${shown(config.root, home)} when you ask it in a room.`
44
+ : `Off. Run talentos agent native enable to let ${agent.name} use your full setup in rooms.`);
44
45
  return;
45
46
  }
46
- if (agent.provider !== "claude_code") {
47
- throw new Error("Full-setup rooms support Claude Code first. Codex is not available yet.");
48
- }
49
47
  const config = await enableNative({
50
48
  agentId: agent.agentId,
51
49
  cwd: process.cwd(),
@@ -60,5 +58,41 @@ export async function runAgentNative(parsed, home = homeDir()) {
60
58
  await disableNative(directory);
61
59
  throw error;
62
60
  }
61
+ // The folder it was enabled in is one of its projects (project #1 if first).
62
+ await registerRoot(directory, config);
63
63
  emit(`I'll work in ${shown(config.root, home)}${config.kind === "repo" ? " (each room thread gets its own copy of the branch)" : ""}. TalentOS will ask you to confirm once.`);
64
64
  }
65
+ // `talentos agent project add | list | remove` (#10987): the escape hatch for a
66
+ // repo the Projects dialog does not list. Same checks and registry as a pick;
67
+ // the running agent mirrors the id and name on its next heartbeat.
68
+ export async function runAgentProject(parsed, home = homeDir()) {
69
+ const action = parsed.args[0];
70
+ if (action !== "add" && action !== "list" && action !== "remove") {
71
+ throw new Error("Use talentos agent project add | list | remove.");
72
+ }
73
+ const agent = await pickAgent(parsed, home, `project ${action}`);
74
+ if (agent.provider !== "claude_code") {
75
+ throw new Error("Projects support Claude Code first. Codex is not available yet.");
76
+ }
77
+ const directory = dirname(agentWorkDir(agent.agentId, home));
78
+ if (action === "add") {
79
+ const project = await registerRoot(directory, await checkRepo(process.cwd(), home));
80
+ emit(`Added ${project.name}. Pick it for a room in that room's members panel.`);
81
+ return;
82
+ }
83
+ const projects = await readProjects(directory);
84
+ if (action === "remove") {
85
+ const match = projects.filter((project) => project.name === parsed.args[1]);
86
+ if (match.length !== 1 || !match[0]) {
87
+ throw new Error("Name one project from `talentos agent project list`, e.g. talentos agent project remove my-app.");
88
+ }
89
+ await removeProject(directory, match[0].id);
90
+ emit(`Removed ${match[0].name}. Its thread folders stay where they are.`);
91
+ return;
92
+ }
93
+ emit(projects.length > 0
94
+ ? projects
95
+ .map((project, index) => `${project.name}${index === 0 ? " (default)" : ""} ${shown(project.root, home)}`)
96
+ .join("\n")
97
+ : "No projects. In a repo, run talentos agent project add.");
98
+ }
@@ -96,6 +96,10 @@ export async function runAgent(parsed, dependencies = {}) {
96
96
  const { runAgentNative } = await import("./agent-native.js");
97
97
  return await runAgentNative(parsed, dependencies.home);
98
98
  }
99
+ case "project": {
100
+ const { runAgentProject } = await import("./agent-native.js");
101
+ return await runAgentProject(parsed, dependencies.home);
102
+ }
99
103
  case "status":
100
104
  case "list":
101
105
  return await showAgents(parsed);
@@ -104,7 +108,7 @@ export async function runAgent(parsed, dependencies = {}) {
104
108
  case "logs":
105
109
  return await showLogs(parsed);
106
110
  default:
107
- throw new Error("Use talentos agent link | repair | status | list | unlink | logs | native.");
111
+ throw new Error("Use talentos agent link | repair | status | list | unlink | logs | native | project.");
108
112
  }
109
113
  }
110
114
  export async function installLinkedAgent(parsed, dependencies = {}) {
@@ -217,6 +217,21 @@ async function installLock(root, signal) {
217
217
  await rm(pending, { force: true });
218
218
  }
219
219
  }
220
+ /**
221
+ * The installed gateway the launcher would run now, when it is a newer, complete
222
+ * version than the one running. `talentos agent repair` swaps `cli/current` but
223
+ * a service that is already running keeps its old code until it restarts, so a
224
+ * serving process asks this between turns and exits to be relaunched on it.
225
+ */
226
+ export async function newerInstalledVersion(home, running) {
227
+ const root = join(home, ".talentos/cli");
228
+ const active = await readlink(join(root, "current")).catch(() => "");
229
+ if ((compareGatewayVersions(active, running) ?? 0) > 0 &&
230
+ (await installed(join(root, active, "node_modules/talentos"), active))) {
231
+ return active;
232
+ }
233
+ return;
234
+ }
220
235
  export async function installSharedGateway(options = {}) {
221
236
  const home = options.home ?? homeDir();
222
237
  const source = options.source ?? fileURLToPath(new URL("../", import.meta.url));
package/dist/mcp-proxy.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
2
2
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
3
  import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
4
+ import { handleRunCommand, RUN_COMMAND_TOOL, stopAllRunCommands, wireShutdown, } from "./agent/native/codex-run-command.js";
4
5
  import { UploadRefusal, uploadFile } from "./upload-file.js";
5
6
  // The two server steps behind upload_file. The model sees only upload_file.
6
7
  const UPLOAD_STEP_TOOLS = new Set(["prepare_upload", "commit_upload"]);
@@ -13,17 +14,38 @@ export async function startMcpProxy(client,
13
14
  // The only folder upload_file reads from: the job's workspace, named by the
14
15
  // launcher. Never a tool argument, never this process's own folder; without
15
16
  // it upload_file refuses.
16
- root) {
17
+ root,
18
+ // An owner-native Codex job's folder (#10987). When set, the proxy also serves
19
+ // run_command, the one-shot shell fence; it is the sole shell gate, so the
20
+ // command is classified here whether the model or a forged stdin write asked.
21
+ ownerJobDir) {
17
22
  const server = new Server({ name: "talentos", version: "1.0.0" }, { capabilities: { tools: {} } });
23
+ // Job Stop kills Codex, which kills this child proxy; and if Codex crashes or
24
+ // is SIGKILLed its stdin pipe to us closes. Either way we abort and kill any
25
+ // in-flight one-shot command, so nothing outlives the job (run_command
26
+ // children run in their own process groups and would otherwise be orphaned).
27
+ const shutdownSignal = wireShutdown({
28
+ signals: ["SIGTERM", "SIGINT", "SIGHUP"],
29
+ stdin: process.stdin,
30
+ });
31
+ process.once("exit", () => stopAllRunCommands());
18
32
  server.setRequestHandler(ListToolsRequestSchema, async () => {
19
33
  const listed = await client.listTools();
34
+ const tools = listed.tools.filter((tool) => !UPLOAD_STEP_TOOLS.has(tool.name));
20
35
  return {
21
36
  ...listed,
22
- tools: listed.tools.filter((tool) => !UPLOAD_STEP_TOOLS.has(tool.name)),
37
+ tools: ownerJobDir ? [...tools, RUN_COMMAND_TOOL] : tools,
23
38
  };
24
39
  });
25
40
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
26
41
  const { name, arguments: args = {} } = request.params;
42
+ if (name === "run_command" && ownerJobDir) {
43
+ return await handleRunCommand({
44
+ command: args.command,
45
+ jobDir: ownerJobDir,
46
+ signal: shutdownSignal,
47
+ });
48
+ }
27
49
  if (name === "upload_file") {
28
50
  return await runUpload(client, args, root);
29
51
  }
@@ -35,6 +57,7 @@ root) {
35
57
  }
36
58
  return await client.callTool({ name, arguments: args });
37
59
  });
60
+ server.onclose = () => stopAllRunCommands();
38
61
  await server.connect(new StdioServerTransport());
39
62
  }
40
63
  async function runUpload(client, args, root) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "talentos",
3
- "version": "1.2.0",
3
+ "version": "1.4.1",
4
4
  "type": "module",
5
5
  "description": "TalentOS CLI: push and pull skills, read and write team memory, and delegate work to your Talent from any coding agent.",
6
6
  "repository": {