@mcpview/compose 0.13.0 → 0.14.0

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 (155) hide show
  1. package/CHANGELOG.md +120 -0
  2. package/README.md +131 -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 +26 -1
  10. package/esm/src/code-mode/chain.d.ts.map +1 -1
  11. package/esm/src/code-mode/chain.js +248 -89
  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/errors.d.ts +80 -0
  16. package/esm/src/code-mode/errors.d.ts.map +1 -0
  17. package/esm/src/code-mode/errors.js +140 -0
  18. package/esm/src/code-mode/guest-worker.d.ts +11 -0
  19. package/esm/src/code-mode/guest-worker.d.ts.map +1 -0
  20. package/esm/src/code-mode/guest-worker.js +80 -0
  21. package/esm/src/code-mode/layout-publisher.d.ts +69 -0
  22. package/esm/src/code-mode/layout-publisher.d.ts.map +1 -0
  23. package/esm/src/code-mode/layout-publisher.js +85 -0
  24. package/esm/src/code-mode/layout-runs.d.ts +35 -0
  25. package/esm/src/code-mode/layout-runs.d.ts.map +1 -0
  26. package/esm/src/code-mode/layout-runs.js +130 -0
  27. package/esm/src/code-mode/layout.d.ts +20 -0
  28. package/esm/src/code-mode/layout.d.ts.map +1 -0
  29. package/esm/src/code-mode/layout.js +54 -0
  30. package/esm/src/code-mode/mod.d.ts +4 -1
  31. package/esm/src/code-mode/mod.d.ts.map +1 -1
  32. package/esm/src/code-mode/mod.js +3 -0
  33. package/esm/src/code-mode/panel-contexts.d.ts +25 -0
  34. package/esm/src/code-mode/panel-contexts.d.ts.map +1 -0
  35. package/esm/src/code-mode/panel-contexts.js +115 -0
  36. package/esm/src/code-mode/providers.d.ts +3 -0
  37. package/esm/src/code-mode/providers.d.ts.map +1 -1
  38. package/esm/src/code-mode/sandbox-core.d.ts +61 -0
  39. package/esm/src/code-mode/sandbox-core.d.ts.map +1 -0
  40. package/esm/src/code-mode/sandbox-core.js +424 -0
  41. package/esm/src/code-mode/sandbox.d.ts +68 -7
  42. package/esm/src/code-mode/sandbox.d.ts.map +1 -1
  43. package/esm/src/code-mode/sandbox.js +180 -119
  44. package/esm/src/code-mode/sync.d.ts +11 -0
  45. package/esm/src/code-mode/sync.d.ts.map +1 -0
  46. package/esm/src/code-mode/sync.js +42 -0
  47. package/esm/src/code-mode/tool.d.ts +1 -1
  48. package/esm/src/code-mode/tool.d.ts.map +1 -1
  49. package/esm/src/code-mode/tool.js +14 -0
  50. package/esm/src/code-mode/worker-host.d.ts +70 -0
  51. package/esm/src/code-mode/worker-host.d.ts.map +1 -0
  52. package/esm/src/code-mode/worker-host.js +355 -0
  53. package/esm/src/code-mode/worker-protocol.d.ts +44 -0
  54. package/esm/src/code-mode/worker-protocol.d.ts.map +1 -0
  55. package/esm/src/code-mode/worker-protocol.js +7 -0
  56. package/esm/src/host/renderer/css/panel-controls.d.ts.map +1 -1
  57. package/esm/src/host/renderer/css/panel-controls.js +5 -1
  58. package/esm/src/host/renderer/html-generator.js +2 -2
  59. package/esm/src/host/renderer/js/card-height.d.ts +11 -1
  60. package/esm/src/host/renderer/js/card-height.d.ts.map +1 -1
  61. package/esm/src/host/renderer/js/card-height.js +57 -10
  62. package/esm/src/host/renderer/js/event-bus.d.ts +11 -0
  63. package/esm/src/host/renderer/js/event-bus.d.ts.map +1 -1
  64. package/esm/src/host/renderer/js/event-bus.js +49 -8
  65. package/esm/src/host/renderer/js/intrinsic-layout.d.ts +26 -0
  66. package/esm/src/host/renderer/js/intrinsic-layout.d.ts.map +1 -0
  67. package/esm/src/host/renderer/js/intrinsic-layout.js +44 -0
  68. package/esm/src/host/renderer/panel-controls.d.ts +7 -0
  69. package/esm/src/host/renderer/panel-controls.js +1 -0
  70. package/esm/src/host/renderer/panel-movement.d.ts.map +1 -1
  71. package/esm/src/host/renderer/panel-movement.js +5 -1
  72. package/esm/src/host/renderer/panel-resizing.d.ts.map +1 -1
  73. package/esm/src/host/renderer/panel-resizing.js +36 -0
  74. package/esm/src/host/renderer/panel-snapshot.d.ts +11 -0
  75. package/esm/src/host/renderer/panel-snapshot.d.ts.map +1 -0
  76. package/esm/src/host/renderer/panel-snapshot.js +65 -0
  77. package/esm/src/version.d.ts +1 -1
  78. package/esm/src/version.js +1 -1
  79. package/package.json +9 -1
  80. package/script/_dnt.polyfills.d.ts +11 -11
  81. package/script/_dnt.polyfills.d.ts.map +1 -1
  82. package/script/_dnt.polyfills.js +14 -14
  83. package/script/src/code-mode/board.d.ts +18 -2
  84. package/script/src/code-mode/board.d.ts.map +1 -1
  85. package/script/src/code-mode/board.js +81 -2
  86. package/script/src/code-mode/chain.d.ts +26 -1
  87. package/script/src/code-mode/chain.d.ts.map +1 -1
  88. package/script/src/code-mode/chain.js +247 -88
  89. package/script/src/code-mode/connections.d.ts +1 -0
  90. package/script/src/code-mode/connections.d.ts.map +1 -1
  91. package/script/src/code-mode/connections.js +1 -0
  92. package/script/src/code-mode/errors.d.ts +80 -0
  93. package/script/src/code-mode/errors.d.ts.map +1 -0
  94. package/script/src/code-mode/errors.js +148 -0
  95. package/script/src/code-mode/guest-worker.d.ts +11 -0
  96. package/script/src/code-mode/guest-worker.d.ts.map +1 -0
  97. package/script/src/code-mode/guest-worker.js +105 -0
  98. package/script/src/code-mode/layout-publisher.d.ts +69 -0
  99. package/script/src/code-mode/layout-publisher.d.ts.map +1 -0
  100. package/script/src/code-mode/layout-publisher.js +88 -0
  101. package/script/src/code-mode/layout-runs.d.ts +35 -0
  102. package/script/src/code-mode/layout-runs.d.ts.map +1 -0
  103. package/script/src/code-mode/layout-runs.js +134 -0
  104. package/script/src/code-mode/layout.d.ts +20 -0
  105. package/script/src/code-mode/layout.d.ts.map +1 -0
  106. package/script/src/code-mode/layout.js +57 -0
  107. package/script/src/code-mode/mod.d.ts +4 -1
  108. package/script/src/code-mode/mod.d.ts.map +1 -1
  109. package/script/src/code-mode/mod.js +14 -1
  110. package/script/src/code-mode/panel-contexts.d.ts +25 -0
  111. package/script/src/code-mode/panel-contexts.d.ts.map +1 -0
  112. package/script/src/code-mode/panel-contexts.js +118 -0
  113. package/script/src/code-mode/providers.d.ts +3 -0
  114. package/script/src/code-mode/providers.d.ts.map +1 -1
  115. package/script/src/code-mode/sandbox-core.d.ts +61 -0
  116. package/script/src/code-mode/sandbox-core.d.ts.map +1 -0
  117. package/script/src/code-mode/sandbox-core.js +430 -0
  118. package/script/src/code-mode/sandbox.d.ts +68 -7
  119. package/script/src/code-mode/sandbox.d.ts.map +1 -1
  120. package/script/src/code-mode/sandbox.js +188 -121
  121. package/script/src/code-mode/sync.d.ts +11 -0
  122. package/script/src/code-mode/sync.d.ts.map +1 -0
  123. package/script/src/code-mode/sync.js +51 -0
  124. package/script/src/code-mode/tool.d.ts +1 -1
  125. package/script/src/code-mode/tool.d.ts.map +1 -1
  126. package/script/src/code-mode/tool.js +14 -0
  127. package/script/src/code-mode/worker-host.d.ts +70 -0
  128. package/script/src/code-mode/worker-host.d.ts.map +1 -0
  129. package/script/src/code-mode/worker-host.js +389 -0
  130. package/script/src/code-mode/worker-protocol.d.ts +44 -0
  131. package/script/src/code-mode/worker-protocol.d.ts.map +1 -0
  132. package/script/src/code-mode/worker-protocol.js +8 -0
  133. package/script/src/host/renderer/css/panel-controls.d.ts.map +1 -1
  134. package/script/src/host/renderer/css/panel-controls.js +5 -1
  135. package/script/src/host/renderer/html-generator.js +2 -2
  136. package/script/src/host/renderer/js/card-height.d.ts +11 -1
  137. package/script/src/host/renderer/js/card-height.d.ts.map +1 -1
  138. package/script/src/host/renderer/js/card-height.js +57 -10
  139. package/script/src/host/renderer/js/event-bus.d.ts +11 -0
  140. package/script/src/host/renderer/js/event-bus.d.ts.map +1 -1
  141. package/script/src/host/renderer/js/event-bus.js +50 -8
  142. package/script/src/host/renderer/js/intrinsic-layout.d.ts +26 -0
  143. package/script/src/host/renderer/js/intrinsic-layout.d.ts.map +1 -0
  144. package/script/src/host/renderer/js/intrinsic-layout.js +48 -0
  145. package/script/src/host/renderer/panel-controls.d.ts +7 -0
  146. package/script/src/host/renderer/panel-controls.js +4 -1
  147. package/script/src/host/renderer/panel-movement.d.ts.map +1 -1
  148. package/script/src/host/renderer/panel-movement.js +5 -1
  149. package/script/src/host/renderer/panel-resizing.d.ts.map +1 -1
  150. package/script/src/host/renderer/panel-resizing.js +36 -0
  151. package/script/src/host/renderer/panel-snapshot.d.ts +11 -0
  152. package/script/src/host/renderer/panel-snapshot.d.ts.map +1 -0
  153. package/script/src/host/renderer/panel-snapshot.js +69 -0
  154. package/script/src/version.d.ts +1 -1
  155. package/script/src/version.js +1 -1
@@ -1,31 +1,53 @@
1
+ import { parseSnippetSyncRule, SNIPPET_SYNC_META_KEY, snippetPorts, snippetSyncKey, supportsSnippetSync, } from "./sync.js";
1
2
  import { SNIPPET_PANELS_META_KEY } from "./board.js";
2
3
  import { isSnippetName } from "./providers.js";
3
- import { encodeValue, runProgram } from "./sandbox.js";
4
+ import { CodeModeError, POSSIBLE_EFFECTS_RECOVERY, withPossibleEffects } from "./errors.js";
5
+ import { assertSandboxIsolation, encodeValue, resolveSandboxLimits, runProgram, } from "./sandbox.js";
4
6
  const maxNativeSize = 4 * 1024 * 1024;
5
7
  const maxNativeBytes = 6 * 1024 * 1024;
6
8
  const maxSavedChains = 64;
7
- const afterDispatch = "One or more upstream operations may have completed. Check their effects before replaying the chain.";
9
+ const maxPanelTitle = 120;
8
10
  function isRecord(value) {
9
11
  return value !== null && typeof value === "object" && !Array.isArray(value);
10
12
  }
11
13
  const providerErrors = new Map([
12
- ["INVALID_INPUT", "Check the snippet input against its declared schema."],
13
- ["ARTIFACT_UNAVAILABLE", "The input artifact is unavailable. Regenerate it before retrying."],
14
- ["PROFILE_INVALID", "The configured provider profile is invalid or unavailable."],
15
- ["UPSTREAM_ERROR", "The upstream operation failed."],
16
- ["TIMEOUT", "The upstream operation timed out."],
14
+ ["INVALID_INPUT", [
15
+ "the provider rejected the input",
16
+ "Check the input against the snippet's inputSchema from api.listSnippets",
17
+ ]],
18
+ ["ARTIFACT_UNAVAILABLE", [
19
+ "the input artifact is unavailable",
20
+ "Regenerate the artifact before retrying",
21
+ ]],
22
+ ["PROFILE_INVALID", [
23
+ "the configured provider profile is invalid or unavailable",
24
+ "Ask the operator to fix the provider profile; retrying will fail again",
25
+ ]],
26
+ ["UPSTREAM_ERROR", ["the upstream operation failed", "Retry once, then report the failure"]],
27
+ ["TIMEOUT", ["the upstream operation timed out", "Retry once with a smaller input"]],
28
+ ["UNAVAILABLE", ["the provider is unavailable", "Retry later"]],
17
29
  ]);
18
- function providerError(result) {
30
+ function providerError(provider, snippet, result) {
19
31
  const data = result.structuredContent;
20
32
  const error = isRecord(data) ? data.error : undefined;
21
- const code = isRecord(error) ? error.code : undefined;
22
- return (typeof code === "string" ? providerErrors.get(code) : undefined) ??
23
- "The provider reported an execution error.";
33
+ const code = isRecord(error) && typeof error.code === "string" ? error.code : undefined;
34
+ const known = code ? providerErrors.get(code) : undefined;
35
+ const [detail, recovery] = known ??
36
+ ["the provider reported an execution error", "Retry once, then report the failure"];
37
+ return new CodeModeError("PROVIDER_ERROR", `Snippet ${snippet}: ${detail}`, recovery, {
38
+ context: { provider, snippet, providerCode: known ? code : "UNKNOWN" },
39
+ });
24
40
  }
25
41
  function validateParams(input, shape) {
26
- if (!isRecord(input))
27
- throw new Error("Supply params as a JSON object.");
28
- encodeValue(input, 8192);
42
+ if (!isRecord(input)) {
43
+ throw new CodeModeError("PARAMS_INVALID", "Supply params as a JSON object", "Pass an object");
44
+ }
45
+ try {
46
+ encodeValue(input, 8192);
47
+ }
48
+ catch {
49
+ throw new CodeModeError("PARAMS_INVALID", "params must be JSON of at most 8192 characters", "Pass fewer or smaller parameters", { context: { limit: 8192 } });
50
+ }
29
51
  if (shape) {
30
52
  const keys = Object.keys(input);
31
53
  if (keys.length !== Object.keys(shape).length ||
@@ -34,138 +56,254 @@ function validateParams(input, shape) {
34
56
  const kind = value === null ? "null" : Array.isArray(value) ? "array" : typeof value;
35
57
  return !Object.hasOwn(shape, key) || shape[key] !== kind;
36
58
  })) {
37
- throw new Error("Replay parameters must match the saved key names and JSON types.");
59
+ throw new CodeModeError("PARAMS_INVALID", "Replay parameters must match the saved key names and JSON types", "Pass the parameters listed by listSaved, with the same types");
38
60
  }
39
61
  }
40
62
  return input;
41
63
  }
42
- function output(value, panels = [], saved) {
64
+ /** Map a catalog failure to a coded error. Catalog messages are constant strings. */
65
+ function catalogError(error) {
66
+ if (error instanceof CodeModeError)
67
+ return error;
68
+ if (error instanceof TypeError || error instanceof RangeError || isCatalogError(error)) {
69
+ const catalogCode = isCatalogError(error) ? error.code : error.name;
70
+ return new CodeModeError("CATALOG_ERROR", error.message, "Call listSaved, then replay an existing name", { context: { catalogCode } });
71
+ }
72
+ return new CodeModeError("CATALOG_ERROR", "The saved chain catalog failed", "Retry once, then report the failure");
73
+ }
74
+ function isCatalogError(error) {
75
+ return error instanceof Error && error.name === "SnippetCatalogError" &&
76
+ typeof error.code === "string";
77
+ }
78
+ /**
79
+ * Await a catalog operation. A failure while the caller's signal is aborted is the
80
+ * caller's cancellation and keeps its reason; any other failure, a store's own
81
+ * `AbortError` included, is a catalog failure.
82
+ */
83
+ async function fromCatalog(work, signal) {
84
+ try {
85
+ return await work;
86
+ }
87
+ catch (error) {
88
+ if (signal?.aborted)
89
+ throw signal.reason;
90
+ throw catalogError(error);
91
+ }
92
+ }
93
+ /** The store may have written the chain even though the write was not confirmed. */
94
+ function saveFailed() {
95
+ return new CodeModeError("SAVE_FAILED", "Failed to confirm that the chain was saved", "Call listSaved before saving again");
96
+ }
97
+ const SAVED_RECOVERY = "The chain was saved. Call listSaved before saving it again";
98
+ /**
99
+ * The cancellation exception: a DOMException named after the caller's reason, so
100
+ * a host can tell a cancelled task from a failed one. Its message carries the
101
+ * advice that structured fields cannot (a DOMException has no `effects`).
102
+ */
103
+ function interrupted(reason, advice) {
104
+ const name = reason instanceof DOMException && reason.name === "TimeoutError"
105
+ ? "TimeoutError"
106
+ : "AbortError";
107
+ return new DOMException(`[execute] INTERRUPTED: The chain was interrupted. Recovery: ${advice.join(". ")}.`, name);
108
+ }
109
+ function output(value, panels = [], saved, sync = []) {
43
110
  const visible = {
44
111
  value,
45
- panels: panels.map(({ result: _result, ...panel }) => panel),
112
+ panels: panels.map(({ result: _result, events: _events, ...panel }) => panel),
46
113
  ...(saved === undefined ? {} : { saved }),
47
114
  };
48
115
  return {
49
116
  content: [{ type: "text", text: JSON.stringify(visible) }],
50
117
  structuredContent: visible,
51
- _meta: { [SNIPPET_PANELS_META_KEY]: panels },
118
+ _meta: {
119
+ [SNIPPET_PANELS_META_KEY]: panels,
120
+ ...(sync.length ? { [SNIPPET_SYNC_META_KEY]: sync } : {}),
121
+ },
52
122
  };
53
123
  }
54
124
  /**
55
125
  * Run JavaScript against host-configured snippet providers. Selected results stay
56
126
  * out of guest memory except for their declared JSON value. Supplying a catalog
57
127
  * enables named chains for calls with a trusted scope.
128
+ *
129
+ * Failures are {@link CodeModeError}s whose message reads
130
+ * `[execute] CODE: detail. Recovery: hint.`; a caller abort rejects with a
131
+ * DOMException. Once an upstream snippet call was dispatched, errors carry
132
+ * `effects: "possible"` and never repeat guest, provider or transport text.
133
+ *
134
+ * @example
135
+ * ```ts
136
+ * const execute = createSnippetChain(providers, catalog, { isolation: "worker" });
137
+ * const result = await execute({ code: "return 1;" }, { scope: "user-1" });
138
+ * ```
58
139
  */
59
- export function createSnippetChain(providers, catalog) {
140
+ export function createSnippetChain(providers, catalog, options = {}) {
141
+ const isolation = options.isolation ?? "worker";
142
+ assertSandboxIsolation(isolation);
143
+ const limits = resolveSandboxLimits(options.limits);
144
+ const aliases = [...providers.keys()];
60
145
  // Keep admission state only while saves overlap. Persistent catalogs are read again
61
146
  // on the next save so a completed tenant leaves no resident quota state here.
62
147
  const activeSaves = new Map();
63
148
  async function execute(code, params, context, status) {
64
149
  const receipts = new Map();
65
150
  const selected = new Map();
151
+ const exposedPorts = new Map();
152
+ const sync = new Map();
66
153
  let totalBytes = 0;
67
- const value = await runProgram(code, params, async (operation, args, signal) => {
154
+ const value = await runProgram(code, params, async (operation, args, signal, stopped) => {
68
155
  signal.throwIfAborted();
69
156
  const [first, second, input] = args;
70
157
  if (operation === "panel") {
71
158
  const panel = typeof first === "string" ? receipts.get(first) : undefined;
72
- if (!panel || args.length > 2)
73
- throw new Error("Select a receipt from this execution.");
74
- if (second !== undefined && (typeof second !== "string" || second.length > 120)) {
75
- throw new Error("Panel titles may contain at most 120 characters.");
159
+ if (!panel || args.length > 2) {
160
+ throw new CodeModeError("PANEL_INVALID", "Select a receipt returned by api.runSnippet in this execution", "Pass receipt.id from this run");
161
+ }
162
+ if (second !== undefined && (typeof second !== "string" || second.length > maxPanelTitle)) {
163
+ throw new CodeModeError("PANEL_INVALID", `Panel titles may contain at most ${maxPanelTitle} characters`, "Shorten the title", { context: { maxTitleLength: maxPanelTitle } });
76
164
  }
77
165
  selected.set(panel.id, { ...panel, title: second ?? panel.title });
166
+ exposedPorts.set(panel.id, panel.events);
167
+ return null;
168
+ }
169
+ if (operation === "sync") {
170
+ const rule = args.length === 1 ? parseSnippetSyncRule(first) : undefined;
171
+ if (!rule || !supportsSnippetSync(rule, exposedPorts)) {
172
+ throw new CodeModeError("SYNC_INVALID", "Sync requires distinct selected panel receipts and their declared event and action", "Select both panels first, then use the source's declared event and the target's declared action");
173
+ }
174
+ sync.set(snippetSyncKey(rule), rule);
78
175
  return null;
79
176
  }
80
177
  const provider = typeof first === "string" ? providers.get(first) : undefined;
81
- if (!provider)
82
- throw new Error("Unknown snippet provider.");
178
+ if (!provider) {
179
+ throw new CodeModeError("PROVIDER_UNKNOWN", "No snippet provider is configured under this alias", "Use one of the configured provider aliases", { context: { available: aliases } });
180
+ }
181
+ const alias = first;
182
+ const callProvider = async (tool, args) => {
183
+ // Any provider call may have effects, and its text may echo into guest
184
+ // errors: redact from here on, not only after runSnippet.
185
+ // Reading `provider.names` may have held the event loop past the wall
186
+ // deadline: check the clock right before the provider can act.
187
+ if (stopped())
188
+ throw signal.reason;
189
+ status.dispatched = true;
190
+ try {
191
+ return await provider.call(tool, args, signal, context);
192
+ }
193
+ catch {
194
+ signal.throwIfAborted();
195
+ // Provider and transport errors, typed or not, may carry credentials or
196
+ // paths: keep only the fact.
197
+ throw new CodeModeError("PROVIDER_UNAVAILABLE", `The ${alias} provider could not complete the request`,
198
+ // The request was sent: the provider may have acted before the failure.
199
+ "Check whether the operation took effect before retrying; the failure may be transient", { context: { provider: alias } });
200
+ }
201
+ };
83
202
  if (operation === "listSnippets" && args.length === 1) {
84
- const catalog = await provider.call("list_snippets", {}, signal, context);
203
+ const catalog = await callProvider("list_snippets", {});
85
204
  signal.throwIfAborted();
86
205
  const snippets = isRecord(catalog.structuredContent)
87
206
  ? catalog.structuredContent.snippets
88
207
  : undefined;
89
208
  if (catalog.isError || !Array.isArray(snippets)) {
90
- throw new Error("Provider snippet catalog is unavailable.");
209
+ throw new CodeModeError("PROVIDER_UNAVAILABLE", `The ${alias} provider could not list its snippets`, "Retry once; the failure may be transient", { context: { provider: alias } });
91
210
  }
92
211
  return snippets.filter((item) => isRecord(item) && typeof item.name === "string" && provider.names.includes(item.name)).map(({ name, description, inputSchema }) => ({ name, description, inputSchema }));
93
212
  }
94
- if (operation !== "runSnippet" || args.length !== 3 || typeof second !== "string" ||
95
- !provider.names.includes(second) || !isRecord(input)) {
96
- throw new Error("Choose an approved named snippet and supply its input object.");
213
+ if (operation !== "runSnippet" || args.length !== 3 || !isRecord(input)) {
214
+ throw new CodeModeError("ARGUMENT_INVALID", "Call api.runSnippet(provider, name, input) with an input object, or api.listSnippets(provider)", "Pass exactly the documented arguments");
97
215
  }
98
- status.dispatched = true;
99
- status.diagnostic = undefined;
100
- const result = await provider.call("run_snippet", { name: second, input }, signal, context);
101
- signal.throwIfAborted();
102
- if (result.isError) {
103
- status.diagnostic = `Snippet ${second}: ${providerError(result)}`;
104
- throw new Error(status.diagnostic);
216
+ if (typeof second !== "string" || !provider.names.includes(second)) {
217
+ throw new CodeModeError("SNIPPET_NOT_APPROVED", "The requested snippet is not approved for this provider", "Call api.listSnippets(provider) and use one of its names", { context: { provider: alias, allowed: [...provider.names] } });
105
218
  }
219
+ const result = await callProvider("run_snippet", { name: second, input });
220
+ signal.throwIfAborted();
221
+ if (result.isError)
222
+ throw providerError(alias, second, result);
106
223
  if (!isRecord(result.structuredContent) || !Object.hasOwn(result.structuredContent, "value")) {
107
- status.diagnostic = `Snippet ${second} returned an invalid result.`;
108
- throw new Error(status.diagnostic);
224
+ throw new CodeModeError("PROVIDER_RESULT_INVALID", `Snippet ${second} returned an invalid result`, "Report the provider bug; retrying will fail again", { context: { provider: alias, snippet: second } });
109
225
  }
110
226
  const value = result.structuredContent.value;
111
- encodeValue(value);
112
- totalBytes += new TextEncoder().encode(encodeValue(result, maxNativeSize)).byteLength;
113
- if (totalBytes > maxNativeBytes) {
114
- throw new Error("Native snippet receipts exceed the board size limit.");
227
+ const tooLarge = (limit) => new CodeModeError("RECEIPT_TOO_LARGE", `Snippet ${second} returned more than the board accepts`, "Select smaller results or fewer panels", { context: { provider: alias, snippet: second, limit } });
228
+ try {
229
+ encodeValue(value, limits.valueLength);
230
+ }
231
+ catch {
232
+ throw tooLarge(limits.valueLength);
115
233
  }
234
+ let receiptSize;
235
+ try {
236
+ receiptSize = new TextEncoder().encode(encodeValue(result, maxNativeSize)).byteLength;
237
+ }
238
+ catch {
239
+ throw tooLarge(maxNativeSize);
240
+ }
241
+ totalBytes += receiptSize;
242
+ if (totalBytes > maxNativeBytes)
243
+ throw tooLarge(maxNativeBytes);
116
244
  const id = crypto.randomUUID();
117
- receipts.set(id, { id, provider: first, name: second, title: second, result });
245
+ const events = snippetPorts(provider.events, second);
246
+ receipts.set(id, {
247
+ id,
248
+ provider: alias,
249
+ name: second,
250
+ title: second,
251
+ result,
252
+ ...(events ? { events } : {}),
253
+ });
118
254
  return { id, value };
119
- }, context.signal);
120
- return { value, panels: [...selected.values()] };
255
+ }, context.signal, { isolation, limits });
256
+ return { value, panels: [...selected.values()], sync: [...sync.values()] };
121
257
  }
122
258
  async function call(input, context, status) {
123
259
  const { signal, scope } = context;
124
260
  signal?.throwIfAborted();
125
- if (!isRecord(input))
126
- throw new Error("Supply execute inputs as a JSON object.");
261
+ if (!isRecord(input)) {
262
+ throw new CodeModeError("INVALID_INPUT", "Supply execute inputs as a JSON object", "Pass an object with code, replay or listSaved");
263
+ }
127
264
  const has = (key) => Object.hasOwn(input, key);
128
265
  const keysAllowed = (...keys) => Object.keys(input).every((key) => keys.includes(key));
129
266
  if (has("code") && !has("saveAs") && keysAllowed("code", "params")) {
130
- if (typeof input.code !== "string")
131
- throw new Error("Supply a JavaScript function body.");
267
+ if (typeof input.code !== "string") {
268
+ throw new CodeModeError("INVALID_INPUT", "Supply code as a JavaScript function body", "Pass code as a string");
269
+ }
132
270
  const result = await execute(input.code, validateParams(input.params === undefined ? {} : input.params), context, status);
133
271
  signal?.throwIfAborted();
134
- return output(result.value, result.panels);
272
+ return output(result.value, result.panels, undefined, result.sync);
135
273
  }
136
274
  if (!catalog || typeof scope !== "string" || !scope.trim()) {
137
- throw new Error("Saved chains require a configured catalog and a trusted scope.");
275
+ throw new CodeModeError("SAVED_CHAINS_UNAVAILABLE", "Saved chains require a configured catalog and a trusted scope", "Run the code directly, without saveAs, replay or listSaved");
138
276
  }
139
277
  if (input.listSaved === true && keysAllowed("listSaved")) {
140
- const snippets = await catalog.list(scope);
278
+ const snippets = await fromCatalog(catalog.list(scope), signal);
141
279
  signal?.throwIfAborted();
142
280
  return output({ snippets });
143
281
  }
144
282
  if (isSnippetName(input.replay) && keysAllowed("replay", "params")) {
145
- const result = await catalog.run(scope, input.replay, input.params === undefined ? {} : input.params, {
283
+ const result = await fromCatalog(catalog.run(scope, input.replay, input.params === undefined ? {} : input.params, {
146
284
  validate: validateParams,
147
285
  execute: (code, params) => execute(code, params, context, status),
148
- });
286
+ }), signal);
149
287
  signal?.throwIfAborted();
150
- return output(result.value, result.panels);
288
+ return output(result.value, result.panels, undefined, result.sync);
151
289
  }
152
290
  if (typeof input.code !== "string" || !has("saveAs") || !keysAllowed("code", "saveAs", "params")) {
153
- throw new Error("Supply code, replay, or listSaved.");
291
+ throw new CodeModeError("INVALID_INPUT", "Supply code, replay, or listSaved", "Pass exactly one of code (optionally with saveAs and params), replay (with params) or listSaved");
154
292
  }
155
293
  const name = input.saveAs;
156
294
  if (!isSnippetName(name)) {
157
- throw new Error("Supply a nonempty saved chain name of up to 256 UTF-8 bytes without surrounding whitespace.");
295
+ throw new CodeModeError("SAVE_NAME_INVALID", "Supply a nonempty saved chain name of up to 256 UTF-8 bytes without surrounding whitespace", "Use a shorter, trimmed name", { context: { maxBytes: 256 } });
158
296
  }
159
297
  const params = validateParams(input.params === undefined ? {} : input.params);
160
298
  const keys = Object.keys(params);
161
299
  if (keys.length > 32 || keys.some((key) => new TextEncoder().encode(key).byteLength > 128)) {
162
- throw new Error("Saved chain parameter contract exceeds its size limit.");
300
+ throw new CodeModeError("PARAMS_INVALID", "Saved chain parameter contract exceeds its size limit", "Use at most 32 parameters with names of up to 128 bytes", { context: { maxKeys: 32, maxKeyBytes: 128 } });
163
301
  }
164
302
  let usage = activeSaves.get(scope);
165
303
  if (!usage) {
166
304
  usage = {
167
305
  users: 0,
168
- stored: catalog.list(scope).then((entries) => new Set(entries.map((entry) => entry.name))),
306
+ stored: fromCatalog(catalog.list(scope)).then((entries) => new Set(entries.map((entry) => entry.name))),
169
307
  saving: new Set(),
170
308
  };
171
309
  activeSaves.set(scope, usage);
@@ -173,13 +311,15 @@ export function createSnippetChain(providers, catalog) {
173
311
  usage.users++;
174
312
  let reserved = false;
175
313
  try {
176
- const savedNames = await usage.stored;
314
+ const savedNames = await fromCatalog(usage.stored, signal);
177
315
  signal?.throwIfAborted();
178
- if (usage.saving.has(name))
179
- throw new Error("A save for this chain is already in progress.");
316
+ if (usage.saving.has(name)) {
317
+ throw new CodeModeError("SAVE_NAME_CONFLICT", "A save for this chain is already in progress", "Wait for it to finish, then call listSaved");
318
+ }
180
319
  if (!savedNames.has(name)) {
181
- if (savedNames.size >= maxSavedChains)
182
- throw new Error("The saved chain catalog is full.");
320
+ if (savedNames.size >= maxSavedChains) {
321
+ throw new CodeModeError("SAVE_CATALOG_FULL", "The saved chain catalog is full", "Reuse an existing name, or run the code without saveAs", { context: { max: maxSavedChains } });
322
+ }
183
323
  savedNames.add(name);
184
324
  reserved = true;
185
325
  }
@@ -187,19 +327,25 @@ export function createSnippetChain(providers, catalog) {
187
327
  usage.saving.add(name);
188
328
  try {
189
329
  if (!reserved) {
190
- const previous = await catalog.inspect(scope, name);
191
- if (previous.code !== input.code)
192
- throw new Error("Snippet name already in use.");
330
+ const previous = await fromCatalog(catalog.inspect(scope, name), signal);
331
+ if (previous.code !== input.code) {
332
+ throw new CodeModeError("SAVE_NAME_CONFLICT", "Snippet name already in use", "Pick another name, or replay the saved chain");
333
+ }
193
334
  validateParams(params, previous.parameters);
194
335
  }
195
336
  signal?.throwIfAborted();
196
337
  const result = await execute(input.code, params, context, status);
197
338
  signal?.throwIfAborted();
198
- status.saving = true;
199
339
  const ref = catalog.recordSuccess(scope, input.code, params);
340
+ status.saving = true;
200
341
  const saved = await catalog.save(scope, ref, name);
342
+ status.saved = true;
343
+ // The name stays counted: the chain exists even if the caller gave up meanwhile.
201
344
  reserved = false;
202
- return output(result.value, result.panels, saved.name);
345
+ // A confirmed write after the caller aborted is not a success the caller waited for.
346
+ if (signal?.aborted)
347
+ throw signal.reason;
348
+ return output(result.value, result.panels, saved.name, result.sync);
203
349
  }
204
350
  finally {
205
351
  usage.saving.delete(name);
@@ -213,28 +359,41 @@ export function createSnippetChain(providers, catalog) {
213
359
  }
214
360
  }
215
361
  return async (input, context = {}) => {
216
- const status = { dispatched: false, saving: false };
362
+ const status = { dispatched: false, saving: false, saved: false };
217
363
  try {
218
364
  return await call(input, context, status);
219
365
  }
220
366
  catch (error) {
221
- if (!status.dispatched)
222
- throw error;
223
- if (context.signal?.aborted) {
224
- const reason = context.signal.reason;
225
- const name = reason instanceof DOMException && reason.name === "TimeoutError"
226
- ? "TimeoutError"
227
- : "AbortError";
228
- throw new DOMException(`Chain interrupted. ${afterDispatch}`, name);
229
- }
230
- // Preserve only diagnostics derived from known provider codes. A transport,
231
- // guest or storage exception may contain credentials, paths or native data.
232
- const message = status.saving
233
- ? "Failed to confirm that the chain was saved."
234
- : status.diagnostic && error instanceof Error && error.message === status.diagnostic
235
- ? status.diagnostic
236
- : "Chain execution failed.";
237
- throw new Error(`${message} ${afterDispatch}`);
367
+ const signal = context.signal;
368
+ if (status.saving) {
369
+ // A catalog write was attempted: classify it before the exception type, since a
370
+ // store may fail with a DOMException (a lost acknowledgement). Say to look before
371
+ // retrying. Only a write the store confirmed is reported as saved.
372
+ if (status.saved && signal?.aborted) {
373
+ throw interrupted(signal.reason, [
374
+ SAVED_RECOVERY,
375
+ ...(status.dispatched ? [POSSIBLE_EFFECTS_RECOVERY] : []),
376
+ ]);
377
+ }
378
+ throw status.dispatched ? withPossibleEffects(saveFailed()) : saveFailed();
379
+ }
380
+ if (!status.dispatched) {
381
+ if (error instanceof CodeModeError || error instanceof DOMException)
382
+ throw error;
383
+ // The caller's own reason, whatever its type.
384
+ if (signal?.aborted)
385
+ throw signal.reason;
386
+ throw new CodeModeError("EXECUTION_FAILED", "The chain failed before calling any provider", "Retry once, then report the failure");
387
+ }
388
+ if (signal?.aborted)
389
+ throw interrupted(signal.reason, [POSSIBLE_EFFECTS_RECOVERY]);
390
+ if (error instanceof CodeModeError) {
391
+ // After a dispatch, guest text might echo upstream values: keep only the kind.
392
+ throw withPossibleEffects(error.code === "GUEST_ERROR"
393
+ ? new CodeModeError("GUEST_ERROR", `The program threw ${error.context.name ?? "an exception"}`, error.recovery, { context: error.context })
394
+ : error);
395
+ }
396
+ throw withPossibleEffects(new CodeModeError("EXECUTION_FAILED", "The chain failed after calling a provider", "Report the failure"));
238
397
  }
239
398
  };
240
399
  }
@@ -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,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,CAiHrC"}
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;IACrC,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC;CAC7C,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,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"}
@@ -81,6 +81,7 @@ export async function connectSnippetProviders(bindings, options = {}) {
81
81
  const clientSource = source;
82
82
  const provider = {
83
83
  names,
84
+ events: binding.events,
84
85
  async call(tool, args, signal, context) {
85
86
  signal.throwIfAborted();
86
87
  if (closing)
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Machine-readable failures of the Code Mode `execute` tool.
3
+ *
4
+ * An MCP host usually forwards only `error.message` to the model, so the message
5
+ * itself is the contract, in the format shared with other MCPView Code Mode
6
+ * servers:
7
+ *
8
+ * [execute] <CODE>: <detail>. Recovery: <recovery>.
9
+ *
10
+ * Guest programs see the same errors as `Error` objects that also carry
11
+ * `code`, `recovery` and `context`, so a program can branch on `e.code`.
12
+ *
13
+ * @module code-mode/errors
14
+ */
15
+ /** Every code the Code Mode tool can report. Codes are API: never rename one. */
16
+ export declare const CODE_MODE_ERROR_CODES: readonly ["INVALID_INPUT", "PARAMS_INVALID", "SAVED_CHAINS_UNAVAILABLE", "SAVE_NAME_INVALID", "SAVE_NAME_CONFLICT", "SAVE_CATALOG_FULL", "SAVE_FAILED", "CATALOG_ERROR", "GUEST_ERROR", "RESOURCE_LIMIT", "TIME_LIMIT", "RESULT_INVALID", "GUEST_STALLED", "UNAWAITED_OPERATION", "OPERATION_LIMIT", "ARGUMENT_INVALID", "OPERATION_FAILED", "SANDBOX_UNAVAILABLE", "SANDBOX_FAILED", "PROVIDER_UNKNOWN", "SNIPPET_NOT_APPROVED", "PROVIDER_UNAVAILABLE", "PROVIDER_ERROR", "PROVIDER_RESULT_INVALID", "RECEIPT_TOO_LARGE", "PANEL_INVALID", "SYNC_INVALID", "EXECUTION_FAILED", "INTERRUPTED"];
17
+ /** A Code Mode error code. */
18
+ export type CodeModeErrorCode = typeof CODE_MODE_ERROR_CODES[number];
19
+ /** Small, host-authored facts about a failure. Never guest or provider text. */
20
+ export type CodeModeErrorContext = Readonly<Record<string, string | number | boolean | readonly string[]>>;
21
+ /**
22
+ * `possible` when an upstream snippet call was already dispatched, so it may
23
+ * have changed something before the failure.
24
+ */
25
+ export type CodeModeErrorEffects = "none" | "possible";
26
+ /** The serializable fields of a {@link CodeModeError}. */
27
+ export interface CodeModeErrorFields {
28
+ readonly code: CodeModeErrorCode;
29
+ readonly detail: string;
30
+ readonly recovery: string;
31
+ readonly context: CodeModeErrorContext;
32
+ readonly effects: CodeModeErrorEffects;
33
+ }
34
+ /** Recovery suffix used once an upstream operation may have completed. */
35
+ export declare const POSSIBLE_EFFECTS_RECOVERY = "One or more upstream operations may have completed. Check their effects before replaying the chain";
36
+ /**
37
+ * Render `[execute] CODE: detail. Recovery: recovery.`
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * formatCodeModeError("TIME_LIMIT", "The program used its 2000 ms of CPU", "Split the work");
42
+ * // "[execute] TIME_LIMIT: The program used its 2000 ms of CPU. Recovery: Split the work."
43
+ * ```
44
+ */
45
+ export declare function formatCodeModeError(code: CodeModeErrorCode, detail: string, recovery: string): string;
46
+ /**
47
+ * A Code Mode failure with a stable code, a recovery hint and context.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * throw new CodeModeError("PROVIDER_UNKNOWN", "No provider is configured as cad", "Use one of the listed aliases", {
52
+ * context: { available: ["slicer"] },
53
+ * });
54
+ * ```
55
+ */
56
+ export declare class CodeModeError extends Error {
57
+ readonly name = "CodeModeError";
58
+ readonly code: CodeModeErrorCode;
59
+ /** What went wrong, without the code prefix or the recovery hint. */
60
+ readonly detail: string;
61
+ readonly recovery: string;
62
+ readonly context: CodeModeErrorContext;
63
+ readonly effects: CodeModeErrorEffects;
64
+ constructor(code: CodeModeErrorCode, detail: string, recovery: string, options?: {
65
+ context?: Record<string, unknown>;
66
+ effects?: CodeModeErrorEffects;
67
+ });
68
+ /** Plain fields, safe to post across a worker boundary. */
69
+ toJSON(): CodeModeErrorFields;
70
+ }
71
+ /** True for a {@link CodeModeError}. */
72
+ export declare function isCodeModeError(error: unknown): error is CodeModeError;
73
+ /**
74
+ * Rebuild an error from {@link CodeModeErrorFields}, for example after it
75
+ * crossed a worker boundary. Returns undefined for any other shape.
76
+ */
77
+ export declare function codeModeErrorFromFields(value: unknown): CodeModeError | undefined;
78
+ /** The same failure, reported once an upstream operation may have completed. */
79
+ export declare function withPossibleEffects(error: CodeModeError): CodeModeError;
80
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/src/code-mode/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,iFAAiF;AACjF,eAAO,MAAM,qBAAqB,ikBAkCxB,CAAC;AAEX,8BAA8B;AAC9B,MAAM,MAAM,iBAAiB,GAAG,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAErE,gFAAgF;AAChF,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CACzC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,MAAM,EAAE,CAAC,CAC9D,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,UAAU,CAAC;AAEvD,0DAA0D;AAC1D,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAC;CACxC;AAED,0EAA0E;AAC1E,eAAO,MAAM,yBAAyB,uGACgE,CAAC;AAOvG;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,iBAAiB,EACvB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,MAAM,CAIR;AAED;;;;;;;;;GASG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,SAAkB,IAAI,mBAAmB;IACzC,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,qEAAqE;IACrE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAC;gBAGrC,IAAI,EAAE,iBAAiB,EACvB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,OAAO,CAAC,EAAE,oBAAoB,CAAA;KAAO;IAUrF,2DAA2D;IAC3D,MAAM,IAAI,mBAAmB;CAS9B;AAUD,wCAAwC;AACxC,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAEtE;AAID;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,CAejF;AAED,gFAAgF;AAChF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CAQvE"}