@thehammer/danx-dashboard-mcp 0.1.326 → 0.1.328

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.
@@ -21,6 +21,15 @@ const READY_WAIT_MS = 5000;
21
21
  export const READY_MESSAGE = "danx-design:ready";
22
22
  const READY_LISTENER = `window.__danxDesignReady = false; window.addEventListener("message", function (e) { ` +
23
23
  `if (e.data && e.data.type === ${JSON.stringify(READY_MESSAGE)}) window.__danxDesignReady = true; });`;
24
+ /**
25
+ * DX-5350: the screenshot renders the page outside `SandboxedFrame`, so `window.danxMiniApp` (which the frame injects, `@danxbot/ui` 27.0.0)
26
+ * is restated here as a stub: `holdReady`, a once-only `ready` and ready-on-`load` unless held, posting the same ready message the listener
27
+ * above hears. `reportError` and `onAppearance` are no-ops so a harness never throws.
28
+ */
29
+ const MINI_APP_STUB = `(function () { var held = false, posted = false; ` +
30
+ `function ready() { if (posted) return; posted = true; window.postMessage({ type: ${JSON.stringify(READY_MESSAGE)} }, "*"); } ` +
31
+ `window.danxMiniApp = { holdReady: function () { held = true; }, ready: ready, reportError: function () {}, onAppearance: function () { return function () {}; } }; ` +
32
+ `window.addEventListener("load", function () { if (!held) ready(); }); })();`;
24
33
  function none(reason) {
25
34
  return { png_base64: null, screenshot: `none: ${reason}` };
26
35
  }
@@ -93,15 +102,21 @@ export async function captureWith(where, offline, drive) {
93
102
  await browser.close().catch((err) => console.error(`[danx-dashboard-mcp] could not close the browser: ${oneLine(err)}`));
94
103
  }
95
104
  }
105
+ /** DX-5319: where the built html is served for the capture: a route answered by the capture itself, so the page is a real navigation and never reaches a network. */
106
+ const DESIGN_PAGE_URL = "https://design.invalid/";
96
107
  /**
97
- * Capture `html` as a 1280x800 viewport PNG (device scale 1, network disabled). The page is `setContent`-ed, then given a short wait
98
- * for the harness's ready message (the page has loaded either way).
108
+ * Capture `html` as a 1280x800 viewport PNG (device scale 1, network disabled). The page is served from a route and navigated to, never
109
+ * `setContent`-ed: an init script runs on a navigation and not on `setContent`'s `document.write`, so the ready listener and the
110
+ * `window.danxMiniApp` stub would not exist and every capture would wait out the whole ready timeout (DX-5319, measured: 5.2 s, the stub
111
+ * undefined). It then gets a short wait for the harness's ready message (the page has loaded either way).
99
112
  */
100
113
  export function captureScreenshot(html, where) {
101
114
  return captureWith(where, true, async (page) => {
102
115
  await page.addInitScript(READY_LISTENER);
103
- await page.setContent(html, { waitUntil: "load" });
104
- // The page has loaded; a design that never posts ready (it threw, or its harness is older) is still captured as it stands.
116
+ await page.addInitScript(MINI_APP_STUB);
117
+ await page.route(DESIGN_PAGE_URL, (route) => route.fulfill({ status: 200, contentType: "text/html; charset=utf-8", body: html }));
118
+ await page.goto(DESIGN_PAGE_URL, { waitUntil: "load" });
119
+ // The page has loaded; a design that never posts ready (it threw) is still captured as it stands.
105
120
  await page.waitForFunction("window.__danxDesignReady === true", undefined, { timeout: READY_WAIT_MS }).catch(() => undefined);
106
121
  });
107
122
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thehammer/danx-dashboard-mcp",
3
- "version": "0.1.326",
3
+ "version": "0.1.328",
4
4
  "description": "Stdio MCP server fronting danxbot's dashboard API for agents (operator sessions and dispatched workers alike): the generic danxbot_api/danxbot_api_list/danxbot_api_spec tools reach any route the caller's credential may call, plus dedicated agent-specific tools (plan_connect, request_permission, attach_file, and danxbot_slack_reply) (DX-3465, PLN-11 R-25).",
5
5
  "license": "MIT",
6
6
  "type": "module",