@agentsky/sky 3.48.1 → 3.49.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/dist/chunk-2H4W5ZKZ.js +34 -0
- package/dist/{chunk-W24YSGH4.js → chunk-2YUZZ5VG.js} +7 -856
- package/dist/{chunk-E7HNEQ7F.js → chunk-6LRSRXQI.js} +1 -1
- package/dist/{chunk-TIP2XS2L.js → chunk-7JFTEJ7B.js} +1 -1
- package/dist/chunk-BKNZQZZD.js +857 -0
- package/dist/chunk-CK7N635F.js +317 -0
- package/dist/{chunk-KHJRD4DR.js → chunk-HFWHVU72.js} +4 -3
- package/dist/{chunk-RVDXKUWH.js → chunk-HGL7TLNA.js} +20 -353
- package/dist/{chunk-X4DBI7R7.js → chunk-HNUY5PBQ.js} +62 -8
- package/dist/{chunk-OJ5ERABF.js → chunk-IO2N34S2.js} +1 -1
- package/dist/{chunk-LVHQILKX.js → chunk-JMGVHVOS.js} +27 -23
- package/dist/{chunk-H7KHMRUZ.js → chunk-QTE5OMZY.js} +7 -5
- package/dist/{chunk-NDVCYVW5.js → chunk-RVI7ZWR2.js} +5 -5
- package/dist/chunk-TGU7T4O7.js +1363 -0
- package/dist/{chunk-46I7RCQQ.js → chunk-UYBKORXA.js} +43 -24
- package/dist/chunk-YO2XUCCF.js +30 -0
- package/dist/{chunk-GDZSCISF.js → chunk-ZOXE2XNH.js} +4 -2
- package/dist/{compute-TCUMLDEK.js → compute-4MMGFJGE.js} +2 -2
- package/dist/compute-report-LIMMRQY3.js +43 -0
- package/dist/grok-bot-export-7LSTXWJW.js +57 -0
- package/dist/index.js +634 -1791
- package/dist/local-agents-O7PYSQGR.js +11 -0
- package/dist/{local-skills-EIUQL24E.js → local-skills-5LJST7EP.js} +9 -3
- package/dist/{local-skills-run-FSVTDDOW.js → local-skills-run-6SZJQSVF.js} +16 -10
- package/dist/mcp-register-XY4MR3ZZ.js +40 -0
- package/dist/mcp-serve-QROKKUJV.js +18 -0
- package/dist/{trace-GFC46TQC.js → trace-SJZ25T35.js} +4 -3
- package/dist/{trace-exclusions-JEGMUPWQ.js → trace-exclusions-IC6OA2ND.js} +3 -2
- package/dist/trace-handoff-CD5LOS7B.js +116 -0
- package/dist/{trace-library-4F57EGL7.js → trace-library-V23TEXG4.js} +14 -8
- package/dist/trace-privacy-DU3TL5EO.js +11 -0
- package/package.json +1 -1
- package/vendor/trace-collect/SOURCE.json +2 -1
- package/vendor/trace-collect/sources/_pii.mjs +56 -0
- package/vendor/trace-collect/sources/grok-bot.mjs +180 -0
- package/vendor/trace-collect/sources/index.mjs +4 -2
- package/vendor/trace-collect/sources/muse-agent.mjs +95 -0
- package/dist/compute-report-LC2OH2QJ.js +0 -39
- package/dist/mcp-serve-NQJZL7YP.js +0 -16
|
@@ -1,44 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ApiError,
|
|
3
3
|
api
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-HFWHVU72.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
} from "./chunk-
|
|
6
|
+
detectHermes
|
|
7
|
+
} from "./chunk-CK7N635F.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
|
|
485
|
-
import { homedir
|
|
486
|
-
import { dirname, join
|
|
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 =
|
|
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:
|
|
598
|
-
if (agent.id === "codex" || agent.id === "cursor") files.push({ engine: agent.id, name: agent.name, path:
|
|
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:
|
|
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
|
|
351
|
+
return join(dirname(configPath()), "settings-block.md");
|
|
670
352
|
}
|
|
671
353
|
function cachedSettingsBlock() {
|
|
672
354
|
try {
|
|
673
|
-
return
|
|
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 =
|
|
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
|
-
|
|
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 (!
|
|
388
|
+
if (!existsSync(cache)) opts.journal.own(cache);
|
|
707
389
|
mkdirSync(dirname(cache), { recursive: true });
|
|
708
|
-
|
|
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 =
|
|
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,17 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SKILL_MARKER,
|
|
3
3
|
SKILL_NAME
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import {
|
|
6
|
-
CLI_VERSION
|
|
7
|
-
} from "./chunk-E7HNEQ7F.js";
|
|
4
|
+
} from "./chunk-7JFTEJ7B.js";
|
|
8
5
|
import {
|
|
9
6
|
configPath
|
|
10
7
|
} from "./chunk-XHZJG3QT.js";
|
|
8
|
+
import {
|
|
9
|
+
CLI_VERSION
|
|
10
|
+
} from "./chunk-6LRSRXQI.js";
|
|
11
11
|
|
|
12
12
|
// src/local-skills.ts
|
|
13
|
-
import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "fs";
|
|
13
|
+
import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from "fs";
|
|
14
|
+
import { homedir } from "os";
|
|
14
15
|
import { dirname, join, resolve, sep } from "path";
|
|
16
|
+
import { parse as parseYaml } from "yaml";
|
|
15
17
|
var HISTORY = 20;
|
|
16
18
|
var SAFE_NAME = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
17
19
|
function localSkillStatePath() {
|
|
@@ -20,7 +22,7 @@ function localSkillStatePath() {
|
|
|
20
22
|
function loadLocalSkillState(path = localSkillStatePath()) {
|
|
21
23
|
try {
|
|
22
24
|
const parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
23
|
-
return { version: 1, workspace: parsed.workspace, checkedAt: parsed.checkedAt, pins: parsed.pins ?? {}, skills: parsed.skills ?? {} };
|
|
25
|
+
return { version: 1, workspace: parsed.workspace, checkedAt: parsed.checkedAt, ...parsed.off ? { off: true } : {}, pins: parsed.pins ?? {}, skills: parsed.skills ?? {} };
|
|
24
26
|
} catch {
|
|
25
27
|
return { version: 1, pins: {}, skills: {} };
|
|
26
28
|
}
|
|
@@ -74,6 +76,7 @@ async function syncLocalSkills(opts) {
|
|
|
74
76
|
const now = (opts.now ?? (() => /* @__PURE__ */ new Date()))().toISOString();
|
|
75
77
|
const statePath = opts.statePath ?? localSkillStatePath();
|
|
76
78
|
const state = loadLocalSkillState(statePath);
|
|
79
|
+
if (state.off) return { workspace: opts.workspace, checked: false, skills: [], off: true };
|
|
77
80
|
const before = JSON.stringify({ pins: state.pins, skills: state.skills });
|
|
78
81
|
const have = installedFingerprints(state, opts.targets);
|
|
79
82
|
const answer = await opts.request("GET", `/skills/local${have.length ? `?have=${encodeURIComponent(have.join(","))}` : ""}`, opts.workspace);
|
|
@@ -163,12 +166,60 @@ function unpinLocalSkill(name, statePath) {
|
|
|
163
166
|
saveLocalSkillState(state, statePath);
|
|
164
167
|
return true;
|
|
165
168
|
}
|
|
169
|
+
function turnOffLocalSkills(targets, statePath) {
|
|
170
|
+
const state = loadLocalSkillState(statePath);
|
|
171
|
+
const names = Object.keys(state.skills).sort();
|
|
172
|
+
for (const name of names) {
|
|
173
|
+
for (const target of targets) {
|
|
174
|
+
const dir = join(target.skillsDir, name);
|
|
175
|
+
if (deliveredHere(dir)) rmSync(dir, { recursive: true, force: true });
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
saveLocalSkillState({ version: 1, workspace: state.workspace, checkedAt: state.checkedAt, off: true, pins: {}, skills: {} }, statePath);
|
|
179
|
+
return names;
|
|
180
|
+
}
|
|
181
|
+
function turnOnLocalSkills(statePath) {
|
|
182
|
+
const state = loadLocalSkillState(statePath);
|
|
183
|
+
if (!state.off) return false;
|
|
184
|
+
const { off: _off, ...rest } = state;
|
|
185
|
+
saveLocalSkillState(rest, statePath);
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
166
188
|
function checkedWithin(ms, now = /* @__PURE__ */ new Date(), statePath) {
|
|
167
189
|
const at = Date.parse(loadLocalSkillState(statePath).checkedAt ?? "");
|
|
168
190
|
return Number.isFinite(at) && now.getTime() - at < ms;
|
|
169
191
|
}
|
|
170
|
-
|
|
171
|
-
|
|
192
|
+
var realDir = (dir) => {
|
|
193
|
+
try {
|
|
194
|
+
return realpathSync(dir);
|
|
195
|
+
} catch {
|
|
196
|
+
return resolve(dir);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
function hermesExternalSkillDirs(hermesRoot, home = homedir()) {
|
|
200
|
+
try {
|
|
201
|
+
const config = parseYaml(readFileSync(join(hermesRoot, "config.yaml"), "utf8"));
|
|
202
|
+
const dirs = config?.skills?.external_dirs;
|
|
203
|
+
if (!Array.isArray(dirs)) return [];
|
|
204
|
+
return dirs.filter((dir) => typeof dir === "string" && dir.length > 0).map((dir) => dir === "~" ? home : dir.startsWith("~/") ? join(home, dir.slice(2)) : resolve(hermesRoot, dir));
|
|
205
|
+
} catch {
|
|
206
|
+
return [];
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function skillTargets(agents, hermesRoot, home = homedir(), opts = {}) {
|
|
210
|
+
const seen = /* @__PURE__ */ new Set();
|
|
211
|
+
const targets = [];
|
|
212
|
+
for (const agent of agents) {
|
|
213
|
+
const real = realDir(agent.skillsDir);
|
|
214
|
+
if (seen.has(real)) continue;
|
|
215
|
+
seen.add(real);
|
|
216
|
+
targets.push({ id: agent.id, skillsDir: agent.skillsDir });
|
|
217
|
+
}
|
|
218
|
+
if (!hermesRoot) return targets;
|
|
219
|
+
const hermesDir = join(hermesRoot, "skills");
|
|
220
|
+
if (seen.has(realDir(hermesDir))) return targets;
|
|
221
|
+
if (!opts.all && hermesExternalSkillDirs(hermesRoot, home).some((dir) => seen.has(realDir(dir)))) return targets;
|
|
222
|
+
return [...targets, { id: "hermes", skillsDir: hermesDir }];
|
|
172
223
|
}
|
|
173
224
|
function revisionAt(state, name, at) {
|
|
174
225
|
const installs = state.skills[name]?.installs ?? [];
|
|
@@ -187,7 +238,10 @@ export {
|
|
|
187
238
|
syncLocalSkills,
|
|
188
239
|
pinLocalSkill,
|
|
189
240
|
unpinLocalSkill,
|
|
241
|
+
turnOffLocalSkills,
|
|
242
|
+
turnOnLocalSkills,
|
|
190
243
|
checkedWithin,
|
|
244
|
+
hermesExternalSkillDirs,
|
|
191
245
|
skillTargets,
|
|
192
246
|
revisionAt
|
|
193
247
|
};
|
|
@@ -1,50 +1,54 @@
|
|
|
1
|
+
import {
|
|
2
|
+
lastUploads,
|
|
3
|
+
loadSyncConfig
|
|
4
|
+
} from "./chunk-UYBKORXA.js";
|
|
1
5
|
import {
|
|
2
6
|
CAPTURE_HOOK_ARGS,
|
|
3
7
|
SetupJournal,
|
|
4
8
|
isCaptureCommand
|
|
5
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ZOXE2XNH.js";
|
|
6
10
|
import {
|
|
7
11
|
localAgentKey,
|
|
8
12
|
shortToolCount
|
|
9
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-QTE5OMZY.js";
|
|
10
14
|
import {
|
|
11
15
|
cachedSettingsBlock,
|
|
12
|
-
detectClaudeApp,
|
|
13
|
-
detectHermes,
|
|
14
|
-
detectLocalAgents,
|
|
15
|
-
hasMcpServer,
|
|
16
16
|
instructionFiles,
|
|
17
|
-
mcpConfigPath,
|
|
18
|
-
mcpUrlFor,
|
|
19
17
|
readWorkspaceSettings,
|
|
20
|
-
registerMcpServer,
|
|
21
|
-
registeredToolList,
|
|
22
18
|
renderSettingsBlock,
|
|
23
19
|
settingsBlockState,
|
|
24
|
-
systemCommandRunner,
|
|
25
20
|
workspaceSlug,
|
|
26
21
|
writeSettingsBlocks
|
|
27
|
-
} from "./chunk-
|
|
28
|
-
import {
|
|
29
|
-
lastUploads,
|
|
30
|
-
loadSyncConfig
|
|
31
|
-
} from "./chunk-46I7RCQQ.js";
|
|
22
|
+
} from "./chunk-HGL7TLNA.js";
|
|
32
23
|
import {
|
|
33
24
|
ApiError,
|
|
34
25
|
api
|
|
35
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-HFWHVU72.js";
|
|
27
|
+
import {
|
|
28
|
+
detectClaudeApp,
|
|
29
|
+
detectHermes,
|
|
30
|
+
hasMcpServer,
|
|
31
|
+
mcpConfigPath,
|
|
32
|
+
mcpUrlFor,
|
|
33
|
+
registerMcpServer,
|
|
34
|
+
registeredToolList,
|
|
35
|
+
systemCommandRunner
|
|
36
|
+
} from "./chunk-CK7N635F.js";
|
|
37
|
+
import {
|
|
38
|
+
detectLocalAgents
|
|
39
|
+
} from "./chunk-2H4W5ZKZ.js";
|
|
36
40
|
import {
|
|
37
41
|
installSkill,
|
|
38
42
|
skillState
|
|
39
|
-
} from "./chunk-
|
|
40
|
-
import {
|
|
41
|
-
CLI_VERSION
|
|
42
|
-
} from "./chunk-E7HNEQ7F.js";
|
|
43
|
+
} from "./chunk-7JFTEJ7B.js";
|
|
43
44
|
import {
|
|
44
45
|
apiBase,
|
|
45
46
|
apiToken,
|
|
46
47
|
configPath
|
|
47
48
|
} from "./chunk-XHZJG3QT.js";
|
|
49
|
+
import {
|
|
50
|
+
CLI_VERSION
|
|
51
|
+
} from "./chunk-6LRSRXQI.js";
|
|
48
52
|
|
|
49
53
|
// src/compute-report.ts
|
|
50
54
|
import { randomBytes } from "crypto";
|
|
@@ -1919,7 +1923,7 @@ ${raw}` : `${line}
|
|
|
1919
1923
|
return { trigger: "codex_notify", outcome: "installed", path };
|
|
1920
1924
|
}
|
|
1921
1925
|
async function installSchedule(opts) {
|
|
1922
|
-
const lib = await import("./trace-library-
|
|
1926
|
+
const lib = await import("./trace-library-V23TEXG4.js");
|
|
1923
1927
|
if ((opts.platform ?? process.platform) !== "darwin") {
|
|
1924
1928
|
return { trigger: "schedule", outcome: "skipped", detail: "the 15-minute sweep is macOS only; on Linux add `*/15 * * * * sky trace sync --quiet` to your crontab. The hooks still capture each session" };
|
|
1925
1929
|
}
|
|
@@ -1942,7 +1946,7 @@ async function installSchedule(opts) {
|
|
|
1942
1946
|
return { trigger: "schedule", outcome: "installed", path };
|
|
1943
1947
|
}
|
|
1944
1948
|
async function installCapture(opts) {
|
|
1945
|
-
const lib = await import("./trace-library-
|
|
1949
|
+
const lib = await import("./trace-library-V23TEXG4.js");
|
|
1946
1950
|
const config = lib.loadSyncConfig();
|
|
1947
1951
|
if (!config.enabled && config.enabledAt) return { sync: "off", triggers: [] };
|
|
1948
1952
|
const configFile = lib.syncConfigPath();
|