@cartanova/qgrid-cli 0.1.1 → 1.0.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/bundle/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.js +9 -0
- package/bundle/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/decorateMetadata.js +6 -0
- package/bundle/dist/_virtual/_rolldown/runtime.js +15 -0
- package/bundle/dist/application/qgrid/oauth.js +140 -0
- package/bundle/dist/application/qgrid/pool.js +100 -0
- package/bundle/dist/application/qgrid/qgrid.frame.js +280 -0
- package/bundle/dist/application/qgrid/qgrid.types.js +79 -0
- package/bundle/dist/application/qgrid/worker.js +183 -0
- package/bundle/dist/application/queries.generated.js +31 -0
- package/bundle/dist/application/request-log/request-log.model.js +113 -0
- package/bundle/dist/application/request-log/request-log.types.js +13 -0
- package/bundle/dist/application/sonamu.generated.js +99 -0
- package/bundle/dist/application/sonamu.generated.sso.js +34 -0
- package/bundle/dist/application/token/token.model.js +157 -0
- package/bundle/dist/application/token/token.types.js +22 -0
- package/bundle/dist/i18n/en.js +63 -0
- package/bundle/dist/i18n/ko.js +62 -0
- package/bundle/dist/i18n/sd.generated.js +272 -0
- package/bundle/dist/index.js +11 -0
- package/bundle/dist/migrations/20260410171405_create__request_logs.js +26 -0
- package/bundle/dist/migrations/20260410171406_create__tokens.js +24 -0
- package/bundle/dist/migrations/20260411120624_alter_tokens_alter2.js +16 -0
- package/bundle/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js +155 -0
- package/bundle/dist/node_modules/.pnpm/@vitest_expect@4.1.2/node_modules/@vitest/expect/dist/index.js +1484 -0
- package/bundle/dist/node_modules/.pnpm/@vitest_pretty-format@4.1.2/node_modules/@vitest/pretty-format/dist/index.js +887 -0
- package/bundle/dist/node_modules/.pnpm/@vitest_runner@4.1.2/node_modules/@vitest/runner/dist/chunk-artifact.js +2746 -0
- package/bundle/dist/node_modules/.pnpm/@vitest_runner@4.1.2/node_modules/@vitest/runner/dist/index.js +8 -0
- package/bundle/dist/node_modules/.pnpm/@vitest_runner@4.1.2/node_modules/@vitest/runner/dist/utils.js +8 -0
- package/bundle/dist/node_modules/.pnpm/@vitest_snapshot@4.1.2/node_modules/@vitest/snapshot/dist/index.js +662 -0
- package/bundle/dist/node_modules/.pnpm/@vitest_spy@4.1.2/node_modules/@vitest/spy/dist/index.js +386 -0
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js +82 -0
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/constants.js +48 -0
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/diff.js +1307 -0
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/display.js +558 -0
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/error.js +33 -0
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/helpers.js +226 -0
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/offset.js +27 -0
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/serialize.js +77 -0
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/source-map.js +374 -0
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/timers.js +37 -0
- package/bundle/dist/node_modules/.pnpm/chai@6.2.2/node_modules/chai/index.js +2886 -0
- package/bundle/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/branding.js +10 -0
- package/bundle/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/index.js +109 -0
- package/bundle/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/messages.js +10 -0
- package/bundle/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/overloads.js +10 -0
- package/bundle/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/utils.js +10 -0
- package/bundle/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.js +1127 -0
- package/bundle/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.js +21 -0
- package/bundle/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.js +432 -0
- package/bundle/dist/node_modules/.pnpm/tinybench@2.9.0/node_modules/tinybench/dist/index.js +506 -0
- package/bundle/dist/node_modules/.pnpm/tinyrainbow@3.1.0/node_modules/tinyrainbow/dist/index.js +86 -0
- package/bundle/dist/node_modules/.pnpm/vite@8.0.3_@emnapi_core@1.9.2_@emnapi_runtime@1.9.2_@types_node@25.0.7_esbuild@0.27.4_jiti@2.6.1_sass@1.98.0_tsx@4.21.0/node_modules/vite/dist/node/module-runner.js +426 -0
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js +6 -0
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/chunks/benchmark.CX_oY03V.js +41 -0
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/chunks/evaluatedModules.Dg1zASAC.js +19 -0
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/chunks/index.Chj8NDwU.js +202 -0
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/chunks/index.DOa3dzoN.js +16 -0
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/chunks/rpc.MzXet3jl.js +59 -0
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/chunks/test.p_J6dB8a.js +2910 -0
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.js +44 -0
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/index.js +28 -0
- package/bundle/dist/sonamu.config.js +196 -0
- package/bundle/dist/testing/fixture.js +8 -0
- package/bundle/dist/testing/global.js +9 -0
- package/bundle/dist/testing/setup-mocks.js +17 -0
- package/bundle/dist/utils/subset-loaders.js +12 -0
- package/bundle/src/application/request-log/request-log.entity.json +75 -0
- package/bundle/src/application/token/token.entity.json +37 -0
- package/bundle/src/migrations/20260410171405_create__request_logs.ts +23 -0
- package/bundle/src/migrations/20260410171406_create__tokens.ts +21 -0
- package/bundle/src/migrations/20260411120624_alter_tokens_alter2.ts +15 -0
- package/bundle/web-dist/client/assets/index-DlPchHBY.js +116 -0
- package/bundle/web-dist/client/assets/index-vZsvyuFn.css +1 -0
- package/bundle/web-dist/client/assets/rolldown-runtime-Dw2cE7zH.js +1 -0
- package/bundle/web-dist/client/assets/routes-CagDz23B.js +1 -0
- package/bundle/web-dist/client/assets/sd.generated-BrQoQXvv.js +47 -0
- package/bundle/web-dist/client/assets/services.generated-BspO2L0j.js +1 -0
- package/bundle/web-dist/client/assets/show-aXUGa0gm.js +29 -0
- package/bundle/web-dist/client/assets/tokens-DRkXtZ3Q.js +1 -0
- package/bundle/web-dist/client/assets/vendor-react-DH4kUfK2.js +9 -0
- package/bundle/web-dist/client/assets/vendor-tanstack-CUxlo6YN.js +1 -0
- package/bundle/web-dist/client/index.html +18 -0
- package/bundle/web-dist/server/assets/react-dom-CGIzOSuj.js +335 -0
- package/bundle/web-dist/server/assets/routes-ClzReRep.js +490 -0
- package/bundle/web-dist/server/assets/sd.generated-BnonqqKr.js +21694 -0
- package/bundle/web-dist/server/assets/services.generated-D5ABD5fr.js +836 -0
- package/bundle/web-dist/server/assets/show-C9pcdSxc.js +23364 -0
- package/bundle/web-dist/server/assets/tokens-JH6FsnWZ.js +860 -0
- package/bundle/web-dist/server/entry-server.generated.js +44646 -0
- package/dist/cli.js +38 -89
- package/package.json +39 -12
package/dist/cli.js
CHANGED
|
@@ -1,106 +1,55 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { execSync } from "node:child_process";
|
|
3
|
-
import { existsSync,
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { Command } from "commander";
|
|
7
7
|
//#region src/cli.ts
|
|
8
|
-
const QGRID_DIR = join(homedir(), ".qgrid");
|
|
9
|
-
const COMPOSE_FILE = join(QGRID_DIR, "docker-compose.yml");
|
|
10
|
-
const IMAGE = "ghcr.io/cartanova-ai/qgrid:latest";
|
|
11
|
-
function ensureDocker() {
|
|
12
|
-
try {
|
|
13
|
-
execSync("docker --version", { stdio: "ignore" });
|
|
14
|
-
} catch {
|
|
15
|
-
console.error("Error: Docker not found.");
|
|
16
|
-
console.error("Install: https://docs.docker.com/get-docker/");
|
|
17
|
-
process.exit(1);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function ensureQgridDir() {
|
|
21
|
-
if (!existsSync(QGRID_DIR)) mkdirSync(QGRID_DIR, { recursive: true });
|
|
22
|
-
}
|
|
23
|
-
function generateCompose(opts) {
|
|
24
|
-
const env = [
|
|
25
|
-
` DB_HOST: "${opts.dbHost ?? "postgres"}"`,
|
|
26
|
-
` DB_PORT: "${opts.dbHost ? opts.dbPort : "5432"}"`,
|
|
27
|
-
` DB_USER: "${opts.dbUser}"`,
|
|
28
|
-
` DB_PASSWORD: "${opts.dbPassword}"`,
|
|
29
|
-
` DB_NAME: "qgrid"`,
|
|
30
|
-
` HOST: "0.0.0.0"`,
|
|
31
|
-
` PORT: "${opts.port}"`
|
|
32
|
-
].join("\n");
|
|
33
|
-
let compose = `services:
|
|
34
|
-
qgrid:
|
|
35
|
-
image: ${IMAGE}
|
|
36
|
-
ports:
|
|
37
|
-
- "${opts.port}:${opts.port}"
|
|
38
|
-
environment:
|
|
39
|
-
${env}
|
|
40
|
-
restart: unless-stopped`;
|
|
41
|
-
if (!opts.dbHost) compose += `
|
|
42
|
-
depends_on:
|
|
43
|
-
postgres:
|
|
44
|
-
condition: service_healthy
|
|
45
|
-
|
|
46
|
-
postgres:
|
|
47
|
-
image: postgres:18
|
|
48
|
-
ports:
|
|
49
|
-
- "${opts.dbPort}:5432"
|
|
50
|
-
environment:
|
|
51
|
-
POSTGRES_USER: ${opts.dbUser}
|
|
52
|
-
POSTGRES_PASSWORD: ${opts.dbPassword}
|
|
53
|
-
POSTGRES_DB: qgrid
|
|
54
|
-
healthcheck:
|
|
55
|
-
test: ["CMD-SHELL", "pg_isready"]
|
|
56
|
-
interval: 3s
|
|
57
|
-
retries: 5
|
|
58
|
-
volumes:
|
|
59
|
-
- qgrid-data:/var/lib/postgresql
|
|
60
|
-
|
|
61
|
-
volumes:
|
|
62
|
-
qgrid-data:`;
|
|
63
|
-
return `${compose}\n`;
|
|
64
|
-
}
|
|
65
8
|
const program = new Command();
|
|
66
9
|
program.name("qgrid").version("0.1.0").description("Qgrid — LLM subscription token proxy server");
|
|
67
|
-
|
|
68
|
-
ensureDocker();
|
|
69
|
-
ensureQgridDir();
|
|
70
|
-
writeFileSync(COMPOSE_FILE, generateCompose(opts));
|
|
71
|
-
console.log(opts.dbHost ? "Starting Qgrid server (external DB)..." : "Starting Qgrid server + PostgreSQL...");
|
|
10
|
+
function checkCommand(cmd) {
|
|
72
11
|
try {
|
|
73
|
-
execSync(
|
|
74
|
-
|
|
12
|
+
execSync(`${cmd} --version`, { stdio: "ignore" });
|
|
13
|
+
return true;
|
|
75
14
|
} catch {
|
|
76
|
-
|
|
77
|
-
process.exit(1);
|
|
15
|
+
return false;
|
|
78
16
|
}
|
|
79
|
-
}
|
|
80
|
-
program.command("
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
17
|
+
}
|
|
18
|
+
program.command("start").description("Start Qgrid server").option("-p, --port <port>", "server port (overrides .env)").action(async (opts) => {
|
|
19
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
20
|
+
const envPath = join(process.cwd(), ".env");
|
|
21
|
+
if (existsSync(envPath)) {
|
|
22
|
+
const envContent = readFileSync(envPath, "utf-8");
|
|
23
|
+
for (const line of envContent.split("\n")) {
|
|
24
|
+
const trimmed = line.trim();
|
|
25
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
26
|
+
const eqIdx = trimmed.indexOf("=");
|
|
27
|
+
if (eqIdx === -1) continue;
|
|
28
|
+
const key = trimmed.slice(0, eqIdx).trim();
|
|
29
|
+
const value = trimmed.slice(eqIdx + 1).trim();
|
|
30
|
+
if (key.startsWith("QGRID_") && !process.env[key]) process.env[key] = value;
|
|
31
|
+
}
|
|
85
32
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
console.
|
|
89
|
-
|
|
90
|
-
console.error("Failed to stop.");
|
|
33
|
+
if (opts.port) process.env.PORT = opts.port;
|
|
34
|
+
if (!checkCommand("claude")) {
|
|
35
|
+
console.error("Error: claude CLI not found.");
|
|
36
|
+
console.error("Install: npm i -g @anthropic-ai/claude-code");
|
|
91
37
|
process.exit(1);
|
|
92
38
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (!existsSync(
|
|
97
|
-
console.
|
|
98
|
-
|
|
39
|
+
process.env.LR = "remote";
|
|
40
|
+
const bundlePath = join(__dirname, "..", "bundle");
|
|
41
|
+
const serverEntry = join(bundlePath, "dist", "index.js");
|
|
42
|
+
if (!existsSync(serverEntry)) {
|
|
43
|
+
console.error(`Error: Server bundle not found at ${serverEntry}`);
|
|
44
|
+
console.error("Run `pnpm run bundle` first, or reinstall @qgrid/cli.");
|
|
45
|
+
process.exit(1);
|
|
99
46
|
}
|
|
47
|
+
process.env.INIT_CWD = bundlePath;
|
|
100
48
|
try {
|
|
101
|
-
|
|
102
|
-
} catch {
|
|
103
|
-
console.
|
|
49
|
+
await import(serverEntry);
|
|
50
|
+
} catch (e) {
|
|
51
|
+
console.error("Failed to start server:", e.stack ?? e.message);
|
|
52
|
+
process.exit(1);
|
|
104
53
|
}
|
|
105
54
|
});
|
|
106
55
|
program.parse();
|
package/package.json
CHANGED
|
@@ -1,26 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cartanova/qgrid-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/cartanova-ai/qgrid"
|
|
7
|
+
},
|
|
4
8
|
"bin": {
|
|
5
|
-
"qgrid": "dist/cli.js"
|
|
9
|
+
"qgrid": "./dist/cli.js"
|
|
6
10
|
},
|
|
7
11
|
"files": [
|
|
8
|
-
"dist"
|
|
12
|
+
"dist",
|
|
13
|
+
"bundle"
|
|
9
14
|
],
|
|
10
15
|
"type": "module",
|
|
11
|
-
"scripts": {
|
|
12
|
-
"build": "tsdown",
|
|
13
|
-
"prepublishOnly": "pnpm run build"
|
|
14
|
-
},
|
|
15
16
|
"dependencies": {
|
|
16
|
-
"
|
|
17
|
+
"@ai-sdk/anthropic": "^3.0.0",
|
|
18
|
+
"@ai-sdk/openai": "^3.0.0",
|
|
19
|
+
"@ai-sdk/provider": "^3.0.0",
|
|
20
|
+
"@ai-sdk/provider-utils": "^4.0.0",
|
|
21
|
+
"@anthropic-ai/sdk": "^0.81.0",
|
|
22
|
+
"@better-auth/passkey": "~1.6.0",
|
|
23
|
+
"@better-auth/sso": "~1.6.0",
|
|
24
|
+
"@logtape/logtape": "2.0.0",
|
|
25
|
+
"@logtape/pretty": "2.0.0",
|
|
26
|
+
"@logtape/redaction": "2.0.0",
|
|
27
|
+
"@oxc-project/runtime": "^0.79.0",
|
|
28
|
+
"ai": "^6.0.1",
|
|
29
|
+
"bcrypt": "^6.0.0",
|
|
30
|
+
"better-auth": "^1.6.0",
|
|
31
|
+
"chalk": "^4.1.2",
|
|
32
|
+
"commander": "^13.0.0",
|
|
33
|
+
"date-fns": "^4.1.0",
|
|
34
|
+
"dotenv": "^16",
|
|
35
|
+
"knex": "^3.1.0",
|
|
36
|
+
"pg": "^8.16.3",
|
|
37
|
+
"radashi": "^12.2.0",
|
|
38
|
+
"sonamu": "^0.9.2",
|
|
39
|
+
"zod": "^4.3.6"
|
|
17
40
|
},
|
|
18
41
|
"devDependencies": {
|
|
19
|
-
"@types/node": "
|
|
20
|
-
"tsdown": "
|
|
21
|
-
"typescript": "
|
|
42
|
+
"@types/node": "25.0.7",
|
|
43
|
+
"tsdown": "^0.12.9",
|
|
44
|
+
"typescript": "^5.9.3"
|
|
22
45
|
},
|
|
23
46
|
"engines": {
|
|
24
47
|
"node": ">=20"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"bundle": "cd ../api && pnpm build && cd ../cli && mkdir -p bundle/public && cp -r ../api/dist ./bundle/dist && cp -r ../api/web-dist ./bundle/web-dist && mkdir -p ./bundle/src/migrations && cp ../api/src/migrations/*.ts ./bundle/src/migrations/ && cd ../api && find src -name '*.entity.json' -exec sh -c 'dest=../cli/bundle/$(echo {}) && mkdir -p $(dirname $dest) && cp {} $dest' \\;",
|
|
51
|
+
"build": "tsdown"
|
|
25
52
|
}
|
|
26
|
-
}
|
|
53
|
+
}
|