@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.
Files changed (66) hide show
  1. package/LICENSE +27 -0
  2. package/README.md +80 -2
  3. package/THIRD_PARTY_LICENSES.txt +111 -0
  4. package/bin/cli.cjs +94 -0
  5. package/bin/npm-runtime.cjs +125 -0
  6. package/client/darwin-arm64/bootstrap.cjs +159 -0
  7. package/client/darwin-arm64/compat.cjs +61 -0
  8. package/client/darwin-arm64/hook.cjs +597 -0
  9. package/client/darwin-arm64/install.cjs +555 -0
  10. package/client/darwin-arm64/manifest.json +1 -0
  11. package/client/darwin-arm64/mcp.cjs +5666 -0
  12. package/client/darwin-arm64/migration.cjs +53 -0
  13. package/client/darwin-arm64/node_sqlite3.node +0 -0
  14. package/client/darwin-arm64/ordered-upload.cjs +236 -0
  15. package/client/darwin-arm64/outbox.cjs +218 -0
  16. package/client/darwin-arm64/recovery.cjs +61 -0
  17. package/client/darwin-arm64/sqlite3.cjs +217 -0
  18. package/client/darwin-arm64/transcript.cjs +138 -0
  19. package/client/darwin-arm64/upload.cjs +446 -0
  20. package/client/darwin-arm64/worker.cjs +76 -0
  21. package/client/darwin-x64/bootstrap.cjs +159 -0
  22. package/client/darwin-x64/compat.cjs +61 -0
  23. package/client/darwin-x64/hook.cjs +597 -0
  24. package/client/darwin-x64/install.cjs +555 -0
  25. package/client/darwin-x64/manifest.json +1 -0
  26. package/client/darwin-x64/mcp.cjs +5666 -0
  27. package/client/darwin-x64/migration.cjs +53 -0
  28. package/client/darwin-x64/node_sqlite3.node +0 -0
  29. package/client/darwin-x64/ordered-upload.cjs +236 -0
  30. package/client/darwin-x64/outbox.cjs +218 -0
  31. package/client/darwin-x64/recovery.cjs +61 -0
  32. package/client/darwin-x64/sqlite3.cjs +217 -0
  33. package/client/darwin-x64/transcript.cjs +138 -0
  34. package/client/darwin-x64/upload.cjs +446 -0
  35. package/client/darwin-x64/worker.cjs +76 -0
  36. package/client/linux-x64-glibc/bootstrap.cjs +159 -0
  37. package/client/linux-x64-glibc/compat.cjs +61 -0
  38. package/client/linux-x64-glibc/hook.cjs +597 -0
  39. package/client/linux-x64-glibc/install.cjs +555 -0
  40. package/client/linux-x64-glibc/manifest.json +1 -0
  41. package/client/linux-x64-glibc/mcp.cjs +5666 -0
  42. package/client/linux-x64-glibc/migration.cjs +53 -0
  43. package/client/linux-x64-glibc/node_sqlite3.node +0 -0
  44. package/client/linux-x64-glibc/ordered-upload.cjs +236 -0
  45. package/client/linux-x64-glibc/outbox.cjs +218 -0
  46. package/client/linux-x64-glibc/recovery.cjs +61 -0
  47. package/client/linux-x64-glibc/sqlite3.cjs +217 -0
  48. package/client/linux-x64-glibc/transcript.cjs +138 -0
  49. package/client/linux-x64-glibc/upload.cjs +446 -0
  50. package/client/linux-x64-glibc/worker.cjs +76 -0
  51. package/client/win32-x64/bootstrap.cjs +159 -0
  52. package/client/win32-x64/compat.cjs +61 -0
  53. package/client/win32-x64/hook.cjs +597 -0
  54. package/client/win32-x64/install.cjs +555 -0
  55. package/client/win32-x64/manifest.json +1 -0
  56. package/client/win32-x64/mcp.cjs +5666 -0
  57. package/client/win32-x64/migration.cjs +53 -0
  58. package/client/win32-x64/node_sqlite3.node +0 -0
  59. package/client/win32-x64/ordered-upload.cjs +236 -0
  60. package/client/win32-x64/outbox.cjs +218 -0
  61. package/client/win32-x64/recovery.cjs +61 -0
  62. package/client/win32-x64/sqlite3.cjs +217 -0
  63. package/client/win32-x64/transcript.cjs +138 -0
  64. package/client/win32-x64/upload.cjs +446 -0
  65. package/client/win32-x64/worker.cjs +76 -0
  66. package/package.json +34 -4
@@ -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 };