talentos 1.4.10 → 1.4.12

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.
Files changed (41) hide show
  1. package/README.md +3 -3
  2. package/dist/agent/adapters.js +207 -14
  3. package/dist/agent/codex-policy.js +22 -0
  4. package/dist/agent/codex-probe.js +114 -30
  5. package/dist/agent/gemini-login.js +74 -0
  6. package/dist/agent/gemini-policy.js +91 -0
  7. package/dist/agent/gemini-probe.js +308 -0
  8. package/dist/agent/mcp-entry.js +22 -9
  9. package/dist/agent/native/approvals.js +15 -11
  10. package/dist/agent/native/codex-launch.js +3 -0
  11. package/dist/agent/native/config.js +4 -2
  12. package/dist/agent/native/gate.js +160 -8
  13. package/dist/agent/native/hook-entry.js +33 -8
  14. package/dist/agent/native/launch.js +3 -0
  15. package/dist/agent/native/native-issue.js +3 -3
  16. package/dist/agent/native/policy.js +62 -14
  17. package/dist/agent/native/probe.js +13 -1
  18. package/dist/agent/native/touch.js +33 -1
  19. package/dist/agent/node-floor.js +140 -0
  20. package/dist/agent/provider-failure.js +2 -2
  21. package/dist/agent/provider-login.js +134 -0
  22. package/dist/agent/room-profile.js +41 -4
  23. package/dist/agent/serve.js +75 -9
  24. package/dist/agent-config.js +6 -1
  25. package/dist/agent-http.js +57 -0
  26. package/dist/agent-link.js +4 -2
  27. package/dist/agent-session.js +137 -0
  28. package/dist/args.js +1 -0
  29. package/dist/client.js +11 -2
  30. package/dist/commands/agent-native.js +0 -3
  31. package/dist/commands/agent-serve.js +7 -2
  32. package/dist/commands/agent-session.js +160 -0
  33. package/dist/commands/agent.js +37 -3
  34. package/dist/commands/init.js +2 -2
  35. package/dist/commands/login.js +2 -2
  36. package/dist/gateway-install.js +50 -11
  37. package/dist/index.js +13 -4
  38. package/dist/install.js +39 -14
  39. package/dist/mcp-proxy.js +30 -2
  40. package/dist/provider-binary.js +12 -2
  41. package/package.json +2 -2
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # talentos
2
2
 
3
- The TalentOS CLI. It connects the coding agent on your machine to your team's
3
+ The TalentOS CLI. It connects the agent on your machine to your team's
4
4
  governed brain, for four jobs:
5
5
 
6
6
  1. **Push** a skill your agent wrote into TalentOS, then share it with the company.
@@ -27,7 +27,7 @@ npx talentos@1 init
27
27
  `init` is the whole setup in one command. It:
28
28
 
29
29
  1. **Signs you in** — skipped when the key already on this machine still works.
30
- 2. **Detects your coding agents** — Claude Code (the `claude` command on your
30
+ 2. **Detects your agents** — Claude Code (the `claude` command on your
31
31
  PATH, or `~/.claude`), Cursor (`~/.cursor` or `./.cursor`), Codex (`~/.codex`).
32
32
  `--for claude|cursor|codex|all` overrides detection.
33
33
  3. **Writes the MCP config** for each of them, at user level (see the table below).
@@ -60,7 +60,7 @@ and asks you to approve the device in TalentOS. The raw key is written to
60
60
  `~/.config/talentos/config.json` (mode 0600) and never leaves the machine.
61
61
 
62
62
  It prints an eight-character code and, when the server returns an approval link,
63
- opens it. Otherwise open TalentOS yourself, go to **Settings → Agents & CLI**, and
63
+ opens it. Otherwise open TalentOS yourself, go to **Settings → Agents**, and
64
64
  enter the code there.
65
65
 
66
66
  Already have a key? `npx talentos@1 login --key tos_...` — it is checked for shape
@@ -10,7 +10,9 @@ import { redactAgentOutput, } from "../agent-link.js";
10
10
  import { gatewayLauncherPath } from "../gateway-install.js";
11
11
  import { providerPathEnv, resolveProviderBinary } from "../provider-binary.js";
12
12
  import { codexRoomArgs, ROOM_TOOLS } from "./codex-policy.js";
13
- import { CodexBoundaryError, codexWebProven, probeCodexBoundary, } from "./codex-probe.js";
13
+ import { binaryIdentity, CodexBoundaryError, CodexProbeInterrupted, codexWebProven, probeCodexBoundary, } from "./codex-probe.js";
14
+ import { geminiRoomArgs } from "./gemini-policy.js";
15
+ import { GeminiBoundaryError, probeGeminiBoundary } from "./gemini-probe.js";
14
16
  import { prepareCodexOwnerLaunch } from "./native/codex-launch.js";
15
17
  import { prepareOwnerLaunch } from "./native/launch.js";
16
18
  import { readReceipts } from "./native/receipts.js";
@@ -35,6 +37,17 @@ const CHILD_ENV = [
35
37
  ];
36
38
  const CLAUDE_VERSION = /^\d+\.\d+\.\d+/u;
37
39
  const CODEX_VERSION = /\b\d+\.\d+\.\d+\b/u;
40
+ const GEMINI_VERSION = /\b\d+\.\d+\.\d+\b/u;
41
+ // What the room launch needs from this Gemini CLI: its own policy files, the
42
+ // workspace-trust skip, headless streaming events, an approval mode and an MCP
43
+ // server allowlist. A Gemini without them cannot hold the room boundary.
44
+ const GEMINI_ROOM_FLAGS = [
45
+ "--policy",
46
+ "--skip-trust",
47
+ "--output-format",
48
+ "--approval-mode",
49
+ "--allowed-mcp-server-names",
50
+ ];
38
51
  const DONT_ASK = /\bdontAsk\b/u;
39
52
  // What the room line says while a job uses web. Neither names a page or a
40
53
  // query, and neither is a private tool, so an owner job shows them too.
@@ -93,8 +106,37 @@ export async function verifyClaudeCode(configured) {
93
106
  }
94
107
  throw new Error(`Update Claude Code (${version}) to a version that supports --permission-mode dontAsk, --setting-sources and --no-session-persistence.`);
95
108
  }
109
+ // What the serve loop already proved about each Codex binary, keyed by the
110
+ // binary's path and valid only while binaryIdentity is unchanged: the loop
111
+ // verifies before every claim, and an unchanged file cannot answer differently.
112
+ // An update in place changes the identity, so the next verify runs in full.
113
+ const verifiedCodex = new Map();
114
+ const webVerifiedCodex = new Map();
115
+ const roomCatalogs = new Map();
116
+ // The job room's file ids from the packet; undefined when it lists none, so the
117
+ // hook taints every read by id (#13471).
118
+ function roomFileIds(packet) {
119
+ return Array.isArray(packet.files)
120
+ ? packet.files.flatMap((file) => typeof file?.id === "string" ? [file.id] : [])
121
+ : undefined;
122
+ }
123
+ async function identityOrUndefined(binary) {
124
+ try {
125
+ return await binaryIdentity(binary);
126
+ }
127
+ catch {
128
+ return;
129
+ }
130
+ }
96
131
  export async function verifyCodex(configured, signal) {
97
132
  const binary = resolveProviderBinary("codex", configured);
133
+ // Taken before the checks: a swap while they run leaves a stale identity, and
134
+ // the next verify runs in full.
135
+ const identity = await identityOrUndefined(binary);
136
+ if (identity !== undefined &&
137
+ verifiedCodex.get(binary)?.identity === identity) {
138
+ return;
139
+ }
98
140
  const execute = promisify(execFile);
99
141
  const options = {
100
142
  env: childEnvironment(process.env, binary),
@@ -122,17 +164,60 @@ export async function verifyCodex(configured, signal) {
122
164
  }
123
165
  if (version !== "unknown") {
124
166
  await probeCodexBoundary(binary, version, await codexRoomCatalog(binary), signal);
167
+ if (identity !== undefined) {
168
+ verifiedCodex.set(binary, { identity, version });
169
+ }
125
170
  return;
126
171
  }
127
172
  }
128
173
  catch (error) {
129
- if (error instanceof CodexBoundaryError) {
174
+ if (error instanceof CodexBoundaryError ||
175
+ error instanceof CodexProbeInterrupted) {
130
176
  throw error;
131
177
  }
132
178
  // Provider diagnostics can contain login details.
133
179
  }
134
180
  throw new Error(`Update Codex (${version}) to a version supporting isolated room turns, exec/resume flags and a local model catalog.`);
135
181
  }
182
+ /**
183
+ * Gemini CLI can run a room job when it has the flags the launch uses and the
184
+ * real binary keeps a job inside its room tools (the loopback probe, which
185
+ * needs no sign-in). A signed-out Gemini still passes: sign-in is a job-time
186
+ * failure with its own plain reason.
187
+ */
188
+ export async function verifyGemini(configured, signal) {
189
+ const binary = resolveProviderBinary("gemini_cli", configured);
190
+ const execute = promisify(execFile);
191
+ const options = {
192
+ env: childEnvironment(process.env, binary),
193
+ timeout: 8000,
194
+ signal,
195
+ maxBuffer: 256_000,
196
+ };
197
+ let version = "unknown";
198
+ try {
199
+ const detected = await execute(binary, ["--version"], options);
200
+ version = GEMINI_VERSION.exec(detected.stdout)?.[0] ?? "unknown";
201
+ const help = await execute(binary, ["--help"], options);
202
+ if (version !== "unknown" &&
203
+ GEMINI_ROOM_FLAGS.every((flag) => help.stdout.includes(flag))) {
204
+ await probeGeminiBoundary({
205
+ binary,
206
+ env: childEnvironment(process.env, binary),
207
+ signal,
208
+ version,
209
+ });
210
+ return;
211
+ }
212
+ }
213
+ catch (error) {
214
+ if (error instanceof GeminiBoundaryError) {
215
+ throw error;
216
+ }
217
+ // Provider diagnostics can contain login details.
218
+ }
219
+ throw new Error(`Update Gemini CLI (${version}) to a version that supports ${GEMINI_ROOM_FLAGS.join(", ")}.`);
220
+ }
136
221
  /**
137
222
  * Proves this Codex's tool surface with live web search on, after the room
138
223
  * proof passed. Optional: a Codex that fails it (or cannot be probed) still
@@ -141,22 +226,50 @@ export async function verifyCodex(configured, signal) {
141
226
  export async function verifyCodexWeb(configured, signal) {
142
227
  try {
143
228
  const binary = resolveProviderBinary("codex", configured);
144
- const { stdout } = await promisify(execFile)(binary, ["--version"], {
145
- env: childEnvironment(process.env, binary),
146
- timeout: 5000,
147
- signal,
148
- maxBuffer: 256_000,
149
- });
150
- const version = CODEX_VERSION.exec(stdout)?.[0];
229
+ const identity = await identityOrUndefined(binary);
230
+ // Only a pass is remembered: a failed or interrupted proof is tried again.
231
+ if (identity !== undefined && webVerifiedCodex.get(binary) === identity) {
232
+ return;
233
+ }
234
+ const known = verifiedCodex.get(binary);
235
+ const version = known && known.identity === identity
236
+ ? known.version
237
+ : await codexVersion(binary, signal);
151
238
  if (version) {
152
239
  await probeCodexBoundary(binary, version, await codexRoomCatalog(binary), signal, { web: true });
240
+ if (identity !== undefined) {
241
+ webVerifiedCodex.set(binary, identity);
242
+ }
153
243
  }
154
244
  }
155
245
  catch {
156
246
  // Web stays off for this Codex.
157
247
  }
158
248
  }
249
+ async function codexVersion(binary, signal) {
250
+ const { stdout } = await promisify(execFile)(binary, ["--version"], {
251
+ env: childEnvironment(process.env, binary),
252
+ timeout: 5000,
253
+ signal,
254
+ maxBuffer: 256_000,
255
+ });
256
+ return CODEX_VERSION.exec(stdout)?.[0];
257
+ }
258
+ // The bundled catalog is the binary's own output, so an unchanged binary gives
259
+ // the same one: it is read once per identity, not on every job.
159
260
  async function codexRoomCatalog(binary) {
261
+ const identity = await identityOrUndefined(binary);
262
+ const known = roomCatalogs.get(binary);
263
+ if (identity !== undefined && known?.identity === identity) {
264
+ return known.catalog;
265
+ }
266
+ const catalog = await readCodexRoomCatalog(binary);
267
+ if (identity !== undefined) {
268
+ roomCatalogs.set(binary, { catalog, identity });
269
+ }
270
+ return catalog;
271
+ }
272
+ async function readCodexRoomCatalog(binary) {
160
273
  try {
161
274
  const { stdout } = await promisify(execFile)(binary, ["debug", "models", "--bundled"], {
162
275
  env: childEnvironment(process.env, binary),
@@ -227,8 +340,34 @@ export function readProviderEvent(provider, value) {
227
340
  if (event.type === "assistant" &&
228
341
  Array.isArray(message?.content) &&
229
342
  message.content.some((part) => part.type === "tool_use")) {
343
+ const names = message.content.flatMap((part) => part.type === "tool_use" ? [part.name ?? ""] : []);
230
344
  return {
231
- status: WEB_STATUS[message.content.find((part) => part.type === "tool_use")?.name ?? ""] ?? "Using room tools…",
345
+ status: WEB_STATUS[names[0] ?? ""] ?? "Using room tools…",
346
+ // Any of the turn's calls, not only the first: they run together.
347
+ ...(names.some((name) => name in WEB_STATUS)
348
+ ? { web: true }
349
+ : {}),
350
+ };
351
+ }
352
+ }
353
+ else if (provider === "gemini_cli") {
354
+ // stream-json: init, message (user and assistant chunks), tool_use,
355
+ // tool_result, error (a warning) and result (status and stats).
356
+ if (event.type === "message" && event.role === "assistant") {
357
+ return typeof event.content === "string"
358
+ ? { textDelta: event.content }
359
+ : {};
360
+ }
361
+ if (event.type === "tool_use") {
362
+ return { status: "Using room tools…", textReset: true };
363
+ }
364
+ if (event.type === "result" && event.status === "error") {
365
+ const error = event.error;
366
+ return {
367
+ failed: true,
368
+ failure: typeof error?.message === "string"
369
+ ? matchFailureText(error.message)
370
+ : undefined,
232
371
  };
233
372
  }
234
373
  }
@@ -255,7 +394,7 @@ export function readProviderEvent(provider, value) {
255
394
  return { status: "Using room tools…" };
256
395
  }
257
396
  if (event.type === "item.started" && item?.type === "web_search") {
258
- return { status: SEARCHING };
397
+ return { status: SEARCHING, web: true };
259
398
  }
260
399
  }
261
400
  return {};
@@ -263,10 +402,12 @@ export function readProviderEvent(provider, value) {
263
402
  export async function runProvider(input) {
264
403
  const { config, job, workDir, sessionId, signal } = input;
265
404
  const { instructions, ...context } = job.packet;
266
- const prompt = JSON.stringify(config.provider === "claude_code" ? context : job.packet), mcpPath = join(dirname(workDir), ROOM_MCP_FILE);
405
+ const prompt = JSON.stringify(config.provider === "codex" ? job.packet : context), mcpPath = join(dirname(workDir), ROOM_MCP_FILE);
267
406
  const catalogPath = join(dirname(workDir), ROOM_CATALOG_FILE);
268
407
  const binary = resolveProviderBinary(config.provider, config.providerPath);
269
408
  let command, args;
409
+ // Gemini CLI reads the packet from stdin; the others take it as an argument.
410
+ let stdinText;
270
411
  let ownerLaunch;
271
412
  let stopWatching;
272
413
  // Only a room-only job: an owner job runs in the owner's own setup on purpose.
@@ -282,6 +423,9 @@ export async function runProvider(input) {
282
423
  instructions,
283
424
  jobId: job.jobId,
284
425
  prompt,
426
+ roomId: job.packet.room?.id,
427
+ roomFileIds: roomFileIds(job.packet),
428
+ triggerId: job.packet.trigger?.id,
285
429
  sessionId,
286
430
  sharedRoom: job.native?.sharedRoom,
287
431
  workspace: input.owner.workspace,
@@ -289,6 +433,35 @@ export async function runProvider(input) {
289
433
  command = binary;
290
434
  args = ownerLaunch.args;
291
435
  }
436
+ else if (config.provider === "gemini_cli") {
437
+ // Gemini CLI never runs the owner's setup (the server never grants it
438
+ // either); a job that arrives as one runs nowhere.
439
+ if (input.owner) {
440
+ throw new Error("A Gemini CLI job is always room-only.");
441
+ }
442
+ command = binary;
443
+ roomProfile = await prepareRoomProfile({
444
+ directory: dirname(workDir),
445
+ env: process.env,
446
+ gemini: {
447
+ apiKey: config.apiKey,
448
+ mcpUrl: new URL("/mcp", config.apiUrl).href,
449
+ },
450
+ jobId: job.jobId,
451
+ provider: config.provider,
452
+ });
453
+ try {
454
+ // The room playbook is the job's own GEMINI.md: its directory is empty and
455
+ // nothing above it is read.
456
+ await writePrivateFile(join(roomProfile.cwd, "GEMINI.md"), instructions);
457
+ }
458
+ catch (error) {
459
+ await roomProfile.cleanup();
460
+ throw error;
461
+ }
462
+ stdinText = prompt;
463
+ args = geminiRoomArgs({ policyPath: roomProfile.geminiPolicyPath ?? "" });
464
+ }
292
465
  else if (input.owner && config.provider === "codex" && input.owner.codex) {
293
466
  const watching = await input.owner.watch?.();
294
467
  stopWatching = watching?.stop;
@@ -303,6 +476,9 @@ export async function runProvider(input) {
303
476
  instructions,
304
477
  jobId: job.jobId,
305
478
  prompt,
479
+ roomId: job.packet.room?.id,
480
+ roomFileIds: roomFileIds(job.packet),
481
+ triggerId: job.packet.trigger?.id,
306
482
  sessionId,
307
483
  sharedRoom: job.native?.sharedRoom,
308
484
  signal,
@@ -437,9 +613,15 @@ export async function runProvider(input) {
437
613
  },
438
614
  // stderr is matched to name a failure, never forwarded: it can hold login
439
615
  // details.
440
- stdio: ["ignore", "pipe", "pipe"],
616
+ stdio: [stdinText === undefined ? "ignore" : "pipe", "pipe", "pipe"],
441
617
  detached: process.platform !== "win32",
442
618
  });
619
+ if (stdinText !== undefined) {
620
+ // A provider that exits before reading it closes the pipe; that is its
621
+ // failure to report, not an error here.
622
+ child.stdin?.on("error", () => undefined);
623
+ child.stdin?.end(stdinText);
624
+ }
443
625
  const marked = new Set();
444
626
  const mark = (name) => {
445
627
  if (!marked.has(name)) {
@@ -488,7 +670,7 @@ export async function runProvider(input) {
488
670
  stop();
489
671
  }
490
672
  try {
491
- let text = "", failure, failed = false, sawResult = false;
673
+ let text = "", segment = "", failure, failed = false, sawResult = false, webReported = false;
492
674
  if (!child.stdout) {
493
675
  throw new Error("Provider output is unavailable.");
494
676
  }
@@ -509,6 +691,10 @@ export async function runProvider(input) {
509
691
  if (event.status) {
510
692
  mark("firstTool");
511
693
  }
694
+ if (event.web && !(webReported || input.owner)) {
695
+ webReported = true;
696
+ await input.webRead?.();
697
+ }
512
698
  if (event.failed) {
513
699
  failed = true;
514
700
  }
@@ -525,6 +711,13 @@ export async function runProvider(input) {
525
711
  ? "Working on your computer…"
526
712
  : event.status);
527
713
  }
714
+ if (event.textReset) {
715
+ segment = "";
716
+ }
717
+ if (event.textDelta) {
718
+ segment = (segment + event.textDelta).slice(0, 12_000);
719
+ text = segment;
720
+ }
528
721
  if (event.text !== undefined) {
529
722
  text = event.text.slice(0, 12_000);
530
723
  }
@@ -2,6 +2,7 @@
2
2
  // server: the shell fence (#10987). The proxy classifies the command.
3
3
  export const ROOM_LOCAL_TOOLS = ["run_command"];
4
4
  export const ROOM_TOOLS = [
5
+ "add_todo",
5
6
  "list_rooms",
6
7
  "list_threads",
7
8
  "reply_route",
@@ -11,21 +12,42 @@ export const ROOM_TOOLS = [
11
12
  "write_room_memory",
12
13
  "list_room_files",
13
14
  "read_file",
15
+ "read_file_comments",
16
+ "read_web_page",
14
17
  "read_app_state",
15
18
  "write_app_state",
16
19
  "get_skill",
20
+ "list_skills",
21
+ "search_memory",
22
+ "list_connections",
23
+ "use_connection",
24
+ "change_connection",
25
+ "prepare_connection",
26
+ "ask_talent",
27
+ "get_thread",
28
+ "list_routines",
29
+ "run_routine",
30
+ "remember",
31
+ "save_skill",
17
32
  "suggest_change",
33
+ "patch_live_page",
18
34
  "create_file",
19
35
  "create_deck",
36
+ "create_spreadsheet",
20
37
  "create_web_app",
38
+ "export_file",
21
39
  "revise_web_app",
22
40
  "upload_file",
23
41
  "prepare_upload",
24
42
  "commit_upload",
25
43
  "post_message",
44
+ "edit_own_message",
26
45
  "post_to_thread",
46
+ "reply_to_comment",
27
47
  "start_thread",
28
48
  "share_link",
49
+ "room_default_set",
50
+ "room_default_remove",
29
51
  "whoami",
30
52
  ];
31
53
  export function codexRoomArgs(input) {