responses-proxy 0.1.0 → 0.1.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/cli.js +27 -0
- package/dist/package.json +1 -0
- package/hooks/postinstall.js +43 -0
- package/package.json +3 -1
package/cli.js
CHANGED
|
@@ -61,6 +61,23 @@ if (!fs.existsSync(serverPath)) {
|
|
|
61
61
|
process.exit(1);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
// Check if deps are installed
|
|
65
|
+
const nodeModulesPath = path.join(__dirname, "dist", "node_modules");
|
|
66
|
+
if (!fs.existsSync(path.join(nodeModulesPath, "fastify"))) {
|
|
67
|
+
console.log("📦 Runtime deps missing. Installing...");
|
|
68
|
+
const { execSync } = require("child_process");
|
|
69
|
+
try {
|
|
70
|
+
execSync("npm install --omit=dev --no-audit --no-fund --loglevel=error", {
|
|
71
|
+
cwd: path.join(__dirname, "dist"),
|
|
72
|
+
stdio: "inherit",
|
|
73
|
+
timeout: 120000,
|
|
74
|
+
});
|
|
75
|
+
} catch {
|
|
76
|
+
console.error("Failed to install deps. Run: cd " + path.join(__dirname, "dist") + " && npm install --omit=dev");
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
64
81
|
// Data directory
|
|
65
82
|
const dataDir = path.join(os.homedir(), ".responses-proxy");
|
|
66
83
|
fs.mkdirSync(path.join(dataDir, "sessions"), { recursive: true });
|
|
@@ -83,12 +100,22 @@ const server = spawn(process.execPath, [serverPath], {
|
|
|
83
100
|
stdio: "inherit",
|
|
84
101
|
env: {
|
|
85
102
|
...process.env,
|
|
103
|
+
NODE_PATH: nodeModulesPath,
|
|
86
104
|
PORT: String(port),
|
|
87
105
|
HOST: host,
|
|
106
|
+
UPSTREAM_BASE_URL: process.env.UPSTREAM_BASE_URL || "https://placeholder.invalid",
|
|
107
|
+
UPSTREAM_API_KEY: process.env.UPSTREAM_API_KEY || "",
|
|
88
108
|
APP_DB_PATH: path.join(dataDir, "app.sqlite"),
|
|
89
109
|
SESSION_LOG_DIR: path.join(dataDir, "sessions"),
|
|
90
110
|
CUSTOMER_KEY_DB_PATH: path.join(dataDir, "telegram-bot.sqlite"),
|
|
91
111
|
KIRO_DB_PATH: path.join(dataDir, "kiro.sqlite"),
|
|
112
|
+
KIRO_ENABLED: process.env.KIRO_ENABLED || "false",
|
|
113
|
+
QUICK_APPLY_HERMES_CONFIG_PATH: path.join(os.homedir(), ".hermes", "config.yaml"),
|
|
114
|
+
QUICK_APPLY_CODEX_CONFIG_PATH: path.join(os.homedir(), ".codex", "config.toml"),
|
|
115
|
+
QUICK_APPLY_CODEX_AUTH_PATH: path.join(os.homedir(), ".codex", "auth.json"),
|
|
116
|
+
TELEGRAM_BOT_TOKEN: "",
|
|
117
|
+
TELEGRAM_OWNER_USER_IDS: "",
|
|
118
|
+
TELEGRAM_ADMIN_USER_IDS: "",
|
|
92
119
|
},
|
|
93
120
|
});
|
|
94
121
|
|
package/dist/package.json
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* postinstall hook — installs production dependencies into dist/node_modules
|
|
4
|
+
* so the server can resolve fastify, better-sqlite3, etc. at runtime.
|
|
5
|
+
*
|
|
6
|
+
* Similar to 9Router's hooks/postinstall.js that installs sql.js into ~/.9router/runtime/
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const { execSync } = require("child_process");
|
|
10
|
+
const path = require("path");
|
|
11
|
+
const fs = require("fs");
|
|
12
|
+
|
|
13
|
+
const DIST_DIR = path.join(__dirname, "..", "dist");
|
|
14
|
+
const PKG_PATH = path.join(DIST_DIR, "package.json");
|
|
15
|
+
|
|
16
|
+
// Only run if dist/package.json exists (skip if just cloning the repo)
|
|
17
|
+
if (!fs.existsSync(PKG_PATH)) {
|
|
18
|
+
process.exit(0);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Check if node_modules already exists and has fastify
|
|
22
|
+
const fastifyPath = path.join(DIST_DIR, "node_modules", "fastify");
|
|
23
|
+
if (fs.existsSync(fastifyPath)) {
|
|
24
|
+
// Already installed
|
|
25
|
+
process.exit(0);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
console.log("📦 Installing responses-proxy runtime dependencies...");
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
execSync("npm install --omit=dev --no-audit --no-fund --loglevel=error", {
|
|
32
|
+
cwd: DIST_DIR,
|
|
33
|
+
stdio: "inherit",
|
|
34
|
+
timeout: 120000,
|
|
35
|
+
});
|
|
36
|
+
console.log("✅ Runtime dependencies installed successfully.");
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.error("⚠️ Failed to install runtime dependencies.");
|
|
39
|
+
console.error(" You may need to run manually:");
|
|
40
|
+
console.error(` cd ${DIST_DIR} && npm install --omit=dev`);
|
|
41
|
+
// Don't fail the install — the user can fix it manually
|
|
42
|
+
process.exit(0);
|
|
43
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "responses-proxy",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "AI routing proxy with multi-provider fallback, RTK token saver, and web dashboard",
|
|
5
5
|
"bin": {
|
|
6
6
|
"responses-proxy": "./cli.js"
|
|
@@ -8,11 +8,13 @@
|
|
|
8
8
|
"files": [
|
|
9
9
|
"cli.js",
|
|
10
10
|
"dist",
|
|
11
|
+
"hooks",
|
|
11
12
|
"README.md",
|
|
12
13
|
"LICENSE"
|
|
13
14
|
],
|
|
14
15
|
"scripts": {
|
|
15
16
|
"build": "node scripts/build-cli.js",
|
|
17
|
+
"postinstall": "node hooks/postinstall.js",
|
|
16
18
|
"prepublishOnly": "npm run build"
|
|
17
19
|
},
|
|
18
20
|
"engines": {
|