openclaw/extensions/diffs
Peter Steinberger 14233c0e6d
chore(release): close out 2026.9.7 on main (#161587)
* test(gateway): await yielded orchestrator cleanup

Wait for the existing registry cleanup publication instead of racing real SQLite worker completion against a two-second polling window. Reuse the plugin-subagent observer and bind the new waits to the test abort signal so timeouts release their subscriptions.

Keep yielded follow-up dispatch on real timers so the acknowledgement helper cannot prematurely run the registry sweeper against mocked run liveness. Preserve all requester lineage, announcement, delivery, cleanup, and predecessor lifecycle assertions.

(cherry picked from commit 0591abe71e703b7cf7c69a42cd8b93287d9fe8d9)

* fix(test): stop resume registry sweeper before gateway teardown

The resume Gateway fixture left its subagent registry sweeper scheduled
across files. A later tick used the retired module generation to open a
shared-state worker against the next fixture's state directory. The worker
registered with the old database lifecycle, escaped current teardown, and
rejected the recreated SQLite pathname.

Reset the fixture-owned registry without persistence before closing the
Gateway so its timers stop before database retirement.

Validation: the six-file same-worker driver reproduced the pathname error
before the fix (270.19s instrumented), then passed all 49 tests (215.72s).
The delete-state-lifecycle file passed all 10 tests alone (102.65s wall).
Targeted oxfmt, oxlint, git diff --check, and independent review passed.
All diagnostic instrumentation was removed.

(cherry picked from commit 613b3f8818d21d0c0d65333b29aabce11dd5afe9)

* test: settle reply recovery before deleting fixtures

The aborted-restart fixture could delete its store while asynchronous
main-session recovery-owner release was still preparing a write. Tracing
reproduced that release recreating/registering the prior store during the
following onAdopted test, invalidating the shared registry generation.

Join reply successor-admission barriers and close each fixture database root
before deleting its directory or resetting the reply registry. Extract the
fixture owner to keep the existing large test file from growing. Re-enable
the adopted-claim cancellation test. Production registry guards and retry
contracts are unchanged.

Validation with OPENCLAW_E2E_SKIP_BUILD=1 pnpm test:e2e:gateway against
src/auto-reply/reply/agent-runner.runreplyagent.e2e.test.ts:
- Original file: 220 passed, 1 registry failure, 1 skipped; 358.38s Vitest.
- Original isolated adoption case repeated 20 times: passed; 170.95s Vitest.
- Repaired aborted-restart/cancellation/adoption sequence: 3 clean runs,
  3 tests each; CLI wall 225.68s, 190.48s, 99.70s.
- Repaired full file: 221 passed, 1 different steering timeout; 528.47s Vitest.
  Remaining failure: keeps the replacement source when retired admission
  completes, first source admission did not persist (existing 5s guard).
  Focused replay passed in 151.18s Vitest; this does not establish a fix for
  that timeout. No timeout was changed.
- Source test types, scoped oxlint, formatting, and independent review passed.
  Broad check:changed guards passed through the core graph boundary; stopped
  before its duplicate messaging type pass. pnpm tsgo:test:src passed that
  graph plus the remaining source test graphs.

The full original CI shard and Telegram case were not replayed within the
requested 35-minute investigation limit.

(cherry picked from commit 0b679e62f6)

* fix(release): retire the 2026.9.7 live-shard waiver before main moves to 2026.9.7

RELEASE_WAIVED_LIVE_FILES (28597852) keyed on package version 2026.9.7 dropped three live files whose only case was skipped on the release branch. Main keeps those cases enabled, so once the closeout sets main to 2026.9.7 the adapter would silently stop running them. Refs #161083 #161084.

* chore(release): record the shipped 2026.9.7 changelog on main

CHANGELOG/2026.9.7.md, its contribution record, the index entry, the finalized Unreleased section, and the Matrix plugin changelog, byte-identical to the 2026.9.7 release SHA c074824a.

* chore(release): set main to the shipped 2026.9.7 version and record its update compatibility

Root version 2026.9.7 with pnpm release:prep version alignment, the macOS Info.plist version, and the verified npm tarball (sha512-/8N2Ln…RQwRWA==) recorded in the update compatibility inventory.

* test(gateway): move yielded orchestrator follow-up cases into their own module

The 0591abe7 forward-port grew agent.sessions-and-models.test-utils.ts past its line-cap ratchet. The yielded-orchestrator follow-up matrix is a self-contained case set, so it moves unchanged into agent.yielded-orchestrator.test-utils.ts, still loaded by agent.test.ts in the same module graph.
2026-09-29 22:39:14 -07:00
..
assets improve(plugins): give bundled logos consistent white icon tiles (#155259) 2026-09-23 19:09:26 -07:00
skills/diffs
src refactor(test): drop unreachable diffs render fixture (#161508) 2026-09-30 02:55:21 +00:00
index.ts refactor(plugins): deslop tool, search and media plugins (#160552) 2026-09-29 00:31:49 +00:00
openclaw.plugin.json fix(plugins): simplify installation and grouped settings (#150234) 2026-09-21 14:02:06 -07:00
package.json chore(release): close out 2026.9.7 on main (#161587) 2026-09-29 22:39:14 -07:00
plugin-startup-laziness.test.ts fix(diffs): load Playwright renderer on demand (#127040) 2026-08-21 10:45:04 -07:00
README.md fix(plugins): simplify installation and grouped settings (#150234) 2026-09-21 14:02:06 -07:00
tsconfig.json

@openclaw/diffs

Read-only diff viewer plugin for OpenClaw agents.

Install

openclaw plugins install @openclaw/diffs

Installation and updates apply automatically when the local Gateway is running. If it is stopped, changes take effect the next time it starts.

It gives agents one tool, diffs, that can:

  • render a gateway-hosted diff viewer
  • render the same diff to a file (PNG or PDF)
  • accept either arbitrary before and after text or a unified patch

What Agents Get

The tool can return:

  • details.changed: false when before/after inputs are identical and no artifact was rendered; true for rendered results
  • details.viewerUrl: a gateway URL that can be opened in the operator's browser
  • details.filePath: a local rendered artifact path when file rendering is requested
  • details.fileFormat: the rendered file format (png or pdf)
  • details.artifactId and details.expiresAt: artifact identity and TTL metadata
  • details.context: available routing metadata such as agentId, sessionId, messageChannel, and agentAccountId

When the plugin is enabled, it also ships a companion skill from skills/ and prepends stable tool-usage guidance into system-prompt space via before_prompt_build. The hook uses prependSystemContext, so the guidance stays out of user-prompt space while still being available every turn.

This means an agent can:

  • call diffs with mode=view, then return details.viewerUrl for the operator to open
  • call diffs with mode=file, then send the file through the normal message tool using path or filePath
  • call diffs with mode=both when it wants both outputs

Tool Inputs

Before and after:

{
  "before": "# Hello\n\nOne",
  "after": "# Hello\n\nTwo",
  "path": "docs/example.md",
  "mode": "view"
}

Patch:

{
  "patch": "diff --git a/src/example.ts b/src/example.ts\n--- a/src/example.ts\n+++ b/src/example.ts\n@@ -1 +1 @@\n-const x = 1;\n+const x = 2;\n",
  "mode": "both"
}

Useful options:

  • mode: view, file, or both Deprecated alias: image behaves like file and is still accepted for backward compatibility.
  • layout: unified or split
  • theme: light or dark (default: dark)
  • fileFormat: png or pdf (default: png)
  • fileQuality: standard, hq, or print
  • fileScale: device scale override (1-4)
  • fileMaxWidth: max width override in CSS pixels (640-2400)
  • expandUnchanged: expand unchanged sections (per-call option only, not a plugin default key)
  • path: display name for before and after input
  • lang: language hint for before/after input; unknown values fall back to plain text
  • Default syntax highlighting covers common source, config, and documentation languages. Install diffs-language-pack for the extended language catalog.
  • title: explicit viewer title
  • ttlSeconds: artifact lifetime for viewer and standalone file outputs
  • baseUrl: override the gateway base URL used in the returned viewer link (origin or origin+base path only; no query/hash)
  • viewerBaseUrl plugin config: persistent fallback used when a tool call omits baseUrl

Input safety limits:

  • before and after: max 512 KiB each
  • patch: max 2 MiB
  • patch rendering cap: max 128 files / 120,000 lines

Plugin Defaults

Set plugin-wide defaults in ~/.openclaw/openclaw.json:

{
  plugins: {
    entries: {
      diffs: {
        enabled: true,
        config: {
          defaults: {
            fontFamily: "Fira Code",
            fontSize: 15,
            lineSpacing: 1.6,
            layout: "unified",
            showLineNumbers: true,
            diffIndicators: "bars",
            wordWrap: true,
            background: true,
            theme: "dark",
            fileFormat: "png",
            fileQuality: "standard",
            fileScale: 2,
            fileMaxWidth: 960,
            mode: "both",
            ttlSeconds: 21600,
          },
        },
      },
    },
  },
}

Explicit tool parameters still win over these defaults.

Docs

Package

  • Plugin id: diffs
  • Package: @openclaw/diffs
  • Minimum OpenClaw host: 2026.4.30

Security options:

  • security.allowRemoteViewer (default false): allows non-loopback access to /plugins/diffs/view/... token URLs
  • viewerBaseUrl (optional): persistent viewer-link origin/path fallback for shareable URLs
  • defaults.ttlSeconds (default 1800, max 21600): default artifact lifetime for viewer and standalone file outputs

Example:

{
  plugins: {
    entries: {
      diffs: {
        enabled: true,
        config: {
          viewerBaseUrl: "https://gateway.example.com/openclaw",
        },
      },
    },
  },
}

Example Agent Prompts

Open in the browser:

Use the `diffs` tool in `view` mode for this before and after content, then return the viewer URL.

Path: docs/example.md

Before:
# Hello

This is version one.

After:
# Hello

This is version two.

Render a file (PNG or PDF):

Use the `diffs` tool in `file` mode for this before and after input. After it returns `details.filePath`, use the `message` tool with `path` or `filePath` to send me the rendered diff file.

Path: README.md

Before:
OpenClaw supports plugins.

After:
OpenClaw supports plugins and hosted diff views.

Do both:

Use the `diffs` tool in `both` mode for this diff. Return the viewer URL and then send the rendered file by passing `details.filePath` to the `message` tool.

Path: src/demo.ts

Before:
const status = "old";

After:
const status = "new";

Patch input:

Use the `diffs` tool with this unified patch in `view` mode. Return its viewer URL.

diff --git a/src/example.ts b/src/example.ts
--- a/src/example.ts
+++ b/src/example.ts
@@ -1,3 +1,3 @@
 export function add(a: number, b: number) {
-  return a + b;
+  return a + b + 1;
 }

Notes

  • Multi-file patches start with a changed-files summary card: totals, per-file +N/-N stats, change badges, and anchor links.
  • Rendered PNG/PDF files keep the per-file header counts but omit the interactive view toggles.
  • The viewer is hosted locally through the gateway under /plugins/diffs/....
  • Viewer HTML and metadata are ephemeral SQLite plugin blobs. The URL token is returned to the caller while SQLite stores only its SHA-256 hash.
  • Rendered PNG/PDF files remain temporary materializations in $TMPDIR/openclaw-diffs because delivery APIs require a file path. No JSON metadata sidecars are written or imported.
  • Default viewer URLs use gateway.publicOrigin when configured, then the existing bind-aware Gateway fallback. Plugin viewerBaseUrl and per-call baseUrl take precedence.
  • If gateway.trustedProxies includes loopback for a same-host proxy (for example Tailscale Serve), raw 127.0.0.1 viewer requests without forwarded client-IP headers fail closed by design.
  • In that topology, prefer mode=file / mode=both for attachments, or intentionally enable remote viewers and set plugin viewerBaseUrl (or pass a proxy/public baseUrl) when you need a shareable viewer URL.
  • Remote viewer misses are throttled to reduce token-guess abuse.
  • PNG or PDF rendering requires a Chromium-compatible browser. Set browser.executablePath if auto-detection is not enough.
  • If your delivery channel compresses images heavily (for example Telegram or WhatsApp), prefer fileFormat: "pdf" to preserve readability.
  • N unmodified lines rows may not always include expand controls for patch input, because many patch hunks do not carry full expandable context data.
  • Diff rendering is powered by Diffs.