@mcpview/compose 0.13.0 → 0.13.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.
Files changed (101) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +79 -2
  3. package/esm/_dnt.polyfills.d.ts +11 -11
  4. package/esm/_dnt.polyfills.d.ts.map +1 -1
  5. package/esm/_dnt.polyfills.js +14 -14
  6. package/esm/src/code-mode/board.d.ts +18 -2
  7. package/esm/src/code-mode/board.d.ts.map +1 -1
  8. package/esm/src/code-mode/board.js +74 -2
  9. package/esm/src/code-mode/chain.d.ts +2 -0
  10. package/esm/src/code-mode/chain.d.ts.map +1 -1
  11. package/esm/src/code-mode/chain.js +34 -8
  12. package/esm/src/code-mode/connections.d.ts +1 -0
  13. package/esm/src/code-mode/connections.d.ts.map +1 -1
  14. package/esm/src/code-mode/connections.js +1 -0
  15. package/esm/src/code-mode/layout-publisher.d.ts +69 -0
  16. package/esm/src/code-mode/layout-publisher.d.ts.map +1 -0
  17. package/esm/src/code-mode/layout-publisher.js +85 -0
  18. package/esm/src/code-mode/layout-runs.d.ts +35 -0
  19. package/esm/src/code-mode/layout-runs.d.ts.map +1 -0
  20. package/esm/src/code-mode/layout-runs.js +130 -0
  21. package/esm/src/code-mode/layout.d.ts +20 -0
  22. package/esm/src/code-mode/layout.d.ts.map +1 -0
  23. package/esm/src/code-mode/layout.js +54 -0
  24. package/esm/src/code-mode/mod.d.ts +1 -0
  25. package/esm/src/code-mode/mod.d.ts.map +1 -1
  26. package/esm/src/code-mode/mod.js +1 -0
  27. package/esm/src/code-mode/panel-contexts.d.ts +25 -0
  28. package/esm/src/code-mode/panel-contexts.d.ts.map +1 -0
  29. package/esm/src/code-mode/panel-contexts.js +115 -0
  30. package/esm/src/code-mode/providers.d.ts +3 -0
  31. package/esm/src/code-mode/providers.d.ts.map +1 -1
  32. package/esm/src/code-mode/sandbox.d.ts.map +1 -1
  33. package/esm/src/code-mode/sandbox.js +2 -1
  34. package/esm/src/code-mode/sync.d.ts +11 -0
  35. package/esm/src/code-mode/sync.d.ts.map +1 -0
  36. package/esm/src/code-mode/sync.js +42 -0
  37. package/esm/src/code-mode/tool.d.ts +1 -1
  38. package/esm/src/code-mode/tool.d.ts.map +1 -1
  39. package/esm/src/code-mode/tool.js +12 -0
  40. package/esm/src/host/renderer/html-generator.js +2 -2
  41. package/esm/src/host/renderer/panel-controls.d.ts +7 -0
  42. package/esm/src/host/renderer/panel-controls.js +1 -0
  43. package/esm/src/host/renderer/panel-movement.d.ts.map +1 -1
  44. package/esm/src/host/renderer/panel-movement.js +5 -1
  45. package/esm/src/host/renderer/panel-resizing.d.ts.map +1 -1
  46. package/esm/src/host/renderer/panel-resizing.js +28 -0
  47. package/esm/src/host/renderer/panel-snapshot.d.ts +11 -0
  48. package/esm/src/host/renderer/panel-snapshot.d.ts.map +1 -0
  49. package/esm/src/host/renderer/panel-snapshot.js +65 -0
  50. package/esm/src/version.d.ts +1 -1
  51. package/esm/src/version.js +1 -1
  52. package/package.json +9 -1
  53. package/script/_dnt.polyfills.d.ts +11 -11
  54. package/script/_dnt.polyfills.d.ts.map +1 -1
  55. package/script/_dnt.polyfills.js +14 -14
  56. package/script/src/code-mode/board.d.ts +18 -2
  57. package/script/src/code-mode/board.d.ts.map +1 -1
  58. package/script/src/code-mode/board.js +81 -2
  59. package/script/src/code-mode/chain.d.ts +2 -0
  60. package/script/src/code-mode/chain.d.ts.map +1 -1
  61. package/script/src/code-mode/chain.js +34 -8
  62. package/script/src/code-mode/connections.d.ts +1 -0
  63. package/script/src/code-mode/connections.d.ts.map +1 -1
  64. package/script/src/code-mode/connections.js +1 -0
  65. package/script/src/code-mode/layout-publisher.d.ts +69 -0
  66. package/script/src/code-mode/layout-publisher.d.ts.map +1 -0
  67. package/script/src/code-mode/layout-publisher.js +88 -0
  68. package/script/src/code-mode/layout-runs.d.ts +35 -0
  69. package/script/src/code-mode/layout-runs.d.ts.map +1 -0
  70. package/script/src/code-mode/layout-runs.js +134 -0
  71. package/script/src/code-mode/layout.d.ts +20 -0
  72. package/script/src/code-mode/layout.d.ts.map +1 -0
  73. package/script/src/code-mode/layout.js +57 -0
  74. package/script/src/code-mode/mod.d.ts +1 -0
  75. package/script/src/code-mode/mod.d.ts.map +1 -1
  76. package/script/src/code-mode/mod.js +6 -1
  77. package/script/src/code-mode/panel-contexts.d.ts +25 -0
  78. package/script/src/code-mode/panel-contexts.d.ts.map +1 -0
  79. package/script/src/code-mode/panel-contexts.js +118 -0
  80. package/script/src/code-mode/providers.d.ts +3 -0
  81. package/script/src/code-mode/providers.d.ts.map +1 -1
  82. package/script/src/code-mode/sandbox.d.ts.map +1 -1
  83. package/script/src/code-mode/sandbox.js +2 -1
  84. package/script/src/code-mode/sync.d.ts +11 -0
  85. package/script/src/code-mode/sync.d.ts.map +1 -0
  86. package/script/src/code-mode/sync.js +51 -0
  87. package/script/src/code-mode/tool.d.ts +1 -1
  88. package/script/src/code-mode/tool.d.ts.map +1 -1
  89. package/script/src/code-mode/tool.js +12 -0
  90. package/script/src/host/renderer/html-generator.js +2 -2
  91. package/script/src/host/renderer/panel-controls.d.ts +7 -0
  92. package/script/src/host/renderer/panel-controls.js +4 -1
  93. package/script/src/host/renderer/panel-movement.d.ts.map +1 -1
  94. package/script/src/host/renderer/panel-movement.js +5 -1
  95. package/script/src/host/renderer/panel-resizing.d.ts.map +1 -1
  96. package/script/src/host/renderer/panel-resizing.js +28 -0
  97. package/script/src/host/renderer/panel-snapshot.d.ts +11 -0
  98. package/script/src/host/renderer/panel-snapshot.d.ts.map +1 -0
  99. package/script/src/host/renderer/panel-snapshot.js +69 -0
  100. package/script/src/version.d.ts +1 -1
  101. package/script/src/version.js +1 -1
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createSnippetChain = createSnippetChain;
4
+ const sync_js_1 = require("./sync.js");
4
5
  const board_js_1 = require("./board.js");
5
6
  const providers_js_1 = require("./providers.js");
6
7
  const sandbox_js_1 = require("./sandbox.js");
@@ -42,16 +43,19 @@ function validateParams(input, shape) {
42
43
  }
43
44
  return input;
44
45
  }
45
- function output(value, panels = [], saved) {
46
+ function output(value, panels = [], saved, sync = []) {
46
47
  const visible = {
47
48
  value,
48
- panels: panels.map(({ result: _result, ...panel }) => panel),
49
+ panels: panels.map(({ result: _result, events: _events, ...panel }) => panel),
49
50
  ...(saved === undefined ? {} : { saved }),
50
51
  };
51
52
  return {
52
53
  content: [{ type: "text", text: JSON.stringify(visible) }],
53
54
  structuredContent: visible,
54
- _meta: { [board_js_1.SNIPPET_PANELS_META_KEY]: panels },
55
+ _meta: {
56
+ [board_js_1.SNIPPET_PANELS_META_KEY]: panels,
57
+ ...(sync.length ? { [sync_js_1.SNIPPET_SYNC_META_KEY]: sync } : {}),
58
+ },
55
59
  };
56
60
  }
57
61
  /**
@@ -66,6 +70,8 @@ function createSnippetChain(providers, catalog) {
66
70
  async function execute(code, params, context, status) {
67
71
  const receipts = new Map();
68
72
  const selected = new Map();
73
+ const exposedPorts = new Map();
74
+ const sync = new Map();
69
75
  let totalBytes = 0;
70
76
  const value = await (0, sandbox_js_1.runProgram)(code, params, async (operation, args, signal) => {
71
77
  signal.throwIfAborted();
@@ -78,6 +84,18 @@ function createSnippetChain(providers, catalog) {
78
84
  throw new Error("Panel titles may contain at most 120 characters.");
79
85
  }
80
86
  selected.set(panel.id, { ...panel, title: second ?? panel.title });
87
+ exposedPorts.set(panel.id, panel.events);
88
+ return null;
89
+ }
90
+ if (operation === "sync") {
91
+ const rule = args.length === 1 ? (0, sync_js_1.parseSnippetSyncRule)(first) : undefined;
92
+ if (!rule || !(0, sync_js_1.supportsSnippetSync)(rule, exposedPorts)) {
93
+ status.diagnostic =
94
+ "Sync requires distinct selected panel receipts and their declared event and action.";
95
+ throw new Error(status.diagnostic);
96
+ }
97
+ const key = (0, sync_js_1.snippetSyncKey)(rule);
98
+ sync.set(key, rule);
81
99
  return null;
82
100
  }
83
101
  const provider = typeof first === "string" ? providers.get(first) : undefined;
@@ -117,10 +135,18 @@ function createSnippetChain(providers, catalog) {
117
135
  throw new Error("Native snippet receipts exceed the board size limit.");
118
136
  }
119
137
  const id = crypto.randomUUID();
120
- receipts.set(id, { id, provider: first, name: second, title: second, result });
138
+ const events = (0, sync_js_1.snippetPorts)(provider.events, second);
139
+ receipts.set(id, {
140
+ id,
141
+ provider: first,
142
+ name: second,
143
+ title: second,
144
+ result,
145
+ ...(events ? { events } : {}),
146
+ });
121
147
  return { id, value };
122
148
  }, context.signal);
123
- return { value, panels: [...selected.values()] };
149
+ return { value, panels: [...selected.values()], sync: [...sync.values()] };
124
150
  }
125
151
  async function call(input, context, status) {
126
152
  const { signal, scope } = context;
@@ -134,7 +160,7 @@ function createSnippetChain(providers, catalog) {
134
160
  throw new Error("Supply a JavaScript function body.");
135
161
  const result = await execute(input.code, validateParams(input.params === undefined ? {} : input.params), context, status);
136
162
  signal?.throwIfAborted();
137
- return output(result.value, result.panels);
163
+ return output(result.value, result.panels, undefined, result.sync);
138
164
  }
139
165
  if (!catalog || typeof scope !== "string" || !scope.trim()) {
140
166
  throw new Error("Saved chains require a configured catalog and a trusted scope.");
@@ -150,7 +176,7 @@ function createSnippetChain(providers, catalog) {
150
176
  execute: (code, params) => execute(code, params, context, status),
151
177
  });
152
178
  signal?.throwIfAborted();
153
- return output(result.value, result.panels);
179
+ return output(result.value, result.panels, undefined, result.sync);
154
180
  }
155
181
  if (typeof input.code !== "string" || !has("saveAs") || !keysAllowed("code", "saveAs", "params")) {
156
182
  throw new Error("Supply code, replay, or listSaved.");
@@ -202,7 +228,7 @@ function createSnippetChain(providers, catalog) {
202
228
  const ref = catalog.recordSuccess(scope, input.code, params);
203
229
  const saved = await catalog.save(scope, ref, name);
204
230
  reserved = false;
205
- return output(result.value, result.panels, saved.name);
231
+ return output(result.value, result.panels, saved.name, result.sync);
206
232
  }
207
233
  finally {
208
234
  usage.saving.delete(name);
@@ -6,6 +6,7 @@ export type SnippetMcpClient = Pick<Client, "callTool">;
6
6
  export type SnippetProviderBinding = {
7
7
  readonly alias: string;
8
8
  readonly snippets: readonly string[];
9
+ readonly events?: SnippetProvider["events"];
9
10
  } & ({
10
11
  readonly url: URL | string;
11
12
  readonly requestInit?: RequestInit;
@@ -1 +1 @@
1
- {"version":3,"file":"connections.d.ts","sourceRoot":"","sources":["../../../src/src/code-mode/connections.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAiC,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACrB,MAAM,gBAAgB,CAAC;AAExB,mGAAmG;AACnG,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAExD,gFAAgF;AAChF,MAAM,MAAM,sBAAsB,GAC9B;IACA,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC,GACC,CAAC;IACD,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IACnC,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC;CACzB,GAAG;IACF,+EAA+E;IAC/E,QAAQ,CAAC,MAAM,EACX,gBAAgB,GAChB,CAAC,CAAC,OAAO,EAAE,mBAAmB,KAAK,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACrF,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC;CAC9B,CAAC,CAAC;AAEL,iGAAiG;AACjG,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACzD,KAAK,IAAI,O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A0B;IACzC,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACzD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,SAAS,sBAAsB,EAAE,EAC3C,OAAO,GAAE;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAO,GAC9C,OAAO,CAAC,0BAA0B,CAAC,CAkHrC"}
@@ -84,6 +84,7 @@ async function connectSnippetProviders(bindings, options = {}) {
84
84
  const clientSource = source;
85
85
  const provider = {
86
86
  names,
87
+ events: binding.events,
87
88
  async call(tool, args, signal, context) {
88
89
  signal.throwIfAborted();
89
90
  if (closing)
@@ -0,0 +1,69 @@
1
+ /** Browser-side transport for user-edited Code Mode dashboard layouts. @module */
2
+ import { capturePanelLayout } from "../host/renderer/panel-controls.js";
3
+ import type { PanelLayoutSnapshot } from "./layout.js";
4
+ /** The conversation receives a reference to the staged geometry. */
5
+ export interface SnippetLayoutReceipt {
6
+ /** Execution reference supplied by the server that owns the snippet. */
7
+ runId: string;
8
+ /** Monotonic revision within this mounted board. */
9
+ revision: number;
10
+ /** Whether the server has acknowledged this revision for saving. */
11
+ status: "pending" | "ready" | "failed";
12
+ }
13
+ /** State available to an App's translated layout feedback and retry controls. */
14
+ export type SnippetLayoutStatus = SnippetLayoutReceipt["status"] | "local" | "restore-failed";
15
+ /** MCP Apps host methods and the board's context writer, which can aggregate panel selections. */
16
+ export interface SnippetBoardLayoutOptions {
17
+ /** Connected MCP App providing the negotiated capabilities and the staging callback. */
18
+ host: {
19
+ getHostCapabilities(): {
20
+ serverTools?: unknown;
21
+ updateModelContext?: {
22
+ structuredContent?: unknown;
23
+ text?: unknown;
24
+ };
25
+ } | undefined;
26
+ callServerTool(params: {
27
+ name: string;
28
+ arguments: {
29
+ runId: string;
30
+ revision: number;
31
+ layout: PanelLayoutSnapshot;
32
+ };
33
+ }, options: {
34
+ signal: AbortSignal;
35
+ }): Promise<{
36
+ structuredContent?: unknown;
37
+ isError?: boolean;
38
+ }>;
39
+ };
40
+ /** The board's context writer, shared with the panels in this App. */
41
+ updateContext(update: {
42
+ structuredContent: {
43
+ snippetLayout: SnippetLayoutReceipt;
44
+ };
45
+ } | {
46
+ content: {
47
+ type: "text";
48
+ text: string;
49
+ }[];
50
+ }): Promise<object>;
51
+ /** App-only callback that stages the geometry and returns the matching run ID and revision. */
52
+ stageTool: string;
53
+ /** Execution metadata from the tool result. Without a reference, edits stay local. */
54
+ runId?: unknown;
55
+ /** Previously saved geometry supplied on replay. */
56
+ savedLayout?: unknown;
57
+ /** Signals the end of this board's display lifetime. */
58
+ signal: AbortSignal;
59
+ /** Receives updates for the App's own feedback, including recoverable errors. */
60
+ onStatus?(status: SnippetLayoutStatus): void;
61
+ }
62
+ /**
63
+ * Install the controls and restore a saved layout on a mounted board. Each
64
+ * committed gesture stages its geometry and publishes an acknowledgement for
65
+ * the next model turn. Pass the board's context writer when other panels share
66
+ * its context. The returned callback retries the current layout after an error.
67
+ */
68
+ export declare function connectSnippetBoardLayout(board: Parameters<typeof capturePanelLayout>[0], { host, updateContext, stageTool, runId, savedLayout, signal, onStatus }: SnippetBoardLayoutOptions): () => Promise<void>;
69
+ //# sourceMappingURL=layout-publisher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout-publisher.d.ts","sourceRoot":"","sources":["../../../src/src/code-mode/layout-publisher.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,OAAO,EACL,kBAAkB,EAInB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,oEAAoE;AACpE,MAAM,WAAW,oBAAoB;IACnC,wEAAwE;IACxE,KAAK,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,MAAM,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AAW,CAAC;IACpB,iFAAiF;IACjF,QAAQ,CAAC,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;CAC9C;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC,EAC/C,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,EACtE,yBAAyB,GAC1B,MAAM,OAAO,CAAC,IAAI,CAAC,CA4ErB"}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.connectSnippetBoardLayout = connectSnippetBoardLayout;
4
+ /** Browser-side transport for user-edited Code Mode dashboard layouts. @module */
5
+ const panel_controls_js_1 = require("../host/renderer/panel-controls.js");
6
+ /**
7
+ * Install the controls and restore a saved layout on a mounted board. Each
8
+ * committed gesture stages its geometry and publishes an acknowledgement for
9
+ * the next model turn. Pass the board's context writer when other panels share
10
+ * its context. The returned callback retries the current layout after an error.
11
+ */
12
+ function connectSnippetBoardLayout(board, { host, updateContext, stageTool, runId, savedLayout, signal, onStatus }) {
13
+ (0, panel_controls_js_1.installPanelMovement)(board, signal);
14
+ (0, panel_controls_js_1.installPanelResizing)(board, signal);
15
+ if (!signal.aborted && savedLayout !== undefined && !(0, panel_controls_js_1.restorePanelLayout)(board, savedLayout)) {
16
+ onStatus?.("restore-failed");
17
+ }
18
+ const capabilities = host.getHostCapabilities();
19
+ const formats = capabilities?.updateModelContext;
20
+ const structured = typeof formats?.structuredContent === "object" &&
21
+ formats.structuredContent !== null;
22
+ const text = typeof formats?.text === "object" && formats.text !== null;
23
+ let latest = 0;
24
+ let contextSent = Promise.resolve();
25
+ function sendReceipt(receipt) {
26
+ // Wait for the preceding context write even if the host delivers requests out of order.
27
+ const next = contextSent.then(async () => {
28
+ signal.throwIfAborted();
29
+ if (receipt.status !== "pending" && receipt.revision !== latest)
30
+ return;
31
+ const value = { snippetLayout: receipt };
32
+ // Once sent, an App-wide context update may include live selections from
33
+ // other panels. Let its acknowledgement settle even if this board closes.
34
+ const response = await updateContext(structured
35
+ ? { structuredContent: value }
36
+ : { content: [{ type: "text", text: JSON.stringify(value) }] });
37
+ if ("isError" in response && response.isError)
38
+ throw new Error("Layout receipt rejected");
39
+ });
40
+ contextSent = next.catch(() => { });
41
+ return next;
42
+ }
43
+ async function commit() {
44
+ if (signal.aborted)
45
+ return;
46
+ if (typeof runId !== "string" || !capabilities?.serverTools || !(structured || text)) {
47
+ onStatus?.("local");
48
+ return;
49
+ }
50
+ const layout = (0, panel_controls_js_1.capturePanelLayout)(board);
51
+ if (!layout) {
52
+ onStatus?.("local");
53
+ return;
54
+ }
55
+ const revision = ++latest;
56
+ const current = () => latest === revision && !signal.aborted;
57
+ onStatus?.("pending");
58
+ try {
59
+ const [staged] = await Promise.all([
60
+ host.callServerTool({ name: stageTool, arguments: { runId, revision, layout } }, {
61
+ signal,
62
+ }),
63
+ sendReceipt({ runId, revision, status: "pending" }),
64
+ ]);
65
+ const ack = staged.structuredContent;
66
+ if (staged.isError || !ack || typeof ack !== "object" ||
67
+ !("runId" in ack) || ack.runId !== runId ||
68
+ !("revision" in ack) || ack.revision !== revision) {
69
+ throw new Error("Layout revision not acknowledged");
70
+ }
71
+ if (!current())
72
+ return;
73
+ await sendReceipt({ runId, revision, status: "ready" });
74
+ if (current())
75
+ onStatus?.("ready");
76
+ }
77
+ catch {
78
+ if (!current())
79
+ return;
80
+ onStatus?.("failed");
81
+ // Leave retry available even when a disconnected host rejects the failure notice.
82
+ await sendReceipt({ runId, revision, status: "failed" }).catch(() => { });
83
+ }
84
+ }
85
+ const events = board;
86
+ events.addEventListener("compose-panel-layout-committed", commit, { signal });
87
+ return commit;
88
+ }
@@ -0,0 +1,35 @@
1
+ /** Scoped layout drafts for saved Code Mode dashboards. @module */
2
+ import "../../_dnt.polyfills.js";
3
+ import { type PanelLayoutSnapshot } from "./layout.js";
4
+ /** Accepted widths per stable panel ID. Use an empty list for a fixed-width viewer. */
5
+ export type PanelWidths = ReadonlyMap<string, readonly number[]>;
6
+ /** Correlate app gestures and explicit snippet saves within a trusted execution scope. */
7
+ export declare class BoardLayoutRuns<Receipt = void> {
8
+ private readonly runs;
9
+ private readonly referenceTtlMs;
10
+ private readonly maxPendingReferences;
11
+ /** Pass the reference lifetime and capacity used by the snippet catalog. */
12
+ constructor(options?: {
13
+ referenceTtlMs?: number;
14
+ maxPendingReferences?: number;
15
+ });
16
+ /** Register a successful run and return the saved layout if it fits today's panel declarations. */
17
+ open(scope: string, runId: string, panels: PanelWidths, replayedName?: string, savedLayout?: unknown): PanelLayoutSnapshot | undefined;
18
+ private find;
19
+ /** Bind the name only after the scoped catalog has successfully saved the program. */
20
+ saved(scope: string, runId: string, name: string): void;
21
+ /** Acknowledge a committed layout, including an identical retry after a lost response. */
22
+ stage(scope: string, runId: unknown, revision: unknown, snapshot: unknown): {
23
+ runId: string;
24
+ revision: number;
25
+ };
26
+ /** Return only acknowledged geometry for save or update. An update must target a bound name. */
27
+ selected(scope: string, runId: string, revision?: unknown, updateName?: string): PanelLayoutSnapshot | undefined;
28
+ /**
29
+ * Apply the explicit update once per named board revision. Retain only the
30
+ * latest receipt per bound name until this execution expires. A failed
31
+ * write can be retried, and an older in-flight write finishes before a newer one.
32
+ */
33
+ commitUpdate(scope: string, runId: string, revision: number, name: string, write: (layout: PanelLayoutSnapshot) => Promise<Receipt>): Promise<Receipt>;
34
+ }
35
+ //# sourceMappingURL=layout-runs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout-runs.d.ts","sourceRoot":"","sources":["../../../src/src/code-mode/layout-runs.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EAAyB,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAE9E,uFAAuF;AACvF,MAAM,MAAM,W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OAAO,CAAC,OAAO,CAAC,GACvD,OAAO,CAAC,OAAO,CAAC;CAiBpB"}
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BoardLayoutRuns = void 0;
4
+ /** Scoped layout drafts for saved Code Mode dashboards. @module */
5
+ require("../../_dnt.polyfills.js");
6
+ const layout_js_1 = require("./layout.js");
7
+ function matchesBoard(value, panels) {
8
+ return (0, layout_js_1.isPanelLayoutSnapshot)(value) && value.order.length === panels.size &&
9
+ value.order.every((id) => panels.has(id)) &&
10
+ value.widths.every(({ panel, width }) => panels.get(panel)?.includes(width));
11
+ }
12
+ function copyLayout({ order, widths, placements }) {
13
+ return {
14
+ version: 1,
15
+ order: [...order],
16
+ widths: widths.map(({ panel, width }) => ({ panel, width })),
17
+ placements: placements.map(({ panel, beside, side }) => ({ panel, beside, side })),
18
+ };
19
+ }
20
+ /** Correlate app gestures and explicit snippet saves within a trusted execution scope. */
21
+ class BoardLayoutRuns {
22
+ runs = new Map();
23
+ referenceTtlMs;
24
+ maxPendingReferences;
25
+ /** Pass the reference lifetime and capacity used by the snippet catalog. */
26
+ constructor(options = {}) {
27
+ this.referenceTtlMs = options.referenceTtlMs ?? 10 * 60_000;
28
+ this.maxPendingReferences = options.maxPendingReferences ?? 1024;
29
+ for (const limit of [this.referenceTtlMs, this.maxPendingReferences]) {
30
+ if (!Number.isSafeInteger(limit) || limit <= 0) {
31
+ throw new RangeError("Invalid reference limit");
32
+ }
33
+ }
34
+ }
35
+ /** Register a successful run and return the saved layout if it fits today's panel declarations. */
36
+ open(scope, runId, panels, replayedName, savedLayout) {
37
+ if (!scope.trim() || !runId.trim()) {
38
+ throw new TypeError("Dashboard runs require a scope and run ID");
39
+ }
40
+ const now = Date.now();
41
+ if ((this.runs.get(runId)?.expiresAt ?? 0) > now) {
42
+ throw new Error("Dashboard execution already registered");
43
+ }
44
+ for (const [key, run] of this.runs) {
45
+ if (run.expiresAt > now && this.runs.size < this.maxPendingReferences)
46
+ break;
47
+ this.runs.delete(key);
48
+ }
49
+ const initial = matchesBoard(savedLayout, panels) ? copyLayout(savedLayout) : undefined;
50
+ this.runs.set(runId, {
51
+ scope,
52
+ panels: new Map(Array.from(panels, ([id, widths]) => [id, [...widths]])),
53
+ names: new Map(replayedName === undefined ? [] : [[replayedName, undefined]]),
54
+ initial,
55
+ expiresAt: now + this.referenceTtlMs,
56
+ });
57
+ return initial && copyLayout(initial);
58
+ }
59
+ find(scope, runId) {
60
+ const run = this.runs.get(runId);
61
+ if (run?.scope === scope && run.expiresAt > Date.now())
62
+ return run;
63
+ }
64
+ /** Bind the name only after the scoped catalog has successfully saved the program. */
65
+ saved(scope, runId, name) {
66
+ const run = this.find(scope, runId);
67
+ if (!run || run.names.has(name))
68
+ return;
69
+ // Cap both bound aliases and retained receipts. A dropped alias can be reopened normally.
70
+ if (run.names.size >= 32)
71
+ run.names.delete(run.names.keys().next().value);
72
+ run.names.set(name, undefined);
73
+ }
74
+ /** Acknowledge a committed layout, including an identical retry after a lost response. */
75
+ stage(scope, runId, revision, snapshot) {
76
+ const run = typeof runId === "string" && this.find(scope, runId);
77
+ if (!run || typeof runId !== "string") {
78
+ throw new Error("Dashboard execution expired or unavailable. Reopen the dashboard.");
79
+ }
80
+ if (typeof revision !== "number" || !Number.isSafeInteger(revision) || revision < 1 ||
81
+ !matchesBoard(snapshot, run.panels)) {
82
+ throw new Error("Invalid layout for this dashboard execution.");
83
+ }
84
+ const layout = copyLayout(snapshot);
85
+ if (run.draft && (revision < run.draft.revision ||
86
+ (revision === run.draft.revision &&
87
+ JSON.stringify(layout) !== JSON.stringify(run.draft.layout)))) {
88
+ throw new Error("The dashboard layout revision is stale.");
89
+ }
90
+ run.draft = { revision, layout };
91
+ return { runId, revision };
92
+ }
93
+ /** Return only acknowledged geometry for save or update. An update must target a bound name. */
94
+ selected(scope, runId, revision, updateName) {
95
+ const run = this.find(scope, runId);
96
+ if (revision === undefined && updateName === undefined && !run?.draft) {
97
+ return run?.initial && copyLayout(run.initial);
98
+ }
99
+ if (!run?.draft || revision !== run.draft.revision) {
100
+ throw new Error("Use the latest ready snippetLayout runId and revision from the dashboard.");
101
+ }
102
+ if (updateName !== undefined && !run.names.has(updateName)) {
103
+ throw new Error("This dashboard belongs to a different snippet. Open or save the requested snippet first.");
104
+ }
105
+ return copyLayout(run.draft.layout);
106
+ }
107
+ /**
108
+ * Apply the explicit update once per named board revision. Retain only the
109
+ * latest receipt per bound name until this execution expires. A failed
110
+ * write can be retried, and an older in-flight write finishes before a newer one.
111
+ */
112
+ async commitUpdate(scope, runId, revision, name, write) {
113
+ const layout = this.selected(scope, runId, revision, name);
114
+ if (!layout)
115
+ throw new Error("The dashboard has no acknowledged layout.");
116
+ const run = this.runs.get(runId);
117
+ const previous = run.names.get(name);
118
+ if (previous?.revision === revision)
119
+ return await previous.receipt;
120
+ const receipt = (previous?.receipt ?? Promise.resolve())
121
+ .catch(() => { })
122
+ .then(() => write(layout));
123
+ run.names.set(name, { revision, receipt });
124
+ try {
125
+ return await receipt;
126
+ }
127
+ catch (error) {
128
+ if (run.names.get(name)?.receipt === receipt)
129
+ run.names.set(name, undefined);
130
+ throw error;
131
+ }
132
+ }
133
+ }
134
+ exports.BoardLayoutRuns = BoardLayoutRuns;
@@ -0,0 +1,20 @@
1
+ /** Versioned layout preferences for a Code Mode dashboard. @module */
2
+ /** User-selected panel positions and supported widths, independent of ERP data and chat context. */
3
+ import "../../_dnt.polyfills.js";
4
+ export type PanelLayoutSnapshot = {
5
+ readonly version: 1;
6
+ /** Panel IDs in the template's original slot order. */
7
+ readonly order: readonly string[];
8
+ readonly widths: readonly {
9
+ readonly panel: string;
10
+ readonly width: number;
11
+ }[];
12
+ readonly placements: readonly {
13
+ readonly panel: string;
14
+ readonly beside: string;
15
+ readonly side: "left" | "right" | "below";
16
+ }[];
17
+ };
18
+ /** Validate an untrusted JSON snapshot, including placement anchors and their dependencies. */
19
+ export declare function isPanelLayoutSnapshot(value: unknown): value is PanelLayoutSnapshot;
20
+ //# sourceMappingURL=layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/src/code-mode/layout.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,oGAAoG;AACpG,OAAO,yBAAyB,CAAC;AAEjC,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACpB,uDAAuD;IACvD,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,SAAS;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC/E,QAAQ,CAAC,UAAU,EAAE,SAAS;QAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;KAC3C,EAAE,CAAC;CACL,CAAC;AAiBF,+FAA+F;AAC/F,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,mBAAmB,CAsClF"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPanelLayoutSnapshot = isPanelLayoutSnapshot;
4
+ /** Versioned layout preferences for a Code Mode dashboard. @module */
5
+ /** User-selected panel positions and supported widths, independent of ERP data and chat context. */
6
+ require("../../_dnt.polyfills.js");
7
+ // This is a versioned wire format. Only geometry crosses the snippet boundary.
8
+ const maxPanels = 128;
9
+ const maxIdLength = 256;
10
+ function fields(value, keys) {
11
+ return value !== null && typeof value === "object" && !Array.isArray(value) &&
12
+ Object.keys(value).length === keys.length &&
13
+ keys.every((key) => Object.hasOwn(value, key));
14
+ }
15
+ function validId(value) {
16
+ return typeof value === "string" && value.trim().length > 0 && value.length <= maxIdLength &&
17
+ !Array.from(value).some((ch) => ch.charCodeAt(0) < 32);
18
+ }
19
+ /** Validate an untrusted JSON snapshot, including placement anchors and their dependencies. */
20
+ function isPanelLayoutSnapshot(value) {
21
+ if (!fields(value, ["version", "order", "widths", "placements"]) || value.version !== 1) {
22
+ return false;
23
+ }
24
+ const { order, widths, placements } = value;
25
+ if (!Array.isArray(order) || !order.length || order.length > maxPanels ||
26
+ !Array.isArray(widths) || widths.length > order.length ||
27
+ !Array.isArray(placements) || placements.length >= order.length)
28
+ return false;
29
+ const ids = new Set(order);
30
+ if (ids.size !== order.length || !Array.from(ids).every(validId))
31
+ return false;
32
+ const resized = new Set();
33
+ for (const item of widths) {
34
+ if (!fields(item, ["panel", "width"]) || !ids.has(item.panel) || resized.has(item.panel) ||
35
+ typeof item.width !== "number" || !Number.isSafeInteger(item.width) || item.width <= 0)
36
+ return false;
37
+ resized.add(item.panel);
38
+ }
39
+ const anchors = new Map();
40
+ for (const item of placements) {
41
+ if (!fields(item, ["panel", "beside", "side"]) || !ids.has(item.panel) || !ids.has(item.beside) ||
42
+ anchors.has(item.panel) ||
43
+ (item.side !== "left" && item.side !== "right" && item.side !== "below"))
44
+ return false;
45
+ anchors.set(item.panel, item.beside);
46
+ }
47
+ for (let id of anchors.keys()) {
48
+ const seen = new Set();
49
+ while (anchors.has(id)) {
50
+ if (seen.has(id))
51
+ return false;
52
+ seen.add(id);
53
+ id = anchors.get(id);
54
+ }
55
+ }
56
+ return true;
57
+ }
@@ -5,4 +5,5 @@ export { connectSnippetProviders, type SnippetMcpClient, type SnippetProviderBin
5
5
  export type { SnippetChainContext, SnippetProvider } from "./providers.js";
6
6
  export { createSnippetExecuteTool, type SnippetExecuteToolOptions } from "./tool.js";
7
7
  export { type ProviderSnippetDefinition, registerSnippetProvider, type SnippetProviderOptions, } from "./provider-tools.js";
8
+ export { parseSnippetSyncRule, SNIPPET_SYNC_META_KEY, snippetSyncKey, supportsSnippetSync, } from "./sync.js";
8
9
  //# sourceMappingURL=mod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/code-mode/mod.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EACL,kBAAkB,EAClB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,GACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,uBAAuB,EACvB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,GAChC,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,KAAK,yBAAyB,EAAE,MAAM,WAAW,CAAC;AACrF,OAAO,EACL,KAAK,yBAAyB,EAC9B,uBAAuB,EACvB,KAAK,sBAAsB,GAC5B,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/code-mode/mod.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EACL,kBAAkB,EAClB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,GACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,uBAAuB,EACvB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,GAChC,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,KAAK,yBAAyB,EAAE,MAAM,WAAW,CAAC;AACrF,OAAO,EACL,KAAK,yBAAyB,EAC9B,uBAAuB,EACvB,KAAK,sBAAsB,GAC5B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,EACd,mBAAmB,GACpB,MAAM,WAAW,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.registerSnippetProvider = exports.createSnippetExecuteTool = exports.connectSnippetProviders = exports.createSnippetChain = void 0;
3
+ exports.supportsSnippetSync = exports.snippetSyncKey = exports.SNIPPET_SYNC_META_KEY = exports.parseSnippetSyncRule = exports.registerSnippetProvider = exports.createSnippetExecuteTool = exports.connectSnippetProviders = exports.createSnippetChain = void 0;
4
4
  /** Run selected snippets across host-configured MCP providers in one Code Mode call. */
5
5
  require("../../_dnt.polyfills.js");
6
6
  var chain_js_1 = require("./chain.js");
@@ -11,3 +11,8 @@ var tool_js_1 = require("./tool.js");
11
11
  Object.defineProperty(exports, "createSnippetExecuteTool", { enumerable: true, get: function () { return tool_js_1.createSnippetExecuteTool; } });
12
12
  var provider_tools_js_1 = require("./provider-tools.js");
13
13
  Object.defineProperty(exports, "registerSnippetProvider", { enumerable: true, get: function () { return provider_tools_js_1.registerSnippetProvider; } });
14
+ var sync_js_1 = require("./sync.js");
15
+ Object.defineProperty(exports, "parseSnippetSyncRule", { enumerable: true, get: function () { return sync_js_1.parseSnippetSyncRule; } });
16
+ Object.defineProperty(exports, "SNIPPET_SYNC_META_KEY", { enumerable: true, get: function () { return sync_js_1.SNIPPET_SYNC_META_KEY; } });
17
+ Object.defineProperty(exports, "snippetSyncKey", { enumerable: true, get: function () { return sync_js_1.snippetSyncKey; } });
18
+ Object.defineProperty(exports, "supportsSnippetSync", { enumerable: true, get: function () { return sync_js_1.supportsSnippetSync; } });
@@ -0,0 +1,25 @@
1
+ /** Aggregate panel selections and board receipts for a single MCP Apps host. @module */
2
+ /** Replacement snapshot accepted by the host in its negotiated content formats. */
3
+ export interface PanelContextUpdate<Block> {
4
+ /** Content blocks offered to hosts that accept text or resources. */
5
+ content?: Block[];
6
+ /** Structured context offered to hosts that accept JSON. */
7
+ structuredContent?: Record<string, unknown>;
8
+ }
9
+ /** Send one context replacement and return the host acknowledgement. */
10
+ export type SendPanelContext<Block, Options, Response> = (update: PanelContextUpdate<Block>, options?: Options) => Promise<Response>;
11
+ /** Writers share a serialized host update queue and retain only acknowledged contributions. */
12
+ export interface PanelContexts<Block, Options, Response> {
13
+ /** Bind a panel's selection to its identity and lifetime. */
14
+ forPanel(id: string, title: string, signal: AbortSignal): SendPanelContext<Block, Options, Response>;
15
+ /**
16
+ * Publish board metadata using its own lifetime and top-level structured keys.
17
+ * Compose reserves the `panels` key to group panel selections.
18
+ */
19
+ forBoard(signal: AbortSignal): SendPanelContext<Block, Options, Response>;
20
+ /** Send a replacement snapshot after one or more contributor lifetimes end. */
21
+ clear(): Promise<void>;
22
+ }
23
+ /** One host snapshot contains the acknowledged selections of every mounted panel. */
24
+ export declare function createPanelContexts<Block, Options, Response extends object>(send: SendPanelContext<Block, Options, Response>, clearErrorMessage?: () => string): PanelContexts<Block, Options, Response>;
25
+ //# sourceMappingURL=panel-contexts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panel-contexts.d.ts","sourceRoot":"","sources":["../../../src/src/code-mode/panel-contexts.ts"],"names":[],"mappings":"AAAA,wFAAwF;AAExF,mFAAmF;AACnF,MAAM,WAAW,kBAAkB,CAAC,KAAK;IACvC,qEAAqE;IACrE,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC;IAClB,4DAA4D;IAC5D,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7C;AAED,wEAAwE;AACxE,MAAM,MAAM,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,IAAI,CACvD,MAAM,EAAE,kBAAkB,CAAC,KAAK,CAAC,EACjC,OAAO,CAAC,EAAE,OAAO,KACd,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEvB,+FAA+F;AAC/F,MAAM,WAAW,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ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