@fungi.computer/tourtois 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Connections.d.ts +94 -0
- package/dist/Connections.js +303 -0
- package/dist/ModelKeys.d.ts +68 -0
- package/dist/ModelKeys.js +200 -0
- package/dist/SystemSettings.js +4 -5
- package/dist/WebsiteChannels.d.ts +131 -0
- package/dist/WebsiteChannels.js +372 -0
- package/dist/oyster-platform-controls.js +97 -14
- package/dist/platform-controls.d.ts +1 -1
- package/dist/platform-controls.js +1 -1
- package/dist/queries.d.ts +3 -0
- package/dist/queries.js +6 -0
- package/dist/settings-navigation.css +7 -0
- package/dist/settings-sections.d.ts +6 -8
- package/dist/settings-sections.js +2 -2
- package/package.json +15 -11
- package/dist/AgentMcpServers.d.ts +0 -34
- package/dist/AgentMcpServers.js +0 -127
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// Standalone Oyster Settings chrome, loaded from the chosen shell Release.
|
|
3
3
|
// App Permissions frame Oyster's own grants page, never its implementation.
|
|
4
|
-
//
|
|
4
|
+
// Connections, Keys and Computers retain their existing host-backed ports.
|
|
5
5
|
// A host with its own Settings (the Hub) never calls this entrypoint.
|
|
6
6
|
import "@fungi.computer/parakeet/styles.css";
|
|
7
7
|
import "./shell.css";
|
|
@@ -13,9 +13,11 @@ import * as S from "effect/Schema";
|
|
|
13
13
|
import { z } from "zod";
|
|
14
14
|
import { useEffect, useRef, useState } from "react";
|
|
15
15
|
import { createRoot } from "react-dom/client";
|
|
16
|
-
import {
|
|
16
|
+
import { connectionAddedSchema, connectionsViewSchema, connectionToolsSchema, createPlatformControls, PlatformControlsView, } from "./platform-controls.js";
|
|
17
|
+
import { modelKeysViewSchema } from "./ModelKeys.js";
|
|
17
18
|
import { settingsLocationSchema } from "./settings-routes.js";
|
|
18
19
|
import { OysterComputers, createOysterComputersPort, } from "./OysterComputers.js";
|
|
20
|
+
import { WebsiteChannels, createOysterWebsiteChannelsPort, } from "./WebsiteChannels.js";
|
|
19
21
|
import { useSettingsLeaveGuard, } from "./settings-leave-guard.js";
|
|
20
22
|
async function json(path) {
|
|
21
23
|
const response = await fetch(path, {
|
|
@@ -50,18 +52,89 @@ async function ownerRequest(path, init, refused) {
|
|
|
50
52
|
retryable: response.status >= 500,
|
|
51
53
|
});
|
|
52
54
|
}
|
|
53
|
-
/** Owner-direct
|
|
54
|
-
const
|
|
55
|
-
list: async () =>
|
|
56
|
-
add: async (
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
/** Owner-direct connections; the host never returns a token. */
|
|
56
|
+
const connections = {
|
|
57
|
+
list: async () => connectionsViewSchema.parse(await json("/api/connections")),
|
|
58
|
+
add: async (draft) => connectionAddedSchema.parse(await (await ownerRequest("/api/connections", {
|
|
59
|
+
method: "POST",
|
|
60
|
+
headers: { "Content-Type": "application/json" },
|
|
61
|
+
body: JSON.stringify(draft),
|
|
62
|
+
}, "The connection change was refused")).json()),
|
|
63
|
+
grant: async ({ connectionId, agentId, access }) => {
|
|
64
|
+
await ownerRequest(`/api/connections/${encodeURIComponent(connectionId)}/agents/${encodeURIComponent(agentId)}`, {
|
|
65
|
+
method: "PUT",
|
|
59
66
|
headers: { "Content-Type": "application/json" },
|
|
60
|
-
body: JSON.stringify(
|
|
61
|
-
}, "The
|
|
67
|
+
body: JSON.stringify({ access }),
|
|
68
|
+
}, "The connection change was refused");
|
|
62
69
|
},
|
|
63
|
-
|
|
64
|
-
await ownerRequest(`/api/
|
|
70
|
+
ungrant: async (connectionId, agentId) => {
|
|
71
|
+
await ownerRequest(`/api/connections/${encodeURIComponent(connectionId)}/agents/${encodeURIComponent(agentId)}`, { method: "DELETE" }, "The connection change was refused");
|
|
72
|
+
},
|
|
73
|
+
remove: async (connectionId) => {
|
|
74
|
+
await ownerRequest(`/api/connections/${encodeURIComponent(connectionId)}`, { method: "DELETE" }, "The connection change was refused");
|
|
75
|
+
},
|
|
76
|
+
tools: async (connectionId) => connectionToolsSchema.parse(await json(`/api/connections/${encodeURIComponent(connectionId)}/tools`)).tools,
|
|
77
|
+
};
|
|
78
|
+
const modelKeyMessages = {
|
|
79
|
+
key_rejected: "The provider rejected this key",
|
|
80
|
+
provider_unavailable: "The provider could not be reached. Try again",
|
|
81
|
+
custody_unavailable: "This instance has no credential key. Set OYSTER_CREDENTIAL_KEY and redeploy",
|
|
82
|
+
limit: "Remove a model key before adding another",
|
|
83
|
+
invalid_key: "Choose a provider, name the key and paste it",
|
|
84
|
+
key_removed: "That key was removed",
|
|
85
|
+
key_source_mismatch: "That model does not belong to the key's provider",
|
|
86
|
+
model_unavailable: "That provider has no such model",
|
|
87
|
+
invalid_model_choice: "That model choice is not valid",
|
|
88
|
+
};
|
|
89
|
+
const modelKeyMessage = (code) => new Map(Object.entries(modelKeyMessages)).get(code) ?? code;
|
|
90
|
+
/** A model-key request whose host refusal code reads as a sentence. */
|
|
91
|
+
async function modelKeyRequest(path, init, refused) {
|
|
92
|
+
try {
|
|
93
|
+
return await ownerRequest(path, init, refused);
|
|
94
|
+
}
|
|
95
|
+
catch (cause) {
|
|
96
|
+
if (cause instanceof AppError)
|
|
97
|
+
throw new Error(modelKeyMessage(cause.message), { cause });
|
|
98
|
+
throw cause;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const jsonInit = (method, body) => ({
|
|
102
|
+
method,
|
|
103
|
+
headers: { "Content-Type": "application/json" },
|
|
104
|
+
body,
|
|
105
|
+
});
|
|
106
|
+
/** Owner-direct model-key custody: a key goes in once and never comes back. */
|
|
107
|
+
const modelKeys = {
|
|
108
|
+
read: async () => {
|
|
109
|
+
const [keys, agents] = await Promise.all([
|
|
110
|
+
json("/api/model-keys"),
|
|
111
|
+
json("/api/agent-models"),
|
|
112
|
+
]);
|
|
113
|
+
return modelKeysViewSchema.parse({
|
|
114
|
+
keys: z.object({ keys: z.unknown() }).parse(keys).keys,
|
|
115
|
+
agents: z.object({ agents: z.unknown() }).parse(agents).agents,
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
addKey: async (draft) => {
|
|
119
|
+
await modelKeyRequest("/api/model-keys", jsonInit("POST", JSON.stringify(draft)), "The model key was refused");
|
|
120
|
+
},
|
|
121
|
+
removeKey: async (keyId) => {
|
|
122
|
+
await modelKeyRequest(`/api/model-keys/${encodeURIComponent(keyId)}`, { method: "DELETE" }, "The model key could not be removed");
|
|
123
|
+
},
|
|
124
|
+
chooseModel: async (agentId, draft) => {
|
|
125
|
+
await modelKeyRequest(`/api/agent-models/${encodeURIComponent(agentId)}`, jsonInit("PUT", JSON.stringify(draft.keyId === null
|
|
126
|
+
? {
|
|
127
|
+
keySource: "workers-ai",
|
|
128
|
+
model: {
|
|
129
|
+
providerId: "cloudflare-workers-ai",
|
|
130
|
+
modelId: "@cf/moonshotai/kimi-k2.6",
|
|
131
|
+
},
|
|
132
|
+
}
|
|
133
|
+
: {
|
|
134
|
+
keySource: "byok",
|
|
135
|
+
keyId: draft.keyId,
|
|
136
|
+
model: { providerId: draft.provider, modelId: draft.modelId },
|
|
137
|
+
})), "The model could not be saved");
|
|
65
138
|
},
|
|
66
139
|
};
|
|
67
140
|
/** Owner-direct Keys custody; a plaintext secret comes back only once, on issue. */
|
|
@@ -185,6 +258,12 @@ function OysterAppPermissions({ selectedKey, onAccepted, }) {
|
|
|
185
258
|
return null;
|
|
186
259
|
return (_jsx(OysterPermissionsFrame, { installationId: selectedKey.slice("installation:".length), onAccepted: onAccepted }, selectedKey));
|
|
187
260
|
}
|
|
261
|
+
/** What a visitor can and cannot reach on a self-hosted Oyster. */
|
|
262
|
+
const oysterWebsiteCopy = {
|
|
263
|
+
intro: (_jsx("p", { className: "text-sm", children: "Put a chat with one of your Agents on a website you run. Visitors open it from a button in the corner of the page; only you sign in to this Oyster." })),
|
|
264
|
+
visitors: (agentName) => `A chat with ${agentName}. Visitors don’t sign in, and they see its replies. Message limits apply to each visitor.`,
|
|
265
|
+
reach: (agentName) => `Visitors talk to ${agentName} itself, with ${agentName}’s own tools and permissions. They cannot sign in to this Oyster or reach your account. The address list limits where the chat appears, not who can call it directly.`,
|
|
266
|
+
};
|
|
188
267
|
export const mountPlatformControls = (root, input) => {
|
|
189
268
|
const keys = createOysterKeysPort(input.keysWire);
|
|
190
269
|
const requestAppAccess = (target, request, dialog) => input.requestAppAccess(target, request, {
|
|
@@ -196,17 +275,21 @@ export const mountPlatformControls = (root, input) => {
|
|
|
196
275
|
}),
|
|
197
276
|
});
|
|
198
277
|
const controls = createPlatformControls({
|
|
199
|
-
sections: ["home", "apps", "connectors", "computers", "keys"],
|
|
278
|
+
sections: ["home", "apps", "connectors", "computers", "keys", "channels"],
|
|
200
279
|
});
|
|
201
280
|
const computersPort = createOysterComputersPort(new URL(window.location.origin));
|
|
202
281
|
const computers = () => (_jsx(OysterComputers, { teamId: input.teamId, port: computersPort, onChanged: controls.changed }));
|
|
282
|
+
const websitesPort = createOysterWebsiteChannelsPort(new URL(window.location.origin));
|
|
283
|
+
const channels = () => (_jsx(WebsiteChannels, { port: websitesPort, copy: oysterWebsiteCopy }));
|
|
203
284
|
const client = createQueryClient();
|
|
204
285
|
const settings = createRoot(root);
|
|
205
286
|
settings.render(_jsx(QueryClientProvider, { client: client, children: _jsx(PlatformControlsView, { teamId: input.teamId, controls: controls, data: {
|
|
206
287
|
directory,
|
|
207
|
-
|
|
288
|
+
connections,
|
|
208
289
|
computers,
|
|
290
|
+
channels,
|
|
209
291
|
keys,
|
|
292
|
+
modelKeys,
|
|
210
293
|
requestAppAccess,
|
|
211
294
|
appPermissions: OysterAppPermissions,
|
|
212
295
|
} }) }));
|
|
@@ -7,7 +7,7 @@ import { createSettingsRouter, type SettingsLocation } from "./settings-routes.j
|
|
|
7
7
|
export { parseSettingsLocation } from "./settings-routes.js";
|
|
8
8
|
import type { SettingsSectionPorts } from "./settings-sections.js";
|
|
9
9
|
export type { SettingsSectionPorts, TeamAdministrationPort, } from "./settings-sections.js";
|
|
10
|
-
export {
|
|
10
|
+
export { connectionAddedSchema, connectionToolsSchema, connectionsViewSchema, type ConnectionAccess, type ConnectionDraft, type ConnectionsPort, type ConnectionsView, } from "./Connections.js";
|
|
11
11
|
export { type KeyAppOption, type KeyGrantOption, type KeyGrantPreviewProps, type KeyTargetOption, type KeyChange, type KeyIssueDraft, type KeyIssueResult, type KeysPort, type KeysView, } from "./Keys.js";
|
|
12
12
|
/**
|
|
13
13
|
* Team administration a dashboard may ask for but never performs itself:
|
|
@@ -12,7 +12,7 @@ import { RouterProvider, useRouterState } from "@tanstack/react-router";
|
|
|
12
12
|
import { createSettingsRouter, navigateSettings, settingsLocationSchema, } from "./settings-routes.js";
|
|
13
13
|
export { parseSettingsLocation } from "./settings-routes.js";
|
|
14
14
|
import { MemberAvatarSource } from "./member-avatar.js";
|
|
15
|
-
export {
|
|
15
|
+
export { connectionAddedSchema, connectionToolsSchema, connectionsViewSchema, } from "./Connections.js";
|
|
16
16
|
export {} from "./Keys.js";
|
|
17
17
|
/** One host's platform controls; render them with `PlatformControlsView`. */
|
|
18
18
|
export function createPlatformControls(options) {
|
package/dist/queries.d.ts
CHANGED
|
@@ -6,6 +6,9 @@ export declare const tourtoisQueryKeys: {
|
|
|
6
6
|
oysterInternetAccess: (teamId: string, computerId: string) => readonly ["tourtois", "oyster-internet-access", string, string];
|
|
7
7
|
oysterKeepAwake: (teamId: string, computerId: string) => readonly ["tourtois", "oyster-keep-awake", string, string];
|
|
8
8
|
oysterEgressPolicy: (teamId: string) => readonly ["tourtois", "oyster-egress-policy", string];
|
|
9
|
+
websiteChannels: (scope: string) => readonly ["tourtois", "website-channels", string];
|
|
10
|
+
websiteConversations: (scope: string, bindingId: string) => readonly ["tourtois", "website-channels", string, string];
|
|
11
|
+
websiteTranscript: (scope: string, bindingId: string, sessionId: string) => readonly ["tourtois", "website-channels", string, string, string];
|
|
9
12
|
hostSettings: (workspaceId: string) => readonly ["tourtois", "host-settings", string];
|
|
10
13
|
workbench: () => readonly ["tourtois", "workbench"];
|
|
11
14
|
workbenchComputers: (teamId: string) => readonly ["tourtois", "workbench-computers", string];
|
package/dist/queries.js
CHANGED
|
@@ -6,6 +6,12 @@ export const tourtoisQueryKeys = {
|
|
|
6
6
|
oysterInternetAccess: (teamId, computerId) => ["tourtois", "oyster-internet-access", teamId, computerId],
|
|
7
7
|
oysterKeepAwake: (teamId, computerId) => ["tourtois", "oyster-keep-awake", teamId, computerId],
|
|
8
8
|
oysterEgressPolicy: (teamId) => ["tourtois", "oyster-egress-policy", teamId],
|
|
9
|
+
websiteChannels: (scope) => ["tourtois", "website-channels", scope],
|
|
10
|
+
websiteConversations: (scope, bindingId) => [...tourtoisQueryKeys.websiteChannels(scope), bindingId],
|
|
11
|
+
websiteTranscript: (scope, bindingId, sessionId) => [
|
|
12
|
+
...tourtoisQueryKeys.websiteConversations(scope, bindingId),
|
|
13
|
+
sessionId,
|
|
14
|
+
],
|
|
9
15
|
hostSettings: (workspaceId) => ["tourtois", "host-settings", workspaceId],
|
|
10
16
|
workbench: () => ["tourtois", "workbench"],
|
|
11
17
|
workbenchComputers: (teamId) => ["tourtois", "workbench-computers", teamId],
|
|
@@ -121,6 +121,13 @@
|
|
|
121
121
|
.tourtois-website-note {
|
|
122
122
|
color: var(--stipe-fg-muted);
|
|
123
123
|
}
|
|
124
|
+
/* A fact's value: its sentence, then a key that keeps its own width. */
|
|
125
|
+
.tourtois-website-fact {
|
|
126
|
+
display: grid;
|
|
127
|
+
justify-items: start;
|
|
128
|
+
gap: var(--spacing-xs);
|
|
129
|
+
min-width: 0;
|
|
130
|
+
}
|
|
124
131
|
|
|
125
132
|
/* The Settings panel owns scrolling; its GitHub contents retain their natural
|
|
126
133
|
height rather than shrinking the form and feedback inside the flex column. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ComponentType } from "react";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ConnectionsPort } from "./Connections.js";
|
|
3
3
|
import type { KeysPort } from "./Keys.js";
|
|
4
|
+
import type { ModelKeysPort } from "./ModelKeys.js";
|
|
4
5
|
import type { MemberAvatarReader, MemberAvatarSave } from "./member-avatar.js";
|
|
5
6
|
import { type SettingsLocation } from "./settings-routes.js";
|
|
6
7
|
export type SettingsCategory = SettingsLocation["category"];
|
|
@@ -29,17 +30,14 @@ export type SettingsSectionPorts = Readonly<{
|
|
|
29
30
|
read: MemberAvatarReader;
|
|
30
31
|
save: MemberAvatarSave;
|
|
31
32
|
}>;
|
|
32
|
-
/**
|
|
33
|
-
|
|
34
|
-
/** A host's own Connectors editor, used when it has no Agent MCP port. */
|
|
35
|
-
connectors?: ComponentType<{
|
|
36
|
-
target: ConnectorsTarget;
|
|
37
|
-
onNavigate: Navigate;
|
|
38
|
-
}>;
|
|
33
|
+
/** Connections settings: the host's connections, who may use them, and its own editors beside. */
|
|
34
|
+
connections?: ConnectionsPort;
|
|
39
35
|
/** Each Computer's outside access. */
|
|
40
36
|
computers?: ComponentType;
|
|
41
37
|
/** Keys settings: the host's owner-direct Keys custody. */
|
|
42
38
|
keys?: KeysPort;
|
|
39
|
+
/** Model keys beside Keys: the host's sealed provider keys and per-Agent models. */
|
|
40
|
+
modelKeys?: ModelKeysPort;
|
|
43
41
|
/** The Team's role defaults. */
|
|
44
42
|
defaults?: ComponentType<{
|
|
45
43
|
onAccepted: Accepted;
|
|
@@ -6,9 +6,9 @@ export function offeredSettings(ceiling, ports) {
|
|
|
6
6
|
home: true,
|
|
7
7
|
apps: true,
|
|
8
8
|
avatar: ports.avatar !== undefined,
|
|
9
|
-
connectors: ports.
|
|
9
|
+
connectors: ports.connections !== undefined,
|
|
10
10
|
computers: ports.computers !== undefined,
|
|
11
|
-
keys: ports.keys !== undefined,
|
|
11
|
+
keys: ports.keys !== undefined || ports.modelKeys !== undefined,
|
|
12
12
|
defaults: ports.defaults !== undefined,
|
|
13
13
|
channels: ports.channels !== undefined,
|
|
14
14
|
selling: ports.selling !== undefined,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fungi.computer/tourtois",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"author": "Levi <levi@technomancy.dev>",
|
|
5
5
|
"description": "Tourtois: the trusted desktop shell for Oyster and Fungi, with host-supplied Settings sections",
|
|
6
6
|
"type": "module",
|
|
@@ -38,6 +38,10 @@
|
|
|
38
38
|
"types": "./dist/OysterComputers.d.ts",
|
|
39
39
|
"import": "./dist/OysterComputers.js"
|
|
40
40
|
},
|
|
41
|
+
"./website-channels": {
|
|
42
|
+
"types": "./dist/WebsiteChannels.d.ts",
|
|
43
|
+
"import": "./dist/WebsiteChannels.js"
|
|
44
|
+
},
|
|
41
45
|
"./settings-routes": {
|
|
42
46
|
"types": "./dist/settings-routes.d.ts",
|
|
43
47
|
"import": "./dist/settings-routes.js"
|
|
@@ -73,15 +77,15 @@
|
|
|
73
77
|
"LICENSE"
|
|
74
78
|
],
|
|
75
79
|
"dependencies": {
|
|
76
|
-
"@fungi.computer/agar": "0.7.
|
|
80
|
+
"@fungi.computer/agar": "0.7.1",
|
|
77
81
|
"@fungi.computer/cairn": "0.1.0",
|
|
78
|
-
"@fungi.computer/caps": "0.7.
|
|
82
|
+
"@fungi.computer/caps": "0.7.1",
|
|
79
83
|
"@fungi.computer/ear-tag": "0.1.0",
|
|
80
|
-
"@fungi.computer/gills": "0.2.
|
|
84
|
+
"@fungi.computer/gills": "0.2.1",
|
|
81
85
|
"@fungi.computer/maosaico": "0.1.0",
|
|
82
|
-
"@fungi.computer/parakeet": "0.
|
|
83
|
-
"@fungi.computer/puffball": "0.5.
|
|
84
|
-
"@fungi.computer/shiitake": "0.
|
|
86
|
+
"@fungi.computer/parakeet": "0.8.0",
|
|
87
|
+
"@fungi.computer/puffball": "0.5.1",
|
|
88
|
+
"@fungi.computer/shiitake": "0.10.0",
|
|
85
89
|
"@fungi.computer/sigils": "0.3.0",
|
|
86
90
|
"@fungi.computer/sprite": "0.2.0",
|
|
87
91
|
"@fungi.computer/sprite-zdog": "0.3.0",
|
|
@@ -96,16 +100,16 @@
|
|
|
96
100
|
"lucide-react": "0.460.0",
|
|
97
101
|
"react-dom": "18.3.1",
|
|
98
102
|
"zod": "4.4.3",
|
|
99
|
-
"@fungi.computer/nacre": "0.
|
|
103
|
+
"@fungi.computer/nacre": "0.2.0"
|
|
100
104
|
},
|
|
101
105
|
"peerDependencies": {
|
|
102
106
|
"react": "^18.3.1 || ^19.2.0"
|
|
103
107
|
},
|
|
104
108
|
"devDependencies": {
|
|
105
|
-
"@fungi.computer/oyster": "0.
|
|
109
|
+
"@fungi.computer/oyster": "0.11.0",
|
|
106
110
|
"@cloudflare/workers-types": "5.20260828.1",
|
|
107
|
-
"@fungi.computer/forage": "0.3.
|
|
108
|
-
"@fungi.computer/mycelium": "0.3.
|
|
111
|
+
"@fungi.computer/forage": "0.3.1",
|
|
112
|
+
"@fungi.computer/mycelium": "0.3.4",
|
|
109
113
|
"@ladle/react": "5.1.1",
|
|
110
114
|
"@types/react": "18.3.3",
|
|
111
115
|
"@vitejs/plugin-react": "6.1.1",
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import * as z from "zod";
|
|
2
|
-
/** Every Agent with its connected MCP servers. */
|
|
3
|
-
export declare const agentMcpServersViewSchema: z.ZodObject<{
|
|
4
|
-
agents: z.ZodArray<z.ZodObject<{
|
|
5
|
-
agentId: z.ZodString;
|
|
6
|
-
name: z.ZodString;
|
|
7
|
-
servers: z.ZodArray<z.ZodObject<{
|
|
8
|
-
serverId: z.ZodString;
|
|
9
|
-
name: z.ZodString;
|
|
10
|
-
url: z.ZodString;
|
|
11
|
-
hasBearer: z.ZodBoolean;
|
|
12
|
-
}, z.core.$strict>>;
|
|
13
|
-
}, z.core.$strict>>;
|
|
14
|
-
}, z.core.$strict>;
|
|
15
|
-
export type AgentMcpServersView = z.output<typeof agentMcpServersViewSchema>;
|
|
16
|
-
/** What the owner submits to connect one server. */
|
|
17
|
-
export type AgentMcpServerDraft = Readonly<{
|
|
18
|
-
name: string;
|
|
19
|
-
url: string;
|
|
20
|
-
bearer: string | null;
|
|
21
|
-
}>;
|
|
22
|
-
/** The host's owner-direct custody for Agent MCP servers. */
|
|
23
|
-
export type AgentMcpServersPort = Readonly<{
|
|
24
|
-
list(): Promise<AgentMcpServersView>;
|
|
25
|
-
add(agentId: string, draft: AgentMcpServerDraft): Promise<void>;
|
|
26
|
-
remove(agentId: string, serverId: string): Promise<void>;
|
|
27
|
-
}>;
|
|
28
|
-
/**
|
|
29
|
-
* The Connectors settings on a standalone host: connect a remote MCP server to
|
|
30
|
-
* an Agent. Its tools become `env.mcp.<name>.<tool>()` in that Agent's code.
|
|
31
|
-
*/
|
|
32
|
-
export declare function AgentMcpServers({ port }: {
|
|
33
|
-
port: AgentMcpServersPort;
|
|
34
|
-
}): import("react/jsx-runtime").JSX.Element;
|
package/dist/AgentMcpServers.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { SectionHeading } from "@fungi.computer/caps/blocks/section-heading";
|
|
3
|
-
import { Button } from "@fungi.computer/caps/components/button";
|
|
4
|
-
import { DataList, DataListHeading, DataRow, } from "@fungi.computer/caps/components/data-list";
|
|
5
|
-
import { FormFooter } from "@fungi.computer/caps/components/field";
|
|
6
|
-
import { KeycapButton } from "@fungi.computer/caps/components/keycap";
|
|
7
|
-
import { SchemaForm, field, useSchemaForm } from "@fungi.computer/caps/form";
|
|
8
|
-
import { Sigil } from "@fungi.computer/sigils";
|
|
9
|
-
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
10
|
-
import { Fragment, useMemo, useState } from "react";
|
|
11
|
-
import * as z from "zod";
|
|
12
|
-
import { SettingsItem } from "./settings-item.js";
|
|
13
|
-
/** One connected MCP server as the host lists it; the token never comes back. */
|
|
14
|
-
const agentMcpServerSchema = z.strictObject({
|
|
15
|
-
serverId: z.string().min(1),
|
|
16
|
-
name: z.string().min(1),
|
|
17
|
-
url: z.string().min(1),
|
|
18
|
-
hasBearer: z.boolean(),
|
|
19
|
-
});
|
|
20
|
-
/** Every Agent with its connected MCP servers. */
|
|
21
|
-
export const agentMcpServersViewSchema = z.strictObject({
|
|
22
|
-
agents: z.array(z.strictObject({
|
|
23
|
-
agentId: z.string().min(1),
|
|
24
|
-
name: z.string(),
|
|
25
|
-
servers: z.array(agentMcpServerSchema),
|
|
26
|
-
})),
|
|
27
|
-
});
|
|
28
|
-
const queryKey = ["tourtois", "agent-mcp-servers"];
|
|
29
|
-
/**
|
|
30
|
-
* The Connectors settings on a standalone host: connect a remote MCP server to
|
|
31
|
-
* an Agent. Its tools become `env.mcp.<name>.<tool>()` in that Agent's code.
|
|
32
|
-
*/
|
|
33
|
-
export function AgentMcpServers({ port }) {
|
|
34
|
-
const client = useQueryClient();
|
|
35
|
-
const view = useQuery({ queryKey, queryFn: () => port.list() });
|
|
36
|
-
const refresh = () => client.invalidateQueries({ queryKey });
|
|
37
|
-
const remove = useMutation({
|
|
38
|
-
mutationFn: (input) => port.remove(input.agentId, input.serverId),
|
|
39
|
-
onSuccess: refresh,
|
|
40
|
-
});
|
|
41
|
-
const agents = view.data?.agents ?? [];
|
|
42
|
-
// A fresh form after each connected server, so the token field empties.
|
|
43
|
-
const [formKey, setFormKey] = useState(0);
|
|
44
|
-
return (_jsxs("section", { className: "tourtois-settings-content tourtois-connectors", "aria-label": "Connectors", children: [_jsx(SectionHeading, { children: "Connectors" }), _jsxs("p", { className: "tourtois-settings-lede", children: ["Connect a remote MCP server to an Agent. Its tools become", " ", _jsx("code", { children: "env.mcp.<name>" }), " in that Agent's code. A token stays with the Agent and is never shown again."] }), view.isPending ? _jsx("p", { children: "Loading MCP servers\u2026" }) : null, view.isError ? (_jsxs("div", { role: "status", className: "tourtois-settings-notice", children: [_jsx("p", { children: "MCP servers could not be loaded." }), _jsx(Button, { size: "sm", variant: "outline", onClick: () => void view.refetch(), children: "Retry" })] })) : null, view.isSuccess && agents.length === 0 ? (_jsx("p", { children: "Create an Agent first, then connect MCP servers to it." })) : null, agents.length > 0 ? (_jsxs(_Fragment, { children: [_jsx(DataList, { "aria-label": "Agent MCP servers", children: agents.map((agent) => (_jsxs(Fragment, { children: [_jsx(DataListHeading, { children: agent.name }), agent.servers.length === 0 ? (_jsx(DataRow, { className: "tourtois-settings-empty", children: "No MCP servers." })) : null, agent.servers.map((server) => (_jsx(DataRow, { children: _jsx(SettingsItem, { icon: _jsx(Sigil, { name: "connected" }), title: server.name, detail: _jsxs("p", { children: [server.url, server.hasBearer ? " · Token saved" : ""] }), actions: _jsx(KeycapButton, { density: "compact", tone: "destructive", label: "Remove", "aria-label": `Remove ${server.name} from ${agent.name}`, disabled: remove.isPending, onClick: () => {
|
|
45
|
-
remove.mutate({
|
|
46
|
-
agentId: agent.agentId,
|
|
47
|
-
serverId: server.serverId,
|
|
48
|
-
});
|
|
49
|
-
} }) }) }, server.serverId)))] }, agent.agentId))) }), remove.isError ? (_jsx("p", { role: "alert", children: "The MCP server could not be removed." })) : null, _jsx(AddMcpServer, { agents: agents, onAdd: async (agentId, draft) => {
|
|
50
|
-
await port.add(agentId, draft);
|
|
51
|
-
await refresh();
|
|
52
|
-
setFormKey((current) => current + 1);
|
|
53
|
-
} }, formKey)] })) : null] }));
|
|
54
|
-
}
|
|
55
|
-
function AddMcpServer({ agents, onAdd, }) {
|
|
56
|
-
const schema = useMemo(() => z.object({
|
|
57
|
-
agentId: z.string().meta(field({
|
|
58
|
-
label: "Agent",
|
|
59
|
-
icon: _jsx(Sigil, { name: "agent" }),
|
|
60
|
-
kind: "select",
|
|
61
|
-
options: Object.fromEntries(agents.map((agent) => [agent.agentId, agent.name])),
|
|
62
|
-
})),
|
|
63
|
-
name: z
|
|
64
|
-
.string()
|
|
65
|
-
.regex(/^[a-z][a-z0-9_]{0,31}$/u, "Lowercase letters, digits and _, starting with a letter")
|
|
66
|
-
.meta(field({
|
|
67
|
-
label: "Name",
|
|
68
|
-
icon: _jsx(Sigil, { name: "write" }),
|
|
69
|
-
help: "The Agent calls its tools as env.mcp.<name>.",
|
|
70
|
-
maxLength: 32,
|
|
71
|
-
placeholder: "linear",
|
|
72
|
-
})),
|
|
73
|
-
url: z
|
|
74
|
-
.string()
|
|
75
|
-
.max(2_048)
|
|
76
|
-
.refine((value) => URL.canParse(value) && new URL(value).protocol === "https:", "Use the server's https:// address")
|
|
77
|
-
.meta(field({
|
|
78
|
-
label: "Server URL",
|
|
79
|
-
icon: _jsx(Sigil, { name: "internet" }),
|
|
80
|
-
kind: "url",
|
|
81
|
-
placeholder: "https://mcp.example.com/mcp",
|
|
82
|
-
})),
|
|
83
|
-
bearer: z
|
|
84
|
-
.string()
|
|
85
|
-
.max(4_096)
|
|
86
|
-
.meta(field({
|
|
87
|
-
label: "Bearer token",
|
|
88
|
-
icon: _jsx(Sigil, { name: "restricted" }),
|
|
89
|
-
help: "Optional: only if the server asks for one.",
|
|
90
|
-
kind: "secret",
|
|
91
|
-
})),
|
|
92
|
-
}), [agents]);
|
|
93
|
-
const add = useMutation({
|
|
94
|
-
mutationFn: (input) => onAdd(input.agentId, input.draft),
|
|
95
|
-
});
|
|
96
|
-
const model = useSchemaForm({
|
|
97
|
-
schema,
|
|
98
|
-
defaultValues: {
|
|
99
|
-
agentId: agents[0]?.agentId ?? "",
|
|
100
|
-
name: "",
|
|
101
|
-
url: "",
|
|
102
|
-
bearer: "",
|
|
103
|
-
},
|
|
104
|
-
onSubmit: async (value) => {
|
|
105
|
-
try {
|
|
106
|
-
await add.mutateAsync({
|
|
107
|
-
agentId: value.agentId,
|
|
108
|
-
draft: {
|
|
109
|
-
name: value.name,
|
|
110
|
-
url: value.url,
|
|
111
|
-
bearer: value.bearer.length === 0 ? null : value.bearer,
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
return { kind: "saved" };
|
|
115
|
-
}
|
|
116
|
-
catch (cause) {
|
|
117
|
-
return {
|
|
118
|
-
kind: "refused",
|
|
119
|
-
error: cause instanceof Error
|
|
120
|
-
? cause.message
|
|
121
|
-
: "The MCP server could not be connected.",
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
});
|
|
126
|
-
return (_jsx(SchemaForm, { model: model, layout: "columns", "aria-label": "Add MCP server", disabled: add.isPending, footer: _jsx(FormFooter, { divider: false, error: model.error, children: _jsx(Button, { type: "submit", children: add.isPending ? "Connecting…" : "Add MCP server" }) }) }));
|
|
127
|
-
}
|