@comecaramelos/dsh-chrome-mcp 0.0.1 → 1.0.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.
- package/README.md +22 -78
- package/assets/dsh-chrome-mcp-social.png +0 -0
- package/assets/icon.svg +71 -0
- package/assets/prelaunch-windows-chrome.html +277 -0
- package/lib/client.js +1433 -568
- package/lib/client.js.map +7 -0
- package/lib/host/apply.d.ts +3 -0
- package/lib/host/apply.d.ts.map +1 -0
- package/lib/host/apply.js +31 -0
- package/lib/host/apply.js.map +1 -0
- package/lib/host/bridge.d.ts +65 -0
- package/lib/host/bridge.d.ts.map +1 -0
- package/lib/host/bridge.js +176 -0
- package/lib/host/bridge.js.map +1 -0
- package/lib/host/catalog.d.ts +31 -0
- package/lib/host/catalog.d.ts.map +1 -0
- package/lib/host/catalog.js +92 -0
- package/lib/host/catalog.js.map +1 -0
- package/lib/host/constants.d.ts +229 -0
- package/lib/host/constants.d.ts.map +1 -0
- package/lib/host/constants.js +242 -0
- package/lib/host/constants.js.map +1 -0
- package/lib/host/controller/bridge-run.d.ts +38 -0
- package/lib/host/controller/bridge-run.d.ts.map +1 -0
- package/lib/host/controller/bridge-run.js +69 -0
- package/lib/host/controller/bridge-run.js.map +1 -0
- package/lib/host/controller/captures.d.ts +22 -0
- package/lib/host/controller/captures.d.ts.map +1 -0
- package/lib/host/controller/captures.js +60 -0
- package/lib/host/controller/captures.js.map +1 -0
- package/lib/host/controller/commits.d.ts +4 -0
- package/lib/host/controller/commits.d.ts.map +1 -0
- package/lib/host/controller/commits.js +75 -0
- package/lib/host/controller/commits.js.map +1 -0
- package/lib/host/controller/controller.d.ts +40 -0
- package/lib/host/controller/controller.d.ts.map +1 -0
- package/lib/host/controller/controller.js +167 -0
- package/lib/host/controller/controller.js.map +1 -0
- package/lib/host/controller/index.d.ts +26 -0
- package/lib/host/controller/index.d.ts.map +1 -0
- package/lib/host/controller/index.js +25 -0
- package/lib/host/controller/index.js.map +1 -0
- package/lib/host/controller/notes.d.ts +26 -0
- package/lib/host/controller/notes.d.ts.map +1 -0
- package/lib/host/controller/notes.js +49 -0
- package/lib/host/controller/notes.js.map +1 -0
- package/lib/host/controller/persist.d.ts +9 -0
- package/lib/host/controller/persist.d.ts.map +1 -0
- package/lib/host/controller/persist.js +51 -0
- package/lib/host/controller/persist.js.map +1 -0
- package/lib/host/controller/runs.d.ts +56 -0
- package/lib/host/controller/runs.d.ts.map +1 -0
- package/lib/host/controller/runs.js +211 -0
- package/lib/host/controller/runs.js.map +1 -0
- package/lib/host/controller/state.d.ts +70 -0
- package/lib/host/controller/state.d.ts.map +1 -0
- package/lib/host/controller/state.js +2 -0
- package/lib/host/controller/state.js.map +1 -0
- package/lib/host/controller/windows-run.d.ts +9 -0
- package/lib/host/controller/windows-run.d.ts.map +1 -0
- package/lib/host/controller/windows-run.js +78 -0
- package/lib/host/controller/windows-run.js.map +1 -0
- package/lib/host/discovery/candidates.d.ts +37 -0
- package/lib/host/discovery/candidates.d.ts.map +1 -0
- package/lib/host/discovery/candidates.js +56 -0
- package/lib/host/discovery/candidates.js.map +1 -0
- package/lib/host/discovery/index.d.ts +18 -0
- package/lib/host/discovery/index.d.ts.map +1 -0
- package/lib/host/discovery/index.js +18 -0
- package/lib/host/discovery/index.js.map +1 -0
- package/lib/host/discovery/probe.d.ts +18 -0
- package/lib/host/discovery/probe.d.ts.map +1 -0
- package/lib/host/discovery/probe.js +97 -0
- package/lib/host/discovery/probe.js.map +1 -0
- package/lib/host/discovery/scan.d.ts +67 -0
- package/lib/host/discovery/scan.d.ts.map +1 -0
- package/lib/host/discovery/scan.js +169 -0
- package/lib/host/discovery/scan.js.map +1 -0
- package/lib/host/flags.d.ts +42 -0
- package/lib/host/flags.d.ts.map +1 -0
- package/lib/host/flags.js +118 -0
- package/lib/host/flags.js.map +1 -0
- package/lib/host/platform.d.ts +38 -0
- package/lib/host/platform.d.ts.map +1 -0
- package/lib/host/platform.js +64 -0
- package/lib/host/platform.js.map +1 -0
- package/lib/host/plugin-meta.d.ts +12 -0
- package/lib/host/plugin-meta.d.ts.map +1 -0
- package/lib/host/plugin-meta.js +12 -0
- package/lib/host/plugin-meta.js.map +1 -0
- package/lib/host/schema.d.ts +307 -0
- package/lib/host/schema.d.ts.map +1 -0
- package/lib/host/schema.js +171 -0
- package/lib/host/schema.js.map +1 -0
- package/lib/host/settings.d.ts +9 -0
- package/lib/host/settings.d.ts.map +1 -0
- package/lib/host/settings.js +70 -0
- package/lib/host/settings.js.map +1 -0
- package/lib/host/status.d.ts +28 -0
- package/lib/host/status.d.ts.map +1 -0
- package/lib/host/status.js +60 -0
- package/lib/host/status.js.map +1 -0
- package/lib/host/tool.d.ts +59 -0
- package/lib/host/tool.d.ts.map +1 -0
- package/lib/host/tool.js +51 -0
- package/lib/host/tool.js.map +1 -0
- package/lib/host/types/config.d.ts +47 -0
- package/lib/host/types/config.d.ts.map +1 -0
- package/lib/host/types/config.js +2 -0
- package/lib/host/types/config.js.map +1 -0
- package/lib/host/types/executable.d.ts +30 -0
- package/lib/host/types/executable.d.ts.map +1 -0
- package/lib/host/types/executable.js +9 -0
- package/lib/host/types/executable.js.map +1 -0
- package/lib/host/types/index.d.ts +23 -0
- package/lib/host/types/index.d.ts.map +1 -0
- package/lib/host/types/index.js +2 -0
- package/lib/host/types/index.js.map +1 -0
- package/lib/host/types/plugin.d.ts +38 -0
- package/lib/host/types/plugin.d.ts.map +1 -0
- package/lib/host/types/plugin.js +10 -0
- package/lib/host/types/plugin.js.map +1 -0
- package/lib/host/types/settings.d.ts +127 -0
- package/lib/host/types/settings.d.ts.map +1 -0
- package/lib/host/types/settings.js +2 -0
- package/lib/host/types/settings.js.map +1 -0
- package/lib/host/types/stderr.d.ts +53 -0
- package/lib/host/types/stderr.d.ts.map +1 -0
- package/lib/host/types/stderr.js +9 -0
- package/lib/host/types/stderr.js.map +1 -0
- package/lib/host/types/windows.d.ts +39 -0
- package/lib/host/types/windows.d.ts.map +1 -0
- package/lib/host/types/windows.js +9 -0
- package/lib/host/types/windows.js.map +1 -0
- package/lib/host/values.d.ts +89 -0
- package/lib/host/values.d.ts.map +1 -0
- package/lib/host/values.js +212 -0
- package/lib/host/values.js.map +1 -0
- package/lib/host/windows/connect-flags.d.ts +16 -0
- package/lib/host/windows/connect-flags.d.ts.map +1 -0
- package/lib/host/windows/connect-flags.js +67 -0
- package/lib/host/windows/connect-flags.js.map +1 -0
- package/lib/host/windows/index.d.ts +31 -0
- package/lib/host/windows/index.d.ts.map +1 -0
- package/lib/host/windows/index.js +30 -0
- package/lib/host/windows/index.js.map +1 -0
- package/lib/host/windows/landing.d.ts +47 -0
- package/lib/host/windows/landing.d.ts.map +1 -0
- package/lib/host/windows/landing.js +174 -0
- package/lib/host/windows/landing.js.map +1 -0
- package/lib/host/windows/link.d.ts +11 -0
- package/lib/host/windows/link.d.ts.map +1 -0
- package/lib/host/windows/link.js +52 -0
- package/lib/host/windows/link.js.map +1 -0
- package/lib/host/windows/paths.d.ts +43 -0
- package/lib/host/windows/paths.d.ts.map +1 -0
- package/lib/host/windows/paths.js +121 -0
- package/lib/host/windows/paths.js.map +1 -0
- package/lib/host/windows/run.d.ts +74 -0
- package/lib/host/windows/run.d.ts.map +1 -0
- package/lib/host/windows/run.js +210 -0
- package/lib/host/windows/run.js.map +1 -0
- package/lib/host/windows/spawn.d.ts +22 -0
- package/lib/host/windows/spawn.d.ts.map +1 -0
- package/lib/host/windows/spawn.js +73 -0
- package/lib/host/windows/spawn.js.map +1 -0
- package/lib/index.d.ts +86 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +72 -625
- package/lib/index.js.map +1 -0
- package/package.json +26 -4
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host half — live state: `createChromeMcpController`.
|
|
3
|
+
*
|
|
4
|
+
* One controller per apply(): the composition base layer (`entry`), the live
|
|
5
|
+
* resolved settings source, the nested bridge, the serialized executable runs,
|
|
6
|
+
* and the two capture paths — bridge log lines and tool-call results. Every
|
|
7
|
+
* base-layer mutation happens here; settings commits route in through the
|
|
8
|
+
* controller methods, never the other way round.
|
|
9
|
+
*
|
|
10
|
+
* The executable state follows the reference plugin's picker shape and the rule
|
|
11
|
+
* that there is no auto mode: the saved **rows** (`{ id: path, name: label }`)
|
|
12
|
+
* are what the card's dropdown lists, the *selection* is what the bridge
|
|
13
|
+
* launches with, and a run refreshes both — it probes every candidate the rows
|
|
14
|
+
* and the row config carry, merges what it finds into the rows (names kept), and
|
|
15
|
+
* seeds a never-configured host exactly once. A fixed path that later breaks
|
|
16
|
+
* stays fixed and reads broken instead of being re-resolved.
|
|
17
|
+
*
|
|
18
|
+
* This file is only the assembly: it resolves the config-derived pieces, builds
|
|
19
|
+
* the base layer, makes the initial bridge connection, and wires the public
|
|
20
|
+
* methods to the behavior modules that sit alongside it (see ./index.ts for the
|
|
21
|
+
* layout). Everything that actually *does* something lives there, not here.
|
|
22
|
+
*/
|
|
23
|
+
import * as McpClient from "@deepseek-ai/dsh-mcp-client";
|
|
24
|
+
import { launchEnvironmentOf } from "@deepseek-ai/dsh-launch-environment";
|
|
25
|
+
import { bridgeConfig, captureLogger } from "../bridge.js";
|
|
26
|
+
import { DEFAULT_EXTRA_FLAGS, FLAGS_ENV_VAR, WSL_EXTRA_FLAGS, WSL_WINDOWS_LAUNCH_ERROR } from "../constants.js";
|
|
27
|
+
import { extractExecutablePathFlag, flagsSkipCheck, stripExecutablePathFlags } from "../flags.js";
|
|
28
|
+
import { isWindowsExecutablePath, isWindowsSubsystemForLinux } from "../platform.js";
|
|
29
|
+
import { runWindowsChromeConnect } from "../windows/index.js";
|
|
30
|
+
import { readPersistedChromePath, readPersistedFlags, readPersistedStderrMode, resolveEnvFlags, resolveStderrMode } from "../values.js";
|
|
31
|
+
import { configForBridge } from "./bridge-run.js";
|
|
32
|
+
import { noteBridgeLog, registerToolCapture } from "./captures.js";
|
|
33
|
+
import { onSettingsChange } from "./commits.js";
|
|
34
|
+
import { noteSelection, noteStderr } from "./notes.js";
|
|
35
|
+
import { prelaunchWindowsChrome, queue } from "./runs.js";
|
|
36
|
+
/**
|
|
37
|
+
* Build the live state for one bridge + card pairing.
|
|
38
|
+
* @param ctx - plugin context.
|
|
39
|
+
* @param config - validated row config.
|
|
40
|
+
* @param deps - optional host overrides (tests replace the Windows run;
|
|
41
|
+
* everything else resolves from this process).
|
|
42
|
+
*/
|
|
43
|
+
export function createChromeMcpController(ctx, config, deps = {}) {
|
|
44
|
+
// The Windows run half — injectable for wiring tests, default is the real
|
|
45
|
+
// one (TCP samples + the interop launch).
|
|
46
|
+
const windowsChrome = typeof deps.runWindowsChrome === "function" ? deps.runWindowsChrome : runWindowsChromeConnect;
|
|
47
|
+
const launchEnvironment = launchEnvironmentOf(ctx);
|
|
48
|
+
const envValue = launchEnvironment.get(FLAGS_ENV_VAR)?.value;
|
|
49
|
+
// Where the plugin runs: a WSL host plus a Windows executable is a selection
|
|
50
|
+
// the bridge can never launch (its debug pipes do not cross the interop
|
|
51
|
+
// boundary, and its debugging port stays on the Windows loopback). The launch
|
|
52
|
+
// environment is authoritative inside a host, so the answer is deterministic;
|
|
53
|
+
// a bare call falls back to the interop marker.
|
|
54
|
+
const wslHost = isWindowsSubsystemForLinux({ env: (name) => launchEnvironment.get(name)?.value });
|
|
55
|
+
// A path this host must never exec. There is only one: a Windows
|
|
56
|
+
// `chrome.exe` selected on a WSL host. Its `--version` probe answers (so the
|
|
57
|
+
// selection looks healthy) but answering attaches to the Windows browser
|
|
58
|
+
// session, and that **starts a browser instance** no tool call could drive —
|
|
59
|
+
// see WSL_WINDOWS_LAUNCH_ERROR. The run keeps such an entry visible carrying
|
|
60
|
+
// this reason; the probe answers nothing instead of paying for it.
|
|
61
|
+
const blockedForPlatform = (candidate) => wslHost && isWindowsExecutablePath(candidate) ? WSL_WINDOWS_LAUNCH_ERROR : "";
|
|
62
|
+
// A row-level `--executablePath` used to be the only way to pin an
|
|
63
|
+
// executable. The picker owns it now, so the flag is read out of the row
|
|
64
|
+
// flags here — it becomes the row-config source of the selection, and the
|
|
65
|
+
// flag itself never reaches argv as a second source of truth.
|
|
66
|
+
const rowChromePath = config.chromePath.trim() !== "" ? config.chromePath.trim() : extractExecutablePathFlag(config.extraFlags);
|
|
67
|
+
const rowFlags = stripExecutablePathFlags(config.extraFlags);
|
|
68
|
+
if (rowChromePath !== "" && config.chromePath.trim() === "" && extractExecutablePathFlag(config.extraFlags) !== "") {
|
|
69
|
+
ctx.logger.warn(`chrome-devtools-mcp(${config.serverName}): an extraFlags "--executablePath" in the row config is now the \`chromePath\` source ("${rowChromePath}"); the flag itself is dropped from the bridge argv`);
|
|
70
|
+
}
|
|
71
|
+
const baseFlags = resolveEnvFlags(rowFlags, envValue);
|
|
72
|
+
if (typeof envValue === "string" && envValue.trim() !== "" && baseFlags === rowFlags) {
|
|
73
|
+
ctx.logger.warn(`chrome-devtools-mcp(${config.serverName}): ignoring ${FLAGS_ENV_VAR} — invalid flags list; using row config`);
|
|
74
|
+
}
|
|
75
|
+
// The persisted UI selection wins over env/row config: seed the first bridge
|
|
76
|
+
// spawn with it. When the settings service is not up yet this yields the base
|
|
77
|
+
// flags, and the installSection initial onChange below switches the bridge to
|
|
78
|
+
// the persisted selection in place right after.
|
|
79
|
+
const initialFlags = readPersistedFlags(ctx) ?? baseFlags;
|
|
80
|
+
// The initial selection: persisted `chromePath` → row config → nothing.
|
|
81
|
+
// Nothing here consults discovery: the first run does, and only seeds if both
|
|
82
|
+
// layers are silent.
|
|
83
|
+
const persistedChromePath = readPersistedChromePath(ctx);
|
|
84
|
+
const runningChromePath = persistedChromePath !== "" ? persistedChromePath : rowChromePath;
|
|
85
|
+
const runningChromeSource = persistedChromePath !== "" ? "selected" : rowChromePath !== "" ? "row-config" : "";
|
|
86
|
+
// The effective bridge stderr mode: the persisted UI toggle when set, else the
|
|
87
|
+
// row-config `bridgeStderr`. Every spawn reads it, and a UI write hot-switches
|
|
88
|
+
// it (restarting the connection).
|
|
89
|
+
const runningStderrMode = resolveStderrMode(readPersistedStderrMode(ctx), config.bridgeStderr);
|
|
90
|
+
// Composition base layer: part of the resolved value served to the client but
|
|
91
|
+
// never persisted. See ./types/index.ts (SettingsBaseLayer) for the whole
|
|
92
|
+
// shape; the static `defaultExtraFlags`/`wslExtraFlags` mirrors feed the card's
|
|
93
|
+
// Restore defaults / Flags WSL actions, and `windowsChromeStatus` reads off
|
|
94
|
+
// this host from the start (the Windows path simply does not exist off WSL).
|
|
95
|
+
const entry = {
|
|
96
|
+
extraFlags: initialFlags,
|
|
97
|
+
refreshExecutablesNonce: 0,
|
|
98
|
+
openWindowsChromeNonce: 0,
|
|
99
|
+
chromePath: "",
|
|
100
|
+
executables: [],
|
|
101
|
+
chromeCustomPaths: [],
|
|
102
|
+
stderrMode: "",
|
|
103
|
+
lastError: "",
|
|
104
|
+
chromeMissing: false,
|
|
105
|
+
executableDiscoveryRevision: 0,
|
|
106
|
+
chromeVersion: "",
|
|
107
|
+
executableStatus: [],
|
|
108
|
+
effectiveChromePath: runningChromePath,
|
|
109
|
+
effectiveSource: runningChromeSource,
|
|
110
|
+
wslWindowsExecutable: wslHost && isWindowsExecutablePath(runningChromePath),
|
|
111
|
+
rowStderr: config.bridgeStderr === "console" ? "console" : "log",
|
|
112
|
+
defaultExtraFlags: [...DEFAULT_EXTRA_FLAGS],
|
|
113
|
+
wslExtraFlags: [...WSL_EXTRA_FLAGS],
|
|
114
|
+
windowsChromeStatus: { state: wslHost ? "off" : "not-applicable", port: 0, error: "" },
|
|
115
|
+
carriesConnectionMode: flagsSkipCheck(initialFlags)
|
|
116
|
+
};
|
|
117
|
+
const state = {
|
|
118
|
+
entry,
|
|
119
|
+
source: () => entry,
|
|
120
|
+
runningFlags: initialFlags,
|
|
121
|
+
runningStderrMode,
|
|
122
|
+
runningChromePath,
|
|
123
|
+
runningChromeSource,
|
|
124
|
+
runningExecutables: [],
|
|
125
|
+
stderrNotice: "",
|
|
126
|
+
lastRefreshNonce: void 0,
|
|
127
|
+
lastWindowsNonce: void 0,
|
|
128
|
+
seededPath: "",
|
|
129
|
+
seenUserSelection: false,
|
|
130
|
+
runs: Promise.resolve(),
|
|
131
|
+
wslNoticeShown: false,
|
|
132
|
+
profileLinkKeptShown: false,
|
|
133
|
+
legacyPathsMerged: false
|
|
134
|
+
};
|
|
135
|
+
const controller = {
|
|
136
|
+
ctx,
|
|
137
|
+
config,
|
|
138
|
+
wslHost,
|
|
139
|
+
blockedForPlatform,
|
|
140
|
+
rowChromePath,
|
|
141
|
+
rowFlags,
|
|
142
|
+
windowsChrome,
|
|
143
|
+
bridge: undefined,
|
|
144
|
+
state
|
|
145
|
+
};
|
|
146
|
+
// Initial connection with the resolved flags + the resolved selection. The
|
|
147
|
+
// bridge-log capture rides only on the bridge scope: our own logs bypass it,
|
|
148
|
+
// so our own warns never masquerade as connection errors.
|
|
149
|
+
const bridgeScope = ctx.extend({ logger: captureLogger(ctx.logger, (level, args) => noteBridgeLog(controller, level, args)) });
|
|
150
|
+
const initial = bridgeConfig(configForBridge(controller, initialFlags), initialFlags, runningStderrMode);
|
|
151
|
+
noteStderr(controller, initial);
|
|
152
|
+
controller.bridge = bridgeScope.plugin(McpClient, initial.config);
|
|
153
|
+
noteSelection(controller);
|
|
154
|
+
// Tool-level status: browser-level failures are returned to the calling agent
|
|
155
|
+
// and never reach the bridge logger.
|
|
156
|
+
registerToolCapture(controller);
|
|
157
|
+
return {
|
|
158
|
+
entry,
|
|
159
|
+
setSource: (next) => {
|
|
160
|
+
state.source = next;
|
|
161
|
+
},
|
|
162
|
+
run: () => queue(controller, "refresh"),
|
|
163
|
+
prelaunchWindowsChrome: () => prelaunchWindowsChrome(controller),
|
|
164
|
+
onSettingsChange: () => onSettingsChange(controller)
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/host/controller/controller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,EAAE,aAAa,CAAC,GAAG,CAAC,MAAoE,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;IAC7L,MAAM,OAAO,GAAG,YAAY,CAAC,eAAe,CAAC,UAAU,EAAE,YAAY,CAAC,EAAE,YAAY,EAAE,iBAAiB,CAAC,CAAC;IACzG,UAAU,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAChC,UAAU,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAyB,CAAC;IAC1F,aAAa,CAAC,UAAU,CAAC,CAAC;IAE1B,8EAA8E;IAC9E,qCAAqC;IACrC,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAEhC,OAAO;QACH,KAAK;QACL,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE;YAChB,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC;QACxB,CAAC;QACD,GAAG,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,UAAU,EAAE,SAAS,CAAC;QACvC,sBAAsB,EAAE,GAAG,EAAE,CAAC,sBAAsB,CAAC,UAAU,CAAC;QAChE,gBAAgB,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,UAAU,CAAC;KACvD,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host half — the controller's live state + behavior.
|
|
3
|
+
*
|
|
4
|
+
* One controller per apply(): the composition base layer, the nested bridge, the
|
|
5
|
+
* serialized executable runs, and the two capture paths. The public surface is
|
|
6
|
+
* `createChromeMcpController` and its config; everything behind it is split into
|
|
7
|
+
* concern modules:
|
|
8
|
+
*
|
|
9
|
+
* ./controller.ts the assembly: resolve config, build the base layer, make
|
|
10
|
+
* the initial bridge connection, wire the public methods
|
|
11
|
+
* ./state.ts the live state + context every helper shares (internal)
|
|
12
|
+
* ./notes.ts base-layer announcements (selection, stderr)
|
|
13
|
+
* ./bridge-run.ts the bridge switches (config build, restart, flags, stderr)
|
|
14
|
+
* ./runs.ts the executable run + serialization + the Windows trigger
|
|
15
|
+
* ./windows-run.ts the one **Prelaunch Windows Chrome** run
|
|
16
|
+
* ./persist.ts settings writes a run makes (seed, rows, connect flag)
|
|
17
|
+
* ./captures.ts bridge-log + tool-call-result captures
|
|
18
|
+
* ./commits.ts settings-commit routing (`onSettingsChange`)
|
|
19
|
+
*
|
|
20
|
+
* The one rule that must survive the split: read the live settings value through
|
|
21
|
+
* `state.source()` at commit time, never capture it, and keep every base-layer
|
|
22
|
+
* mutation in these modules — settings commits route in, never out.
|
|
23
|
+
*/
|
|
24
|
+
export { createChromeMcpController } from "./controller.js";
|
|
25
|
+
export type { ChromeMcpController, ChromeMcpControllerDeps } from "./controller.js";
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/host/controller/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,YAAY,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host half — the controller's live state + behavior.
|
|
3
|
+
*
|
|
4
|
+
* One controller per apply(): the composition base layer, the nested bridge, the
|
|
5
|
+
* serialized executable runs, and the two capture paths. The public surface is
|
|
6
|
+
* `createChromeMcpController` and its config; everything behind it is split into
|
|
7
|
+
* concern modules:
|
|
8
|
+
*
|
|
9
|
+
* ./controller.ts the assembly: resolve config, build the base layer, make
|
|
10
|
+
* the initial bridge connection, wire the public methods
|
|
11
|
+
* ./state.ts the live state + context every helper shares (internal)
|
|
12
|
+
* ./notes.ts base-layer announcements (selection, stderr)
|
|
13
|
+
* ./bridge-run.ts the bridge switches (config build, restart, flags, stderr)
|
|
14
|
+
* ./runs.ts the executable run + serialization + the Windows trigger
|
|
15
|
+
* ./windows-run.ts the one **Prelaunch Windows Chrome** run
|
|
16
|
+
* ./persist.ts settings writes a run makes (seed, rows, connect flag)
|
|
17
|
+
* ./captures.ts bridge-log + tool-call-result captures
|
|
18
|
+
* ./commits.ts settings-commit routing (`onSettingsChange`)
|
|
19
|
+
*
|
|
20
|
+
* The one rule that must survive the split: read the live settings value through
|
|
21
|
+
* `state.source()` at commit time, never capture it, and keep every base-layer
|
|
22
|
+
* mutation in these modules — settings commits route in, never out.
|
|
23
|
+
*/
|
|
24
|
+
export { createChromeMcpController } from "./controller.js";
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/host/controller/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Controller — base-layer announcements.
|
|
3
|
+
*
|
|
4
|
+
* The two notes the base layer carries that a client can only learn from here:
|
|
5
|
+
* the resolved selection (with the static WSL + Windows-executable state, keyed
|
|
6
|
+
* on the *selection*, not a probe), and where the bridge console output goes.
|
|
7
|
+
*/
|
|
8
|
+
import type { BridgeStderrNotice } from "../types/index.js";
|
|
9
|
+
import type { Controller } from "./state.js";
|
|
10
|
+
/**
|
|
11
|
+
* Publish the resolved selection into the base layer — with the one state the
|
|
12
|
+
* client can only learn from here, and with the static notice that goes with it.
|
|
13
|
+
* The Windows-executable state is keyed on the *selection*, not on any probe: a
|
|
14
|
+
* Windows binary answers `--version` just fine across the interop boundary, so a
|
|
15
|
+
* healthy-looking pill is exactly what a broken Windows selection looks like
|
|
16
|
+
* until the first tool call fails.
|
|
17
|
+
*/
|
|
18
|
+
export declare function noteSelection(controller: Controller): void;
|
|
19
|
+
/**
|
|
20
|
+
* Announce where the bridge's console output goes — one line per change of
|
|
21
|
+
* state, keyed on what actually happened, so neither the "log" capture nor
|
|
22
|
+
* a switch to console echo is silent. An unavailable redirect (no POSIX shell)
|
|
23
|
+
* warns with the reason so the fallback is not mysterious.
|
|
24
|
+
*/
|
|
25
|
+
export declare function noteStderr(controller: Controller, built: BridgeStderrNotice): void;
|
|
26
|
+
//# sourceMappingURL=notes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notes.d.ts","sourceRoot":"","sources":["../../../src/host/controller/notes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAK5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAc1D;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAclF"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { flagsSkipCheck } from "../flags.js";
|
|
2
|
+
import { isWindowsExecutablePath } from "../platform.js";
|
|
3
|
+
/**
|
|
4
|
+
* Publish the resolved selection into the base layer — with the one state the
|
|
5
|
+
* client can only learn from here, and with the static notice that goes with it.
|
|
6
|
+
* The Windows-executable state is keyed on the *selection*, not on any probe: a
|
|
7
|
+
* Windows binary answers `--version` just fine across the interop boundary, so a
|
|
8
|
+
* healthy-looking pill is exactly what a broken Windows selection looks like
|
|
9
|
+
* until the first tool call fails.
|
|
10
|
+
*/
|
|
11
|
+
export function noteSelection(controller) {
|
|
12
|
+
const { state } = controller;
|
|
13
|
+
state.entry.effectiveChromePath = state.runningChromePath;
|
|
14
|
+
state.entry.effectiveSource = state.runningChromeSource;
|
|
15
|
+
const windowsUnderWsl = !flagsSkipCheck(state.runningFlags) && controller.wslHost && isWindowsExecutablePath(state.runningChromePath);
|
|
16
|
+
state.entry.wslWindowsExecutable = windowsUnderWsl;
|
|
17
|
+
// The card has the full recipe; the log only needs the pointer, since a
|
|
18
|
+
// headless host never sees the notice.
|
|
19
|
+
if (windowsUnderWsl && !state.wslNoticeShown) {
|
|
20
|
+
state.wslNoticeShown = true;
|
|
21
|
+
controller.ctx.logger.warn(`chrome-devtools-mcp(${controller.config.serverName}): running under WSL with a Windows executable selected ("${state.runningChromePath}") — that binary cannot be launched from here; drive the Windows browser in connect mode instead (see the card's Windows executable notice)`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Announce where the bridge's console output goes — one line per change of
|
|
26
|
+
* state, keyed on what actually happened, so neither the "log" capture nor
|
|
27
|
+
* a switch to console echo is silent. An unavailable redirect (no POSIX shell)
|
|
28
|
+
* warns with the reason so the fallback is not mysterious.
|
|
29
|
+
*/
|
|
30
|
+
export function noteStderr(controller, built) {
|
|
31
|
+
const { state } = controller;
|
|
32
|
+
const key = built.redirect !== "" ? `file:${built.redirect}` : built.fallback !== "" ? `fallback:${built.fallback}` : "console";
|
|
33
|
+
if (state.stderrNotice === key)
|
|
34
|
+
return;
|
|
35
|
+
state.stderrNotice = key;
|
|
36
|
+
if (built.fallback === "platform") {
|
|
37
|
+
controller.ctx.logger.warn(`chrome-devtools-mcp(${controller.config.serverName}): bridgeStderr="log" is unavailable on this platform (no POSIX shell wrapper) — bridge logs keep going to the console`);
|
|
38
|
+
}
|
|
39
|
+
else if (built.fallback === "shell") {
|
|
40
|
+
controller.ctx.logger.warn(`chrome-devtools-mcp(${controller.config.serverName}): bridgeStderr="log" is unavailable (no /bin/sh was found) — bridge logs keep going to the console`);
|
|
41
|
+
}
|
|
42
|
+
else if (built.redirect !== "") {
|
|
43
|
+
controller.ctx.logger.info(`chrome-devtools-mcp(${controller.config.serverName}): bridge stderr → ${built.redirect}`);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
controller.ctx.logger.info(`chrome-devtools-mcp(${controller.config.serverName}): bridge stderr → console (echo)`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=notes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notes.js","sourceRoot":"","sources":["../../../src/host/controller/notes.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAIzD;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,UAAsB;IAChD,MAAM,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC;IAC7B,KAAK,CAAC,KAAK,CAAC,mBAAmB,GAAG,KAAK,CAAC,iBAAiB,CAAC;IAC1D,KAAK,CAAC,KAAK,CAAC,eAAe,GAAG,KAAK,CAAC,mBAAmB,CAAC;IACxD,MAAM,eAAe,GAAG,CAAC,cAAc,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,UAAU,CAAC,OAAO,IAAI,uBAAuB,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACtI,KAAK,CAAC,KAAK,CAAC,oBAAoB,GAAG,eAAe,CAAC;IACnD,wEAAwE;IACxE,uCAAuC;IACvC,IAAI,eAAe,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC;QAC3C,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC;QAC5B,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CACtB,uBAAuB,UAAU,CAAC,MAAM,CAAC,UAAU,6DAA6D,KAAK,CAAC,iBAAiB,6IAA6I,CACvR,CAAC;IACN,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,UAAsB,EAAE,K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write through the settings service. */
|
|
4
|
+
export declare function persistChromePath(controller: Controller, path: string): Promise<void>;
|
|
5
|
+
/** Persist the saved-executables rows a run merged into. */
|
|
6
|
+
export declare function persistExecutables(controller: Controller, entries: ChromeExecutableEntry[]): Promise<void>;
|
|
7
|
+
/** Persist the saved flags list a Windows connect run composed. */
|
|
8
|
+
export declare function persistExtraFlags(controller: Controller, flags: string[]): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=persist.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persist.d.ts","sourceRoot":"","sources":["../../../src/host/controller/persist.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAO7C,wEAAwE;AACxE,wBAAsB,iBAAiB,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ3F;AAED,4DAA4D;AAC5D,wBAAsB,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAQhH;AAED,mEAAmE;AACnE,wBAAsB,iBAAiB,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ9F"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Controller — settings persistence.
|
|
3
|
+
*
|
|
4
|
+
* The three writes a run may need to make back into the persisted settings
|
|
5
|
+
* section: the seeded executable, the saved rows a merged scan folded in, and
|
|
6
|
+
* the connect-mode flag a Windows run composed. All three follow the same rule —
|
|
7
|
+
* never throw out of a run, because the base layer is what the card reads and a
|
|
8
|
+
* failed write must not break an otherwise successful run.
|
|
9
|
+
*/
|
|
10
|
+
import { SETTINGS_NAMESPACE } from "../constants.js";
|
|
11
|
+
/** Read the `settings` service surface as consumed here (`mutate` only). */
|
|
12
|
+
function settingsService(controller) {
|
|
13
|
+
return controller.ctx.get("settings");
|
|
14
|
+
}
|
|
15
|
+
/** Persist one seeded/executable write through the settings service. */
|
|
16
|
+
export async function persistChromePath(controller, path) {
|
|
17
|
+
try {
|
|
18
|
+
const settings = settingsService(controller);
|
|
19
|
+
if (!settings || typeof settings.mutate !== "function")
|
|
20
|
+
return;
|
|
21
|
+
await Promise.resolve(settings.mutate(SETTINGS_NAMESPACE, [{ op: "set", path: ["chromePath"], value: path }]));
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
controller.ctx.logger.warn(`chrome-devtools-mcp(${controller.config.serverName}): failed to persist the seeded chromePath: ${String(error)}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** Persist the saved-executables rows a run merged into. */
|
|
28
|
+
export async function persistExecutables(controller, entries) {
|
|
29
|
+
try {
|
|
30
|
+
const settings = settingsService(controller);
|
|
31
|
+
if (!settings || typeof settings.mutate !== "function")
|
|
32
|
+
return;
|
|
33
|
+
await Promise.resolve(settings.mutate(SETTINGS_NAMESPACE, [{ op: "set", path: ["executables"], value: entries }]));
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
controller.ctx.logger.warn(`chrome-devtools-mcp(${controller.config.serverName}): failed to persist the executable rows: ${String(error)}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** Persist the saved flags list a Windows connect run composed. */
|
|
40
|
+
export async function persistExtraFlags(controller, flags) {
|
|
41
|
+
try {
|
|
42
|
+
const settings = settingsService(controller);
|
|
43
|
+
if (!settings || typeof settings.mutate !== "function")
|
|
44
|
+
return;
|
|
45
|
+
await Promise.resolve(settings.mutate(SETTINGS_NAMESPACE, [{ op: "set", path: ["extraFlags"], value: flags }]));
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
controller.ctx.logger.warn(`chrome-devtools-mcp(${controller.config.serverName}): failed to persist the connect-mode flag: ${String(error)}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=persist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persist.js","sourceRoot":"","sources":["../../../src/host/controller/persist.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAKrD,4EAA4E;AAC5E,SAAS,eAAe,CAAC,UAAsB;IAC3C,OAAO,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAqE,CAAC;AAC9G,CAAC;AAED,wEAAwE;AACxE,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,UAAsB,EAAE,IAAY;IACxE,IAAI,CAAC;QACD,MAAM,QAAQ,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,CAAC,MAAM,KAAK,UAAU;YAAE,OAAO;QAC/D,MAAM,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,kBAAkB,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACnH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,uBAAuB,UAAU,CAAC,MAAM,CAAC,UAAU,+CAA+C,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClJ,CAAC;AACL,CAAC;AAED,4DAA4D;AAC5D,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,UAAsB,EAAE,OAAgC;IAC7F,IAAI,CAAC;QACD,MAAM,QAAQ,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,CAAC,QAAQ,I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
|
+
/** The serialized units one controller may queue. */
|
|
4
|
+
export type RunKind = "refresh" | "probe" | "windows";
|
|
5
|
+
/** Element-wise equality of two saved-row lists (order is the dropdown order). */
|
|
6
|
+
export declare function sameEntries(a: readonly ChromeExecutableEntry[], b: readonly ChromeExecutableEntry[]): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Fold the legacy hand-typed MRU into the rows, exactly once. It is the same list
|
|
9
|
+
* the older card used to write, so reading it never duplicates a row the card
|
|
10
|
+
* already saved: the merge keeps stored rows and only appends ids that are
|
|
11
|
+
* missing, and the result lands in the persisted rows instead of staying
|
|
12
|
+
* readable forever as a second source.
|
|
13
|
+
*/
|
|
14
|
+
export declare function mergeLegacyPaths(controller: Controller): ChromeExecutableEntry[];
|
|
15
|
+
/**
|
|
16
|
+
* One executable run. Probe every candidate the row config and the saved rows
|
|
17
|
+
* carry (plus the selection — the same path may appear as a row), publish what
|
|
18
|
+
* answered as per-path status, and merge what was found into the saved rows,
|
|
19
|
+
* keeping the names their user gave them. When nothing is configured at all
|
|
20
|
+
* (neither layer carries a path) the first runnable entry is **seeded**: written
|
|
21
|
+
* into the persisted `chromePath` once, so what the picker shows is what the
|
|
22
|
+
* bridge runs. A selection that is already fixed is never re-resolved, however
|
|
23
|
+
* broken.
|
|
24
|
+
* @returns the per-path statuses the run answered with.
|
|
25
|
+
*/
|
|
26
|
+
export declare function runExecutableDiscovery(controller: Controller): Promise<ChromeExecutableStatus[]>;
|
|
27
|
+
/**
|
|
28
|
+
* The probe of the *selection* — the one run that answers the version line the
|
|
29
|
+
* card shows under the pill. Nothing probed (no selection, or a connect-mode
|
|
30
|
+
* flag) must not clear anything: upstream starts the browser lazily, so silence
|
|
31
|
+
* is not health.
|
|
32
|
+
*/
|
|
33
|
+
export declare function probeSelection(controller: Controller): Promise<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Restart the bridge connection with a different executable selected — the argv
|
|
36
|
+
* tail carries `--executablePath=<path>`, so unlike a flag change this one is
|
|
37
|
+
* what the card's pill claims is running. `rerun` schedules the scan+probe that
|
|
38
|
+
* follows a selection change; a caller that is already inside that run (the
|
|
39
|
+
* seeding branch above) passes `false`.
|
|
40
|
+
*/
|
|
41
|
+
export declare function applyChromePath(controller: Controller, path: string, nextSource: EffectiveChromeSource, rerun?: boolean): void;
|
|
42
|
+
/**
|
|
43
|
+
* Serialize one unit of work: a rows-only refresh, a run that also re-probes
|
|
44
|
+
* what is selected, or the Windows Chrome launch. Windows runs share this chain
|
|
45
|
+
* because the invariant is "one run at a time" — nothing about it interacts with
|
|
46
|
+
* the local probe.
|
|
47
|
+
*/
|
|
48
|
+
export declare function queue(controller: Controller, kind: RunKind): Promise<unknown>;
|
|
49
|
+
/**
|
|
50
|
+
* One Windows Chrome run on demand: queued on the same chain as the button (one
|
|
51
|
+
* run at a time), resolved once it settled. The answer is the base-layer mirror
|
|
52
|
+
* read after the run — the tool surface says what `windowsChromeStatus` says,
|
|
53
|
+
* never more than the run answered.
|
|
54
|
+
*/
|
|
55
|
+
export declare function prelaunchWindowsChrome(controller: Controller): Promise<string>;
|
|
56
|
+
//# sourceMappingURL=runs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runs.d.ts","sourceRoot":"","sources":["../../../src/host/controller/runs.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAO9G,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,qDAAqD;AACrD,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAEtD,kFAAkF;AAClF,wBAAgB,WAAW,CAAC,CAAC,EAAE,SAAS,qBAAqB,EAAE,EAAE,CAAC,EAAE,SAAS,qBAAqB,EAAE,GAAG,OAAO,CAG7G;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,UAAU,GAAG,qBAAqB,EAAE,CAehF;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,sBAAsB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAmDtG;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAkC5E;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,qBAAqB,EAAE,KAAK,UAAO,GAAG,IAAI,CAY3H;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAc7E;AAED;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAWpF"}
|