@kombai/cli 0.1.3 → 0.1.4-beta.2
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 +1206 -239
- package/dist/mcp-apps/design-taste.js +142 -142
- package/dist/mcp-apps/plans.js +92 -92
- package/dist/mcp-apps/sign-in.js +78 -78
- package/dist/mcp-apps/starters.js +2616 -0
- 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, "preprod") ? (
|
|
1561
1561
|
/** @type {EnvName} */
|
|
1562
|
-
"
|
|
1562
|
+
"preprod"
|
|
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-beta.2" : (
|
|
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@beta" : `npx -y ${KOMBAI_CLI_PACKAGE}`;
|
|
2080
|
+
CLI_PACKAGE = true ? "@kombai/cli@beta" : 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, path25) {
|
|
|
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, path25) {
|
|
|
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,14 +4075,15 @@ 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";
|
|
3767
4082
|
init_define_KOMBAI_TELEMETRY();
|
|
3768
4083
|
CODEX_DESKTOP_ORIGINATOR = "Codex Desktop";
|
|
3769
4084
|
FIND_CANVAS_APP = "ALL_TOOLS.filter((t) => t.name.endsWith('canvas_app'))";
|
|
3770
|
-
VIEW_MISSING = "If no canvas_app tool exists, Kombai's view
|
|
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,6 +10014,405 @@ var init_ds = __esm({
|
|
|
9698
10014
|
}
|
|
9699
10015
|
});
|
|
9700
10016
|
|
|
10017
|
+
// src/mcp/install.js
|
|
10018
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
10019
|
+
import fs16 from "node:fs/promises";
|
|
10020
|
+
import path16 from "node:path";
|
|
10021
|
+
function codexHomeOf(env, osHome) {
|
|
10022
|
+
return env.CODEX_HOME ? path16.resolve(env.CODEX_HOME) : path16.join(osHome, ".codex");
|
|
10023
|
+
}
|
|
10024
|
+
async function readClientConfig(clientHome, file2, client) {
|
|
10025
|
+
try {
|
|
10026
|
+
await fs16.stat(clientHome);
|
|
10027
|
+
} catch (error2) {
|
|
10028
|
+
if (!isErrno(error2, "ENOENT")) throw error2;
|
|
10029
|
+
throw new CliError(
|
|
10030
|
+
"CLI_MCP_CLIENT_NOT_FOUND",
|
|
10031
|
+
`${client} hasn't created ${clientHome} yet: open ${client} once, then run this again.`,
|
|
10032
|
+
{ details: { path: clientHome } }
|
|
10033
|
+
);
|
|
10034
|
+
}
|
|
10035
|
+
try {
|
|
10036
|
+
const target = await fs16.realpath(file2);
|
|
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
|
+
};
|
|
10046
|
+
} catch (error2) {
|
|
10047
|
+
if (!isErrno(error2, "ENOENT")) throw error2;
|
|
10048
|
+
let link = null;
|
|
10049
|
+
try {
|
|
10050
|
+
link = await fs16.lstat(file2);
|
|
10051
|
+
} catch (lstatError) {
|
|
10052
|
+
if (!isErrno(lstatError, "ENOENT")) throw lstatError;
|
|
10053
|
+
}
|
|
10054
|
+
if (link?.isSymbolicLink()) throw brokenLink(file2, path16.resolve(path16.dirname(file2), await fs16.readlink(file2)));
|
|
10055
|
+
return { file: file2, target: file2, linked: false, content: "", mode: NEW_CONFIG_MODE, changedAt: 0 };
|
|
10056
|
+
}
|
|
10057
|
+
}
|
|
10058
|
+
function brokenLink(file2, target) {
|
|
10059
|
+
return new CliError(
|
|
10060
|
+
"CLI_MCP_CONFIG_LINK_BROKEN",
|
|
10061
|
+
`${file2} is a link to ${target}, which doesn't exist, so it was left as it is.`,
|
|
10062
|
+
{
|
|
10063
|
+
exit: Exit.REFUSED,
|
|
10064
|
+
next: `Ask the user to restore ${target} or remove the link ${file2}, then run this again.`,
|
|
10065
|
+
details: { path: file2, target }
|
|
10066
|
+
}
|
|
10067
|
+
);
|
|
10068
|
+
}
|
|
10069
|
+
function inlineMcpServers(file2) {
|
|
10070
|
+
return new CliError(
|
|
10071
|
+
"CLI_MCP_CONFIG_UNSUPPORTED",
|
|
10072
|
+
`${file2} sets mcp_servers as one value or with dotted keys, so Kombai can't add its server without breaking the file, which Codex would then refuse.`,
|
|
10073
|
+
{
|
|
10074
|
+
exit: Exit.REFUSED,
|
|
10075
|
+
next: `Ask the user to write the servers in ${file2} as [mcp_servers.<name>] tables, then run this again.`,
|
|
10076
|
+
details: { path: file2 }
|
|
10077
|
+
}
|
|
10078
|
+
);
|
|
10079
|
+
}
|
|
10080
|
+
function foreignEntry(file2, entry = "[mcp_servers.kombai]") {
|
|
10081
|
+
return new CliError(
|
|
10082
|
+
"CLI_MCP_ENTRY_FOREIGN",
|
|
10083
|
+
`${file2} already has a kombai MCP server that Kombai did not add, so it was left as it is.`,
|
|
10084
|
+
{
|
|
10085
|
+
exit: Exit.REFUSED,
|
|
10086
|
+
next: `Ask the user to remove or rename the ${entry} entry in ${file2}, then run this again.`,
|
|
10087
|
+
details: { path: file2 }
|
|
10088
|
+
}
|
|
10089
|
+
);
|
|
10090
|
+
}
|
|
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);
|
|
10104
|
+
if (kind === "foreign" /* Foreign */) throw foreignEntry(file2);
|
|
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
|
+
}
|
|
10114
|
+
if (codexMcpServersInline(content)) throw inlineMcpServers(file2);
|
|
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
|
+
});
|
|
10138
|
+
}
|
|
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
|
+
}
|
|
10146
|
+
}
|
|
10147
|
+
async function uninstallCodexEntry(codexHome) {
|
|
10148
|
+
const { file: file2, target, linked, content, mode } = await readClientConfig(codexHome, codexConfigOf(codexHome), "Codex");
|
|
10149
|
+
const kind = codexKombaiEntryKind(content);
|
|
10150
|
+
if (kind === "foreign" /* Foreign */) throw foreignEntry(file2);
|
|
10151
|
+
if (kind === "none" /* None */) return UninstallOutcome.Absent;
|
|
10152
|
+
const rest = withoutCodexKombaiBlock(content);
|
|
10153
|
+
if (rest === null) return UninstallOutcome.Absent;
|
|
10154
|
+
if (rest === "" && !linked) await fs16.rm(file2);
|
|
10155
|
+
else await writeFileAtomic(target, rest, { mode });
|
|
10156
|
+
return UninstallOutcome.Removed;
|
|
10157
|
+
}
|
|
10158
|
+
var McpClient, InstallOutcome, UninstallOutcome, CODEX_CONFIG, NEW_CONFIG_MODE, codexConfigOf, blockHash, ENTRY_RECORDS;
|
|
10159
|
+
var init_install = __esm({
|
|
10160
|
+
"src/mcp/install.js"() {
|
|
10161
|
+
"use strict";
|
|
10162
|
+
init_define_KOMBAI_TELEMETRY();
|
|
10163
|
+
init_codexKombaiEntry();
|
|
10164
|
+
init_fsx();
|
|
10165
|
+
init_output();
|
|
10166
|
+
init_store();
|
|
10167
|
+
McpClient = Object.freeze({ Codex: "codex", ClaudeCode: "claude-code" });
|
|
10168
|
+
InstallOutcome = Object.freeze({
|
|
10169
|
+
/** There was no `kombai` entry: the CLI's block was added. */
|
|
10170
|
+
Added: "added",
|
|
10171
|
+
/** The CLI's block was there already: nothing was written. */
|
|
10172
|
+
Already: "already",
|
|
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
|
+
*/
|
|
10177
|
+
Replaced: "replaced"
|
|
10178
|
+
});
|
|
10179
|
+
UninstallOutcome = Object.freeze({
|
|
10180
|
+
Removed: "removed",
|
|
10181
|
+
/** There was no Kombai entry to take out. */
|
|
10182
|
+
Absent: "absent"
|
|
10183
|
+
});
|
|
10184
|
+
CODEX_CONFIG = "config.toml";
|
|
10185
|
+
NEW_CONFIG_MODE = 384;
|
|
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);
|
|
10403
|
+
}
|
|
10404
|
+
});
|
|
10405
|
+
|
|
10406
|
+
// ../shared/src/mcp/codexLinks.ts
|
|
10407
|
+
var CODEX_NEW_CHAT_URL;
|
|
10408
|
+
var init_codexLinks = __esm({
|
|
10409
|
+
"../shared/src/mcp/codexLinks.ts"() {
|
|
10410
|
+
"use strict";
|
|
10411
|
+
init_define_KOMBAI_TELEMETRY();
|
|
10412
|
+
CODEX_NEW_CHAT_URL = "codex://threads/new?prompt=";
|
|
10413
|
+
}
|
|
10414
|
+
});
|
|
10415
|
+
|
|
9701
10416
|
// ../../node_modules/zod/v3/helpers/util.js
|
|
9702
10417
|
var util, objectUtil, ZodParsedType, getParsedType;
|
|
9703
10418
|
var init_util = __esm({
|
|
@@ -10108,8 +10823,8 @@ var init_parseUtil = __esm({
|
|
|
10108
10823
|
init_errors();
|
|
10109
10824
|
init_en();
|
|
10110
10825
|
makeIssue = (params) => {
|
|
10111
|
-
const { data, path:
|
|
10112
|
-
const fullPath = [...
|
|
10826
|
+
const { data, path: path28, errorMaps, issueData } = params;
|
|
10827
|
+
const fullPath = [...path28, ...issueData.path || []];
|
|
10113
10828
|
const fullIssue = {
|
|
10114
10829
|
...issueData,
|
|
10115
10830
|
path: fullPath
|
|
@@ -10392,11 +11107,11 @@ var init_types = __esm({
|
|
|
10392
11107
|
init_parseUtil();
|
|
10393
11108
|
init_util();
|
|
10394
11109
|
ParseInputLazyPath = class {
|
|
10395
|
-
constructor(parent, value,
|
|
11110
|
+
constructor(parent, value, path28, key) {
|
|
10396
11111
|
this._cachedPath = [];
|
|
10397
11112
|
this.parent = parent;
|
|
10398
11113
|
this.data = value;
|
|
10399
|
-
this._path =
|
|
11114
|
+
this._path = path28;
|
|
10400
11115
|
this._key = key;
|
|
10401
11116
|
}
|
|
10402
11117
|
get path() {
|
|
@@ -13905,10 +14620,10 @@ function mergeDefs(...defs) {
|
|
|
13905
14620
|
function cloneDef(schema) {
|
|
13906
14621
|
return mergeDefs(schema._zod.def);
|
|
13907
14622
|
}
|
|
13908
|
-
function getElementAtPath(obj,
|
|
13909
|
-
if (!
|
|
14623
|
+
function getElementAtPath(obj, path28) {
|
|
14624
|
+
if (!path28)
|
|
13910
14625
|
return obj;
|
|
13911
|
-
return
|
|
14626
|
+
return path28.reduce((acc, key) => acc?.[key], obj);
|
|
13912
14627
|
}
|
|
13913
14628
|
function promiseAllObject(promisesObj) {
|
|
13914
14629
|
const keys = Object.keys(promisesObj);
|
|
@@ -14220,11 +14935,11 @@ function aborted(x, startIndex = 0) {
|
|
|
14220
14935
|
}
|
|
14221
14936
|
return false;
|
|
14222
14937
|
}
|
|
14223
|
-
function prefixIssues(
|
|
14938
|
+
function prefixIssues(path28, issues) {
|
|
14224
14939
|
return issues.map((iss) => {
|
|
14225
14940
|
var _a3;
|
|
14226
14941
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
14227
|
-
iss.path.unshift(
|
|
14942
|
+
iss.path.unshift(path28);
|
|
14228
14943
|
return iss;
|
|
14229
14944
|
});
|
|
14230
14945
|
}
|
|
@@ -23738,7 +24453,7 @@ var init_protocol = __esm({
|
|
|
23738
24453
|
return;
|
|
23739
24454
|
}
|
|
23740
24455
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
23741
|
-
await new Promise((
|
|
24456
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
23742
24457
|
options?.signal?.throwIfAborted();
|
|
23743
24458
|
}
|
|
23744
24459
|
} catch (error2) {
|
|
@@ -23755,7 +24470,7 @@ var init_protocol = __esm({
|
|
|
23755
24470
|
*/
|
|
23756
24471
|
request(request, resultSchema, options) {
|
|
23757
24472
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
23758
|
-
return new Promise((
|
|
24473
|
+
return new Promise((resolve2, reject) => {
|
|
23759
24474
|
const earlyReject = (error2) => {
|
|
23760
24475
|
reject(error2);
|
|
23761
24476
|
};
|
|
@@ -23833,7 +24548,7 @@ var init_protocol = __esm({
|
|
|
23833
24548
|
if (!parseResult.success) {
|
|
23834
24549
|
reject(parseResult.error);
|
|
23835
24550
|
} else {
|
|
23836
|
-
|
|
24551
|
+
resolve2(parseResult.data);
|
|
23837
24552
|
}
|
|
23838
24553
|
} catch (error2) {
|
|
23839
24554
|
reject(error2);
|
|
@@ -24094,12 +24809,12 @@ var init_protocol = __esm({
|
|
|
24094
24809
|
}
|
|
24095
24810
|
} catch {
|
|
24096
24811
|
}
|
|
24097
|
-
return new Promise((
|
|
24812
|
+
return new Promise((resolve2, reject) => {
|
|
24098
24813
|
if (signal.aborted) {
|
|
24099
24814
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
24100
24815
|
return;
|
|
24101
24816
|
}
|
|
24102
|
-
const timeoutId = setTimeout(
|
|
24817
|
+
const timeoutId = setTimeout(resolve2, interval);
|
|
24103
24818
|
signal.addEventListener("abort", () => {
|
|
24104
24819
|
clearTimeout(timeoutId);
|
|
24105
24820
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -27147,7 +27862,7 @@ var require_compile = __commonJS({
|
|
|
27147
27862
|
const schOrFunc = root.refs[ref];
|
|
27148
27863
|
if (schOrFunc)
|
|
27149
27864
|
return schOrFunc;
|
|
27150
|
-
let _sch =
|
|
27865
|
+
let _sch = resolve2.call(this, root, ref);
|
|
27151
27866
|
if (_sch === void 0) {
|
|
27152
27867
|
const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
|
|
27153
27868
|
const { schemaId } = this.opts;
|
|
@@ -27174,7 +27889,7 @@ var require_compile = __commonJS({
|
|
|
27174
27889
|
function sameSchemaEnv(s1, s2) {
|
|
27175
27890
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
27176
27891
|
}
|
|
27177
|
-
function
|
|
27892
|
+
function resolve2(root, ref) {
|
|
27178
27893
|
let sch;
|
|
27179
27894
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
27180
27895
|
ref = sch;
|
|
@@ -27390,8 +28105,8 @@ var require_utils = __commonJS({
|
|
|
27390
28105
|
}
|
|
27391
28106
|
return ind;
|
|
27392
28107
|
}
|
|
27393
|
-
function removeDotSegments(
|
|
27394
|
-
let input =
|
|
28108
|
+
function removeDotSegments(path28) {
|
|
28109
|
+
let input = path28;
|
|
27395
28110
|
const output = [];
|
|
27396
28111
|
let nextSlash = -1;
|
|
27397
28112
|
let len = 0;
|
|
@@ -27591,8 +28306,8 @@ var require_schemes = __commonJS({
|
|
|
27591
28306
|
wsComponent.secure = void 0;
|
|
27592
28307
|
}
|
|
27593
28308
|
if (wsComponent.resourceName) {
|
|
27594
|
-
const [
|
|
27595
|
-
wsComponent.path =
|
|
28309
|
+
const [path28, query] = wsComponent.resourceName.split("?");
|
|
28310
|
+
wsComponent.path = path28 && path28 !== "/" ? path28 : void 0;
|
|
27596
28311
|
wsComponent.query = query;
|
|
27597
28312
|
wsComponent.resourceName = void 0;
|
|
27598
28313
|
}
|
|
@@ -27752,7 +28467,7 @@ var require_fast_uri = __commonJS({
|
|
|
27752
28467
|
}
|
|
27753
28468
|
return uri;
|
|
27754
28469
|
}
|
|
27755
|
-
function
|
|
28470
|
+
function resolve2(baseURI, relativeURI, options) {
|
|
27756
28471
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
27757
28472
|
const resolved = resolveComponent(parse3(baseURI, schemelessOptions), parse3(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
27758
28473
|
schemelessOptions.skipEscape = true;
|
|
@@ -27979,7 +28694,7 @@ var require_fast_uri = __commonJS({
|
|
|
27979
28694
|
var fastUri = {
|
|
27980
28695
|
SCHEMES,
|
|
27981
28696
|
normalize,
|
|
27982
|
-
resolve,
|
|
28697
|
+
resolve: resolve2,
|
|
27983
28698
|
resolveComponent,
|
|
27984
28699
|
equal,
|
|
27985
28700
|
serialize,
|
|
@@ -30991,12 +31706,12 @@ var require_dist = __commonJS({
|
|
|
30991
31706
|
throw new Error(`Unknown format "${name}"`);
|
|
30992
31707
|
return f;
|
|
30993
31708
|
};
|
|
30994
|
-
function addFormats(ajv, list,
|
|
31709
|
+
function addFormats(ajv, list, fs22, exportName) {
|
|
30995
31710
|
var _a3;
|
|
30996
31711
|
var _b2;
|
|
30997
31712
|
(_a3 = (_b2 = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b2.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
30998
31713
|
for (const f of list)
|
|
30999
|
-
ajv.addFormat(f,
|
|
31714
|
+
ajv.addFormat(f, fs22[f]);
|
|
31000
31715
|
}
|
|
31001
31716
|
module.exports = exports = formatsPlugin;
|
|
31002
31717
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -31679,12 +32394,12 @@ var init_stdio2 = __esm({
|
|
|
31679
32394
|
this.onclose?.();
|
|
31680
32395
|
}
|
|
31681
32396
|
send(message) {
|
|
31682
|
-
return new Promise((
|
|
32397
|
+
return new Promise((resolve2) => {
|
|
31683
32398
|
const json2 = serializeMessage(message);
|
|
31684
32399
|
if (this._stdout.write(json2)) {
|
|
31685
|
-
|
|
32400
|
+
resolve2();
|
|
31686
32401
|
} else {
|
|
31687
|
-
this._stdout.once("drain",
|
|
32402
|
+
this._stdout.once("drain", resolve2);
|
|
31688
32403
|
}
|
|
31689
32404
|
});
|
|
31690
32405
|
}
|
|
@@ -31717,9 +32432,9 @@ var init_kombai_icon = __esm({
|
|
|
31717
32432
|
});
|
|
31718
32433
|
|
|
31719
32434
|
// src/commands/taste.js
|
|
31720
|
-
import { createHash as
|
|
31721
|
-
import
|
|
31722
|
-
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";
|
|
31723
32438
|
async function writeDirections(runDir, envelope) {
|
|
31724
32439
|
const parts = [];
|
|
31725
32440
|
const images = [];
|
|
@@ -31729,7 +32444,7 @@ async function writeDirections(runDir, envelope) {
|
|
|
31729
32444
|
if (text.trim()) parts.push(text);
|
|
31730
32445
|
} else if (item.type === "image" && item.data) {
|
|
31731
32446
|
const extension = IMAGE_EXTENSIONS[item.mimeType ?? ""] ?? "png";
|
|
31732
|
-
const file2 =
|
|
32447
|
+
const file2 = path19.join(runDir, `image-${images.length + 1}.${extension}`);
|
|
31733
32448
|
await writeFileAtomic(file2, Buffer.from(item.data, "base64"), { mode: 420 });
|
|
31734
32449
|
images.push(file2);
|
|
31735
32450
|
parts.push(``);
|
|
@@ -31809,8 +32524,8 @@ var init_taste = __esm({
|
|
|
31809
32524
|
async run(ctx, { flags }) {
|
|
31810
32525
|
await refuseGuest(ctx);
|
|
31811
32526
|
const variants = Number(flags.variants);
|
|
31812
|
-
const briefFile =
|
|
31813
|
-
const brief = await
|
|
32527
|
+
const briefFile = path19.resolve(ctx.cwd, String(flags.brief));
|
|
32528
|
+
const brief = await fs18.readFile(briefFile, "utf8").catch((error2) => {
|
|
31814
32529
|
if (isErrno(error2, "ENOENT"))
|
|
31815
32530
|
throw new CliError("CLI_FILE_MISSING", `${briefFile} does not exist.`, { details: { path: briefFile } });
|
|
31816
32531
|
if (isErrno(error2, "EISDIR"))
|
|
@@ -31829,7 +32544,7 @@ var init_taste = __esm({
|
|
|
31829
32544
|
const checkout2 = await resolveCheckout(ctx.cwd, { platform: ctx.platform, home: ctx.home });
|
|
31830
32545
|
const work = workDir(ctx.home, session.env, checkout2.checkoutId);
|
|
31831
32546
|
await loadWorkspace(work, checkout2);
|
|
31832
|
-
const tasteDir =
|
|
32547
|
+
const tasteDir = path19.join(work, "taste");
|
|
31833
32548
|
await ensureDir(tasteDir);
|
|
31834
32549
|
const fields = {
|
|
31835
32550
|
projectId: checkout2.projectId,
|
|
@@ -31839,8 +32554,8 @@ var init_taste = __esm({
|
|
|
31839
32554
|
...flags.cards === true ? { cards: true } : {},
|
|
31840
32555
|
client: { name: "kombai-cli", version: ctx.version }
|
|
31841
32556
|
};
|
|
31842
|
-
const pendingFile =
|
|
31843
|
-
const key =
|
|
32557
|
+
const pendingFile = path19.join(tasteDir, "pending.json");
|
|
32558
|
+
const key = createHash4("sha256").update(JSON.stringify(fields)).digest("hex");
|
|
31844
32559
|
const pending = (
|
|
31845
32560
|
/** @type {{ key?: string, createId?: string } | undefined} */
|
|
31846
32561
|
await readJson(pendingFile)
|
|
@@ -31861,7 +32576,7 @@ var init_taste = __esm({
|
|
|
31861
32576
|
error2.next = rerun;
|
|
31862
32577
|
}
|
|
31863
32578
|
if (error2 instanceof CliError && error2.code === "TASTE_CREATE_ID_REUSED") {
|
|
31864
|
-
await
|
|
32579
|
+
await fs18.rm(pendingFile, { force: true });
|
|
31865
32580
|
error2.next = rerun;
|
|
31866
32581
|
}
|
|
31867
32582
|
throw explainTasteError(error2, session.hosts.web);
|
|
@@ -31870,10 +32585,10 @@ var init_taste = __esm({
|
|
|
31870
32585
|
if (created.status === "awaiting_files") {
|
|
31871
32586
|
created = (await session.api.call({ method: "POST", path: `/design/taste/${created.run}/start`, body: {} })).body;
|
|
31872
32587
|
}
|
|
31873
|
-
const runDir =
|
|
32588
|
+
const runDir = path19.join(tasteDir, created.run);
|
|
31874
32589
|
await ensureDir(runDir);
|
|
31875
|
-
await writeFileAtomic(
|
|
31876
|
-
await
|
|
32590
|
+
await writeFileAtomic(path19.join(runDir, "brief.md"), brief, { mode: 420 });
|
|
32591
|
+
await fs18.rm(pendingFile, { force: true });
|
|
31877
32592
|
return { run: created.run, status: created.status, next: `kombai taste wait ${created.run}` };
|
|
31878
32593
|
}
|
|
31879
32594
|
};
|
|
@@ -31895,7 +32610,7 @@ var init_taste = __esm({
|
|
|
31895
32610
|
const session = await openSession(ctx, { deadline });
|
|
31896
32611
|
const checkout2 = await resolveCheckout(ctx.cwd, { platform: ctx.platform, home: ctx.home });
|
|
31897
32612
|
const work = workDir(ctx.home, session.env, checkout2.checkoutId);
|
|
31898
|
-
const runDir =
|
|
32613
|
+
const runDir = path19.join(work, "taste", run3);
|
|
31899
32614
|
const again = `kombai taste wait ${run3}`;
|
|
31900
32615
|
let seenRunning = false;
|
|
31901
32616
|
for (; ; ) {
|
|
@@ -31913,8 +32628,8 @@ var init_taste = __esm({
|
|
|
31913
32628
|
const envelope = JSON.parse(new TextDecoder().decode(await session.api.download(state.result.url)));
|
|
31914
32629
|
await loadWorkspace(work, checkout2);
|
|
31915
32630
|
await ensureDir(runDir);
|
|
31916
|
-
await writeJsonAtomic(
|
|
31917
|
-
const directions =
|
|
32631
|
+
await writeJsonAtomic(path19.join(runDir, "result.json"), envelope, { mode: 420 });
|
|
32632
|
+
const directions = path19.join(runDir, "directions.md");
|
|
31918
32633
|
const written = await writeDirections(runDir, envelope);
|
|
31919
32634
|
await writeFileAtomic(directions, written.text, { mode: 420 });
|
|
31920
32635
|
return {
|
|
@@ -31989,7 +32704,7 @@ html,body{margin:0;background:transparent}
|
|
|
31989
32704
|
});
|
|
31990
32705
|
|
|
31991
32706
|
// src/mcp/client-gate.js
|
|
31992
|
-
import
|
|
32707
|
+
import path20 from "node:path";
|
|
31993
32708
|
function declaresMcpApps(capabilities) {
|
|
31994
32709
|
if (!capabilities || typeof capabilities !== "object") return false;
|
|
31995
32710
|
const extensions = (
|
|
@@ -32009,7 +32724,7 @@ function declaresMcpApps(capabilities) {
|
|
|
32009
32724
|
return !Array.isArray(mimeTypes) || mimeTypes.includes(MCP_APP_MIME_TYPE);
|
|
32010
32725
|
}
|
|
32011
32726
|
function isCodexAppWideFolder(cwd, osHome, platform2, codexHome) {
|
|
32012
|
-
const p = platform2 === "win32" ?
|
|
32727
|
+
const p = platform2 === "win32" ? path20.win32 : path20.posix;
|
|
32013
32728
|
const fold = (value) => platform2 === "linux" ? value : value.toLowerCase();
|
|
32014
32729
|
const same = (a, b) => fold(p.resolve(a)) === fold(p.resolve(b));
|
|
32015
32730
|
const resolved = p.resolve(cwd);
|
|
@@ -32074,8 +32789,8 @@ function createLoginRunner(ctx, options = {}) {
|
|
|
32074
32789
|
if (current) return current;
|
|
32075
32790
|
unread.clear();
|
|
32076
32791
|
let markStarted = () => void 0;
|
|
32077
|
-
const started = new Promise((
|
|
32078
|
-
markStarted =
|
|
32792
|
+
const started = new Promise((resolve2) => {
|
|
32793
|
+
markStarted = resolve2;
|
|
32079
32794
|
});
|
|
32080
32795
|
const state = { started, settled: Promise.resolve({ ok: true, claim: null }), waiting: null, linkOpened: false };
|
|
32081
32796
|
let claim2 = null;
|
|
@@ -32147,13 +32862,13 @@ var init_login_runner = __esm({
|
|
|
32147
32862
|
});
|
|
32148
32863
|
|
|
32149
32864
|
// src/mcp/download.js
|
|
32150
|
-
import
|
|
32151
|
-
import
|
|
32865
|
+
import fs19 from "node:fs/promises";
|
|
32866
|
+
import path21 from "node:path";
|
|
32152
32867
|
async function reserveName(dir, stem) {
|
|
32153
32868
|
for (let n = 0; ; n++) {
|
|
32154
|
-
const file2 =
|
|
32869
|
+
const file2 = path21.join(dir, n === 0 ? `${stem}${ZIP}` : `${stem} (${n})${ZIP}`);
|
|
32155
32870
|
try {
|
|
32156
|
-
await (await
|
|
32871
|
+
await (await fs19.open(file2, "wx")).close();
|
|
32157
32872
|
return file2;
|
|
32158
32873
|
} catch (error2) {
|
|
32159
32874
|
if (!isErrno(error2, "EEXIST") || n >= 999) throw error2;
|
|
@@ -32163,16 +32878,16 @@ async function reserveName(dir, stem) {
|
|
|
32163
32878
|
async function saveZip(dir, fileName, bytes) {
|
|
32164
32879
|
const base = fileName.toLowerCase().endsWith(ZIP) ? fileName.slice(0, -ZIP.length) : fileName;
|
|
32165
32880
|
const stem = WINDOWS_DEVICE_NAME_RE.test(base) ? `${base}-canvas` : base;
|
|
32166
|
-
const tmp =
|
|
32881
|
+
const tmp = path21.join(dir, tempName(`.${stem}${ZIP}`));
|
|
32167
32882
|
let file2 = null;
|
|
32168
32883
|
try {
|
|
32169
|
-
await
|
|
32170
|
-
await
|
|
32884
|
+
await fs19.mkdir(dir, { recursive: true });
|
|
32885
|
+
await fs19.writeFile(tmp, bytes, { flag: "wx" });
|
|
32171
32886
|
file2 = await reserveName(dir, stem);
|
|
32172
|
-
await
|
|
32887
|
+
await fs19.rename(tmp, file2);
|
|
32173
32888
|
return file2;
|
|
32174
32889
|
} catch (error2) {
|
|
32175
|
-
await Promise.all([
|
|
32890
|
+
await Promise.all([fs19.rm(tmp, { force: true }), file2 ? fs19.rm(file2, { force: true }) : void 0]).catch(
|
|
32176
32891
|
() => void 0
|
|
32177
32892
|
);
|
|
32178
32893
|
const reason = isErrnoLike(error2) ? error2.code : "the file could not be written";
|
|
@@ -33001,8 +33716,8 @@ var init_sign_in_card = __esm({
|
|
|
33001
33716
|
});
|
|
33002
33717
|
|
|
33003
33718
|
// src/mcp/cards.js
|
|
33004
|
-
import
|
|
33005
|
-
import
|
|
33719
|
+
import fs20 from "node:fs/promises";
|
|
33720
|
+
import path22 from "node:path";
|
|
33006
33721
|
import { fileURLToPath } from "node:url";
|
|
33007
33722
|
function createCards(ctx, options) {
|
|
33008
33723
|
const appBrowser = () => options.appBrowser?.() ?? null;
|
|
@@ -33011,7 +33726,7 @@ function createCards(ctx, options) {
|
|
|
33011
33726
|
const script = (spec) => {
|
|
33012
33727
|
let read2 = scripts.get(spec);
|
|
33013
33728
|
if (!read2) {
|
|
33014
|
-
read2 =
|
|
33729
|
+
read2 = fs20.readFile(path22.join(dir, spec.bundle), "utf8").catch(() => null);
|
|
33015
33730
|
scripts.set(spec, read2);
|
|
33016
33731
|
}
|
|
33017
33732
|
return read2;
|
|
@@ -33028,6 +33743,7 @@ function createCards(ctx, options) {
|
|
|
33028
33743
|
const toolsOf = (spec) => {
|
|
33029
33744
|
if (spec === TASTE) return [tasteTool(uriOf(spec))];
|
|
33030
33745
|
if (spec === PLANS) return [plansTool(uriOf(spec)), checkoutTool()];
|
|
33746
|
+
if (spec === STARTERS) return [startersTool(uriOf(spec))];
|
|
33031
33747
|
if (spec === SIGN_IN) return [signInTool(uriOf(spec)), chatSignInTool(), chatGuestTool()];
|
|
33032
33748
|
return [];
|
|
33033
33749
|
};
|
|
@@ -33081,6 +33797,7 @@ function createCards(ctx, options) {
|
|
|
33081
33797
|
if (name === TASTE_CARD_TOOL2 && specs.includes(TASTE)) return inAppWords(await showTaste(ctx, args, signInBuilt));
|
|
33082
33798
|
if (name === PLANS_CARD_TOOL && specs.includes(PLANS)) return inAppWords(await showPlans(ctx, signInBuilt));
|
|
33083
33799
|
if (name === CHECKOUT_TOOL && specs.includes(PLANS)) return inAppWords(await checkout(ctx, args, signInBuilt));
|
|
33800
|
+
if (name === STARTERS_CARD_TOOL && specs.includes(STARTERS)) return showStarters(args);
|
|
33084
33801
|
if (name === SIGN_IN_CARD_TOOL && specs.includes(SIGN_IN)) {
|
|
33085
33802
|
return showSignIn(ctx, args, appBrowser()?.label ?? null);
|
|
33086
33803
|
}
|
|
@@ -33115,6 +33832,24 @@ async function showTaste(ctx, args, signInBuilt) {
|
|
|
33115
33832
|
return shownWords(`Kombai could not show this taste brief: ${error2.message}`);
|
|
33116
33833
|
}
|
|
33117
33834
|
}
|
|
33835
|
+
function showStarters(args) {
|
|
33836
|
+
const { plugin } = args;
|
|
33837
|
+
if (plugin !== void 0 && (typeof plugin !== "string" || !KOMBAI_PLUGIN.test(plugin))) {
|
|
33838
|
+
return failed("plugin must be Kombai's plugin id in Codex (kombai@ and its marketplace), or left out.");
|
|
33839
|
+
}
|
|
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
|
+
);
|
|
33843
|
+
return {
|
|
33844
|
+
structuredContent: { prompts },
|
|
33845
|
+
content: [
|
|
33846
|
+
{
|
|
33847
|
+
type: "text",
|
|
33848
|
+
text: "Showing prompts to try with Kombai in the chat. Each Try opens a new chat with its prompt. Do not list them in text, and end your turn."
|
|
33849
|
+
}
|
|
33850
|
+
]
|
|
33851
|
+
};
|
|
33852
|
+
}
|
|
33118
33853
|
async function showPlans(ctx, signInBuilt) {
|
|
33119
33854
|
const { hosts } = await currentEnv(ctx);
|
|
33120
33855
|
const plansLink = { url: `${hosts.web}/account/plan` };
|
|
@@ -33238,7 +33973,7 @@ function failed(message) {
|
|
|
33238
33973
|
function shownWords(message) {
|
|
33239
33974
|
return { content: [{ type: "text", text: message }] };
|
|
33240
33975
|
}
|
|
33241
|
-
var TASTE_CARD_TOOL2, PLANS_CARD_TOOL, CHECKOUT_TOOL, SIGN_IN_CARD_TOOL, CHAT_SIGN_IN_TOOL, CHAT_GUEST_TOOL, SIGNIN_REQUIRED, CARDS_DIR, GOOGLE_FONTS, INLINE, TASTE, PLANS, SIGN_IN, specsIn, reads, acts, icons, tasteTool, plansTool, checkoutTool, signInTool, chatSignInTool, chatGuestTool;
|
|
33976
|
+
var TASTE_CARD_TOOL2, PLANS_CARD_TOOL, CHECKOUT_TOOL, SIGN_IN_CARD_TOOL, CHAT_SIGN_IN_TOOL, CHAT_GUEST_TOOL, STARTERS_CARD_TOOL, KOMBAI_PLUGIN, STARTER_PROMPTS, SIGNIN_REQUIRED, CARDS_DIR, GOOGLE_FONTS, INLINE, TASTE, PLANS, SIGN_IN, STARTERS, specsIn, reads, acts, icons, tasteTool, plansTool, checkoutTool, signInTool, startersTool, chatSignInTool, chatGuestTool;
|
|
33242
33977
|
var init_cards = __esm({
|
|
33243
33978
|
"src/mcp/cards.js"() {
|
|
33244
33979
|
"use strict";
|
|
@@ -33259,6 +33994,13 @@ var init_cards = __esm({
|
|
|
33259
33994
|
SIGN_IN_CARD_TOOL = "sign_in_card";
|
|
33260
33995
|
CHAT_SIGN_IN_TOOL = "chat_sign_in";
|
|
33261
33996
|
CHAT_GUEST_TOOL = "chat_guest";
|
|
33997
|
+
STARTERS_CARD_TOOL = "starters_card";
|
|
33998
|
+
KOMBAI_PLUGIN = /^kombai@[A-Za-z0-9][A-Za-z0-9._~-]{0,199}$/;
|
|
33999
|
+
STARTER_PROMPTS = Object.freeze([
|
|
34000
|
+
"Design a standout UI for my website",
|
|
34001
|
+
"Explore design directions on canvas",
|
|
34002
|
+
"Redesign this section for my app"
|
|
34003
|
+
]);
|
|
33262
34004
|
SIGNIN_REQUIRED = "CLI_SIGNIN_REQUIRED";
|
|
33263
34005
|
CARDS_DIR = fileURLToPath(new URL("./mcp-apps/", import.meta.url));
|
|
33264
34006
|
GOOGLE_FONTS = ["https://fonts.googleapis.com", "https://fonts.gstatic.com"];
|
|
@@ -33300,7 +34042,20 @@ var init_cards = __esm({
|
|
|
33300
34042
|
"openai/widgetHeightHint": 180
|
|
33301
34043
|
}
|
|
33302
34044
|
};
|
|
33303
|
-
|
|
34045
|
+
STARTERS = {
|
|
34046
|
+
uriBase: "ui://kombai/cli-starters",
|
|
34047
|
+
bundle: "starters.js",
|
|
34048
|
+
title: "Kombai",
|
|
34049
|
+
rootId: "kombai-starters",
|
|
34050
|
+
global: "__kombaiStarters",
|
|
34051
|
+
// No fetches at all: the prompts come in the tool result, and Try asks the host for a new chat.
|
|
34052
|
+
meta: {
|
|
34053
|
+
ui: { csp: { connectDomains: [], resourceDomains: [] }, prefersBorder: true },
|
|
34054
|
+
...INLINE,
|
|
34055
|
+
"openai/widgetHeightHint": 320
|
|
34056
|
+
}
|
|
34057
|
+
};
|
|
34058
|
+
specsIn = (set2) => set2 === Cards.All ? [TASTE, PLANS, STARTERS, SIGN_IN] : set2 === Cards.Taste ? [TASTE] : [];
|
|
33304
34059
|
reads = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
33305
34060
|
acts = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true };
|
|
33306
34061
|
icons = () => KOMBAI_ICONS.map((icon) => ({ ...icon, sizes: [...icon.sizes] }));
|
|
@@ -33369,6 +34124,24 @@ var init_cards = __esm({
|
|
|
33369
34124
|
annotations: reads,
|
|
33370
34125
|
_meta: { ui: { resourceUri, visibility: ["model", "app"] } }
|
|
33371
34126
|
});
|
|
34127
|
+
startersTool = (resourceUri) => ({
|
|
34128
|
+
name: STARTERS_CARD_TOOL,
|
|
34129
|
+
title: "Try Kombai",
|
|
34130
|
+
description: "Show prompts to try with Kombai as a card in this chat. Each has a Try button that opens a new chat with its prompt filled in. Call it at the end of Kombai's onboarding, with plugin set to the Kombai plugin id the onboarding skill gives, then end your turn with one line. Do not list the prompts in text.",
|
|
34131
|
+
inputSchema: {
|
|
34132
|
+
type: "object",
|
|
34133
|
+
properties: {
|
|
34134
|
+
plugin: {
|
|
34135
|
+
type: "string",
|
|
34136
|
+
description: "Kombai's plugin id in Codex, e.g. kombai@openai-curated-remote: each prompt mentions it. Leave it out to name Kombai in words."
|
|
34137
|
+
}
|
|
34138
|
+
},
|
|
34139
|
+
additionalProperties: false
|
|
34140
|
+
},
|
|
34141
|
+
icons: icons(),
|
|
34142
|
+
annotations: reads,
|
|
34143
|
+
_meta: { ui: { resourceUri, visibility: ["model", "app"] } }
|
|
34144
|
+
});
|
|
33372
34145
|
chatSignInTool = () => ({
|
|
33373
34146
|
name: CHAT_SIGN_IN_TOOL,
|
|
33374
34147
|
title: "Sign in to Kombai",
|
|
@@ -34229,7 +35002,7 @@ html.dark #cover{background:rgba(30,30,30,.6)}
|
|
|
34229
35002
|
|
|
34230
35003
|
// src/mcp/server.js
|
|
34231
35004
|
import os2 from "node:os";
|
|
34232
|
-
import
|
|
35005
|
+
import path23 from "node:path";
|
|
34233
35006
|
function createMcpServer(ctx, options = {}) {
|
|
34234
35007
|
const place = {
|
|
34235
35008
|
cwd: ctx.cwd,
|
|
@@ -34255,7 +35028,7 @@ function createMcpServer(ctx, options = {}) {
|
|
|
34255
35028
|
const login2 = createLoginRunner(ctx, { inApp: () => appBrowser() !== null });
|
|
34256
35029
|
const callSession = createSessionTool(ctx, { login: login2 });
|
|
34257
35030
|
const cards = createCards(ctx, { dir: options.cardsDir, login: login2, appBrowser });
|
|
34258
|
-
const downloadsDir =
|
|
35031
|
+
const downloadsDir = path23.join(place.osHome, "Downloads");
|
|
34259
35032
|
const resourceMeta = async () => {
|
|
34260
35033
|
const { hosts } = await currentEnv(ctx);
|
|
34261
35034
|
return {
|
|
@@ -34342,14 +35115,14 @@ function createMcpServer(ctx, options = {}) {
|
|
|
34342
35115
|
async function startMcpServer(ctx) {
|
|
34343
35116
|
const server = createMcpServer(ctx);
|
|
34344
35117
|
process.stderr.on("error", () => void 0);
|
|
34345
|
-
await new Promise((
|
|
35118
|
+
await new Promise((resolve2) => {
|
|
34346
35119
|
let done = false;
|
|
34347
35120
|
const finish2 = (why) => {
|
|
34348
35121
|
if (done) return;
|
|
34349
35122
|
done = true;
|
|
34350
35123
|
ctx.stderr.write(`kombai mcp: ${why}
|
|
34351
35124
|
`);
|
|
34352
|
-
void server.close().catch(() => void 0).finally(() =>
|
|
35125
|
+
void server.close().catch(() => void 0).finally(() => resolve2(void 0));
|
|
34353
35126
|
};
|
|
34354
35127
|
installClientDisconnectHooks({
|
|
34355
35128
|
stdin: process.stdin,
|
|
@@ -34454,7 +35227,7 @@ var init_brief = __esm({
|
|
|
34454
35227
|
var claude_desktop_default;
|
|
34455
35228
|
var init_claude_desktop = __esm({
|
|
34456
35229
|
"src/skill/claude-desktop.md"() {
|
|
34457
|
-
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";
|
|
34458
35231
|
}
|
|
34459
35232
|
});
|
|
34460
35233
|
|
|
@@ -34462,7 +35235,7 @@ var init_claude_desktop = __esm({
|
|
|
34462
35235
|
var codex_desktop_default;
|
|
34463
35236
|
var init_codex_desktop = __esm({
|
|
34464
35237
|
"src/skill/codex-desktop.md"() {
|
|
34465
|
-
codex_desktop_default = "You are running in the Codex app. Notes for it:\n\n- Kombai's tools here (canvas_app, sign_in_card, taste_card, plans_card) are not listed up front. Find them in\n exec with `ALL_TOOLS.filter((t) => t.name.startsWith('mcp__kombai'))` before you decide one is missing.\n- The canvas: Kombai's view, the canvas_app tool, is the only way to show it here. Call it with the canvas id\n right after `kombai canvas create`, before you write any design, or when you first use a canvas that isn't\n already open beside the chat, as `kombai skill opening` says. Never open a canvas in a browser or the in-app\n browser, and put no canvas or design link in a reply: the commands print none here, and a user who wants one\n copies it from the view (the canvas's Share, or a design's Copy link).\n- Taste: add --cards to every `kombai taste start`, and call taste_card when `kombai taste wait` answers with\n card.\n";
|
|
35238
|
+
codex_desktop_default = "You are running in the Codex app. Notes for it:\n\n- Kombai's tools here (canvas_app, sign_in_card, taste_card, plans_card) are not listed up front. Find them in\n exec with `ALL_TOOLS.filter((t) => t.name.startsWith('mcp__kombai'))` before you decide one is missing. Do that\n first, before any design work: if none exist, set up Kombai's view as `kombai skill opening` says and move the\n work to a new task, since this one can't show the canvas.\n- The canvas: Kombai's view, the canvas_app tool, is the only way to show it here. Call it with the canvas id\n right after `kombai canvas create`, before you write any design, or when you first use a canvas that isn't\n already open beside the chat, as `kombai skill opening` says. Never open a canvas in a browser or the in-app\n browser, and put no canvas or design link in a reply: the commands print none here, and a user who wants one\n copies it from the view (the canvas's Share, or a design's Copy link).\n- Taste: add --cards to every `kombai taste start`, and call taste_card when `kombai taste wait` answers with\n card.\n";
|
|
34466
35239
|
}
|
|
34467
35240
|
});
|
|
34468
35241
|
|
|
@@ -34502,7 +35275,7 @@ var init_html = __esm({
|
|
|
34502
35275
|
var opening_codex_default;
|
|
34503
35276
|
var init_opening_codex = __esm({
|
|
34504
35277
|
"src/skill/opening-codex.md"() {
|
|
34505
|
-
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?**
|
|
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";
|
|
34506
35279
|
}
|
|
34507
35280
|
});
|
|
34508
35281
|
|
|
@@ -34510,7 +35283,7 @@ var init_opening_codex = __esm({
|
|
|
34510
35283
|
var opening_default;
|
|
34511
35284
|
var init_opening = __esm({
|
|
34512
35285
|
"src/skill/opening.md"() {
|
|
34513
|
-
opening_default = "# Showing the canvas\n\nShow a canvas to the user once, when you create or first use it. The page updates live as you push, so\nnever open it again after a push. Pick the first of these that fits:\n\n1. **A `canvas_app` tool is among your tools** (the Kombai view; the Codex app lists no MCP tool up front, so\n filter ALL_TOOLS for canvas_app there before you pick): call `canvas_app` with the canvas id, and `node`\n set to a design id to focus one. It shows the canvas beside the chat. Call it once per canvas: each call\n opens another view. Make changes with the commands, never through the view.\n2. **No `canvas_app`, and you have a browser panel the user can see** (the one you sign in with,\n `kombai skill sign-in`: the Claude desktop app's Browser pane, VS Code's Integrated Browser through\n `open_browser_page`): `kombai canvas url --canvas <id> --in-app` prints a signed-in link. Open it in your\n panel. It works once, within 10 minutes; for a later visit, run it again.\n3. **Otherwise**: `kombai canvas open --canvas <id>` opens the canvas in the user's browser, signed in.\n If it answers opened: false (no browser on this machine), give the user the link it printed instead.\n\nIn the Codex app use 1 alone: with no canvas_app there,
|
|
35286
|
+
opening_default = "# Showing the canvas\n\nShow a canvas to the user once, when you create or first use it. The page updates live as you push, so\nnever open it again after a push. Pick the first of these that fits:\n\n1. **A `canvas_app` tool is among your tools** (the Kombai view; the Codex app lists no MCP tool up front, so\n filter ALL_TOOLS for canvas_app there before you pick): call `canvas_app` with the canvas id, and `node`\n set to a design id to focus one. It shows the canvas beside the chat. Call it once per canvas: each call\n opens another view. Make changes with the commands, never through the view.\n2. **No `canvas_app`, and you have a browser panel the user can see** (the one you sign in with,\n `kombai skill sign-in`: the Claude desktop app's Browser pane, VS Code's Integrated Browser through\n `open_browser_page`): `kombai canvas url --canvas <id> --in-app` prints a signed-in link. Open it in your\n panel. It works once, within 10 minutes; for a later visit, run it again.\n3. **Otherwise**: `kombai canvas open --canvas <id>` opens the canvas in the user's browser, signed in.\n If it answers opened: false (no browser on this machine), give the user the link it printed instead.\n\nIn the Codex app use 1 alone: with no canvas_app there, run `kombai mcp install codex` without asking and continue in\na new task, and show no link.\n\nTo point the user at one design, give the `url` node start, node pull or node push printed for it, or\nadd ?node=<node> to the canvas link. Never the design's .html file, and never a link that holds a\n#ticket=; it signs in whoever opens it first.\n\n**Beside the chat, no links.** Once `canvas_app` shows the canvas, the user watches every change there.\nEnd with a short line on what you made or changed, naming designs by their labels. Put no canvas or\ndesign link in your replies, and don't ask the user to open the canvas. Give a link only when the user\nasks for one.\n\n**A new canvas is private.** When you give the user a link, don't suggest they send it to anyone before sharing it.\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 and teammates can edit it.\n";
|
|
34514
35287
|
}
|
|
34515
35288
|
});
|
|
34516
35289
|
|
|
@@ -34531,6 +35304,7 @@ var init_sign_in = __esm({
|
|
|
34531
35304
|
});
|
|
34532
35305
|
|
|
34533
35306
|
// src/commands/skill.js
|
|
35307
|
+
import os3 from "node:os";
|
|
34534
35308
|
function skillAppOf(ctx) {
|
|
34535
35309
|
return ctx.codexDesktop ? "codex-desktop" : ctx.claudeDesktop ? "claude-desktop" : null;
|
|
34536
35310
|
}
|
|
@@ -34542,13 +35316,30 @@ function fillSkillText(text, app) {
|
|
|
34542
35316
|
function topicText(topic, app) {
|
|
34543
35317
|
return fillSkillText(topic === "opening" && app === "codex-desktop" ? opening_codex_default : TOPICS[topic], app);
|
|
34544
35318
|
}
|
|
34545
|
-
|
|
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;
|
|
34546
35334
|
var init_skill = __esm({
|
|
34547
35335
|
"src/commands/skill.js"() {
|
|
34548
35336
|
"use strict";
|
|
34549
35337
|
init_define_KOMBAI_TELEMETRY();
|
|
35338
|
+
init_codexKombaiEntry();
|
|
34550
35339
|
init_output();
|
|
34551
35340
|
init_version();
|
|
35341
|
+
init_install();
|
|
35342
|
+
init_install_claude_code();
|
|
34552
35343
|
init_actions();
|
|
34553
35344
|
init_brief();
|
|
34554
35345
|
init_claude_desktop();
|
|
@@ -34575,6 +35366,7 @@ var init_skill = __esm({
|
|
|
34575
35366
|
RUN = `Commands here and in a result's next are written as \`kombai <command>\`. Run each as
|
|
34576
35367
|
\`${CLI_RUN} <command>\`, in full, never from a variable.`;
|
|
34577
35368
|
APP_NOTES = { "claude-desktop": claude_desktop_default, "codex-desktop": codex_desktop_default };
|
|
35369
|
+
CHANNEL_NOTES = { "codex-desktop": viewChannelNote, "claude-desktop": serverChannelNote };
|
|
34578
35370
|
skill = {
|
|
34579
35371
|
name: "skill",
|
|
34580
35372
|
summary: "Print the skill's text, or one topic of it. Plain text: these are the agent's instructions.",
|
|
@@ -34588,10 +35380,12 @@ var init_skill = __esm({
|
|
|
34588
35380
|
details: { topics: Object.keys(TOPICS) }
|
|
34589
35381
|
});
|
|
34590
35382
|
}
|
|
34591
|
-
ctx
|
|
35383
|
+
const app = skillAppOf(ctx);
|
|
35384
|
+
const note = topic === "overview" && app ? await CHANNEL_NOTES[app]() : "";
|
|
35385
|
+
ctx.stdout.write(`${note}${topicText(
|
|
34592
35386
|
/** @type {keyof typeof TOPICS} */
|
|
34593
35387
|
topic,
|
|
34594
|
-
|
|
35388
|
+
app
|
|
34595
35389
|
)}
|
|
34596
35390
|
`);
|
|
34597
35391
|
return { [PLAIN_TEXT]: true };
|
|
@@ -34602,14 +35396,153 @@ var init_skill = __esm({
|
|
|
34602
35396
|
});
|
|
34603
35397
|
|
|
34604
35398
|
// src/commands/mcp.js
|
|
34605
|
-
|
|
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;
|
|
34606
35449
|
var init_mcp = __esm({
|
|
34607
35450
|
"src/commands/mcp.js"() {
|
|
34608
35451
|
"use strict";
|
|
34609
35452
|
init_define_KOMBAI_TELEMETRY();
|
|
35453
|
+
init_install();
|
|
35454
|
+
init_install_claude_code();
|
|
35455
|
+
init_codexLinks();
|
|
35456
|
+
init_codexKombaiEntry();
|
|
35457
|
+
init_codex_app();
|
|
35458
|
+
init_version();
|
|
34610
35459
|
init_server3();
|
|
34611
35460
|
init_output();
|
|
34612
35461
|
init_skill();
|
|
35462
|
+
CLIENT_ARG = [{ name: "client", required: true, values: Object.values(McpClient) }];
|
|
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.";
|
|
35469
|
+
mcpInstall = {
|
|
35470
|
+
name: "mcp install",
|
|
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.",
|
|
35472
|
+
args: CLIENT_ARG,
|
|
35473
|
+
example: "kombai mcp install codex",
|
|
35474
|
+
async run(ctx, { args }) {
|
|
35475
|
+
if (args[0] === McpClient.ClaudeCode) return installClaudeCode(ctx);
|
|
35476
|
+
const codexHome = codexHomeOf(process.env, os4.homedir());
|
|
35477
|
+
const config2 = codexConfigOf(codexHome);
|
|
35478
|
+
const install = await installCodexEntry(codexHome, ctx.platform, CLI_PACKAGE);
|
|
35479
|
+
const { outcome } = install;
|
|
35480
|
+
if (install.disabled) {
|
|
35481
|
+
return {
|
|
35482
|
+
client: McpClient.Codex,
|
|
35483
|
+
outcome,
|
|
35484
|
+
config: config2,
|
|
35485
|
+
disabled: true,
|
|
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.`
|
|
35487
|
+
};
|
|
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
|
+
}
|
|
35517
|
+
return {
|
|
35518
|
+
client: McpClient.Codex,
|
|
35519
|
+
outcome,
|
|
35520
|
+
config: config2,
|
|
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
|
|
35522
|
+
};
|
|
35523
|
+
}
|
|
35524
|
+
};
|
|
35525
|
+
mcpUninstall = {
|
|
35526
|
+
name: "mcp uninstall",
|
|
35527
|
+
summary: "Remove the entry `kombai mcp install` added.",
|
|
35528
|
+
args: CLIENT_ARG,
|
|
35529
|
+
example: "kombai mcp uninstall codex",
|
|
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 };
|
|
35544
|
+
}
|
|
35545
|
+
};
|
|
34613
35546
|
mcp = {
|
|
34614
35547
|
name: "mcp",
|
|
34615
35548
|
summary: "Serve Kombai's canvas view and cards to Codex and Claude Code over stdin and stdout. The agent starts it; people don't run it.",
|
|
@@ -34630,8 +35563,8 @@ var init_mcp = __esm({
|
|
|
34630
35563
|
});
|
|
34631
35564
|
|
|
34632
35565
|
// src/commands/node.js
|
|
34633
|
-
import
|
|
34634
|
-
import
|
|
35566
|
+
import fs21 from "node:fs/promises";
|
|
35567
|
+
import path24 from "node:path";
|
|
34635
35568
|
async function placeText(cc) {
|
|
34636
35569
|
try {
|
|
34637
35570
|
const read2 = (await cc.session.api.call({ method: "GET", path: `/design/canvases/${cc.canvasId}` })).body;
|
|
@@ -34673,10 +35606,10 @@ function rectFrom(value) {
|
|
|
34673
35606
|
return { x, y, w, h };
|
|
34674
35607
|
}
|
|
34675
35608
|
async function readDrawingFile(ctx, given2) {
|
|
34676
|
-
const file2 =
|
|
35609
|
+
const file2 = path24.resolve(ctx.cwd, given2);
|
|
34677
35610
|
let bytes;
|
|
34678
35611
|
try {
|
|
34679
|
-
bytes = new Uint8Array(await
|
|
35612
|
+
bytes = new Uint8Array(await fs21.readFile(file2));
|
|
34680
35613
|
} catch (error2) {
|
|
34681
35614
|
if (isErrno(error2, "ENOENT"))
|
|
34682
35615
|
throw new CliError("CLI_FILE_MISSING", `${file2} does not exist.`, { details: { path: file2 } });
|
|
@@ -34931,7 +35864,7 @@ async function pushDrawing(ctx, cc, projectId, nodeId, entry, saved) {
|
|
|
34931
35864
|
if (!saved && sent === entry.files.content) {
|
|
34932
35865
|
return { nodeId, status: "unchanged", version: entry.version, images: { uploaded: 0, stored: 0 } };
|
|
34933
35866
|
}
|
|
34934
|
-
const before = parseStored(await
|
|
35867
|
+
const before = parseStored(await fs21.readFile(baseFile(paths, nodeId, "content")).catch(() => null));
|
|
34935
35868
|
const images = await storeDrawingPicture(cc, projectId, drawing, file2, nodeId, before?.src);
|
|
34936
35869
|
const body = {
|
|
34937
35870
|
ifVersion: saved?.version ?? entry.version,
|
|
@@ -35008,7 +35941,7 @@ async function storeDrawingPicture(cc, projectId, drawing, file2, nodeId, stored
|
|
|
35008
35941
|
}
|
|
35009
35942
|
throw error2;
|
|
35010
35943
|
}
|
|
35011
|
-
if (image.sha256 !==
|
|
35944
|
+
if (image.sha256 !== path24.posix.basename(src).split(".")[0]) {
|
|
35012
35945
|
throw badDrawing(
|
|
35013
35946
|
file2,
|
|
35014
35947
|
nodeId,
|
|
@@ -35130,14 +36063,14 @@ async function explainGone(ctx, cc, nodeId, error2) {
|
|
|
35130
36063
|
}
|
|
35131
36064
|
async function saveConflict2(paths, canvasId, nodeId, stored, files) {
|
|
35132
36065
|
await removeRemotes(paths, nodeId);
|
|
35133
|
-
const dir =
|
|
35134
|
-
await
|
|
35135
|
-
if (files.html) await writeFileAtomic(
|
|
35136
|
-
if (files.overrides) await writeFileAtomic(
|
|
35137
|
-
if (files.content) await writeFileAtomic(
|
|
35138
|
-
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 });
|
|
35139
36072
|
await writeJsonAtomic(
|
|
35140
|
-
|
|
36073
|
+
path24.join(dir, "node.json"),
|
|
35141
36074
|
{ version: stored.version, state: stored.state, modifiedBy: stored.modifiedBy, node: stored.node },
|
|
35142
36075
|
{ mode: 420 }
|
|
35143
36076
|
);
|
|
@@ -35160,16 +36093,16 @@ async function saveConflict2(paths, canvasId, nodeId, stored, files) {
|
|
|
35160
36093
|
);
|
|
35161
36094
|
}
|
|
35162
36095
|
async function latestRemote2(paths, nodeId) {
|
|
35163
|
-
const names = await
|
|
36096
|
+
const names = await fs21.readdir(paths.remote).catch(() => (
|
|
35164
36097
|
/** @type {string[]} */
|
|
35165
36098
|
[]
|
|
35166
36099
|
));
|
|
35167
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);
|
|
35168
36101
|
if (!versions.length) return null;
|
|
35169
|
-
const dir =
|
|
36102
|
+
const dir = path24.join(paths.remote, `${nodeId}@v${versions[0]}`);
|
|
35170
36103
|
const saved = (
|
|
35171
36104
|
/** @type {{ version?: number, node?: unknown } | undefined} */
|
|
35172
|
-
await readJson(
|
|
36105
|
+
await readJson(path24.join(dir, "node.json"))
|
|
35173
36106
|
);
|
|
35174
36107
|
const node = saved?.node && typeof saved.node === "object" ? (
|
|
35175
36108
|
/** @type {Record<string, unknown>} */
|
|
@@ -35191,7 +36124,7 @@ async function readNode(cc, nodeId) {
|
|
|
35191
36124
|
}
|
|
35192
36125
|
async function readWorking(paths, nodeId, kind) {
|
|
35193
36126
|
try {
|
|
35194
|
-
return new Uint8Array(await
|
|
36127
|
+
return new Uint8Array(await fs21.readFile(workingFile(paths, nodeId, kind)));
|
|
35195
36128
|
} catch (error2) {
|
|
35196
36129
|
if (isErrno(error2, "ENOENT")) return null;
|
|
35197
36130
|
throw error2;
|
|
@@ -35199,7 +36132,7 @@ async function readWorking(paths, nodeId, kind) {
|
|
|
35199
36132
|
}
|
|
35200
36133
|
async function baseCopies2(paths, nodeId, entry) {
|
|
35201
36134
|
const files = {};
|
|
35202
|
-
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));
|
|
35203
36136
|
return files;
|
|
35204
36137
|
}
|
|
35205
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;
|
|
@@ -35335,11 +36268,11 @@ var init_node = __esm({
|
|
|
35335
36268
|
return Object.keys(base.nodes).length === 0 && Object.keys(base.starts).length === 0;
|
|
35336
36269
|
});
|
|
35337
36270
|
if (fresh && unused && (error2.status === 404 || error2.status === 410)) {
|
|
35338
|
-
const files = await
|
|
36271
|
+
const files = await fs21.readdir(paths.nodes).catch(() => (
|
|
35339
36272
|
/** @type {string[]} */
|
|
35340
36273
|
[]
|
|
35341
36274
|
));
|
|
35342
|
-
if (!files.length) await
|
|
36275
|
+
if (!files.length) await fs21.rm(paths.dir, { recursive: true, force: true });
|
|
35343
36276
|
}
|
|
35344
36277
|
}
|
|
35345
36278
|
throw await canvasGone(cc, error2);
|
|
@@ -35464,7 +36397,7 @@ var init_node = __esm({
|
|
|
35464
36397
|
type,
|
|
35465
36398
|
version: read2.version,
|
|
35466
36399
|
state: read2.state,
|
|
35467
|
-
file: info.file ?
|
|
36400
|
+
file: info.file ? path24.join(paths.dir, info.file) : null,
|
|
35468
36401
|
...linkField(ctx, nodeLink(cc, nodeId)),
|
|
35469
36402
|
overrides: files.overrides ? workingFile(paths, nodeId, "overrides") : null,
|
|
35470
36403
|
images: read2.images ?? [],
|
|
@@ -35692,7 +36625,7 @@ var init_pngtiles = __esm({
|
|
|
35692
36625
|
|
|
35693
36626
|
// src/commands/screenshot.js
|
|
35694
36627
|
import { execFile as execFile2 } from "node:child_process";
|
|
35695
|
-
import
|
|
36628
|
+
import path25 from "node:path";
|
|
35696
36629
|
async function writeTiles(ctx, dir, nodeId, version2, png, screenshotFile) {
|
|
35697
36630
|
const tiles = png ? pngTiles(png, TILE_HEIGHT) : null;
|
|
35698
36631
|
if (!tiles) {
|
|
@@ -35703,8 +36636,8 @@ async function writeTiles(ctx, dir, nodeId, version2, png, screenshotFile) {
|
|
|
35703
36636
|
});
|
|
35704
36637
|
return [screenshotFile];
|
|
35705
36638
|
}
|
|
35706
|
-
if (tiles.length === 1) return [
|
|
35707
|
-
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`));
|
|
35708
36641
|
await Promise.all(files.map((file2, i) => writeFileAtomic(file2, tiles[i], { mode: 420 })));
|
|
35709
36642
|
return files;
|
|
35710
36643
|
}
|
|
@@ -35726,35 +36659,35 @@ function waitTimedOut(canvasId, nodeId) {
|
|
|
35726
36659
|
);
|
|
35727
36660
|
}
|
|
35728
36661
|
function askVersion(browserPath, timeoutMs = 1e4) {
|
|
35729
|
-
return new Promise((
|
|
36662
|
+
return new Promise((resolve2) => {
|
|
35730
36663
|
execFile2(browserPath, ["--version"], { timeout: timeoutMs, windowsHide: true }, (error2, stdout, stderr) => {
|
|
35731
36664
|
const version2 = String(stdout).trim();
|
|
35732
|
-
if (!error2 && CHROMIUM_VERSION.test(version2)) return
|
|
36665
|
+
if (!error2 && CHROMIUM_VERSION.test(version2)) return resolve2({ version: version2, problem: "" });
|
|
35733
36666
|
const said = String(stderr).trim().split(/\r?\n/)[0] || error2?.message || version2 || "it printed nothing";
|
|
35734
|
-
|
|
36667
|
+
resolve2({ version: null, problem: said.slice(0, 300) });
|
|
35735
36668
|
});
|
|
35736
36669
|
});
|
|
35737
36670
|
}
|
|
35738
36671
|
function fileVersion(browserPath) {
|
|
35739
36672
|
const script = '$i = (Get-Item -LiteralPath $env:KOMBAI_BROWSER_PROBE).VersionInfo; $i.ProductName + " " + $i.ProductVersion';
|
|
35740
|
-
return new Promise((
|
|
36673
|
+
return new Promise((resolve2) => {
|
|
35741
36674
|
execFile2(
|
|
35742
36675
|
"powershell.exe",
|
|
35743
36676
|
["-NoProfile", "-NonInteractive", "-Command", script],
|
|
35744
36677
|
{ timeout: 1e4, windowsHide: true, env: { ...process.env, KOMBAI_BROWSER_PROBE: browserPath } },
|
|
35745
36678
|
(error2, stdout) => {
|
|
35746
36679
|
const version2 = String(stdout).trim();
|
|
35747
|
-
|
|
36680
|
+
resolve2(!error2 && CHROMIUM_VERSION.test(version2) ? version2 : null);
|
|
35748
36681
|
}
|
|
35749
36682
|
);
|
|
35750
36683
|
});
|
|
35751
36684
|
}
|
|
35752
36685
|
function readLine() {
|
|
35753
|
-
return new Promise((
|
|
36686
|
+
return new Promise((resolve2) => {
|
|
35754
36687
|
process.stdin.setEncoding("utf8");
|
|
35755
36688
|
process.stdin.once("data", (data) => {
|
|
35756
36689
|
process.stdin.pause();
|
|
35757
|
-
|
|
36690
|
+
resolve2(String(data).trim());
|
|
35758
36691
|
});
|
|
35759
36692
|
});
|
|
35760
36693
|
}
|
|
@@ -35800,7 +36733,7 @@ var init_screenshot = __esm({
|
|
|
35800
36733
|
if (named2 && flags.canvas === void 0) {
|
|
35801
36734
|
throw new CliError("CLI_BAD_FLAG", "--node needs --canvas.", { next: "kombai screenshot fill --help" });
|
|
35802
36735
|
}
|
|
35803
|
-
const browserFlag = flags.browser === void 0 ? void 0 :
|
|
36736
|
+
const browserFlag = flags.browser === void 0 ? void 0 : path25.resolve(ctx.cwd, String(flags.browser));
|
|
35804
36737
|
if (browserFlag) {
|
|
35805
36738
|
await checkNamedBrowser(
|
|
35806
36739
|
browserFlag,
|
|
@@ -36008,14 +36941,14 @@ var init_screenshot = __esm({
|
|
|
36008
36941
|
if (shot.state === "ok" && shot.screenshot) {
|
|
36009
36942
|
const dir = canvasPaths(cc.work, canvasId).screenshots;
|
|
36010
36943
|
await ensureDir(dir);
|
|
36011
|
-
const screenshotFile =
|
|
36944
|
+
const screenshotFile = path25.join(dir, `${nodeId}@v${read2.version}.jpg`);
|
|
36012
36945
|
await writeFileAtomic(screenshotFile, await cc.session.api.download(shot.screenshot, deadline), {
|
|
36013
36946
|
mode: 420
|
|
36014
36947
|
});
|
|
36015
36948
|
let screenshotPngFile = null;
|
|
36016
36949
|
let png = null;
|
|
36017
36950
|
if (shot.screenshotPng) {
|
|
36018
|
-
screenshotPngFile =
|
|
36951
|
+
screenshotPngFile = path25.join(dir, `${nodeId}@v${read2.version}.png`);
|
|
36019
36952
|
png = await cc.session.api.download(shot.screenshotPng, deadline);
|
|
36020
36953
|
await writeFileAtomic(screenshotPngFile, png, { mode: 420 });
|
|
36021
36954
|
}
|
|
@@ -36078,7 +37011,7 @@ var init_screenshot = __esm({
|
|
|
36078
37011
|
);
|
|
36079
37012
|
}
|
|
36080
37013
|
ctx.stderr.write(
|
|
36081
|
-
`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] `
|
|
36082
37015
|
);
|
|
36083
37016
|
if (!/^y(es)?$/i.test(await readLine())) throw new CliError("CLI_CANCELLED", "Nothing was downloaded.");
|
|
36084
37017
|
}
|
|
@@ -36088,7 +37021,7 @@ var init_screenshot = __esm({
|
|
|
36088
37021
|
/** @type {typeof import('../render/install-entry.js')} */
|
|
36089
37022
|
await import(INSTALL_MODULE)
|
|
36090
37023
|
);
|
|
36091
|
-
const executable = await installHeadlessShell(
|
|
37024
|
+
const executable = await installHeadlessShell(path25.join(ctx.home, "browser"), PINNED_BUILD);
|
|
36092
37025
|
const answer2 = await askVersion(executable, 3e4);
|
|
36093
37026
|
if (!answer2.version) {
|
|
36094
37027
|
throw new CliError(
|
|
@@ -36106,7 +37039,7 @@ var init_screenshot = __esm({
|
|
|
36106
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.",
|
|
36107
37040
|
args: [{ name: "path", required: true }],
|
|
36108
37041
|
async run(ctx, { args }) {
|
|
36109
|
-
const browserPath =
|
|
37042
|
+
const browserPath = path25.resolve(ctx.cwd, args[0]);
|
|
36110
37043
|
await checkNamedBrowser(browserPath, "Give the path of a Chromium browser's program.");
|
|
36111
37044
|
const version2 = (ctx.platform === "win32" ? await fileVersion(browserPath) : null) ?? (await askVersion(browserPath)).version;
|
|
36112
37045
|
if (!version2) {
|
|
@@ -36177,24 +37110,26 @@ var init_commands = __esm({
|
|
|
36177
37110
|
browserInstall,
|
|
36178
37111
|
configBrowser,
|
|
36179
37112
|
skill,
|
|
36180
|
-
mcp
|
|
37113
|
+
mcp,
|
|
37114
|
+
mcpInstall,
|
|
37115
|
+
mcpUninstall
|
|
36181
37116
|
];
|
|
36182
37117
|
}
|
|
36183
37118
|
});
|
|
36184
37119
|
|
|
36185
37120
|
// src/lib/app-skills.js
|
|
36186
37121
|
import { access, lstat, readdir, rm } from "node:fs/promises";
|
|
36187
|
-
import
|
|
37122
|
+
import path26 from "node:path";
|
|
36188
37123
|
function appSkillDirsOf(home, env) {
|
|
36189
37124
|
const dirs = [
|
|
36190
|
-
|
|
36191
|
-
|
|
36192
|
-
|
|
36193
|
-
|
|
36194
|
-
|
|
36195
|
-
|
|
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")
|
|
36196
37131
|
];
|
|
36197
|
-
if (env.CLAUDE_CONFIG_DIR) dirs.push(
|
|
37132
|
+
if (env.CLAUDE_CONFIG_DIR) dirs.push(path26.join(path26.resolve(env.CLAUDE_CONFIG_DIR), "skills"));
|
|
36198
37133
|
return [...new Set(dirs)];
|
|
36199
37134
|
}
|
|
36200
37135
|
async function removeAppSkillsOnce(ctx) {
|
|
@@ -36223,7 +37158,7 @@ async function removeAppSkills(dirs) {
|
|
|
36223
37158
|
return isAbsent(error2);
|
|
36224
37159
|
}
|
|
36225
37160
|
const removed = await Promise.all(
|
|
36226
|
-
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)))
|
|
36227
37162
|
);
|
|
36228
37163
|
return removed.every(Boolean);
|
|
36229
37164
|
})
|
|
@@ -36232,14 +37167,14 @@ async function removeAppSkills(dirs) {
|
|
|
36232
37167
|
}
|
|
36233
37168
|
async function removeIfApps(folder) {
|
|
36234
37169
|
try {
|
|
36235
|
-
await access(
|
|
37170
|
+
await access(path26.join(folder, APP_MARKER));
|
|
36236
37171
|
} catch (error2) {
|
|
36237
37172
|
return isAbsent(error2);
|
|
36238
37173
|
}
|
|
36239
37174
|
try {
|
|
36240
37175
|
if ((await lstat(folder)).isDirectory()) {
|
|
36241
37176
|
const names = (await readdir(folder)).filter((name) => name !== APP_MARKER);
|
|
36242
|
-
await Promise.all(names.map((name) => rm(
|
|
37177
|
+
await Promise.all(names.map((name) => rm(path26.join(folder, name), { recursive: true, force: true })));
|
|
36243
37178
|
}
|
|
36244
37179
|
await rm(folder, { recursive: true, force: true });
|
|
36245
37180
|
return true;
|
|
@@ -36439,18 +37374,45 @@ var init_args = __esm({
|
|
|
36439
37374
|
}
|
|
36440
37375
|
});
|
|
36441
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
|
+
|
|
36442
37404
|
// src/lib/open.js
|
|
36443
37405
|
import { spawn as spawn3 } from "node:child_process";
|
|
36444
37406
|
function openInBrowser(url2, platform2, options = {}) {
|
|
36445
37407
|
const [command, args] = platform2 === "darwin" ? ["open", [url2]] : platform2 === "win32" ? ["cmd", ["/c", "start", '""', url2.replace(/&/g, "^&")]] : ["xdg-open", [url2]];
|
|
36446
|
-
return new Promise((
|
|
37408
|
+
return new Promise((resolve2) => {
|
|
36447
37409
|
let timer;
|
|
36448
37410
|
let settled = false;
|
|
36449
37411
|
const settle = (opened) => {
|
|
36450
37412
|
if (settled) return;
|
|
36451
37413
|
settled = true;
|
|
36452
37414
|
clearTimeout(timer);
|
|
36453
|
-
|
|
37415
|
+
resolve2(opened);
|
|
36454
37416
|
};
|
|
36455
37417
|
try {
|
|
36456
37418
|
const child = spawn3(command, args, {
|
|
@@ -36493,7 +37455,7 @@ var init_posthog = __esm({
|
|
|
36493
37455
|
// src/lib/telemetry.js
|
|
36494
37456
|
import { spawn as spawn4 } from "node:child_process";
|
|
36495
37457
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
36496
|
-
import
|
|
37458
|
+
import os5 from "node:os";
|
|
36497
37459
|
async function guestBefore(ctx) {
|
|
36498
37460
|
if (!ctx.telemetry.keys) return void 0;
|
|
36499
37461
|
try {
|
|
@@ -36542,11 +37504,11 @@ async function postDetached(_ctx, requests) {
|
|
|
36542
37504
|
stdio: ["pipe", "ignore", "ignore"],
|
|
36543
37505
|
windowsHide: true
|
|
36544
37506
|
});
|
|
36545
|
-
await new Promise((
|
|
36546
|
-
child.once("error",
|
|
36547
|
-
child.stdin?.once("error",
|
|
36548
|
-
child.stdin?.end(JSON.stringify(requests), () =>
|
|
36549
|
-
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();
|
|
36550
37512
|
});
|
|
36551
37513
|
child.unref();
|
|
36552
37514
|
}
|
|
@@ -36576,7 +37538,10 @@ function eventsOf(ctx, ran, scope, machine) {
|
|
|
36576
37538
|
ci: Boolean(process.env.CI),
|
|
36577
37539
|
// Whether the CLI took this for an agent in the Codex desktop app (codex-app.js). Its marker is internal to
|
|
36578
37540
|
// Codex, so a drop to none here is how a release that renamed it shows up.
|
|
36579
|
-
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
|
|
36580
37545
|
}
|
|
36581
37546
|
}
|
|
36582
37547
|
];
|
|
@@ -36648,7 +37613,7 @@ function framesOf(stack) {
|
|
|
36648
37613
|
return frames.reverse();
|
|
36649
37614
|
}
|
|
36650
37615
|
function scrub(text) {
|
|
36651
|
-
const home =
|
|
37616
|
+
const home = os5.homedir();
|
|
36652
37617
|
return home.length > 1 ? text.split(home).join("~") : text;
|
|
36653
37618
|
}
|
|
36654
37619
|
var TELEMETRY_KEYS, SEND_MS, CHILD_SEND_MS, MAX_ERRORS, Telemetry, SENDER, FRAME;
|
|
@@ -36692,15 +37657,15 @@ var init_telemetry = __esm({
|
|
|
36692
37657
|
|
|
36693
37658
|
// src/lib/context.js
|
|
36694
37659
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
36695
|
-
import
|
|
36696
|
-
import
|
|
37660
|
+
import os6 from "node:os";
|
|
37661
|
+
import path27 from "node:path";
|
|
36697
37662
|
function createContext(overrides = {}) {
|
|
36698
37663
|
const platform2 = overrides.platform ?? process.platform;
|
|
36699
37664
|
const stdout = overrides.stdout ?? process.stdout;
|
|
36700
37665
|
const ctx = {
|
|
36701
37666
|
stdout,
|
|
36702
37667
|
stderr: process.stderr,
|
|
36703
|
-
home:
|
|
37668
|
+
home: path27.join(os6.homedir(), ".kombai", "cli"),
|
|
36704
37669
|
cwd: process.cwd(),
|
|
36705
37670
|
fetch: globalThis.fetch,
|
|
36706
37671
|
now: Date.now,
|
|
@@ -36721,9 +37686,10 @@ function createContext(overrides = {}) {
|
|
|
36721
37686
|
telemetry: new Telemetry(process.env.DO_NOT_TRACK === "1" ? null : TELEMETRY_KEYS, postDetached),
|
|
36722
37687
|
sandbox: sandboxOf(process.env),
|
|
36723
37688
|
claudeDesktop: process.env.CLAUDE_CODE_ENTRYPOINT === "claude-desktop",
|
|
37689
|
+
claudeSessionStartedAt: () => claudeSessionStartedAt(process.env, platform2, ctx.now),
|
|
36724
37690
|
codexDesktop: inCodexDesktop(process.env),
|
|
36725
37691
|
changeSent: false,
|
|
36726
|
-
appSkillDirs: appSkillDirsOf(
|
|
37692
|
+
appSkillDirs: appSkillDirsOf(os6.homedir(), process.env),
|
|
36727
37693
|
...overrides
|
|
36728
37694
|
};
|
|
36729
37695
|
return ctx;
|
|
@@ -36733,6 +37699,7 @@ var init_context = __esm({
|
|
|
36733
37699
|
"use strict";
|
|
36734
37700
|
init_define_KOMBAI_TELEMETRY();
|
|
36735
37701
|
init_app_skills();
|
|
37702
|
+
init_claude_code();
|
|
36736
37703
|
init_codex_app();
|
|
36737
37704
|
init_deadline();
|
|
36738
37705
|
init_open();
|