dsh-qwenwork-connect 0.2.2 → 0.3.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/README.md +46 -19
- package/THIRD-PARTY-NOTICES.md +135 -0
- package/lib/catalog.js +179 -0
- package/lib/chat-shim.js +51 -23
- package/lib/client.js +200 -26
- package/lib/cosy.js +203 -0
- package/lib/credentials-seam.js +1 -1
- package/lib/credentials.js +1 -1
- package/lib/endpoint.js +2 -2
- package/lib/index.js +149 -45
- package/lib/login-route.js +6 -1
- package/lib/models.js +8 -10
- package/lib/rest.js +2 -2
- package/lib/signer-session.js +73 -212
- package/lib/signer-shim.js +1 -1
- package/lib/sse.js +21 -19
- package/lib/upstream-errors.js +225 -0
- package/package.json +3 -4
- package/research/qoder-wasm-glue.mjs +0 -329
- package/research/wasm.bin +0 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 上游错误分类:把 HTTP 状态、业务码、排队信息归一成下游可理解的语义。
|
|
3
|
+
*
|
|
4
|
+
* 背景:千问办公把很多错误塞在 HTTP 200 的 SSE 帧里(例如 `code: "10605"`
|
|
5
|
+
* 表示排队),pi-ai 只按错误文案里的状态码分类。若不把这些业务码翻译成
|
|
6
|
+
* 明确的 HTTP 语义,pi-ai 会落到 `PI_AI_ERROR`,DSH 不重试——多轮 agent
|
|
7
|
+
* 跑到一半撞上模型池忙,整轮就停在这里。
|
|
8
|
+
*
|
|
9
|
+
* 本模块只做**分类**,不做重试、不做降级:分类结果交给调用方决定
|
|
10
|
+
* (pre-stream 用 HTTP 状态,in-band 用 `HTTP <code>: <message>` 文案)。
|
|
11
|
+
*
|
|
12
|
+
* @module dsh-qwenwork-connect/upstream-errors
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** 上游「排队」业务码。 */
|
|
16
|
+
const QUEUED_CODE = '10605';
|
|
17
|
+
|
|
18
|
+
/** 配额/额度类业务码。 */
|
|
19
|
+
const QUOTA_CODES = new Set([
|
|
20
|
+
'110', '112', '113', '114', '115', '116', '117', '118', '119', '122',
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
/** 请求非法类业务码。 */
|
|
24
|
+
const REQUEST_CODES = new Set([
|
|
25
|
+
'406', '416', '430', '80411', '80412', '100400', '100401', '100403',
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
const ALL_MODELS_FAILED_RE = /all models failed/i;
|
|
29
|
+
const UPSTREAM_FAILED_RE = /error in upstream response/i;
|
|
30
|
+
const QUOTA_TEXT_RE = /quota|credits?|usage limit|insufficient (?:balance|quota|credits?)|out of credits?|exceeded.*(?:quota|limit)|余额不足|额度/i;
|
|
31
|
+
|
|
32
|
+
/** 上游未给出等待时间时的默认值(秒)。 */
|
|
33
|
+
const DEFAULT_BUSY_WAIT = 30;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 解析上游错误原文(可能是 JSON,也可能是纯文本)。
|
|
37
|
+
*
|
|
38
|
+
* 处理上游的两种嵌套:`message` 字段里再塞一层 JSON;以及 `details.error.message`。
|
|
39
|
+
*
|
|
40
|
+
* @param {unknown} text
|
|
41
|
+
* @returns {{ status?: number, code?: string, message?: string, queue?: object }}
|
|
42
|
+
*/
|
|
43
|
+
export function parseUpstreamFailureText(text) {
|
|
44
|
+
if (isObject(text)) return fromParsed(text);
|
|
45
|
+
const raw = typeof text === 'string' ? text.trim() : '';
|
|
46
|
+
if (raw === '') return {};
|
|
47
|
+
let json;
|
|
48
|
+
try {
|
|
49
|
+
json = JSON.parse(raw);
|
|
50
|
+
} catch {
|
|
51
|
+
return { message: raw.slice(0, 400) };
|
|
52
|
+
}
|
|
53
|
+
if (!isObject(json)) return { message: raw.slice(0, 400) };
|
|
54
|
+
return fromParsed(json);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** 已解析后的 JSON 对象 → 归一字段。 */
|
|
58
|
+
function fromParsed(json) {
|
|
59
|
+
|
|
60
|
+
const status = toStatus(json.statusCodeValue ?? json.statusCode);
|
|
61
|
+
let code = json.code === undefined || json.code === null ? '' : String(json.code);
|
|
62
|
+
let message = typeof json.message === 'string' ? json.message : '';
|
|
63
|
+
let queue = isObject(json.queue) ? json.queue : undefined;
|
|
64
|
+
|
|
65
|
+
if (json.details !== undefined) {
|
|
66
|
+
const details = typeof json.details === 'string' ? tryParse(json.details) : json.details;
|
|
67
|
+
const detailMessage = isObject(details) && isObject(details.error) ? details.error.message : undefined;
|
|
68
|
+
if (typeof detailMessage === 'string' && detailMessage !== '') {
|
|
69
|
+
message = message === '' ? detailMessage : `${message}: ${detailMessage}`;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// 401/403 外壳里再包一层 JSON(上游真实形态之一)。
|
|
74
|
+
const nested = tryParse(message);
|
|
75
|
+
if (isObject(nested)) {
|
|
76
|
+
if (['', '401', '403'].includes(code) && nested.code !== undefined) {
|
|
77
|
+
code = String(nested.code);
|
|
78
|
+
}
|
|
79
|
+
if (typeof nested.message === 'string' && nested.message !== '') message = nested.message;
|
|
80
|
+
if (queue === undefined && isObject(nested.queue)) queue = nested.queue;
|
|
81
|
+
if (queue === undefined && hasQueueFields(nested)) queue = nested;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
...(status === undefined ? {} : { status }),
|
|
86
|
+
...(code === '' ? {} : { code }),
|
|
87
|
+
...(message === '' ? {} : { message }),
|
|
88
|
+
...(queue === undefined ? {} : { queue }),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 把一次上游失败归一成 `{ status, code, message, retryAfter? }`。
|
|
94
|
+
*
|
|
95
|
+
* @param {{ status?: number, code?: string, message?: string, queue?: object }} [input]
|
|
96
|
+
* @returns {{ status: number, code: string, message: string, retryAfter?: number }}
|
|
97
|
+
*/
|
|
98
|
+
export function classifyUpstreamFailure(input = {}) {
|
|
99
|
+
const status = toStatus(input.status);
|
|
100
|
+
const code = input.code === undefined || input.code === null ? '' : String(input.code);
|
|
101
|
+
const message =
|
|
102
|
+
typeof input.message === 'string' && input.message.trim() !== ''
|
|
103
|
+
? input.message.trim()
|
|
104
|
+
: status === undefined
|
|
105
|
+
? 'upstream error'
|
|
106
|
+
: `HTTP ${status}`;
|
|
107
|
+
const queue = isObject(input.queue) ? input.queue : undefined;
|
|
108
|
+
|
|
109
|
+
if (code === QUEUED_CODE || queue?.isQueued === true || queue?.serviceAvailable === false) {
|
|
110
|
+
const wait = retryAfterOf(queue);
|
|
111
|
+
const label = queue?.isQueued === true ? '已排队' : '正忙';
|
|
112
|
+
return {
|
|
113
|
+
status: 503,
|
|
114
|
+
code: 'QUEUED',
|
|
115
|
+
message: `千问办公${label}(queued),约 ${wait} 秒后重试:${message}`,
|
|
116
|
+
retryAfter: wait,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (QUOTA_CODES.has(code)) {
|
|
121
|
+
return {
|
|
122
|
+
status: 429,
|
|
123
|
+
code: 'QUOTA_EXCEEDED',
|
|
124
|
+
message: `用量已用完(insufficient quota):${message}`,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (REQUEST_CODES.has(code)) {
|
|
129
|
+
return {
|
|
130
|
+
status: 400,
|
|
131
|
+
code: 'INVALID_REQUEST',
|
|
132
|
+
message: `千问办公拒绝了这次请求(${code}):${message}`,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (UPSTREAM_FAILED_RE.test(message)) {
|
|
137
|
+
return { status: 502, code: 'SERVER', message: `上游服务错误(HTTP 502):${message}` };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (ALL_MODELS_FAILED_RE.test(message)) {
|
|
141
|
+
return {
|
|
142
|
+
status: 503,
|
|
143
|
+
code: 'MODEL_POOL_BUSY',
|
|
144
|
+
message: `千问办公模型池暂时不可用(model pool busy),约 ${DEFAULT_BUSY_WAIT} 秒后重试:${message}`,
|
|
145
|
+
retryAfter: DEFAULT_BUSY_WAIT,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (status === 401 || status === 403) {
|
|
150
|
+
return {
|
|
151
|
+
status: 401,
|
|
152
|
+
code: 'AUTH',
|
|
153
|
+
message: `登录已失效,请重新登录(上游 ${status}:${message})`,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (QUOTA_TEXT_RE.test(message)) {
|
|
158
|
+
return {
|
|
159
|
+
status: 429,
|
|
160
|
+
code: 'QUOTA_EXCEEDED',
|
|
161
|
+
message: `用量已用完(insufficient quota):${message}`,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (status === 429) {
|
|
166
|
+
return {
|
|
167
|
+
status: 429,
|
|
168
|
+
code: 'MODEL_POOL_BUSY',
|
|
169
|
+
message: `上游限流(rate limit),约 ${DEFAULT_BUSY_WAIT} 秒后重试:${message}`,
|
|
170
|
+
retryAfter: DEFAULT_BUSY_WAIT,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (status !== undefined && status >= 500) {
|
|
175
|
+
return { status, code: 'SERVER', message };
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (status === 400) {
|
|
179
|
+
return { status: 400, code: 'INVALID_REQUEST', message };
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return {
|
|
183
|
+
status: status ?? 502,
|
|
184
|
+
code: status !== undefined && status >= 500 ? 'SERVER' : 'INVALID_REQUEST',
|
|
185
|
+
message,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* 给 in-band 错误帧用:pi-ai 只能从文案里认状态码,所以必须带 `HTTP <code>:`。
|
|
191
|
+
* @param {{ status: number, message: string }} failure
|
|
192
|
+
*/
|
|
193
|
+
export function formatFailureMessage(failure) {
|
|
194
|
+
const text = String(failure?.message ?? '');
|
|
195
|
+
return text.startsWith('HTTP ') ? text : `HTTP ${failure.status}: ${text}`;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function retryAfterOf(queue) {
|
|
199
|
+
const value = Number(queue?.retryAfterSeconds);
|
|
200
|
+
if (Number.isFinite(value) && value > 0) return Math.ceil(value);
|
|
201
|
+
return DEFAULT_BUSY_WAIT;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function hasQueueFields(value) {
|
|
205
|
+
return isObject(value)
|
|
206
|
+
&& ('isQueued' in value || 'serviceAvailable' in value || 'retryAfterSeconds' in value);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function toStatus(value) {
|
|
210
|
+
const n = Number(value);
|
|
211
|
+
return Number.isInteger(n) && n > 0 ? n : undefined;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function tryParse(value) {
|
|
215
|
+
if (typeof value !== 'string' || value.trim() === '') return undefined;
|
|
216
|
+
try {
|
|
217
|
+
return JSON.parse(value);
|
|
218
|
+
} catch {
|
|
219
|
+
return undefined;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function isObject(value) {
|
|
224
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
225
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-qwenwork-connect",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "千问办公(QwenWork)的 DSH 模型提供方:device flow 登录、官方网关、支持工具调用",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "AaIchhe",
|
|
@@ -27,11 +27,10 @@
|
|
|
27
27
|
"files": [
|
|
28
28
|
"lib/",
|
|
29
29
|
"bin/",
|
|
30
|
-
"research/wasm.bin",
|
|
31
|
-
"research/qoder-wasm-glue.mjs",
|
|
32
30
|
"cordis.patch.yml",
|
|
33
31
|
"README.md",
|
|
34
|
-
"LICENSE"
|
|
32
|
+
"LICENSE",
|
|
33
|
+
"THIRD-PARTY-NOTICES.md"
|
|
35
34
|
],
|
|
36
35
|
"peerDependencies": {
|
|
37
36
|
"@deepseek-ai/cordis": "^4.0.2 || ^5.0.0-0",
|
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
// ============================================================================
|
|
2
|
-
// qoder_auth_wasm glue 的独立 Node 复刻版
|
|
3
|
-
// 目标:在 Node 中实例化 QwenWorkCN 内联的签名 WASM 并直接调用官方签名逻辑。
|
|
4
|
-
//
|
|
5
|
-
// 来源(只读):qoder-worker-runtime.obf.mjs 中的 wasm-bindgen glue 区块
|
|
6
|
-
// 本文件是手写复刻,逐一对照原 glue 的语义(见 research/glue/qodercontext_pretty.js)
|
|
7
|
-
// 不含任何凭据。
|
|
8
|
-
// ============================================================================
|
|
9
|
-
import fs from 'node:fs';
|
|
10
|
-
|
|
11
|
-
// ---------------------------------------------------------------------------
|
|
12
|
-
// wasm-bindgen 运行时状态
|
|
13
|
-
// ---------------------------------------------------------------------------
|
|
14
|
-
let kt = null; // wasm exports
|
|
15
|
-
let LlA = null; // DataView cache
|
|
16
|
-
let F6A = null; // Uint8Array cache
|
|
17
|
-
let U6A = 0; // heap object free slot
|
|
18
|
-
const Zq = new Array(1024).fill(undefined);
|
|
19
|
-
Zq.push(undefined, null, true, false);
|
|
20
|
-
U6A = Zq.length;
|
|
21
|
-
const N6A = new TextEncoder();
|
|
22
|
-
let KQt = 0;
|
|
23
|
-
let ug = 0; // 最近写入的字节长度
|
|
24
|
-
const Vfs = 2146435072;
|
|
25
|
-
let oCe = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
26
|
-
|
|
27
|
-
function ZB(A) { // addHeapObject
|
|
28
|
-
if (U6A === Zq.length) Zq.push(Zq.length + 1);
|
|
29
|
-
const e = U6A;
|
|
30
|
-
U6A = Zq[e];
|
|
31
|
-
Zq[e] = A;
|
|
32
|
-
return e;
|
|
33
|
-
}
|
|
34
|
-
function jfs(A) { // takeHeapObject
|
|
35
|
-
if (A < 1028) return;
|
|
36
|
-
Zq[A] = U6A;
|
|
37
|
-
U6A = A;
|
|
38
|
-
}
|
|
39
|
-
function DSA(A, e) { // getUint8ArrayFromMem
|
|
40
|
-
return A >>>= 0, SSA().subarray(A, A + e);
|
|
41
|
-
}
|
|
42
|
-
function Mr() { // getDataView
|
|
43
|
-
if (LlA === null || LlA.buffer.detached === true ||
|
|
44
|
-
(LlA.buffer.detached === undefined && LlA.buffer !== kt.memory.buffer)) {
|
|
45
|
-
LlA = new DataView(kt.memory.buffer);
|
|
46
|
-
}
|
|
47
|
-
return LlA;
|
|
48
|
-
}
|
|
49
|
-
function Ww(A, e) { // getStringFromWasm0
|
|
50
|
-
return qfs(A >>>= 0, e);
|
|
51
|
-
}
|
|
52
|
-
function SSA() { // getUint8Array
|
|
53
|
-
if (F6A === null || F6A.byteLength === 0) F6A = new Uint8Array(kt.memory.buffer);
|
|
54
|
-
return F6A;
|
|
55
|
-
}
|
|
56
|
-
function om(A) { return Zq[A]; } // getObject
|
|
57
|
-
function Wq(A) { return A === null || A === undefined; }
|
|
58
|
-
function kS(A) { const e = om(A); jfs(A); return e; } // takeObject
|
|
59
|
-
|
|
60
|
-
function b6A(A, e) { // handleError: run + route JS exception into wasm
|
|
61
|
-
try { return A.apply(this, e); }
|
|
62
|
-
catch (A) { kt.__wbindgen_export(ZB(A)); }
|
|
63
|
-
}
|
|
64
|
-
function qfs(A, e) { // getStringFromWasm0 impl
|
|
65
|
-
KQt += e;
|
|
66
|
-
if (KQt >= Vfs) { oCe = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); oCe.decode(); KQt = e; }
|
|
67
|
-
return oCe.decode(SSA().subarray(A, A + e));
|
|
68
|
-
}
|
|
69
|
-
function QZn(A, e) { // passArray8ToWasm0
|
|
70
|
-
const t = e(A.length, 1) >>> 0;
|
|
71
|
-
SSA().set(A, t);
|
|
72
|
-
ug = A.length;
|
|
73
|
-
return t;
|
|
74
|
-
}
|
|
75
|
-
function bf(A, e, t) { // passStringToWasm0
|
|
76
|
-
if (t === undefined) {
|
|
77
|
-
const t = N6A.encode(A);
|
|
78
|
-
const i = e(t.length, 1) >>> 0;
|
|
79
|
-
SSA().subarray(i, i + t.length).set(t);
|
|
80
|
-
ug = t.length;
|
|
81
|
-
return i;
|
|
82
|
-
}
|
|
83
|
-
let i = A.length;
|
|
84
|
-
let n = e(i, 1) >>> 0;
|
|
85
|
-
const r = SSA();
|
|
86
|
-
let o = 0;
|
|
87
|
-
for (; o < i; o++) { const e = A.charCodeAt(o); if (e > 127) break; r[n + o] = e; }
|
|
88
|
-
if (o !== i) {
|
|
89
|
-
if (o !== 0) A = A.slice(o);
|
|
90
|
-
n = t(n, i, i = o + 3 * A.length, 1) >>> 0;
|
|
91
|
-
const e = SSA().subarray(n + o, n + i);
|
|
92
|
-
o += N6A.encodeInto(A, e).written;
|
|
93
|
-
n = t(n, i, o, 1) >>> 0;
|
|
94
|
-
}
|
|
95
|
-
ug = o;
|
|
96
|
-
return n;
|
|
97
|
-
}
|
|
98
|
-
function CZn(A, e) { kt = A.exports; LlA = null; F6A = null; return kt; }
|
|
99
|
-
|
|
100
|
-
// ---------------------------------------------------------------------------
|
|
101
|
-
// imports(严格照抄 hZn() 的实现)
|
|
102
|
-
// ---------------------------------------------------------------------------
|
|
103
|
-
function hZn() {
|
|
104
|
-
return {
|
|
105
|
-
'./qoder_auth_wasm_bg.js': {
|
|
106
|
-
__wbg_Error_2e59b1b37a9a34c3: (A, e) => ZB(Error(Ww(A, e))),
|
|
107
|
-
__wbg___wbindgen_is_function_49868bde5eb1e745: (A) => typeof om(A) === 'function',
|
|
108
|
-
__wbg___wbindgen_is_object_40c5a80572e8f9d3: (A) => { const e = om(A); return typeof e === 'object' && e !== null; },
|
|
109
|
-
__wbg___wbindgen_is_string_b29b5c5a8065ba1a: (A) => typeof om(A) === 'string',
|
|
110
|
-
__wbg___wbindgen_is_undefined_c0cca72b82b86f4d: (A) => om(A) === undefined,
|
|
111
|
-
__wbg___wbindgen_throw_81fc77679af83bc6: (A, e) => { throw new Error(Ww(A, e)); },
|
|
112
|
-
__wbg_call_d578befcc3145dee: function () { return b6A((A, e, t) => ZB(om(A).call(om(e), om(t))), arguments); },
|
|
113
|
-
__wbg_crypto_38df2bab126b63dc: (A) => ZB(om(A).crypto),
|
|
114
|
-
__wbg_getRandomValues_c44a50d8cfdaebeb: function () { return b6A((A, e) => { om(A).getRandomValues(om(e)); }, arguments); },
|
|
115
|
-
__wbg_getRandomValues_d49329ff89a07af1: function () { return b6A((A, e) => { globalThis.crypto.getRandomValues(DSA(A, e)); }, arguments); },
|
|
116
|
-
__wbg_length_0c32cb8543c8e4c8: (A) => om(A).length,
|
|
117
|
-
__wbg_msCrypto_bd5a034af96bcba6: (A) => ZB(om(A).msCrypto),
|
|
118
|
-
__wbg_new_99cabae501c0a8a0: () => ZB(new Map()),
|
|
119
|
-
__wbg_new_with_length_9cedd08484b73942: (A) => ZB(new Uint8Array(A >>> 0)),
|
|
120
|
-
__wbg_node_84ea875411254db1: (A) => ZB(om(A).node),
|
|
121
|
-
__wbg_now_88621c9c9a4f3ffc: () => Date.now(),
|
|
122
|
-
__wbg_process_44c7a14e11e9f69e: (A) => ZB(om(A).process),
|
|
123
|
-
__wbg_prototypesetcall_3e05eb9545565046: (A, e, t) => { Uint8Array.prototype.set.call(DSA(A, e), om(t)); },
|
|
124
|
-
__wbg_randomFillSync_6c25eac9869eb53c: function () { return b6A((A, e) => { om(A).randomFillSync(kS(e)); }, arguments); },
|
|
125
|
-
// 注意:原 glue 用 module.require;在 ESM 下 module 不存在,但该分支在本流程中用不到,
|
|
126
|
-
// 保留惰性求值以免 import 阶段抛错。
|
|
127
|
-
__wbg_require_b4edbdcf3e2a1ef0: function () {
|
|
128
|
-
return b6A(function () { return ZB(typeof module !== 'undefined' ? module.require : (() => { throw new Error('require unavailable'); })); }, arguments);
|
|
129
|
-
},
|
|
130
|
-
__wbg_set_08463b1df38a7e29: (A, e, t) => ZB(om(A).set(om(e), om(t))),
|
|
131
|
-
__wbg_static_accessor_GLOBAL_THIS_a1248013d790bf5f: () => { const A = typeof globalThis === 'undefined' ? null : globalThis; return Wq(A) ? 0 : ZB(A); },
|
|
132
|
-
__wbg_static_accessor_GLOBAL_f2e0f995a21329ff: () => { const A = typeof global === 'undefined' ? null : global; return Wq(A) ? 0 : ZB(A); },
|
|
133
|
-
__wbg_static_accessor_SELF_24f78b6d23f286ea: () => { const A = typeof self === 'undefined' ? null : self; return Wq(A) ? 0 : ZB(A); },
|
|
134
|
-
__wbg_static_accessor_WINDOW_59fd959c540fe405: () => { const A = typeof window === 'undefined' ? null : window; return Wq(A) ? 0 : ZB(A); },
|
|
135
|
-
__wbg_subarray_0f98d3fb634508ad: (A, e, t) => ZB(om(A).subarray(e >>> 0, t >>> 0)),
|
|
136
|
-
__wbg_versions_276b2795b1c6a219: (A) => ZB(om(A).versions),
|
|
137
|
-
__wbindgen_cast_0000000000000001: (A, e) => ZB(DSA(A, e)),
|
|
138
|
-
__wbindgen_cast_0000000000000002: (A, e) => ZB(Ww(A, e)),
|
|
139
|
-
__wbindgen_object_clone_ref: (A) => ZB(om(A)),
|
|
140
|
-
__wbindgen_object_drop_ref: (A) => { kS(A); },
|
|
141
|
-
},
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// ---------------------------------------------------------------------------
|
|
146
|
-
// 类包装(照抄 H6A / HlA)
|
|
147
|
-
// ---------------------------------------------------------------------------
|
|
148
|
-
const NOOP_REGISTRY = { register: () => {}, unregister: () => {} };
|
|
149
|
-
const IZn = typeof FinalizationRegistry === 'undefined' ? NOOP_REGISTRY
|
|
150
|
-
: new FinalizationRegistry((A) => kt.__wbg_qodercontext_free(A >>> 0, 1));
|
|
151
|
-
const BZn = typeof FinalizationRegistry === 'undefined' ? NOOP_REGISTRY
|
|
152
|
-
: new FinalizationRegistry((A) => kt.__wbg_requestresult_free(A >>> 0, 1));
|
|
153
|
-
|
|
154
|
-
class RequestResult {
|
|
155
|
-
static __wrap(e) {
|
|
156
|
-
e >>>= 0;
|
|
157
|
-
const t = Object.create(RequestResult.prototype);
|
|
158
|
-
t.__wbg_ptr = e;
|
|
159
|
-
BZn.register(t, t.__wbg_ptr, t);
|
|
160
|
-
return t;
|
|
161
|
-
}
|
|
162
|
-
__destroy_into_raw() { const A = this.__wbg_ptr; this.__wbg_ptr = 0; BZn.unregister(this); return A; }
|
|
163
|
-
free() { const A = this.__destroy_into_raw(); kt.__wbg_requestresult_free(A, 0); }
|
|
164
|
-
get body() {
|
|
165
|
-
try {
|
|
166
|
-
const t = kt.__wbindgen_add_to_stack_pointer(-16);
|
|
167
|
-
kt.requestresult_body(t, this.__wbg_ptr);
|
|
168
|
-
const A = Mr().getInt32(t + 0, true), e = Mr().getInt32(t + 4, true);
|
|
169
|
-
let i;
|
|
170
|
-
if (A !== 0) { i = Ww(A, e).slice(); kt.__wbindgen_export4(A, 1 * e, 1); }
|
|
171
|
-
return i;
|
|
172
|
-
} finally { kt.__wbindgen_add_to_stack_pointer(16); }
|
|
173
|
-
}
|
|
174
|
-
get headerCount() { return kt.requestresult_headerCount(this.__wbg_ptr) >>> 0; }
|
|
175
|
-
get headers() { return kS(kt.requestresult_headers(this.__wbg_ptr)); }
|
|
176
|
-
get url() {
|
|
177
|
-
let A, e;
|
|
178
|
-
try {
|
|
179
|
-
const n = kt.__wbindgen_add_to_stack_pointer(-16);
|
|
180
|
-
kt.requestresult_url(n, this.__wbg_ptr);
|
|
181
|
-
const t = Mr().getInt32(n + 0, true), i = Mr().getInt32(n + 4, true);
|
|
182
|
-
A = t; e = i;
|
|
183
|
-
return Ww(t, i);
|
|
184
|
-
} finally { kt.__wbindgen_add_to_stack_pointer(16); kt.__wbindgen_export4(A, e, 1); }
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
class QoderContext {
|
|
189
|
-
__destroy_into_raw() { const A = this.__wbg_ptr; this.__wbg_ptr = 0; IZn.unregister(this); return A; }
|
|
190
|
-
free() { const A = this.__destroy_into_raw(); kt.__wbg_qodercontext_free(A, 0); }
|
|
191
|
-
get_external_providers_access() {
|
|
192
|
-
let A, e;
|
|
193
|
-
try {
|
|
194
|
-
const n = kt.__wbindgen_add_to_stack_pointer(-16);
|
|
195
|
-
kt.qodercontext_get_external_providers_access(n, this.__wbg_ptr);
|
|
196
|
-
const t = Mr().getInt32(n + 0, true), i = Mr().getInt32(n + 4, true);
|
|
197
|
-
A = t; e = i;
|
|
198
|
-
return Ww(t, i);
|
|
199
|
-
} finally { kt.__wbindgen_add_to_stack_pointer(16); kt.__wbindgen_export4(A, e, 1); }
|
|
200
|
-
}
|
|
201
|
-
constructor(A, e, t, i) {
|
|
202
|
-
try {
|
|
203
|
-
const a = kt.__wbindgen_add_to_stack_pointer(-16);
|
|
204
|
-
const g = bf(A, kt.__wbindgen_export2, kt.__wbindgen_export3), l = ug;
|
|
205
|
-
const B = bf(e, kt.__wbindgen_export2, kt.__wbindgen_export3), c = ug;
|
|
206
|
-
const Q = bf(t, kt.__wbindgen_export2, kt.__wbindgen_export3), E = ug;
|
|
207
|
-
const n = Wq(i) ? 0 : bf(i, kt.__wbindgen_export2, kt.__wbindgen_export3), r = ug;
|
|
208
|
-
kt.qodercontext_new(a, g, l, B, c, Q, E, n, r);
|
|
209
|
-
const o = Mr().getInt32(a + 0, true), s = Mr().getInt32(a + 4, true);
|
|
210
|
-
if (Mr().getInt32(a + 8, true)) throw kS(s);
|
|
211
|
-
this.__wbg_ptr = o >>> 0;
|
|
212
|
-
IZn.register(this, this.__wbg_ptr, this);
|
|
213
|
-
return this;
|
|
214
|
-
} finally { kt.__wbindgen_add_to_stack_pointer(16); }
|
|
215
|
-
}
|
|
216
|
-
prepareInferRequest(A, e, t, i) {
|
|
217
|
-
try {
|
|
218
|
-
const l = kt.__wbindgen_add_to_stack_pointer(-16);
|
|
219
|
-
const B = bf(A, kt.__wbindgen_export2, kt.__wbindgen_export3), c = ug;
|
|
220
|
-
const Q = bf(e, kt.__wbindgen_export2, kt.__wbindgen_export3), E = ug;
|
|
221
|
-
const n = Wq(t) ? 0 : bf(t, kt.__wbindgen_export2, kt.__wbindgen_export3), r = ug;
|
|
222
|
-
const o = Wq(i) ? 0 : bf(i, kt.__wbindgen_export2, kt.__wbindgen_export3), s = ug;
|
|
223
|
-
kt.qodercontext_prepareInferRequest(l, this.__wbg_ptr, B, c, Q, E, n, r, o, s);
|
|
224
|
-
const a = Mr().getInt32(l + 0, true), g = Mr().getInt32(l + 4, true);
|
|
225
|
-
if (Mr().getInt32(l + 8, true)) throw kS(g);
|
|
226
|
-
return RequestResult.__wrap(a);
|
|
227
|
-
} finally { kt.__wbindgen_add_to_stack_pointer(16); }
|
|
228
|
-
}
|
|
229
|
-
prepareRequest(A, e, t, i, n, r) {
|
|
230
|
-
try {
|
|
231
|
-
const c = kt.__wbindgen_add_to_stack_pointer(-16);
|
|
232
|
-
const Q = bf(A, kt.__wbindgen_export2, kt.__wbindgen_export3), E = ug;
|
|
233
|
-
const I = bf(e, kt.__wbindgen_export2, kt.__wbindgen_export3), u = ug;
|
|
234
|
-
const d = bf(t, kt.__wbindgen_export2, kt.__wbindgen_export3), C = ug;
|
|
235
|
-
const w = bf(i, kt.__wbindgen_export2, kt.__wbindgen_export3), h = ug;
|
|
236
|
-
const o = Wq(n) ? 0 : bf(n, kt.__wbindgen_export2, kt.__wbindgen_export3), s = ug;
|
|
237
|
-
const a = Wq(r) ? 0 : bf(r, kt.__wbindgen_export2, kt.__wbindgen_export3), g = ug;
|
|
238
|
-
kt.qodercontext_prepareRequest(c, this.__wbg_ptr, Q, E, I, u, d, C, w, h, o, s, a, g);
|
|
239
|
-
const l = Mr().getInt32(c + 0, true), B = Mr().getInt32(c + 4, true);
|
|
240
|
-
if (Mr().getInt32(c + 8, true)) throw kS(B);
|
|
241
|
-
return RequestResult.__wrap(l);
|
|
242
|
-
} finally { kt.__wbindgen_add_to_stack_pointer(16); }
|
|
243
|
-
}
|
|
244
|
-
refreshAuthFields(A) {
|
|
245
|
-
try {
|
|
246
|
-
const t = kt.__wbindgen_add_to_stack_pointer(-16);
|
|
247
|
-
const i = bf(A, kt.__wbindgen_export2, kt.__wbindgen_export3), n = ug;
|
|
248
|
-
kt.qodercontext_refreshAuthFields(t, this.__wbg_ptr, i, n);
|
|
249
|
-
const e = Mr().getInt32(t + 0, true);
|
|
250
|
-
if (Mr().getInt32(t + 4, true)) throw kS(e);
|
|
251
|
-
} finally { kt.__wbindgen_add_to_stack_pointer(16); }
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// ---------------------------------------------------------------------------
|
|
256
|
-
// initSync:给定 wasm bytes,构造 imports 并实例化
|
|
257
|
-
// ---------------------------------------------------------------------------
|
|
258
|
-
export function initSync(wasmBytes) {
|
|
259
|
-
if (kt !== null) return kt;
|
|
260
|
-
const e = hZn();
|
|
261
|
-
const mod = wasmBytes instanceof WebAssembly.Module ? wasmBytes : new WebAssembly.Module(wasmBytes);
|
|
262
|
-
return CZn(new WebAssembly.Instance(mod, e), mod);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
export function getWasm() { return kt; }
|
|
266
|
-
export function wasmExports() { return kt; }
|
|
267
|
-
export { QoderContext, RequestResult };
|
|
268
|
-
|
|
269
|
-
// ---------------------------------------------------------------------------
|
|
270
|
-
// 顶层自由函数(照抄 glue 中 Ufs / Ffs / Nfs / Lfs / Hfs / Ofs / Yfs 等)
|
|
271
|
-
// 注意:kt.xxx 是 wasm 原始导出,ABI 为 (retptr, ptr, len) -> (),
|
|
272
|
-
// 绝不能按 JS 语义直接调用,必须经过下面的包装。
|
|
273
|
-
// ---------------------------------------------------------------------------
|
|
274
|
-
export function generate_runtime_auth_fields(A) {
|
|
275
|
-
let e, t;
|
|
276
|
-
try {
|
|
277
|
-
const g = kt.__wbindgen_add_to_stack_pointer(-16);
|
|
278
|
-
const l = bf(A, kt.__wbindgen_export2, kt.__wbindgen_export3), B = ug;
|
|
279
|
-
kt.generate_runtime_auth_fields(g, l, B);
|
|
280
|
-
const i = Mr().getInt32(g + 0, true), n = Mr().getInt32(g + 4, true);
|
|
281
|
-
const r = Mr().getInt32(g + 8, true), o = Mr().getInt32(g + 12, true);
|
|
282
|
-
let s = i, a = n;
|
|
283
|
-
if (o) { s = 0; a = 0; throw kS(r); }
|
|
284
|
-
e = s; t = a;
|
|
285
|
-
return Ww(s, a);
|
|
286
|
-
} finally {
|
|
287
|
-
kt.__wbindgen_add_to_stack_pointer(16);
|
|
288
|
-
kt.__wbindgen_export4(e, t, 1);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
export function decrypt_server_response(A) {
|
|
293
|
-
let e, t;
|
|
294
|
-
try {
|
|
295
|
-
const g = kt.__wbindgen_add_to_stack_pointer(-16);
|
|
296
|
-
const l = bf(A, kt.__wbindgen_export2, kt.__wbindgen_export3), B = ug;
|
|
297
|
-
kt.decrypt_server_response(g, l, B);
|
|
298
|
-
const i = Mr().getInt32(g + 0, true), n = Mr().getInt32(g + 4, true);
|
|
299
|
-
const r = Mr().getInt32(g + 8, true), o = Mr().getInt32(g + 12, true);
|
|
300
|
-
let s = i, a = n;
|
|
301
|
-
if (o) { s = 0; a = 0; throw kS(r); }
|
|
302
|
-
e = s; t = a;
|
|
303
|
-
return Ww(s, a);
|
|
304
|
-
} finally {
|
|
305
|
-
kt.__wbindgen_add_to_stack_pointer(16);
|
|
306
|
-
kt.__wbindgen_export4(e, t, 1);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
function nullary0(fn) {
|
|
311
|
-
let A, e;
|
|
312
|
-
try {
|
|
313
|
-
const n = kt.__wbindgen_add_to_stack_pointer(-16);
|
|
314
|
-
kt[fn](n);
|
|
315
|
-
const t = Mr().getInt32(n + 0, true), i = Mr().getInt32(n + 4, true);
|
|
316
|
-
A = t; e = i;
|
|
317
|
-
return Ww(t, i);
|
|
318
|
-
} finally {
|
|
319
|
-
kt.__wbindgen_add_to_stack_pointer(16);
|
|
320
|
-
kt.__wbindgen_export4(A, e, 1);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
export const get_httpdns_account_id = () => nullary0('get_httpdns_account_id');
|
|
324
|
-
export const get_httpdns_config = () => nullary0('get_httpdns_config');
|
|
325
|
-
export const get_httpdns_secret_key = () => nullary0('get_httpdns_secret_key');
|
|
326
|
-
export const get_profile_key_fingerprint = () => nullary0('get_profile_key_fingerprint');
|
|
327
|
-
|
|
328
|
-
// 便捷:从文件加载
|
|
329
|
-
export function initFromFile(p) { return initSync(fs.readFileSync(p)); }
|
package/research/wasm.bin
DELETED
|
Binary file
|