clavarium 0.2.394-next.1 → 0.2.396-next.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/config/launch/claude-code.sh +8 -7
- package/config/launch/codex.sh +4 -4
- package/config/launch/mcp-sock.sh +31 -0
- package/config/launch/tools-host.mjs +93 -0
- package/config/launch/vibe.sh +4 -4
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/server/settingswords.mjs +6 -2
- package/web/app.js +85 -21
- package/web/index.html +19 -12
- package/web/style.css +22 -0
|
@@ -21,17 +21,18 @@ node "$(dirname "$0")/json-set.mjs" .claude/settings.json "$keys" \
|
|
|
21
21
|
# work folder trusted -- in its own file, as it records them itself; nothing to answer in the terminal.
|
|
22
22
|
node "$(dirname "$0")/json-set.mjs" .claude.json '{"hasCompletedOnboarding": true, "projects": {"/work": {"hasTrustDialogAccepted": true}}}' \
|
|
23
23
|
|| echo "launch: Claude Code may ask its first questions in the terminal" >&2
|
|
24
|
-
# ITS TOOLS (MCP), EACH THROUGH THE
|
|
25
|
-
#
|
|
26
|
-
# once, by Claude Code itself (its other servers kept); an older
|
|
24
|
+
# ITS TOOLS (MCP), EACH THROUGH THE SHARED HOST (11-11, #350; the relay since 02-11): one program for all its
|
|
25
|
+
# tools (mcp-sock.sh -> tools-host.mjs), a tool updated on the machine taken up between two of its requests,
|
|
26
|
+
# the session never restarted. Declared once, by Claude Code itself (its other servers kept); an older
|
|
27
|
+
# declaration (the relay alone) is replaced.
|
|
27
28
|
# Looked for in its settings first, since asking Claude Code takes seconds. Nothing stops the start.
|
|
28
|
-
relay="$(dirname "$0")/mcp-
|
|
29
|
+
relay="$(dirname "$0")/mcp-sock.sh"
|
|
29
30
|
tool() { # NAME FOLDER COMMAND ARGS...
|
|
30
31
|
name="$1"; folder="$2"; shift 2
|
|
31
|
-
if grep -q "\"$folder\"" "$HOME/.claude.json" 2>/dev/null && grep -q "mcp-
|
|
32
|
-
&& node -e 'const d=require(process.argv[1]);const s=d.mcpServers?.[process.argv[2]];const a=JSON.stringify(s?.args??[]);process.exit(a.includes("mcp-
|
|
32
|
+
if grep -q "\"$folder\"" "$HOME/.claude.json" 2>/dev/null && grep -q "mcp-sock.sh" "$HOME/.claude.json" 2>/dev/null \
|
|
33
|
+
&& node -e 'const d=require(process.argv[1]);const s=d.mcpServers?.[process.argv[2]];const a=JSON.stringify(s?.args??[]);process.exit(a.includes("mcp-sock.sh")&&a.includes(JSON.stringify(process.argv[3]))?0:1)' "$HOME/.claude.json" "$name" "$1" 2>/dev/null; then return 0; fi
|
|
33
34
|
claude mcp remove --scope user "$name" >/dev/null 2>&1
|
|
34
|
-
claude mcp add --scope user "$name" --
|
|
35
|
+
claude mcp add --scope user "$name" -- sh "$relay" "$@" >/dev/null 2>&1 \
|
|
35
36
|
|| echo "launch: $name was not given to Claude Code as tools: the command $name still works" >&2
|
|
36
37
|
}
|
|
37
38
|
# Parley, the chat of the conversation, when it has one: the version installed on the machine (parley-mcp),
|
package/config/launch/codex.sh
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
mode="$1"; shift
|
|
6
6
|
case "$mode" in full|ask) ;; *) echo "launch: the first argument is full or ask" >&2; exit 64 ;; esac
|
|
7
7
|
[ $# -gt 0 ] || { echo "launch: no command to run" >&2; exit 64; }
|
|
8
|
-
here="$(dirname "$0")"; relay="$here/mcp-
|
|
8
|
+
here="$(dirname "$0")"; relay="$here/mcp-sock.sh"
|
|
9
9
|
chat="${PARLEY_DIR:-/work/.parley}"; docket="/work/.docket"; tether="/work/.tether"
|
|
10
10
|
# ITS SETTINGS (~/.codex/config.toml), in a block of their own, the rest kept: its work folder trusted (no
|
|
11
11
|
# question at its first start), and its tools (MCP) each through the relay -- a tool updated on the
|
|
@@ -14,15 +14,15 @@ block='[projects."/work"]
|
|
|
14
14
|
trust_level = "trusted"'
|
|
15
15
|
if [ -f "$chat/server.mjs" ] && command -v parley-mcp >/dev/null 2>&1; then block="$block
|
|
16
16
|
[mcp_servers.parley]
|
|
17
|
-
command = \"
|
|
17
|
+
command = \"sh\"
|
|
18
18
|
args = [\"$relay\", \"parley-mcp\", \"--dir\", \"$chat\"]"; fi
|
|
19
19
|
if [ -f "$chat/server.mjs" ] && command -v docket-mcp >/dev/null 2>&1; then block="$block
|
|
20
20
|
[mcp_servers.docket]
|
|
21
|
-
command = \"
|
|
21
|
+
command = \"sh\"
|
|
22
22
|
args = [\"$relay\", \"docket-mcp\", \"--dir\", \"$docket\"]"; fi
|
|
23
23
|
if command -v tether-mcp >/dev/null 2>&1; then block="$block
|
|
24
24
|
[mcp_servers.tether]
|
|
25
|
-
command = \"
|
|
25
|
+
command = \"sh\"
|
|
26
26
|
args = [\"$relay\", \"tether-mcp\", \"--dir\", \"$tether\"]"; fi
|
|
27
27
|
node "$here/toml-block.mjs" .codex/config.toml tools "$block" \
|
|
28
28
|
|| echo "launch: Codex may ask its first questions, and has not its tools (MCP)" >&2
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# A TOOL OF THE CONVERSATION, THROUGH THE SHARED HOST (11-11, card #350): what the agent starts for each of its
|
|
3
|
+
# tools (MCP) -- the same arguments as mcp-relay.mjs, COMMAND ARGS... -- but instead of a Node program of its
|
|
4
|
+
# own, a few lines of sh and netcat: the session goes to tools-host.mjs, one program for all the tools of this
|
|
5
|
+
# user. Anything missing (netcat, the host not starting): the relay of before, as if nothing changed.
|
|
6
|
+
here="$(dirname "$0")"
|
|
7
|
+
fallback() { exec node "$here/mcp-relay.mjs" "$@"; }
|
|
8
|
+
command -v nc >/dev/null 2>&1 || fallback "$@"
|
|
9
|
+
dir="${XDG_RUNTIME_DIR:-/tmp}/clavarium-tools-$(id -u)"
|
|
10
|
+
# Its folder: this user's alone (700), or the relay of before.
|
|
11
|
+
mkdir -p "$dir" 2>/dev/null && [ -O "$dir" ] && chmod 700 "$dir" 2>/dev/null || fallback "$@"
|
|
12
|
+
sock="$dir/host.sock"
|
|
13
|
+
up() { [ -S "$sock" ] && nc -zU "$sock" 2>/dev/null; }
|
|
14
|
+
if ! up; then
|
|
15
|
+
(
|
|
16
|
+
flock 9 # the host itself never holds the lock (9>&- below): two tools starting at once both get in
|
|
17
|
+
if ! up; then
|
|
18
|
+
# its own session (setsid): an agent ending its tools never ends the host the others use
|
|
19
|
+
ns=""; command -v setsid >/dev/null 2>&1 && ns=setsid
|
|
20
|
+
$ns nohup node "$here/tools-host.mjs" "$dir" >>"$dir/host.log" 2>&1 </dev/null 9>&- &
|
|
21
|
+
i=0; while [ $i -lt 30 ] && ! up; do sleep 0.1; i=$((i + 1)); done
|
|
22
|
+
fi
|
|
23
|
+
) 9>"$dir/lock"
|
|
24
|
+
fi
|
|
25
|
+
up || fallback "$@"
|
|
26
|
+
# Its first line: which tool, with which arguments (JSON); then the session, both ways.
|
|
27
|
+
json() { printf '%s' "$1" | sed -e 's/\\/\\\\/g' -e 's/"/\\"/g'; }
|
|
28
|
+
head="{\"command\":\"$(json "$1")\",\"args\":["; shift
|
|
29
|
+
sep=""; for a in "$@"; do head="$head$sep\"$(json "$a")\""; sep=","; done
|
|
30
|
+
head="$head]}"
|
|
31
|
+
{ printf '%s\n' "$head"; exec cat; } | exec nc -NU "$sock"
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/* ONE PROGRAM FOR ALL THE TOOLS OF A CONVERSATION (11-11, card #350). Each tool (Parley, Docket, Tether...) was
|
|
2
|
+
* given to the agent as its own Node program, under its own relay: two Node programs a tool, ~435 MB for three.
|
|
3
|
+
* Here they share one: each session of a tool runs in a worker thread of this host, the same file started the
|
|
4
|
+
* same way (its own argv, stdin and stdout), so a tool runs unchanged. ~100 MB for three.
|
|
5
|
+
*
|
|
6
|
+
* The agent still starts one command a tool (mcp-sock.sh, a few lines of sh and netcat): it connects to this
|
|
7
|
+
* host's socket, says on its first line which tool and with which arguments, then the session flows through.
|
|
8
|
+
* The relay is the same as before (mcp-relay.mjs): a version installed under a session is taken up between two
|
|
9
|
+
* requests -- its worker replaced, the session told its tools may have changed.
|
|
10
|
+
*
|
|
11
|
+
* The socket lives in a folder of this user alone (700): in a machine shared by several conversations, one
|
|
12
|
+
* conversation never reaches another's tools. Nobody connected for 10 minutes: the host stops; the next tool
|
|
13
|
+
* started starts it again. */
|
|
14
|
+
import { createServer } from 'node:net';
|
|
15
|
+
import { Worker } from 'node:worker_threads';
|
|
16
|
+
import { spawn } from 'node:child_process';
|
|
17
|
+
import { PassThrough } from 'node:stream';
|
|
18
|
+
import { createInterface } from 'node:readline';
|
|
19
|
+
import { existsSync, realpathSync, rmSync, statSync, readFileSync } from 'node:fs';
|
|
20
|
+
import { delimiter, join, isAbsolute } from 'node:path';
|
|
21
|
+
import { fileURLToPath } from 'node:url';
|
|
22
|
+
import { relay, packageOf } from './mcp-relay.mjs';
|
|
23
|
+
|
|
24
|
+
const say = (text) => process.stderr.write(`${new Date().toISOString()} tools-host: ${text}\n`);
|
|
25
|
+
|
|
26
|
+
/* The script a command runs, when it is a Node script (node FILE, or a command whose file is one): its path. */
|
|
27
|
+
export function scriptOf(command, args, path = process.env.PATH ?? '') {
|
|
28
|
+
if (/(^|\/)node$/.test(command)) return args[0] ? { file: args[0], args: args.slice(1) } : null;
|
|
29
|
+
const found = isAbsolute(command) ? command : path.split(delimiter).map((d) => join(d, command)).find((f) => { try { return statSync(f).isFile(); } catch { return false; } });
|
|
30
|
+
if (!found) return null;
|
|
31
|
+
let file; try { file = realpathSync(found); } catch { return null; }
|
|
32
|
+
if (/\.(mjs|cjs|js)$/.test(file)) return { file, args };
|
|
33
|
+
try { if (/^#!.*\bnode\b/.test(readFileSync(file, 'utf8').slice(0, 120))) return { file, args }; } catch { /* unreadable */ }
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* A worker that looks like a child process to the relay: stdin, stdout, 'exit', kill. Not a Node script: a real
|
|
38
|
+
child, as before. */
|
|
39
|
+
export function workerSpawner(command, args, opts = {}) {
|
|
40
|
+
const script = scriptOf(command, args);
|
|
41
|
+
if (!script) return spawn(command, args, opts);
|
|
42
|
+
const w = new Worker(script.file, { argv: script.args, stdin: true, stdout: true, env: { ...(opts.env ?? process.env) } });
|
|
43
|
+
w.on('error', (error) => say(`${script.file}: ${error?.stack ?? error}`));
|
|
44
|
+
const child = {
|
|
45
|
+
stdin: w.stdin, stdout: w.stdout,
|
|
46
|
+
on(event, f) { if (event === 'exit') w.on('exit', f); return child; },
|
|
47
|
+
kill() { void w.terminate(); },
|
|
48
|
+
};
|
|
49
|
+
return child;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* One session: its first line names the tool { command, args }; the rest is the session, relayed to a worker. */
|
|
53
|
+
export function session(socket, { spawner = workerSpawner } = {}) {
|
|
54
|
+
const input = new PassThrough();
|
|
55
|
+
let header = null;
|
|
56
|
+
const lines = createInterface({ input: socket });
|
|
57
|
+
lines.on('line', (line) => {
|
|
58
|
+
if (header) { input.write(`${line}\n`); return; }
|
|
59
|
+
try { header = JSON.parse(line); } catch { header = null; }
|
|
60
|
+
if (!header || typeof header.command !== 'string' || !Array.isArray(header.args)) { socket.end(); return; }
|
|
61
|
+
const script = scriptOf(header.command, header.args);
|
|
62
|
+
const target = script?.file ?? header.command;
|
|
63
|
+
relay({ command: header.command, args: header.args.map(String), packageJson: packageOf(target) ?? '/nonexistent/package.json',
|
|
64
|
+
input, output: socket, spawner, log: say });
|
|
65
|
+
});
|
|
66
|
+
lines.on('close', () => input.end());
|
|
67
|
+
socket.on('error', () => { /* the agent went: its worker ends with its input */ });
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function host(dir, { idleMs = 10 * 60_000 } = {}) {
|
|
71
|
+
const sock = join(dir, 'host.sock');
|
|
72
|
+
rmSync(sock, { force: true });
|
|
73
|
+
let open = 0; let idle = null;
|
|
74
|
+
const server = createServer((socket) => {
|
|
75
|
+
open++; clearTimeout(idle);
|
|
76
|
+
socket.on('close', () => { open--; if (open === 0) idle = setTimeout(() => { server.close(); rmSync(sock, { force: true }); process.exit(0); }, idleMs); });
|
|
77
|
+
session(socket);
|
|
78
|
+
});
|
|
79
|
+
server.listen(sock, () => say(`listening (${process.pid})`));
|
|
80
|
+
idle = setTimeout(() => { if (open === 0) { server.close(); rmSync(sock, { force: true }); process.exit(0); } }, idleMs);
|
|
81
|
+
return server;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const HERE = fileURLToPath(import.meta.url);
|
|
85
|
+
const main = (() => { try { return realpathSync(process.argv[1] ?? '') === realpathSync(HERE); } catch { return false; } })();
|
|
86
|
+
if (main) {
|
|
87
|
+
const dir = process.argv[2];
|
|
88
|
+
if (!dir || !existsSync(dir)) { say('a folder of its own, given first'); process.exit(64); }
|
|
89
|
+
/* Its folder: this user's, closed to others -- or nothing is served. */
|
|
90
|
+
const st = statSync(dir);
|
|
91
|
+
if (st.uid !== process.getuid() || (st.mode & 0o077) !== 0) { say(`${dir} is not closed to others: nothing served`); process.exit(77); }
|
|
92
|
+
host(dir);
|
|
93
|
+
}
|
package/config/launch/vibe.sh
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
mode="$1"; shift
|
|
6
6
|
case "$mode" in full|ask) ;; *) echo "launch: the first argument is full or ask" >&2; exit 64 ;; esac
|
|
7
7
|
[ $# -gt 0 ] || { echo "launch: no command to run" >&2; exit 64; }
|
|
8
|
-
here="$(dirname "$0")"; relay="$here/mcp-
|
|
8
|
+
here="$(dirname "$0")"; relay="$here/mcp-sock.sh"
|
|
9
9
|
chat="${PARLEY_DIR:-/work/.parley}"; docket="/work/.docket"; tether="/work/.tether"
|
|
10
10
|
# ITS KEY: a secret named MISTRAL_API_KEY given to the conversation is in its environment; Vibe reads it
|
|
11
11
|
# there, and asks nothing. Without it, Vibe asks for it in its terminal at its first start.
|
|
@@ -15,19 +15,19 @@ if [ -f "$chat/server.mjs" ] && command -v parley-mcp >/dev/null 2>&1; then bloc
|
|
|
15
15
|
[[mcp_servers]]
|
|
16
16
|
name = \"parley\"
|
|
17
17
|
transport = \"stdio\"
|
|
18
|
-
command = \"
|
|
18
|
+
command = \"sh\"
|
|
19
19
|
args = [\"$relay\", \"parley-mcp\", \"--dir\", \"$chat\"]"; fi
|
|
20
20
|
if [ -f "$chat/server.mjs" ] && command -v docket-mcp >/dev/null 2>&1; then block="$block
|
|
21
21
|
[[mcp_servers]]
|
|
22
22
|
name = \"docket\"
|
|
23
23
|
transport = \"stdio\"
|
|
24
|
-
command = \"
|
|
24
|
+
command = \"sh\"
|
|
25
25
|
args = [\"$relay\", \"docket-mcp\", \"--dir\", \"$docket\"]"; fi
|
|
26
26
|
if command -v tether-mcp >/dev/null 2>&1; then block="$block
|
|
27
27
|
[[mcp_servers]]
|
|
28
28
|
name = \"tether\"
|
|
29
29
|
transport = \"stdio\"
|
|
30
|
-
command = \"
|
|
30
|
+
command = \"sh\"
|
|
31
31
|
args = [\"$relay\", \"tether-mcp\", \"--dir\", \"$tether\"]"; fi
|
|
32
32
|
node "$here/toml-block.mjs" .vibe/config.toml tools "$block" \
|
|
33
33
|
|| echo "launch: Vibe has not its tools (MCP)" >&2
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.396-next.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.396-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/settingswords.mjs
CHANGED
|
@@ -159,8 +159,12 @@ export const SETTINGS_WORDS_FR = {
|
|
|
159
159
|
'set-na-k-mcp': 'Serveur MCP', 'set-cx-mcp': 'serveur MCP',
|
|
160
160
|
'set-mcp-head': 'Ajouter un serveur MCP', 'set-mcp-hint': 'Ses outils pour vos IA ; la clé reste ici.',
|
|
161
161
|
'set-mcp-name': 'Nom', 'set-mcp-url': 'Adresse', 'set-mcp-key': 'Clé', 'set-mcp-add': 'Ajouter',
|
|
162
|
-
'set-mcp-
|
|
163
|
-
'set-mcp-
|
|
162
|
+
'set-mcp-drop': 'Collez ici la configuration du service', 'set-mcp-drop-hint': 'le bloc { "mcpServers": … } de sa page d\'aide',
|
|
163
|
+
'set-mcp-hand': 'Remplir à la main', 'set-mcp-add-n': 'Ajouter les {n}', 'set-mcp-nokey': 'aucune',
|
|
164
|
+
'set-mcp-notjson': 'Pas du JSON : collez tout le bloc.',
|
|
165
|
+
'set-mcp-noserver': 'Pas de serveur dans ce bloc.', 'set-mcp-program': '« {name} » : programme à lancer, refusé ici.',
|
|
166
|
+
'set-mcp-heads': '« {name} » : un seul en-tête pour sa clé.', 'set-mcp-basic': '« {name} » : clé non « Bearer », à la main.',
|
|
167
|
+
'set-mcp-need': 'Collez le bloc, ou donnez nom et adresse.', 'set-mcp-tools': 'Outils', 'set-mcp-refresh': 'Actualiser', 'set-mcp-seen': 'Marquer comme vu',
|
|
164
168
|
'set-mcp-none': 'Aucun outil listé pour l\'instant.', 'set-mcp-unreached': 'Injoignable : {why}', 'set-mcp-open': 'atteint l\'extérieur',
|
|
165
169
|
'set-mcp-fresh': 'Nouveau : demandé jusqu\'à ce que vous l\'ayez vu',
|
|
166
170
|
'set-mcp-c-read': 'Lecture seule', 'set-mcp-c-write': 'Écrit', 'set-mcp-c-destructive': 'Supprime ou écrase',
|
package/web/app.js
CHANGED
|
@@ -9174,20 +9174,96 @@
|
|
|
9174
9174
|
btn.disabled = false; btn.textContent = was;
|
|
9175
9175
|
await paintAssets();
|
|
9176
9176
|
});
|
|
9177
|
-
/* ADD AN MCP SERVER (mcpx.mjs): its name, address and key
|
|
9178
|
-
|
|
9177
|
+
/* ADD AN MCP SERVER (mcpx.mjs): the block the service gives, pasted -- its name, address and key read from it, shown
|
|
9178
|
+
ticked, the key masked; or filled in by hand. The key goes to the server's vault on Add, never shown again. A block
|
|
9179
|
+
naming its keys as secrets (${NAME}) is imported as it is; a program to start (stdio) is not run here. */
|
|
9180
|
+
const mcpWord = (k, en, v) => uiSaid(k, en, v);
|
|
9181
|
+
const mcpMask = (k) => (k.length <= 8 ? '••••' : `${k.slice(0, 4)}••••${k.slice(-3)}`);
|
|
9182
|
+
function mcpRead(text) {
|
|
9183
|
+
let j;
|
|
9184
|
+
try { j = JSON.parse(text); } catch { return { error: mcpWord('set-mcp-notjson', 'Not JSON: paste the whole block.') }; }
|
|
9185
|
+
const all = j && typeof j === 'object' ? (j.mcpServers ?? j.servers ?? (j.url || j.serverUrl ? { [j.name || 'mcp']: j } : null)) : null;
|
|
9186
|
+
if (!all || typeof all !== 'object' || Array.isArray(all) || !Object.keys(all).length) return { error: mcpWord('set-mcp-noserver', 'No server in this block.') };
|
|
9187
|
+
const servers = []; let refs = false;
|
|
9188
|
+
for (const [name, s] of Object.entries(all)) {
|
|
9189
|
+
if (!s || typeof s !== 'object') return { error: mcpWord('set-mcp-noserver', 'No server in this block.') };
|
|
9190
|
+
if (s.command !== undefined || s.args !== undefined || s.type === 'stdio') return { error: mcpWord('set-mcp-program', '« {name} »: a program to start, refused here.', { name }) };
|
|
9191
|
+
const heads = s.headers && typeof s.headers === 'object' ? Object.entries(s.headers) : [];
|
|
9192
|
+
if (heads.length > 1) return { error: mcpWord('set-mcp-heads', '« {name} »: one header for its key at most.', { name }) };
|
|
9193
|
+
let key = '', header = '';
|
|
9194
|
+
if (heads.length) {
|
|
9195
|
+
const [h, v] = heads[0]; const value = String(v ?? '').trim();
|
|
9196
|
+
if (/\$\{[^}]+\}/.test(value)) refs = true;
|
|
9197
|
+
const bearer = /^Bearer\s+(.+)$/i.exec(value);
|
|
9198
|
+
if (h.toLowerCase() === 'authorization') { if (!bearer) return { error: mcpWord('set-mcp-basic', '« {name} »: not a « Bearer » key, fill in by hand.', { name }) }; key = bearer[1].trim(); }
|
|
9199
|
+
else { key = value; header = h; }
|
|
9200
|
+
}
|
|
9201
|
+
servers.push({ name: String(name).slice(0, 120), url: String(s.url ?? s.serverUrl ?? ''), key, header });
|
|
9202
|
+
}
|
|
9203
|
+
return { servers, refs };
|
|
9204
|
+
}
|
|
9205
|
+
let mcpPasted = null, mcpPick = 0;
|
|
9206
|
+
function mcpShow() {
|
|
9207
|
+
const s = mcpPasted?.servers?.[mcpPick];
|
|
9208
|
+
$('mcp-found').hidden = !s;
|
|
9209
|
+
const n = mcpPasted?.servers?.length ?? 0;
|
|
9210
|
+
$('mcp-add').textContent = n > 1 ? mcpWord('set-mcp-add-n', 'Add the {n}', { n }) : mcpWord('set-mcp-add', 'Add');
|
|
9211
|
+
if (!s) return;
|
|
9212
|
+
$('mcp-found-name').textContent = s.name; $('mcp-found-url').textContent = s.url;
|
|
9213
|
+
$('mcp-found-keyline').classList.toggle('mcp-found-miss', !s.key);
|
|
9214
|
+
$('mcp-found-key').textContent = !s.key ? mcpWord('set-mcp-nokey', 'none') : mcpPasted.refs ? s.key : `${mcpMask(s.key)}${s.header ? ` · ${s.header}` : ''}`;
|
|
9215
|
+
if (n === 1 && !mcpPasted.refs) { $('mcp-name').value = s.name; $('mcp-url').value = s.url; $('mcp-key').value = s.key; }
|
|
9216
|
+
}
|
|
9217
|
+
function mcpPaste() {
|
|
9218
|
+
const text = $('mcp-config').value.trim();
|
|
9219
|
+
const drop = $('mcp-drop'); drop.classList.toggle('filled', !!text); drop.classList.remove('ok', 'bad');
|
|
9220
|
+
$('mcp-error').hidden = true; mcpPasted = null; mcpPick = 0;
|
|
9221
|
+
const pick = $('mcp-pick'); pick.replaceChildren(); pick.hidden = true;
|
|
9222
|
+
if (text) {
|
|
9223
|
+
const r = mcpRead(text);
|
|
9224
|
+
if (r.error) { drop.classList.add('bad'); $('mcp-error').textContent = r.error; $('mcp-error').hidden = false; }
|
|
9225
|
+
else {
|
|
9226
|
+
mcpPasted = r; drop.classList.add('ok');
|
|
9227
|
+
if (r.servers.length > 1) {
|
|
9228
|
+
r.servers.forEach((s, i) => { const b = el('button', '', s.name); b.type = 'button'; b.setAttribute('aria-pressed', String(i === 0));
|
|
9229
|
+
b.addEventListener('click', () => { mcpPick = i; [...pick.children].forEach((x, k) => x.setAttribute('aria-pressed', String(k === i))); mcpShow(); }); pick.append(b); });
|
|
9230
|
+
pick.hidden = false;
|
|
9231
|
+
}
|
|
9232
|
+
}
|
|
9233
|
+
}
|
|
9234
|
+
mcpShow();
|
|
9235
|
+
}
|
|
9236
|
+
$('mcp-config').addEventListener('input', mcpPaste);
|
|
9237
|
+
const mcpClear = () => { $('mcp-new').reset(); $('mcp-config').value = ''; mcpPaste(); };
|
|
9179
9238
|
$('mcp-new').addEventListener('submit', async (event) => {
|
|
9180
9239
|
event.preventDefault();
|
|
9181
9240
|
$('mcp-error').hidden = true;
|
|
9182
9241
|
const btn = $('mcp-add'); btn.disabled = true;
|
|
9242
|
+
const fail = (message) => { $('mcp-error').textContent = message; $('mcp-error').hidden = false; };
|
|
9183
9243
|
try {
|
|
9184
|
-
const
|
|
9185
|
-
|
|
9186
|
-
|
|
9187
|
-
|
|
9188
|
-
|
|
9189
|
-
|
|
9190
|
-
|
|
9244
|
+
const many = mcpPasted && (mcpPasted.refs || mcpPasted.servers.length > 1);
|
|
9245
|
+
if (mcpPasted?.refs) {
|
|
9246
|
+
const made = await post(`${API}/tether/mcp-import`, { config: $('mcp-config').value });
|
|
9247
|
+
const first = made.servers?.[0];
|
|
9248
|
+
mcpClear();
|
|
9249
|
+
if (first) await assetMade($('mcp-box'), { key: `connexion:${first.id}`, name: first.title, give: (to, level) => Promise.all(made.servers.map((x) => grantTarget(x.id, to, targetLevel(level)))) });
|
|
9250
|
+
} else if (many) {
|
|
9251
|
+
const made = [];
|
|
9252
|
+
for (const s of mcpPasted.servers) made.push(await post(`${API}/tether/mcp-add`, { name: s.name, url: s.url, ...(s.key ? { key: s.key } : {}), ...(s.header ? { header: s.header } : {}) }));
|
|
9253
|
+
mcpClear();
|
|
9254
|
+
await assetMade($('mcp-box'), { key: `connexion:${made[0].id}`, name: made[0].title, give: (to, level) => Promise.all(made.map((x) => grantTarget(x.id, to, targetLevel(level)))) });
|
|
9255
|
+
} else {
|
|
9256
|
+
const name = $('mcp-name').value.trim(), url = $('mcp-url').value.trim(), key = $('mcp-key').value;
|
|
9257
|
+
if (!name || !url) { $('mcp-hand').open = true; fail(mcpWord('set-mcp-need', 'Paste the block, or give a name and an address.')); return; }
|
|
9258
|
+
const one = mcpPasted?.servers?.[0];
|
|
9259
|
+
const header = one && one.key && one.key === key ? one.header : '';
|
|
9260
|
+
const made = await post(`${API}/tether/mcp-add`, { name, url, key, ...(header ? { header } : {}) });
|
|
9261
|
+
mcpClear();
|
|
9262
|
+
await assetMade($('mcp-box'), { key: `connexion:${made.id}`, name: made.title, note: made.error ? uiSaid('set-mcp-unreached', 'Not reached: {why}', { why: made.error }) : '',
|
|
9263
|
+
give: (to, level) => grantTarget(made.id, to, targetLevel(level)) });
|
|
9264
|
+
}
|
|
9265
|
+
} catch (error) { fail(error.message); }
|
|
9266
|
+
finally { $('mcp-key').value = ''; btn.disabled = false; }
|
|
9191
9267
|
await paintAssets();
|
|
9192
9268
|
});
|
|
9193
9269
|
/* PAIR A BROWSER (browsers.mjs): one line to copy into the Tether extension's popup -- its address and a key good once,
|
|
@@ -9239,18 +9315,6 @@
|
|
|
9239
9315
|
try { await navigator.clipboard.writeText($('browser-config').value); $('browser-copy').textContent = uiSaid('set-br-copied', 'Copied'); }
|
|
9240
9316
|
catch { $('browser-config').select(); }
|
|
9241
9317
|
});
|
|
9242
|
-
$('mcp-import').addEventListener('click', async () => {
|
|
9243
|
-
$('mcp-error').hidden = true;
|
|
9244
|
-
const btn = $('mcp-import'); btn.disabled = true;
|
|
9245
|
-
try {
|
|
9246
|
-
const made = await post(`${API}/tether/mcp-import`, { config: $('mcp-config').value });
|
|
9247
|
-
$('mcp-config').value = '';
|
|
9248
|
-
const first = made.servers?.[0];
|
|
9249
|
-
if (first) await assetMade($('mcp-box'), { key: `connexion:${first.id}`, name: first.title, give: (to, level) => Promise.all(made.servers.map((x) => grantTarget(x.id, to, targetLevel(level)))) });
|
|
9250
|
-
} catch (error) { $('mcp-error').textContent = error.message; $('mcp-error').hidden = false; }
|
|
9251
|
-
btn.disabled = false;
|
|
9252
|
-
await paintAssets();
|
|
9253
|
-
});
|
|
9254
9318
|
const connexionKinds = () => [['connexion-mail', 'mail'], ['connexion-calendar', 'calendar'], ['connexion-contacts', 'contacts']].filter(([id]) => $(id).checked && !$(id).disabled).map(([, k]) => k);
|
|
9255
9319
|
$('connexion-open').addEventListener('click', async () => {
|
|
9256
9320
|
$('connexion-error').hidden = true;
|
package/web/index.html
CHANGED
|
@@ -886,20 +886,27 @@
|
|
|
886
886
|
</div>
|
|
887
887
|
<div id="mcp-box" class="as-form" data-kind="mcp"><h3 data-said="set-mcp-head">Add an MCP server</h3>
|
|
888
888
|
<p class="hint" data-said="set-mcp-hint">Its tools, given to the AIs you choose. The key stays on the server.</p>
|
|
889
|
-
<form id="mcp-new" autocomplete="off">
|
|
890
|
-
<
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
<
|
|
895
|
-
<
|
|
889
|
+
<form id="mcp-new" autocomplete="off" novalidate>
|
|
890
|
+
<div id="mcp-drop" class="mcp-drop">
|
|
891
|
+
<textarea id="mcp-config" rows="4" spellcheck="false" autocapitalize="off" autocomplete="off" aria-label="Configuration"></textarea>
|
|
892
|
+
<div class="mcp-drop-ph" aria-hidden="true"><b data-said="set-mcp-drop">Paste the service's configuration here</b><span data-said="set-mcp-drop-hint">the { "mcpServers": … } block from its help page</span></div>
|
|
893
|
+
</div>
|
|
894
|
+
<div id="mcp-pick" class="mcp-pick" role="group" hidden></div>
|
|
895
|
+
<ul id="mcp-found" class="mcp-found" hidden>
|
|
896
|
+
<li><span class="mcp-found-k" data-said="set-mcp-name">Name</span><span class="mcp-found-v" id="mcp-found-name"></span><span class="mcp-found-t" aria-hidden="true">✓</span></li>
|
|
897
|
+
<li><span class="mcp-found-k" data-said="set-mcp-url">Address</span><span class="mcp-found-v" id="mcp-found-url"></span><span class="mcp-found-t" aria-hidden="true">✓</span></li>
|
|
898
|
+
<li id="mcp-found-keyline"><span class="mcp-found-k" data-said="set-mcp-key">Key</span><span class="mcp-found-v" id="mcp-found-key"></span><span class="mcp-found-t" aria-hidden="true">✓</span></li>
|
|
899
|
+
</ul>
|
|
900
|
+
<p id="mcp-error" class="error" role="alert" hidden></p>
|
|
896
901
|
<div class="row"><button type="submit" id="mcp-add" class="primary" data-said="set-mcp-add">Add</button></div>
|
|
897
|
-
<details class="more"><summary data-said="set-mcp-
|
|
898
|
-
<
|
|
899
|
-
<
|
|
900
|
-
<
|
|
902
|
+
<details class="more" id="mcp-hand"><summary data-said="set-mcp-hand">Fill in by hand</summary>
|
|
903
|
+
<label for="mcp-name" data-said="set-mcp-name">Name</label>
|
|
904
|
+
<input id="mcp-name" maxlength="120" spellcheck="false" placeholder="CRM">
|
|
905
|
+
<label for="mcp-url" data-said="set-mcp-url">Address</label>
|
|
906
|
+
<input id="mcp-url" type="url" spellcheck="false" autocapitalize="off" placeholder="https://mcp.example.com/mcp">
|
|
907
|
+
<label for="mcp-key" data-said="set-mcp-key">Key</label>
|
|
908
|
+
<input id="mcp-key" type="password" autocomplete="new-password" placeholder="optional, never shown again">
|
|
901
909
|
</details>
|
|
902
|
-
<p id="mcp-error" class="error" role="alert" hidden></p>
|
|
903
910
|
</form>
|
|
904
911
|
</div>
|
|
905
912
|
<div id="browser-box" class="as-form" data-kind="browser"><h3 data-said="set-br-head">Pair a browser</h3>
|
package/web/style.css
CHANGED
|
@@ -1258,6 +1258,28 @@ header .ic, #folders .ic { width: 18px; height: 18px; fill: none; stroke: curren
|
|
|
1258
1258
|
.as-form { display: flex; flex-direction: column; gap: 8px; }
|
|
1259
1259
|
.as-form h3 { margin: 0; font-size: 1.125rem; }
|
|
1260
1260
|
.as-form form, #connexion-classic:not([hidden]) { display: flex; flex-direction: column; gap: 6px; }
|
|
1261
|
+
/* Add an MCP server: the service's block pasted, what was read from it ticked. */
|
|
1262
|
+
.mcp-drop { position: relative; border: 1.5px dashed var(--line); border-radius: 10px; background: var(--bar); transition: border-color .2s; }
|
|
1263
|
+
.mcp-drop:focus-within { border-color: var(--brass); }
|
|
1264
|
+
.mcp-drop.ok { border-style: solid; border-color: var(--ok); }
|
|
1265
|
+
.mcp-drop.bad { border-style: solid; border-color: var(--danger); }
|
|
1266
|
+
/* Read: the block (its key in clear) blurred until touched again (no change of size: nothing moves under the pointer). */
|
|
1267
|
+
#mcp-box .mcp-drop.ok textarea:not(:focus) { color: transparent; text-shadow: 0 0 7px var(--ink2); }
|
|
1268
|
+
#mcp-box .mcp-drop textarea { display: block; width: 100%; min-height: 84px; box-sizing: border-box; border: 0; background: transparent; color: var(--ink); font: .8125rem/1.45 var(--mono, ui-monospace, monospace); padding: 12px; resize: vertical; outline: none; }
|
|
1269
|
+
.mcp-drop-ph { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-align: center; padding: 10px; color: var(--ink2); font-size: .8125rem; pointer-events: none; }
|
|
1270
|
+
.mcp-drop-ph b { color: var(--ink); font-size: .9375rem; }
|
|
1271
|
+
.mcp-drop.filled .mcp-drop-ph { display: none; }
|
|
1272
|
+
.mcp-pick { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
1273
|
+
.mcp-pick button { border-radius: 999px; padding: 4px 12px; }
|
|
1274
|
+
.mcp-pick button[aria-pressed="true"] { border-color: var(--brass); color: var(--brass-ink, var(--brass)); }
|
|
1275
|
+
.mcp-found { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
|
|
1276
|
+
.mcp-found li { display: flex; align-items: center; gap: 10px; min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px; font-size: .875rem; }
|
|
1277
|
+
.mcp-found-k { flex: none; width: 5.5em; color: var(--ink2); font-size: .8125rem; }
|
|
1278
|
+
.mcp-found-v { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1279
|
+
.mcp-found-t { color: var(--ok); font-weight: 700; }
|
|
1280
|
+
.mcp-found-miss .mcp-found-t { visibility: hidden; }
|
|
1281
|
+
.mcp-found-miss .mcp-found-v { color: var(--ink2); }
|
|
1282
|
+
#mcp-hand[open] { display: flex; flex-direction: column; gap: 6px; }
|
|
1261
1283
|
#gitview-remote-box > summary { display: none; }
|
|
1262
1284
|
#gitview-remote { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
|
|
1263
1285
|
.as-none { margin: auto; text-align: center; }
|