@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
package/dist/operator-ui/view.js
DELETED
|
@@ -1,631 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Everything the operator app knows, and every rule for changing it, with no
|
|
3
|
-
* DOM in sight. The components render this and nothing else, so the questions
|
|
4
|
-
* that matter — what a page shows while it loads, what an identity change
|
|
5
|
-
* erases, whether a value may become an href — are answered by functions a test
|
|
6
|
-
* can call directly rather than by reading rendered markup back out of a
|
|
7
|
-
* browser.
|
|
8
|
-
*/
|
|
9
|
-
const REGISTRATION_LABELS = {
|
|
10
|
-
cimd: "Client metadata document (CIMD)",
|
|
11
|
-
dcr: "Dynamic registration (DCR)",
|
|
12
|
-
static: "Pre-registered client",
|
|
13
|
-
};
|
|
14
|
-
export function registrationPathLabel(path) {
|
|
15
|
-
return REGISTRATION_LABELS[path];
|
|
16
|
-
}
|
|
17
|
-
/** Pages the nav lists, in dashboard order. */
|
|
18
|
-
export const OPERATOR_PAGES = [
|
|
19
|
-
"overview",
|
|
20
|
-
"endpoints",
|
|
21
|
-
"connections",
|
|
22
|
-
"activity",
|
|
23
|
-
"tokens",
|
|
24
|
-
"settings",
|
|
25
|
-
];
|
|
26
|
-
export const PAGE_META = {
|
|
27
|
-
overview: { path: "/", label: "Overview" },
|
|
28
|
-
endpoints: { path: "/endpoints", label: "Endpoints" },
|
|
29
|
-
connector: { path: "/connectors", label: "Connector" },
|
|
30
|
-
settings: { path: "/settings", label: "Settings" },
|
|
31
|
-
tokens: { path: "/tokens", label: "Tokens" },
|
|
32
|
-
connections: { path: "/connectors", label: "Connectors" },
|
|
33
|
-
activity: { path: "/activity", label: "Activity" },
|
|
34
|
-
};
|
|
35
|
-
/** Legacy links remain valid, with the browser replacing their URL. */
|
|
36
|
-
export function canonicalOperatorPath(path) {
|
|
37
|
-
return ({ "/access": "/endpoints", "/tools": "/connectors", "/config": "/settings" }[path] ??
|
|
38
|
-
path);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* What each page is for, in one line under its heading — on the gate as well
|
|
42
|
-
* as once signed in, so the page an operator lands on reads the same before
|
|
43
|
-
* and after the session is checked.
|
|
44
|
-
*/
|
|
45
|
-
export function pageDescription(page, productDescription) {
|
|
46
|
-
if (page === "activity") {
|
|
47
|
-
return "Tool calls by caller and result. Arguments and results are not stored.";
|
|
48
|
-
}
|
|
49
|
-
return productDescription;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Signed in, but neither a maintainer nor a member of any endpoint: who to
|
|
53
|
-
* ask, and that this is not an error to retry.
|
|
54
|
-
*/
|
|
55
|
-
export function noAccessCopy(kind, productName) {
|
|
56
|
-
const who = kind === "clerk" ? "This account" : kind === "cloudflare-access" ? "This Cloudflare Access identity" : "This token";
|
|
57
|
-
return `${who} has no access to ${productName}. Ask a maintainer to add you to an endpoint, then reload.`;
|
|
58
|
-
}
|
|
59
|
-
/** What the gate says while the session is checked, page by page. */
|
|
60
|
-
export function checkingCopy() {
|
|
61
|
-
return "Checking your session…";
|
|
62
|
-
}
|
|
63
|
-
export function pageForPath(path) {
|
|
64
|
-
if (/^\/connectors\/[a-z0-9_-]+$/.test(path))
|
|
65
|
-
return "connector";
|
|
66
|
-
if (path === "/tokens")
|
|
67
|
-
return "tokens";
|
|
68
|
-
const match = OPERATOR_PAGES.find((page) => PAGE_META[page].path === canonicalOperatorPath(path));
|
|
69
|
-
return match ?? "connections";
|
|
70
|
-
}
|
|
71
|
-
export function info(message) {
|
|
72
|
-
return { message, tone: "info" };
|
|
73
|
-
}
|
|
74
|
-
export function failure(message, fix) {
|
|
75
|
-
return fix ? { message, tone: "error", fix } : { message, tone: "error" };
|
|
76
|
-
}
|
|
77
|
-
const REFUSED_COPY = {
|
|
78
|
-
oauth_disconnect: "Disconnect failed. The deployment log has the reason.",
|
|
79
|
-
oauth_reconnect: "Authorization couldn't start. The deployment log has the reason.",
|
|
80
|
-
credential_test: "The credential test couldn't run.",
|
|
81
|
-
};
|
|
82
|
-
/**
|
|
83
|
-
* The route's answer to a finished OAuth action. Its state picks the sentence;
|
|
84
|
-
* `opened` says whether the authorization page is already in a new tab.
|
|
85
|
-
*/
|
|
86
|
-
export function oauthDoneNotice(action, answer, opened = true) {
|
|
87
|
-
if (action === "oauth_disconnect") {
|
|
88
|
-
if (answer?.code === "oauth_revocation_failed")
|
|
89
|
-
return info("Disconnected here. Revoke the grant in the provider's console too.");
|
|
90
|
-
return info("Disconnected.");
|
|
91
|
-
}
|
|
92
|
-
if (answer?.state === "ok")
|
|
93
|
-
return info("Connected.");
|
|
94
|
-
return info(opened ? "Finish in the new tab." : "The new tab was blocked. Open the link here.");
|
|
95
|
-
}
|
|
96
|
-
/** A credential Test's result. `ok` is the only part of the answer it reads. */
|
|
97
|
-
export function credentialTestNotice(connectorId, answer) {
|
|
98
|
-
return answer?.ok === true
|
|
99
|
-
? info("Credential is valid.")
|
|
100
|
-
: failure("Credential test failed. The deployment log has the reason.", {
|
|
101
|
-
kind: "credential_test_failed",
|
|
102
|
-
connectorId,
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* A route that refused one of these actions. A credential Test that found
|
|
107
|
-
* nothing usable to test names the problem, which picks the same copy and fix
|
|
108
|
-
* prompt the Connections page uses for it; every other refusal gets the
|
|
109
|
-
* action's one sentence. `problem` is whatever the response carried, so it is
|
|
110
|
-
* checked, not trusted.
|
|
111
|
-
*/
|
|
112
|
-
export function refusedNotice(action, connectorId, problem) {
|
|
113
|
-
if (action === "credential_test" && (problem === "credential_required" || problem === "credential_mismatch")) {
|
|
114
|
-
return failure(PROBLEM_COPY[problem], { kind: problem, connectorId });
|
|
115
|
-
}
|
|
116
|
-
return failure(REFUSED_COPY[action], {
|
|
117
|
-
kind: action === "credential_test" ? "credential_test_failed" : "oauth_action_failed",
|
|
118
|
-
connectorId,
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* A credential save or removal the route refused, by status. The route's
|
|
123
|
-
* `error` can name a vault failure or echo validation detail, so none of it
|
|
124
|
-
* is shown; the status is enough to say what to do next.
|
|
125
|
-
*/
|
|
126
|
-
function credentialRefusedCopy(action, status, problem) {
|
|
127
|
-
if (problem === "credential_mismatch")
|
|
128
|
-
return PROBLEM_COPY.credential_mismatch;
|
|
129
|
-
const verb = action === "credential_save" ? "saved" : "removed";
|
|
130
|
-
if (status === 400 || status === 413 || status === 415) {
|
|
131
|
-
return action === "credential_save"
|
|
132
|
-
? "Not saved. A value is empty or in the wrong format."
|
|
133
|
-
: "Not removed. Refresh and try again.";
|
|
134
|
-
}
|
|
135
|
-
if (status === 404) {
|
|
136
|
-
return "This connector no longer has a credential slot. Refresh the page.";
|
|
137
|
-
}
|
|
138
|
-
if (status === 503) {
|
|
139
|
-
return `No credential storage is configured, so nothing was ${verb}.`;
|
|
140
|
-
}
|
|
141
|
-
return `Not ${verb}. Try again, or check the deployment log.`;
|
|
142
|
-
}
|
|
143
|
-
/** An action whose permission or target changed before it was sent. */
|
|
144
|
-
export const STALE_COPY = "This changed before sending, so nothing was sent. Try again.";
|
|
145
|
-
/**
|
|
146
|
-
* Every row action's failure, in one voice. The page's own failures — a
|
|
147
|
-
* lapsed session, a denied identity, a dropped connection — read the same for
|
|
148
|
-
* every action; a route's refusal picks the action's fixed sentence.
|
|
149
|
-
*/
|
|
150
|
-
export function actionFailedNotice(action, connectorId, facts, productName) {
|
|
151
|
-
if (facts.kind === "session") {
|
|
152
|
-
return failure("Session ended. Sign in again.");
|
|
153
|
-
}
|
|
154
|
-
if (facts.kind === "forbidden") {
|
|
155
|
-
return failure("You can't change this connection's authentication.");
|
|
156
|
-
}
|
|
157
|
-
if (facts.kind === "network") {
|
|
158
|
-
return failure(`Couldn't reach ${productName}. Try again.`);
|
|
159
|
-
}
|
|
160
|
-
if (facts.kind === "stale")
|
|
161
|
-
return failure(STALE_COPY);
|
|
162
|
-
if (action === "credential_save" || action === "credential_remove") {
|
|
163
|
-
return failure(credentialRefusedCopy(action, facts.status, facts.problem));
|
|
164
|
-
}
|
|
165
|
-
return refusedNotice(action, connectorId, facts.problem);
|
|
166
|
-
}
|
|
167
|
-
export function connectorLoadFailureCopy(failure, productName) {
|
|
168
|
-
if (failure === "unavailable")
|
|
169
|
-
return "Session identity is unavailable. Retry.";
|
|
170
|
-
return failure === "session"
|
|
171
|
-
? "Session not accepted. Retry, or sign in again."
|
|
172
|
-
: `Couldn't reach ${productName}. Refresh to retry.`;
|
|
173
|
-
}
|
|
174
|
-
/** The signed-in page's answer when `/ui/data` could not be read. */
|
|
175
|
-
export function loadFailureCopy(failure, productName) {
|
|
176
|
-
return {
|
|
177
|
-
title: `Couldn't reach ${productName}`,
|
|
178
|
-
body: failure === "network"
|
|
179
|
-
? "Your browser couldn't connect. Retry."
|
|
180
|
-
: "The deployment returned an error. Retry, or check its log.",
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
/** A collection page's load failure: fixed words, whatever the route said. */
|
|
184
|
-
export function collectionFailureCopy(_collection, facts, productName) {
|
|
185
|
-
if (facts.kind === "network") {
|
|
186
|
-
return `Couldn't reach ${productName}. Retry.`;
|
|
187
|
-
}
|
|
188
|
-
if (facts.kind === "session")
|
|
189
|
-
return "Session ended. Sign in again.";
|
|
190
|
-
if (facts.kind === "forbidden" || facts.status === 404) {
|
|
191
|
-
return "Activity isn't available to you.";
|
|
192
|
-
}
|
|
193
|
-
return "The deployment returned an error. Retry, or check its log.";
|
|
194
|
-
}
|
|
195
|
-
/** The confirm's question, naming the connector by its title. */
|
|
196
|
-
export function confirmCopy(action, name) {
|
|
197
|
-
if (action === "oauth_disconnect") {
|
|
198
|
-
return {
|
|
199
|
-
question: `Disconnect ${name}? Its tools stop working until you connect again.`,
|
|
200
|
-
confirm: "Disconnect",
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
if (action === "oauth_restart") {
|
|
204
|
-
return {
|
|
205
|
-
question: `Reconnect ${name}? It stops working until you finish in the new tab.`,
|
|
206
|
-
confirm: "Reconnect",
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
return {
|
|
210
|
-
question: `Remove ${name}'s credential? Its tools stop working until you add a new one.`,
|
|
211
|
-
confirm: "Remove",
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
export function accessTokenUnavailableCopy(capability) {
|
|
215
|
-
return capability === undefined
|
|
216
|
-
? "Agent tokens aren't configured."
|
|
217
|
-
: "Managing tokens needs an interactive sign-in with permission.";
|
|
218
|
-
}
|
|
219
|
-
/** Who the contract says this viewer is, or null before it loads. */
|
|
220
|
-
export function operatorRole(state) {
|
|
221
|
-
return state.contract?.role ?? null;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* The role pages and navigation render for. The contract's, or, while a
|
|
225
|
-
* refresh that failed has left no contract on screen, maintainer when the
|
|
226
|
-
* last good contract confirmed one and that maintainer's data is still here:
|
|
227
|
-
* their page stays mounted on its own retry state instead of being torn down
|
|
228
|
-
* mid-recovery. Never a request's permission; the store sends maintainer
|
|
229
|
-
* reads only while the contract itself says maintainer.
|
|
230
|
-
*/
|
|
231
|
-
export function displayRole(state) {
|
|
232
|
-
if (state.contract)
|
|
233
|
-
return state.contract.role;
|
|
234
|
-
return state.role === "maintainer" && state.data ? "maintainer" : null;
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* A confirmed maintainer's page is mounted without a contract behind it: a
|
|
238
|
-
* refresh failed, or its read ran past the deadline. The shell shows one
|
|
239
|
-
* recovery banner with Retry above whichever page is open, and that page is
|
|
240
|
-
* stale until a contract confirms the role again.
|
|
241
|
-
*/
|
|
242
|
-
export function contractRecovering(state) {
|
|
243
|
-
return !state.contract && displayRole(state) === "maintainer";
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Whether Activity is open to this viewer: maintainers only, on a deployment
|
|
247
|
-
* that records history. Members always read "forbidden".
|
|
248
|
-
*/
|
|
249
|
-
export function activityReadable(state) {
|
|
250
|
-
return Boolean(state.data?.activityEnabled) && activityAllowed(state);
|
|
251
|
-
}
|
|
252
|
-
/** The contract's half of `activityReadable`: a maintainer, on a deployment that records. */
|
|
253
|
-
export function activityAllowed(state) {
|
|
254
|
-
const contract = state.contract;
|
|
255
|
-
return (contract?.role === "maintainer" &&
|
|
256
|
-
contract.live.activity !== "forbidden" &&
|
|
257
|
-
contract.live.activity !== "unconfigured");
|
|
258
|
-
}
|
|
259
|
-
export function initialState(page) {
|
|
260
|
-
return {
|
|
261
|
-
page,
|
|
262
|
-
generation: 0,
|
|
263
|
-
session: "loading",
|
|
264
|
-
gate: null,
|
|
265
|
-
refreshing: false,
|
|
266
|
-
loadFailure: null,
|
|
267
|
-
pendingFocus: null,
|
|
268
|
-
focusIfLost: null,
|
|
269
|
-
...identityScopedState(),
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Every field that belongs to one operator identity. Split out because the only
|
|
274
|
-
* safe way to change identity is to replace all of them at once: a field left
|
|
275
|
-
* behind here is one identity's data on another identity's screen.
|
|
276
|
-
*/
|
|
277
|
-
function identityScopedState() {
|
|
278
|
-
return {
|
|
279
|
-
recoveryPending: false,
|
|
280
|
-
data: null,
|
|
281
|
-
contract: null,
|
|
282
|
-
role: null,
|
|
283
|
-
contractPhase: "idle",
|
|
284
|
-
health: "loading",
|
|
285
|
-
connectorFilter: "",
|
|
286
|
-
oauthNotice: null,
|
|
287
|
-
oauthNoticeFor: null,
|
|
288
|
-
oauthBusy: null,
|
|
289
|
-
oauthBlocked: null,
|
|
290
|
-
oauthBlockedUrl: null,
|
|
291
|
-
confirming: null,
|
|
292
|
-
connectorFailures: {},
|
|
293
|
-
credentialNotice: null,
|
|
294
|
-
credentialNoticeFor: null,
|
|
295
|
-
credentialEditing: null,
|
|
296
|
-
credentialBusy: null,
|
|
297
|
-
tokenPhase: "idle",
|
|
298
|
-
tokenNotice: null,
|
|
299
|
-
tokens: [],
|
|
300
|
-
createdToken: null,
|
|
301
|
-
createdTokenFor: null,
|
|
302
|
-
tokenConfirm: null,
|
|
303
|
-
unresolvedSlots: [],
|
|
304
|
-
tokenBusy: false,
|
|
305
|
-
activityPhase: "idle",
|
|
306
|
-
activityNotice: null,
|
|
307
|
-
activityEvents: [],
|
|
308
|
-
activityCursor: null,
|
|
309
|
-
activitySearch: "",
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* Drop to the gate and forget the previous operator. Bumping the generation is
|
|
314
|
-
* what makes the drop stick: work already in flight for the old identity
|
|
315
|
-
* resolves into a state that no longer accepts it.
|
|
316
|
-
*/
|
|
317
|
-
export function resetIdentity(state, gate = null) {
|
|
318
|
-
return {
|
|
319
|
-
...state,
|
|
320
|
-
generation: state.generation + 1,
|
|
321
|
-
session: "gated",
|
|
322
|
-
gate,
|
|
323
|
-
refreshing: false,
|
|
324
|
-
loadFailure: null,
|
|
325
|
-
pendingFocus: null,
|
|
326
|
-
focusIfLost: null,
|
|
327
|
-
...identityScopedState(),
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
/**
|
|
331
|
-
* Leaving a page closes what should not survive it: a one-time secret, a half
|
|
332
|
-
* typed credential, and the notices that answered the page just left.
|
|
333
|
-
*/
|
|
334
|
-
export function withPage(state, page) {
|
|
335
|
-
return {
|
|
336
|
-
...state,
|
|
337
|
-
page,
|
|
338
|
-
createdToken: null,
|
|
339
|
-
createdTokenFor: null,
|
|
340
|
-
tokenConfirm: null,
|
|
341
|
-
tokenNotice: null,
|
|
342
|
-
credentialEditing: null,
|
|
343
|
-
credentialNotice: null,
|
|
344
|
-
credentialNoticeFor: null,
|
|
345
|
-
confirming: null,
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
/**
|
|
349
|
-
* The status badge. An auth-needed connector is named by what it needs, so a
|
|
350
|
-
* row whose fix is "Add credential" does not say "Authorization needed".
|
|
351
|
-
*/
|
|
352
|
-
export function connectorStatusLabel(status, problem) {
|
|
353
|
-
if (status === "loading")
|
|
354
|
-
return "Loading details";
|
|
355
|
-
if (status === "ok")
|
|
356
|
-
return "Connected";
|
|
357
|
-
if (status === "credential_required")
|
|
358
|
-
return "Credential needed";
|
|
359
|
-
if (status === "auth_required") {
|
|
360
|
-
return problem === "credential_required" ? "Credential needed" : "Authorization needed";
|
|
361
|
-
}
|
|
362
|
-
return "Unavailable";
|
|
363
|
-
}
|
|
364
|
-
export function connectorStatusTone(status) {
|
|
365
|
-
if (status === "ok")
|
|
366
|
-
return "ok";
|
|
367
|
-
if (status === "auth_required" || status === "credential_required")
|
|
368
|
-
return "warn";
|
|
369
|
-
if (status === "loading")
|
|
370
|
-
return "neutral";
|
|
371
|
-
return "danger";
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* What the page says about a connector that is not usable, one fixed sentence
|
|
375
|
-
* per problem kind the server classified. This is the only account of a
|
|
376
|
-
* failure the Connections page renders: a connector's status message can quote
|
|
377
|
-
* a downstream error body, and a downstream error body can quote the secret
|
|
378
|
-
* that was just rejected, so the raw text stays in the deployment's log and
|
|
379
|
-
* never reaches the payload or the DOM. The fix prompt beside it is keyed off
|
|
380
|
-
* the same kind.
|
|
381
|
-
*/
|
|
382
|
-
const PROBLEM_COPY = {
|
|
383
|
-
connector_unavailable: "Unavailable. Its status check or catalog load failed or timed out. The deployment log has the error.",
|
|
384
|
-
oauth_required: "Needs OAuth authorization. No grant is stored, or it expired or was revoked.",
|
|
385
|
-
credential_required: "Needs a credential. Nothing usable is stored.",
|
|
386
|
-
auth_required: "Needs authorization. Its secret is set in deployment config, not here.",
|
|
387
|
-
credential_mismatch: "The stored credential doesn't match this connector's fields.",
|
|
388
|
-
catalog_failed: "Connected, but its catalog failed to load, so no tools are served.",
|
|
389
|
-
};
|
|
390
|
-
export function problemCopy(problem) {
|
|
391
|
-
return problem ? (PROBLEM_COPY[problem] ?? null) : null;
|
|
392
|
-
}
|
|
393
|
-
/**
|
|
394
|
-
* A problem someone can fix by authorizing is a warning, matching the amber
|
|
395
|
-
* "Authorization needed" badge above it; one where something broke is an
|
|
396
|
-
* error. The two used to share the red box, so the row contradicted itself.
|
|
397
|
-
*/
|
|
398
|
-
export function problemTone(problem) {
|
|
399
|
-
return problem === "oauth_required" || problem === "credential_required" || problem === "auth_required"
|
|
400
|
-
? "warn"
|
|
401
|
-
: "danger";
|
|
402
|
-
}
|
|
403
|
-
const PROBLEM_LABEL = {
|
|
404
|
-
connector_unavailable: "Unavailable",
|
|
405
|
-
oauth_required: "Authorization needed",
|
|
406
|
-
credential_required: "Credential needed",
|
|
407
|
-
auth_required: "Authorization needed",
|
|
408
|
-
credential_mismatch: "Credential mismatch",
|
|
409
|
-
catalog_failed: "Catalog failed",
|
|
410
|
-
};
|
|
411
|
-
function problemAction(problem) {
|
|
412
|
-
if (problem === "credential_mismatch")
|
|
413
|
-
return "Replace key";
|
|
414
|
-
return problemTone(problem) === "warn" ? "Connect" : "Inspect";
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* The verdict the Connectors list, the Overview, Endpoints and a connector's
|
|
418
|
-
* page all show. The server's problem code comes first, then a failed detail
|
|
419
|
-
* read on this page, then a non-ok status. Catalog drift is informational. A problem
|
|
420
|
-
* outranks the status, so a connector whose catalog failed is never
|
|
421
|
-
* "Connected". A failed read marks its connector `connector_unavailable` in
|
|
422
|
-
* the store, so that one code beside a failed read is the page's own and
|
|
423
|
-
* reads "Couldn't load" instead of blaming the downstream.
|
|
424
|
-
*/
|
|
425
|
-
export function connectorVerdict(live, signals = {}) {
|
|
426
|
-
if (live.problem && !(signals.failed && live.problem === "connector_unavailable")) {
|
|
427
|
-
return { tone: problemTone(live.problem), label: PROBLEM_LABEL[live.problem], action: problemAction(live.problem) };
|
|
428
|
-
}
|
|
429
|
-
if (signals.failed)
|
|
430
|
-
return { tone: "warn", label: "Couldn't load", action: "Inspect" };
|
|
431
|
-
if (live.status === "loading")
|
|
432
|
-
return { tone: "neutral", label: connectorStatusLabel(live.status), action: null };
|
|
433
|
-
if (live.status !== "ok") {
|
|
434
|
-
const tone = connectorStatusTone(live.status) === "warn" ? "warn" : "danger";
|
|
435
|
-
return { tone, label: connectorStatusLabel(live.status), action: tone === "warn" ? "Connect" : "Inspect" };
|
|
436
|
-
}
|
|
437
|
-
return { tone: "ok", label: "Connected", action: null };
|
|
438
|
-
}
|
|
439
|
-
/**
|
|
440
|
-
* Only http/https may become a clickable href — the browser half of the gate
|
|
441
|
-
* `src/ui.ts` applies before an authorizationUrl is ever serialized. A hostile
|
|
442
|
-
* downstream that gets a `javascript:` URL past one of them still meets the
|
|
443
|
-
* other, and the caller renders inert text instead of a link.
|
|
444
|
-
*/
|
|
445
|
-
export function safeHttpHref(url) {
|
|
446
|
-
if (!url)
|
|
447
|
-
return null;
|
|
448
|
-
try {
|
|
449
|
-
const protocol = new URL(url).protocol;
|
|
450
|
-
return protocol === "http:" || protocol === "https:" ? url : null;
|
|
451
|
-
}
|
|
452
|
-
catch {
|
|
453
|
-
return null;
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
/** Locale timestamp, or "" for anything that is not a readable date. */
|
|
457
|
-
export function formatDate(value) {
|
|
458
|
-
if (!value)
|
|
459
|
-
return "";
|
|
460
|
-
const date = new Date(value);
|
|
461
|
-
// Minutes, not seconds: nothing on these pages is read to the second, and
|
|
462
|
-
// the seconds were most of the noise in every row that carried a date.
|
|
463
|
-
return Number.isNaN(date.valueOf())
|
|
464
|
-
? ""
|
|
465
|
-
: date.toLocaleString(undefined, { dateStyle: "medium", timeStyle: "short" });
|
|
466
|
-
}
|
|
467
|
-
const ACTOR_KINDS = {
|
|
468
|
-
clerk: "Clerk",
|
|
469
|
-
bearer: "Bearer token",
|
|
470
|
-
"cloudflare-access": "Cloudflare Access",
|
|
471
|
-
anonymous: "Anonymous",
|
|
472
|
-
access_token: "Agent token",
|
|
473
|
-
vercel_oidc: "Vercel workload",
|
|
474
|
-
};
|
|
475
|
-
/** How a caller signed in, as a person reads it. An unknown kind is shown as sent. */
|
|
476
|
-
function actorKindLabel(kind) {
|
|
477
|
-
if (!kind)
|
|
478
|
-
return "Unknown caller";
|
|
479
|
-
return ACTOR_KINDS[kind] ?? kind;
|
|
480
|
-
}
|
|
481
|
-
/** Who made a call: their name when there is one, and how they signed in. */
|
|
482
|
-
export function actorLabel(actor) {
|
|
483
|
-
if (!actor?.kind)
|
|
484
|
-
return "Unknown caller";
|
|
485
|
-
const who = actor.label || actor.id;
|
|
486
|
-
const kind = actorKindLabel(actor.kind);
|
|
487
|
-
return who ? `${who} (${kind})` : kind;
|
|
488
|
-
}
|
|
489
|
-
/**
|
|
490
|
-
* The stable id behind a friendly label, shown only when a label or namespace
|
|
491
|
-
* could otherwise make two different people look like one.
|
|
492
|
-
*/
|
|
493
|
-
export function actorStableId(actor) {
|
|
494
|
-
if (!actor?.id)
|
|
495
|
-
return null;
|
|
496
|
-
if (!actor.label && !actor.namespace)
|
|
497
|
-
return null;
|
|
498
|
-
return actor.namespace ? `${actor.namespace} · ${actor.id}` : actor.id;
|
|
499
|
-
}
|
|
500
|
-
function activityMatches(event, query) {
|
|
501
|
-
const q = query.trim().toLowerCase();
|
|
502
|
-
if (!q)
|
|
503
|
-
return true;
|
|
504
|
-
return [
|
|
505
|
-
event.address,
|
|
506
|
-
event.connectorId,
|
|
507
|
-
event.toolName,
|
|
508
|
-
event.source,
|
|
509
|
-
event.outcome,
|
|
510
|
-
event.errorCode,
|
|
511
|
-
event.friction,
|
|
512
|
-
event.actor?.kind,
|
|
513
|
-
event.actor?.id,
|
|
514
|
-
event.actor?.namespace,
|
|
515
|
-
event.actor?.label,
|
|
516
|
-
activityOutcomeBadge(event.outcome).label,
|
|
517
|
-
activityDetail(event),
|
|
518
|
-
actorKindLabel(event.actor?.kind),
|
|
519
|
-
].some((value) => String(value ?? "")
|
|
520
|
-
.toLowerCase()
|
|
521
|
-
.includes(q));
|
|
522
|
-
}
|
|
523
|
-
export function filterActivity(events, query) {
|
|
524
|
-
return events.filter((event) => activityMatches(event, query));
|
|
525
|
-
}
|
|
526
|
-
/** Counts only. What the deployment ran, never what it sent or received. */
|
|
527
|
-
export function activitySummary(events) {
|
|
528
|
-
if (events.length === 0)
|
|
529
|
-
return "";
|
|
530
|
-
const calls = events.filter((event) => event.kind !== "catalog_drift");
|
|
531
|
-
const failed = calls.filter((event) => ["error", "timeout"].includes(activityOutcomeClass(event.outcome))).length;
|
|
532
|
-
const changes = events.length - calls.length;
|
|
533
|
-
const tools = new Set(calls.map((event) => event.address)).size;
|
|
534
|
-
return `${calls.length} loaded call${calls.length === 1 ? "" : "s"} · ${failed} failed · ${tools} tool${tools === 1 ? "" : "s"}${changes ? ` · ${changes} catalog change${changes === 1 ? "" : "s"}` : ""}`;
|
|
535
|
-
}
|
|
536
|
-
// A pause and an approval are neither success nor failure: each gets its own
|
|
537
|
-
// class, and the stylesheet paints neither as an error. Nothing has emitted
|
|
538
|
-
// either since issue #672 removed program pauses, but older rows carry them.
|
|
539
|
-
const ACTIVITY_OUTCOMES = ["success", "error", "timeout", "cancelled", "paused", "approved"];
|
|
540
|
-
export function activityOutcomeClass(outcome) {
|
|
541
|
-
return ACTIVITY_OUTCOMES.includes(outcome) ? outcome : "error";
|
|
542
|
-
}
|
|
543
|
-
/** Each outcome as a badge: a word a person reads, and a tone that is never alone. */
|
|
544
|
-
const OUTCOME_BADGE = {
|
|
545
|
-
success: { label: "Succeeded", tone: "ok" },
|
|
546
|
-
error: { label: "Failed", tone: "danger" },
|
|
547
|
-
timeout: { label: "Timed out", tone: "danger" },
|
|
548
|
-
cancelled: { label: "Cancelled", tone: "neutral" },
|
|
549
|
-
paused: { label: "Paused for approval", tone: "warn" },
|
|
550
|
-
approved: { label: "Approved", tone: "ok" },
|
|
551
|
-
};
|
|
552
|
-
export function activityOutcomeBadge(outcome) {
|
|
553
|
-
return OUTCOME_BADGE[outcome] ?? { label: "Failed", tone: "danger" };
|
|
554
|
-
}
|
|
555
|
-
const SOURCE_LABELS = {
|
|
556
|
-
native: "Native tool call",
|
|
557
|
-
execute_code: "In a program",
|
|
558
|
-
call_tool: "Direct call",
|
|
559
|
-
call_destructive_tool: "Direct call, approved by the host",
|
|
560
|
-
// History only: resume_execution left with program pauses (#672).
|
|
561
|
-
resume_execution: "Resumed program",
|
|
562
|
-
batch_call: "Batch call",
|
|
563
|
-
};
|
|
564
|
-
/**
|
|
565
|
-
* Friction classes and the error codes an operator meets most, in words. An
|
|
566
|
-
* unknown code falls back to itself with the underscores taken out, which is
|
|
567
|
-
* still more readable than the wire form and never a guess at its meaning.
|
|
568
|
-
*/
|
|
569
|
-
const REASON_LABELS = {
|
|
570
|
-
tool_not_found: "tool not found",
|
|
571
|
-
unknown_address: "tool not found",
|
|
572
|
-
unknown_tool: "tool not found",
|
|
573
|
-
ambiguous_tool_alias: "ambiguous tool name",
|
|
574
|
-
schema_retry: "arguments didn't match the schema",
|
|
575
|
-
invalid_args: "arguments didn't match the schema",
|
|
576
|
-
destructive_reroute: "needed host approval",
|
|
577
|
-
destructive_tool_requires_approval: "needed host approval",
|
|
578
|
-
read_only_endpoint: "endpoint is read-only",
|
|
579
|
-
approval_required: "needed approval",
|
|
580
|
-
auth_required: "needed authorization",
|
|
581
|
-
result_too_large: "result too large",
|
|
582
|
-
timeout: "timed out",
|
|
583
|
-
};
|
|
584
|
-
function reasonLabel(code) {
|
|
585
|
-
return REASON_LABELS[code] ?? code.replaceAll("_", " ");
|
|
586
|
-
}
|
|
587
|
-
/** Why a call stalled or failed, in words; "" when nothing was recorded. */
|
|
588
|
-
export function activityReason(event) {
|
|
589
|
-
const reasons = [event.friction, event.errorCode].filter((code) => Boolean(code)).map(reasonLabel);
|
|
590
|
-
return [...new Set(reasons)].join(" · ");
|
|
591
|
-
}
|
|
592
|
-
/** The one-line detail under an address: where it ran, retries, and why it stalled. */
|
|
593
|
-
export function activityDetail(event) {
|
|
594
|
-
if (event.kind === "catalog_drift")
|
|
595
|
-
return "Catalog changed";
|
|
596
|
-
const parts = [SOURCE_LABELS[event.source] ?? event.source];
|
|
597
|
-
if (event.approval === "tool")
|
|
598
|
-
parts.push("approved for the rest of the run");
|
|
599
|
-
if (event.approval === "call")
|
|
600
|
-
parts.push("approved for this call");
|
|
601
|
-
if (event.attempts > 1)
|
|
602
|
-
parts.push(`${event.attempts} attempts`);
|
|
603
|
-
const reasons = [event.friction, event.errorCode].filter((code) => Boolean(code)).map(reasonLabel);
|
|
604
|
-
// The friction class and the code often say the same thing in two
|
|
605
|
-
// vocabularies ("auth_required" twice); once is enough.
|
|
606
|
-
for (const reason of new Set(reasons))
|
|
607
|
-
parts.push(reason);
|
|
608
|
-
return parts.join(" · ");
|
|
609
|
-
}
|
|
610
|
-
/**
|
|
611
|
-
* A stored credential that cannot be used, by cause. The payload's `error`
|
|
612
|
-
* beside it is not shown: it can carry a vault's own words.
|
|
613
|
-
*/
|
|
614
|
-
export function credentialProblemCopy(problem) {
|
|
615
|
-
if (problem === "credential_mismatch")
|
|
616
|
-
return PROBLEM_COPY.credential_mismatch;
|
|
617
|
-
if (problem === "credential_unreadable") {
|
|
618
|
-
return "Credential status is unavailable. Retry before replacing or removing it.";
|
|
619
|
-
}
|
|
620
|
-
return "The stored credential can't be used. Replace it.";
|
|
621
|
-
}
|
|
622
|
-
/** Gate copy for each browser-auth shape, so the sign-in state is never a blank page. */
|
|
623
|
-
export function gateCopy(kind, signedIn) {
|
|
624
|
-
if (kind === "cloudflare-access") {
|
|
625
|
-
return "Couldn't check your Cloudflare Access identity. Retry.";
|
|
626
|
-
}
|
|
627
|
-
if (kind !== "clerk") {
|
|
628
|
-
return "Paste an operator token.";
|
|
629
|
-
}
|
|
630
|
-
return signedIn ? "This Clerk account can't open operator pages." : "Sign in with Clerk.";
|
|
631
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A provider `create` that dispatches on `options.auth.type`. Pair it with
|
|
3
|
-
* `variants(["auth", "type"], …)` options, which refuse a missing or unknown
|
|
4
|
-
* type, and options the selected case does not accept, before this runs.
|
|
5
|
-
*/
|
|
6
|
-
export function byAuth(cases) {
|
|
7
|
-
return (id, options, provider) => {
|
|
8
|
-
const type = options.auth?.type;
|
|
9
|
-
const create = typeof type === "string" && Object.hasOwn(cases, type) ? cases[type] : undefined;
|
|
10
|
-
if (!create) {
|
|
11
|
-
throw new Error(`auth.type must be one of ${Object.keys(cases)
|
|
12
|
-
.filter((name) => cases[name] !== removedHostedMcp)
|
|
13
|
-
.map((name) => JSON.stringify(name))
|
|
14
|
-
.join(", ")}.`);
|
|
15
|
-
}
|
|
16
|
-
return create(id, options, provider);
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
export function removedHostedMcp() {
|
|
20
|
-
throw new Error("remoteMcp() with ConnectaConfig.classification for hosted MCP connections; use a distinct id beside the API connector.");
|
|
21
|
-
}
|