env->load($root.'/.env'); $app->config->set(require $root.'/config/prescription_ai.php','prescription_ai'); $matches=[]; foreach (glob($root.'/runtime/ai-synthetic-runtime-20261027/controls/*.json') ?: [] as $file) { if (hash_file('sha256',$file)==='d1a87c46e302a5579d23d04af01f763dc4847ef7fe06babda738b6e8cf07b483') $matches[]=$file; } if(count($matches)!==1) {echo '{"ok":false,"error_code":"SYNTHETIC_PIN_NOT_UNIQUE"}';exit;} $file=$matches[0]; $before=hash_file('sha256',$file); $s=json_decode((string)file_get_contents($file),true,64,JSON_THROW_ON_ERROR); if(($s['upstream']['profile']??'')!=='openai' || !str_starts_with($s['upstream']['user']??'','synthetic-runtime-20261027-') || empty($s['cancel_requested']) || !empty($s['upstream_terminal_confirmed'])) throw new \RuntimeException(); $identity=array_intersect_key($s['upstream'],array_flip(['profile','user','task_id','workflow_run_id','generation'])); $r=\app\common\service\DifyWorkflowRunStatus::lookup($identity,1000); echo json_encode(['ok'=>($r['ok']??false)===true,'status'=>$r['status']??null, 'error_code'=>$r['error_code']??null,'status_lookup_count'=>1,'original_control_unchanged'=>hash_file('sha256',$file)===$before]); } catch(\Throwable $ignored) {echo '{"ok":false,"error_code":"SYNTHETIC_STATUS_FAILED"}';}