@kombai/cli 0.1.4-beta.1 → 0.1.4
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/dist/kombai.mjs +1012 -418
- package/dist/mcp-apps/design-taste.js +1 -1
- package/dist/mcp-apps/plans.js +1 -1
- package/dist/mcp-apps/sign-in.js +1 -1
- package/dist/mcp-apps/starters.js +73 -72
- package/package.json +1 -1
package/dist/kombai.mjs
CHANGED
|
@@ -829,9 +829,9 @@ function buildCanvasDownload(read2, bodies) {
|
|
|
829
829
|
const swaps = /* @__PURE__ */ new Map();
|
|
830
830
|
const nodeAssets = [];
|
|
831
831
|
for (const image of files.images ?? []) {
|
|
832
|
-
const
|
|
833
|
-
swaps.set(image.path, `${LOCAL_IMAGES_PREFIX}${
|
|
834
|
-
nodeAssets.push({ path:
|
|
832
|
+
const path28 = downloadAssetPathOf(image);
|
|
833
|
+
swaps.set(image.path, `${LOCAL_IMAGES_PREFIX}${path28}`);
|
|
834
|
+
nodeAssets.push({ path: path28, url: image.url, contentType: image.contentType });
|
|
835
835
|
}
|
|
836
836
|
const body = bodies[nodeId] ?? {};
|
|
837
837
|
const node = downloadNodeOf(lite, body, swaps);
|
|
@@ -882,8 +882,8 @@ function zipCanvasDownload(download, files) {
|
|
|
882
882
|
const parsed = Date.parse(download.modified);
|
|
883
883
|
const mtime = Number.isFinite(parsed) ? parsed : FALLBACK_ENTRY_TIME;
|
|
884
884
|
const entries = {};
|
|
885
|
-
for (const [
|
|
886
|
-
entries[
|
|
885
|
+
for (const [path28, bytes] of Object.entries(files).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) {
|
|
886
|
+
entries[path28] = [bytes, { level: entryLevel(path28), mtime }];
|
|
887
887
|
}
|
|
888
888
|
return zipSync(entries);
|
|
889
889
|
}
|
|
@@ -993,7 +993,7 @@ var init_canvas_download = __esm({
|
|
|
993
993
|
}
|
|
994
994
|
};
|
|
995
995
|
escapeForRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
996
|
-
entryLevel = (
|
|
996
|
+
entryLevel = (path28) => path28.endsWith(".canvas") || path28.endsWith(".svg") ? 6 : 0;
|
|
997
997
|
}
|
|
998
998
|
});
|
|
999
999
|
|
|
@@ -1557,9 +1557,9 @@ var init_env = __esm({
|
|
|
1557
1557
|
preprod: { api: "https://api.assistant.preprod.kombai.com", web: "https://agent.preprod.kombai.com" },
|
|
1558
1558
|
prod: { api: "https://api.assistant.app.kombai.com", web: "https://agent.kombai.com" }
|
|
1559
1559
|
});
|
|
1560
|
-
DEFAULT_ENV = Object.hasOwn(ENVIRONMENTS, "
|
|
1560
|
+
DEFAULT_ENV = Object.hasOwn(ENVIRONMENTS, "prod") ? (
|
|
1561
1561
|
/** @type {EnvName} */
|
|
1562
|
-
"
|
|
1562
|
+
"prod"
|
|
1563
1563
|
) : "prod";
|
|
1564
1564
|
}
|
|
1565
1565
|
});
|
|
@@ -1570,9 +1570,9 @@ import { createHash as createHash2 } from "node:crypto";
|
|
|
1570
1570
|
import fs3 from "node:fs/promises";
|
|
1571
1571
|
import path3 from "node:path";
|
|
1572
1572
|
function runGit(args, cwd) {
|
|
1573
|
-
return new Promise((
|
|
1573
|
+
return new Promise((resolve2) => {
|
|
1574
1574
|
execFile("git", args, { cwd, timeout: 5e3, windowsHide: true }, (error2, stdout) => {
|
|
1575
|
-
|
|
1575
|
+
resolve2(error2 ? null : stdout.trim());
|
|
1576
1576
|
});
|
|
1577
1577
|
});
|
|
1578
1578
|
}
|
|
@@ -1652,14 +1652,14 @@ var init_project = __esm({
|
|
|
1652
1652
|
|
|
1653
1653
|
// src/lib/deadline.js
|
|
1654
1654
|
function sleep(ms, signal) {
|
|
1655
|
-
return new Promise((
|
|
1656
|
-
if (ms <= 0 || signal?.aborted) return
|
|
1655
|
+
return new Promise((resolve2) => {
|
|
1656
|
+
if (ms <= 0 || signal?.aborted) return resolve2();
|
|
1657
1657
|
const timer = setTimeout(done, ms);
|
|
1658
1658
|
signal?.addEventListener("abort", done, { once: true });
|
|
1659
1659
|
function done() {
|
|
1660
1660
|
clearTimeout(timer);
|
|
1661
1661
|
signal?.removeEventListener("abort", done);
|
|
1662
|
-
|
|
1662
|
+
resolve2();
|
|
1663
1663
|
}
|
|
1664
1664
|
});
|
|
1665
1665
|
}
|
|
@@ -1756,17 +1756,328 @@ var init_sandbox = __esm({
|
|
|
1756
1756
|
}
|
|
1757
1757
|
});
|
|
1758
1758
|
|
|
1759
|
+
// ../shared/src/mcp/chatMcpRegistrationArg.ts
|
|
1760
|
+
var CHAT_MCP_REGISTRATION_ARG;
|
|
1761
|
+
var init_chatMcpRegistrationArg = __esm({
|
|
1762
|
+
"../shared/src/mcp/chatMcpRegistrationArg.ts"() {
|
|
1763
|
+
"use strict";
|
|
1764
|
+
init_define_KOMBAI_TELEMETRY();
|
|
1765
|
+
CHAT_MCP_REGISTRATION_ARG = "--registration";
|
|
1766
|
+
}
|
|
1767
|
+
});
|
|
1768
|
+
|
|
1769
|
+
// ../shared/src/mcp/codexKombaiEntry.ts
|
|
1770
|
+
function kombaiCliMcpEntry(platform2, cliPackage = KOMBAI_CLI_PACKAGE) {
|
|
1771
|
+
const args = ["-y", cliPackage, "mcp"];
|
|
1772
|
+
if (platform2 === "win32") {
|
|
1773
|
+
const [shell, ...shellArgs] = WINDOWS_SHELL_WRAPPER;
|
|
1774
|
+
return { command: shell, args: [...shellArgs, KOMBAI_CLI_MCP_COMMAND, ...args] };
|
|
1775
|
+
}
|
|
1776
|
+
return { command: KOMBAI_CLI_MCP_COMMAND, args };
|
|
1777
|
+
}
|
|
1778
|
+
function kombaiCliPackageOf({ command, args }) {
|
|
1779
|
+
let program = command;
|
|
1780
|
+
let rest = args;
|
|
1781
|
+
if (/^cmd(?:\.exe)?$/i.test(program) && rest[0]?.toLowerCase() === "/c") {
|
|
1782
|
+
program = rest[1] ?? "";
|
|
1783
|
+
rest = rest.slice(2);
|
|
1784
|
+
}
|
|
1785
|
+
if (!/^npx(?:\.cmd)?$/i.test(program)) return null;
|
|
1786
|
+
if (rest[0] === "-y" || rest[0] === "--yes") rest = rest.slice(1);
|
|
1787
|
+
return rest.length === 2 && KOMBAI_CLI_PACKAGE_RE.test(rest[0]) && rest[1] === "mcp" ? rest[0] : null;
|
|
1788
|
+
}
|
|
1789
|
+
function packageParts(spec) {
|
|
1790
|
+
const at = spec.indexOf("@", 1);
|
|
1791
|
+
return at === -1 ? { name: spec, tag: "latest" } : { name: spec.slice(0, at), tag: spec.slice(at + 1) };
|
|
1792
|
+
}
|
|
1793
|
+
function kombaiCliSwitchable(entryPackage, cliPackage) {
|
|
1794
|
+
const entry = packageParts(entryPackage);
|
|
1795
|
+
const cli = packageParts(cliPackage);
|
|
1796
|
+
return entry.name === cli.name && !/^\d/.test(entry.tag) && entry.tag !== cli.tag;
|
|
1797
|
+
}
|
|
1798
|
+
function tomlString(value) {
|
|
1799
|
+
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
1800
|
+
}
|
|
1801
|
+
function codexKombaiBlock(platform2, cliPackage = KOMBAI_CLI_PACKAGE) {
|
|
1802
|
+
const entry = kombaiCliMcpEntry(platform2, cliPackage);
|
|
1803
|
+
return `[mcp_servers.${KOMBAI_MCP_KEY}]
|
|
1804
|
+
${tomlCommandLine(entry.command)}
|
|
1805
|
+
${tomlArgsLine(entry.args)}
|
|
1806
|
+
`;
|
|
1807
|
+
}
|
|
1808
|
+
function bracketBalance(line) {
|
|
1809
|
+
let balance = 0;
|
|
1810
|
+
let quote = null;
|
|
1811
|
+
for (let i = 0; i < line.length; i++) {
|
|
1812
|
+
const c = line[i];
|
|
1813
|
+
if (quote) {
|
|
1814
|
+
if (c === "\\" && quote === '"') i++;
|
|
1815
|
+
else if (c === quote) quote = null;
|
|
1816
|
+
} else if (c === '"' || c === "'") quote = c;
|
|
1817
|
+
else if (c === "#") break;
|
|
1818
|
+
else if (c === "[") balance++;
|
|
1819
|
+
else if (c === "]") balance--;
|
|
1820
|
+
}
|
|
1821
|
+
return balance;
|
|
1822
|
+
}
|
|
1823
|
+
function tomlLines(text) {
|
|
1824
|
+
const lines = [];
|
|
1825
|
+
let depth = 0;
|
|
1826
|
+
let multiline = null;
|
|
1827
|
+
for (const line of text.split(/\r?\n/)) {
|
|
1828
|
+
if (multiline) {
|
|
1829
|
+
if (line.split(multiline).length % 2 === 0) multiline = null;
|
|
1830
|
+
lines.push({ line, header: false });
|
|
1831
|
+
continue;
|
|
1832
|
+
}
|
|
1833
|
+
const header = depth === 0 && TOML_HEADER_LINE_RE.test(line);
|
|
1834
|
+
lines.push({ line, header });
|
|
1835
|
+
if (header) continue;
|
|
1836
|
+
depth = Math.max(0, depth + bracketBalance(line));
|
|
1837
|
+
multiline = MULTILINE_QUOTES.find((quotes) => line.split(quotes).length % 2 === 0) ?? null;
|
|
1838
|
+
}
|
|
1839
|
+
return lines;
|
|
1840
|
+
}
|
|
1841
|
+
function mcpServersTableDefinesKombai(text) {
|
|
1842
|
+
let inMcpServers = false;
|
|
1843
|
+
for (const { line, header } of tomlLines(text)) {
|
|
1844
|
+
if (header) inMcpServers = MCP_SERVERS_HEADER_RE.test(line);
|
|
1845
|
+
else if (inMcpServers && KOMBAI_KEY_LINE_RE.test(line)) return true;
|
|
1846
|
+
}
|
|
1847
|
+
return false;
|
|
1848
|
+
}
|
|
1849
|
+
function codexMcpServersInline(content) {
|
|
1850
|
+
for (const { line, header } of tomlLines(withoutBom(content))) {
|
|
1851
|
+
if (header) return false;
|
|
1852
|
+
if (MCP_SERVERS_KEY_LINE_RE.test(line)) return true;
|
|
1853
|
+
}
|
|
1854
|
+
return false;
|
|
1855
|
+
}
|
|
1856
|
+
function skipBlank(text, at, newlines) {
|
|
1857
|
+
let i = at;
|
|
1858
|
+
for (; ; ) {
|
|
1859
|
+
const c = text[i];
|
|
1860
|
+
if (c === " " || c === " " || newlines && (c === "\n" || c === "\r")) i++;
|
|
1861
|
+
else if (c === "#") {
|
|
1862
|
+
const eol = text.indexOf("\n", i);
|
|
1863
|
+
if (eol === -1) return text.length;
|
|
1864
|
+
i = eol;
|
|
1865
|
+
if (!newlines) return i;
|
|
1866
|
+
} else return i;
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
function readTomlString(text, at) {
|
|
1870
|
+
const quote = text[at];
|
|
1871
|
+
if (quote === "'") {
|
|
1872
|
+
const close = text.indexOf("'", at + 1);
|
|
1873
|
+
return close === -1 || /[\r\n]/.test(text.slice(at + 1, close)) ? null : { value: text.slice(at + 1, close), end: close + 1 };
|
|
1874
|
+
}
|
|
1875
|
+
if (quote !== '"') return null;
|
|
1876
|
+
let value = "";
|
|
1877
|
+
for (let i = at + 1; i < text.length; i++) {
|
|
1878
|
+
const c = text[i];
|
|
1879
|
+
if (c === '"') return { value, end: i + 1 };
|
|
1880
|
+
if (c === "\n" || c === "\r") return null;
|
|
1881
|
+
if (c === "\\") {
|
|
1882
|
+
const escaped = text[++i];
|
|
1883
|
+
if (escaped !== "\\" && escaped !== '"') return null;
|
|
1884
|
+
value += escaped;
|
|
1885
|
+
} else value += c;
|
|
1886
|
+
}
|
|
1887
|
+
return null;
|
|
1888
|
+
}
|
|
1889
|
+
function readTomlStringArray(text) {
|
|
1890
|
+
if (text[0] !== "[") return null;
|
|
1891
|
+
const values = [];
|
|
1892
|
+
let i = skipBlank(text, 1, true);
|
|
1893
|
+
while (text[i] !== "]") {
|
|
1894
|
+
const item = readTomlString(text, i);
|
|
1895
|
+
if (!item) return null;
|
|
1896
|
+
values.push(item.value);
|
|
1897
|
+
i = skipBlank(text, item.end, true);
|
|
1898
|
+
if (text[i] === ",") i = skipBlank(text, i + 1, true);
|
|
1899
|
+
else if (text[i] !== "]") return null;
|
|
1900
|
+
}
|
|
1901
|
+
return skipBlank(text, i + 1, false) === text.length ? values : null;
|
|
1902
|
+
}
|
|
1903
|
+
function kombaiCommandKeys(lines) {
|
|
1904
|
+
const marks = tomlLines(lines.join("\n"));
|
|
1905
|
+
const start = marks.findIndex(({ line, header }) => header && KOMBAI_TABLE_HEADER_RE.test(line));
|
|
1906
|
+
if (start === -1) return null;
|
|
1907
|
+
const next = marks.findIndex(({ header }, index) => index > start && header);
|
|
1908
|
+
const end = next === -1 ? marks.length : next;
|
|
1909
|
+
let command = null;
|
|
1910
|
+
let args = null;
|
|
1911
|
+
for (let i = start + 1; i < end; i++) {
|
|
1912
|
+
const key = COMMAND_OR_ARGS_RE.exec(lines[i]);
|
|
1913
|
+
if (!key) continue;
|
|
1914
|
+
const value = key[2];
|
|
1915
|
+
if (key[1].replace(/["']/g, "") === "command") {
|
|
1916
|
+
const read3 = readTomlString(value, 0);
|
|
1917
|
+
if (command || !read3 || skipBlank(value, read3.end, false) !== value.length) return null;
|
|
1918
|
+
command = { value: read3.value, at: i };
|
|
1919
|
+
continue;
|
|
1920
|
+
}
|
|
1921
|
+
let to = i;
|
|
1922
|
+
let balance = bracketBalance(value);
|
|
1923
|
+
while (balance > 0 && to + 1 < end) balance += bracketBalance(lines[++to]);
|
|
1924
|
+
const read2 = balance === 0 ? readTomlStringArray([value, ...lines.slice(i + 1, to + 1)].join("\n")) : null;
|
|
1925
|
+
if (args || !read2) return null;
|
|
1926
|
+
args = { value: read2, from: i, to };
|
|
1927
|
+
i = to;
|
|
1928
|
+
}
|
|
1929
|
+
if (!command || !args) return null;
|
|
1930
|
+
return { command: command.value, args: args.value, commandAt: command.at, argsFrom: args.from, argsTo: args.to };
|
|
1931
|
+
}
|
|
1932
|
+
function codexKombaiEntryCommand(content) {
|
|
1933
|
+
const keys = kombaiCommandKeys(withoutBom(content).split(/\r?\n/));
|
|
1934
|
+
return keys && { command: keys.command, args: keys.args };
|
|
1935
|
+
}
|
|
1936
|
+
function codexKombaiEntryPackage(content) {
|
|
1937
|
+
const entry = codexKombaiEntryCommand(content);
|
|
1938
|
+
return entry && kombaiCliPackageOf(entry);
|
|
1939
|
+
}
|
|
1940
|
+
function codexKombaiBlockText(content) {
|
|
1941
|
+
const blocks = withoutBom(content).match(KOMBAI_TOML_BLOCK_RE);
|
|
1942
|
+
if (!blocks) return null;
|
|
1943
|
+
return blocks.map((block) => block.replace(/^\r?\n/, "")).join("\n").replace(/\r\n/g, "\n").trimEnd();
|
|
1944
|
+
}
|
|
1945
|
+
function codexKombaiEntryKind(content) {
|
|
1946
|
+
const text = withoutBom(content);
|
|
1947
|
+
const blocks = text.match(KOMBAI_TOML_BLOCK_RE);
|
|
1948
|
+
if (!blocks) return mcpServersTableDefinesKombai(text) ? "foreign" /* Foreign */ : "none" /* None */;
|
|
1949
|
+
if (codexKombaiEntryPackage(text)) return "cli" /* Cli */;
|
|
1950
|
+
const block = blocks.join("\n");
|
|
1951
|
+
return block.includes(`"${CHAT_MCP_REGISTRATION_ARG}"`) || LEGACY_LAUNCHER_RE.test(block) ? "legacy" /* Legacy */ : "foreign" /* Foreign */;
|
|
1952
|
+
}
|
|
1953
|
+
function codexKombaiEntryDisabled(content) {
|
|
1954
|
+
const blocks = withoutBom(content).match(KOMBAI_TOML_BLOCK_RE) ?? [];
|
|
1955
|
+
return blocks.some((block) => {
|
|
1956
|
+
const lines = tomlLines(block);
|
|
1957
|
+
const own = lines.findIndex((entry) => entry.header);
|
|
1958
|
+
const sub = lines.findIndex((entry, index) => index > own && entry.header);
|
|
1959
|
+
return lines.slice(own + 1, sub === -1 ? void 0 : sub).some(({ line }) => /^[ \t]*enabled[ \t]*=[ \t]*false\b/.test(line));
|
|
1960
|
+
});
|
|
1961
|
+
}
|
|
1962
|
+
function withoutCodexKombaiBlock(content) {
|
|
1963
|
+
const bom = content.startsWith(BOM) ? BOM : "";
|
|
1964
|
+
const text = withoutBom(content);
|
|
1965
|
+
let stripped = text.replace(KOMBAI_TOML_BLOCK_RE, "").trimEnd();
|
|
1966
|
+
if (stripped === text.trimEnd()) return null;
|
|
1967
|
+
if (KOMBAI_TOML_AT_START_RE.test(text)) stripped = stripped.replace(/^\r?\n/, "");
|
|
1968
|
+
if (stripped.length === 0) return "";
|
|
1969
|
+
const crlf = stripped.includes("\n") ? /\r\n[^\n]*$/.test(stripped) : text.includes("\r\n");
|
|
1970
|
+
return bom + stripped + (crlf ? "\r\n" : "\n");
|
|
1971
|
+
}
|
|
1972
|
+
function withCodexKombaiBlock(content, platform2, cliPackage = KOMBAI_CLI_PACKAGE) {
|
|
1973
|
+
const bom = content.startsWith(BOM) ? BOM : "";
|
|
1974
|
+
const text = withoutBom(content);
|
|
1975
|
+
const rest = withoutBom(withoutCodexKombaiBlock(text) ?? text).trimEnd();
|
|
1976
|
+
const block = codexKombaiBlock(platform2, cliPackage);
|
|
1977
|
+
if (rest.length === 0) return bom + block;
|
|
1978
|
+
const eol = text.includes("\r\n") ? "\r\n" : "\n";
|
|
1979
|
+
return `${bom}${rest}${eol}${eol}${eol === "\n" ? block : block.replace(/\n/g, eol)}`;
|
|
1980
|
+
}
|
|
1981
|
+
function trailingComment(line) {
|
|
1982
|
+
let quote = null;
|
|
1983
|
+
for (let i = 0; i < line.length; i++) {
|
|
1984
|
+
const c = line[i];
|
|
1985
|
+
if (quote) {
|
|
1986
|
+
if (c === "\\" && quote === '"') i++;
|
|
1987
|
+
else if (c === quote) quote = null;
|
|
1988
|
+
} else if (c === '"' || c === "'") quote = c;
|
|
1989
|
+
else if (c === "#") {
|
|
1990
|
+
let start = i;
|
|
1991
|
+
while (start > 0 && (line[start - 1] === " " || line[start - 1] === " ")) start--;
|
|
1992
|
+
return line.slice(start);
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
return "";
|
|
1996
|
+
}
|
|
1997
|
+
function withCodexKombaiCommand(content, platform2, cliPackage) {
|
|
1998
|
+
const bom = content.startsWith(BOM) ? BOM : "";
|
|
1999
|
+
const parts = withoutBom(content).split(/(\r?\n)/);
|
|
2000
|
+
const lines = parts.filter((_, index) => index % 2 === 0);
|
|
2001
|
+
const keys = kombaiCommandKeys(lines);
|
|
2002
|
+
if (!keys) return content;
|
|
2003
|
+
const entry = kombaiCliMcpEntry(platform2, cliPackage);
|
|
2004
|
+
const current = kombaiCliPackageOf(keys);
|
|
2005
|
+
const packageOnly = current !== null && keys.command === entry.command && keys.args.length === entry.args.length && keys.args.every((arg, index) => arg === entry.args[index] || arg === current && entry.args[index] === cliPackage);
|
|
2006
|
+
if (packageOnly) {
|
|
2007
|
+
for (let at = keys.argsFrom; at <= keys.argsTo; at++) {
|
|
2008
|
+
for (const quote of ['"', "'"]) {
|
|
2009
|
+
const literal2 = `${quote}${current}${quote}`;
|
|
2010
|
+
const column = lines[at].indexOf(literal2);
|
|
2011
|
+
if (column === -1) continue;
|
|
2012
|
+
parts[at * 2] = lines[at].slice(0, column) + quote + cliPackage + quote + lines[at].slice(column + literal2.length);
|
|
2013
|
+
return bom + parts.join("");
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
const indent = (at) => /^[ \t]*/.exec(lines[at])?.[0] ?? "";
|
|
2018
|
+
const edits = [
|
|
2019
|
+
{
|
|
2020
|
+
from: keys.commandAt,
|
|
2021
|
+
to: keys.commandAt,
|
|
2022
|
+
line: indent(keys.commandAt) + tomlCommandLine(entry.command) + trailingComment(lines[keys.commandAt])
|
|
2023
|
+
},
|
|
2024
|
+
{
|
|
2025
|
+
from: keys.argsFrom,
|
|
2026
|
+
to: keys.argsTo,
|
|
2027
|
+
line: indent(keys.argsFrom) + tomlArgsLine(entry.args) + trailingComment(lines[keys.argsTo])
|
|
2028
|
+
}
|
|
2029
|
+
];
|
|
2030
|
+
for (const edit of edits.sort((a, b) => b.from - a.from)) {
|
|
2031
|
+
parts.splice(edit.from * 2, (edit.to - edit.from) * 2 + 1, edit.line);
|
|
2032
|
+
}
|
|
2033
|
+
return bom + parts.join("");
|
|
2034
|
+
}
|
|
2035
|
+
var KOMBAI_MCP_KEY, KOMBAI_CLI_MCP_COMMAND, KOMBAI_CLI_PACKAGE, WINDOWS_SHELL_WRAPPER, KOMBAI_CLI_PACKAGE_RE, LEGACY_LAUNCHER_RE, KOMBAI_TOML_TABLE, TOML_OTHER_HEADER, KOMBAI_TOML_BLOCK_RE, KOMBAI_TOML_AT_START_RE, tomlCommandLine, tomlArgsLine, BOM, withoutBom, TOML_HEADER_LINE_RE, MULTILINE_QUOTES, MCP_SERVERS_HEADER_RE, KOMBAI_KEY_LINE_RE, MCP_SERVERS_KEY_LINE_RE, KOMBAI_TABLE_HEADER_RE, COMMAND_OR_ARGS_RE;
|
|
2036
|
+
var init_codexKombaiEntry = __esm({
|
|
2037
|
+
"../shared/src/mcp/codexKombaiEntry.ts"() {
|
|
2038
|
+
"use strict";
|
|
2039
|
+
init_define_KOMBAI_TELEMETRY();
|
|
2040
|
+
init_chatMcpRegistrationArg();
|
|
2041
|
+
KOMBAI_MCP_KEY = "kombai";
|
|
2042
|
+
KOMBAI_CLI_MCP_COMMAND = "npx";
|
|
2043
|
+
KOMBAI_CLI_PACKAGE = "@kombai/cli@latest";
|
|
2044
|
+
WINDOWS_SHELL_WRAPPER = ["cmd", "/c"];
|
|
2045
|
+
KOMBAI_CLI_PACKAGE_RE = /^@kombai(?:-io)?\/cli(?:@[A-Za-z0-9._-]+)?$/;
|
|
2046
|
+
LEGACY_LAUNCHER_RE = /[\\/]+\.kombai[\\/]+bin[\\/]+mcp-gateway(?:\.cmd)?(?=$|")/;
|
|
2047
|
+
KOMBAI_TOML_TABLE = String.raw`[ \t]*mcp_servers[ \t]*\.[ \t]*(?:kombai|"kombai"|'kombai')[ \t]*`;
|
|
2048
|
+
TOML_OTHER_HEADER = String.raw`[ \t]*\[(?!${KOMBAI_TOML_TABLE}(?:\.|\]))[^\r\n]*\][ \t]*(?:#[^\r\n]*)?(?=\r?\n|$)`;
|
|
2049
|
+
KOMBAI_TOML_BLOCK_RE = new RegExp(
|
|
2050
|
+
String.raw`(?:^|\r?\n)[ \t]*\[${KOMBAI_TOML_TABLE}\][\s\S]*?(?=((?:\r?\n[ \t]*(?=\r?\n))*))\1` + String.raw`(?=(?:\r?\n[ \t]*(?:#[^\r\n]*)?)*(?:\r?\n${TOML_OTHER_HEADER}|$))`,
|
|
2051
|
+
"g"
|
|
2052
|
+
);
|
|
2053
|
+
KOMBAI_TOML_AT_START_RE = new RegExp(String.raw`^[ \t]*\[${KOMBAI_TOML_TABLE}\]`);
|
|
2054
|
+
tomlCommandLine = (command) => `command = ${tomlString(command)}`;
|
|
2055
|
+
tomlArgsLine = (args) => `args = [${args.map(tomlString).join(", ")}]`;
|
|
2056
|
+
BOM = "\uFEFF";
|
|
2057
|
+
withoutBom = (content) => content.startsWith(BOM) ? content.slice(BOM.length) : content;
|
|
2058
|
+
TOML_HEADER_LINE_RE = /^[ \t]*\[/;
|
|
2059
|
+
MULTILINE_QUOTES = ['"""', "'''"];
|
|
2060
|
+
MCP_SERVERS_HEADER_RE = /^[ \t]*\[[ \t]*(?:mcp_servers|"mcp_servers"|'mcp_servers')[ \t]*\][ \t]*(?:#.*)?$/;
|
|
2061
|
+
KOMBAI_KEY_LINE_RE = /^[ \t]*(?:kombai|"kombai"|'kombai')[ \t]*[.=]/;
|
|
2062
|
+
MCP_SERVERS_KEY_LINE_RE = /^[ \t]*(?:mcp_servers|"mcp_servers"|'mcp_servers')[ \t]*[.=]/;
|
|
2063
|
+
KOMBAI_TABLE_HEADER_RE = new RegExp(String.raw`^[ \t]*\[${KOMBAI_TOML_TABLE}\][ \t]*(?:#.*)?$`);
|
|
2064
|
+
COMMAND_OR_ARGS_RE = /^[ \t]*(command|args|"command"|"args"|'command'|'args')[ \t]*=[ \t]*(.*)$/;
|
|
2065
|
+
}
|
|
2066
|
+
});
|
|
2067
|
+
|
|
1759
2068
|
// src/lib/version.js
|
|
1760
|
-
var CLI_VERSION, CLI_RUN;
|
|
2069
|
+
var CLI_VERSION, CLI_RUN, CLI_PACKAGE;
|
|
1761
2070
|
var init_version = __esm({
|
|
1762
2071
|
"src/lib/version.js"() {
|
|
1763
2072
|
"use strict";
|
|
1764
2073
|
init_define_KOMBAI_TELEMETRY();
|
|
1765
|
-
|
|
2074
|
+
init_codexKombaiEntry();
|
|
2075
|
+
CLI_VERSION = true ? "0.1.4" : (
|
|
1766
2076
|
/** @type {{ version: string }} */
|
|
1767
2077
|
JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8")).version
|
|
1768
2078
|
);
|
|
1769
|
-
CLI_RUN = true ? "npx -y @kombai/cli@
|
|
2079
|
+
CLI_RUN = true ? "npx -y @kombai/cli@latest" : `npx -y ${KOMBAI_CLI_PACKAGE}`;
|
|
2080
|
+
CLI_PACKAGE = true ? "@kombai/cli@latest" : KOMBAI_CLI_PACKAGE;
|
|
1770
2081
|
}
|
|
1771
2082
|
});
|
|
1772
2083
|
|
|
@@ -1793,7 +2104,7 @@ function retryAfterMs(value) {
|
|
|
1793
2104
|
const at = Date.parse(value ?? "");
|
|
1794
2105
|
return Number.isFinite(at) ? Math.max(0, at - Date.now()) : 2e3;
|
|
1795
2106
|
}
|
|
1796
|
-
function apiError(status, body, method,
|
|
2107
|
+
function apiError(status, body, method, path28) {
|
|
1797
2108
|
const {
|
|
1798
2109
|
errorCode,
|
|
1799
2110
|
apiMessage,
|
|
@@ -1807,7 +2118,7 @@ function apiError(status, body, method, path26) {
|
|
|
1807
2118
|
...extras
|
|
1808
2119
|
};
|
|
1809
2120
|
const code2 = typeof errorCode === "string" ? errorCode : `HTTP_${status}`;
|
|
1810
|
-
const message = code2 === "DESIGN_NOT_FOUND" && rest.what === "canvas" ? PRIVATE_CANVAS : typeof apiMessage === "string" && apiMessage ? apiMessage : `${method} ${
|
|
2121
|
+
const message = code2 === "DESIGN_NOT_FOUND" && rest.what === "canvas" ? PRIVATE_CANVAS : typeof apiMessage === "string" && apiMessage ? apiMessage : `${method} ${path28} answered ${status}.`;
|
|
1811
2122
|
const guestRow = GUEST_ERRORS[code2];
|
|
1812
2123
|
const needsLogin = status === 401 || guestRow !== void 0;
|
|
1813
2124
|
const text = guestRow?.message?.(rest, typeof apiMessage === "string" ? apiMessage : "") ?? message;
|
|
@@ -1820,8 +2131,8 @@ function apiError(status, body, method, path26) {
|
|
|
1820
2131
|
details: Object.keys(rest).length ? rest : void 0
|
|
1821
2132
|
});
|
|
1822
2133
|
}
|
|
1823
|
-
function timedOut(method,
|
|
1824
|
-
return new CliError("CLI_TIMEOUT", `The command's deadline passed during ${method} ${
|
|
2134
|
+
function timedOut(method, path28) {
|
|
2135
|
+
return new CliError("CLI_TIMEOUT", `The command's deadline passed during ${method} ${path28}.`, {
|
|
1825
2136
|
exit: Exit.TIMED_OUT
|
|
1826
2137
|
});
|
|
1827
2138
|
}
|
|
@@ -1856,10 +2167,10 @@ var init_api = __esm({
|
|
|
1856
2167
|
* @param {string} path
|
|
1857
2168
|
* @param {number | undefined} status
|
|
1858
2169
|
*/
|
|
1859
|
-
constructor(method,
|
|
1860
|
-
super("CLI_NETWORK", `${method} ${
|
|
2170
|
+
constructor(method, path28, status) {
|
|
2171
|
+
super("CLI_NETWORK", `${method} ${path28} got no usable answer${status ? ` (${status})` : ""}.`, {
|
|
1861
2172
|
status,
|
|
1862
|
-
details: { method, path:
|
|
2173
|
+
details: { method, path: path28 }
|
|
1863
2174
|
});
|
|
1864
2175
|
this.lost = true;
|
|
1865
2176
|
}
|
|
@@ -1894,9 +2205,9 @@ var init_api = __esm({
|
|
|
1894
2205
|
* @returns {Promise<ApiResponse>}
|
|
1895
2206
|
*/
|
|
1896
2207
|
async call(options) {
|
|
1897
|
-
const { method, path:
|
|
2208
|
+
const { method, path: path28, retry = "safe" } = options;
|
|
1898
2209
|
const deadline = options.deadline ?? this.deadline;
|
|
1899
|
-
const url2 = `${this.baseUrl}${
|
|
2210
|
+
const url2 = `${this.baseUrl}${path28}${queryString(options.query)}`;
|
|
1900
2211
|
const headers = {
|
|
1901
2212
|
"x-kombai-cli": this.ctx.version,
|
|
1902
2213
|
"x-type": "agent",
|
|
@@ -1910,7 +2221,7 @@ var init_api = __esm({
|
|
|
1910
2221
|
let lostTries = 0;
|
|
1911
2222
|
for (; ; ) {
|
|
1912
2223
|
const limit = deadline.clamp(CALL_LIMIT_MS);
|
|
1913
|
-
if (limit <= 0) throw timedOut(method,
|
|
2224
|
+
if (limit <= 0) throw timedOut(method, path28);
|
|
1914
2225
|
let res;
|
|
1915
2226
|
if (method !== "GET") this.ctx.changeSent = true;
|
|
1916
2227
|
try {
|
|
@@ -1924,12 +2235,12 @@ var init_api = __esm({
|
|
|
1924
2235
|
} catch (error3) {
|
|
1925
2236
|
const blocked = blockedRequest(this.ctx.sandbox, error3);
|
|
1926
2237
|
if (blocked) throw blocked;
|
|
1927
|
-
if (deadline.expired()) throw timedOut(method,
|
|
2238
|
+
if (deadline.expired()) throw timedOut(method, path28);
|
|
1928
2239
|
if (retry === "safe" && lostTries < LOST_ANSWER_BACKOFF_MS.length) {
|
|
1929
|
-
await this.wait(LOST_ANSWER_BACKOFF_MS[lostTries++], deadline, method,
|
|
2240
|
+
await this.wait(LOST_ANSWER_BACKOFF_MS[lostTries++], deadline, method, path28);
|
|
1930
2241
|
continue;
|
|
1931
2242
|
}
|
|
1932
|
-
throw new LostAnswer(method,
|
|
2243
|
+
throw new LostAnswer(method, path28, void 0);
|
|
1933
2244
|
}
|
|
1934
2245
|
this.checkContractVersion(res.headers);
|
|
1935
2246
|
const parsed = await readBody(res);
|
|
@@ -1943,17 +2254,17 @@ var init_api = __esm({
|
|
|
1943
2254
|
}
|
|
1944
2255
|
if (UNKNOWN_OUTCOME_STATUSES.has(res.status)) {
|
|
1945
2256
|
if (retry === "safe" && lostTries < LOST_ANSWER_BACKOFF_MS.length) {
|
|
1946
|
-
await this.wait(LOST_ANSWER_BACKOFF_MS[lostTries++], deadline, method,
|
|
2257
|
+
await this.wait(LOST_ANSWER_BACKOFF_MS[lostTries++], deadline, method, path28);
|
|
1947
2258
|
continue;
|
|
1948
2259
|
}
|
|
1949
|
-
if (retry === "once") throw new LostAnswer(method,
|
|
2260
|
+
if (retry === "once") throw new LostAnswer(method, path28, res.status);
|
|
1950
2261
|
}
|
|
1951
2262
|
if (res.ok) {
|
|
1952
2263
|
if (headers["x-kombai-guest"] && parsed?.guest === true && typeof parsed.guestExpiresAt === "string")
|
|
1953
2264
|
await this.onGuestExpires?.(parsed.guestExpiresAt);
|
|
1954
2265
|
return { status: res.status, body: parsed, headers: res.headers };
|
|
1955
2266
|
}
|
|
1956
|
-
const error2 = apiError(res.status, parsed, method,
|
|
2267
|
+
const error2 = apiError(res.status, parsed, method, path28);
|
|
1957
2268
|
if (res.status === 503 && res.headers.has("retry-after")) {
|
|
1958
2269
|
error2.details = { ...error2.details, retryAfter: res.headers.get("retry-after") };
|
|
1959
2270
|
}
|
|
@@ -2038,8 +2349,8 @@ var init_api = __esm({
|
|
|
2038
2349
|
* @param {string} method
|
|
2039
2350
|
* @param {string} path
|
|
2040
2351
|
*/
|
|
2041
|
-
async wait(ms, deadline, method,
|
|
2042
|
-
if (deadline.remaining() <= ms) throw timedOut(method,
|
|
2352
|
+
async wait(ms, deadline, method, path28) {
|
|
2353
|
+
if (deadline.remaining() <= ms) throw timedOut(method, path28);
|
|
2043
2354
|
await this.ctx.sleep(ms);
|
|
2044
2355
|
}
|
|
2045
2356
|
/** @param {Headers} headers */
|
|
@@ -3748,6 +4059,10 @@ function linkField(ctx, url2) {
|
|
|
3748
4059
|
function canvasJsonLink(ctx, url2) {
|
|
3749
4060
|
return ctx.codexDesktop ? null : url2;
|
|
3750
4061
|
}
|
|
4062
|
+
function codexTaskStartedAt(env) {
|
|
4063
|
+
const id = UUID_V7_RE.exec(env.CODEX_THREAD_ID ?? "");
|
|
4064
|
+
return id ? Number.parseInt(id[1] + id[2], 16) : null;
|
|
4065
|
+
}
|
|
3751
4066
|
function inCodexDesktop(env) {
|
|
3752
4067
|
return Boolean(env.CODEX_THREAD_ID) && env.CLAUDECODE !== "1" && env.CODEX_INTERNAL_ORIGINATOR_OVERRIDE === CODEX_DESKTOP_ORIGINATOR;
|
|
3753
4068
|
}
|
|
@@ -3760,7 +4075,7 @@ function viewInstead(canvas) {
|
|
|
3760
4075
|
next: `${showWithCanvasApp(canvas)} In the Codex app it shows the canvas beside the chat. ${VIEW_MISSING}`
|
|
3761
4076
|
};
|
|
3762
4077
|
}
|
|
3763
|
-
var CODEX_DESKTOP_ORIGINATOR, FIND_CANVAS_APP, VIEW_MISSING;
|
|
4078
|
+
var CODEX_DESKTOP_ORIGINATOR, FIND_CANVAS_APP, VIEW_MISSING, UUID_V7_RE;
|
|
3764
4079
|
var init_codex_app = __esm({
|
|
3765
4080
|
"src/lib/codex-app.js"() {
|
|
3766
4081
|
"use strict";
|
|
@@ -3768,6 +4083,7 @@ var init_codex_app = __esm({
|
|
|
3768
4083
|
CODEX_DESKTOP_ORIGINATOR = "Codex Desktop";
|
|
3769
4084
|
FIND_CANVAS_APP = "ALL_TOOLS.filter((t) => t.name.endsWith('canvas_app'))";
|
|
3770
4085
|
VIEW_MISSING = "If no canvas_app tool exists, Kombai's view isn't set up in Codex yet: run `kombai mcp install codex` without asking, tell the user in one line, and continue in a new task (kombai skill opening). Show no link instead.";
|
|
4086
|
+
UUID_V7_RE = /^([0-9a-f]{8})-([0-9a-f]{4})-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
3771
4087
|
}
|
|
3772
4088
|
});
|
|
3773
4089
|
|
|
@@ -4270,7 +4586,7 @@ var require_supports_color = __commonJS({
|
|
|
4270
4586
|
"../../node_modules/supports-color/index.js"(exports, module) {
|
|
4271
4587
|
"use strict";
|
|
4272
4588
|
init_define_KOMBAI_TELEMETRY();
|
|
4273
|
-
var
|
|
4589
|
+
var os7 = __require("os");
|
|
4274
4590
|
var tty = __require("tty");
|
|
4275
4591
|
var hasFlag = require_has_flag();
|
|
4276
4592
|
var { env } = process;
|
|
@@ -4327,7 +4643,7 @@ var require_supports_color = __commonJS({
|
|
|
4327
4643
|
return min;
|
|
4328
4644
|
}
|
|
4329
4645
|
if (process.platform === "win32") {
|
|
4330
|
-
const osRelease =
|
|
4646
|
+
const osRelease = os7.release().split(".");
|
|
4331
4647
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
4332
4648
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
4333
4649
|
}
|
|
@@ -4921,11 +5237,11 @@ var require_is_docker = __commonJS({
|
|
|
4921
5237
|
"../../node_modules/is-docker/index.js"(exports, module) {
|
|
4922
5238
|
"use strict";
|
|
4923
5239
|
init_define_KOMBAI_TELEMETRY();
|
|
4924
|
-
var
|
|
5240
|
+
var fs22 = __require("fs");
|
|
4925
5241
|
var isDocker;
|
|
4926
5242
|
function hasDockerEnv() {
|
|
4927
5243
|
try {
|
|
4928
|
-
|
|
5244
|
+
fs22.statSync("/.dockerenv");
|
|
4929
5245
|
return true;
|
|
4930
5246
|
} catch (_) {
|
|
4931
5247
|
return false;
|
|
@@ -4933,7 +5249,7 @@ var require_is_docker = __commonJS({
|
|
|
4933
5249
|
}
|
|
4934
5250
|
function hasDockerCGroup() {
|
|
4935
5251
|
try {
|
|
4936
|
-
return
|
|
5252
|
+
return fs22.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
4937
5253
|
} catch (_) {
|
|
4938
5254
|
return false;
|
|
4939
5255
|
}
|
|
@@ -4952,21 +5268,21 @@ var require_is_wsl = __commonJS({
|
|
|
4952
5268
|
"../../node_modules/is-wsl/index.js"(exports, module) {
|
|
4953
5269
|
"use strict";
|
|
4954
5270
|
init_define_KOMBAI_TELEMETRY();
|
|
4955
|
-
var
|
|
4956
|
-
var
|
|
5271
|
+
var os7 = __require("os");
|
|
5272
|
+
var fs22 = __require("fs");
|
|
4957
5273
|
var isDocker = require_is_docker();
|
|
4958
5274
|
var isWsl3 = () => {
|
|
4959
5275
|
if (process.platform !== "linux") {
|
|
4960
5276
|
return false;
|
|
4961
5277
|
}
|
|
4962
|
-
if (
|
|
5278
|
+
if (os7.release().toLowerCase().includes("microsoft")) {
|
|
4963
5279
|
if (isDocker()) {
|
|
4964
5280
|
return false;
|
|
4965
5281
|
}
|
|
4966
5282
|
return true;
|
|
4967
5283
|
}
|
|
4968
5284
|
try {
|
|
4969
|
-
return
|
|
5285
|
+
return fs22.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isDocker() : false;
|
|
4970
5286
|
} catch (_) {
|
|
4971
5287
|
return false;
|
|
4972
5288
|
}
|
|
@@ -4987,7 +5303,7 @@ function defaults(val, def) {
|
|
|
4987
5303
|
return typeof val === "undefined" ? def : val;
|
|
4988
5304
|
}
|
|
4989
5305
|
async function delay(time3) {
|
|
4990
|
-
return new Promise((
|
|
5306
|
+
return new Promise((resolve2) => setTimeout(resolve2, time3));
|
|
4991
5307
|
}
|
|
4992
5308
|
function getPlatform() {
|
|
4993
5309
|
return import_is_wsl.default ? "wsl" : process.platform;
|
|
@@ -5030,15 +5346,15 @@ function toWSLPath(dir, fallback) {
|
|
|
5030
5346
|
return fallback;
|
|
5031
5347
|
}
|
|
5032
5348
|
}
|
|
5033
|
-
function getLocalAppDataPath(
|
|
5349
|
+
function getLocalAppDataPath(path28) {
|
|
5034
5350
|
const userRegExp = /\/mnt\/([a-z])\/Users\/([^\/:]+)\/AppData\//;
|
|
5035
|
-
const results = userRegExp.exec(
|
|
5351
|
+
const results = userRegExp.exec(path28) || [];
|
|
5036
5352
|
return `/mnt/${results[1]}/Users/${results[2]}/AppData/Local`;
|
|
5037
5353
|
}
|
|
5038
|
-
function getWSLLocalAppDataPath(
|
|
5354
|
+
function getWSLLocalAppDataPath(path28) {
|
|
5039
5355
|
const userRegExp = /\/([a-z])\/Users\/([^\/:]+)\/AppData\//;
|
|
5040
|
-
const results = userRegExp.exec(
|
|
5041
|
-
return toWSLPath(`${results[1]}:\\Users\\${results[2]}\\AppData\\Local`, getLocalAppDataPath(
|
|
5356
|
+
const results = userRegExp.exec(path28) || [];
|
|
5357
|
+
return toWSLPath(`${results[1]}:\\Users\\${results[2]}\\AppData\\Local`, getLocalAppDataPath(path28));
|
|
5042
5358
|
}
|
|
5043
5359
|
function makeUnixTmpDir() {
|
|
5044
5360
|
return childProcess.execSync("mktemp -d -t lighthouse.XXXXXXX").toString().trim();
|
|
@@ -5296,12 +5612,12 @@ var init_chrome_finder = __esm({
|
|
|
5296
5612
|
// ../../node_modules/chrome-launcher/dist/random-port.js
|
|
5297
5613
|
import { createServer } from "http";
|
|
5298
5614
|
function getRandomPort() {
|
|
5299
|
-
return new Promise((
|
|
5615
|
+
return new Promise((resolve2, reject) => {
|
|
5300
5616
|
const server = createServer();
|
|
5301
5617
|
server.listen(0);
|
|
5302
5618
|
server.once("listening", () => {
|
|
5303
5619
|
const { port } = server.address();
|
|
5304
|
-
server.close(() =>
|
|
5620
|
+
server.close(() => resolve2(port));
|
|
5305
5621
|
});
|
|
5306
5622
|
server.once("error", reject);
|
|
5307
5623
|
});
|
|
@@ -5585,7 +5901,7 @@ var init_chrome_launcher = __esm({
|
|
|
5585
5901
|
}
|
|
5586
5902
|
// resolves if ready, rejects otherwise
|
|
5587
5903
|
isDebuggerReady() {
|
|
5588
|
-
return new Promise((
|
|
5904
|
+
return new Promise((resolve2, reject) => {
|
|
5589
5905
|
const client = net.createConnection(this.port, "127.0.0.1");
|
|
5590
5906
|
client.once("error", (err2) => {
|
|
5591
5907
|
this.cleanup(client);
|
|
@@ -5593,14 +5909,14 @@ var init_chrome_launcher = __esm({
|
|
|
5593
5909
|
});
|
|
5594
5910
|
client.once("connect", () => {
|
|
5595
5911
|
this.cleanup(client);
|
|
5596
|
-
|
|
5912
|
+
resolve2();
|
|
5597
5913
|
});
|
|
5598
5914
|
});
|
|
5599
5915
|
}
|
|
5600
5916
|
// resolves when debugger is ready, rejects after 10 polls
|
|
5601
5917
|
waitUntilReady() {
|
|
5602
5918
|
const launcher = this;
|
|
5603
|
-
return new Promise((
|
|
5919
|
+
return new Promise((resolve2, reject) => {
|
|
5604
5920
|
let retries = 0;
|
|
5605
5921
|
let waitStatus = "Waiting for browser.";
|
|
5606
5922
|
const poll = () => {
|
|
@@ -5612,7 +5928,7 @@ var init_chrome_launcher = __esm({
|
|
|
5612
5928
|
lighthouse_logger_default.log("ChromeLauncher", waitStatus);
|
|
5613
5929
|
launcher.isDebuggerReady().then(() => {
|
|
5614
5930
|
lighthouse_logger_default.log("ChromeLauncher", waitStatus + `${lighthouse_logger_default.greenify(lighthouse_logger_default.tick)}`);
|
|
5615
|
-
|
|
5931
|
+
resolve2();
|
|
5616
5932
|
}).catch((err2) => {
|
|
5617
5933
|
if (retries > launcher.maxConnectionRetries) {
|
|
5618
5934
|
lighthouse_logger_default.error("ChromeLauncher", err2.message);
|
|
@@ -5686,8 +6002,8 @@ var require_windows = __commonJS({
|
|
|
5686
6002
|
init_define_KOMBAI_TELEMETRY();
|
|
5687
6003
|
module.exports = isexe;
|
|
5688
6004
|
isexe.sync = sync;
|
|
5689
|
-
var
|
|
5690
|
-
function checkPathExt(
|
|
6005
|
+
var fs22 = __require("fs");
|
|
6006
|
+
function checkPathExt(path28, options) {
|
|
5691
6007
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
5692
6008
|
if (!pathext) {
|
|
5693
6009
|
return true;
|
|
@@ -5698,25 +6014,25 @@ var require_windows = __commonJS({
|
|
|
5698
6014
|
}
|
|
5699
6015
|
for (var i = 0; i < pathext.length; i++) {
|
|
5700
6016
|
var p = pathext[i].toLowerCase();
|
|
5701
|
-
if (p &&
|
|
6017
|
+
if (p && path28.substr(-p.length).toLowerCase() === p) {
|
|
5702
6018
|
return true;
|
|
5703
6019
|
}
|
|
5704
6020
|
}
|
|
5705
6021
|
return false;
|
|
5706
6022
|
}
|
|
5707
|
-
function checkStat(stat,
|
|
6023
|
+
function checkStat(stat, path28, options) {
|
|
5708
6024
|
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
5709
6025
|
return false;
|
|
5710
6026
|
}
|
|
5711
|
-
return checkPathExt(
|
|
6027
|
+
return checkPathExt(path28, options);
|
|
5712
6028
|
}
|
|
5713
|
-
function isexe(
|
|
5714
|
-
|
|
5715
|
-
cb(er, er ? false : checkStat(stat,
|
|
6029
|
+
function isexe(path28, options, cb) {
|
|
6030
|
+
fs22.stat(path28, function(er, stat) {
|
|
6031
|
+
cb(er, er ? false : checkStat(stat, path28, options));
|
|
5716
6032
|
});
|
|
5717
6033
|
}
|
|
5718
|
-
function sync(
|
|
5719
|
-
return checkStat(
|
|
6034
|
+
function sync(path28, options) {
|
|
6035
|
+
return checkStat(fs22.statSync(path28), path28, options);
|
|
5720
6036
|
}
|
|
5721
6037
|
}
|
|
5722
6038
|
});
|
|
@@ -5727,14 +6043,14 @@ var require_mode = __commonJS({
|
|
|
5727
6043
|
init_define_KOMBAI_TELEMETRY();
|
|
5728
6044
|
module.exports = isexe;
|
|
5729
6045
|
isexe.sync = sync;
|
|
5730
|
-
var
|
|
5731
|
-
function isexe(
|
|
5732
|
-
|
|
6046
|
+
var fs22 = __require("fs");
|
|
6047
|
+
function isexe(path28, options, cb) {
|
|
6048
|
+
fs22.stat(path28, function(er, stat) {
|
|
5733
6049
|
cb(er, er ? false : checkStat(stat, options));
|
|
5734
6050
|
});
|
|
5735
6051
|
}
|
|
5736
|
-
function sync(
|
|
5737
|
-
return checkStat(
|
|
6052
|
+
function sync(path28, options) {
|
|
6053
|
+
return checkStat(fs22.statSync(path28), options);
|
|
5738
6054
|
}
|
|
5739
6055
|
function checkStat(stat, options) {
|
|
5740
6056
|
return stat.isFile() && checkMode(stat, options);
|
|
@@ -5759,7 +6075,7 @@ var require_mode = __commonJS({
|
|
|
5759
6075
|
var require_isexe = __commonJS({
|
|
5760
6076
|
"../../node_modules/isexe/index.js"(exports, module) {
|
|
5761
6077
|
init_define_KOMBAI_TELEMETRY();
|
|
5762
|
-
var
|
|
6078
|
+
var fs22 = __require("fs");
|
|
5763
6079
|
var core;
|
|
5764
6080
|
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
5765
6081
|
core = require_windows();
|
|
@@ -5768,7 +6084,7 @@ var require_isexe = __commonJS({
|
|
|
5768
6084
|
}
|
|
5769
6085
|
module.exports = isexe;
|
|
5770
6086
|
isexe.sync = sync;
|
|
5771
|
-
function isexe(
|
|
6087
|
+
function isexe(path28, options, cb) {
|
|
5772
6088
|
if (typeof options === "function") {
|
|
5773
6089
|
cb = options;
|
|
5774
6090
|
options = {};
|
|
@@ -5777,17 +6093,17 @@ var require_isexe = __commonJS({
|
|
|
5777
6093
|
if (typeof Promise !== "function") {
|
|
5778
6094
|
throw new TypeError("callback not provided");
|
|
5779
6095
|
}
|
|
5780
|
-
return new Promise(function(
|
|
5781
|
-
isexe(
|
|
6096
|
+
return new Promise(function(resolve2, reject) {
|
|
6097
|
+
isexe(path28, options || {}, function(er, is) {
|
|
5782
6098
|
if (er) {
|
|
5783
6099
|
reject(er);
|
|
5784
6100
|
} else {
|
|
5785
|
-
|
|
6101
|
+
resolve2(is);
|
|
5786
6102
|
}
|
|
5787
6103
|
});
|
|
5788
6104
|
});
|
|
5789
6105
|
}
|
|
5790
|
-
core(
|
|
6106
|
+
core(path28, options || {}, function(er, is) {
|
|
5791
6107
|
if (er) {
|
|
5792
6108
|
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
5793
6109
|
er = null;
|
|
@@ -5797,9 +6113,9 @@ var require_isexe = __commonJS({
|
|
|
5797
6113
|
cb(er, is);
|
|
5798
6114
|
});
|
|
5799
6115
|
}
|
|
5800
|
-
function sync(
|
|
6116
|
+
function sync(path28, options) {
|
|
5801
6117
|
try {
|
|
5802
|
-
return core.sync(
|
|
6118
|
+
return core.sync(path28, options || {});
|
|
5803
6119
|
} catch (er) {
|
|
5804
6120
|
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
5805
6121
|
return false;
|
|
@@ -5816,7 +6132,7 @@ var require_which = __commonJS({
|
|
|
5816
6132
|
"../../node_modules/which/which.js"(exports, module) {
|
|
5817
6133
|
init_define_KOMBAI_TELEMETRY();
|
|
5818
6134
|
var isWindows3 = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
5819
|
-
var
|
|
6135
|
+
var path28 = __require("path");
|
|
5820
6136
|
var COLON = isWindows3 ? ";" : ":";
|
|
5821
6137
|
var isexe = require_isexe();
|
|
5822
6138
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
@@ -5849,27 +6165,27 @@ var require_which = __commonJS({
|
|
|
5849
6165
|
opt = {};
|
|
5850
6166
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
5851
6167
|
const found = [];
|
|
5852
|
-
const step = (i) => new Promise((
|
|
6168
|
+
const step = (i) => new Promise((resolve2, reject) => {
|
|
5853
6169
|
if (i === pathEnv.length)
|
|
5854
|
-
return opt.all && found.length ?
|
|
6170
|
+
return opt.all && found.length ? resolve2(found) : reject(getNotFoundError(cmd));
|
|
5855
6171
|
const ppRaw = pathEnv[i];
|
|
5856
6172
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
5857
|
-
const pCmd =
|
|
6173
|
+
const pCmd = path28.join(pathPart, cmd);
|
|
5858
6174
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
5859
|
-
|
|
6175
|
+
resolve2(subStep(p, i, 0));
|
|
5860
6176
|
});
|
|
5861
|
-
const subStep = (p, i, ii) => new Promise((
|
|
6177
|
+
const subStep = (p, i, ii) => new Promise((resolve2, reject) => {
|
|
5862
6178
|
if (ii === pathExt.length)
|
|
5863
|
-
return
|
|
6179
|
+
return resolve2(step(i + 1));
|
|
5864
6180
|
const ext = pathExt[ii];
|
|
5865
6181
|
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
5866
6182
|
if (!er && is) {
|
|
5867
6183
|
if (opt.all)
|
|
5868
6184
|
found.push(p + ext);
|
|
5869
6185
|
else
|
|
5870
|
-
return
|
|
6186
|
+
return resolve2(p + ext);
|
|
5871
6187
|
}
|
|
5872
|
-
return
|
|
6188
|
+
return resolve2(subStep(p, i, ii + 1));
|
|
5873
6189
|
});
|
|
5874
6190
|
});
|
|
5875
6191
|
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
@@ -5881,7 +6197,7 @@ var require_which = __commonJS({
|
|
|
5881
6197
|
for (let i = 0; i < pathEnv.length; i++) {
|
|
5882
6198
|
const ppRaw = pathEnv[i];
|
|
5883
6199
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
5884
|
-
const pCmd =
|
|
6200
|
+
const pCmd = path28.join(pathPart, cmd);
|
|
5885
6201
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
5886
6202
|
for (let j = 0; j < pathExt.length; j++) {
|
|
5887
6203
|
const cur = p + pathExt[j];
|
|
@@ -5913,8 +6229,8 @@ import { existsSync } from "fs";
|
|
|
5913
6229
|
import path10 from "path";
|
|
5914
6230
|
function getEdgeLinux(name) {
|
|
5915
6231
|
try {
|
|
5916
|
-
let
|
|
5917
|
-
return
|
|
6232
|
+
let path28 = import_which.default.sync(name);
|
|
6233
|
+
return path28;
|
|
5918
6234
|
} catch (e) {
|
|
5919
6235
|
}
|
|
5920
6236
|
return null;
|
|
@@ -7213,16 +7529,16 @@ async function launch(ctx, browserPath, options) {
|
|
|
7213
7529
|
exited,
|
|
7214
7530
|
send(method, params = {}, sessionId) {
|
|
7215
7531
|
const id = nextId++;
|
|
7216
|
-
const reply = new Promise((
|
|
7532
|
+
const reply = new Promise((resolve2, reject) => pending.set(id, { resolve: resolve2, reject }));
|
|
7217
7533
|
out.write(`${JSON.stringify({ id, method, params, sessionId })}\0`);
|
|
7218
7534
|
return Promise.race([reply, exited]);
|
|
7219
7535
|
},
|
|
7220
7536
|
once(method, sessionId) {
|
|
7221
|
-
const event = new Promise((
|
|
7537
|
+
const event = new Promise((resolve2) => {
|
|
7222
7538
|
const fn = (msg) => {
|
|
7223
7539
|
if (msg.method === method && (!sessionId || msg.sessionId === sessionId)) {
|
|
7224
7540
|
listeners.splice(listeners.indexOf(fn), 1);
|
|
7225
|
-
|
|
7541
|
+
resolve2(msg.params);
|
|
7226
7542
|
}
|
|
7227
7543
|
};
|
|
7228
7544
|
listeners.push(fn);
|
|
@@ -7380,7 +7696,7 @@ async function startProxy() {
|
|
|
7380
7696
|
sockets.add(socket);
|
|
7381
7697
|
socket.on("close", () => sockets.delete(socket));
|
|
7382
7698
|
});
|
|
7383
|
-
await new Promise((
|
|
7699
|
+
await new Promise((resolve2) => server.listen(0, "127.0.0.1", () => resolve2(void 0)));
|
|
7384
7700
|
const { port } = (
|
|
7385
7701
|
/** @type {net.AddressInfo} */
|
|
7386
7702
|
server.address()
|
|
@@ -7394,9 +7710,9 @@ async function startProxy() {
|
|
|
7394
7710
|
pages.set(pathname, html);
|
|
7395
7711
|
return `http://${PAGE_HOST}${pathname}`;
|
|
7396
7712
|
},
|
|
7397
|
-
close: () => new Promise((
|
|
7713
|
+
close: () => new Promise((resolve2) => {
|
|
7398
7714
|
for (const socket of sockets) socket.destroy();
|
|
7399
|
-
server.close(() =>
|
|
7715
|
+
server.close(() => resolve2(void 0));
|
|
7400
7716
|
})
|
|
7401
7717
|
};
|
|
7402
7718
|
}
|
|
@@ -7534,8 +7850,8 @@ async function openRender(ctx, {
|
|
|
7534
7850
|
async capturePng(cutoff) {
|
|
7535
7851
|
if (cutoff.expired()) return { png: null, status: "cut_off" };
|
|
7536
7852
|
let timer;
|
|
7537
|
-
const cut = new Promise((
|
|
7538
|
-
timer = setTimeout(() =>
|
|
7853
|
+
const cut = new Promise((resolve2) => {
|
|
7854
|
+
timer = setTimeout(() => resolve2(null), cutoff.remaining());
|
|
7539
7855
|
});
|
|
7540
7856
|
const shot = s("Page.captureScreenshot", { format: "png", captureBeyondViewport: true, clip }).catch(
|
|
7541
7857
|
() => null
|
|
@@ -7564,8 +7880,8 @@ async function openRender(ctx, {
|
|
|
7564
7880
|
}
|
|
7565
7881
|
async function by(promise2, at) {
|
|
7566
7882
|
let timer;
|
|
7567
|
-
const late2 = new Promise((
|
|
7568
|
-
timer = setTimeout(() =>
|
|
7883
|
+
const late2 = new Promise((resolve2) => {
|
|
7884
|
+
timer = setTimeout(() => resolve2(LATE), Math.max(0, at - Date.now()));
|
|
7569
7885
|
});
|
|
7570
7886
|
try {
|
|
7571
7887
|
return (
|
|
@@ -7592,7 +7908,7 @@ async function waitForReady(send, readyAt, willSignal) {
|
|
|
7592
7908
|
if (state.settled && state.prepared && !state.declared && !willSignal) return "fonts_and_images";
|
|
7593
7909
|
const left = readyAt - Date.now();
|
|
7594
7910
|
if (left <= 0) return "timeout";
|
|
7595
|
-
await new Promise((
|
|
7911
|
+
await new Promise((resolve2) => setTimeout(resolve2, Math.min(READY_POLL_MS, left)));
|
|
7596
7912
|
}
|
|
7597
7913
|
}
|
|
7598
7914
|
var DEFAULT_RENDER_WIDTH, RENDER_MS, READY_MS, READY_POLL_MS, MAX_HEIGHT, JPEG_MAX_BYTES, PNG_MAX_BYTES, JPEG_QUALITIES, RenderFailure, READY_WATCH, SIGNALS, READY_STATE, SETTLE, LATE;
|
|
@@ -9698,168 +10014,35 @@ var init_ds = __esm({
|
|
|
9698
10014
|
}
|
|
9699
10015
|
});
|
|
9700
10016
|
|
|
9701
|
-
// ../shared/src/mcp/chatMcpRegistrationArg.ts
|
|
9702
|
-
var CHAT_MCP_REGISTRATION_ARG;
|
|
9703
|
-
var init_chatMcpRegistrationArg = __esm({
|
|
9704
|
-
"../shared/src/mcp/chatMcpRegistrationArg.ts"() {
|
|
9705
|
-
"use strict";
|
|
9706
|
-
init_define_KOMBAI_TELEMETRY();
|
|
9707
|
-
CHAT_MCP_REGISTRATION_ARG = "--registration";
|
|
9708
|
-
}
|
|
9709
|
-
});
|
|
9710
|
-
|
|
9711
|
-
// ../shared/src/mcp/codexKombaiEntry.ts
|
|
9712
|
-
function kombaiCliMcpEntry(platform2) {
|
|
9713
|
-
if (platform2 === "win32") {
|
|
9714
|
-
const [shell, ...shellArgs] = WINDOWS_SHELL_WRAPPER;
|
|
9715
|
-
return { command: shell, args: [...shellArgs, KOMBAI_CLI_MCP_COMMAND, ...KOMBAI_CLI_MCP_ARGS] };
|
|
9716
|
-
}
|
|
9717
|
-
return { command: KOMBAI_CLI_MCP_COMMAND, args: [...KOMBAI_CLI_MCP_ARGS] };
|
|
9718
|
-
}
|
|
9719
|
-
function tomlString(value) {
|
|
9720
|
-
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
9721
|
-
}
|
|
9722
|
-
function codexKombaiBlock(platform2) {
|
|
9723
|
-
const entry = kombaiCliMcpEntry(platform2);
|
|
9724
|
-
return `[mcp_servers.${KOMBAI_MCP_KEY}]
|
|
9725
|
-
command = ${tomlString(entry.command)}
|
|
9726
|
-
args = [${entry.args.map(tomlString).join(", ")}]
|
|
9727
|
-
`;
|
|
9728
|
-
}
|
|
9729
|
-
function bracketBalance(line) {
|
|
9730
|
-
let balance = 0;
|
|
9731
|
-
let quote = null;
|
|
9732
|
-
for (let i = 0; i < line.length; i++) {
|
|
9733
|
-
const c = line[i];
|
|
9734
|
-
if (quote) {
|
|
9735
|
-
if (c === "\\" && quote === '"') i++;
|
|
9736
|
-
else if (c === quote) quote = null;
|
|
9737
|
-
} else if (c === '"' || c === "'") quote = c;
|
|
9738
|
-
else if (c === "#") break;
|
|
9739
|
-
else if (c === "[") balance++;
|
|
9740
|
-
else if (c === "]") balance--;
|
|
9741
|
-
}
|
|
9742
|
-
return balance;
|
|
9743
|
-
}
|
|
9744
|
-
function tomlLines(text) {
|
|
9745
|
-
const lines = [];
|
|
9746
|
-
let depth = 0;
|
|
9747
|
-
let multiline = null;
|
|
9748
|
-
for (const line of text.split(/\r?\n/)) {
|
|
9749
|
-
if (multiline) {
|
|
9750
|
-
if (line.split(multiline).length % 2 === 0) multiline = null;
|
|
9751
|
-
lines.push({ line, header: false });
|
|
9752
|
-
continue;
|
|
9753
|
-
}
|
|
9754
|
-
const header = depth === 0 && TOML_HEADER_LINE_RE.test(line);
|
|
9755
|
-
lines.push({ line, header });
|
|
9756
|
-
if (header) continue;
|
|
9757
|
-
depth = Math.max(0, depth + bracketBalance(line));
|
|
9758
|
-
multiline = MULTILINE_QUOTES.find((quotes) => line.split(quotes).length % 2 === 0) ?? null;
|
|
9759
|
-
}
|
|
9760
|
-
return lines;
|
|
9761
|
-
}
|
|
9762
|
-
function mcpServersTableDefinesKombai(text) {
|
|
9763
|
-
let inMcpServers = false;
|
|
9764
|
-
for (const { line, header } of tomlLines(text)) {
|
|
9765
|
-
if (header) inMcpServers = MCP_SERVERS_HEADER_RE.test(line);
|
|
9766
|
-
else if (inMcpServers && KOMBAI_KEY_LINE_RE.test(line)) return true;
|
|
9767
|
-
}
|
|
9768
|
-
return false;
|
|
9769
|
-
}
|
|
9770
|
-
function codexMcpServersInline(content) {
|
|
9771
|
-
for (const { line, header } of tomlLines(withoutBom(content))) {
|
|
9772
|
-
if (header) return false;
|
|
9773
|
-
if (MCP_SERVERS_KEY_LINE_RE.test(line)) return true;
|
|
9774
|
-
}
|
|
9775
|
-
return false;
|
|
9776
|
-
}
|
|
9777
|
-
function codexKombaiEntryKind(content, platform2) {
|
|
9778
|
-
const text = withoutBom(content);
|
|
9779
|
-
const blocks = text.match(KOMBAI_TOML_BLOCK_RE);
|
|
9780
|
-
if (!blocks) return mcpServersTableDefinesKombai(text) ? "foreign" /* Foreign */ : "none" /* None */;
|
|
9781
|
-
if (text.replace(/\r\n/g, "\n").includes(codexKombaiBlock(platform2))) return "cli" /* Cli */;
|
|
9782
|
-
const block = blocks.join("\n");
|
|
9783
|
-
return block.includes(`"${CHAT_MCP_REGISTRATION_ARG}"`) || LEGACY_LAUNCHER_RE.test(block) ? "legacy" /* Legacy */ : "foreign" /* Foreign */;
|
|
9784
|
-
}
|
|
9785
|
-
function codexKombaiEntryDisabled(content) {
|
|
9786
|
-
const blocks = withoutBom(content).match(KOMBAI_TOML_BLOCK_RE) ?? [];
|
|
9787
|
-
return blocks.some((block) => {
|
|
9788
|
-
const lines = tomlLines(block);
|
|
9789
|
-
const own = lines.findIndex((entry) => entry.header);
|
|
9790
|
-
const sub = lines.findIndex((entry, index) => index > own && entry.header);
|
|
9791
|
-
return lines.slice(own + 1, sub === -1 ? void 0 : sub).some(({ line }) => /^[ \t]*enabled[ \t]*=[ \t]*false\b/.test(line));
|
|
9792
|
-
});
|
|
9793
|
-
}
|
|
9794
|
-
function withoutCodexKombaiBlock(content) {
|
|
9795
|
-
const bom = content.startsWith(BOM) ? BOM : "";
|
|
9796
|
-
const text = withoutBom(content);
|
|
9797
|
-
let stripped = text.replace(KOMBAI_TOML_BLOCK_RE, "").trimEnd();
|
|
9798
|
-
if (stripped === text.trimEnd()) return null;
|
|
9799
|
-
if (KOMBAI_TOML_AT_START_RE.test(text)) stripped = stripped.replace(/^\r?\n/, "");
|
|
9800
|
-
if (stripped.length === 0) return "";
|
|
9801
|
-
const crlf = stripped.includes("\n") ? /\r\n[^\n]*$/.test(stripped) : text.includes("\r\n");
|
|
9802
|
-
return bom + stripped + (crlf ? "\r\n" : "\n");
|
|
9803
|
-
}
|
|
9804
|
-
function withCodexKombaiBlock(content, platform2) {
|
|
9805
|
-
const bom = content.startsWith(BOM) ? BOM : "";
|
|
9806
|
-
const text = withoutBom(content);
|
|
9807
|
-
const rest = withoutBom(withoutCodexKombaiBlock(text) ?? text).trimEnd();
|
|
9808
|
-
const block = codexKombaiBlock(platform2);
|
|
9809
|
-
if (rest.length === 0) return bom + block;
|
|
9810
|
-
const eol = text.includes("\r\n") ? "\r\n" : "\n";
|
|
9811
|
-
return `${bom}${rest}${eol}${eol}${eol === "\n" ? block : block.replace(/\n/g, eol)}`;
|
|
9812
|
-
}
|
|
9813
|
-
var KOMBAI_MCP_KEY, KOMBAI_CLI_MCP_COMMAND, KOMBAI_CLI_MCP_ARGS, WINDOWS_SHELL_WRAPPER, LEGACY_LAUNCHER_RE, KOMBAI_TOML_TABLE, TOML_OTHER_HEADER, KOMBAI_TOML_BLOCK_RE, KOMBAI_TOML_AT_START_RE, BOM, withoutBom, TOML_HEADER_LINE_RE, MULTILINE_QUOTES, MCP_SERVERS_HEADER_RE, KOMBAI_KEY_LINE_RE, MCP_SERVERS_KEY_LINE_RE;
|
|
9814
|
-
var init_codexKombaiEntry = __esm({
|
|
9815
|
-
"../shared/src/mcp/codexKombaiEntry.ts"() {
|
|
9816
|
-
"use strict";
|
|
9817
|
-
init_define_KOMBAI_TELEMETRY();
|
|
9818
|
-
init_chatMcpRegistrationArg();
|
|
9819
|
-
KOMBAI_MCP_KEY = "kombai";
|
|
9820
|
-
KOMBAI_CLI_MCP_COMMAND = "npx";
|
|
9821
|
-
KOMBAI_CLI_MCP_ARGS = ["-y", "@kombai/cli@latest", "mcp"];
|
|
9822
|
-
WINDOWS_SHELL_WRAPPER = ["cmd", "/c"];
|
|
9823
|
-
LEGACY_LAUNCHER_RE = /[\\/]+\.kombai[\\/]+bin[\\/]+mcp-gateway(?:\.cmd)?(?=$|")/;
|
|
9824
|
-
KOMBAI_TOML_TABLE = String.raw`[ \t]*mcp_servers[ \t]*\.[ \t]*(?:kombai|"kombai"|'kombai')[ \t]*`;
|
|
9825
|
-
TOML_OTHER_HEADER = String.raw`[ \t]*\[(?!${KOMBAI_TOML_TABLE}(?:\.|\]))[^\r\n]*\][ \t]*(?:#[^\r\n]*)?(?=\r?\n|$)`;
|
|
9826
|
-
KOMBAI_TOML_BLOCK_RE = new RegExp(
|
|
9827
|
-
String.raw`(?:^|\r?\n)[ \t]*\[${KOMBAI_TOML_TABLE}\][\s\S]*?(?=((?:\r?\n[ \t]*(?=\r?\n))*))\1` + String.raw`(?=(?:\r?\n[ \t]*(?:#[^\r\n]*)?)*(?:\r?\n${TOML_OTHER_HEADER}|$))`,
|
|
9828
|
-
"g"
|
|
9829
|
-
);
|
|
9830
|
-
KOMBAI_TOML_AT_START_RE = new RegExp(String.raw`^[ \t]*\[${KOMBAI_TOML_TABLE}\]`);
|
|
9831
|
-
BOM = "\uFEFF";
|
|
9832
|
-
withoutBom = (content) => content.startsWith(BOM) ? content.slice(BOM.length) : content;
|
|
9833
|
-
TOML_HEADER_LINE_RE = /^[ \t]*\[/;
|
|
9834
|
-
MULTILINE_QUOTES = ['"""', "'''"];
|
|
9835
|
-
MCP_SERVERS_HEADER_RE = /^[ \t]*\[[ \t]*(?:mcp_servers|"mcp_servers"|'mcp_servers')[ \t]*\][ \t]*(?:#.*)?$/;
|
|
9836
|
-
KOMBAI_KEY_LINE_RE = /^[ \t]*(?:kombai|"kombai"|'kombai')[ \t]*[.=]/;
|
|
9837
|
-
MCP_SERVERS_KEY_LINE_RE = /^[ \t]*(?:mcp_servers|"mcp_servers"|'mcp_servers')[ \t]*[.=]/;
|
|
9838
|
-
}
|
|
9839
|
-
});
|
|
9840
|
-
|
|
9841
10017
|
// src/mcp/install.js
|
|
10018
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
9842
10019
|
import fs16 from "node:fs/promises";
|
|
9843
10020
|
import path16 from "node:path";
|
|
9844
10021
|
function codexHomeOf(env, osHome) {
|
|
9845
10022
|
return env.CODEX_HOME ? path16.resolve(env.CODEX_HOME) : path16.join(osHome, ".codex");
|
|
9846
10023
|
}
|
|
9847
|
-
async function
|
|
10024
|
+
async function readClientConfig(clientHome, file2, client) {
|
|
9848
10025
|
try {
|
|
9849
|
-
await fs16.stat(
|
|
10026
|
+
await fs16.stat(clientHome);
|
|
9850
10027
|
} catch (error2) {
|
|
9851
10028
|
if (!isErrno(error2, "ENOENT")) throw error2;
|
|
9852
10029
|
throw new CliError(
|
|
9853
10030
|
"CLI_MCP_CLIENT_NOT_FOUND",
|
|
9854
|
-
|
|
9855
|
-
{ details: { path:
|
|
10031
|
+
`${client} hasn't created ${clientHome} yet: open ${client} once, then run this again.`,
|
|
10032
|
+
{ details: { path: clientHome } }
|
|
9856
10033
|
);
|
|
9857
10034
|
}
|
|
9858
|
-
const file2 = codexConfigOf(codexHome);
|
|
9859
10035
|
try {
|
|
9860
10036
|
const target = await fs16.realpath(file2);
|
|
9861
|
-
const
|
|
9862
|
-
return {
|
|
10037
|
+
const stat = await fs16.stat(target);
|
|
10038
|
+
return {
|
|
10039
|
+
file: file2,
|
|
10040
|
+
target,
|
|
10041
|
+
linked: target !== file2,
|
|
10042
|
+
content: await fs16.readFile(target, "utf8"),
|
|
10043
|
+
mode: stat.mode & 511,
|
|
10044
|
+
changedAt: stat.mtimeMs
|
|
10045
|
+
};
|
|
9863
10046
|
} catch (error2) {
|
|
9864
10047
|
if (!isErrno(error2, "ENOENT")) throw error2;
|
|
9865
10048
|
let link = null;
|
|
@@ -9869,7 +10052,7 @@ async function readConfig2(codexHome) {
|
|
|
9869
10052
|
if (!isErrno(lstatError, "ENOENT")) throw lstatError;
|
|
9870
10053
|
}
|
|
9871
10054
|
if (link?.isSymbolicLink()) throw brokenLink(file2, path16.resolve(path16.dirname(file2), await fs16.readlink(file2)));
|
|
9872
|
-
return { file: file2, target: file2, linked: false, content: "", mode: NEW_CONFIG_MODE };
|
|
10055
|
+
return { file: file2, target: file2, linked: false, content: "", mode: NEW_CONFIG_MODE, changedAt: 0 };
|
|
9873
10056
|
}
|
|
9874
10057
|
}
|
|
9875
10058
|
function brokenLink(file2, target) {
|
|
@@ -9894,33 +10077,76 @@ function inlineMcpServers(file2) {
|
|
|
9894
10077
|
}
|
|
9895
10078
|
);
|
|
9896
10079
|
}
|
|
9897
|
-
function foreignEntry(file2) {
|
|
10080
|
+
function foreignEntry(file2, entry = "[mcp_servers.kombai]") {
|
|
9898
10081
|
return new CliError(
|
|
9899
10082
|
"CLI_MCP_ENTRY_FOREIGN",
|
|
9900
10083
|
`${file2} already has a kombai MCP server that Kombai did not add, so it was left as it is.`,
|
|
9901
10084
|
{
|
|
9902
10085
|
exit: Exit.REFUSED,
|
|
9903
|
-
next: `Ask the user to remove or rename the
|
|
10086
|
+
next: `Ask the user to remove or rename the ${entry} entry in ${file2}, then run this again.`,
|
|
9904
10087
|
details: { path: file2 }
|
|
9905
10088
|
}
|
|
9906
10089
|
);
|
|
9907
10090
|
}
|
|
9908
|
-
async function installCodexEntry(codexHome, platform2) {
|
|
9909
|
-
const { file: file2, target, content, mode } = await
|
|
9910
|
-
|
|
10091
|
+
async function installCodexEntry(codexHome, platform2, cliPackage = KOMBAI_CLI_PACKAGE) {
|
|
10092
|
+
const { file: file2, target, content, mode, changedAt } = await readClientConfig(
|
|
10093
|
+
codexHome,
|
|
10094
|
+
codexConfigOf(codexHome),
|
|
10095
|
+
"Codex"
|
|
10096
|
+
);
|
|
10097
|
+
const done = (outcome, text, at) => ({
|
|
10098
|
+
outcome,
|
|
10099
|
+
disabled: codexKombaiEntryDisabled(text),
|
|
10100
|
+
block: codexKombaiBlockText(text),
|
|
10101
|
+
configChangedAt: at
|
|
10102
|
+
});
|
|
10103
|
+
const kind = codexKombaiEntryKind(content);
|
|
9911
10104
|
if (kind === "foreign" /* Foreign */) throw foreignEntry(file2);
|
|
9912
|
-
if (kind === "cli" /* Cli */)
|
|
10105
|
+
if (kind === "cli" /* Cli */) {
|
|
10106
|
+
const current = codexKombaiEntryPackage(content);
|
|
10107
|
+
if (current === null || !kombaiCliSwitchable(current, cliPackage)) {
|
|
10108
|
+
return done(InstallOutcome.Already, content, changedAt);
|
|
10109
|
+
}
|
|
10110
|
+
const next2 = withCodexKombaiCommand(content, platform2, cliPackage);
|
|
10111
|
+
await writeFileAtomic(target, next2, { mode });
|
|
10112
|
+
return done(InstallOutcome.Replaced, next2, Date.now());
|
|
10113
|
+
}
|
|
9913
10114
|
if (codexMcpServersInline(content)) throw inlineMcpServers(file2);
|
|
9914
|
-
|
|
9915
|
-
|
|
10115
|
+
const next = withCodexKombaiBlock(content, platform2, cliPackage);
|
|
10116
|
+
await writeFileAtomic(target, next, { mode });
|
|
10117
|
+
return done(kind === "legacy" /* Legacy */ ? InstallOutcome.Replaced : InstallOutcome.Added, next, Date.now());
|
|
10118
|
+
}
|
|
10119
|
+
async function entryChangedAt(home, client, config2, install) {
|
|
10120
|
+
if (install.block === null) return null;
|
|
10121
|
+
const key = ENTRY_RECORDS[client];
|
|
10122
|
+
const hash2 = blockHash(install.block);
|
|
10123
|
+
const known = (await readConfig(home))[key]?.[config2];
|
|
10124
|
+
if (install.outcome === InstallOutcome.Already && known?.hash === hash2 && typeof known.at === "number") {
|
|
10125
|
+
return known.at;
|
|
10126
|
+
}
|
|
10127
|
+
const at = install.configChangedAt;
|
|
10128
|
+
await updateConfig(home, (stored) => ({ ...stored, [key]: { ...stored[key], [config2]: { hash: hash2, at } } }));
|
|
10129
|
+
return at;
|
|
10130
|
+
}
|
|
10131
|
+
async function forgetEntry(home, client, config2) {
|
|
10132
|
+
const key = ENTRY_RECORDS[client];
|
|
10133
|
+
if (!(await readConfig(home))[key]?.[config2]) return;
|
|
10134
|
+
await updateConfig(home, (stored) => {
|
|
10135
|
+
const { [config2]: _gone, ...rest } = stored[key] ?? {};
|
|
10136
|
+
return { ...stored, [key]: rest };
|
|
10137
|
+
});
|
|
9916
10138
|
}
|
|
9917
|
-
async function
|
|
9918
|
-
|
|
9919
|
-
|
|
10139
|
+
async function codexEntryPackage(codexHome) {
|
|
10140
|
+
try {
|
|
10141
|
+
return codexKombaiEntryPackage(await fs16.readFile(codexConfigOf(codexHome), "utf8"));
|
|
10142
|
+
} catch (error2) {
|
|
10143
|
+
if (["ENOENT", "ENOTDIR", "EACCES", "EPERM"].some((code2) => isErrno(error2, code2))) return null;
|
|
10144
|
+
throw error2;
|
|
10145
|
+
}
|
|
9920
10146
|
}
|
|
9921
|
-
async function uninstallCodexEntry(codexHome
|
|
9922
|
-
const { file: file2, target, linked, content, mode } = await
|
|
9923
|
-
const kind = codexKombaiEntryKind(content
|
|
10147
|
+
async function uninstallCodexEntry(codexHome) {
|
|
10148
|
+
const { file: file2, target, linked, content, mode } = await readClientConfig(codexHome, codexConfigOf(codexHome), "Codex");
|
|
10149
|
+
const kind = codexKombaiEntryKind(content);
|
|
9924
10150
|
if (kind === "foreign" /* Foreign */) throw foreignEntry(file2);
|
|
9925
10151
|
if (kind === "none" /* None */) return UninstallOutcome.Absent;
|
|
9926
10152
|
const rest = withoutCodexKombaiBlock(content);
|
|
@@ -9929,7 +10155,7 @@ async function uninstallCodexEntry(codexHome, platform2) {
|
|
|
9929
10155
|
else await writeFileAtomic(target, rest, { mode });
|
|
9930
10156
|
return UninstallOutcome.Removed;
|
|
9931
10157
|
}
|
|
9932
|
-
var McpClient, InstallOutcome, UninstallOutcome, CODEX_CONFIG, NEW_CONFIG_MODE, codexConfigOf;
|
|
10158
|
+
var McpClient, InstallOutcome, UninstallOutcome, CODEX_CONFIG, NEW_CONFIG_MODE, codexConfigOf, blockHash, ENTRY_RECORDS;
|
|
9933
10159
|
var init_install = __esm({
|
|
9934
10160
|
"src/mcp/install.js"() {
|
|
9935
10161
|
"use strict";
|
|
@@ -9937,13 +10163,17 @@ var init_install = __esm({
|
|
|
9937
10163
|
init_codexKombaiEntry();
|
|
9938
10164
|
init_fsx();
|
|
9939
10165
|
init_output();
|
|
9940
|
-
|
|
10166
|
+
init_store();
|
|
10167
|
+
McpClient = Object.freeze({ Codex: "codex", ClaudeCode: "claude-code" });
|
|
9941
10168
|
InstallOutcome = Object.freeze({
|
|
9942
10169
|
/** There was no `kombai` entry: the CLI's block was added. */
|
|
9943
10170
|
Added: "added",
|
|
9944
10171
|
/** The CLI's block was there already: nothing was written. */
|
|
9945
10172
|
Already: "already",
|
|
9946
|
-
/**
|
|
10173
|
+
/**
|
|
10174
|
+
* An older Kombai build's entry was there, and the CLI's block took its place; or the CLI's entry on another
|
|
10175
|
+
* channel (a release's where a beta runs, say), which now runs this build (`kombaiCliSwitchable`).
|
|
10176
|
+
*/
|
|
9947
10177
|
Replaced: "replaced"
|
|
9948
10178
|
});
|
|
9949
10179
|
UninstallOutcome = Object.freeze({
|
|
@@ -9954,6 +10184,222 @@ var init_install = __esm({
|
|
|
9954
10184
|
CODEX_CONFIG = "config.toml";
|
|
9955
10185
|
NEW_CONFIG_MODE = 384;
|
|
9956
10186
|
codexConfigOf = (codexHome) => path16.join(codexHome, CODEX_CONFIG);
|
|
10187
|
+
blockHash = (block) => createHash3("sha256").update(block).digest("hex");
|
|
10188
|
+
ENTRY_RECORDS = { [McpClient.Codex]: "codexEntries", [McpClient.ClaudeCode]: "claudeCodeEntries" };
|
|
10189
|
+
}
|
|
10190
|
+
});
|
|
10191
|
+
|
|
10192
|
+
// ../shared/src/mcp/jsonKombaiEntry.ts
|
|
10193
|
+
import * as path17 from "node:path";
|
|
10194
|
+
function isRecord3(value) {
|
|
10195
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
10196
|
+
}
|
|
10197
|
+
function commandOf(entry) {
|
|
10198
|
+
if (!isRecord3(entry)) return null;
|
|
10199
|
+
if (entry.type !== void 0 && entry.type !== STDIO) return null;
|
|
10200
|
+
const { command, args } = entry;
|
|
10201
|
+
if (typeof command !== "string" || !Array.isArray(args) || !args.every((arg) => typeof arg === "string")) {
|
|
10202
|
+
return null;
|
|
10203
|
+
}
|
|
10204
|
+
return { command, args };
|
|
10205
|
+
}
|
|
10206
|
+
function claudeCodeKombaiEntry(platform2, cliPackage = KOMBAI_CLI_PACKAGE) {
|
|
10207
|
+
return { type: STDIO, ...kombaiCliMcpEntry(platform2, cliPackage), env: {} };
|
|
10208
|
+
}
|
|
10209
|
+
function jsonKombaiEntryPackage(entry) {
|
|
10210
|
+
const command = commandOf(entry);
|
|
10211
|
+
return command && kombaiCliPackageOf(command);
|
|
10212
|
+
}
|
|
10213
|
+
function isLegacyEntry(entry) {
|
|
10214
|
+
if (!isRecord3(entry)) return false;
|
|
10215
|
+
const args = Array.isArray(entry.args) ? entry.args : [];
|
|
10216
|
+
return args.includes(CHAT_MCP_REGISTRATION_ARG) || typeof entry.command === "string" && LEGACY_LAUNCHER_RE.test(entry.command);
|
|
10217
|
+
}
|
|
10218
|
+
function jsonKombaiEntryKind(entry) {
|
|
10219
|
+
if (entry === void 0) return "none" /* None */;
|
|
10220
|
+
if (jsonKombaiEntryPackage(entry)) return "cli" /* Cli */;
|
|
10221
|
+
return isLegacyEntry(entry) ? "legacy" /* Legacy */ : "foreign" /* Foreign */;
|
|
10222
|
+
}
|
|
10223
|
+
function withJsonKombaiCommand(entry, platform2, cliPackage) {
|
|
10224
|
+
const { command, args } = kombaiCliMcpEntry(platform2, cliPackage);
|
|
10225
|
+
return { ...entry, command, args };
|
|
10226
|
+
}
|
|
10227
|
+
function claudeCodeConfigFile(env, osHome, statOf) {
|
|
10228
|
+
const configDir = env.CLAUDE_CONFIG_DIR ? path17.resolve(env.CLAUDE_CONFIG_DIR) : void 0;
|
|
10229
|
+
const current = path17.join(configDir ?? osHome, ".claude.json");
|
|
10230
|
+
const legacy = path17.join(configDir ?? path17.join(osHome, ".claude"), ".config.json");
|
|
10231
|
+
const old = statOf(legacy);
|
|
10232
|
+
const writable = (old?.mode ?? 0) & 146;
|
|
10233
|
+
if (old?.isFile && (old.size > 0 || writable !== 0 && statOf(current) === null)) return legacy;
|
|
10234
|
+
return current;
|
|
10235
|
+
}
|
|
10236
|
+
var STDIO;
|
|
10237
|
+
var init_jsonKombaiEntry = __esm({
|
|
10238
|
+
"../shared/src/mcp/jsonKombaiEntry.ts"() {
|
|
10239
|
+
"use strict";
|
|
10240
|
+
init_define_KOMBAI_TELEMETRY();
|
|
10241
|
+
init_chatMcpRegistrationArg();
|
|
10242
|
+
init_codexKombaiEntry();
|
|
10243
|
+
STDIO = "stdio";
|
|
10244
|
+
}
|
|
10245
|
+
});
|
|
10246
|
+
|
|
10247
|
+
// src/mcp/install-claude-code.js
|
|
10248
|
+
import { statSync } from "node:fs";
|
|
10249
|
+
import fs17 from "node:fs/promises";
|
|
10250
|
+
import path18 from "node:path";
|
|
10251
|
+
function claudeHomeOf(env, osHome) {
|
|
10252
|
+
return env.CLAUDE_CONFIG_DIR ? path18.resolve(env.CLAUDE_CONFIG_DIR) : path18.join(osHome, ".claude");
|
|
10253
|
+
}
|
|
10254
|
+
async function claudeCodeConfigOf(env, osHome) {
|
|
10255
|
+
return claudeCodeConfigFile(env, osHome, (file2) => {
|
|
10256
|
+
try {
|
|
10257
|
+
const stat = statSync(file2);
|
|
10258
|
+
return { isFile: stat.isFile(), size: stat.size, mode: stat.mode };
|
|
10259
|
+
} catch {
|
|
10260
|
+
return null;
|
|
10261
|
+
}
|
|
10262
|
+
});
|
|
10263
|
+
}
|
|
10264
|
+
async function withConfigLock(configFile, sleep2, command, fn) {
|
|
10265
|
+
const lock = `${configFile}.lock`;
|
|
10266
|
+
for (let attempt = 0; ; attempt++) {
|
|
10267
|
+
try {
|
|
10268
|
+
await fs17.mkdir(lock);
|
|
10269
|
+
break;
|
|
10270
|
+
} catch (error2) {
|
|
10271
|
+
if (isErrno(error2, "ENOENT")) return fn();
|
|
10272
|
+
if (!isErrno(error2, "EEXIST")) throw error2;
|
|
10273
|
+
}
|
|
10274
|
+
const held = await fs17.stat(lock).catch(() => null);
|
|
10275
|
+
if (held && Date.now() - held.mtimeMs > LOCK_STALE_MS) {
|
|
10276
|
+
await fs17.rm(lock, { recursive: true, force: true });
|
|
10277
|
+
continue;
|
|
10278
|
+
}
|
|
10279
|
+
if (attempt >= LOCK_WAITS_MS.length) {
|
|
10280
|
+
throw new CliError(
|
|
10281
|
+
"CLI_MCP_CONFIG_LOCKED",
|
|
10282
|
+
`Claude Code is writing ${configFile} (it holds ${lock}), so it was left as it is.`,
|
|
10283
|
+
{ next: command, details: { path: configFile, lock } }
|
|
10284
|
+
);
|
|
10285
|
+
}
|
|
10286
|
+
await sleep2(LOCK_WAITS_MS[attempt]);
|
|
10287
|
+
}
|
|
10288
|
+
try {
|
|
10289
|
+
return await fn();
|
|
10290
|
+
} finally {
|
|
10291
|
+
await fs17.rm(lock, { recursive: true, force: true });
|
|
10292
|
+
}
|
|
10293
|
+
}
|
|
10294
|
+
function disabledIn(config2, cwd) {
|
|
10295
|
+
const { projects } = config2;
|
|
10296
|
+
if (!isRecord4(projects) || !cwd) return false;
|
|
10297
|
+
for (let dir = path18.resolve(cwd); ; dir = path18.dirname(dir)) {
|
|
10298
|
+
const project = projects[dir];
|
|
10299
|
+
if (isRecord4(project)) {
|
|
10300
|
+
return Array.isArray(project.disabledMcpServers) && project.disabledMcpServers.includes(KOMBAI_MCP_KEY);
|
|
10301
|
+
}
|
|
10302
|
+
if (path18.dirname(dir) === dir) return false;
|
|
10303
|
+
}
|
|
10304
|
+
}
|
|
10305
|
+
function unsupported(file2, why) {
|
|
10306
|
+
return new CliError("CLI_MCP_CONFIG_UNSUPPORTED", `${file2} ${why}, so Kombai can't add its server to it.`, {
|
|
10307
|
+
exit: Exit.REFUSED,
|
|
10308
|
+
next: `Ask the user to fix ${file2} (Claude Code can't read it either), then run this again.`,
|
|
10309
|
+
details: { path: file2 }
|
|
10310
|
+
});
|
|
10311
|
+
}
|
|
10312
|
+
function parseConfig(file2, content) {
|
|
10313
|
+
const bom = content.startsWith(BOM2) ? BOM2 : "";
|
|
10314
|
+
const text = content.slice(bom.length);
|
|
10315
|
+
let config2 = {};
|
|
10316
|
+
if (text.trim() !== "") {
|
|
10317
|
+
try {
|
|
10318
|
+
config2 = JSON.parse(text);
|
|
10319
|
+
} catch {
|
|
10320
|
+
throw unsupported(file2, "isn't valid JSON");
|
|
10321
|
+
}
|
|
10322
|
+
}
|
|
10323
|
+
if (!isRecord4(config2)) throw unsupported(file2, "holds no JSON object");
|
|
10324
|
+
const servers = config2[MCP_SERVERS];
|
|
10325
|
+
if (servers !== void 0 && !isRecord4(servers)) throw unsupported(file2, `has a ${MCP_SERVERS} that is no object`);
|
|
10326
|
+
const eol = text === "" || text.endsWith("\n") ? "\n" : "";
|
|
10327
|
+
return {
|
|
10328
|
+
config: config2,
|
|
10329
|
+
servers,
|
|
10330
|
+
/** @param {Record<string, unknown>} next */
|
|
10331
|
+
text: (next) => `${bom}${JSON.stringify(next, null, 2)}${eol}`
|
|
10332
|
+
};
|
|
10333
|
+
}
|
|
10334
|
+
function installClaudeCodeEntry(claudeHome, configFile, platform2, cliPackage = KOMBAI_CLI_PACKAGE, { sleep: sleep2 = sleep, cwd } = {}) {
|
|
10335
|
+
return withConfigLock(configFile, sleep2, "kombai mcp install claude-code", async () => {
|
|
10336
|
+
const { file: file2, target, content, mode, changedAt } = await readClientConfig(claudeHome, configFile, "Claude Code");
|
|
10337
|
+
return writeEntry(file2, target, content, mode, changedAt, platform2, cliPackage, cwd);
|
|
10338
|
+
});
|
|
10339
|
+
}
|
|
10340
|
+
async function writeEntry(file2, target, content, mode, changedAt, platform2, cliPackage, cwd) {
|
|
10341
|
+
const { config: config2, servers, text } = parseConfig(file2, content);
|
|
10342
|
+
const disabled = disabledIn(config2, cwd);
|
|
10343
|
+
const current = servers?.[KOMBAI_MCP_KEY];
|
|
10344
|
+
const kind = jsonKombaiEntryKind(current);
|
|
10345
|
+
if (kind === "foreign" /* Foreign */) throw foreignEntry(file2, ENTRY_NAME);
|
|
10346
|
+
const done = (outcome2, entry2, at) => ({ outcome: outcome2, block: JSON.stringify(entry2), configChangedAt: at, disabled });
|
|
10347
|
+
let entry;
|
|
10348
|
+
let outcome;
|
|
10349
|
+
if (kind === "cli" /* Cli */ && isRecord4(current)) {
|
|
10350
|
+
const running = jsonKombaiEntryPackage(current);
|
|
10351
|
+
if (running === null || !kombaiCliSwitchable(running, cliPackage)) {
|
|
10352
|
+
return done(InstallOutcome.Already, current, changedAt);
|
|
10353
|
+
}
|
|
10354
|
+
entry = withJsonKombaiCommand(current, platform2, cliPackage);
|
|
10355
|
+
outcome = InstallOutcome.Replaced;
|
|
10356
|
+
} else {
|
|
10357
|
+
entry = claudeCodeKombaiEntry(platform2, cliPackage);
|
|
10358
|
+
outcome = kind === "legacy" /* Legacy */ ? InstallOutcome.Replaced : InstallOutcome.Added;
|
|
10359
|
+
}
|
|
10360
|
+
const next = { ...config2, [MCP_SERVERS]: { ...servers, [KOMBAI_MCP_KEY]: entry } };
|
|
10361
|
+
await writeFileAtomic(target, text(next), { mode });
|
|
10362
|
+
return done(outcome, entry, Date.now());
|
|
10363
|
+
}
|
|
10364
|
+
async function claudeCodeEntryPackage(configFile) {
|
|
10365
|
+
try {
|
|
10366
|
+
const servers = JSON.parse((await fs17.readFile(configFile, "utf8")).replace(/^\uFEFF/, ""))?.[MCP_SERVERS];
|
|
10367
|
+
return isRecord4(servers) ? jsonKombaiEntryPackage(servers[KOMBAI_MCP_KEY]) : null;
|
|
10368
|
+
} catch (error2) {
|
|
10369
|
+
if (error2 instanceof SyntaxError) return null;
|
|
10370
|
+
if (["ENOENT", "ENOTDIR", "EACCES", "EPERM"].some((code2) => isErrno(error2, code2))) return null;
|
|
10371
|
+
throw error2;
|
|
10372
|
+
}
|
|
10373
|
+
}
|
|
10374
|
+
function uninstallClaudeCodeEntry(claudeHome, configFile, { sleep: sleep2 = sleep } = {}) {
|
|
10375
|
+
return withConfigLock(configFile, sleep2, "kombai mcp uninstall claude-code", async () => {
|
|
10376
|
+
const { file: file2, target, content, mode } = await readClientConfig(claudeHome, configFile, "Claude Code");
|
|
10377
|
+
const { config: config2, servers, text } = parseConfig(file2, content);
|
|
10378
|
+
const kind = jsonKombaiEntryKind(servers?.[KOMBAI_MCP_KEY]);
|
|
10379
|
+
if (kind === "foreign" /* Foreign */) throw foreignEntry(file2, ENTRY_NAME);
|
|
10380
|
+
if (kind === "none" /* None */ || !servers) return UninstallOutcome.Absent;
|
|
10381
|
+
const { [KOMBAI_MCP_KEY]: _gone, ...rest } = servers;
|
|
10382
|
+
await writeFileAtomic(target, text({ ...config2, [MCP_SERVERS]: rest }), { mode });
|
|
10383
|
+
return UninstallOutcome.Removed;
|
|
10384
|
+
});
|
|
10385
|
+
}
|
|
10386
|
+
var MCP_SERVERS, ENTRY_NAME, BOM2, LOCK_STALE_MS, LOCK_WAITS_MS, isRecord4;
|
|
10387
|
+
var init_install_claude_code = __esm({
|
|
10388
|
+
"src/mcp/install-claude-code.js"() {
|
|
10389
|
+
"use strict";
|
|
10390
|
+
init_define_KOMBAI_TELEMETRY();
|
|
10391
|
+
init_codexKombaiEntry();
|
|
10392
|
+
init_jsonKombaiEntry();
|
|
10393
|
+
init_deadline();
|
|
10394
|
+
init_fsx();
|
|
10395
|
+
init_output();
|
|
10396
|
+
init_install();
|
|
10397
|
+
MCP_SERVERS = "mcpServers";
|
|
10398
|
+
ENTRY_NAME = `"${MCP_SERVERS}": { "${KOMBAI_MCP_KEY}": \u2026 }`;
|
|
10399
|
+
BOM2 = "\uFEFF";
|
|
10400
|
+
LOCK_STALE_MS = 1e4;
|
|
10401
|
+
LOCK_WAITS_MS = [50, 100, 200, 400, 800, 1600];
|
|
10402
|
+
isRecord4 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
9957
10403
|
}
|
|
9958
10404
|
});
|
|
9959
10405
|
|
|
@@ -10377,8 +10823,8 @@ var init_parseUtil = __esm({
|
|
|
10377
10823
|
init_errors();
|
|
10378
10824
|
init_en();
|
|
10379
10825
|
makeIssue = (params) => {
|
|
10380
|
-
const { data, path:
|
|
10381
|
-
const fullPath = [...
|
|
10826
|
+
const { data, path: path28, errorMaps, issueData } = params;
|
|
10827
|
+
const fullPath = [...path28, ...issueData.path || []];
|
|
10382
10828
|
const fullIssue = {
|
|
10383
10829
|
...issueData,
|
|
10384
10830
|
path: fullPath
|
|
@@ -10661,11 +11107,11 @@ var init_types = __esm({
|
|
|
10661
11107
|
init_parseUtil();
|
|
10662
11108
|
init_util();
|
|
10663
11109
|
ParseInputLazyPath = class {
|
|
10664
|
-
constructor(parent, value,
|
|
11110
|
+
constructor(parent, value, path28, key) {
|
|
10665
11111
|
this._cachedPath = [];
|
|
10666
11112
|
this.parent = parent;
|
|
10667
11113
|
this.data = value;
|
|
10668
|
-
this._path =
|
|
11114
|
+
this._path = path28;
|
|
10669
11115
|
this._key = key;
|
|
10670
11116
|
}
|
|
10671
11117
|
get path() {
|
|
@@ -14174,10 +14620,10 @@ function mergeDefs(...defs) {
|
|
|
14174
14620
|
function cloneDef(schema) {
|
|
14175
14621
|
return mergeDefs(schema._zod.def);
|
|
14176
14622
|
}
|
|
14177
|
-
function getElementAtPath(obj,
|
|
14178
|
-
if (!
|
|
14623
|
+
function getElementAtPath(obj, path28) {
|
|
14624
|
+
if (!path28)
|
|
14179
14625
|
return obj;
|
|
14180
|
-
return
|
|
14626
|
+
return path28.reduce((acc, key) => acc?.[key], obj);
|
|
14181
14627
|
}
|
|
14182
14628
|
function promiseAllObject(promisesObj) {
|
|
14183
14629
|
const keys = Object.keys(promisesObj);
|
|
@@ -14489,11 +14935,11 @@ function aborted(x, startIndex = 0) {
|
|
|
14489
14935
|
}
|
|
14490
14936
|
return false;
|
|
14491
14937
|
}
|
|
14492
|
-
function prefixIssues(
|
|
14938
|
+
function prefixIssues(path28, issues) {
|
|
14493
14939
|
return issues.map((iss) => {
|
|
14494
14940
|
var _a3;
|
|
14495
14941
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
14496
|
-
iss.path.unshift(
|
|
14942
|
+
iss.path.unshift(path28);
|
|
14497
14943
|
return iss;
|
|
14498
14944
|
});
|
|
14499
14945
|
}
|
|
@@ -24007,7 +24453,7 @@ var init_protocol = __esm({
|
|
|
24007
24453
|
return;
|
|
24008
24454
|
}
|
|
24009
24455
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
24010
|
-
await new Promise((
|
|
24456
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
24011
24457
|
options?.signal?.throwIfAborted();
|
|
24012
24458
|
}
|
|
24013
24459
|
} catch (error2) {
|
|
@@ -24024,7 +24470,7 @@ var init_protocol = __esm({
|
|
|
24024
24470
|
*/
|
|
24025
24471
|
request(request, resultSchema, options) {
|
|
24026
24472
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
24027
|
-
return new Promise((
|
|
24473
|
+
return new Promise((resolve2, reject) => {
|
|
24028
24474
|
const earlyReject = (error2) => {
|
|
24029
24475
|
reject(error2);
|
|
24030
24476
|
};
|
|
@@ -24102,7 +24548,7 @@ var init_protocol = __esm({
|
|
|
24102
24548
|
if (!parseResult.success) {
|
|
24103
24549
|
reject(parseResult.error);
|
|
24104
24550
|
} else {
|
|
24105
|
-
|
|
24551
|
+
resolve2(parseResult.data);
|
|
24106
24552
|
}
|
|
24107
24553
|
} catch (error2) {
|
|
24108
24554
|
reject(error2);
|
|
@@ -24363,12 +24809,12 @@ var init_protocol = __esm({
|
|
|
24363
24809
|
}
|
|
24364
24810
|
} catch {
|
|
24365
24811
|
}
|
|
24366
|
-
return new Promise((
|
|
24812
|
+
return new Promise((resolve2, reject) => {
|
|
24367
24813
|
if (signal.aborted) {
|
|
24368
24814
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
24369
24815
|
return;
|
|
24370
24816
|
}
|
|
24371
|
-
const timeoutId = setTimeout(
|
|
24817
|
+
const timeoutId = setTimeout(resolve2, interval);
|
|
24372
24818
|
signal.addEventListener("abort", () => {
|
|
24373
24819
|
clearTimeout(timeoutId);
|
|
24374
24820
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -27416,7 +27862,7 @@ var require_compile = __commonJS({
|
|
|
27416
27862
|
const schOrFunc = root.refs[ref];
|
|
27417
27863
|
if (schOrFunc)
|
|
27418
27864
|
return schOrFunc;
|
|
27419
|
-
let _sch =
|
|
27865
|
+
let _sch = resolve2.call(this, root, ref);
|
|
27420
27866
|
if (_sch === void 0) {
|
|
27421
27867
|
const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
|
|
27422
27868
|
const { schemaId } = this.opts;
|
|
@@ -27443,7 +27889,7 @@ var require_compile = __commonJS({
|
|
|
27443
27889
|
function sameSchemaEnv(s1, s2) {
|
|
27444
27890
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
27445
27891
|
}
|
|
27446
|
-
function
|
|
27892
|
+
function resolve2(root, ref) {
|
|
27447
27893
|
let sch;
|
|
27448
27894
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
27449
27895
|
ref = sch;
|
|
@@ -27659,8 +28105,8 @@ var require_utils = __commonJS({
|
|
|
27659
28105
|
}
|
|
27660
28106
|
return ind;
|
|
27661
28107
|
}
|
|
27662
|
-
function removeDotSegments(
|
|
27663
|
-
let input =
|
|
28108
|
+
function removeDotSegments(path28) {
|
|
28109
|
+
let input = path28;
|
|
27664
28110
|
const output = [];
|
|
27665
28111
|
let nextSlash = -1;
|
|
27666
28112
|
let len = 0;
|
|
@@ -27860,8 +28306,8 @@ var require_schemes = __commonJS({
|
|
|
27860
28306
|
wsComponent.secure = void 0;
|
|
27861
28307
|
}
|
|
27862
28308
|
if (wsComponent.resourceName) {
|
|
27863
|
-
const [
|
|
27864
|
-
wsComponent.path =
|
|
28309
|
+
const [path28, query] = wsComponent.resourceName.split("?");
|
|
28310
|
+
wsComponent.path = path28 && path28 !== "/" ? path28 : void 0;
|
|
27865
28311
|
wsComponent.query = query;
|
|
27866
28312
|
wsComponent.resourceName = void 0;
|
|
27867
28313
|
}
|
|
@@ -28021,7 +28467,7 @@ var require_fast_uri = __commonJS({
|
|
|
28021
28467
|
}
|
|
28022
28468
|
return uri;
|
|
28023
28469
|
}
|
|
28024
|
-
function
|
|
28470
|
+
function resolve2(baseURI, relativeURI, options) {
|
|
28025
28471
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
28026
28472
|
const resolved = resolveComponent(parse3(baseURI, schemelessOptions), parse3(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
28027
28473
|
schemelessOptions.skipEscape = true;
|
|
@@ -28248,7 +28694,7 @@ var require_fast_uri = __commonJS({
|
|
|
28248
28694
|
var fastUri = {
|
|
28249
28695
|
SCHEMES,
|
|
28250
28696
|
normalize,
|
|
28251
|
-
resolve,
|
|
28697
|
+
resolve: resolve2,
|
|
28252
28698
|
resolveComponent,
|
|
28253
28699
|
equal,
|
|
28254
28700
|
serialize,
|
|
@@ -31260,12 +31706,12 @@ var require_dist = __commonJS({
|
|
|
31260
31706
|
throw new Error(`Unknown format "${name}"`);
|
|
31261
31707
|
return f;
|
|
31262
31708
|
};
|
|
31263
|
-
function addFormats(ajv, list,
|
|
31709
|
+
function addFormats(ajv, list, fs22, exportName) {
|
|
31264
31710
|
var _a3;
|
|
31265
31711
|
var _b2;
|
|
31266
31712
|
(_a3 = (_b2 = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b2.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
31267
31713
|
for (const f of list)
|
|
31268
|
-
ajv.addFormat(f,
|
|
31714
|
+
ajv.addFormat(f, fs22[f]);
|
|
31269
31715
|
}
|
|
31270
31716
|
module.exports = exports = formatsPlugin;
|
|
31271
31717
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -31948,12 +32394,12 @@ var init_stdio2 = __esm({
|
|
|
31948
32394
|
this.onclose?.();
|
|
31949
32395
|
}
|
|
31950
32396
|
send(message) {
|
|
31951
|
-
return new Promise((
|
|
32397
|
+
return new Promise((resolve2) => {
|
|
31952
32398
|
const json2 = serializeMessage(message);
|
|
31953
32399
|
if (this._stdout.write(json2)) {
|
|
31954
|
-
|
|
32400
|
+
resolve2();
|
|
31955
32401
|
} else {
|
|
31956
|
-
this._stdout.once("drain",
|
|
32402
|
+
this._stdout.once("drain", resolve2);
|
|
31957
32403
|
}
|
|
31958
32404
|
});
|
|
31959
32405
|
}
|
|
@@ -31986,9 +32432,9 @@ var init_kombai_icon = __esm({
|
|
|
31986
32432
|
});
|
|
31987
32433
|
|
|
31988
32434
|
// src/commands/taste.js
|
|
31989
|
-
import { createHash as
|
|
31990
|
-
import
|
|
31991
|
-
import
|
|
32435
|
+
import { createHash as createHash4, randomUUID as randomUUID2 } from "node:crypto";
|
|
32436
|
+
import fs18 from "node:fs/promises";
|
|
32437
|
+
import path19 from "node:path";
|
|
31992
32438
|
async function writeDirections(runDir, envelope) {
|
|
31993
32439
|
const parts = [];
|
|
31994
32440
|
const images = [];
|
|
@@ -31998,7 +32444,7 @@ async function writeDirections(runDir, envelope) {
|
|
|
31998
32444
|
if (text.trim()) parts.push(text);
|
|
31999
32445
|
} else if (item.type === "image" && item.data) {
|
|
32000
32446
|
const extension = IMAGE_EXTENSIONS[item.mimeType ?? ""] ?? "png";
|
|
32001
|
-
const file2 =
|
|
32447
|
+
const file2 = path19.join(runDir, `image-${images.length + 1}.${extension}`);
|
|
32002
32448
|
await writeFileAtomic(file2, Buffer.from(item.data, "base64"), { mode: 420 });
|
|
32003
32449
|
images.push(file2);
|
|
32004
32450
|
parts.push(``);
|
|
@@ -32078,8 +32524,8 @@ var init_taste = __esm({
|
|
|
32078
32524
|
async run(ctx, { flags }) {
|
|
32079
32525
|
await refuseGuest(ctx);
|
|
32080
32526
|
const variants = Number(flags.variants);
|
|
32081
|
-
const briefFile =
|
|
32082
|
-
const brief = await
|
|
32527
|
+
const briefFile = path19.resolve(ctx.cwd, String(flags.brief));
|
|
32528
|
+
const brief = await fs18.readFile(briefFile, "utf8").catch((error2) => {
|
|
32083
32529
|
if (isErrno(error2, "ENOENT"))
|
|
32084
32530
|
throw new CliError("CLI_FILE_MISSING", `${briefFile} does not exist.`, { details: { path: briefFile } });
|
|
32085
32531
|
if (isErrno(error2, "EISDIR"))
|
|
@@ -32098,7 +32544,7 @@ var init_taste = __esm({
|
|
|
32098
32544
|
const checkout2 = await resolveCheckout(ctx.cwd, { platform: ctx.platform, home: ctx.home });
|
|
32099
32545
|
const work = workDir(ctx.home, session.env, checkout2.checkoutId);
|
|
32100
32546
|
await loadWorkspace(work, checkout2);
|
|
32101
|
-
const tasteDir =
|
|
32547
|
+
const tasteDir = path19.join(work, "taste");
|
|
32102
32548
|
await ensureDir(tasteDir);
|
|
32103
32549
|
const fields = {
|
|
32104
32550
|
projectId: checkout2.projectId,
|
|
@@ -32108,8 +32554,8 @@ var init_taste = __esm({
|
|
|
32108
32554
|
...flags.cards === true ? { cards: true } : {},
|
|
32109
32555
|
client: { name: "kombai-cli", version: ctx.version }
|
|
32110
32556
|
};
|
|
32111
|
-
const pendingFile =
|
|
32112
|
-
const key =
|
|
32557
|
+
const pendingFile = path19.join(tasteDir, "pending.json");
|
|
32558
|
+
const key = createHash4("sha256").update(JSON.stringify(fields)).digest("hex");
|
|
32113
32559
|
const pending = (
|
|
32114
32560
|
/** @type {{ key?: string, createId?: string } | undefined} */
|
|
32115
32561
|
await readJson(pendingFile)
|
|
@@ -32130,7 +32576,7 @@ var init_taste = __esm({
|
|
|
32130
32576
|
error2.next = rerun;
|
|
32131
32577
|
}
|
|
32132
32578
|
if (error2 instanceof CliError && error2.code === "TASTE_CREATE_ID_REUSED") {
|
|
32133
|
-
await
|
|
32579
|
+
await fs18.rm(pendingFile, { force: true });
|
|
32134
32580
|
error2.next = rerun;
|
|
32135
32581
|
}
|
|
32136
32582
|
throw explainTasteError(error2, session.hosts.web);
|
|
@@ -32139,10 +32585,10 @@ var init_taste = __esm({
|
|
|
32139
32585
|
if (created.status === "awaiting_files") {
|
|
32140
32586
|
created = (await session.api.call({ method: "POST", path: `/design/taste/${created.run}/start`, body: {} })).body;
|
|
32141
32587
|
}
|
|
32142
|
-
const runDir =
|
|
32588
|
+
const runDir = path19.join(tasteDir, created.run);
|
|
32143
32589
|
await ensureDir(runDir);
|
|
32144
|
-
await writeFileAtomic(
|
|
32145
|
-
await
|
|
32590
|
+
await writeFileAtomic(path19.join(runDir, "brief.md"), brief, { mode: 420 });
|
|
32591
|
+
await fs18.rm(pendingFile, { force: true });
|
|
32146
32592
|
return { run: created.run, status: created.status, next: `kombai taste wait ${created.run}` };
|
|
32147
32593
|
}
|
|
32148
32594
|
};
|
|
@@ -32164,7 +32610,7 @@ var init_taste = __esm({
|
|
|
32164
32610
|
const session = await openSession(ctx, { deadline });
|
|
32165
32611
|
const checkout2 = await resolveCheckout(ctx.cwd, { platform: ctx.platform, home: ctx.home });
|
|
32166
32612
|
const work = workDir(ctx.home, session.env, checkout2.checkoutId);
|
|
32167
|
-
const runDir =
|
|
32613
|
+
const runDir = path19.join(work, "taste", run3);
|
|
32168
32614
|
const again = `kombai taste wait ${run3}`;
|
|
32169
32615
|
let seenRunning = false;
|
|
32170
32616
|
for (; ; ) {
|
|
@@ -32182,8 +32628,8 @@ var init_taste = __esm({
|
|
|
32182
32628
|
const envelope = JSON.parse(new TextDecoder().decode(await session.api.download(state.result.url)));
|
|
32183
32629
|
await loadWorkspace(work, checkout2);
|
|
32184
32630
|
await ensureDir(runDir);
|
|
32185
|
-
await writeJsonAtomic(
|
|
32186
|
-
const directions =
|
|
32631
|
+
await writeJsonAtomic(path19.join(runDir, "result.json"), envelope, { mode: 420 });
|
|
32632
|
+
const directions = path19.join(runDir, "directions.md");
|
|
32187
32633
|
const written = await writeDirections(runDir, envelope);
|
|
32188
32634
|
await writeFileAtomic(directions, written.text, { mode: 420 });
|
|
32189
32635
|
return {
|
|
@@ -32258,7 +32704,7 @@ html,body{margin:0;background:transparent}
|
|
|
32258
32704
|
});
|
|
32259
32705
|
|
|
32260
32706
|
// src/mcp/client-gate.js
|
|
32261
|
-
import
|
|
32707
|
+
import path20 from "node:path";
|
|
32262
32708
|
function declaresMcpApps(capabilities) {
|
|
32263
32709
|
if (!capabilities || typeof capabilities !== "object") return false;
|
|
32264
32710
|
const extensions = (
|
|
@@ -32278,7 +32724,7 @@ function declaresMcpApps(capabilities) {
|
|
|
32278
32724
|
return !Array.isArray(mimeTypes) || mimeTypes.includes(MCP_APP_MIME_TYPE);
|
|
32279
32725
|
}
|
|
32280
32726
|
function isCodexAppWideFolder(cwd, osHome, platform2, codexHome) {
|
|
32281
|
-
const p = platform2 === "win32" ?
|
|
32727
|
+
const p = platform2 === "win32" ? path20.win32 : path20.posix;
|
|
32282
32728
|
const fold = (value) => platform2 === "linux" ? value : value.toLowerCase();
|
|
32283
32729
|
const same = (a, b) => fold(p.resolve(a)) === fold(p.resolve(b));
|
|
32284
32730
|
const resolved = p.resolve(cwd);
|
|
@@ -32343,8 +32789,8 @@ function createLoginRunner(ctx, options = {}) {
|
|
|
32343
32789
|
if (current) return current;
|
|
32344
32790
|
unread.clear();
|
|
32345
32791
|
let markStarted = () => void 0;
|
|
32346
|
-
const started = new Promise((
|
|
32347
|
-
markStarted =
|
|
32792
|
+
const started = new Promise((resolve2) => {
|
|
32793
|
+
markStarted = resolve2;
|
|
32348
32794
|
});
|
|
32349
32795
|
const state = { started, settled: Promise.resolve({ ok: true, claim: null }), waiting: null, linkOpened: false };
|
|
32350
32796
|
let claim2 = null;
|
|
@@ -32416,13 +32862,13 @@ var init_login_runner = __esm({
|
|
|
32416
32862
|
});
|
|
32417
32863
|
|
|
32418
32864
|
// src/mcp/download.js
|
|
32419
|
-
import
|
|
32420
|
-
import
|
|
32865
|
+
import fs19 from "node:fs/promises";
|
|
32866
|
+
import path21 from "node:path";
|
|
32421
32867
|
async function reserveName(dir, stem) {
|
|
32422
32868
|
for (let n = 0; ; n++) {
|
|
32423
|
-
const file2 =
|
|
32869
|
+
const file2 = path21.join(dir, n === 0 ? `${stem}${ZIP}` : `${stem} (${n})${ZIP}`);
|
|
32424
32870
|
try {
|
|
32425
|
-
await (await
|
|
32871
|
+
await (await fs19.open(file2, "wx")).close();
|
|
32426
32872
|
return file2;
|
|
32427
32873
|
} catch (error2) {
|
|
32428
32874
|
if (!isErrno(error2, "EEXIST") || n >= 999) throw error2;
|
|
@@ -32432,16 +32878,16 @@ async function reserveName(dir, stem) {
|
|
|
32432
32878
|
async function saveZip(dir, fileName, bytes) {
|
|
32433
32879
|
const base = fileName.toLowerCase().endsWith(ZIP) ? fileName.slice(0, -ZIP.length) : fileName;
|
|
32434
32880
|
const stem = WINDOWS_DEVICE_NAME_RE.test(base) ? `${base}-canvas` : base;
|
|
32435
|
-
const tmp =
|
|
32881
|
+
const tmp = path21.join(dir, tempName(`.${stem}${ZIP}`));
|
|
32436
32882
|
let file2 = null;
|
|
32437
32883
|
try {
|
|
32438
|
-
await
|
|
32439
|
-
await
|
|
32884
|
+
await fs19.mkdir(dir, { recursive: true });
|
|
32885
|
+
await fs19.writeFile(tmp, bytes, { flag: "wx" });
|
|
32440
32886
|
file2 = await reserveName(dir, stem);
|
|
32441
|
-
await
|
|
32887
|
+
await fs19.rename(tmp, file2);
|
|
32442
32888
|
return file2;
|
|
32443
32889
|
} catch (error2) {
|
|
32444
|
-
await Promise.all([
|
|
32890
|
+
await Promise.all([fs19.rm(tmp, { force: true }), file2 ? fs19.rm(file2, { force: true }) : void 0]).catch(
|
|
32445
32891
|
() => void 0
|
|
32446
32892
|
);
|
|
32447
32893
|
const reason = isErrnoLike(error2) ? error2.code : "the file could not be written";
|
|
@@ -33270,8 +33716,8 @@ var init_sign_in_card = __esm({
|
|
|
33270
33716
|
});
|
|
33271
33717
|
|
|
33272
33718
|
// src/mcp/cards.js
|
|
33273
|
-
import
|
|
33274
|
-
import
|
|
33719
|
+
import fs20 from "node:fs/promises";
|
|
33720
|
+
import path22 from "node:path";
|
|
33275
33721
|
import { fileURLToPath } from "node:url";
|
|
33276
33722
|
function createCards(ctx, options) {
|
|
33277
33723
|
const appBrowser = () => options.appBrowser?.() ?? null;
|
|
@@ -33280,7 +33726,7 @@ function createCards(ctx, options) {
|
|
|
33280
33726
|
const script = (spec) => {
|
|
33281
33727
|
let read2 = scripts.get(spec);
|
|
33282
33728
|
if (!read2) {
|
|
33283
|
-
read2 =
|
|
33729
|
+
read2 = fs20.readFile(path22.join(dir, spec.bundle), "utf8").catch(() => null);
|
|
33284
33730
|
scripts.set(spec, read2);
|
|
33285
33731
|
}
|
|
33286
33732
|
return read2;
|
|
@@ -33391,11 +33837,9 @@ function showStarters(args) {
|
|
|
33391
33837
|
if (plugin !== void 0 && (typeof plugin !== "string" || !KOMBAI_PLUGIN.test(plugin))) {
|
|
33392
33838
|
return failed("plugin must be Kombai's plugin id in Codex (kombai@ and its marketplace), or left out.");
|
|
33393
33839
|
}
|
|
33394
|
-
const prompts = STARTER_PROMPTS.map(
|
|
33395
|
-
|
|
33396
|
-
|
|
33397
|
-
prompt: plugin ? `[@Kombai](plugin://${plugin}) ${text.charAt(0).toLowerCase()}${text.slice(1)}` : `${text} with Kombai`
|
|
33398
|
-
}));
|
|
33840
|
+
const prompts = STARTER_PROMPTS.map(
|
|
33841
|
+
(request) => plugin ? { label: `@Kombai ${request}`, prompt: `[@Kombai](plugin://${plugin}) ${request}` } : { label: `${request} with Kombai`, prompt: `${request} with Kombai` }
|
|
33842
|
+
);
|
|
33399
33843
|
return {
|
|
33400
33844
|
structuredContent: { prompts },
|
|
33401
33845
|
content: [
|
|
@@ -33553,9 +33997,9 @@ var init_cards = __esm({
|
|
|
33553
33997
|
STARTERS_CARD_TOOL = "starters_card";
|
|
33554
33998
|
KOMBAI_PLUGIN = /^kombai@[A-Za-z0-9][A-Za-z0-9._~-]{0,199}$/;
|
|
33555
33999
|
STARTER_PROMPTS = Object.freeze([
|
|
33556
|
-
|
|
33557
|
-
|
|
33558
|
-
|
|
34000
|
+
"Design a standout UI for my website",
|
|
34001
|
+
"Explore design directions on canvas",
|
|
34002
|
+
"Redesign this section for my app"
|
|
33559
34003
|
]);
|
|
33560
34004
|
SIGNIN_REQUIRED = "CLI_SIGNIN_REQUIRED";
|
|
33561
34005
|
CARDS_DIR = fileURLToPath(new URL("./mcp-apps/", import.meta.url));
|
|
@@ -34558,7 +35002,7 @@ html.dark #cover{background:rgba(30,30,30,.6)}
|
|
|
34558
35002
|
|
|
34559
35003
|
// src/mcp/server.js
|
|
34560
35004
|
import os2 from "node:os";
|
|
34561
|
-
import
|
|
35005
|
+
import path23 from "node:path";
|
|
34562
35006
|
function createMcpServer(ctx, options = {}) {
|
|
34563
35007
|
const place = {
|
|
34564
35008
|
cwd: ctx.cwd,
|
|
@@ -34584,7 +35028,7 @@ function createMcpServer(ctx, options = {}) {
|
|
|
34584
35028
|
const login2 = createLoginRunner(ctx, { inApp: () => appBrowser() !== null });
|
|
34585
35029
|
const callSession = createSessionTool(ctx, { login: login2 });
|
|
34586
35030
|
const cards = createCards(ctx, { dir: options.cardsDir, login: login2, appBrowser });
|
|
34587
|
-
const downloadsDir =
|
|
35031
|
+
const downloadsDir = path23.join(place.osHome, "Downloads");
|
|
34588
35032
|
const resourceMeta = async () => {
|
|
34589
35033
|
const { hosts } = await currentEnv(ctx);
|
|
34590
35034
|
return {
|
|
@@ -34671,14 +35115,14 @@ function createMcpServer(ctx, options = {}) {
|
|
|
34671
35115
|
async function startMcpServer(ctx) {
|
|
34672
35116
|
const server = createMcpServer(ctx);
|
|
34673
35117
|
process.stderr.on("error", () => void 0);
|
|
34674
|
-
await new Promise((
|
|
35118
|
+
await new Promise((resolve2) => {
|
|
34675
35119
|
let done = false;
|
|
34676
35120
|
const finish2 = (why) => {
|
|
34677
35121
|
if (done) return;
|
|
34678
35122
|
done = true;
|
|
34679
35123
|
ctx.stderr.write(`kombai mcp: ${why}
|
|
34680
35124
|
`);
|
|
34681
|
-
void server.close().catch(() => void 0).finally(() =>
|
|
35125
|
+
void server.close().catch(() => void 0).finally(() => resolve2(void 0));
|
|
34682
35126
|
};
|
|
34683
35127
|
installClientDisconnectHooks({
|
|
34684
35128
|
stdin: process.stdin,
|
|
@@ -34783,7 +35227,7 @@ var init_brief = __esm({
|
|
|
34783
35227
|
var claude_desktop_default;
|
|
34784
35228
|
var init_claude_desktop = __esm({
|
|
34785
35229
|
"src/skill/claude-desktop.md"() {
|
|
34786
|
-
claude_desktop_default = "You are running in the Claude desktop app's Code tab.
|
|
35230
|
+
claude_desktop_default = "You are running in the Claude desktop app's Code tab. Four notes for it:\n\n- Task list: keep it to at most 6 steps, following this skill's steps. When a step finishes, call\n update_plan with {\"advance\": true} in the same message as the next step's first tool call, so the list\n never sits on its first step. Call wrap_up before your final message: it checks off the rest.\n- The canvas and the sign-in page: when you open either in your Browser pane (`kombai skill opening`,\n `kombai skill sign-in`), open the link with preview_start (url) and, in the same message, call show_pane\n with {\"pane\": \"preview\"}: opening a page doesn't show the pane. Say it is open only once show_pane says\n it is showing. If the page looks blank, check tabs_context first: it says whether the pane is hidden.\n- A design's HTML file: never open it yourself. The app opens an .html file in the Browser pane by\n itself after Write or Edit changes it, which hides the canvas. In the same message as each\n `kombai node push`, call tabs_context. If a tab shows the design's file, close it with tabs_close and\n bring the canvas tab to the front with tabs_select; if the canvas tab itself shows the file, navigate it\n back to the canvas link. Judge the design only on the canvas and with `kombai screenshot wait --tiles`.\n- Kombai's taste card: if none of your tools ends in taste_card (they may be listed by name only), Kombai's\n server isn't set up for this session: run `kombai mcp install claude-code` once in this session, without asking,\n and follow its next.\n";
|
|
34787
35231
|
}
|
|
34788
35232
|
});
|
|
34789
35233
|
|
|
@@ -34831,7 +35275,7 @@ var init_html = __esm({
|
|
|
34831
35275
|
var opening_codex_default;
|
|
34832
35276
|
var init_opening_codex = __esm({
|
|
34833
35277
|
"src/skill/opening-codex.md"() {
|
|
34834
|
-
opening_codex_default = "# Showing the canvas\n\nIn the Codex app, Kombai's view shows a canvas beside the chat. It is the only way to show one here: no\nbrowser, no in-app browser, no link.\n\n1. **Find the view.** Codex lists no MCP tool up front, so search even when you see none: in exec,\n `ALL_TOOLS.filter((t) => t.name.endsWith('canvas_app'))`.\n2. **Call `canvas_app` with the canvas id** right after `kombai canvas create`, before you write any design,\n or when you first use a canvas that isn't already open beside the chat. A request from the canvas, copied\n from its page or put in the message box by the view, comes from a canvas the user has open: don't call it\n for that one. Set `node` to a design id to focus one. Each call opens another view, and the view updates\n live as you push, so call it again only when the user asks to see the canvas again or says they closed it.\n3. **No canvas_app tool?** Kombai's view isn't set up in Codex yet: set it up now, without asking, before any\n design work. Run `kombai mcp install codex`, then tell the user in one line that it added Kombai's view to\n Codex. A running task never picks up a new MCP server, so the work belongs in a new task: offer in one line to\n continue there, with `[Continue in a new chat \u2192](codex://threads/new?prompt=\u2026)`, a link that opens it with its\n prompt filled in (build the link in exec with `encodeURIComponent`, then `(` and `)` as `%28` and `%29`, so a\n bracket in the request can't end the link)
|
|
35278
|
+
opening_codex_default = "# Showing the canvas\n\nIn the Codex app, Kombai's view shows a canvas beside the chat. It is the only way to show one here: no\nbrowser, no in-app browser, no link.\n\n1. **Find the view.** Codex lists no MCP tool up front, so search even when you see none: in exec,\n `ALL_TOOLS.filter((t) => t.name.endsWith('canvas_app'))`.\n2. **Call `canvas_app` with the canvas id** right after `kombai canvas create`, before you write any design,\n or when you first use a canvas that isn't already open beside the chat. A request from the canvas, copied\n from its page or put in the message box by the view, comes from a canvas the user has open: don't call it\n for that one. Set `node` to a design id to focus one. Each call opens another view, and the view updates\n live as you push, so call it again only when the user asks to see the canvas again or says they closed it.\n3. **No canvas_app tool?** Kombai's view isn't set up in Codex yet: set it up now, without asking, before any\n design work. Run `kombai mcp install codex`, then tell the user in one line that it added Kombai's view to\n Codex. A running task never picks up a new MCP server, so the work belongs in a new task: offer in one line to\n continue there, with `[Continue in a new chat \u2192](codex://threads/new?prompt=\u2026)`, a link that opens it with its\n prompt filled in (build the link in exec with `encodeURIComponent`, then `(` and `)` as `%28` and `%29`, so a\n bracket in the request can't end the link), and end that line with \"or reply yes and I'll open it for you.\"\n The prompt is Kombai's mention where the\n plugin's skill names Kombai's plugin id, then the user's request in their own words, the files they named, and\n any canvas or brief already made, so it continues rather than repeats. On yes, create it (`create_thread`) with\n the same prompt. Codex starts a new task only when the user asks; if they say no, or you can't create one, give\n them the prompt to paste into a new task. If it answers with `disabled: true`, Kombai's view is turned off in\n the user's Codex config: tell the user the canvas can't be shown until they turn it on, and start no task for it.\n If it answers `notStarting: true`, Kombai's server isn't starting in Codex, so no task would get the view: tell\n the user the canvas can't be shown and why that may be (the answer says), and start no task for it. If the command fails, or running it outside the sandbox is declined, tell the user the canvas can't be\n shown in this chat, and don't show it any other way.\n4. **canvas_app answers an error?** Tell the user what it says in one line. Don't show the canvas any other\n way.\n\nMake changes with the commands, never through the view.\n\n**No links.** The commands print no canvas or design link here. The user watches every change in the view: end\nwith a short line on what you made or changed, naming designs by their labels, and don't ask them to open the\ncanvas. If the user asks for a link, tell them the view copies it: the canvas's Share button, or Copy link on a\ndesign's right-click menu. Never give the design's .html file. A user who wants the canvas in their own browser\nopens that copied link there; never open one yourself.\n\n**A new canvas is private.** Don't suggest the user send its link to anyone before sharing is on.\n\n**Never turn sharing on by yourself.** Run `kombai canvas share --on` only when the user asks for a link others can open, and tell them in the reply that anyone with the link can now view it, that teammates can edit it, and that the canvas's Share button copies it.\n";
|
|
34835
35279
|
}
|
|
34836
35280
|
});
|
|
34837
35281
|
|
|
@@ -34860,6 +35304,7 @@ var init_sign_in = __esm({
|
|
|
34860
35304
|
});
|
|
34861
35305
|
|
|
34862
35306
|
// src/commands/skill.js
|
|
35307
|
+
import os3 from "node:os";
|
|
34863
35308
|
function skillAppOf(ctx) {
|
|
34864
35309
|
return ctx.codexDesktop ? "codex-desktop" : ctx.claudeDesktop ? "claude-desktop" : null;
|
|
34865
35310
|
}
|
|
@@ -34871,13 +35316,30 @@ function fillSkillText(text, app) {
|
|
|
34871
35316
|
function topicText(topic, app) {
|
|
34872
35317
|
return fillSkillText(topic === "opening" && app === "codex-desktop" ? opening_codex_default : TOPICS[topic], app);
|
|
34873
35318
|
}
|
|
34874
|
-
|
|
35319
|
+
async function viewChannelNote() {
|
|
35320
|
+
const running = await codexEntryPackage(codexHomeOf(process.env, os3.homedir()));
|
|
35321
|
+
if (running === null || !kombaiCliSwitchable(running, CLI_PACKAGE)) return "";
|
|
35322
|
+
return `Kombai's view in this Codex runs \`${running}\`, another build than this CLI (\`${CLI_PACKAGE}\`), so a canvas this CLI makes may not open in it: before anything else, run \`${CLI_RUN} mcp install codex\` and follow its next.
|
|
35323
|
+
|
|
35324
|
+
`;
|
|
35325
|
+
}
|
|
35326
|
+
async function serverChannelNote() {
|
|
35327
|
+
const running = await claudeCodeEntryPackage(await claudeCodeConfigOf(process.env, os3.homedir()));
|
|
35328
|
+
if (running === null || !kombaiCliSwitchable(running, CLI_PACKAGE)) return "";
|
|
35329
|
+
return `Kombai's MCP server in Claude Code runs \`${running}\`, another build than this CLI (\`${CLI_PACKAGE}\`), so its taste card may not find a run this CLI starts: before anything else, run \`${CLI_RUN} mcp install claude-code\` and follow its next.
|
|
35330
|
+
|
|
35331
|
+
`;
|
|
35332
|
+
}
|
|
35333
|
+
var TOPICS, RUN, APP_NOTES, CHANNEL_NOTES, skill, PLAIN_TEXT;
|
|
34875
35334
|
var init_skill = __esm({
|
|
34876
35335
|
"src/commands/skill.js"() {
|
|
34877
35336
|
"use strict";
|
|
34878
35337
|
init_define_KOMBAI_TELEMETRY();
|
|
35338
|
+
init_codexKombaiEntry();
|
|
34879
35339
|
init_output();
|
|
34880
35340
|
init_version();
|
|
35341
|
+
init_install();
|
|
35342
|
+
init_install_claude_code();
|
|
34881
35343
|
init_actions();
|
|
34882
35344
|
init_brief();
|
|
34883
35345
|
init_claude_desktop();
|
|
@@ -34904,6 +35366,7 @@ var init_skill = __esm({
|
|
|
34904
35366
|
RUN = `Commands here and in a result's next are written as \`kombai <command>\`. Run each as
|
|
34905
35367
|
\`${CLI_RUN} <command>\`, in full, never from a variable.`;
|
|
34906
35368
|
APP_NOTES = { "claude-desktop": claude_desktop_default, "codex-desktop": codex_desktop_default };
|
|
35369
|
+
CHANNEL_NOTES = { "codex-desktop": viewChannelNote, "claude-desktop": serverChannelNote };
|
|
34907
35370
|
skill = {
|
|
34908
35371
|
name: "skill",
|
|
34909
35372
|
summary: "Print the skill's text, or one topic of it. Plain text: these are the agent's instructions.",
|
|
@@ -34917,10 +35380,12 @@ var init_skill = __esm({
|
|
|
34917
35380
|
details: { topics: Object.keys(TOPICS) }
|
|
34918
35381
|
});
|
|
34919
35382
|
}
|
|
34920
|
-
ctx
|
|
35383
|
+
const app = skillAppOf(ctx);
|
|
35384
|
+
const note = topic === "overview" && app ? await CHANNEL_NOTES[app]() : "";
|
|
35385
|
+
ctx.stdout.write(`${note}${topicText(
|
|
34921
35386
|
/** @type {keyof typeof TOPICS} */
|
|
34922
35387
|
topic,
|
|
34923
|
-
|
|
35388
|
+
app
|
|
34924
35389
|
)}
|
|
34925
35390
|
`);
|
|
34926
35391
|
return { [PLAIN_TEXT]: true };
|
|
@@ -34931,29 +35396,88 @@ var init_skill = __esm({
|
|
|
34931
35396
|
});
|
|
34932
35397
|
|
|
34933
35398
|
// src/commands/mcp.js
|
|
34934
|
-
import
|
|
34935
|
-
|
|
35399
|
+
import os4 from "node:os";
|
|
35400
|
+
async function installClaudeCode(ctx) {
|
|
35401
|
+
const claudeHome = claudeHomeOf(process.env, os4.homedir());
|
|
35402
|
+
const config2 = await claudeCodeConfigOf(process.env, os4.homedir());
|
|
35403
|
+
const install = await installClaudeCodeEntry(claudeHome, config2, ctx.platform, CLI_PACKAGE, {
|
|
35404
|
+
sleep: ctx.sleep,
|
|
35405
|
+
cwd: ctx.cwd
|
|
35406
|
+
});
|
|
35407
|
+
const answer2 = { client: McpClient.ClaudeCode, outcome: install.outcome, config: config2 };
|
|
35408
|
+
const changedAt = await entryChangedAt(ctx.home, McpClient.ClaudeCode, config2, install);
|
|
35409
|
+
if (!ctx.claudeDesktop) {
|
|
35410
|
+
return {
|
|
35411
|
+
...answer2,
|
|
35412
|
+
claudeDesktop: false,
|
|
35413
|
+
next: process.env.CLAUDECODE === "1" ? `Kombai's MCP server is set up in ${config2}: it shows Kombai's taste card in the Claude desktop app's Code tab, in sessions started from now on. Claude Code here shows no Kombai card, so nothing changes: carry on as the skill says, and don't run this again in this session.` : `Kombai's MCP server is set up in ${config2}. New sessions in the Claude desktop app's Code tab show Kombai's taste card.`
|
|
35414
|
+
};
|
|
35415
|
+
}
|
|
35416
|
+
if (install.disabled) {
|
|
35417
|
+
return {
|
|
35418
|
+
...answer2,
|
|
35419
|
+
disabled: true,
|
|
35420
|
+
next: `Kombai's MCP server is set up in ${config2} but turned off in this project (/mcp disable), so no session here gets Kombai's taste card: tell the user in one line that \`/mcp enable kombai\` turns it back on, and carry on here; don't run this again in this session.`
|
|
35421
|
+
};
|
|
35422
|
+
}
|
|
35423
|
+
if (install.outcome === InstallOutcome.Replaced) {
|
|
35424
|
+
return {
|
|
35425
|
+
...answer2,
|
|
35426
|
+
next: `Kombai's MCP server in ${config2} now runs \`${CLI_PACKAGE}\` for new Claude Code sessions; this session keeps the server it started with, whose taste card may not find a run this CLI starts, so in this session don't add --cards to \`kombai taste start\` and don't call taste_card. ` + CLAUDE_CARRY_ON
|
|
35427
|
+
};
|
|
35428
|
+
}
|
|
35429
|
+
if (install.outcome === InstallOutcome.Added) {
|
|
35430
|
+
return {
|
|
35431
|
+
...answer2,
|
|
35432
|
+
next: `Kombai's MCP server is set up in ${config2} for new Claude Code sessions; this one never picks up a new or changed MCP server, so it has no taste card. ${CLAUDE_CARRY_ON}`
|
|
35433
|
+
};
|
|
35434
|
+
}
|
|
35435
|
+
const startedAt = await ctx.claudeSessionStartedAt();
|
|
35436
|
+
if (startedAt !== null && changedAt !== null && startedAt > changedAt) {
|
|
35437
|
+
return {
|
|
35438
|
+
...answer2,
|
|
35439
|
+
notStarting: true,
|
|
35440
|
+
next: `Kombai's MCP server is set up in ${config2}, and this session started after that, yet it has no taste_card: Claude Code couldn't start Kombai's server (\`${serverCommand(ctx.platform)}\`), for example on a Node older than 20 or with npx not on the PATH the Claude app starts it with, or the user turned it off (/mcp shows which). Tell the user in one line that Kombai's cards can't show in this session and why that may be; if Kombai may never have run on this machine, its first download can take longer than Claude Code waits, so a new session in a minute or two may get them. Then carry on here, and don't run this again in this session.`
|
|
35441
|
+
};
|
|
35442
|
+
}
|
|
35443
|
+
return {
|
|
35444
|
+
...answer2,
|
|
35445
|
+
next: `Kombai's MCP server is set up in ${config2}, but ` + (startedAt === null ? "this session seems to predate it" : "this session started before Kombai's entry last changed") + `, and Claude Code gives a session only the MCP servers it had when it started. ${CLAUDE_CARRY_ON}`
|
|
35446
|
+
};
|
|
35447
|
+
}
|
|
35448
|
+
var CLIENT_ARG, HANDOFF, serverCommand, CLAUDE_CARRY_ON, mcpInstall, mcpUninstall, mcp;
|
|
34936
35449
|
var init_mcp = __esm({
|
|
34937
35450
|
"src/commands/mcp.js"() {
|
|
34938
35451
|
"use strict";
|
|
34939
35452
|
init_define_KOMBAI_TELEMETRY();
|
|
34940
35453
|
init_install();
|
|
35454
|
+
init_install_claude_code();
|
|
34941
35455
|
init_codexLinks();
|
|
35456
|
+
init_codexKombaiEntry();
|
|
35457
|
+
init_codex_app();
|
|
35458
|
+
init_version();
|
|
34942
35459
|
init_server3();
|
|
34943
35460
|
init_output();
|
|
34944
35461
|
init_skill();
|
|
34945
35462
|
CLIENT_ARG = [{ name: "client", required: true, values: Object.values(McpClient) }];
|
|
34946
|
-
HANDOFF = `Write the new task's prompt: Kombai's mention [@Kombai](plugin://<id>) where the skill names Kombai's plugin id, then the user's request in their own words, the files they named and any canvas or brief already made, so it continues rather than repeats. Offer the user, in one line, to continue in a new task, with [Continue in a new chat \u2192](${CODEX_NEW_CHAT_URL}\u2026), a link that opens one with the prompt filled in
|
|
35463
|
+
HANDOFF = `Write the new task's prompt: Kombai's mention [@Kombai](plugin://<id>) where the skill names Kombai's plugin id, then the user's request in their own words, the files they named and any canvas or brief already made, so it continues rather than repeats. Offer the user, in one line, to continue in a new task, with [Continue in a new chat \u2192](${CODEX_NEW_CHAT_URL}\u2026), a link that opens one with the prompt filled in (build it in exec with encodeURIComponent, then ( and ) as %28 and %29), and end that line with "or reply yes and I'll open it for you." On yes, create the task (create_thread) with the same prompt. If you can't, give them the prompt to paste into a new task.`;
|
|
35464
|
+
serverCommand = (platform2) => {
|
|
35465
|
+
const { command, args } = kombaiCliMcpEntry(platform2, CLI_PACKAGE);
|
|
35466
|
+
return [command, ...args].join(" ");
|
|
35467
|
+
};
|
|
35468
|
+
CLAUDE_CARRY_ON = "Tell the user in one line that new sessions show Kombai's taste card, and carry on here as the skill says (the canvas still opens in your Browser pane); don't run this again in this session.";
|
|
34947
35469
|
mcpInstall = {
|
|
34948
35470
|
name: "mcp install",
|
|
34949
|
-
summary: "Add Kombai's
|
|
35471
|
+
summary: "Add Kombai's MCP server to Codex or Claude Code, in the client's own config (Codex's config.toml, Claude Code's .claude.json). New Codex tasks get Kombai's canvas view; new sessions in the Claude desktop app's Code tab get Kombai's taste card.",
|
|
34950
35472
|
args: CLIENT_ARG,
|
|
34951
35473
|
example: "kombai mcp install codex",
|
|
34952
|
-
async run(ctx) {
|
|
34953
|
-
|
|
34954
|
-
const
|
|
35474
|
+
async run(ctx, { args }) {
|
|
35475
|
+
if (args[0] === McpClient.ClaudeCode) return installClaudeCode(ctx);
|
|
35476
|
+
const codexHome = codexHomeOf(process.env, os4.homedir());
|
|
34955
35477
|
const config2 = codexConfigOf(codexHome);
|
|
34956
|
-
|
|
35478
|
+
const install = await installCodexEntry(codexHome, ctx.platform, CLI_PACKAGE);
|
|
35479
|
+
const { outcome } = install;
|
|
35480
|
+
if (install.disabled) {
|
|
34957
35481
|
return {
|
|
34958
35482
|
client: McpClient.Codex,
|
|
34959
35483
|
outcome,
|
|
@@ -34962,11 +35486,39 @@ var init_mcp = __esm({
|
|
|
34962
35486
|
next: `Kombai's view is set up in ${config2} but turned off (enabled = false), so no Codex task gets it: tell the user the canvas can't be shown until they remove that line or set it to true, and start no new task for it.`
|
|
34963
35487
|
};
|
|
34964
35488
|
}
|
|
35489
|
+
if (!ctx.codexDesktop) {
|
|
35490
|
+
return {
|
|
35491
|
+
client: McpClient.Codex,
|
|
35492
|
+
outcome,
|
|
35493
|
+
config: config2,
|
|
35494
|
+
codexApp: false,
|
|
35495
|
+
next: process.env.CODEX_THREAD_ID ? `Kombai's view is set up in ${config2}: it shows the canvas beside the chat in the Codex app, in tasks started from now on. This Codex shows no view, so carry on here and show a canvas as \`${CLI_RUN} skill\` says, and start no new task for it.` : `Kombai's view is set up in ${config2}. New chats in the Codex app show Kombai's canvas beside the chat.`
|
|
35496
|
+
};
|
|
35497
|
+
}
|
|
35498
|
+
const changedAt = await entryChangedAt(ctx.home, McpClient.Codex, config2, install);
|
|
35499
|
+
if (outcome !== InstallOutcome.Already) {
|
|
35500
|
+
return {
|
|
35501
|
+
client: McpClient.Codex,
|
|
35502
|
+
outcome,
|
|
35503
|
+
config: config2,
|
|
35504
|
+
next: "Kombai's view is set up for new Codex tasks; this one never picks up a new or changed MCP server. " + HANDOFF
|
|
35505
|
+
};
|
|
35506
|
+
}
|
|
35507
|
+
const startedAt = codexTaskStartedAt(process.env);
|
|
35508
|
+
if (startedAt !== null && changedAt !== null && startedAt > changedAt) {
|
|
35509
|
+
return {
|
|
35510
|
+
client: McpClient.Codex,
|
|
35511
|
+
outcome,
|
|
35512
|
+
config: config2,
|
|
35513
|
+
notStarting: true,
|
|
35514
|
+
next: `Kombai's view is set up in ${config2}, and this task started after that, yet it has no canvas_app: Codex couldn't start Kombai's server (\`${serverCommand(ctx.platform)}\`), for example on a Node older than 20 or with npx not on Codex's PATH. Tell the user the canvas can't be shown in this chat and why that may be; if Kombai may never have run on this machine, its first download can take longer than Codex waits, so a new chat in a minute or two may get it. Then start no new task for it.`
|
|
35515
|
+
};
|
|
35516
|
+
}
|
|
34965
35517
|
return {
|
|
34966
35518
|
client: McpClient.Codex,
|
|
34967
35519
|
outcome,
|
|
34968
35520
|
config: config2,
|
|
34969
|
-
next:
|
|
35521
|
+
next: `Kombai's view is set up in ${config2}, but ` + (startedAt === null ? "this task seems to predate it" : "this task started before Kombai's entry last changed") + ", and Codex gives a task only the MCP servers it had when it started: move the work to a new task. " + HANDOFF
|
|
34970
35522
|
};
|
|
34971
35523
|
}
|
|
34972
35524
|
};
|
|
@@ -34975,10 +35527,20 @@ var init_mcp = __esm({
|
|
|
34975
35527
|
summary: "Remove the entry `kombai mcp install` added.",
|
|
34976
35528
|
args: CLIENT_ARG,
|
|
34977
35529
|
example: "kombai mcp uninstall codex",
|
|
34978
|
-
async run(ctx) {
|
|
34979
|
-
const
|
|
34980
|
-
|
|
34981
|
-
|
|
35530
|
+
async run(ctx, { args }) {
|
|
35531
|
+
const client = args[0] === McpClient.ClaudeCode ? McpClient.ClaudeCode : McpClient.Codex;
|
|
35532
|
+
let config2;
|
|
35533
|
+
let outcome;
|
|
35534
|
+
if (client === McpClient.ClaudeCode) {
|
|
35535
|
+
config2 = await claudeCodeConfigOf(process.env, os4.homedir());
|
|
35536
|
+
outcome = await uninstallClaudeCodeEntry(claudeHomeOf(process.env, os4.homedir()), config2, { sleep: ctx.sleep });
|
|
35537
|
+
} else {
|
|
35538
|
+
const codexHome = codexHomeOf(process.env, os4.homedir());
|
|
35539
|
+
config2 = codexConfigOf(codexHome);
|
|
35540
|
+
outcome = await uninstallCodexEntry(codexHome);
|
|
35541
|
+
}
|
|
35542
|
+
if (outcome === UninstallOutcome.Removed) await forgetEntry(ctx.home, client, config2);
|
|
35543
|
+
return { client, outcome, config: config2 };
|
|
34982
35544
|
}
|
|
34983
35545
|
};
|
|
34984
35546
|
mcp = {
|
|
@@ -35001,8 +35563,8 @@ var init_mcp = __esm({
|
|
|
35001
35563
|
});
|
|
35002
35564
|
|
|
35003
35565
|
// src/commands/node.js
|
|
35004
|
-
import
|
|
35005
|
-
import
|
|
35566
|
+
import fs21 from "node:fs/promises";
|
|
35567
|
+
import path24 from "node:path";
|
|
35006
35568
|
async function placeText(cc) {
|
|
35007
35569
|
try {
|
|
35008
35570
|
const read2 = (await cc.session.api.call({ method: "GET", path: `/design/canvases/${cc.canvasId}` })).body;
|
|
@@ -35044,10 +35606,10 @@ function rectFrom(value) {
|
|
|
35044
35606
|
return { x, y, w, h };
|
|
35045
35607
|
}
|
|
35046
35608
|
async function readDrawingFile(ctx, given2) {
|
|
35047
|
-
const file2 =
|
|
35609
|
+
const file2 = path24.resolve(ctx.cwd, given2);
|
|
35048
35610
|
let bytes;
|
|
35049
35611
|
try {
|
|
35050
|
-
bytes = new Uint8Array(await
|
|
35612
|
+
bytes = new Uint8Array(await fs21.readFile(file2));
|
|
35051
35613
|
} catch (error2) {
|
|
35052
35614
|
if (isErrno(error2, "ENOENT"))
|
|
35053
35615
|
throw new CliError("CLI_FILE_MISSING", `${file2} does not exist.`, { details: { path: file2 } });
|
|
@@ -35302,7 +35864,7 @@ async function pushDrawing(ctx, cc, projectId, nodeId, entry, saved) {
|
|
|
35302
35864
|
if (!saved && sent === entry.files.content) {
|
|
35303
35865
|
return { nodeId, status: "unchanged", version: entry.version, images: { uploaded: 0, stored: 0 } };
|
|
35304
35866
|
}
|
|
35305
|
-
const before = parseStored(await
|
|
35867
|
+
const before = parseStored(await fs21.readFile(baseFile(paths, nodeId, "content")).catch(() => null));
|
|
35306
35868
|
const images = await storeDrawingPicture(cc, projectId, drawing, file2, nodeId, before?.src);
|
|
35307
35869
|
const body = {
|
|
35308
35870
|
ifVersion: saved?.version ?? entry.version,
|
|
@@ -35379,7 +35941,7 @@ async function storeDrawingPicture(cc, projectId, drawing, file2, nodeId, stored
|
|
|
35379
35941
|
}
|
|
35380
35942
|
throw error2;
|
|
35381
35943
|
}
|
|
35382
|
-
if (image.sha256 !==
|
|
35944
|
+
if (image.sha256 !== path24.posix.basename(src).split(".")[0]) {
|
|
35383
35945
|
throw badDrawing(
|
|
35384
35946
|
file2,
|
|
35385
35947
|
nodeId,
|
|
@@ -35501,14 +36063,14 @@ async function explainGone(ctx, cc, nodeId, error2) {
|
|
|
35501
36063
|
}
|
|
35502
36064
|
async function saveConflict2(paths, canvasId, nodeId, stored, files) {
|
|
35503
36065
|
await removeRemotes(paths, nodeId);
|
|
35504
|
-
const dir =
|
|
35505
|
-
await
|
|
35506
|
-
if (files.html) await writeFileAtomic(
|
|
35507
|
-
if (files.overrides) await writeFileAtomic(
|
|
35508
|
-
if (files.content) await writeFileAtomic(
|
|
35509
|
-
await writeJsonAtomic(
|
|
36066
|
+
const dir = path24.join(paths.remote, `${nodeId}@v${stored.version}`);
|
|
36067
|
+
await fs21.mkdir(dir, { recursive: true });
|
|
36068
|
+
if (files.html) await writeFileAtomic(path24.join(dir, "node.html"), files.html, { mode: 420 });
|
|
36069
|
+
if (files.overrides) await writeFileAtomic(path24.join(dir, "node.overrides.json"), files.overrides, { mode: 420 });
|
|
36070
|
+
if (files.content) await writeFileAtomic(path24.join(dir, "node.content.json"), files.content, { mode: 420 });
|
|
36071
|
+
await writeJsonAtomic(path24.join(dir, "images.json"), stored.images ?? [], { mode: 420 });
|
|
35510
36072
|
await writeJsonAtomic(
|
|
35511
|
-
|
|
36073
|
+
path24.join(dir, "node.json"),
|
|
35512
36074
|
{ version: stored.version, state: stored.state, modifiedBy: stored.modifiedBy, node: stored.node },
|
|
35513
36075
|
{ mode: 420 }
|
|
35514
36076
|
);
|
|
@@ -35531,16 +36093,16 @@ async function saveConflict2(paths, canvasId, nodeId, stored, files) {
|
|
|
35531
36093
|
);
|
|
35532
36094
|
}
|
|
35533
36095
|
async function latestRemote2(paths, nodeId) {
|
|
35534
|
-
const names = await
|
|
36096
|
+
const names = await fs21.readdir(paths.remote).catch(() => (
|
|
35535
36097
|
/** @type {string[]} */
|
|
35536
36098
|
[]
|
|
35537
36099
|
));
|
|
35538
36100
|
const versions = names.map((name) => name.startsWith(`${nodeId}@v`) ? Number(name.slice(nodeId.length + 2)) : NaN).filter(Number.isInteger).sort((a, b) => b - a);
|
|
35539
36101
|
if (!versions.length) return null;
|
|
35540
|
-
const dir =
|
|
36102
|
+
const dir = path24.join(paths.remote, `${nodeId}@v${versions[0]}`);
|
|
35541
36103
|
const saved = (
|
|
35542
36104
|
/** @type {{ version?: number, node?: unknown } | undefined} */
|
|
35543
|
-
await readJson(
|
|
36105
|
+
await readJson(path24.join(dir, "node.json"))
|
|
35544
36106
|
);
|
|
35545
36107
|
const node = saved?.node && typeof saved.node === "object" ? (
|
|
35546
36108
|
/** @type {Record<string, unknown>} */
|
|
@@ -35562,7 +36124,7 @@ async function readNode(cc, nodeId) {
|
|
|
35562
36124
|
}
|
|
35563
36125
|
async function readWorking(paths, nodeId, kind) {
|
|
35564
36126
|
try {
|
|
35565
|
-
return new Uint8Array(await
|
|
36127
|
+
return new Uint8Array(await fs21.readFile(workingFile(paths, nodeId, kind)));
|
|
35566
36128
|
} catch (error2) {
|
|
35567
36129
|
if (isErrno(error2, "ENOENT")) return null;
|
|
35568
36130
|
throw error2;
|
|
@@ -35570,7 +36132,7 @@ async function readWorking(paths, nodeId, kind) {
|
|
|
35570
36132
|
}
|
|
35571
36133
|
async function baseCopies2(paths, nodeId, entry) {
|
|
35572
36134
|
const files = {};
|
|
35573
|
-
for (const kind of KINDS) if (entry.files[kind]) files[kind] = await
|
|
36135
|
+
for (const kind of KINDS) if (entry.files[kind]) files[kind] = await fs21.readFile(baseFile(paths, nodeId, kind));
|
|
35574
36136
|
return files;
|
|
35575
36137
|
}
|
|
35576
36138
|
var PUSH_TRIES, START_TRIES2, TEXT_SIZE, PLACEMENT_GAP, EMPTY_HTML, CONFLICT_MARKER, RECT_PROBLEM, DATA_KIDS_MODULE, STOPS_PUSH, nodeStart, nodePull, nodePush, nodeLock, nodeUnlock;
|
|
@@ -35706,11 +36268,11 @@ var init_node = __esm({
|
|
|
35706
36268
|
return Object.keys(base.nodes).length === 0 && Object.keys(base.starts).length === 0;
|
|
35707
36269
|
});
|
|
35708
36270
|
if (fresh && unused && (error2.status === 404 || error2.status === 410)) {
|
|
35709
|
-
const files = await
|
|
36271
|
+
const files = await fs21.readdir(paths.nodes).catch(() => (
|
|
35710
36272
|
/** @type {string[]} */
|
|
35711
36273
|
[]
|
|
35712
36274
|
));
|
|
35713
|
-
if (!files.length) await
|
|
36275
|
+
if (!files.length) await fs21.rm(paths.dir, { recursive: true, force: true });
|
|
35714
36276
|
}
|
|
35715
36277
|
}
|
|
35716
36278
|
throw await canvasGone(cc, error2);
|
|
@@ -35835,7 +36397,7 @@ var init_node = __esm({
|
|
|
35835
36397
|
type,
|
|
35836
36398
|
version: read2.version,
|
|
35837
36399
|
state: read2.state,
|
|
35838
|
-
file: info.file ?
|
|
36400
|
+
file: info.file ? path24.join(paths.dir, info.file) : null,
|
|
35839
36401
|
...linkField(ctx, nodeLink(cc, nodeId)),
|
|
35840
36402
|
overrides: files.overrides ? workingFile(paths, nodeId, "overrides") : null,
|
|
35841
36403
|
images: read2.images ?? [],
|
|
@@ -36063,7 +36625,7 @@ var init_pngtiles = __esm({
|
|
|
36063
36625
|
|
|
36064
36626
|
// src/commands/screenshot.js
|
|
36065
36627
|
import { execFile as execFile2 } from "node:child_process";
|
|
36066
|
-
import
|
|
36628
|
+
import path25 from "node:path";
|
|
36067
36629
|
async function writeTiles(ctx, dir, nodeId, version2, png, screenshotFile) {
|
|
36068
36630
|
const tiles = png ? pngTiles(png, TILE_HEIGHT) : null;
|
|
36069
36631
|
if (!tiles) {
|
|
@@ -36074,8 +36636,8 @@ async function writeTiles(ctx, dir, nodeId, version2, png, screenshotFile) {
|
|
|
36074
36636
|
});
|
|
36075
36637
|
return [screenshotFile];
|
|
36076
36638
|
}
|
|
36077
|
-
if (tiles.length === 1) return [
|
|
36078
|
-
const files = tiles.map((_, i) =>
|
|
36639
|
+
if (tiles.length === 1) return [path25.join(dir, `${nodeId}@v${version2}.png`)];
|
|
36640
|
+
const files = tiles.map((_, i) => path25.join(dir, `${nodeId}@v${version2}.tile-${i + 1}.png`));
|
|
36079
36641
|
await Promise.all(files.map((file2, i) => writeFileAtomic(file2, tiles[i], { mode: 420 })));
|
|
36080
36642
|
return files;
|
|
36081
36643
|
}
|
|
@@ -36097,35 +36659,35 @@ function waitTimedOut(canvasId, nodeId) {
|
|
|
36097
36659
|
);
|
|
36098
36660
|
}
|
|
36099
36661
|
function askVersion(browserPath, timeoutMs = 1e4) {
|
|
36100
|
-
return new Promise((
|
|
36662
|
+
return new Promise((resolve2) => {
|
|
36101
36663
|
execFile2(browserPath, ["--version"], { timeout: timeoutMs, windowsHide: true }, (error2, stdout, stderr) => {
|
|
36102
36664
|
const version2 = String(stdout).trim();
|
|
36103
|
-
if (!error2 && CHROMIUM_VERSION.test(version2)) return
|
|
36665
|
+
if (!error2 && CHROMIUM_VERSION.test(version2)) return resolve2({ version: version2, problem: "" });
|
|
36104
36666
|
const said = String(stderr).trim().split(/\r?\n/)[0] || error2?.message || version2 || "it printed nothing";
|
|
36105
|
-
|
|
36667
|
+
resolve2({ version: null, problem: said.slice(0, 300) });
|
|
36106
36668
|
});
|
|
36107
36669
|
});
|
|
36108
36670
|
}
|
|
36109
36671
|
function fileVersion(browserPath) {
|
|
36110
36672
|
const script = '$i = (Get-Item -LiteralPath $env:KOMBAI_BROWSER_PROBE).VersionInfo; $i.ProductName + " " + $i.ProductVersion';
|
|
36111
|
-
return new Promise((
|
|
36673
|
+
return new Promise((resolve2) => {
|
|
36112
36674
|
execFile2(
|
|
36113
36675
|
"powershell.exe",
|
|
36114
36676
|
["-NoProfile", "-NonInteractive", "-Command", script],
|
|
36115
36677
|
{ timeout: 1e4, windowsHide: true, env: { ...process.env, KOMBAI_BROWSER_PROBE: browserPath } },
|
|
36116
36678
|
(error2, stdout) => {
|
|
36117
36679
|
const version2 = String(stdout).trim();
|
|
36118
|
-
|
|
36680
|
+
resolve2(!error2 && CHROMIUM_VERSION.test(version2) ? version2 : null);
|
|
36119
36681
|
}
|
|
36120
36682
|
);
|
|
36121
36683
|
});
|
|
36122
36684
|
}
|
|
36123
36685
|
function readLine() {
|
|
36124
|
-
return new Promise((
|
|
36686
|
+
return new Promise((resolve2) => {
|
|
36125
36687
|
process.stdin.setEncoding("utf8");
|
|
36126
36688
|
process.stdin.once("data", (data) => {
|
|
36127
36689
|
process.stdin.pause();
|
|
36128
|
-
|
|
36690
|
+
resolve2(String(data).trim());
|
|
36129
36691
|
});
|
|
36130
36692
|
});
|
|
36131
36693
|
}
|
|
@@ -36171,7 +36733,7 @@ var init_screenshot = __esm({
|
|
|
36171
36733
|
if (named2 && flags.canvas === void 0) {
|
|
36172
36734
|
throw new CliError("CLI_BAD_FLAG", "--node needs --canvas.", { next: "kombai screenshot fill --help" });
|
|
36173
36735
|
}
|
|
36174
|
-
const browserFlag = flags.browser === void 0 ? void 0 :
|
|
36736
|
+
const browserFlag = flags.browser === void 0 ? void 0 : path25.resolve(ctx.cwd, String(flags.browser));
|
|
36175
36737
|
if (browserFlag) {
|
|
36176
36738
|
await checkNamedBrowser(
|
|
36177
36739
|
browserFlag,
|
|
@@ -36379,14 +36941,14 @@ var init_screenshot = __esm({
|
|
|
36379
36941
|
if (shot.state === "ok" && shot.screenshot) {
|
|
36380
36942
|
const dir = canvasPaths(cc.work, canvasId).screenshots;
|
|
36381
36943
|
await ensureDir(dir);
|
|
36382
|
-
const screenshotFile =
|
|
36944
|
+
const screenshotFile = path25.join(dir, `${nodeId}@v${read2.version}.jpg`);
|
|
36383
36945
|
await writeFileAtomic(screenshotFile, await cc.session.api.download(shot.screenshot, deadline), {
|
|
36384
36946
|
mode: 420
|
|
36385
36947
|
});
|
|
36386
36948
|
let screenshotPngFile = null;
|
|
36387
36949
|
let png = null;
|
|
36388
36950
|
if (shot.screenshotPng) {
|
|
36389
|
-
screenshotPngFile =
|
|
36951
|
+
screenshotPngFile = path25.join(dir, `${nodeId}@v${read2.version}.png`);
|
|
36390
36952
|
png = await cc.session.api.download(shot.screenshotPng, deadline);
|
|
36391
36953
|
await writeFileAtomic(screenshotPngFile, png, { mode: 420 });
|
|
36392
36954
|
}
|
|
@@ -36449,7 +37011,7 @@ var init_screenshot = __esm({
|
|
|
36449
37011
|
);
|
|
36450
37012
|
}
|
|
36451
37013
|
ctx.stderr.write(
|
|
36452
|
-
`Download chrome-headless-shell ${PINNED_BUILD} (about 100 MB) into ${
|
|
37014
|
+
`Download chrome-headless-shell ${PINNED_BUILD} (about 100 MB) into ${path25.join(ctx.home, "browser")}? [y/N] `
|
|
36453
37015
|
);
|
|
36454
37016
|
if (!/^y(es)?$/i.test(await readLine())) throw new CliError("CLI_CANCELLED", "Nothing was downloaded.");
|
|
36455
37017
|
}
|
|
@@ -36459,7 +37021,7 @@ var init_screenshot = __esm({
|
|
|
36459
37021
|
/** @type {typeof import('../render/install-entry.js')} */
|
|
36460
37022
|
await import(INSTALL_MODULE)
|
|
36461
37023
|
);
|
|
36462
|
-
const executable = await installHeadlessShell(
|
|
37024
|
+
const executable = await installHeadlessShell(path25.join(ctx.home, "browser"), PINNED_BUILD);
|
|
36463
37025
|
const answer2 = await askVersion(executable, 3e4);
|
|
36464
37026
|
if (!answer2.version) {
|
|
36465
37027
|
throw new CliError(
|
|
@@ -36477,7 +37039,7 @@ var init_screenshot = __esm({
|
|
|
36477
37039
|
summary: "Save the path of a Chromium browser the search missed, after checking that it answers --version as Chromium. Clears a launch-failed skip.",
|
|
36478
37040
|
args: [{ name: "path", required: true }],
|
|
36479
37041
|
async run(ctx, { args }) {
|
|
36480
|
-
const browserPath =
|
|
37042
|
+
const browserPath = path25.resolve(ctx.cwd, args[0]);
|
|
36481
37043
|
await checkNamedBrowser(browserPath, "Give the path of a Chromium browser's program.");
|
|
36482
37044
|
const version2 = (ctx.platform === "win32" ? await fileVersion(browserPath) : null) ?? (await askVersion(browserPath)).version;
|
|
36483
37045
|
if (!version2) {
|
|
@@ -36557,17 +37119,17 @@ var init_commands = __esm({
|
|
|
36557
37119
|
|
|
36558
37120
|
// src/lib/app-skills.js
|
|
36559
37121
|
import { access, lstat, readdir, rm } from "node:fs/promises";
|
|
36560
|
-
import
|
|
37122
|
+
import path26 from "node:path";
|
|
36561
37123
|
function appSkillDirsOf(home, env) {
|
|
36562
37124
|
const dirs = [
|
|
36563
|
-
|
|
36564
|
-
|
|
36565
|
-
|
|
36566
|
-
|
|
36567
|
-
|
|
36568
|
-
|
|
37125
|
+
path26.join(home, ".claude", "skills"),
|
|
37126
|
+
path26.join(home, ".agents", "skills"),
|
|
37127
|
+
path26.join(home, ".cursor", "skills"),
|
|
37128
|
+
path26.join(home, ".copilot", "skills"),
|
|
37129
|
+
path26.join(home, ".gemini", "skills"),
|
|
37130
|
+
path26.join(home, ".gemini", "config", "skills")
|
|
36569
37131
|
];
|
|
36570
|
-
if (env.CLAUDE_CONFIG_DIR) dirs.push(
|
|
37132
|
+
if (env.CLAUDE_CONFIG_DIR) dirs.push(path26.join(path26.resolve(env.CLAUDE_CONFIG_DIR), "skills"));
|
|
36571
37133
|
return [...new Set(dirs)];
|
|
36572
37134
|
}
|
|
36573
37135
|
async function removeAppSkillsOnce(ctx) {
|
|
@@ -36596,7 +37158,7 @@ async function removeAppSkills(dirs) {
|
|
|
36596
37158
|
return isAbsent(error2);
|
|
36597
37159
|
}
|
|
36598
37160
|
const removed = await Promise.all(
|
|
36599
|
-
names.filter((name) => APP_SKILL_NAMES.has(name)).map((name) => removeIfApps(
|
|
37161
|
+
names.filter((name) => APP_SKILL_NAMES.has(name)).map((name) => removeIfApps(path26.join(dir, name)))
|
|
36600
37162
|
);
|
|
36601
37163
|
return removed.every(Boolean);
|
|
36602
37164
|
})
|
|
@@ -36605,14 +37167,14 @@ async function removeAppSkills(dirs) {
|
|
|
36605
37167
|
}
|
|
36606
37168
|
async function removeIfApps(folder) {
|
|
36607
37169
|
try {
|
|
36608
|
-
await access(
|
|
37170
|
+
await access(path26.join(folder, APP_MARKER));
|
|
36609
37171
|
} catch (error2) {
|
|
36610
37172
|
return isAbsent(error2);
|
|
36611
37173
|
}
|
|
36612
37174
|
try {
|
|
36613
37175
|
if ((await lstat(folder)).isDirectory()) {
|
|
36614
37176
|
const names = (await readdir(folder)).filter((name) => name !== APP_MARKER);
|
|
36615
|
-
await Promise.all(names.map((name) => rm(
|
|
37177
|
+
await Promise.all(names.map((name) => rm(path26.join(folder, name), { recursive: true, force: true })));
|
|
36616
37178
|
}
|
|
36617
37179
|
await rm(folder, { recursive: true, force: true });
|
|
36618
37180
|
return true;
|
|
@@ -36812,18 +37374,45 @@ var init_args = __esm({
|
|
|
36812
37374
|
}
|
|
36813
37375
|
});
|
|
36814
37376
|
|
|
37377
|
+
// src/lib/claude-code.js
|
|
37378
|
+
import { execFile as execFile3 } from "node:child_process";
|
|
37379
|
+
function elapsedSeconds(text) {
|
|
37380
|
+
const match = /^\s*(?:(\d+)-)?(?:(\d+):)?(\d+):(\d+)\s*$/.exec(text);
|
|
37381
|
+
if (!match) return null;
|
|
37382
|
+
const [, days = "0", hours = "0", minutes, seconds] = match;
|
|
37383
|
+
return ((Number(days) * 24 + Number(hours)) * 60 + Number(minutes)) * 60 + Number(seconds);
|
|
37384
|
+
}
|
|
37385
|
+
function claudeSessionStartedAt(env, platform2, now) {
|
|
37386
|
+
const pid = Number(env.CLAUDE_PID);
|
|
37387
|
+
if (platform2 === "win32" || !Number.isSafeInteger(pid) || pid <= 0) return Promise.resolve(null);
|
|
37388
|
+
return new Promise((resolve2) => {
|
|
37389
|
+
execFile3("ps", ["-o", "etime=", "-p", String(pid)], { timeout: PS_TIMEOUT_MS }, (error2, stdout) => {
|
|
37390
|
+
const elapsed = error2 ? null : elapsedSeconds(String(stdout));
|
|
37391
|
+
resolve2(elapsed === null ? null : now() - (elapsed + 1) * 1e3);
|
|
37392
|
+
});
|
|
37393
|
+
});
|
|
37394
|
+
}
|
|
37395
|
+
var PS_TIMEOUT_MS;
|
|
37396
|
+
var init_claude_code = __esm({
|
|
37397
|
+
"src/lib/claude-code.js"() {
|
|
37398
|
+
"use strict";
|
|
37399
|
+
init_define_KOMBAI_TELEMETRY();
|
|
37400
|
+
PS_TIMEOUT_MS = 2e3;
|
|
37401
|
+
}
|
|
37402
|
+
});
|
|
37403
|
+
|
|
36815
37404
|
// src/lib/open.js
|
|
36816
37405
|
import { spawn as spawn3 } from "node:child_process";
|
|
36817
37406
|
function openInBrowser(url2, platform2, options = {}) {
|
|
36818
37407
|
const [command, args] = platform2 === "darwin" ? ["open", [url2]] : platform2 === "win32" ? ["cmd", ["/c", "start", '""', url2.replace(/&/g, "^&")]] : ["xdg-open", [url2]];
|
|
36819
|
-
return new Promise((
|
|
37408
|
+
return new Promise((resolve2) => {
|
|
36820
37409
|
let timer;
|
|
36821
37410
|
let settled = false;
|
|
36822
37411
|
const settle = (opened) => {
|
|
36823
37412
|
if (settled) return;
|
|
36824
37413
|
settled = true;
|
|
36825
37414
|
clearTimeout(timer);
|
|
36826
|
-
|
|
37415
|
+
resolve2(opened);
|
|
36827
37416
|
};
|
|
36828
37417
|
try {
|
|
36829
37418
|
const child = spawn3(command, args, {
|
|
@@ -36866,7 +37455,7 @@ var init_posthog = __esm({
|
|
|
36866
37455
|
// src/lib/telemetry.js
|
|
36867
37456
|
import { spawn as spawn4 } from "node:child_process";
|
|
36868
37457
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
36869
|
-
import
|
|
37458
|
+
import os5 from "node:os";
|
|
36870
37459
|
async function guestBefore(ctx) {
|
|
36871
37460
|
if (!ctx.telemetry.keys) return void 0;
|
|
36872
37461
|
try {
|
|
@@ -36915,11 +37504,11 @@ async function postDetached(_ctx, requests) {
|
|
|
36915
37504
|
stdio: ["pipe", "ignore", "ignore"],
|
|
36916
37505
|
windowsHide: true
|
|
36917
37506
|
});
|
|
36918
|
-
await new Promise((
|
|
36919
|
-
child.once("error",
|
|
36920
|
-
child.stdin?.once("error",
|
|
36921
|
-
child.stdin?.end(JSON.stringify(requests), () =>
|
|
36922
|
-
setTimeout(
|
|
37507
|
+
await new Promise((resolve2) => {
|
|
37508
|
+
child.once("error", resolve2);
|
|
37509
|
+
child.stdin?.once("error", resolve2);
|
|
37510
|
+
child.stdin?.end(JSON.stringify(requests), () => resolve2(void 0));
|
|
37511
|
+
setTimeout(resolve2, 500).unref();
|
|
36923
37512
|
});
|
|
36924
37513
|
child.unref();
|
|
36925
37514
|
}
|
|
@@ -36949,7 +37538,10 @@ function eventsOf(ctx, ran, scope, machine) {
|
|
|
36949
37538
|
ci: Boolean(process.env.CI),
|
|
36950
37539
|
// Whether the CLI took this for an agent in the Codex desktop app (codex-app.js). Its marker is internal to
|
|
36951
37540
|
// Codex, so a drop to none here is how a release that renamed it shows up.
|
|
36952
|
-
codexDesktop: ctx.codexDesktop
|
|
37541
|
+
codexDesktop: ctx.codexDesktop,
|
|
37542
|
+
// Whether it ran in the Claude desktop app's Code tab, the one Claude Code that shows Kombai's taste card and
|
|
37543
|
+
// whose notes set Kombai's server up (`mcp install claude-code`).
|
|
37544
|
+
claudeDesktop: ctx.claudeDesktop
|
|
36953
37545
|
}
|
|
36954
37546
|
}
|
|
36955
37547
|
];
|
|
@@ -37021,7 +37613,7 @@ function framesOf(stack) {
|
|
|
37021
37613
|
return frames.reverse();
|
|
37022
37614
|
}
|
|
37023
37615
|
function scrub(text) {
|
|
37024
|
-
const home =
|
|
37616
|
+
const home = os5.homedir();
|
|
37025
37617
|
return home.length > 1 ? text.split(home).join("~") : text;
|
|
37026
37618
|
}
|
|
37027
37619
|
var TELEMETRY_KEYS, SEND_MS, CHILD_SEND_MS, MAX_ERRORS, Telemetry, SENDER, FRAME;
|
|
@@ -37065,15 +37657,15 @@ var init_telemetry = __esm({
|
|
|
37065
37657
|
|
|
37066
37658
|
// src/lib/context.js
|
|
37067
37659
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
37068
|
-
import
|
|
37069
|
-
import
|
|
37660
|
+
import os6 from "node:os";
|
|
37661
|
+
import path27 from "node:path";
|
|
37070
37662
|
function createContext(overrides = {}) {
|
|
37071
37663
|
const platform2 = overrides.platform ?? process.platform;
|
|
37072
37664
|
const stdout = overrides.stdout ?? process.stdout;
|
|
37073
37665
|
const ctx = {
|
|
37074
37666
|
stdout,
|
|
37075
37667
|
stderr: process.stderr,
|
|
37076
|
-
home:
|
|
37668
|
+
home: path27.join(os6.homedir(), ".kombai", "cli"),
|
|
37077
37669
|
cwd: process.cwd(),
|
|
37078
37670
|
fetch: globalThis.fetch,
|
|
37079
37671
|
now: Date.now,
|
|
@@ -37094,9 +37686,10 @@ function createContext(overrides = {}) {
|
|
|
37094
37686
|
telemetry: new Telemetry(process.env.DO_NOT_TRACK === "1" ? null : TELEMETRY_KEYS, postDetached),
|
|
37095
37687
|
sandbox: sandboxOf(process.env),
|
|
37096
37688
|
claudeDesktop: process.env.CLAUDE_CODE_ENTRYPOINT === "claude-desktop",
|
|
37689
|
+
claudeSessionStartedAt: () => claudeSessionStartedAt(process.env, platform2, ctx.now),
|
|
37097
37690
|
codexDesktop: inCodexDesktop(process.env),
|
|
37098
37691
|
changeSent: false,
|
|
37099
|
-
appSkillDirs: appSkillDirsOf(
|
|
37692
|
+
appSkillDirs: appSkillDirsOf(os6.homedir(), process.env),
|
|
37100
37693
|
...overrides
|
|
37101
37694
|
};
|
|
37102
37695
|
return ctx;
|
|
@@ -37106,6 +37699,7 @@ var init_context = __esm({
|
|
|
37106
37699
|
"use strict";
|
|
37107
37700
|
init_define_KOMBAI_TELEMETRY();
|
|
37108
37701
|
init_app_skills();
|
|
37702
|
+
init_claude_code();
|
|
37109
37703
|
init_codex_app();
|
|
37110
37704
|
init_deadline();
|
|
37111
37705
|
init_open();
|