@bokutake/dsh-connect-qoder 0.0.0-stage → 1.28.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/CHANGELOG.md +4860 -0
- package/LICENSE +21 -0
- package/LICENSE-MODIFICATIONS.md +60 -0
- package/README.en.md +492 -0
- package/README.md +498 -2
- package/THIRD_PARTY_NOTICES.md +60 -0
- package/cordis.patch.yml +12 -0
- package/docs/DESIGN.md +249 -0
- package/docs/DSH-0.2.1-RC1-FOLLOWUP.md +348 -0
- package/docs/DSH-0.2.2-RC1-FOLLOWUP.md +328 -0
- package/docs/DSH-0.2.2-RC2-FOLLOWUP.md +342 -0
- package/docs/DSH-0.2.2-RC3-FOLLOWUP.md +317 -0
- package/docs/DSH-0.2.2-RC5-FOLLOWUP.md +219 -0
- package/docs/PAT.md +191 -0
- package/docs/PRIVACY.md +109 -0
- package/docs/PROMO_BADGE.md +293 -0
- package/docs/assets/dsh-connect-qoder-composer-credits.png +0 -0
- package/docs/assets/dsh-connect-qoder-model-management.png +0 -0
- package/docs/assets/dsh-connect-qoder-model-picker.png +0 -0
- package/docs/assets/dsh-connect-qoder-promo-badge.png +0 -0
- package/docs/assets/dsh-connect-qoder-settings-page.png +0 -0
- package/docs/assets/dsh-connect-qoder-usage-card.png +0 -0
- package/docs/issues/magpie-330-billing-count.md +91 -0
- package/icons/dsh-connect-qoder-128.png +0 -0
- package/icons/dsh-connect-qoder-64.png +0 -0
- package/lib/bin.d.ts +26 -0
- package/lib/bin.js +219 -0
- package/lib/client.js +9252 -0
- package/lib/host-heartbeat-Daj8rZV0.js +4497 -0
- package/lib/index.d.ts +872 -0
- package/lib/index.js +6567 -0
- package/lib/transfer-pMn4lOHy.js +171 -0
- package/package.json +151 -4
- package/screenshots.json +8 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# magpie #330:一次任务 265 次请求后触发「Billing daily count exceeded」
|
|
2
|
+
|
|
3
|
+
> **来源**:这是**另一个仓库**的 issue ——
|
|
4
|
+
> [`magpie-community/plugins#330`](https://github.com/magpie-community/plugins/issues/330),
|
|
5
|
+
> 不是本仓库的编号。文件名带 `magpie-` 前缀就是为了不与本仓库 `dingminhua/dsh-connect-qoder`
|
|
6
|
+
> 的 issue 编号混淆(本仓库的 issue #330 是另一件事,或者还不存在)。
|
|
7
|
+
>
|
|
8
|
+
> **为什么要在这里落盘**:那份 issue 提出的问题与本插件 1.28.0 修的缺陷指向同一个根因,
|
|
9
|
+
> 而它给出的结论边界不清。把对照写下来,一是给维护者一个可核验的参照,二是避免日后有人
|
|
10
|
+
> 拿「magpie 说已经修了」当成本插件也已验证的结论。
|
|
11
|
+
|
|
12
|
+
## 一、issue 说了什么
|
|
13
|
+
|
|
14
|
+
标题原文:
|
|
15
|
+
|
|
16
|
+
> qoder: 一次 DSH 任务 265 次请求后触发 "Billing daily count exceeded",怀疑每条请求都被
|
|
17
|
+
> 记成一次新对话
|
|
18
|
+
|
|
19
|
+
要点:
|
|
20
|
+
|
|
21
|
+
1. 一次 DSH 任务产生了 **265 次请求**,之后撞上 `Billing daily count exceeded`;
|
|
22
|
+
2. 作者(`real-jacket`)的推断是「每条请求都被记成一次新对话」,于是日计数按**请求数**
|
|
23
|
+
而不是按**对话数**累计,很快就超限;
|
|
24
|
+
3. 维护者(`yetone`)在 magpie `0.2.31` 里做了修复;
|
|
25
|
+
4. 作者的复测结论:**不再出现该报错**,但补充说明计数语义「查不到,也没用真实账号测过」。
|
|
26
|
+
|
|
27
|
+
## 二、我们的实测结论
|
|
28
|
+
|
|
29
|
+
对官方 CN CLI(`qoderclicn` 1.1.94)做 MITM 抓包,两次共 80 个请求,结论与 issue 的
|
|
30
|
+
**推断方向一致,但定位更靠下**:
|
|
31
|
+
|
|
32
|
+
| 层次 | issue 的假设 | 实测结论 |
|
|
33
|
+
| --- | --- | --- |
|
|
34
|
+
| 计数单位 | 每条 HTTP 请求 = 一次对话 | **每轮用户提示 = 一条 `business` 记录**;轮内 N 次补全共用 1 个 `id`,只 1 次闭合 |
|
|
35
|
+
| 触发原因 | 265 次请求 → 265 条对话 → 超限 | 不只是「请求多」,而是**每条记录都没闭合**:服务端只能等 TTL 释放租约与日计数 |
|
|
36
|
+
| 修复层次 | 不在 issue 里 | 既要按轮回并,**也要在轮末发 `business/finish`** |
|
|
37
|
+
|
|
38
|
+
支撑数据:
|
|
39
|
+
|
|
40
|
+
- 一轮 1 次补全(无工具)→ **1 次** `business/finish`;
|
|
41
|
+
- 一轮 2 次补全(含 1 次 `Bash` 工具调用)→ **仍然 1 次** `business/finish`;
|
|
42
|
+
- 两笔补全的请求体从 155 648 B 涨到 157 648 B(工具结果在轮内累积),闭合次数不变;
|
|
43
|
+
- 恢复旧会话后第二轮 → 1 次补全、1 次闭合。
|
|
44
|
+
|
|
45
|
+
也就是说:**issue 猜的「每条请求一次对话」在官方客户端里不成立** —— 官方是按轮来的。
|
|
46
|
+
真正让日计数膨胀的是「记录创建了却永不闭合」,而不是「请求次数多」。
|
|
47
|
+
|
|
48
|
+
## 三、和 magpie 实现的对照
|
|
49
|
+
|
|
50
|
+
| 项 | 官方 CLI | magpie 0.2.71 | 本插件 1.28.0 |
|
|
51
|
+
| --- | --- | --- | --- |
|
|
52
|
+
| `business.id` 粒度 | 每轮用户提示 | 每轮用户提示(`sha256([sid, lastUserIndex, lastUserContent])`) | 每轮用户提示(`session_id` + 本轮用户提示) |
|
|
53
|
+
| 记录上限 | — | `TASK_MAX = 512`、`TASK_IDLE = 2h` | `STAGE_MAP_LIMIT = 512`,闭合即删 |
|
|
54
|
+
| `business/finish` | **发**(每轮 1 次) | **不发**(注释说靠服务端 TTL) | **发**,响应 `success` |
|
|
55
|
+
| 终态 `stage` | `init → start → processing → complete` | `start` / `processing` | 同官方,含终态 |
|
|
56
|
+
|
|
57
|
+
**所以「本插件在计数语义上比 magpie 更完整」这句话是有依据的**:magpie 把计数单位改对了
|
|
58
|
+
(这一步它是对的,也是 0.2.31 修的东西),但没有补闭合 —— 记录仍然永不收口,只能等服务端
|
|
59
|
+
TTL。本插件两环都补了。
|
|
60
|
+
|
|
61
|
+
## 四、结论边界(**重要**)
|
|
62
|
+
|
|
63
|
+
**本插件没有验证「`Billing daily count exceeded` 不再出现」。**
|
|
64
|
+
|
|
65
|
+
必须把这条写清楚,否则这份文档会被读成比实际更强的结论:
|
|
66
|
+
|
|
67
|
+
- **已验证**:每轮只产生一条记录、一次闭合;闭合被上游接受(响应 `success`);计费控制台
|
|
68
|
+
确实出现**逐条消费行**,时间戳与抓包逐条对得上。
|
|
69
|
+
- **未验证**:那个报错是**日累计**触发的,需要跑到当日上限才会重现。验证期间只跑了几轮,
|
|
70
|
+
远不到上限。本机控制台**没有暴露日计数**(只有逐条消费行),连间接读数都没有。
|
|
71
|
+
|
|
72
|
+
推论方向是清楚的(日计数超限最可能的成因是大量记录永不闭合),但**它仍是推论**。
|
|
73
|
+
|
|
74
|
+
同样地,magpie 那边「0.2.31 之后不再报错」这个结论,其作者自己也说明没有用真实账号验证过
|
|
75
|
+
计数语义。**两边都缺直接观测** —— 差别只在于本插件补上了 magpie 没有的那一环。
|
|
76
|
+
|
|
77
|
+
要把这条变成验证过的结论,需要一次「跑到当日上限」的实测。在那之前,这一项在
|
|
78
|
+
[`CHANGELOG.md`](../../CHANGELOG.md) 的「明确未验证」一节里保持标记。
|
|
79
|
+
|
|
80
|
+
## 五、复现与取证方法(不含凭据)
|
|
81
|
+
|
|
82
|
+
本仓库**不收录**抓包文件与脚手架:`captures/` 里含真实的 `cosy-key`、`cosy-machinetoken`
|
|
83
|
+
与 bearer 载荷,等价于会话凭据。可信的替代做法是自己抓一次,判据如下:
|
|
84
|
+
|
|
85
|
+
1. 抓包观察 `POST /algo/api/v2/service/business/finish?Encode=1` 的**次数**;
|
|
86
|
+
2. 让一次用户提示触发工具调用(一轮内多次补全),确认补全次数 > 1 而闭合次数 == 1;
|
|
87
|
+
3. 解 `Encode=1` 请求体,确认明文是 `{"payload":"<JSON 字符串>","encodeVersion":"1"}`;
|
|
88
|
+
4. 对照 `business.id` 在轮内稳定、跨轮变化。
|
|
89
|
+
|
|
90
|
+
请求头层面的对照值(`cosy-clienttype: 5`、`cosy-business-product: cli`、`Bun/1.4.4` 等)
|
|
91
|
+
与实测结果见 [`CHANGELOG.md`](../../CHANGELOG.md) 的「实测验证」一节。
|
|
Binary file
|
|
Binary file
|
package/lib/bin.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/bin.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Standalone status/diagnostics CLI for the dsh-connect-qoder bundle.
|
|
4
|
+
*
|
|
5
|
+
* 参考:dsh-connect-workbuddy(MIT,Copyright (c) 2026 LaoDing)——三个子命令
|
|
6
|
+
* 的骨架(`doctor` / `status` / `logout`)、`--json` 输出、`safeMessage` 脱敏与
|
|
7
|
+
* 「凭据来源 + 上游连通性」诊断的结构由该项目设计。
|
|
8
|
+
* 改动(按 Qoder 上游的现实):
|
|
9
|
+
* - 凭据只读环境变量 + 本地 vault(CLI 运行于宿主之外,无法访问设置服务);
|
|
10
|
+
* - `doctor` 增加 cosy 指纹派生自检、pi-ai 代际、宿主心跳存活、vault 账号计数;
|
|
11
|
+
* - `status` 汇报每区域凭据来源 + 上游可达性 + 当前剩余积分(总额);
|
|
12
|
+
* - `logout` 清除本区域的 vault 凭据与账号池测量副本(可 `--region` 指定,
|
|
13
|
+
* 否则两区域都清)。
|
|
14
|
+
*
|
|
15
|
+
* @module dsh-connect-qoder/bin
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* 从 argv 里取出**命令词**:剥掉 flag 与区域实参,剩下的第一个就是。
|
|
19
|
+
*
|
|
20
|
+
* 必须是「保留**不是** flag、**不是**区域名的实参」。写反成
|
|
21
|
+
* `REGION_KEYS.includes(arg)`(只留 cn/global)会让命令词自己被过滤掉,
|
|
22
|
+
* 于是三条子命令全部只会打印 usage。抽成纯函数就是为了能对它断言。
|
|
23
|
+
*/
|
|
24
|
+
declare function commandArgOf(argv: readonly string[]): string | undefined;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { commandArgOf };
|
package/lib/bin.js
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { S as isQoderUpstreamError, Z as deriveFingerprint, b as QoderUpstreamClient, d as QoderAccountStore, f as qoderAccountsPath, g as patFromEnv, i as readHostHeartbeat, n as isHeartbeatProcessAlive, o as qoderPoolStorePath, p as QODER_PAT_ENV_VARS, r as qoderHostHeartbeatPath, v as piAiRuntimeInfo, y as QODER_REGIONS } from "./host-heartbeat-Daj8rZV0.js";
|
|
3
|
+
import { rm } from "node:fs/promises";
|
|
4
|
+
//#region src/bin.ts
|
|
5
|
+
/**
|
|
6
|
+
* Standalone status/diagnostics CLI for the dsh-connect-qoder bundle.
|
|
7
|
+
*
|
|
8
|
+
* 参考:dsh-connect-workbuddy(MIT,Copyright (c) 2026 LaoDing)——三个子命令
|
|
9
|
+
* 的骨架(`doctor` / `status` / `logout`)、`--json` 输出、`safeMessage` 脱敏与
|
|
10
|
+
* 「凭据来源 + 上游连通性」诊断的结构由该项目设计。
|
|
11
|
+
* 改动(按 Qoder 上游的现实):
|
|
12
|
+
* - 凭据只读环境变量 + 本地 vault(CLI 运行于宿主之外,无法访问设置服务);
|
|
13
|
+
* - `doctor` 增加 cosy 指纹派生自检、pi-ai 代际、宿主心跳存活、vault 账号计数;
|
|
14
|
+
* - `status` 汇报每区域凭据来源 + 上游可达性 + 当前剩余积分(总额);
|
|
15
|
+
* - `logout` 清除本区域的 vault 凭据与账号池测量副本(可 `--region` 指定,
|
|
16
|
+
* 否则两区域都清)。
|
|
17
|
+
*
|
|
18
|
+
* @module dsh-connect-qoder/bin
|
|
19
|
+
*/
|
|
20
|
+
const JSON_SCHEMA_VERSION = 2;
|
|
21
|
+
const REGION_KEYS = ["cn", "global"];
|
|
22
|
+
/** Remove token-like strings from an unexpected diagnostic message. */
|
|
23
|
+
function safeMessage(error) {
|
|
24
|
+
return (error instanceof Error ? error.message : String(error)).replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/gu, "[redacted token]").replace(/(\b(?:code|token|refresh_token|access_token)=)[^&\s]+/giu, "$1[redacted]");
|
|
25
|
+
}
|
|
26
|
+
/** One region's total remaining credits from a usage read (secret-free). */
|
|
27
|
+
function creditsTotal(usage) {
|
|
28
|
+
if (usage === void 0) return void 0;
|
|
29
|
+
let total = 0;
|
|
30
|
+
let seen = false;
|
|
31
|
+
const userQuota = usage.userQuota;
|
|
32
|
+
if (userQuota !== void 0 && typeof userQuota.total === "number") {
|
|
33
|
+
total += Math.max(userQuota.total - (userQuota.used ?? 0), 0);
|
|
34
|
+
seen = true;
|
|
35
|
+
}
|
|
36
|
+
const addOnQuota = usage.addOnQuota;
|
|
37
|
+
if (addOnQuota !== void 0 && typeof addOnQuota.total === "number") {
|
|
38
|
+
total += Math.max(addOnQuota.total - (addOnQuota.used ?? 0), 0);
|
|
39
|
+
seen = true;
|
|
40
|
+
}
|
|
41
|
+
const org = usage.orgResourcePackage;
|
|
42
|
+
if (org !== void 0 && typeof org.cap === "number") {
|
|
43
|
+
total += Math.max(org.cap - (org.used ?? 0), 0);
|
|
44
|
+
seen = true;
|
|
45
|
+
}
|
|
46
|
+
return seen ? total : void 0;
|
|
47
|
+
}
|
|
48
|
+
function printHelp() {
|
|
49
|
+
process.stdout.write([
|
|
50
|
+
"Usage: dsh-connect-qoder <doctor|status|logout> [--json] [--region cn|global]",
|
|
51
|
+
"",
|
|
52
|
+
" doctor PAT source, cosy fingerprint, pi-ai generation, heartbeat, vault (no network)",
|
|
53
|
+
" status per-region PAT presence, upstream model-list reachability, credits",
|
|
54
|
+
" logout clear the local vault accounts + pool measurements for a region",
|
|
55
|
+
" --json emit one secret-free JSON document",
|
|
56
|
+
"",
|
|
57
|
+
"Credentials come from the environment:",
|
|
58
|
+
` ${QODER_PAT_ENV_VARS.global} (global, qoder.sh)`,
|
|
59
|
+
` ${QODER_PAT_ENV_VARS.cn} (CN, qoder.com.cn)`,
|
|
60
|
+
"or from the local vault ($DSH_HOME/.qoder-accounts.<region>.json).",
|
|
61
|
+
""
|
|
62
|
+
].join("\n"));
|
|
63
|
+
}
|
|
64
|
+
function printJson(value) {
|
|
65
|
+
process.stdout.write(`${JSON.stringify(value, null, 2)}\n`);
|
|
66
|
+
}
|
|
67
|
+
function regionArg() {
|
|
68
|
+
const index = process.argv.indexOf("--region");
|
|
69
|
+
if (index !== -1) {
|
|
70
|
+
const value = process.argv[index + 1];
|
|
71
|
+
if (value === "cn" || value === "global") return [value];
|
|
72
|
+
}
|
|
73
|
+
return REGION_KEYS;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* 从 argv 里取出**命令词**:剥掉 flag 与区域实参,剩下的第一个就是。
|
|
77
|
+
*
|
|
78
|
+
* 必须是「保留**不是** flag、**不是**区域名的实参」。写反成
|
|
79
|
+
* `REGION_KEYS.includes(arg)`(只留 cn/global)会让命令词自己被过滤掉,
|
|
80
|
+
* 于是三条子命令全部只会打印 usage。抽成纯函数就是为了能对它断言。
|
|
81
|
+
*/
|
|
82
|
+
function commandArgOf(argv) {
|
|
83
|
+
return argv.filter((arg) => arg !== "--json" && arg !== "--region" && !REGION_KEYS.includes(arg))[0];
|
|
84
|
+
}
|
|
85
|
+
async function doctor() {
|
|
86
|
+
const piAi = piAiRuntimeInfo();
|
|
87
|
+
const heartbeat = await readHostHeartbeat();
|
|
88
|
+
const entries = [];
|
|
89
|
+
for (const region of REGION_KEYS) {
|
|
90
|
+
const fingerprint = deriveFingerprint("", `doctor:${region}`);
|
|
91
|
+
const vault = await new QoderAccountStore(region).vaultAccounts();
|
|
92
|
+
entries.push({
|
|
93
|
+
region,
|
|
94
|
+
gateway: QODER_REGIONS[region].gateway,
|
|
95
|
+
patEnv: QODER_PAT_ENV_VARS[region],
|
|
96
|
+
patPresent: patFromEnv(region) !== void 0,
|
|
97
|
+
vaultAccounts: vault.length,
|
|
98
|
+
fingerprint: {
|
|
99
|
+
machineId: fingerprint.machineId,
|
|
100
|
+
machineType: fingerprint.machineType,
|
|
101
|
+
machineToken: fingerprint.machineToken
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const report = {
|
|
106
|
+
schemaVersion: JSON_SCHEMA_VERSION,
|
|
107
|
+
piAi: {
|
|
108
|
+
generation: piAi?.generation ?? "unknown",
|
|
109
|
+
version: piAi?.version ?? "unknown"
|
|
110
|
+
},
|
|
111
|
+
heartbeat: {
|
|
112
|
+
present: heartbeat !== void 0,
|
|
113
|
+
alive: heartbeat !== void 0 && isHeartbeatProcessAlive(heartbeat),
|
|
114
|
+
...heartbeat?.pid === void 0 ? {} : { pid: heartbeat.pid }
|
|
115
|
+
},
|
|
116
|
+
entries
|
|
117
|
+
};
|
|
118
|
+
if (process.argv.includes("--json")) {
|
|
119
|
+
printJson(report);
|
|
120
|
+
return report;
|
|
121
|
+
}
|
|
122
|
+
process.stdout.write(`pi-ai: ${report.piAi.generation} (${report.piAi.version})\n`);
|
|
123
|
+
process.stdout.write(`heartbeat: ${report.heartbeat.present ? report.heartbeat.alive ? `alive (pid ${report.heartbeat.pid ?? "?"})` : "stale" : "absent"} — ${qoderHostHeartbeatPath()}\n`);
|
|
124
|
+
for (const entry of entries) {
|
|
125
|
+
process.stdout.write(`[${entry.region}] ${entry.gateway}\n`);
|
|
126
|
+
process.stdout.write(` PAT ${entry.patEnv}: ${entry.patPresent ? "present" : "missing"}\n`);
|
|
127
|
+
process.stdout.write(` vault: ${entry.vaultAccounts} account(s) — ${qoderAccountsPath(entry.region)}\n`);
|
|
128
|
+
process.stdout.write(` fingerprint: machineId=${entry.fingerprint.machineId} type=${entry.fingerprint.machineType}\n`);
|
|
129
|
+
}
|
|
130
|
+
const missing = entries.filter((entry) => !entry.patPresent && entry.vaultAccounts === 0);
|
|
131
|
+
if (missing.length > 0) {
|
|
132
|
+
process.stdout.write(`\nNo PAT in the environment or vault for: ${missing.map((entry) => entry.region).join(", ")}\n`);
|
|
133
|
+
process.stdout.write("Set the variable above (or add an account in the plugin card) before using that region.\n");
|
|
134
|
+
}
|
|
135
|
+
return report;
|
|
136
|
+
}
|
|
137
|
+
async function status() {
|
|
138
|
+
const entries = [];
|
|
139
|
+
for (const region of REGION_KEYS) {
|
|
140
|
+
const envPat = patFromEnv(region);
|
|
141
|
+
const vault = await new QoderAccountStore(region).vaultAccounts();
|
|
142
|
+
const pat = envPat ?? vault[0]?.pat;
|
|
143
|
+
const patSource = envPat !== void 0 ? "env" : vault.length > 0 ? "vault" : "none";
|
|
144
|
+
const entry = {
|
|
145
|
+
region,
|
|
146
|
+
gateway: QODER_REGIONS[region].gateway,
|
|
147
|
+
...patSource === void 0 ? {} : { patSource },
|
|
148
|
+
models: 0
|
|
149
|
+
};
|
|
150
|
+
if (pat === void 0) {
|
|
151
|
+
entries.push(entry);
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
const client = new QoderUpstreamClient(region);
|
|
156
|
+
entry.models = (await client.fetchModels(pat)).length;
|
|
157
|
+
try {
|
|
158
|
+
const credits = creditsTotal(await client.fetchUsage(pat));
|
|
159
|
+
if (credits !== void 0) entry.creditsTotal = credits;
|
|
160
|
+
} catch {}
|
|
161
|
+
} catch (error) {
|
|
162
|
+
if (isQoderUpstreamError(error)) entry.error = `${error.kind} (HTTP ${error.status}): ${safeMessage(error.message)}`;
|
|
163
|
+
else entry.error = safeMessage(error);
|
|
164
|
+
}
|
|
165
|
+
entries.push(entry);
|
|
166
|
+
}
|
|
167
|
+
if (process.argv.includes("--json")) {
|
|
168
|
+
printJson({
|
|
169
|
+
schemaVersion: JSON_SCHEMA_VERSION,
|
|
170
|
+
entries
|
|
171
|
+
});
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
for (const entry of entries) {
|
|
175
|
+
process.stdout.write(`[${entry.region}] ${entry.gateway}\n`);
|
|
176
|
+
process.stdout.write(` PAT: ${entry.patSource ?? "none"}\n`);
|
|
177
|
+
if (entry.error !== void 0) process.stdout.write(` upstream: FAILED (${entry.error})\n`);
|
|
178
|
+
else if (entry.patSource !== "none") {
|
|
179
|
+
const credits = entry.creditsTotal === void 0 ? "" : `, credits ${entry.creditsTotal}`;
|
|
180
|
+
process.stdout.write(` upstream: OK, ${entry.models} models${credits}\n`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
async function logout() {
|
|
185
|
+
const regions = regionArg();
|
|
186
|
+
const cleared = [];
|
|
187
|
+
for (const region of regions) for (const path of [qoderAccountsPath(region), qoderPoolStorePath(region)]) try {
|
|
188
|
+
await rm(path, { force: true });
|
|
189
|
+
cleared.push(path);
|
|
190
|
+
} catch {}
|
|
191
|
+
if (process.argv.includes("--json")) {
|
|
192
|
+
printJson({
|
|
193
|
+
schemaVersion: JSON_SCHEMA_VERSION,
|
|
194
|
+
cleared
|
|
195
|
+
});
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
process.stdout.write(cleared.length === 0 ? "Nothing to clear (no vault files present).\n" : `Cleared:\n${cleared.map((path) => ` ${path}\n`).join("")}`);
|
|
199
|
+
}
|
|
200
|
+
async function main() {
|
|
201
|
+
const command = commandArgOf(process.argv.slice(2));
|
|
202
|
+
if (command === "doctor") {
|
|
203
|
+
await doctor();
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (command === "status") {
|
|
207
|
+
await status();
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (command === "logout") {
|
|
211
|
+
await logout();
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
printHelp();
|
|
215
|
+
process.exitCode = command === void 0 ? 0 : 2;
|
|
216
|
+
}
|
|
217
|
+
main();
|
|
218
|
+
//#endregion
|
|
219
|
+
export { commandArgOf };
|