hmcp-web 0.1.0 → 0.2.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/README.md +3 -2
- package/dist/api.d.ts +11 -0
- package/dist/api.js +64 -10
- package/dist/model/app-servers.d.ts +85 -0
- package/dist/model/app-servers.js +109 -0
- package/dist/model/import-record.d.ts +80 -0
- package/dist/model/import-record.js +179 -0
- package/dist/model/metrics.js +16 -1
- package/dist/model/protection.d.ts +1 -0
- package/dist/model/protection.js +6 -2
- package/dist/routes/connect-import.d.ts +9 -0
- package/dist/routes/connect-import.js +594 -0
- package/dist/routes/connect.d.ts +36 -0
- package/dist/routes/connect.js +71 -13
- package/dist/routes/github.d.ts +97 -0
- package/dist/routes/github.js +587 -0
- package/dist/routes/guard.d.ts +3 -0
- package/dist/routes/guard.js +166 -0
- package/dist/routes/runtime.d.ts +6 -0
- package/dist/routes/runtime.js +1 -1
- package/dist/routes/servers-add.d.ts +8 -0
- package/dist/routes/servers-add.js +2 -2
- package/dist-ui/assets/{Activity-BqKGpXMN.js → Activity-Dgo5oK2r.js} +1 -1
- package/dist-ui/assets/Approvals-C5_8rBkL.js +1 -0
- package/dist-ui/assets/AttachApp-BRW1mJ7X.js +5 -0
- package/dist-ui/assets/Connections-BHsXRdYI.js +2 -0
- package/dist-ui/assets/{Gallery-B39L2Yma.js → Gallery-DB_OO7Vw.js} +1 -1
- package/dist-ui/assets/{PreApprovals-BsIhjMqb.js → PreApprovals-CXcU-_ug.js} +1 -1
- package/dist-ui/assets/{Protection-DlB09ABa.js → Protection-BF5OlzGC.js} +1 -1
- package/dist-ui/assets/{Safety-CN-oHO2h.js → Safety-DVb8sdbt.js} +1 -1
- package/dist-ui/assets/{Settings-BLD7G1Ag.js → Settings-XjNZ-wo-.js} +1 -1
- package/dist-ui/assets/StartPage-D8WBBhDy.js +1 -0
- package/dist-ui/assets/{Suggestions-Dp7pofcs.js → Suggestions-HZyd0jDU.js} +1 -1
- package/dist-ui/assets/Tools-GMaKxxIG.js +4 -0
- package/dist-ui/assets/index-CvZ3niHA.css +2 -0
- package/dist-ui/assets/index-DbHZ_SUd.js +16 -0
- package/dist-ui/assets/{kit-DQ7Oxf5n.js → kit-DRVm92_t.js} +1 -1
- package/dist-ui/index.html +3 -3
- package/package.json +4 -4
- package/dist-ui/assets/Approvals-Qo7bCcli.js +0 -1
- package/dist-ui/assets/AttachApp-0zRSPgSY.js +0 -5
- package/dist-ui/assets/Connections-CE0JGe8c.js +0 -2
- package/dist-ui/assets/StartPage-HuZSnmSr.js +0 -1
- package/dist-ui/assets/Tools-Bfot3bx5.js +0 -4
- package/dist-ui/assets/index-Khp0l1zp.js +0 -16
- package/dist-ui/assets/index-Ylyt4DEr.css +0 -2
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { dirname, isAbsolute, resolve } from "node:path";
|
|
3
|
+
import { existsSync, statSync } from "node:fs";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { AuditLog, expandPath, readRegistry } from "hmcp-core";
|
|
6
|
+
import { GuardInstallError, guardStatus, installGuard, loadGatewayConfig, uninstallGuard } from "hmcp-gateway";
|
|
7
|
+
import { badRequest, route, unprocessable } from "../http.js";
|
|
8
|
+
/**
|
|
9
|
+
* "Guard every Claude Code tool with hmcp": the guard's hooks in Claude
|
|
10
|
+
* Code's settings, added or taken out from the console.
|
|
11
|
+
*
|
|
12
|
+
* Like the connect routes, this writes another program's settings, so the
|
|
13
|
+
* browser names a scope and a toolbox and never a file: the settings path is
|
|
14
|
+
* the one `guardSettingsPath` resolves, and the config is the registered
|
|
15
|
+
* toolbox's own. The response names files and says what happened; it never
|
|
16
|
+
* echoes the settings file, which can hold a person's environment and keys.
|
|
17
|
+
*/
|
|
18
|
+
const Body = z
|
|
19
|
+
.object({
|
|
20
|
+
scope: z.enum(["user", "project"]),
|
|
21
|
+
projectDir: z.string().min(1).optional(),
|
|
22
|
+
/** Which toolbox's policy checks the calls. Optional when only one is registered. */
|
|
23
|
+
serverId: z.string().min(1).optional(),
|
|
24
|
+
install: z.boolean(),
|
|
25
|
+
confirm: z.literal(true)
|
|
26
|
+
})
|
|
27
|
+
.strict();
|
|
28
|
+
function projectDirOf(raw, scope) {
|
|
29
|
+
if (scope !== "project")
|
|
30
|
+
return undefined;
|
|
31
|
+
if (!raw)
|
|
32
|
+
throw unprocessable("a project install needs projectDir, the project folder");
|
|
33
|
+
if (raw.includes("\0") || !isAbsolute(raw) || raw.split(/[\\/]+/).some((p) => p === "." || p === "..")) {
|
|
34
|
+
throw unprocessable("projectDir must be an absolute path, written plainly");
|
|
35
|
+
}
|
|
36
|
+
const dir = resolve(raw);
|
|
37
|
+
if (!existsSync(dir) || !statSync(dir).isDirectory())
|
|
38
|
+
throw unprocessable(`projectDir ${dir} is not a folder`);
|
|
39
|
+
return dir;
|
|
40
|
+
}
|
|
41
|
+
/** The toolbox whose gateway.yaml the guard checks calls against. */
|
|
42
|
+
function toolboxConfig(options, serverId) {
|
|
43
|
+
const gateways = readRegistry(options.registryPath).servers.filter((s) => s.kind === "gateway");
|
|
44
|
+
const entry = serverId ? gateways.find((s) => s.id === serverId) : gateways.length === 1 ? gateways[0] : undefined;
|
|
45
|
+
if (!entry) {
|
|
46
|
+
throw unprocessable(serverId
|
|
47
|
+
? `there is no toolbox called "${serverId}"`
|
|
48
|
+
: "say which toolbox should check Claude Code's calls (serverId): there is more than one, or none");
|
|
49
|
+
}
|
|
50
|
+
return { id: entry.id, configPath: expandPath(entry.config_path) };
|
|
51
|
+
}
|
|
52
|
+
/** The toolbox's own log, so turning the guard on or off is recorded beside what it then decides. */
|
|
53
|
+
function auditFor(configPath, actor) {
|
|
54
|
+
try {
|
|
55
|
+
const { policy } = loadGatewayConfig(configPath);
|
|
56
|
+
return policy.audit.enabled
|
|
57
|
+
? new AuditLog({ config: policy.audit, actor, component: "hmcp-web", cwd: dirname(configPath) })
|
|
58
|
+
: null;
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export function guardRoutes(options) {
|
|
65
|
+
// The outermost layer, and the only place the real home folder is assumed.
|
|
66
|
+
const home = () => options.home ?? homedir();
|
|
67
|
+
return [
|
|
68
|
+
route("GET", "/api/v1/guard/claude-code", (ctx) => {
|
|
69
|
+
const scope = ctx.query.get("scope") ?? "user";
|
|
70
|
+
if (scope !== "user" && scope !== "project")
|
|
71
|
+
throw badRequest('scope must be "user" or "project"');
|
|
72
|
+
const projectDir = projectDirOf(ctx.query.get("projectDir"), scope);
|
|
73
|
+
try {
|
|
74
|
+
const status = guardStatus({ scope, home: home(), ...(projectDir ? { projectDir } : {}) });
|
|
75
|
+
const server = status.configPath
|
|
76
|
+
? readRegistry(options.registryPath).servers.find((s) => expandPath(s.config_path) === status.configPath)
|
|
77
|
+
: undefined;
|
|
78
|
+
return { ...status, serverId: server?.id ?? null };
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
if (err instanceof GuardInstallError)
|
|
82
|
+
throw unprocessable(err.message);
|
|
83
|
+
throw err;
|
|
84
|
+
}
|
|
85
|
+
}),
|
|
86
|
+
route("POST", "/api/v1/guard/claude-code", (ctx) => {
|
|
87
|
+
const parsed = Body.safeParse(ctx.body ?? {});
|
|
88
|
+
if (!parsed.success) {
|
|
89
|
+
throw badRequest("the request body is not valid", parsed.error.issues.map((i) => ({ path: i.path.join(".") || "(root)", message: i.message })));
|
|
90
|
+
}
|
|
91
|
+
const body = parsed.data;
|
|
92
|
+
const projectDir = projectDirOf(body.projectDir, body.scope);
|
|
93
|
+
const where = { scope: body.scope, home: home(), ...(projectDir ? { projectDir } : {}) };
|
|
94
|
+
try {
|
|
95
|
+
if (body.install) {
|
|
96
|
+
const { id, configPath } = toolboxConfig(options, body.serverId);
|
|
97
|
+
const result = installGuard({
|
|
98
|
+
...where,
|
|
99
|
+
configPath,
|
|
100
|
+
...(options.guardCliPath ? { local: true, cliPath: options.guardCliPath } : {})
|
|
101
|
+
});
|
|
102
|
+
const warning = result.changed
|
|
103
|
+
? note(auditFor(configPath, ctx.actor), {
|
|
104
|
+
tool: "(guard)",
|
|
105
|
+
effect: null,
|
|
106
|
+
decision: "allow",
|
|
107
|
+
rule_id: "guard.install",
|
|
108
|
+
reason: `the Claude Code guard was turned on by ${ctx.actor} in the console: hooks added to ${result.settingsPath}`,
|
|
109
|
+
outcome: "completed",
|
|
110
|
+
args_redacted: { scope: body.scope, settings: result.settingsPath, server_id: id }
|
|
111
|
+
})
|
|
112
|
+
: null;
|
|
113
|
+
return {
|
|
114
|
+
installed: true,
|
|
115
|
+
changed: result.changed,
|
|
116
|
+
settingsPath: result.settingsPath,
|
|
117
|
+
configPath: result.configPath,
|
|
118
|
+
serverId: id,
|
|
119
|
+
waitSeconds: result.waitSeconds,
|
|
120
|
+
observing: result.observing,
|
|
121
|
+
gitignoreWarning: result.gitignoreWarning,
|
|
122
|
+
restartHint: "Restart Claude Code after turning this on.",
|
|
123
|
+
warning
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
const before = guardStatus(where);
|
|
127
|
+
const result = uninstallGuard(where);
|
|
128
|
+
const warning = result.removed > 0 && before.configPath
|
|
129
|
+
? note(auditFor(before.configPath, ctx.actor), {
|
|
130
|
+
tool: "(guard)",
|
|
131
|
+
effect: null,
|
|
132
|
+
decision: "allow",
|
|
133
|
+
rule_id: "guard.uninstall",
|
|
134
|
+
reason: `the Claude Code guard was turned off by ${ctx.actor} in the console: hooks removed from ${result.settingsPath}`,
|
|
135
|
+
outcome: "completed",
|
|
136
|
+
args_redacted: { scope: body.scope, settings: result.settingsPath }
|
|
137
|
+
})
|
|
138
|
+
: null;
|
|
139
|
+
return {
|
|
140
|
+
installed: false,
|
|
141
|
+
changed: result.removed > 0,
|
|
142
|
+
settingsPath: result.settingsPath,
|
|
143
|
+
restartHint: "Restart Claude Code after turning this off.",
|
|
144
|
+
warning
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
catch (err) {
|
|
148
|
+
if (err instanceof GuardInstallError)
|
|
149
|
+
throw unprocessable(err.message);
|
|
150
|
+
throw err;
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
];
|
|
154
|
+
}
|
|
155
|
+
/** Appends one record; a failure is a warning, because the change itself already happened. */
|
|
156
|
+
function note(log, entry) {
|
|
157
|
+
if (!log)
|
|
158
|
+
return "this toolbox keeps no activity log, so the change was not recorded there";
|
|
159
|
+
try {
|
|
160
|
+
log.appendStrict(entry);
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
catch (err) {
|
|
164
|
+
return `the change was made but the activity log record failed: ${err.message}`;
|
|
165
|
+
}
|
|
166
|
+
}
|
package/dist/routes/runtime.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { ApiOptions } from "../api.js";
|
|
2
2
|
import { type Route } from "../http.js";
|
|
3
|
+
import { type LoadedServer } from "../model/server.js";
|
|
3
4
|
import { type ApplyState, type CommitResult } from "../model/gateway-config.js";
|
|
4
5
|
/** What a write just did to what is running. See `applyStateFor`. */
|
|
5
6
|
export declare function applyStateAfter(options: ApiOptions, id: string, result: CommitResult): ApplyState;
|
|
7
|
+
/** Takes the ready-made rules written for a removed server out of policy.yaml, and says what happened. */
|
|
8
|
+
export declare function removeServerRules(server: LoadedServer, name: string): {
|
|
9
|
+
removed: string[];
|
|
10
|
+
note: string | null;
|
|
11
|
+
};
|
|
6
12
|
export declare function runtimeRoutes(options: ApiOptions): Route[];
|
package/dist/routes/runtime.js
CHANGED
|
@@ -356,7 +356,7 @@ function commitWithEgress(server, plan, file, text, expectedDigest, acknowledged
|
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
358
|
/** Takes the ready-made rules written for a removed server out of policy.yaml, and says what happened. */
|
|
359
|
-
function removeServerRules(server, name) {
|
|
359
|
+
export function removeServerRules(server, name) {
|
|
360
360
|
const path = server.policyFile;
|
|
361
361
|
if (path === null || !server.gateway.config.policy_writes)
|
|
362
362
|
return { removed: [], note: null };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Upstream } from "hmcp-gateway";
|
|
1
2
|
import type { ApiOptions } from "../api.js";
|
|
2
3
|
import { type Route } from "../http.js";
|
|
3
4
|
/**
|
|
@@ -17,6 +18,13 @@ import { type Route } from "../http.js";
|
|
|
17
18
|
*/
|
|
18
19
|
/** The toolbox made for someone who has none yet. */
|
|
19
20
|
export declare const DEFAULT_GATEWAY_ID = "main";
|
|
21
|
+
/** Drops the keys `UpstreamSchema` filled with nothing, so the file says only what was chosen. */
|
|
22
|
+
export declare function upstreamYaml(upstream: Upstream): Record<string, unknown>;
|
|
23
|
+
/** Which registered toolboxes use which locked keys. Broken files are skipped. */
|
|
24
|
+
export declare function secretUsage(options: ApiOptions): Map<string, {
|
|
25
|
+
gatewayId: string;
|
|
26
|
+
upstream: string;
|
|
27
|
+
}[]>;
|
|
20
28
|
export interface ServersAddRouteOptions {
|
|
21
29
|
/** Tests only: let sign-in discovery reach a mock server on 127.0.0.1. */
|
|
22
30
|
readonly oauthAllowLoopbackForTests?: boolean;
|
|
@@ -161,7 +161,7 @@ function auditEntry(rule, reason, args) {
|
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
163
|
/** Drops the keys `UpstreamSchema` filled with nothing, so the file says only what was chosen. */
|
|
164
|
-
function upstreamYaml(upstream) {
|
|
164
|
+
export function upstreamYaml(upstream) {
|
|
165
165
|
const out = {};
|
|
166
166
|
for (const [key, value] of Object.entries(upstream)) {
|
|
167
167
|
if (value === undefined)
|
|
@@ -212,7 +212,7 @@ function secretRefsOf(upstream) {
|
|
|
212
212
|
return out;
|
|
213
213
|
}
|
|
214
214
|
/** Which registered toolboxes use which locked keys. Broken files are skipped. */
|
|
215
|
-
function secretUsage(options) {
|
|
215
|
+
export function secretUsage(options) {
|
|
216
216
|
const usage = new Map();
|
|
217
217
|
for (const entry of readRegistry(options.registryPath).servers) {
|
|
218
218
|
let config;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,B as t,Ct as n,E as r,Et as i,G as a,H as o,I as s,It as c,M as l,O as u,Ot as d,P as f,Pt as p,R as m,S as h,St as g,U as _,V as v,Z as y,_ as b,bt as x,c as ee,d as S,dt as C,et as w,gt as T,ht as E,k as D,kt as O,lt as k,ot as A,pt as j,s as M,tt as te,ut as N,w as ne,wt as re,x as P,y as F,yt as I,z as L}from"./kit-DQ7Oxf5n.js";import{Ct as ie,Dt as R,Et as z,Ot as B,St as ae,Tt as V,Zt as oe,_t as se,bt as H,gt as ce,kt as U,s as W,vt as G,wt as le,xt as K,yt as q}from"./index-Khp0l1zp.js";var J=c(),Y=O();function ue({open:e,onClose:n,serverId:i}){let s=F(),[c,u]=(0,J.useState)(null),[d,f]=(0,J.useState)(null),[m,h]=(0,J.useState)(!1),[g,_]=(0,J.useState)(``),[v,y]=(0,J.useState)(null),[b,x]=(0,J.useState)(null),[ee,S]=(0,J.useState)(!1),C=()=>{h(!0),f(null),p.verify(i).then(u).catch(e=>f(e.message)).finally(()=>h(!1))};(0,J.useEffect)(()=>{e&&(u(null),y(null),x(null),C())},[e,i]);let w=g.trim().toLowerCase(),D=/^[0-9a-f]{16,128}$/.test(w),O=()=>{D&&(S(!0),x(null),p.verify(i,w).then(e=>y({head:w,result:e})).catch(e=>x(e.message)).finally(()=>S(!1)))},k=async e=>{let t=await q(e);s.show(t?`ok`:`bad`,t?`Fingerprint copied`:`The browser did not allow copying`)};return(0,Y.jsx)(P,{open:e,onClose:n,title:`Check log integrity`,description:`Reads every entry in the activity log and checks that each still matches its fingerprint.`,width:600,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(E,{variant:`ghost`,icon:`refresh`,onClick:C,loading:m,children:`Check again`}),(0,Y.jsx)(E,{variant:`primary`,onClick:n,children:`Close`})]}),children:(0,Y.jsxs)(`div`,{className:`space-y-5 pb-1 text-[14px]`,children:[d&&(0,Y.jsx)(o,{tone:`danger`,title:`The check could not run`,actions:(0,Y.jsx)(E,{size:`sm`,onClick:C,children:`Try again`}),children:d}),!c&&!d&&(0,Y.jsx)(a,{lines:3,height:18}),c&&(0,Y.jsxs)(Y.Fragment,{children:[c.ok?(0,Y.jsx)(o,{tone:`ok`,role:`status`,title:`All ${L(c.count)} entries are intact`,children:`No entry has been edited, removed or put out of order.`}):(0,Y.jsxs)(o,{tone:`danger`,role:`alert`,title:`${t(c.problems.length,`problem`)} found in ${t(c.count,`entry`,`entries`)}`,children:[(0,Y.jsx)(`ul`,{className:`mt-1 space-y-1`,children:c.problems.slice(0,8).map(e=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsxs)(`span`,{className:`font-semibold`,children:[`Entry `,e.line,`:`]}),` `,de(e.message),` `,(0,Y.jsxs)(`span`,{className:`mono text-[11.5px] opacity-80`,children:[`(`,e.message,`)`]})]},`${e.line}-${e.message}`))}),c.problems.length>8&&(0,Y.jsxs)(`p`,{className:`mt-1`,children:[`And `,c.problems.length-8,` more.`]})]}),c.head?(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`mb-1.5 text-[13px] font-semibold`,children:`Fingerprint of the latest entry`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 rounded-2xl bg-sunken py-2 pr-2 pl-4`,children:[(0,Y.jsx)(`code`,{className:`mono min-w-0 flex-1 text-[12px] break-all`,children:c.head}),(0,Y.jsx)(T,{icon:`copy`,label:`Copy fingerprint`,variant:`soft`,size:36,onClick:()=>k(c.head)})]}),(0,Y.jsx)(`p`,{className:`mt-2 text-[13px] text-soft`,children:`Save this somewhere the toolbox cannot reach, such as a note or a ticket. The check above catches an entry that was edited or removed, but not the newest entries being cut off the end, because what is left still checks out. A fingerprint you saved earlier can prove nothing was cut.`})]}):(0,Y.jsx)(`p`,{className:`text-soft`,children:`The log has no entries yet, so there is no fingerprint to save.`}),(0,Y.jsxs)(`div`,{className:`border-t border-faint pt-5`,children:[(0,Y.jsx)(r,{label:`Compare with a fingerprint you saved earlier`,help:`Paste the fingerprint exactly as you saved it.`,error:g.trim()&&!D?`That does not look like a fingerprint. It is a long run of letters a–f and digits.`:null,children:(0,Y.jsx)(l,{value:g,onChange:_,mono:!0,onEnter:O,placeholder:`e.g. 3f9a…`})}),(0,Y.jsx)(`div`,{className:`mt-3`,children:(0,Y.jsx)(E,{onClick:O,disabled:!D,loading:ee,icon:`search`,children:`Compare fingerprint`})}),b&&(0,Y.jsx)(`p`,{role:`alert`,className:`mt-3 text-[13px] font-medium text-bad`,children:b}),v&&(0,Y.jsx)(`div`,{className:`mt-4`,children:v.result.headPosition===void 0?(0,Y.jsx)(o,{tone:`danger`,role:`alert`,title:`Not found in this log`,children:`The log may have been cut short or replaced, or the fingerprint came from a different toolbox's log. Treat this as something to look into.`}):(0,Y.jsxs)(o,{tone:`ok`,role:`status`,title:`Found at entry ${L(v.result.headPosition+1)} of ${L(v.result.count)}`,children:[`Everything up to that entry is still in the log, so nothing written before you saved the fingerprint was lost.`,` `,v.result.count-v.result.headPosition-1>0?`${t(v.result.count-v.result.headPosition-1,`entry has`,`entries have`)} been added since.`:`No entries have been added since.`]})})]})]})]})})}function de(e){return/^record altered/.test(e)?`This entry was changed after it was written.`:/^sequence gap/.test(e)?`An entry before this one was removed, or entries were put out of order.`:/^chain break/.test(e)?`This entry doesn't follow on from the one before it: something was removed or put in between.`:/^unparseable JSON/.test(e)?`This entry can't be read; the file was edited or cut short.`:e}function fe({record:t,onClose:r,nav:a,redaction:o}){let c=F();if(!t)return null;let l=t,u=K(l),p=l.rule_id===`gateway.unknown-tool`,g=p?null:U(l),_=A[l.outcome]?.tone??`neutral`;return(0,Y.jsx)(h,{open:!0,onClose:r,title:u?u.title:(0,Y.jsxs)(Y.Fragment,{children:[G(l),` `,(0,Y.jsx)(`span`,{className:`mono text-[17px]`,children:l.tool})]}),subtitle:`Entry ${L(l.seq)} · ${s(l.ts)}`,width:620,footer:(0,Y.jsx)(E,{icon:`copy`,onClick:async()=>{let e=await q(`${location.origin}${i(a,{seq:String(l.seq)})}`);c.show(e?`ok`:`bad`,e?`Link to this entry copied`:`The browser did not allow copying`)},children:`Copy link to entry`}),children:(0,Y.jsxs)(`div`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[p?(0,Y.jsx)(e,{tone:`warn`,children:`No such tool: your AI app asked for a tool this toolbox doesn't have`}):(0,Y.jsx)(w,{decision:l.decision}),!p&&C(l.outcome)!==k(l.decision)&&(0,Y.jsx)(e,{tone:_,children:V(l)?`You said no`:C(l.outcome)}),l.grant_id&&(0,Y.jsx)(e,{icon:`key`,children:`Released by a pre-approval`})]}),g&&(0,Y.jsxs)(`p`,{className:`flex gap-2 rounded-2xl bg-warn-tint px-4 py-3 text-[14px] text-ink`,children:[(0,Y.jsx)(d,{name:`eye`,size:18,className:`mt-0.5 shrink-0 text-warn`}),(0,Y.jsxs)(`span`,{children:[g,`. `,(0,Y.jsx)(b,{term:`watchOnly`})]})]}),(0,Y.jsxs)(X,{title:`What happened`,children:[(0,Y.jsx)(Z,{label:`Tool`,children:(0,Y.jsx)(`span`,{className:`mono text-[13px] break-all`,children:l.tool})}),(0,Y.jsx)(Z,{label:`What the tool does`,children:l.effect?(0,Y.jsx)(y,{effect:l.effect,withLabel:!0}):(0,Y.jsx)($,{children:N(null)})}),(0,Y.jsxs)(Z,{label:`Decided by`,children:[H(l),` `,(0,Y.jsx)(Q,{children:l.rule_id})]}),(0,Y.jsx)(Z,{label:`Reason`,children:l.reason||(0,Y.jsx)($,{children:`None recorded`})}),(0,Y.jsx)(Z,{label:`Took`,children:l.duration_ms===null?(0,Y.jsx)($,{children:`Not timed`}):m(l.duration_ms)}),l.error&&(0,Y.jsx)(Z,{label:`Error`,children:(0,Y.jsx)(`span`,{className:`text-bad`,children:l.error})})]}),(0,Y.jsxs)(X,{title:`Who asked`,children:[(0,Y.jsx)(Z,{label:`Asked by`,children:(0,Y.jsx)(`span`,{className:`break-all`,children:l.actor})}),(0,Y.jsx)(Z,{label:`Session`,children:(0,Y.jsx)(Q,{children:l.session})}),(0,Y.jsx)(Z,{label:`Written by`,children:(0,Y.jsx)(Q,{children:l.component})}),l.tenant!==null&&(0,Y.jsx)(Z,{label:(0,Y.jsxs)(Y.Fragment,{children:[`Customer `,(0,Y.jsx)(b,{term:`customer`})]}),children:l.tenant===``?(0,Y.jsx)($,{children:`None`}):l.tenant})]}),l.upstream&&(0,Y.jsxs)(X,{title:`Request to the connected server`,children:[(0,Y.jsx)(Z,{label:`Request`,children:(0,Y.jsxs)(`span`,{className:`mono text-[12.5px] break-all`,children:[l.upstream.method??`?`,` `,l.upstream.host??``,l.upstream.path??``]})}),(0,Y.jsx)(Z,{label:`Answer`,children:l.upstream.status===null?(0,Y.jsx)($,{children:`No status`}):(0,Y.jsx)(`span`,{className:`tnum`,children:l.upstream.status})}),l.upstream.bytes!==null&&(0,Y.jsx)(Z,{label:`Size`,children:f(l.upstream.bytes)})]}),(l.approval_id||l.grant_id)&&(0,Y.jsxs)(X,{title:`Linked`,children:[l.approval_id&&(0,Y.jsx)(Z,{label:`Approval request`,children:(0,Y.jsx)(me,{href:n(a,`/approvals`,{id:l.approval_id}),children:l.approval_id})}),l.grant_id&&(0,Y.jsx)(Z,{label:(0,Y.jsxs)(Y.Fragment,{children:[`Pre-approval `,(0,Y.jsx)(b,{term:`preApproval`})]}),children:(0,Y.jsx)(me,{href:n(a,`/pre-approvals`,{id:l.grant_id}),children:l.grant_id})})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`h3`,{className:`mb-2 flex items-center gap-2 text-[15px] font-semibold`,children:[`Inputs, as recorded `,(0,Y.jsx)(b,{term:`redaction`})]}),l.args_redacted===null?(0,Y.jsx)(`p`,{className:`text-[14px] text-soft`,children:`This toolbox does not record call inputs.`}):(0,Y.jsx)(S,{label:`Inputs as recorded`,maxHeight:260,children:JSON.stringify(l.args_redacted,null,2)}),o&&l.args_redacted!==null&&(0,Y.jsxs)(`details`,{className:`mt-3 rounded-2xl border border-faint px-4 py-3 text-[13px]`,children:[(0,Y.jsx)(`summary`,{className:`cursor-pointer font-semibold`,children:`What the hidden-value markers mean`}),(0,Y.jsx)(`ul`,{className:`mt-2 space-y-1.5`,children:o.markers.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-wrap gap-x-3`,children:[(0,Y.jsx)(Q,{children:e.marker}),(0,Y.jsxs)(`span`,{className:`text-muted`,children:[pe(e.meaning),`.`]})]},e.marker))}),(0,Y.jsx)(`p`,{className:`mt-2 text-soft`,children:`Inputs are hidden by their name as well as their content, so a harmless value can still be hidden. The original values were never written down, so they cannot be recovered from the log.`})]})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`h3`,{className:`mb-2 flex items-center gap-2 text-[15px] font-semibold`,children:[`Tamper check `,(0,Y.jsx)(b,{term:`hashChain`})]}),(0,Y.jsxs)(`ol`,{className:`space-y-2 text-[13px]`,children:[(0,Y.jsx)(he,{label:`Fingerprint of the entry before`,value:l.prev_hash}),(0,Y.jsx)(`li`,{"aria-hidden":!0,className:`pl-4 text-soft`,children:(0,Y.jsx)(d,{name:`chevron`,size:16})}),(0,Y.jsx)(he,{label:`Fingerprint of this entry`,value:l.hash,strong:!0})]}),(0,Y.jsx)(`p`,{className:`mt-2 text-[13px] text-soft`,children:`This entry's fingerprint covers its contents and the one before it, so editing or removing any earlier entry breaks every fingerprint after it.`}),(0,Y.jsxs)(`p`,{className:`mt-3 text-[12.5px] text-soft`,children:[`Fingerprint of the inputs: `,(0,Y.jsx)(Q,{children:l.args_hash})]})]})]})})}var pe=e=>e.charAt(0).toUpperCase()+e.slice(1);function X({title:e,children:t}){return(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h3`,{className:`mb-2 text-[15px] font-semibold`,children:e}),(0,Y.jsx)(`dl`,{className:`divide-y divide-faint rounded-2xl border border-faint px-4`,children:t})]})}function Z({label:e,children:t}){return(0,Y.jsxs)(`div`,{className:`grid gap-1 py-2.5 sm:grid-cols-[160px_1fr] sm:gap-4`,children:[(0,Y.jsx)(`dt`,{className:`flex items-center gap-1.5 text-[13px] text-soft`,children:e}),(0,Y.jsx)(`dd`,{className:`min-w-0 text-[14px]`,children:t})]})}var Q=({children:e})=>(0,Y.jsx)(`code`,{className:`mono text-[12px] break-all text-soft`,children:e}),$=({children:e})=>(0,Y.jsx)(`span`,{className:`text-soft`,children:e});function me({href:e,children:t}){return(0,Y.jsx)(`a`,{href:e,onClick:g,className:`mono text-[12.5px] break-all text-ok underline underline-offset-2`,children:t})}function he({label:e,value:t,strong:n}){return(0,Y.jsxs)(`li`,{className:n?`rounded-2xl bg-sunken px-4 py-3`:`rounded-2xl border border-faint px-4 py-3`,children:[(0,Y.jsx)(`span`,{className:`block text-[12.5px] text-soft`,children:e}),(0,Y.jsx)(`code`,{className:`mono mt-1 block text-[12px] break-all text-ink`,children:t})]})}function ge(){let{serverId:e,server:n,tenant:a,tenantInfo:s,nav:c}=oe(),[d,f]=(0,J.useState)(()=>le(c)),[m,h]=(0,J.useState)(()=>Date.now()),[g,_]=(0,J.useState)([]),[v,y]=(0,J.useState)(),[b,S]=(0,J.useState)(null),[w,T]=(0,J.useState)(!1),[O,N]=(0,J.useState)(!1),[P=``,F=``,I=``]=x([d.tool,d.actor,d.component].join(`\0`),300).split(`\0`),R={...d,tool:P,actor:F,component:I};(0,J.useEffect)(()=>{re(i(c,{...ae(R),seq:b?String(b.seq):null}))},[JSON.stringify(R),b?.seq]);let z=se(R,a,m),B=JSON.stringify(z),V=M(()=>p.audit(e,v===void 0?z:{...z,cursor:String(v)}),[e,B,v]),H=M(()=>p.redaction(),[]),U=v===void 0?V.data?.records??[]:[...g,...V.data?.records??[]],W=V.loading&&!V.data;function G(e){f(t=>({...t,...e})),y(void 0),_([]),e.range!==void 0&&h(Date.now())}let K=()=>{y(void 0),_([]),h(Date.now()),V.reload()},[q,de]=(0,J.useState)(()=>c.query.get(`seq`));(0,J.useEffect)(()=>{if(!q)return;let t=Number(q);if(de(null),!Number.isInteger(t)||t<0)return;let n={limit:`1`,cursor:String(t+1)};!d.allTenants&&a!==null&&(n.tenant=a),p.audit(e,n).then(e=>{let n=e.records.find(e=>e.seq===t);n&&S(n)}).catch(()=>void 0)},[q]);let pe=(0,J.useMemo)(()=>[{value:``,label:`Any decision`},...(H.data?.decisions??Object.keys(te).map(e=>({value:e,label:e}))).map(e=>({value:e.value,label:k(e.value)}))],[H.data]),X=(0,J.useMemo)(()=>[{value:``,label:`Any result`},...(H.data?.outcomes??Object.keys(A).map(e=>({value:e,label:e}))).map(e=>({value:e.value,label:C(e.value)}))],[H.data]),Z=s?.configured?s.tenants.filter(e=>e!==``):[];return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(ee,{title:`Activity`,subtitle:`Every call your AI made through this toolbox, and what happened. Each entry is chained to the one before it, so edits can be detected.`,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(E,{variant:`primary`,icon:`shield-check`,onClick:()=>T(!0),children:`Check log integrity`}),(0,Y.jsx)(E,{icon:`download`,onClick:()=>N(!0),disabled:U.length===0,children:`Download log`})]})}),(0,Y.jsxs)(`div`,{className:`space-y-5`,children:[(0,Y.jsxs)(j,{title:`Filters`,actions:ie(d)&&(0,Y.jsx)(E,{size:`sm`,variant:`ghost`,icon:`x`,onClick:()=>G(ce),children:`Clear filters`}),children:[(0,Y.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-4`,children:[(0,Y.jsx)(r,{label:`Result`,children:(0,Y.jsx)(D,{value:d.outcome,onChange:e=>G({outcome:e}),options:X})}),(0,Y.jsx)(r,{label:`Decision`,children:(0,Y.jsx)(D,{value:d.decision,onChange:e=>G({decision:e}),options:pe})}),(0,Y.jsx)(r,{label:`Tool`,help:`Use * to match any text, like files.*`,children:(0,Y.jsx)(l,{value:d.tool,onChange:e=>G({tool:e}),mono:!0,placeholder:`Any tool`})}),(0,Y.jsx)(r,{label:`Who asked`,children:(0,Y.jsx)(l,{value:d.actor,onChange:e=>G({actor:e}),placeholder:`Anyone`})}),Z.length>0&&(0,Y.jsx)(r,{label:`Customer`,children:(0,Y.jsx)(D,{value:d.allTenants?`*`:a??``,onChange:e=>{e===`*`?G({allTenants:!0}):e===a?G({allTenants:!1}):re(i(c,{tenant:e,allTenants:null}))},options:[...a===null?[{value:``,label:`Choose a customer`}]:[],...Z.map(e=>({value:e,label:e})),{value:`*`,label:`All customers`}]})}),d.component&&(0,Y.jsx)(r,{label:`Written by`,technical:`component`,children:(0,Y.jsx)(l,{value:d.component,onChange:e=>G({component:e}),mono:!0})})]}),(0,Y.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-end justify-between gap-4 border-t border-faint pt-5`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-[13px] font-semibold text-soft`,"aria-hidden":!0,children:`When`}),(0,Y.jsx)(u,{label:`Time range`,value:d.range,onChange:e=>G({range:e}),options:[{value:``,label:`Any time`},{value:`1h`,label:`Last hour`},{value:`24h`,label:`Last 24 hours`},{value:`7d`,label:`Last 7 days`},{value:`custom`,label:`Custom`}]})]}),(0,Y.jsx)(ne,{checked:d.noteworthy,onChange:e=>G({noteworthy:e}),label:`Only problems`,description:`Blocked, failed or still waiting.`})]}),d.range===`custom`&&(0,Y.jsxs)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2`,children:[(0,Y.jsx)(xe,{label:`From`,value:d.since,onChange:e=>G({since:e})}),(0,Y.jsx)(xe,{label:`Until`,value:d.until,onChange:e=>G({until:e}),help:`Leave empty for up to now.`})]})]}),V.data&&V.data.malformed>0&&(0,Y.jsxs)(o,{tone:`warn`,title:`${t(V.data.malformed,`line`)} could not be read`,children:[`Of the `,L(V.data.scanned),` lines read for this list, `,L(V.data.malformed),` were damaged and skipped. Run the integrity check to see where.`]}),(0,Y.jsxs)(j,{title:W?`Entries`:`${t(U.length,`entry`,`entries`)}${V.data?.nextCursor==null?``:` so far`}`,actions:(0,Y.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:K,loading:V.loading&&!!V.data,children:`Refresh list`}),children:[(0,Y.jsx)(_e,{loading:W,error:V.error,onRetry:V.reload,records:U,filtered:ie(d),onClear:()=>G(ce),onOpen:S,mixedCustomers:d.allTenants}),V.data?.nextCursor!=null&&(0,Y.jsx)(`div`,{className:`mt-5 flex flex-wrap items-center gap-3`,children:(0,Y.jsx)(E,{icon:`chevron`,loading:V.loading,onClick:()=>{_(U),y(V.data.nextCursor)},children:`Load older entries`})})]})]}),(0,Y.jsx)(fe,{record:b,onClose:()=>S(null),nav:c,redaction:H.data}),(0,Y.jsx)(ue,{open:w,onClose:()=>T(!1),serverId:e}),(0,Y.jsx)(Se,{open:O,onClose:()=>N(!1),records:U,stem:`activity-${n.id}-${new Date().toISOString().slice(0,10)}`})]})}function _e({loading:e,error:t,onRetry:n,records:r,filtered:i,onClear:s,onOpen:c,mixedCustomers:l}){return t?(0,Y.jsx)(o,{tone:`danger`,title:`The activity log could not be read`,actions:(0,Y.jsx)(E,{size:`sm`,onClick:n,children:`Try again`}),children:t}):e?(0,Y.jsx)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[0,1,2,3,4].map(e=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(`span`,{className:`skeleton h-10 w-10 shrink-0 rounded-full`}),(0,Y.jsx)(a,{lines:2})]},e))}):r.length===0?i?(0,Y.jsx)(_,{icon:`filter`,title:`No entries match these filters`,actions:(0,Y.jsx)(E,{onClick:s,children:`Clear filters`}),children:`The whole log was searched. Try a wider time range or fewer filters.`}):(0,Y.jsx)(_,{icon:`activity`,title:`No activity yet`,children:`Calls appear here as soon as an AI app connected to this toolbox uses a tool.`}):(0,Y.jsx)(`ul`,{className:`-mx-2`,children:r.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(be,{record:e,onOpen:()=>c(e),showCustomer:l})},`${e.seq}-${e.id}`))})}var ve={ok:`bg-ok-tint text-ok`,warn:`bg-warn-tint text-warn`,bad:`bg-bad-tint text-bad`,neutral:`bg-sunken text-muted`};function ye(e,t){if(!t&&(e.actor===`agent`||!e.actor))return`Your AI app`;if(e.actor===`gateway`)return`The toolbox`;let n=e.args_redacted?.origin;return t&&(n===`console`||e.component===`hmcp-web`||e.rule_id===`approval.decide`||e.tool?.startsWith(`(`))?e.actor&&e.actor!==`console`?`You (${e.actor})`:`You`:e.actor}function be({record:t,onOpen:n,showCustomer:r}){let i=K(t),a=t.rule_id===`gateway.unknown-tool`,o=a?null:U(t),c=A[t.outcome]?.tone??`neutral`,l=i?`neutral`:a?`warn`:t.outcome===`error`?`bad`:te[t.decision]?.tone??`neutral`,u=i?.icon??(t.decision===`deny`?`x`:t.decision===`approve`?`clock`:`check`);return(0,Y.jsxs)(`button`,{type:`button`,onClick:n,className:`flex w-full flex-wrap items-center gap-x-3 gap-y-2 rounded-2xl px-2 py-3 text-left transition-colors hover:bg-faint focus-visible:bg-faint`,children:[(0,Y.jsx)(`span`,{className:I(`grid h-10 w-10 shrink-0 place-items-center rounded-full`,ve[l]),children:(0,Y.jsx)(d,{name:u,size:18,strokeWidth:2})}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 basis-56`,children:[(0,Y.jsx)(`span`,{className:`block truncate text-[14.5px] font-medium`,children:i?(0,Y.jsxs)(Y.Fragment,{children:[i.title,t.tool&&!t.tool.startsWith(`(`)&&(0,Y.jsx)(`span`,{className:`ml-1.5 text-soft`,title:t.tool,children:W(t.tool).label})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`text-soft`,children:G(t)}),` `,(0,Y.jsx)(`span`,{title:t.tool,children:W(t.tool).label})]})}),(0,Y.jsxs)(`span`,{className:`mt-0.5 block truncate text-[12.5px] text-soft`,children:[(0,Y.jsx)(`time`,{dateTime:t.ts,title:s(t.ts),children:v(t.ts)}),` · `,ye(t,i!==null),r&&t.tenant?` · ${t.tenant}`:``,!i&&(0,Y.jsxs)(Y.Fragment,{children:[` · `,H(t)]})]}),o&&(0,Y.jsxs)(`span`,{className:`mt-1 flex items-center gap-1.5 text-[12.5px] font-medium text-warn`,children:[(0,Y.jsx)(d,{name:`eye`,size:14,strokeWidth:2}),o]})]}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-1.5 max-sm:pl-[52px] sm:shrink-0`,children:[a?(0,Y.jsx)(e,{tone:`warn`,children:`No such tool`}):!i&&(0,Y.jsx)(w,{decision:t.decision}),!a&&(i||C(t.outcome)!==k(t.decision))&&(0,Y.jsx)(e,{tone:c,children:V(t)?`You said no`:C(t.outcome)}),(0,Y.jsx)(d,{name:`chevron-right`,size:18,className:`text-soft max-sm:hidden`})]})]})}function xe({label:e,value:t,onChange:n,help:i}){return(0,Y.jsx)(r,{label:e,help:i,children:(0,Y.jsx)(`input`,{type:`datetime-local`,value:t,onChange:e=>n(e.target.value),className:`field`})})}function Se({open:e,onClose:n,records:r,stem:i}){let[a,o]=(0,J.useState)(`jsonl`);return(0,Y.jsx)(P,{open:e,onClose:n,title:`Download log`,description:`Saves the ${t(r.length,`entry`,`entries`)} listed now, with the filters you set. Load older entries first to include more.`,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(E,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,Y.jsx)(E,{variant:`primary`,icon:`download`,onClick:()=>{a===`jsonl`?z(`${i}.jsonl`,`application/x-ndjson`,B(r)):z(`${i}.csv`,`text/csv`,R(r)),n()},children:`Download file`})]}),children:(0,Y.jsxs)(`fieldset`,{className:`space-y-3`,children:[(0,Y.jsx)(`legend`,{className:`sr-only`,children:`File format`}),(0,Y.jsx)(Ce,{checked:a===`jsonl`,onSelect:()=>o(`jsonl`),title:`Exact log entries (JSONL)`,children:`One entry per line, exactly as written, fingerprints included. Use this to keep a copy or to check it later.`}),(0,Y.jsx)(Ce,{checked:a===`csv`,onSelect:()=>o(`csv`),title:`Spreadsheet (CSV)`,children:`The main columns, for sorting and counting in a spreadsheet. Fingerprints are left out.`})]})})}function Ce({checked:e,onSelect:t,title:n,children:r}){return(0,Y.jsxs)(`label`,{className:I(`flex cursor-pointer gap-3 rounded-2xl border-[1.5px] px-4 py-3 transition-colors`,e?`border-[var(--primary)] bg-ok-tint/40`:`border-line hover:bg-faint`),children:[(0,Y.jsx)(`input`,{type:`radio`,name:`log-format`,checked:e,onChange:t,className:`mt-1 accent-[var(--primary)]`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`block text-[14px] font-semibold`,children:n}),(0,Y.jsx)(`span`,{className:`mt-0.5 block text-[13px] text-soft`,children:r})]})]})}export{ge as ActivityPage};
|
|
1
|
+
import{$ as e,B as t,Ct as n,E as r,Et as i,G as a,H as o,I as s,It as c,M as l,O as u,Ot as d,P as f,Pt as p,R as m,S as h,St as g,U as _,V as v,Z as y,_ as b,bt as x,c as ee,d as S,dt as C,et as w,gt as T,ht as E,k as D,kt as O,lt as k,ot as A,pt as j,s as M,tt as te,ut as N,w as ne,wt as re,x as P,y as F,yt as I,z as L}from"./kit-DRVm92_t.js";import{Ct as ie,Dt as R,Et as z,Ot as B,St as ae,Tt as V,_t as oe,bt as H,gt as se,kt as U,s as W,un as ce,vt as G,wt as le,xt as K,yt as q}from"./index-DbHZ_SUd.js";var J=c(),Y=O();function ue({open:e,onClose:n,serverId:i}){let s=F(),[c,u]=(0,J.useState)(null),[d,f]=(0,J.useState)(null),[m,h]=(0,J.useState)(!1),[g,_]=(0,J.useState)(``),[v,y]=(0,J.useState)(null),[b,x]=(0,J.useState)(null),[ee,S]=(0,J.useState)(!1),C=()=>{h(!0),f(null),p.verify(i).then(u).catch(e=>f(e.message)).finally(()=>h(!1))};(0,J.useEffect)(()=>{e&&(u(null),y(null),x(null),C())},[e,i]);let w=g.trim().toLowerCase(),D=/^[0-9a-f]{16,128}$/.test(w),O=()=>{D&&(S(!0),x(null),p.verify(i,w).then(e=>y({head:w,result:e})).catch(e=>x(e.message)).finally(()=>S(!1)))},k=async e=>{let t=await q(e);s.show(t?`ok`:`bad`,t?`Fingerprint copied`:`The browser did not allow copying`)};return(0,Y.jsx)(P,{open:e,onClose:n,title:`Check log integrity`,description:`Reads every entry in the activity log and checks that each still matches its fingerprint.`,width:600,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(E,{variant:`ghost`,icon:`refresh`,onClick:C,loading:m,children:`Check again`}),(0,Y.jsx)(E,{variant:`primary`,onClick:n,children:`Close`})]}),children:(0,Y.jsxs)(`div`,{className:`space-y-5 pb-1 text-[14px]`,children:[d&&(0,Y.jsx)(o,{tone:`danger`,title:`The check could not run`,actions:(0,Y.jsx)(E,{size:`sm`,onClick:C,children:`Try again`}),children:d}),!c&&!d&&(0,Y.jsx)(a,{lines:3,height:18}),c&&(0,Y.jsxs)(Y.Fragment,{children:[c.ok?(0,Y.jsx)(o,{tone:`ok`,role:`status`,title:`All ${L(c.count)} entries are intact`,children:`No entry has been edited, removed or put out of order.`}):(0,Y.jsxs)(o,{tone:`danger`,role:`alert`,title:`${t(c.problems.length,`problem`)} found in ${t(c.count,`entry`,`entries`)}`,children:[(0,Y.jsx)(`ul`,{className:`mt-1 space-y-1`,children:c.problems.slice(0,8).map(e=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsxs)(`span`,{className:`font-semibold`,children:[`Entry `,e.line,`:`]}),` `,de(e.message),` `,(0,Y.jsxs)(`span`,{className:`mono text-[11.5px] opacity-80`,children:[`(`,e.message,`)`]})]},`${e.line}-${e.message}`))}),c.problems.length>8&&(0,Y.jsxs)(`p`,{className:`mt-1`,children:[`And `,c.problems.length-8,` more.`]})]}),c.head?(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`mb-1.5 text-[13px] font-semibold`,children:`Fingerprint of the latest entry`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 rounded-2xl bg-sunken py-2 pr-2 pl-4`,children:[(0,Y.jsx)(`code`,{className:`mono min-w-0 flex-1 text-[12px] break-all`,children:c.head}),(0,Y.jsx)(T,{icon:`copy`,label:`Copy fingerprint`,variant:`soft`,size:36,onClick:()=>k(c.head)})]}),(0,Y.jsx)(`p`,{className:`mt-2 text-[13px] text-soft`,children:`Save this somewhere the toolbox cannot reach, such as a note or a ticket. The check above catches an entry that was edited or removed, but not the newest entries being cut off the end, because what is left still checks out. A fingerprint you saved earlier can prove nothing was cut.`})]}):(0,Y.jsx)(`p`,{className:`text-soft`,children:`The log has no entries yet, so there is no fingerprint to save.`}),(0,Y.jsxs)(`div`,{className:`border-t border-faint pt-5`,children:[(0,Y.jsx)(r,{label:`Compare with a fingerprint you saved earlier`,help:`Paste the fingerprint exactly as you saved it.`,error:g.trim()&&!D?`That does not look like a fingerprint. It is a long run of letters a–f and digits.`:null,children:(0,Y.jsx)(l,{value:g,onChange:_,mono:!0,onEnter:O,placeholder:`e.g. 3f9a…`})}),(0,Y.jsx)(`div`,{className:`mt-3`,children:(0,Y.jsx)(E,{onClick:O,disabled:!D,loading:ee,icon:`search`,children:`Compare fingerprint`})}),b&&(0,Y.jsx)(`p`,{role:`alert`,className:`mt-3 text-[13px] font-medium text-bad`,children:b}),v&&(0,Y.jsx)(`div`,{className:`mt-4`,children:v.result.headPosition===void 0?(0,Y.jsx)(o,{tone:`danger`,role:`alert`,title:`Not found in this log`,children:`The log may have been cut short or replaced, or the fingerprint came from a different toolbox's log. Treat this as something to look into.`}):(0,Y.jsxs)(o,{tone:`ok`,role:`status`,title:`Found at entry ${L(v.result.headPosition+1)} of ${L(v.result.count)}`,children:[`Everything up to that entry is still in the log, so nothing written before you saved the fingerprint was lost.`,` `,v.result.count-v.result.headPosition-1>0?`${t(v.result.count-v.result.headPosition-1,`entry has`,`entries have`)} been added since.`:`No entries have been added since.`]})})]})]})]})})}function de(e){return/^record altered/.test(e)?`This entry was changed after it was written.`:/^sequence gap/.test(e)?`An entry before this one was removed, or entries were put out of order.`:/^chain break/.test(e)?`This entry doesn't follow on from the one before it: something was removed or put in between.`:/^unparseable JSON/.test(e)?`This entry can't be read; the file was edited or cut short.`:e}function fe({record:t,onClose:r,nav:a,redaction:o}){let c=F();if(!t)return null;let l=t,u=K(l),p=l.rule_id===`gateway.unknown-tool`,g=p?null:U(l),_=A[l.outcome]?.tone??`neutral`;return(0,Y.jsx)(h,{open:!0,onClose:r,title:u?u.title:(0,Y.jsxs)(Y.Fragment,{children:[G(l),` `,(0,Y.jsx)(`span`,{className:`mono text-[17px]`,children:l.tool})]}),subtitle:`Entry ${L(l.seq)} · ${s(l.ts)}`,width:620,footer:(0,Y.jsx)(E,{icon:`copy`,onClick:async()=>{let e=await q(`${location.origin}${i(a,{seq:String(l.seq)})}`);c.show(e?`ok`:`bad`,e?`Link to this entry copied`:`The browser did not allow copying`)},children:`Copy link to entry`}),children:(0,Y.jsxs)(`div`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[p?(0,Y.jsx)(e,{tone:`warn`,children:`No such tool: your AI app asked for a tool this toolbox doesn't have`}):(0,Y.jsx)(w,{decision:l.decision}),!p&&C(l.outcome)!==k(l.decision)&&(0,Y.jsx)(e,{tone:_,children:V(l)?`You said no`:C(l.outcome)}),l.grant_id&&(0,Y.jsx)(e,{icon:`key`,children:`Released by a pre-approval`})]}),g&&(0,Y.jsxs)(`p`,{className:`flex gap-2 rounded-2xl bg-warn-tint px-4 py-3 text-[14px] text-ink`,children:[(0,Y.jsx)(d,{name:`eye`,size:18,className:`mt-0.5 shrink-0 text-warn`}),(0,Y.jsxs)(`span`,{children:[g,`. `,(0,Y.jsx)(b,{term:`watchOnly`})]})]}),(0,Y.jsxs)(X,{title:`What happened`,children:[(0,Y.jsx)(Z,{label:`Tool`,children:(0,Y.jsx)(`span`,{className:`mono text-[13px] break-all`,children:l.tool})}),(0,Y.jsx)(Z,{label:`What the tool does`,children:l.effect?(0,Y.jsx)(y,{effect:l.effect,withLabel:!0}):(0,Y.jsx)($,{children:N(null)})}),(0,Y.jsxs)(Z,{label:`Decided by`,children:[H(l),` `,(0,Y.jsx)(Q,{children:l.rule_id})]}),(0,Y.jsx)(Z,{label:`Reason`,children:l.reason||(0,Y.jsx)($,{children:`None recorded`})}),(0,Y.jsx)(Z,{label:`Took`,children:l.duration_ms===null?(0,Y.jsx)($,{children:`Not timed`}):m(l.duration_ms)}),l.error&&(0,Y.jsx)(Z,{label:`Error`,children:(0,Y.jsx)(`span`,{className:`text-bad`,children:l.error})})]}),(0,Y.jsxs)(X,{title:`Who asked`,children:[(0,Y.jsx)(Z,{label:`Asked by`,children:(0,Y.jsx)(`span`,{className:`break-all`,children:l.actor})}),(0,Y.jsx)(Z,{label:`Session`,children:(0,Y.jsx)(Q,{children:l.session})}),(0,Y.jsx)(Z,{label:`Written by`,children:(0,Y.jsx)(Q,{children:l.component})}),l.tenant!==null&&(0,Y.jsx)(Z,{label:(0,Y.jsxs)(Y.Fragment,{children:[`Customer `,(0,Y.jsx)(b,{term:`customer`})]}),children:l.tenant===``?(0,Y.jsx)($,{children:`None`}):l.tenant})]}),l.upstream&&(0,Y.jsxs)(X,{title:`Request to the connected server`,children:[(0,Y.jsx)(Z,{label:`Request`,children:(0,Y.jsxs)(`span`,{className:`mono text-[12.5px] break-all`,children:[l.upstream.method??`?`,` `,l.upstream.host??``,l.upstream.path??``]})}),(0,Y.jsx)(Z,{label:`Answer`,children:l.upstream.status===null?(0,Y.jsx)($,{children:`No status`}):(0,Y.jsx)(`span`,{className:`tnum`,children:l.upstream.status})}),l.upstream.bytes!==null&&(0,Y.jsx)(Z,{label:`Size`,children:f(l.upstream.bytes)})]}),(l.approval_id||l.grant_id)&&(0,Y.jsxs)(X,{title:`Linked`,children:[l.approval_id&&(0,Y.jsx)(Z,{label:`Approval request`,children:(0,Y.jsx)(me,{href:n(a,`/approvals`,{id:l.approval_id}),children:l.approval_id})}),l.grant_id&&(0,Y.jsx)(Z,{label:(0,Y.jsxs)(Y.Fragment,{children:[`Pre-approval `,(0,Y.jsx)(b,{term:`preApproval`})]}),children:(0,Y.jsx)(me,{href:n(a,`/pre-approvals`,{id:l.grant_id}),children:l.grant_id})})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`h3`,{className:`mb-2 flex items-center gap-2 text-[15px] font-semibold`,children:[`Inputs, as recorded `,(0,Y.jsx)(b,{term:`redaction`})]}),l.args_redacted===null?(0,Y.jsx)(`p`,{className:`text-[14px] text-soft`,children:`This toolbox does not record call inputs.`}):(0,Y.jsx)(S,{label:`Inputs as recorded`,maxHeight:260,children:JSON.stringify(l.args_redacted,null,2)}),o&&l.args_redacted!==null&&(0,Y.jsxs)(`details`,{className:`mt-3 rounded-2xl border border-faint px-4 py-3 text-[13px]`,children:[(0,Y.jsx)(`summary`,{className:`cursor-pointer font-semibold`,children:`What the hidden-value markers mean`}),(0,Y.jsx)(`ul`,{className:`mt-2 space-y-1.5`,children:o.markers.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-wrap gap-x-3`,children:[(0,Y.jsx)(Q,{children:e.marker}),(0,Y.jsxs)(`span`,{className:`text-muted`,children:[pe(e.meaning),`.`]})]},e.marker))}),(0,Y.jsx)(`p`,{className:`mt-2 text-soft`,children:`Inputs are hidden by their name as well as their content, so a harmless value can still be hidden. The original values were never written down, so they cannot be recovered from the log.`})]})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`h3`,{className:`mb-2 flex items-center gap-2 text-[15px] font-semibold`,children:[`Tamper check `,(0,Y.jsx)(b,{term:`hashChain`})]}),(0,Y.jsxs)(`ol`,{className:`space-y-2 text-[13px]`,children:[(0,Y.jsx)(he,{label:`Fingerprint of the entry before`,value:l.prev_hash}),(0,Y.jsx)(`li`,{"aria-hidden":!0,className:`pl-4 text-soft`,children:(0,Y.jsx)(d,{name:`chevron`,size:16})}),(0,Y.jsx)(he,{label:`Fingerprint of this entry`,value:l.hash,strong:!0})]}),(0,Y.jsx)(`p`,{className:`mt-2 text-[13px] text-soft`,children:`This entry's fingerprint covers its contents and the one before it, so editing or removing any earlier entry breaks every fingerprint after it.`}),(0,Y.jsxs)(`p`,{className:`mt-3 text-[12.5px] text-soft`,children:[`Fingerprint of the inputs: `,(0,Y.jsx)(Q,{children:l.args_hash})]})]})]})})}var pe=e=>e.charAt(0).toUpperCase()+e.slice(1);function X({title:e,children:t}){return(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h3`,{className:`mb-2 text-[15px] font-semibold`,children:e}),(0,Y.jsx)(`dl`,{className:`divide-y divide-faint rounded-2xl border border-faint px-4`,children:t})]})}function Z({label:e,children:t}){return(0,Y.jsxs)(`div`,{className:`grid gap-1 py-2.5 sm:grid-cols-[160px_1fr] sm:gap-4`,children:[(0,Y.jsx)(`dt`,{className:`flex items-center gap-1.5 text-[13px] text-soft`,children:e}),(0,Y.jsx)(`dd`,{className:`min-w-0 text-[14px]`,children:t})]})}var Q=({children:e})=>(0,Y.jsx)(`code`,{className:`mono text-[12px] break-all text-soft`,children:e}),$=({children:e})=>(0,Y.jsx)(`span`,{className:`text-soft`,children:e});function me({href:e,children:t}){return(0,Y.jsx)(`a`,{href:e,onClick:g,className:`mono text-[12.5px] break-all text-ok underline underline-offset-2`,children:t})}function he({label:e,value:t,strong:n}){return(0,Y.jsxs)(`li`,{className:n?`rounded-2xl bg-sunken px-4 py-3`:`rounded-2xl border border-faint px-4 py-3`,children:[(0,Y.jsx)(`span`,{className:`block text-[12.5px] text-soft`,children:e}),(0,Y.jsx)(`code`,{className:`mono mt-1 block text-[12px] break-all text-ink`,children:t})]})}function ge(){let{serverId:e,server:n,tenant:a,tenantInfo:s,nav:c}=ce(),[d,f]=(0,J.useState)(()=>le(c)),[m,h]=(0,J.useState)(()=>Date.now()),[g,_]=(0,J.useState)([]),[v,y]=(0,J.useState)(),[b,S]=(0,J.useState)(null),[w,T]=(0,J.useState)(!1),[O,N]=(0,J.useState)(!1),[P=``,F=``,I=``]=x([d.tool,d.actor,d.component].join(`\0`),300).split(`\0`),R={...d,tool:P,actor:F,component:I};(0,J.useEffect)(()=>{re(i(c,{...ae(R),seq:b?String(b.seq):null}))},[JSON.stringify(R),b?.seq]);let z=oe(R,a,m),B=JSON.stringify(z),V=M(()=>p.audit(e,v===void 0?z:{...z,cursor:String(v)}),[e,B,v],v===void 0?5e3:void 0),H=M(()=>p.redaction(),[]),U=v===void 0?V.data?.records??[]:[...g,...V.data?.records??[]],W=V.loading&&!V.data;function G(e){f(t=>({...t,...e})),y(void 0),_([]),e.range!==void 0&&h(Date.now())}let K=()=>{y(void 0),_([]),h(Date.now()),V.reload()},[q,de]=(0,J.useState)(()=>c.query.get(`seq`));(0,J.useEffect)(()=>{if(!q)return;let t=Number(q);if(de(null),!Number.isInteger(t)||t<0)return;let n={limit:`1`,cursor:String(t+1)};!d.allTenants&&a!==null&&(n.tenant=a),p.audit(e,n).then(e=>{let n=e.records.find(e=>e.seq===t);n&&S(n)}).catch(()=>void 0)},[q]);let pe=(0,J.useMemo)(()=>[{value:``,label:`Any decision`},...(H.data?.decisions??Object.keys(te).map(e=>({value:e,label:e}))).map(e=>({value:e.value,label:k(e.value)}))],[H.data]),X=(0,J.useMemo)(()=>[{value:``,label:`Any result`},...(H.data?.outcomes??Object.keys(A).map(e=>({value:e,label:e}))).map(e=>({value:e.value,label:C(e.value)}))],[H.data]),Z=s?.configured?s.tenants.filter(e=>e!==``):[];return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(ee,{title:`Activity`,subtitle:`Every call your AI made through this toolbox, and what happened. Each entry is chained to the one before it, so edits can be detected.`,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(E,{variant:`primary`,icon:`shield-check`,onClick:()=>T(!0),children:`Check log integrity`}),(0,Y.jsx)(E,{icon:`download`,onClick:()=>N(!0),disabled:U.length===0,children:`Download log`})]})}),(0,Y.jsxs)(`div`,{className:`space-y-5`,children:[(0,Y.jsxs)(j,{title:`Filters`,actions:ie(d)&&(0,Y.jsx)(E,{size:`sm`,variant:`ghost`,icon:`x`,onClick:()=>G(se),children:`Clear filters`}),children:[(0,Y.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-4`,children:[(0,Y.jsx)(r,{label:`Result`,children:(0,Y.jsx)(D,{value:d.outcome,onChange:e=>G({outcome:e}),options:X})}),(0,Y.jsx)(r,{label:`Decision`,children:(0,Y.jsx)(D,{value:d.decision,onChange:e=>G({decision:e}),options:pe})}),(0,Y.jsx)(r,{label:`Tool`,help:`Use * to match any text, like files.*`,children:(0,Y.jsx)(l,{value:d.tool,onChange:e=>G({tool:e}),mono:!0,placeholder:`Any tool`})}),(0,Y.jsx)(r,{label:`Who asked`,children:(0,Y.jsx)(l,{value:d.actor,onChange:e=>G({actor:e}),placeholder:`Anyone`})}),Z.length>0&&(0,Y.jsx)(r,{label:`Customer`,children:(0,Y.jsx)(D,{value:d.allTenants?`*`:a??``,onChange:e=>{e===`*`?G({allTenants:!0}):e===a?G({allTenants:!1}):re(i(c,{tenant:e,allTenants:null}))},options:[...a===null?[{value:``,label:`Choose a customer`}]:[],...Z.map(e=>({value:e,label:e})),{value:`*`,label:`All customers`}]})}),d.component&&(0,Y.jsx)(r,{label:`Written by`,technical:`component`,children:(0,Y.jsx)(l,{value:d.component,onChange:e=>G({component:e}),mono:!0})})]}),(0,Y.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-end justify-between gap-4 border-t border-faint pt-5`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-[13px] font-semibold text-soft`,"aria-hidden":!0,children:`When`}),(0,Y.jsx)(u,{label:`Time range`,value:d.range,onChange:e=>G({range:e}),options:[{value:``,label:`Any time`},{value:`1h`,label:`Last hour`},{value:`24h`,label:`Last 24 hours`},{value:`7d`,label:`Last 7 days`},{value:`custom`,label:`Custom`}]})]}),(0,Y.jsx)(ne,{checked:d.noteworthy,onChange:e=>G({noteworthy:e}),label:`Only problems`,description:`Blocked, failed or still waiting.`})]}),d.range===`custom`&&(0,Y.jsxs)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2`,children:[(0,Y.jsx)(xe,{label:`From`,value:d.since,onChange:e=>G({since:e})}),(0,Y.jsx)(xe,{label:`Until`,value:d.until,onChange:e=>G({until:e}),help:`Leave empty for up to now.`})]})]}),V.data&&V.data.malformed>0&&(0,Y.jsxs)(o,{tone:`warn`,title:`${t(V.data.malformed,`line`)} could not be read`,children:[`Of the `,L(V.data.scanned),` lines read for this list, `,L(V.data.malformed),` were damaged and skipped. Run the integrity check to see where.`]}),(0,Y.jsxs)(j,{title:W?`Entries`:`${t(U.length,`entry`,`entries`)}${V.data?.nextCursor==null?``:` so far`}`,actions:(0,Y.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:K,loading:V.loading&&!!V.data,children:`Refresh list`}),children:[(0,Y.jsx)(_e,{loading:W,error:V.error,onRetry:V.reload,records:U,filtered:ie(d),onClear:()=>G(se),onOpen:S,mixedCustomers:d.allTenants}),V.data?.nextCursor!=null&&(0,Y.jsx)(`div`,{className:`mt-5 flex flex-wrap items-center gap-3`,children:(0,Y.jsx)(E,{icon:`chevron`,loading:V.loading,onClick:()=>{_(U),y(V.data.nextCursor)},children:`Load older entries`})})]})]}),(0,Y.jsx)(fe,{record:b,onClose:()=>S(null),nav:c,redaction:H.data}),(0,Y.jsx)(ue,{open:w,onClose:()=>T(!1),serverId:e}),(0,Y.jsx)(Se,{open:O,onClose:()=>N(!1),records:U,stem:`activity-${n.id}-${new Date().toISOString().slice(0,10)}`})]})}function _e({loading:e,error:t,onRetry:n,records:r,filtered:i,onClear:s,onOpen:c,mixedCustomers:l}){return t?(0,Y.jsx)(o,{tone:`danger`,title:`The activity log could not be read`,actions:(0,Y.jsx)(E,{size:`sm`,onClick:n,children:`Try again`}),children:t}):e?(0,Y.jsx)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[0,1,2,3,4].map(e=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(`span`,{className:`skeleton h-10 w-10 shrink-0 rounded-full`}),(0,Y.jsx)(a,{lines:2})]},e))}):r.length===0?i?(0,Y.jsx)(_,{icon:`filter`,title:`No entries match these filters`,actions:(0,Y.jsx)(E,{onClick:s,children:`Clear filters`}),children:`The whole log was searched. Try a wider time range or fewer filters.`}):(0,Y.jsx)(_,{icon:`activity`,title:`No activity yet`,children:`Calls appear here as soon as an AI app connected to this toolbox uses a tool.`}):(0,Y.jsx)(`ul`,{className:`-mx-2`,children:r.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(be,{record:e,onOpen:()=>c(e),showCustomer:l})},`${e.seq}-${e.id}`))})}var ve={ok:`bg-ok-tint text-ok`,warn:`bg-warn-tint text-warn`,bad:`bg-bad-tint text-bad`,neutral:`bg-sunken text-muted`};function ye(e,t){if(!t&&(e.actor===`agent`||!e.actor))return`Your AI app`;if(e.actor===`gateway`)return`The toolbox`;let n=e.args_redacted?.origin;return t&&(n===`console`||e.component===`hmcp-web`||e.rule_id===`approval.decide`||e.tool?.startsWith(`(`))?e.actor&&e.actor!==`console`?`You (${e.actor})`:`You`:e.actor}function be({record:t,onOpen:n,showCustomer:r}){let i=K(t),a=t.rule_id===`gateway.unknown-tool`,o=a?null:U(t),c=A[t.outcome]?.tone??`neutral`,l=i?`neutral`:a?`warn`:t.outcome===`error`?`bad`:te[t.decision]?.tone??`neutral`,u=i?.icon??(t.decision===`deny`?`x`:t.decision===`approve`?`clock`:`check`);return(0,Y.jsxs)(`button`,{type:`button`,onClick:n,className:`flex w-full flex-wrap items-center gap-x-3 gap-y-2 rounded-2xl px-2 py-3 text-left transition-colors hover:bg-faint focus-visible:bg-faint`,children:[(0,Y.jsx)(`span`,{className:I(`grid h-10 w-10 shrink-0 place-items-center rounded-full`,ve[l]),children:(0,Y.jsx)(d,{name:u,size:18,strokeWidth:2})}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 basis-56`,children:[(0,Y.jsx)(`span`,{className:`block truncate text-[14.5px] font-medium`,children:i?(0,Y.jsxs)(Y.Fragment,{children:[i.title,t.tool&&!t.tool.startsWith(`(`)&&(0,Y.jsx)(`span`,{className:`ml-1.5 text-soft`,title:t.tool,children:W(t.tool).label})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`text-soft`,children:G(t)}),` `,(0,Y.jsx)(`span`,{title:t.tool,children:W(t.tool).label})]})}),(0,Y.jsxs)(`span`,{className:`mt-0.5 block truncate text-[12.5px] text-soft`,children:[(0,Y.jsx)(`time`,{dateTime:t.ts,title:s(t.ts),children:v(t.ts)}),` · `,ye(t,i!==null),r&&t.tenant?` · ${t.tenant}`:``,!i&&(0,Y.jsxs)(Y.Fragment,{children:[` · `,H(t)]})]}),o&&(0,Y.jsxs)(`span`,{className:`mt-1 flex items-center gap-1.5 text-[12.5px] font-medium text-warn`,children:[(0,Y.jsx)(d,{name:`eye`,size:14,strokeWidth:2}),o]})]}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-1.5 max-sm:pl-[52px] sm:shrink-0`,children:[a?(0,Y.jsx)(e,{tone:`warn`,children:`No such tool`}):!i&&(0,Y.jsx)(w,{decision:t.decision}),!a&&(i||C(t.outcome)!==k(t.decision))&&(0,Y.jsx)(e,{tone:c,children:V(t)?`You said no`:C(t.outcome)}),(0,Y.jsx)(d,{name:`chevron-right`,size:18,className:`text-soft max-sm:hidden`})]})]})}function xe({label:e,value:t,onChange:n,help:i}){return(0,Y.jsx)(r,{label:e,help:i,children:(0,Y.jsx)(`input`,{type:`datetime-local`,value:t,onChange:e=>n(e.target.value),className:`field`})})}function Se({open:e,onClose:n,records:r,stem:i}){let[a,o]=(0,J.useState)(`jsonl`);return(0,Y.jsx)(P,{open:e,onClose:n,title:`Download log`,description:`Saves the ${t(r.length,`entry`,`entries`)} listed now, with the filters you set. Load older entries first to include more.`,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(E,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,Y.jsx)(E,{variant:`primary`,icon:`download`,onClick:()=>{a===`jsonl`?z(`${i}.jsonl`,`application/x-ndjson`,B(r)):z(`${i}.csv`,`text/csv`,R(r)),n()},children:`Download file`})]}),children:(0,Y.jsxs)(`fieldset`,{className:`space-y-3`,children:[(0,Y.jsx)(`legend`,{className:`sr-only`,children:`File format`}),(0,Y.jsx)(Ce,{checked:a===`jsonl`,onSelect:()=>o(`jsonl`),title:`Exact log entries (JSONL)`,children:`One entry per line, exactly as written, fingerprints included. Use this to keep a copy or to check it later.`}),(0,Y.jsx)(Ce,{checked:a===`csv`,onSelect:()=>o(`csv`),title:`Spreadsheet (CSV)`,children:`The main columns, for sorting and counting in a spreadsheet. Fingerprints are left out.`})]})})}function Ce({checked:e,onSelect:t,title:n,children:r}){return(0,Y.jsxs)(`label`,{className:I(`flex cursor-pointer gap-3 rounded-2xl border-[1.5px] px-4 py-3 transition-colors`,e?`border-[var(--primary)] bg-ok-tint/40`:`border-line hover:bg-faint`),children:[(0,Y.jsx)(`input`,{type:`radio`,name:`log-format`,checked:e,onChange:t,className:`mt-1 accent-[var(--primary)]`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`block text-[14px] font-semibold`,children:n}),(0,Y.jsx)(`span`,{className:`mt-0.5 block text-[13px] text-soft`,children:r})]})]})}export{ge as ActivityPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as e,B as t,Ct as n,D as r,E as i,Et as a,F as o,G as s,H as c,I as l,It as u,J as d,K as f,M as p,Nt as m,Ot as h,Pt as g,T as _,U as v,V as ee,Y as te,Z as y,_ as b,_t as x,c as S,gt as ne,ht as C,j as w,kt as T,mt as E,pt as D,q as O,rt as k,s as A,w as j,wt as M,x as re,y as ie,yt as N}from"./kit-DRVm92_t.js";import{a as P,c as ae,l as F,n as oe,o as I,r as L,s as R,t as se,u as z,un as ce}from"./index-DbHZ_SUd.js";var B=u(),V=T(),H=/^\[redacted:([^\]]+)\]$/,U=/…\[truncated (\d+) chars\]$/,W=/^\[truncated (\d+) items\]$/;function G(e){if(typeof e!=`string`)return null;let t=H.exec(e);return t?t[1]===`key`||t[1]===`circular`||t[1]===`max-depth`?t[1]:`pattern`:U.test(e)?`chars`:W.test(e)?`items`:null}function K(e,t,n=0){if(n>20)return;let r=G(e);r&&t.add(r),Array.isArray(e)?e.forEach(e=>K(e,t,n+1)):e&&typeof e==`object`&&Object.values(e).forEach(e=>K(e,t,n+1))}var q={key:`[redacted:key]`,pattern:`[redacted:<pattern>]`,circular:`[redacted:circular]`,"max-depth":`[redacted:max-depth]`,chars:`…[truncated N chars]`,items:`[truncated N items]`},J={key:`Hidden`,pattern:`Hidden`,circular:`Hidden`,"max-depth":`Hidden`,chars:`Cut short`,items:`Cut short`};function Y({args:e,error:t,meta:n}){let r=new Set;K(e,r);let i=e=>n?.markers.find(t=>t.marker===q[e])?.meaning,a=e&&typeof e==`object`&&!Array.isArray(e)?Object.entries(e):null;return(0,V.jsxs)(`div`,{className:`space-y-3`,children:[t&&(0,V.jsx)(c,{tone:`warn`,title:`Some inputs could not be read back`,children:t}),a===null?e==null?!t&&(0,V.jsx)(`p`,{className:`text-[13.5px] text-soft`,children:`The inputs were not recorded.`}):(0,V.jsx)(X,{value:e,meaning:i}):a.length===0?(0,V.jsx)(`p`,{className:`text-[13.5px] text-soft`,children:`This call sent no inputs.`}):(0,V.jsx)(`dl`,{className:`divide-y divide-faint overflow-hidden rounded-2xl bg-sunken/60`,children:a.map(([e,t])=>(0,V.jsxs)(`div`,{className:`grid gap-1 px-4 py-2.5 sm:grid-cols-[minmax(6rem,10rem)_minmax(0,1fr)] sm:gap-4`,children:[(0,V.jsx)(`dt`,{className:`mono pt-px text-[12.5px] break-all text-soft`,children:e}),(0,V.jsx)(`dd`,{className:`min-w-0`,children:(0,V.jsx)(X,{value:t,meaning:i})})]},e))}),r.size>0&&(0,V.jsxs)(`div`,{className:`flex gap-2 text-[12.5px] text-soft`,children:[(0,V.jsx)(h,{name:`eye-off`,size:15,className:`mt-0.5 shrink-0`}),(0,V.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,V.jsxs)(`p`,{className:`flex items-center gap-1.5 font-medium text-muted`,children:[`Some values are hidden or cut short in the record `,(0,V.jsx)(b,{term:`redaction`})]}),[...r].map(e=>(0,V.jsxs)(`p`,{children:[(0,V.jsx)(`code`,{className:`mono text-[11.5px]`,children:q[e]}),`: `,i(e)??`not shown in full`]},e))]})]})]})}function X({value:t,meaning:n}){let r=G(t);if(r&&r!==`chars`)return(0,V.jsx)(e,{tone:`neutral`,icon:`eye-off`,title:n(r),children:J[r]});if(typeof t==`string`){let r=U.exec(t),i=r?t.slice(0,r.index):t;return(0,V.jsxs)(`p`,{className:`scrollbar-thin max-h-40 overflow-y-auto text-[13.5px] break-words whitespace-pre-wrap`,children:[i===``?(0,V.jsx)(`span`,{className:`text-soft`,children:`(empty)`}):i,r&&(0,V.jsxs)(e,{tone:`neutral`,className:`ml-1.5 align-middle`,title:n(`chars`),children:[r[1],` more characters not recorded`]})]})}return typeof t==`number`||typeof t==`boolean`||t===null?(0,V.jsx)(`span`,{className:`mono text-[13px]`,children:String(t)}):(0,V.jsx)(`pre`,{className:`scrollbar-thin mono max-h-48 overflow-auto rounded-xl bg-surface px-3 py-2 text-[12px] leading-relaxed whitespace-pre-wrap break-words`,children:JSON.stringify(t,null,2)})}var Z=e=>e instanceof m&&(e.status===409||e.status===404);function le({approval:e,meta:t,now:n,serverId:a,tenant:s,selecting:u,selected:d,onSelect:f,locked:h,onDecided:v,onRemembered:te}){let x=ie(),[S,ne]=(0,B.useState)(``),[w,T]=(0,B.useState)(null),[E,D]=(0,B.useState)(!1),[O,A]=(0,B.useState)(t?.rememberDefaults.ttlSeconds??3600),[M,re]=(0,B.useState)(t?.rememberDefaults.maxUses??20),[F,oe]=(0,B.useState)(!1),[ce,H]=(0,B.useState)(null),U=R(e.tool),W=e.expiresAt-n,G=L(e),K=t?.grantTtlMaxSeconds,q=h||w!==null;async function J(t,n={}){T(n.remember?`remember`:n.classify?`classify-${n.classify}`:t),H(null);let r;try{r=await g.decide(a,e.id,t,S.trim(),s,n.classify,n.remember)}catch(e){T(null),Z(e)?(x.show(`warn`,`This call was already answered, or it ran out of time.`),v()):n.remember&&e instanceof m&&e.status===422?H(I(e.message)):x.show(`bad`,I(e.message));return}T(null),t===`denied`?x.show(`ok`,`You said no. ${U.label} will not run, and the AI is told you said no.`):r.remembered?(x.show(`ok`,`Approved. Similar calls won't ask until ${ae(r.remembered.expiresAt)}.`),te(r.remembered,e.tool)):r.classifyWarning?x.show(`warn`,I(r.classifyWarning)):r.classified&&n.classify?x.show(`ok`,`Approved, and ${U.label} is now labelled "${k[n.classify].label}". Its calls still ask you.`):x.show(`ok`,`Approved. The call can go ahead.`),v()}let X=O!==null&&(K===void 0||O<=K)&&(F||M!==null&&M>=1);return(0,V.jsxs)(`article`,{"aria-labelledby":`apr-${e.id}`,className:N(`card flex min-w-0 flex-col gap-5 p-5 sm:p-6`,d&&`outline-2 outline-offset-2 outline-[var(--primary)]`),children:[(0,V.jsxs)(`header`,{className:`flex items-start gap-3`,children:[u&&(0,V.jsx)(`span`,{className:`pt-2.5`,children:(0,V.jsx)(j,{checked:d,onChange:f,disabled:q,label:(0,V.jsxs)(`span`,{className:`sr-only`,children:[`Select `,U.label]})})}),(0,V.jsx)(`span`,{className:`grid h-11 w-11 shrink-0 place-items-center rounded-full bg-sunken`,children:(0,V.jsx)(y,{effect:e.effect})}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`h3`,{id:`apr-${e.id}`,tabIndex:-1,className:`text-[18px] outline-none focus-visible:outline-2 focus-visible:outline-[var(--focus)] leading-snug font-medium tracking-[-0.015em] break-words`,children:U.label}),(0,V.jsxs)(`p`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-[12.5px] text-soft`,children:[U.server&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{children:U.server}),(0,V.jsx)(`span`,{"aria-hidden":!0,children:`·`})]}),(0,V.jsx)(y,{effect:e.effect,withLabel:!0})]})]})]}),(0,V.jsxs)(`section`,{"aria-label":`What it wants to do`,className:`space-y-2.5`,children:[(0,V.jsx)(`p`,{className:`text-[15px] leading-relaxed [overflow-wrap:anywhere]`,children:se(e)}),(0,V.jsx)(`p`,{className:`text-[14px] text-muted`,children:z(e)}),e.violations.length>0&&(0,V.jsx)(`ul`,{className:`space-y-1.5 rounded-2xl bg-warn-tint px-4 py-3 text-[13.5px]`,children:e.violations.map(t=>(0,V.jsxs)(`li`,{className:`flex gap-2`,children:[(0,V.jsx)(`span`,{className:`mt-[7px] h-1.5 w-1.5 shrink-0 rounded-full bg-warn`,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`min-w-0 break-words`,children:P(t,e.args)})]},t))}),(0,V.jsx)(`p`,{className:`text-[13px] text-soft`,children:W>0?`If you don't answer by ${o(e.expiresAt)}, it doesn't run. The AI can ask again.`:`This request ran out of time, so it doesn't run. The AI can ask again.`})]}),(0,V.jsxs)(`section`,{"aria-label":`The details it would send`,className:`space-y-2`,children:[(0,V.jsx)(`h4`,{className:`eyebrow`,children:`The details it would send`}),(0,V.jsx)(Y,{args:e.args,error:e.argsError,meta:t})]}),(0,V.jsxs)(`details`,{className:`group text-[12.5px] text-soft`,children:[(0,V.jsx)(`summary`,{className:`cursor-pointer select-none font-medium text-muted`,children:`Details`}),(0,V.jsxs)(`dl`,{className:`mt-2 grid grid-cols-[max-content_1fr] gap-x-4 gap-y-1`,children:[(0,V.jsx)(`dt`,{children:`Tool`}),(0,V.jsx)(`dd`,{children:(0,V.jsx)(`code`,{className:`mono break-all`,children:e.tool})}),(0,V.jsx)(`dt`,{children:`Asked by`}),(0,V.jsxs)(`dd`,{children:[e.actor,` `,(0,V.jsx)(`span`,{title:l(e.createdAt),children:ee(e.createdAt,n)})]}),(0,V.jsx)(`dt`,{children:`Session`}),(0,V.jsx)(`dd`,{children:(0,V.jsx)(`code`,{className:`mono break-all`,children:e.session})}),e.ruleId&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{children:`Rule`}),(0,V.jsx)(`dd`,{children:(0,V.jsx)(`code`,{className:`mono break-all`,children:e.ruleId})})]}),(0,V.jsx)(`dt`,{children:`Request`}),(0,V.jsxs)(`dd`,{children:[(0,V.jsx)(`code`,{className:`mono break-all`,children:e.id}),`, expires `,l(e.expiresAt)]})]})]}),(0,V.jsxs)(`div`,{className:`mt-auto space-y-3 border-t border-faint pt-4`,children:[(0,V.jsx)(i,{label:`Note for the activity log`,optional:!0,children:(0,V.jsx)(p,{value:S,onChange:ne,placeholder:`Why you said yes or no`,disabled:q})}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(C,{variant:`primary`,icon:`check`,onClick:()=>J(`granted`),loading:w===`granted`,disabled:q,children:`Approve`}),(0,V.jsx)(C,{variant:`secondary`,icon:`x`,onClick:()=>J(`denied`),loading:w===`denied`,disabled:q,children:`Say no`}),e.rememberAllowed&&!G&&(0,V.jsx)(C,{variant:`ghost`,icon:E?`chevron`:`chevron-right`,"aria-expanded":E,"aria-controls":`remember-${e.id}`,onClick:()=>D(e=>!e),disabled:q,children:`Approve and don't ask again`})]}),G&&(0,V.jsxs)(`div`,{className:`space-y-2.5 rounded-2xl bg-sunken/70 p-4`,children:[(0,V.jsx)(`p`,{className:`text-[13.5px] font-semibold`,children:`Approve and remember this tool as:`}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":`Approve and say what this tool does`,children:[`read`,`write`,`destructive`].map(e=>(0,V.jsx)(C,{size:`sm`,variant:`secondary`,onClick:()=>J(`granted`,{classify:e}),loading:w===`classify-${e}`,disabled:q,title:k[e].explain,children:k[e].label},e))}),(0,V.jsx)(`p`,{className:`text-[12.5px] text-soft`,children:`This approves the call and saves what the tool does in your protection settings. Its calls still ask you; once it is labelled you can set a rule for it on the Tools page.`})]}),E&&e.rememberAllowed&&(0,V.jsxs)(`div`,{id:`remember-${e.id}`,className:`space-y-4 rounded-2xl bg-sunken/70 p-4`,children:[(0,V.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[14px] font-semibold`,children:[`Approve and don't ask again `,(0,V.jsx)(b,{term:`preApproval`})]}),(0,V.jsx)(i,{label:`For how long`,children:(0,V.jsx)(_,{value:O,onChange:A,label:`For how long`,max:K})}),(0,V.jsx)(i,{label:`Up to how many calls`,children:(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,V.jsx)(r,{value:F?null:M,onChange:re,min:1,step:1,unit:`calls`,disabled:F||q,className:`w-40`}),(0,V.jsx)(j,{checked:F,onChange:oe,label:`No limit`,disabled:q})]})}),(0,V.jsx)(`p`,{className:`text-[13px] text-muted`,children:`For the time you choose, your AI can make this same request again without asking. Anything different still asks you, including a list with items changed, repeated or left out. You can take it back any time on the Pre-approvals page.`}),ce&&(0,V.jsx)(c,{tone:`danger`,title:`Nothing was approved`,role:`alert`,children:ce}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,V.jsx)(C,{variant:`primary`,icon:`check`,disabled:!X||q,loading:w===`remember`,onClick:()=>J(`granted`,{remember:{ttlSeconds:O,maxUses:F?null:M}}),children:`Approve and remember`}),(0,V.jsx)(C,{variant:`ghost`,onClick:()=>D(!1),disabled:w!==null,children:`Cancel`})]})]})]})]})}var ue={elicit:`On this toolbox your AI app asks you in its own window, so calls usually do not wait here.`,cli:`On this toolbox every call that needs your OK waits here until you answer it.`,both:`Your AI app asks you in its own window when it can. When it cannot, the call waits here.`,deny:`On this toolbox calls that would need your OK are blocked instead, so nothing waits here.`};function Q(){let{serverId:e,tenant:r,nav:i,reload:o}=ce(),l=ie(),u=F(1e3),f=A(()=>g.pending(e,r),[e,r],2e3),p=A(()=>g.approvals(e,r,{limit:200}),[e,r],15e3),h=A(()=>g.redaction(),[]),_=A(()=>g.protection(e,r),[e,r],3e4),y=i.query.get(`id`),b=y!==null&&(f.data??[]).some(e=>e.id===y),T=i.query.get(`tab`)===`history`||y!==null&&f.data!==null&&!b?`history`:`waiting`,k=e=>M(a(i,{tab:e===`waiting`?null:e})),j=(0,B.useMemo)(()=>[...f.data??[]].filter(e=>e.expiresAt>u).sort((e,t)=>e.createdAt-t.createdAt),[f.data,u]),N=(0,B.useMemo)(()=>(p.data??[]).filter(e=>e.state!==`pending`).sort((e,t)=>(t.decidedAt??t.expiresAt)-(e.decidedAt??e.expiresAt)),[p.data]),[P,L]=(0,B.useState)(!1),[se,z]=(0,B.useState)([]),H=new Set(j.map(e=>e.id)),U=se.filter(e=>H.has(e)),[W,G]=(0,B.useState)(null),[K,q]=(0,B.useState)(``),[J,Y]=(0,B.useState)(!1),[X,Z]=(0,B.useState)(null),Q=(0,B.useRef)(!1),de=(0,B.useRef)(null),fe=(0,B.useRef)(null);(0,B.useEffect)(()=>{Q.current&&f.data!==null&&(Q.current=!1,(de.current?.querySelector(`article h3[tabindex]`)??fe.current)?.focus())},[f.data]);let me=()=>{f.reload(),p.reload(),_.reload(),o()};async function he(n){Y(!0);let i=0,a=0,o=[];for(let t of U)try{await g.decide(e,t,n,K.trim(),r),i++}catch(e){e instanceof m&&(e.status===409||e.status===404)?a++:o.push(I(e.message))}Y(!1),G(null),q(``),z([]),L(!1),me();let s=[`${n===`granted`?`Approved`:`Denied`} ${t(i,`call`)}.`];a&&s.push(`${t(a,`call`)} had already been answered or ran out of time.`),o.length&&s.push(`${o.length} failed: ${o[0]}`),l.show(o.length?`bad`:a?`warn`:`ok`,s.join(` `))}let $=_.data?.approvals,ge=$?ue[$.mode]:void 0,_e=j.reduce((e,t)=>e===null||t.expiresAt<e?t.expiresAt:e,null),ve=j[0];return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(S,{title:`Waiting for you`,subtitle:`Your AI wanted to do these things. Nothing happens until you decide.`,actions:(0,V.jsx)(C,{variant:P?`primary`:`secondary`,icon:P?`x`:`list`,"aria-pressed":P,disabled:!P&&j.length<2,onClick:()=>{L(e=>!e),z([])},children:P?`Stop selecting`:`Select several`})}),(0,V.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2 xl:grid-cols-3`,children:[(0,V.jsx)(E,{tone:`hero`,title:`Waiting now`,loading:f.data===null&&!f.error,value:j.length,sub:ve?`Oldest asked ${ee(ve.createdAt,u)}`:`Nothing needs you`}),(0,V.jsxs)(`div`,{className:`contents max-sm:hidden`,children:[(0,V.jsx)(E,{title:`Expires next`,loading:f.data===null&&!f.error,value:_e===null?`None`:oe(_e-u),sub:_e===null?`Nothing is waiting`:`A request nobody answers doesn't run`}),(0,V.jsx)(E,{title:`Pre-approvals in use`,loading:_.data===null&&!_.error,value:$?.activeGrantCount??`–`,sub:`Calls they cover skip this page`,href:n(i,`/pre-approvals`),hrefLabel:`Open pre-approvals`})]})]}),(0,V.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[$&&$.pendingElsewhere>0&&(0,V.jsxs)(c,{tone:`info`,title:`${t($.pendingElsewhere,`call`)} ${$.pendingElsewhere===1?`is`:`are`} waiting for a different customer`,children:[`Choose that customer at the top of the page to answer `,$.pendingElsewhere===1?`it`:`them`,`.`]}),X&&(0,V.jsxs)(c,{tone:`ok`,title:`Pre-approval created`,role:`status`,actions:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(x,{size:`sm`,variant:`secondary`,href:n(i,`/pre-approvals`,{grant:X.grant.id}),children:`Open pre-approval`}),(0,V.jsx)(ne,{icon:`x`,label:`Dismiss message`,size:32,onClick:()=>Z(null)})]}),children:[`Calls like this one to `,R(X.tool).label,` won't ask until `,ae(X.grant.expiresAt),X.grant.maxUses===null?``:`, for up to ${t(X.grant.maxUses,`call`)}`,`.`]})]}),(0,V.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center justify-between gap-3`,children:[(0,V.jsx)(O,{label:`Calls`,value:T,onChange:k,items:[{id:`waiting`,label:`Waiting`,count:j.length},{id:`history`,label:`Decided earlier`,count:N.length}]}),T===`waiting`&&j.length>0&&(0,V.jsx)(`p`,{className:`text-[13px] text-soft`,children:`Oldest first: the call at the top runs out soonest.`})]}),(0,V.jsx)(`div`,{role:`tabpanel`,id:te(T),"aria-labelledby":d(T),className:`mt-5`,children:T===`waiting`?(0,V.jsxs)(V.Fragment,{children:[P&&j.length>0&&(0,V.jsx)(D,{className:`mb-5`,padded:!1,children:(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 px-5 py-4`,children:[(0,V.jsxs)(`p`,{className:`min-w-0 flex-1 text-[14px]`,children:[(0,V.jsx)(`span`,{className:`tnum font-semibold`,children:U.length}),` of `,t(j.length,`call`),` selected`]}),(0,V.jsx)(C,{size:`sm`,variant:`ghost`,onClick:()=>z(U.length===j.length?[]:j.map(e=>e.id)),children:U.length===j.length?`Clear selection`:`Select all`}),(0,V.jsx)(C,{size:`sm`,variant:`primary`,icon:`check`,disabled:U.length===0,onClick:()=>G(`granted`),children:`Approve all`}),(0,V.jsx)(C,{size:`sm`,variant:`secondary`,icon:`x`,disabled:U.length===0,onClick:()=>G(`denied`),children:`Deny all`})]})}),f.error&&(0,V.jsx)(`div`,{className:`mb-5`,children:(0,V.jsx)(c,{tone:`danger`,title:`Could not load the calls waiting for you`,role:`alert`,actions:(0,V.jsx)(C,{size:`sm`,icon:`refresh`,onClick:f.reload,children:`Try again`}),children:I(f.error)})}),f.data===null?!f.error&&(0,V.jsx)(`div`,{className:`grid gap-5 xl:grid-cols-2`,children:[0,1].map(e=>(0,V.jsxs)(D,{children:[(0,V.jsx)(s,{height:22,width:`45%`}),(0,V.jsx)(`div`,{className:`mt-5`,children:(0,V.jsx)(s,{lines:4})})]},e))}):j.length===0?(0,V.jsx)(D,{children:(0,V.jsx)(`div`,{ref:fe,tabIndex:-1,className:`outline-none`,children:(0,V.jsxs)(v,{icon:`inbox`,title:`Nothing is waiting for you.`,actions:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(C,{variant:`secondary`,onClick:()=>k(`history`),children:`Show decided calls`}),(0,V.jsx)(x,{variant:`secondary`,href:n(i,`/pre-approvals`),children:`Manage pre-approvals`})]}),children:[`When your AI tries something that needs your OK, it appears here and this page updates by itself.`,` `,ge]})})}):(0,V.jsx)(`div`,{ref:de,className:`grid items-start gap-5 xl:grid-cols-2`,children:j.map(t=>(0,V.jsx)(`div`,{className:t.id===y?`rounded-[22px] ring-2 ring-[var(--focus)] ring-offset-2 ring-offset-[var(--bg)]`:void 0,children:(0,V.jsx)(le,{approval:t,meta:h.data,now:u,serverId:e,tenant:r,selecting:P,selected:P&&U.includes(t.id),onSelect:e=>z(n=>e?[...new Set([...n,t.id])]:n.filter(e=>e!==t.id)),locked:J,onDecided:()=>{Q.current=!0,me()},onRemembered:(e,t)=>Z({grant:e,tool:t})})},t.id))})]}):(0,V.jsx)(pe,{rows:N,error:p.error,loading:p.data===null,retry:p.reload,now:u,focusId:y})}),(0,V.jsxs)(re,{open:W!==null,onClose:()=>!J&&G(null),dismissable:!J,title:W===`granted`?`Approve ${t(U.length,`call`)}?`:`Deny ${t(U.length,`call`)}?`,description:W===`granted`?`Each call runs with exactly the inputs shown on its card. Nothing else is approved.`:`None of these calls will run. Your AI is told they were denied.`,footer:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(C,{variant:`secondary`,onClick:()=>G(null),disabled:J,children:`Go back`}),(0,V.jsx)(C,{variant:W===`granted`?`primary`:`danger`,loading:J,onClick:()=>W&&he(W),children:W===`granted`?`Approve all`:`Deny all`})]}),children:[(0,V.jsx)(`ul`,{className:`mb-4 max-h-48 space-y-1 overflow-y-auto text-[14px]`,children:j.filter(e=>U.includes(e.id)).map(e=>(0,V.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,V.jsx)(`span`,{className:`font-medium`,children:R(e.tool).label}),(0,V.jsx)(`code`,{className:`mono text-[12px] text-soft`,children:e.tool})]},e.id))}),(0,V.jsx)(w,{value:K,onChange:q,rows:2,"aria-label":`Note for the activity log, for every selected call`,placeholder:`Note for the activity log (optional)`})]})]})}function de(t){return t.decidedBy?.startsWith(`standing-grant:`)?(0,V.jsx)(e,{tone:`ok`,icon:`key`,children:`Let through by a pre-approval`}):t.state===`granted`||t.state===`used`?(0,V.jsx)(e,{tone:`ok`,icon:`check`,children:`Approved`}):t.state===`denied`?(0,V.jsx)(e,{tone:`bad`,icon:`x`,children:`Denied`}):t.state===`expired`?(0,V.jsx)(e,{tone:`neutral`,icon:`clock`,children:`Expired`}):(0,V.jsx)(e,{children:t.state})}function fe(e){return e.decidedBy?e.decidedBy.startsWith(`standing-grant:`)?(0,V.jsxs)(`span`,{children:[`Pre-approval `,(0,V.jsx)(`code`,{className:`mono text-[12px] text-soft`,children:e.decidedBy.slice(15)})]}):e.decidedBy:(0,V.jsx)(`span`,{className:`text-soft`,children:e.state===`expired`?`Nobody answered`:`Not recorded`})}function pe({rows:e,error:t,loading:n,retry:r,now:i,focusId:a}){let o=[{key:`call`,header:`Call`,cell:e=>(0,V.jsxs)(`span`,{className:`block min-w-0`,children:[(0,V.jsx)(`span`,{className:`block font-medium`,children:R(e.tool).label}),(0,V.jsx)(`code`,{className:`mono block text-[12px] break-all text-soft`,children:e.tool})]})},{key:`result`,header:`Result`,cell:de},{key:`who`,header:`Decided by`,cell:fe},{key:`when`,header:`When`,cell:e=>{let t=e.decidedAt??e.expiresAt;return(0,V.jsx)(`span`,{title:l(t),children:ee(t,i)})}},{key:`note`,header:`Note`,cell:e=>e.decisionNote?(0,V.jsx)(`span`,{className:`break-words`,children:e.decisionNote}):(0,V.jsx)(`span`,{className:`text-soft`,children:`None`}),hideOnMobile:!1}];return(0,V.jsxs)(D,{children:[t&&(0,V.jsx)(`div`,{className:`mb-4`,children:(0,V.jsx)(c,{tone:`danger`,title:`Could not load decided calls`,actions:(0,V.jsx)(C,{size:`sm`,icon:`refresh`,onClick:r,children:`Try again`}),children:I(t)})}),n?!t&&(0,V.jsx)(s,{lines:5,height:18}):(0,V.jsx)(f,{caption:`Calls decided earlier`,columns:o,rows:e,rowKey:e=>e.id,selectedKey:a,empty:(0,V.jsx)(v,{icon:`clock`,title:`No calls decided yet`,compact:!0,children:`Calls you approve or deny, and calls that run out of time, are listed here.`})})]})}export{Q as ApprovalsPage};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{$ as e,A as t,At as n,B as r,Ct as i,E as a,G as o,H as s,It as c,J as l,M as u,N as d,Nt as f,O as p,Ot as m,Pt as h,Tt as g,U as _,V as v,Y as y,Z as b,_t as x,a as S,b as C,bt as w,et as T,ht as E,i as D,jt as O,k,kt as A,n as ee,o as te,q as j,r as M,rt as N,s as ne,t as P,tt as re,vt as ie,w as ae,x as oe,xt as se,y as ce,yt as F}from"./kit-DRVm92_t.js";import{$ as I,$t as le,A as ue,At as de,B as fe,Bt as L,C as R,D as pe,Dn as me,E as he,F as ge,Ft as _e,G as ve,Gt as ye,H as be,I as xe,It as z,J as Se,Jt as B,K as Ce,Kt as we,L as Te,Lt as Ee,M as De,Mt as V,N as Oe,O as ke,P as Ae,Pt as H,Q as U,Qt as je,R as Me,Rt as W,S as Ne,T as G,U as Pe,Ut as K,V as Fe,Vt as Ie,W as Le,X as Re,Y as ze,Yt as Be,Zt as Ve,an as q,b as He,cn as J,ct as Ue,en as Y,et as X,hn as We,in as Ge,j as Ke,k as qe,ln as Je,m as Ye,nt as Xe,on as Ze,q as Qe,rn as $e,rt as et,s as tt,tt as nt,x as rt,z as it}from"./index-DbHZ_SUd.js";var Z=c(),Q=A(),at=()=>({name:``,transport:`stdio`,command:``,args:[],env:[],passEnv:[],cwd:``,url:``,headers:[],passthrough:!1,passthroughHeader:`authorization`,passthroughRequired:!1,onInjection:``});function ot(e){let t=at();return t.name=e.name,t.transport=e.transport,t.onInjection=e.on_injection??``,e.transport===`stdio`?(t.command=e.command,t.args=e.args??[],t.env=et(e.env),t.passEnv=e.pass_env??[],t.cwd=e.cwd??``):(t.url=e.url,t.headers=et(e.headers),t.passthrough=!!e.credential_passthrough?.enabled,t.passthroughHeader=e.credential_passthrough?.header??`authorization`,t.passthroughRequired=!!e.credential_passthrough?.required),t}function st(e){let t=e.onInjection?{on_injection:e.onInjection}:{};return e.transport===`stdio`?{name:e.name.trim(),transport:`stdio`,...t,command:e.command.trim(),...e.args.length?{args:e.args}:{},...e.env.length?{env:Xe(e.env)}:{},...e.passEnv.length?{pass_env:e.passEnv}:{},...e.cwd.trim()?{cwd:e.cwd.trim()}:{}}:{name:e.name.trim(),transport:`http`,...t,url:e.url.trim(),...e.headers.length?{headers:Xe(e.headers)}:{},...e.passthrough?{credential_passthrough:{enabled:!0,header:e.passthroughHeader.trim()||`authorization`,required:e.passthroughRequired}}:{}}}function ct(e,t=[]){if(!/^[a-z0-9_]+$/.test(e.name.trim()))return`Give the server a name of lower-case letters, digits and underscores.`;if(t.includes(e.name.trim()))return`Another connected server is already called “${e.name.trim()}”.`;if(e.transport===`stdio`&&!e.command.trim())return`Say which program starts the server.`;if(e.transport===`http`)try{new URL(e.url.trim())}catch{return`Enter the server's full web address, starting with https://.`}return null}function lt({value:e,onChange:n,nameLocked:r,secret:i,literalWarning:o}){let c=(t,r)=>n({...e,[t]:r}),l=([e,t])=>!!t&&t!==i&&!le(t)&&!B(e),f=e.transport===`stdio`?e.env.some(l):e.headers.some(l);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(a,{label:`Name`,technical:`name`,help:r?`A server's name can't be changed. Remove it and add it again under a new name.`:`Lower-case letters, digits and underscores. Its tools are shown to your AI app as name__tool.`,children:(0,Q.jsx)(u,{value:e.name,onChange:e=>c(`name`,e),mono:!0,disabled:r,placeholder:`files`})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[13px] font-semibold`,children:`Where it runs`}),(0,Q.jsx)(p,{label:`Where it runs`,value:e.transport,onChange:e=>c(`transport`,e),options:[{value:`stdio`,label:`Runs on this computer`},{value:`http`,label:`Remote server`}]})]}),e.transport===`stdio`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{label:`Program to start`,technical:`command`,help:`The program the toolbox runs to start this server, such as npx or a full path.`,children:(0,Q.jsx)(u,{value:e.command,onChange:e=>c(`command`,e),mono:!0,placeholder:`npx`})}),(0,Q.jsx)(a,{label:`What to pass the program`,technical:`args`,optional:!0,help:`One item at a time. Press Enter after each.`,children:(0,Q.jsx)(t,{value:e.args,onChange:e=>c(`args`,e),placeholder:`-y, @modelcontextprotocol/server-filesystem`})}),(0,Q.jsx)(a,{label:`Values it is given`,technical:`env`,optional:!0,help:`Settings the server reads when it starts, such as an access key.`,children:(0,Q.jsx)(I,{value:e.env,onChange:e=>c(`env`,e),keyLabel:`Name of value`,valueLabel:`Value`,addLabel:`Add a value`,secret:i,valueType:`password`,keyPlaceholder:`API_KEY`})}),(0,Q.jsx)(a,{label:`Values passed on from the toolbox`,technical:`pass_env`,optional:!0,help:`Names of values the toolbox already has, given to this server as they are. Nothing else is passed on.`,children:(0,Q.jsx)(t,{value:e.passEnv,onChange:e=>c(`passEnv`,e),placeholder:`GITHUB_TOKEN`})})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{label:`Web address`,technical:`url`,children:(0,Q.jsx)(u,{value:e.url,onChange:e=>c(`url`,e),type:`url`,mono:!0,placeholder:`https://mcp.example.com/mcp`})}),(0,Q.jsx)(a,{label:`Headers sent with every request`,technical:`headers`,optional:!0,help:`Such as an access key the server expects.`,children:(0,Q.jsx)(I,{value:e.headers,onChange:e=>c(`headers`,e),keyLabel:`Header name`,valueLabel:`Header value`,addLabel:`Add a header`,secret:i,valueType:`password`,keyPlaceholder:`authorization`})})]}),o&&f&&(0,Q.jsx)(s,{tone:`warn`,title:`These values are saved in the toolbox's settings file as typed`,children:`A value whose name says it is a key (a TOKEN, KEY, SECRET or PASSWORD) goes into your locked keys instead. If another one is a password or key, give it a name like that, or anyone who can read the file can read it.`}),(0,Q.jsxs)(U,{title:`More options`,children:[(0,Q.jsx)(a,{label:`Hidden instructions in its tool descriptions`,technical:`on_injection`,help:e.onInjection?V[e.onInjection].explain:`Uses the toolbox-wide setting.`,children:(0,Q.jsx)(k,{value:e.onInjection,onChange:e=>c(`onInjection`,e),options:[{value:``,label:`Same as the toolbox`},{value:`strip`,label:V.strip.label},{value:`deny`,label:V.deny.label},{value:`annotate`,label:V.annotate.label}]})}),e.transport===`stdio`?(0,Q.jsx)(a,{label:`Folder it starts in`,technical:`cwd`,optional:!0,children:(0,Q.jsx)(u,{value:e.cwd,onChange:e=>c(`cwd`,e),mono:!0,placeholder:`/Users/me/project`})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(d,{checked:e.passthrough,onChange:e=>c(`passthrough`,e),label:`Send each caller's own sign-in`,description:`Instead of one shared key, the toolbox passes on the key each AI app connects with. This sends that key to this server.`}),e.passthrough&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{label:`Header it goes in`,technical:`credential_passthrough.header`,children:(0,Q.jsx)(u,{value:e.passthroughHeader,onChange:e=>c(`passthroughHeader`,e),mono:!0})}),(0,Q.jsx)(d,{checked:e.passthroughRequired,onChange:e=>c(`passthroughRequired`,e),label:`Refuse calls without a sign-in`,description:`Otherwise a caller with no key of its own falls back to the headers above.`})]})]})]})]})}function ut({compact:e,tab:t,onTab:r,onCatalog:i,onDraft:a}){let[o,s]=(0,Z.useState)(null),[c,u]=(0,Z.useState)(!1),d=e&&!c;if((0,Z.useEffect)(()=>{if(d)return;let e=!0;return n.settings().then(t=>e&&s(t.registry.enabled)).catch(()=>e&&s(!0)),()=>{e=!1}},[d]),d){let e=e=>{u(!0),r(e)};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(dt,{compact:!0,onPick:i}),(0,Q.jsxs)(`p`,{className:`text-[13px] text-soft`,children:[`Other ways:`,` `,(0,Q.jsx)(`button`,{type:`button`,className:`font-medium text-muted underline hover:text-ink`,onClick:()=>e(`registry`),children:`search the public list`}),` · `,(0,Q.jsx)(`button`,{type:`button`,className:`font-medium text-muted underline hover:text-ink`,onClick:()=>e(`paste`),children:`paste instructions from a README`})]})]})}let f=[{id:`popular`,label:`Popular`},...o===!1?[]:[{id:`registry`,label:`Search the public list`}],{id:`paste`,label:`Paste instructions`},{id:`advanced`,label:`Advanced`}],p=t===`registry`&&o===!1?`popular`:t;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(j,{items:f,value:p,onChange:r,label:`Where to find the server`}),(0,Q.jsx)(`div`,{role:`tabpanel`,id:y(p),"aria-labelledby":l(p),children:p===`popular`?(0,Q.jsx)(dt,{onPick:i}):p===`registry`?(0,Q.jsx)(mt,{onCatalogId:(e,t)=>t&&i(t),onDraft:a}):p===`paste`?(0,Q.jsx)(ht,{onDraft:a,onAdvanced:()=>r(`advanced`)}):(0,Q.jsx)(gt,{onDraft:a})})]})}function dt({onPick:e,compact:t}){let i=ne(()=>n.catalog(),[]),[a,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(`all`),[d,f]=(0,Z.useState)(!1),p=i.data?.entries??[],h=a?it(p,a,l):[...it(p,a,l)].sort((e,t)=>Number(t.id===ft)-Number(e.id===ft)),g=[...new Set(p.map(e=>e.category))],v=t&&!d&&!a?6:1/0,y=h.slice(0,v);return i.error&&!i.data?(0,Q.jsx)(s,{tone:`danger`,title:`The list of servers could not be loaded`,actions:(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:i.reload,children:`Try again`}),children:K(i.error)}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`span`,{className:`relative flex items-center`,children:[(0,Q.jsx)(m,{name:`search`,size:17,className:`pointer-events-none absolute left-3.5 text-soft`}),(0,Q.jsx)(`input`,{type:`search`,value:a,onChange:e=>c(e.target.value),placeholder:`Search: files, GitHub, notes…`,"aria-label":`Search servers`,className:`field pl-10`})]}),!t&&g.length>1&&(0,Q.jsx)(`div`,{role:`group`,"aria-label":`Kind of server`,className:`flex flex-wrap gap-1.5`,children:[`all`,...g].map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":l===e,onClick:()=>u(e),className:F(`h-8 rounded-full border-[1.5px] px-3.5 text-[13px] font-semibold transition-colors`,l===e?`border-primary bg-primary text-white`:`border-line text-muted hover:border-[var(--soft)] hover:text-ink`),children:e===`all`?`All`:R[e]},e))})]}),i.data?h.length===0?(0,Q.jsxs)(_,{icon:`search`,title:`Nothing matches`,compact:!0,children:[`Try another word. You can also search the public list, or paste the server's setup instructions, using the `,t?`links below`:`tabs above`,`.`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`sr-only`,role:`status`,children:[r(h.length,`server`),` found`]}),(0,Q.jsx)(`ul`,{className:`grid gap-3 sm:grid-cols-2`,children:y.map(t=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(pt,{entry:t,onPick:()=>e(t)})},t.id))}),y.length<h.length&&(0,Q.jsx)(`div`,{children:(0,Q.jsxs)(E,{size:`sm`,variant:`ghost`,onClick:()=>f(!0),children:[`Show all `,h.length]})})]}):(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[0,1,2,3].map(e=>(0,Q.jsx)(`div`,{className:`rounded-[18px] border border-line p-4`,children:(0,Q.jsx)(o,{lines:3})},e))})]})}var ft=`filesystem`;function pt({entry:t,onPick:n}){let r=Me(t.requires);return(0,Q.jsxs)(`button`,{type:`button`,onClick:n,className:`flex h-full w-full min-w-0 flex-col items-start gap-2 rounded-[18px] border-[1.5px] border-line p-4 text-left transition-colors hover:border-[var(--soft)] hover:bg-faint/50`,children:[(0,Q.jsxs)(`span`,{className:`flex w-full items-start gap-2`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-[15.5px] font-semibold`,children:t.name}),(0,Q.jsxs)(`span`,{className:`block text-[12.5px] text-muted`,children:[`by `,t.publisher.name]})]}),t.id===ft?(0,Q.jsx)(e,{tone:`ok`,icon:`check`,children:`Good first choice`}):t.publisher.official&&(0,Q.jsx)(e,{tone:`ok`,icon:`shield-check`,children:`Official`})]}),(0,Q.jsx)(`span`,{className:`text-[13.5px] text-muted`,children:t.summary}),(r.setup.length>0||r.needs.length>0)&&(0,Q.jsxs)(`span`,{className:`mt-auto flex flex-wrap gap-1.5 pt-1`,children:[r.setup.length>0&&(0,Q.jsx)(`span`,{title:`Needs ${r.setup.map(e=>G[e]??e).join(` and `)}. The next screen walks you through it.`,children:(0,Q.jsx)(e,{icon:`wrench`,children:`Needs a little setup`})}),r.needs.map(t=>(0,Q.jsx)(e,{children:t},t))]})]})}function mt({onCatalogId:t,onDraft:i}){let[a,c]=(0,Z.useState)(``),l=w(a.trim(),300),[u,d]=(0,Z.useState)(null),[p,h]=(0,Z.useState)([]),[g,_]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(0),[C,T]=(0,Z.useState)(null),D=ne(()=>n.catalog(),[]),O=l?it(D.data?.entries??[],l).slice(0,3):[];(0,Z.useEffect)(()=>{if(!l){d(null),h([]),_(null),b(!1);return}let e=!0;return b(!0),n.registrySearch(l).then(t=>{e&&(d(t),h(t.hits),_(null))}).catch(t=>{e&&(t instanceof f&&(t.status===404||t.code===`registry-off`)?_(`Searching the public list is switched off in Settings & help.`):_(K(t)))}).finally(()=>e&&b(!1)),()=>{e=!1}},[l,x]),(0,Z.useEffect)(()=>{if(!u?.loading)return;let e=setTimeout(()=>S(e=>e+1),2e3);return()=>clearTimeout(e)},[u]);let k=()=>{u?.nextCursor&&(b(!0),n.registrySearch(l,u.nextCursor).then(e=>{d(e),h(t=>[...t,...e.hits])}).catch(e=>_(K(e))).finally(()=>b(!1)))},A=e=>{e.catalogId?(T(e.name),n.catalog().then(n=>t(e.catalogId,n.entries.find(t=>t.id===e.catalogId)??null)).catch(e=>_(K(e))).finally(()=>T(null))):e.draft&&i(e.draft,{})};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:`A public directory of servers that anyone can publish to. Only the words you type are sent to it to find matches. Nobody has checked these servers, so look at who made one before you add it.`}),(0,Q.jsxs)(`span`,{className:`relative flex items-center`,children:[(0,Q.jsx)(m,{name:`search`,size:17,className:`pointer-events-none absolute left-3.5 text-soft`}),(0,Q.jsx)(`input`,{type:`search`,value:a,onChange:e=>c(e.target.value),placeholder:`Search the public list`,"aria-label":`Search the public list`,className:`field pl-10`}),y&&(0,Q.jsx)(`span`,{className:`absolute right-3.5 text-soft`,children:(0,Q.jsx)(ie,{})})]}),(0,Q.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`text-[13px] text-soft`,children:u?.loading?(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(ie,{size:14}),` Getting the list…`]}):u&&l?`${r(u.total+O.length,`server`)}${u.updatedAt?` · list updated ${v(u.updatedAt)}`:``}`:null}),u?.problem&&(0,Q.jsx)(s,{tone:`warn`,children:u.problem}),g&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,actions:(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:()=>S(e=>e+1),children:`Try again`}),children:g}),l?!u&&!g?(0,Q.jsx)(o,{lines:4,height:18}):(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-2`,children:[O.map(n=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>t(n.id,n),className:`flex w-full min-w-0 flex-col items-start gap-1 rounded-[18px] border-[1.5px] border-line p-4 text-left transition-colors hover:border-[var(--soft)] hover:bg-faint/50`,children:[(0,Q.jsxs)(`span`,{className:`flex w-full flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 text-[15px] font-semibold`,children:n.name}),(0,Q.jsx)(e,{tone:`ok`,icon:`shield-check`,children:`Checked by us`})]}),(0,Q.jsx)(`span`,{className:`text-[13.5px] text-muted`,children:n.summary}),(0,Q.jsxs)(`span`,{className:`text-[12.5px] text-soft`,children:[`by `,n.publisher.name]})]})},`catalog-${n.id}`)),p.filter(e=>!e.catalogId||!O.some(t=>t.id===e.catalogId)).map(t=>{let n=!!t.catalogId||!!t.draft;return(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,disabled:!n,onClick:()=>A(t),"aria-describedby":n?void 0:`why-${t.name}`,className:F(`flex w-full min-w-0 flex-col items-start gap-1 rounded-[18px] border-[1.5px] p-4 text-left transition-colors`,n?`border-line hover:border-[var(--soft)] hover:bg-faint/50`:`cursor-not-allowed border-line bg-sunken/40 opacity-70`),children:[(0,Q.jsxs)(`span`,{className:`flex w-full flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 text-[15px] font-semibold`,children:t.title??t.name}),C===t.name&&(0,Q.jsx)(ie,{}),t.catalogId?(0,Q.jsx)(e,{tone:`ok`,icon:`shield-check`,children:`Checked by us`}):n?(0,Q.jsx)(e,{tone:`warn`,children:`From the public list — not checked by us`}):(0,Q.jsx)(e,{children:`Can't be added`})]}),(0,Q.jsx)(`span`,{className:`text-[13.5px] text-muted`,children:t.description}),t.caution&&(0,Q.jsxs)(`span`,{className:`flex items-start gap-1.5 text-[12.5px] font-medium text-warn`,children:[(0,Q.jsx)(m,{name:`warning`,size:14,className:`mt-0.5 shrink-0`}),t.caution]}),(0,Q.jsxs)(`code`,{className:`mono text-[11.5px] text-soft`,children:[t.name,` · `,t.version]}),!n&&(0,Q.jsx)(`span`,{id:`why-${t.name}`,className:`text-[12.5px] text-soft`,children:t.unsupported??`It can't be started from the public list's description.`})]})},t.name)})]}):(0,Q.jsx)(`p`,{className:`rounded-2xl bg-sunken/60 px-4 py-3 text-[13.5px] text-muted`,children:`Type the name of a server or a service, such as “weather” or “slack”, to search the public list.`}),u?.nextCursor&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,onClick:k,loading:y,children:`Show more`})})]})}function ht({onDraft:e,onAdvanced:t}){let[i,a]=(0,Z.useState)(``),[o,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`label`,{htmlFor:`add-paste`,className:`text-[13px] font-semibold`,children:`Paste the setup instructions`}),(0,Q.jsx)(`textarea`,{id:`add-paste`,rows:8,value:i,onChange:e=>{a(e.target.value),u(null)},"aria-describedby":`add-paste-help`,placeholder:`{
|
|
2
|
+
"mcpServers": {
|
|
3
|
+
"weather": { "command": "npx", "args": ["-y", "weather-mcp"] }
|
|
4
|
+
}
|
|
5
|
+
}`,className:`field resize-y font-mono text-[13px]`}),(0,Q.jsx)(`p`,{id:`add-paste-help`,className:`text-[12.5px] text-soft`,children:`Copy the part of the server's instructions page (often called its README) that shows how to add it: a block of settings, a one-line command, or just its web address. Nothing is saved yet, and any keys in it go into your locked keys, never into a settings file.`})]}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{variant:`primary`,icon:`search`,onClick:()=>{c(!0),f(null),n.paste(i).then(u).catch(e=>f(K(e))).finally(()=>c(!1))},loading:o,disabled:!i.trim(),children:`Read it`})}),d&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,children:d}),l&&(0,Q.jsxs)(`div`,{role:`status`,className:`flex flex-col gap-3`,children:[l.servers.length===0?(0,Q.jsx)(s,{tone:`warn`,title:`No server could be added from that`,children:l.warnings.length>0&&!/didn't look like setup instructions/.test(l.warnings.join(` `))?(0,Q.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5`,children:l.warnings.map(e=>(0,Q.jsx)(`li`,{children:e},e))}):(0,Q.jsxs)(Q.Fragment,{children:[`We couldn't find a server in that. Paste the line that starts with `,(0,Q.jsx)(`code`,{className:`mono`,children:`npx`}),`, `,(0,Q.jsx)(`code`,{className:`mono`,children:`uvx`}),` or`,` `,(0,Q.jsx)(`code`,{className:`mono`,children:`docker`}),`, the block that contains `,(0,Q.jsx)(`code`,{className:`mono`,children:`mcpServers`}),`, or the server's web address. You can also add it by hand under`,` `,(0,Q.jsx)(`button`,{type:`button`,className:`font-semibold underline`,onClick:t,children:`Advanced`}),`.`]})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`text-[14px] font-medium`,children:[`Found `,r(l.servers.length,`server`),l.recognisedAs&&(0,Q.jsxs)(`span`,{className:`font-normal text-soft`,children:[` · read as `,l.recognisedAs]})]}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:l.servers.map((t,n)=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>e(t.draft,t.values),className:`flex w-full items-center gap-3 rounded-[18px] border-[1.5px] border-line p-4 text-left hover:border-[var(--soft)] hover:bg-faint/50`,children:[(0,Q.jsx)(`span`,{className:`grid h-10 w-10 shrink-0 place-items-center rounded-full bg-sunken text-muted`,children:(0,Q.jsx)(m,{name:t.draft.launch.transport===`http`?`external`:`server`,size:18})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-[15px] font-semibold`,children:t.draft.displayName}),(0,Q.jsx)(`span`,{className:`block truncate text-[12.5px] text-soft`,children:t.draft.launch.transport===`http`?`Remote server · ${t.draft.launch.url}`:`Runs on this computer · ${[t.draft.launch.command,...t.draft.launch.args??[]].join(` `)}`}),t.draft.warnings.map(e=>(0,Q.jsx)(`span`,{className:`mt-1 block text-[12.5px] text-warn`,children:e},e))]}),(0,Q.jsx)(m,{name:`chevron-right`,size:18,className:`shrink-0 text-soft`})]})},`${t.draft.name}-${n}`))})]}),l.servers.length>0&&l.warnings.length>0&&(0,Q.jsx)(s,{tone:`info`,title:`Note`,children:(0,Q.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5`,children:l.warnings.map(e=>(0,Q.jsx)(`li`,{children:e},e))})})]})]})}function gt({onDraft:e}){let[t,n]=(0,Z.useState)(at()),[r,i]=(0,Z.useState)(!1),a=ct(t);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:`For a server you know how to start. Values whose names look like keys (TOKEN, KEY, SECRET, PASSWORD) go into your locked keys rather than the toolbox's settings file.`}),(0,Q.jsx)(lt,{value:t,onChange:n}),r&&a&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-[13px] font-medium text-bad`,children:a}),(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(E,{variant:`primary`,iconRight:`arrow-right`,onClick:()=>{if(i(!0),a)return;let n=Ae(st(t));e(n.draft,n.values)},children:`Continue`})})]})}function _t({transport:e}){let[t,n]=(0,Z.useState)(0);return(0,Z.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,Q.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex flex-col items-center gap-4 py-12 text-center`,children:[(0,Q.jsx)(`span`,{className:`grid h-14 w-14 place-items-center rounded-full bg-ok-tint text-ok`,children:(0,Q.jsx)(ie,{size:26})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[17px] font-medium`,children:be(t,e)}),(0,Q.jsxs)(`p`,{className:`mt-1 text-[13.5px] text-soft`,children:[`Nothing is saved yet. `,t>2&&(0,Q.jsxs)(`span`,{className:`tnum`,children:[`(`,t,` s)`]})]})]})]})}var vt=[`run`,`ask`,`blocked`],yt={run:`Your AI can use these without asking.`,ask:`Once protection is on, each use waits until you say yes.`,blocked:`Once protection is on, your AI can't use these.`};function bt({outcome:e,name:t,watching:n,keyUnchecked:r}){let i=De(e),a=ze(e),o=vt.filter(e=>i[e].length>0);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsxs)(`div`,{role:`status`,className:`flex items-center gap-3 rounded-[18px] bg-ok-tint p-4`,children:[(0,Q.jsx)(`span`,{className:`grid h-10 w-10 shrink-0 place-items-center rounded-full bg-surface text-ok`,children:(0,Q.jsx)(m,{name:`check`,size:20,strokeWidth:2.2})}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block text-[15px] font-semibold`,children:r?`${t} started`:`${t} works`}),(0,Q.jsxs)(`span`,{className:`block text-[13.5px] text-muted`,children:[Pe(e),r&&` Your key is checked the first time your AI uses it.`]})]})]}),i.offered>0&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(nt,{sub:n?`What happens when your AI uses each tool once protection is on. Right now your toolbox only watches, so everything runs and is written down. You can change any of this later on the Tools page.`:n===!1?`What happens when your AI uses each tool. Protection is on. You can change any of this later on the Tools page.`:`What happens when your AI uses each tool once protection is on. You can change any of this later on the Tools page.`,children:`What your AI can do`}),(0,Q.jsx)(`div`,{className:F(`grid gap-3`,o.length===2?`md:grid-cols-2`:o.length>=3?`lg:grid-cols-3 md:grid-cols-2`:``),children:o.map(e=>(0,Q.jsx)(xt,{verdict:e,tools:i[e],wide:o.length===1},e))})]}),(a.lines.length>0||a.quiet)&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(nt,{children:a.lines.length>0?`Please check`:`Note`}),(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-2 text-[13.5px]`,children:[a.lines.map((e,t)=>(0,Q.jsxs)(`li`,{className:F(`flex gap-2 rounded-2xl p-3`,e.tone===`warn`?`bg-warn-tint`:`border border-line`),children:[(0,Q.jsx)(m,{name:e.text.startsWith(`Won't be offered`)?`eye-off`:`warning`,size:17,className:F(`mt-0.5 shrink-0`,e.tone===`warn`?`text-warn`:`text-soft`)}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[e.tool&&(0,Q.jsx)(`code`,{className:`mono mr-1 font-semibold`,children:e.tool}),e.text,e.technical&&(0,Q.jsxs)(`details`,{className:`mt-1`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-[12.5px] text-soft select-none`,children:`Details`}),(0,Q.jsx)(`p`,{className:`mono mt-1 text-[12px] break-words text-soft`,children:e.technical})]})]})]},t)),a.quiet&&(0,Q.jsx)(`li`,{className:`rounded-2xl border border-line p-3 text-muted`,children:(0,Q.jsxs)(`details`,{children:[(0,Q.jsxs)(`summary`,{className:`cursor-pointer select-none`,children:[a.quiet.text,` `,(0,Q.jsx)(`span`,{className:`text-soft underline`,children:`Details`})]}),(0,Q.jsx)(`ul`,{className:`mt-2 flex max-h-64 flex-col gap-1 overflow-auto text-[12px] text-soft`,children:a.quiet.details.map((e,t)=>(0,Q.jsxs)(`li`,{className:`mono break-words`,children:[e.tool&&(0,Q.jsxs)(`span`,{className:`font-semibold`,children:[e.tool,`: `]}),e.text]},t))})]})})]})]})]})}function xt({verdict:e,tools:t,wide:n}){let[r,i]=(0,Z.useState)(t.length<=8),a=r?t:t.slice(0,8),o=ke[e];return(0,Q.jsxs)(`div`,{className:`rounded-[18px] border border-line p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(T,{decision:o}),(0,Q.jsx)(`span`,{className:`tnum text-[13px] text-soft`,children:t.length})]}),(0,Q.jsx)(`p`,{className:`mt-1.5 mb-2 text-[12.5px] text-soft`,children:yt[e]}),(0,Q.jsx)(`ul`,{className:F(`grid`,n&&`sm:grid-cols-2 sm:gap-x-6`),"aria-label":re[o].label,children:a.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-center gap-2 border-b border-faint py-1.5 last:border-b-0`,children:[(0,Q.jsx)(b,{effect:e.effect}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(`span`,{className:`block text-[13px] [overflow-wrap:anywhere]`,title:e.description?`${e.name}: ${e.description}`:e.name,children:e.title??tt(e.name).label})}),(0,Q.jsx)(`span`,{className:`sr-only`,children:N[e.effect]?.label}),e.packRule&&(0,Q.jsx)(`span`,{className:`shrink-0 text-[11.5px] text-muted`,title:`Decided by a ready-made rule for this server`,children:`Ready-made rule`})]},e.name))}),!r&&(0,Q.jsxs)(E,{size:`sm`,variant:`ghost`,className:`mt-1`,onClick:()=>i(!0),children:[`Show all `,t.length]}),(0,Q.jsxs)(`details`,{className:`mt-2 text-[12px] text-soft`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer select-none`,children:`Details`}),(0,Q.jsxs)(`p`,{className:`mt-1`,children:[`The server's own names:`,` `,t.map((e,t)=>(0,Q.jsxs)(`span`,{children:[t>0&&`, `,(0,Q.jsx)(`code`,{className:`mono break-normal`,children:te(e.name)})]},e.name))]})]})]})}var St=e=>`add-field-${e.replace(/[^\w-]/g,`_`)}`;function Ct({draft:t,entry:n,values:r,onValues:i,problems:a,tried:o,onVariant:c,name:l,onName:u,signedIn:f,onSignedIn:p,doctor:h,doctorBusy:g,onRecheck:_,focus:v}){let[y,b]=(0,Z.useState)({}),x=(e,t)=>i({...r,[e]:t}),S=t.source.kind===`catalog`?t.source.variant:null,C=n?.variants??[],w=ge(t.requires,h),T=Le(t),E=t.launch.transport===`http`?Ke(t.launch.url,r):``,D=Fe(t,r);(0,Z.useEffect)(()=>{if(!v||v.kind!==`field`||!v.field)return;let e=document.getElementById(St(v.field));e?.focus(),e?.scrollIntoView({block:`center`,behavior:`smooth`})},[v?.nonce]);let O=e=>a[e.id]??(o||y[e.id]?Ce(e,r[e.id]):null);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h2`,{className:`text-[20px] font-medium tracking-[-0.02em]`,children:t.displayName}),n?.publisher.official&&(0,Q.jsx)(e,{tone:`ok`,icon:`shield-check`,children:`Official`}),t.source.kind===`registry`&&(0,Q.jsx)(e,{tone:`warn`,icon:`warning`,children:`From the public list — not checked by us`}),t.source.kind===`paste`&&(0,Q.jsx)(e,{children:`From what you pasted`}),t.requires.map(t=>(0,Q.jsxs)(e,{children:[`Needs `,G[t]??t]},t))]}),(n?.description??n?.summary)&&(0,Q.jsx)(`p`,{className:`text-[14px] text-muted`,children:(0,Q.jsx)(M,{text:n?.description??n?.summary??``})})]}),t.warnings.length>0&&(0,Q.jsx)(s,{tone:`warn`,title:`Before you go on`,children:(0,Q.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5`,children:t.warnings.map(e=>(0,Q.jsx)(`li`,{children:e},e))})}),D&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-2xl bg-warn-tint px-4 py-3`,children:[(0,Q.jsx)(d,{checked:r.__local_ok===!0,onChange:e=>x(`__local_ok`,e),label:`This is on my own computer or network`,description:D===`loopback`?`This server's address is on this computer. Testing it lets the toolbox reach that address, just for the test. Only tick this if you started that program yourself.`:`This server's address is on your own network (a router or another computer). Testing it lets the toolbox reach that address, just for the test. Only tick this if you know what is there.`}),a.__local_ok&&r.__local_ok!==!0&&(0,Q.jsxs)(`p`,{role:`alert`,className:`flex items-center gap-1.5 text-[12.5px] font-medium text-bad`,children:[(0,Q.jsx)(m,{name:`warning`,size:14,strokeWidth:2}),`Tick this first, or choose another server.`]})]}),(0,Q.jsx)(rt,{missing:w,platform:h?.platform,onRecheck:_,checking:g}),C.length>1&&S&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-[13.5px] font-semibold`,children:`How to run it`}),(0,Q.jsx)(Re,{label:`How to run it`,value:S,onChange:c,options:C.map(e=>({value:e.id,title:e.label,body:(0,Q.jsxs)(Q.Fragment,{children:[e.summary??(e.launch.transport===`http`?`Runs on the service's own computers. Nothing to install.`:`Runs on this computer.`),(e.requires??[]).length>0&&(0,Q.jsxs)(`span`,{className:`mt-1 block`,children:[`Needs `,(e.requires??[]).map(e=>G[e]).join(` and `),`.`]})]})}))})]}),(0,Q.jsxs)(`div`,{className:F(`grid gap-6`,t.guide.length>0&&`md:grid-cols-2`),children:[t.guide.length>0&&(0,Q.jsx)(ee,{steps:t.guide,className:`md:self-start`}),(0,Q.jsxs)(`section`,{"aria-label":`Settings for this server`,className:`flex min-w-0 flex-col gap-5`,children:[T&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-[13.5px] font-semibold`,children:`Sign in`}),(0,Q.jsx)(He,{serverUrl:E,secretName:fe(l||t.name),name:t.displayName,signedIn:f,onSignedIn:p,startNonce:v?.kind===`sign-in`?v.nonce:void 0})]}),t.fields.map(e=>(0,Q.jsx)(wt,{field:e,value:r[e.id],storedAs:typeof r[`__saved.${e.id}`]==`string`?r[`__saved.${e.id}`]:void 0,onChange:t=>x(e.id,t),onBlur:()=>b(t=>({...t,[e.id]:!0})),error:O(e),openFolder:v?.kind===`folder`&&(!v.field||v.field===e.id)?v.nonce:void 0},e.id)),t.fields.length===0&&!T&&(0,Q.jsxs)(`p`,{className:`flex items-center gap-2 rounded-2xl bg-sunken/60 px-4 py-3 text-[13.5px] text-muted`,children:[(0,Q.jsx)(m,{name:`check`,size:17,className:`text-ok`}),` Nothing to fill in. Test it to see what it can do.`]}),(0,Q.jsxs)(U,{title:`More options`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Q.jsx)(`label`,{htmlFor:`add-server-name`,className:`text-[13px] font-semibold`,children:`Name in your toolbox`}),(0,Q.jsx)(`code`,{className:`mono text-[11.5px] text-muted`,"aria-hidden":!0,children:`name`})]}),(0,Q.jsx)(`input`,{id:`add-server-name`,className:`field font-mono text-[13px]`,value:l,onChange:e=>u(e.target.value),"aria-describedby":`add-server-name-help`,"aria-invalid":!!xe(l)||void 0}),(0,Q.jsx)(`p`,{id:`add-server-name-help`,className:F(`text-[12.5px]`,xe(l)?`font-medium text-bad`:`text-soft`),children:xe(l)??`Your AI app sees its tools as ${l||`name`}__tool.`})]}),(0,Q.jsx)(Tt,{draft:t})]})]})]}),w.length===0&&t.requires.length>0&&h&&(0,Q.jsx)(`p`,{className:`sr-only`,role:`status`,children:`This computer has everything this server needs.`})]})}function wt({field:e,value:t,onChange:n,onBlur:r,error:i,openFolder:a,storedAs:o}){let s=St(e.id),c=`${s}-help`,l=`${s}-err`,u=[e.help&&!i?c:null,i?l:null].filter(Boolean).join(` `)||void 0;if(e.kind===`toggle`)return(0,Q.jsx)(d,{checked:t===!0,onChange:n,label:e.label,description:e.help});let f=typeof t==`string`?t:``,p=Array.isArray(t)?t:typeof t==`string`&&t?[t]:[],h=(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Q.jsxs)(`label`,{htmlFor:s,className:`text-[13px] font-semibold text-ink`,children:[e.label,!e.required&&e.kind!==`choice`&&!/\boptional\b/i.test(e.label)&&(0,Q.jsx)(`span`,{className:`ml-2 font-normal text-muted`,children:`optional`})]}),e.technical&&(0,Q.jsx)(`code`,{className:`mono text-[11.5px] text-muted`,"aria-hidden":!0,children:e.technical})]}),g;return g=e.kind===`secret`?(0,Q.jsx)(D,{id:s,value:f,onChange:n,storedAs:o,placeholder:e.placeholder,"aria-describedby":u,invalid:!!i}):e.kind===`folder`||e.kind===`folders`?(0,Q.jsx)(P,{id:s,value:p,multiple:e.kind===`folders`,onChange:t=>{n(e.kind===`folders`?t:t[0]??``),r()},openNonce:a,"aria-describedby":u}):e.kind===`choice`?(0,Q.jsxs)(`span`,{className:`relative flex items-center`,children:[(0,Q.jsx)(`select`,{id:s,value:f,onChange:e=>n(e.target.value),onBlur:r,"aria-describedby":u,"aria-invalid":!!i||void 0,className:`field appearance-none pr-9`,children:(e.choices??[]).map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,Q.jsx)(m,{name:`chevron`,size:16,className:`pointer-events-none absolute right-3 text-soft`})]}):(0,Q.jsx)(`input`,{id:s,type:e.kind===`url`?`url`:`text`,value:f,onChange:e=>n(e.target.value),onBlur:r,placeholder:e.placeholder??(e.kind===`url`?`https://`:void 0),spellCheck:!1,"aria-describedby":u,"aria-invalid":!!i||void 0,className:F(`field`,e.kind===`url`&&`font-mono text-[13px]`)}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e.kind===`folder`||e.kind===`folders`?(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2 text-[13px] font-semibold text-ink`,children:[e.label,!e.required&&!/\boptional\b/i.test(e.label)&&(0,Q.jsx)(`span`,{className:`font-normal text-soft`,children:`optional`})]}):h,g,e.help&&!i&&(0,Q.jsx)(`p`,{id:c,className:`text-[12.5px] text-soft`,children:(0,Q.jsx)(M,{text:e.help})}),i&&(0,Q.jsxs)(`p`,{id:l,role:`alert`,className:`flex items-center gap-1.5 text-[12.5px] font-medium text-bad`,children:[(0,Q.jsx)(m,{name:`warning`,size:14,strokeWidth:2}),i]})]})}function Tt({draft:e}){let t=e.launch,n=e=>typeof e==`string`?e:`${e.prefix??``}<locked key: ${e.field}>`;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 text-[12.5px]`,children:[(0,Q.jsx)(`p`,{className:`font-semibold`,children:`What it runs`}),t.transport===`stdio`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`code`,{className:`mono rounded-xl bg-sunken px-3 py-2 break-all`,children:[t.command,...t.args??[]].join(` `)}),Object.entries(t.env??{}).map(([e,t])=>(0,Q.jsxs)(`code`,{className:`mono text-soft break-all`,children:[e,`=`,n(t)]},e))]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`code`,{className:`mono rounded-xl bg-sunken px-3 py-2 break-all`,children:t.url}),Object.entries(t.headers??{}).map(([e,t])=>(0,Q.jsxs)(`code`,{className:`mono text-soft break-all`,children:[e,`: `,n(t)]},e))]})]})}var $={saved:null},Et=new Set([`brave-search`]);function Dt(){$.saved=null}function Ot(e){let{gatewayId:t,onDone:r,onCancel:i,initialCatalogId:a,compact:c,fixUpstream:l}=e,[u,d]=(0,Z.useState)(`popular`),[p,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(a??null),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)({}),[w,T]=(0,Z.useState)(``),[D,k]=(0,Z.useState)(!1),[A,ee]=(0,Z.useState)(!1),[te,j]=(0,Z.useState)({}),[M,N]=(0,Z.useState)(null),[ne,P]=(0,Z.useState)(null),[re,ae]=(0,Z.useState)(null),[oe,se]=(0,Z.useState)(!1),[ce,F]=(0,Z.useState)(!1),[I,le]=(0,Z.useState)(null),[de,L]=(0,Z.useState)(null),[R,me]=(0,Z.useState)($.saved),[ge,_e]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{if(!t){_e(!0);return}let e=!0;return h.protection(t).then(t=>e&&_e(t.enforcement!==`enforce`)).catch(()=>e&&_e(null)),()=>{e=!1}},[t]);let[ye,be]=(0,Z.useState)(null),z=e=>{$.saved=e,me(e)},B=(0,Z.useRef)(null),Ce=R?`done`:M&&M.kind!==`error`?`test`:p?`setup`:`choose`;(0,Z.useEffect)(()=>{B.current?.focus()},[Ce]);let we=(e,t,n={})=>{g({draft:e,entry:t}),be(null);let r=Object.fromEntries(Object.entries(n).filter(([e])=>e.startsWith(he)));S({...Oe(e,n),...r}),T(e.name),k(!1),ee(!1),j({}),N(null),le(null),e.requires.length&&!re&&Ae()},Ee=(e,t,r)=>{v(e.id),b(null),n.catalogDraft(e.id,t).then(t=>we(t.draft,e,r)).catch(e=>b(K(e))).finally(()=>v(null))},[De,V]=(0,Z.useState)(!1),ke=async(e,t,r)=>{V(!0),b(null);try{let i=(await n.catalog()).entries,a=qe(e,i),o,s,c=null;a?(o=(await n.catalogDraft(a.entry.id,a.variant)).draft,s=Qe(o,e,r),c=a.entry):{draft:o,values:s}=ue(e,r),we(o,c,s),be(e.name),T(e.name);let l=Date.now(),u=e=>o.fields.find(t=>e.includes(t.kind))?.id;if(t===`choose-folder`)P({kind:`folder`,field:u([`folder`,`folders`]),nonce:l});else if(t===`replace-key`){let e=u([`secret`]);e&&S(t=>Object.fromEntries(Object.entries({...t,[e]:``}).filter(([t])=>t!==`${he}${e}`))),P(e?{kind:`field`,field:e,nonce:l}:null)}else t===`sign-in`&&P({kind:`sign-in`,nonce:l})}catch(e){b(K(e))}finally{V(!1)}};(0,Z.useEffect)(()=>{l&&!$.saved&&ke(l.upstream,l.action,l.path)},[l?.upstream.name,l?.action]),(0,Z.useEffect)(()=>{a&&!$.saved&&n.catalog().then(e=>{let t=e.entries.find(e=>e.id===a);t?Ee(t):v(null)}).catch(e=>{b(K(e)),v(null)})},[a]);let Ae=()=>{se(!0),n.doctor().then(ae).catch(()=>void 0).finally(()=>se(!1))},H=p?.draft??null,U=H?Le(H):!1,Me=fe(w||H?.name||`server`),W=()=>{if(!H)return;ee(!0),le(null);let e=ve(H,x);if(Object.keys(e).length||xe(w)){let t=H.fields.find(t=>e[t.id]);t&&P({kind:`field`,field:t.id,nonce:Date.now()}),N({kind:`error`,text:xe(w)?`The name under More options needs fixing.`:`Some settings need fixing first. They are marked above.`})}else U&&!D?N({kind:`error`,text:`Sign in with ${H.displayName} first.`}):Fe(H,x)&&x.__local_ok!==!0?N({kind:`error`,text:`This server's address is on your own computer or network. Tick “This is on my own computer or network” first, or choose another server.`}):(N({kind:`running`}),j({}),n.testServer({...t?{gatewayId:t}:{},draft:H,values:U?{...x,[pe]:Me}:x,...w.trim()===H.name?{}:{name:w.trim()},...ye?{replacing:ye}:{}}).then(e=>{if(Object.keys(e.problems).length){j(e.problems);let t=H.fields.find(t=>e.problems[t.id]);t&&P({kind:`field`,field:t.id,nonce:Date.now()}),N({kind:`error`,text:`Some settings need fixing first. They are marked above.`})}else N({kind:`done`,res:e})}).catch(e=>N({kind:`error`,text:K(e)})))},G=e=>{if(!H)return;let t=Date.now(),n=e=>H.fields.find(t=>e.includes(t.kind))?.id;switch(e){case`retry`:case`allow-address`:return W();case`install-runtime`:case`start-runtime`:return Ae();case`show-details`:return;case`choose-folder`:{N(null);let e=n([`folder`,`folders`]);if(!e&&H.launch.transport===`stdio`&&p){let e=M?.kind===`done`?M.res.outcome.problem?.detail?.path:void 0,n=ue({name:w||H.name,transport:`stdio`,command:H.launch.command,args:H.launch.args??[]},e);if(n.draft.fields.some(e=>e.kind===`folders`)){let e={...H,launch:{...H.launch,args:n.draft.launch.args??[]},fields:[...H.fields,...n.draft.fields]};return g({...p,draft:e}),S(e=>({...e,folders:n.values.folders??[]})),P({kind:`folder`,field:`folders`,nonce:t})}return P(null)}return P({kind:`folder`,field:e,nonce:t})}case`replace-key`:{N(null);let e=n([`secret`]);return e&&S(t=>Object.fromEntries(Object.entries({...t,[e]:``}).filter(([t])=>t!==`${he}${e}`))),P(e?{kind:`field`,field:e,nonce:t}:null)}case`sign-in`:return!Le(H)&&p&&g({...p,draft:Se(H)}),N(null),k(!1),P({kind:`sign-in`,nonce:t});case`check-address`:{N(null);let e=n([`url`,`text`]);return P(e?{kind:`field`,field:e,nonce:t}:null)}}},[Pe,Ie]=(0,Z.useState)(null),Re=async(e,t,n)=>{if(!R)return;Ie(null);let{upstreamName:r}=R.result;if(p){z(null),be(r),T(r),G(e);return}let i=t;if(!i)try{i=(await We(R.result.gatewayId)).config?.upstreams.find(e=>e.name===r)??null}catch(e){Ie(K(e));return}i?(z(null),await ke(i,e,n)):Ie(`The server "${r}" isn't in your toolbox any more.`)},ze=(0,Z.useRef)(!1),Ve=async e=>{if(M?.kind!==`done`||ze.current)return;ze.current=!0,F(!0),le(null);let r;if(t)try{let[e,n]=await Promise.all([We(t),h.protection(t)]);r={gateway:e.digest,policy:n.policyWrite.digest}}catch{r=void 0}try{if(!e){let e=await n.install(t??`main`,{probeId:M.res.probeId,...r?{expected:r}:{},preview:!0});if(e.preview&&(e.loosens??[]).length>0){L(e.loosens);return}}let i=await n.install(t??`main`,{probeId:M.res.probeId,...r?{expected:r}:{},...e?{acknowledged:{loosens:!0}}:{}});L(null);let a=i.apply===`live`||i.apply===`pending`||i.apply===`needs-restart`;z({result:i,name:H?.displayName??i.upstreamName,live:{kind:`waiting`},settled:!a})}catch(e){e instanceof f&&e.needsLoosenAck?L(je(e)):e instanceof f&&(e.status===410||/probe/i.test(e.code))?(L(null),le({text:`The test result is too old to save. Test it again, then save.`,retest:!0})):(L(null),le({text:Be(e)?`The toolbox's settings changed while you were here. Save again to use the latest.`:K(e)}))}finally{ze.current=!1,F(!1)}};(0,Z.useEffect)(()=>{if(!R||R.settled)return;let e=Date.now(),t=R.result.gatewayId,r=!0,i=()=>n.live(t).then(t=>{if(!r)return;let{live:n,settled:i}=Te(t,R.result.upstreamName,R.result.apply,Date.now()-e,e);z({...R,live:n,settled:i})}).catch(()=>r&&(R.result.apply===`needs-restart`||Date.now()-e>=15e3)&&z({...R,settled:!0})),a=setInterval(i,1e3);return i(),()=>{r=!1,clearInterval(a)}},[R?.result.upstreamName,R?.settled]);let q=()=>{$.saved=null,i?.()},He=()=>{let e=R?.result;$.saved=null,e&&r(e)};if(R)return(0,Q.jsx)(kt,{saved:R,heading:B,onFinish:He,onRewatch:()=>z({...R,live:{kind:`waiting`},settled:!1}),onReopen:(e,t,n)=>void Re(e,t,n),reopenError:Pe});if(!p)return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`h2`,{ref:B,tabIndex:-1,className:`text-[17px] font-semibold outline-none`,children:c?`Pick a server to add`:`Find the server you want`}),y&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,children:y}),_&&a||De?(0,Q.jsx)(o,{lines:5}):(0,Q.jsxs)(`div`,{className:`relative`,children:[_&&(0,Q.jsx)(`div`,{role:`status`,className:`absolute inset-0 z-10 grid place-items-center rounded-[18px] bg-surface/70`,children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2 text-[14px]`,children:[(0,Q.jsx)(ie,{}),` Opening…`]})}),(0,Q.jsx)(ut,{compact:c,tab:u,onTab:d,onCatalog:e=>Ee(e),onDraft:(e,t)=>we(e,null,t)})]}),i&&(0,Q.jsx)(`div`,{className:`flex justify-end border-t border-faint pt-5`,children:(0,Q.jsx)(E,{variant:`ghost`,onClick:q,children:`Cancel`})})]});let J=p.draft,Y=(0,Q.jsx)(E,{variant:`ghost`,icon:`arrow-left`,onClick:()=>M?N(null):(g(null),O({kind:`picker`})),disabled:M?.kind===`running`||ce,children:M&&M.kind!==`error`?`Change its settings`:`Choose another server`}),X=M?.kind===`done`&&!M.res.outcome.ok?M.res.outcome.problem??{code:`unknown`,message:`It did not start, and gave no reason.`}:null,Ge=J.source.kind===`catalog`&&J.launch.transport===`http`&&/^https?:\/\/(127\.|localhost|\[::1\])/i.test(J.launch.url)?p.entry?.name??J.displayName:void 0,Ke={firstSignIn:U?!D:M?.kind===`done`&&!!M.res.signInAvailable,...Ge?{desktopApp:Ge.replace(/\s*\(desktop app\)\s*$/i,``)}:{},hasFolderField:J.fields.some(e=>e.kind===`folder`||e.kind===`folders`)||J.launch.transport===`stdio`};return Ce===`test`&&M?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`h2`,{ref:B,tabIndex:-1,className:`text-[17px] font-semibold outline-none`,children:[`Test `,J.displayName]}),M.kind===`running`?(0,Q.jsx)(_t,{transport:J.launch.transport}):M.kind===`done`&&M.res.outcome.ok?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(bt,{outcome:M.res.outcome,name:J.displayName,watching:ge,keyUnchecked:J.fields.some(e=>e.kind===`secret`)&&!(J.source.kind===`catalog`&&Et.has(J.source.id))}),M.res.egressHosts.length>0&&(0,Q.jsxs)(`p`,{className:`flex items-start gap-2 text-[13px] text-soft`,children:[(0,Q.jsx)(m,{name:`shield`,size:16,className:`mt-0.5 shrink-0`}),(0,Q.jsxs)(`span`,{children:[`Saving lets the toolbox reach `,(0,Q.jsx)(`span`,{className:`mono`,children:M.res.egressHosts.join(`, `)}),`. You'll be asked to confirm.`]})]})]}):M.kind===`done`?(0,Q.jsx)(Ne,{problem:X,onFix:G,context:Ke,extra:(0,Q.jsxs)(Q.Fragment,{children:[M.res.signInAvailable&&!U&&M.res.outcome.problem?.code!==`needs-sign-in`&&(0,Q.jsx)(E,{size:`sm`,icon:`key`,onClick:()=>G(`sign-in`),children:`Sign in instead`}),Ue(X,Ke).fix?.action!==`retry`&&(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:W,children:`Try again`})]})}):null,I&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,title:`It wasn't saved`,actions:I.retest?(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:W,children:`Test it again`}):void 0,children:I.text}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2 border-t border-faint pt-5`,children:[Y,M.kind===`done`&&M.res.outcome.ok&&(0,Q.jsx)(E,{variant:`primary`,icon:`power`,onClick:()=>void Ve(),loading:ce,children:`Save and turn on`})]}),(0,Q.jsx)(C,{open:!!de,title:`Save ${J.displayName}?`,confirmLabel:`Save and turn on`,consequences:de??[],busy:ce,error:I?.text??null,onCancel:()=>L(null),onConfirm:()=>void Ve(!0),children:`Adding this server lets your AI apps do more than before. Here is exactly what changes. Nothing is saved until you press Save and turn on.`})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`h2`,{ref:B,tabIndex:-1,className:`sr-only outline-none`,children:[`Set up `,J.displayName]}),(0,Q.jsx)(Ct,{draft:J,entry:p.entry,values:x,onValues:e=>{S(e),j({})},problems:te,tried:A,onVariant:e=>p.entry&&Ee(p.entry,e,x),name:w,onName:T,signedIn:D,onSignedIn:k,doctor:re,doctorBusy:oe,onRecheck:Ae,focus:ne}),M?.kind===`error`&&(0,Q.jsxs)(`p`,{role:`alert`,className:`flex items-center gap-1.5 text-[13.5px] font-medium text-bad`,children:[(0,Q.jsx)(m,{name:`warning`,size:16,strokeWidth:2}),` `,M.text]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2 border-t border-faint pt-5`,children:[Y,(0,Q.jsx)(E,{variant:`primary`,icon:`play`,onClick:W,disabled:!!_,children:`Test it`})]})]})}function kt({saved:e,heading:t,onFinish:n,onRewatch:r,onReopen:a,reopenError:o}){let{result:c,live:l,settled:u,name:d}=e,f=g(),p=!u,[h,_]=(0,Z.useState)(null),v=l.kind===`problem`||l.kind===`needs-sign-in`;(0,Z.useEffect)(()=>{if(!v||h)return;let e=!0;return We(c.gatewayId).then(t=>e&&t.broken===null&&_(t.config.upstreams.find(e=>e.name===c.upstreamName)??null)).catch(()=>void 0),()=>{e=!1}},[v,c.gatewayId,c.upstreamName]);let y,b=null,x=`check`;l.kind===`live`?(y=`Live — ${l.tools} ${l.tools===1?`tool`:`tools`} ready`,b=`${d} is on. Your AI app can use it now, no restart needed.`):c.apply===`not-running`?(y=`${d} is saved`,b=`It turns on when your AI app opens your toolbox. If you haven't connected an app yet, that's the next step.`):c.apply===`needs-restart`||l.kind===`needs-restart`?(y=`${d} is saved. Restart your AI app once`,b=(l.kind===`needs-restart`?l.why:void 0)??`The running toolbox couldn't take this change while running. Quit your AI app and open it again.`,x=`clock`):l.kind===`needs-sign-in`?(y=`Saved, but it needs you to sign in`,b=`Press Sign in again below. It turns on as soon as you're signed in.`,x=`warning`):l.kind===`problem`?(y=`Saved, but it isn't working yet`,x=`warning`):p?(y=`Turning on ${d}…`,x=`clock`):(y=`${d} is saved`,b=`It's still starting. You can see how it's doing on the Connections page.`,x=`clock`);let C=l.kind===`problem`?{name:c.upstreamName,state:`failed`,problem:l.problem,since:``,attempts:0,tool_count:0}:l.kind===`needs-sign-in`?{name:c.upstreamName,state:`needs-sign-in`,since:``,attempts:0,tool_count:0}:null,w=e=>{$.saved=null,se(i(f,e,{server:c.gatewayId}))};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex flex-col items-center gap-3 py-6 text-center`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:F(`grid h-12 w-12 place-items-center rounded-full`,x===`check`?`bg-ok-tint text-ok`:x===`warning`?`bg-warn-tint text-warn`:`bg-sunken text-muted`),children:(0,Q.jsx)(m,{name:x,size:22,strokeWidth:2})}),(0,Q.jsx)(`h2`,{ref:t,tabIndex:-1,className:`text-[17px] font-semibold outline-none`,children:y}),(0,Q.jsx)(`div`,{className:`max-w-[46ch] text-[14px] text-muted`,children:p&&l.kind===`waiting`?(0,Q.jsx)(`span`,{className:`inline-flex items-center gap-2`,children:(0,Q.jsx)(S,{state:`connecting`,label:`Starting`})}):b})]}),C&&(0,Q.jsx)(Ye,{gatewayId:c.gatewayId,upstream:h??{name:c.upstreamName,transport:`stdio`,command:``},state:C,onEdit:e=>a(e,h,l.kind===`problem`?l.problem.detail?.path:void 0),onFixed:r,onAllowAddress:()=>w(`/protection`)}),o&&(0,Q.jsxs)(s,{tone:`danger`,role:`alert`,title:`The setup screen couldn't be opened again`,children:[o,` You can change this server on the Connections page instead.`]}),(c.summary.length>0||c.created)&&(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-2 rounded-[18px] bg-sunken/60 p-4 text-[13.5px]`,children:[c.created&&(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(m,{name:`check`,size:16,className:`mt-0.5 shrink-0 text-ok`}),` Your toolbox is ready. Connect your AI app to it next.`]}),c.summary.map(e=>(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(m,{name:`check`,size:16,className:`mt-0.5 shrink-0 text-ok`}),` `,e]},e))]}),(0,Q.jsx)(`div`,{className:`flex justify-end border-t border-faint pt-5`,children:(0,Q.jsx)(E,{variant:`primary`,icon:`check`,onClick:n,children:`Done`})})]})}var At={};function jt({scope:t,projectDir:n}){let r=ne(()=>me.clients(n),[n]),i=r.data?.clients.find(e=>e.scope===t)??null,[a,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null),[p,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(At[t]??null),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),S=e=>{At[t]=e??void 0,_(e)};if(!i)return r.error?(0,Q.jsx)(s,{tone:`danger`,children:K(r.error)}):(0,Q.jsx)(o,{lines:3});if(!i.attachedTo)return null;let w=H(t),T=i.servers??[],D=e=>T.find(t=>t.source===`extension`&&t.extensionId===e),O=a??new Set(ye(T)),k=T.filter(e=>e.importable&&!(e.source===`extension`&&e.inToolbox)),A=k.filter(e=>O.has(Ze(e))),ee=(e,t)=>{let n=new Set(O);t?n.add(Ze(e)):n.delete(Ze(e)),c(n)},te=e=>{u(!0),f(null),me.importServers({scope:t,names:A.filter(e=>e.source===`config`).map(e=>e.name),extensions:A.filter(e=>e.source===`extension`).map(e=>e.extensionId),...i.projectScoped&&r.data?.projectDir?{projectDir:r.data.projectDir}:{},acknowledged:e}).then(e=>{h(null),c(null),S(e),r.reload()}).catch(t=>{t.detail?.needs===`loosens`&&!e?h(je(t)):(h(null),f(K(t)))}).finally(()=>u(!1))},j=v&&(0,Q.jsxs)(s,{tone:`warn`,title:`Give these servers back to ${w}?`,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(E,{size:`sm`,variant:`secondary`,onClick:()=>y(!1),disabled:l,children:`Keep them in the toolbox`}),(0,Q.jsx)(E,{size:`sm`,variant:`danger`,onClick:()=>{u(!0),f(null),me.undoImport(t,i.projectScoped?r.data?.projectDir:void 0).then(e=>{y(!1),S(null),x(e),r.reload()}).catch(e=>f(K(e))).finally(()=>u(!1))},loading:l,children:`Give them back`})]}),children:[`They are taken out of your toolbox and put back in `,w,`'s own settings, the way they were. Keys saved for them are removed if nothing else uses them.`]});if(g){let t=g.extensionsToSwitchOff.map(e=>({...e,enabled:D(e.id)?.enabled??e.enabled}));return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-4`,"aria-label":`Servers brought in`,children:[(0,Q.jsxs)(`div`,{role:`status`,className:`flex flex-col gap-2 rounded-[18px] bg-ok-tint p-5`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-2.5 text-[16px] font-medium`,children:[(0,Q.jsx)(m,{name:`check`,size:19,className:`text-ok`,strokeWidth:2.2}),we(w,g.imported.length+g.takenOut.length)]}),t.some(e=>e.enabled)&&(0,Q.jsx)(`p`,{className:`text-[14px] text-muted`,children:J(t.filter(e=>e.enabled).map(e=>e.name))}),g.imported.length+g.takenOut.length>0&&(0,Q.jsxs)(`ul`,{className:`space-y-1 text-[14px]`,children:[g.imported.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,Q.jsxs)(`span`,{className:`text-muted`,children:[` `,`— as “`,e.upstream,`”, `,e.tools===1?`1 tool`:`${e.tools} tools`,e.keysLocked.length>0?`; ${e.keysLocked.join(`, `)} kept in your locked keys`:``]})]},`i-${e.name}`)),g.takenOut.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,Q.jsxs)(`span`,{className:`text-muted`,children:[` — your toolbox already had it; `,w,`'s own copy was taken out`]})]},`t-${e.name}`))]}),g.restartHint&&(0,Q.jsx)(`p`,{className:`text-[14px] font-medium`,children:q(Y(g.restartHint))})]}),g.failures.length>0&&(0,Q.jsxs)(s,{tone:`warn`,title:`${g.failures.length===1?`This one stayed`:`These stayed`} in ${w}`,children:[g.failures.length===1?`It`:`They`,` didn't connect when tested, so nothing about `,g.failures.length===1?`it`:`them`,` was changed.`,(0,Q.jsx)(`ul`,{className:`mt-2 space-y-1`,children:g.failures.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`span`,{className:`font-medium`,children:[e.name,`:`]}),` `,q(Y(e.message))]},e.name))})]}),t.length>0&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-[18px] border-[1.5px] border-line p-4`,children:[(0,Q.jsx)(`p`,{className:`text-[15px] font-semibold`,children:`Switch these off in Claude`}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-3`,children:t.map(t=>(0,Q.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[14px] font-medium`,children:t.name}),t.enabled?(0,Q.jsx)(e,{tone:`warn`,children:`Still on`}):(0,Q.jsx)(e,{tone:`ok`,children:`Switched off`})]}),t.enabled&&(0,Q.jsx)(`span`,{className:`text-[13.5px] text-muted`,children:Je(t.name)})]},t.id))}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{size:`sm`,variant:`secondary`,icon:`refresh`,loading:r.loading,onClick:r.reload,children:`Check again`})})]}),g.otherApps.length>0&&(0,Q.jsxs)(`p`,{className:`text-[13.5px] text-soft`,children:[g.otherApps.join(` and `),` `,g.otherApps.length===1?`uses`:`use`,` this toolbox too, so `,g.otherApps.length===1?`it gets`:`they get`,` these servers as well.`]}),g.warning&&(0,Q.jsx)(s,{tone:`warn`,children:q(Y(g.warning))}),d&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,children:d}),j,(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[i.canUndoImport&&!v&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:()=>y(!0),children:`Undo`}),(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,onClick:()=>S(null),children:`Done`})]})]})}return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-4`,"aria-label":`Servers ${w} runs itself`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[15px] font-semibold`,children:`Bring its servers into your toolbox`}),(0,Q.jsx)(`p`,{className:`mt-1 text-[13.5px] text-muted`,children:T.length>0?`${w} runs these servers itself, so your toolbox doesn't check what they do. Each one you choose is tested first; the ones that connect run through your toolbox instead and are taken out of ${w}'s own settings. A backup is kept, so you can undo it.`:`${w} has no servers of its own to bring in.`})]}),b&&(0,Q.jsxs)(s,{tone:`ok`,role:`status`,title:`Given back to ${w}`,children:[b.restored.length>0?`${b.restored.join(`, `)} ${b.restored.length===1?`is`:`are`} back in ${w}'s own settings. `:``,b.extensions.length>0?`Switch ${b.extensions.map(e=>e.name).join(` and `)} back on in Claude, under Settings, then Extensions, if you want Claude to run ${b.extensions.length===1?`it`:`them`} itself. `:``,q(Y(b.restartHint))]}),T.length>0&&(0,Q.jsx)(`p`,{className:`text-[13.5px] text-soft`,children:$e(w)}),T.length>0&&(0,Q.jsx)(`ul`,{className:`flex flex-col gap-3`,children:T.map(e=>(0,Q.jsx)(`li`,{className:`rounded-[14px] border border-line p-3`,children:(0,Q.jsx)(Mt,{server:e,app:w,checked:O.has(Ze(e)),onChange:t=>ee(e,t)})},Ze(e)))}),t===`claude-desktop`&&(0,Q.jsx)(`p`,{className:`text-[13px] text-soft`,children:`Connectors added on claude.ai live in your Claude account, not on this computer, so they can't be listed here.`}),(i.imported?.length??0)>0&&!b&&(0,Q.jsxs)(`p`,{className:`text-[13.5px] text-muted`,children:[`Brought in earlier: `,i.imported.map(e=>e.name).join(`, `),`.`]}),d&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,children:d}),j,(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[k.length>0&&(0,Q.jsx)(E,{size:`sm`,variant:`primary`,icon:`plug`,disabled:A.length===0||l&&!p,loading:l&&!p,onClick:()=>te(!1),children:l&&!p?`Testing each one…`:Ee(A.length)}),i.canUndoImport&&!v&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:()=>y(!0),children:`Undo bringing them in`})]}),(0,Q.jsx)(C,{open:p!==null,onCancel:()=>h(null),onConfirm:()=>te(!0),title:`Let your toolbox reach these servers?`,consequences:p??[],confirmLabel:`Bring them in`,cancelLabel:`Don't bring them in`,busy:l,children:`At least one of these servers runs on this computer or your local network, which your toolbox only reaches once its allowed addresses are widened.`})]})}function Mt({server:t,app:n,checked:r,onChange:i}){let a=(0,Q.jsxs)(`span`,{className:`ml-2 inline-flex flex-wrap gap-1.5 align-middle`,children:[t.source===`extension`&&(0,Q.jsx)(e,{children:`Extension`}),t.inToolbox&&t.source===`config`&&(0,Q.jsx)(e,{tone:`warn`,children:`In both`}),t.inToolbox&&t.source===`extension`&&(t.enabled?(0,Q.jsx)(e,{tone:`warn`,children:`Still on`}):(0,Q.jsx)(e,{tone:`ok`,children:`Switched off`})),!t.importable&&(0,Q.jsx)(e,{children:`Can't be brought in`})]}),o=t.importable?t.inToolbox&&t.source===`config`?`Your toolbox already has it (as “${t.inToolbox}”), and ${n} still runs its own copy. Tick it to take ${n}'s copy out.`:t.inToolbox?t.enabled?`Your toolbox already has it. ${Je(t.name)}`:`Your toolbox has it, and it is switched off in Claude.`:[t.source===`extension`?`A Claude extension. It isn't changed here; you switch it off in Claude afterwards.`:null,t.keysLocked.length>0?`${t.keysLocked.join(`, `)} ${t.keysLocked.length===1?`goes`:`go`} into your locked keys.`:null,t.needsLocalHttp?`It runs on this computer or your local network, so you'll be asked to confirm.`:null,t.upstreamName&&t.upstreamName!==t.name?`In your toolbox it will be called “${t.upstreamName}”.`:null].filter(Boolean).join(` `):q(Y(t.reason??`It can't be brought in.`));return!t.importable||t.inToolbox&&t.source===`extension`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 text-[14px]`,children:[(0,Q.jsxs)(`span`,{className:t.importable?`font-medium`:`font-medium text-soft`,children:[t.name,a]}),(0,Q.jsx)(`span`,{className:`text-[13px] text-soft`,children:o})]}):(0,Q.jsx)(ae,{checked:r,onChange:i,label:(0,Q.jsxs)(`span`,{className:`font-medium`,children:[t.name,a]}),description:o||void 0})}function Nt({client:e,projectDir:t}){let[n,r]=(0,Z.useState)(!1);if(!e.attachedTo)return null;let i=H(e.scope);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(E,{size:`sm`,variant:`secondary`,icon:`plus`,onClick:()=>r(!0),children:`Bring in servers`}),(0,Q.jsx)(oe,{open:n,onClose:()=>r(!1),title:`Bring ${i}'s servers into your toolbox`,width:640,footer:(0,Q.jsx)(E,{onClick:()=>r(!1),children:`Close`}),children:(0,Q.jsx)(jt,{scope:e.scope,...t?{projectDir:t}:{}})})]})}var Pt=null;function Ft({client:e,projectDir:t,onClose:n,onDone:r}){let i=ce(),[a,o]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(Pt),h=(0,Z.useRef)(!0);if((0,Z.useEffect)(()=>{h.current?h.current=!1:e&&(Pt=null,o(!1),d(null),p(null))},[e]),!e)return null;let g=()=>{Pt=null,n(),r()},_=_e(e.scope),v=()=>{l(!0),d(null),me.revert(e.scope,a,e.projectScoped?t:void 0).then(t=>{Pt=t,p(t),i.show(`ok`,`${e.label} no longer uses your toolbox.`)}).catch(e=>d(K(e))).finally(()=>l(!1))};if(f){let e=f;return(0,Q.jsx)(oe,{open:!0,onClose:g,title:`Connection undone`,description:`Restart ${_} so it uses its own server list again.`,width:580,footer:(0,Q.jsx)(E,{variant:`primary`,onClick:g,children:`Close`}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 text-[14px]`,children:[(0,Q.jsx)(`p`,{children:e.fileRestored===`bytes`?`Your toolbox was taken out of ${_}, and its settings file is back exactly as it was before.`:e.fileRestored===`removed`?`Your toolbox was taken out of ${_}. Its settings file didn't exist before, so it was removed again.`:`Your toolbox was taken out of ${_}.`}),f.restored.length>0?(0,Q.jsx)(It,{title:`Servers given back to ${_}`,items:f.restored}):(0,Q.jsxs)(`p`,{className:`text-soft`,children:[_,`'s own servers were never moved, so they keep working as before.`]}),e.copyLeft&&(0,Q.jsxs)(s,{tone:`warn`,title:`A copy of the old settings is kept`,children:[_,`'s settings file changed since it was connected, so a copy of it as it was is kept at `,(0,Q.jsx)(X,{children:e.copyLeft}),`. It holds the old values, including any keys that were written in it. Delete it once you no longer need it.`]}),e.keysKept&&e.keysKept.length>0&&(0,Q.jsxs)(`p`,{className:`text-soft`,children:[`Its keys stay in your locked keys (`,e.keysKept.join(`, `),`). Remove them under Settings & help, Locked keys, if nothing else uses them.`]}),f.importedNote&&(0,Q.jsx)(`p`,{className:`text-soft`,children:q(Y(f.importedNote))}),e.stillUsedBy&&e.stillUsedBy.length>0&&(0,Q.jsxs)(`p`,{className:`text-soft`,children:[`Your toolbox was kept, because `,e.stillUsedBy.join(` and `),` still `,e.stillUsedBy.length===1?`uses`:`use`,` it.`]}),f.deleted.length>0&&(0,Q.jsx)(It,{title:`Files deleted`,items:f.deleted,paths:!0}),f.leftInPlace.length>0&&(0,Q.jsx)(It,{title:`Files kept`,items:f.leftInPlace,paths:!0}),f.refusedToDelete.length>0&&(0,Q.jsx)(s,{tone:`warn`,title:`Some files were not deleted`,children:(0,Q.jsx)(`ul`,{className:`mt-1 space-y-1`,children:f.refusedToDelete.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(X,{children:e.path}),` `,q(Y(e.why))]},e.path))})}),f.registryRemoved&&(0,Q.jsx)(`p`,{className:`text-soft`,children:`The toolbox was also removed from this console.`}),f.clientAllowRemoved&&(0,Q.jsx)(`p`,{className:`text-soft`,children:`The “Don't ask me twice” setting was removed from Claude Code.`}),f.clientAllowError&&(0,Q.jsx)(s,{tone:`warn`,children:q(Y(f.clientAllowError))}),f.warning&&(0,Q.jsx)(s,{tone:`warn`,children:q(Y(f.warning))})]})})}return(0,Q.jsx)(oe,{open:!0,onClose:n,tone:`danger`,dismissable:!c,title:`Undo the connection for ${e.label}?`,description:`${_} goes back to reaching its servers directly, without your toolbox checking each call.`,width:580,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(E,{variant:`secondary`,onClick:n,disabled:c,children:`Keep it connected`}),(0,Q.jsx)(E,{variant:`danger`,onClick:v,loading:c,children:`Undo connection`})]}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 text-[14px]`,children:[(0,Q.jsxs)(`ul`,{className:`space-y-2 text-muted`,children:[(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(m,{name:`refresh`,size:17,className:`mt-0.5 shrink-0 text-soft`}),`The app's original server list is put back from the backup made when it was connected.`]}),(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(m,{name:`file`,size:17,className:`mt-0.5 shrink-0 text-soft`}),(0,Q.jsxs)(`span`,{children:[`The file changed is `,(0,Q.jsx)(X,{children:e.path})]})]})]}),(0,Q.jsx)(ae,{checked:a,onChange:o,label:`Also delete the toolbox's files`,description:`Its settings file and protection settings. Your rules and choices in them are lost. Leave this off to keep them for later. They are kept anyway while another app still uses the toolbox.`}),u&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,children:u})]})})}function It({title:e,items:t,empty:n,paths:r}){return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-semibold`,children:e}),t.length===0?(0,Q.jsx)(`p`,{className:`text-soft`,children:n}):(0,Q.jsx)(`ul`,{className:`mt-1 space-y-0.5`,children:t.map(e=>(0,Q.jsx)(`li`,{children:r?(0,Q.jsx)(X,{children:e}):(0,Q.jsx)(`code`,{className:`mono text-[13px]`,children:e})},e))})]})}var Lt={done:null};function Rt({gatewayId:t,onDone:r,compact:i,scope:a}){let c=ne(()=>me.clients(),[]),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null),[p,h]=(0,Z.useState)(Lt.done&&(!a||Lt.done.scope===a)?Lt.done:null),g=e=>{Lt.done=e,h(e)},[_,v]=(0,Z.useState)(null),y=(0,Z.useRef)(null),b=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{p&&b.current&&(b.current=!1,y.current?.focus())},[p]);let S=c.data?.clients??[],C=(a?S.filter(e=>e.scope===a):S).filter(e=>!i||e.installed!==!1||e.exists).sort((e,t)=>zt(e)-zt(t)),w=e=>{u(e.scope),f(null),n.attach({gatewayId:t,scope:e.scope,...e.projectScoped&&c.data?.projectDir?{projectDir:c.data.projectDir}:{}}).then(t=>{let n=H(e.scope);b.current=!0,g({...t,appLabel:n,scope:e.scope}),r({...t,appLabel:n,scope:e.scope}),c.reload()}).catch(t=>f({scope:e.scope,text:K(t)})).finally(()=>u(null))};if(p){let e=S.find(e=>e.scope===p.scope)??null,t=e?.servers?Ge(e.servers).length:0;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{ref:y,tabIndex:-1,role:`status`,className:`flex flex-col gap-3 rounded-[18px] bg-ok-tint p-5 outline-none focus-visible:outline-2 focus-visible:outline-[var(--focus)]`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-2.5 text-[17px] font-medium`,children:[(0,Q.jsx)(m,{name:`check`,size:20,className:`text-ok`,strokeWidth:2.2}),p.alreadyConnected?`${p.appLabel} was already connected`:`Restart ${p.appLabel} once`]}),(0,Q.jsx)(`p`,{className:`text-[14px] text-muted`,children:p.alreadyConnected?`Nothing needed changing.${t>0?` Its own servers still run directly; bring them in below.`:``}`:`${p.appLabel} reads its list of servers when it opens, so it needs one restart to find your toolbox. After that, servers you add show up by themselves.`}),p.restartHint&&(0,Q.jsx)(`p`,{className:`text-[14px] font-medium`,children:q(Y(p.restartHint))})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 text-[12.5px] text-soft`,children:[(0,Q.jsxs)(`span`,{children:[`Changed: `,(0,Q.jsx)(X,{children:p.configPath})]}),p.backupPath&&(0,Q.jsxs)(`span`,{children:[`Backup of how it was: `,(0,Q.jsx)(X,{children:p.backupPath})]})]}),e?.attachedTo&&(0,Q.jsx)(jt,{scope:e.scope,...c.data?.projectDir?{projectDir:c.data.projectDir}:{}}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:()=>v({...e,canRevert:!0}),children:`Undo`}),!a&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`plug`,onClick:()=>g(null),children:`Connect another app`})]}),(0,Q.jsx)(Ft,{client:_,projectDir:c.data?.projectDir,onClose:()=>v(null),onDone:()=>{g(null),c.reload()}})]})}return c.error&&!c.data?(0,Q.jsx)(s,{tone:`danger`,title:`Your apps could not be checked`,actions:(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:c.reload,children:`Check again`}),children:K(c.error)}):c.data?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[!a&&(0,Q.jsx)(`p`,{className:`text-[14px] text-muted`,children:`Pick the app you talk to. One click adds your toolbox to it; nothing else in the app changes.`}),C.length===0&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-[18px] border border-line p-4`,children:[(0,Q.jsx)(`p`,{className:`text-[14px] font-medium`,children:`No AI app was found on this computer.`}),(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:`Install one of these, open it once, then come back here and press Check again.`}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[de.map(e=>(0,Q.jsxs)(x,{href:e.url,external:!0,size:`sm`,iconRight:`external`,children:[`Get `,e.label]},e.url)),(0,Q.jsx)(E,{size:`sm`,variant:`primary`,icon:`refresh`,loading:c.loading,onClick:c.reload,children:`Check again`})]})]}),(0,Q.jsx)(`ul`,{className:F(`grid gap-3`,!a&&`sm:grid-cols-2`),children:C.map(t=>{let n=W(t),r=t.alreadyAdopted;return(0,Q.jsxs)(`li`,{className:F(`flex min-w-0 flex-col gap-2 rounded-[18px] border-[1.5px] border-line p-4`,!n&&!r&&`bg-sunken/40`),children:[(0,Q.jsxs)(`span`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:F(`min-w-0 flex-1 text-[15px] font-semibold`,!n&&!r&&`text-soft`),children:Ve(t,c.data?.projectDir)}),r?(0,Q.jsx)(e,{tone:`ok`,children:`Connected`}):!n&&(0,Q.jsx)(e,{children:t.error?`Can't be read`:`Not found`})]}),(0,Q.jsx)(`span`,{className:`text-[13px] text-soft`,children:t.error?q(Y(t.error)):r?L(t.servers,Ie(t)):n?z(t.servers?.length??t.serverCount):`This app isn't on this computer.`}),d?.scope===t.scope&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-[13px] font-medium text-bad`,children:d.text}),(0,Q.jsxs)(`div`,{className:`mt-auto flex flex-wrap gap-2 pt-1`,children:[n&&!r&&(0,Q.jsxs)(E,{size:`sm`,variant:`primary`,icon:`plug`,loading:l===t.scope,disabled:!!l&&l!==t.scope,onClick:()=>w(t),children:[`Connect `,H(t.scope)]}),r&&(0,Q.jsx)(Nt,{client:t,...c.data?.projectDir?{projectDir:c.data.projectDir}:{}}),t.canRevert&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:()=>v(t),children:`Undo connection`})]})]},t.scope)})}),(0,Q.jsx)(Ft,{client:_,projectDir:c.data.projectDir,onClose:()=>v(null),onDone:c.reload})]}):(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[0,1].map(e=>(0,Q.jsx)(`div`,{className:`rounded-[18px] border border-line p-4`,children:(0,Q.jsx)(o,{lines:2})},e))})}var zt=e=>e.error?3:e.alreadyAdopted?1:W(e)?0:4;export{Ot as a,ot as c,st as d,Nt as i,ct as l,Ft as n,Dt as o,jt as r,lt as s,Rt as t,at as u};
|