@remnic/plugin-openclaw 9.25.5 → 9.25.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
@@ -5614,6 +5614,15 @@ function daemonUrl(target, pathname) {
5614
5614
  const host = target.host.includes(":") && !target.host.startsWith("[") ? `[${target.host}]` : target.host;
5615
5615
  return `http://${host}:${target.port}${pathname}`;
5616
5616
  }
5617
+ var daemonAuthFailureLogKeys = /* @__PURE__ */ new Set();
5618
+ function reportDaemonAuthorizationFailure(serviceId, pathname, status, tokenSource) {
5619
+ const key = `${serviceId}:${pathname}:${status}:${tokenSource}`;
5620
+ if (daemonAuthFailureLogKeys.has(key)) return;
5621
+ daemonAuthFailureLogKeys.add(key);
5622
+ log2.error(
5623
+ `delegate ${pathname} authorization failed (${status}; token source: ${tokenSource})`
5624
+ );
5625
+ }
5617
5626
  async function probeDelegateAuthorization(target, namespace = "", operations = DEFAULT_DELEGATE_AUTHORIZATION_OPERATIONS) {
5618
5627
  const auth = target.resolveAuthToken();
5619
5628
  const headers = auth.token ? { Authorization: `Bearer ${auth.token}` } : void 0;
@@ -5637,7 +5646,7 @@ async function probeDelegateAuthorization(target, namespace = "", operations = D
5637
5646
  }
5638
5647
  return { state: "unavailable", tokenSource: auth.source };
5639
5648
  }
5640
- async function postJson(target, pathname, body, timeoutMs) {
5649
+ async function postJson(target, serviceId, pathname, body, timeoutMs) {
5641
5650
  const headers = { "Content-Type": "application/json" };
5642
5651
  const auth = target.resolveAuthToken();
5643
5652
  if (auth.token) headers.Authorization = `Bearer ${auth.token}`;
@@ -5648,6 +5657,12 @@ async function postJson(target, pathname, body, timeoutMs) {
5648
5657
  signal: AbortSignal.timeout(timeoutMs)
5649
5658
  });
5650
5659
  if (!res.ok) {
5660
+ if (res.status === 401 || res.status === 403) {
5661
+ const status = res.status === 401 ? 401 : 403;
5662
+ await res.body?.cancel();
5663
+ reportDaemonAuthorizationFailure(serviceId, pathname, status, auth.source);
5664
+ return null;
5665
+ }
5651
5666
  throw new Error(`daemon ${pathname} responded ${res.status}`);
5652
5667
  }
5653
5668
  const parsed = await res.json().catch(() => null);
@@ -5716,6 +5731,7 @@ function registerDelegateRuntime(api, options) {
5716
5731
  const cwd = cwdFrom(event, ctx, options.cwd);
5717
5732
  const response = await postJson(
5718
5733
  target,
5734
+ options.serviceId,
5719
5735
  "/engram/v1/recall",
5720
5736
  withNamespace(namespace, {
5721
5737
  query,
@@ -5789,6 +5805,7 @@ ${context}`;
5789
5805
  const cwd = cwdFrom(event, ctx, options.cwd);
5790
5806
  await postJson(
5791
5807
  target,
5808
+ options.serviceId,
5792
5809
  "/engram/v1/observe",
5793
5810
  withNamespace(namespace, {
5794
5811
  sessionKey,
@@ -5808,6 +5825,7 @@ ${context}`;
5808
5825
  try {
5809
5826
  await postJson(
5810
5827
  target,
5828
+ options.serviceId,
5811
5829
  "/engram/v1/lcm/compaction/flush",
5812
5830
  withNamespace(namespace, { sessionKey }),
5813
5831
  options.flushTimeoutMs