@openclaw/diagnostics-prometheus 2026.8.2 → 2026.8.33

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.
Files changed (2) hide show
  1. package/dist/index.js +19 -0
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@ import { isInternalDiagnosticEventMetadata, redactSensitiveText } from "./api.js
2
2
  import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
3
3
  import { normalizeDiagnosticLane, normalizeDiagnosticValue } from "openclaw/plugin-sdk/diagnostic-runtime";
4
4
  import { asNonNegativeFiniteNumber } from "openclaw/plugin-sdk/number-runtime";
5
+ import { getPluginRuntimeGatewayRequestScope } from "openclaw/plugin-sdk/plugin-runtime";
5
6
  import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
6
7
  //#region extensions/diagnostics-prometheus/src/service.ts
7
8
  const DURATION_BUCKETS_SECONDS = [
@@ -548,8 +549,26 @@ function recordDiagnosticEvent(store, evt, metadata) {
548
549
  store.histogram("openclaw_payload_large_bytes", "Oversized payload byte sizes by surface and action.", payloadLargeLabels(evt), asNonNegativeFiniteNumber(evt.bytes), BYTE_BUCKETS);
549
550
  }
550
551
  }
552
+ const METRICS_READ_SCOPE = "operator.read";
553
+ const METRICS_READ_IMPLYING_SCOPES = [
554
+ METRICS_READ_SCOPE,
555
+ "operator.write",
556
+ "operator.admin"
557
+ ];
558
+ function hasMetricsReadScope() {
559
+ const runtimeScopes = getPluginRuntimeGatewayRequestScope()?.client?.connect?.scopes;
560
+ const scopes = Array.isArray(runtimeScopes) ? runtimeScopes : [];
561
+ return METRICS_READ_IMPLYING_SCOPES.some((scope) => scopes.includes(scope));
562
+ }
551
563
  function createMetricsHandler(store) {
552
564
  return (req, res) => {
565
+ if (!hasMetricsReadScope()) {
566
+ res.statusCode = 403;
567
+ res.setHeader("Cache-Control", "no-store");
568
+ res.setHeader("Content-Type", "text/plain; charset=utf-8");
569
+ res.end(`missing scope: ${METRICS_READ_SCOPE}`);
570
+ return true;
571
+ }
553
572
  if (req.method !== "GET" && req.method !== "HEAD") {
554
573
  res.statusCode = 405;
555
574
  res.setHeader("Allow", "GET, HEAD");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/diagnostics-prometheus",
3
- "version": "2026.8.2",
3
+ "version": "2026.8.33",
4
4
  "description": "OpenClaw diagnostics Prometheus exporter for runtime metrics.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,10 +18,10 @@
18
18
  "minHostVersion": ">=2026.4.25"
19
19
  },
20
20
  "compat": {
21
- "pluginApi": ">=2026.8.2"
21
+ "pluginApi": ">=2026.8.33"
22
22
  },
23
23
  "build": {
24
- "openclawVersion": "2026.8.2"
24
+ "openclawVersion": "2026.8.33"
25
25
  },
26
26
  "release": {
27
27
  "publishToClawHub": true,
@@ -37,7 +37,7 @@
37
37
  "README.md"
38
38
  ],
39
39
  "peerDependencies": {
40
- "openclaw": ">=2026.8.2"
40
+ "openclaw": ">=2026.8.33"
41
41
  },
42
42
  "peerDependenciesMeta": {
43
43
  "openclaw": {