mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 04:59:37 +08:00
Replaces the oauth_cli_kit indirection with DeepTutor's own PKCE loopback sign-in, an account-scoped live model catalog, and a Settings card that exposes only the OAuth surface. Credentials live in `<user-root>/private/openai-codex/` with owner-only permissions, atomic writes, and a generation guard that stops a late refresh from resurrecting a signed-out session; `~/.codex` is never read or modified. A CLI path shares the same service. A Codex token authorizes one person's ChatGPT plan, so credentials anchor to the signing-in account's own root and the managed profile is marked `owner_bound`: `redacted_model_access` drops it for every caller, and it is not offered as an assignable model. Signing in publishes the profile but only activates it when no LLM is configured yet, so it never repoints a deployment that already has one. Also from review: reschedule the status poll so one dropped response cannot strand the card on "waiting"; defer the catalog reload when the operator has unsaved edits instead of discarding them; log the real cause behind the generic provider error; stop promising a retry when the token refresh actually failed; bind both loopback stacks since `localhost` may resolve to either; and drop the provider metadata fields nothing consumed.
61 lines
1.5 KiB
JavaScript
61 lines
1.5 KiB
JavaScript
import { readdirSync, rmSync, statSync } from "node:fs";
|
|
import { spawnSync } from "node:child_process";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
const webRoot = path.resolve(__dirname, "..");
|
|
const distRoot = path.join(webRoot, "dist", "node-tests");
|
|
const testRoot = path.join(distRoot, "tests");
|
|
|
|
function run(cmd, args) {
|
|
const result = spawnSync(cmd, args, {
|
|
cwd: webRoot,
|
|
stdio: "inherit",
|
|
env: process.env,
|
|
});
|
|
if (result.status !== 0) {
|
|
process.exit(result.status ?? 1);
|
|
}
|
|
}
|
|
|
|
function collectTests(dir) {
|
|
const entries = readdirSync(dir)
|
|
.map((name) => path.join(dir, name))
|
|
.sort((a, b) => a.localeCompare(b));
|
|
const files = [];
|
|
for (const entry of entries) {
|
|
const stats = statSync(entry);
|
|
if (stats.isDirectory()) {
|
|
files.push(...collectTests(entry));
|
|
continue;
|
|
}
|
|
if (entry.endsWith(".test.js")) {
|
|
files.push(entry);
|
|
}
|
|
}
|
|
return files;
|
|
}
|
|
|
|
rmSync(distRoot, { recursive: true, force: true });
|
|
|
|
run(process.execPath, [
|
|
path.join(webRoot, "node_modules", "typescript", "bin", "tsc"),
|
|
"-p",
|
|
"tsconfig.node-tests.json",
|
|
]);
|
|
|
|
const testFiles = collectTests(testRoot);
|
|
if (testFiles.length === 0) {
|
|
console.error("No compiled node tests found.");
|
|
process.exit(1);
|
|
}
|
|
|
|
run(process.execPath, [
|
|
"-r",
|
|
"./scripts/register-node-test-aliases.cjs",
|
|
"--test",
|
|
...testFiles,
|
|
]);
|