@melaya/runner 1.1.16 → 1.1.17
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/dist/assistantHost.py +14 -6
- package/dist/connection.js +16 -2
- package/package.json +1 -1
package/dist/assistantHost.py
CHANGED
|
@@ -272,17 +272,25 @@ def _apply_browser_turn_grant(req) -> bool:
|
|
|
272
272
|
present (injected by the runner's per-turn bridge registration). These are
|
|
273
273
|
purged at turn end alongside the grant (see _purge_browser_turn_grant)."""
|
|
274
274
|
grant = str((req or {}).get("browser_grant") or "") if isinstance(req, dict) else ""
|
|
275
|
+
# Front 3: EXTENSION-target proxy turn — no client-side grant; the host's
|
|
276
|
+
# browser tools call the server bridge (MEL_BROWSER_URL/TOKEN) which holds the
|
|
277
|
+
# grant and runs the action against the user's real tab.
|
|
278
|
+
ext_proxy = bool((req or {}).get("browser_ext_proxy")) if isinstance(req, dict) else False
|
|
275
279
|
target_ref = str((req or {}).get("browser_target_ref") or "") if isinstance(req, dict) else ""
|
|
276
|
-
|
|
277
|
-
|
|
280
|
+
bridge_url = str((req or {}).get("mel_browser_url") or "") if isinstance(req, dict) else ""
|
|
281
|
+
bridge_token = str((req or {}).get("mel_browser_token") or "") if isinstance(req, dict) else ""
|
|
282
|
+
if (grant or ext_proxy) and _browser_capable():
|
|
283
|
+
if grant:
|
|
284
|
+
os.environ["MEL_BROWSER_TURN_GRANT"] = grant
|
|
285
|
+
else:
|
|
286
|
+
os.environ.pop("MEL_BROWSER_TURN_GRANT", None) # proxy: grant stays server-side
|
|
278
287
|
if target_ref:
|
|
279
288
|
os.environ["MEL_BROWSER_TURN_TARGET_REF"] = target_ref
|
|
280
289
|
else:
|
|
281
290
|
os.environ.pop("MEL_BROWSER_TURN_TARGET_REF", None)
|
|
282
|
-
# Per-turn bridge URL + token (assistant path
|
|
283
|
-
#
|
|
284
|
-
|
|
285
|
-
bridge_token = str((req or {}).get("mel_browser_token") or "") if isinstance(req, dict) else ""
|
|
291
|
+
# Per-turn bridge URL + token (assistant path). For the runner target this
|
|
292
|
+
# is the runner's local bridge; for the extension proxy it is the server's
|
|
293
|
+
# /ext-bridge. Apply only when present on the frame.
|
|
286
294
|
if bridge_url:
|
|
287
295
|
os.environ["MEL_BROWSER_URL"] = bridge_url
|
|
288
296
|
if bridge_token:
|
package/dist/connection.js
CHANGED
|
@@ -1569,6 +1569,16 @@ export async function connect(opts) {
|
|
|
1569
1569
|
return;
|
|
1570
1570
|
}
|
|
1571
1571
|
}
|
|
1572
|
+
else if (payload.browserExtProxy && payload.browserExtProxy.url && payload.browserExtProxy.token) {
|
|
1573
|
+
// Front 3: EXTENSION target. No grant verification / local bridge run — the
|
|
1574
|
+
// host's browser_* tools POST to the server bridge (Bearer proxy token) and
|
|
1575
|
+
// the SERVER runs the action against the extension using the grant it holds.
|
|
1576
|
+
turnBridgeUrl = String(payload.browserExtProxy.url);
|
|
1577
|
+
turnBridgeToken = String(payload.browserExtProxy.token);
|
|
1578
|
+
browserTargetRef = String(payload.browserExtProxy.targetRef || "");
|
|
1579
|
+
if (opts.verbose)
|
|
1580
|
+
console.log(chalk.gray(` [browser-bridge] ext-proxy turn (session=${payload.sessionId.slice(0, 10)} url=${turnBridgeUrl})`));
|
|
1581
|
+
}
|
|
1572
1582
|
// Capture for the stdout "done" handler closure below.
|
|
1573
1583
|
const _turnBridgeRunId = turnBridgeRunId;
|
|
1574
1584
|
const _turnId = payload.turnId;
|
|
@@ -1617,9 +1627,13 @@ export async function connect(opts) {
|
|
|
1617
1627
|
// JWS string so the Python browser toolkit can verify it again
|
|
1618
1628
|
// (defence-in-depth) and install MEL_BROWSER_TURN_GRANT in the
|
|
1619
1629
|
// host env for THIS turn only. Absent when no grant was provided.
|
|
1620
|
-
...(verifiedGrantToken
|
|
1630
|
+
...(verifiedGrantToken
|
|
1631
|
+
? { browser_grant: verifiedGrantToken, browser_target_ref: browserTargetRef ?? "" }
|
|
1632
|
+
// Front 3 EXTENSION proxy: no grant, but the host must still apply
|
|
1633
|
+
// MEL_BROWSER_URL/TOKEN + register the browser toolkit for the turn.
|
|
1634
|
+
: (turnBridgeUrl ? { browser_ext_proxy: true, browser_target_ref: browserTargetRef ?? "" } : {})),
|
|
1621
1635
|
// Bridge URL + token for the host process env (applied per-turn by
|
|
1622
|
-
// _apply_browser_turn_grant alongside the grant token).
|
|
1636
|
+
// _apply_browser_turn_grant, alongside the grant token OR the proxy flag).
|
|
1623
1637
|
...(turnBridgeUrl && turnBridgeToken
|
|
1624
1638
|
? { mel_browser_url: turnBridgeUrl, mel_browser_token: turnBridgeToken }
|
|
1625
1639
|
: {}),
|