@melaya/runner 1.0.90 → 1.0.92

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.
@@ -292,12 +292,19 @@ def _register_stream_hooks(agent) -> None:
292
292
  except Exception:
293
293
  return
294
294
 
295
- def _pre_print_hook(_agent, **kwargs) -> None:
295
+ # agentscope hook calling convention (see agent/_agent_meta.py):
296
+ # pre-hook(self, normalized_kwargs_dict)
297
+ # post-hook(self, normalized_kwargs_dict, output)
298
+ # normalized_kwargs_dict is dict(bound.arguments) keyed by the wrapped
299
+ # method's PARAMETER NAMES. So print(self, msg, last) → {"msg":…, "last":…}
300
+ # and _acting(self, tool_call) → {"tool_call":…} (SINGULAR). `*_rest` absorbs
301
+ # the post-hook's trailing `output` arg so ONE shape works for both.
302
+ def _pre_print_hook(_self, kw, *_rest) -> None:
296
303
  try:
297
304
  tid = _stream.get("turnId")
298
- if not tid:
305
+ if not tid or not isinstance(kw, dict):
299
306
  return
300
- msg = kwargs.get("msg") or kwargs.get("message")
307
+ msg = kw.get("msg") or kw.get("message")
301
308
  if msg is None:
302
309
  return
303
310
  mid = str(getattr(msg, "id", "") or id(msg))
@@ -311,12 +318,16 @@ def _register_stream_hooks(agent) -> None:
311
318
  except Exception:
312
319
  pass
313
320
 
314
- def _post_acting_hook(_agent, **kwargs) -> None:
321
+ def _post_acting_hook(_self, kw, *_rest) -> None:
315
322
  try:
316
323
  tid = _stream.get("turnId")
317
- if not tid:
324
+ if not tid or not isinstance(kw, dict):
318
325
  return
319
- for tc in (kwargs.get("tool_calls") or []):
326
+ tcs = kw.get("tool_calls")
327
+ if tcs is None:
328
+ tc = kw.get("tool_call") # this agentscope: one tool_call per _acting
329
+ tcs = [tc] if tc is not None else []
330
+ for tc in tcs:
320
331
  name = tc.get("name", "") if isinstance(tc, dict) else getattr(tc, "name", "")
321
332
  if name:
322
333
  _emit(tid, "tool", name=str(name))
@@ -874,6 +874,14 @@ export async function connect(opts) {
874
874
  mkdirSync(workDir, { recursive: true });
875
875
  const stagedHost = join(workDir, "assistantHost.py");
876
876
  copyFileSync(hostScript, stagedHost);
877
+ // If Luma is enabled for this chat, make sure the browser bridge is up so
878
+ // luma_register_event can route /event/register through Playwright and clear
879
+ // Cloudflare's write-bot rule. Without it the tool falls back to aiohttp,
880
+ // which 403s ("cloudflare_mitigation" / "velocity_throttled") on every RSVP.
881
+ // Idempotent + best-effort; only paid when luma is actually selected.
882
+ if (Array.isArray(payload.connectors) && payload.connectors.includes("luma")) {
883
+ await _ensureLumaBridge();
884
+ }
877
885
  const sharedDir = getSharedDir();
878
886
  const certBundle = (await import("./pythonEnv.js")).getCertBundlePath();
879
887
  const sslEnv = certBundle ? { SSL_CERT_FILE: certBundle, REQUESTS_CA_BUNDLE: certBundle } : {};
@@ -899,6 +907,13 @@ export async function connect(opts) {
899
907
  MEL_ASSISTANT_CONNECTORS: Array.isArray(payload.connectors) ? payload.connectors.join(",") : "",
900
908
  // Gate write connector-tools behind the in-chat approval card (fail-safe).
901
909
  MEL_ASSISTANT_CONNECTOR_HITL: Array.isArray(payload.connectors) && payload.connectors.length ? "1" : "",
910
+ // Luma browser bridge (same injection as pipeline runs, line ~431): lets
911
+ // shared/tools/luma.py route /event/register through Playwright and bypass
912
+ // Cloudflare's write rule. Reads keep using aiohttp. Empty when no signed-in
913
+ // Luma session exists (bridge not started) — reads still work, writes 403.
914
+ ...(lumaBridge
915
+ ? { MEL_LUMA_BROWSER_URL: lumaBridge.url, MEL_LUMA_BROWSER_TOKEN: lumaBridge.token }
916
+ : {}),
902
917
  // Per-user creds (incl. MELAYA_API_KEY + the selected connectors' env).
903
918
  ...(payload.credentials || {}),
904
919
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@melaya/runner",
3
- "version": "1.0.90",
3
+ "version": "1.0.92",
4
4
  "description": "Run Melaya AI pipelines locally with your own LM Studio or Ollama models",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,