koishi-plugin-p-draw 1.2.0 → 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.
Files changed (2) hide show
  1. package/index.js +27 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1331,7 +1331,31 @@ exports.apply = async function apply(ctx, cfg) {
1331
1331
  body: JSON.stringify(body),
1332
1332
  signal: controller.signal,
1333
1333
  })
1334
- if (!res.ok) throw new Error(`HTTP ${res.status}`)
1334
+ if (!res.ok) {
1335
+ // ComfyUI /prompt 校验失败时会返回 node_errors 等详细错误,尽量带出来便于排查
1336
+ const text = await res.text().catch(() => '')
1337
+ const detail = (() => {
1338
+ try {
1339
+ const data = JSON.parse(text)
1340
+ const nodeErrors = (data && data.node_errors) || (data && data.error && data.error.extra_info && data.error.extra_info.node_errors) || null
1341
+ if (nodeErrors && typeof nodeErrors === 'object') {
1342
+ const lines = Object.entries(nodeErrors).map(([id, e]) => {
1343
+ const cls = (e && e.class_type) || ''
1344
+ const errs = (e && Array.isArray(e.errors) && e.errors.length)
1345
+ ? e.errors.map(x => `${(x && x.message) || ''}${x && x.details ? ' | ' + x.details : ''}`.trim()).join('; ')
1346
+ : JSON.stringify(e)
1347
+ return ` #${id} [${cls}]: ${errs}`
1348
+ })
1349
+ if (lines.length) return `\n${lines.join('\n')}`
1350
+ }
1351
+ if (data && data.error) {
1352
+ return `${data.error.message || ''}${data.error.details ? ' ' + data.error.details : ''}`.trim()
1353
+ }
1354
+ } catch (e) { /* ignore */ }
1355
+ return text.slice(0, 800)
1356
+ })()
1357
+ throw new Error(`HTTP ${res.status}${detail ? ':' + detail : ''}`)
1358
+ }
1335
1359
  return await res.json()
1336
1360
  } finally {
1337
1361
  clearTimeout(timer)
@@ -1606,6 +1630,7 @@ exports.apply = async function apply(ctx, cfg) {
1606
1630
  const submit = await comfyPost('/prompt', { prompt: promptBody, client_id: clientId }, 20000)
1607
1631
  const promptId = submit && submit.prompt_id
1608
1632
  if (!promptId) {
1633
+ if (cfg.outputLogs) logger.warn(`[p-draw] ComfyUI 提交失败,工作流:\n${JSON.stringify(promptBody).slice(0, 3000)}`)
1609
1634
  return { ok: false, message: `ComfyUI 提交失败:${JSON.stringify(submit || {}).slice(0, 300)}` }
1610
1635
  }
1611
1636
 
@@ -3025,7 +3050,7 @@ exports.apply = async function apply(ctx, cfg) {
3025
3050
  logger.warn(`上传原图失败:${e.message}`)
3026
3051
  return session.text('.i2i-upload-fail', [e.message])
3027
3052
  }
3028
- if (cfg.outputLogs) logger.info(`[p-draw] i2i ${session.userId} 原图已上传:${uploadName}`)
3053
+ if (cfg.outputLogs) logger.info(`[p-draw] i2i ${session.userId} 原图已上传:${uploadName} 模式=${mode} ControlNet=${caps.controlNet.available ? caps.controlNet.model : '-'} IPAdapter=${caps.ipAdapter.available ? 'on' : 'off'}`)
3029
3054
 
3030
3055
  // 能力检测(ControlNet / Anima IP-Adapter)
3031
3056
  const caps = await detectI2ICapabilities()
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-p-draw",
3
3
  "description": "p点-绘图,连接本地 ComfyUI 生图。支持自然语言优化、尺寸选择、画师组、固定角色、生成队列,需要配合 p-qiandao 使用",
4
- "version": "1.2.0",
4
+ "version": "1.2.2",
5
5
  "main": "index.js",
6
6
  "files": [
7
7
  "index.js",