@xmoxmo/bncr 0.4.4 → 0.4.6

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/index.js CHANGED
@@ -840,6 +840,12 @@ var plugin = {
840
840
  owner = adopted.owner;
841
841
  previousOwner = adopted.previousOwner;
842
842
  gatewayRuntime.currentBridge = bridge;
843
+ if (rebuilt) {
844
+ gatewayRuntime.serviceRegistered = false;
845
+ gatewayRuntime.channelRegistered = false;
846
+ gatewayRuntime.serviceOwnerApiInstanceId = void 0;
847
+ gatewayRuntime.channelOwnerApiInstanceId = void 0;
848
+ }
843
849
  } else {
844
850
  runtime2 = loadBncrRuntimeSync();
845
851
  bridge = gatewayRuntime.currentBridge || getExistingBridgeSingleton();
package/index.ts CHANGED
@@ -101,6 +101,12 @@ const plugin = {
101
101
  owner = adopted.owner;
102
102
  previousOwner = adopted.previousOwner;
103
103
  gatewayRuntime.currentBridge = bridge;
104
+ if (rebuilt) {
105
+ gatewayRuntime.serviceRegistered = false;
106
+ gatewayRuntime.channelRegistered = false;
107
+ gatewayRuntime.serviceOwnerApiInstanceId = undefined;
108
+ gatewayRuntime.channelOwnerApiInstanceId = undefined;
109
+ }
104
110
  } else {
105
111
  runtime = loadBncrRuntimeSync();
106
112
  bridge = gatewayRuntime.currentBridge || getExistingBridgeSingleton();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmoxmo/bncr",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,3 +1,6 @@
1
+ import { existsSync } from 'node:fs';
2
+ import path from 'node:path';
3
+
1
4
  type RuntimeMediaLoaded = {
2
5
  buffer: Buffer;
3
6
  contentType?: string;
@@ -40,6 +43,23 @@ export function isOpenClawRemoteHttpMediaUrl(mediaUrl: string): boolean {
40
43
  return /^https?:\/\//i.test(String(mediaUrl || '').trim());
41
44
  }
42
45
 
46
+ /**
47
+ * Try to resolve a relative media path against each local root.
48
+ * Returns the first absolute path that exists on disk, or the original
49
+ * relative path if nothing is found (the host will then emit its own error).
50
+ */
51
+ export function resolveRelativeMediaPath(mediaUrl: string, localRoots?: readonly string[]): string {
52
+ if (!mediaUrl || !localRoots?.length) return mediaUrl;
53
+ if (path.isAbsolute(mediaUrl)) return mediaUrl;
54
+ // HTTP / file:// / data: / ~ paths are handled elsewhere
55
+ if (/^(https?|file|data):/i.test(mediaUrl) || mediaUrl.startsWith('~')) return mediaUrl;
56
+ for (const root of localRoots) {
57
+ const candidate = path.resolve(root, mediaUrl);
58
+ if (existsSync(candidate)) return candidate;
59
+ }
60
+ return mediaUrl;
61
+ }
62
+
43
63
  export async function loadOpenClawWebMedia(
44
64
  api: RuntimeApiHolder,
45
65
  mediaUrl: string,
@@ -54,7 +74,11 @@ export async function loadOpenClawWebMedia(
54
74
  if (typeof loadWebMedia !== 'function') {
55
75
  throw new Error('OpenClaw runtime media loadWebMedia API is unavailable');
56
76
  }
57
- return loadWebMedia(mediaUrl, options);
77
+
78
+ // Resolve relative paths against local roots before handing off to the host
79
+ const resolvedUrl = resolveRelativeMediaPath(mediaUrl, options?.localRoots);
80
+
81
+ return loadWebMedia(resolvedUrl, options);
58
82
  }
59
83
 
60
84
  export async function saveOpenClawChannelMediaBuffer(