Files
baji-vc/scripts/import-standing-avatar.py
T
zenord 9ea5eb31c1 feat: deliver clean avatar home in 0.6.2 UI debug candidate
Keep the avatar mounted while all connection, permission, privacy and diagnostic controls live in a settings sheet. Save the tested continuous-body renderer, safe transition driver and foreground HELLO/permission workflow from this session. Pin runtime03 for the code14 UI-only candidate; mouth deformation remains unresolved. Add source UI contracts, an optional sensor-free device probe, exact asset import and candidate packaging checks. Portrait binaries and diagnostics remain private and untracked.
2026-10-12 22:19:56 +08:00

64 lines
3.7 KiB
Python

#!/usr/bin/env python3
"""Import a pinned accepted reference, or review motion bytes without activating them."""
from pathlib import Path
import argparse, hashlib, json, re
ROOT = Path(__file__).resolve().parents[1]
STILL_SHA = '5dd89c63879f250d05745b506bb79329aa69171b2f6d1660879af85cea926329'
def sha(data): return hashlib.sha256(data).hexdigest()
def review_motion(source):
raw=(source/'manifest.json').read_bytes()
assert len(raw)<=256000
manifest=json.loads(raw)
assert manifest['schemaVersion']==1 and manifest['identityId']=='a01'
rows=manifest['assets']; assert isinstance(rows,list) and len(rows)<=32
total=0
for row in rows:
name=row['path']; assert re.fullmatch(r'(videos|delivery)/[A-Za-z0-9_.-]+\.mp4',name)
path=(source/name).resolve(strict=True); assert path.is_relative_to(source)
data=path.read_bytes(); assert len(data)<=16000000 and sha(data)==row['sha256']
assert row['emotion']=='neutral' and row['intensity']==0 and row['hasAudio'] is False
total+=len(data); assert total<=128000000
ext=manifest.get('safeTransitions',{})
print(json.dumps({'manifestSha256':sha(raw),'reviewStatus':ext.get('reviewStatus','unknown'),
'edgesDeclared':len(ext.get('transitions',[])),'activated':False,
'note':'Read-only byte/hash review. No import/approval; runtime allowlist remains explicit and empty until coordinator approval.'},indent=2))
def main():
parser=argparse.ArgumentParser(description=__doc__)
parser.add_argument('source',type=Path)
parser.add_argument('--review-motion-only',action='store_true')
parser.add_argument('--arms-reference',action='store_true',help='SOURCE is the exact accepted original crossed-arms PNG')
args=parser.parse_args(); source=args.source.resolve(strict=True)
if args.arms_reference:
assert not args.review_motion_only
expected='36a078ad9e1d2929612e9baa2af524bda90dafceddc4515dd448fc08121d7dd2'
assert source.is_file() and source.stat().st_size<=8_000_000
data=source.read_bytes(); assert sha(data)==expected
dest=ROOT/'app/src/main/assets/avatar/a01-standing-arms-reference/frames/reference.png'
assert not dest.exists() or sha(dest.read_bytes())==expected, 'Unknown existing static asset'
dest.parent.mkdir(parents=True,exist_ok=True,mode=0o700)
dest.write_bytes(data); dest.chmod(0o600)
print(json.dumps({'staticReferenceSha256':expected,'motionActivated':False,'rightsStatus':'unverified'}))
return
if args.review_motion_only: review_motion(source); return
raw=(source/'reference-manifest.json').read_bytes(); manifest=json.loads(raw)
assert manifest['schemaVersion']==1 and manifest['packId']=='a01-standing-v2' and manifest['identityId']=='a01'
assert manifest['referencePath']=='frames/standing-reference.png' and manifest['sha256']==STILL_SHA
image=(source/manifest['referencePath']).resolve(strict=True); assert image.is_relative_to(source)
data=image.read_bytes(); assert len(data)<=8000000 and sha(data)==STILL_SHA
target=ROOT/'app/src/main/assets/avatar/a01-standing-v2'
files={'frames/standing-reference.png':data,'reference-manifest.json':raw}
for name,contents in files.items():
dest=target/name
assert not dest.exists() or sha(dest.read_bytes())==sha(contents),f'Unknown existing asset: {dest}'
for name,contents in files.items():
dest=target/name; dest.parent.mkdir(parents=True,exist_ok=True,mode=0o700)
dest.write_bytes(contents); dest.chmod(0o600)
print(json.dumps({'pack':'a01-standing-v2','staticIdentityApproval':'user confirmed this exact image for testing',
'sha256':STILL_SHA,'motionActivated':False,'rightsStatus':'unverified'},indent=2))
if __name__=='__main__': main()