"""Package locally built additions into the verified official 4.0.11 runtime.""" from pathlib import Path import json,struct,hashlib,shutil root=Path(__file__).resolve().parent.parent stage=root/'integration-work/stage-4.0.11/app' archive=stage/'resources/app.asar' baseline=archive.with_name('app.official-4.0.11.asar') if not baseline.exists(): shutil.copy2(archive,baseline) raw=baseline.read_bytes() _,header_size,_,json_size=struct.unpack('<4I',raw[:16]) header=json.loads(raw[16:16+json_size]); data=raw[8+header_size:] replacements={'build/backend.mjs':root/'huobao-source/desktop/build/backend.mjs', 'dist/main.js':root/'huobao-source/desktop/dist/main.js', 'dist/preload.js':root/'huobao-source/desktop/dist/preload.js'} for target,source in replacements.items(): node=header for part in target.split('/'): node=node['files'][part] content=source.read_bytes() node['size']=len(content); node['offset']=str(len(data)) block_size=4194304 node['integrity']={'algorithm':'SHA256','hash':hashlib.sha256(content).hexdigest(),'blockSize':block_size, 'blocks':[hashlib.sha256(content[i:i+block_size]).hexdigest() for i in range(0,len(content),block_size)]} data+=content encoded=json.dumps(header,separators=(',',':')).encode() padding=b'\0'*((-len(encoded))%4) size=8+len(encoded)+len(padding) archive.write_bytes(struct.pack('<4I',4,size,size-4,len(encoded))+encoded+padding+data) frontend=root/'huobao-source/frontend/.output/public' shutil.copytree(frontend,stage/'resources/frontend',dirs_exist_ok=True) for directory in ('prompts', 'skills'): shutil.copytree(root/'huobao-source/backend/workspace'/directory, stage/'resources/workspace-template'/directory,dirs_exist_ok=True) manifest={'upstream_version':'4.0.11','source_commit':'b48e6b2312166e25b1ff141832d2e82e5d63c142', 'custom_features':['persistent-data','local-video-pool','multi-gpu-images','vdn-hd-versions','per-model-gpu-selection','fixed-gpu-models','cancel-and-regenerate','per-shot-routing','direct-comfy-panels','confirmed-worker-labels','asset-image-references','durable-local-task-tracking','cross-episode-continuity','tail-frame-dependency-queue','storyboard-timeline-validation','gpu-replacement-inline-references','comfy-live-progress-and-estimates','per-task-image-video-cancel','bilingual-storyboard-english-h3-submission'], 'archive_sha256':hashlib.sha256(archive.read_bytes()).hexdigest()} manifest['custom_features'].append('shared-scene-environment-lock-and-references') manifest['custom_features'].extend(['per-shot-model-reference-limits','doubao-thinking-off-bounded-english-translation']) manifest['custom_features'].append('ltx-wan-all-reference-first-frame-composition') manifest['custom_features'].append('verified-local-video-comfy-source-cleanup') manifest['custom_features'].append('tracked-storyboard-jobs-atomic-bilingual-save') manifest['custom_features'].append('single-and-batch-storyboard-soft-delete') manifest['custom_features'].append('storyboard-draft-voice-normalization-and-no-progress-guard') manifest['custom_features'].append('storyboard-section-coverage-and-dialogue-timing') (stage/'resources/huobao-local-build.json').write_text(json.dumps(manifest,indent=2)) print('Staged 4.0.11 with persistent data and VDN HD:',manifest['archive_sha256'])