@mcpview/compose 0.12.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.
- package/CHANGELOG.md +22 -0
- package/README.md +104 -1
- package/esm/_dnt.polyfills.d.ts +49 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -1
- package/esm/_dnt.polyfills.js +36 -0
- package/esm/src/code-mode/board.d.ts +21 -1
- package/esm/src/code-mode/board.d.ts.map +1 -1
- package/esm/src/code-mode/board.js +76 -2
- package/esm/src/code-mode/chain.d.ts +2 -0
- package/esm/src/code-mode/chain.d.ts.map +1 -1
- package/esm/src/code-mode/chain.js +34 -8
- package/esm/src/code-mode/connections.d.ts +1 -0
- package/esm/src/code-mode/connections.d.ts.map +1 -1
- package/esm/src/code-mode/connections.js +1 -0
- package/esm/src/code-mode/layout-publisher.d.ts +69 -0
- package/esm/src/code-mode/layout-publisher.d.ts.map +1 -0
- package/esm/src/code-mode/layout-publisher.js +85 -0
- package/esm/src/code-mode/layout-runs.d.ts +35 -0
- package/esm/src/code-mode/layout-runs.d.ts.map +1 -0
- package/esm/src/code-mode/layout-runs.js +130 -0
- package/esm/src/code-mode/layout.d.ts +20 -0
- package/esm/src/code-mode/layout.d.ts.map +1 -0
- package/esm/src/code-mode/layout.js +54 -0
- package/esm/src/code-mode/mod.d.ts +1 -0
- package/esm/src/code-mode/mod.d.ts.map +1 -1
- package/esm/src/code-mode/mod.js +1 -0
- package/esm/src/code-mode/panel-contexts.d.ts +25 -0
- package/esm/src/code-mode/panel-contexts.d.ts.map +1 -0
- package/esm/src/code-mode/panel-contexts.js +115 -0
- package/esm/src/code-mode/providers.d.ts +3 -0
- package/esm/src/code-mode/providers.d.ts.map +1 -1
- package/esm/src/code-mode/sandbox.d.ts.map +1 -1
- package/esm/src/code-mode/sandbox.js +2 -1
- package/esm/src/code-mode/sync.d.ts +11 -0
- package/esm/src/code-mode/sync.d.ts.map +1 -0
- package/esm/src/code-mode/sync.js +42 -0
- package/esm/src/code-mode/tool.d.ts +1 -1
- package/esm/src/code-mode/tool.d.ts.map +1 -1
- package/esm/src/code-mode/tool.js +12 -0
- package/esm/src/core/collector/collector.d.ts +2 -1
- package/esm/src/core/collector/collector.d.ts.map +1 -1
- package/esm/src/core/collector/collector.js +6 -0
- package/esm/src/core/types/resources.d.ts +4 -0
- package/esm/src/core/types/resources.d.ts.map +1 -1
- package/esm/src/core/types/resources.js +10 -1
- package/esm/src/host/renderer/css/base.d.ts.map +1 -1
- package/esm/src/host/renderer/css/base.js +3 -0
- package/esm/src/host/renderer/css/layouts.d.ts.map +1 -1
- package/esm/src/host/renderer/css/layouts.js +17 -14
- package/esm/src/host/renderer/css/panel-controls.d.ts +3 -0
- package/esm/src/host/renderer/css/panel-controls.d.ts.map +1 -0
- package/esm/src/host/renderer/css/panel-controls.js +89 -0
- package/esm/src/host/renderer/html-generator.d.ts.map +1 -1
- package/esm/src/host/renderer/html-generator.js +38 -42
- package/esm/src/host/renderer/js/card-height.d.ts +3 -0
- package/esm/src/host/renderer/js/card-height.d.ts.map +1 -0
- package/esm/src/host/renderer/js/card-height.js +58 -0
- package/esm/src/host/renderer/js/event-bus.d.ts.map +1 -1
- package/esm/src/host/renderer/js/event-bus.js +32 -12
- package/esm/src/host/renderer/panel-controls.d.ts +30 -0
- package/esm/src/host/renderer/panel-controls.d.ts.map +1 -0
- package/esm/src/host/renderer/panel-controls.js +6 -0
- package/esm/src/host/renderer/panel-movement.d.ts +8 -0
- package/esm/src/host/renderer/panel-movement.d.ts.map +1 -0
- package/esm/src/host/renderer/panel-movement.js +396 -0
- package/esm/src/host/renderer/panel-reflow.d.ts +17 -0
- package/esm/src/host/renderer/panel-reflow.d.ts.map +1 -0
- package/esm/src/host/renderer/panel-reflow.js +342 -0
- package/esm/src/host/renderer/panel-resizing.d.ts +11 -0
- package/esm/src/host/renderer/panel-resizing.d.ts.map +1 -0
- package/esm/src/host/renderer/panel-resizing.js +375 -0
- package/esm/src/host/renderer/panel-snapshot.d.ts +11 -0
- package/esm/src/host/renderer/panel-snapshot.d.ts.map +1 -0
- package/esm/src/host/renderer/panel-snapshot.js +65 -0
- package/esm/src/runtime/compose.d.ts.map +1 -1
- package/esm/src/runtime/compose.js +3 -0
- package/esm/src/runtime/manifest.d.ts.map +1 -1
- package/esm/src/runtime/manifest.js +4 -0
- package/esm/src/runtime/types.d.ts +2 -0
- package/esm/src/runtime/types.d.ts.map +1 -1
- package/esm/src/sdk/mcp-sdk.d.ts +2 -1
- package/esm/src/sdk/mcp-sdk.d.ts.map +1 -1
- package/esm/src/sdk/mcp-sdk.js +2 -2
- package/esm/src/version.d.ts +1 -1
- package/esm/src/version.js +1 -1
- package/package.json +9 -1
- package/script/_dnt.polyfills.d.ts +49 -0
- package/script/_dnt.polyfills.d.ts.map +1 -1
- package/script/_dnt.polyfills.js +36 -0
- package/script/src/code-mode/board.d.ts +21 -1
- package/script/src/code-mode/board.d.ts.map +1 -1
- package/script/src/code-mode/board.js +87 -3
- package/script/src/code-mode/chain.d.ts +2 -0
- package/script/src/code-mode/chain.d.ts.map +1 -1
- package/script/src/code-mode/chain.js +34 -8
- package/script/src/code-mode/connections.d.ts +1 -0
- package/script/src/code-mode/connections.d.ts.map +1 -1
- package/script/src/code-mode/connections.js +1 -0
- package/script/src/code-mode/layout-publisher.d.ts +69 -0
- package/script/src/code-mode/layout-publisher.d.ts.map +1 -0
- package/script/src/code-mode/layout-publisher.js +88 -0
- package/script/src/code-mode/layout-runs.d.ts +35 -0
- package/script/src/code-mode/layout-runs.d.ts.map +1 -0
- package/script/src/code-mode/layout-runs.js +134 -0
- package/script/src/code-mode/layout.d.ts +20 -0
- package/script/src/code-mode/layout.d.ts.map +1 -0
- package/script/src/code-mode/layout.js +57 -0
- package/script/src/code-mode/mod.d.ts +1 -0
- package/script/src/code-mode/mod.d.ts.map +1 -1
- package/script/src/code-mode/mod.js +6 -1
- package/script/src/code-mode/panel-contexts.d.ts +25 -0
- package/script/src/code-mode/panel-contexts.d.ts.map +1 -0
- package/script/src/code-mode/panel-contexts.js +118 -0
- package/script/src/code-mode/providers.d.ts +3 -0
- package/script/src/code-mode/providers.d.ts.map +1 -1
- package/script/src/code-mode/sandbox.d.ts.map +1 -1
- package/script/src/code-mode/sandbox.js +2 -1
- package/script/src/code-mode/sync.d.ts +11 -0
- package/script/src/code-mode/sync.d.ts.map +1 -0
- package/script/src/code-mode/sync.js +51 -0
- package/script/src/code-mode/tool.d.ts +1 -1
- package/script/src/code-mode/tool.d.ts.map +1 -1
- package/script/src/code-mode/tool.js +12 -0
- package/script/src/core/collector/collector.d.ts +2 -1
- package/script/src/core/collector/collector.d.ts.map +1 -1
- package/script/src/core/collector/collector.js +6 -0
- package/script/src/core/types/resources.d.ts +4 -0
- package/script/src/core/types/resources.d.ts.map +1 -1
- package/script/src/core/types/resources.js +11 -0
- package/script/src/host/renderer/css/base.d.ts.map +1 -1
- package/script/src/host/renderer/css/base.js +3 -0
- package/script/src/host/renderer/css/layouts.d.ts.map +1 -1
- package/script/src/host/renderer/css/layouts.js +17 -14
- package/script/src/host/renderer/css/panel-controls.d.ts +3 -0
- package/script/src/host/renderer/css/panel-controls.d.ts.map +1 -0
- package/script/src/host/renderer/css/panel-controls.js +92 -0
- package/script/src/host/renderer/html-generator.d.ts.map +1 -1
- package/script/src/host/renderer/html-generator.js +38 -42
- package/script/src/host/renderer/js/card-height.d.ts +3 -0
- package/script/src/host/renderer/js/card-height.d.ts.map +1 -0
- package/script/src/host/renderer/js/card-height.js +61 -0
- package/script/src/host/renderer/js/event-bus.d.ts.map +1 -1
- package/script/src/host/renderer/js/event-bus.js +32 -12
- package/script/src/host/renderer/panel-controls.d.ts +30 -0
- package/script/src/host/renderer/panel-controls.d.ts.map +1 -0
- package/script/src/host/renderer/panel-controls.js +14 -0
- package/script/src/host/renderer/panel-movement.d.ts +8 -0
- package/script/src/host/renderer/panel-movement.d.ts.map +1 -0
- package/script/src/host/renderer/panel-movement.js +399 -0
- package/script/src/host/renderer/panel-reflow.d.ts +17 -0
- package/script/src/host/renderer/panel-reflow.d.ts.map +1 -0
- package/script/src/host/renderer/panel-reflow.js +345 -0
- package/script/src/host/renderer/panel-resizing.d.ts +11 -0
- package/script/src/host/renderer/panel-resizing.d.ts.map +1 -0
- package/script/src/host/renderer/panel-resizing.js +378 -0
- package/script/src/host/renderer/panel-snapshot.d.ts +11 -0
- package/script/src/host/renderer/panel-snapshot.d.ts.map +1 -0
- package/script/src/host/renderer/panel-snapshot.js +69 -0
- package/script/src/runtime/compose.d.ts.map +1 -1
- package/script/src/runtime/compose.js +3 -0
- package/script/src/runtime/manifest.d.ts.map +1 -1
- package/script/src/runtime/manifest.js +4 -0
- package/script/src/runtime/types.d.ts +2 -0
- package/script/src/runtime/types.d.ts.map +1 -1
- package/script/src/sdk/mcp-sdk.d.ts +2 -1
- package/script/src/sdk/mcp-sdk.d.ts.map +1 -1
- package/script/src/sdk/mcp-sdk.js +2 -2
- package/script/src/version.d.ts +1 -1
- package/script/src/version.js +1 -1
|
@@ -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,WAAW,GAAG,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;AA0BjE,0FAA0F;AAC1F,qBAAa,eAAe,CAAC,OAAO,GAAG,IAAI;IACzC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAwC;IAC7D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAS;IAE9C,4EAA4E;gBAChE,OAAO,GAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAC;QAAC,oBAAoB,CAAC,EAAE,MAAM,CAAA;KAAO;IAUpF,mGAAmG;IACnG,IAAI,CACF,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,WAAW,EACnB,YAAY,CAAC,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,OAAO,GACpB,mBAAmB,GAAG,SAAS;IAuBlC,OAAO,CAAC,IAAI;IAKZ,sFAAsF;IACtF,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAQvD,0FAA0F;IAC1F,KAAK,CACH,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,OAAO,GAChB;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE;IAuBtC,gGAAgG;IAChG,QAAQ,CACN,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,QAAQ,CAAC,EAAE,OAAO,EAClB,UAAU,CAAC,EAAE,MAAM,GAClB,mBAAmB,GAAG,SAAS;IAgBlC;;;;OAIG;IACG,YAAY,CAChB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,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;IACrD,6DAA6D;IAC7D,QAAQ,CACN,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,WAAW,GAClB,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC9C;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC1E,+EAA+E;IAC/E,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAQD,qFAAqF;AACrF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,SAAS,MAAM,EACzE,IAAI,EAAE,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,EAChD,iBAAiB,GAAE,MAAM,MAAoC,GAC5D,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CA4HzC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** Aggregate panel selections and board receipts for a single MCP Apps host. @module */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.createPanelContexts = createPanelContexts;
|
|
5
|
+
/** One host snapshot contains the acknowledged selections of every mounted panel. */
|
|
6
|
+
function createPanelContexts(send, clearErrorMessage = () => "Context not updated") {
|
|
7
|
+
const board = Symbol("layout receipt");
|
|
8
|
+
let active = new Map();
|
|
9
|
+
// A lost acknowledgement leaves the host snapshot unknown. Retain only the
|
|
10
|
+
// formats to clear on the next replacement, never the attempted selection.
|
|
11
|
+
let uncertain;
|
|
12
|
+
function liveSelections() {
|
|
13
|
+
return new Map([...active].filter(([, selection]) => !selection.signal.aborted));
|
|
14
|
+
}
|
|
15
|
+
let queued = Promise.resolve();
|
|
16
|
+
function enqueue(work) {
|
|
17
|
+
const next = queued.then(work);
|
|
18
|
+
queued = next.catch(() => { });
|
|
19
|
+
return next;
|
|
20
|
+
}
|
|
21
|
+
function hasSelection(value) {
|
|
22
|
+
return Boolean(value.content?.length ||
|
|
23
|
+
Object.keys(value.structuredContent ?? {}).length);
|
|
24
|
+
}
|
|
25
|
+
function businessSelection(entries, last, boardMetadata) {
|
|
26
|
+
if (entries.length === 0)
|
|
27
|
+
return last;
|
|
28
|
+
if (entries.length === 1) {
|
|
29
|
+
const only = entries[0].value;
|
|
30
|
+
const overlap = boardMetadata &&
|
|
31
|
+
Object.keys(only.structuredContent ?? {}).some((key) => Object.hasOwn(boardMetadata, key));
|
|
32
|
+
if (!overlap)
|
|
33
|
+
return only;
|
|
34
|
+
}
|
|
35
|
+
const content = entries.flatMap(({ value }) => value.content ?? []);
|
|
36
|
+
const panels = entries.flatMap(({ title, value }) => value.structuredContent ? [{ title, context: value.structuredContent }] : []);
|
|
37
|
+
return {
|
|
38
|
+
...(entries.some(({ value }) => value.content !== undefined) ? { content } : {}),
|
|
39
|
+
...(panels.length ? { structuredContent: { panels } } : {}),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function merge(next, last) {
|
|
43
|
+
const receipt = next.get(board)?.value;
|
|
44
|
+
if (!receipt)
|
|
45
|
+
return businessSelection([...next.values()], last);
|
|
46
|
+
const business = businessSelection([...next].filter(([key]) => key !== board).map(([, entry]) => entry), {}, receipt.structuredContent);
|
|
47
|
+
return {
|
|
48
|
+
...(business.structuredContent || receipt.structuredContent ||
|
|
49
|
+
last.structuredContent
|
|
50
|
+
? {
|
|
51
|
+
structuredContent: {
|
|
52
|
+
...business.structuredContent,
|
|
53
|
+
...receipt.structuredContent,
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
: {}),
|
|
57
|
+
...(business.content || receipt.content || last.content
|
|
58
|
+
? { content: [...(business.content ?? []), ...(receipt.content ?? [])] }
|
|
59
|
+
: {}),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
async function replace(next, last, options) {
|
|
63
|
+
const update = { ...uncertain, ...merge(next, last) };
|
|
64
|
+
let response;
|
|
65
|
+
try {
|
|
66
|
+
response = await send(update, options);
|
|
67
|
+
}
|
|
68
|
+
catch (cause) {
|
|
69
|
+
uncertain = {
|
|
70
|
+
...(update.content !== undefined ? { content: [] } : {}),
|
|
71
|
+
...(update.structuredContent !== undefined ? { structuredContent: {} } : {}),
|
|
72
|
+
};
|
|
73
|
+
throw cause;
|
|
74
|
+
}
|
|
75
|
+
if (!("isError" in response && response.isError)) {
|
|
76
|
+
active = next;
|
|
77
|
+
uncertain = undefined;
|
|
78
|
+
}
|
|
79
|
+
return response;
|
|
80
|
+
}
|
|
81
|
+
function forSource(id, title, signal) {
|
|
82
|
+
return (value, options) => enqueue(async () => {
|
|
83
|
+
signal.throwIfAborted();
|
|
84
|
+
if (id === board && value.structuredContent &&
|
|
85
|
+
Object.hasOwn(value.structuredContent, "panels")) {
|
|
86
|
+
throw new TypeError('Board context reserves "panels" for panel selections');
|
|
87
|
+
}
|
|
88
|
+
const next = liveSelections();
|
|
89
|
+
if (hasSelection(value))
|
|
90
|
+
next.set(id, { title, value, signal });
|
|
91
|
+
else
|
|
92
|
+
next.delete(id);
|
|
93
|
+
return await replace(next, value, options);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
forPanel: (id, title, signal) => forSource(id, title, signal),
|
|
98
|
+
forBoard: (signal) => forSource(board, "", signal),
|
|
99
|
+
clear() {
|
|
100
|
+
return enqueue(async () => {
|
|
101
|
+
const next = liveSelections();
|
|
102
|
+
if (!uncertain && next.size === active.size)
|
|
103
|
+
return;
|
|
104
|
+
const entries = [...active.values()];
|
|
105
|
+
const empty = {
|
|
106
|
+
...(entries.some(({ value }) => value.structuredContent !== undefined)
|
|
107
|
+
? { structuredContent: {} }
|
|
108
|
+
: {}),
|
|
109
|
+
...(entries.some(({ value }) => value.content !== undefined) ? { content: [] } : {}),
|
|
110
|
+
};
|
|
111
|
+
const response = await replace(next, empty);
|
|
112
|
+
if ("isError" in response && response.isError) {
|
|
113
|
+
throw new Error(clearErrorMessage());
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CallToolResult } from "@modelcontextprotocol/client";
|
|
2
|
+
import type { ViewComponentEventPorts } from "../core/types/components.js";
|
|
2
3
|
/** Trusted, per-request server context, supplied by the host rather than guest code. */
|
|
3
4
|
export interface SnippetChainContext {
|
|
4
5
|
/** Catalog partition derived from the authenticated principal and integration. */
|
|
@@ -10,6 +11,8 @@ export interface SnippetChainContext {
|
|
|
10
11
|
export interface SnippetProvider {
|
|
11
12
|
/** The subset of this provider's snippets reachable by a program. */
|
|
12
13
|
readonly names: readonly string[];
|
|
14
|
+
/** Board event ports declared by the host for exact snippet names. */
|
|
15
|
+
readonly events?: Readonly<Record<string, ViewComponentEventPorts>>;
|
|
13
16
|
/** Forward only these protocol operations with host-owned transport credentials. */
|
|
14
17
|
call(tool: "list_snippets" | "run_snippet", args: Record<string, unknown>, signal: AbortSignal, context: SnippetChainContext): Promise<CallToolResult>;
|
|
15
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../../src/src/code-mode/providers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../../src/src/code-mode/providers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAE3E,wFAAwF;AACxF,MAAM,WAAW,mBAAmB;IAClC,kFAAkF;IAClF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,gDAAgD;IAChD,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED,iGAAiG;AACjG,MAAM,WAAW,eAAe;IAC9B,qEAAqE;IACrE,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,sEAAsE;IACtE,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC,CAAC;IACpE,oFAAoF;IACpF,IAAI,CACF,IAAI,EAAE,eAAe,GAAG,aAAa,EACrC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,cAAc,CAAC,CAAC;CAC5B;AAED,6DAA6D;AAC7D,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAEnE;AAED,oFAAoF;AACpF,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAG7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../../src/src/code-mode/sandbox.ts"],"names":[],"mappings":"AAEA,oEAAoE;AACpE,eAAO,MAAM,aAAa,QAAS,CAAC;AAIpC,8EAA8E;AAC9E,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,SAAiB,GAAG,MAAM,CAM1E;AAkBD;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,OAAO,CAAC,EACrF,YAAY,CAAC,EAAE,WAAW,GACzB,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../../src/src/code-mode/sandbox.ts"],"names":[],"mappings":"AAEA,oEAAoE;AACpE,eAAO,MAAM,aAAa,QAAS,CAAC;AAIpC,8EAA8E;AAC9E,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,SAAiB,GAAG,MAAM,CAM1E;AAkBD;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,OAAO,CAAC,EACrF,YAAY,CAAC,EAAE,WAAW,GACzB,OAAO,CAAC,OAAO,CAAC,CA6HlB"}
|
|
@@ -111,6 +111,7 @@ async function runProgram(code, params, invoke, callerSignal) {
|
|
|
111
111
|
listSnippets: (...args) => call("listSnippets", args),
|
|
112
112
|
runSnippet: (...args) => call("runSnippet", args),
|
|
113
113
|
panel: (...args) => call("panel", args),
|
|
114
|
+
sync: (...args) => call("sync", args),
|
|
114
115
|
});
|
|
115
116
|
return (async function(api) { "use strict";\n${code}\n})(api);
|
|
116
117
|
})()`, "mcpview-code-mode.js", { type: "global" })));
|
|
@@ -123,7 +124,7 @@ async function runProgram(code, params, invoke, callerSignal) {
|
|
|
123
124
|
if (state.type === "fulfilled") {
|
|
124
125
|
const value = scope.manage(state.value);
|
|
125
126
|
if (pending.length) {
|
|
126
|
-
throw new Error("Await every snippet operation, including api.panel().");
|
|
127
|
+
throw new Error("Await every snippet operation, including api.panel() and api.sync().");
|
|
127
128
|
}
|
|
128
129
|
return vm.typeof(value) === "undefined" ? null : read(value);
|
|
129
130
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ViewComponentEventPorts } from "../core/types/components.js";
|
|
2
|
+
import type { UiSyncRule } from "../core/types/sync-rules.js";
|
|
3
|
+
/** App-only metadata for explicit, receipt-scoped Compose rules. */
|
|
4
|
+
export declare const SNIPPET_SYNC_META_KEY = "io.mcpview/snippet-sync";
|
|
5
|
+
export declare function isPortName(value: unknown): value is string;
|
|
6
|
+
export declare function snippetPorts(events: Readonly<Record<string, ViewComponentEventPorts>> | undefined, name: string): ViewComponentEventPorts | undefined;
|
|
7
|
+
export declare function readSnippetEventPorts(value: unknown): ViewComponentEventPorts | undefined;
|
|
8
|
+
export declare function parseSnippetSyncRule(value: unknown): UiSyncRule | undefined;
|
|
9
|
+
export declare function supportsSnippetSync(rule: UiSyncRule, panels: ReadonlyMap<string, ViewComponentEventPorts | undefined>): boolean;
|
|
10
|
+
export declare function snippetSyncKey({ from, event, to, action }: UiSyncRule): string;
|
|
11
|
+
//# sourceMappingURL=sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../src/src/code-mode/sync.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D,oEAAoE;AACpE,eAAO,MAAM,qBAAqB,4BAA4B,CAAC;AAE/D,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAG1D;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC,GAAG,SAAS,EACrE,IAAI,EAAE,MAAM,GACX,uBAAuB,GAAG,SAAS,CAGrC;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,uBAAuB,GAAG,SAAS,CAQzF;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,CAW3E;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,uBAAuB,GAAG,SAAS,CAAC,GAC/D,OAAO,CAIT;AAED,wBAAgB,cAAc,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,UAAU,GAAG,MAAM,CAE9E"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SNIPPET_SYNC_META_KEY = void 0;
|
|
4
|
+
exports.isPortName = isPortName;
|
|
5
|
+
exports.snippetPorts = snippetPorts;
|
|
6
|
+
exports.readSnippetEventPorts = readSnippetEventPorts;
|
|
7
|
+
exports.parseSnippetSyncRule = parseSnippetSyncRule;
|
|
8
|
+
exports.supportsSnippetSync = supportsSnippetSync;
|
|
9
|
+
exports.snippetSyncKey = snippetSyncKey;
|
|
10
|
+
const validator_js_1 = require("../core/sync/validator.js");
|
|
11
|
+
/** App-only metadata for explicit, receipt-scoped Compose rules. */
|
|
12
|
+
exports.SNIPPET_SYNC_META_KEY = "io.mcpview/snippet-sync";
|
|
13
|
+
function isPortName(value) {
|
|
14
|
+
return typeof value === "string" && value.length > 0 && value.length <= 120 &&
|
|
15
|
+
value.trim() === value && value !== "*";
|
|
16
|
+
}
|
|
17
|
+
function snippetPorts(events, name) {
|
|
18
|
+
if (!events || !Object.hasOwn(events, name))
|
|
19
|
+
return;
|
|
20
|
+
return readSnippetEventPorts(events[name]);
|
|
21
|
+
}
|
|
22
|
+
function readSnippetEventPorts(value) {
|
|
23
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
24
|
+
return;
|
|
25
|
+
const ports = value;
|
|
26
|
+
const names = (values) => Array.isArray(values) ? [...new Set(values.filter(isPortName))] : [];
|
|
27
|
+
const emits = names(ports.emits);
|
|
28
|
+
const accepts = names(ports.accepts);
|
|
29
|
+
if (emits.length || accepts.length)
|
|
30
|
+
return { emits, accepts };
|
|
31
|
+
}
|
|
32
|
+
function parseSnippetSyncRule(value) {
|
|
33
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
34
|
+
return;
|
|
35
|
+
const fields = ["from", "event", "to", "action"];
|
|
36
|
+
if (Object.keys(value).length !== fields.length || !fields.every((key) => Object.hasOwn(value, key))) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const { from, event, to, action } = value;
|
|
40
|
+
if (!isPortName(from) || !isPortName(event) || !isPortName(to) || !isPortName(action))
|
|
41
|
+
return;
|
|
42
|
+
return { from, event, to, action };
|
|
43
|
+
}
|
|
44
|
+
function supportsSnippetSync(rule, panels) {
|
|
45
|
+
return (0, validator_js_1.validateSyncRules)([rule], [rule.from, rule.to].filter((id) => panels.has(id))).valid &&
|
|
46
|
+
panels.get(rule.from)?.emits?.includes(rule.event) === true &&
|
|
47
|
+
panels.get(rule.to)?.accepts?.includes(rule.action) === true;
|
|
48
|
+
}
|
|
49
|
+
function snippetSyncKey({ from, event, to, action }) {
|
|
50
|
+
return JSON.stringify([from, event, to, action]);
|
|
51
|
+
}
|
|
@@ -3,7 +3,7 @@ import type { SnippetProvider } from "./providers.js";
|
|
|
3
3
|
/** Configure the single model-facing tool and its MCP Apps board resource. */
|
|
4
4
|
export interface SnippetExecuteToolOptions {
|
|
5
5
|
readonly resourceUri: string;
|
|
6
|
-
readonly providers: ReadonlyMap<string, Pick<SnippetProvider, "names">>;
|
|
6
|
+
readonly providers: ReadonlyMap<string, Pick<SnippetProvider, "names" | "events">>;
|
|
7
7
|
/** Enable this when the chain uses a catalog and the host supplies a trusted scope. */
|
|
8
8
|
readonly savedChains?: boolean;
|
|
9
9
|
readonly annotations?: MCPTool["annotations"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../src/src/code-mode/tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../src/src/code-mode/tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAItD,8EAA8E;AAC9E,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC;IACnF,uFAAuF;IACvF,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAC/C;AAED,0EAA0E;AAC1E,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAkEpF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createSnippetExecuteTool = createSnippetExecuteTool;
|
|
4
|
+
const sync_js_1 = require("./sync.js");
|
|
4
5
|
const sandbox_js_1 = require("./sandbox.js");
|
|
5
6
|
/** Build the tool declaration for registration with an MCPView server. */
|
|
6
7
|
function createSnippetExecuteTool(options) {
|
|
@@ -9,6 +10,10 @@ function createSnippetExecuteTool(options) {
|
|
|
9
10
|
throw new Error("Supply a ui:// resource URI for the board.");
|
|
10
11
|
}
|
|
11
12
|
const available = [...options.providers.keys()];
|
|
13
|
+
const eventPorts = [...options.providers].flatMap(([provider, config]) => config.names.flatMap((snippet) => {
|
|
14
|
+
const ports = (0, sync_js_1.snippetPorts)(config.events, snippet);
|
|
15
|
+
return ports ? [{ provider, snippet, ...ports }] : [];
|
|
16
|
+
}));
|
|
12
17
|
return {
|
|
13
18
|
name: "execute",
|
|
14
19
|
description: [
|
|
@@ -17,6 +22,13 @@ function createSnippetExecuteTool(options) {
|
|
|
17
22
|
"Configured provider aliases: " + JSON.stringify(available) + ".",
|
|
18
23
|
"await api.runSnippet(provider, name, input) returns a receipt {id, value}.",
|
|
19
24
|
"Pass values between calls. Use await api.panel(receipt.id, optionalTitle) for each result to display, in display order. Return a JSON summary.",
|
|
25
|
+
...(eventPorts.length
|
|
26
|
+
? [
|
|
27
|
+
"After selecting both panels, use await api.sync({from: source.id, event, to: target.id, action}) to route a UI event between them.",
|
|
28
|
+
"Use the source's declared emits and the target's declared accepts. Available panel event ports: " +
|
|
29
|
+
JSON.stringify(eventPorts) + ".",
|
|
30
|
+
]
|
|
31
|
+
: []),
|
|
20
32
|
...(options.savedChains
|
|
21
33
|
? [
|
|
22
34
|
"Use saveAs to save a successful chain, listSaved to list your saved chains, or replay with the saved name and new params.",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module collector/collector
|
|
5
5
|
*/
|
|
6
|
-
import type
|
|
6
|
+
import { type CollectedUiResource } from "../types/resources.js";
|
|
7
7
|
import type { ComponentSurface } from "../types/components.js";
|
|
8
8
|
/**
|
|
9
9
|
* Collector interface for accumulating UI resources from MCP tool results.
|
|
@@ -21,6 +21,7 @@ export interface UiCollector {
|
|
|
21
21
|
collect(toolName: string, result: unknown, context?: Record<string, unknown>, options?: {
|
|
22
22
|
readonly componentId?: string;
|
|
23
23
|
readonly surface?: ComponentSurface;
|
|
24
|
+
readonly supportedWidths?: readonly number[];
|
|
24
25
|
}): CollectedUiResource | null;
|
|
25
26
|
/** Get all collected resources in slot order. */
|
|
26
27
|
getResources(): CollectedUiResource[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collector.d.ts","sourceRoot":"","sources":["../../../../src/src/core/collector/collector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"collector.d.ts","sourceRoot":"","sources":["../../../../src/src/core/collector/collector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,mBAAmB,EAAqB,MAAM,uBAAuB,CAAC;AACpF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D;;;;;;;;;;GAUG;AACH,MAAM,WAAW,WAAW;IAC1B,yFAAyF;IACzF,OAAO,CACL,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,OAAO,CAAC,EAAE;QACR,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;QACpC,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;KAC9C,GACA,mBAAmB,GAAG,IAAI,CAAC;IAE9B,iDAAiD;IACjD,YAAY,IAAI,mBAAmB,EAAE,CAAC;IAEtC,iCAAiC;IACjC,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,eAAe,IAAI,WAAW,CAoC7C"}
|