@agentsky/sky 3.48.0 → 3.48.2

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.
@@ -0,0 +1,34 @@
1
+ // src/local-agents.ts
2
+ import { existsSync } from "fs";
3
+ import { homedir } from "os";
4
+ import { join } from "path";
5
+ function localAgents(env = process.env, home = homedir()) {
6
+ const claude = env.CLAUDE_CONFIG_DIR || join(home, ".claude");
7
+ const codex = env.CODEX_HOME || join(home, ".codex");
8
+ const cursor = join(home, ".cursor");
9
+ const grok = env.GROK_HOME || join(home, ".grok");
10
+ return [
11
+ { id: "claude_code", name: "Claude Code", root: claude, skillsDir: join(claude, "skills") },
12
+ { id: "codex", name: "Codex", root: codex, skillsDir: join(codex, "skills") },
13
+ { id: "cursor", name: "Cursor", root: cursor, skillsDir: join(cursor, "skills") },
14
+ { id: "grok", name: "Grok", root: grok, skillsDir: join(grok, "skills") }
15
+ ];
16
+ }
17
+ function detectLocalAgents(env = process.env, home = homedir()) {
18
+ return localAgents(env, home).filter((agent) => existsSync(agent.root));
19
+ }
20
+ function selectLocalAgents(ids, env = process.env, home = homedir()) {
21
+ if (!ids?.length) return detectLocalAgents(env, home);
22
+ const known = localAgents(env, home);
23
+ return ids.map((id) => {
24
+ const agent = known.find((candidate) => candidate.id === id);
25
+ if (!agent) throw new Error(`unknown agent ${id} \u2014 expected ${known.map((candidate) => candidate.id).join(" | ")}`);
26
+ return agent;
27
+ });
28
+ }
29
+
30
+ export {
31
+ localAgents,
32
+ detectLocalAgents,
33
+ selectLocalAgents
34
+ };
@@ -1,8 +1,10 @@
1
+ import {
2
+ withoutSettingsBlock
3
+ } from "./chunk-A45NGV2Q.js";
1
4
  import {
2
5
  MCP_SERVER_NAME,
3
- withoutSettingsBlock,
4
6
  withoutTomlServer
5
- } from "./chunk-V4NPUQM2.js";
7
+ } from "./chunk-RKMMLSGJ.js";
6
8
  import {
7
9
  configPath
8
10
  } from "./chunk-XHZJG3QT.js";
@@ -1,44 +1,18 @@
1
1
  import {
2
2
  ApiError,
3
3
  api
4
- } from "./chunk-NENCXIQO.js";
4
+ } from "./chunk-NAIYHS6Q.js";
5
5
  import {
6
- SKILL_NAME
7
- } from "./chunk-I6R6JSZT.js";
6
+ detectHermes
7
+ } from "./chunk-RKMMLSGJ.js";
8
+ import {
9
+ detectLocalAgents
10
+ } from "./chunk-2H4W5ZKZ.js";
8
11
  import {
9
12
  configPath,
10
13
  currentUniverse
11
14
  } from "./chunk-XHZJG3QT.js";
12
15
 
13
- // src/local-agents.ts
14
- import { existsSync } from "fs";
15
- import { homedir } from "os";
16
- import { join } from "path";
17
- function localAgents(env = process.env, home = homedir()) {
18
- const claude = env.CLAUDE_CONFIG_DIR || join(home, ".claude");
19
- const codex = env.CODEX_HOME || join(home, ".codex");
20
- const cursor = join(home, ".cursor");
21
- const grok = env.GROK_HOME || join(home, ".grok");
22
- return [
23
- { id: "claude_code", name: "Claude Code", root: claude, skillsDir: join(claude, "skills") },
24
- { id: "codex", name: "Codex", root: codex, skillsDir: join(codex, "skills") },
25
- { id: "cursor", name: "Cursor", root: cursor, skillsDir: join(cursor, "skills") },
26
- { id: "grok", name: "Grok", root: grok, skillsDir: join(grok, "skills") }
27
- ];
28
- }
29
- function detectLocalAgents(env = process.env, home = homedir()) {
30
- return localAgents(env, home).filter((agent) => existsSync(agent.root));
31
- }
32
- function selectLocalAgents(ids, env = process.env, home = homedir()) {
33
- if (!ids?.length) return detectLocalAgents(env, home);
34
- const known = localAgents(env, home);
35
- return ids.map((id) => {
36
- const agent = known.find((candidate) => candidate.id === id);
37
- if (!agent) throw new Error(`unknown agent ${id} \u2014 expected ${known.map((candidate) => candidate.id).join(" | ")}`);
38
- return agent;
39
- });
40
- }
41
-
42
16
  // src/workspace.ts
43
17
  import { createInterface } from "readline";
44
18
  var KINDS = ["TOOL_CALL", "SPEND_CAP", "CALL_COUNT", "CAPABILITY"];
@@ -188,302 +162,10 @@ function typedConfirmation(slug) {
188
162
  });
189
163
  }
190
164
 
191
- // src/mcp-register.ts
192
- import { existsSync as existsSync2, readFileSync, writeFileSync } from "fs";
193
- import { spawnSync } from "child_process";
194
- import { homedir as homedir2 } from "os";
195
- import { join as join2 } from "path";
196
- import { parse as parseToml } from "smol-toml";
197
- import { isMap, parseDocument } from "yaml";
198
-
199
- // ../../packages/spec/src/mcp-tool-list.ts
200
- var MCP_TOOL_LIST_PARAM = "tools";
201
- function mcpUrlWithToolList(mcpUrl, list) {
202
- const url = new URL(mcpUrl);
203
- if (list === "short") url.searchParams.set(MCP_TOOL_LIST_PARAM, "short");
204
- else url.searchParams.delete(MCP_TOOL_LIST_PARAM);
205
- return url.toString();
206
- }
207
- function mcpToolListOf(mcpUrl) {
208
- const value = (typeof mcpUrl === "string" ? new URL(mcpUrl) : mcpUrl).searchParams.get(MCP_TOOL_LIST_PARAM);
209
- if (value === null) return "every";
210
- return value === "short" || value === "every" ? value : null;
211
- }
212
-
213
- // src/mcp-register.ts
214
- var MCP_SERVER_NAME = SKILL_NAME;
215
- function detectHermes(env = process.env, home = homedir2()) {
216
- const root = env.HERMES_HOME || join2(home, ".hermes");
217
- return existsSync2(root) ? { id: "hermes", name: "Hermes", root } : null;
218
- }
219
- function claudeAppRoot(env = process.env, home = homedir2(), platform = process.platform) {
220
- if (platform === "darwin") return join2(home, "Library", "Application Support", "Claude");
221
- if (platform === "win32") return join2(env.APPDATA || join2(home, "AppData", "Roaming"), "Claude");
222
- return join2(env.XDG_CONFIG_HOME || join2(home, ".config"), "Claude");
223
- }
224
- function detectClaudeApp(env = process.env, home = homedir2(), platform = process.platform) {
225
- const root = claudeAppRoot(env, home, platform);
226
- return existsSync2(root) ? { id: "claude_app", name: "Claude app", root } : null;
227
- }
228
- function detectMcpClients(env = process.env, home = homedir2(), platform = process.platform) {
229
- const hermes = detectHermes(env, home);
230
- const claudeApp = detectClaudeApp(env, home, platform);
231
- return [...detectLocalAgents(env, home), ...hermes ? [hermes] : [], ...claudeApp ? [claudeApp] : []];
232
- }
233
- function systemCommandRunner() {
234
- return {
235
- has: (command) => spawnSync(command, ["--version"], { stdio: "ignore" }).status === 0,
236
- run: (command, args) => {
237
- const result = spawnSync(command, args, { encoding: "utf8" });
238
- return { status: result.status, stderr: result.stderr ?? "", stdout: result.stdout ?? "" };
239
- }
240
- };
241
- }
242
- function mcpUrlFor(apiBase, list = "every") {
243
- return mcpUrlWithToolList(`${apiBase.replace(/\/$/, "")}/mcp`, list);
244
- }
245
- function mcpCommands(agent, opts) {
246
- if (agent === "grok") {
247
- return {
248
- command: "grok",
249
- remove: ["mcp", "remove", MCP_SERVER_NAME],
250
- add: ["mcp", "add", "--scope", "user", "--transport", "http", "--header", `Authorization: Bearer ${opts.token}`, MCP_SERVER_NAME, opts.mcpUrl]
251
- };
252
- }
253
- return null;
254
- }
255
- var NO_TOOLS = "this sign-in gets no AgentSky tools (a workspace's own key has none); sign in as yourself with `sky auth login` and run setup again";
256
- function redact(text2, token) {
257
- return text2.split(token).join(`${token.slice(0, 10)}\u2026`);
258
- }
259
- function registerMcpServer(client, opts, runner = systemCommandRunner(), env = process.env, home = homedir2()) {
260
- if (client.id === "claude_code") return registerClaudeCode(client, opts, mcpConfigPath(client, env, home));
261
- if (client.id === "codex") return registerCodex(client, opts);
262
- if (client.id === "cursor") return registerCursor(client, opts);
263
- if (client.id === "hermes") return registerHermes(client, opts);
264
- if (client.id === "claude_app") return registerClaudeApp(client, opts);
265
- const commands = mcpCommands(client.id, opts);
266
- if (!commands) return { agent: client.id, outcome: "unsupported" };
267
- if (!runner.has(commands.command)) return { agent: client.id, outcome: "no_command", detail: `${commands.command} is not on PATH` };
268
- if (opts.dryRun) return { agent: client.id, outcome: "planned", detail: redact(`run ${[commands.command, ...commands.add].join(" ")}`, opts.token) };
269
- runner.run(commands.command, commands.remove);
270
- const added = runner.run(commands.command, commands.add);
271
- if (added.status !== 0) return { agent: client.id, outcome: "failed", detail: redact(added.stderr.trim() || `exit ${added.status}`, opts.token) };
272
- return { agent: client.id, outcome: "registered" };
273
- }
274
- function mcpConfigPath(client, env = process.env, home = homedir2()) {
275
- switch (client.id) {
276
- case "claude_code":
277
- return join2(env.CLAUDE_CONFIG_DIR || home, ".claude.json");
278
- case "codex":
279
- case "grok":
280
- return join2(client.root, "config.toml");
281
- case "cursor":
282
- return join2(client.root, "mcp.json");
283
- case "hermes":
284
- return join2(client.root, "config.yaml");
285
- case "claude_app":
286
- return join2(client.root, "claude_desktop_config.json");
287
- }
288
- }
289
- function readText(path) {
290
- try {
291
- return readFileSync(path, "utf8");
292
- } catch {
293
- return null;
294
- }
295
- }
296
- function registeredMcpUrl(client, env = process.env, home = homedir2()) {
297
- const raw = readText(mcpConfigPath(client, env, home));
298
- if (raw === null) return null;
299
- try {
300
- let entry;
301
- if (client.id === "codex" || client.id === "grok") entry = parseToml(raw).mcp_servers?.[MCP_SERVER_NAME];
302
- else if (client.id === "hermes") entry = parseDocument(raw).toJS()?.mcp_servers?.[MCP_SERVER_NAME];
303
- else entry = JSON.parse(raw).mcpServers?.[MCP_SERVER_NAME];
304
- const url = entry?.url;
305
- return typeof url === "string" ? url : null;
306
- } catch {
307
- return null;
308
- }
309
- }
310
- function registeredToolList(client, env = process.env, home = homedir2()) {
311
- const url = registeredMcpUrl(client, env, home);
312
- if (url === null) return "every";
313
- try {
314
- return mcpToolListOf(url) === "short" ? "short" : "every";
315
- } catch {
316
- return "every";
317
- }
318
- }
319
- function hasMcpServer(client, env = process.env, home = homedir2()) {
320
- const raw = readText(mcpConfigPath(client, env, home));
321
- if (raw === null) return false;
322
- try {
323
- if (client.id === "codex" || client.id === "grok") return Boolean(parseToml(raw).mcp_servers?.[MCP_SERVER_NAME]);
324
- if (client.id === "hermes") return parseDocument(raw).hasIn(["mcp_servers", MCP_SERVER_NAME]);
325
- return Boolean(JSON.parse(raw).mcpServers?.[MCP_SERVER_NAME]);
326
- } catch {
327
- return false;
328
- }
329
- }
330
- function planned(client, path, entry, opts) {
331
- return { agent: client.id, outcome: "planned", detail: `write to ${path}: ${redact(entry, opts.token)}` };
332
- }
333
- function written(client, path, text2) {
334
- try {
335
- writeFileSync(path, text2, { encoding: "utf8", mode: 384 });
336
- } catch (err) {
337
- return { agent: client.id, outcome: "failed", detail: String(err) };
338
- }
339
- return { agent: client.id, outcome: "registered" };
340
- }
341
- function tomlTableKey(name) {
342
- const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
343
- return `(?:${escaped}|"${escaped}"|'${escaped}')`;
344
- }
345
- function withoutTomlServer(text2, name) {
346
- return withTomlServer(text2, name, null);
347
- }
348
- function withTomlServer(text2, name, block) {
349
- const ours = new RegExp(`^\\s*\\[\\s*mcp_servers\\s*\\.\\s*${tomlTableKey(name)}\\s*(?:\\.[^\\]]*)?\\]\\s*(?:#.*)?$`);
350
- let skipping = false;
351
- let placed = false;
352
- const kept = [];
353
- for (const line of text2.split(/\r?\n/)) {
354
- if (/^\s*\[/.test(line)) {
355
- const was = skipping;
356
- skipping = ours.test(line);
357
- if (was && !skipping && block !== null) kept.push("");
358
- }
359
- if (skipping && !placed && block !== null) {
360
- kept.push(block);
361
- placed = true;
362
- }
363
- if (!skipping) kept.push(line);
364
- }
365
- const rest = kept.join("\n").replace(/\n+$/, "");
366
- if (block === null || placed) return rest;
367
- return rest ? `${rest}
368
-
369
- ${block}` : block;
370
- }
371
- function registerCodex(client, opts) {
372
- const path = mcpConfigPath(client);
373
- const block = [
374
- `[mcp_servers.${MCP_SERVER_NAME}]`,
375
- `url = ${JSON.stringify(opts.mcpUrl)}`,
376
- `http_headers = { Authorization = ${JSON.stringify(`Bearer ${opts.token}`)} }`
377
- ].join("\n");
378
- if (opts.dryRun) return planned(client, path, block, opts);
379
- const raw = readText(path) ?? "";
380
- let before;
381
- try {
382
- before = parseToml(raw);
383
- } catch (err) {
384
- return { agent: client.id, outcome: "failed", detail: `${path} is not valid TOML, left as it was (${String(err).split("\n")[0]})` };
385
- }
386
- const text2 = `${withTomlServer(raw, MCP_SERVER_NAME, block)}
387
- `;
388
- if (text2 === raw) return { agent: client.id, outcome: "registered", detail: "already registered" };
389
- try {
390
- const after = parseToml(text2);
391
- const others = Object.keys(before.mcp_servers ?? {}).filter((name) => name !== MCP_SERVER_NAME);
392
- if (after.mcp_servers?.[MCP_SERVER_NAME]?.url !== opts.mcpUrl || others.some((name) => !after.mcp_servers?.[name])) throw new Error("the edited file lost an entry");
393
- } catch (err) {
394
- return { agent: client.id, outcome: "failed", detail: `could not edit ${path} safely, left as it was (${String(err).split("\n")[0]})` };
395
- }
396
- return written(client, path, text2);
397
- }
398
- function registerClaudeCode(client, opts, path) {
399
- const entry = { type: "http", url: opts.mcpUrl, headers: { Authorization: `Bearer ${opts.token}` } };
400
- if (opts.dryRun) return planned(client, path, JSON.stringify({ [MCP_SERVER_NAME]: entry }, null, 2), opts);
401
- const raw = readText(path);
402
- let existing = {};
403
- if (raw !== null && raw.trim()) {
404
- try {
405
- const parsed = JSON.parse(raw);
406
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error("not an object");
407
- existing = parsed;
408
- } catch (err) {
409
- return { agent: client.id, outcome: "failed", detail: `${path} is not valid JSON, left as it was (${String(err).split("\n")[0]})` };
410
- }
411
- }
412
- if (JSON.stringify(existing.mcpServers?.[MCP_SERVER_NAME]) === JSON.stringify(entry)) return { agent: client.id, outcome: "registered", detail: "already registered" };
413
- const indent = raw ? /^[{[]\r?\n([ \t]+)/.exec(raw)?.[1] ?? 2 : 2;
414
- const ending = raw === null || raw.endsWith("\n") ? "\n" : "";
415
- const updated = { ...existing, mcpServers: { ...existing.mcpServers ?? {}, [MCP_SERVER_NAME]: entry } };
416
- return written(client, path, `${JSON.stringify(updated, null, indent)}${ending}`);
417
- }
418
- function registerCursor(client, opts) {
419
- const path = mcpConfigPath(client);
420
- const entry = { url: opts.mcpUrl, headers: { Authorization: `Bearer ${opts.token}` } };
421
- if (opts.dryRun) return planned(client, path, JSON.stringify({ [MCP_SERVER_NAME]: entry }, null, 2), opts);
422
- let existing = {};
423
- try {
424
- const parsed = JSON.parse(readText(path) ?? "");
425
- if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) existing = parsed;
426
- } catch {
427
- existing = {};
428
- }
429
- const updated = { ...existing, mcpServers: { ...existing.mcpServers ?? {}, [MCP_SERVER_NAME]: entry } };
430
- return written(client, path, `${JSON.stringify(updated, null, 2)}
431
- `);
432
- }
433
- function registerClaudeApp(client, opts) {
434
- if (!opts.sky?.length) return { agent: client.id, outcome: "unsupported", detail: "no sky command to start" };
435
- const path = mcpConfigPath(client);
436
- const [command, ...args] = opts.sky;
437
- const entry = { command, args: [...args, "mcp", "serve"] };
438
- if (opts.dryRun) return planned(client, path, JSON.stringify({ [MCP_SERVER_NAME]: entry }, null, 2), opts);
439
- let existing = {};
440
- const raw = readText(path);
441
- if (raw !== null && raw.trim()) {
442
- try {
443
- const parsed = JSON.parse(raw);
444
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error("not an object");
445
- existing = parsed;
446
- } catch (err) {
447
- return { agent: client.id, outcome: "failed", detail: `${path} is not valid JSON, left as it was (${String(err).split("\n")[0]})` };
448
- }
449
- }
450
- const current = existing.mcpServers?.[MCP_SERVER_NAME];
451
- if (JSON.stringify(current) === JSON.stringify(entry)) return { agent: client.id, outcome: "registered", detail: "already registered" };
452
- const updated = { ...existing, mcpServers: { ...existing.mcpServers ?? {}, [MCP_SERVER_NAME]: entry } };
453
- return written(client, path, `${JSON.stringify(updated, null, 2)}
454
- `);
455
- }
456
- function registerHermes(client, opts) {
457
- const path = mcpConfigPath(client);
458
- const entry = { url: opts.mcpUrl, headers: { Authorization: `Bearer ${opts.token}` } };
459
- if (opts.dryRun) return planned(client, path, `mcp_servers.${MCP_SERVER_NAME}: ${JSON.stringify(entry)}`, opts);
460
- const doc = parseDocument(readText(path) ?? "");
461
- if (doc.errors.length) return { agent: client.id, outcome: "failed", detail: `${path} is not valid YAML, left as it was (${doc.errors[0].message.split("\n")[0]})` };
462
- if (doc.contents !== null && !isMap(doc.contents)) {
463
- return { agent: client.id, outcome: "failed", detail: `${path} is not a YAML mapping, left as it was` };
464
- }
465
- doc.setIn(["mcp_servers", MCP_SERVER_NAME], doc.createNode(entry));
466
- return written(client, path, doc.toString());
467
- }
468
- async function refreshMcpRegistrations(opts, clients = detectMcpClients(), runner = systemCommandRunner(), env = process.env, home = homedir2()) {
469
- const registrations = [];
470
- for (const client of clients.filter((candidate) => candidate.id !== "claude_app" && hasMcpServer(candidate, env, home))) {
471
- let token;
472
- try {
473
- token = await opts.token(client);
474
- } catch (error) {
475
- registrations.push({ agent: client.id, outcome: "failed", detail: `no key of its own could be made (${(error instanceof Error ? error.message : String(error)).split("\n")[0]})` });
476
- continue;
477
- }
478
- registrations.push(registerMcpServer(client, { token, mcpUrl: mcpUrlFor(opts.apiBase, registeredToolList(client, env, home)) }, runner, env, home));
479
- }
480
- return registrations;
481
- }
482
-
483
165
  // src/settings-block.ts
484
- import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
485
- import { homedir as homedir3 } from "os";
486
- import { dirname, join as join3 } from "path";
166
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
167
+ import { homedir } from "os";
168
+ import { dirname, join } from "path";
487
169
 
488
170
  // ../../packages/uikit-components/src/rules-model.ts
489
171
  var ACTIONS = { deny: "block", ask: "ask first", allow: "allow", block: "block", require_approval: "ask first", model_review: "ask only when a model is unsure", notify: "notify a webhook" };
@@ -591,14 +273,14 @@ var BLOCK_BEGIN = "<!-- agentsky:begin (managed by AgentSky; edit in Settings, n
591
273
  var BLOCK_END = "<!-- agentsky:end -->";
592
274
  var BLOCK_MAX_BYTES = 16 * 1024;
593
275
  var BLOCK = /\n?<!-- agentsky:begin[^\n]*-->\n[\s\S]*?\n<!-- agentsky:end -->\n?/;
594
- function instructionFiles(env = process.env, home = homedir3()) {
276
+ function instructionFiles(env = process.env, home = homedir()) {
595
277
  const files = [];
596
278
  for (const agent of detectLocalAgents(env, home)) {
597
- if (agent.id === "claude_code") files.push({ engine: agent.id, name: agent.name, path: join3(agent.root, "CLAUDE.md") });
598
- if (agent.id === "codex" || agent.id === "cursor") files.push({ engine: agent.id, name: agent.name, path: join3(agent.root, "AGENTS.md") });
279
+ if (agent.id === "claude_code") files.push({ engine: agent.id, name: agent.name, path: join(agent.root, "CLAUDE.md") });
280
+ if (agent.id === "codex" || agent.id === "cursor") files.push({ engine: agent.id, name: agent.name, path: join(agent.root, "AGENTS.md") });
599
281
  }
600
282
  const hermes = detectHermes(env, home);
601
- if (hermes) files.push({ engine: "hermes", name: hermes.name, path: join3(hermes.root, "SOUL.md") });
283
+ if (hermes) files.push({ engine: "hermes", name: hermes.name, path: join(hermes.root, "SOUL.md") });
602
284
  return files;
603
285
  }
604
286
  function withoutSettingsBlock(text2) {
@@ -666,11 +348,11 @@ async function readWorkspaceSettings(workspace) {
666
348
  return { workspace, files, rules: said, plugins };
667
349
  }
668
350
  function settingsCachePath() {
669
- return join3(dirname(configPath()), "settings-block.md");
351
+ return join(dirname(configPath()), "settings-block.md");
670
352
  }
671
353
  function cachedSettingsBlock() {
672
354
  try {
673
- return readFileSync2(settingsCachePath(), "utf8");
355
+ return readFileSync(settingsCachePath(), "utf8");
674
356
  } catch {
675
357
  return null;
676
358
  }
@@ -680,7 +362,7 @@ function writeSettingsBlocks(block, opts) {
680
362
  for (const file of opts.files ?? instructionFiles()) {
681
363
  let text2 = "";
682
364
  try {
683
- text2 = readFileSync2(file.path, "utf8");
365
+ text2 = readFileSync(file.path, "utf8");
684
366
  } catch {
685
367
  text2 = "";
686
368
  }
@@ -695,7 +377,7 @@ function writeSettingsBlocks(block, opts) {
695
377
  try {
696
378
  opts.journal.track(file.path, ["settings_block"]);
697
379
  mkdirSync(dirname(file.path), { recursive: true });
698
- writeFileSync2(file.path, withSettingsBlock(text2, block));
380
+ writeFileSync(file.path, withSettingsBlock(text2, block));
699
381
  outcomes.push({ engine: file.engine, path: file.path, outcome: "written" });
700
382
  } catch (error) {
701
383
  outcomes.push({ engine: file.engine, path: file.path, outcome: "failed", detail: error instanceof Error ? error.message : String(error) });
@@ -703,16 +385,16 @@ function writeSettingsBlocks(block, opts) {
703
385
  }
704
386
  if (!opts.dryRun && cachedSettingsBlock() !== block) {
705
387
  const cache = settingsCachePath();
706
- if (!existsSync3(cache)) opts.journal.own(cache);
388
+ if (!existsSync(cache)) opts.journal.own(cache);
707
389
  mkdirSync(dirname(cache), { recursive: true });
708
- writeFileSync2(cache, block, { mode: 384 });
390
+ writeFileSync(cache, block, { mode: 384 });
709
391
  }
710
392
  return outcomes;
711
393
  }
712
394
  function settingsBlockState(block, file) {
713
395
  let text2 = "";
714
396
  try {
715
- text2 = readFileSync2(file.path, "utf8");
397
+ text2 = readFileSync(file.path, "utf8");
716
398
  } catch {
717
399
  return "missing";
718
400
  }
@@ -722,8 +404,6 @@ function settingsBlockState(block, file) {
722
404
  }
723
405
 
724
406
  export {
725
- detectLocalAgents,
726
- selectLocalAgents,
727
407
  workspaceSlug,
728
408
  listMembers,
729
409
  invite,
@@ -742,19 +422,6 @@ export {
742
422
  renderDeletionPreview,
743
423
  deleteWorkspace,
744
424
  typedConfirmation,
745
- MCP_SERVER_NAME,
746
- detectHermes,
747
- detectClaudeApp,
748
- detectMcpClients,
749
- systemCommandRunner,
750
- mcpUrlFor,
751
- NO_TOOLS,
752
- registerMcpServer,
753
- mcpConfigPath,
754
- registeredToolList,
755
- hasMcpServer,
756
- withoutTomlServer,
757
- refreshMcpRegistrations,
758
425
  instructionFiles,
759
426
  withoutSettingsBlock,
760
427
  renderSettingsBlock,
@@ -1,20 +1,22 @@
1
1
  import {
2
2
  cachedSettingsBlock,
3
- mcpUrlFor,
4
3
  workspaceSlug
5
- } from "./chunk-V4NPUQM2.js";
4
+ } from "./chunk-A45NGV2Q.js";
6
5
  import {
7
6
  api
8
- } from "./chunk-NENCXIQO.js";
7
+ } from "./chunk-NAIYHS6Q.js";
9
8
  import {
10
- USER_AGENT
11
- } from "./chunk-JSW6RJM4.js";
9
+ mcpUrlFor
10
+ } from "./chunk-RKMMLSGJ.js";
12
11
  import {
13
12
  apiBase,
14
13
  apiToken,
15
14
  configPath,
16
15
  loadConfig
17
16
  } from "./chunk-XHZJG3QT.js";
17
+ import {
18
+ USER_AGENT
19
+ } from "./chunk-ZRV3UUW5.js";
18
20
 
19
21
  // src/mcp-serve.ts
20
22
  import { createInterface } from "readline";
@@ -1,9 +1,9 @@
1
- import {
2
- USER_AGENT
3
- } from "./chunk-JSW6RJM4.js";
4
1
  import {
5
2
  configPath
6
3
  } from "./chunk-XHZJG3QT.js";
4
+ import {
5
+ USER_AGENT
6
+ } from "./chunk-ZRV3UUW5.js";
7
7
  import {
8
8
  TRACE_CONTENT_SCOPES,
9
9
  redactTraceText
@@ -1,11 +1,11 @@
1
- import {
2
- USER_AGENT
3
- } from "./chunk-JSW6RJM4.js";
4
1
  import {
5
2
  apiBase,
6
3
  apiToken,
7
4
  currentUniverse
8
5
  } from "./chunk-XHZJG3QT.js";
6
+ import {
7
+ USER_AGENT
8
+ } from "./chunk-ZRV3UUW5.js";
9
9
 
10
10
  // src/api.ts
11
11
  import { createWriteStream, writeFileSync } from "fs";
@@ -1,22 +1,22 @@
1
1
  import {
2
2
  ApiError,
3
3
  api
4
- } from "./chunk-NENCXIQO.js";
4
+ } from "./chunk-NAIYHS6Q.js";
5
5
  import {
6
6
  installClaudeHooks
7
- } from "./chunk-ENG7YVFA.js";
7
+ } from "./chunk-FVIPGI3E.js";
8
8
  import {
9
9
  loadLocalSkillState,
10
10
  revisionAt
11
- } from "./chunk-4RUMYOAH.js";
12
- import {
13
- USER_AGENT
14
- } from "./chunk-JSW6RJM4.js";
11
+ } from "./chunk-ZF2P6PKM.js";
15
12
  import {
16
13
  apiBase,
17
14
  apiToken,
18
15
  configPath
19
16
  } from "./chunk-XHZJG3QT.js";
17
+ import {
18
+ USER_AGENT
19
+ } from "./chunk-ZRV3UUW5.js";
20
20
  import {
21
21
  IncompleteSourceCaptureError,
22
22
  SOURCE_CAPTURE_VERSION,
@@ -1774,7 +1774,7 @@ async function runSync(config, options) {
1774
1774
  savePendingSource(item, { previewSaved: true, link: saved.linked_task ?? null });
1775
1775
  const link = item.manifest.link;
1776
1776
  const linkKey = createHash3("sha256").update(JSON.stringify(link ?? null)).digest("hex").slice(0, 16);
1777
- await libraryRequest("POST", "/events", workspace, { events: [{
1777
+ const sourceLinked = await libraryRequest("POST", "/events", workspace, { events: [{
1778
1778
  idempotency_key: `trace-source:${source.sha256}:${linkKey}`,
1779
1779
  ...link ? { session_id: link.session_id, task_id: link.task_id } : {},
1780
1780
  log: "workspace",
@@ -1795,7 +1795,11 @@ async function runSync(config, options) {
1795
1795
  library_is_preview: true
1796
1796
  },
1797
1797
  bodies: [{ role: "transcript", media_type: "application/x-ndjson", file_id: item.manifest.fileId, complete: source.complete }]
1798
- }] });
1798
+ }] }).then(() => true, (error) => {
1799
+ if (error instanceof ApiError && error.status === 403 && error.code === "restricted_token") return false;
1800
+ throw error;
1801
+ });
1802
+ if (!sourceLinked) options.onProgress?.(`${key(local)}: kept in the trace library; this key cannot record its source archive`);
1799
1803
  record(local, { workspace, sha256: source.sha256, status: source.complete ? "stored" : "stored_with_gaps" });
1800
1804
  writePrivateJson(statePath2(), state);
1801
1805
  removePendingSource(item);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CLI_VERSION
3
- } from "./chunk-JSW6RJM4.js";
3
+ } from "./chunk-ZRV3UUW5.js";
4
4
 
5
5
  // src/skill.ts
6
6
  import { mkdirSync, readFileSync, writeFileSync } from "fs";