19 lines
1.1 KiB
Python
19 lines
1.1 KiB
Python
import sys, json, datetime
|
|
from pathlib import Path
|
|
sys.path.insert(0, r'C:\Users\LB\.agents\skills\shared-unity-skills\scripts')
|
|
import unity_skills as u
|
|
instances = u.list_instances()
|
|
entry = next(i for i in instances if i['path'].replace('\\','/').lower() == 'c:/projects/ft/client')
|
|
c = u.connect(port=entry['port'])
|
|
health = u.get_server_status()
|
|
assert health.get('serverRunning') and health.get('instanceId') == entry['id'], health
|
|
operations=json.loads(sys.stdin.read())
|
|
for op in operations:
|
|
result=c.call(op['skill'], **op.get('args',{}))
|
|
record={'time':datetime.datetime.now().isoformat(),'instance':entry['id'],**op,'result':result}
|
|
with Path('CodexOutput/upserver/自动验收-执行证据.jsonl').open('a',encoding='utf-8') as f:
|
|
f.write(json.dumps(record,ensure_ascii=False)+'\n')
|
|
if op['skill']=='console_get_logs':
|
|
print(json.dumps({'skill':op['skill'],'count':result.get('count'),'logs':[{'type':x['type'],'message':x['message'].split('\n')[0]} for x in result.get('logs',[])]},ensure_ascii=False))
|
|
else: print(json.dumps(record,ensure_ascii=False))
|