vanspod 0.4.5 → 0.4.6
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/README.md +4 -4
- package/dist/classroomApp.js +101 -27
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ npm run dist
|
|
|
38
38
|
npm pack --pack-destination dist
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
exe 產物為 `dist/VansPod.exe`,本機套件為 `dist/vanspod-0.4.
|
|
41
|
+
exe 產物為 `dist/VansPod.exe`,本機套件為 `dist/vanspod-0.4.6.tgz`;可在 Windows 用 `npm install -g <套件路徑>` 安裝測試。圖片、favicon、系統匣與移除腳本均包含在發佈產物中。更新 logo 後執行 `powershell.exe -NoProfile -File scripts/build-icon.ps1` 重建多尺寸 Windows icon。
|
|
42
42
|
|
|
43
43
|
exe 發佈管道為本專案 GitHub Releases,npm 為公開 registry 的 [`vanspod`](https://www.npmjs.com/package/vanspod) 套件。更新時不要執行完整移除,否則會清除課堂資料。
|
|
44
44
|
|
|
@@ -46,12 +46,12 @@ exe 發佈管道為本專案 GitHub Releases,npm 為公開 registry 的 [`vans
|
|
|
46
46
|
|
|
47
47
|
一般 push 不發佈;推送 `v*` tag 會在 Windows runner 安裝 Node.js 24、檢查型別、執行測試、打包並驗證 exe/npm 生命週期,全部通過後才建立 GitHub Release,最後發佈 npm 套件。學生從 Release 下載 `VansPod.exe`,同頁提供 `SHA256SUMS.txt`。
|
|
48
48
|
|
|
49
|
-
發版前同步 `package.json`、`package-lock.json` 與 `src/version.ts` 的版本;tag 必須等於 `v` 加版本號,否則流程失敗。以 `0.4.
|
|
49
|
+
發版前同步 `package.json`、`package-lock.json` 與 `src/version.ts` 的版本;tag 必須等於 `v` 加版本號,否則流程失敗。以 `0.4.6` 為例:
|
|
50
50
|
|
|
51
51
|
```powershell
|
|
52
52
|
git push origin master
|
|
53
|
-
git tag -a v0.4.
|
|
54
|
-
git push origin v0.4.
|
|
53
|
+
git tag -a v0.4.6 -m "VansPod 0.4.6"
|
|
54
|
+
git push origin v0.4.6
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
新版本使用新的版本號與 tag。相同 tag 的 Actions 重跑會更新該 Release 的產物。
|
package/dist/classroomApp.js
CHANGED
|
@@ -9,6 +9,7 @@ const node_util_1 = require("node:util");
|
|
|
9
9
|
const courseCatalog_1 = require("./courseCatalog");
|
|
10
10
|
const modelProxy_1 = require("./modelProxy");
|
|
11
11
|
const classroomKeyRejection_1 = require("./classroomKeyRejection");
|
|
12
|
+
const CLIENT_ROUTE_OF = { codex: "codex", claude: "claudeCode", vscode: "vsCodeChat" };
|
|
12
13
|
// 新工具加在最後,不改既有 id。
|
|
13
14
|
exports.ENVIRONMENT_TOOLS = ["uv", "git", "node", "pwsh", "vscode"];
|
|
14
15
|
exports.ENVIRONMENT_LABEL = {
|
|
@@ -24,8 +25,9 @@ const KEY_REJECTED_NOTICE = {
|
|
|
24
25
|
expired: "Classroom API Key 已過期,請按「清除連線」,再用老師給的新邀請碼重新兌換。",
|
|
25
26
|
invalid: "Classroom API Key 已失效,請按「清除連線」,再用老師給的新邀請碼重新兌換。",
|
|
26
27
|
};
|
|
27
|
-
const
|
|
28
|
-
const
|
|
28
|
+
const MODELS_UNLOADED_NOTICE = "無法載入課堂模型,請按「↻ 更新」再試。";
|
|
29
|
+
const RESTORE_FETCH_ATTEMPTS = 3;
|
|
30
|
+
const RESTORE_FETCH_RETRY_MS = 1_000;
|
|
29
31
|
const INSTALL_UNAVAILABLE = "尚未指定專案資料夾,安裝不可用。";
|
|
30
32
|
const ENVIRONMENT_ABORTED = "已中止安裝。系統安裝程式可能仍在執行,請等待結束或稍後重新安裝。";
|
|
31
33
|
const PROXY_CLIENTS = ["codex", "claude", "copilot"];
|
|
@@ -89,6 +91,11 @@ class ClassroomApp {
|
|
|
89
91
|
allowlistError;
|
|
90
92
|
// Router refused this Classroom API Key; only a new redeem or Clear resets it.
|
|
91
93
|
keyRejection;
|
|
94
|
+
// 啟動時抓不到 Session Model Allowlist 而暫時退回 Native 的 Client Route;設定檔仍保留 Classroom,
|
|
95
|
+
// 「更新」抓到模型後切回去。學生自己切換或換堂後就不再代為恢復。
|
|
96
|
+
classroomAwaitingModels = new Set();
|
|
97
|
+
// 恢復 Classroom Connection 時重試後仍抓不到 Session Model Allowlist;和老師沒開放任何模型不同。
|
|
98
|
+
allowlistUnloaded = false;
|
|
92
99
|
routeRestartNoted = false;
|
|
93
100
|
vsCodeOrigin;
|
|
94
101
|
sending = new Map();
|
|
@@ -794,6 +801,8 @@ class ClassroomApp {
|
|
|
794
801
|
this.modelProviders = [];
|
|
795
802
|
this.allowlistError = undefined;
|
|
796
803
|
this.keyRejection = undefined;
|
|
804
|
+
this.allowlistUnloaded = false;
|
|
805
|
+
this.classroomAwaitingModels.clear();
|
|
797
806
|
this.forgetModelChoices();
|
|
798
807
|
this.catalog = undefined;
|
|
799
808
|
this.catalogError = undefined;
|
|
@@ -889,6 +898,18 @@ class ClassroomApp {
|
|
|
889
898
|
return this.serialConnectionOperation(() => client ? this.setClientSwitch(mode, client) : this.setSwitchNow(mode));
|
|
890
899
|
}
|
|
891
900
|
async setClientSwitch(mode, client) {
|
|
901
|
+
// 學生自己選了 Native,就不再代為恢復啟動前的 Classroom;路由此時已是 Native,只差存檔。
|
|
902
|
+
// 選 Classroom 則照常切換,抓不到模型被拒時仍等「更新」恢復。
|
|
903
|
+
const route = CLIENT_ROUTE_OF[client];
|
|
904
|
+
if (mode === "native" && this.classroomAwaitingModels.delete(route)) {
|
|
905
|
+
try {
|
|
906
|
+
await this.saveClientRoutePreferences();
|
|
907
|
+
}
|
|
908
|
+
catch {
|
|
909
|
+
this.notice = "無法儲存 Native 模式,重新啟動仍可能恢復 Classroom;請重試。";
|
|
910
|
+
}
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
892
913
|
if (client === "vscode") {
|
|
893
914
|
await this.setVsCodeClientRouteSwitch(mode);
|
|
894
915
|
return;
|
|
@@ -1166,12 +1187,41 @@ class ClassroomApp {
|
|
|
1166
1187
|
return this.serialConnectionOperation(() => this.reloadAllowlistNow());
|
|
1167
1188
|
}
|
|
1168
1189
|
async saveClientRoutePreferences() {
|
|
1190
|
+
const savedMode = (id) => this.classroomAwaitingModels.has(id) ? "classroom" : this.clientRoutes[id].mode;
|
|
1169
1191
|
await this.deps.clientRouteSettings?.save({
|
|
1170
|
-
codex: { mode:
|
|
1171
|
-
claudeCode: { mode:
|
|
1172
|
-
vsCodeChat: { mode:
|
|
1192
|
+
codex: { mode: savedMode("codex"), adapter: this.clientRoutes.codex.adapter },
|
|
1193
|
+
claudeCode: { mode: savedMode("claudeCode"), adapter: this.clientRoutes.claudeCode.adapter },
|
|
1194
|
+
vsCodeChat: { mode: savedMode("vsCodeChat"), adapter: this.clientRoutes.vsCodeChat.adapter },
|
|
1173
1195
|
});
|
|
1174
1196
|
}
|
|
1197
|
+
noteClassroomAwaitingModels(route) {
|
|
1198
|
+
if (this.connected && this.allowlistUnloaded)
|
|
1199
|
+
this.classroomAwaitingModels.add(route);
|
|
1200
|
+
}
|
|
1201
|
+
/** 「更新」抓到 Session Model Allowlist 後,把啟動時暫時退回 Native 的 Client Route 切回 Classroom。 */
|
|
1202
|
+
// 老師沒開放任何模型、或路由已紅燈/灰燈時不切回;紅燈恢復後仍須學生自己切入 Classroom(ADR-0006)。
|
|
1203
|
+
async resumeClassroomAwaitingModels() {
|
|
1204
|
+
const waiting = [...this.classroomAwaitingModels];
|
|
1205
|
+
if (waiting.length === 0)
|
|
1206
|
+
return;
|
|
1207
|
+
this.classroomAwaitingModels.clear();
|
|
1208
|
+
for (const route of waiting) {
|
|
1209
|
+
const health = this.clientRoutes[route].health;
|
|
1210
|
+
if (this.modelIds.length === 0 || health === "red" || health === "gray")
|
|
1211
|
+
continue;
|
|
1212
|
+
if (route === "codex")
|
|
1213
|
+
await this.setCodexClientRouteSwitch("classroom");
|
|
1214
|
+
else if (route === "claudeCode")
|
|
1215
|
+
await this.setClaudeCodeClientRouteSwitch("classroom");
|
|
1216
|
+
else
|
|
1217
|
+
await this.setVsCodeClientRouteSwitch("classroom");
|
|
1218
|
+
}
|
|
1219
|
+
// 沒切回的路由此時才把 Native 寫進設定檔。
|
|
1220
|
+
try {
|
|
1221
|
+
await this.saveClientRoutePreferences();
|
|
1222
|
+
}
|
|
1223
|
+
catch { /* Route state stays visible; the next save retries. */ }
|
|
1224
|
+
}
|
|
1175
1225
|
async startCodexRoute() {
|
|
1176
1226
|
const runtime = this.deps.clientRouteRuntime;
|
|
1177
1227
|
if (!runtime)
|
|
@@ -1208,6 +1258,7 @@ class ClassroomApp {
|
|
|
1208
1258
|
}
|
|
1209
1259
|
lifecycle = this.codexLifecycle(); // start() supplied the route's authoritative origin.
|
|
1210
1260
|
if (this.clientRoutes.codex.mode === "classroom" && (!this.connected || this.modelIds.length === 0)) {
|
|
1261
|
+
this.noteClassroomAwaitingModels("codex");
|
|
1211
1262
|
lifecycle.setMode("native");
|
|
1212
1263
|
try {
|
|
1213
1264
|
await this.saveClientRoutePreferences();
|
|
@@ -1293,6 +1344,8 @@ class ClassroomApp {
|
|
|
1293
1344
|
this.settleVsCodePublish(result?.changed);
|
|
1294
1345
|
}
|
|
1295
1346
|
else {
|
|
1347
|
+
if (this.clientRoutes.vsCodeChat.mode === "classroom")
|
|
1348
|
+
this.noteClassroomAwaitingModels("vsCodeChat");
|
|
1296
1349
|
this.clientRoutes.vsCodeChat.mode = "native";
|
|
1297
1350
|
await this.deps.vsCodeRouteSettings?.initializeNative();
|
|
1298
1351
|
this.clientRoutes.vsCodeChat.health = "green";
|
|
@@ -1361,6 +1414,7 @@ class ClassroomApp {
|
|
|
1361
1414
|
return;
|
|
1362
1415
|
}
|
|
1363
1416
|
if (route.mode === "classroom" && (!this.connected || this.modelIds.length === 0)) {
|
|
1417
|
+
this.noteClassroomAwaitingModels("claudeCode");
|
|
1364
1418
|
route.mode = "native";
|
|
1365
1419
|
try {
|
|
1366
1420
|
await this.saveClientRoutePreferences();
|
|
@@ -1439,8 +1493,14 @@ class ClassroomApp {
|
|
|
1439
1493
|
const refreshed = await this.loadModels(apiKey);
|
|
1440
1494
|
if (this.keyRejection)
|
|
1441
1495
|
this.showKeyRejection(this.keyRejection);
|
|
1496
|
+
else if (refreshed)
|
|
1497
|
+
this.allowlistError = undefined;
|
|
1442
1498
|
else
|
|
1443
|
-
this.allowlistError =
|
|
1499
|
+
this.allowlistError = this.allowlistUnloaded ? MODELS_UNLOADED_NOTICE : "重新載入課堂模型失敗,已保留上次成功的模型清單。";
|
|
1500
|
+
if (refreshed) {
|
|
1501
|
+
this.allowlistUnloaded = false;
|
|
1502
|
+
await this.resumeClassroomAwaitingModels();
|
|
1503
|
+
}
|
|
1444
1504
|
const current = this.mode === "classroom" ? this.modelIds.join("\0") : "";
|
|
1445
1505
|
if (previous !== current) {
|
|
1446
1506
|
this.modelRestart = ["codex", "claude"].filter(client => this.clientModes[client] === "classroom");
|
|
@@ -1456,10 +1516,10 @@ class ClassroomApp {
|
|
|
1456
1516
|
}
|
|
1457
1517
|
}
|
|
1458
1518
|
}
|
|
1459
|
-
async loadModels(apiKey) {
|
|
1519
|
+
async loadModels(apiKey, attempts = 1) {
|
|
1460
1520
|
let payload;
|
|
1461
1521
|
try {
|
|
1462
|
-
payload = await this.deps.router.fetchSessionModels(apiKey);
|
|
1522
|
+
payload = await fetchWithRetries(attempts, () => this.deps.router.fetchSessionModels(apiKey));
|
|
1463
1523
|
}
|
|
1464
1524
|
catch (error) {
|
|
1465
1525
|
if (error instanceof classroomKeyRejection_1.ClassroomKeyRejectedError)
|
|
@@ -1640,6 +1700,8 @@ class ClassroomApp {
|
|
|
1640
1700
|
this.notice = undefined;
|
|
1641
1701
|
this.allowlistError = undefined;
|
|
1642
1702
|
this.keyRejection = undefined;
|
|
1703
|
+
this.allowlistUnloaded = false;
|
|
1704
|
+
this.classroomAwaitingModels.clear();
|
|
1643
1705
|
this.catalog = undefined;
|
|
1644
1706
|
this.catalogError = undefined;
|
|
1645
1707
|
this.remoteCatalogHeld = false;
|
|
@@ -1794,11 +1856,16 @@ class ClassroomApp {
|
|
|
1794
1856
|
this.hiddenKeys.add(connection.apiKey);
|
|
1795
1857
|
this.applyConnectionIdentity(connection);
|
|
1796
1858
|
this.mode = "native";
|
|
1797
|
-
// 版本更新後重新啟動時網路可能還沒穩;恢復 Classroom Connection 時抓不到 Course Catalog
|
|
1798
|
-
|
|
1799
|
-
await this.
|
|
1859
|
+
// 版本更新後重新啟動時網路可能還沒穩;恢復 Classroom Connection 時抓不到 Course Catalog
|
|
1860
|
+
// 或 Session Model Allowlist 就稍候再試,才退回本機的 classroom-installs.yaml 或 Native。
|
|
1861
|
+
await this.loadCatalog(RESTORE_FETCH_ATTEMPTS);
|
|
1862
|
+
const modelsLoaded = await this.loadModels(connection.apiKey, RESTORE_FETCH_ATTEMPTS);
|
|
1800
1863
|
if (this.keyRejection)
|
|
1801
1864
|
this.showKeyRejection(this.keyRejection);
|
|
1865
|
+
else if (!modelsLoaded) {
|
|
1866
|
+
this.allowlistUnloaded = true;
|
|
1867
|
+
this.allowlistError = MODELS_UNLOADED_NOTICE;
|
|
1868
|
+
}
|
|
1802
1869
|
if (connection.mode === "classroom" && this.modelIds.length > 0) {
|
|
1803
1870
|
this.mode = "classroom";
|
|
1804
1871
|
this.clientModes = connection.clientModes ?? { codex: "classroom", claude: "classroom" };
|
|
@@ -1888,23 +1955,17 @@ class ClassroomApp {
|
|
|
1888
1955
|
return;
|
|
1889
1956
|
}
|
|
1890
1957
|
let body;
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
this.keyRejection = error.reason;
|
|
1900
|
-
return;
|
|
1901
|
-
}
|
|
1902
|
-
if (attempt >= attempts) {
|
|
1903
|
-
await this.loadLocalCatalog();
|
|
1904
|
-
return;
|
|
1905
|
-
}
|
|
1906
|
-
await new Promise(resolve => setTimeout(resolve, RESTORE_CATALOG_RETRY_MS));
|
|
1958
|
+
try {
|
|
1959
|
+
body = await fetchWithRetries(attempts, () => this.deps.catalog.fetchCourseCatalog(apiKey));
|
|
1960
|
+
}
|
|
1961
|
+
catch (error) {
|
|
1962
|
+
// The refused key is reported with the allowlist; the last catalog stays on screen.
|
|
1963
|
+
if (error instanceof classroomKeyRejection_1.ClassroomKeyRejectedError) {
|
|
1964
|
+
this.keyRejection = error.reason;
|
|
1965
|
+
return;
|
|
1907
1966
|
}
|
|
1967
|
+
await this.loadLocalCatalog();
|
|
1968
|
+
return;
|
|
1908
1969
|
}
|
|
1909
1970
|
const yaml = usableCatalogYaml(body?.course_catalog_yaml);
|
|
1910
1971
|
if (yaml === undefined) {
|
|
@@ -1950,6 +2011,19 @@ class ClassroomApp {
|
|
|
1950
2011
|
}
|
|
1951
2012
|
}
|
|
1952
2013
|
exports.ClassroomApp = ClassroomApp;
|
|
2014
|
+
/** 失敗時稍候再試,最多 attempts 次;Router 拒絕 Classroom API Key 時再試也沒用,立刻放棄。 */
|
|
2015
|
+
async function fetchWithRetries(attempts, fetch) {
|
|
2016
|
+
for (let attempt = 1;; attempt++) {
|
|
2017
|
+
try {
|
|
2018
|
+
return await fetch();
|
|
2019
|
+
}
|
|
2020
|
+
catch (error) {
|
|
2021
|
+
if (error instanceof classroomKeyRejection_1.ClassroomKeyRejectedError || attempt >= attempts)
|
|
2022
|
+
throw error;
|
|
2023
|
+
await new Promise(resolve => setTimeout(resolve, RESTORE_FETCH_RETRY_MS));
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
1953
2027
|
/** 安裝後驗證未通過時的提示;安裝程式要求重新開機時,請學生重開機後再檢查。 */
|
|
1954
2028
|
function environmentInstallFailure(label, result, verified) {
|
|
1955
2029
|
const rejected = result?.failure
|
package/dist/version.js
CHANGED