@etilic/rutter_ai 0.0.0-stage → 0.2.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 +27 -0
- package/README.md +80 -2
- package/THIRD_PARTY_LICENSES.txt +111 -0
- package/bin/cli.cjs +94 -0
- package/bin/npm-runtime.cjs +125 -0
- package/client/darwin-arm64/bootstrap.cjs +159 -0
- package/client/darwin-arm64/compat.cjs +61 -0
- package/client/darwin-arm64/hook.cjs +597 -0
- package/client/darwin-arm64/install.cjs +555 -0
- package/client/darwin-arm64/manifest.json +1 -0
- package/client/darwin-arm64/mcp.cjs +5666 -0
- package/client/darwin-arm64/migration.cjs +53 -0
- package/client/darwin-arm64/node_sqlite3.node +0 -0
- package/client/darwin-arm64/ordered-upload.cjs +236 -0
- package/client/darwin-arm64/outbox.cjs +218 -0
- package/client/darwin-arm64/recovery.cjs +61 -0
- package/client/darwin-arm64/sqlite3.cjs +217 -0
- package/client/darwin-arm64/transcript.cjs +138 -0
- package/client/darwin-arm64/upload.cjs +446 -0
- package/client/darwin-arm64/worker.cjs +76 -0
- package/client/darwin-x64/bootstrap.cjs +159 -0
- package/client/darwin-x64/compat.cjs +61 -0
- package/client/darwin-x64/hook.cjs +597 -0
- package/client/darwin-x64/install.cjs +555 -0
- package/client/darwin-x64/manifest.json +1 -0
- package/client/darwin-x64/mcp.cjs +5666 -0
- package/client/darwin-x64/migration.cjs +53 -0
- package/client/darwin-x64/node_sqlite3.node +0 -0
- package/client/darwin-x64/ordered-upload.cjs +236 -0
- package/client/darwin-x64/outbox.cjs +218 -0
- package/client/darwin-x64/recovery.cjs +61 -0
- package/client/darwin-x64/sqlite3.cjs +217 -0
- package/client/darwin-x64/transcript.cjs +138 -0
- package/client/darwin-x64/upload.cjs +446 -0
- package/client/darwin-x64/worker.cjs +76 -0
- package/client/linux-x64-glibc/bootstrap.cjs +159 -0
- package/client/linux-x64-glibc/compat.cjs +61 -0
- package/client/linux-x64-glibc/hook.cjs +597 -0
- package/client/linux-x64-glibc/install.cjs +555 -0
- package/client/linux-x64-glibc/manifest.json +1 -0
- package/client/linux-x64-glibc/mcp.cjs +5666 -0
- package/client/linux-x64-glibc/migration.cjs +53 -0
- package/client/linux-x64-glibc/node_sqlite3.node +0 -0
- package/client/linux-x64-glibc/ordered-upload.cjs +236 -0
- package/client/linux-x64-glibc/outbox.cjs +218 -0
- package/client/linux-x64-glibc/recovery.cjs +61 -0
- package/client/linux-x64-glibc/sqlite3.cjs +217 -0
- package/client/linux-x64-glibc/transcript.cjs +138 -0
- package/client/linux-x64-glibc/upload.cjs +446 -0
- package/client/linux-x64-glibc/worker.cjs +76 -0
- package/client/win32-x64/bootstrap.cjs +159 -0
- package/client/win32-x64/compat.cjs +61 -0
- package/client/win32-x64/hook.cjs +597 -0
- package/client/win32-x64/install.cjs +555 -0
- package/client/win32-x64/manifest.json +1 -0
- package/client/win32-x64/mcp.cjs +5666 -0
- package/client/win32-x64/migration.cjs +53 -0
- package/client/win32-x64/node_sqlite3.node +0 -0
- package/client/win32-x64/ordered-upload.cjs +236 -0
- package/client/win32-x64/outbox.cjs +218 -0
- package/client/win32-x64/recovery.cjs +61 -0
- package/client/win32-x64/sqlite3.cjs +217 -0
- package/client/win32-x64/transcript.cjs +138 -0
- package/client/win32-x64/upload.cjs +446 -0
- package/client/win32-x64/worker.cjs +76 -0
- package/package.json +34 -4
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
5
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
// agents/direct-memory-access/compat.cjs
|
|
9
|
+
var require_compat = __commonJS({
|
|
10
|
+
"agents/direct-memory-access/compat.cjs"(exports2, module2) {
|
|
11
|
+
"use strict";
|
|
12
|
+
var http = require("http");
|
|
13
|
+
var https = require("https");
|
|
14
|
+
var readline = require("readline");
|
|
15
|
+
function request2(url, options = {}) {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
let target;
|
|
19
|
+
try {
|
|
20
|
+
target = new URL(url);
|
|
21
|
+
} catch {
|
|
22
|
+
reject(new Error("Invalid service URL"));
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (!["http:", "https:"].includes(target.protocol) || target.username || target.password) {
|
|
26
|
+
reject(new Error("Invalid service URL"));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const deadline = options.timeoutMs === void 0 ? 15e3 : options.timeoutMs;
|
|
30
|
+
const maxBytes = options.maxBytes === void 0 ? 8 * 1024 * 1024 : options.maxBytes;
|
|
31
|
+
let timer, response, settled = false;
|
|
32
|
+
const finish = (error, value) => {
|
|
33
|
+
var _a2;
|
|
34
|
+
if (settled) return;
|
|
35
|
+
settled = true;
|
|
36
|
+
clearTimeout(timer);
|
|
37
|
+
(_a2 = options.signal) == null ? void 0 : _a2.removeEventListener("abort", abort);
|
|
38
|
+
if (error) {
|
|
39
|
+
response == null ? void 0 : response.destroy();
|
|
40
|
+
req.destroy();
|
|
41
|
+
reject(error);
|
|
42
|
+
} else resolve(value);
|
|
43
|
+
};
|
|
44
|
+
const abort = () => {
|
|
45
|
+
const error = new Error("Request aborted");
|
|
46
|
+
error.name = "AbortError";
|
|
47
|
+
finish(error);
|
|
48
|
+
};
|
|
49
|
+
const req = (target.protocol === "https:" ? https : http).request(target, {
|
|
50
|
+
method: options.method || "GET",
|
|
51
|
+
headers: options.headers,
|
|
52
|
+
agent: false
|
|
53
|
+
}, (res) => {
|
|
54
|
+
response = res;
|
|
55
|
+
if (res.statusCode >= 300 && res.statusCode < 400) {
|
|
56
|
+
finish(new Error("Redirect refused"));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
let size = 0;
|
|
60
|
+
const chunks = [];
|
|
61
|
+
res.on("data", (chunk) => {
|
|
62
|
+
size += chunk.length;
|
|
63
|
+
if (size > maxBytes) {
|
|
64
|
+
finish(new Error("Response size limit exceeded"));
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
chunks.push(chunk);
|
|
68
|
+
});
|
|
69
|
+
res.once("aborted", () => finish(new Error("Response interrupted")));
|
|
70
|
+
res.once("error", () => finish(new Error("Response interrupted")));
|
|
71
|
+
res.once("end", () => {
|
|
72
|
+
const body = Buffer.concat(chunks).toString("utf8");
|
|
73
|
+
finish(null, {
|
|
74
|
+
status: res.statusCode,
|
|
75
|
+
ok: res.statusCode >= 200 && res.statusCode < 300,
|
|
76
|
+
headers: { get: (name) => res.headers[String(name).toLowerCase()] || null },
|
|
77
|
+
text: async () => body,
|
|
78
|
+
json: async () => JSON.parse(body),
|
|
79
|
+
arrayBuffer: async () => Buffer.concat(chunks)
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
req.once("error", () => finish(new Error("Service connection failed")));
|
|
84
|
+
timer = setTimeout(() => {
|
|
85
|
+
const error = new Error("Request deadline exceeded");
|
|
86
|
+
error.name = "TimeoutError";
|
|
87
|
+
finish(error);
|
|
88
|
+
}, deadline);
|
|
89
|
+
if ((_a = options.signal) == null ? void 0 : _a.aborted) {
|
|
90
|
+
abort();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
(_b = options.signal) == null ? void 0 : _b.addEventListener("abort", abort, { once: true });
|
|
94
|
+
req.end(options.body);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function createInterface(options) {
|
|
98
|
+
const rl = readline.createInterface(options);
|
|
99
|
+
return { question: (prompt) => new Promise((resolve) => rl.question(prompt, resolve)), close: () => rl.close() };
|
|
100
|
+
}
|
|
101
|
+
module2.exports = { request: request2, createInterface, performance: require("perf_hooks").performance };
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// agents/direct-memory-access/bootstrap.cjs
|
|
106
|
+
var fs = require("node:fs");
|
|
107
|
+
var os = require("node:os");
|
|
108
|
+
var path = require("node:path");
|
|
109
|
+
var crypto = require("node:crypto");
|
|
110
|
+
var { spawnSync } = require("node:child_process");
|
|
111
|
+
var { request } = require_compat();
|
|
112
|
+
var names = ["hook.cjs", "install.cjs", "mcp.cjs", "transcript.cjs", "upload.cjs", "compat.cjs", "outbox.cjs", "worker.cjs", "ordered-upload.cjs", "recovery.cjs", "migration.cjs", "sqlite3.cjs", "node_sqlite3.node"];
|
|
113
|
+
function baseUrl(value) {
|
|
114
|
+
const url = new URL(value);
|
|
115
|
+
const local = ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
|
|
116
|
+
if (!(url.protocol === "https:" || local && url.protocol === "http:") || url.username || url.password || url.search || url.hash) throw new Error("Use an HTTPS server URL, or HTTP on localhost.");
|
|
117
|
+
url.pathname = url.pathname.replace(/\/+$/, "");
|
|
118
|
+
return url.toString().replace(/\/$/, "");
|
|
119
|
+
}
|
|
120
|
+
async function download(url, limit) {
|
|
121
|
+
const response = await request(url, { timeoutMs: 3e4, maxBytes: limit });
|
|
122
|
+
if (!response.ok) throw new Error(`Download failed (${response.status}).`);
|
|
123
|
+
return Buffer.from(await response.arrayBuffer());
|
|
124
|
+
}
|
|
125
|
+
async function main() {
|
|
126
|
+
if (Number(process.versions.node.split(".")[0]) < 16) throw new Error("Node.js 16 or newer is required.");
|
|
127
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) throw new Error("Run the installer in an interactive terminal.");
|
|
128
|
+
const base = baseUrl(process.argv[2]);
|
|
129
|
+
const manifest = JSON.parse((await download(`${base}/direct-memory-client/manifest.json`, 16384)).toString("utf8"));
|
|
130
|
+
if (manifest.runtime && (manifest.runtime.platform !== process.platform || manifest.runtime.arch !== process.arch || process.platform === "linux" && manifest.runtime.libc !== (process.report.getReport().header.glibcVersionRuntime ? "glibc" : "musl"))) throw new Error("This client package has no compatible prebuilt SQLite runtime for this platform; use a matching platform release.");
|
|
131
|
+
if (!/^[a-f0-9]{20}$/.test(manifest.version) || !manifest.files || Object.keys(manifest.files).length !== names.length || names.some((name) => !/^[a-f0-9]{64}$/.test(manifest.files[name] || ""))) throw new Error("Invalid package manifest.");
|
|
132
|
+
const root = path.join(process.env.HOME || os.homedir(), ".config", "rutter-direct-memory", "releases");
|
|
133
|
+
fs.mkdirSync(root, { recursive: true, mode: 448 });
|
|
134
|
+
const stage = fs.mkdtempSync(path.join(root, ".download-"));
|
|
135
|
+
try {
|
|
136
|
+
for (const name of names) {
|
|
137
|
+
const data = await download(`${base}/direct-memory-client/${name}`, 10 * 1024 * 1024);
|
|
138
|
+
if (crypto.createHash("sha256").update(data).digest("hex") !== manifest.files[name]) throw new Error(`Checksum mismatch: ${name}`);
|
|
139
|
+
fs.writeFileSync(path.join(stage, name), data, { mode: 384, flag: "wx" });
|
|
140
|
+
}
|
|
141
|
+
const release = path.join(root, manifest.version);
|
|
142
|
+
if (fs.existsSync(release)) {
|
|
143
|
+
for (const name of names) {
|
|
144
|
+
const hash = crypto.createHash("sha256").update(fs.readFileSync(path.join(release, name))).digest("hex");
|
|
145
|
+
if (hash !== manifest.files[name]) throw new Error("Existing release has unexpected contents; remove it before retrying.");
|
|
146
|
+
}
|
|
147
|
+
} else fs.renameSync(stage, release);
|
|
148
|
+
const result = spawnSync(process.execPath, [path.join(release, "install.cjs"), ...process.argv.slice(3)], { stdio: "inherit", env: { ...process.env, RUTTER_DIRECT_MEMORY_SERVER: base } });
|
|
149
|
+
if (result.error) throw result.error;
|
|
150
|
+
process.exitCode = result.status ?? 1;
|
|
151
|
+
} finally {
|
|
152
|
+
fs.rmSync(stage, { recursive: true, force: true });
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (require.main === module) main().catch((error) => {
|
|
156
|
+
console.error(error.message);
|
|
157
|
+
process.exitCode = 1;
|
|
158
|
+
});
|
|
159
|
+
module.exports = { baseUrl, download };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const http = require('http');
|
|
4
|
+
const https = require('https');
|
|
5
|
+
const readline = require('readline');
|
|
6
|
+
|
|
7
|
+
// A deadline includes DNS, connection, response headers AND the complete body.
|
|
8
|
+
// No redirects: a credential must never follow a server-controlled Location.
|
|
9
|
+
function request(url, options = {}) {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
let target;
|
|
12
|
+
try { target = new URL(url); } catch { reject(new Error('Invalid service URL')); return; }
|
|
13
|
+
if (!['http:', 'https:'].includes(target.protocol) || target.username || target.password) {
|
|
14
|
+
reject(new Error('Invalid service URL')); return;
|
|
15
|
+
}
|
|
16
|
+
const deadline = options.timeoutMs === undefined ? 15000 : options.timeoutMs;
|
|
17
|
+
const maxBytes = options.maxBytes === undefined ? 8 * 1024 * 1024 : options.maxBytes;
|
|
18
|
+
let timer, response, settled = false;
|
|
19
|
+
const finish = (error, value) => {
|
|
20
|
+
if (settled) return;
|
|
21
|
+
settled = true; clearTimeout(timer);
|
|
22
|
+
options.signal?.removeEventListener('abort', abort);
|
|
23
|
+
if (error) { response?.destroy(); req.destroy(); reject(error); } else resolve(value);
|
|
24
|
+
};
|
|
25
|
+
const abort = () => { const error = new Error('Request aborted'); error.name = 'AbortError'; finish(error); };
|
|
26
|
+
const req = (target.protocol === 'https:' ? https : http).request(target, {
|
|
27
|
+
method: options.method || 'GET', headers: options.headers, agent: false,
|
|
28
|
+
}, res => {
|
|
29
|
+
response = res;
|
|
30
|
+
if (res.statusCode >= 300 && res.statusCode < 400) { finish(new Error('Redirect refused')); return; }
|
|
31
|
+
let size = 0; const chunks = [];
|
|
32
|
+
res.on('data', chunk => {
|
|
33
|
+
size += chunk.length;
|
|
34
|
+
if (size > maxBytes) { finish(new Error('Response size limit exceeded')); return; }
|
|
35
|
+
chunks.push(chunk);
|
|
36
|
+
});
|
|
37
|
+
res.once('aborted', () => finish(new Error('Response interrupted')));
|
|
38
|
+
res.once('error', () => finish(new Error('Response interrupted')));
|
|
39
|
+
res.once('end', () => {
|
|
40
|
+
const body = Buffer.concat(chunks).toString('utf8');
|
|
41
|
+
finish(null, { status: res.statusCode, ok: res.statusCode >= 200 && res.statusCode < 300,
|
|
42
|
+
headers: { get: name => res.headers[String(name).toLowerCase()] || null },
|
|
43
|
+
text: async () => body, json: async () => JSON.parse(body),
|
|
44
|
+
arrayBuffer: async () => Buffer.concat(chunks) });
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
// Do not include URL, headers, credentials or response text in errors.
|
|
48
|
+
req.once('error', () => finish(new Error('Service connection failed')));
|
|
49
|
+
timer = setTimeout(() => { const error = new Error('Request deadline exceeded'); error.name = 'TimeoutError'; finish(error); }, deadline);
|
|
50
|
+
if (options.signal?.aborted) { abort(); return; }
|
|
51
|
+
options.signal?.addEventListener('abort', abort, { once: true });
|
|
52
|
+
req.end(options.body);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function createInterface(options) {
|
|
57
|
+
const rl = readline.createInterface(options);
|
|
58
|
+
return { question: prompt => new Promise(resolve => rl.question(prompt, resolve)), close: () => rl.close() };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = { request, createInterface, performance: require('perf_hooks').performance };
|