openclaw - ✅(Solved) Fix Bundled persistedAuthState probes prefer source auth-presence modules in dev checkout [2 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#78462Fetched 2026-05-07 03:36:40
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
2
Author
Timeline (top)
cross-referenced ×2commented ×1

In a source checkout / dev runtime, bundled channel persistedAuthState probes can try to load source auth-presence.ts files directly. For Matrix and WhatsApp this fails package self-resolution for openclaw/plugin-sdk/*, producing noisy gateway startup logs.

Error Message

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'openclaw' imported from .../extensions/matrix/auth-presence.ts

Root Cause

In a source checkout / dev runtime, bundled channel persistedAuthState probes can try to load source auth-presence.ts files directly. For Matrix and WhatsApp this fails package self-resolution for openclaw/plugin-sdk/*, producing noisy gateway startup logs.

Fix Action

Fixed

PR fix notes

PR #78474: fix(channels): prefer built dist artifacts over source .ts in bundled package-state probes

Description (problem / solution / changelog)

Problem

In a dev checkout, bundled channel persistedAuthState/configuredState probes load the wrong file. resolveExistingPluginModulePath finds extensions/<chan>/auth-presence.ts (source) before dist/extensions/<chan>/auth-presence.js (built artifact). The source .ts file imports openclaw/plugin-sdk/* subpaths that fail package self-resolution in the source tree, producing noisy gateway startup warnings:

[channels] failed to load persistedAuthState checker for matrix: Cannot find module '/home/ubuntu/openclaw/dist/plugin-sdk/state-paths.js'
Require stack:
- /home/ubuntu/openclaw/extensions/matrix/auth-presence.ts

Reported in #78462.

Fix

Added resolveBuiltArtifactPath() in package-state-probes.ts: when resolveExistingPluginModulePath returns a source .ts/.mts/.cts path under an extensions/ directory, the function tries the corresponding .js/.mjs/.cjs path under dist/extensions/ first. If the built artifact exists, it's used instead. Falls through to the source path otherwise.

Files changed (2):

  • src/channels/plugins/package-state-probes.tsresolveBuiltArtifactPath helper + call at the probe resolution site
  • src/channels/plugins/package-state-probes.test.ts — test that asserts built .js is passed to loadChannelPluginModule when dist artifact exists

Audits:

  • A (existing helper): isSourceModulePath already existed; reused regex pattern as SOURCE_EXT_RE. ✓
  • B (shared caller check): resolveExistingPluginModulePath has 1 caller outside its file (this probe). ✓
  • C (rival scan): No rival PR for #78462. ✓

Tests: 2/2 pass (vitest run src/channels/plugins/package-state-probes.test.ts)

Changed files

  • src/channels/plugins/package-state-probes.test.ts (modified, +60/-2)
  • src/channels/plugins/package-state-probes.ts (modified, +48/-2)

PR #78480: fix(plugins): reuse workspace snapshot for model normalization

Description (problem / solution / changelog)

Problem

Manifest model-id normalization can miss the Gateway-owned plugin metadata snapshot when the caller does not pass an explicit workspace and the active runtime workspace has not been set yet. In that case resolveMetadataSnapshotForPolicies() calls getCurrentPluginMetadataSnapshot() without allowWorkspaceScopedSnapshot, so a valid workspace-scoped current snapshot is rejected and the path falls back to loadPluginMetadataSnapshot().

That matches the source-level slow path reported in #78461: model normalization can rebuild plugin metadata / installed plugin indexes during embedded agent prep even though Gateway already prepared a compatible metadata snapshot.

Fixes #78461.

Fix

  • Normalize omitted config to {} before snapshot compatibility checks, matching adjacent manifest readers.
  • Pass allowWorkspaceScopedSnapshot: true for unscoped callers, while still honoring an explicit workspaceDir or active runtime workspace when present.
  • Avoid passing workspaceDir: undefined into the fallback loader.
  • Add regression coverage for a workspace-scoped current snapshot with no active runtime workspace.

Commit shape

This is intentionally split into two commits:

  1. fix(plugins): reuse workspace snapshot for model normalization
  2. test(plugins): cover unscoped model normalization snapshot reuse

Scope boundary

What changed:

  • src/plugins/manifest-model-id-normalization.ts
  • src/plugins/manifest-model-id-normalization.test.ts

What did not change:

  • provider selection semantics
  • plugin install/index discovery policy
  • current snapshot compatibility checks
  • Gateway lifecycle / startup ordering
  • provider runtime cache behavior from #77948

Audits

  • Existing-helper check: reused existing getCurrentPluginMetadataSnapshot(... allowWorkspaceScopedSnapshot) behavior already used by model catalog and manifest-contract readers.
  • Shared-helper caller check: did not change getCurrentPluginMetadataSnapshot contract; only changed this caller.
  • Rival scan: #77948 is adjacent provider-runtime snapshot reuse, but does not touch src/plugins/manifest-model-id-normalization.ts; #78474 is package-state probe resolution for #78462 and does not cover this path.

Tests

pnpm test src/plugins/manifest-model-id-normalization.test.ts src/plugins/current-plugin-metadata-snapshot.test.ts src/agents/pi-embedded-runner/run/attempt-stage-timing.test.ts
# passed 2 Vitest shards; 18 tests passed

pnpm -s tsgo:core
# exit 0

pnpm -s build
# exit 0

git diff --check origin/main..HEAD
# exit 0

Real behavior proof

Behavior or issue addressed: Unscoped manifest model-id normalization now reuses the Gateway-owned workspace-scoped plugin metadata snapshot instead of falling back to a cold loadPluginMetadataSnapshot() path when the active runtime workspace is still unset. This addresses the #78461 model-normalization snapshot miss.

Real environment tested: Local OpenClaw source checkout /home/chenglunhu/code/openclaw, branch fix/manifest-model-normalization-snapshot-78461, built with pnpm -s build, OpenClaw 2026.5.6, Node v24.13.0, Linux/WSL host. Runtime env for the smoke used an empty temporary OPENCLAW_STATE_DIR and OPENCLAW_DISABLE_BUNDLED_PLUGINS=1 so the alpha/demo-model result can only come from the current metadata snapshot, not from a fallback manifest scan.

Exact steps or command run after this patch:

pnpm -s build
OPENCLAW_DISABLE_BUNDLED_PLUGINS=1 OPENCLAW_STATE_DIR="$(mktemp -d)" node --input-type=module <<'EOF'
import { t as normalizeProviderModelIdWithManifest } from './dist/manifest-model-id-normalization-BsZfNFDu.js';
import { r as setCurrentPluginMetadataSnapshot, t as clearCurrentPluginMetadataSnapshot } from './dist/current-plugin-metadata-snapshot-vavLhBTt.js';
import { _ as resolveInstalledPluginIndexPolicyHash } from './dist/installed-plugin-index-store-BekK6vjO.js';

const policyHash = resolveInstalledPluginIndexPolicyHash({});
const workspaceDir = '/tmp/openclaw-real-workspace-78461';
const index = {
  version: 1,
  hostContractVersion: 'real-proof',
  compatRegistryVersion: 'real-proof',
  migrationVersion: 1,
  policyHash,
  generatedAtMs: Date.now(),
  installRecords: {},
  plugins: [],
  diagnostics: [],
};
const snapshot = {
  policyHash,
  workspaceDir,
  index,
  plugins: [
    {
      id: 'normalizer-real-proof',
      modelIdNormalization: {
        providers: {
          demo: {
            prefixWhenBare: 'alpha',
          },
        },
      },
    },
  ],
};

clearCurrentPluginMetadataSnapshot();
setCurrentPluginMetadataSnapshot(snapshot, { config: {}, env: process.env });
const normalized = normalizeProviderModelIdWithManifest({
  provider: 'demo',
  context: { provider: 'demo', modelId: 'demo-model' },
});
console.log(`openclawVersion=2026.5.6`);
console.log(`command=node --input-type=module dist manifest-normalization smoke`);
console.log(`activeRuntimeWorkspace=unset`);
console.log(`storedSnapshotWorkspace=${workspaceDir}`);
console.log(`normalized=${normalized}`);
console.log(`workspaceScopedSnapshotReused=${normalized === 'alpha/demo-model'}`);
EOF

Evidence after fix: copied terminal output from the built OpenClaw dist smoke:

openclawVersion=2026.5.6
command=node --input-type=module dist manifest-normalization smoke
activeRuntimeWorkspace=unset
storedSnapshotWorkspace=/tmp/openclaw-real-workspace-78461
normalized=alpha/demo-model
workspaceScopedSnapshotReused=true

Observed result after fix: With no active runtime workspace and an empty plugin state dir, normalizeProviderModelIdWithManifest() returned alpha/demo-model from the stored workspace-scoped current snapshot. That verifies the unscoped caller reused the current snapshot path after this patch.

What was not tested: I did not run a live Gateway CPU profile in this PR. The live performance evidence is in #78461; this PR verifies the exact source-level snapshot miss with a built-dist smoke and regression test.

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • src/plugins/manifest-model-id-normalization.test.ts (modified, +14/-0)
  • src/plugins/manifest-model-id-normalization.ts (modified, +6/-4)

Code Example

[channels] failed to load persistedAuthState checker for matrix: Cannot find module '/home/ubuntu/openclaw/dist/plugin-sdk/state-paths.js'
Require stack:
- /home/ubuntu/openclaw/extensions/matrix/auth-presence.ts

[channels] failed to load persistedAuthState checker for whatsapp: Cannot find module '/home/ubuntu/openclaw/dist/plugin-sdk/account-id.js'
Require stack:
- /home/ubuntu/openclaw/extensions/whatsapp/auth-presence.ts

---

extensions/matrix/auth-presence.ts
extensions/whatsapp/auth-presence.ts

---

dist/plugin-sdk/account-id.js
dist/plugin-sdk/state-paths.js

---

node -e "import('/home/ubuntu/openclaw/dist/extensions/matrix/auth-presence.js')..."
matrix ok [ 'hasAnyMatrixAuth' ]

---

node -e "import('/home/ubuntu/openclaw/extensions/matrix/auth-presence.ts')..."
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'openclaw' imported from .../extensions/matrix/auth-presence.ts

---

resolveExistingPluginModulePath(params.entry.rootDir, metadata.specifier!)

---

./auth-presence
./auth-presence.ts
./auth-presence.mts
./auth-presence.js
...

---

import { resolveStateDir } from "openclaw/plugin-sdk/state-paths";
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
RAW_BUFFERClick to expand / collapse

Summary

In a source checkout / dev runtime, bundled channel persistedAuthState probes can try to load source auth-presence.ts files directly. For Matrix and WhatsApp this fails package self-resolution for openclaw/plugin-sdk/*, producing noisy gateway startup logs.

Observed logs

On OpenClaw 2026.5.4 (70d92b5) from a local source checkout:

[channels] failed to load persistedAuthState checker for matrix: Cannot find module '/home/ubuntu/openclaw/dist/plugin-sdk/state-paths.js'
Require stack:
- /home/ubuntu/openclaw/extensions/matrix/auth-presence.ts

[channels] failed to load persistedAuthState checker for whatsapp: Cannot find module '/home/ubuntu/openclaw/dist/plugin-sdk/account-id.js'
Require stack:
- /home/ubuntu/openclaw/extensions/whatsapp/auth-presence.ts

The interesting part is that the require stack points at source files:

extensions/matrix/auth-presence.ts
extensions/whatsapp/auth-presence.ts

not the built dist artifacts.

What I checked

The local dist SDK files do exist:

dist/plugin-sdk/account-id.js
dist/plugin-sdk/state-paths.js

The built Matrix artifact imports successfully:

node -e "import('/home/ubuntu/openclaw/dist/extensions/matrix/auth-presence.js')..."
matrix ok [ 'hasAnyMatrixAuth' ]

But importing the source checker directly fails package self-resolution:

node -e "import('/home/ubuntu/openclaw/extensions/matrix/auth-presence.ts')..."
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'openclaw' imported from .../extensions/matrix/auth-presence.ts

Likely cause

src/channels/plugins/package-state-probes.ts resolves the checker from the bundled channel catalog entry root:

resolveExistingPluginModulePath(params.entry.rootDir, metadata.specifier!)

For ./auth-presence, resolveExistingPluginModulePath() searches source extensions before built JS:

./auth-presence
./auth-presence.ts
./auth-presence.mts
./auth-presence.js
...

So in a dev checkout where extensions/<channel>/auth-presence.ts exists, the package-state probe may prefer source TS over dist/extensions/<channel>/auth-presence.js. That source file imports public SDK subpaths such as:

import { resolveStateDir } from "openclaw/plugin-sdk/state-paths";
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";

and can fail under the package-state source loader.

Expected behavior

Bundled channel package-state probes should either:

  • prefer built bundled artifacts for bundled channels when available, or
  • load source probes with package self-resolution equivalent to the normal dev runtime, or
  • avoid warning when the probe is optional and the built artifact is available.

Impact

This does not appear to be the main agent prep slowdown, but it adds gateway startup noise and can make channel/config diagnostics look broken even when the built bundled artifacts are present.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Bundled channel package-state probes should either:

  • prefer built bundled artifacts for bundled channels when available, or
  • load source probes with package self-resolution equivalent to the normal dev runtime, or
  • avoid warning when the probe is optional and the built artifact is available.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix Bundled persistedAuthState probes prefer source auth-presence modules in dev checkout [2 pull requests, 1 comments, 2 participants]