@deepblend/dsh-blender-bundle 0.23.0 → 0.25.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/lib/doctor-cli.js CHANGED
@@ -1,13 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  import { formatEnvironmentReport, inspectEnvironment } from './doctor.js'
3
+ import { runFunctionalProbe } from './functional-probe.js'
3
4
 
4
- const help = `deepblend-doctor [--json] [--require-video]
5
+ const help = `deepblend-doctor [--json] [--require-video] [--probe]
5
6
  [--blender PATH] [--dsh PATH] [--pnpm PATH] [--ffmpeg PATH] [--ffprobe PATH]
6
7
 
7
8
  Read-only environment checks / 只读环境自检
8
9
  Reports all missing tools, supported versions and next steps.
9
10
  FFmpeg/ffprobe are optional unless --require-video is selected.
10
11
  Explicit paths check the executables you name; profile configuration is not read.
12
+ --probe renders a small temporary Blender image and checks MP4 encoding/decoding.
13
+ It does not verify the plugin, the configured model, image input or visual review.
11
14
  Exit: 0 required tools ready, 1 requirements missing, 2 invalid arguments.
12
15
  This does not install tools or change your DSH profile.`
13
16
 
@@ -16,10 +19,12 @@ function main(args) {
16
19
  const commands = {}
17
20
  let json = false
18
21
  let requireVideo = false
22
+ let functional = false
19
23
  for (let i = 0; i < args.length; i++) {
20
24
  const arg = args[i]
21
25
  if (arg === '--json') json = true
22
26
  else if (arg === '--require-video') requireVideo = true
27
+ else if (arg === '--probe') functional = true
23
28
  else if (/^--(?:blender|dsh|pnpm|ffmpeg|ffprobe)$/.test(arg)) {
24
29
  const path = args[++i]
25
30
  if (!path || path.startsWith('--')) { console.error(`${arg} requires an executable path.\n${help}`); return 2 }
@@ -27,8 +32,13 @@ function main(args) {
27
32
  } else { console.error(`Unknown argument: ${arg}\n${help}`); return 2 }
28
33
  }
29
34
  const report = inspectEnvironment({ commands })
35
+ if (functional) {
36
+ report.functional = runFunctionalProbe({ commands })
37
+ report.scope = 'Executable versions and a small temporary Workbench PNG and MP4 round trip only; this does not verify the DSH profile, plugin activation, model, image input, visual review or product quality.'
38
+ }
30
39
  console.log(json ? JSON.stringify(report, null, 2) : formatEnvironmentReport(report))
31
- return report.ready.installation && (!requireVideo || report.ready.video) ? 0 : 1
40
+ const exercised = !functional || (report.functional.blenderPreview.status === 'pass' && (!requireVideo || report.functional.videoEncoding.status === 'pass'))
41
+ return report.ready.installation && (!requireVideo || report.ready.video) && exercised ? 0 : 1
32
42
  }
33
43
 
34
44
  process.exitCode = main(process.argv.slice(2))
package/lib/doctor.js CHANGED
@@ -79,6 +79,15 @@ export function formatEnvironmentReport(report) {
79
79
  lines.push(`[${check.status.toUpperCase()}] ${check.label}: ${check.version ?? check.reason}${check.expected ? ` (requires ${check.expected})` : ''}`)
80
80
  if (check.action) lines.push(` Next: ${check.action}`)
81
81
  }
82
+ if (report.functional) {
83
+ lines.push('', 'Functional probes / 实际运行检查:')
84
+ const labels = { blenderPreview: 'Blender preview / Blender 预览', videoEncoding: 'MP4 encode and decode / 视频编码与解码',
85
+ pluginActivation: 'Plugin activation / 插件启用', agent: 'Agent / 智能体', imageInput: 'Model image input / 模型看图', visualReview: 'Visual review / 视觉评审' }
86
+ for (const [id, result] of Object.entries(report.functional)) lines.push(` ${labels[id] ?? id}: ${result.status}${result.reason ? ` (${result.reason})` : ''}`)
87
+ if (report.functional.blenderPreview.status !== 'pass') lines.push(' Next / 下一步: verify the Blender path and run a preview in DSH. 请检查 Blender 路径并在 DSH 中重试预览。')
88
+ if (report.functional.videoEncoding.status === 'fail') lines.push(' Next / 下一步: check FFmpeg, ffprobe and H.264 encoding; PNG work can continue. 请检查编码器与 H.264 支持,仍可继续制作图片。')
89
+ lines.push(' Small Workbench and MP4 probes do not prove product quality. Check unverified items in the current DSH profile. 小图和编码探针不代表作品质量;未验证项需在当前 DSH 配置中另行检查。')
90
+ }
82
91
  lines.push('', `Installation / 安装: ${report.ready.installation ? 'ready' : 'needs attention'}`,
83
92
  `PNG tools / 图片工具: ${report.ready.images ? 'ready' : 'needs attention'}`,
84
93
  `MP4 tools / 视频工具: ${report.ready.video ? 'ready' : 'needs attention'}`,
@@ -0,0 +1,69 @@
1
+ /** Small, opt-in executable probes. They do not inspect or change DSH profiles. */
2
+ import { spawnSync } from 'node:child_process'
3
+ import { mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs'
4
+ import { crc32, inflateSync } from 'node:zlib'
5
+ import { tmpdir } from 'node:os'
6
+ import { join } from 'node:path'
7
+
8
+ function run(executable, args, timeout = 60_000) {
9
+ const result = spawnSync(executable, args, { encoding: 'utf8', timeout, maxBuffer: 256 * 1024, windowsHide: true, shell: false })
10
+ if (result.error?.code === 'ETIMEDOUT') return { ok: false, reason: 'timeout' }
11
+ if (result.error?.code === 'ENOENT') return { ok: false, reason: 'missing' }
12
+ if (result.error || result.status !== 0) return { ok: false, reason: 'failed' }
13
+ return { ok: true, output: result.stdout ?? '' }
14
+ }
15
+
16
+ // Verify a small PNG all the way through decompression. A plausible header alone
17
+ // is not evidence that Blender wrote a usable picture.
18
+ function validPreview(path) {
19
+ try {
20
+ if (statSync(path).size > 1024 * 1024) return false
21
+ const bytes = readFileSync(path)
22
+ if (!bytes.subarray(0, 8).equals(Buffer.from([137,80,78,71,13,10,26,10]))) return false
23
+ let offset = 8, header, end = false; const compressed = []
24
+ while (offset + 12 <= bytes.length) {
25
+ const length = bytes.readUInt32BE(offset), after = offset + length + 12
26
+ if (after > bytes.length || length > 1024 * 1024) return false
27
+ const type = bytes.toString('ascii', offset + 4, offset + 8), payload = bytes.subarray(offset + 8, offset + 8 + length)
28
+ if (crc32(bytes.subarray(offset + 4, offset + 8 + length)) !== bytes.readUInt32BE(offset + 8 + length)) return false
29
+ if (!header && type !== 'IHDR') return false
30
+ if (type === 'IHDR') { if (header || length !== 13) return false; header = payload }
31
+ if (type === 'IDAT') compressed.push(payload)
32
+ offset = after
33
+ if (type === 'IEND') { end = length === 0 && offset === bytes.length; break }
34
+ }
35
+ if (!header || !end || !compressed.length || header.readUInt32BE(0) !== 64 || header.readUInt32BE(4) !== 64
36
+ || ![8, 16].includes(header[8]) || ![0, 2, 4, 6].includes(header[9]) || header[10] || header[11] || header[12]) return false
37
+ const channels = { 0: 1, 2: 3, 4: 2, 6: 4 }[header[9]], rowBytes = 64 * channels * (header[8] / 8)
38
+ const raw = inflateSync(Buffer.concat(compressed), { maxOutputLength: 64 * (rowBytes + 1) })
39
+ return raw.length === 64 * (rowBytes + 1) && Array.from({ length: 64 }, (_, row) => raw[row * (rowBytes + 1)]).every(filter => filter <= 4)
40
+ } catch { return false }
41
+ }
42
+
43
+ /** A tiny actual Workbench render and MP4 round trip, not a product-quality or model test. */
44
+ export function runFunctionalProbe({ commands = {} } = {}) {
45
+ const directory = mkdtempSync(join(tmpdir(), 'deepblend-probe-'))
46
+ const image = join(directory, 'preview.png'), video = join(directory, 'probe.mp4'), script = join(directory, 'probe.py')
47
+ const checks = { blenderPreview: { status: 'unverified' }, videoEncoding: { status: 'unverified' },
48
+ pluginActivation: { status: 'unverified' }, agent: { status: 'unverified' }, imageInput: { status: 'unverified' }, visualReview: { status: 'unverified' } }
49
+ try {
50
+ writeFileSync(script, `import bpy\ns = bpy.context.scene\ns.render.engine = 'BLENDER_WORKBENCH'\ns.render.resolution_x = 64\ns.render.resolution_y = 64\ns.render.resolution_percentage = 100\ns.render.image_settings.file_format = 'PNG'\ns.render.filepath = ${JSON.stringify(image)}\nbpy.ops.render.render(write_still=True)\n`)
51
+ const rendered = run(commands.blender ?? 'blender', ['--background', '--factory-startup', '--disable-autoexec', '--python-exit-code', '1', '--python', script])
52
+ const pngValid = rendered.ok && validPreview(image)
53
+ checks.blenderPreview = pngValid ? { status: 'pass' } : { status: 'fail', reason: rendered.ok ? 'invalid-output' : rendered.reason }
54
+ if (!pngValid) return checks
55
+ const encoded = run(commands.ffmpeg ?? 'ffmpeg', ['-v','error','-y','-loop','1','-i',image,'-frames:v','2','-r','24','-c:v','libx264','-pix_fmt','yuv420p',video])
56
+ if (!encoded.ok) { checks.videoEncoding = { status: 'fail', reason: encoded.reason }; return checks }
57
+ const probed = run(commands.ffprobe ?? 'ffprobe', ['-v','error','-count_frames','-select_streams','v:0','-show_entries','stream=codec_name,width,height,r_frame_rate,nb_read_frames','-of','json',video])
58
+ let valid = false
59
+ try {
60
+ const streams = JSON.parse(probed.output).streams
61
+ valid = streams.length === 1 && streams[0].codec_name === 'h264' && streams[0].width === 64 && streams[0].height === 64
62
+ && streams[0].r_frame_rate === '24/1' && streams[0].nb_read_frames === '2'
63
+ } catch { /* Missing or malformed evidence is not success. */ }
64
+ if (!probed.ok || !valid) { checks.videoEncoding = { status: 'fail', reason: probed.ok ? 'invalid-output' : probed.reason }; return checks }
65
+ const decoded = run(commands.ffmpeg ?? 'ffmpeg', ['-v','error','-i',video,'-f','null','-'])
66
+ checks.videoEncoding = decoded.ok ? { status: 'pass' } : { status: 'fail', reason: decoded.reason }
67
+ return checks
68
+ } finally { rmSync(directory, { recursive: true, force: true }) }
69
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepblend/dsh-blender-bundle",
3
- "version": "0.23.0",
3
+ "version": "0.25.0",
4
4
  "description": "Create Blender product scenes in DSH with editable recipes, model imports, previews and PNG/MP4 delivery; includes workbench and agent configuration.",
5
5
  "main": "lib/index.js",
6
6
  "bin": {
@@ -44,12 +44,12 @@
44
44
  }
45
45
  },
46
46
  "dependencies": {
47
- "@deepblend/dsh-blender-contracts": "0.23.0",
48
- "@deepblend/dsh-blender-host": "0.23.0",
49
- "@deepblend/dsh-blender-preset": "0.23.0",
50
- "@deepblend/dsh-blender-provider-local": "0.23.0",
51
- "@deepblend/dsh-blender-tool": "0.23.0",
52
- "@deepblend/dsh-blender-ui": "0.23.0"
47
+ "@deepblend/dsh-blender-contracts": "0.25.0",
48
+ "@deepblend/dsh-blender-host": "0.25.0",
49
+ "@deepblend/dsh-blender-preset": "0.25.0",
50
+ "@deepblend/dsh-blender-provider-local": "0.25.0",
51
+ "@deepblend/dsh-blender-tool": "0.25.0",
52
+ "@deepblend/dsh-blender-ui": "0.25.0"
53
53
  },
54
54
  "type": "module",
55
55
  "license": "MIT",