storyboard-bridge 0.7.2 → 0.7.4
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/package.json +1 -1
- package/tryinfer_client.py +28 -6
package/package.json
CHANGED
package/tryinfer_client.py
CHANGED
|
@@ -151,10 +151,28 @@ class BrowserSession:
|
|
|
151
151
|
break
|
|
152
152
|
if not tid:
|
|
153
153
|
raise RuntimeError(f"No open tab whose URL contains '{self.match}'. Open tryinfer.com and log in.")
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
154
|
+
# A HOST tab left in the background gets DISCARDED/frozen by Chrome (no live renderer). Attaching still
|
|
155
|
+
# works, but Runtime.enable then hangs waiting for a renderer → "Timed out waiting for CDP response".
|
|
156
|
+
# Activate (foreground/wake) the tab first, and retry attach+enable a couple times so a just-woken tab
|
|
157
|
+
# gets a moment to spin its renderer back up.
|
|
158
|
+
last = None
|
|
159
|
+
for attempt in range(3):
|
|
160
|
+
self.cdp = CDP(self.browser_ws)
|
|
161
|
+
try:
|
|
162
|
+
try: self.cdp.call("Target.activateTarget", {"targetId": tid}, timeout=10) # wake a discarded tab
|
|
163
|
+
except Exception: pass
|
|
164
|
+
self.session_id = self.cdp.call("Target.attachToTarget", {"targetId": tid, "flatten": True}, timeout=15)["sessionId"]
|
|
165
|
+
self.cdp.call("Runtime.enable", session_id=self.session_id, timeout=20)
|
|
166
|
+
log(f"Routing API calls through tab: {url}")
|
|
167
|
+
return
|
|
168
|
+
except Exception as e:
|
|
169
|
+
last = e
|
|
170
|
+
try: self.cdp.close()
|
|
171
|
+
except Exception: pass
|
|
172
|
+
if attempt < 2:
|
|
173
|
+
log(f" CDP attach stalled (tab may be waking) — retrying… ({e})")
|
|
174
|
+
time.sleep(2)
|
|
175
|
+
raise RuntimeError(f"couldn't attach to the tryinfer tab — is it awake + logged in? ({last})")
|
|
158
176
|
|
|
159
177
|
def request(self, method, url, body=None, timeout=120, retries=4):
|
|
160
178
|
last = None
|
|
@@ -314,8 +332,11 @@ def main():
|
|
|
314
332
|
# model default is capability-aware: image caps use seedream (seedANCE is the VIDEO model — a common mixup).
|
|
315
333
|
model = args.model or ("seedream-5.0-pro" if args.capability in ("edit", "text-to-image") else "seedance-2.0-pro")
|
|
316
334
|
image_urls = args.image_url or ["https://www.gstatic.com/webp/gallery/1.jpg"] # default = permissive test image
|
|
317
|
-
sess =
|
|
335
|
+
sess = None
|
|
318
336
|
try:
|
|
337
|
+
# inside the try so a connect/tab failure ("No open tab … Open tryinfer.com and log in") surfaces as a
|
|
338
|
+
# clean error EVENT the node can show — not a raw Python traceback dumped to the UI.
|
|
339
|
+
sess = BrowserSession(f"http://{args.host}:{args.port}", args.match)
|
|
319
340
|
if args.resume_task:
|
|
320
341
|
task_id = args.resume_task
|
|
321
342
|
log(f"resuming task {task_id}")
|
|
@@ -333,7 +354,8 @@ def main():
|
|
|
333
354
|
log(f"\n❌ {e}")
|
|
334
355
|
sys.exit(1)
|
|
335
356
|
finally:
|
|
336
|
-
sess
|
|
357
|
+
if sess:
|
|
358
|
+
sess.close()
|
|
337
359
|
|
|
338
360
|
if res.get("images"):
|
|
339
361
|
event(event="done", taskId=task_id, images=res["images"])
|