@wp-playground/remote 3.1.51 → 3.1.53

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.
@@ -5,8 +5,10 @@ import type { ProgressReceiver } from '@php-wasm/progress';
5
5
  import type { MessageListener, UniversalPHP } from '@php-wasm/universal';
6
6
  import type { RemoteAPI, SyncProgressCallback } from '@php-wasm/web';
7
7
  import type { ProgressBarOptions } from './progress-bar';
8
+ import type { WebMCPToolDescriptor } from './webmcp-frame-bridge';
8
9
  import type { PlaygroundWorkerEndpoint, MountDescriptor, WorkerBootOptions } from './playground-worker-endpoint';
9
10
  export type { BootProgressEvent } from './playground-worker-endpoint';
11
+ export type { WebMCPToolDescriptor } from './webmcp-frame-bridge';
10
12
  export interface WebClientMixin extends ProgressReceiver {
11
13
  /**
12
14
  * Sets the progress bar options.
@@ -49,6 +51,23 @@ export interface WebClientMixin extends ProgressReceiver {
49
51
  * @param flags The iframe sandbox flags.
50
52
  */
51
53
  setIframeSandboxFlags(flags: string[]): Promise<void>;
54
+ /**
55
+ * Subscribes to the WebMCP tools a plugin registers with
56
+ * `document.modelContext` inside the WordPress document.
57
+ *
58
+ * The callback receives the complete tool list every time it changes, and
59
+ * once with the current list when it subscribes. A navigation to a page
60
+ * that registers no tools reports an empty list.
61
+ */
62
+ onWebMCPToolsChanged(fn: (tools: WebMCPToolDescriptor[]) => void): Promise<void>;
63
+ /**
64
+ * Runs one of those tools inside the WordPress document and returns its
65
+ * JSON-serializable result.
66
+ *
67
+ * @param name The tool name as announced by `onWebMCPToolsChanged`.
68
+ * @param args The tool input.
69
+ */
70
+ callWebMCPTool(name: string, args: Record<string, unknown>): Promise<unknown>;
52
71
  /**
53
72
  * The onDownloadProgress event listener.
54
73
  */
@@ -0,0 +1,30 @@
1
+ /**
2
+ * A tool a plugin registered with `document.modelContext` inside the
3
+ * WordPress document, as seen from outside that document.
4
+ *
5
+ * `execute` does not survive the frame boundary, so only the descriptive
6
+ * fields are carried over. Calls travel back through `callWebMCPTool()`.
7
+ */
8
+ export interface WebMCPToolDescriptor {
9
+ name: string;
10
+ description: string;
11
+ inputSchema?: Record<string, unknown>;
12
+ annotations?: {
13
+ readOnlyHint?: boolean;
14
+ destructiveHint?: boolean;
15
+ };
16
+ }
17
+ export interface WebMCPFrameBridge {
18
+ subscribe(listener: (tools: WebMCPToolDescriptor[]) => void): void;
19
+ callTool(name: string, args: Record<string, unknown>): Promise<unknown>;
20
+ }
21
+ /**
22
+ * Mirrors the WordPress document's WebMCP tools into this frame and forwards
23
+ * tool calls back into it.
24
+ *
25
+ * The WordPress document owns the registry because the remote frame cannot
26
+ * read its DOM under Document-Isolation-Policy. Each announcement carries the
27
+ * full tool list and replaces the previous one, so a navigation that registers
28
+ * no tools clears the list.
29
+ */
30
+ export declare function createWebMCPFrameBridge(wpFrame: HTMLIFrameElement): WebMCPFrameBridge;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wp-playground/remote",
3
- "version": "3.1.51",
3
+ "version": "3.1.53",
4
4
  "description": "WordPress Playground remote host",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,5 +25,5 @@
25
25
  "access": "public",
26
26
  "directory": "../../../dist/packages/playground/remote"
27
27
  },
28
- "gitHead": "a18fe6b003d7c8ab12441297eca0f525cce7e3e6"
28
+ "gitHead": "8cd60ace8c3d32c8cb2b569b7471fdd98f88013e"
29
29
  }