@ninkch/dsh-infinite-canvas 0.19.15 → 0.19.16
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/client.js +41 -6
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -6266,6 +6266,44 @@ function queueThumb(assetId) {
|
|
|
6266
6266
|
taskUrl: (tid) => apiRoot + '/api/v1/tasks/' + encodeURIComponent(tid),
|
|
6267
6267
|
};
|
|
6268
6268
|
}
|
|
6269
|
+
/** DashScope 兼容中转站的响应形态归一(tiantoken 等中转会改写响应结构,纯函数供回归断言):
|
|
6270
|
+
* · task_id:output.task_id → task_id → data.task_id → output.id → id;
|
|
6271
|
+
* · 状态:output.task_status → output.status → task_status → status,统一小写比较
|
|
6272
|
+
* (官方大写 SUCCEEDED / 中转小写 succeeded / 顶层 status 都能认);
|
|
6273
|
+
* · 成功/失败集合外的一切状态(unknown/pending/running 及未知值)= 继续轮询,绝不误杀
|
|
6274
|
+
* (中转在任务刚提交、上游未回报时常回 {status:'unknown'})。 */
|
|
6275
|
+
function wanTaskIdOf(j) {
|
|
6276
|
+
if (!j || typeof j !== 'object') return null;
|
|
6277
|
+
return (j.output && j.output.task_id) || j.task_id || (j.data && j.data.task_id)
|
|
6278
|
+
|| (j.output && j.output.id) || j.id || null;
|
|
6279
|
+
}
|
|
6280
|
+
const WAN_STATUS_DONE = ['succeeded', 'success', 'done', 'completed', 'complete', 'finished', 'ok'];
|
|
6281
|
+
const WAN_STATUS_FAIL = ['failed', 'failure', 'fail', 'error', 'canceled', 'cancelled', 'expired', 'rejected', 'timeout'];
|
|
6282
|
+
function wanStatusOf(j) {
|
|
6283
|
+
if (!j || typeof j !== 'object') return '';
|
|
6284
|
+
const v = (j.output && (j.output.task_status ?? j.output.status)) ?? j.task_status ?? j.status;
|
|
6285
|
+
return String(v ?? '').trim().toLowerCase();
|
|
6286
|
+
}
|
|
6287
|
+
function wanVideoUrlOf(j) {
|
|
6288
|
+
if (!j || typeof j !== 'object') return '';
|
|
6289
|
+
const o = j.output || {};
|
|
6290
|
+
return [o.video_url, o.url, o.videoUrl, j.video_url, j.data && j.data.result_url]
|
|
6291
|
+
.find((u) => typeof u === 'string' && /^https?:/.test(u)) || '';
|
|
6292
|
+
}
|
|
6293
|
+
function wanErrorOf(j) {
|
|
6294
|
+
const o = (j && j.output) || {};
|
|
6295
|
+
const msg = o.message || (j && (j.message || (j.error && j.error.message))) || '';
|
|
6296
|
+
return (o.code && msg) ? (o.code + ' ' + msg) : (msg || o.code || '');
|
|
6297
|
+
}
|
|
6298
|
+
function wanPollState(j) {
|
|
6299
|
+
const st = wanStatusOf(j);
|
|
6300
|
+
if (WAN_STATUS_DONE.includes(st)) {
|
|
6301
|
+
const url = wanVideoUrlOf(j);
|
|
6302
|
+
return url ? { state: 'done', url } : { state: 'fail', error: '成功但无视频地址' };
|
|
6303
|
+
}
|
|
6304
|
+
if (WAN_STATUS_FAIL.includes(st)) return { state: 'fail', error: wanErrorOf(j) || st };
|
|
6305
|
+
return { state: 'wait' }; // unknown/pending/running 及一切未知状态 = 继续轮询
|
|
6306
|
+
}
|
|
6269
6307
|
/** 读取生成视频的真实尺寸与时长(用于「厂商是否忽略了参数」的可见校验)。 */
|
|
6270
6308
|
function probeVideoMeta(blob) {
|
|
6271
6309
|
return new Promise((resolve) => {
|
|
@@ -6427,17 +6465,14 @@ function queueThumb(assetId) {
|
|
|
6427
6465
|
const r1 = await fetchViaProxy(ep.submitUrl, { headers, body, label: 'Wan 提交' });
|
|
6428
6466
|
if (!r1.ok) throw new Error('Wan 提交 HTTP ' + r1.status + ' @ ' + ep.submitUrl + ':' + r1.text.slice(0, 300));
|
|
6429
6467
|
let j1 = null; try { j1 = JSON.parse(r1.text); } catch { throw new Error('Wan 响应非 JSON:' + r1.text.slice(0, 200)); }
|
|
6430
|
-
const tid = j1
|
|
6468
|
+
const tid = wanTaskIdOf(j1);
|
|
6431
6469
|
if (!tid) throw new Error('Wan 响应中没有 task_id:' + r1.text.slice(0, 200));
|
|
6432
6470
|
if (o.onTask) { try { o.onTask(tid, ep.taskUrl(tid)); } catch { /* 持久化失败不影响生成 */ } }
|
|
6433
6471
|
const url = await vendorPoll('Wan', 8000, async () => {
|
|
6434
6472
|
const r = await fetchViaProxy(ep.taskUrl(tid), { method: 'GET', headers: { Authorization: 'Bearer ' + (s.apiKey || '') }, timeoutMs: 60000, label: 'Wan 查询' });
|
|
6435
6473
|
if (!r || !r.ok) return { state: 'wait' };
|
|
6436
6474
|
let j = null; try { j = JSON.parse(r.text); } catch { return { state: 'wait' }; }
|
|
6437
|
-
|
|
6438
|
-
if (st === 'SUCCEEDED') return j.output.video_url ? { state: 'done', url: j.output.video_url } : { state: 'fail', error: '成功但无视频地址' };
|
|
6439
|
-
if (st === 'FAILED' || st === 'CANCELED') return { state: 'fail', error: (j.output && j.output.message) || st };
|
|
6440
|
-
return { state: 'wait' };
|
|
6475
|
+
return wanPollState(j);
|
|
6441
6476
|
});
|
|
6442
6477
|
return await downloadVideo(url, {});
|
|
6443
6478
|
},
|
|
@@ -20153,7 +20188,7 @@ const DIRECTOR_KEY_HELP = [
|
|
|
20153
20188
|
// IC-04:参考图上传三件套的纯函数出口(供 scripts/test-image-upload.mjs 直接断言)
|
|
20154
20189
|
window.__DSH_IC_IMGREF__ = { rawImageDims, sniffImageEncoding, registerReferenceAsset };
|
|
20155
20190
|
// IC-03:视频厂商识别/前缀归一化的纯函数出口(供 scripts/test-vendor-detect.mjs 直接断言)
|
|
20156
|
-
window.__DSH_IC_VENDOR__ = { detectVideoVendor, gatewayPrefixFor, wanEndpoints, vendorBase, VIDEO_REF_CAPS, needsSimpleMediaRetry, buildSimpleMediaRetryBody };
|
|
20191
|
+
window.__DSH_IC_VENDOR__ = { detectVideoVendor, gatewayPrefixFor, wanEndpoints, vendorBase, VIDEO_REF_CAPS, needsSimpleMediaRetry, buildSimpleMediaRetryBody, wanTaskIdOf, wanStatusOf, wanPollState };
|
|
20157
20192
|
// 按镜头切段(分段生成本身就是最容易出错的地方):规划器 + 强弱模型分流 + 节点段区间解析
|
|
20158
20193
|
// 供 scripts/test-segment-plan.mjs 直接断言
|
|
20159
20194
|
window.__DSH_IC_SEGMENT__ = { planShotSegments, isCutPoint, segmentNeedsHardFrame, videoSegmentOf, shotContinuityPlan };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninkch/dsh-infinite-canvas",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.16",
|
|
4
4
|
"description": "无限画布(Infinite Canvas)for DeepSeek Harness:节点式创作工作室(剧本/分镜/生成/成片),内置「媒体创作」预设模式(导演第一视角 + 引导工作坊)。Version-agnostic: reads the live catalog from the installed package at load time.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|