@agentsky/sky 3.47.0 → 3.47.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/agent-plugins/plugins/meetings/.codex-plugin/plugin.json +1 -1
  2. package/agent-plugins/plugins/meetings/skills/agentsky-meetings/SKILL.md +1 -1
  3. package/dist/{chunk-2OIW436E.js → chunk-BIWRJ65N.js} +1 -1
  4. package/dist/{chunk-QTMW37EN.js → chunk-C3RW65GZ.js} +2 -2
  5. package/dist/{chunk-LM3WPNRW.js → chunk-DAVMU66H.js} +1 -1
  6. package/dist/{chunk-I63VASQP.js → chunk-FDR6JOIJ.js} +19 -12
  7. package/dist/{chunk-IJOMMFEK.js → chunk-IZCS7FH3.js} +2 -2
  8. package/dist/{chunk-OXCZMLEZ.js → chunk-LMYRAGDR.js} +1 -1
  9. package/dist/chunk-MSEGJ7V5.js +214 -0
  10. package/dist/{chunk-YYI5NQ35.js → chunk-OJ5ERABF.js} +1 -1
  11. package/dist/{chunk-6LQLH5CI.js → chunk-SJIBWHJU.js} +185 -5
  12. package/dist/{chunk-KX6JJECK.js → chunk-W24YSGH4.js} +255 -79
  13. package/dist/{chunk-U25SCHLE.js → chunk-Y7JBA7AC.js} +6 -6
  14. package/dist/{chunk-IZT53CAI.js → chunk-YUZWSDVE.js} +3 -175
  15. package/dist/{compute-VNGFIQCD.js → compute-FAXL7DAK.js} +2 -2
  16. package/dist/{compute-report-AAEKLNPM.js → compute-report-XQJSIK6B.js} +12 -12
  17. package/dist/index.js +458 -173
  18. package/dist/{local-skills-RRJCNVLS.js → local-skills-DRZH2R3Q.js} +3 -3
  19. package/dist/{local-skills-run-Y47FCKEL.js → local-skills-run-MH2TI2UC.js} +11 -11
  20. package/dist/{mcp-serve-OLHMHG4M.js → mcp-serve-JJD6JGYS.js} +5 -5
  21. package/dist/{trace-PXIY5WUU.js → trace-RMYKGACV.js} +3 -3
  22. package/dist/{trace-exclusions-HG5MF7NI.js → trace-exclusions-JEGMUPWQ.js} +2 -2
  23. package/dist/{trace-library-IUFJWBN3.js → trace-library-QLCECTIS.js} +8 -8
  24. package/package.json +2 -2
  25. package/dist/chunk-AKCKFNLJ.js +0 -116
@@ -10,7 +10,7 @@
10
10
  "interface": {
11
11
  "displayName": "Meetings",
12
12
  "shortDescription": "Notes for every call",
13
- "longDescription": "Meetings notices a call in WeChat, Tencent Meeting, Zoom, Lark, Feishu, Teams, Chrome or Safari, records both sides and transcribes it on your Mac. Each call becomes one note with a summary and action items, named from your Google or Outlook calendar or your Mac's own Calendar (where a Lark calendar can be synced) and shared with your workspace as a document, where the workspace's other plugins can pick it up. For meetings you take elsewhere, a recorder can join Zoom, Meet and Teams as “AgentSky Notetaker”. In Zoom it also records the call window, what you share and what you do in it, kept closed at the end of the note; in Lark and Feishu it records the meeting window, not yet what you share. Each recording is deleted from your Mac once its call is transcribed, unless you keep recordings for 30 days; notes are kept. The menu bar shows ● Notes while a call is recorded.",
13
+ "longDescription": "Meetings notices a call in WeChat, Tencent Meeting, Zoom, Lark, Feishu, Teams, a Slack huddle, Chrome or Safari, records both sides and transcribes it on your Mac. Each call becomes one note with a summary and action items, named from your Google or Outlook calendar or your Mac's own Calendar (where a Lark calendar can be synced) and shared with your workspace as a document, where the workspace's other plugins can pick it up. For meetings you take elsewhere, a recorder can join Zoom, Meet and Teams as “AgentSky Notetaker”. In Zoom it also records the call window, what you share and what you do in it, kept closed at the end of the note; in Lark and Feishu it records the meeting window, not yet what you share. Each recording is deleted from your Mac once its call is transcribed, unless you keep recordings for 30 days; notes are kept. The menu bar shows ● Notes while a call is recorded.",
14
14
  "developerName": "AgentSky",
15
15
  "category": "Meetings & calls",
16
16
  "capabilities": [],
@@ -5,7 +5,7 @@ description: "AI meeting notes for every call you take on your Mac, from WeChat
5
5
 
6
6
  # Meetings (AgentSky)
7
7
 
8
- Meetings notices a call in WeChat, Tencent Meeting, Zoom, Lark, Feishu, Teams, Chrome or Safari, records both sides and transcribes it on your Mac. Each call becomes one note with a summary and action items, named from your Google or Outlook calendar or your Mac's own Calendar (where a Lark calendar can be synced) and shared with your workspace as a document, where the workspace's other plugins can pick it up. For meetings you take elsewhere, a recorder can join Zoom, Meet and Teams as “AgentSky Notetaker”. In Zoom it also records the call window, what you share and what you do in it, kept closed at the end of the note; in Lark and Feishu it records the meeting window, not yet what you share. Each recording is deleted from your Mac once its call is transcribed, unless you keep recordings for 30 days; notes are kept. The menu bar shows ● Notes while a call is recorded.
8
+ Meetings notices a call in WeChat, Tencent Meeting, Zoom, Lark, Feishu, Teams, a Slack huddle, Chrome or Safari, records both sides and transcribes it on your Mac. Each call becomes one note with a summary and action items, named from your Google or Outlook calendar or your Mac's own Calendar (where a Lark calendar can be synced) and shared with your workspace as a document, where the workspace's other plugins can pick it up. For meetings you take elsewhere, a recorder can join Zoom, Meet and Teams as “AgentSky Notetaker”. In Zoom it also records the call window, what you share and what you do in it, kept closed at the end of the note; in Lark and Feishu it records the meeting window, not yet what you share. Each recording is deleted from your Mac once its call is transcribed, unless you keep recordings for 30 days; notes are kept. The menu bar shows ● Notes while a call is recorded.
9
9
 
10
10
  ## Use it
11
11
 
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var CLI_VERSION = "3.47.0";
2
+ var CLI_VERSION = "3.47.1";
3
3
  var USER_AGENT = `sky-cli/${CLI_VERSION} (${process.platform}; node/${process.versions.node})`;
4
4
 
5
5
  export {
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  SKILL_MARKER,
3
3
  SKILL_NAME
4
- } from "./chunk-OXCZMLEZ.js";
4
+ } from "./chunk-LMYRAGDR.js";
5
5
  import {
6
6
  CLI_VERSION
7
- } from "./chunk-2OIW436E.js";
7
+ } from "./chunk-BIWRJ65N.js";
8
8
  import {
9
9
  configPath
10
10
  } from "./chunk-XHZJG3QT.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  USER_AGENT
3
- } from "./chunk-2OIW436E.js";
3
+ } from "./chunk-BIWRJ65N.js";
4
4
  import {
5
5
  apiBase,
6
6
  apiToken,
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  CAPTURE_HOOK_ARGS,
3
3
  SetupJournal,
4
- isCaptureCommand,
5
- workspaceSlug
6
- } from "./chunk-IZT53CAI.js";
4
+ isCaptureCommand
5
+ } from "./chunk-YUZWSDVE.js";
7
6
  import {
7
+ localAgentKey,
8
8
  shortToolCount
9
- } from "./chunk-AKCKFNLJ.js";
9
+ } from "./chunk-MSEGJ7V5.js";
10
10
  import {
11
11
  cachedSettingsBlock,
12
12
  detectClaudeApp,
@@ -22,23 +22,24 @@ import {
22
22
  renderSettingsBlock,
23
23
  settingsBlockState,
24
24
  systemCommandRunner,
25
+ workspaceSlug,
25
26
  writeSettingsBlocks
26
- } from "./chunk-6LQLH5CI.js";
27
+ } from "./chunk-SJIBWHJU.js";
27
28
  import {
28
29
  lastUploads,
29
30
  loadSyncConfig
30
- } from "./chunk-U25SCHLE.js";
31
+ } from "./chunk-Y7JBA7AC.js";
31
32
  import {
32
33
  ApiError,
33
34
  api
34
- } from "./chunk-LM3WPNRW.js";
35
+ } from "./chunk-DAVMU66H.js";
35
36
  import {
36
37
  installSkill,
37
38
  skillState
38
- } from "./chunk-OXCZMLEZ.js";
39
+ } from "./chunk-LMYRAGDR.js";
39
40
  import {
40
41
  CLI_VERSION
41
- } from "./chunk-2OIW436E.js";
42
+ } from "./chunk-BIWRJ65N.js";
42
43
  import {
43
44
  apiBase,
44
45
  apiToken,
@@ -1918,7 +1919,7 @@ ${raw}` : `${line}
1918
1919
  return { trigger: "codex_notify", outcome: "installed", path };
1919
1920
  }
1920
1921
  async function installSchedule(opts) {
1921
- const lib = await import("./trace-library-IUFJWBN3.js");
1922
+ const lib = await import("./trace-library-QLCECTIS.js");
1922
1923
  if ((opts.platform ?? process.platform) !== "darwin") {
1923
1924
  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" };
1924
1925
  }
@@ -1941,7 +1942,7 @@ async function installSchedule(opts) {
1941
1942
  return { trigger: "schedule", outcome: "installed", path };
1942
1943
  }
1943
1944
  async function installCapture(opts) {
1944
- const lib = await import("./trace-library-IUFJWBN3.js");
1945
+ const lib = await import("./trace-library-QLCECTIS.js");
1945
1946
  const config = lib.loadSyncConfig();
1946
1947
  if (!config.enabled && config.enabledAt) return { sync: "off", triggers: [] };
1947
1948
  const configFile = lib.syncConfigPath();
@@ -2067,7 +2068,13 @@ async function repairComputer(opts) {
2067
2068
  const path = mcpConfigPath(client);
2068
2069
  const setUpBefore = opts.journal.tracks(path);
2069
2070
  opts.journal.track(path, [MCP_ENTRY[client.id]]);
2070
- const registered = registerMcpServer(client, { token, mcpUrl: mcpUrlFor(apiBase(), "short"), sky: opts.sky }, runner);
2071
+ let key;
2072
+ try {
2073
+ key = client.id === "claude_app" ? "" : await (opts.agentKey ?? localAgentKey)(client.id);
2074
+ } catch {
2075
+ continue;
2076
+ }
2077
+ const registered = registerMcpServer(client, { token: key, mcpUrl: mcpUrlFor(apiBase(), "short"), sky: opts.sky }, runner);
2071
2078
  if (registered.outcome === "registered") engines.push({ id: client.id, what: mark === "missing" && !setUpBefore ? "AgentSky added" : "AgentSky registration put back" });
2072
2079
  }
2073
2080
  for (const agent of agents) {
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  USER_AGENT
3
- } from "./chunk-2OIW436E.js";
3
+ } from "./chunk-BIWRJ65N.js";
4
4
  import {
5
5
  configPath
6
6
  } from "./chunk-XHZJG3QT.js";
7
7
  import {
8
8
  TRACE_CONTENT_SCOPES,
9
9
  redactTraceText
10
- } from "./chunk-KX6JJECK.js";
10
+ } from "./chunk-W24YSGH4.js";
11
11
 
12
12
  // src/trace.ts
13
13
  import { randomBytes } from "crypto";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CLI_VERSION
3
- } from "./chunk-2OIW436E.js";
3
+ } from "./chunk-BIWRJ65N.js";
4
4
 
5
5
  // src/skill.ts
6
6
  import { mkdirSync, readFileSync, writeFileSync } from "fs";
@@ -0,0 +1,214 @@
1
+ import {
2
+ cachedSettingsBlock,
3
+ mcpUrlFor,
4
+ workspaceSlug
5
+ } from "./chunk-SJIBWHJU.js";
6
+ import {
7
+ api
8
+ } from "./chunk-DAVMU66H.js";
9
+ import {
10
+ USER_AGENT
11
+ } from "./chunk-BIWRJ65N.js";
12
+ import {
13
+ apiBase,
14
+ apiToken,
15
+ configPath,
16
+ loadConfig
17
+ } from "./chunk-XHZJG3QT.js";
18
+
19
+ // src/mcp-serve.ts
20
+ import { createInterface } from "readline";
21
+
22
+ // src/local-agent-keys.ts
23
+ import { createHash } from "crypto";
24
+ import { mkdirSync, readFileSync, rmSync, writeFileSync } from "fs";
25
+ import { hostname } from "os";
26
+ import { dirname, join } from "path";
27
+ var SHELL_AGENT = "shell";
28
+ function agentKeysPath() {
29
+ return join(dirname(configPath()), "agent-keys.json");
30
+ }
31
+ function readKeys() {
32
+ try {
33
+ const parsed = JSON.parse(readFileSync(agentKeysPath(), "utf8"));
34
+ if (parsed?.version === 1 && parsed.keys && typeof parsed.keys === "object") return parsed;
35
+ } catch {
36
+ }
37
+ return { version: 1, keys: {} };
38
+ }
39
+ function writeKeys(file) {
40
+ const path = agentKeysPath();
41
+ mkdirSync(dirname(path), { recursive: true });
42
+ writeFileSync(path, `${JSON.stringify(file, null, 2)}
43
+ `, { mode: 384 });
44
+ }
45
+ function slot(agent, workspace, account) {
46
+ return createHash("sha256").update([apiBase(), account, workspace, agent].join("\n")).digest("hex").slice(0, 32);
47
+ }
48
+ var AGENT_NAMES = {
49
+ claude_code: "Claude Code",
50
+ codex: "Codex",
51
+ cursor: "Cursor",
52
+ grok: "Grok",
53
+ hermes: "Hermes",
54
+ claude_app: "Claude app",
55
+ [SHELL_AGENT]: "new shells"
56
+ };
57
+ function agentKeyName(agent, host = hostname()) {
58
+ return `${AGENT_NAMES[agent] ?? agent} on ${host}`.slice(0, 60);
59
+ }
60
+ var INTERACTIVE_CLIENT_AGENTS = ["claude_code", "codex"];
61
+ var UNATTENDED_ENV = ["SKY_API_TOKEN", "E2B_SANDBOX", "CI", "AGENTSKY_HARNESS_TOKEN", "SKY_WORKER_TOKEN", "AGENTSKY_POD_ID", "AGENTSKY_SESSION_ID"];
62
+ function wantsInteractiveClientKey(agent, at) {
63
+ return INTERACTIVE_CLIENT_AGENTS.includes(agent) && at.stdinTTY && at.stdoutTTY && !at.unattended && !at.agentKeyOnly;
64
+ }
65
+ function runsUnattended(env = process.env) {
66
+ return UNATTENDED_ENV.some((name) => Boolean(env[name]?.trim()));
67
+ }
68
+ async function localAgentKey(agent, deps = {}, options = {}) {
69
+ if (!apiToken()) throw new Error("sky is not signed in on this computer: run `sky auth login`");
70
+ const workspace = await (deps.workspace ?? (() => workspaceSlug()))();
71
+ const account = (deps.account ?? (() => loadConfig().email ?? "signed-in"))();
72
+ const file = readKeys();
73
+ const key = slot(options.interactiveClient ? `${agent}:interactive_client` : agent, workspace, account);
74
+ const stored = file.keys[key];
75
+ if (stored?.secret) return stored.secret;
76
+ const mint = deps.mint ?? ((body) => api("POST", "/api_keys", body));
77
+ const made = await mint({ name: agentKeyName(agent), scopes: ["read", "write"], universe: workspace, access: "agent", agent, ...options.interactiveClient ? { interactive_client: true } : {} });
78
+ file.keys[key] = { id: made.api_key.id, secret: made.secret, workspace };
79
+ writeKeys(file);
80
+ return made.secret;
81
+ }
82
+ async function revokeLocalAgentKeys(revoke = (id) => api("POST", `/api_keys/${encodeURIComponent(id)}/revoke`)) {
83
+ const file = readKeys();
84
+ if (!Object.keys(file.keys).length) return { revoked: 0, left: 0 };
85
+ let revoked = 0;
86
+ const left = {};
87
+ for (const [key, stored] of Object.entries(file.keys)) {
88
+ try {
89
+ await revoke(stored.id);
90
+ revoked++;
91
+ } catch {
92
+ left[key] = stored;
93
+ }
94
+ }
95
+ if (Object.keys(left).length) writeKeys({ version: 1, keys: left });
96
+ else rmSync(agentKeysPath(), { force: true });
97
+ return { revoked, left: Object.keys(left).length };
98
+ }
99
+
100
+ // src/mcp-serve.ts
101
+ var defaults = () => ({
102
+ fetch,
103
+ token: async () => apiToken() ? localAgentKey("claude_app") : void 0,
104
+ url: () => mcpUrlFor(apiBase(), "short"),
105
+ settings: cachedSettingsBlock,
106
+ write: (line) => process.stdout.write(`${line}
107
+ `)
108
+ });
109
+ function failure(id, message) {
110
+ return JSON.stringify({ jsonrpc: "2.0", id: id ?? null, error: { code: -32e3, message } });
111
+ }
112
+ function answersIn(body, type) {
113
+ const texts = type?.includes("text/event-stream") ? body.split(/\r?\n/).filter((line) => line.startsWith("data:")).map((line) => line.slice(5).trim()).filter(Boolean) : body.trim() ? [body] : [];
114
+ return texts.flatMap((text) => {
115
+ const parsed = JSON.parse(text);
116
+ return Array.isArray(parsed) ? parsed : [parsed];
117
+ });
118
+ }
119
+ async function shortToolCount(token, url = mcpUrlFor(apiBase(), "short"), fetchImpl = fetch) {
120
+ try {
121
+ const response = await fetchImpl(url, {
122
+ method: "POST",
123
+ headers: { "user-agent": USER_AGENT, authorization: `Bearer ${token}`, "content-type": "application/json", accept: "application/json, text/event-stream" },
124
+ body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/list" })
125
+ });
126
+ if (!response.ok) return null;
127
+ const tools = answersIn(await response.text(), response.headers.get("content-type")).find((answer) => answer.id === 1)?.result?.tools;
128
+ return Array.isArray(tools) ? tools.length : null;
129
+ } catch {
130
+ return null;
131
+ }
132
+ }
133
+ async function forwardLine(line, deps = defaults(), protocol = {}) {
134
+ let message;
135
+ try {
136
+ message = JSON.parse(line);
137
+ } catch {
138
+ return deps.write(failure(null, "not a JSON-RPC message"));
139
+ }
140
+ const expectsAnswer = message.id !== void 0 && message.id !== null;
141
+ let token;
142
+ try {
143
+ token = await deps.token();
144
+ } catch (error) {
145
+ if (expectsAnswer) deps.write(failure(message.id, `sky could not get this app a key of its own: ${(error instanceof Error ? error.message : String(error)).split("\n")[0]}`));
146
+ return;
147
+ }
148
+ if (!token) {
149
+ if (expectsAnswer) deps.write(failure(message.id, "sky is not signed in on this computer: run `sky auth login`"));
150
+ return;
151
+ }
152
+ let response;
153
+ try {
154
+ response = await deps.fetch(deps.url(), {
155
+ method: "POST",
156
+ headers: {
157
+ "user-agent": USER_AGENT,
158
+ authorization: `Bearer ${token}`,
159
+ "content-type": "application/json",
160
+ accept: "application/json, text/event-stream",
161
+ ...protocol.version ? { "mcp-protocol-version": protocol.version } : {}
162
+ },
163
+ body: line
164
+ });
165
+ } catch (error) {
166
+ if (expectsAnswer) deps.write(failure(message.id, `AgentSky could not be reached: ${error instanceof Error ? error.message : String(error)}`));
167
+ return;
168
+ }
169
+ const body = await response.text();
170
+ if (!response.ok) {
171
+ if (expectsAnswer) deps.write(failure(message.id, `AgentSky answered ${response.status}`));
172
+ return;
173
+ }
174
+ let answers;
175
+ try {
176
+ answers = answersIn(body, response.headers.get("content-type"));
177
+ } catch {
178
+ if (expectsAnswer) deps.write(failure(message.id, "AgentSky's answer was not JSON"));
179
+ return;
180
+ }
181
+ for (const answer of answers) {
182
+ if (message.method === "initialize" && answer.result) {
183
+ const version = answer.result.protocolVersion;
184
+ if (typeof version === "string") protocol.version = version;
185
+ const settings = deps.settings();
186
+ if (settings) answer.result.instructions = `${answer.result.instructions ?? ""}
187
+
188
+ ${settings}`.trim();
189
+ }
190
+ deps.write(JSON.stringify(answer));
191
+ }
192
+ }
193
+ async function serveMcp(deps = defaults()) {
194
+ const protocol = {};
195
+ const lines = createInterface({ input: process.stdin, crlfDelay: Infinity });
196
+ let queue = Promise.resolve();
197
+ for await (const line of lines) {
198
+ if (!line.trim()) continue;
199
+ queue = queue.then(() => forwardLine(line, deps, protocol));
200
+ }
201
+ await queue;
202
+ }
203
+
204
+ export {
205
+ SHELL_AGENT,
206
+ agentKeysPath,
207
+ wantsInteractiveClientKey,
208
+ runsUnattended,
209
+ localAgentKey,
210
+ revokeLocalAgentKeys,
211
+ shortToolCount,
212
+ forwardLine,
213
+ serveMcp
214
+ };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  UnsafeImportError,
3
3
  redactLine
4
- } from "./chunk-KX6JJECK.js";
4
+ } from "./chunk-W24YSGH4.js";
5
5
 
6
6
  // src/trace-exclusions.ts
7
7
  import { existsSync as existsSync3, readFileSync as readFileSync2 } from "fs";
@@ -1,11 +1,13 @@
1
1
  import {
2
+ ApiError,
2
3
  api
3
- } from "./chunk-LM3WPNRW.js";
4
+ } from "./chunk-DAVMU66H.js";
4
5
  import {
5
6
  SKILL_NAME
6
- } from "./chunk-OXCZMLEZ.js";
7
+ } from "./chunk-LMYRAGDR.js";
7
8
  import {
8
- configPath
9
+ configPath,
10
+ currentUniverse
9
11
  } from "./chunk-XHZJG3QT.js";
10
12
 
11
13
  // src/local-agents.ts
@@ -37,6 +39,155 @@ function selectLocalAgents(ids, env = process.env, home = homedir()) {
37
39
  });
38
40
  }
39
41
 
42
+ // src/workspace.ts
43
+ import { createInterface } from "readline";
44
+ var KINDS = ["TOOL_CALL", "SPEND_CAP", "CALL_COUNT", "CAPABILITY"];
45
+ async function workspaceSlug(explicit) {
46
+ if (explicit) return explicit;
47
+ const current = currentUniverse();
48
+ if (current) return current;
49
+ return (await api("GET", "/whoami")).universe.slug;
50
+ }
51
+ var workspacePath = (slug) => `/universes/${encodeURIComponent(slug)}`;
52
+ async function listMembers(slug, page = {}) {
53
+ const query = new URLSearchParams({ ...page.limit ? { limit: page.limit } : {}, ...page.cursor ? { cursor: page.cursor } : {} }).toString();
54
+ return api("GET", `${workspacePath(slug)}/members${query ? `?${query}` : ""}`);
55
+ }
56
+ function findMember(members, ref) {
57
+ const needle = ref.toLowerCase();
58
+ const found = members.find((m) => m.user_id === ref || m.email?.toLowerCase() === needle);
59
+ if (!found) throw new ApiError(404, "not_found", `no member ${ref} in this workspace`);
60
+ return found;
61
+ }
62
+ function inviteBody(emails, options) {
63
+ if (options.role && options.role !== "admin" && options.role !== "member") {
64
+ throw new ApiError(400, "invalid_request", "--role is admin or member");
65
+ }
66
+ return {
67
+ emails,
68
+ ...options.role ? { role: options.role } : {},
69
+ ...options.sendEmail ? { send_email: true } : {}
70
+ };
71
+ }
72
+ async function invite(slug, emails, options) {
73
+ return api("POST", `${workspacePath(slug)}/invites`, inviteBody(emails, options));
74
+ }
75
+ async function withdrawInvite(slug, inviteId) {
76
+ await api("DELETE", `${workspacePath(slug)}/invites/${encodeURIComponent(inviteId)}`);
77
+ }
78
+ async function setRole(slug, memberRef, role) {
79
+ if (role !== "admin" && role !== "member") throw new ApiError(400, "invalid_request", "a role is admin or member");
80
+ const member = findMember((await listMembers(slug)).members, memberRef);
81
+ await api("PATCH", `${workspacePath(slug)}/members/${encodeURIComponent(member.user_id)}`, { role });
82
+ return member;
83
+ }
84
+ async function removeMember(slug, memberRef) {
85
+ if (memberRef === "me") {
86
+ await leaveWorkspace(slug);
87
+ return null;
88
+ }
89
+ const member = findMember((await listMembers(slug)).members, memberRef);
90
+ await api("DELETE", `${workspacePath(slug)}/members/${encodeURIComponent(member.user_id)}`);
91
+ return member;
92
+ }
93
+ async function leaveWorkspace(slug) {
94
+ await api("DELETE", `${workspacePath(slug)}/members/me`);
95
+ }
96
+ async function joinWorkspace(token) {
97
+ return (await api("POST", `/invites/${encodeURIComponent(token)}`)).workspace;
98
+ }
99
+ function renderMembers(page) {
100
+ const lines = page.members.map((m) => `${m.role.padEnd(6)} ${m.email ?? m.user_id}${m.name ? ` (${m.name})` : ""} ${m.user_id}`);
101
+ for (const i of page.invites) lines.push(`invited ${i.email} as ${i.role} by ${i.invited_by} until ${i.expires_at.slice(0, 10)} ${i.id}`);
102
+ if (page.next_cursor) lines.push(`more: --cursor ${page.next_cursor}`);
103
+ return lines;
104
+ }
105
+ function policyRuleBody(options) {
106
+ const kind = options.kind.toUpperCase().replace(/-/g, "_");
107
+ if (!KINDS.includes(kind)) throw new ApiError(400, "invalid_request", `--kind is one of ${KINDS.join(", ")}`);
108
+ let config;
109
+ try {
110
+ config = JSON.parse(options.config);
111
+ } catch {
112
+ throw new ApiError(400, "invalid_request", "--config must be a JSON object");
113
+ }
114
+ if (!config || typeof config !== "object" || Array.isArray(config)) {
115
+ throw new ApiError(400, "invalid_request", "--config must be a JSON object");
116
+ }
117
+ const position = options.position === void 0 ? void 0 : Number(options.position);
118
+ if (position !== void 0 && !Number.isInteger(position)) throw new ApiError(400, "invalid_request", "--position is a whole number");
119
+ return {
120
+ name: options.name,
121
+ kind,
122
+ config,
123
+ ...position !== void 0 ? { position } : {},
124
+ ...options.disabled ? { enabled: false } : {}
125
+ };
126
+ }
127
+ var policiesPath = (scope) => "session" in scope ? `/sessions/${encodeURIComponent(scope.session)}/policies` : `${workspacePath(scope.slug)}/policies`;
128
+ async function listPolicies(scope, effective = false) {
129
+ if (effective && "session" in scope) return api("GET", `/sessions/${encodeURIComponent(scope.session)}/effective-policy`);
130
+ return api("GET", policiesPath(scope));
131
+ }
132
+ async function addPolicy(scope, options) {
133
+ return (await api("POST", policiesPath(scope), policyRuleBody(options))).rule;
134
+ }
135
+ async function setPolicyEnabled(scope, ruleId, enabled) {
136
+ return (await api("PATCH", `${policiesPath(scope)}/${encodeURIComponent(ruleId)}`, { enabled })).rule;
137
+ }
138
+ async function removePolicy(scope, ruleId) {
139
+ await api("DELETE", `${policiesPath(scope)}/${encodeURIComponent(ruleId)}`);
140
+ }
141
+ function renderPolicy(rule) {
142
+ const state = rule.enabled ? "on " : "off";
143
+ return `${state} ${rule.layer.padEnd(9)} ${rule.kind.padEnd(10)} ${rule.name} ${JSON.stringify(rule.config)} ${rule.id}`;
144
+ }
145
+ var REMOVED_KINDS = [
146
+ ["sessions", "sessions and their transcripts"],
147
+ ["agents", "agents"],
148
+ ["artifacts", "artifacts"],
149
+ ["files", "task files"],
150
+ ["memory_stores", "memory stores"],
151
+ ["routines", "routines"],
152
+ ["channels", "channel connections"],
153
+ ["webhooks", "webhooks"],
154
+ ["api_keys", "API keys"],
155
+ ["vaults", "vaults"],
156
+ ["skills", "skills"],
157
+ ["environments", "environments"],
158
+ ["connections", "connected apps"],
159
+ ["traces", "uploaded traces"],
160
+ ["members", "other members"],
161
+ ["invites", "pending invitations"]
162
+ ];
163
+ async function deletionPreview(slug) {
164
+ return api("GET", `/universes/${encodeURIComponent(slug)}/deletion`);
165
+ }
166
+ function renderDeletionPreview(preview) {
167
+ if (!preview.can_delete) return [`${preview.workspace.slug} cannot be deleted:`, ...preview.blockers.map((b) => ` ${b.message}`)];
168
+ const lines = [`Deleting ${preview.workspace.slug} (${preview.workspace.name}) permanently removes:`];
169
+ const removed = REMOVED_KINDS.filter(([key]) => (preview.removes[key] ?? 0) > 0);
170
+ for (const [key, label] of removed) lines.push(` ${preview.removes[key]} ${label}`);
171
+ if (!removed.length) lines.push(" nothing: the workspace is empty");
172
+ const running = preview.removes.running_sessions ?? 0;
173
+ if (running) lines.push(`${running} running session${running === 1 ? " is" : "s are"} stopped first.`);
174
+ if (preview.wallet) lines.push(`$${(preview.wallet.balance_micros / 1e6).toFixed(2)} in its wallet goes back to ${preview.wallet.returns_to ?? "you"}.`);
175
+ lines.push("This cannot be undone.");
176
+ return lines;
177
+ }
178
+ async function deleteWorkspace(slug) {
179
+ return (await api("DELETE", `/universes/${encodeURIComponent(slug)}`)).deleted;
180
+ }
181
+ function typedConfirmation(slug) {
182
+ return new Promise((done) => {
183
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
184
+ rl.question(`Type ${slug} to delete it: `, (answer) => {
185
+ rl.close();
186
+ done(answer.trim() === slug);
187
+ });
188
+ });
189
+ }
190
+
40
191
  // src/mcp-register.ts
41
192
  import { existsSync as existsSync2, readFileSync, writeFileSync } from "fs";
42
193
  import { spawnSync } from "child_process";
@@ -314,8 +465,19 @@ function registerHermes(client, opts) {
314
465
  doc.setIn(["mcp_servers", MCP_SERVER_NAME], doc.createNode(entry));
315
466
  return written(client, path, doc.toString());
316
467
  }
317
- function refreshMcpRegistrations(opts, clients = detectMcpClients(), runner = systemCommandRunner(), env = process.env, home = homedir2()) {
318
- return clients.filter((client) => client.id !== "claude_app" && hasMcpServer(client, env, home)).map((client) => registerMcpServer(client, { token: opts.token, mcpUrl: mcpUrlFor(opts.apiBase, registeredToolList(client, env, home)) }, runner, env, home));
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;
319
481
  }
320
482
 
321
483
  // src/settings-block.ts
@@ -562,6 +724,24 @@ function settingsBlockState(block, file) {
562
724
  export {
563
725
  detectLocalAgents,
564
726
  selectLocalAgents,
727
+ workspaceSlug,
728
+ listMembers,
729
+ invite,
730
+ withdrawInvite,
731
+ setRole,
732
+ removeMember,
733
+ leaveWorkspace,
734
+ joinWorkspace,
735
+ renderMembers,
736
+ listPolicies,
737
+ addPolicy,
738
+ setPolicyEnabled,
739
+ removePolicy,
740
+ renderPolicy,
741
+ deletionPreview,
742
+ renderDeletionPreview,
743
+ deleteWorkspace,
744
+ typedConfirmation,
565
745
  MCP_SERVER_NAME,
566
746
  detectHermes,
567
747
  detectClaudeApp,