@melaya/runner 1.1.63 → 1.1.65

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.
@@ -45,6 +45,20 @@ import urllib.request
45
45
  from pathlib import Path
46
46
  from typing import Any, Callable, Iterable
47
47
 
48
+
49
+ def _runner_user_agent() -> str:
50
+ # Cloudflare's browser integrity check refuses urllib's default
51
+ # "Python-urllib/x.y" agent (403, error 1010) before the request reaches
52
+ # Melaya, so every upload must name the runner.
53
+ try:
54
+ pkg = json.loads((Path(__file__).resolve().parent / "package.json").read_text(encoding="utf-8"))
55
+ return f"melaya-runner/{pkg.get('version') or 'dev'} (vault-mirror)"
56
+ except Exception:
57
+ return "melaya-runner (vault-mirror)"
58
+
59
+
60
+ _USER_AGENT = _runner_user_agent()
61
+
48
62
  CONFIG_FILES = (
49
63
  "app.json", "daily-notes.json", "templates.json", "zk-prefixer.json", "bookmarks.json",
50
64
  "types.json", "workspace.json", "workspaces.json", "core-plugins.json",
@@ -95,7 +109,7 @@ class HttpTransport:
95
109
  url = f"{self.base}/{rel}"
96
110
  if params:
97
111
  url += "?" + urllib.parse.urlencode(params)
98
- h = {"Authorization": f"Mirror {self._token}", **(headers or {})}
112
+ h = {"Authorization": f"Mirror {self._token}", "User-Agent": _USER_AGENT, **(headers or {})}
99
113
  body = data
100
114
  if json_body is not None:
101
115
  body = json.dumps(json_body).encode("utf-8")
package/dist/vaults.d.ts CHANGED
@@ -295,6 +295,9 @@ export declare class VaultService {
295
295
  args?: unknown;
296
296
  idempotency_key?: unknown;
297
297
  }, via: VaultVia): Promise<VaultEnvelope>;
298
+ /** The vault's history policy travels with each answer (as the builder does):
299
+ * obsidian_* tools keep excerpts out of saved logs unless it is "retain". */
300
+ private withHistory;
298
301
  /** One engine op on the Python host (re-registers once after a host restart). */
299
302
  private hostOp;
300
303
  /** Merge the Obsidian app's availability into a vault's capability report
package/dist/vaults.js CHANGED
@@ -792,7 +792,7 @@ export class VaultService {
792
792
  if (this.o.app) {
793
793
  const served = await this.o.app.serve({ reg, grant: appGrant, op, args, idempotencyKey: idem }).catch(() => null);
794
794
  if (served?.kind === "env")
795
- return served.env;
795
+ return this.withHistory(served.env, g);
796
796
  if (served?.kind === "files")
797
797
  args = served.args;
798
798
  }
@@ -803,7 +803,7 @@ export class VaultService {
803
803
  if (this.o.app && op === "base_query") {
804
804
  const viaApp = await this.o.app.afterFiles({ reg, grant: appGrant, op, args }, env).catch(() => null);
805
805
  if (viaApp)
806
- return viaApp;
806
+ return this.withHistory(viaApp, g);
807
807
  }
808
808
  if (this.o.app && op === "capabilities" && env.ok) {
809
809
  const st = await this.o.app.status(reg).catch(() => null);
@@ -814,6 +814,13 @@ export class VaultService {
814
814
  e.app = { cli: st.cli, rest: st.rest, version: st.version, features: st.features };
815
815
  }
816
816
  }
817
+ return this.withHistory(env, g);
818
+ }
819
+ /** The vault's history policy travels with each answer (as the builder does):
820
+ * obsidian_* tools keep excerpts out of saved logs unless it is "retain". */
821
+ withHistory(env, g) {
822
+ if (env && typeof env === "object" && env.ok)
823
+ env.history = g.history === "retain" ? "retain" : "reference";
817
824
  return env;
818
825
  }
819
826
  /** One engine op on the Python host (re-registers once after a host restart). */
@@ -45,6 +45,20 @@ import urllib.request
45
45
  from pathlib import Path
46
46
  from typing import Any, Callable, Iterable
47
47
 
48
+
49
+ def _runner_user_agent() -> str:
50
+ # Cloudflare's browser integrity check refuses urllib's default
51
+ # "Python-urllib/x.y" agent (403, error 1010) before the request reaches
52
+ # Melaya, so every upload must name the runner.
53
+ try:
54
+ pkg = json.loads((Path(__file__).resolve().parent / "package.json").read_text(encoding="utf-8"))
55
+ return f"melaya-runner/{pkg.get('version') or 'dev'} (vault-mirror)"
56
+ except Exception:
57
+ return "melaya-runner (vault-mirror)"
58
+
59
+
60
+ _USER_AGENT = _runner_user_agent()
61
+
48
62
  CONFIG_FILES = (
49
63
  "app.json", "daily-notes.json", "templates.json", "zk-prefixer.json", "bookmarks.json",
50
64
  "types.json", "workspace.json", "workspaces.json", "core-plugins.json",
@@ -95,7 +109,7 @@ class HttpTransport:
95
109
  url = f"{self.base}/{rel}"
96
110
  if params:
97
111
  url += "?" + urllib.parse.urlencode(params)
98
- h = {"Authorization": f"Mirror {self._token}", **(headers or {})}
112
+ h = {"Authorization": f"Mirror {self._token}", "User-Agent": _USER_AGENT, **(headers or {})}
99
113
  body = data
100
114
  if json_body is not None:
101
115
  body = json.dumps(json_body).encode("utf-8")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@melaya/runner",
3
- "version": "1.1.63",
3
+ "version": "1.1.65",
4
4
  "description": "Run Melaya AI pipelines locally with your own LM Studio or Ollama models",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Melaya Labs LLC",