@alfe.ai/ai-proxy-local 0.0.1 → 0.0.2
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/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createProxyServer } from "./server.js";
|
|
3
|
-
import {
|
|
3
|
+
import { getAiServiceUrlFromToken, readConfig } from "@alfe.ai/config";
|
|
4
4
|
//#region src/cli.ts
|
|
5
5
|
/**
|
|
6
6
|
* CLI entry point for the local AI proxy.
|
|
@@ -30,7 +30,7 @@ async function main() {
|
|
|
30
30
|
let proxyUrl;
|
|
31
31
|
try {
|
|
32
32
|
apiKey = (await readConfig()).api_key;
|
|
33
|
-
proxyUrl =
|
|
33
|
+
proxyUrl = getAiServiceUrlFromToken(apiKey);
|
|
34
34
|
} catch (err) {
|
|
35
35
|
console.error(`[ai-proxy-local] Failed to read config: ${err instanceof Error ? err.message : err}`);
|
|
36
36
|
process.exit(1);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * CLI entry point for the local AI proxy.\n *\n * Reads the API key from ~/.alfe/config.toml, derives the ai-proxy URL\n * from the key prefix, and starts the proxy server.\n *\n * Usage:\n * alfe-ai-proxy [--port 18193]\n */\n\nimport { readConfig,
|
|
1
|
+
{"version":3,"file":"cli.js","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * CLI entry point for the local AI proxy.\n *\n * Reads the API key from ~/.alfe/config.toml, derives the ai-proxy URL\n * from the key prefix, and starts the proxy server.\n *\n * Usage:\n * alfe-ai-proxy [--port 18193]\n */\n\nimport { readConfig, getAiServiceUrlFromToken } from \"@alfe.ai/config\";\nimport { createProxyServer } from \"./server.js\";\n\nconst DEFAULT_PORT = 18193;\n\nfunction parsePort(args: string[]): number {\n const idx = args.indexOf(\"--port\");\n if (idx !== -1 && args[idx + 1]) {\n const port = parseInt(args[idx + 1], 10);\n if (Number.isNaN(port) || port < 1 || port > 65535) {\n console.error(`Invalid port: ${args[idx + 1]}`);\n process.exit(1);\n }\n return port;\n }\n return DEFAULT_PORT;\n}\n\nasync function main() {\n const port = parsePort(process.argv.slice(2));\n\n let apiKey: string;\n let proxyUrl: string;\n\n try {\n const cfg = await readConfig();\n apiKey = cfg.api_key;\n proxyUrl = getAiServiceUrlFromToken(apiKey);\n } catch (err) {\n console.error(\n `[ai-proxy-local] Failed to read config: ${err instanceof Error ? err.message : err}`,\n );\n process.exit(1);\n }\n\n const server = createProxyServer({ port, apiKey, proxyUrl });\n\n server.listen(port, \"127.0.0.1\", () => {\n console.log(`[ai-proxy-local] listening on http://127.0.0.1:${port}`);\n console.log(`[ai-proxy-local] forwarding to ${proxyUrl}`);\n });\n\n // Graceful shutdown\n for (const signal of [\"SIGINT\", \"SIGTERM\"] as const) {\n process.on(signal, () => {\n console.log(`[ai-proxy-local] received ${signal}, shutting down`);\n server.close(() => process.exit(0));\n });\n }\n}\n\nmain();\n"],"mappings":";;;;;;;;;;;;;AAeA,MAAM,eAAe;AAErB,SAAS,UAAU,MAAwB;CACzC,MAAM,MAAM,KAAK,QAAQ,SAAS;AAClC,KAAI,QAAQ,MAAM,KAAK,MAAM,IAAI;EAC/B,MAAM,OAAO,SAAS,KAAK,MAAM,IAAI,GAAG;AACxC,MAAI,OAAO,MAAM,KAAK,IAAI,OAAO,KAAK,OAAO,OAAO;AAClD,WAAQ,MAAM,iBAAiB,KAAK,MAAM,KAAK;AAC/C,WAAQ,KAAK,EAAE;;AAEjB,SAAO;;AAET,QAAO;;AAGT,eAAe,OAAO;CACpB,MAAM,OAAO,UAAU,QAAQ,KAAK,MAAM,EAAE,CAAC;CAE7C,IAAI;CACJ,IAAI;AAEJ,KAAI;AAEF,YADY,MAAM,YAAY,EACjB;AACb,aAAW,yBAAyB,OAAO;UACpC,KAAK;AACZ,UAAQ,MACN,2CAA2C,eAAe,QAAQ,IAAI,UAAU,MACjF;AACD,UAAQ,KAAK,EAAE;;CAGjB,MAAM,SAAS,kBAAkB;EAAE;EAAM;EAAQ;EAAU,CAAC;AAE5D,QAAO,OAAO,MAAM,mBAAmB;AACrC,UAAQ,IAAI,kDAAkD,OAAO;AACrE,UAAQ,IAAI,kCAAkC,WAAW;GACzD;AAGF,MAAK,MAAM,UAAU,CAAC,UAAU,UAAU,CACxC,SAAQ,GAAG,cAAc;AACvB,UAAQ,IAAI,6BAA6B,OAAO,iBAAiB;AACjE,SAAO,YAAY,QAAQ,KAAK,EAAE,CAAC;GACnC;;AAIN,MAAM"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfe.ai/ai-proxy-local",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"alfe-ai-proxy": "./dist/cli.js"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@auriclabs/logger": "^0.1.1",
|
|
21
|
-
"@alfe.ai/config": "^0.0.
|
|
21
|
+
"@alfe.ai/config": "^0.0.2"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "tsdown",
|