@openclaw/diffs 2026.7.1 → 2026.7.2-beta.1

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
@@ -18,7 +18,8 @@ import { readFiniteNumberParam } from "openclaw/plugin-sdk/param-readers";
18
18
  import { Type } from "typebox";
19
19
  import { chromium } from "playwright-core";
20
20
  import { parsePatchFiles, resolveLanguage } from "@pierre/diffs";
21
- import { preloadFileDiff, preloadMultiFileDiff } from "@pierre/diffs/ssr";
21
+ import { preloadDiffHTML } from "@pierre/diffs/ssr";
22
+ import { escapeHtml } from "openclaw/plugin-sdk/text-utility-runtime";
22
23
  //#region extensions/diffs/src/types.ts
23
24
  const DIFF_LAYOUTS = ["unified", "split"];
24
25
  const DIFF_MODES = [
@@ -284,15 +285,15 @@ function normalizeTtlSeconds(ttlSeconds) {
284
285
  return Math.min(Math.max(Math.floor(ttlSeconds), 1), 21600);
285
286
  }
286
287
  function resolveDiffImageRenderOptions(params) {
287
- const format = normalizeFileFormat(params.fileFormat ?? params.imageFormat ?? params.format ?? params.defaults.fileFormat);
288
- const qualityOverrideProvided = params.fileQuality !== void 0 || params.imageQuality !== void 0;
289
- const qualityPreset = normalizeFileQuality$1(params.fileQuality ?? params.imageQuality ?? params.defaults.fileQuality);
288
+ const format = normalizeFileFormat(params.fileFormat ?? params.defaults.fileFormat);
289
+ const qualityOverrideProvided = params.fileQuality !== void 0;
290
+ const qualityPreset = normalizeFileQuality$1(params.fileQuality ?? params.defaults.fileQuality);
290
291
  const profile = DEFAULT_IMAGE_QUALITY_PROFILES[qualityPreset];
291
292
  return {
292
293
  format,
293
294
  qualityPreset,
294
- scale: normalizeFileScale(params.fileScale ?? params.imageScale, qualityOverrideProvided ? profile.scale : params.defaults.fileScale),
295
- maxWidth: normalizeFileMaxWidth(params.fileMaxWidth ?? params.imageMaxWidth, qualityOverrideProvided ? profile.maxWidth : params.defaults.fileMaxWidth),
295
+ scale: normalizeFileScale(params.fileScale, qualityOverrideProvided ? profile.scale : params.defaults.fileScale),
296
+ maxWidth: normalizeFileMaxWidth(params.fileMaxWidth, qualityOverrideProvided ? profile.maxWidth : params.defaults.fileMaxWidth),
296
297
  maxPixels: profile.maxPixels
297
298
  };
298
299
  }
@@ -1590,9 +1591,6 @@ var DiffRenderInputError = class extends Error {
1590
1591
  function escapeCssString(value) {
1591
1592
  return value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"");
1592
1593
  }
1593
- function escapeHtml(value) {
1594
- return value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;").replaceAll("'", "&#39;");
1595
- }
1596
1594
  function escapeJsonScript(value) {
1597
1595
  return JSON.stringify(value).replaceAll("<", "\\u003c");
1598
1596
  }
@@ -2008,19 +2006,18 @@ async function renderBeforeAfterDiff(input, options, target) {
2008
2006
  });
2009
2007
  const preloadOptions = viewerOptions ?? imageOptions;
2010
2008
  if (!preloadOptions) throw new Error(`Unsupported diff render target: ${target}`);
2011
- const preloadResult = await preloadMultiFileDiffWithFallback({
2009
+ const normalizedPayload = await normalizeDiffViewerPayloadLanguages({
2010
+ prerenderedHTML: await preloadDiffHTMLWithFallback({
2011
+ oldFile,
2012
+ newFile,
2013
+ options: preloadOptions
2014
+ }),
2012
2015
  oldFile,
2013
2016
  newFile,
2014
- options: preloadOptions
2015
- });
2016
- const normalizedPayload = await normalizeDiffViewerPayloadLanguages({
2017
- prerenderedHTML: preloadResult.prerenderedHTML,
2018
- oldFile: preloadResult.oldFile,
2019
- newFile: preloadResult.newFile,
2020
2017
  options: preloadOptions,
2021
2018
  langs: collectDiffPayloadLanguageHints({
2022
- oldFile: preloadResult.oldFile,
2023
- newFile: preloadResult.newFile
2019
+ oldFile,
2020
+ newFile
2024
2021
  })
2025
2022
  }, { languagePackAvailable });
2026
2023
  const viewerPayload = viewerOptions ? {
@@ -2063,15 +2060,14 @@ async function renderPatchDiff(input, options, target) {
2063
2060
  stats: computeFileDiffStats(fileDiff)
2064
2061
  }));
2065
2062
  const sections = await Promise.all(files.map(async (fileDiff, index) => {
2066
- const preloadResult = await preloadFileDiffWithFallback({
2067
- fileDiff,
2068
- options: preloadOptions
2069
- });
2070
2063
  const normalizedPayload = await normalizeDiffViewerPayloadLanguages({
2071
- prerenderedHTML: preloadResult.prerenderedHTML,
2072
- fileDiff: preloadResult.fileDiff,
2064
+ prerenderedHTML: await preloadDiffHTMLWithFallback({
2065
+ fileDiff,
2066
+ options: preloadOptions
2067
+ }),
2068
+ fileDiff,
2073
2069
  options: preloadOptions,
2074
- langs: collectDiffPayloadLanguageHints({ fileDiff: preloadResult.fileDiff })
2070
+ langs: collectDiffPayloadLanguageHints({ fileDiff })
2075
2071
  }, { languagePackAvailable });
2076
2072
  const viewerPayload = viewerOptions ? {
2077
2073
  ...normalizedPayload,
@@ -2134,27 +2130,12 @@ async function renderDiffDocument(input, options, target = "both") {
2134
2130
  function shouldFallbackToClientHydration(error) {
2135
2131
  return error instanceof TypeError && error.message.includes("needs an import attribute of \"type: json\"");
2136
2132
  }
2137
- async function preloadFileDiffWithFallback(params) {
2133
+ async function preloadDiffHTMLWithFallback(params) {
2138
2134
  try {
2139
- return await preloadFileDiff(params);
2135
+ return await preloadDiffHTML(params);
2140
2136
  } catch (error) {
2141
2137
  if (!shouldFallbackToClientHydration(error)) throw error;
2142
- return {
2143
- fileDiff: params.fileDiff,
2144
- prerenderedHTML: ""
2145
- };
2146
- }
2147
- }
2148
- async function preloadMultiFileDiffWithFallback(params) {
2149
- try {
2150
- return await preloadMultiFileDiff(params);
2151
- } catch (error) {
2152
- if (!shouldFallbackToClientHydration(error)) throw error;
2153
- return {
2154
- oldFile: params.oldFile,
2155
- newFile: params.newFile,
2156
- prerenderedHTML: ""
2157
- };
2138
+ return "";
2158
2139
  }
2159
2140
  }
2160
2141
  //#endregion
@@ -2199,30 +2180,6 @@ const DiffsToolSchema = Type.Object({
2199
2180
  minimum: 640,
2200
2181
  maximum: 2400
2201
2182
  }),
2202
- /** @deprecated Use fileQuality. */
2203
- imageQuality: Type.Optional(stringEnum(DIFF_IMAGE_QUALITY_PRESETS, {
2204
- description: "Deprecated alias for fileQuality.",
2205
- deprecated: true
2206
- })),
2207
- /** @deprecated Use fileFormat. */
2208
- imageFormat: Type.Optional(stringEnum(DIFF_OUTPUT_FORMATS, {
2209
- description: "Deprecated alias for fileFormat.",
2210
- deprecated: true
2211
- })),
2212
- /** @deprecated Use fileScale. */
2213
- imageScale: optionalFiniteNumberSchema({
2214
- description: "Deprecated alias for fileScale.",
2215
- deprecated: true,
2216
- minimum: 1,
2217
- maximum: 4
2218
- }),
2219
- /** @deprecated Use fileMaxWidth. */
2220
- imageMaxWidth: optionalFiniteNumberSchema({
2221
- description: "Deprecated alias for fileMaxWidth.",
2222
- deprecated: true,
2223
- minimum: 640,
2224
- maximum: 2400
2225
- }),
2226
2183
  expandUnchanged: Type.Optional(Type.Boolean({ description: "Expand unchanged sections instead of collapsing them." })),
2227
2184
  ttlSeconds: optionalFiniteNumberSchema({
2228
2185
  description: "Artifact lifetime in seconds. Default: 1800. Maximum: 21600.",
@@ -2257,13 +2214,13 @@ function createDiffsTool(params) {
2257
2214
  const layout = normalizeLayout(toolParams.layout, params.defaults.layout);
2258
2215
  const expandUnchanged = toolParams.expandUnchanged === true;
2259
2216
  const ttlSeconds = readFiniteNumberParam(rawRecord, "ttlSeconds") ?? params.defaults.ttlSeconds;
2260
- const fileScale = readFiniteNumberParam(rawRecord, "fileScale") ?? readFiniteNumberParam(rawRecord, "imageScale");
2261
- const fileMaxWidth = readFiniteNumberParam(rawRecord, "fileMaxWidth") ?? readFiniteNumberParam(rawRecord, "imageMaxWidth");
2217
+ const fileScale = readFiniteNumberParam(rawRecord, "fileScale");
2218
+ const fileMaxWidth = readFiniteNumberParam(rawRecord, "fileMaxWidth");
2262
2219
  const ttlMs = normalizeTtlMs(ttlSeconds);
2263
2220
  const image = resolveDiffImageRenderOptions({
2264
2221
  defaults: params.defaults,
2265
- fileFormat: normalizeOutputFormat(toolParams.fileFormat ?? toolParams.imageFormat ?? toolParams.format),
2266
- fileQuality: normalizeFileQuality(toolParams.fileQuality ?? toolParams.imageQuality),
2222
+ fileFormat: normalizeOutputFormat(toolParams.fileFormat),
2223
+ fileQuality: normalizeFileQuality(toolParams.fileQuality),
2267
2224
  fileScale,
2268
2225
  fileMaxWidth
2269
2226
  });
@@ -2383,8 +2340,7 @@ function createDiffsTool(params) {
2383
2340
  }],
2384
2341
  details: {
2385
2342
  ...baseDetails,
2386
- fileError: errorMessage,
2387
- imageError: errorMessage
2343
+ fileError: errorMessage
2388
2344
  }
2389
2345
  };
2390
2346
  }
@@ -2415,18 +2371,12 @@ function buildArtifactDetails(params) {
2415
2371
  return {
2416
2372
  ...params.baseDetails,
2417
2373
  filePath: params.artifactFile.path,
2418
- imagePath: params.artifactFile.path,
2419
2374
  path: params.artifactFile.path,
2420
2375
  fileBytes: params.artifactFile.bytes,
2421
- imageBytes: params.artifactFile.bytes,
2422
- format: params.image.format,
2423
2376
  fileFormat: params.image.format,
2424
2377
  fileQuality: params.image.qualityPreset,
2425
- imageQuality: params.image.qualityPreset,
2426
2378
  fileScale: params.image.scale,
2427
- imageScale: params.image.scale,
2428
- fileMaxWidth: params.image.maxWidth,
2429
- imageMaxWidth: params.image.maxWidth
2379
+ fileMaxWidth: params.image.maxWidth
2430
2380
  };
2431
2381
  }
2432
2382
  function buildFileArtifactMessage(params) {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@openclaw/diffs",
3
- "version": "2026.7.1",
3
+ "version": "2026.7.2-beta.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@openclaw/diffs",
9
- "version": "2026.7.1",
9
+ "version": "2026.7.2-beta.1",
10
10
  "dependencies": {
11
11
  "@pierre/diffs": "1.2.12",
12
12
  "@shikijs/langs": "4.3.0",
@@ -5,6 +5,7 @@
5
5
  },
6
6
  "name": "Diffs",
7
7
  "description": "OpenClaw read-only diff viewer plugin and file renderer for agents.",
8
+ "catalog": { "featured": true, "order": 40 },
8
9
  "contracts": {
9
10
  "tools": ["diffs"]
10
11
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/diffs",
3
- "version": "2026.7.1",
3
+ "version": "2026.7.2-beta.1",
4
4
  "description": "OpenClaw read-only diff viewer plugin and file renderer for agents.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,13 +25,13 @@
25
25
  "minHostVersion": ">=2026.4.30"
26
26
  },
27
27
  "compat": {
28
- "pluginApi": ">=2026.7.1"
28
+ "pluginApi": ">=2026.7.2-beta.1"
29
29
  },
30
30
  "assetScripts": {
31
31
  "build": "node ../../scripts/build-diffs-viewer-runtime.mjs curated"
32
32
  },
33
33
  "build": {
34
- "openclawVersion": "2026.7.1",
34
+ "openclawVersion": "2026.7.2-beta.1",
35
35
  "staticAssets": [
36
36
  {
37
37
  "source": "./assets/viewer-runtime.js",
@@ -55,7 +55,7 @@
55
55
  "skills/**"
56
56
  ],
57
57
  "peerDependencies": {
58
- "openclaw": ">=2026.7.1"
58
+ "openclaw": ">=2026.7.2-beta.1"
59
59
  },
60
60
  "peerDependenciesMeta": {
61
61
  "openclaw": {