@a-tether/server 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +12 -2
- package/dist/backends/backend.js +1 -0
- package/dist/backends/claude-code/claude-process.js +133 -0
- package/dist/backends/claude-code/claude-turn.js +229 -0
- package/dist/backends/claude-code/index.js +22 -0
- package/dist/backends/claude-code/tool-catalog.mjs +15 -0
- package/dist/server/http.js +219 -0
- package/dist/server.js +10 -0
- package/dist/shared/protocol.js +53 -0
- package/package.json +27 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SandyKid
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @a-tether/server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A-tether 的 C 端服务。它把 C 上已登录的 Claude Code 通过 SSH 隧道借给另一台电脑上的 Pi 使用。A 端请使用 [`@a-tether/pi`](https://www.npmjs.com/package/@a-tether/pi)。
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
export A_TETHER_TOKEN="$(cat ~/.config/a-tether/token)" # 至少 32 个字符的随机令牌
|
|
7
|
+
npx -y @a-tether/server # 全局安装后命令为 a-tether-server
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
- 只监听 `127.0.0.1`,默认端口 7310,可用 `A_TETHER_PORT` 修改。
|
|
11
|
+
- 需要 C 上已登录的 `claude` CLI。若 PATH 不同,可设置 `A_TETHER_CLAUDE` 为其绝对路径。
|
|
12
|
+
- 请求失败时在 stderr 输出一行脱敏诊断,不记录对话内容或令牌。
|
|
13
|
+
- 完整配置见 [setup 文档](https://github.com/SandyKidYao/a-tether/blob/main/docs/setup.md)。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { createInterface } from "node:readline";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
import { getBuiltinModels } from "@earendil-works/pi-ai/providers/all";
|
|
5
|
+
import { api, providerId, defaultUrl } from "../../shared/protocol.js";
|
|
6
|
+
export const isolated = ["-p", "--tools", "", "--setting-sources", "", "--strict-mcp-config",
|
|
7
|
+
"--settings", JSON.stringify({ disableAllHooks: true }), "--disable-slash-commands", "--no-session-persistence", "--permission-mode", "dontAsk"];
|
|
8
|
+
export const streaming = ["--verbose", "--input-format", "stream-json", "--output-format", "stream-json"];
|
|
9
|
+
export async function invoke(args, options) {
|
|
10
|
+
const { signal } = options;
|
|
11
|
+
signal?.throwIfAborted();
|
|
12
|
+
const env = { ...process.env, ...options.env };
|
|
13
|
+
const command = env.A_TETHER_CLAUDE || env.PI_CLAUDE_CODE_COMMAND || "claude";
|
|
14
|
+
delete env.ANTHROPIC_API_KEY;
|
|
15
|
+
delete env.A_TETHER_TOKEN;
|
|
16
|
+
if (env.ANTHROPIC_BASE_URL || env.ANTHROPIC_AUTH_TOKEN || env.ANTHROPIC_FOUNDRY_API_KEY ||
|
|
17
|
+
["CLAUDE_CODE_USE_BEDROCK", "CLAUDE_CODE_USE_VERTEX", "CLAUDE_CODE_USE_FOUNDRY"].some(k => env[k] && !["false", "0"].includes(env[k]))) {
|
|
18
|
+
throw new Error("Conflicting backend configuration");
|
|
19
|
+
}
|
|
20
|
+
if (env.PI_CLAUDE_CODE_CONFIG_DIR)
|
|
21
|
+
env.CLAUDE_CONFIG_DIR = env.PI_CLAUDE_CODE_CONFIG_DIR;
|
|
22
|
+
Object.assign(env, { ENABLE_TOOL_SEARCH: "false", CLAUDE_CODE_DISABLE_FILE_MENTIONS: "1",
|
|
23
|
+
CLAUDE_CODE_DISABLE_AUTO_MEMORY: "1", CLAUDE_CODE_DISABLE_CLAUDE_MDS: "1", DISABLE_AUTOUPDATER: "1",
|
|
24
|
+
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: "1", DISABLE_TELEMETRY: "1" });
|
|
25
|
+
const child = spawn(command, args, { cwd: options.cwd, env, detached: process.platform !== "win32", windowsHide: true,
|
|
26
|
+
stdio: ["pipe", "pipe", "pipe"] });
|
|
27
|
+
// Keep only a short stderr tail for the C diagnostic log.
|
|
28
|
+
let stderr = "";
|
|
29
|
+
child.stderr.setEncoding("utf8");
|
|
30
|
+
child.stderr.on("data", (data) => { stderr = (stderr + data).slice(-4096); });
|
|
31
|
+
const closed = new Promise((resolve, reject) => {
|
|
32
|
+
child.once("error", reject);
|
|
33
|
+
child.once("close", code => resolve(code ?? -1));
|
|
34
|
+
});
|
|
35
|
+
const stop = () => {
|
|
36
|
+
if (!child.pid)
|
|
37
|
+
return;
|
|
38
|
+
if (process.platform === "win32") {
|
|
39
|
+
if (child.exitCode !== null || child.signalCode !== null)
|
|
40
|
+
return;
|
|
41
|
+
spawn("taskkill", ["/pid", String(child.pid), "/t", "/f"], { stdio: "ignore", windowsHide: true }).on("error", () => child.kill());
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
try {
|
|
45
|
+
process.kill(-child.pid, "SIGKILL");
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
child.kill();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
// A CLI launcher can exit while an MCP descendant still owns its pipes.
|
|
53
|
+
if (process.platform !== "win32")
|
|
54
|
+
child.once("exit", stop);
|
|
55
|
+
signal?.addEventListener("abort", stop, { once: true });
|
|
56
|
+
const lines = createInterface({ input: child.stdout, crlfDelay: Infinity });
|
|
57
|
+
child.stdin.on("error", () => { }); // A short-lived CLI can exit before consuming stdin.
|
|
58
|
+
try {
|
|
59
|
+
child.stdin.end(options.input);
|
|
60
|
+
const output = (async () => { for await (const line of lines)
|
|
61
|
+
options.onLine(line); })();
|
|
62
|
+
const [code] = await Promise.all([closed, output]);
|
|
63
|
+
signal?.throwIfAborted();
|
|
64
|
+
return { code, stderr: stderr.trim() };
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
stop();
|
|
68
|
+
await closed.catch(() => { });
|
|
69
|
+
lines.close();
|
|
70
|
+
signal?.removeEventListener("abort", stop);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function deadline(signal) {
|
|
74
|
+
const timeout = AbortSignal.timeout(20000);
|
|
75
|
+
return signal ? AbortSignal.any([signal, timeout]) : timeout;
|
|
76
|
+
}
|
|
77
|
+
export async function getClaudeStatus(env, signal) {
|
|
78
|
+
let data = "";
|
|
79
|
+
let result = { code: 0, stderr: "" };
|
|
80
|
+
try {
|
|
81
|
+
result = await invoke(["auth", "status"], { env, signal: deadline(signal), onLine: line => { data = (data + line).slice(-65536); } });
|
|
82
|
+
const status = JSON.parse(data);
|
|
83
|
+
const diagnostic = typeof status.loggedIn !== "boolean";
|
|
84
|
+
return { available: true, loggedIn: status.loggedIn === true, diagnostic,
|
|
85
|
+
detail: diagnostic ? "unexpected auth status output" : undefined };
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
signal?.throwIfAborted();
|
|
89
|
+
const available = error.code !== "ENOENT";
|
|
90
|
+
const reason = error?.name === "TimeoutError" ? "claude auth status timed out after 20s"
|
|
91
|
+
: error instanceof SyntaxError ? "claude auth status printed no JSON"
|
|
92
|
+
: error instanceof Error ? error.message : String(error);
|
|
93
|
+
const detail = [reason, result.code ? "exit " + result.code : "", result.stderr].filter(Boolean).join("; ");
|
|
94
|
+
return { available, loggedIn: false, diagnostic: available, detail };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export async function discoverClaudeModels(env, signal) {
|
|
98
|
+
const request_id = randomUUID();
|
|
99
|
+
const models = new Map();
|
|
100
|
+
const input = JSON.stringify({ type: "control_request", request_id, request: { subtype: "initialize" } }) + "\n";
|
|
101
|
+
const { code, stderr } = await invoke([...isolated, ...streaming, "--mcp-config", '{"mcpServers":{}}'], {
|
|
102
|
+
env, signal: deadline(signal), input, onLine(line) {
|
|
103
|
+
let event;
|
|
104
|
+
try {
|
|
105
|
+
event = JSON.parse(line);
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const reply = event.response;
|
|
111
|
+
if (event.type !== "control_response" || reply?.request_id !== request_id || reply.subtype !== "success")
|
|
112
|
+
return;
|
|
113
|
+
for (const row of reply.response.models) {
|
|
114
|
+
if (typeof row.value !== "string" || typeof row.displayName !== "string")
|
|
115
|
+
continue;
|
|
116
|
+
const model = modelEntry(row);
|
|
117
|
+
models.set(model.id, model);
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
if (code || !models.size)
|
|
122
|
+
throw new Error(["Model discovery failed", "exit " + code, stderr].filter(Boolean).join("; "));
|
|
123
|
+
return [...models.values()];
|
|
124
|
+
}
|
|
125
|
+
function modelEntry(row) {
|
|
126
|
+
const resolved = (row.resolvedModel || row.value).replace(/\[1m\]$/i, "");
|
|
127
|
+
const id = row.value === "default" ? "default" : resolved;
|
|
128
|
+
const known = getBuiltinModels("anthropic").find(m => m.id === resolved);
|
|
129
|
+
return { id, route: row.value, name: row.displayName, api, provider: providerId, baseUrl: defaultUrl,
|
|
130
|
+
cost: known?.cost ?? { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, reasoning: row.supportsEffort ?? known?.reasoning ?? false,
|
|
131
|
+
contextWindow: row.resolvedModel?.endsWith("[1m]") ? 1000000 : known?.contextWindow ?? 200000,
|
|
132
|
+
maxTokens: known?.maxTokens ?? 64000, input: ["text", "image"] };
|
|
133
|
+
}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { calculateCost, createAssistantMessageEventStream, getCurrentSystemPrompt, getCurrentTools } from "@earendil-works/pi-ai";
|
|
6
|
+
import { invoke, isolated, streaming } from "./claude-process.js";
|
|
7
|
+
// Present the conversation in order, retaining call IDs and images. Do not forward
|
|
8
|
+
// provider diagnostics, local tool details, or session bookkeeping to Claude.
|
|
9
|
+
function userInput(context) {
|
|
10
|
+
const blocks = [];
|
|
11
|
+
for (const msg of context.messages) {
|
|
12
|
+
if (msg.role === "system")
|
|
13
|
+
continue;
|
|
14
|
+
const parts = typeof msg.content === "string" ? [{ type: "text", text: msg.content }] : msg.content;
|
|
15
|
+
const content = parts.flatMap((p) => {
|
|
16
|
+
if (p.type === "image")
|
|
17
|
+
return [{ type: "image", attachment: true }];
|
|
18
|
+
if (p.type === "thinking")
|
|
19
|
+
return [];
|
|
20
|
+
return [p];
|
|
21
|
+
});
|
|
22
|
+
const record = msg.role === "toolResult"
|
|
23
|
+
? { role: msg.role, toolCallId: msg.toolCallId, name: msg.toolName, isError: msg.isError, content }
|
|
24
|
+
: { role: msg.role, content };
|
|
25
|
+
blocks.push({ type: "text", text: JSON.stringify(record) });
|
|
26
|
+
for (const p of parts)
|
|
27
|
+
if (p.type === "image") {
|
|
28
|
+
blocks.push({ type: "image", source: { type: "base64", media_type: p.mimeType, data: p.data } });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return JSON.stringify({ type: "user", message: { role: "user", content: blocks } }) + "\n";
|
|
32
|
+
}
|
|
33
|
+
export function streamClaudeCode(model, context, options, route = model.id) {
|
|
34
|
+
const stream = createAssistantMessageEventStream();
|
|
35
|
+
const message = { role: "assistant", api: model.api, provider: model.provider, model: model.id,
|
|
36
|
+
timestamp: Date.now(), content: [], stopReason: "pending",
|
|
37
|
+
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 } } };
|
|
38
|
+
async function generate() {
|
|
39
|
+
const tools = getCurrentTools(context.messages);
|
|
40
|
+
const reserved = new Set(tools.map(tool => tool.name));
|
|
41
|
+
function transportName(name, index) {
|
|
42
|
+
if (/^[a-zA-Z0-9_-]{1,48}$/.test(name))
|
|
43
|
+
return name;
|
|
44
|
+
let replacement = "tool_" + index;
|
|
45
|
+
while (reserved.has(replacement))
|
|
46
|
+
replacement += "_";
|
|
47
|
+
reserved.add(replacement);
|
|
48
|
+
return replacement;
|
|
49
|
+
}
|
|
50
|
+
const catalog = tools.map((tool, index) => ({
|
|
51
|
+
name: transportName(tool.name, index),
|
|
52
|
+
description: tool.description, inputSchema: tool.parameters,
|
|
53
|
+
}));
|
|
54
|
+
const names = new Map(catalog.map((tool, i) => ["mcp__tether__" + tool.name, tools[i].name]));
|
|
55
|
+
const dir = await mkdtemp(join(tmpdir(), "a-tether-turn-"));
|
|
56
|
+
try {
|
|
57
|
+
const file = join(dir, "catalog.json");
|
|
58
|
+
const system = join(dir, "system.txt");
|
|
59
|
+
await writeFile(file, JSON.stringify(catalog), { mode: 0o600 });
|
|
60
|
+
const instructions = "You are the assistant in a Pi conversation. The input records represent the conversation in chronological order. Continue from the last record. Use the available tether tools for actions on computer A; Pi supplies their results on subsequent turns.";
|
|
61
|
+
await writeFile(system, getCurrentSystemPrompt(context.messages) + "\n\n" + instructions, { mode: 0o600 });
|
|
62
|
+
const servers = tools.length ? { tether: { command: process.execPath, args: [fileURLToPath(new URL("./tool-catalog.mjs", import.meta.url)), file] } } : {};
|
|
63
|
+
const args = [...isolated, ...streaming, "--include-partial-messages", "--max-turns", "1", "--model", route,
|
|
64
|
+
"--mcp-config", JSON.stringify({ mcpServers: servers }), "--system-prompt-file", system];
|
|
65
|
+
if (options.reasoning)
|
|
66
|
+
args.push("--effort", options.reasoning === "minimal" ? "low" : options.reasoning);
|
|
67
|
+
let completed = false;
|
|
68
|
+
let stopReason = "";
|
|
69
|
+
let cliError = "";
|
|
70
|
+
let hasAssistant = false;
|
|
71
|
+
const callsSeen = new Set();
|
|
72
|
+
const positions = new Map();
|
|
73
|
+
const pendingFinal = [];
|
|
74
|
+
function finishText(kind, text, signature, redacted = false) {
|
|
75
|
+
let i = pendingFinal.shift();
|
|
76
|
+
if (i === undefined) {
|
|
77
|
+
i = message.content.length;
|
|
78
|
+
if (kind === "text") {
|
|
79
|
+
message.content.push({ type: "text", text: "" });
|
|
80
|
+
stream.push({ type: "text_start", contentIndex: i, partial: message });
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
message.content.push({ type: "thinking", thinking: "", redacted });
|
|
84
|
+
stream.push({ type: "thinking_start", contentIndex: i, partial: message });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const b = message.content[i];
|
|
88
|
+
if (b.type === "text" && kind === "text" && text.startsWith(b.text)) {
|
|
89
|
+
const delta = text.slice(b.text.length);
|
|
90
|
+
b.text = text;
|
|
91
|
+
if (delta)
|
|
92
|
+
stream.push({ type: "text_delta", delta, contentIndex: i, partial: message });
|
|
93
|
+
stream.push({ type: "text_end", content: text, contentIndex: i, partial: message });
|
|
94
|
+
}
|
|
95
|
+
else if (b.type === "thinking" && kind === "thinking" && text.startsWith(b.thinking)) {
|
|
96
|
+
const delta = text.slice(b.thinking.length);
|
|
97
|
+
b.thinking = text;
|
|
98
|
+
b.thinkingSignature = signature;
|
|
99
|
+
if (delta)
|
|
100
|
+
stream.push({ type: "thinking_delta", delta, contentIndex: i, partial: message });
|
|
101
|
+
stream.push({ type: "thinking_end", content: text, contentIndex: i, partial: message });
|
|
102
|
+
}
|
|
103
|
+
else
|
|
104
|
+
throw new Error("Claude final content differs from stream");
|
|
105
|
+
}
|
|
106
|
+
stream.push({ type: "start", partial: message });
|
|
107
|
+
const { code, stderr } = await invoke(args, { signal: options.signal, cwd: dir, input: userInput(context),
|
|
108
|
+
env: options.maxTokens ? { CLAUDE_CODE_MAX_OUTPUT_TOKENS: String(options.maxTokens) } : {}, onLine(line) {
|
|
109
|
+
let envelope;
|
|
110
|
+
try {
|
|
111
|
+
envelope = JSON.parse(line);
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
return;
|
|
115
|
+
} // ignore non-JSON noise on stdout
|
|
116
|
+
if (envelope.parent_tool_use_id)
|
|
117
|
+
return;
|
|
118
|
+
if (envelope.type === "stream_event") {
|
|
119
|
+
const e = envelope.event;
|
|
120
|
+
if (e.type === "content_block_start") {
|
|
121
|
+
const b = e.content_block;
|
|
122
|
+
const i = message.content.length;
|
|
123
|
+
if (b.type === "text") {
|
|
124
|
+
positions.set(e.index, i);
|
|
125
|
+
pendingFinal.push(i);
|
|
126
|
+
message.content.push({ type: "text", text: b.text || "" });
|
|
127
|
+
stream.push({ type: "text_start", partial: message, contentIndex: i });
|
|
128
|
+
}
|
|
129
|
+
else if (b.type === "thinking") {
|
|
130
|
+
positions.set(e.index, i);
|
|
131
|
+
pendingFinal.push(i);
|
|
132
|
+
message.content.push({ type: "thinking", thinking: b.thinking || "" });
|
|
133
|
+
stream.push({ type: "thinking_start", partial: message, contentIndex: i });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const i = positions.get(e.index);
|
|
137
|
+
if (i === undefined)
|
|
138
|
+
return;
|
|
139
|
+
const b = message.content[i];
|
|
140
|
+
if (e.type === "content_block_delta") {
|
|
141
|
+
if (b.type === "text" && e.delta.type === "text_delta") {
|
|
142
|
+
b.text += e.delta.text;
|
|
143
|
+
stream.push({ type: "text_delta", partial: message, contentIndex: i, delta: e.delta.text });
|
|
144
|
+
}
|
|
145
|
+
if (b.type === "thinking" && e.delta.type === "thinking_delta") {
|
|
146
|
+
b.thinking += e.delta.thinking;
|
|
147
|
+
stream.push({ type: "thinking_delta", partial: message, contentIndex: i, delta: e.delta.thinking });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
else if (e.type === "content_block_stop") {
|
|
151
|
+
positions.delete(e.index);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
else if (envelope.type === "assistant") {
|
|
155
|
+
if (envelope.error) {
|
|
156
|
+
cliError = String(envelope.error);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
hasAssistant = true;
|
|
160
|
+
message.responseId = envelope.message.id;
|
|
161
|
+
stopReason = envelope.message.stop_reason || stopReason;
|
|
162
|
+
for (const b of envelope.message.content) {
|
|
163
|
+
if (b.type === "text") {
|
|
164
|
+
finishText("text", b.text);
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
if (b.type === "thinking") {
|
|
168
|
+
finishText("thinking", b.thinking, b.signature);
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
if (b.type === "redacted_thinking") {
|
|
172
|
+
finishText("thinking", "", b.data, true);
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
if (b.type !== "tool_use")
|
|
176
|
+
continue;
|
|
177
|
+
const name = names.get(b.name);
|
|
178
|
+
if (!name)
|
|
179
|
+
throw new Error("Unexpected Claude tool");
|
|
180
|
+
if (typeof b.id !== "string" || !b.input || typeof b.input !== "object" || Array.isArray(b.input))
|
|
181
|
+
throw new Error("Invalid tool call");
|
|
182
|
+
if (callsSeen.has(b.id))
|
|
183
|
+
continue;
|
|
184
|
+
callsSeen.add(b.id);
|
|
185
|
+
const toolCall = { type: "toolCall", id: b.id, name, arguments: b.input };
|
|
186
|
+
const i = message.content.push(toolCall) - 1;
|
|
187
|
+
stream.push({ type: "toolcall_start", contentIndex: i, partial: message });
|
|
188
|
+
stream.push({ type: "toolcall_end", contentIndex: i, toolCall, partial: message });
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
else if (envelope.type === "result") {
|
|
192
|
+
const calls = message.content.some(b => b.type === "toolCall");
|
|
193
|
+
completed = envelope.subtype === "success" && !envelope.is_error || calls && envelope.subtype === "error_max_turns";
|
|
194
|
+
stopReason = envelope.stop_reason || stopReason;
|
|
195
|
+
if (!completed)
|
|
196
|
+
cliError = [cliError, JSON.stringify(envelope.errors || envelope.result)].filter(Boolean).join("; ");
|
|
197
|
+
const u = envelope.usage ?? {};
|
|
198
|
+
Object.assign(message.usage, { input: u.input_tokens ?? 0, output: u.output_tokens ?? 0,
|
|
199
|
+
cacheRead: u.cache_read_input_tokens ?? 0, cacheWrite: u.cache_creation_input_tokens ?? 0 });
|
|
200
|
+
const { input, output, cacheRead, cacheWrite } = message.usage;
|
|
201
|
+
message.usage.totalTokens = input + output + cacheRead + cacheWrite;
|
|
202
|
+
calculateCost(model, message.usage);
|
|
203
|
+
}
|
|
204
|
+
else if (envelope.type === "rate_limit_event" && envelope.rate_limit_info?.isUsingOverage &&
|
|
205
|
+
process.env.PI_CLAUDE_CODE_ALLOW_USAGE_CREDITS !== "1") {
|
|
206
|
+
throw new Error("Claude billing limit");
|
|
207
|
+
}
|
|
208
|
+
} });
|
|
209
|
+
const calls = message.content.some(b => b.type === "toolCall");
|
|
210
|
+
if (pendingFinal.length || !hasAssistant || !completed || cliError || (code && !calls))
|
|
211
|
+
throw new Error([cliError || "Claude did not finish", "exit " + code, stderr].filter(Boolean).join("; "));
|
|
212
|
+
if (stopReason === "refusal")
|
|
213
|
+
throw new Error("Claude refused this request");
|
|
214
|
+
message.stopReason = stopReason === "max_tokens" ? "length" : calls ? "toolUse" : "stop";
|
|
215
|
+
}
|
|
216
|
+
finally {
|
|
217
|
+
await rm(dir, { recursive: true, force: true });
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
void generate().then(() => {
|
|
221
|
+
stream.push({ type: "done", reason: message.stopReason, message });
|
|
222
|
+
}).catch(error => {
|
|
223
|
+
const reason = options.signal?.aborted ? "aborted" : "error";
|
|
224
|
+
message.stopReason = reason;
|
|
225
|
+
message.errorMessage = error instanceof Error ? error.message : "Claude request failed";
|
|
226
|
+
stream.push({ type: "error", reason, error: message });
|
|
227
|
+
}).finally(() => stream.end());
|
|
228
|
+
return stream;
|
|
229
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { discoverClaudeModels, getClaudeStatus } from "./claude-process.js";
|
|
2
|
+
import { streamClaudeCode } from "./claude-turn.js";
|
|
3
|
+
export function backendCode(detail) {
|
|
4
|
+
if (/prompt is too long|context.(length|window)|too many tokens|maximum context/i.test(detail))
|
|
5
|
+
return "context";
|
|
6
|
+
if (/quota|rate.limit|billing|credit|status 429|usage limit/i.test(detail))
|
|
7
|
+
return "quota";
|
|
8
|
+
if (/not logged in|auth login|unauthorized|authentication.(failed|error)|invalid.api.key|oauth token|status 401/i.test(detail))
|
|
9
|
+
return "login";
|
|
10
|
+
if (/overloaded|status 5\d\d|\b5(00|02|03|04|29)\b|internal server error|service unavailable|bad gateway|api_error|ECONNRESET|ETIMEDOUT|socket hang up/i.test(detail))
|
|
11
|
+
return "overloaded";
|
|
12
|
+
if (/not installed|not found on PATH/i.test(detail))
|
|
13
|
+
return "unavailable";
|
|
14
|
+
return "backend";
|
|
15
|
+
}
|
|
16
|
+
export const claudeCode = {
|
|
17
|
+
name: "Claude Code",
|
|
18
|
+
status: (signal) => getClaudeStatus(process.env, signal),
|
|
19
|
+
models: (signal) => discoverClaudeModels(process.env, signal),
|
|
20
|
+
stream: (model, context, options) => streamClaudeCode(model, context, options, model.route),
|
|
21
|
+
errorCode: backendCode,
|
|
22
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// A read-only MCP catalog. The only supported operations are discovery and listing.
|
|
2
|
+
import {createInterface} from "node:readline";
|
|
3
|
+
import {readFile} from "node:fs/promises";
|
|
4
|
+
const tools = JSON.parse(await readFile(process.argv[2],"utf8"));
|
|
5
|
+
for await (const line of createInterface({input:process.stdin})) {
|
|
6
|
+
const {id,method,params} = JSON.parse(line);
|
|
7
|
+
if (id === undefined) continue;
|
|
8
|
+
let result;
|
|
9
|
+
if (method === "initialize") {
|
|
10
|
+
result = {protocolVersion:params.protocolVersion,serverInfo:{name:"a-tether",version:"0.1.0"},capabilities:{tools:{}}};
|
|
11
|
+
} else if (method === "tools/list") result = {tools};
|
|
12
|
+
else if (method === "ping") result = {};
|
|
13
|
+
const response = result ? {result} : {error:{code:-32601,message:"Tool execution belongs to Pi on A"}};
|
|
14
|
+
process.stdout.write(JSON.stringify({jsonrpc:"2.0",id,...response})+"\n");
|
|
15
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { normalizeContext } from "@earendil-works/pi-ai";
|
|
2
|
+
import { createServer } from "node:http";
|
|
3
|
+
import { createHash, timingSafeEqual } from "node:crypto";
|
|
4
|
+
import { once } from "node:events";
|
|
5
|
+
import { mkdtemp, rm } from "node:fs/promises";
|
|
6
|
+
import { tmpdir } from "node:os";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import { generationOptions, uuid, wireEvent } from "../shared/protocol.js";
|
|
9
|
+
function json(res, status, data) {
|
|
10
|
+
res.writeHead(status, { "content-type": "application/json", "cache-control": "no-store" }).end(JSON.stringify(data));
|
|
11
|
+
}
|
|
12
|
+
export class Failure extends Error {
|
|
13
|
+
status;
|
|
14
|
+
code;
|
|
15
|
+
detail;
|
|
16
|
+
constructor(status, code, detail = "") {
|
|
17
|
+
super(code);
|
|
18
|
+
this.status = status;
|
|
19
|
+
this.code = code;
|
|
20
|
+
this.detail = detail;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// C logs one line per failure: time, request ID prefix, code and a clipped
|
|
24
|
+
// diagnostic from Claude Code. Conversation content and tool data are never logged.
|
|
25
|
+
export function clip(text) { return text.replace(/\s+/g, " ").trim().slice(0, 500); }
|
|
26
|
+
function logError(id, code, detail = "") {
|
|
27
|
+
const text = clip(detail);
|
|
28
|
+
console.error(`${new Date().toISOString()} ${id ? id.slice(0, 8) : "--------"} ${code}${text ? ": " + text : ""}`);
|
|
29
|
+
}
|
|
30
|
+
function describe(error) {
|
|
31
|
+
return error instanceof Failure ? error.detail : error instanceof Error ? error.message : typeof error === "string" ? error : "";
|
|
32
|
+
}
|
|
33
|
+
// Keeps the last good catalog when a refresh fails transiently, such as a slow
|
|
34
|
+
// `claude auth status`, and retries soon instead of failing the request.
|
|
35
|
+
export function catalogCache(load, onStale, ttl = 60_000, retry = 10_000, now = Date.now) {
|
|
36
|
+
let catalog = [];
|
|
37
|
+
let refreshAt = 0;
|
|
38
|
+
return async (signal) => {
|
|
39
|
+
if (now() < refreshAt)
|
|
40
|
+
return catalog;
|
|
41
|
+
try {
|
|
42
|
+
catalog = await load(signal);
|
|
43
|
+
refreshAt = now() + ttl;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
const transient = error instanceof Failure && (error.code === "backend" || error.code === "discovery");
|
|
47
|
+
if (signal.aborted || !transient || !catalog.length)
|
|
48
|
+
throw error;
|
|
49
|
+
onStale(error.detail);
|
|
50
|
+
refreshAt = now() + retry;
|
|
51
|
+
}
|
|
52
|
+
return catalog;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
async function readRequest(req) {
|
|
56
|
+
const chunks = [];
|
|
57
|
+
let size = 0;
|
|
58
|
+
for await (const chunk of req.iterator({ destroyOnReturn: false })) {
|
|
59
|
+
size += chunk.length;
|
|
60
|
+
if (size > 32 * 1024 * 1024)
|
|
61
|
+
throw new Failure(413, "large");
|
|
62
|
+
chunks.push(chunk);
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
return JSON.parse(Buffer.concat(chunks).toString());
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
throw new Failure(400, "invalid");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export async function runServer(backend) {
|
|
72
|
+
const token = process.env.A_TETHER_TOKEN;
|
|
73
|
+
if (!token || token.length < 32 || /\s/.test(token))
|
|
74
|
+
throw new Error("Set A_TETHER_TOKEN to a random token of at least 32 characters");
|
|
75
|
+
const digest = (value) => createHash("sha256").update(value).digest();
|
|
76
|
+
const expected = digest("Bearer " + token);
|
|
77
|
+
delete process.env.A_TETHER_TOKEN;
|
|
78
|
+
const port = Number(process.env.A_TETHER_PORT ?? 7310);
|
|
79
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535)
|
|
80
|
+
throw new Error("Invalid A_TETHER_PORT");
|
|
81
|
+
const directory = await mkdtemp(join(tmpdir(), "a-tether-"));
|
|
82
|
+
process.chdir(directory);
|
|
83
|
+
const active = new Map();
|
|
84
|
+
const pending = new Set();
|
|
85
|
+
const controllers = new Set();
|
|
86
|
+
const models = catalogCache(async (signal) => {
|
|
87
|
+
const health = await backend.status(signal);
|
|
88
|
+
if (!health.available)
|
|
89
|
+
throw new Failure(503, "unavailable", health.detail);
|
|
90
|
+
if (health.diagnostic)
|
|
91
|
+
throw new Failure(502, "backend", "status check failed: " + (health.detail ?? "unknown"));
|
|
92
|
+
if (!health.loggedIn)
|
|
93
|
+
throw new Failure(503, "login");
|
|
94
|
+
try {
|
|
95
|
+
return await backend.models(signal);
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
signal.throwIfAborted();
|
|
99
|
+
throw new Failure(502, "discovery", describe(error));
|
|
100
|
+
}
|
|
101
|
+
}, detail => logError("", "stale-catalog", detail));
|
|
102
|
+
async function handle(req, res, controller) {
|
|
103
|
+
if (!timingSafeEqual(digest(req.headers.authorization ?? ""), expected))
|
|
104
|
+
throw new Failure(401, "unauthorized");
|
|
105
|
+
const signal = controller.signal;
|
|
106
|
+
if (req.method === "GET" && req.url === "/v1/health") {
|
|
107
|
+
const { available, loggedIn, diagnostic } = await backend.status(signal);
|
|
108
|
+
return json(res, 200, { available, loggedIn, diagnostic });
|
|
109
|
+
}
|
|
110
|
+
if (req.method === "GET" && req.url === "/v1/models")
|
|
111
|
+
return json(res, 200, (await models(signal)).map(({ route, ...model }) => model));
|
|
112
|
+
const cancelId = req.url?.slice("/v1/requests/".length) ?? "";
|
|
113
|
+
if (req.method === "DELETE" && req.url?.startsWith("/v1/requests/") && uuid.test(cancelId)) {
|
|
114
|
+
active.get(cancelId)?.abort("cancelled");
|
|
115
|
+
return json(res, 200, { id: cancelId });
|
|
116
|
+
}
|
|
117
|
+
if (req.method !== "POST" || req.url !== "/v1/requests")
|
|
118
|
+
throw new Failure(404, "invalid");
|
|
119
|
+
const body = await readRequest(req);
|
|
120
|
+
if (!body || typeof body.id !== "string" || !uuid.test(body.id) || !Array.isArray(body.context?.messages))
|
|
121
|
+
throw new Failure(400, "invalid");
|
|
122
|
+
const id = body.id;
|
|
123
|
+
if (active.has(id))
|
|
124
|
+
throw new Failure(409, "duplicate");
|
|
125
|
+
active.set(id, controller);
|
|
126
|
+
const timer = setTimeout(() => controller.abort("timeout"), 300_000);
|
|
127
|
+
try {
|
|
128
|
+
const model = (await models(signal)).find(m => m.id === body.model);
|
|
129
|
+
signal.throwIfAborted();
|
|
130
|
+
if (!model)
|
|
131
|
+
throw new Failure(400, "invalid", "unknown model");
|
|
132
|
+
res.writeHead(200, { "content-type": "application/x-ndjson", "cache-control": "no-store" });
|
|
133
|
+
res.flushHeaders();
|
|
134
|
+
const stream = backend.stream(model, normalizeContext({ messages: body.context.messages }), {
|
|
135
|
+
...generationOptions(body.options), signal,
|
|
136
|
+
});
|
|
137
|
+
try {
|
|
138
|
+
for await (const event of stream) {
|
|
139
|
+
if (event.type === "error") {
|
|
140
|
+
const code = signal.aborted ? signal.reason : backend.errorCode(event.error.errorMessage ?? "");
|
|
141
|
+
logError(id, code, signal.aborted ? "" : event.error.errorMessage);
|
|
142
|
+
if (!res.destroyed)
|
|
143
|
+
res.write(JSON.stringify({ id, type: "error", code }) + "\n");
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
if (res.destroyed)
|
|
147
|
+
continue;
|
|
148
|
+
const frame = { id, type: event.type === "done" ? "done" : "event", event: wireEvent(event) };
|
|
149
|
+
if (!res.write(JSON.stringify(frame) + "\n") && !signal.aborted)
|
|
150
|
+
await once(res, "drain", { signal });
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
finally {
|
|
154
|
+
controller.abort("cancelled");
|
|
155
|
+
await stream.result();
|
|
156
|
+
}
|
|
157
|
+
res.end();
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
error.requestId = id;
|
|
161
|
+
throw error;
|
|
162
|
+
}
|
|
163
|
+
finally {
|
|
164
|
+
clearTimeout(timer);
|
|
165
|
+
active.delete(id);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const server = createServer((req, res) => {
|
|
169
|
+
const controller = new AbortController();
|
|
170
|
+
controllers.add(controller);
|
|
171
|
+
res.once("close", () => controller.abort("cancelled"));
|
|
172
|
+
const task = handle(req, res, controller).catch(error => {
|
|
173
|
+
const reason = controller.signal.reason;
|
|
174
|
+
const failure = error instanceof Failure ? error
|
|
175
|
+
: reason === "timeout" ? new Failure(504, "timeout")
|
|
176
|
+
: reason === "cancelled" ? new Failure(499, "cancelled")
|
|
177
|
+
: new Failure(502, "backend", describe(error));
|
|
178
|
+
logError(error?.requestId ?? "", failure.code, failure.detail);
|
|
179
|
+
if (res.destroyed)
|
|
180
|
+
return;
|
|
181
|
+
if (res.headersSent)
|
|
182
|
+
return res.destroy();
|
|
183
|
+
json(res, failure.status, { code: failure.code });
|
|
184
|
+
}).then(() => { });
|
|
185
|
+
pending.add(task);
|
|
186
|
+
void task.finally(() => { pending.delete(task); controllers.delete(controller); });
|
|
187
|
+
});
|
|
188
|
+
const startup = new AbortController();
|
|
189
|
+
const shutdown = () => {
|
|
190
|
+
startup.abort("cancelled");
|
|
191
|
+
for (const controller of controllers)
|
|
192
|
+
controller.abort("cancelled");
|
|
193
|
+
server.close();
|
|
194
|
+
server.closeAllConnections();
|
|
195
|
+
};
|
|
196
|
+
process.once("SIGINT", shutdown);
|
|
197
|
+
process.once("SIGTERM", shutdown);
|
|
198
|
+
try {
|
|
199
|
+
const health = await backend.status(startup.signal);
|
|
200
|
+
startup.signal.throwIfAborted();
|
|
201
|
+
const state = !health.available ? "missing"
|
|
202
|
+
: health.diagnostic ? "status check failed" + (health.detail ? " (" + clip(health.detail) + ")" : "")
|
|
203
|
+
: health.loggedIn ? "logged in" : "not logged in";
|
|
204
|
+
console.log(backend.name + ":", state);
|
|
205
|
+
server.listen(port, "127.0.0.1");
|
|
206
|
+
await once(server, "listening", { signal: startup.signal });
|
|
207
|
+
console.log("A-tether listening on 127.0.0.1:" + port);
|
|
208
|
+
await once(server, "close");
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
if (!startup.signal.aborted)
|
|
212
|
+
throw error;
|
|
213
|
+
}
|
|
214
|
+
finally {
|
|
215
|
+
await Promise.allSettled(pending);
|
|
216
|
+
process.chdir(tmpdir());
|
|
217
|
+
await rm(directory, { recursive: true, force: true });
|
|
218
|
+
}
|
|
219
|
+
}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { claudeCode } from "./backends/claude-code/index.js";
|
|
3
|
+
import { runServer } from "./server/http.js";
|
|
4
|
+
try {
|
|
5
|
+
await runServer(claudeCode);
|
|
6
|
+
}
|
|
7
|
+
catch (error) {
|
|
8
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
9
|
+
process.exitCode = 1;
|
|
10
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export const providerId = "a-tether";
|
|
2
|
+
export const api = "a-tether-v1";
|
|
3
|
+
export const defaultUrl = "http://127.0.0.1:7310";
|
|
4
|
+
export const uuid = /^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/i;
|
|
5
|
+
export const messages = {
|
|
6
|
+
unauthorized: "A-tether 认证失败,请检查两端的 A_TETHER_TOKEN。",
|
|
7
|
+
unavailable: "C 上找不到 Claude Code,请检查服务进程的 PATH。",
|
|
8
|
+
login: "C 上的 Claude Code 尚未登录或登录已失效。",
|
|
9
|
+
quota: "Claude 额度、速率或计费限制,请在 C 上检查账户。",
|
|
10
|
+
backend: "C 上的 Claude Code 调用失败,具体原因见 C 端服务控制台。",
|
|
11
|
+
overloaded: "模型服务繁忙或暂时不可用,请稍后重试。",
|
|
12
|
+
context: "请求超出模型的上下文长度,请在 Pi 中压缩上下文或减少输入。",
|
|
13
|
+
discovery: "C 无法获取 Claude 模型目录,请检查 CLI 版本和连接。",
|
|
14
|
+
cancelled: "请求已取消。",
|
|
15
|
+
timeout: "C 上的请求超时。",
|
|
16
|
+
invalid: "请求格式或模型 ID 无效。",
|
|
17
|
+
duplicate: "请求 ID 已在使用。",
|
|
18
|
+
large: "请求超过 32 MiB 上限。",
|
|
19
|
+
connection: "A-tether 连接中断,请检查 SSH 隧道和 C 端服务。",
|
|
20
|
+
};
|
|
21
|
+
// Runtime whitelist on BOTH ends. In particular, never forward env, headers,
|
|
22
|
+
// sessionId, filesystem paths, credentials, or callbacks from Pi.
|
|
23
|
+
export function generationOptions(options) {
|
|
24
|
+
const reasoning = options?.reasoning;
|
|
25
|
+
const maxTokens = options?.maxTokens;
|
|
26
|
+
return {
|
|
27
|
+
...(reasoning && ["minimal", "low", "medium", "high", "xhigh", "max"].includes(reasoning) ? { reasoning } : {}),
|
|
28
|
+
...(Number.isSafeInteger(maxTokens) && maxTokens > 0 ? { maxTokens } : {}),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
// Pi partials refer to a mutable, cumulative message. Only block boundaries
|
|
32
|
+
// need snapshots on the wire. Streaming deltas carry just the newly arrived data.
|
|
33
|
+
export function wireEvent(event) {
|
|
34
|
+
if (event.type === "done")
|
|
35
|
+
return event;
|
|
36
|
+
const { partial, ...update } = event;
|
|
37
|
+
if (event.type === "start")
|
|
38
|
+
return { ...update, partial: { ...partial, content: [] } };
|
|
39
|
+
const block = partial.content[event.contentIndex];
|
|
40
|
+
switch (event.type) {
|
|
41
|
+
case "toolcall_start":
|
|
42
|
+
if (block.type === "toolCall")
|
|
43
|
+
return { ...update, block: { type: block.type, id: block.id, name: block.name, arguments: {} } };
|
|
44
|
+
break;
|
|
45
|
+
case "thinking_start":
|
|
46
|
+
if (block.type === "thinking")
|
|
47
|
+
return { ...update, block: { type: block.type, thinking: block.redacted ? block.thinking : "", redacted: block.redacted } };
|
|
48
|
+
break;
|
|
49
|
+
case "text_start": return { ...update, block: { type: "text", text: "" } };
|
|
50
|
+
case "thinking_end": return { ...update, signature: block.type === "thinking" ? block.thinkingSignature : undefined };
|
|
51
|
+
}
|
|
52
|
+
return update;
|
|
53
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@a-tether/server",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A-tether C-side service: lends a logged-in Claude Code to Pi on another machine over an SSH tunnel.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/SandyKidYao/a-tether.git",
|
|
10
|
+
"directory": "packages/server"
|
|
11
|
+
},
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=22.19.0"
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"a-tether-server": "dist/server.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@earendil-works/pi-ai": "1.5.2"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
}
|
|
29
|
+
}
|