talentos 1.3.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.
- package/dist/agent/adapters.js +23 -0
- package/dist/agent/codex-policy.js +3 -0
- package/dist/agent/gateway.js +11 -1
- package/dist/agent/mcp-entry.js +4 -1
- package/dist/agent/native/codex-fence-probe.js +629 -0
- package/dist/agent/native/codex-fence.js +168 -0
- package/dist/agent/native/codex-launch.js +86 -0
- package/dist/agent/native/codex-owner-probe.js +145 -4
- package/dist/agent/native/codex-run-command.js +302 -0
- package/dist/agent/native/config.js +8 -2
- package/dist/agent/native/discover.js +137 -0
- package/dist/agent/native/fresh.js +104 -0
- package/dist/agent/native/gate.js +139 -17
- package/dist/agent/native/policy.js +63 -14
- package/dist/agent/native/project-requests.js +106 -0
- package/dist/agent/native/projects.js +111 -0
- package/dist/agent/native/touch.js +10 -0
- package/dist/agent/native/workspace.js +20 -5
- package/dist/agent/serve.js +59 -5
- package/dist/args.js +1 -0
- package/dist/commands/agent-native.js +39 -5
- package/dist/commands/agent.js +5 -1
- package/dist/mcp-proxy.js +25 -2
- package/package.json +1 -1
package/dist/agent/serve.js
CHANGED
|
@@ -9,6 +9,8 @@ import { runProvider } from "./adapters.js";
|
|
|
9
9
|
import { AgentGateway, GatewayError } from "./gateway.js";
|
|
10
10
|
import { ApprovalBridge } from "./native/approvals.js";
|
|
11
11
|
import { NativeGate } from "./native/gate.js";
|
|
12
|
+
import { ProjectRequests } from "./native/project-requests.js";
|
|
13
|
+
import { mirrorOf } from "./native/projects.js";
|
|
12
14
|
import { SessionMap } from "./sessions.js";
|
|
13
15
|
const HEARTBEAT_MS = 20_000;
|
|
14
16
|
const LEASE_SAFETY_MS = 55_000;
|
|
@@ -88,16 +90,40 @@ export async function serveAgent(config, directory, version, stop, verify, optio
|
|
|
88
90
|
wake();
|
|
89
91
|
}
|
|
90
92
|
};
|
|
93
|
+
let requests;
|
|
91
94
|
const heartbeat = async () => {
|
|
92
95
|
gate.refresh();
|
|
93
|
-
|
|
96
|
+
// Ids and names only; a registry that cannot be read is not sent.
|
|
97
|
+
const mirror = gate.projects
|
|
98
|
+
? await gate
|
|
99
|
+
.projects()
|
|
100
|
+
.then(mirrorOf)
|
|
101
|
+
.catch(() => undefined)
|
|
102
|
+
: undefined;
|
|
103
|
+
const response = await gateway.request("/agent-gateway/heartbeat", {
|
|
104
|
+
cliVersion: version,
|
|
105
|
+
nativeOptIn: gate.reportable(),
|
|
106
|
+
...(mirror ? { projects: mirror } : {}),
|
|
107
|
+
}, signal);
|
|
94
108
|
if (response) {
|
|
95
109
|
minimum = response.cliMinVersion;
|
|
96
110
|
if (response.pendingJobs > 0 || needsUpdate(version, minimum)) {
|
|
97
111
|
wake();
|
|
98
112
|
}
|
|
113
|
+
if ((response.projectRequests ?? 0) > 0) {
|
|
114
|
+
requests?.poke().catch(() => undefined);
|
|
115
|
+
}
|
|
99
116
|
}
|
|
100
117
|
};
|
|
118
|
+
requests = gate.projects
|
|
119
|
+
? new ProjectRequests({
|
|
120
|
+
directory,
|
|
121
|
+
env: () => gate.loginEnv?.() ?? Promise.resolve(process.env),
|
|
122
|
+
home: homeDir(),
|
|
123
|
+
mirror: () => heartbeat(),
|
|
124
|
+
post: (path, body) => gateway.request(path, body, signal),
|
|
125
|
+
})
|
|
126
|
+
: undefined;
|
|
101
127
|
const heartbeatLoop = async () => {
|
|
102
128
|
while (!signal.aborted) {
|
|
103
129
|
const started = Date.now();
|
|
@@ -156,7 +182,11 @@ export async function serveAgent(config, directory, version, stop, verify, optio
|
|
|
156
182
|
if (active && jobIds.includes(active.job.jobId)) {
|
|
157
183
|
active.cancel.abort();
|
|
158
184
|
}
|
|
159
|
-
}
|
|
185
|
+
}, requests
|
|
186
|
+
? () => {
|
|
187
|
+
requests?.poke().catch(() => undefined);
|
|
188
|
+
}
|
|
189
|
+
: undefined);
|
|
160
190
|
}
|
|
161
191
|
catch (error) {
|
|
162
192
|
push = false;
|
|
@@ -235,7 +265,15 @@ export async function serveAgent(config, directory, version, stop, verify, optio
|
|
|
235
265
|
lastStatusAt = Date.now();
|
|
236
266
|
const [, prepared] = await Promise.all([
|
|
237
267
|
gateway.request(`/agent-gateway/jobs/${job.jobId}/native-confirm`, { leaseToken: job.leaseToken }, signal),
|
|
238
|
-
gate
|
|
268
|
+
gate
|
|
269
|
+
.prepare(job.packet.thread.id, {
|
|
270
|
+
projectId: job.native.projectId,
|
|
271
|
+
status: (line) => {
|
|
272
|
+
lastStatusAt = Date.now();
|
|
273
|
+
post(line);
|
|
274
|
+
},
|
|
275
|
+
})
|
|
276
|
+
.catch(() => undefined),
|
|
239
277
|
]);
|
|
240
278
|
owner = prepared;
|
|
241
279
|
current.owner = Boolean(owner);
|
|
@@ -249,9 +287,22 @@ export async function serveAgent(config, directory, version, stop, verify, optio
|
|
|
249
287
|
.catch(() => undefined);
|
|
250
288
|
}
|
|
251
289
|
}
|
|
290
|
+
// A project's sessions are its own; the root from before projects
|
|
291
|
+
// keeps its key so those threads still resume.
|
|
252
292
|
const sessionKey = owner
|
|
253
|
-
? `${job.packet.thread.id}:owner`
|
|
293
|
+
? `${job.packet.thread.id}:owner${owner.project.legacy ? "" : `:${owner.project.id}`}`
|
|
254
294
|
: job.packet.thread.id;
|
|
295
|
+
// Which code the work started from, on the owner's record.
|
|
296
|
+
const base = owner?.workspace.base;
|
|
297
|
+
const baseRow = base && {
|
|
298
|
+
at: Date.now(),
|
|
299
|
+
decision: "allow",
|
|
300
|
+
seq: 0,
|
|
301
|
+
subagent: false,
|
|
302
|
+
target: base.receipt,
|
|
303
|
+
tier: 0,
|
|
304
|
+
tool: "Workspace",
|
|
305
|
+
};
|
|
255
306
|
const bridge = () => new ApprovalBridge({
|
|
256
307
|
gateway: {
|
|
257
308
|
touch: async (flags) => {
|
|
@@ -281,7 +332,10 @@ export async function serveAgent(config, directory, version, stop, verify, optio
|
|
|
281
332
|
remember: async (sessionId) => {
|
|
282
333
|
await sessions.remember(sessionKey, sessionId);
|
|
283
334
|
},
|
|
284
|
-
receipts: async (
|
|
335
|
+
receipts: async (hookRows) => {
|
|
336
|
+
const rows = baseRow
|
|
337
|
+
? [baseRow, ...hookRows].map((row, seq) => ({ ...row, seq }))
|
|
338
|
+
: hookRows;
|
|
285
339
|
// The gateway body limit is 32 kB: 50 rows of at most ~250 B.
|
|
286
340
|
for (let at = 0; at < rows.length; at += 50) {
|
|
287
341
|
await gateway.request(`/agent-gateway/jobs/${job.jobId}/receipts`, {
|
package/dist/args.js
CHANGED
|
@@ -23,6 +23,7 @@ const CLI_OPTIONS = {
|
|
|
23
23
|
yes: { type: "boolean" },
|
|
24
24
|
agent: { type: "string" },
|
|
25
25
|
"upload-root": { type: "string" },
|
|
26
|
+
"owner-job-dir": { type: "string" },
|
|
26
27
|
};
|
|
27
28
|
/** Groups whose first positional is a sub-command rather than an argument. */
|
|
28
29
|
const ACTION_GROUPS = new Set(["agent", "mcp", "skills", "memory", "routines"]);
|
|
@@ -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(
|
|
23
|
+
throw new Error(`Choose a linked agent with \`talentos agent ${command} --agent <id>\`.`);
|
|
23
24
|
}
|
|
24
25
|
return chosen;
|
|
25
26
|
}
|
|
@@ -43,9 +44,6 @@ export async function runAgentNative(parsed, home = homeDir()) {
|
|
|
43
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
|
+
}
|
package/dist/commands/agent.js
CHANGED
|
@@ -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 = {}) {
|
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:
|
|
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