@zackbart/connecta 0.35.0 → 0.36.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.
- package/CHANGELOG.md +97 -0
- package/README.md +8 -4
- package/bin/version.mjs +1 -1
- package/dist/auth/downstream-oauth.js +71 -79
- package/dist/auth/static-oauth.js +104 -26
- package/dist/connectors/api-connector.d.ts +17 -0
- package/dist/connectors/api-connector.js +3 -1
- package/dist/http/client.js +1 -1
- package/dist/http/hatch-paging.js +2 -2
- package/dist/http/paging.js +3 -89
- package/dist/http/provider.js +1 -2
- package/dist/http/services.js +1 -1
- package/dist/http/tools.js +1 -27
- package/dist/operator-ui/contract.d.ts +1 -0
- package/dist/operator-ui/generated.js +4 -4
- package/dist/program-writes.js +0 -1
- package/dist/providers/_shared/google/kit.js +29 -139
- package/dist/providers/_shared/rest/kit.js +4 -404
- package/dist/providers/_shared/sensitive-fields.js +0 -16
- package/dist/providers/breeze/api.js +2 -2
- package/dist/providers/ccb/api.js +1 -1
- package/dist/providers/cloudflare/api.js +8 -8
- package/dist/providers/cloudflare/lib/config.d.ts +2 -1
- package/dist/providers/docs/api.js +1 -1
- package/dist/providers/docs/tools.js +1 -2
- package/dist/providers/drive/api.js +2 -2
- package/dist/providers/drive/lib/hatch.js +1 -1
- package/dist/providers/drive/tools.js +1 -1
- package/dist/providers/forms/api.js +1 -1
- package/dist/providers/forms/lib/hatch.js +1 -1
- package/dist/providers/forms/tools.js +2 -3
- package/dist/providers/github/api.js +1 -1
- package/dist/providers/github/lib/discovery.js +2 -2
- package/dist/providers/gmail/api.js +1 -1
- package/dist/providers/gmail/tools.js +2 -2
- package/dist/providers/granola/api.js +155 -0
- package/dist/providers/granola/index.d.ts +10 -0
- package/dist/providers/granola/index.js +68 -0
- package/dist/providers/granola/openapi.generated.js +30 -0
- package/dist/providers/granola/safety.js +37 -0
- package/dist/providers/granola/skill.generated.js +5 -0
- package/dist/providers/granola/tools.js +2 -0
- package/dist/providers/overflow/api.js +26 -26
- package/dist/providers/planning-center/api.js +4 -4
- package/dist/providers/planning-center/lib/constants.d.ts +1 -1
- package/dist/providers/planning-center/lib/json-api.js +2 -2
- package/dist/providers/quickbooks/api.js +299 -0
- package/dist/providers/quickbooks/index.d.ts +13 -0
- package/dist/providers/quickbooks/index.js +93 -0
- package/dist/providers/quickbooks/lib/query.js +118 -0
- package/dist/providers/quickbooks/lib/writes.js +168 -0
- package/dist/providers/quickbooks/safety.js +222 -0
- package/dist/providers/quickbooks/skill.generated.js +5 -0
- package/dist/providers/quickbooks/tools.js +117 -0
- package/dist/providers/sheets/api.js +1 -1
- package/dist/providers/sheets/lib/hatch.js +2 -2
- package/dist/providers/sheets/lib/requests.js +1 -1
- package/dist/providers/sheets/tools.js +1 -2
- package/dist/providers/slides/api.js +1 -1
- package/dist/providers/slides/tools.js +2 -2
- package/dist/providers/stripe/api.js +7 -7
- package/dist/providers/tithely/api.js +2 -2
- package/dist/providers/vercel/api.js +12 -12
- package/dist/providers/vercel/index.js +1 -2
- package/dist/providers/vercel/lib/pin.js +1 -1
- package/dist/routes/mcp.js +1 -1
- package/dist/routes/oauth.js +3 -0
- package/dist/runtime/admission.js +0 -12
- package/dist/runtime/call.js +0 -4
- package/dist/skills.js +0 -1
- package/dist/storage/keys.js +2 -3
- package/dist/types.d.ts +2 -0
- package/dist/ui.d.ts +1 -1
- package/dist/ui.js +0 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/documentation/README.md +1 -0
- package/documentation/architecture.md +249 -366
- package/documentation/auth.md +56 -19
- package/documentation/code-mode.md +6 -6
- package/documentation/integrating.md +1 -1
- package/documentation/meta-tools.md +6 -3
- package/documentation/operator-tests.md +11 -2
- package/documentation/operator-ui.md +17 -5
- package/documentation/providers.md +492 -0
- package/package.json +12 -9
- package/templates/node/package.json +1 -1
- package/dist/operator-ui/agents.d.ts +0 -75
- package/dist/operator-ui/agents.js +0 -114
- package/dist/operator-ui/config-summary.js +0 -566
- package/dist/operator-ui/connection-map.js +0 -378
- package/dist/operator-ui/endpoints.js +0 -212
- package/dist/operator-ui/fix-prompts.d.ts +0 -18
- package/dist/operator-ui/fix-prompts.js +0 -79
- package/dist/operator-ui/health.js +0 -52
- package/dist/operator-ui/member-page.js +0 -97
- package/dist/operator-ui/overview.js +0 -126
- package/dist/operator-ui/setup-commands.js +0 -47
- package/dist/operator-ui/view.d.ts +0 -378
- package/dist/operator-ui/view.js +0 -631
- package/dist/providers/_shared/rest/dispatch.js +0 -21
- package/dist/providers/_shared/rest/tools.js +0 -592
|
@@ -1,378 +0,0 @@
|
|
|
1
|
-
import { endpointRows, hueOf, initialsOf } from "./endpoints.js";
|
|
2
|
-
import { connectorVerdict } from "./view.js";
|
|
3
|
-
/* Layout. One coordinate system, scaled by the SVG's viewBox. */
|
|
4
|
-
const MAP_WIDTH = 1000;
|
|
5
|
-
const COLUMN_X = [16, 280, 544];
|
|
6
|
-
const COLUMN_WIDTH = [196, 196, 196];
|
|
7
|
-
/** Each connector's read and write tools sit in a fourth column, joined by a straight link. */
|
|
8
|
-
const TOOLS_X = 808;
|
|
9
|
-
const TOOLS_WIDTH = 176;
|
|
10
|
-
const NODE_HEIGHT = 54;
|
|
11
|
-
const NODE_GAP = 12;
|
|
12
|
-
const HEAD = 40;
|
|
13
|
-
const FOOT = 12;
|
|
14
|
-
/** Characters a node's name keeps before it is cut with an ellipsis. */
|
|
15
|
-
const LABEL_LIMIT = [18, 17, 17];
|
|
16
|
-
/** A read-only endpoint's name shares its row with the read-only chip. */
|
|
17
|
-
const READ_ONLY_LABEL_LIMIT = 12;
|
|
18
|
-
/** "a", "a and b", "a, b and c". */
|
|
19
|
-
export function joinList(items) {
|
|
20
|
-
if (items.length <= 1)
|
|
21
|
-
return items[0] ?? "";
|
|
22
|
-
return `${items.slice(0, -1).join(", ")} and ${items[items.length - 1]}`;
|
|
23
|
-
}
|
|
24
|
-
function plural(count, one, many = `${one}s`) {
|
|
25
|
-
return `${count} ${count === 1 ? one : many}`;
|
|
26
|
-
}
|
|
27
|
-
/** Cut a name to `limit` characters, ending in an ellipsis when it was longer. */
|
|
28
|
-
function truncate(text, limit) {
|
|
29
|
-
return text.length <= limit ? text : `${text.slice(0, limit - 1).trimEnd()}…`;
|
|
30
|
-
}
|
|
31
|
-
/** Where an endpoint's row opens on the Endpoints page. */
|
|
32
|
-
function endpointHref(path) {
|
|
33
|
-
return `/endpoints#${path.replace(/^\//, "")}`;
|
|
34
|
-
}
|
|
35
|
-
/** The endpoint path an Endpoints page hash names, or null. */
|
|
36
|
-
export function endpointFromHash(hash) {
|
|
37
|
-
const value = hash.replace(/^#/, "");
|
|
38
|
-
return value.startsWith("mcp") ? `/${value}` : null;
|
|
39
|
-
}
|
|
40
|
-
function connectorHref(id, healthy) {
|
|
41
|
-
return `/connectors/${encodeURIComponent(id)}#${healthy ? "tools" : "connection"}`;
|
|
42
|
-
}
|
|
43
|
-
function tokenWorks(agent) {
|
|
44
|
-
return agent?.credentialTypes.includes("vercel_oidc") === true || agent?.token?.state === "issued";
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* People in the order the contract first lists them (plain /mcp's
|
|
48
|
-
* maintainers, then each pool's members), then every declared agent, then any
|
|
49
|
-
* agent a pool lists that is not declared. Plain /mcp admits no agents.
|
|
50
|
-
*/
|
|
51
|
-
function callersOf(contract, rows) {
|
|
52
|
-
const people = new Map();
|
|
53
|
-
const agents = new Map();
|
|
54
|
-
for (const agent of contract.agents) {
|
|
55
|
-
agents.set(agent.name, { id: `agent:${agent.name}`, kind: "agent", name: agent.name, agent, endpoints: [] });
|
|
56
|
-
}
|
|
57
|
-
const memberLists = rows.map((row) => [
|
|
58
|
-
row,
|
|
59
|
-
row.pool === null
|
|
60
|
-
? (contract.root?.maintainers ?? [])
|
|
61
|
-
: (contract.pools.find((pool) => pool.name === row.pool)?.members ?? []),
|
|
62
|
-
]);
|
|
63
|
-
for (const [row, members] of memberLists) {
|
|
64
|
-
for (const member of members) {
|
|
65
|
-
if (member.kind === "agent") {
|
|
66
|
-
if (row.pool === null)
|
|
67
|
-
continue;
|
|
68
|
-
let caller = agents.get(member.name);
|
|
69
|
-
if (!caller) {
|
|
70
|
-
caller = { id: `agent:${member.name}`, kind: "agent", name: member.name, agent: null, endpoints: [] };
|
|
71
|
-
agents.set(member.name, caller);
|
|
72
|
-
}
|
|
73
|
-
if (!caller.endpoints.includes(row))
|
|
74
|
-
caller.endpoints.push(row);
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
const id = `person:${member.namespace}:${member.id}`;
|
|
78
|
-
let caller = people.get(id);
|
|
79
|
-
if (!caller) {
|
|
80
|
-
caller = { id, kind: "person", name: member.label ?? member.id, agent: null, endpoints: [] };
|
|
81
|
-
people.set(id, caller);
|
|
82
|
-
}
|
|
83
|
-
if (!caller.endpoints.includes(row))
|
|
84
|
-
caller.endpoints.push(row);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return [...people.values(), ...agents.values()];
|
|
88
|
-
}
|
|
89
|
-
/** Unique live tools a set of endpoints serves, by address. */
|
|
90
|
-
function servedTools(rows) {
|
|
91
|
-
const connectors = new Set();
|
|
92
|
-
const tools = new Map();
|
|
93
|
-
for (const row of rows) {
|
|
94
|
-
for (const group of row.groups) {
|
|
95
|
-
connectors.add(group.config.id);
|
|
96
|
-
for (const tool of group.tools)
|
|
97
|
-
tools.set(tool.address, tool.classification);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
const write = [...tools.values()].filter((value) => value === "write").length;
|
|
101
|
-
return { connectors, tools: tools.size, write };
|
|
102
|
-
}
|
|
103
|
-
export function toolsPhrase(tools, write) {
|
|
104
|
-
if (!tools)
|
|
105
|
-
return "no tools";
|
|
106
|
-
return write ? `${plural(tools, "tool")}, ${write} write` : `${plural(tools, "tool")}, all read`;
|
|
107
|
-
}
|
|
108
|
-
function callerSummary(caller) {
|
|
109
|
-
const name = caller.name;
|
|
110
|
-
if (!caller.endpoints.length) {
|
|
111
|
-
return caller.kind === "agent" ? `${name} is in no endpoint, so it reaches nothing.` : `${name} reaches nothing.`;
|
|
112
|
-
}
|
|
113
|
-
const served = servedTools(caller.endpoints);
|
|
114
|
-
// An agent connects only at a pool's agent URL, never the people's one.
|
|
115
|
-
const through = joinList(caller.endpoints.map((row) => (caller.kind === "agent" ? (row.agentPath ?? row.path) : row.path)));
|
|
116
|
-
const reach = served.connectors.size
|
|
117
|
-
? `${name} reaches ${plural(served.connectors.size, "connector")} through ${through}: ${toolsPhrase(served.tools, served.write)}.`
|
|
118
|
-
: `${name} uses ${through}, which serves no connectors.`;
|
|
119
|
-
if (caller.kind !== "agent" || tokenWorks(caller.agent))
|
|
120
|
-
return reach;
|
|
121
|
-
const state = caller.agent?.token?.state;
|
|
122
|
-
return `${reach} ${state === "revoked" ? "Its token is revoked" : "It has no token"}, so it can't connect.`;
|
|
123
|
-
}
|
|
124
|
-
function callerDetail(caller, maintainers) {
|
|
125
|
-
if (caller.kind === "person")
|
|
126
|
-
return maintainers.has(caller.id) ? "maintainer" : "member";
|
|
127
|
-
if (caller.agent?.credentialTypes.includes("vercel_oidc"))
|
|
128
|
-
return "agent · Vercel OIDC";
|
|
129
|
-
const state = caller.agent?.token?.state;
|
|
130
|
-
return state === "issued"
|
|
131
|
-
? "agent · token issued"
|
|
132
|
-
: state === "revoked"
|
|
133
|
-
? "agent · token revoked"
|
|
134
|
-
: "agent · no token";
|
|
135
|
-
}
|
|
136
|
-
function endpointSummary(row, callers) {
|
|
137
|
-
const listed = callers.filter((caller) => caller.endpoints.includes(row));
|
|
138
|
-
const people = listed.filter((caller) => caller.kind === "person").length;
|
|
139
|
-
const agents = listed.length - people;
|
|
140
|
-
const who = row.pool === null ? plural(people, "maintainer") : plural(people, "person", "people");
|
|
141
|
-
const users = agents ? `${who} and ${plural(agents, "agent")}` : who;
|
|
142
|
-
const served = servedTools([row]);
|
|
143
|
-
const mode = row.readOnly ? `${row.path} is read-only and serves ${users}` : `${row.path} serves ${users}`;
|
|
144
|
-
if (!served.connectors.size)
|
|
145
|
-
return `${mode}. It has no connectors.`;
|
|
146
|
-
return `${mode} with ${plural(served.connectors.size, "connector")}: ${toolsPhrase(served.tools, served.write)}.`;
|
|
147
|
-
}
|
|
148
|
-
const STATUS_SENTENCE = {
|
|
149
|
-
ok: "",
|
|
150
|
-
neutral: "",
|
|
151
|
-
warn: " It needs attention.",
|
|
152
|
-
danger: " It is failing.",
|
|
153
|
-
};
|
|
154
|
-
function connectorSummary(title, id, health, rows, callers) {
|
|
155
|
-
const on = rows.filter((row) => row.groups.some((group) => group.config.id === id));
|
|
156
|
-
const status = STATUS_SENTENCE[health.tone];
|
|
157
|
-
if (!on.length)
|
|
158
|
-
return `No endpoint serves ${title}, so nobody reaches it.${status}`;
|
|
159
|
-
const reaching = callers.filter((caller) => caller.endpoints.some((row) => on.includes(row)));
|
|
160
|
-
const people = reaching.filter((caller) => caller.kind === "person").length;
|
|
161
|
-
const agents = reaching.length - people;
|
|
162
|
-
const who = agents
|
|
163
|
-
? `${plural(people, "person", "people")} and ${plural(agents, "agent")}`
|
|
164
|
-
: plural(people, "person", "people");
|
|
165
|
-
const verb = reaching.length === 1 ? "reaches" : "reach";
|
|
166
|
-
return `${who} ${verb} ${title} through ${joinList(on.map((row) => row.path))}.${status}`;
|
|
167
|
-
}
|
|
168
|
-
function edgePath(from, to) {
|
|
169
|
-
const x1 = from.x + from.width;
|
|
170
|
-
const y1 = from.y + from.height / 2;
|
|
171
|
-
const x2 = to.x;
|
|
172
|
-
const y2 = to.y + to.height / 2;
|
|
173
|
-
const dx = (x2 - x1) / 2;
|
|
174
|
-
return `M${x1},${y1} C${x1 + dx},${y1} ${x2 - dx},${y2} ${x2},${y2}`;
|
|
175
|
-
}
|
|
176
|
-
/** Each column's nodes stacked from the top, the shorter columns centered on the tallest. */
|
|
177
|
-
function place(nodes) {
|
|
178
|
-
const columns = [0, 1, 2].map((column) => nodes.filter((node) => node.column === column));
|
|
179
|
-
const tallest = Math.max(1, ...columns.map((column) => column.length));
|
|
180
|
-
const body = tallest * (NODE_HEIGHT + NODE_GAP) - NODE_GAP;
|
|
181
|
-
columns.forEach((column, index) => {
|
|
182
|
-
const height = column.length * (NODE_HEIGHT + NODE_GAP) - NODE_GAP;
|
|
183
|
-
const top = HEAD + Math.max(0, (body - height) / 2);
|
|
184
|
-
column.forEach((node, position) => {
|
|
185
|
-
node.x = COLUMN_X[index];
|
|
186
|
-
node.width = COLUMN_WIDTH[index];
|
|
187
|
-
node.height = NODE_HEIGHT;
|
|
188
|
-
node.y = top + position * (NODE_HEIGHT + NODE_GAP);
|
|
189
|
-
if (node.kind === "connector")
|
|
190
|
-
node.toolsBox = { x: TOOLS_X, y: node.y, width: TOOLS_WIDTH, height: NODE_HEIGHT };
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
return HEAD + body + FOOT;
|
|
194
|
-
}
|
|
195
|
-
function node(fields, limit) {
|
|
196
|
-
return { hue: 0, ...fields, label: truncate(fields.name, limit), toolsBox: null, x: 0, y: 0, width: 0, height: 0 };
|
|
197
|
-
}
|
|
198
|
-
/** A connector's tile: two words' initials, a camel-case title's two capitals, or one letter. */
|
|
199
|
-
export function monogram(title) {
|
|
200
|
-
const words = title.split(/[\s._-]+/).filter(Boolean);
|
|
201
|
-
if (words.length > 1)
|
|
202
|
-
return (words[0][0] + words[1][0]).toUpperCase();
|
|
203
|
-
const capitals = title.match(/[A-Z]/g) ?? [];
|
|
204
|
-
if (capitals.length >= 2)
|
|
205
|
-
return capitals[0] + capitals[1];
|
|
206
|
-
return (words[0] ?? title).charAt(0).toUpperCase();
|
|
207
|
-
}
|
|
208
|
-
/** The whole map for a maintainer's contract; an empty map for anyone else. */
|
|
209
|
-
export function connectionMap(contract, options = {}) {
|
|
210
|
-
const rows = contract.role === "maintainer" ? endpointRows(contract) : [];
|
|
211
|
-
const callers = callersOf(contract, rows);
|
|
212
|
-
const maintainers = new Set((contract.root?.maintainers ?? []).flatMap((member) => member.kind === "human" ? [`person:${member.namespace}:${member.id}`] : []));
|
|
213
|
-
const connectors = (contract.role === "maintainer" ? (contract.config?.connectors ?? []) : []).flatMap((config) => {
|
|
214
|
-
const live = contract.live.connectors.find((c) => c.id === config.id);
|
|
215
|
-
const signals = options.signals && Object.hasOwn(options.signals, config.id) ? options.signals[config.id] : undefined;
|
|
216
|
-
return live ? [{ config, live, health: connectorVerdict(live, signals) }] : [];
|
|
217
|
-
});
|
|
218
|
-
const health = new Map(connectors.map(({ config, health }) => [config.id, health]));
|
|
219
|
-
const nodes = [];
|
|
220
|
-
for (const caller of callers) {
|
|
221
|
-
const works = caller.kind === "person" || tokenWorks(caller.agent);
|
|
222
|
-
nodes.push(node({
|
|
223
|
-
id: caller.id,
|
|
224
|
-
kind: caller.kind,
|
|
225
|
-
column: 0,
|
|
226
|
-
name: caller.name,
|
|
227
|
-
detail: callerDetail(caller, maintainers),
|
|
228
|
-
href: caller.kind === "agent"
|
|
229
|
-
? options.tokensPage
|
|
230
|
-
? "/tokens"
|
|
231
|
-
: null
|
|
232
|
-
: caller.endpoints[0]
|
|
233
|
-
? endpointHref(caller.endpoints[0].path)
|
|
234
|
-
: null,
|
|
235
|
-
tone: works ? "neutral" : "warn",
|
|
236
|
-
readOnly: false,
|
|
237
|
-
tools: null,
|
|
238
|
-
initials: caller.kind === "person" ? initialsOf(caller.name) : "",
|
|
239
|
-
hue: caller.kind === "person" ? hueOf(caller.id.slice("person:".length)) : 0,
|
|
240
|
-
summary: callerSummary(caller),
|
|
241
|
-
}, LABEL_LIMIT[0]));
|
|
242
|
-
}
|
|
243
|
-
for (const row of rows) {
|
|
244
|
-
const listed = callers.filter((caller) => caller.endpoints.includes(row)).length;
|
|
245
|
-
nodes.push(node({
|
|
246
|
-
id: `endpoint:${row.path}`,
|
|
247
|
-
kind: "endpoint",
|
|
248
|
-
column: 1,
|
|
249
|
-
name: row.path,
|
|
250
|
-
detail: `${row.pool === null ? "maintainers" : plural(listed, "caller")} · ${plural(row.groups.length, "connector")}`,
|
|
251
|
-
href: endpointHref(row.path),
|
|
252
|
-
tone: "neutral",
|
|
253
|
-
readOnly: row.readOnly,
|
|
254
|
-
tools: null,
|
|
255
|
-
initials: "",
|
|
256
|
-
summary: endpointSummary(row, callers),
|
|
257
|
-
}, row.readOnly ? READ_ONLY_LABEL_LIMIT : LABEL_LIMIT[1]));
|
|
258
|
-
}
|
|
259
|
-
for (const { config, live, health: verdict } of connectors) {
|
|
260
|
-
const title = config.title ?? config.id;
|
|
261
|
-
const read = live.tools.filter((tool) => tool.classification === "read").length;
|
|
262
|
-
const scope = config.authScope === "personal" ? "personal" : "shared";
|
|
263
|
-
// A failed or unobserved catalog has no tools to count, which is not zero tools.
|
|
264
|
-
const known = live.tools.length > 0 || (live.status === "ok" && !live.problem);
|
|
265
|
-
nodes.push(node({
|
|
266
|
-
id: `connector:${config.id}`,
|
|
267
|
-
kind: "connector",
|
|
268
|
-
column: 2,
|
|
269
|
-
name: title,
|
|
270
|
-
detail: verdict.tone === "ok" ? `${scope} · ${plural(live.tools.length, "tool")}` : verdict.label,
|
|
271
|
-
href: connectorHref(config.id, verdict.tone === "ok"),
|
|
272
|
-
tone: verdict.tone,
|
|
273
|
-
readOnly: false,
|
|
274
|
-
tools: known ? { read, write: live.tools.length - read } : null,
|
|
275
|
-
initials: monogram(title),
|
|
276
|
-
summary: connectorSummary(title, config.id, verdict, rows, callers),
|
|
277
|
-
}, LABEL_LIMIT[2]));
|
|
278
|
-
}
|
|
279
|
-
const height = place(nodes);
|
|
280
|
-
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
281
|
-
const edges = [];
|
|
282
|
-
for (const caller of callers) {
|
|
283
|
-
for (const row of caller.endpoints) {
|
|
284
|
-
const from = byId.get(caller.id);
|
|
285
|
-
const to = byId.get(`endpoint:${row.path}`);
|
|
286
|
-
edges.push({
|
|
287
|
-
id: `${from.id}>${to.id}`,
|
|
288
|
-
from: from.id,
|
|
289
|
-
to: to.id,
|
|
290
|
-
kind: "access",
|
|
291
|
-
tone: "neutral",
|
|
292
|
-
readOnly: false,
|
|
293
|
-
noToken: caller.kind === "agent" && !tokenWorks(caller.agent),
|
|
294
|
-
served: null,
|
|
295
|
-
path: edgePath(from, to),
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
for (const row of rows) {
|
|
300
|
-
for (const group of row.groups) {
|
|
301
|
-
const from = byId.get(`endpoint:${row.path}`);
|
|
302
|
-
const to = byId.get(`connector:${group.config.id}`);
|
|
303
|
-
if (!to)
|
|
304
|
-
continue;
|
|
305
|
-
edges.push({
|
|
306
|
-
id: `${from.id}>${to.id}`,
|
|
307
|
-
from: from.id,
|
|
308
|
-
to: to.id,
|
|
309
|
-
kind: "grant",
|
|
310
|
-
tone: health.get(group.config.id)?.tone ?? "neutral",
|
|
311
|
-
readOnly: row.readOnly,
|
|
312
|
-
noToken: false,
|
|
313
|
-
served: {
|
|
314
|
-
tools: group.tools.length,
|
|
315
|
-
write: group.tools.filter((tool) => tool.classification === "write").length,
|
|
316
|
-
},
|
|
317
|
-
path: edgePath(from, to),
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
return {
|
|
322
|
-
nodes,
|
|
323
|
-
edges,
|
|
324
|
-
width: MAP_WIDTH,
|
|
325
|
-
height,
|
|
326
|
-
columns: [
|
|
327
|
-
{ label: "Callers", count: callers.length, x: COLUMN_X[0] },
|
|
328
|
-
{ label: "Endpoints", count: rows.length, x: COLUMN_X[1] },
|
|
329
|
-
{ label: "Connectors", count: connectors.length, x: COLUMN_X[2] },
|
|
330
|
-
{ label: "Tools", count: connectors.reduce((n, { live }) => n + live.tools.length, 0), x: TOOLS_X },
|
|
331
|
-
],
|
|
332
|
-
};
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* What hovering a node lights up: every node and link on a path through it.
|
|
336
|
-
* Links are walked forward from the node and backward to it, never both ways
|
|
337
|
-
* from a neighbor, so a caller lights only what it reaches and a connector
|
|
338
|
-
* lights only who reaches it.
|
|
339
|
-
*/
|
|
340
|
-
export function mapHighlight(map, id) {
|
|
341
|
-
const nodes = new Set([id]);
|
|
342
|
-
const edges = new Set();
|
|
343
|
-
const walk = (forward) => {
|
|
344
|
-
const queue = [id];
|
|
345
|
-
const seen = new Set([id]);
|
|
346
|
-
while (queue.length) {
|
|
347
|
-
const current = queue.shift();
|
|
348
|
-
for (const edge of map.edges) {
|
|
349
|
-
if ((forward ? edge.from : edge.to) !== current)
|
|
350
|
-
continue;
|
|
351
|
-
const target = forward ? edge.to : edge.from;
|
|
352
|
-
edges.add(edge.id);
|
|
353
|
-
nodes.add(target);
|
|
354
|
-
if (!seen.has(target)) {
|
|
355
|
-
seen.add(target);
|
|
356
|
-
queue.push(target);
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
};
|
|
361
|
-
walk(true);
|
|
362
|
-
walk(false);
|
|
363
|
-
return { nodes, edges };
|
|
364
|
-
}
|
|
365
|
-
export function mapList(map) {
|
|
366
|
-
const byId = new Map(map.nodes.map((n) => [n.id, n]));
|
|
367
|
-
return map.nodes
|
|
368
|
-
.filter((n) => n.kind === "endpoint")
|
|
369
|
-
.map((endpoint) => ({
|
|
370
|
-
endpoint,
|
|
371
|
-
callers: map.edges
|
|
372
|
-
.filter((edge) => edge.to === endpoint.id)
|
|
373
|
-
.map((edge) => ({ node: byId.get(edge.from), noToken: edge.noToken })),
|
|
374
|
-
connectors: map.edges
|
|
375
|
-
.filter((edge) => edge.from === endpoint.id)
|
|
376
|
-
.map((edge) => ({ node: byId.get(edge.to), served: edge.served ?? { tools: 0, write: 0 } })),
|
|
377
|
-
}));
|
|
378
|
-
}
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
/** How many chips an endpoint row shows before "+N more". */
|
|
2
|
-
const ACCESS_CHIP_LIMIT = 4;
|
|
3
|
-
/** Up to two letters for a person's avatar, from their label or raw id. */
|
|
4
|
-
export function initialsOf(text) {
|
|
5
|
-
const words = text
|
|
6
|
-
.replace(/^user_/, "")
|
|
7
|
-
.split(/[\s._@-]+/)
|
|
8
|
-
.filter(Boolean);
|
|
9
|
-
const letters = words.length > 1 ? words[0][0] + words[1][0] : (words[0] ?? text).slice(0, 2);
|
|
10
|
-
return letters.toUpperCase();
|
|
11
|
-
}
|
|
12
|
-
/** A stable tint bucket for a member key, shared by chips and the Overview map. */
|
|
13
|
-
export function hueOf(key) {
|
|
14
|
-
let hash = 0;
|
|
15
|
-
for (const char of key)
|
|
16
|
-
hash = (hash * 31 + char.charCodeAt(0)) >>> 0;
|
|
17
|
-
return hash % 6;
|
|
18
|
-
}
|
|
19
|
-
/** A member as a chip. Labels are null on Access deployments, where the raw id shows instead. */
|
|
20
|
-
function accessChip(member) {
|
|
21
|
-
if (member.kind === "agent") {
|
|
22
|
-
const key = `agent:${member.name}`;
|
|
23
|
-
return { key, kind: "agent", text: member.name, initials: "", hue: hueOf(key) };
|
|
24
|
-
}
|
|
25
|
-
const key = `${member.namespace}:${member.id}`;
|
|
26
|
-
const text = member.label ?? member.id;
|
|
27
|
-
return { key, kind: "human", text, initials: initialsOf(text), hue: hueOf(key) };
|
|
28
|
-
}
|
|
29
|
-
/** Chips for one endpoint in contract order, people first, without repeats. */
|
|
30
|
-
export function accessChips(members) {
|
|
31
|
-
const unique = new Map();
|
|
32
|
-
for (const chip of members.map(accessChip))
|
|
33
|
-
if (!unique.has(chip.key))
|
|
34
|
-
unique.set(chip.key, chip);
|
|
35
|
-
const chips = [...unique.values()];
|
|
36
|
-
return [...chips.filter((chip) => chip.kind === "human"), ...chips.filter((chip) => chip.kind === "agent")];
|
|
37
|
-
}
|
|
38
|
-
/** The chips a collapsed row shows, and how many the "+N more" button holds back. */
|
|
39
|
-
export function visibleChips(chips, expanded) {
|
|
40
|
-
if (expanded || chips.length <= ACCESS_CHIP_LIMIT)
|
|
41
|
-
return { shown: chips, hidden: 0 };
|
|
42
|
-
return { shown: chips.slice(0, ACCESS_CHIP_LIMIT), hidden: chips.length - ACCESS_CHIP_LIMIT };
|
|
43
|
-
}
|
|
44
|
-
/** Matrix cells for one endpoint, keyed by connector id. */
|
|
45
|
-
function cellsFor(contract, pool) {
|
|
46
|
-
return new Map(contract.matrix.filter((cell) => cell.pool === pool).map((cell) => [cell.connectorId, cell]));
|
|
47
|
-
}
|
|
48
|
-
/** Plain /mcp declares no tool list; its matrix cells are its grants. */
|
|
49
|
-
function rootGrants(contract) {
|
|
50
|
-
return contract.matrix
|
|
51
|
-
.filter((cell) => cell.pool === null)
|
|
52
|
-
.map((cell) => ({
|
|
53
|
-
connectorId: cell.connectorId,
|
|
54
|
-
tools: cell.tools === "all" ? "all" : cell.tools.map((name) => ({ name, requireReadOnly: false })),
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
/** Intersect declared grants with final live verdicts, in config order. */
|
|
58
|
-
function endpointGroups(contract, grants, readOnly, pool) {
|
|
59
|
-
const cells = cellsFor(contract, pool);
|
|
60
|
-
return (contract.config?.connectors ?? []).flatMap((config) => {
|
|
61
|
-
const live = contract.live.connectors.find((c) => c.id === config.id);
|
|
62
|
-
const grant = grants.find((g) => g.connectorId === config.id);
|
|
63
|
-
if (!live || !grant)
|
|
64
|
-
return [];
|
|
65
|
-
const tools = live.tools.filter((tool) => {
|
|
66
|
-
if ((readOnly || config.readOnly) && tool.classification !== "read")
|
|
67
|
-
return false;
|
|
68
|
-
return (grant.tools === "all" ||
|
|
69
|
-
grant.tools.some((g) => g.name === tool.name && (!g.requireReadOnly || tool.classification === "read")));
|
|
70
|
-
});
|
|
71
|
-
// A granted connector with no complete catalog still needs a visible fix.
|
|
72
|
-
return [{ config, live, tools, runsAs: cells.get(config.id)?.runsAs ?? null }];
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
const toolCount = (groups) => groups.reduce((n, group) => n + group.tools.length, 0);
|
|
76
|
-
/** How many of these tools read and how many write; an unclassified tool counts as neither. */
|
|
77
|
-
export function toolSplit(tools) {
|
|
78
|
-
let read = 0;
|
|
79
|
-
let write = 0;
|
|
80
|
-
for (const tool of tools) {
|
|
81
|
-
if (tool.classification === "read")
|
|
82
|
-
read++;
|
|
83
|
-
else if (tool.classification === "write")
|
|
84
|
-
write++;
|
|
85
|
-
}
|
|
86
|
-
return { read, write };
|
|
87
|
-
}
|
|
88
|
-
/** One row for plain /mcp, then one per pool, in contract order. Maintainer view only. */
|
|
89
|
-
export function endpointRows(contract) {
|
|
90
|
-
if (contract.role !== "maintainer")
|
|
91
|
-
return [];
|
|
92
|
-
const rows = [];
|
|
93
|
-
if (contract.root) {
|
|
94
|
-
const groups = endpointGroups(contract, rootGrants(contract), contract.root.readOnly, null);
|
|
95
|
-
rows.push({
|
|
96
|
-
pool: null,
|
|
97
|
-
label: "Default",
|
|
98
|
-
path: contract.root.path,
|
|
99
|
-
agentPath: null,
|
|
100
|
-
readOnly: contract.root.readOnly,
|
|
101
|
-
surface: "meta",
|
|
102
|
-
executeCode: true,
|
|
103
|
-
toolCount: toolCount(groups),
|
|
104
|
-
groups,
|
|
105
|
-
access: accessChips(contract.root.maintainers),
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
for (const pool of contract.pools) {
|
|
109
|
-
const groups = endpointGroups(contract, pool.tools, pool.readOnly, pool.name);
|
|
110
|
-
rows.push({
|
|
111
|
-
pool: pool.name,
|
|
112
|
-
label: pool.name,
|
|
113
|
-
path: pool.humanPath,
|
|
114
|
-
agentPath: pool.members.some((member) => member.kind === "agent") ? pool.agentPath : null,
|
|
115
|
-
readOnly: pool.readOnly,
|
|
116
|
-
surface: pool.surface,
|
|
117
|
-
executeCode: pool.executeCode,
|
|
118
|
-
toolCount: toolCount(groups),
|
|
119
|
-
groups,
|
|
120
|
-
access: accessChips(pool.members),
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
return rows;
|
|
124
|
-
}
|
|
125
|
-
/** A calendar day, without the time: when a shared credential was saved. */
|
|
126
|
-
function formatDay(value) {
|
|
127
|
-
const date = new Date(value);
|
|
128
|
-
return Number.isNaN(date.valueOf()) ? "" : date.toLocaleDateString(undefined, { dateStyle: "medium" });
|
|
129
|
-
}
|
|
130
|
-
/** Where a shared credential lives; a vault or OAuth date when the contract has one. */
|
|
131
|
-
function sharedSourceLabel(source, date) {
|
|
132
|
-
switch (source) {
|
|
133
|
-
case "vault":
|
|
134
|
-
return date ? `saved ${date}` : "saved";
|
|
135
|
-
case "oauth":
|
|
136
|
-
return date ? `connected ${date}` : "connected";
|
|
137
|
-
case "missing":
|
|
138
|
-
return "not configured";
|
|
139
|
-
case "config":
|
|
140
|
-
return "set in deployment";
|
|
141
|
-
case "unauthenticated":
|
|
142
|
-
return "no credential needed";
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
/** Whose account a connector acts with on one endpoint, in one line. */
|
|
146
|
-
export function runsAsLabel(runsAs, day = formatDay) {
|
|
147
|
-
switch (runsAs.kind) {
|
|
148
|
-
case "shared":
|
|
149
|
-
return `Shared · ${sharedSourceLabel(runsAs.source, runsAs.savedAt ? day(runsAs.savedAt) : "")}`;
|
|
150
|
-
case "personal":
|
|
151
|
-
return `Personal · ${runsAs.connectedMembers} of ${runsAs.members} connected`;
|
|
152
|
-
case "workspace":
|
|
153
|
-
return `Workspace · people: self · agents: ${runsAs.agents ?? "none"}`;
|
|
154
|
-
case "workspaceFixed":
|
|
155
|
-
return `Everyone acts as ${runsAs.subject}`;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
export function matrixColumns(contract) {
|
|
159
|
-
if (contract.role !== "maintainer")
|
|
160
|
-
return [];
|
|
161
|
-
return [
|
|
162
|
-
...(contract.root ? [{ pool: null, path: contract.root.path, readOnly: contract.root.readOnly }] : []),
|
|
163
|
-
...contract.pools.map((pool) => ({ pool: pool.name, path: pool.humanPath, readOnly: pool.readOnly })),
|
|
164
|
-
];
|
|
165
|
-
}
|
|
166
|
-
/** What one connector × endpoint cell holds, straight from the contract's matrix. */
|
|
167
|
-
export function matrixCell(contract, connectorId, column) {
|
|
168
|
-
const cell = contract.matrix.find((c) => c.connectorId === connectorId && c.pool === column.pool);
|
|
169
|
-
if (!cell)
|
|
170
|
-
return { kind: "none" };
|
|
171
|
-
const overlay = contract.live.connectors.find((c) => c.id === connectorId);
|
|
172
|
-
const live = overlay?.tools ?? [];
|
|
173
|
-
const tools = cell.tools === "all"
|
|
174
|
-
? live.map(({ name, classification }) => ({ name, classification }))
|
|
175
|
-
: cell.tools.map((name) => ({ name, classification: live.find((t) => t.name === name)?.classification ?? null }));
|
|
176
|
-
const known = overlay && (live.length > 0 || (overlay.status === "ok" && !overlay.problem));
|
|
177
|
-
const granted = cell.tools === "all" ? live : live.filter((tool) => cell.tools.includes(tool.name));
|
|
178
|
-
return {
|
|
179
|
-
kind: cell.tools === "all" ? "all" : "some",
|
|
180
|
-
tools,
|
|
181
|
-
runsAs: cell.runsAs,
|
|
182
|
-
coverage: known ? { granted: granted.length, total: live.length } : null,
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
/** The live grant fraction, or null when no complete catalog is available. */
|
|
186
|
-
export function matrixCellShare(cell) {
|
|
187
|
-
if (cell.kind === "none")
|
|
188
|
-
return 0;
|
|
189
|
-
if (!cell.coverage)
|
|
190
|
-
return null;
|
|
191
|
-
return cell.coverage.total ? cell.coverage.granted / cell.coverage.total : 0;
|
|
192
|
-
}
|
|
193
|
-
/** The cell's visible text: "all", a count, or a dash. */
|
|
194
|
-
export function matrixCellText(cell) {
|
|
195
|
-
if (cell.kind === "none")
|
|
196
|
-
return "—";
|
|
197
|
-
if (!cell.coverage)
|
|
198
|
-
return "?";
|
|
199
|
-
return cell.kind === "all" ? "all" : String(cell.coverage.granted);
|
|
200
|
-
}
|
|
201
|
-
/** The cell's accessible name, e.g. "GitHub on /mcp/support: 1 of 2 live tools". */
|
|
202
|
-
export function matrixCellLabel(connector, column, cell) {
|
|
203
|
-
const where = `${connector} on ${column.path}`;
|
|
204
|
-
if (cell.kind === "none")
|
|
205
|
-
return `${where}: no tools`;
|
|
206
|
-
const what = !cell.coverage
|
|
207
|
-
? "unknown live tool coverage"
|
|
208
|
-
: cell.kind === "all"
|
|
209
|
-
? `all ${cell.coverage.total} tools`
|
|
210
|
-
: `${cell.coverage.granted} of ${cell.coverage.total} live tools`;
|
|
211
|
-
return `${where}: ${what}${column.readOnly ? ", read-only" : ""}`;
|
|
212
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { UiCredentialProblem, UiProblem } from "./model.js";
|
|
2
|
-
/**
|
|
3
|
-
* Every failure the Connections page can show, with the prompt its "Copy fix
|
|
4
|
-
* prompt" button puts on the clipboard.
|
|
5
|
-
*
|
|
6
|
-
* The signature is the guarantee. A prompt is looked up by kind and may name
|
|
7
|
-
* the connector's configured id; there is no argument an error message, a
|
|
8
|
-
* downstream body, or a credential could travel through, so none can reach a
|
|
9
|
-
* coding agent's context by way of this page. The notice beside it is fixed
|
|
10
|
-
* copy too wherever a downstream could have written the failure (see
|
|
11
|
-
* `refusedNotice` in view.ts); what remains are the page's own sentences and a
|
|
12
|
-
* credential form's field checks.
|
|
13
|
-
*/
|
|
14
|
-
export type FixPromptKind = UiProblem | UiCredentialProblem | "credential_test_failed" | "oauth_action_failed";
|
|
15
|
-
/** The clipboard text for one failure. Fixed by kind; see `CATALOGUE`. */
|
|
16
|
-
export declare function fixPrompt(kind: FixPromptKind, connectorId?: string): string;
|
|
17
|
-
/** Every kind, so a test can walk the whole catalogue. */
|
|
18
|
-
export declare const FIX_PROMPT_KINDS: FixPromptKind[];
|