ai-zero-token 2.0.6 → 2.0.8
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/CHANGELOG.md +19 -1
- package/README.md +5 -5
- package/README.zh-CN.md +5 -5
- package/admin-ui/dist/assets/accounts-p9bqmijS.js +4 -0
- package/admin-ui/dist/assets/{docs--eK_2fzC.js → docs-BQaF_ZMr.js} +1 -1
- package/admin-ui/dist/assets/{image-bed-7wBZ1GhS.js → image-bed-D4w1m7k6.js} +1 -1
- package/admin-ui/dist/assets/index-BRQrU_AA.css +1 -0
- package/admin-ui/dist/assets/{index-CdFYy5j6.js → index-_5Ny0cZf.js} +3 -3
- package/admin-ui/dist/assets/{launch-BiD1Khtg.js → launch-BEDxgkQf.js} +1 -1
- package/admin-ui/dist/assets/{logs-BdoKDqh2.js → logs-BcL0n0Ld.js} +1 -1
- package/admin-ui/dist/assets/{network-detect-BvKns5nQ.js → network-detect-lEfklmIy.js} +1 -1
- package/admin-ui/dist/assets/{overview-wm6M45fu.js → overview-DsUMffIU.js} +1 -1
- package/admin-ui/dist/assets/{profiles-DMOjJORP.js → profiles-C5SmQvju.js} +1 -1
- package/admin-ui/dist/assets/settings-a3HxExcC.js +8 -0
- package/admin-ui/dist/assets/{tester-NrARmlis.js → tester-Ca4JOgAq.js} +1 -1
- package/admin-ui/dist/assets/usage-hMH0gMZ5.js +1 -0
- package/admin-ui/dist/index.html +3 -3
- package/dist/cli/commands/help.js +1 -1
- package/dist/cli/commands/models.js +3 -2
- package/dist/core/context.js +1 -1
- package/dist/core/models/openai-codex-models.js +106 -1
- package/dist/core/providers/http-client.js +142 -12
- package/dist/core/providers/openai-codex/chat.js +139 -8
- package/dist/core/services/auth-service.js +104 -7
- package/dist/core/services/chat-service.js +16 -18
- package/dist/core/services/model-service.js +22 -8
- package/dist/core/services/usage-service.js +402 -31
- package/dist/core/store/codex-auth-store.js +82 -7
- package/dist/server/app.js +410 -34
- package/dist/server/index.js +1 -1
- package/docs/API_USAGE.md +1 -1
- package/docs/DESKTOP_RELEASE.md +12 -1
- package/package.json +1 -1
- package/admin-ui/dist/assets/accounts-bCDKXGg9.js +0 -4
- package/admin-ui/dist/assets/index-C22_3Mxq.css +0 -1
- package/admin-ui/dist/assets/settings-DOOu7Kd8.js +0 -5
- package/admin-ui/dist/assets/usage-CdWRVMDV.js +0 -1
|
@@ -48,10 +48,71 @@ function sqliteQuote(value) {
|
|
|
48
48
|
async function runSqlite(dbPath, sql) {
|
|
49
49
|
const { stdout } = await execFileAsync("sqlite3", [dbPath, sql], {
|
|
50
50
|
timeout: 15e3,
|
|
51
|
-
maxBuffer: 1024 * 1024
|
|
51
|
+
maxBuffer: 8 * 1024 * 1024
|
|
52
52
|
});
|
|
53
53
|
return stdout.trim();
|
|
54
54
|
}
|
|
55
|
+
function resolveCodexSessionPath(value) {
|
|
56
|
+
return path.isAbsolute(value) ? value : path.join(getCodexHomeDir(), value);
|
|
57
|
+
}
|
|
58
|
+
function parseLegacyHistoryThreadRows(raw) {
|
|
59
|
+
if (!raw.trim()) {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
return raw.split(/\r?\n/).map((line) => {
|
|
63
|
+
const separator = line.indexOf(" ");
|
|
64
|
+
if (separator === -1) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
const id = line.slice(0, separator).trim();
|
|
68
|
+
const rolloutPath = line.slice(separator + 1).trim();
|
|
69
|
+
return id && rolloutPath ? { id, rolloutPath } : null;
|
|
70
|
+
}).filter((item) => Boolean(item));
|
|
71
|
+
}
|
|
72
|
+
async function patchSessionRolloutProvider(rolloutPath, backupSuffix, fromProvider, toProvider) {
|
|
73
|
+
const targetPath = resolveCodexSessionPath(rolloutPath);
|
|
74
|
+
let raw = "";
|
|
75
|
+
try {
|
|
76
|
+
raw = await fs.readFile(targetPath, "utf8");
|
|
77
|
+
} catch (error) {
|
|
78
|
+
if (error && typeof error === "object" && error.code === "ENOENT") {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
const newline = raw.includes("\r\n") ? "\r\n" : "\n";
|
|
84
|
+
const trailingNewline = raw.endsWith("\n");
|
|
85
|
+
const lines = raw.replace(/\r?\n$/u, "").split(/\r?\n/u);
|
|
86
|
+
let changed = false;
|
|
87
|
+
for (let index = 0; index < Math.min(lines.length, 20); index += 1) {
|
|
88
|
+
try {
|
|
89
|
+
const parsed = JSON.parse(lines[index] ?? "");
|
|
90
|
+
if (!isRecord(parsed) || parsed.type !== "session_meta" || !isRecord(parsed.payload)) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (parsed.payload.model_provider !== fromProvider) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
parsed.payload.model_provider = toProvider;
|
|
97
|
+
lines[index] = JSON.stringify(parsed);
|
|
98
|
+
changed = true;
|
|
99
|
+
break;
|
|
100
|
+
} catch {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (!changed) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
await fs.copyFile(targetPath, `${targetPath}.azt-backup-${backupSuffix}`);
|
|
108
|
+
const tmpPath = `${targetPath}.tmp-${process.pid}`;
|
|
109
|
+
await fs.writeFile(tmpPath, `${lines.join(newline)}${trailingNewline ? newline : ""}`, {
|
|
110
|
+
encoding: "utf8",
|
|
111
|
+
mode: 384
|
|
112
|
+
});
|
|
113
|
+
await fs.rename(tmpPath, targetPath);
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
55
116
|
async function migrateLegacyCodexHistoryProvider() {
|
|
56
117
|
const dbPath = getCodexStateDbPath();
|
|
57
118
|
if (!await fileExists(dbPath)) {
|
|
@@ -62,20 +123,32 @@ async function migrateLegacyCodexHistoryProvider() {
|
|
|
62
123
|
};
|
|
63
124
|
}
|
|
64
125
|
try {
|
|
65
|
-
const
|
|
126
|
+
const rowsRaw = await runSqlite(
|
|
66
127
|
dbPath,
|
|
67
|
-
`select
|
|
128
|
+
`select id || char(9) || rollout_path from threads where model_provider=${sqliteQuote(LEGACY_CODEX_PROVIDER_ID)};`
|
|
68
129
|
);
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
130
|
+
const legacyThreads = parseLegacyHistoryThreadRows(rowsRaw);
|
|
131
|
+
if (legacyThreads.length <= 0) {
|
|
71
132
|
return {
|
|
72
133
|
path: dbPath,
|
|
73
134
|
migratedCount: 0,
|
|
74
135
|
skipped: true
|
|
75
136
|
};
|
|
76
137
|
}
|
|
77
|
-
const
|
|
138
|
+
const backupSuffix = createBackupSuffix();
|
|
139
|
+
const backupPath = `${dbPath}.azt-backup-${backupSuffix}`;
|
|
78
140
|
await runSqlite(dbPath, `.backup ${sqliteQuote(backupPath)}`);
|
|
141
|
+
let rolloutPatchedCount = 0;
|
|
142
|
+
const rolloutPatchErrors = [];
|
|
143
|
+
for (const thread of legacyThreads) {
|
|
144
|
+
try {
|
|
145
|
+
if (await patchSessionRolloutProvider(thread.rolloutPath, backupSuffix, LEGACY_CODEX_PROVIDER_ID, OPENAI_CODEX_PROVIDER_ID)) {
|
|
146
|
+
rolloutPatchedCount += 1;
|
|
147
|
+
}
|
|
148
|
+
} catch (error) {
|
|
149
|
+
rolloutPatchErrors.push(`${thread.id}: ${error instanceof Error ? error.message : String(error)}`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
79
152
|
await runSqlite(
|
|
80
153
|
dbPath,
|
|
81
154
|
`update threads set model_provider=${sqliteQuote(OPENAI_CODEX_PROVIDER_ID)} where model_provider=${sqliteQuote(LEGACY_CODEX_PROVIDER_ID)};`
|
|
@@ -83,7 +156,9 @@ async function migrateLegacyCodexHistoryProvider() {
|
|
|
83
156
|
return {
|
|
84
157
|
path: dbPath,
|
|
85
158
|
backupPath,
|
|
86
|
-
migratedCount
|
|
159
|
+
migratedCount: legacyThreads.length,
|
|
160
|
+
rolloutPatchedCount,
|
|
161
|
+
rolloutPatchErrors: rolloutPatchErrors.length ? rolloutPatchErrors.slice(0, 20) : void 0
|
|
87
162
|
};
|
|
88
163
|
} catch (error) {
|
|
89
164
|
return {
|