dsh-rinko-nai 1.2.1 → 1.2.2
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 +1 -1
- package/lib/index.js +8 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -124,7 +124,7 @@ DSH 插件:在 DSH 里直接用 **YesNAI(公益站 nai.rinko.ai / 主站 yna
|
|
|
124
124
|
- 先跑 `rinko_nai_status`:`modelsOk` 看连通、`keyValid` 看凭据、`account` 看账户。
|
|
125
125
|
- **报错 `SyntaxError: Unexpected token ''` / 插件被跳过、加载不了**:`package.json` 开头混进了 **UTF-8 BOM**(旧包问题,≥1.0.1 已修)。手动救:把文件另存为「UTF-8 无 BOM」;或运行
|
|
126
126
|
`node -e "const fs=require('fs'),f='package.json',b=fs.readFileSync(f);if(b[0]===0xEF&&b[1]===0xBB&&b[2]===0xBF)fs.writeFileSync(f,b.subarray(3))"`。
|
|
127
|
-
- **网络慢/连不上 → 建议开代理**:插件走系统网络(不读插件内代理设置)。若出图或查账户经常「连接超时 / 连不上站点」,多半是到 `*.rinko.ai` 的直连不稳,**开启代理(如 Clash,建议“全局”或“TUN”模式)后再试**即可。插件每次请求分两段计时:**连接 20 秒**连不上就快速报错(不会干吊几百秒),连上后最多等 **
|
|
127
|
+
- **网络慢/连不上 → 建议开代理**:插件走系统网络(不读插件内代理设置)。若出图或查账户经常「连接超时 / 连不上站点」,多半是到 `*.rinko.ai` 的直连不稳,**开启代理(如 Clash,建议“全局”或“TUN”模式)后再试**即可。插件每次请求分两段计时:**连接 20 秒**连不上就快速报错(不会干吊几百秒),连上后最多等 **120 秒**出图。
|
|
128
128
|
- HTTP 502/504:网站上游抖了,稍后再试(设置页「测试连接」会如实报告)。
|
|
129
129
|
实测 2026-11-20 晚:直连与 Clash 代理(127.0.0.1:7897)**同样 502**,且失败请求会自动退款
|
|
130
130
|
(`wallet/ledger` 里是 `generation_debit` + `generation_refund` 成对出现),说明是站点自己的出图上游故障,与本地网络无关。
|
package/lib/index.js
CHANGED
|
@@ -556,7 +556,7 @@ const TOOL_DEFS = {
|
|
|
556
556
|
}
|
|
557
557
|
|
|
558
558
|
async function requestRaw(path, options = {}) {
|
|
559
|
-
const { method = 'POST', body, token, timeoutMs =
|
|
559
|
+
const { method = 'POST', body, token, timeoutMs = 120000, connectTimeoutMs = 20000 } = options
|
|
560
560
|
const headers = {}
|
|
561
561
|
if (token) headers.Authorization = `Bearer ${token}`
|
|
562
562
|
if (body !== undefined) headers['Content-Type'] = 'application/json'
|
|
@@ -768,7 +768,7 @@ async function request(path, options = {}) {
|
|
|
768
768
|
}
|
|
769
769
|
|
|
770
770
|
async function requestOnce(path, options = {}) {
|
|
771
|
-
const { method = 'GET', body, token, timeoutMs =
|
|
771
|
+
const { method = 'GET', body, token, timeoutMs = 120000, connectTimeoutMs = 20000, headers: extraHeaders } = options
|
|
772
772
|
const headers = { ...(extraHeaders || {}) }
|
|
773
773
|
if (token) headers.Authorization = `Bearer ${token}`
|
|
774
774
|
if (body !== undefined) headers['Content-Type'] = 'application/json'
|
|
@@ -1305,7 +1305,7 @@ async function yesnaiGenerate(payload, seedValue, keyObj) {
|
|
|
1305
1305
|
p.parameters.seed = Number(seedValue) % 4294967295
|
|
1306
1306
|
const idemKey = randomUUID()
|
|
1307
1307
|
let key = keyObj.token
|
|
1308
|
-
const call = (retries) => request('/v1/nai/generate-image', { method: 'POST', body: p, token: key, timeoutMs:
|
|
1308
|
+
const call = (retries) => request('/v1/nai/generate-image', { method: 'POST', body: p, token: key, timeoutMs: 120000, retries, headers: { 'Idempotency-Key': idemKey } })
|
|
1309
1309
|
let r = await call(1)
|
|
1310
1310
|
if (!r.ok && r.status === 401 && keyObj.kind === 'auto-key') {
|
|
1311
1311
|
const rec = await recoverAutoKey()
|
|
@@ -1332,7 +1332,7 @@ async function openaiGenerate(payload, keyObj) {
|
|
|
1332
1332
|
}
|
|
1333
1333
|
if (par.negative_prompt) body.negative_prompt = par.negative_prompt
|
|
1334
1334
|
const idemKey = randomUUID()
|
|
1335
|
-
const call = (retries) => request('/v1/images/generations', { method: 'POST', body, token: keyObj.token, timeoutMs:
|
|
1335
|
+
const call = (retries) => request('/v1/images/generations', { method: 'POST', body, token: keyObj.token, timeoutMs: 120000, retries, headers: { 'Idempotency-Key': idemKey } })
|
|
1336
1336
|
let r = await call(1)
|
|
1337
1337
|
if (!r.ok && r.status === 429) { await sleep(2500); r = await call(0) }
|
|
1338
1338
|
if (!r.ok) throw new Error('生成失败:' + describeError(r.status, r.data))
|
|
@@ -1360,7 +1360,7 @@ async function openaiGenerate(payload, keyObj) {
|
|
|
1360
1360
|
}
|
|
1361
1361
|
|
|
1362
1362
|
/** multipart/form-data 请求(OpenAI /images/edits 用)。 */
|
|
1363
|
-
async function requestMultipart(path, { fields = {}, file, token, timeoutMs =
|
|
1363
|
+
async function requestMultipart(path, { fields = {}, file, token, timeoutMs = 120000 } = {}) {
|
|
1364
1364
|
const controller = new AbortController()
|
|
1365
1365
|
let phase = 'connect'
|
|
1366
1366
|
let timer = setTimeout(() => controller.abort(), 20000)
|
|
@@ -1406,8 +1406,8 @@ async function openaiEdit(payload, keyObj, img) {
|
|
|
1406
1406
|
const par = payload.parameters || {}
|
|
1407
1407
|
const fields = { model: payload.model, prompt: payload.input, n: 1, size: `${par.width || 1024}x${par.height || 1024}`, response_format: 'b64_json' }
|
|
1408
1408
|
const file = { field: 'image', buffer: img.buffer, mime: img.mime, name: 'image.' + img.ext }
|
|
1409
|
-
let r = await requestMultipart('/v1/images/edits', { fields, file, token: keyObj.token, timeoutMs:
|
|
1410
|
-
if (!r.ok && r.status === 429) { await sleep(2500); r = await requestMultipart('/v1/images/edits', { fields, file, token: keyObj.token, timeoutMs:
|
|
1409
|
+
let r = await requestMultipart('/v1/images/edits', { fields, file, token: keyObj.token, timeoutMs: 120000 })
|
|
1410
|
+
if (!r.ok && r.status === 429) { await sleep(2500); r = await requestMultipart('/v1/images/edits', { fields, file, token: keyObj.token, timeoutMs: 120000 }) }
|
|
1411
1411
|
if (!r.ok) throw new Error('图生图失败:' + describeError(r.status, r.data))
|
|
1412
1412
|
const raw = r.data || {}
|
|
1413
1413
|
let arr = Array.isArray(raw.data) ? raw.data : (Array.isArray(raw.images) ? raw.images : [])
|
|
@@ -1429,7 +1429,7 @@ async function yesnaiImg2Img(payload, keyObj, img, strength) {
|
|
|
1429
1429
|
p.parameters.strength = Math.min(1, Math.max(0, Number(strength) || 0.7))
|
|
1430
1430
|
p.parameters.noise = 0
|
|
1431
1431
|
const idemKey = randomUUID()
|
|
1432
|
-
const call = (retries) => request('/v1/nai/generate-image', { method: 'POST', body: p, token: keyObj.token, timeoutMs:
|
|
1432
|
+
const call = (retries) => request('/v1/nai/generate-image', { method: 'POST', body: p, token: keyObj.token, timeoutMs: 120000, retries, headers: { 'Idempotency-Key': idemKey } })
|
|
1433
1433
|
let r = await call(1)
|
|
1434
1434
|
if (!r.ok && r.status === 429) { await sleep(2500); r = await call(0) }
|
|
1435
1435
|
if (!r.ok) throw new Error('图生图失败:' + describeError(r.status, r.data))
|