talentos 1.5.0 → 1.6.0

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 CHANGED
@@ -17,9 +17,6 @@ same server over stdio for clients that cannot speak streamable HTTP.
17
17
  Every command below pins `talentos@1`, the major that speaks the hosted MCP endpoint.
18
18
  The `0.x` releases are the retired stdio wrapper and no longer work.
19
19
 
20
- Release 1.1.0 includes Rooms agent linking, the gateway, and the `create_deck`
21
- MCP permission. `talentos@1` picks it up automatically after publication.
22
-
23
20
  ```bash
24
21
  npx talentos@1 init
25
22
  ```
@@ -27,15 +24,21 @@ npx talentos@1 init
27
24
  `init` is the whole setup in one command. It:
28
25
 
29
26
  1. **Signs you in** — skipped when the key already on this machine still works.
30
- 2. **Detects your agents** — Claude Code (the `claude` command on your
31
- PATH, or `~/.claude`), Cursor (`~/.cursor` or `./.cursor`), Codex (`~/.codex`).
32
- `--for claude|cursor|codex|all` overrides detection.
27
+ 2. **Detects your agents**: Claude Code (the `claude` command on your PATH, or
28
+ `~/.claude`), Cursor (`~/.cursor` or `./.cursor`), Codex (`~/.codex`),
29
+ Gemini CLI (the `gemini` command on your PATH) and Antigravity CLI (the `agy`
30
+ command on your PATH, or `~/.gemini/antigravity-cli`).
31
+ `--for claude|cursor|codex|gemini|antigravity|all` overrides detection.
33
32
  3. **Writes the MCP config** for each of them, at user level (see the table below).
34
33
  4. **Pulls the company's skills** into `./.agents/skills` — the folder Cursor and
35
34
  Codex auto-load — plus `./.claude/skills` when Claude Code is here. `--no-pull`
36
35
  skips this.
37
36
 
38
- Then ask your agent to call the `talentos` `whoami` tool. Re-running `init` is
37
+ Then restart or reload the agent so it loads the new tools (Claude Code: a new
38
+ session, or `/mcp`; Cursor: reload and enable `talentos` in MCP settings; Codex:
39
+ restart), and ask it to call the `talentos` `whoami` tool. Other agents (OpenCode,
40
+ Claude Desktop) are set up by hand; `talentos mcp install json`
41
+ prints the snippet. Re-running `init` is
39
42
  safe: the config entry is replaced (so a new key takes effect) and skills are
40
43
  overwritten by slug.
41
44
 
@@ -44,6 +47,8 @@ overwritten by slug.
44
47
  | Claude Code | `claude mcp add --scope user --transport http talentos <url> --header ...` (prints the command if `claude` is not on your PATH). With `--oauth`: the TalentOS plugin, below |
45
48
  | Cursor | `~/.cursor/mcp.json` → `mcpServers.talentos` (other servers kept, mode 0600). Same with `--oauth`: Cursor keeps the key for now |
46
49
  | Codex | `~/.codex/config.toml` → `[mcp_servers.talentos]`, the stdio proxy carrying `TALENTOS_API_KEY` and `TALENTOS_API_URL` (mode 0600). With `--oauth`: `url = ...` only |
50
+ | Gemini CLI | `~/.gemini/settings.json` → `mcpServers.talentos` (other servers and settings kept, mode 0600). With `--oauth`: no key; run `/mcp auth talentos` in Gemini |
51
+ | Antigravity CLI | `~/.gemini/config/mcp_config.json` → `mcpServers.talentos`. With `--oauth`: no key; open `/mcp` and authenticate |
47
52
 
48
53
  **Nothing is written inside the repo except pulled skills** (and the `.talentos-sync.json` that tracks them). Your API key lives in
49
54
  `~/.config/talentos/config.json` and in those user-level agent configs, never in
@@ -129,24 +134,30 @@ before it is sent, and stored only once TalentOS accepts it.
129
134
  | `claude` | a `claude mcp add --scope user --transport http` command |
130
135
  | `cursor` | the `~/.cursor/mcp.json` entry |
131
136
  | `codex` | the `~/.codex/config.toml` entry (stdio, via `npx -y talentos@1 mcp`, with the API url in its env) |
137
+ | `gemini` | the `~/.gemini/settings.json` entry (`httpUrl`) |
138
+ | `antigravity` | the `~/.gemini/config/mcp_config.json` entry (`serverUrl`) |
132
139
  | `json` | a generic `mcpServers` entry (print only) |
133
140
 
134
141
  ## MCP tools and machine output
135
142
 
136
- The prepared 1.5.0 release is unpublished; James owns publication. Enable
137
- `HEADLESS_CLI_V1=true` in the CLI process to try its contract:
143
+ Enable `HEADLESS_CLI_V1=true` in the CLI process to try its contract:
138
144
 
139
145
  ```sh
140
146
  talentos tools --json
141
147
  talentos call whoami --json '{}'
142
148
  talentos task status '<taskId>' --json
143
149
  talentos task watch '<taskId>' --json
150
+ talentos approvals watch --json
144
151
  talentos doctor --json
145
152
  ```
146
153
 
147
154
  The [CLI contract](../../docs/features/agent-access/README.md#cli-output-and-task-continuation)
148
155
  defines output, error results, task continuation and human approval boundaries.
149
156
 
157
+ `talentos approvals [list|status|watch] [id]` reads `approval_status` (server flag
158
+ `HEADLESS_APPROVAL_STATUS_V1`) and prints the TalentOS link where the member
159
+ decides. It has no allow or deny, by design ([ADR 0120](../../docs/adr/0120-a-member-decides-their-ais-approvals-from-a-signed-in-link-and-the-ai-only-watches.md)).
160
+
150
161
  ## Commands
151
162
 
152
163
  ### Agents in Rooms
@@ -160,8 +171,9 @@ and left untouched. A room-only job (a teammate's ask, a not-ready owner job,
160
171
  every Codex job) runs in its own empty folder and does not load your CLAUDE.md,
161
172
  rules, hooks, memory or Codex AGENTS.md and skills (not even their names); only
162
173
  your provider login is used. Final text posts automatically.
163
- The service heartbeats every 20 seconds and stops the child if its lease is
164
- lost. A required CLI update installs under the agent directory between turns.
174
+ Idle, the service heartbeats as often as the server asks (every 45 seconds; 20
175
+ against a server that names no interval). A running job renews its lease every
176
+ 20 seconds, or 10 for an owner job, and the child stops if the lease is lost. A required CLI update installs under the agent directory between turns.
165
177
  Signing-key provisioning and real staging latency proofs are
166
178
  tracked in [Agent access](../../docs/features/agent-access/README.md).
167
179
 
@@ -207,8 +219,21 @@ talentos memory add "<fact>" [--company]
207
219
  talentos ask "<message>" [--thread <id>] [--no-wait]
208
220
  talentos routines list
209
221
  talentos routines run <id>
222
+
223
+ talentos publish [folder|page.html] [--title <title>] [--replace]
210
224
  ```
211
225
 
226
+ `publish` saves a web page to your TalentOS Library and prints its link. Only you
227
+ can open it until you share it. It reads the folder's `index.html` (or the one
228
+ `.html` file you name) and puts the page's own styles, scripts, images and fonts
229
+ inside it. It hosts one page per site and loads nothing from other websites.
230
+ Publishing the same page again updates the same app, and TalentOS keeps every
231
+ version. If someone changed the app in TalentOS since, nothing is replaced
232
+ unless you add `--replace`. The CLI remembers which app each page went to in
233
+ `published.json` beside its config.
234
+ `init` also installs a **Host on TalentOS** skill for this where your workspace
235
+ has hosting on. With that skill, telling your agent "host it" is enough.
236
+
212
237
  `skills pull` writes to `./.agents/skills` by default. `--for claude` writes to
213
238
  `./.claude/skills`, `--for all` writes both, and `--global` puts the same folders
214
239
  under your home directory; an explicit `--to` wins over all of them.
@@ -222,7 +247,9 @@ After `skills push`, `skills get`, `ask` and `routines run`, the last line is
222
247
 
223
248
  See [MCP tools and machine output](#mcp-tools-and-machine-output) for automation and task continuation.
224
249
 
225
- `talentos --help` and `talentos <group> --help` print usage.
250
+ `talentos --help` lists every command, including `tools`, `call`, `task`,
251
+ `approvals` and the `agent` subcommands the block above leaves out;
252
+ `talentos <group> --help` prints usage.
226
253
 
227
254
  A skill package is a `SKILL.md` (YAML frontmatter with `name` and `description`,
228
255
  body = the instructions) plus any supporting files next to it. `push` accepts the
@@ -237,6 +264,7 @@ file or the folder that contains it; a folder is walked recursively, skipping
237
264
  | `TALENTOS_API_KEY` | overrides the stored key |
238
265
  | `MCP_PUBLIC_ORIGIN` | optional HTTPS origin for remote MCP install snippets; unset uses the saved API origin. Keep `TALENTOS_API_URL` on the REST/gateway deployment. |
239
266
  | `TALENTOS_API_URL` | overrides the stored API url (default `https://woozy-oyster-769.convex.site`) |
267
+ | `HEADLESS_CLI_V1` | exact `true` turns on the `--json` envelope, `tools`/`call`, `task status|watch` and `approvals` |
240
268
  | `HEADLESS_SETUP_V1` | `true` or `1` makes `init` use the browser sign-in setup, like `--oauth` |
241
269
  | `TALENTOS_SKILLS_SYNC` | `1` lets the Claude Code plugin sync skills when a session starts |
242
270
  | `--api-url` | overrides both, for one command |
@@ -1,7 +1,56 @@
1
+ // Private member-session tools are offered by the session MCP server, never by a room-job adapter.
2
+ export const MEMBER_SESSION_TOOLS = [
3
+ "list_notifications",
4
+ "mark_notification_read",
5
+ "dismiss_my_retained_draft",
6
+ "get_my_settings",
7
+ "list_agent_memory",
8
+ "list_my_chats",
9
+ "list_my_today",
10
+ "pin_my_chat",
11
+ "read_my_chat",
12
+ "read_my_retained_draft",
13
+ "remove_agent_memory",
14
+ "restore_my_chat",
15
+ "set_today_done",
16
+ "update_my_profile",
17
+ "update_my_settings",
18
+ "save_file_to_library",
19
+ "memory_add_file",
20
+ "list_my_files",
21
+ "file_versions",
22
+ "manage_file",
23
+ "organize_files",
24
+ "change_my_message",
25
+ "change_room_fact",
26
+ "list_room_decisions",
27
+ "read_meeting",
28
+ "set_room_view",
29
+ "update_meeting_notes",
30
+ "list_room_context",
31
+ "room_context",
32
+ ];
1
33
  // Served by our LOCAL stdio proxy in an owner-native Codex job, not by the
2
34
  // server: the shell fence (#10987). The proxy classifies the command.
3
35
  export const ROOM_LOCAL_TOOLS = ["run_command"];
4
36
  export const ROOM_TOOLS = [
37
+ "artifact_audience_set",
38
+ "room_share",
39
+ "room_unshare",
40
+ "publish_link",
41
+ "unpublish_link",
42
+ "artifact_marketplace_publish",
43
+ "artifact_marketplace_unpublish",
44
+ "skill_audience_set",
45
+ "routine_audience_set",
46
+ "skill_room_share",
47
+ "skill_room_unshare",
48
+ "routine_room_share",
49
+ "routine_room_unshare",
50
+ "skill_marketplace_publish",
51
+ "skill_marketplace_unpublish",
52
+ "routine_marketplace_publish",
53
+ "routine_marketplace_unpublish",
5
54
  "recall",
6
55
  "update_memory",
7
56
  "forget",
@@ -23,11 +72,14 @@ export const ROOM_TOOLS = [
23
72
  "read_web_page",
24
73
  "read_app_state",
25
74
  "write_app_state",
75
+ "read_app_activity",
26
76
  "get_skill",
27
77
  "list_skills",
28
78
  "search_memory",
29
79
  "memory_outline",
30
80
  "memory_read",
81
+ "memory_facts",
82
+ "memory_edit_section",
31
83
  "list_connections",
32
84
  "use_connection",
33
85
  "change_connection",
@@ -40,12 +92,15 @@ export const ROOM_TOOLS = [
40
92
  "remember",
41
93
  "save_skill",
42
94
  "suggest_change",
95
+ "edit_sheet_cells",
96
+ "get_sheet_edit",
43
97
  "patch_live_page",
44
98
  "create_file",
45
99
  "create_deck",
46
100
  "create_spreadsheet",
47
101
  "create_web_app",
48
102
  "export_file",
103
+ "export_web_app",
49
104
  "revise_web_app",
50
105
  "share_file_to_room",
51
106
  "upload_file",
@@ -55,6 +110,8 @@ export const ROOM_TOOLS = [
55
110
  "ask_owner",
56
111
  "delete_own_message",
57
112
  "edit_own_message",
113
+ "set_file_pinned",
114
+ "forward_message",
58
115
  "react_to_message",
59
116
  "post_to_thread",
60
117
  "reply_to_comment",
@@ -67,6 +124,7 @@ export const ROOM_TOOLS = [
67
124
  "room_default_set",
68
125
  "room_default_remove",
69
126
  "whoami",
127
+ "onboarding_dismiss",
70
128
  ];
71
129
  // The upload tools run in the talentos CLI's stdio proxy (mcp-proxy.ts), which
72
130
  // reads the file from the job's folder and streams it to storage; the server's
@@ -52,11 +52,12 @@ function readsOtherRoom(call, jobRoomId) {
52
52
  const aimed = call.toolInput.roomId;
53
53
  return aimed !== undefined && aimed !== jobRoomId;
54
54
  }
55
- // read_file and read_app_state name no room, so the id has to: only a file id
55
+ // read_file, read_app_state and read_app_activity name no room, so the id has
56
+ // to: only a file id
56
57
  // the packet listed for the job's room, or an attachment of the message that
57
58
  // started the job (the owner's own words), stays inside it (#13471). A read by
58
59
  // versionId or another messageId, or a job with no list, fails closed.
59
- const BY_ID_TOOLS = new Set(["read_file", "read_app_state"].map((name) => ROOM_SERVER_PREFIX + name));
60
+ const BY_ID_TOOLS = new Set(["read_file", "read_app_state", "read_app_activity"].map((name) => ROOM_SERVER_PREFIX + name));
60
61
  function readsOtherRoomFile(call, context) {
61
62
  if (!BY_ID_TOOLS.has(call.tool)) {
62
63
  return false;
@@ -55,10 +55,17 @@ export class ProviderFailureError extends Error {
55
55
  this.reason = reason;
56
56
  }
57
57
  }
58
- /** The reason to send for a job that threw; absent keeps the generic failure. */
58
+ /**
59
+ * The reason to send for a job that threw. Any other thrown error (an output
60
+ * over its limit, a broken stream) is a crash: an absent reason made the room
61
+ * guess at a sign-in or usage limit that was fine (#16148).
62
+ */
59
63
  export function failureReasonOf(error) {
60
64
  if (error instanceof ProviderFailureError) {
61
65
  return error.reason;
62
66
  }
63
- return error instanceof ProviderBinaryError ? "missing_binary" : undefined;
67
+ if (error instanceof ProviderBinaryError) {
68
+ return "missing_binary";
69
+ }
70
+ return error instanceof Error ? "crashed" : undefined;
64
71
  }
@@ -21,6 +21,9 @@ import { failureReasonOf } from "./provider-failure.js";
21
21
  import { ProviderLoginWatch, probeProviderLogin } from "./provider-login.js";
22
22
  import { sweepRoomJobs } from "./room-profile.js";
23
23
  const HEARTBEAT_MS = 20_000;
24
+ // With push on, a claim on a timer is only a backstop: push wakes the loop for
25
+ // a new job, and so does a heartbeat that reports one waiting (#15948).
26
+ const PUSH_CLAIM_MS = 5 * 60_000;
24
27
  // A native job holds a 30 s server lease and is re-derived on every renewal.
25
28
  const NATIVE_RENEW_MS = 10_000;
26
29
  // A launch waits this long for the server before it starts the provider anyway.
@@ -105,6 +108,15 @@ export async function serveAgent(config, directory, version, stop, verify, optio
105
108
  wakeResolve?.();
106
109
  };
107
110
  let active;
111
+ // Idle, the server names the beat on each reply (an older one names none);
112
+ // a job's lease renewals keep their own.
113
+ const defaultIdleBeatMs = options.lease?.beatMs ?? HEARTBEAT_MS;
114
+ let idleBeatMs = defaultIdleBeatMs;
115
+ // A claim that met a server away (a deploy) is retried at the poll pace.
116
+ let claimFailed = false;
117
+ // Aborted by a claim, so the job's renewals start without waiting out an
118
+ // idle beat.
119
+ let idleWait = new AbortController();
108
120
  let minimum = version,
109
121
  // The Node range of an update this computer declined, reported until the
110
122
  // update is no longer blocked.
@@ -153,6 +165,10 @@ export async function serveAgent(config, directory, version, stop, verify, optio
153
165
  }, signal);
154
166
  if (response) {
155
167
  minimum = response.cliMinVersion;
168
+ idleBeatMs =
169
+ typeof response.heartbeatMs === "number"
170
+ ? Math.max(HEARTBEAT_MS, response.heartbeatMs)
171
+ : defaultIdleBeatMs;
156
172
  // The server's exact list of Codex versions allowed full setup; the
157
173
  // background probe waits for it.
158
174
  gate.setCodexTested?.(response.codexFenceTested);
@@ -174,7 +190,10 @@ export async function serveAgent(config, directory, version, stop, verify, optio
174
190
  post: (path, body) => gateway.request(path, body, signal),
175
191
  })
176
192
  : undefined;
177
- const beat = (native) => options.lease?.beatMs ?? (native ? NATIVE_RENEW_MS : HEARTBEAT_MS);
193
+ const beat = (job) => job
194
+ ? (options.lease?.beatMs ??
195
+ (job.native ? NATIVE_RENEW_MS : HEARTBEAT_MS))
196
+ : idleBeatMs;
178
197
  const holdFor = (native) => options.lease?.holdMs ?? holdMs(native);
179
198
  let failedRenewals = 0;
180
199
  // The server is away: a 5xx or no answer at all, as during a Convex push.
@@ -244,9 +263,10 @@ export async function serveAgent(config, directory, version, stop, verify, optio
244
263
  if (active?.job.native && active.owner && !gate.optedIn()) {
245
264
  active.cancel.abort();
246
265
  }
247
- await delay(Math.max(1, renewDelayMs(beat(Boolean(active?.job.native)), failedRenewals) -
248
- (Date.now() - started)), undefined, { signal }).catch(() => {
249
- /* Shutdown interrupts the timer. */
266
+ idleWait = new AbortController();
267
+ await delay(Math.max(1, renewDelayMs(beat(active?.job), failedRenewals) -
268
+ (Date.now() - started)), undefined, { signal: AbortSignal.any([signal, idleWait.signal]) }).catch(() => {
269
+ /* Shutdown or a claim interrupts the timer. */
250
270
  });
251
271
  }
252
272
  };
@@ -351,9 +371,11 @@ export async function serveAgent(config, directory, version, stop, verify, optio
351
371
  const claimStartedAt = Date.now();
352
372
  try {
353
373
  job = await gateway.request("/agent-gateway/claim", { cliVersion: version, deviceId }, signal);
374
+ claimFailed = false;
354
375
  }
355
376
  catch (error) {
356
377
  failService(error);
378
+ claimFailed = serverAway(error);
357
379
  job = null;
358
380
  }
359
381
  if (job) {
@@ -367,6 +389,7 @@ export async function serveAgent(config, directory, version, stop, verify, optio
367
389
  answered: false,
368
390
  };
369
391
  active = current;
392
+ idleWait.abort();
370
393
  let lastStatusAt = 0;
371
394
  // Until then, room progress lines wait so the room-only reason is read.
372
395
  let reasonUntil = 0;
@@ -574,7 +597,7 @@ export async function serveAgent(config, directory, version, stop, verify, optio
574
597
  continue;
575
598
  }
576
599
  await new Promise((resolve) => {
577
- const timer = setTimeout(finish, push ? HEARTBEAT_MS : claimPollInterval(lastJobAt));
600
+ const timer = setTimeout(finish, push && !claimFailed ? PUSH_CLAIM_MS : claimPollInterval(lastJobAt));
578
601
  function finish() {
579
602
  clearTimeout(timer);
580
603
  signal.removeEventListener("abort", finish);
@@ -1,10 +1,37 @@
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|hermes_agent)\/?$/;
2
+ const SETUP_PATH = /^\/agent-setup\/(any|claude_code|codex|gemini_cli|hermes_agent)\/?$/;
3
+ // The CLIs a universal link (/agent-setup/any) can connect: the ones the
4
+ // server seats in rooms.
5
+ const UNIVERSAL_PROVIDERS = ["claude_code", "codex", "gemini_cli"];
6
+ const NAME_YOUR_CLI = "This link works for any agent: add --provider claude_code, codex or gemini_cli for the CLI you are.";
3
7
  const FRAGMENT_TOKEN = /((?:#|%23)token(?:=|%3d))[^\s"'<>]+/giu;
4
8
  const RAW_KEY = /\btos_[a-z\d_-]+/giu;
5
9
  const BEARER = /\bBearer\s+\S+/giu;
6
10
  const TOKEN_WHITESPACE = /\s/u;
7
- export function parseAgentLink(value) {
11
+ /**
12
+ * The setup link and the provider it connects. A per-agent link names its
13
+ * provider in its path, and `named` (from --provider) must match it. A
14
+ * universal link (`/agent-setup/any`) names none, so `named` is required and
15
+ * must be one of the CLIs the server seats; TalentOS still checks that CLI on
16
+ * this computer before it connects.
17
+ */
18
+ export function parseAgentLink(value, named) {
19
+ const link = parseSetupUrl(value);
20
+ if (link.provider === "any") {
21
+ if (!isUniversalProvider(named)) {
22
+ throw new Error(NAME_YOUR_CLI);
23
+ }
24
+ return { ...link, provider: named };
25
+ }
26
+ if (named !== undefined && named !== link.provider) {
27
+ throw new Error(`This link is for ${link.provider}. Drop --provider, or ask for a new prompt from TalentOS.`);
28
+ }
29
+ return { ...link, provider: link.provider };
30
+ }
31
+ function isUniversalProvider(value) {
32
+ return UNIVERSAL_PROVIDERS.includes(value);
33
+ }
34
+ function parseSetupUrl(value) {
8
35
  try {
9
36
  const url = new URL(value);
10
37
  const provider = SETUP_PATH.exec(url.pathname)?.[1];
@@ -12,7 +39,8 @@ export function parseAgentLink(value) {
12
39
  const tokens = fragment.getAll("token");
13
40
  const token = tokens[0];
14
41
  if (!(isSecureUrl(url) &&
15
- (provider === "claude_code" ||
42
+ (provider === "any" ||
43
+ provider === "claude_code" ||
16
44
  provider === "codex" ||
17
45
  provider === "gemini_cli" ||
18
46
  provider === "hermes_agent") &&
package/dist/args.js CHANGED
@@ -27,7 +27,10 @@ const CLI_OPTIONS = {
27
27
  "upload-root": { type: "string" },
28
28
  "upload-scratch": { type: "string" },
29
29
  "owner-job-dir": { type: "string" },
30
+ provider: { type: "string" },
30
31
  surface: { type: "string" },
32
+ title: { type: "string" },
33
+ replace: { type: "boolean" },
31
34
  };
32
35
  /** Groups whose first positional is a sub-command rather than an argument. */
33
36
  const ACTION_GROUPS = new Set([
@@ -37,6 +40,7 @@ const ACTION_GROUPS = new Set([
37
40
  "memory",
38
41
  "routines",
39
42
  "task",
43
+ "approvals",
40
44
  ]);
41
45
  export function parseArgv(argv) {
42
46
  const { values, positionals } = parse(argv);
package/dist/client.js CHANGED
@@ -27,6 +27,10 @@ export class AgentClient {
27
27
  this.credentials = credentials;
28
28
  this.retryDelaysMs = retryDelaysMs;
29
29
  }
30
+ /** The deployment this client talks to. */
31
+ get apiUrl() {
32
+ return this.credentials.apiUrl;
33
+ }
30
34
  async call(name, args, options) {
31
35
  const client = await this.connect();
32
36
  const result = (await withFriendlyErrors(() => client.callTool({ name, arguments: args }, undefined, options)));
@@ -143,7 +143,7 @@ export async function runAgent(parsed, dependencies = {}) {
143
143
  }
144
144
  }
145
145
  export async function installLinkedAgent(parsed, dependencies = {}) {
146
- const link = parseAgentLink(parsed.options.url ?? "");
146
+ const link = parseAgentLink(parsed.options.url ?? "", parsed.options.provider);
147
147
  // The Connect dialog shows each step and the reason a link stopped (#15553).
148
148
  const report = dependencies.reportProgress ??
149
149
  linkProgressReporter(link, parsed.options["api-url"] ?? process.env.TALENTOS_API_URL);
@@ -0,0 +1,145 @@
1
+ import { withClient } from "../client.js";
2
+ import { emit, emitJson } from "../format.js";
3
+ import { CliError, cliContractEnabled, nextActions, withApiUrl, } from "../output.js";
4
+ import { watch } from "../watch.js";
5
+ // `talentos approvals` (ADR 0120): read-only. It lists, reads or follows the
6
+ // approvals the member has not yet decided, and prints the link they open in
7
+ // TalentOS. It has no allow, deny or open-and-approve: an approval is the
8
+ // member's tap on their own device, and anything the CLI could do the AI
9
+ // running beside it could do too.
10
+ const ACTIONS = new Set(["list", "status", "watch"]);
11
+ // approval_status answers at once, so the pause between reads is ours; it grows
12
+ // while nothing changes and resets on a change.
13
+ const POLL_START_SECONDS = 3;
14
+ const POLL_MAX_SECONDS = 15;
15
+ const MS = 1000;
16
+ const TOOL_MISSING = /Tool approval_status not found/i;
17
+ export async function runApprovals(parsed) {
18
+ if (!cliContractEnabled()) {
19
+ throw new CliError("FEATURE_DISABLED", "Approval commands need HEADLESS_CLI_V1=true until release.");
20
+ }
21
+ const action = parsed.action ?? "list";
22
+ const approvalId = parsed.args[0];
23
+ if (!ACTIONS.has(action) ||
24
+ parsed.args.length > 1 ||
25
+ (action === "list" && approvalId !== undefined)) {
26
+ throw new CliError("INVALID_ARGUMENT", "Usage: talentos approvals [list|status|watch] [approvalId] [--json]");
27
+ }
28
+ const id = action === "list" ? undefined : approvalId;
29
+ await withClient(parsed.options["api-url"], async (client) => {
30
+ const read = async (signal) => {
31
+ try {
32
+ return (await client.call("approval_status", id === undefined ? {} : { approvalId: id }, signal ? { signal } : undefined)).data;
33
+ }
34
+ catch (error) {
35
+ // A server without the tool (older, or the flag is off) says so in
36
+ // protocol words; the member gets a plain line.
37
+ if (error instanceof Error && TOOL_MISSING.test(error.message)) {
38
+ throw new Error("Following approvals isn't turned on for your workspace yet.");
39
+ }
40
+ throw error;
41
+ }
42
+ };
43
+ let latest;
44
+ if (action === "watch") {
45
+ const pacer = createPacer();
46
+ latest = await watch({
47
+ isRunning: waiting,
48
+ onChange: (value) => {
49
+ pacer.reset();
50
+ emit(render(value));
51
+ },
52
+ read: async (previous, waitSeconds, signal) => {
53
+ if (previous !== undefined && waitSeconds > 0) {
54
+ await sleep(pacer.next(waitSeconds) * MS, signal);
55
+ }
56
+ return await read(signal);
57
+ },
58
+ version: signature,
59
+ // The helper's wait ceiling (it also caps it at the time left): the
60
+ // pacer starts at POLL_START_SECONDS and grows to it.
61
+ waitSeconds: POLL_MAX_SECONDS,
62
+ });
63
+ }
64
+ else {
65
+ latest = await read();
66
+ }
67
+ const next = nextFor(latest, parsed.options["api-url"], id);
68
+ nextActions(next);
69
+ if (parsed.options.json) {
70
+ emitJson(latest);
71
+ return;
72
+ }
73
+ if (action !== "watch") {
74
+ emit(render(latest));
75
+ }
76
+ for (const action of next) {
77
+ emit(`Next: ${action.command} — ${action.why}`);
78
+ }
79
+ });
80
+ }
81
+ function waiting(value) {
82
+ return value.approvals.some((approval) => approval.status === "awaiting_human");
83
+ }
84
+ function signature(value) {
85
+ return value.approvals
86
+ .map((approval) => `${approval.approvalId}:${approval.status}`)
87
+ .join(",");
88
+ }
89
+ function nextFor(value, apiUrl, approvalId) {
90
+ const pending = value.approvals.filter((approval) => approval.status === "awaiting_human");
91
+ if (pending.length === 0) {
92
+ return [];
93
+ }
94
+ const where = pending.find((approval) => approval.link)?.link;
95
+ return [
96
+ {
97
+ // A watch of one card keeps following that card, so its decline is seen.
98
+ command: withApiUrl(approvalId === undefined
99
+ ? "talentos approvals watch"
100
+ : `talentos approvals watch ${shellQuote(approvalId)}`, apiUrl),
101
+ why: `Only the member can decide, in TalentOS${where ? ` (${where})` : ""}. Watching changes nothing; follow again afterwards.`,
102
+ },
103
+ ];
104
+ }
105
+ function render(value) {
106
+ if (value.approvals.length === 0) {
107
+ return "Nothing of yours is waiting for the member's approval.";
108
+ }
109
+ return value.approvals
110
+ .map((approval) => `${approval.status}: ${approval.what}${approval.link ? `\n Open: ${approval.link}` : ""}`)
111
+ .join("\n");
112
+ }
113
+ /** A pause that ends early, quietly, when the watch is cancelled. */
114
+ function sleep(ms, signal) {
115
+ return new Promise((resolve) => {
116
+ const timer = setTimeout(done, ms);
117
+ function done() {
118
+ clearTimeout(timer);
119
+ signal.removeEventListener("abort", done);
120
+ resolve();
121
+ }
122
+ signal.addEventListener("abort", done, { once: true });
123
+ });
124
+ }
125
+ function shellQuote(value) {
126
+ return `'${value.replaceAll("'", "'\\''")}'`;
127
+ }
128
+ /**
129
+ * The pause between reads: it starts at POLL_START_SECONDS, doubles while
130
+ * nothing changes up to the ceiling the watch passes in, and starts over on a
131
+ * change.
132
+ */
133
+ export function createPacer() {
134
+ let quiet = 0;
135
+ return {
136
+ next(ceilingSeconds) {
137
+ const pause = Math.min(POLL_START_SECONDS * 2 ** quiet, ceilingSeconds);
138
+ quiet += 1;
139
+ return pause;
140
+ },
141
+ reset() {
142
+ quiet = 0;
143
+ },
144
+ };
145
+ }
@@ -28,6 +28,8 @@ export async function diagnose(deps) {
28
28
  checkClaude(deps),
29
29
  await checkCursor(deps),
30
30
  await checkCodex(deps),
31
+ await checkJsonClient(deps, GEMINI_CLIENT),
32
+ await checkJsonClient(deps, ANTIGRAVITY_CLIENT),
31
33
  ],
32
34
  };
33
35
  if (cliContractEnabled()) {
@@ -211,6 +213,60 @@ async function checkCursor(deps) {
211
213
  }
212
214
  : finding;
213
215
  }
216
+ const GEMINI_CLIENT = {
217
+ file: "~/.gemini/settings.json",
218
+ label: "Gemini CLI",
219
+ path: [".gemini", "settings.json"],
220
+ signIn: "Run /mcp auth talentos in Gemini if it asks you to sign in.",
221
+ target: "gemini",
222
+ urlKey: "httpUrl",
223
+ };
224
+ const ANTIGRAVITY_CLIENT = {
225
+ file: "~/.gemini/config/mcp_config.json",
226
+ label: "Antigravity CLI",
227
+ path: [".gemini", "config", "mcp_config.json"],
228
+ signIn: "Open /mcp and authenticate talentos if it asks you to sign in.",
229
+ target: "antigravity",
230
+ urlKey: "serverUrl",
231
+ };
232
+ // Gemini CLI and Antigravity CLI keep TalentOS under `mcpServers.talentos`
233
+ // in a JSON file, with a key header or none (browser sign-in).
234
+ async function checkJsonClient(deps, client) {
235
+ const raw = await readIfPresent(join(deps.home, ...client.path));
236
+ const fix = `${FIX_INIT} --for ${client.target}`;
237
+ if (raw === undefined) {
238
+ return {
239
+ status: "note",
240
+ title: `${client.label}: not found on this machine.`,
241
+ };
242
+ }
243
+ let entry;
244
+ try {
245
+ entry = JSON.parse(raw).mcpServers?.talentos;
246
+ }
247
+ catch {
248
+ return {
249
+ status: "problem",
250
+ title: `${client.label}: ${client.file} is not plain JSON.`,
251
+ // Never "delete it": the file holds the member's other settings.
252
+ fix: `Add the talentos entry by hand, or remove its comments and run \`npx talentos@1 init --for ${client.target}\`.`,
253
+ };
254
+ }
255
+ if (entry === undefined) {
256
+ return {
257
+ status: "problem",
258
+ title: `${client.label} is not set up for TalentOS.`,
259
+ fix,
260
+ };
261
+ }
262
+ return keyedClientFinding(client.label, {
263
+ config: deps.config,
264
+ fix,
265
+ key: entry.headers?.Authorization?.replace(BEARER, ""),
266
+ signIn: client.signIn,
267
+ url: entry[client.urlKey],
268
+ });
269
+ }
214
270
  async function checkCodex(deps) {
215
271
  const raw = await readIfPresent(join(deps.home, ".codex", "config.toml"));
216
272
  const fix = `${FIX_INIT} --for codex`;