@khanglvm/ai-router 1.0.0 → 1.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanglvm/ai-router",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Generic AI Router Proxy (local + Cloudflare Worker)",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/cli-entry.js CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import path from "node:path";
4
+ import { realpathSync } from "node:fs";
3
5
  import { fileURLToPath } from "node:url";
4
6
  import { getDefaultConfigPath } from "./node/config-store.js";
5
7
  import { runStartCommand } from "./node/start-command.js";
@@ -102,12 +104,25 @@ export async function runCli(argv = process.argv.slice(2), isTTY = undefined) {
102
104
  return runStartFastPath(parsedStart.args);
103
105
  }
104
106
 
105
- const normalized = [...argv];
107
+ const normalized = [...argv];
106
108
  if (normalized[0] === "help") normalized[0] = "--help";
107
109
  return runSnapCli(normalized, isTTY);
108
110
  }
109
111
 
110
- const isMain = process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1];
112
+ function resolveExecutablePath(filePath) {
113
+ if (!filePath) return "";
114
+ try {
115
+ return realpathSync(filePath);
116
+ } catch {
117
+ return path.resolve(filePath);
118
+ }
119
+ }
120
+
121
+ const isMain = (() => {
122
+ const modulePath = resolveExecutablePath(fileURLToPath(import.meta.url));
123
+ const argvPath = resolveExecutablePath(process.argv[1]);
124
+ return Boolean(argvPath) && modulePath === argvPath;
125
+ })();
111
126
 
112
127
  if (isMain) {
113
128
  runCli()
package/wrangler.toml CHANGED
@@ -2,13 +2,16 @@ name = "ai-router-proxy"
2
2
  main = "src/index.js"
3
3
  compatibility_date = "2024-01-01"
4
4
 
5
+ # No custom routes are defined by default.
6
+ # Configure routes/domains per environment in your own deployment setup.
7
+
5
8
  # Optional non-secret vars
6
9
  [vars]
7
10
  ENVIRONMENT = "production"
8
11
 
9
12
  # Required secret(s):
10
13
  # AI_ROUTER_CONFIG_JSON - All-in-one JSON config exported by:
11
- # npx ai-router-proxy worker-export --out=.ai-router.worker.json
14
+ # ai-router deploy --export-only=true --out=.ai-router.worker.json
12
15
  # wrangler secret put AI_ROUTER_CONFIG_JSON < .ai-router.worker.json
13
16
  #
14
17
  # Optional override: