@fungi.computer/tourtois 0.7.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/SystemSettings.js +3 -5
- package/dist/WebsiteChannels.d.ts +131 -0
- package/dist/WebsiteChannels.js +372 -0
- package/dist/oyster-platform-controls.js +33 -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 +3 -8
- package/dist/settings-sections.js +1 -1
- package/package.json +9 -5
- package/dist/AgentMcpServers.d.ts +0 -34
- package/dist/AgentMcpServers.js +0 -127
|
@@ -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 is sealed by this Oyster, never given to the Agent, and 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
|
-
}
|